Skip to content

Commit

Permalink
feat: update create challenge and challenge generator
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalaforge committed May 27, 2024
1 parent c8ba057 commit 9bef9db
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
14 changes: 10 additions & 4 deletions docs/src/content/docs/guides/create-challenge.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
:::

- <b>challengeDifficulty</b>: The difficulty you think your challenge has. There are three difficulty levels : 🟢 easy / 🟠 medium / 🔴 hard
- <b>name</b>: name of the Nx application.
- <b>author</b>: 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.
:::
- <b>docRepository</b>: The category of your Challenge is Nx, Angular, Angular Performance, Rxjs, NgRx, Typescript, or Forms.

- <b>challengeDifficulty</b>: The difficulty you think your challenge has. There are three difficulty levels : 🟢 easy / 🟠 medium / 🔴 hard

- <b>docRepository</b>: The category of your Challenge is Nx, Angular, Angular Performance, Rxjs, NgRx, Typescript, Forms or Signals.

#### optional parameters

- <b>challengeNumber</b>: You can specify a challenge number if a challenge is being submitted. (If empty, the number will be the next one).
- <b>directory</b>: If you want your application to be located in a specific folder inside `apps`.
- <b>addTest</b>: If you want to add test configuration.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "<%= authorName %>"
}
15 changes: 15 additions & 0 deletions libs/cli/src/generators/challenge/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit 9bef9db

Please sign in to comment.