@nx/web 0.0.0-pr-31222-862e973 → 0.0.0-pr-31313-387cdca
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/LICENSE +1 -1
- package/README.md +1 -1
- package/migrations.json +2 -25
- package/package.json +5 -6
- package/src/executors/file-server/file-server.impl.js +1 -1
- package/src/executors/file-server/schema.json +9 -1
- package/src/generators/application/application.js +148 -100
- package/src/generators/application/files/app-vite/index.html__tmpl__ +1 -1
- package/src/generators/application/files/app-webpack/src/index.html +1 -1
- package/src/generators/application/files/app-webpack/webpack.config.js__tmpl__ +1 -1
- package/src/generators/application/schema.d.ts +3 -5
- package/src/generators/application/schema.json +18 -21
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
- package/src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors.d.ts +0 -2
- package/src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors.js +0 -34
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
[](https://circleci.com/gh/nrwl/nx)
|
|
11
11
|
[]()
|
|
12
|
-
[](https://www.npmjs.com/package/nx)
|
|
13
13
|
[]()
|
|
14
14
|
[](http://commitizen.github.io/cz-cli/)
|
|
15
15
|
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
package/migrations.json
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generators": {
|
|
3
|
-
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"version": "16.0.0-beta.1",
|
|
6
|
-
"description": "Replace @nrwl/web with @nx/web",
|
|
7
|
-
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
8
|
-
},
|
|
9
|
-
"update-16-0-0-update-executors": {
|
|
10
|
-
"cli": "nx",
|
|
11
|
-
"version": "16.0.0-beta.4",
|
|
12
|
-
"description": "Replace @nrwl/web executors with @nx/webpack and @nx/rollup",
|
|
13
|
-
"implementation": "./src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"packageJsonUpdates": {
|
|
17
|
-
"17.3.0": {
|
|
18
|
-
"version": "17.3.0-beta.3",
|
|
19
|
-
"packages": {
|
|
20
|
-
"@types/node": {
|
|
21
|
-
"version": "18.16.9",
|
|
22
|
-
"alwaysAddToPackageJson": false
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
2
|
+
"generators": {},
|
|
3
|
+
"packageJsonUpdates": {}
|
|
27
4
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/web",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-31313-387cdca",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Web Components contains generators for managing Web Component applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Playwright, Cypress, and Storybook.\n\n- Scaffolding for creating buildable libraries that can be published to npm.\n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -35,13 +35,12 @@
|
|
|
35
35
|
"http-server": "^14.1.0",
|
|
36
36
|
"picocolors": "^1.1.0",
|
|
37
37
|
"tslib": "^2.3.0",
|
|
38
|
-
"@nx/devkit": "0.0.0-pr-
|
|
39
|
-
"@nx/js": "0.0.0-pr-
|
|
40
|
-
"@nrwl/web": "0.0.0-pr-31222-862e973"
|
|
38
|
+
"@nx/devkit": "0.0.0-pr-31313-387cdca",
|
|
39
|
+
"@nx/js": "0.0.0-pr-31313-387cdca"
|
|
41
40
|
},
|
|
42
41
|
"publishConfig": {
|
|
43
42
|
"access": "public"
|
|
44
43
|
},
|
|
45
|
-
"
|
|
46
|
-
"
|
|
44
|
+
"types": "./index.d.ts",
|
|
45
|
+
"type": "commonjs"
|
|
47
46
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 2,
|
|
3
|
+
"continuous": true,
|
|
3
4
|
"outputCapture": "direct-nodejs",
|
|
4
5
|
"title": "File Server",
|
|
5
6
|
"description": "Serve a web application from a folder. This executor is a wrapper around the [http-server](https://www.npmjs.com/package/http-server) package.",
|
|
@@ -74,7 +75,14 @@
|
|
|
74
75
|
"description": "Path where the build artifacts are located. If not provided then it will be infered from the buildTarget executor options as outputPath"
|
|
75
76
|
},
|
|
76
77
|
"cors": {
|
|
77
|
-
"
|
|
78
|
+
"oneOf": [
|
|
79
|
+
{
|
|
80
|
+
"type": "boolean"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"type": "string"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
78
86
|
"description": "Enable CORS",
|
|
79
87
|
"default": true
|
|
80
88
|
},
|
|
@@ -14,31 +14,33 @@ const has_webpack_plugin_1 = require("../../utils/has-webpack-plugin");
|
|
|
14
14
|
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
15
15
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
16
16
|
const static_serve_configuration_1 = require("../static-serve/static-serve-configuration");
|
|
17
|
-
const
|
|
17
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
18
18
|
function createApplicationFiles(tree, options) {
|
|
19
|
+
const rootTsConfigPath = (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot);
|
|
19
20
|
if (options.bundler === 'vite') {
|
|
20
21
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/app-vite'), options.appProjectRoot, {
|
|
21
22
|
...options,
|
|
22
|
-
...(0, devkit_1.names)(options.name),
|
|
23
23
|
tmpl: '',
|
|
24
24
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
25
|
-
rootTsConfigPath
|
|
25
|
+
rootTsConfigPath,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
+
const rootOffset = (0, devkit_1.offsetFromRoot)(options.appProjectRoot);
|
|
29
30
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/app-webpack'), options.appProjectRoot, {
|
|
30
31
|
...options,
|
|
31
|
-
...(0, devkit_1.names)(options.name),
|
|
32
32
|
tmpl: '',
|
|
33
|
-
offsetFromRoot:
|
|
34
|
-
rootTsConfigPath
|
|
33
|
+
offsetFromRoot: rootOffset,
|
|
34
|
+
rootTsConfigPath,
|
|
35
35
|
webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)
|
|
36
36
|
? {
|
|
37
37
|
compiler: options.compiler,
|
|
38
38
|
target: 'web',
|
|
39
|
-
outputPath:
|
|
40
|
-
?
|
|
41
|
-
:
|
|
39
|
+
outputPath: options.isUsingTsSolutionConfig
|
|
40
|
+
? 'dist'
|
|
41
|
+
: (0, devkit_1.joinPathFragments)(rootOffset, 'dist', options.appProjectRoot !== '.'
|
|
42
|
+
? options.appProjectRoot
|
|
43
|
+
: options.projectName),
|
|
42
44
|
tsConfig: './tsconfig.app.json',
|
|
43
45
|
main: './src/main.ts',
|
|
44
46
|
assets: ['./src/favicon.ico', './src/assets'],
|
|
@@ -52,15 +54,29 @@ function createApplicationFiles(tree, options) {
|
|
|
52
54
|
tree.delete((0, path_1.join)(options.appProjectRoot, './src/app/app.element.spec.ts'));
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
if (options.isUsingTsSolutionConfig) {
|
|
58
|
+
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'), () => ({
|
|
59
|
+
extends: rootTsConfigPath,
|
|
60
|
+
files: [],
|
|
61
|
+
include: [],
|
|
62
|
+
references: [
|
|
63
|
+
{
|
|
64
|
+
path: './tsconfig.app.json',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.json'), (json) => {
|
|
71
|
+
return {
|
|
72
|
+
...json,
|
|
73
|
+
compilerOptions: {
|
|
74
|
+
...(json.compilerOptions || {}),
|
|
75
|
+
strict: options.strict,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
}
|
|
64
80
|
}
|
|
65
81
|
async function setupBundler(tree, options) {
|
|
66
82
|
const main = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/main.ts');
|
|
@@ -83,7 +99,7 @@ async function setupBundler(tree, options) {
|
|
|
83
99
|
addPlugin: options.addPlugin,
|
|
84
100
|
});
|
|
85
101
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
86
|
-
if (project.targets
|
|
102
|
+
if (project.targets?.build) {
|
|
87
103
|
const prodConfig = project.targets.build.configurations.production;
|
|
88
104
|
const buildOptions = project.targets.build.options;
|
|
89
105
|
buildOptions.assets = assets;
|
|
@@ -116,6 +132,7 @@ async function setupBundler(tree, options) {
|
|
|
116
132
|
else if (options.bundler === 'none') {
|
|
117
133
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
118
134
|
(0, target_defaults_utils_1.addBuildTargetDefaults)(tree, `@nx/js:${options.compiler}`);
|
|
135
|
+
project.targets ??= {};
|
|
119
136
|
project.targets.build = {
|
|
120
137
|
executor: `@nx/js:${options.compiler}`,
|
|
121
138
|
outputs: ['{options.outputPath}'],
|
|
@@ -132,14 +149,32 @@ async function setupBundler(tree, options) {
|
|
|
132
149
|
}
|
|
133
150
|
}
|
|
134
151
|
async function addProject(tree, options) {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
152
|
+
const packageJson = {
|
|
153
|
+
name: options.importPath,
|
|
154
|
+
version: '0.0.1',
|
|
155
|
+
private: true,
|
|
156
|
+
};
|
|
157
|
+
if (!options.useProjectJson) {
|
|
158
|
+
if (options.projectName !== options.importPath) {
|
|
159
|
+
packageJson.nx = { name: options.projectName };
|
|
160
|
+
}
|
|
161
|
+
if (options.parsedTags?.length) {
|
|
162
|
+
packageJson.nx ??= {};
|
|
163
|
+
packageJson.nx.tags = options.parsedTags;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
|
|
168
|
+
projectType: 'application',
|
|
169
|
+
root: options.appProjectRoot,
|
|
170
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src'),
|
|
171
|
+
tags: options.parsedTags,
|
|
172
|
+
targets: {},
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
176
|
+
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
|
|
177
|
+
}
|
|
143
178
|
}
|
|
144
179
|
function setDefaults(tree, options) {
|
|
145
180
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
@@ -156,16 +191,19 @@ function setDefaults(tree, options) {
|
|
|
156
191
|
async function applicationGenerator(host, schema) {
|
|
157
192
|
return await applicationGeneratorInternal(host, {
|
|
158
193
|
addPlugin: false,
|
|
159
|
-
projectNameAndRootFormat: 'derived',
|
|
160
194
|
...schema,
|
|
161
195
|
});
|
|
162
196
|
}
|
|
163
197
|
async function applicationGeneratorInternal(host, schema) {
|
|
164
198
|
const options = await normalizeOptions(host, schema);
|
|
199
|
+
if (options.isUsingTsSolutionConfig) {
|
|
200
|
+
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
|
|
201
|
+
}
|
|
165
202
|
const tasks = [];
|
|
166
203
|
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
167
204
|
js: false,
|
|
168
205
|
skipFormat: true,
|
|
206
|
+
platform: 'web',
|
|
169
207
|
});
|
|
170
208
|
tasks.push(jsInitTask);
|
|
171
209
|
const webTask = await (0, init_1.webInitGenerator)(host, {
|
|
@@ -178,6 +216,21 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
178
216
|
await setupBundler(host, options);
|
|
179
217
|
}
|
|
180
218
|
createApplicationFiles(host, options);
|
|
219
|
+
if (options.linter === 'eslint') {
|
|
220
|
+
const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', versions_2.nxVersion);
|
|
221
|
+
const lintTask = await lintProjectGenerator(host, {
|
|
222
|
+
linter: options.linter,
|
|
223
|
+
project: options.projectName,
|
|
224
|
+
tsConfigPaths: [
|
|
225
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
226
|
+
],
|
|
227
|
+
unitTestRunner: options.unitTestRunner,
|
|
228
|
+
skipFormat: true,
|
|
229
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
230
|
+
addPlugin: options.addPlugin,
|
|
231
|
+
});
|
|
232
|
+
tasks.push(lintTask);
|
|
233
|
+
}
|
|
181
234
|
if (options.bundler === 'vite') {
|
|
182
235
|
const { viteConfigurationGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_2.nxVersion);
|
|
183
236
|
// We recommend users use `import.meta.env.MODE` and other variables in their code to differentiate between production and development.
|
|
@@ -211,6 +264,7 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
211
264
|
inSourceTests: options.inSourceTests,
|
|
212
265
|
skipFormat: true,
|
|
213
266
|
addPlugin: options.addPlugin,
|
|
267
|
+
compiler: options.compiler,
|
|
214
268
|
});
|
|
215
269
|
tasks.push(vitestTask);
|
|
216
270
|
createOrEditViteConfig(host, {
|
|
@@ -224,21 +278,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
224
278
|
options.inSourceTests) {
|
|
225
279
|
host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, `src/app/app.element.spec.ts`));
|
|
226
280
|
}
|
|
227
|
-
if (options.linter === 'eslint') {
|
|
228
|
-
const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', versions_2.nxVersion);
|
|
229
|
-
const lintTask = await lintProjectGenerator(host, {
|
|
230
|
-
linter: options.linter,
|
|
231
|
-
project: options.projectName,
|
|
232
|
-
tsConfigPaths: [
|
|
233
|
-
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
234
|
-
],
|
|
235
|
-
unitTestRunner: options.unitTestRunner,
|
|
236
|
-
skipFormat: true,
|
|
237
|
-
setParserOptionsProject: options.setParserOptionsProject,
|
|
238
|
-
addPlugin: options.addPlugin,
|
|
239
|
-
});
|
|
240
|
-
tasks.push(lintTask);
|
|
241
|
-
}
|
|
242
281
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
243
282
|
let hasPlugin;
|
|
244
283
|
let buildPlugin;
|
|
@@ -272,14 +311,29 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
272
311
|
}
|
|
273
312
|
if (options.e2eTestRunner === 'cypress') {
|
|
274
313
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_2.nxVersion);
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
314
|
+
const packageJson = {
|
|
315
|
+
name: options.e2eProjectName,
|
|
316
|
+
version: '0.0.1',
|
|
317
|
+
private: true,
|
|
318
|
+
};
|
|
319
|
+
if (!options.useProjectJson) {
|
|
320
|
+
packageJson.nx = {
|
|
321
|
+
implicitDependencies: [options.projectName],
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
326
|
+
root: options.e2eProjectRoot,
|
|
327
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
328
|
+
projectType: 'application',
|
|
329
|
+
targets: {},
|
|
330
|
+
tags: [],
|
|
331
|
+
implicitDependencies: [options.projectName],
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
335
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
|
|
336
|
+
}
|
|
283
337
|
const cypressTask = await configurationGenerator(host, {
|
|
284
338
|
...options,
|
|
285
339
|
project: options.e2eProjectName,
|
|
@@ -287,42 +341,40 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
287
341
|
baseUrl: e2eWebServerInfo.e2eWebServerAddress,
|
|
288
342
|
directory: 'src',
|
|
289
343
|
skipFormat: true,
|
|
290
|
-
webServerCommands:
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
: undefined,
|
|
296
|
-
ciWebServerCommand: hasPlugin
|
|
297
|
-
? e2eWebServerInfo.e2eCiWebServerCommand
|
|
298
|
-
: undefined,
|
|
344
|
+
webServerCommands: {
|
|
345
|
+
default: e2eWebServerInfo.e2eWebServerCommand,
|
|
346
|
+
production: e2eWebServerInfo.e2eCiWebServerCommand,
|
|
347
|
+
},
|
|
348
|
+
ciWebServerCommand: e2eWebServerInfo.e2eCiWebServerCommand,
|
|
299
349
|
ciBaseUrl: e2eWebServerInfo.e2eCiBaseUrl,
|
|
300
350
|
});
|
|
301
|
-
if (options.addPlugin ||
|
|
302
|
-
(0, devkit_1.readNxJson)(host).plugins?.find((p) => typeof p === 'string'
|
|
303
|
-
? p === '@nx/cypress/plugin'
|
|
304
|
-
: p.plugin === '@nx/cypress/plugin')) {
|
|
305
|
-
let buildTarget = '^build';
|
|
306
|
-
if (hasPlugin) {
|
|
307
|
-
const matchingPlugin = await (0, find_plugin_for_config_file_1.findPluginForConfigFile)(host, buildPlugin, (0, devkit_1.joinPathFragments)(options.appProjectRoot, buildConfigFile));
|
|
308
|
-
if (matchingPlugin && typeof matchingPlugin !== 'string') {
|
|
309
|
-
buildTarget = `^${matchingPlugin.options?.buildTargetName ?? 'build'}`;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
await (0, target_defaults_utils_1.addE2eCiTargetDefaults)(host, '@nx/cypress/plugin', buildTarget, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, `cypress.config.ts`));
|
|
313
|
-
}
|
|
314
351
|
tasks.push(cypressTask);
|
|
315
352
|
}
|
|
316
353
|
else if (options.e2eTestRunner === 'playwright') {
|
|
317
354
|
const { configurationGenerator: playwrightConfigGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_2.nxVersion);
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
355
|
+
const packageJson = {
|
|
356
|
+
name: options.e2eProjectName,
|
|
357
|
+
version: '0.0.1',
|
|
358
|
+
private: true,
|
|
359
|
+
};
|
|
360
|
+
if (!options.useProjectJson) {
|
|
361
|
+
packageJson.nx = {
|
|
362
|
+
implicitDependencies: [options.projectName],
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
367
|
+
root: options.e2eProjectRoot,
|
|
368
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
369
|
+
projectType: 'application',
|
|
370
|
+
targets: {},
|
|
371
|
+
tags: [],
|
|
372
|
+
implicitDependencies: [options.projectName],
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
376
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
|
|
377
|
+
}
|
|
326
378
|
const playwrightTask = await playwrightConfigGenerator(host, {
|
|
327
379
|
project: options.e2eProjectName,
|
|
328
380
|
skipFormat: true,
|
|
@@ -335,19 +387,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
335
387
|
webServerAddress: e2eWebServerInfo.e2eCiBaseUrl,
|
|
336
388
|
addPlugin: options.addPlugin,
|
|
337
389
|
});
|
|
338
|
-
if (options.addPlugin ||
|
|
339
|
-
(0, devkit_1.readNxJson)(host).plugins?.find((p) => typeof p === 'string'
|
|
340
|
-
? p === '@nx/playwright/plugin'
|
|
341
|
-
: p.plugin === '@nx/playwright/plugin')) {
|
|
342
|
-
let buildTarget = '^build';
|
|
343
|
-
if (hasPlugin) {
|
|
344
|
-
const matchingPlugin = await (0, find_plugin_for_config_file_1.findPluginForConfigFile)(host, buildPlugin, (0, devkit_1.joinPathFragments)(options.appProjectRoot, buildConfigFile));
|
|
345
|
-
if (matchingPlugin && typeof matchingPlugin !== 'string') {
|
|
346
|
-
buildTarget = `^${matchingPlugin.options?.buildTargetName ?? 'build'}`;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
await (0, target_defaults_utils_1.addE2eCiTargetDefaults)(host, '@nx/playwright/plugin', buildTarget, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, `playwright.config.ts`));
|
|
350
|
-
}
|
|
351
390
|
tasks.push(playwrightTask);
|
|
352
391
|
}
|
|
353
392
|
if (options.unitTestRunner === 'jest') {
|
|
@@ -381,7 +420,13 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
381
420
|
}
|
|
382
421
|
setDefaults(host, options);
|
|
383
422
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, { tslib: versions_2.tsLibVersion }, { '@types/node': versions_2.typesNodeVersion }));
|
|
384
|
-
|
|
423
|
+
(0, ts_solution_setup_1.updateTsconfigFiles)(host, options.appProjectRoot, 'tsconfig.app.json', {
|
|
424
|
+
module: 'esnext',
|
|
425
|
+
moduleResolution: 'bundler',
|
|
426
|
+
}, options.linter === 'eslint'
|
|
427
|
+
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
428
|
+
: undefined);
|
|
429
|
+
if (!options.skipFormat) {
|
|
385
430
|
await (0, devkit_1.formatFiles)(host);
|
|
386
431
|
}
|
|
387
432
|
tasks.push(() => {
|
|
@@ -390,18 +435,18 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
390
435
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
391
436
|
}
|
|
392
437
|
async function normalizeOptions(host, options) {
|
|
393
|
-
|
|
438
|
+
await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
|
|
439
|
+
const { projectName, projectRoot: appProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
394
440
|
name: options.name,
|
|
395
441
|
projectType: 'application',
|
|
396
442
|
directory: options.directory,
|
|
397
|
-
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
398
|
-
callingGenerator: '@nx/web:application',
|
|
399
443
|
});
|
|
400
|
-
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
401
444
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
402
445
|
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
403
446
|
nxJson.useInferencePlugins !== false;
|
|
404
447
|
options.addPlugin ??= addPluginDefault;
|
|
448
|
+
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
449
|
+
const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
|
|
405
450
|
const e2eProjectName = `${appProjectName}-e2e`;
|
|
406
451
|
const e2eProjectRoot = `${appProjectRoot}-e2e`;
|
|
407
452
|
const npmScope = (0, get_npm_scope_1.getNpmScope)(host);
|
|
@@ -415,15 +460,18 @@ async function normalizeOptions(host, options) {
|
|
|
415
460
|
return {
|
|
416
461
|
...options,
|
|
417
462
|
prefix: options.prefix ?? npmScope ?? 'app',
|
|
418
|
-
name: (0, devkit_1.names)(options.name).fileName,
|
|
419
463
|
compiler: options.compiler ?? 'babel',
|
|
420
464
|
bundler: options.bundler ?? 'webpack',
|
|
421
465
|
projectName: appProjectName,
|
|
466
|
+
importPath,
|
|
422
467
|
strict: options.strict ?? true,
|
|
423
468
|
appProjectRoot,
|
|
424
469
|
e2eProjectRoot,
|
|
425
470
|
e2eProjectName,
|
|
426
471
|
parsedTags,
|
|
472
|
+
names: (0, devkit_1.names)(projectName),
|
|
473
|
+
isUsingTsSolutionConfig,
|
|
474
|
+
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
427
475
|
};
|
|
428
476
|
}
|
|
429
477
|
exports.default = applicationGenerator;
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
1
|
import type { Linter, LinterType } from '@nx/eslint';
|
|
3
2
|
|
|
4
3
|
export interface Schema {
|
|
5
|
-
|
|
4
|
+
directory: string;
|
|
5
|
+
name?: string;
|
|
6
6
|
prefix?: string;
|
|
7
7
|
style?: string;
|
|
8
8
|
bundler?: 'webpack' | 'none' | 'vite';
|
|
9
9
|
compiler?: 'babel' | 'swc';
|
|
10
10
|
skipFormat?: boolean;
|
|
11
|
-
directory?: string;
|
|
12
|
-
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
13
11
|
tags?: string;
|
|
14
12
|
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
15
13
|
inSourceTests?: boolean;
|
|
16
14
|
e2eTestRunner?: 'cypress' | 'playwright' | 'none';
|
|
17
15
|
linter?: Linter | LinterType;
|
|
18
|
-
standaloneConfig?: boolean;
|
|
19
16
|
setParserOptionsProject?: boolean;
|
|
20
17
|
strict?: boolean;
|
|
21
18
|
addPlugin?: boolean;
|
|
19
|
+
useProjectJson?: boolean;
|
|
22
20
|
}
|
|
@@ -6,24 +6,20 @@
|
|
|
6
6
|
"description": "Create a web application using `swc` or `babel` as compiler.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"
|
|
10
|
-
"description": "The
|
|
9
|
+
"directory": {
|
|
10
|
+
"description": "The directory of the new application.",
|
|
11
11
|
"type": "string",
|
|
12
12
|
"$default": {
|
|
13
13
|
"$source": "argv",
|
|
14
14
|
"index": 0
|
|
15
15
|
},
|
|
16
|
-
"x-prompt": "
|
|
17
|
-
"pattern": "^[a-zA-Z][^:]*$"
|
|
18
|
-
},
|
|
19
|
-
"directory": {
|
|
20
|
-
"description": "The directory of the new application.",
|
|
21
|
-
"type": "string"
|
|
16
|
+
"x-prompt": "Which directory do you want to create the application in?"
|
|
22
17
|
},
|
|
23
|
-
"
|
|
24
|
-
"description": "
|
|
18
|
+
"name": {
|
|
19
|
+
"description": "The name of the application.",
|
|
25
20
|
"type": "string",
|
|
26
|
-
"
|
|
21
|
+
"pattern": "^[a-zA-Z][^:]*$",
|
|
22
|
+
"x-priority": "important"
|
|
27
23
|
},
|
|
28
24
|
"style": {
|
|
29
25
|
"description": "The file extension to be used for style files.",
|
|
@@ -58,8 +54,8 @@
|
|
|
58
54
|
"bundler": {
|
|
59
55
|
"type": "string",
|
|
60
56
|
"description": "The bundler to use.",
|
|
61
|
-
"enum": ["
|
|
62
|
-
"default": "
|
|
57
|
+
"enum": ["vite", "webpack", "none"],
|
|
58
|
+
"default": "vite",
|
|
63
59
|
"x-prompt": "Which bundler do you want to use?",
|
|
64
60
|
"x-priority": "important"
|
|
65
61
|
},
|
|
@@ -67,7 +63,8 @@
|
|
|
67
63
|
"description": "The tool to use for running lint checks.",
|
|
68
64
|
"type": "string",
|
|
69
65
|
"enum": ["eslint", "none"],
|
|
70
|
-
"default": "
|
|
66
|
+
"default": "none",
|
|
67
|
+
"x-prompt": "Which linter would you like to use?"
|
|
71
68
|
},
|
|
72
69
|
"skipFormat": {
|
|
73
70
|
"description": "Skip formatting files",
|
|
@@ -77,8 +74,10 @@
|
|
|
77
74
|
},
|
|
78
75
|
"unitTestRunner": {
|
|
79
76
|
"type": "string",
|
|
80
|
-
"enum": ["
|
|
81
|
-
"
|
|
77
|
+
"enum": ["vitest", "jest", "none"],
|
|
78
|
+
"default": "none",
|
|
79
|
+
"description": "Test runner to use for unit tests. Default value is 'jest' when using 'webpack' or 'none' as the bundler and 'vitest' when using 'vite' as the bundler",
|
|
80
|
+
"x-prompt": "What unit test runner should be used?"
|
|
82
81
|
},
|
|
83
82
|
"inSourceTests": {
|
|
84
83
|
"type": "boolean",
|
|
@@ -106,13 +105,11 @@
|
|
|
106
105
|
"description": "Creates an application with strict mode and strict type checking.",
|
|
107
106
|
"default": true
|
|
108
107
|
},
|
|
109
|
-
"
|
|
110
|
-
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside workspace.json",
|
|
108
|
+
"useProjectJson": {
|
|
111
109
|
"type": "boolean",
|
|
112
|
-
"
|
|
113
|
-
"x-deprecated": "Nx only supports standaloneConfig"
|
|
110
|
+
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
114
111
|
}
|
|
115
112
|
},
|
|
116
|
-
"required": ["
|
|
113
|
+
"required": ["directory"],
|
|
117
114
|
"examplesFile": "../../../docs/application-examples.md"
|
|
118
115
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = replacePackage;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
|
-
async function replacePackage(tree) {
|
|
7
|
-
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/web', '@nx/web');
|
|
8
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
9
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = update;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const versions_1 = require("../../utils/versions");
|
|
6
|
-
async function update(host) {
|
|
7
|
-
const projects = (0, devkit_1.getProjects)(host);
|
|
8
|
-
const deps = {};
|
|
9
|
-
for (const [name, config] of projects.entries()) {
|
|
10
|
-
let updated = false;
|
|
11
|
-
// webpack
|
|
12
|
-
if (config?.targets?.build?.executor === '@nrwl/web:webpack') {
|
|
13
|
-
config.targets.build.executor = '@nx/webpack:webpack';
|
|
14
|
-
deps['@nx/webpack'] = versions_1.nxVersion;
|
|
15
|
-
updated = true;
|
|
16
|
-
}
|
|
17
|
-
if (config?.targets?.serve?.executor === '@nrwl/web:dev-server') {
|
|
18
|
-
config.targets.serve.executor = '@nx/webpack:dev-server';
|
|
19
|
-
deps['@nx/webpack'] = versions_1.nxVersion;
|
|
20
|
-
updated = true;
|
|
21
|
-
}
|
|
22
|
-
// rollup
|
|
23
|
-
if (config?.targets?.build?.executor === '@nrwl/web:rollup') {
|
|
24
|
-
config.targets.build.executor = '@nx/rollup:rollup';
|
|
25
|
-
deps['@nx/rollup'] = versions_1.nxVersion;
|
|
26
|
-
updated = true;
|
|
27
|
-
}
|
|
28
|
-
if (updated) {
|
|
29
|
-
(0, devkit_1.updateProjectConfiguration)(host, name, config);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
await (0, devkit_1.formatFiles)(host);
|
|
33
|
-
return (0, devkit_1.addDependenciesToPackageJson)(host, {}, deps);
|
|
34
|
-
}
|