fix: generator

This commit is contained in:
thomas
2024-05-11 21:41:13 +02:00
parent 001d35731a
commit 4eb6f64f16
46 changed files with 63 additions and 72 deletions

View File

@@ -5,7 +5,7 @@
### Run Application
```bash
npx nx serve nx-static-dynamic-import
npx nx serve nx-static-vs-dynamic-import
```
### Documentation and Instruction

View File

@@ -1,27 +1,27 @@
{
"name": "nx-static-dynamic-import",
"name": "nx-static-vs-dynamic-import",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"prefix": "app",
"sourceRoot": "apps/nx/static-dynamic-import/src",
"sourceRoot": "apps/nx/42-static-vs-dynamic-import/src",
"tags": [],
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:application",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/nx/static-dynamic-import",
"index": "apps/nx/static-dynamic-import/src/index.html",
"browser": "apps/nx/static-dynamic-import/src/main.ts",
"outputPath": "dist/apps/nx/42-static-vs-dynamic-import",
"index": "apps/nx/42-static-vs-dynamic-import/src/index.html",
"browser": "apps/nx/42-static-vs-dynamic-import/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "apps/nx/static-dynamic-import/tsconfig.app.json",
"tsConfig": "apps/nx/42-static-vs-dynamic-import/tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"apps/nx/static-dynamic-import/src/favicon.ico",
"apps/nx/static-dynamic-import/src/assets"
"apps/nx/42-static-vs-dynamic-import/src/favicon.ico",
"apps/nx/42-static-vs-dynamic-import/src/assets"
],
"styles": [
"apps/nx/static-dynamic-import/src/styles.scss",
"apps/nx/42-static-vs-dynamic-import/src/styles.scss",
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css"
],
"scripts": []
@@ -55,10 +55,10 @@
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "nx-static-dynamic-import:build:production"
"buildTarget": "nx-static-vs-dynamic-import:build:production"
},
"development": {
"buildTarget": "nx-static-dynamic-import:build:development"
"buildTarget": "nx-static-vs-dynamic-import:build:development"
}
},
"defaultConfiguration": "development"
@@ -66,7 +66,7 @@
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "nx-static-dynamic-import:build"
"buildTarget": "nx-static-vs-dynamic-import:build"
}
},
"lint": {

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -5,9 +5,9 @@
### Run Application
```bash
npx nx serve typescript-overload`
npx nx serve typescript-function-overload`
```
### Documentation and Instruction
Challenge documentation is [here](https://angular-challenges.vercel.app/challenges/typescript/15-typescript-overload-fn/).
Challenge documentation is [here](https://angular-challenges.vercel.app/challenges/typescript/15-typescript-function-overload-fn/).

View File

@@ -1,25 +1,25 @@
{
"name": "typescript-overload",
"name": "typescript-function-overload",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/typescript/overload/src",
"sourceRoot": "apps/typescript/15-function-overload/src",
"prefix": "app",
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/typescript/overload",
"index": "apps/typescript/overload/src/index.html",
"main": "apps/typescript/overload/src/main.ts",
"outputPath": "dist/apps/typescript/15-function-overload",
"index": "apps/typescript/15-function-overload/src/index.html",
"main": "apps/typescript/15-function-overload/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "apps/typescript/overload/tsconfig.app.json",
"tsConfig": "apps/typescript/15-function-overload/tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"apps/typescript/overload/src/favicon.ico",
"apps/typescript/overload/src/assets"
"apps/typescript/15-function-overload/src/favicon.ico",
"apps/typescript/15-function-overload/src/assets"
],
"styles": ["apps/typescript/overload/src/styles.scss"],
"styles": ["apps/typescript/15-function-overload/src/styles.scss"],
"scripts": []
},
"configurations": {
@@ -53,10 +53,10 @@
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "typescript-overload:build:production"
"buildTarget": "typescript-function-overload:build:production"
},
"development": {
"buildTarget": "typescript-overload:build:development"
"buildTarget": "typescript-function-overload:build:development"
}
},
"defaultConfiguration": "development"
@@ -64,7 +64,7 @@
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "typescript-overload:build"
"buildTarget": "typescript-function-overload:build"
}
},
"lint": {

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -3,24 +3,24 @@
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"prefix": "app",
"sourceRoot": "apps/typescript/enums-vs-union-types/src",
"sourceRoot": "apps/typescript/47-enums-vs-union-types/src",
"tags": [],
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:application",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/typescript/enums-vs-union-types",
"index": "apps/typescript/enums-vs-union-types/src/index.html",
"browser": "apps/typescript/enums-vs-union-types/src/main.ts",
"outputPath": "dist/apps/typescript/47-enums-vs-union-types",
"index": "apps/typescript/47-enums-vs-union-types/src/index.html",
"browser": "apps/typescript/47-enums-vs-union-types/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "apps/typescript/enums-vs-union-types/tsconfig.app.json",
"tsConfig": "apps/typescript/47-enums-vs-union-types/tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"apps/typescript/enums-vs-union-types/src/favicon.ico",
"apps/typescript/enums-vs-union-types/src/assets"
"apps/typescript/47-enums-vs-union-types/src/favicon.ico",
"apps/typescript/47-enums-vs-union-types/src/assets"
],
"styles": ["apps/typescript/enums-vs-union-types/src/styles.scss"],
"styles": ["apps/typescript/47-enums-vs-union-types/src/styles.scss"],
"scripts": []
},
"configurations": {

View File

@@ -41,7 +41,7 @@ enum Direction {
`,
styles: `
section {
@apply flex flex-col mx-auto my-5 w-fit gap-2 items-center;
@apply mx-auto my-5 flex w-fit flex-col items-center gap-2;
> div {
@apply flex w-fit gap-5;

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -8,23 +8,23 @@
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json",
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.editor.json",
},
"path": "./tsconfig.editor.json"
}
],
"extends": "../../../tsconfig.base.json",
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true,
},
"strictTemplates": true
}
}

