mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-19 18:18:27 -05:00
fix(tools): prevent create-new-x overwriting old projects (#62621)
This commit is contained in:
committed by
GitHub
parent
f5361f4341
commit
6fc3684049
@@ -10,7 +10,7 @@ import {
|
||||
writeBlockStructure
|
||||
} from '../../curriculum/file-handler';
|
||||
import { superBlockToFilename } from '../../curriculum/build-curriculum';
|
||||
import { createQuizFile, validateBlockName } from './utils';
|
||||
import { createQuizFile, getAllBlocks, validateBlockName } from './utils';
|
||||
import { getBaseMeta } from './helpers/get-base-meta';
|
||||
import { createIntroMD } from './helpers/create-intro';
|
||||
import { updateSimpleSuperblockStructure } from './helpers/create-project';
|
||||
@@ -145,41 +145,44 @@ function withTrace<Args extends unknown[], Result>(
|
||||
});
|
||||
}
|
||||
|
||||
void prompt([
|
||||
{
|
||||
name: 'superBlock',
|
||||
message: 'Which certification does this belong to?',
|
||||
default: SuperBlocks.FullStackDeveloper,
|
||||
type: 'list',
|
||||
choices: Object.values(SuperBlocks)
|
||||
},
|
||||
{
|
||||
name: 'block',
|
||||
message: 'What is the dashed name (in kebab-case) for this quiz?',
|
||||
validate: validateBlockName,
|
||||
filter: (block: string) => {
|
||||
return block.toLowerCase().trim();
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'title',
|
||||
default: ({ block }: { block: string }) => block
|
||||
},
|
||||
{
|
||||
name: 'helpCategory',
|
||||
message: 'Choose a help category',
|
||||
default: 'HTML-CSS',
|
||||
type: 'list',
|
||||
choices: helpCategories
|
||||
},
|
||||
{
|
||||
name: 'questionCount',
|
||||
message: 'Should this quiz have either ten or twenty questions?',
|
||||
default: 20,
|
||||
type: 'list',
|
||||
choices: [20, 10]
|
||||
}
|
||||
])
|
||||
void getAllBlocks()
|
||||
.then(existingBlocks =>
|
||||
prompt([
|
||||
{
|
||||
name: 'superBlock',
|
||||
message: 'Which certification does this belong to?',
|
||||
default: SuperBlocks.FullStackDeveloper,
|
||||
type: 'list',
|
||||
choices: Object.values(SuperBlocks)
|
||||
},
|
||||
{
|
||||
name: 'block',
|
||||
message: 'What is the dashed name (in kebab-case) for this quiz?',
|
||||
validate: (block: string) => validateBlockName(block, existingBlocks),
|
||||
filter: (block: string) => {
|
||||
return block.toLowerCase().trim();
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'title',
|
||||
default: ({ block }: { block: string }) => block
|
||||
},
|
||||
{
|
||||
name: 'helpCategory',
|
||||
message: 'Choose a help category',
|
||||
default: 'HTML-CSS',
|
||||
type: 'list',
|
||||
choices: helpCategories
|
||||
},
|
||||
{
|
||||
name: 'questionCount',
|
||||
message: 'Should this quiz have either ten or twenty questions?',
|
||||
default: 20,
|
||||
type: 'list',
|
||||
choices: [20, 10]
|
||||
}
|
||||
])
|
||||
)
|
||||
.then(
|
||||
async ({
|
||||
superBlock,
|
||||
|
||||
Reference in New Issue
Block a user