feat(generator): update generator

This commit is contained in:
thomas
2023-09-22 22:12:15 +02:00
parent e6c6e4d351
commit 7d36bf6635
4 changed files with 38 additions and 4 deletions

View File

@@ -23,7 +23,7 @@ If you would like to propose a challenge, this project is open source, so feel f
## Challenges ## Challenges
Check [all challenges](https://angular-challenges.vercel.app/) Check [all 35 challenges](https://angular-challenges.vercel.app/)
## Challenges (previous version) ## Challenges (previous version)

View File

@@ -19,8 +19,8 @@ hero:
import { Card, CardGrid } from '@astrojs/starlight/components'; import { Card, CardGrid } from '@astrojs/starlight/components';
<CardGrid> <CardGrid>
<Card title="More than 30 Challenges"> <Card title="35 Challenges">
This repository gathers over 30 challenges related to <b>Angular</b>, <b>Nx</b>, <b>Ngrx</b>, <b>RxJS</b>, and <b>Ngrx</b>. This repository gathers 35 Challenges related to <b>Angular</b>, <b>Nx</b>, <b>Ngrx</b>, <b>RxJS</b>, and <b>Ngrx</b>.
These challenges revolve around real-life issues or specific features to elevate your skills. These challenges revolve around real-life issues or specific features to elevate your skills.
</Card> </Card>

View File

@@ -12,6 +12,7 @@ import {
updateJson, updateJson,
} from '@nx/devkit'; } from '@nx/devkit';
import { Linter } from '@nx/linter'; import { Linter } from '@nx/linter';
import { readFile, writeFile } from 'fs';
import { join } from 'path'; import { join } from 'path';
import { getProjectDir } from '../../utils/normalize'; import { getProjectDir } from '../../utils/normalize';
import { Schema } from './schema'; import { Schema } from './schema';
@@ -69,6 +70,39 @@ export async function appGenerator(tree: Tree, options: Schema) {
}); });
} }
readFile('./README.md', 'utf-8', function (err, contents) {
const regex = new RegExp(`all ${challengeNumber} challenges`);
const replaced = contents.replace(
regex,
`all ${challengeNumber + 1} challenges`
);
writeFile('./README.md', replaced, 'utf-8', function (err) {
console.log(err);
});
});
readFile(
'./docs/src/content/docs/index.mdx',
'utf-8',
function (err, contents) {
const regex = new RegExp(`${challengeNumber} Challenges`, 'gi');
const replaced = contents.replace(
regex,
`${challengeNumber + 1} Challenges`
);
writeFile(
'./docs/src/content/docs/index.mdx',
replaced,
'utf-8',
function (err) {
console.log(err);
}
);
}
);
updateJson(tree, challengeNumberPath, (json) => { updateJson(tree, challengeNumberPath, (json) => {
json.total = json.total + 1; json.total = json.total + 1;
return json; return json;

View File

@@ -113,5 +113,5 @@
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"required": ["name", "title", "challengeNumber"] "required": ["name", "title", "challengeDifficulty", "docRepository"]
} }