feat: add challenge number to generator

This commit is contained in:
thomas
2024-05-13 16:17:09 +02:00
parent b610c8c614
commit fbb9e3eccf
3 changed files with 7 additions and 1 deletions

View File

@@ -38,7 +38,8 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
const challengeNumberJson = JSON.parse( const challengeNumberJson = JSON.parse(
tree.read(challengeNumberPath).toString(), tree.read(challengeNumberPath).toString(),
); );
const challengeNumber = challengeNumberJson.total + 1; const challengeNumber =
options.challengeNumber ?? challengeNumberJson.total + 1;
const difficulty = options.challengeDifficulty; const difficulty = options.challengeDifficulty;
const name = options.title.toLowerCase().split(' ').join('-'); const name = options.title.toLowerCase().split(' ').join('-');

View File

@@ -6,4 +6,5 @@ export interface Schema {
addTest?: boolean; addTest?: boolean;
skipPackageJson?: boolean; skipPackageJson?: boolean;
rootProject?: boolean; rootProject?: boolean;
challengeNumber?: number;
} }

View File

@@ -95,6 +95,10 @@
] ]
} }
}, },
"challengeNumber": {
"description": "Specify a challenge number (If you don't, the challenge number will be set automatically)",
"type": "number"
},
"addTest": { "addTest": {
"description": "add spec files.", "description": "add spec files.",
"type": "boolean", "type": "boolean",