From 9bef9dbd9081a2f1e441940e2d96173f3cf24cc7 Mon Sep 17 00:00:00 2001 From: thomas Date: Mon, 27 May 2024 21:38:48 +0200 Subject: [PATCH] feat: update create challenge and challenge generator --- docs/src/content/docs/guides/create-challenge.md | 14 ++++++++++---- .../files/author/__authorName__.json__tmpl__ | 3 +++ libs/cli/src/generators/challenge/generator.ts | 15 +++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 libs/cli/src/generators/challenge/files/author/__authorName__.json__tmpl__ diff --git a/docs/src/content/docs/guides/create-challenge.md b/docs/src/content/docs/guides/create-challenge.md index 6c70786a4..4b01d6bb8 100644 --- a/docs/src/content/docs/guides/create-challenge.md +++ b/docs/src/content/docs/guides/create-challenge.md @@ -28,15 +28,21 @@ Alternatively, you may utilize your IDE's [Nx Console extension](https://nx.dev/ The title must be a maximum of 25 characters. ::: -- challengeDifficulty: The difficulty you think your challenge has. There are three difficulty levels : 🟢 easy / 🟠 medium / 🔴 hard -- name: name of the Nx application. +- author: Your name + :::note + Your name should be in kebab-case. (e.g. john-doe) + ::: :::note - It must be written in **kebab-case**. + Don't forget to update your personal information inside the file at your name. ::: -- docRepository: The category of your Challenge is Nx, Angular, Angular Performance, Rxjs, NgRx, Typescript, or Forms. + +- challengeDifficulty: The difficulty you think your challenge has. There are three difficulty levels : 🟢 easy / 🟠 medium / 🔴 hard + +- docRepository: The category of your Challenge is Nx, Angular, Angular Performance, Rxjs, NgRx, Typescript, Forms or Signals. #### optional parameters +- challengeNumber: You can specify a challenge number if a challenge is being submitted. (If empty, the number will be the next one). - directory: If you want your application to be located in a specific folder inside `apps`. - addTest: If you want to add test configuration. diff --git a/libs/cli/src/generators/challenge/files/author/__authorName__.json__tmpl__ b/libs/cli/src/generators/challenge/files/author/__authorName__.json__tmpl__ new file mode 100644 index 000000000..fa1f27116 --- /dev/null +++ b/libs/cli/src/generators/challenge/files/author/__authorName__.json__tmpl__ @@ -0,0 +1,3 @@ +{ + "name": "<%= authorName %>" +} diff --git a/libs/cli/src/generators/challenge/generator.ts b/libs/cli/src/generators/challenge/generator.ts index bfebaaa8f..12ed70bdd 100644 --- a/libs/cli/src/generators/challenge/generator.ts +++ b/libs/cli/src/generators/challenge/generator.ts @@ -81,6 +81,21 @@ export async function challengeGenerator(tree: Tree, options: Schema) { category: options.category, }); + const authorFile = tree.read( + `./docs/src/content/authors/${options.author}.json`, + ); + if (!authorFile) { + generateFiles( + tree, + join(__dirname, 'files', 'author'), + `./docs/src/content/authors/`, + { + tmpl: '', + authorName: options.author, + }, + ); + } + generateFiles( tree, join(__dirname, 'files', 'docs'),