feat(tools/scripts): test project create tool (#55247)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Anna
2024-06-21 11:47:36 -04:00
committed by GitHub
parent 2847c7c77a
commit cd636a143a
3 changed files with 41 additions and 13 deletions

View File

@@ -6,7 +6,7 @@ import { format } from 'prettier';
import ObjectID from 'bson-objectid';
import { SuperBlocks } from '../../shared/config/superblocks';
import { createStepFile } from './utils';
import { createStepFile, validateBlockName } from './utils';
import { getSuperBlockSubPath } from './fs-utils';
import { Meta } from './helpers/project-metadata';
@@ -198,17 +198,9 @@ void prompt([
{
name: 'block',
message: 'What is the dashed name (in kebab-case) for this project?',
validate: (block: string) => {
if (!block.length) {
return 'please enter a dashed name';
}
if (/[^a-z0-9-]/.test(block)) {
return 'please use alphanumerical characters and kebab case';
}
return true;
},
validate: validateBlockName,
filter: (block: string) => {
return block.toLowerCase();
return block.toLowerCase().trim();
}
},
{