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:
@@ -15,7 +15,7 @@ hero:
|
|||||||
icon: right-arrow
|
icon: right-arrow
|
||||||
variant: primary
|
variant: primary
|
||||||
- text: Aller au dernier Challenge
|
- text: Aller au dernier Challenge
|
||||||
link: /challenges/angular/43-signal-input/
|
link: /fr/challenges/angular/43-signal-input/
|
||||||
icon: rocket
|
icon: rocket
|
||||||
- text: Donne une étoile
|
- text: Donne une étoile
|
||||||
link: https://github.com/tomalaforge/angular-challenges
|
link: https://github.com/tomalaforge/angular-challenges
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import MyIcon from '../../components/MyIcon.astro';
|
|||||||
|
|
||||||
<CardGrid>
|
<CardGrid>
|
||||||
<Card title="43 Challenges">
|
<Card title="43 Challenges">
|
||||||
This repository gathers 43 Challenges related to <b>Angular</b>, <b>Nx</b>, <b>RxJS</b>, <b>Ngrx</b> and <b>Typescript</b>.
|
This repository gathers 43 challenges related to <b>Angular</b>, <b>Nx</b>, <b>RxJS</b>, <b>Ngrx</b> and <b>Typescript</b>.
|
||||||
These challenges resolve around real-life issues or specific features to elevate your skills.
|
These challenges resolve around real-life issues or specific features to elevate your skills.
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|||||||
7
libs/cli/src/generators/challenge/files/lang-mapper.ts
Normal file
7
libs/cli/src/generators/challenge/files/lang-mapper.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export const langMapper = {
|
||||||
|
en: 'Challenges',
|
||||||
|
fr: 'Défis',
|
||||||
|
es: 'Desafíos',
|
||||||
|
pt: 'Desafios',
|
||||||
|
ru: 'Испытания',
|
||||||
|
};
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
import { Linter } from '@nx/eslint';
|
import { Linter } from '@nx/eslint';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { getProjectDir } from '../../utils/normalize';
|
import { getProjectDir } from '../../utils/normalize';
|
||||||
|
import { langMapper } from './files/lang-mapper';
|
||||||
import { Schema } from './schema';
|
import { Schema } from './schema';
|
||||||
|
|
||||||
function findPreviousChallengeFilePath(tree, path, number) {
|
function findPreviousChallengeFilePath(tree, path, number) {
|
||||||
@@ -25,8 +26,7 @@ function findPreviousChallengeFilePath(tree, path, number) {
|
|||||||
.find((child) => child.startsWith(`${number}-`));
|
.find((child) => child.startsWith(`${number}-`));
|
||||||
|
|
||||||
if (matchingChild) {
|
if (matchingChild) {
|
||||||
const fullPath = path + '/' + matchingChild;
|
return path + '/' + matchingChild;
|
||||||
return fullPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const child of tree.children(path)) {
|
for (const child of tree.children(path)) {
|
||||||
@@ -49,7 +49,8 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
|
|||||||
|
|
||||||
await applicationGenerator(tree, {
|
await applicationGenerator(tree, {
|
||||||
...options,
|
...options,
|
||||||
directory: `apps/${options.category}`,
|
name: `${options.category}-${options.name}`,
|
||||||
|
directory: `apps/${options.category}/${options.name}`,
|
||||||
style: 'scss',
|
style: 'scss',
|
||||||
routing: false,
|
routing: false,
|
||||||
inlineStyle: true,
|
inlineStyle: true,
|
||||||
@@ -61,14 +62,15 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
|
|||||||
addTailwind: true,
|
addTailwind: true,
|
||||||
standalone: true,
|
standalone: true,
|
||||||
skipTests: true,
|
skipTests: true,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
|
|
||||||
const challengeNumberPath = 'challenge-number.json';
|
const challengeNumberPath = 'challenge-number.json';
|
||||||
const challangeNumberJson = JSON.parse(
|
const challengeNumberJson = JSON.parse(
|
||||||
tree.read(challengeNumberPath).toString(),
|
tree.read(challengeNumberPath).toString(),
|
||||||
);
|
);
|
||||||
const challengeNumber = challangeNumberJson.total + 1;
|
const challengeNumber = challengeNumberJson.total + 1;
|
||||||
const order = challangeNumberJson[difficulty] + 1;
|
const order = challengeNumberJson[difficulty] + 1;
|
||||||
|
|
||||||
generateFiles(tree, join(__dirname, 'files', 'app'), appDirectory, {
|
generateFiles(tree, join(__dirname, 'files', 'app'), appDirectory, {
|
||||||
tmpl: '',
|
tmpl: '',
|
||||||
@@ -116,20 +118,36 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
|
|||||||
|
|
||||||
tree.write('./README.md', readmeReplace);
|
tree.write('./README.md', readmeReplace);
|
||||||
|
|
||||||
const docs = tree.read('./docs/src/content/docs/index.mdx').toString();
|
for (const lang of ['en', 'es', 'fr', 'pt', 'ru']) {
|
||||||
|
const docs = tree
|
||||||
|
.read(`./docs/src/content/docs/${lang === 'en' ? '' : lang}/index.mdx`)
|
||||||
|
.toString();
|
||||||
|
|
||||||
const regex = new RegExp(`${challengeNumber - 1} Challenges`, 'gi');
|
const regex = new RegExp(
|
||||||
const replaced = docs.replace(regex, `${challengeNumber} Challenges`);
|
`${challengeNumber - 1} ${langMapper[lang]}`,
|
||||||
|
'gi',
|
||||||
|
);
|
||||||
|
const replaced = docs.replace(
|
||||||
|
regex,
|
||||||
|
`${challengeNumber} ${langMapper[lang]}`,
|
||||||
|
);
|
||||||
|
|
||||||
const linkRegex = new RegExp(`link: \\/challenges\\/(.*?)\n`, 'gi');
|
const linkRegex = new RegExp(
|
||||||
const replacedLink = replaced.replace(
|
`link: \\/${lang}\\/challenges\\/(.*?)\n`,
|
||||||
linkRegex,
|
'gi',
|
||||||
`link: /challenges/${options.category}/${challengeNumber}-${
|
);
|
||||||
names(options.name).name
|
const replacedLink = replaced.replace(
|
||||||
}/\n`,
|
linkRegex,
|
||||||
);
|
`link: /${lang}/challenges/${options.category}/${challengeNumber}-${
|
||||||
|
names(options.name).name
|
||||||
|
}/\n`,
|
||||||
|
);
|
||||||
|
|
||||||
tree.write('./docs/src/content/docs/index.mdx', replacedLink);
|
tree.write(
|
||||||
|
`./docs/src/content/docs/${lang === 'en' ? '' : lang}/index.mdx`,
|
||||||
|
replacedLink,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const previousChallengeFilePath = findPreviousChallengeFilePath(
|
const previousChallengeFilePath = findPreviousChallengeFilePath(
|
||||||
tree,
|
tree,
|
||||||
|
|||||||
@@ -24,13 +24,16 @@
|
|||||||
"$source": "argv",
|
"$source": "argv",
|
||||||
"index": 1
|
"index": 1
|
||||||
},
|
},
|
||||||
"x-priority": "important"
|
"x-priority": "important",
|
||||||
|
"x-prompt": "What should be the title of your challenge?",
|
||||||
|
"pattern": "^[a-zA-Z].*$"
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"description": "Your full name",
|
"description": "Your full name",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"maxLength": "25",
|
"maxLength": "25",
|
||||||
"x-priority": "important"
|
"x-priority": "important",
|
||||||
|
"x-prompt": "Author?"
|
||||||
},
|
},
|
||||||
"challengeDifficulty": {
|
"challengeDifficulty": {
|
||||||
"description": "The difficulty of the challenge.",
|
"description": "The difficulty of the challenge.",
|
||||||
|
|||||||
Reference in New Issue
Block a user