@nx/web 16.8.0-beta.1 → 16.8.0-beta.3
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/generators.json +1 -1
- package/package.json +5 -5
- package/src/generators/application/application.d.ts +1 -0
- package/src/generators/application/application.js +55 -30
- package/src/generators/application/schema.d.ts +2 -0
- package/src/generators/application/schema.json +6 -1
- package/src/generators/application/files/app-webpack/.babelrc__tmpl__ +0 -5
package/generators.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"hidden": true
|
|
11
11
|
},
|
|
12
12
|
"application": {
|
|
13
|
-
"factory": "./src/generators/application/application#
|
|
13
|
+
"factory": "./src/generators/application/application#applicationGeneratorInternal",
|
|
14
14
|
"schema": "./src/generators/application/schema.json",
|
|
15
15
|
"aliases": ["app"],
|
|
16
16
|
"x-type": "application",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/web",
|
|
3
|
-
"version": "16.8.0-beta.
|
|
3
|
+
"version": "16.8.0-beta.3",
|
|
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, 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": {
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"migrations": "./migrations.json"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@nrwl/web": "16.8.0-beta.
|
|
34
|
-
"@nx/devkit": "16.8.0-beta.
|
|
35
|
-
"@nx/js": "16.8.0-beta.
|
|
33
|
+
"@nrwl/web": "16.8.0-beta.3",
|
|
34
|
+
"@nx/devkit": "16.8.0-beta.3",
|
|
35
|
+
"@nx/js": "16.8.0-beta.3",
|
|
36
36
|
"chalk": "^4.1.0",
|
|
37
37
|
"chokidar": "^3.5.1",
|
|
38
38
|
"detect-port": "^1.5.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"type": "commonjs",
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "dcd48165a485bc8db57a1fb02b96a0772de3b7e9"
|
|
48
48
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
3
|
export declare function applicationGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function applicationGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
5
|
export default applicationGenerator;
|
|
5
6
|
export declare const applicationSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applicationSchematic = exports.applicationGenerator = void 0;
|
|
3
|
+
exports.applicationSchematic = exports.applicationGeneratorInternal = exports.applicationGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const path_1 = require("path");
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const
|
|
6
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
8
7
|
const js_1 = require("@nx/js");
|
|
8
|
+
const versions_1 = require("@nx/js/src/utils/versions");
|
|
9
|
+
const path_1 = require("path");
|
|
9
10
|
const versions_2 = require("../../utils/versions");
|
|
10
11
|
const init_1 = require("../init/init");
|
|
11
12
|
function createApplicationFiles(tree, options) {
|
|
@@ -105,7 +106,13 @@ function setDefaults(tree, options) {
|
|
|
105
106
|
}
|
|
106
107
|
function applicationGenerator(host, schema) {
|
|
107
108
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
|
|
109
|
+
return yield applicationGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
exports.applicationGenerator = applicationGenerator;
|
|
113
|
+
function applicationGeneratorInternal(host, schema) {
|
|
114
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const options = yield normalizeOptions(host, schema);
|
|
109
116
|
const tasks = [];
|
|
110
117
|
const webTask = yield (0, init_1.webInitGenerator)(host, Object.assign(Object.assign({}, options), { skipFormat: true }));
|
|
111
118
|
tasks.push(webTask);
|
|
@@ -160,7 +167,9 @@ function applicationGenerator(host, schema) {
|
|
|
160
167
|
}
|
|
161
168
|
if (options.e2eTestRunner === 'cypress') {
|
|
162
169
|
const { cypressProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_2.nxVersion);
|
|
163
|
-
const cypressTask = yield cypressProjectGenerator(host, Object.assign(Object.assign({}, options), { name:
|
|
170
|
+
const cypressTask = yield cypressProjectGenerator(host, Object.assign(Object.assign({}, options), { name: options.e2eProjectName, directory: options.e2eProjectRoot,
|
|
171
|
+
// the name and root are already normalized, instruct the generator to use them as is
|
|
172
|
+
projectNameAndRootFormat: 'as-provided', project: options.projectName, skipFormat: true }));
|
|
164
173
|
tasks.push(cypressTask);
|
|
165
174
|
}
|
|
166
175
|
else if (options.e2eTestRunner === 'playwright') {
|
|
@@ -197,9 +206,22 @@ function applicationGenerator(host, schema) {
|
|
|
197
206
|
tasks.push(jestTask);
|
|
198
207
|
}
|
|
199
208
|
if (options.compiler === 'swc') {
|
|
209
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, '.swcrc'), {
|
|
210
|
+
jsc: {
|
|
211
|
+
parser: {
|
|
212
|
+
syntax: 'typescript',
|
|
213
|
+
},
|
|
214
|
+
target: 'es2016',
|
|
215
|
+
},
|
|
216
|
+
});
|
|
200
217
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, { '@swc/core': versions_1.swcCoreVersion, 'swc-loader': versions_2.swcLoaderVersion });
|
|
201
218
|
tasks.push(installTask);
|
|
202
219
|
}
|
|
220
|
+
else {
|
|
221
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, '.babelrc'), {
|
|
222
|
+
presets: ['@nx/js/babel'],
|
|
223
|
+
});
|
|
224
|
+
}
|
|
203
225
|
setDefaults(host, options);
|
|
204
226
|
if (!schema.skipFormat) {
|
|
205
227
|
yield (0, devkit_1.formatFiles)(host);
|
|
@@ -207,33 +229,36 @@ function applicationGenerator(host, schema) {
|
|
|
207
229
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
208
230
|
});
|
|
209
231
|
}
|
|
210
|
-
exports.
|
|
232
|
+
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
211
233
|
function normalizeOptions(host, options) {
|
|
212
234
|
var _a, _b, _c, _d;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
236
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
237
|
+
name: options.name,
|
|
238
|
+
projectType: 'application',
|
|
239
|
+
directory: options.directory,
|
|
240
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
241
|
+
callingGenerator: '@nx/web:application',
|
|
242
|
+
});
|
|
243
|
+
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
244
|
+
const e2eProjectName = `${appProjectName}-e2e`;
|
|
245
|
+
const e2eProjectRoot = `${appProjectRoot}-e2e`;
|
|
246
|
+
const { npmScope } = (0, devkit_1.getWorkspaceLayout)(host);
|
|
247
|
+
const parsedTags = options.tags
|
|
248
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
249
|
+
: [];
|
|
250
|
+
if (options.bundler === 'vite' && !options.unitTestRunner) {
|
|
251
|
+
options.unitTestRunner = 'vitest';
|
|
252
|
+
}
|
|
253
|
+
options.style = options.style || 'css';
|
|
254
|
+
options.linter = options.linter || 'eslint';
|
|
255
|
+
options.unitTestRunner = options.unitTestRunner || 'jest';
|
|
256
|
+
options.e2eTestRunner = options.e2eTestRunner || 'cypress';
|
|
257
|
+
return Object.assign(Object.assign({}, options), { prefix: (_b = (_a = options.prefix) !== null && _a !== void 0 ? _a : npmScope) !== null && _b !== void 0 ? _b : 'app', name: (0, devkit_1.names)(options.name).fileName, compiler: (_c = options.compiler) !== null && _c !== void 0 ? _c : 'babel', bundler: (_d = options.bundler) !== null && _d !== void 0 ? _d : 'webpack', projectName: appProjectName, appProjectRoot,
|
|
258
|
+
e2eProjectRoot,
|
|
259
|
+
e2eProjectName,
|
|
260
|
+
parsedTags });
|
|
261
|
+
});
|
|
237
262
|
}
|
|
238
263
|
exports.default = applicationGenerator;
|
|
239
264
|
exports.applicationSchematic = (0, devkit_1.convertNxGenerator)(applicationGenerator);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
1
2
|
import type { Linter } from '@nx/linter';
|
|
2
3
|
|
|
3
4
|
export interface Schema {
|
|
@@ -8,6 +9,7 @@ export interface Schema {
|
|
|
8
9
|
compiler?: 'babel' | 'swc';
|
|
9
10
|
skipFormat?: boolean;
|
|
10
11
|
directory?: string;
|
|
12
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
11
13
|
tags?: string;
|
|
12
14
|
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
13
15
|
inSourceTests?: boolean;
|
|
@@ -14,12 +14,17 @@
|
|
|
14
14
|
"index": 0
|
|
15
15
|
},
|
|
16
16
|
"x-prompt": "What name would you like to use for the application?",
|
|
17
|
-
"pattern": "^[a-zA-Z]
|
|
17
|
+
"pattern": "^[a-zA-Z][^:]*$"
|
|
18
18
|
},
|
|
19
19
|
"directory": {
|
|
20
20
|
"description": "The directory of the new application.",
|
|
21
21
|
"type": "string"
|
|
22
22
|
},
|
|
23
|
+
"projectNameAndRootFormat": {
|
|
24
|
+
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
25
|
+
"type": "string",
|
|
26
|
+
"enum": ["as-provided", "derived"]
|
|
27
|
+
},
|
|
23
28
|
"style": {
|
|
24
29
|
"description": "The file extension to be used for style files.",
|
|
25
30
|
"type": "string",
|