fix(generator): fix generator

This commit is contained in:
thomas
2023-10-18 11:01:17 +02:00
parent f72782ee4c
commit b945521dbf
4 changed files with 9 additions and 21 deletions

View File

@@ -10,4 +10,4 @@ npx nx serve <%= appProjectName %>
### Documentation and Instruction ### Documentation and Instruction
Challenge documentation is [here](https://angular-challenges.vercel.app/challenges/<%= docRepository %>/<%= challengeNumber %>-<%= projectName %>/). Challenge documentation is [here](https://angular-challenges.vercel.app/challenges/<%= category %>/<%= challengeNumber %>-<%= projectName %>/).

View File

@@ -43,12 +43,11 @@ function findPreviousChallengeFilePath(tree, path, number) {
export async function challengeGenerator(tree: Tree, options: Schema) { export async function challengeGenerator(tree: Tree, options: Schema) {
const { appProjectName, appDirectory } = getProjectDir( const { appProjectName, appDirectory } = getProjectDir(
options.name, options.name,
options.directory `apps/${options.category}`
); );
const difficulty = options.challengeDifficulty; const difficulty = options.challengeDifficulty;
// read json file with the total challanges and display order
const challengeNumberPath = 'challenge-number.json'; const challengeNumberPath = 'challenge-number.json';
const challangeNumberJson = readJsonFile(challengeNumberPath); const challangeNumberJson = readJsonFile(challengeNumberPath);
const challengeNumber = challangeNumberJson.total + 1; const challengeNumber = challangeNumberJson.total + 1;
@@ -56,6 +55,7 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
await applicationGenerator(tree, { await applicationGenerator(tree, {
...options, ...options,
directory: `apps/${options.category}`,
style: 'scss', style: 'scss',
routing: false, routing: false,
inlineStyle: true, inlineStyle: true,
@@ -80,13 +80,13 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
appProjectName, appProjectName,
title: options.title, title: options.title,
challengeNumber, challengeNumber,
docRepository: options.docRepository, category: options.category,
}); });
generateFiles( generateFiles(
tree, tree,
join(__dirname, 'files', 'docs'), join(__dirname, 'files', 'docs'),
`./docs/src/content/docs/challenges/${options.docRepository}`, `./docs/src/content/docs/challenges/${options.category}`,
{ {
tmpl: '', tmpl: '',
projectName: names(options.name).name, projectName: names(options.name).name,
@@ -123,7 +123,7 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
const linkRegex = new RegExp(`link: \\/challenges\\/(.*?)\n`, 'gi'); const linkRegex = new RegExp(`link: \\/challenges\\/(.*?)\n`, 'gi');
const replacedLink = replaced.replace( const replacedLink = replaced.replace(
linkRegex, linkRegex,
`link: /challenges/${options.docRepository}/${challengeNumber}-${ `link: /challenges/${options.category}/${challengeNumber}-${
names(options.name).name names(options.name).name
}/\n` }/\n`
); );

View File

@@ -2,9 +2,8 @@ export interface Schema {
title: string; title: string;
author: string; author: string;
challengeDifficulty: string; challengeDifficulty: string;
docRepository: string; category: string;
name: string; name: string;
directory?: string;
addTest?: boolean; addTest?: boolean;
skipPackageJson?: boolean; skipPackageJson?: boolean;
rootProject?: boolean; rootProject?: boolean;

View File

@@ -55,7 +55,7 @@
] ]
} }
}, },
"docRepository": { "category": {
"type": "string", "type": "string",
"description": "The category of your challenge.", "description": "The category of your challenge.",
"x-priority": "important", "x-priority": "important",
@@ -94,11 +94,6 @@
] ]
} }
}, },
"directory": {
"description": "The directory of the new application.",
"type": "string",
"x-priority": "important"
},
"addTest": { "addTest": {
"description": "add spec files.", "description": "add spec files.",
"type": "boolean", "type": "boolean",
@@ -120,11 +115,5 @@
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": ["name", "title", "author", "challengeDifficulty", "category"]
"name",
"title",
"author",
"challengeDifficulty",
"docRepository"
]
} }