@aws/nx-plugin 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -8
- package/generators.json +14 -7
- package/package.json +1 -1
- package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/core/user-identity.ts.template +1 -0
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +42 -0
- package/src/infra/app/generator.js +14 -0
- package/src/infra/app/generator.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +199 -0
- package/src/preset/files/README.md +107 -0
- package/src/preset/generator.d.ts +10 -0
- package/src/preset/generator.js +63 -0
- package/src/preset/generator.js.map +1 -0
- package/src/preset/schema.d.ts +7 -0
- package/src/preset/schema.json +14 -0
- package/src/setup-tests.d.ts +2 -0
- package/src/setup-tests.js +14 -0
- package/src/setup-tests.js.map +1 -0
- package/src/ts/lib/__snapshots__/generator.spec.ts.snap +26 -0
- package/src/ts/lib/generator.js +9 -0
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +1 -1
package/README.md
CHANGED
|
@@ -71,17 +71,11 @@
|
|
|
71
71
|
1. Create a new NX workspace
|
|
72
72
|
|
|
73
73
|
```bash
|
|
74
|
-
npx create-nx-workspace@~20.6.3 demo --pm=pnpm --preset
|
|
74
|
+
npx create-nx-workspace@~20.6.3 demo --pm=pnpm --preset=@aws/nx-plugin --ci=skip
|
|
75
75
|
cd demo
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
2.
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
pnpm add -Dw @aws/nx-plugin
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
3. Add components:
|
|
78
|
+
2. Add components:
|
|
85
79
|
|
|
86
80
|
```bash
|
|
87
81
|
# Generate a tRPC API backend
|
package/generators.json
CHANGED
|
@@ -86,13 +86,6 @@
|
|
|
86
86
|
"metric": "g13",
|
|
87
87
|
"hidden": true
|
|
88
88
|
},
|
|
89
|
-
"open-api#ts-metadata": {
|
|
90
|
-
"factory": "./src/open-api/ts-metadata/generator",
|
|
91
|
-
"schema": "./src/open-api/ts-metadata/schema.json",
|
|
92
|
-
"description": "Generate typescript metadata from an OpenAPI specification",
|
|
93
|
-
"metric": "g19",
|
|
94
|
-
"hidden": true
|
|
95
|
-
},
|
|
96
89
|
"license": {
|
|
97
90
|
"factory": "./src/license/generator",
|
|
98
91
|
"schema": "./src/license/schema.json",
|
|
@@ -123,6 +116,20 @@
|
|
|
123
116
|
"schema": "./src/ts/mcp-server/schema.json",
|
|
124
117
|
"description": "Generate a TypeScript Model Context Protocol (MCP) server for providing context to Large Language Models",
|
|
125
118
|
"metric": "g18"
|
|
119
|
+
},
|
|
120
|
+
"open-api#ts-metadata": {
|
|
121
|
+
"factory": "./src/open-api/ts-metadata/generator",
|
|
122
|
+
"schema": "./src/open-api/ts-metadata/schema.json",
|
|
123
|
+
"description": "Generate typescript metadata from an OpenAPI specification",
|
|
124
|
+
"metric": "g19",
|
|
125
|
+
"hidden": true
|
|
126
|
+
},
|
|
127
|
+
"preset": {
|
|
128
|
+
"factory": "./src/preset/generator",
|
|
129
|
+
"schema": "./src/preset/schema.json",
|
|
130
|
+
"description": "The @aws/nx-plugin workspace preset.",
|
|
131
|
+
"metric": "g20",
|
|
132
|
+
"hidden": true
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
135
|
}
|
package/package.json
CHANGED
|
@@ -121,6 +121,13 @@ exports[`infra generator > should configure project.json with correct targets >
|
|
|
121
121
|
"sourceRoot": "packages/test/src",
|
|
122
122
|
"tags": [],
|
|
123
123
|
"targets": {
|
|
124
|
+
"bootstrap": {
|
|
125
|
+
"executor": "nx:run-commands",
|
|
126
|
+
"options": {
|
|
127
|
+
"command": "cdk bootstrap",
|
|
128
|
+
"cwd": "packages/test",
|
|
129
|
+
},
|
|
130
|
+
},
|
|
124
131
|
"build": {
|
|
125
132
|
"dependsOn": [
|
|
126
133
|
"lint",
|
|
@@ -129,6 +136,13 @@ exports[`infra generator > should configure project.json with correct targets >
|
|
|
129
136
|
"synth",
|
|
130
137
|
],
|
|
131
138
|
},
|
|
139
|
+
"cdk": {
|
|
140
|
+
"executor": "nx:run-commands",
|
|
141
|
+
"options": {
|
|
142
|
+
"command": "cdk",
|
|
143
|
+
"cwd": "packages/test",
|
|
144
|
+
},
|
|
145
|
+
},
|
|
132
146
|
"compile": {
|
|
133
147
|
"executor": "nx:run-commands",
|
|
134
148
|
"options": {
|
|
@@ -469,9 +483,23 @@ exports[`infra generator > should generate files with correct content > project-
|
|
|
469
483
|
"projectType": "application",
|
|
470
484
|
"tags": [],
|
|
471
485
|
"targets": {
|
|
486
|
+
"bootstrap": {
|
|
487
|
+
"executor": "nx:run-commands",
|
|
488
|
+
"options": {
|
|
489
|
+
"cwd": "packages/test",
|
|
490
|
+
"command": "cdk bootstrap"
|
|
491
|
+
}
|
|
492
|
+
},
|
|
472
493
|
"build": {
|
|
473
494
|
"dependsOn": ["lint", "compile", "test", "synth"]
|
|
474
495
|
},
|
|
496
|
+
"cdk": {
|
|
497
|
+
"executor": "nx:run-commands",
|
|
498
|
+
"options": {
|
|
499
|
+
"cwd": "packages/test",
|
|
500
|
+
"command": "cdk"
|
|
501
|
+
}
|
|
502
|
+
},
|
|
475
503
|
"compile": {
|
|
476
504
|
"executor": "nx:run-commands",
|
|
477
505
|
"outputs": ["{workspaceRoot}/dist/packages/test/tsc"],
|
|
@@ -768,6 +796,13 @@ exports[`infra generator > should handle custom project names correctly > custom
|
|
|
768
796
|
"sourceRoot": "packages/custom-infra/src",
|
|
769
797
|
"tags": [],
|
|
770
798
|
"targets": {
|
|
799
|
+
"bootstrap": {
|
|
800
|
+
"executor": "nx:run-commands",
|
|
801
|
+
"options": {
|
|
802
|
+
"command": "cdk bootstrap",
|
|
803
|
+
"cwd": "packages/custom-infra",
|
|
804
|
+
},
|
|
805
|
+
},
|
|
771
806
|
"build": {
|
|
772
807
|
"dependsOn": [
|
|
773
808
|
"lint",
|
|
@@ -776,6 +811,13 @@ exports[`infra generator > should handle custom project names correctly > custom
|
|
|
776
811
|
"synth",
|
|
777
812
|
],
|
|
778
813
|
},
|
|
814
|
+
"cdk": {
|
|
815
|
+
"executor": "nx:run-commands",
|
|
816
|
+
"options": {
|
|
817
|
+
"command": "cdk",
|
|
818
|
+
"cwd": "packages/custom-infra",
|
|
819
|
+
},
|
|
820
|
+
},
|
|
779
821
|
"compile": {
|
|
780
822
|
"executor": "nx:run-commands",
|
|
781
823
|
"options": {
|
|
@@ -78,6 +78,20 @@ function infraGenerator(tree, schema) {
|
|
|
78
78
|
command: `cdk destroy --require-approval=never --app ${synthDirFromProject}`,
|
|
79
79
|
},
|
|
80
80
|
};
|
|
81
|
+
config.targets.cdk = {
|
|
82
|
+
executor: 'nx:run-commands',
|
|
83
|
+
options: {
|
|
84
|
+
cwd: libraryRoot,
|
|
85
|
+
command: 'cdk',
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
config.targets.bootstrap = {
|
|
89
|
+
executor: 'nx:run-commands',
|
|
90
|
+
options: {
|
|
91
|
+
cwd: libraryRoot,
|
|
92
|
+
command: 'cdk bootstrap',
|
|
93
|
+
},
|
|
94
|
+
};
|
|
81
95
|
config.targets = (0, object_1.sortObjectKeys)(config.targets);
|
|
82
96
|
return config;
|
|
83
97
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/infra/app/generator.ts"],"names":[],"mappings":";;;AAqCA,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/infra/app/generator.ts"],"names":[],"mappings":";;;AAqCA,wCAkJC;;AAvLD;;;GAGG;AACH,uCAYoB;AAEpB,4EAAyE;AACzE,mDAAoD;AACpD,qDAAwE;AAC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C,IAAI,EAAE,GAAG,WAAW,gBAAgB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,iCAC1D,QAAQ,KACX,UAAU,EAAE;gBACV,GAAG,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;gBAC9B;oBACE,IAAI,EAAE,GAAG,cAAI,CAAC,QAAQ,CACpB,WAAW,EACX,GAAG,IAAI,CAAC,IAAI,IAAI,0CAAY,EAAE,CAC/B,IAAI,mDAAqB,gBAAgB;iBAC3C;aACF,IACD,CAAC,CAAC;QAEJ,MAAM,IAAA,yCAA+B,EAAC,IAAI,EAAE,CAAC,gCAAwB,CAAC,CAAC,CAAC;QAExE,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;QACjC,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AACD,kBAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`preset generator > should run successfully > .prettierignore 1`] = `
|
|
4
|
+
"# Add files here to ignore them from prettier formatting
|
|
5
|
+
/dist
|
|
6
|
+
/coverage
|
|
7
|
+
/.nx/cache
|
|
8
|
+
/.nx/workspace-data"
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
exports[`preset generator > should run successfully > .prettierrc 1`] = `
|
|
12
|
+
"{ "singleQuote": true }
|
|
13
|
+
"
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
exports[`preset generator > should run successfully > README.md 1`] = `
|
|
17
|
+
"# proj
|
|
18
|
+
|
|
19
|
+
✨ Your new, shiny [Nx workspace](https://nx.dev) has been successfully created! ✨.
|
|
20
|
+
|
|
21
|
+
[Learn more about this workspace setup and the @aws/nx-plugin](https://awslabs.github.io/nx-plugin-for-aws). Now, let's get you up to speed!
|
|
22
|
+
|
|
23
|
+
## Install Nx Console
|
|
24
|
+
|
|
25
|
+
Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.
|
|
26
|
+
|
|
27
|
+
[Install Nx Console »](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
|
28
|
+
|
|
29
|
+
## Available generators
|
|
30
|
+
|
|
31
|
+
The following list of generators are what is currently available in the \`@aws/nx-plugin\`:
|
|
32
|
+
|
|
33
|
+
- **ts#project**: Generates a TypeScript project
|
|
34
|
+
|
|
35
|
+
- **py#project**: Generates a Python project
|
|
36
|
+
|
|
37
|
+
- **py#fast-api**: Generates a FastAPI Python project
|
|
38
|
+
|
|
39
|
+
- **ts#cloudscape-website**: Generates a React static website based on Cloudscape
|
|
40
|
+
|
|
41
|
+
- **ts#cloudscape-website#auth**: Adds auth to an existing cloudscape website
|
|
42
|
+
|
|
43
|
+
- **ts#infra**: Generates a cdk application
|
|
44
|
+
|
|
45
|
+
- **ts#trpc-api**: creates a trpc backend
|
|
46
|
+
|
|
47
|
+
- **api-connection**: Integrates a source project with a target API project
|
|
48
|
+
|
|
49
|
+
- **license**: Add LICENSE files and configure source code licence headers
|
|
50
|
+
|
|
51
|
+
- **py#lambda-function**: Adds a lambda function to a python project
|
|
52
|
+
|
|
53
|
+
- **ts#nx-generator**: Generator for adding an Nx Generator to an existing TypeScript project
|
|
54
|
+
|
|
55
|
+
- **ts#mcp-server**: Generate a TypeScript Model Context Protocol (MCP) server for providing context to Large Language Models
|
|
56
|
+
|
|
57
|
+
You also have the option of using additional [commmunity plugins](https://nx.dev/plugin-registry) as needed.
|
|
58
|
+
|
|
59
|
+
## Invoking a generator
|
|
60
|
+
|
|
61
|
+
\`\`\`sh
|
|
62
|
+
npx nx g @aws/nx-plugin:<generator-name>
|
|
63
|
+
\`\`\`
|
|
64
|
+
|
|
65
|
+
Alternatively you can use the NX IDE plugin to invoke your generators.
|
|
66
|
+
|
|
67
|
+
Refer to the [full documentation](https://awslabs.github.io/nx-plugin-for-aws) for additional guidance for each generator.
|
|
68
|
+
|
|
69
|
+
## Common tasks
|
|
70
|
+
|
|
71
|
+
### Build a single project
|
|
72
|
+
|
|
73
|
+
\`\`\`sh
|
|
74
|
+
npx nx build <project-name>
|
|
75
|
+
\`\`\`
|
|
76
|
+
|
|
77
|
+
### Build all projects
|
|
78
|
+
|
|
79
|
+
\`\`\`sh
|
|
80
|
+
npx nx run-many --target build --all
|
|
81
|
+
# or
|
|
82
|
+
npx build:all
|
|
83
|
+
\`\`\`
|
|
84
|
+
|
|
85
|
+
### Run arbitrary task
|
|
86
|
+
|
|
87
|
+
\`\`\`sh
|
|
88
|
+
npx nx <target> <project-name>
|
|
89
|
+
\`\`\`
|
|
90
|
+
|
|
91
|
+
### Lint (and fix) all projects
|
|
92
|
+
|
|
93
|
+
\`\`\`sh
|
|
94
|
+
npx nx run-many --target lint --configuration=fix --all
|
|
95
|
+
\`\`\`
|
|
96
|
+
|
|
97
|
+
## Test all projects (and update snapshots)
|
|
98
|
+
|
|
99
|
+
\`\`\`sh
|
|
100
|
+
npx nx run-many --target test --all --update
|
|
101
|
+
\`\`\`
|
|
102
|
+
|
|
103
|
+
These targets are either [inferred automatically](https://nx.dev/concepts/inferred-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or defined in the \`project.json\` or \`package.json\` files.
|
|
104
|
+
|
|
105
|
+
[More about running tasks in the Nx docs »](https://nx.dev/features/run-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
|
106
|
+
|
|
107
|
+
## Keep TypeScript project references up to date
|
|
108
|
+
|
|
109
|
+
Nx automatically updates TypeScript [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) in \`tsconfig.json\` files to ensure they remain accurate based on your project dependencies (\`import\` statements). This sync is automatically done when running tasks such as \`build\`, which require updated references to function correctly.
|
|
110
|
+
|
|
111
|
+
To manually trigger the process to sync the project graph dependencies information to the TypeScript project references, run the following command:
|
|
112
|
+
|
|
113
|
+
\`\`\`sh
|
|
114
|
+
npx nx sync
|
|
115
|
+
\`\`\`
|
|
116
|
+
|
|
117
|
+
You can enforce that the TypeScript project references are always in the correct state when running in CI by adding a step to your CI job configuration that runs the following command:
|
|
118
|
+
|
|
119
|
+
\`\`\`sh
|
|
120
|
+
npx nx sync:check
|
|
121
|
+
\`\`\`
|
|
122
|
+
|
|
123
|
+
[Learn more about nx sync](https://nx.dev/reference/nx-commands#sync)
|
|
124
|
+
|
|
125
|
+
## Set up CI!
|
|
126
|
+
|
|
127
|
+
Use the following command to configure a CI workflow for your workspace:
|
|
128
|
+
|
|
129
|
+
\`\`\`sh
|
|
130
|
+
npx nx g ci-workflow
|
|
131
|
+
\`\`\`
|
|
132
|
+
|
|
133
|
+
[Learn more about Nx on CI](https://nx.dev/ci/intro/ci-with-nx#ready-get-started-with-your-provider?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
|
134
|
+
|
|
135
|
+
## Useful links
|
|
136
|
+
|
|
137
|
+
Learn more:
|
|
138
|
+
|
|
139
|
+
- [@aws/nx-plugin quick-start](https://awslabs.github.io/nx-plugin-for-aws/en/get_started/quick-start/)
|
|
140
|
+
- [@aws/nx-plugin AI dungeon game](https://awslabs.github.io/nx-plugin-for-aws/en/get_started/tutorials/dungeon-game/overview/)
|
|
141
|
+
- [What are Nx plugins?](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
|
142
|
+
- [Learn about Nx on CI](https://nx.dev/ci/intro/ci-with-nx?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
|
143
|
+
"
|
|
144
|
+
`;
|
|
145
|
+
|
|
146
|
+
exports[`preset generator > should run successfully > nx.json 1`] = `
|
|
147
|
+
"{
|
|
148
|
+
"affected": { "defaultBase": "main" },
|
|
149
|
+
"targetDefaults": { "build": { "cache": true }, "lint": { "cache": true } }
|
|
150
|
+
}
|
|
151
|
+
"
|
|
152
|
+
`;
|
|
153
|
+
|
|
154
|
+
exports[`preset generator > should run successfully > package.json 1`] = `
|
|
155
|
+
"{
|
|
156
|
+
"name": "@proj/source",
|
|
157
|
+
"dependencies": {},
|
|
158
|
+
"devDependencies": {
|
|
159
|
+
"@nx/js": "21.0.3",
|
|
160
|
+
"@nx/workspace": "21.0.3",
|
|
161
|
+
"@swc-node/register": "~1.9.1",
|
|
162
|
+
"@swc/core": "~1.5.7",
|
|
163
|
+
"@swc/helpers": "~0.5.11",
|
|
164
|
+
"prettier": "^2.6.2",
|
|
165
|
+
"typescript": "~5.7.2"
|
|
166
|
+
},
|
|
167
|
+
"workspaces": [
|
|
168
|
+
"packages/*"
|
|
169
|
+
],
|
|
170
|
+
"type": "module",
|
|
171
|
+
"scripts": {
|
|
172
|
+
"build:all": "nx run-many --target build --all",
|
|
173
|
+
"affected:all": "nx affected --target build"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
"
|
|
177
|
+
`;
|
|
178
|
+
|
|
179
|
+
exports[`preset generator > should run successfully > packages/.gitkeep 1`] = `""`;
|
|
180
|
+
|
|
181
|
+
exports[`preset generator > should run successfully > pnpm-workspace.yaml 1`] = `
|
|
182
|
+
"packages:
|
|
183
|
+
- packages/*
|
|
184
|
+
"
|
|
185
|
+
`;
|
|
186
|
+
|
|
187
|
+
exports[`preset generator > should run successfully > tsconfig.base.json 1`] = `
|
|
188
|
+
"{
|
|
189
|
+
"compilerOptions": {
|
|
190
|
+
"paths": {}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
"
|
|
194
|
+
`;
|
|
195
|
+
|
|
196
|
+
exports[`preset generator > should run successfully > tsconfig.json 1`] = `
|
|
197
|
+
"{}
|
|
198
|
+
"
|
|
199
|
+
`;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# <%= projectName %>
|
|
2
|
+
|
|
3
|
+
✨ Your new, shiny [Nx workspace](https://nx.dev) has been successfully created! ✨.
|
|
4
|
+
|
|
5
|
+
[Learn more about this workspace setup and the @aws/nx-plugin](https://awslabs.github.io/nx-plugin-for-aws). Now, let's get you up to speed!
|
|
6
|
+
|
|
7
|
+
## Install Nx Console
|
|
8
|
+
|
|
9
|
+
Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.
|
|
10
|
+
|
|
11
|
+
[Install Nx Console »](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
|
12
|
+
|
|
13
|
+
## Available generators
|
|
14
|
+
|
|
15
|
+
The following list of generators are what is currently available in the `@aws/nx-plugin`:
|
|
16
|
+
|
|
17
|
+
<%_ generators.forEach((generator) => { _%>
|
|
18
|
+
|
|
19
|
+
- **<%- generator.name %>**: <%- generator.description %>
|
|
20
|
+
<%_ }); _%>
|
|
21
|
+
|
|
22
|
+
You also have the option of using additional [commmunity plugins](https://nx.dev/plugin-registry) as needed.
|
|
23
|
+
|
|
24
|
+
## Invoking a generator
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
<%= pkgMgrCmd %> nx g @aws/nx-plugin:<generator-name>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Alternatively you can use the NX IDE plugin to invoke your generators.
|
|
31
|
+
|
|
32
|
+
Refer to the [full documentation](https://awslabs.github.io/nx-plugin-for-aws) for additional guidance for each generator.
|
|
33
|
+
|
|
34
|
+
## Common tasks
|
|
35
|
+
|
|
36
|
+
### Build a single project
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
<%= pkgMgrCmd %> nx build <project-name>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Build all projects
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
<%= pkgMgrCmd %> nx run-many --target build --all
|
|
46
|
+
# or
|
|
47
|
+
<%= pkgMgrCmd %> build:all
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Run arbitrary task
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
<%= pkgMgrCmd %> nx <target> <project-name>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Lint (and fix) all projects
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
<%= pkgMgrCmd %> nx run-many --target lint --configuration=fix --all
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Test all projects (and update snapshots)
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
<%= pkgMgrCmd %> nx run-many --target test --all --update
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
These targets are either [inferred automatically](https://nx.dev/concepts/inferred-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or defined in the `project.json` or `package.json` files.
|
|
69
|
+
|
|
70
|
+
[More about running tasks in the Nx docs »](https://nx.dev/features/run-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
|
71
|
+
|
|
72
|
+
## Keep TypeScript project references up to date
|
|
73
|
+
|
|
74
|
+
Nx automatically updates TypeScript [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) in `tsconfig.json` files to ensure they remain accurate based on your project dependencies (`import` statements). This sync is automatically done when running tasks such as `build`, which require updated references to function correctly.
|
|
75
|
+
|
|
76
|
+
To manually trigger the process to sync the project graph dependencies information to the TypeScript project references, run the following command:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
<%= pkgMgrCmd %> nx sync
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
You can enforce that the TypeScript project references are always in the correct state when running in CI by adding a step to your CI job configuration that runs the following command:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
<%= pkgMgrCmd %> nx sync:check
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
[Learn more about nx sync](https://nx.dev/reference/nx-commands#sync)
|
|
89
|
+
|
|
90
|
+
## Set up CI!
|
|
91
|
+
|
|
92
|
+
Use the following command to configure a CI workflow for your workspace:
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
<%= pkgMgrCmd %> nx g ci-workflow
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
[Learn more about Nx on CI](https://nx.dev/ci/intro/ci-with-nx#ready-get-started-with-your-provider?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
|
99
|
+
|
|
100
|
+
## Useful links
|
|
101
|
+
|
|
102
|
+
Learn more:
|
|
103
|
+
|
|
104
|
+
- [@aws/nx-plugin quick-start](https://awslabs.github.io/nx-plugin-for-aws/en/get_started/quick-start/)
|
|
105
|
+
- [@aws/nx-plugin AI dungeon game](https://awslabs.github.io/nx-plugin-for-aws/en/get_started/tutorials/dungeon-game/overview/)
|
|
106
|
+
- [What are Nx plugins?](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
|
107
|
+
- [Learn about Nx on CI](https://nx.dev/ci/intro/ci-with-nx?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
6
|
+
import { NxGeneratorInfo } from '../utils/nx';
|
|
7
|
+
import { PresetGeneratorSchema } from './schema';
|
|
8
|
+
export declare const PRESET_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
|
+
export declare const presetGenerator: (tree: Tree, { addTsPlugin }: PresetGeneratorSchema) => Promise<GeneratorCallback>;
|
|
10
|
+
export default presetGenerator;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.presetGenerator = exports.PRESET_GENERATOR_INFO = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
/**
|
|
6
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
9
|
+
const devkit_1 = require("@nx/devkit");
|
|
10
|
+
const nx_1 = require("../utils/nx");
|
|
11
|
+
const metrics_1 = require("../utils/metrics");
|
|
12
|
+
const format_1 = require("../utils/format");
|
|
13
|
+
const js_1 = require("@nx/js");
|
|
14
|
+
const package_json_1 = require("nx/src/utils/package-json");
|
|
15
|
+
const npm_scope_1 = require("../utils/npm-scope");
|
|
16
|
+
const generators_json_1 = tslib_1.__importDefault(require("../../generators.json"));
|
|
17
|
+
const WORKSPACES = ['packages/*'];
|
|
18
|
+
exports.PRESET_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
19
|
+
const setUpWorkspaces = (tree) => {
|
|
20
|
+
if ((0, devkit_1.detectPackageManager)() === 'pnpm') {
|
|
21
|
+
tree.write('pnpm-workspace.yaml', `packages:
|
|
22
|
+
${WORKSPACES.map((workspace) => `- "${workspace}"`).join('\n ')}
|
|
23
|
+
`);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (json) => {
|
|
27
|
+
json.workspaces = WORKSPACES;
|
|
28
|
+
return json;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const presetGenerator = (tree_1, _a) => tslib_1.__awaiter(void 0, [tree_1, _a], void 0, function* (tree, { addTsPlugin }) {
|
|
33
|
+
yield (0, js_1.initGenerator)(tree, {
|
|
34
|
+
formatter: 'prettier',
|
|
35
|
+
addTsPlugin: addTsPlugin !== null && addTsPlugin !== void 0 ? addTsPlugin : true,
|
|
36
|
+
});
|
|
37
|
+
tree.delete('apps/.gitkeep');
|
|
38
|
+
tree.delete('libs/.gitkeep');
|
|
39
|
+
tree.write('packages/.gitkeep', '');
|
|
40
|
+
setUpWorkspaces(tree);
|
|
41
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => (Object.assign(Object.assign({}, packageJson), { type: 'module', scripts: Object.assign(Object.assign({}, packageJson.scripts), { 'build:all': 'nx run-many --target build --all', 'affected:all': 'nx affected --target build' }) })));
|
|
42
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
43
|
+
'@nx/workspace': (0, package_json_1.readModulePackageJson)('@nx/js').packageJson.version,
|
|
44
|
+
});
|
|
45
|
+
(0, devkit_1.generateFiles)(tree, // the virtual file system
|
|
46
|
+
(0, devkit_1.joinPathFragments)(__dirname, 'files'), '.', {
|
|
47
|
+
projectName: (0, npm_scope_1.getNpmScope)(tree),
|
|
48
|
+
generators: Object.entries(generators_json_1.default.generators)
|
|
49
|
+
.filter(([_, v]) => !v['hidden'])
|
|
50
|
+
.map(([k, v]) => ({ name: k, description: v.description })),
|
|
51
|
+
pkgMgrCmd: (0, devkit_1.getPackageManagerCommand)().exec,
|
|
52
|
+
}, {
|
|
53
|
+
overwriteStrategy: devkit_1.OverwriteStrategy.Overwrite,
|
|
54
|
+
});
|
|
55
|
+
yield (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [exports.PRESET_GENERATOR_INFO]);
|
|
56
|
+
yield (0, format_1.formatFilesInSubtree)(tree);
|
|
57
|
+
return () => {
|
|
58
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
exports.presetGenerator = presetGenerator;
|
|
62
|
+
exports.default = exports.presetGenerator;
|
|
63
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/preset/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAWoB;AACpB,oCAAgE;AAChE,8CAAmE;AACnE,4CAAuD;AACvD,+BAAuC;AACvC,4DAAkE;AAClE,kDAAiD;AACjD,oFAAmD;AAGnD,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6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"addTsPlugin": {
|
|
9
|
+
"type": "boolean",
|
|
10
|
+
"description": "Whether to add the ts plugin.",
|
|
11
|
+
"default": "true"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
/**
|
|
5
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
// Global Setup https://vitest.dev/config/#globalsetup
|
|
10
|
+
exports.default = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
+
// Create the project graph in global setup to ensure it's cached in the daemon
|
|
12
|
+
yield (0, devkit_1.createProjectGraphAsync)();
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=setup-tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-tests.js","sourceRoot":"","sources":["../../../../packages/nx-plugin/src/setup-tests.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAAqD;AAErD,sDAAsD;AACtD,kBAAe,GAAS,EAAE;IACxB,+EAA+E;IAC/E,MAAM,IAAA,gCAAuB,GAAE,CAAC;AAClC,CAAC,CAAA,CAAC"}
|
|
@@ -140,6 +140,32 @@ exports[`ts lib generator > should generate library with custom directory > cust
|
|
|
140
140
|
"
|
|
141
141
|
`;
|
|
142
142
|
|
|
143
|
+
exports[`ts lib generator > should generate library with default options > eslint.config.mjs 1`] = `
|
|
144
|
+
"import baseConfig from '../eslint.config.mjs';
|
|
145
|
+
|
|
146
|
+
export default [
|
|
147
|
+
...baseConfig,
|
|
148
|
+
{
|
|
149
|
+
files: ['**/*.json'],
|
|
150
|
+
rules: {
|
|
151
|
+
'@nx/dependency-checks': [
|
|
152
|
+
'warn',
|
|
153
|
+
{
|
|
154
|
+
ignoredFiles: [
|
|
155
|
+
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
|
156
|
+
'{projectRoot}/vite.config.{js,ts,mjs,mts}',
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
languageOptions: {
|
|
162
|
+
parser: await import('jsonc-eslint-parser'),
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
"
|
|
167
|
+
`;
|
|
168
|
+
|
|
143
169
|
exports[`ts lib generator > should generate library with default options > index.ts 1`] = `
|
|
144
170
|
"export function hello() {
|
|
145
171
|
return 'Hello!';
|
package/src/ts/lib/generator.js
CHANGED
|
@@ -16,6 +16,8 @@ const format_1 = require("../../utils/format");
|
|
|
16
16
|
const object_1 = require("../../utils/object");
|
|
17
17
|
const nx_1 = require("../../utils/nx");
|
|
18
18
|
const metrics_1 = require("../../utils/metrics");
|
|
19
|
+
const ast_1 = require("../../utils/ast");
|
|
20
|
+
const typescript_1 = require("typescript");
|
|
19
21
|
exports.TS_LIB_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
20
22
|
/**
|
|
21
23
|
* Returns details about the TS library to be created
|
|
@@ -111,6 +113,13 @@ const tsLibGenerator = (tree, schema) => tslib_1.__awaiter(void 0, void 0, void
|
|
|
111
113
|
];
|
|
112
114
|
return nxJson;
|
|
113
115
|
});
|
|
116
|
+
// change error to warn for the @nx/dependency-checks rule
|
|
117
|
+
(0, ast_1.replace)(tree, (0, devkit_1.joinPathFragments)(dir, 'eslint.config.mjs'), 'PropertyAssignment:has(Identifier[name="rules"]) ObjectLiteralExpression PropertyAssignment:has(StringLiteral[value="@nx/dependency-checks"]) ArrayLiteralExpression:has(StringLiteral[value="error"])', (node) => {
|
|
118
|
+
return typescript_1.factory.createArrayLiteralExpression([
|
|
119
|
+
typescript_1.factory.createStringLiteral('warn'),
|
|
120
|
+
...node.elements.slice(1),
|
|
121
|
+
]);
|
|
122
|
+
});
|
|
114
123
|
yield (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [exports.TS_LIB_GENERATOR_INFO]);
|
|
115
124
|
yield (0, format_1.formatFilesInSubtree)(tree);
|
|
116
125
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAYoB;AAEpB,+BAA0C;AAC1C,qDAA0D;AAC1D,yDAAwD;AACxD,6CAAgD;AAChD,+BAAgC;AAChC,+CAA0D;AAC1D,+CAAoD;AACpD,uCAAmE;AACnE,iDAAsE;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lib/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAYoB;AAEpB,+BAA0C;AAC1C,qDAA0D;AAC1D,yDAAwD;AACxD,6CAAgD;AAChD,+BAAgC;AAChC,+CAA0D;AAC1D,+CAAoD;AACpD,uCAAmE;AACnE,iDAAsE;AACtE,yCAA0C;AAC1C,2CAA6D;AAEhD,QAAA,qBAAqB,GAChC,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAa/B;;GAEG;AACI,MAAM,eAAe,GAAG,CAC7B,IAAU,EACV,MAA4B,EACd,EAAE;;IAChB,MAAM,KAAK,GAAG,IAAA,6BAAiB,EAAC,IAAI,CAAC,CAAC;IACtC,MAAM,cAAc,GAAG,IAAA,mBAAW,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,kBAAkB,GAAG,GAAG,KAAK,GAAG,cAAc,EAAE,CAAC;IACvD,MAAM,GAAG,GAAG,IAAA,0BAAiB,EAC3B,MAAA,IAAA,mBAAW,EAAC,MAAM,CAAC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