Skip to content

Commit 89b76dd

Browse files
committed
feat: update schematics
1 parent 694283a commit 89b76dd

File tree

11 files changed

+125
-4
lines changed

11 files changed

+125
-4
lines changed

apps/azlmqhys/public/favicon.ico

-14.7 KB
Binary file not shown.

apps/azlmqhys/public/favicon.svg

Lines changed: 17 additions & 0 deletions
Loading

apps/azlmqhys/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<title>azlmqhys</title>
66
<base href="/" />
77
<meta name="viewport" content="width=device-width, initial-scale=1" />
8-
<link rel="icon" type="image/x-icon" href="favicon.ico" />
8+
<link rel="icon" type="image/x-icon" href="favicon.svg" />
99
</head>
1010
<body>
1111
<app-root></app-root>

public/favicon.svg

Lines changed: 17 additions & 0 deletions
Loading

tools/schematics/src/generators/app-generator.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import {
1212
UnitTestRunner,
1313
} from '@nx/angular/generators';
1414
import { Linter } from '@nx/eslint';
15+
import { applicationGenerator as nestApplicationGenerator } from '@nx/nest';
1516

16-
function generateRandomString(length: number = 8): string {
17+
function generateRandomString(length = 8): string {
1718
const characters = 'abcdefghijklmnopqrstuvwxyz';
1819
let result = '';
1920
for (let i = 0; i < length; i++) {
@@ -36,12 +37,39 @@ export async function appGeneratorGenerator(
3637
e2eTestRunner: E2eTestRunner.Playwright,
3738
addTailwind: false,
3839
style: 'css',
40+
inlineStyle: true,
41+
skipTests: true,
3942
});
4043

41-
generateFiles(tree, path.join(__dirname, 'files'), `apps/${name}`, {
44+
generateFiles(tree, path.join(__dirname, 'files/front'), `apps/${name}`, {
4245
name,
4346
});
4447
await formatFiles(tree);
48+
49+
tree.delete(`apps/${name}/src/app/nx-welcome.component.ts`);
50+
tree.delete(`apps/${name}/src/app/app.component.css`);
51+
tree.delete(`apps/${name}/src/app/app.component.spec.ts`);
52+
53+
if (options.generateApi) {
54+
await nestApplicationGenerator(tree, {
55+
name: `${name}-api`,
56+
directory: `apps/${name}-api`,
57+
linter: Linter.EsLint,
58+
unitTestRunner: UnitTestRunner.Jest,
59+
frontendProject: name,
60+
strict: true,
61+
e2eTestRunner: 'none',
62+
});
63+
64+
generateFiles(
65+
tree,
66+
path.join(__dirname, 'files/back'),
67+
`apps/${name}-api`,
68+
{
69+
name,
70+
}
71+
);
72+
}
4573
}
4674

4775
export default appGeneratorGenerator;

tools/schematics/src/generators/files/README.md renamed to tools/schematics/src/generators/files/front/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,23 @@
99
## Expected behavior
1010

1111
<img src="../<%= name %>-e2e/screenshots/approval-screenshot.png" alt="Approval Screenshot" />
12+
13+
# Developer notes
14+
15+
## Run the complete project
16+
17+
```bash
18+
nx run-many -t serve --projects=<%= name %>,<%= name %>-api
19+
```
20+
21+
## Run the frontend
22+
23+
```bash
24+
npx nx serve <%= name %>
25+
```
26+
27+
## Run the API
28+
29+
```bash
30+
npx nx serve <%= name %>-api
31+
```
Lines changed: 17 additions & 0 deletions
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>azlmqhys</title>
6+
<base href="/" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<link rel="icon" type="image/x-icon" href="favicon.svg" />
9+
</head>
10+
<body>
11+
<app-root></app-root>
12+
</body>
13+
</html>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* You can add global styles to this file, and also import other style files */
2+
@import 'tailwindcss';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export interface AppGeneratorGeneratorSchema {
22
name: string;
3+
generateApi: boolean;
34
}

tools/schematics/src/generators/schema.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@
33
"$id": "AppGenerator",
44
"title": "Generates an angular application with tailwindcss, Playwright and a custom random name",
55
"type": "object",
6-
"properties": {}
6+
"properties": {
7+
"generateApi": {
8+
"type": "boolean",
9+
"description": "Generate a NestJS API for the application",
10+
"default": false
11+
}
12+
}
713
}

0 commit comments

Comments
 (0)