@nx/node 20.5.0-rc.3 → 20.5.0
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
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/node",
|
3
|
-
"version": "20.5.0
|
3
|
+
"version": "20.5.0",
|
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": {
|
@@ -32,10 +32,10 @@
|
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
34
|
"tslib": "^2.3.0",
|
35
|
-
"@nx/devkit": "20.5.0
|
36
|
-
"@nx/jest": "20.5.0
|
37
|
-
"@nx/js": "20.5.0
|
38
|
-
"@nx/eslint": "20.5.0
|
35
|
+
"@nx/devkit": "20.5.0",
|
36
|
+
"@nx/jest": "20.5.0",
|
37
|
+
"@nx/js": "20.5.0",
|
38
|
+
"@nx/eslint": "20.5.0"
|
39
39
|
},
|
40
40
|
"publishConfig": {
|
41
41
|
"access": "public"
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
2
2
|
import { Schema } from './schema';
|
3
|
-
export interface NormalizedSchema extends Schema {
|
3
|
+
export interface NormalizedSchema extends Omit<Schema, 'useTsSolution'> {
|
4
4
|
appProjectRoot: string;
|
5
5
|
parsedTags: string[];
|
6
6
|
outputPath: string;
|
7
|
+
importPath: string;
|
7
8
|
isUsingTsSolutionConfig: boolean;
|
8
9
|
}
|
9
10
|
export declare function addLintingToApplication(tree: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addLintingToApplication = addLintingToApplication;
|
4
4
|
exports.applicationGenerator = applicationGenerator;
|
5
5
|
exports.applicationGeneratorInternal = applicationGeneratorInternal;
|
6
|
-
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
7
6
|
const devkit_1 = require("@nx/devkit");
|
8
7
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
9
8
|
const jest_1 = require("@nx/jest");
|
@@ -140,13 +139,11 @@ function addProject(tree, options) {
|
|
140
139
|
project.targets.serve = getServeConfig(options);
|
141
140
|
if (options.isUsingTsSolutionConfig) {
|
142
141
|
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
|
143
|
-
name:
|
142
|
+
name: options.importPath,
|
144
143
|
version: '0.0.1',
|
145
144
|
private: true,
|
146
145
|
nx: {
|
147
|
-
name: options.name,
|
148
|
-
projectType: 'application',
|
149
|
-
sourceRoot: project.sourceRoot,
|
146
|
+
name: options.name !== options.importPath ? options.name : undefined,
|
150
147
|
targets: project.targets,
|
151
148
|
tags: project.tags?.length ? project.tags : undefined,
|
152
149
|
},
|
@@ -374,6 +371,11 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
374
371
|
}
|
375
372
|
addAppFiles(tree, options);
|
376
373
|
addProject(tree, options);
|
374
|
+
// If we are using the new TS solution
|
375
|
+
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
376
|
+
if (options.isUsingTsSolutionConfig) {
|
377
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
|
378
|
+
}
|
377
379
|
updateTsConfigOptions(tree, options);
|
378
380
|
if (options.linter === eslint_1.Linter.EsLint) {
|
379
381
|
const lintTask = await addLintingToApplication(tree, options);
|
@@ -438,11 +440,6 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
438
440
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
439
441
|
: undefined);
|
440
442
|
}
|
441
|
-
// If we are using the new TS solution
|
442
|
-
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
443
|
-
if (options.isUsingTsSolutionConfig) {
|
444
|
-
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
|
445
|
-
}
|
446
443
|
(0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
|
447
444
|
if (!options.skipFormat) {
|
448
445
|
await (0, devkit_1.formatFiles)(tree);
|
@@ -453,8 +450,8 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
453
450
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
454
451
|
}
|
455
452
|
async function normalizeOptions(host, options) {
|
456
|
-
await (0, project_name_and_root_utils_1.
|
457
|
-
const { projectName
|
453
|
+
await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
|
454
|
+
const { projectName, projectRoot: appProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
458
455
|
name: options.name,
|
459
456
|
projectType: 'application',
|
460
457
|
directory: options.directory,
|
@@ -471,6 +468,7 @@ async function normalizeOptions(host, options) {
|
|
471
468
|
nxJson.useInferencePlugins !== false;
|
472
469
|
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
473
470
|
const swcJest = options.swcJest ?? isUsingTsSolutionConfig;
|
471
|
+
const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
|
474
472
|
return {
|
475
473
|
addPlugin,
|
476
474
|
...options,
|
@@ -479,6 +477,7 @@ async function normalizeOptions(host, options) {
|
|
479
477
|
? (0, devkit_1.names)(options.frontendProject).fileName
|
480
478
|
: undefined,
|
481
479
|
appProjectRoot,
|
480
|
+
importPath,
|
482
481
|
parsedTags,
|
483
482
|
linter: options.linter ?? eslint_1.Linter.EsLint,
|
484
483
|
unitTestRunner: options.unitTestRunner ?? 'jest',
|
@@ -486,7 +485,7 @@ async function normalizeOptions(host, options) {
|
|
486
485
|
port: options.port ?? 3000,
|
487
486
|
outputPath: isUsingTsSolutionConfig
|
488
487
|
? (0, devkit_1.joinPathFragments)(appProjectRoot, 'dist')
|
489
|
-
: (0, devkit_1.joinPathFragments)('dist', options.rootProject ?
|
488
|
+
: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? appProjectName : appProjectRoot),
|
490
489
|
isUsingTsSolutionConfig,
|
491
490
|
swcJest,
|
492
491
|
};
|
@@ -12,7 +12,6 @@ const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
12
12
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
13
13
|
const config_file_1 = require("@nx/jest/src/utils/config/config-file");
|
14
14
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
15
|
-
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
16
15
|
const posix_1 = require("node:path/posix");
|
17
16
|
const add_swc_config_1 = require("@nx/js/src/utils/swc/add-swc-config");
|
18
17
|
async function e2eProjectGenerator(host, options) {
|
@@ -29,17 +28,18 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
29
28
|
// TODO(@ndcunningham): This is broken.. the outputs are wrong.. and this isn't using the jest generator
|
30
29
|
if (isUsingTsSolutionConfig) {
|
31
30
|
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
|
32
|
-
name:
|
31
|
+
name: options.importPath,
|
33
32
|
version: '0.0.1',
|
34
33
|
private: true,
|
35
34
|
nx: {
|
36
|
-
name: options.e2eProjectName
|
37
|
-
|
35
|
+
name: options.e2eProjectName !== options.importPath
|
36
|
+
? options.e2eProjectName
|
37
|
+
: undefined,
|
38
38
|
implicitDependencies: [options.project],
|
39
39
|
targets: {
|
40
40
|
e2e: {
|
41
41
|
executor: '@nx/jest:jest',
|
42
|
-
outputs: ['{
|
42
|
+
outputs: ['{projectRoot}/test-output/jest/coverage'],
|
43
43
|
options: {
|
44
44
|
jestConfig: `${options.e2eProjectRoot}/jest.config.ts`,
|
45
45
|
passWithNoTests: true,
|
@@ -101,10 +101,11 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
101
101
|
const coverageDirectory = isUsingTsSolutionConfig
|
102
102
|
? 'test-output/jest/coverage'
|
103
103
|
: (0, devkit_1.joinPathFragments)(rootOffset, 'coverage', options.e2eProjectName);
|
104
|
+
const projectSimpleName = options.project.split('/').pop();
|
104
105
|
if (options.projectType === 'server') {
|
105
106
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/common'), options.e2eProjectRoot, {
|
106
107
|
...options,
|
107
|
-
...(0, devkit_1.names)(options.rootProject ? 'server' :
|
108
|
+
...(0, devkit_1.names)(options.rootProject ? 'server' : projectSimpleName),
|
108
109
|
tsConfigFile,
|
109
110
|
offsetFromRoot: rootOffset,
|
110
111
|
jestPreset,
|
@@ -115,7 +116,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
115
116
|
if (options.isNest) {
|
116
117
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/nest'), options.e2eProjectRoot, {
|
117
118
|
...options,
|
118
|
-
...(0, devkit_1.names)(options.rootProject ? 'server' :
|
119
|
+
...(0, devkit_1.names)(options.rootProject ? 'server' : projectSimpleName),
|
119
120
|
tsConfigFile,
|
120
121
|
offsetFromRoot: rootOffset,
|
121
122
|
tmpl: '',
|
@@ -126,7 +127,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
126
127
|
const mainFile = appProject.targets.build?.options?.outputPath;
|
127
128
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/cli'), options.e2eProjectRoot, {
|
128
129
|
...options,
|
129
|
-
...(0, devkit_1.names)(options.rootProject ? 'cli' :
|
130
|
+
...(0, devkit_1.names)(options.rootProject ? 'cli' : projectSimpleName),
|
130
131
|
mainFile,
|
131
132
|
tsConfigFile,
|
132
133
|
offsetFromRoot: rootOffset,
|
@@ -201,11 +202,15 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
201
202
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
202
203
|
}
|
203
204
|
async function normalizeOptions(tree, options) {
|
204
|
-
|
205
|
-
|
205
|
+
let directory = options.rootProject ? 'e2e' : options.directory;
|
206
|
+
if (!directory) {
|
207
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
208
|
+
directory = `${projectConfig.root}-e2e`;
|
209
|
+
}
|
210
|
+
const { projectName: e2eProjectName, projectRoot: e2eProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
206
211
|
name: options.name,
|
207
|
-
projectType: '
|
208
|
-
directory
|
212
|
+
projectType: 'application',
|
213
|
+
directory,
|
209
214
|
});
|
210
215
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
211
216
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
@@ -215,6 +220,7 @@ async function normalizeOptions(tree, options) {
|
|
215
220
|
...options,
|
216
221
|
e2eProjectRoot,
|
217
222
|
e2eProjectName,
|
223
|
+
importPath,
|
218
224
|
port: options.port ?? 3000,
|
219
225
|
rootProject: !!options.rootProject,
|
220
226
|
};
|
@@ -12,7 +12,6 @@ const versions_1 = require("../../utils/versions");
|
|
12
12
|
const init_1 = require("../init/init");
|
13
13
|
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
14
14
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
15
|
-
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
16
15
|
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
17
16
|
async function libraryGenerator(tree, schema) {
|
18
17
|
return await libraryGeneratorInternal(tree, {
|
@@ -36,7 +35,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
36
35
|
options.publishable ||
|
37
36
|
options.buildable) {
|
38
37
|
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
|
39
|
-
name:
|
38
|
+
name: options.importPath,
|
40
39
|
version: '0.0.1',
|
41
40
|
private: true,
|
42
41
|
files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
|
@@ -75,7 +74,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
75
74
|
}
|
76
75
|
exports.default = libraryGenerator;
|
77
76
|
async function normalizeOptions(tree, options) {
|
78
|
-
await (0, project_name_and_root_utils_1.
|
77
|
+
await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'library');
|
79
78
|
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
80
79
|
name: options.name,
|
81
80
|
projectType: 'library',
|
@@ -96,9 +95,7 @@ async function normalizeOptions(tree, options) {
|
|
96
95
|
return {
|
97
96
|
...options,
|
98
97
|
fileName,
|
99
|
-
projectName: isUsingTsSolutionConfig
|
100
|
-
? (0, get_import_path_1.getImportPath)(tree, projectName)
|
101
|
-
: projectName,
|
98
|
+
projectName: isUsingTsSolutionConfig && !options.name ? importPath : projectName,
|
102
99
|
projectRoot,
|
103
100
|
parsedTags,
|
104
101
|
importPath,
|