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