diff --git a/challenge-number.json b/challenge-number.json new file mode 100644 index 000000000..4fc2198af --- /dev/null +++ b/challenge-number.json @@ -0,0 +1,3 @@ +{ + "total": 35 +} diff --git a/libs/cli/src/generators/app/generator.ts b/libs/cli/src/generators/app/generator.ts index 0355e5bc4..90b2b7c94 100644 --- a/libs/cli/src/generators/app/generator.ts +++ b/libs/cli/src/generators/app/generator.ts @@ -3,7 +3,14 @@ import { E2eTestRunner, UnitTestRunner, } from '@nx/angular/generators'; -import { formatFiles, generateFiles, names, Tree } from '@nx/devkit'; +import { + formatFiles, + generateFiles, + names, + readJsonFile, + Tree, + updateJson, +} from '@nx/devkit'; import { Linter } from '@nx/linter'; import { join } from 'path'; import { getProjectDir } from '../../utils/normalize'; @@ -12,6 +19,9 @@ import { Schema } from './schema'; export async function appGenerator(tree: Tree, options: Schema) { const { appDirectory } = getProjectDir(options.name, options.directory); + const challengeNumberPath = 'challenge-number.json'; + const challengeNumber = readJsonFile(challengeNumberPath).total; + await applicationGenerator(tree, { ...options, style: 'scss', @@ -36,7 +46,7 @@ export async function appGenerator(tree: Tree, options: Schema) { tmpl: '', projectName: names(options.name).name, title: options.title, - challengeNumber: options.challengeNumber, + challengeNumber, docRepository: options.docRepository, }); @@ -48,7 +58,7 @@ export async function appGenerator(tree: Tree, options: Schema) { tmpl: '', projectName: names(options.name).name, title: options.title, - challengeNumber: options.challengeNumber, + challengeNumber, difficulty: options.challengeDifficulty, } ); @@ -59,6 +69,11 @@ export async function appGenerator(tree: Tree, options: Schema) { }); } + updateJson(tree, challengeNumberPath, (json) => { + json.total = json.total + 1; + return json; + }); + await formatFiles(tree); } diff --git a/libs/cli/src/generators/app/schema.d.ts b/libs/cli/src/generators/app/schema.d.ts index 12df13783..a352d7f57 100644 --- a/libs/cli/src/generators/app/schema.d.ts +++ b/libs/cli/src/generators/app/schema.d.ts @@ -1,6 +1,5 @@ export interface Schema { title: string; - challengeNumber: number; challengeDifficulty: string; docRepository: string; name: string; diff --git a/libs/cli/src/generators/app/schema.json b/libs/cli/src/generators/app/schema.json index 9340ee48a..dce563c23 100644 --- a/libs/cli/src/generators/app/schema.json +++ b/libs/cli/src/generators/app/schema.json @@ -25,15 +25,6 @@ }, "x-priority": "important" }, - "challengeNumber": { - "description": "The number of your challenge.", - "type": "number", - "$default": { - "$source": "argv", - "index": 2 - }, - "x-priority": "important" - }, "challengeDifficulty": { "description": "The difficulty of the challenge.", "type": "string",