@nx/web 0.0.0-pr-30418-4e2b721 → 0.0.0-pr-3-ec41644
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/package.json +3 -3
- package/src/generators/application/application.js +44 -49
- 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/schema.d.ts +0 -1
- package/src/generators/application/schema.json +0 -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-3-ec41644",
|
|
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,8 +35,8 @@
|
|
|
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-
|
|
38
|
+
"@nx/devkit": "0.0.0-pr-3-ec41644",
|
|
39
|
+
"@nx/js": "0.0.0-pr-3-ec41644"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
@@ -16,11 +16,13 @@ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-projec
|
|
|
16
16
|
const static_serve_configuration_1 = require("../static-serve/static-serve-configuration");
|
|
17
17
|
const find_plugin_for_config_file_1 = require("@nx/devkit/src/utils/find-plugin-for-config-file");
|
|
18
18
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
19
|
+
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
19
20
|
function createApplicationFiles(tree, options) {
|
|
20
21
|
const rootTsConfigPath = (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot);
|
|
21
22
|
if (options.bundler === 'vite') {
|
|
22
23
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/app-vite'), options.appProjectRoot, {
|
|
23
24
|
...options,
|
|
25
|
+
...(0, devkit_1.names)(options.name),
|
|
24
26
|
tmpl: '',
|
|
25
27
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
26
28
|
rootTsConfigPath,
|
|
@@ -30,6 +32,7 @@ function createApplicationFiles(tree, options) {
|
|
|
30
32
|
const rootOffset = (0, devkit_1.offsetFromRoot)(options.appProjectRoot);
|
|
31
33
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/app-webpack'), options.appProjectRoot, {
|
|
32
34
|
...options,
|
|
35
|
+
...(0, devkit_1.names)(options.name),
|
|
33
36
|
tmpl: '',
|
|
34
37
|
offsetFromRoot: rootOffset,
|
|
35
38
|
rootTsConfigPath,
|
|
@@ -150,19 +153,17 @@ async function setupBundler(tree, options) {
|
|
|
150
153
|
}
|
|
151
154
|
}
|
|
152
155
|
async function addProject(tree, options) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
packageJson.nx.tags = options.parsedTags;
|
|
165
|
-
}
|
|
156
|
+
if (options.isUsingTsSolutionConfig) {
|
|
157
|
+
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
|
|
158
|
+
name: (0, get_import_path_1.getImportPath)(tree, options.name),
|
|
159
|
+
version: '0.0.1',
|
|
160
|
+
private: true,
|
|
161
|
+
nx: options.parsedTags?.length
|
|
162
|
+
? {
|
|
163
|
+
tags: options.parsedTags,
|
|
164
|
+
}
|
|
165
|
+
: undefined,
|
|
166
|
+
});
|
|
166
167
|
}
|
|
167
168
|
else {
|
|
168
169
|
(0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
|
|
@@ -173,9 +174,6 @@ async function addProject(tree, options) {
|
|
|
173
174
|
targets: {},
|
|
174
175
|
});
|
|
175
176
|
}
|
|
176
|
-
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
177
|
-
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
|
|
178
|
-
}
|
|
179
177
|
}
|
|
180
178
|
function setDefaults(tree, options) {
|
|
181
179
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
@@ -198,7 +196,7 @@ async function applicationGenerator(host, schema) {
|
|
|
198
196
|
async function applicationGeneratorInternal(host, schema) {
|
|
199
197
|
const options = await normalizeOptions(host, schema);
|
|
200
198
|
if (options.isUsingTsSolutionConfig) {
|
|
201
|
-
|
|
199
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
|
|
202
200
|
}
|
|
203
201
|
const tasks = [];
|
|
204
202
|
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
@@ -312,15 +310,17 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
312
310
|
}
|
|
313
311
|
if (options.e2eTestRunner === 'cypress') {
|
|
314
312
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_2.nxVersion);
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
313
|
+
if (options.isUsingTsSolutionConfig) {
|
|
314
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
|
|
315
|
+
name: options.e2eProjectName,
|
|
316
|
+
version: '0.0.1',
|
|
317
|
+
private: true,
|
|
318
|
+
nx: {
|
|
319
|
+
projectType: 'application',
|
|
320
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
321
|
+
implicitDependencies: [options.projectName],
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
324
|
}
|
|
325
325
|
else {
|
|
326
326
|
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
@@ -332,9 +332,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
332
332
|
implicitDependencies: [options.projectName],
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
|
-
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
336
|
-
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
|
|
337
|
-
}
|
|
338
335
|
const cypressTask = await configurationGenerator(host, {
|
|
339
336
|
...options,
|
|
340
337
|
project: options.e2eProjectName,
|
|
@@ -370,15 +367,17 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
370
367
|
}
|
|
371
368
|
else if (options.e2eTestRunner === 'playwright') {
|
|
372
369
|
const { configurationGenerator: playwrightConfigGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_2.nxVersion);
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
370
|
+
if (options.isUsingTsSolutionConfig) {
|
|
371
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
|
|
372
|
+
name: options.e2eProjectName,
|
|
373
|
+
version: '0.0.1',
|
|
374
|
+
private: true,
|
|
375
|
+
nx: {
|
|
376
|
+
projectType: 'application',
|
|
377
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
378
|
+
implicitDependencies: [options.projectName],
|
|
379
|
+
},
|
|
380
|
+
});
|
|
382
381
|
}
|
|
383
382
|
else {
|
|
384
383
|
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
@@ -390,9 +389,6 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
390
389
|
implicitDependencies: [options.projectName],
|
|
391
390
|
});
|
|
392
391
|
}
|
|
393
|
-
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
394
|
-
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
|
|
395
|
-
}
|
|
396
392
|
const playwrightTask = await playwrightConfigGenerator(host, {
|
|
397
393
|
project: options.e2eProjectName,
|
|
398
394
|
skipFormat: true,
|
|
@@ -466,8 +462,8 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
466
462
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
467
463
|
}
|
|
468
464
|
async function normalizeOptions(host, options) {
|
|
469
|
-
await (0, project_name_and_root_utils_1.
|
|
470
|
-
const { projectName, projectRoot: appProjectRoot
|
|
465
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
|
466
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
471
467
|
name: options.name,
|
|
472
468
|
projectType: 'application',
|
|
473
469
|
directory: options.directory,
|
|
@@ -476,10 +472,9 @@ async function normalizeOptions(host, options) {
|
|
|
476
472
|
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
477
473
|
nxJson.useInferencePlugins !== false;
|
|
478
474
|
options.addPlugin ??= addPluginDefault;
|
|
479
|
-
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
480
|
-
const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
|
|
481
475
|
const e2eProjectName = `${appProjectName}-e2e`;
|
|
482
476
|
const e2eProjectRoot = `${appProjectRoot}-e2e`;
|
|
477
|
+
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
483
478
|
const npmScope = (0, get_npm_scope_1.getNpmScope)(host);
|
|
484
479
|
const parsedTags = options.tags
|
|
485
480
|
? options.tags.split(',').map((s) => s.trim())
|
|
@@ -491,18 +486,18 @@ async function normalizeOptions(host, options) {
|
|
|
491
486
|
return {
|
|
492
487
|
...options,
|
|
493
488
|
prefix: options.prefix ?? npmScope ?? 'app',
|
|
489
|
+
name: (0, devkit_1.names)(options.name).fileName,
|
|
494
490
|
compiler: options.compiler ?? 'babel',
|
|
495
491
|
bundler: options.bundler ?? 'webpack',
|
|
496
|
-
projectName:
|
|
497
|
-
|
|
492
|
+
projectName: isUsingTsSolutionConfig
|
|
493
|
+
? (0, get_import_path_1.getImportPath)(host, appProjectName)
|
|
494
|
+
: appProjectName,
|
|
498
495
|
strict: options.strict ?? true,
|
|
499
496
|
appProjectRoot,
|
|
500
497
|
e2eProjectRoot,
|
|
501
498
|
e2eProjectName,
|
|
502
499
|
parsedTags,
|
|
503
|
-
names: (0, devkit_1.names)(projectName),
|
|
504
500
|
isUsingTsSolutionConfig,
|
|
505
|
-
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
506
501
|
};
|
|
507
502
|
}
|
|
508
503
|
exports.default = applicationGenerator;
|
|
@@ -104,10 +104,6 @@
|
|
|
104
104
|
"type": "boolean",
|
|
105
105
|
"description": "Creates an application with strict mode and strict type checking.",
|
|
106
106
|
"default": true
|
|
107
|
-
},
|
|
108
|
-
"useProjectJson": {
|
|
109
|
-
"type": "boolean",
|
|
110
|
-
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
111
107
|
}
|
|
112
108
|
},
|
|
113
109
|
"required": ["directory"],
|