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

@@ -12,6 +12,7 @@ import {
updateJson,
} from '@nx/devkit';
import { Linter } from '@nx/linter';
import { readFile, writeFile } from 'fs';
import { join } from 'path';
import { getProjectDir } from '../../utils/normalize';
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) => {
json.total = json.total + 1;
return json;

View File

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