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

View File

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

View File

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