View File

@@ -5,7 +5,7 @@ author: thomas-laforge
contributors:
- tomalaforge
challengeNumber: 42
command: nx-static-dynamic-import
command: nx-static-vs-dynamic-import
sidebar:
order: 15
---

View File

@@ -5,7 +5,7 @@ author: thomas-laforge
contributors:
- tomalaforge
challengeNumber: 15
command: typescript-overload
command: typescript-function-overload
blogLink: https://medium.com/ngconf/function-overloading-in-typescript-8236706b2c05
sidebar:
order: 115

View File

@@ -40,17 +40,26 @@ function findPreviousChallengeFilePath(tree, path, number) {
}
export async function challengeGenerator(tree: Tree, options: Schema) {
const challengeNumberPath = 'challenge-number.json';
const challengeNumberJson = JSON.parse(
tree.read(challengeNumberPath).toString(),
);
const challengeNumber = challengeNumberJson.total + 1;
const difficulty = options.challengeDifficulty;
const name = options.title.toLowerCase().split(' ').join('-');
const order = challengeNumberJson[difficulty] + 1;
const { appProjectName, appDirectory } = getProjectDir(
options.name,
name,
`apps/${options.category}`,
);
const difficulty = options.challengeDifficulty;
await applicationGenerator(tree, {
...options,
name: `${options.category}-${options.name}`,
directory: `apps/${options.category}/${options.name}`,
name: `${options.category}-${name}`,
directory: `apps/${options.category}/${challengeNumber}-${name}`,
style: 'scss',
routing: false,
inlineStyle: true,
@@ -65,13 +74,6 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
projectNameAndRootFormat: 'as-provided',
});
const challengeNumberPath = 'challenge-number.json';
const challengeNumberJson = JSON.parse(
tree.read(challengeNumberPath).toString(),
);
const challengeNumber = challengeNumberJson.total + 1;
const order = challengeNumberJson[difficulty] + 1;
generateFiles(tree, join(__dirname, 'files', 'app'), appDirectory, {
tmpl: '',
});
@@ -79,7 +81,7 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
generateFiles(tree, join(__dirname, 'files', 'readme'), appDirectory, {
tmpl: '',
projectName: names(options.name).name,
projectName: names(name).name,
appProjectName,
title: options.title,
challengeNumber,
@@ -92,7 +94,7 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
`./docs/src/content/docs/challenges/${options.category}`,
{
tmpl: '',
projectName: names(options.name).name,
projectName: names(name).name,
appProjectName,
author: options.author,
title: options.title,
@@ -141,7 +143,7 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
const replacedLink = replaced.replace(
linkRegex,
`link: /${lang}/challenges/${options.category}/${challengeNumber}-${
names(options.name).name
names(name).name
}/\n`,
);

View File

@@ -3,7 +3,6 @@ export interface Schema {
author: string;
challengeDifficulty: string;
category: string;
name: string;
addTest?: boolean;
skipPackageJson?: boolean;
rootProject?: boolean;

View File

@@ -6,16 +6,6 @@
"type": "object",
"cli": "nx",
"properties": {
"name": {
"description": "The name of the application. (should be in kebab case)",
"type": "string",
"$default": {
"$source": "argv",
"index": 0
},
"x-prompt": "What name would you like to use for the application?",
"pattern": "^[a-zA-Z].*$"
},
"title": {
"description": "Title of your challenge.",
"type": "string",