mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 04:43:03 -05:00
fix: generator
This commit is contained in:
@@ -6,7 +6,6 @@ import {
|
||||
import { formatFiles, generateFiles, Tree, updateJson } from '@nx/devkit';
|
||||
import { Linter } from '@nx/eslint';
|
||||
import { join } from 'path';
|
||||
import { getProjectDir } from '../../utils/normalize';
|
||||
import { langMapper } from './files/lang-mapper';
|
||||
import { Schema } from './schema';
|
||||
|
||||
@@ -40,21 +39,20 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
|
||||
);
|
||||
const challengeNumber =
|
||||
options.challengeNumber ?? challengeNumberJson.total + 1;
|
||||
|
||||
const difficulty = options.challengeDifficulty;
|
||||
|
||||
const name = options.title.toLowerCase().split(' ').join('-');
|
||||
|
||||
const order = challengeNumberJson[difficulty] + 1;
|
||||
|
||||
const { appProjectName, appDirectory } = getProjectDir(
|
||||
name,
|
||||
`apps/${options.category}`,
|
||||
);
|
||||
const appProjectName = `${options.category}-${name}`;
|
||||
const appDirectory = `apps/${options.category}/${challengeNumber}-${name}`;
|
||||
|
||||
await applicationGenerator(tree, {
|
||||
...options,
|
||||
name: `${options.category}-${name}`,
|
||||
directory: `apps/${options.category}/${challengeNumber}-${name}`,
|
||||
directory: appDirectory,
|
||||
style: 'scss',
|
||||
routing: false,
|
||||
inlineStyle: true,
|
||||
@@ -146,18 +144,20 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
|
||||
);
|
||||
}
|
||||
|
||||
const previousChallengeFilePath = findPreviousChallengeFilePath(
|
||||
tree,
|
||||
`./docs/src/content/docs/challenges`,
|
||||
String(challengeNumber - 1),
|
||||
);
|
||||
if (!options.challengeNumber) {
|
||||
const previousChallengeFilePath = findPreviousChallengeFilePath(
|
||||
tree,
|
||||
`./docs/src/content/docs/challenges`,
|
||||
String(Number(challengeNumber) - 1),
|
||||
);
|
||||
|
||||
const previousChallenge = tree.read(previousChallengeFilePath).toString();
|
||||
const previousChallenge = tree.read(previousChallengeFilePath).toString();
|
||||
|
||||
tree.write(
|
||||
previousChallengeFilePath,
|
||||
previousChallenge.replace(`badge: New`, ``),
|
||||
);
|
||||
tree.write(
|
||||
previousChallengeFilePath,
|
||||
previousChallenge.replace(`badge: New`, ``),
|
||||
);
|
||||
}
|
||||
|
||||
updateJson(tree, challengeNumberPath, (json) => {
|
||||
json.total += 1;
|
||||
|
||||
Reference in New Issue
Block a user