@nx/node 16.8.0-beta.4 → 16.8.0-beta.5
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 +8 -8
- package/src/generators/application/application.js +172 -99
- package/src/generators/e2e-project/e2e-project.js +88 -73
- package/src/generators/init/init.js +20 -17
- package/src/generators/library/library.js +66 -51
- package/src/generators/setup-docker/setup-docker.js +17 -17
- package/src/migrations/update-13-0-0/remove-deprecated-options-13-0-0.js +20 -24
- package/src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0.js +10 -14
- package/src/migrations/update-13-8-5/rename-build-to-webpack.js +6 -9
- package/src/migrations/update-13-8-5/rename-execute-to-node.js +6 -9
- package/src/migrations/update-13-8-5/update-package-to-tsc.js +27 -30
- package/src/migrations/update-14-7-6/update-webpack-executor.js +8 -11
- package/src/migrations/update-16-0-0/update-webpack-executor.js +11 -14
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-3-1/update-webpack-executor.js +11 -14
- package/src/migrations/update-16-4-0/replace-node-executor.js +8 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/node",
|
|
3
|
-
"version": "16.8.0-beta.
|
|
3
|
+
"version": "16.8.0-beta.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Node Plugin for Nx contains generators to manage Node applications within an Nx workspace.",
|
|
6
6
|
"repository": {
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
"migrations": "./migrations.json"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@nrwl/node": "16.8.0-beta.
|
|
34
|
-
"@nx/devkit": "16.8.0-beta.
|
|
35
|
-
"@nx/jest": "16.8.0-beta.
|
|
36
|
-
"@nx/js": "16.8.0-beta.
|
|
37
|
-
"@nx/linter": "16.8.0-beta.
|
|
38
|
-
"@nx/workspace": "16.8.0-beta.
|
|
33
|
+
"@nrwl/node": "16.8.0-beta.5",
|
|
34
|
+
"@nx/devkit": "16.8.0-beta.5",
|
|
35
|
+
"@nx/jest": "16.8.0-beta.5",
|
|
36
|
+
"@nx/js": "16.8.0-beta.5",
|
|
37
|
+
"@nx/linter": "16.8.0-beta.5",
|
|
38
|
+
"@nx/workspace": "16.8.0-beta.5",
|
|
39
39
|
"tslib": "^2.3.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"type": "commonjs",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "ad2d1e8a55b2d1b358bb5e7483343d9757ff2c53"
|
|
46
46
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.applicationSchematic = exports.applicationGeneratorInternal = exports.applicationGenerator = exports.addLintingToApplication = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
7
6
|
const jest_1 = require("@nx/jest");
|
|
@@ -31,7 +30,9 @@ function getWebpackBuildConfig(project, options) {
|
|
|
31
30
|
},
|
|
32
31
|
configurations: {
|
|
33
32
|
development: {},
|
|
34
|
-
production:
|
|
33
|
+
production: {
|
|
34
|
+
...(options.docker && { generateLockfile: true }),
|
|
35
|
+
},
|
|
35
36
|
},
|
|
36
37
|
};
|
|
37
38
|
}
|
|
@@ -58,11 +59,14 @@ function getEsBuildConfig(project, options) {
|
|
|
58
59
|
},
|
|
59
60
|
configurations: {
|
|
60
61
|
development: {},
|
|
61
|
-
production:
|
|
62
|
+
production: {
|
|
63
|
+
...(options.docker && { generateLockfile: true }),
|
|
64
|
+
esbuildOptions: {
|
|
62
65
|
sourcemap: false,
|
|
63
66
|
// Generate CJS files as .js so imports can be './foo' rather than './foo.cjs'.
|
|
64
67
|
outExtension: { '.js': '.js' },
|
|
65
|
-
}
|
|
68
|
+
},
|
|
69
|
+
},
|
|
66
70
|
},
|
|
67
71
|
};
|
|
68
72
|
}
|
|
@@ -99,12 +103,26 @@ function addProject(tree, options) {
|
|
|
99
103
|
(0, devkit_1.addProjectConfiguration)(tree, options.name, project, options.standaloneConfig);
|
|
100
104
|
}
|
|
101
105
|
function addAppFiles(tree, options) {
|
|
102
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/common'), options.appProjectRoot,
|
|
106
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/common'), options.appProjectRoot, {
|
|
107
|
+
...options,
|
|
108
|
+
tmpl: '',
|
|
109
|
+
name: options.name,
|
|
110
|
+
root: options.appProjectRoot,
|
|
111
|
+
offset: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
112
|
+
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot),
|
|
113
|
+
});
|
|
103
114
|
if (options.bundler !== 'webpack') {
|
|
104
115
|
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'));
|
|
105
116
|
}
|
|
106
117
|
if (options.framework && options.framework !== 'none') {
|
|
107
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, `./files/${options.framework}`), options.appProjectRoot,
|
|
118
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, `./files/${options.framework}`), options.appProjectRoot, {
|
|
119
|
+
...options,
|
|
120
|
+
tmpl: '',
|
|
121
|
+
name: options.name,
|
|
122
|
+
root: options.appProjectRoot,
|
|
123
|
+
offset: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
124
|
+
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot),
|
|
125
|
+
});
|
|
108
126
|
}
|
|
109
127
|
if (options.js) {
|
|
110
128
|
(0, devkit_1.toJS)(tree);
|
|
@@ -117,7 +135,10 @@ function addProxy(tree, options) {
|
|
|
117
135
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.frontendProject);
|
|
118
136
|
if (projectConfig.targets && projectConfig.targets.serve) {
|
|
119
137
|
const pathToProxyFile = `${projectConfig.root}/proxy.conf.json`;
|
|
120
|
-
projectConfig.targets.serve.options =
|
|
138
|
+
projectConfig.targets.serve.options = {
|
|
139
|
+
...projectConfig.targets.serve.options,
|
|
140
|
+
proxyConfig: pathToProxyFile,
|
|
141
|
+
};
|
|
121
142
|
if (!tree.exists(pathToProxyFile)) {
|
|
122
143
|
tree.write(pathToProxyFile, JSON.stringify({
|
|
123
144
|
'/api': {
|
|
@@ -129,33 +150,34 @@ function addProxy(tree, options) {
|
|
|
129
150
|
else {
|
|
130
151
|
//add new entry to existing config
|
|
131
152
|
const proxyFileContent = tree.read(pathToProxyFile).toString();
|
|
132
|
-
const proxyModified =
|
|
153
|
+
const proxyModified = {
|
|
154
|
+
...JSON.parse(proxyFileContent),
|
|
155
|
+
[`/${options.name}-api`]: {
|
|
133
156
|
target: `http://localhost:${options.port}`,
|
|
134
157
|
secure: false,
|
|
135
|
-
}
|
|
158
|
+
},
|
|
159
|
+
};
|
|
136
160
|
tree.write(pathToProxyFile, JSON.stringify(proxyModified, null, 2));
|
|
137
161
|
}
|
|
138
162
|
(0, devkit_1.updateProjectConfiguration)(tree, options.frontendProject, projectConfig);
|
|
139
163
|
}
|
|
140
164
|
}
|
|
141
|
-
function addLintingToApplication(tree, options) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
rootProject: options.rootProject,
|
|
156
|
-
});
|
|
157
|
-
return lintTask;
|
|
165
|
+
async function addLintingToApplication(tree, options) {
|
|
166
|
+
const lintTask = await (0, linter_1.lintProjectGenerator)(tree, {
|
|
167
|
+
linter: options.linter,
|
|
168
|
+
project: options.name,
|
|
169
|
+
tsConfigPaths: [
|
|
170
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
171
|
+
],
|
|
172
|
+
eslintFilePatterns: [
|
|
173
|
+
(0, lint_project_1.mapLintPattern)(options.appProjectRoot, options.js ? 'js' : 'ts', options.rootProject),
|
|
174
|
+
],
|
|
175
|
+
unitTestRunner: options.unitTestRunner,
|
|
176
|
+
skipFormat: true,
|
|
177
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
178
|
+
rootProject: options.rootProject,
|
|
158
179
|
});
|
|
180
|
+
return lintTask;
|
|
159
181
|
}
|
|
160
182
|
exports.addLintingToApplication = addLintingToApplication;
|
|
161
183
|
function addProjectDependencies(tree, options) {
|
|
@@ -191,95 +213,146 @@ function addProjectDependencies(tree, options) {
|
|
|
191
213
|
},
|
|
192
214
|
fastify: {},
|
|
193
215
|
};
|
|
194
|
-
return (0, devkit_1.addDependenciesToPackageJson)(tree,
|
|
216
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
217
|
+
...frameworkDependencies[options.framework],
|
|
218
|
+
}, {
|
|
219
|
+
...frameworkDevDependencies[options.framework],
|
|
220
|
+
...bundlers[options.bundler],
|
|
221
|
+
});
|
|
195
222
|
}
|
|
196
223
|
function updateTsConfigOptions(tree, options) {
|
|
197
224
|
(0, devkit_1.updateJson)(tree, `${options.appProjectRoot}/tsconfig.json`, (json) => {
|
|
198
225
|
if (options.rootProject) {
|
|
199
|
-
return
|
|
226
|
+
return {
|
|
227
|
+
compilerOptions: {
|
|
228
|
+
...js_1.tsConfigBaseOptions,
|
|
229
|
+
...json.compilerOptions,
|
|
230
|
+
esModuleInterop: true,
|
|
231
|
+
},
|
|
232
|
+
...json,
|
|
233
|
+
extends: undefined,
|
|
234
|
+
exclude: ['node_modules', 'tmp'],
|
|
235
|
+
};
|
|
200
236
|
}
|
|
201
237
|
else {
|
|
202
|
-
return
|
|
238
|
+
return {
|
|
239
|
+
...json,
|
|
240
|
+
compilerOptions: {
|
|
241
|
+
...json.compilerOptions,
|
|
242
|
+
esModuleInterop: true,
|
|
243
|
+
},
|
|
244
|
+
};
|
|
203
245
|
}
|
|
204
246
|
});
|
|
205
247
|
}
|
|
206
|
-
function applicationGenerator(tree, schema) {
|
|
207
|
-
return
|
|
208
|
-
|
|
248
|
+
async function applicationGenerator(tree, schema) {
|
|
249
|
+
return await applicationGeneratorInternal(tree, {
|
|
250
|
+
projectNameAndRootFormat: 'derived',
|
|
251
|
+
...schema,
|
|
209
252
|
});
|
|
210
253
|
}
|
|
211
254
|
exports.applicationGenerator = applicationGenerator;
|
|
212
|
-
function applicationGeneratorInternal(tree, schema) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const installTask = addProjectDependencies(tree, options);
|
|
223
|
-
tasks.push(installTask);
|
|
224
|
-
addAppFiles(tree, options);
|
|
225
|
-
addProject(tree, options);
|
|
226
|
-
updateTsConfigOptions(tree, options);
|
|
227
|
-
if (options.linter === linter_1.Linter.EsLint) {
|
|
228
|
-
const lintTask = yield addLintingToApplication(tree, options);
|
|
229
|
-
tasks.push(lintTask);
|
|
230
|
-
}
|
|
231
|
-
if (options.unitTestRunner === 'jest') {
|
|
232
|
-
const jestTask = yield (0, jest_1.configurationGenerator)(tree, Object.assign(Object.assign({}, options), { project: options.name, setupFile: 'none', skipSerializers: true, supportTsx: options.js, testEnvironment: 'node', compiler: options.swcJest ? 'swc' : 'tsc', skipFormat: true }));
|
|
233
|
-
tasks.push(jestTask);
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
// No need for default spec file if unit testing is not setup.
|
|
237
|
-
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/app/app.spec.ts'));
|
|
238
|
-
}
|
|
239
|
-
if (options.e2eTestRunner === 'jest') {
|
|
240
|
-
const e2eTask = yield (0, e2e_project_1.e2eProjectGenerator)(tree, Object.assign(Object.assign({}, options), { projectType: options.framework === 'none' ? 'cli' : 'server', name: options.rootProject ? 'e2e' : `${options.name}-e2e`, directory: options.rootProject ? 'e2e' : `${options.appProjectRoot}-e2e`, projectNameAndRootFormat: 'as-provided', project: options.name, port: options.port, isNest: options.isNest, skipFormat: true }));
|
|
241
|
-
tasks.push(e2eTask);
|
|
242
|
-
}
|
|
243
|
-
if (options.js) {
|
|
244
|
-
(0, devkit_1.updateTsConfigsToJs)(tree, { projectRoot: options.appProjectRoot });
|
|
245
|
-
}
|
|
246
|
-
if (options.frontendProject) {
|
|
247
|
-
addProxy(tree, options);
|
|
248
|
-
}
|
|
249
|
-
if (options.docker) {
|
|
250
|
-
const dockerTask = yield (0, setup_docker_1.setupDockerGenerator)(tree, Object.assign(Object.assign({}, options), { project: options.name, skipFormat: true }));
|
|
251
|
-
tasks.push(dockerTask);
|
|
252
|
-
}
|
|
253
|
-
if (!options.skipFormat) {
|
|
254
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
255
|
-
}
|
|
256
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
255
|
+
async function applicationGeneratorInternal(tree, schema) {
|
|
256
|
+
const options = await normalizeOptions(tree, schema);
|
|
257
|
+
const tasks = [];
|
|
258
|
+
if (options.framework === 'nest') {
|
|
259
|
+
const { applicationGenerator } = (0, devkit_1.ensurePackage)('@nx/nest', versions_2.nxVersion);
|
|
260
|
+
return await applicationGenerator(tree, { ...options, skipFormat: true });
|
|
261
|
+
}
|
|
262
|
+
const initTask = await (0, init_1.initGenerator)(tree, {
|
|
263
|
+
...schema,
|
|
264
|
+
skipFormat: true,
|
|
257
265
|
});
|
|
266
|
+
tasks.push(initTask);
|
|
267
|
+
const installTask = addProjectDependencies(tree, options);
|
|
268
|
+
tasks.push(installTask);
|
|
269
|
+
addAppFiles(tree, options);
|
|
270
|
+
addProject(tree, options);
|
|
271
|
+
updateTsConfigOptions(tree, options);
|
|
272
|
+
if (options.linter === linter_1.Linter.EsLint) {
|
|
273
|
+
const lintTask = await addLintingToApplication(tree, options);
|
|
274
|
+
tasks.push(lintTask);
|
|
275
|
+
}
|
|
276
|
+
if (options.unitTestRunner === 'jest') {
|
|
277
|
+
const jestTask = await (0, jest_1.configurationGenerator)(tree, {
|
|
278
|
+
...options,
|
|
279
|
+
project: options.name,
|
|
280
|
+
setupFile: 'none',
|
|
281
|
+
skipSerializers: true,
|
|
282
|
+
supportTsx: options.js,
|
|
283
|
+
testEnvironment: 'node',
|
|
284
|
+
compiler: options.swcJest ? 'swc' : 'tsc',
|
|
285
|
+
skipFormat: true,
|
|
286
|
+
});
|
|
287
|
+
tasks.push(jestTask);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
// No need for default spec file if unit testing is not setup.
|
|
291
|
+
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/app/app.spec.ts'));
|
|
292
|
+
}
|
|
293
|
+
if (options.e2eTestRunner === 'jest') {
|
|
294
|
+
const e2eTask = await (0, e2e_project_1.e2eProjectGenerator)(tree, {
|
|
295
|
+
...options,
|
|
296
|
+
projectType: options.framework === 'none' ? 'cli' : 'server',
|
|
297
|
+
name: options.rootProject ? 'e2e' : `${options.name}-e2e`,
|
|
298
|
+
directory: options.rootProject ? 'e2e' : `${options.appProjectRoot}-e2e`,
|
|
299
|
+
projectNameAndRootFormat: 'as-provided',
|
|
300
|
+
project: options.name,
|
|
301
|
+
port: options.port,
|
|
302
|
+
isNest: options.isNest,
|
|
303
|
+
skipFormat: true,
|
|
304
|
+
});
|
|
305
|
+
tasks.push(e2eTask);
|
|
306
|
+
}
|
|
307
|
+
if (options.js) {
|
|
308
|
+
(0, devkit_1.updateTsConfigsToJs)(tree, { projectRoot: options.appProjectRoot });
|
|
309
|
+
}
|
|
310
|
+
if (options.frontendProject) {
|
|
311
|
+
addProxy(tree, options);
|
|
312
|
+
}
|
|
313
|
+
if (options.docker) {
|
|
314
|
+
const dockerTask = await (0, setup_docker_1.setupDockerGenerator)(tree, {
|
|
315
|
+
...options,
|
|
316
|
+
project: options.name,
|
|
317
|
+
skipFormat: true,
|
|
318
|
+
});
|
|
319
|
+
tasks.push(dockerTask);
|
|
320
|
+
}
|
|
321
|
+
if (!options.skipFormat) {
|
|
322
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
323
|
+
}
|
|
324
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
258
325
|
}
|
|
259
326
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
260
|
-
function normalizeOptions(host, options) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
rootProject: options.rootProject,
|
|
269
|
-
callingGenerator: '@nx/node:application',
|
|
270
|
-
});
|
|
271
|
-
options.rootProject = appProjectRoot === '.';
|
|
272
|
-
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
273
|
-
options.bundler = (_a = options.bundler) !== null && _a !== void 0 ? _a : 'esbuild';
|
|
274
|
-
options.e2eTestRunner = (_b = options.e2eTestRunner) !== null && _b !== void 0 ? _b : 'jest';
|
|
275
|
-
const parsedTags = options.tags
|
|
276
|
-
? options.tags.split(',').map((s) => s.trim())
|
|
277
|
-
: [];
|
|
278
|
-
return Object.assign(Object.assign({}, options), { name: appProjectName, frontendProject: options.frontendProject
|
|
279
|
-
? (0, devkit_1.names)(options.frontendProject).fileName
|
|
280
|
-
: undefined, appProjectRoot,
|
|
281
|
-
parsedTags, linter: (_c = options.linter) !== null && _c !== void 0 ? _c : linter_1.Linter.EsLint, unitTestRunner: (_d = options.unitTestRunner) !== null && _d !== void 0 ? _d : 'jest', rootProject: (_e = options.rootProject) !== null && _e !== void 0 ? _e : false, port: (_f = options.port) !== null && _f !== void 0 ? _f : 3000 });
|
|
327
|
+
async function normalizeOptions(host, options) {
|
|
328
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
329
|
+
name: options.name,
|
|
330
|
+
projectType: 'application',
|
|
331
|
+
directory: options.directory,
|
|
332
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
333
|
+
rootProject: options.rootProject,
|
|
334
|
+
callingGenerator: '@nx/node:application',
|
|
282
335
|
});
|
|
336
|
+
options.rootProject = appProjectRoot === '.';
|
|
337
|
+
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
338
|
+
options.bundler = options.bundler ?? 'esbuild';
|
|
339
|
+
options.e2eTestRunner = options.e2eTestRunner ?? 'jest';
|
|
340
|
+
const parsedTags = options.tags
|
|
341
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
342
|
+
: [];
|
|
343
|
+
return {
|
|
344
|
+
...options,
|
|
345
|
+
name: appProjectName,
|
|
346
|
+
frontendProject: options.frontendProject
|
|
347
|
+
? (0, devkit_1.names)(options.frontendProject).fileName
|
|
348
|
+
: undefined,
|
|
349
|
+
appProjectRoot,
|
|
350
|
+
parsedTags,
|
|
351
|
+
linter: options.linter ?? linter_1.Linter.EsLint,
|
|
352
|
+
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
353
|
+
rootProject: options.rootProject ?? false,
|
|
354
|
+
port: options.port ?? 3000,
|
|
355
|
+
};
|
|
283
356
|
}
|
|
284
357
|
exports.default = applicationGenerator;
|
|
285
358
|
exports.applicationSchematic = (0, devkit_1.convertNxGenerator)(applicationGenerator);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.e2eProjectSchematic = exports.e2eProjectGeneratorInternal = exports.e2eProjectGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
7
6
|
const linter_1 = require("@nx/linter");
|
|
@@ -9,90 +8,106 @@ const global_eslint_config_1 = require("@nx/linter/src/generators/init/global-es
|
|
|
9
8
|
const path = require("path");
|
|
10
9
|
const versions_1 = require("../../utils/versions");
|
|
11
10
|
const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
|
|
12
|
-
function e2eProjectGenerator(host, options) {
|
|
13
|
-
return
|
|
14
|
-
|
|
11
|
+
async function e2eProjectGenerator(host, options) {
|
|
12
|
+
return await e2eProjectGeneratorInternal(host, {
|
|
13
|
+
projectNameAndRootFormat: 'derived',
|
|
14
|
+
...options,
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
exports.e2eProjectGenerator = e2eProjectGenerator;
|
|
18
|
-
function e2eProjectGeneratorInternal(host, _options) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
jestConfig: `${options.e2eProjectRoot}/jest.config.ts`,
|
|
33
|
-
passWithNoTests: true,
|
|
34
|
-
},
|
|
18
|
+
async function e2eProjectGeneratorInternal(host, _options) {
|
|
19
|
+
const tasks = [];
|
|
20
|
+
const options = await normalizeOptions(host, _options);
|
|
21
|
+
const appProject = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
22
|
+
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
23
|
+
root: options.e2eProjectRoot,
|
|
24
|
+
implicitDependencies: [options.project],
|
|
25
|
+
targets: {
|
|
26
|
+
e2e: {
|
|
27
|
+
executor: '@nx/jest:jest',
|
|
28
|
+
outputs: ['{workspaceRoot}/coverage/{e2eProjectRoot}'],
|
|
29
|
+
options: {
|
|
30
|
+
jestConfig: `${options.e2eProjectRoot}/jest.config.ts`,
|
|
31
|
+
passWithNoTests: true,
|
|
35
32
|
},
|
|
36
33
|
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
if (options.projectType === 'server') {
|
|
37
|
+
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/common'), options.e2eProjectRoot, {
|
|
38
|
+
...options,
|
|
39
|
+
...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
|
|
40
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
|
|
41
|
+
tmpl: '',
|
|
37
42
|
});
|
|
38
|
-
if (options.
|
|
39
|
-
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/
|
|
40
|
-
|
|
41
|
-
(0, devkit_1.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
else if (options.projectType === 'cli') {
|
|
45
|
-
const mainFile = (_b = (_a = appProject.targets.build) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.outputPath;
|
|
46
|
-
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/cli'), options.e2eProjectRoot, Object.assign(Object.assign(Object.assign({}, options), (0, devkit_1.names)(options.rootProject ? 'cli' : options.project)), { mainFile, offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot), tmpl: '' }));
|
|
47
|
-
}
|
|
48
|
-
// axios is more than likely used in the application code, so install it as a regular dependency.
|
|
49
|
-
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, { axios: versions_1.axiosVersion }, {});
|
|
50
|
-
tasks.push(installTask);
|
|
51
|
-
if (options.linter === linter_1.Linter.EsLint) {
|
|
52
|
-
const linterTask = yield (0, linter_1.lintProjectGenerator)(host, {
|
|
53
|
-
project: options.e2eProjectName,
|
|
54
|
-
linter: linter_1.Linter.EsLint,
|
|
55
|
-
skipFormat: true,
|
|
56
|
-
tsConfigPaths: [
|
|
57
|
-
(0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'tsconfig.json'),
|
|
58
|
-
],
|
|
59
|
-
eslintFilePatterns: [`${options.e2eProjectRoot}/**/*.{js,ts}`],
|
|
60
|
-
setParserOptionsProject: false,
|
|
61
|
-
skipPackageJson: false,
|
|
62
|
-
rootProject: options.rootProject,
|
|
43
|
+
if (options.isNest) {
|
|
44
|
+
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/nest'), options.e2eProjectRoot, {
|
|
45
|
+
...options,
|
|
46
|
+
...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
|
|
47
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
|
|
48
|
+
tmpl: '',
|
|
63
49
|
});
|
|
64
|
-
tasks.push(linterTask);
|
|
65
|
-
if (options.rootProject && (0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
66
|
-
(0, eslint_file_1.addPluginsToLintConfig)(host, options.e2eProjectRoot, '@nx');
|
|
67
|
-
(0, eslint_file_1.replaceOverridesInLintConfig)(host, options.e2eProjectRoot, [
|
|
68
|
-
global_eslint_config_1.typeScriptOverride,
|
|
69
|
-
global_eslint_config_1.javaScriptOverride,
|
|
70
|
-
]);
|
|
71
|
-
}
|
|
72
50
|
}
|
|
73
|
-
|
|
74
|
-
|
|
51
|
+
}
|
|
52
|
+
else if (options.projectType === 'cli') {
|
|
53
|
+
const mainFile = appProject.targets.build?.options?.outputPath;
|
|
54
|
+
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/cli'), options.e2eProjectRoot, {
|
|
55
|
+
...options,
|
|
56
|
+
...(0, devkit_1.names)(options.rootProject ? 'cli' : options.project),
|
|
57
|
+
mainFile,
|
|
58
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot),
|
|
59
|
+
tmpl: '',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// axios is more than likely used in the application code, so install it as a regular dependency.
|
|
63
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, { axios: versions_1.axiosVersion }, {});
|
|
64
|
+
tasks.push(installTask);
|
|
65
|
+
if (options.linter === linter_1.Linter.EsLint) {
|
|
66
|
+
const linterTask = await (0, linter_1.lintProjectGenerator)(host, {
|
|
67
|
+
project: options.e2eProjectName,
|
|
68
|
+
linter: linter_1.Linter.EsLint,
|
|
69
|
+
skipFormat: true,
|
|
70
|
+
tsConfigPaths: [
|
|
71
|
+
(0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'tsconfig.json'),
|
|
72
|
+
],
|
|
73
|
+
eslintFilePatterns: [`${options.e2eProjectRoot}/**/*.{js,ts}`],
|
|
74
|
+
setParserOptionsProject: false,
|
|
75
|
+
skipPackageJson: false,
|
|
76
|
+
rootProject: options.rootProject,
|
|
77
|
+
});
|
|
78
|
+
tasks.push(linterTask);
|
|
79
|
+
if (options.rootProject && (0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
80
|
+
(0, eslint_file_1.addPluginsToLintConfig)(host, options.e2eProjectRoot, '@nx');
|
|
81
|
+
(0, eslint_file_1.replaceOverridesInLintConfig)(host, options.e2eProjectRoot, [
|
|
82
|
+
global_eslint_config_1.typeScriptOverride,
|
|
83
|
+
global_eslint_config_1.javaScriptOverride,
|
|
84
|
+
]);
|
|
75
85
|
}
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
}
|
|
87
|
+
if (!options.skipFormat) {
|
|
88
|
+
await (0, devkit_1.formatFiles)(host);
|
|
89
|
+
}
|
|
90
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
78
91
|
}
|
|
79
92
|
exports.e2eProjectGeneratorInternal = e2eProjectGeneratorInternal;
|
|
80
|
-
function normalizeOptions(tree, options) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// this is an internal generator, don't save defaults
|
|
91
|
-
callingGenerator: null,
|
|
92
|
-
});
|
|
93
|
-
return Object.assign(Object.assign({}, options), { e2eProjectRoot,
|
|
94
|
-
e2eProjectName, port: (_b = options.port) !== null && _b !== void 0 ? _b : 3000, rootProject: !!options.rootProject });
|
|
93
|
+
async function normalizeOptions(tree, options) {
|
|
94
|
+
const { projectName: e2eProjectName, projectRoot: e2eProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
95
|
+
name: options.name ?? `${options.project}-e2e`,
|
|
96
|
+
projectType: 'library',
|
|
97
|
+
directory: options.rootProject ? 'e2e' : options.directory,
|
|
98
|
+
projectNameAndRootFormat: options.rootProject
|
|
99
|
+
? 'as-provided'
|
|
100
|
+
: options.projectNameAndRootFormat,
|
|
101
|
+
// this is an internal generator, don't save defaults
|
|
102
|
+
callingGenerator: null,
|
|
95
103
|
});
|
|
104
|
+
return {
|
|
105
|
+
...options,
|
|
106
|
+
e2eProjectRoot,
|
|
107
|
+
e2eProjectName,
|
|
108
|
+
port: options.port ?? 3000,
|
|
109
|
+
rootProject: !!options.rootProject,
|
|
110
|
+
};
|
|
96
111
|
}
|
|
97
112
|
exports.default = e2eProjectGenerator;
|
|
98
113
|
exports.e2eProjectSchematic = (0, devkit_1.convertNxGenerator)(e2eProjectGenerator);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initSchematic = exports.initGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const jest_1 = require("@nx/jest");
|
|
7
6
|
const js_1 = require("@nx/js");
|
|
@@ -13,23 +12,27 @@ function updateDependencies(tree) {
|
|
|
13
12
|
}, { '@nx/node': versions_1.nxVersion, '@types/node': versions_1.typesNodeVersion });
|
|
14
13
|
}
|
|
15
14
|
function normalizeOptions(schema) {
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
return {
|
|
16
|
+
...schema,
|
|
17
|
+
unitTestRunner: schema.unitTestRunner ?? 'jest',
|
|
18
|
+
};
|
|
18
19
|
}
|
|
19
|
-
function initGenerator(tree, schema) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
async function initGenerator(tree, schema) {
|
|
21
|
+
const options = normalizeOptions(schema);
|
|
22
|
+
const tasks = [];
|
|
23
|
+
tasks.push(await (0, js_1.initGenerator)(tree, {
|
|
24
|
+
...schema,
|
|
25
|
+
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
26
|
+
skipFormat: true,
|
|
27
|
+
}));
|
|
28
|
+
if (options.unitTestRunner === 'jest') {
|
|
29
|
+
tasks.push(await (0, jest_1.jestInitGenerator)(tree, { ...schema, testEnvironment: 'node' }));
|
|
30
|
+
}
|
|
31
|
+
tasks.push(updateDependencies(tree));
|
|
32
|
+
if (!options.skipFormat) {
|
|
33
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
34
|
+
}
|
|
35
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
33
36
|
}
|
|
34
37
|
exports.initGenerator = initGenerator;
|
|
35
38
|
exports.default = initGenerator;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.librarySchematic = exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
7
6
|
const js_1 = require("@nx/js");
|
|
@@ -9,63 +8,74 @@ const add_swc_config_1 = require("@nx/js/src/utils/swc/add-swc-config");
|
|
|
9
8
|
const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
|
|
10
9
|
const path_1 = require("path");
|
|
11
10
|
const init_1 = require("../init/init");
|
|
12
|
-
function libraryGenerator(tree, schema) {
|
|
13
|
-
return
|
|
14
|
-
|
|
11
|
+
async function libraryGenerator(tree, schema) {
|
|
12
|
+
return await libraryGeneratorInternal(tree, {
|
|
13
|
+
projectNameAndRootFormat: 'derived',
|
|
14
|
+
...schema,
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
exports.libraryGenerator = libraryGenerator;
|
|
18
|
-
function libraryGeneratorInternal(tree, schema) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
18
|
+
async function libraryGeneratorInternal(tree, schema) {
|
|
19
|
+
const options = await normalizeOptions(tree, schema);
|
|
20
|
+
const tasks = [
|
|
21
|
+
await (0, init_1.initGenerator)(tree, {
|
|
22
|
+
...options,
|
|
23
|
+
skipFormat: true,
|
|
24
|
+
}),
|
|
25
|
+
];
|
|
26
|
+
if (options.publishable === true && !schema.importPath) {
|
|
27
|
+
throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
|
|
28
|
+
}
|
|
29
|
+
const libraryInstall = await (0, js_1.libraryGenerator)(tree, {
|
|
30
|
+
...schema,
|
|
31
|
+
bundler: schema.buildable ? 'tsc' : 'none',
|
|
32
|
+
includeBabelRc: schema.babelJest,
|
|
33
|
+
importPath: options.importPath,
|
|
34
|
+
testEnvironment: 'node',
|
|
35
|
+
skipFormat: true,
|
|
36
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
38
37
|
});
|
|
38
|
+
tasks.push(libraryInstall);
|
|
39
|
+
createFiles(tree, options);
|
|
40
|
+
if (options.js) {
|
|
41
|
+
(0, devkit_1.updateTsConfigsToJs)(tree, options);
|
|
42
|
+
}
|
|
43
|
+
updateProject(tree, options);
|
|
44
|
+
if (!schema.skipFormat) {
|
|
45
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
46
|
+
}
|
|
47
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
39
48
|
}
|
|
40
49
|
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
41
50
|
exports.default = libraryGenerator;
|
|
42
51
|
exports.librarySchematic = (0, devkit_1.convertNxGenerator)(libraryGenerator);
|
|
43
|
-
function normalizeOptions(tree, options) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
callingGenerator: '@nx/node:library',
|
|
52
|
-
});
|
|
53
|
-
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
54
|
-
const fileName = getCaseAwareFileName({
|
|
55
|
-
fileName: options.simpleModuleName
|
|
56
|
-
? projectNames.projectSimpleName
|
|
57
|
-
: projectNames.projectFileName,
|
|
58
|
-
pascalCaseFiles: options.pascalCaseFiles,
|
|
59
|
-
});
|
|
60
|
-
const parsedTags = options.tags
|
|
61
|
-
? options.tags.split(',').map((s) => s.trim())
|
|
62
|
-
: [];
|
|
63
|
-
return Object.assign(Object.assign({}, options), { fileName,
|
|
64
|
-
projectName,
|
|
65
|
-
projectRoot,
|
|
66
|
-
parsedTags,
|
|
67
|
-
importPath });
|
|
52
|
+
async function normalizeOptions(tree, options) {
|
|
53
|
+
const { projectName, names: projectNames, projectRoot, importPath, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
54
|
+
name: options.name,
|
|
55
|
+
projectType: 'library',
|
|
56
|
+
directory: options.directory,
|
|
57
|
+
importPath: options.importPath,
|
|
58
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
59
|
+
callingGenerator: '@nx/node:library',
|
|
68
60
|
});
|
|
61
|
+
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
62
|
+
const fileName = getCaseAwareFileName({
|
|
63
|
+
fileName: options.simpleModuleName
|
|
64
|
+
? projectNames.projectSimpleName
|
|
65
|
+
: projectNames.projectFileName,
|
|
66
|
+
pascalCaseFiles: options.pascalCaseFiles,
|
|
67
|
+
});
|
|
68
|
+
const parsedTags = options.tags
|
|
69
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
70
|
+
: [];
|
|
71
|
+
return {
|
|
72
|
+
...options,
|
|
73
|
+
fileName,
|
|
74
|
+
projectName,
|
|
75
|
+
projectRoot,
|
|
76
|
+
parsedTags,
|
|
77
|
+
importPath,
|
|
78
|
+
};
|
|
69
79
|
}
|
|
70
80
|
function getCaseAwareFileName(options) {
|
|
71
81
|
const normalized = (0, devkit_1.names)(options.fileName);
|
|
@@ -73,9 +83,14 @@ function getCaseAwareFileName(options) {
|
|
|
73
83
|
}
|
|
74
84
|
function createFiles(tree, options) {
|
|
75
85
|
const { className, name, propertyName } = (0, devkit_1.names)(options.fileName);
|
|
76
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/lib'), options.projectRoot,
|
|
86
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/lib'), options.projectRoot, {
|
|
87
|
+
...options,
|
|
88
|
+
className,
|
|
77
89
|
name,
|
|
78
|
-
propertyName,
|
|
90
|
+
propertyName,
|
|
91
|
+
tmpl: '',
|
|
92
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
|
|
93
|
+
});
|
|
79
94
|
if (options.unitTestRunner === 'none') {
|
|
80
95
|
tree.delete((0, path_1.join)(options.projectRoot, `./src/lib/${options.fileName}.spec.ts`));
|
|
81
96
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setupDockerSchematic = exports.setupDockerGenerator = exports.updateProjectConfig = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const path_1 = require("path");
|
|
7
6
|
function normalizeOptions(tree, setupOptions) {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
return {
|
|
8
|
+
...setupOptions,
|
|
9
|
+
project: setupOptions.project ?? (0, devkit_1.readNxJson)(tree).defaultProject,
|
|
10
|
+
targetName: setupOptions.targetName ?? 'docker-build',
|
|
11
|
+
buildTarget: setupOptions.buildTarget ?? 'build',
|
|
12
|
+
};
|
|
10
13
|
}
|
|
11
14
|
function addDocker(tree, options) {
|
|
12
|
-
var _a;
|
|
13
15
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
14
16
|
if (!project || !options.targetName) {
|
|
15
17
|
return;
|
|
@@ -18,7 +20,7 @@ function addDocker(tree, options) {
|
|
|
18
20
|
devkit_1.logger.info(`Skipping setup since a Dockerfile already exists inside ${project.root}`);
|
|
19
21
|
}
|
|
20
22
|
else {
|
|
21
|
-
const outputPath =
|
|
23
|
+
const outputPath = project.targets[`${options.buildTarget}`]?.options.outputPath;
|
|
22
24
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), project.root, {
|
|
23
25
|
tmpl: '',
|
|
24
26
|
app: project.sourceRoot,
|
|
@@ -36,18 +38,16 @@ function updateProjectConfig(tree, options) {
|
|
|
36
38
|
(0, devkit_1.updateProjectConfiguration)(tree, options.project, projectConfig);
|
|
37
39
|
}
|
|
38
40
|
exports.updateProjectConfig = updateProjectConfig;
|
|
39
|
-
function setupDockerGenerator(tree, setupOptions) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
50
|
-
});
|
|
41
|
+
async function setupDockerGenerator(tree, setupOptions) {
|
|
42
|
+
const tasks = [];
|
|
43
|
+
const options = normalizeOptions(tree, setupOptions);
|
|
44
|
+
// Should check if the node project exists
|
|
45
|
+
addDocker(tree, options);
|
|
46
|
+
updateProjectConfig(tree, options);
|
|
47
|
+
if (!options.skipFormat) {
|
|
48
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
49
|
+
}
|
|
50
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
51
51
|
}
|
|
52
52
|
exports.setupDockerGenerator = setupDockerGenerator;
|
|
53
53
|
exports.default = setupDockerGenerator;
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function update(host) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
delete config.targets.build.configurations.production['showCircularDependencies'];
|
|
15
|
-
updated = true;
|
|
16
|
-
}
|
|
17
|
-
if (typeof ((_e = (_d = config.targets.build) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e['showCircularDependencies']) !==
|
|
18
|
-
'undefined') {
|
|
19
|
-
delete config.targets.build.options['showCircularDependencies'];
|
|
20
|
-
updated = true;
|
|
21
|
-
}
|
|
22
|
-
if (updated) {
|
|
23
|
-
(0, devkit_1.updateProjectConfiguration)(host, name, config);
|
|
24
|
-
devkit_1.logger.info(`NX Removed legacy build option from "${name}": showCircularDependencies`);
|
|
25
|
-
}
|
|
4
|
+
async function update(host) {
|
|
5
|
+
const projects = (0, devkit_1.getProjects)(host);
|
|
6
|
+
for (const [name, config] of projects.entries()) {
|
|
7
|
+
if (config.targets.build.executor !== '@nrwl/node:build')
|
|
8
|
+
return;
|
|
9
|
+
let updated = false;
|
|
10
|
+
if (typeof config.targets.build?.configurations?.production?.['showCircularDependencies'] !== 'undefined') {
|
|
11
|
+
delete config.targets.build.configurations.production['showCircularDependencies'];
|
|
12
|
+
updated = true;
|
|
26
13
|
}
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
if (typeof config.targets.build?.options?.['showCircularDependencies'] !==
|
|
15
|
+
'undefined') {
|
|
16
|
+
delete config.targets.build.options['showCircularDependencies'];
|
|
17
|
+
updated = true;
|
|
18
|
+
}
|
|
19
|
+
if (updated) {
|
|
20
|
+
(0, devkit_1.updateProjectConfiguration)(host, name, config);
|
|
21
|
+
devkit_1.logger.info(`NX Removed legacy build option from "${name}": showCircularDependencies`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
await (0, devkit_1.formatFiles)(host);
|
|
29
25
|
}
|
|
30
26
|
exports.default = update;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const packages = [
|
|
6
5
|
'webpack',
|
|
@@ -15,18 +14,15 @@ const packages = [
|
|
|
15
14
|
'react-refresh',
|
|
16
15
|
'@pmmmwh/react-refresh-webpack-plugin',
|
|
17
16
|
];
|
|
18
|
-
function update(tree) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
return task;
|
|
30
|
-
});
|
|
17
|
+
async function update(tree) {
|
|
18
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
19
|
+
let task = undefined;
|
|
20
|
+
// Undo the install by `nx g @nrwl/web:webpack5` in Nx 12.
|
|
21
|
+
if (packageJson.devDependencies['webpack']?.match(/^([\^~])?5\./) &&
|
|
22
|
+
packages.every((p) => packageJson.devDependencies[p])) {
|
|
23
|
+
task = (0, devkit_1.removeDependenciesFromPackageJson)(tree, [], packages);
|
|
24
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
25
|
+
}
|
|
26
|
+
return task;
|
|
31
27
|
}
|
|
32
28
|
exports.default = update;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
function update(host) {
|
|
7
|
-
|
|
8
|
-
(0,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
(0, devkit_1.updateProjectConfiguration)(host, projectName, projectConfiguration);
|
|
12
|
-
});
|
|
13
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
5
|
+
async function update(host) {
|
|
6
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(host, '@nrwl/node:build', (_, projectName, targetName) => {
|
|
7
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, projectName);
|
|
8
|
+
projectConfiguration.targets[targetName].executor = '@nrwl/node:webpack';
|
|
9
|
+
(0, devkit_1.updateProjectConfiguration)(host, projectName, projectConfiguration);
|
|
14
10
|
});
|
|
11
|
+
await (0, devkit_1.formatFiles)(host);
|
|
15
12
|
}
|
|
16
13
|
exports.default = update;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
function update(tree) {
|
|
7
|
-
|
|
8
|
-
(0,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
12
|
-
});
|
|
13
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/node:execute', (_, projectName, targetName) => {
|
|
7
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
8
|
+
projectConfiguration.targets[targetName].executor = '@nrwl/node:node';
|
|
9
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
14
10
|
});
|
|
11
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
15
12
|
}
|
|
16
13
|
exports.default = update;
|
|
@@ -1,38 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
5
|
const versions_1 = require("@nx/workspace/src/utils/versions");
|
|
7
|
-
function update(host) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
projectConfiguration.targets[targetName].options.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
(0, devkit_1.updateProjectConfiguration)(host, projectName, projectConfiguration);
|
|
28
|
-
});
|
|
29
|
-
const task = installNeeded
|
|
30
|
-
? (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
31
|
-
'@nrwl/js': versions_1.nxVersion,
|
|
32
|
-
})
|
|
33
|
-
: undefined;
|
|
34
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
35
|
-
return task;
|
|
6
|
+
async function update(host) {
|
|
7
|
+
let installNeeded = false;
|
|
8
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(host, '@nrwl/node:package', (_, projectName, targetName) => {
|
|
9
|
+
installNeeded = true;
|
|
10
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, projectName);
|
|
11
|
+
projectConfiguration.targets[targetName].executor = '@nrwl/js:tsc';
|
|
12
|
+
const transformers = projectConfiguration.targets[targetName].options?.tsPlugins;
|
|
13
|
+
if (transformers) {
|
|
14
|
+
delete projectConfiguration.targets[targetName].options.tsPlugins;
|
|
15
|
+
projectConfiguration.targets[targetName].options.transformers =
|
|
16
|
+
transformers;
|
|
17
|
+
}
|
|
18
|
+
if (projectConfiguration.targets[targetName].options
|
|
19
|
+
?.srcRootForCompilationRoot) {
|
|
20
|
+
projectConfiguration.targets[targetName].options.rootDir =
|
|
21
|
+
projectConfiguration.targets[targetName].options.srcRootForCompilationRoot;
|
|
22
|
+
delete projectConfiguration.targets[targetName].options
|
|
23
|
+
.srcRootForCompilationRoot;
|
|
24
|
+
}
|
|
25
|
+
(0, devkit_1.updateProjectConfiguration)(host, projectName, projectConfiguration);
|
|
36
26
|
});
|
|
27
|
+
const task = installNeeded
|
|
28
|
+
? (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
29
|
+
'@nrwl/js': versions_1.nxVersion,
|
|
30
|
+
})
|
|
31
|
+
: undefined;
|
|
32
|
+
await (0, devkit_1.formatFiles)(host);
|
|
33
|
+
return task;
|
|
37
34
|
}
|
|
38
35
|
exports.default = update;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
function update(tree) {
|
|
7
|
-
|
|
8
|
-
(0,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
14
|
-
});
|
|
15
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/node:webpack', (options, projectName, targetName) => {
|
|
7
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
8
|
+
projectConfig.targets[targetName].executor = '@nrwl/webpack:webpack';
|
|
9
|
+
projectConfig.targets[targetName].options.compiler = 'tsc';
|
|
10
|
+
projectConfig.targets[targetName].options.target = 'node';
|
|
11
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
16
12
|
});
|
|
13
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
17
14
|
}
|
|
18
15
|
exports.default = update;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
function update(tree) {
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
18
|
-
});
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
const migrateProject = (options, projectName, targetName) => {
|
|
7
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
8
|
+
projectConfig.targets[targetName].executor = '@nx/webpack:webpack';
|
|
9
|
+
projectConfig.targets[targetName].options.compiler = 'tsc';
|
|
10
|
+
projectConfig.targets[targetName].options.target = 'node';
|
|
11
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
12
|
+
};
|
|
13
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/node:webpack', migrateProject);
|
|
14
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/node:webpack', migrateProject);
|
|
15
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
19
16
|
}
|
|
20
17
|
exports.default = update;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
|
-
function replacePackage(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
10
|
-
});
|
|
5
|
+
async function replacePackage(tree) {
|
|
6
|
+
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/node', '@nx/node');
|
|
7
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
11
8
|
}
|
|
12
9
|
exports.default = replacePackage;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
function update(tree) {
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
18
|
-
});
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
const migrateProject = (options, projectName, targetName) => {
|
|
7
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
8
|
+
projectConfig.targets[targetName].executor = '@nx/webpack:webpack';
|
|
9
|
+
projectConfig.targets[targetName].options.compiler = 'tsc';
|
|
10
|
+
projectConfig.targets[targetName].options.target = 'node';
|
|
11
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
12
|
+
};
|
|
13
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/node:webpack', migrateProject);
|
|
14
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/node:webpack', migrateProject);
|
|
15
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
19
16
|
}
|
|
20
17
|
exports.default = update;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
function update(tree) {
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
15
|
-
});
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
const migrateProject = (_options, projectName, targetName) => {
|
|
7
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
8
|
+
projectConfig.targets[targetName].executor = '@nx/js:node';
|
|
9
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfig);
|
|
10
|
+
};
|
|
11
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/node:node', migrateProject);
|
|
12
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
16
13
|
}
|
|
17
14
|
exports.default = update;
|