mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 12:53:03 -05:00
feat(generator): add challenge number automatically
This commit is contained in:
3
challenge-number.json
Normal file
3
challenge-number.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"total": 35
|
||||||
|
}
|
||||||
@@ -3,7 +3,14 @@ import {
|
|||||||
E2eTestRunner,
|
E2eTestRunner,
|
||||||
UnitTestRunner,
|
UnitTestRunner,
|
||||||
} from '@nx/angular/generators';
|
} 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 { Linter } from '@nx/linter';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { getProjectDir } from '../../utils/normalize';
|
import { getProjectDir } from '../../utils/normalize';
|
||||||
@@ -12,6 +19,9 @@ import { Schema } from './schema';
|
|||||||
export async function appGenerator(tree: Tree, options: Schema) {
|
export async function appGenerator(tree: Tree, options: Schema) {
|
||||||
const { appDirectory } = getProjectDir(options.name, options.directory);
|
const { appDirectory } = getProjectDir(options.name, options.directory);
|
||||||
|
|
||||||
|
const challengeNumberPath = 'challenge-number.json';
|
||||||
|
const challengeNumber = readJsonFile(challengeNumberPath).total;
|
||||||
|
|
||||||
await applicationGenerator(tree, {
|
await applicationGenerator(tree, {
|
||||||
...options,
|
...options,
|
||||||
style: 'scss',
|
style: 'scss',
|
||||||
@@ -36,7 +46,7 @@ export async function appGenerator(tree: Tree, options: Schema) {
|
|||||||
tmpl: '',
|
tmpl: '',
|
||||||
projectName: names(options.name).name,
|
projectName: names(options.name).name,
|
||||||
title: options.title,
|
title: options.title,
|
||||||
challengeNumber: options.challengeNumber,
|
challengeNumber,
|
||||||
docRepository: options.docRepository,
|
docRepository: options.docRepository,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -48,7 +58,7 @@ export async function appGenerator(tree: Tree, options: Schema) {
|
|||||||
tmpl: '',
|
tmpl: '',
|
||||||
projectName: names(options.name).name,
|
projectName: names(options.name).name,
|
||||||
title: options.title,
|
title: options.title,
|
||||||
challengeNumber: options.challengeNumber,
|
challengeNumber,
|
||||||
difficulty: options.challengeDifficulty,
|
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);
|
await formatFiles(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
libs/cli/src/generators/app/schema.d.ts
vendored
1
libs/cli/src/generators/app/schema.d.ts
vendored
@@ -1,6 +1,5 @@
|
|||||||
export interface Schema {
|
export interface Schema {
|
||||||
title: string;
|
title: string;
|
||||||
challengeNumber: number;
|
|
||||||
challengeDifficulty: string;
|
challengeDifficulty: string;
|
||||||
docRepository: string;
|
docRepository: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@@ -25,15 +25,6 @@
|
|||||||
},
|
},
|
||||||
"x-priority": "important"
|
"x-priority": "important"
|
||||||
},
|
},
|
||||||
"challengeNumber": {
|
|
||||||
"description": "The number of your challenge.",
|
|
||||||
"type": "number",
|
|
||||||
"$default": {
|
|
||||||
"$source": "argv",
|
|
||||||
"index": 2
|
|
||||||
},
|
|
||||||
"x-priority": "important"
|
|
||||||
},
|
|
||||||
"challengeDifficulty": {
|
"challengeDifficulty": {
|
||||||
"description": "The difficulty of the challenge.",
|
"description": "The difficulty of the challenge.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
Reference in New Issue
Block a user