@nx/node 17.0.4 → 17.0.6
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 +4 -9
- package/migrations.json +1 -20
- package/package.json +6 -6
- package/src/generators/application/application.d.ts +2 -2
- package/src/generators/application/application.js +10 -65
- package/src/generators/application/files/common/webpack.config.js__tmpl__ +5 -32
- package/src/generators/application/files/fastify/src/app/app.ts__tmpl__ +1 -1
- package/src/generators/application/files/fastify/src/app/plugins/sensible.ts__tmpl__ +1 -1
- package/src/generators/application/files/fastify/src/app/routes/root.ts__tmpl__ +2 -2
- package/src/generators/application/schema.d.ts +0 -1
- package/src/generators/application/schema.json +1 -1
- package/src/generators/e2e-project/e2e-project.js +1 -11
- package/src/generators/e2e-project/files/server/common/src/__fileName__/__fileName__.spec.ts__tmpl__ +1 -1
- package/src/generators/e2e-project/files/server/nest/src/__fileName__/__fileName__.spec.ts__tmpl__ +1 -1
- package/src/generators/e2e-project/schema.d.ts +0 -1
- package/src/generators/e2e-project/schema.json +1 -1
- package/src/generators/init/init.d.ts +1 -1
- package/src/generators/init/init.js +25 -10
- package/src/generators/init/schema.d.ts +3 -2
- package/src/generators/init/schema.json +10 -10
- package/src/generators/library/library.js +1 -13
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +1 -1
- package/src/generators/setup-docker/schema.json +1 -1
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -2
- package/src/utils/has-webpack-plugin.d.ts +0 -2
- package/src/utils/has-webpack-plugin.js +0 -11
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
<p style="text-align: center;">
|
|
2
|
-
<picture>
|
|
3
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
-
<img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
-
</picture>
|
|
6
|
-
</p>
|
|
1
|
+
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
|
|
7
2
|
|
|
8
3
|
<div style="text-align: center;">
|
|
9
4
|
|
|
@@ -20,9 +15,9 @@
|
|
|
20
15
|
|
|
21
16
|
<hr>
|
|
22
17
|
|
|
23
|
-
# Nx: Smart
|
|
18
|
+
# Nx: Smart, Fast and Extensible Build System
|
|
24
19
|
|
|
25
|
-
Nx is a build system with
|
|
20
|
+
Nx is a next generation build system with first class monorepo support and powerful integrations.
|
|
26
21
|
|
|
27
22
|
## Getting Started
|
|
28
23
|
|
|
@@ -62,5 +57,5 @@ npx nx@latest init
|
|
|
62
57
|
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
63
58
|
|
|
64
59
|
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
65
|
-
width="100%" alt="Nx - Smart
|
|
60
|
+
width="100%" alt="Nx - Smart, Fast and Extensible Build System"></a></p>
|
|
66
61
|
|
package/migrations.json
CHANGED
|
@@ -25,24 +25,5 @@
|
|
|
25
25
|
"implementation": "./src/migrations/update-16-4-0/replace-node-executor"
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
|
-
"packageJsonUpdates": {
|
|
29
|
-
"17.3.0": {
|
|
30
|
-
"version": "17.3.0-beta.3",
|
|
31
|
-
"packages": {
|
|
32
|
-
"@types/node": {
|
|
33
|
-
"version": "18.16.9",
|
|
34
|
-
"alwaysAddToPackageJson": false
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"17.3.1": {
|
|
39
|
-
"version": "17.3.1-beta.0",
|
|
40
|
-
"packages": {
|
|
41
|
-
"axios": {
|
|
42
|
-
"version": "^1.6.0",
|
|
43
|
-
"alwaysAddToPackageJson": false
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
28
|
+
"packageJsonUpdates": {}
|
|
48
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/node",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "v17.0.6",
|
|
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": {
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"tslib": "^2.3.0",
|
|
34
|
-
"@nx/devkit": "
|
|
35
|
-
"@nx/jest": "
|
|
36
|
-
"@nx/js": "
|
|
37
|
-
"@nx/eslint": "
|
|
38
|
-
"@nrwl/node": "
|
|
34
|
+
"@nx/devkit": "v17.0.6",
|
|
35
|
+
"@nx/jest": "v17.0.6",
|
|
36
|
+
"@nx/js": "v17.0.6",
|
|
37
|
+
"@nx/eslint": "v17.0.6",
|
|
38
|
+
"@nrwl/node": "v17.0.6"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
@@ -5,6 +5,6 @@ export interface NormalizedSchema extends Schema {
|
|
|
5
5
|
parsedTags: string[];
|
|
6
6
|
}
|
|
7
7
|
export declare function addLintingToApplication(tree: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
|
8
|
-
export declare function applicationGenerator(tree: Tree, schema: Schema): Promise<
|
|
9
|
-
export declare function applicationGeneratorInternal(tree: Tree, schema: Schema): Promise<
|
|
8
|
+
export declare function applicationGenerator(tree: Tree, schema: Schema): Promise<any>;
|
|
9
|
+
export declare function applicationGeneratorInternal(tree: Tree, schema: Schema): Promise<any>;
|
|
10
10
|
export default applicationGenerator;
|
|
@@ -7,14 +7,12 @@ const jest_1 = require("@nx/jest");
|
|
|
7
7
|
const js_1 = require("@nx/js");
|
|
8
8
|
const versions_1 = require("@nx/js/src/utils/versions");
|
|
9
9
|
const eslint_1 = require("@nx/eslint");
|
|
10
|
+
const lint_project_1 = require("@nx/eslint/src/generators/lint-project/lint-project");
|
|
10
11
|
const path_1 = require("path");
|
|
11
12
|
const versions_2 = require("../../utils/versions");
|
|
12
13
|
const e2e_project_1 = require("../e2e-project/e2e-project");
|
|
13
14
|
const init_1 = require("../init/init");
|
|
14
15
|
const setup_docker_1 = require("../setup-docker/setup-docker");
|
|
15
|
-
const has_webpack_plugin_1 = require("../../utils/has-webpack-plugin");
|
|
16
|
-
const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
|
|
17
|
-
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
18
16
|
function getWebpackBuildConfig(project, options) {
|
|
19
17
|
return {
|
|
20
18
|
executor: `@nx/webpack:webpack`,
|
|
@@ -27,6 +25,7 @@ function getWebpackBuildConfig(project, options) {
|
|
|
27
25
|
main: (0, devkit_1.joinPathFragments)(project.sourceRoot, 'main' + (options.js ? '.js' : '.ts')),
|
|
28
26
|
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
29
27
|
assets: [(0, devkit_1.joinPathFragments)(project.sourceRoot, 'assets')],
|
|
28
|
+
isolatedConfig: true,
|
|
30
29
|
webpackConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'),
|
|
31
30
|
},
|
|
32
31
|
configurations: {
|
|
@@ -96,21 +95,14 @@ function addProject(tree, options) {
|
|
|
96
95
|
targets: {},
|
|
97
96
|
tags: options.parsedTags,
|
|
98
97
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
else if (options.bundler === 'webpack') {
|
|
104
|
-
if (!(0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) {
|
|
105
|
-
(0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, `@nx/webpack:webpack`);
|
|
106
|
-
project.targets.build = getWebpackBuildConfig(project, options);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
98
|
+
project.targets.build =
|
|
99
|
+
options.bundler === 'esbuild'
|
|
100
|
+
? getEsBuildConfig(project, options)
|
|
101
|
+
: getWebpackBuildConfig(project, options);
|
|
109
102
|
project.targets.serve = getServeConfig(options);
|
|
110
103
|
(0, devkit_1.addProjectConfiguration)(tree, options.name, project, options.standaloneConfig);
|
|
111
104
|
}
|
|
112
105
|
function addAppFiles(tree, options) {
|
|
113
|
-
const sourceRoot = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src');
|
|
114
106
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/common'), options.appProjectRoot, {
|
|
115
107
|
...options,
|
|
116
108
|
tmpl: '',
|
|
@@ -118,14 +110,6 @@ function addAppFiles(tree, options) {
|
|
|
118
110
|
root: options.appProjectRoot,
|
|
119
111
|
offset: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
120
112
|
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot),
|
|
121
|
-
webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)
|
|
122
|
-
? {
|
|
123
|
-
outputPath: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : options.appProjectRoot),
|
|
124
|
-
main: './src/main' + (options.js ? '.js' : '.ts'),
|
|
125
|
-
tsConfig: './tsconfig.app.json',
|
|
126
|
-
assets: ['./src/assets'],
|
|
127
|
-
}
|
|
128
|
-
: null,
|
|
129
113
|
});
|
|
130
114
|
if (options.bundler !== 'webpack') {
|
|
131
115
|
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'webpack.config.js'));
|
|
@@ -185,11 +169,13 @@ async function addLintingToApplication(tree, options) {
|
|
|
185
169
|
tsConfigPaths: [
|
|
186
170
|
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
187
171
|
],
|
|
172
|
+
eslintFilePatterns: [
|
|
173
|
+
(0, lint_project_1.mapLintPattern)(options.appProjectRoot, options.js ? 'js' : 'ts', options.rootProject),
|
|
174
|
+
],
|
|
188
175
|
unitTestRunner: options.unitTestRunner,
|
|
189
176
|
skipFormat: true,
|
|
190
177
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
191
178
|
rootProject: options.rootProject,
|
|
192
|
-
addPlugin: options.addPlugin,
|
|
193
179
|
});
|
|
194
180
|
return lintTask;
|
|
195
181
|
}
|
|
@@ -229,11 +215,9 @@ function addProjectDependencies(tree, options) {
|
|
|
229
215
|
};
|
|
230
216
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
231
217
|
...frameworkDependencies[options.framework],
|
|
232
|
-
tslib: versions_2.tslibVersion,
|
|
233
218
|
}, {
|
|
234
219
|
...frameworkDevDependencies[options.framework],
|
|
235
220
|
...bundlers[options.bundler],
|
|
236
|
-
'@types/node': versions_2.typesNodeVersion,
|
|
237
221
|
});
|
|
238
222
|
}
|
|
239
223
|
function updateTsConfigOptions(tree, options) {
|
|
@@ -263,7 +247,6 @@ function updateTsConfigOptions(tree, options) {
|
|
|
263
247
|
}
|
|
264
248
|
async function applicationGenerator(tree, schema) {
|
|
265
249
|
return await applicationGeneratorInternal(tree, {
|
|
266
|
-
addPlugin: false,
|
|
267
250
|
projectNameAndRootFormat: 'derived',
|
|
268
251
|
...schema,
|
|
269
252
|
});
|
|
@@ -273,25 +256,9 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
273
256
|
const options = await normalizeOptions(tree, schema);
|
|
274
257
|
const tasks = [];
|
|
275
258
|
if (options.framework === 'nest') {
|
|
276
|
-
// nx-ignore-next-line
|
|
277
259
|
const { applicationGenerator } = (0, devkit_1.ensurePackage)('@nx/nest', versions_2.nxVersion);
|
|
278
|
-
|
|
279
|
-
...options,
|
|
280
|
-
skipFormat: true,
|
|
281
|
-
});
|
|
282
|
-
return (0, devkit_1.runTasksInSerial)(...[
|
|
283
|
-
nestTasks,
|
|
284
|
-
() => {
|
|
285
|
-
(0, log_show_project_command_1.logShowProjectCommand)(options.name);
|
|
286
|
-
},
|
|
287
|
-
]);
|
|
260
|
+
return await applicationGenerator(tree, { ...options, skipFormat: true });
|
|
288
261
|
}
|
|
289
|
-
const jsInitTask = await (0, js_1.initGenerator)(tree, {
|
|
290
|
-
...schema,
|
|
291
|
-
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
292
|
-
skipFormat: true,
|
|
293
|
-
});
|
|
294
|
-
tasks.push(jsInitTask);
|
|
295
262
|
const initTask = await (0, init_1.initGenerator)(tree, {
|
|
296
263
|
...schema,
|
|
297
264
|
skipFormat: true,
|
|
@@ -299,21 +266,6 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
299
266
|
tasks.push(initTask);
|
|
300
267
|
const installTask = addProjectDependencies(tree, options);
|
|
301
268
|
tasks.push(installTask);
|
|
302
|
-
if (options.bundler === 'webpack') {
|
|
303
|
-
const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_2.nxVersion);
|
|
304
|
-
const webpackInitTask = await webpackInitGenerator(tree, {
|
|
305
|
-
skipPackageJson: options.skipPackageJson,
|
|
306
|
-
skipFormat: true,
|
|
307
|
-
addPlugin: options.addPlugin,
|
|
308
|
-
});
|
|
309
|
-
tasks.push(webpackInitTask);
|
|
310
|
-
if (!options.skipPackageJson) {
|
|
311
|
-
const { ensureDependencies } = await Promise.resolve().then(() => require('@nx/webpack/src/utils/ensure-dependencies'));
|
|
312
|
-
tasks.push(ensureDependencies(tree, {
|
|
313
|
-
uiFramework: options.isNest ? 'none' : 'react',
|
|
314
|
-
}));
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
269
|
addAppFiles(tree, options);
|
|
318
270
|
addProject(tree, options);
|
|
319
271
|
updateTsConfigOptions(tree, options);
|
|
@@ -369,9 +321,6 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
369
321
|
if (!options.skipFormat) {
|
|
370
322
|
await (0, devkit_1.formatFiles)(tree);
|
|
371
323
|
}
|
|
372
|
-
tasks.push(() => {
|
|
373
|
-
(0, log_show_project_command_1.logShowProjectCommand)(options.name);
|
|
374
|
-
});
|
|
375
324
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
376
325
|
}
|
|
377
326
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
|
@@ -391,11 +340,7 @@ async function normalizeOptions(host, options) {
|
|
|
391
340
|
const parsedTags = options.tags
|
|
392
341
|
? options.tags.split(',').map((s) => s.trim())
|
|
393
342
|
: [];
|
|
394
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
395
|
-
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
396
|
-
nxJson.useInferencePlugins !== false;
|
|
397
343
|
return {
|
|
398
|
-
addPlugin,
|
|
399
344
|
...options,
|
|
400
345
|
name: appProjectName,
|
|
401
346
|
frontendProject: options.frontendProject
|
|
@@ -1,35 +1,8 @@
|
|
|
1
|
-
<% if (webpackPluginOptions) { %>
|
|
2
|
-
const { NxWebpackPlugin } = require('@nx/webpack');
|
|
3
|
-
const { join } = require('path');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
output: {
|
|
7
|
-
path: join(__dirname, '<%= offset %><%= webpackPluginOptions.outputPath %>'),
|
|
8
|
-
},
|
|
9
|
-
plugins: [
|
|
10
|
-
new NxWebpackPlugin({
|
|
11
|
-
target: 'node',
|
|
12
|
-
compiler: 'tsc',
|
|
13
|
-
main: '<%= webpackPluginOptions.main %>',
|
|
14
|
-
tsConfig: '<%= webpackPluginOptions.tsConfig %>',
|
|
15
|
-
assets: <%- JSON.stringify(webpackPluginOptions.assets) %>,
|
|
16
|
-
optimization: false,
|
|
17
|
-
outputHashing: 'none',
|
|
18
|
-
})
|
|
19
|
-
],
|
|
20
|
-
};
|
|
21
|
-
<% } else { %>
|
|
22
1
|
const { composePlugins, withNx} = require('@nx/webpack');
|
|
23
2
|
|
|
24
3
|
// Nx plugins for webpack.
|
|
25
|
-
module.exports = composePlugins(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// Update the webpack config as needed here.
|
|
31
|
-
// e.g. `config.plugins.push(new MyPlugin())`
|
|
32
|
-
return config;
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
<% } %>
|
|
4
|
+
module.exports = composePlugins(withNx(), (config) => {
|
|
5
|
+
// Update the webpack config as needed here.
|
|
6
|
+
// e.g. `config.plugins.push(new MyPlugin())`
|
|
7
|
+
return config;
|
|
8
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FastifyInstance } from 'fastify';
|
|
1
|
+
import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
|
|
2
2
|
|
|
3
3
|
export default async function(fastify: FastifyInstance) {
|
|
4
|
-
fastify.get('/', async function() {
|
|
4
|
+
fastify.get('/', async function(request: FastifyRequest, reply: FastifyReply) {
|
|
5
5
|
return { message: 'Hello API' };
|
|
6
6
|
});
|
|
7
7
|
}
|
|
@@ -8,10 +8,8 @@ const global_eslint_config_1 = require("@nx/eslint/src/generators/init/global-es
|
|
|
8
8
|
const path = require("path");
|
|
9
9
|
const versions_1 = require("../../utils/versions");
|
|
10
10
|
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
11
|
-
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
12
11
|
async function e2eProjectGenerator(host, options) {
|
|
13
12
|
return await e2eProjectGeneratorInternal(host, {
|
|
14
|
-
addPlugin: false,
|
|
15
13
|
projectNameAndRootFormat: 'derived',
|
|
16
14
|
...options,
|
|
17
15
|
});
|
|
@@ -21,7 +19,6 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
21
19
|
const tasks = [];
|
|
22
20
|
const options = await normalizeOptions(host, _options);
|
|
23
21
|
const appProject = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
24
|
-
// TODO(@ndcunningham): This is broken.. the outputs are wrong.. and this isn't using the jest generator
|
|
25
22
|
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
26
23
|
root: options.e2eProjectRoot,
|
|
27
24
|
implicitDependencies: [options.project],
|
|
@@ -74,10 +71,10 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
74
71
|
tsConfigPaths: [
|
|
75
72
|
(0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'tsconfig.json'),
|
|
76
73
|
],
|
|
74
|
+
eslintFilePatterns: [`${options.e2eProjectRoot}/**/*.{js,ts}`],
|
|
77
75
|
setParserOptionsProject: false,
|
|
78
76
|
skipPackageJson: false,
|
|
79
77
|
rootProject: options.rootProject,
|
|
80
|
-
addPlugin: options.addPlugin,
|
|
81
78
|
});
|
|
82
79
|
tasks.push(linterTask);
|
|
83
80
|
if (options.rootProject && (0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
@@ -91,9 +88,6 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
91
88
|
if (!options.skipFormat) {
|
|
92
89
|
await (0, devkit_1.formatFiles)(host);
|
|
93
90
|
}
|
|
94
|
-
tasks.push(() => {
|
|
95
|
-
(0, log_show_project_command_1.logShowProjectCommand)(options.e2eProjectName);
|
|
96
|
-
});
|
|
97
91
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
98
92
|
}
|
|
99
93
|
exports.e2eProjectGeneratorInternal = e2eProjectGeneratorInternal;
|
|
@@ -108,11 +102,7 @@ async function normalizeOptions(tree, options) {
|
|
|
108
102
|
// this is an internal generator, don't save defaults
|
|
109
103
|
callingGenerator: null,
|
|
110
104
|
});
|
|
111
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
112
|
-
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
113
|
-
nxJson.useInferencePlugins !== false;
|
|
114
105
|
return {
|
|
115
|
-
addPlugin,
|
|
116
106
|
...options,
|
|
117
107
|
e2eProjectRoot,
|
|
118
108
|
e2eProjectName,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
|
-
export declare function initGenerator(tree: Tree,
|
|
3
|
+
export declare function initGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
4
|
export default initGenerator;
|
|
@@ -2,22 +2,37 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const jest_1 = require("@nx/jest");
|
|
6
|
+
const js_1 = require("@nx/js");
|
|
5
7
|
const versions_1 = require("../../utils/versions");
|
|
6
|
-
function updateDependencies(tree
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
function updateDependencies(tree) {
|
|
9
|
+
(0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@nx/node'], []);
|
|
10
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
11
|
+
tslib: versions_1.tslibVersion,
|
|
12
|
+
}, { '@nx/node': versions_1.nxVersion, '@types/node': versions_1.typesNodeVersion });
|
|
13
|
+
}
|
|
14
|
+
function normalizeOptions(schema) {
|
|
15
|
+
return {
|
|
16
|
+
...schema,
|
|
17
|
+
unitTestRunner: schema.unitTestRunner ?? 'jest',
|
|
18
|
+
};
|
|
11
19
|
}
|
|
12
|
-
async function initGenerator(tree,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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' }));
|
|
16
30
|
}
|
|
31
|
+
tasks.push(updateDependencies(tree));
|
|
17
32
|
if (!options.skipFormat) {
|
|
18
33
|
await (0, devkit_1.formatFiles)(tree);
|
|
19
34
|
}
|
|
20
|
-
return
|
|
35
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
21
36
|
}
|
|
22
37
|
exports.initGenerator = initGenerator;
|
|
23
38
|
exports.default = initGenerator;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxNodeInit",
|
|
5
5
|
"title": "Init Node Plugin",
|
|
6
6
|
"description": "Init Node Plugin.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
+
"unitTestRunner": {
|
|
10
|
+
"description": "Adds the specified unit test runner.",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"enum": ["jest", "none"],
|
|
13
|
+
"default": "jest"
|
|
14
|
+
},
|
|
9
15
|
"skipFormat": {
|
|
10
16
|
"description": "Skip formatting files.",
|
|
11
17
|
"type": "boolean",
|
|
12
18
|
"default": false
|
|
13
19
|
},
|
|
14
|
-
"
|
|
15
|
-
"description": "Do not add dependencies to `package.json`.",
|
|
20
|
+
"js": {
|
|
16
21
|
"type": "boolean",
|
|
17
|
-
"default": false
|
|
18
|
-
|
|
19
|
-
"keepExistingVersions": {
|
|
20
|
-
"type": "boolean",
|
|
21
|
-
"x-priority": "internal",
|
|
22
|
-
"description": "Keep existing dependencies versions",
|
|
23
|
-
"default": false
|
|
22
|
+
"default": false,
|
|
23
|
+
"description": "Use JavaScript instead of TypeScript"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"required": []
|
|
@@ -7,12 +7,9 @@ const js_1 = require("@nx/js");
|
|
|
7
7
|
const add_swc_config_1 = require("@nx/js/src/utils/swc/add-swc-config");
|
|
8
8
|
const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
|
|
9
9
|
const path_1 = require("path");
|
|
10
|
-
const versions_1 = require("../../utils/versions");
|
|
11
10
|
const init_1 = require("../init/init");
|
|
12
|
-
const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
|
|
13
11
|
async function libraryGenerator(tree, schema) {
|
|
14
12
|
return await libraryGeneratorInternal(tree, {
|
|
15
|
-
addPlugin: false,
|
|
16
13
|
projectNameAndRootFormat: 'derived',
|
|
17
14
|
...schema,
|
|
18
15
|
});
|
|
@@ -30,7 +27,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
30
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)`);
|
|
31
28
|
}
|
|
32
29
|
const libraryInstall = await (0, js_1.libraryGenerator)(tree, {
|
|
33
|
-
...
|
|
30
|
+
...schema,
|
|
34
31
|
bundler: schema.buildable ? 'tsc' : 'none',
|
|
35
32
|
includeBabelRc: schema.babelJest,
|
|
36
33
|
importPath: options.importPath,
|
|
@@ -44,7 +41,6 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
44
41
|
(0, devkit_1.updateTsConfigsToJs)(tree, options);
|
|
45
42
|
}
|
|
46
43
|
updateProject(tree, options);
|
|
47
|
-
tasks.push(ensureDependencies(tree));
|
|
48
44
|
if (!schema.skipFormat) {
|
|
49
45
|
await (0, devkit_1.formatFiles)(tree);
|
|
50
46
|
}
|
|
@@ -62,10 +58,6 @@ async function normalizeOptions(tree, options) {
|
|
|
62
58
|
callingGenerator: '@nx/node:library',
|
|
63
59
|
});
|
|
64
60
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
65
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
66
|
-
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
67
|
-
nxJson.useInferencePlugins !== false;
|
|
68
|
-
options.addPlugin ??= addPluginDefault;
|
|
69
61
|
const fileName = getCaseAwareFileName({
|
|
70
62
|
fileName: options.simpleModuleName
|
|
71
63
|
? projectNames.projectSimpleName
|
|
@@ -115,7 +107,6 @@ function updateProject(tree, options) {
|
|
|
115
107
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
116
108
|
const rootProject = options.projectRoot === '.' || options.projectRoot === '';
|
|
117
109
|
project.targets = project.targets || {};
|
|
118
|
-
(0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, `@nx/js:${options.compiler}`);
|
|
119
110
|
project.targets.build = {
|
|
120
111
|
executor: `@nx/js:${options.compiler}`,
|
|
121
112
|
outputs: ['{options.outputPath}'],
|
|
@@ -136,6 +127,3 @@ function updateProject(tree, options) {
|
|
|
136
127
|
}
|
|
137
128
|
(0, devkit_1.updateProjectConfiguration)(tree, options.projectName, project);
|
|
138
129
|
}
|
|
139
|
-
function ensureDependencies(tree) {
|
|
140
|
-
return (0, devkit_1.addDependenciesToPackageJson)(tree, { tslib: versions_1.tslibVersion }, { '@types/node': versions_1.typesNodeVersion });
|
|
141
|
-
}
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const nxVersion: any;
|
|
2
2
|
export declare const tslibVersion = "^2.3.0";
|
|
3
|
-
export declare const typesNodeVersion = "~18.
|
|
3
|
+
export declare const typesNodeVersion = "~18.7.1";
|
|
4
4
|
export declare const expressVersion = "~4.18.1";
|
|
5
5
|
export declare const expressTypingsVersion = "~4.17.13";
|
|
6
6
|
export declare const koaVersion = "~2.14.1";
|
|
@@ -9,4 +9,4 @@ export declare const fastifyVersion = "~4.13.0";
|
|
|
9
9
|
export declare const fastifyAutoloadVersion = "~5.7.1";
|
|
10
10
|
export declare const fastifySensibleVersion = "~5.2.0";
|
|
11
11
|
export declare const fastifyPluginVersion = "~4.5.0";
|
|
12
|
-
export declare const axiosVersion = "^1.
|
|
12
|
+
export declare const axiosVersion = "^1.0.0";
|
package/src/utils/versions.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.axiosVersion = exports.fastifyPluginVersion = exports.fastifySensibleVersion = exports.fastifyAutoloadVersion = exports.fastifyVersion = exports.koaTypingsVersion = exports.koaVersion = exports.expressTypingsVersion = exports.expressVersion = exports.typesNodeVersion = exports.tslibVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
5
|
exports.tslibVersion = '^2.3.0';
|
|
6
|
-
exports.typesNodeVersion = '~18.
|
|
6
|
+
exports.typesNodeVersion = '~18.7.1';
|
|
7
7
|
exports.expressVersion = '~4.18.1';
|
|
8
8
|
exports.expressTypingsVersion = '~4.17.13';
|
|
9
9
|
exports.koaVersion = '~2.14.1';
|
|
@@ -12,4 +12,4 @@ exports.fastifyVersion = '~4.13.0';
|
|
|
12
12
|
exports.fastifyAutoloadVersion = '~5.7.1';
|
|
13
13
|
exports.fastifySensibleVersion = '~5.2.0';
|
|
14
14
|
exports.fastifyPluginVersion = '~4.5.0';
|
|
15
|
-
exports.axiosVersion = '^1.
|
|
15
|
+
exports.axiosVersion = '^1.0.0';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasWebpackPlugin = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function hasWebpackPlugin(tree) {
|
|
6
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
-
return !!nxJson.plugins?.some((p) => typeof p === 'string'
|
|
8
|
-
? p === '@nx/webpack/plugin'
|
|
9
|
-
: p.plugin === '@nx/webpack/plugin');
|
|
10
|
-
}
|
|
11
|
-
exports.hasWebpackPlugin = hasWebpackPlugin;
|