@nx/node 0.0.0-pr-29464-ce29f31 → 0.0.0-pr-3-81283b1
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": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-3-81283b1",
|
|
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": "0.0.0-pr-
|
|
36
|
-
"@nx/jest": "0.0.0-pr-
|
|
37
|
-
"@nx/js": "0.0.0-pr-
|
|
38
|
-
"@nx/eslint": "0.0.0-pr-
|
|
35
|
+
"@nx/devkit": "0.0.0-pr-3-81283b1",
|
|
36
|
+
"@nx/jest": "0.0.0-pr-3-81283b1",
|
|
37
|
+
"@nx/js": "0.0.0-pr-3-81283b1",
|
|
38
|
+
"@nx/eslint": "0.0.0-pr-3-81283b1"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
|
-
export interface NormalizedSchema extends
|
|
3
|
+
export interface NormalizedSchema extends Schema {
|
|
4
4
|
appProjectRoot: string;
|
|
5
5
|
parsedTags: string[];
|
|
6
6
|
outputPath: string;
|
|
7
|
-
importPath: string;
|
|
8
7
|
isUsingTsSolutionConfig: boolean;
|
|
9
8
|
}
|
|
10
9
|
export declare function addLintingToApplication(tree: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
|
@@ -3,6 +3,7 @@ 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");
|
|
6
7
|
const devkit_1 = require("@nx/devkit");
|
|
7
8
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
8
9
|
const jest_1 = require("@nx/jest");
|
|
@@ -78,6 +79,7 @@ function getEsBuildConfig(project, options) {
|
|
|
78
79
|
}
|
|
79
80
|
function getServeConfig(options) {
|
|
80
81
|
return {
|
|
82
|
+
continuous: true,
|
|
81
83
|
executor: '@nx/js:node',
|
|
82
84
|
defaultConfiguration: 'development',
|
|
83
85
|
// Run build, which includes dependency on "^build" by default, so the first run
|
|
@@ -139,11 +141,13 @@ function addProject(tree, options) {
|
|
|
139
141
|
project.targets.serve = getServeConfig(options);
|
|
140
142
|
if (options.isUsingTsSolutionConfig) {
|
|
141
143
|
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
|
|
142
|
-
name: options.
|
|
144
|
+
name: (0, get_import_path_1.getImportPath)(tree, options.name),
|
|
143
145
|
version: '0.0.1',
|
|
144
146
|
private: true,
|
|
145
147
|
nx: {
|
|
146
|
-
name: options.name
|
|
148
|
+
name: options.name,
|
|
149
|
+
projectType: 'application',
|
|
150
|
+
sourceRoot: project.sourceRoot,
|
|
147
151
|
targets: project.targets,
|
|
148
152
|
tags: project.tags?.length ? project.tags : undefined,
|
|
149
153
|
},
|
|
@@ -191,10 +195,16 @@ function addAppFiles(tree, options) {
|
|
|
191
195
|
}
|
|
192
196
|
function addProxy(tree, options) {
|
|
193
197
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.frontendProject);
|
|
194
|
-
if (projectConfig.targets &&
|
|
198
|
+
if (projectConfig.targets &&
|
|
199
|
+
['serve', 'dev'].find((t) => !!projectConfig.targets[t])) {
|
|
200
|
+
const targetName = ['serve', 'dev'].find((t) => !!projectConfig.targets[t]);
|
|
201
|
+
projectConfig.targets[targetName].dependsOn = [
|
|
202
|
+
...(projectConfig.targets[targetName].dependsOn ?? []),
|
|
203
|
+
`${options.name}:serve`,
|
|
204
|
+
];
|
|
195
205
|
const pathToProxyFile = `${projectConfig.root}/proxy.conf.json`;
|
|
196
|
-
projectConfig.targets.
|
|
197
|
-
...projectConfig.targets.
|
|
206
|
+
projectConfig.targets[targetName].options = {
|
|
207
|
+
...projectConfig.targets[targetName].options,
|
|
198
208
|
proxyConfig: pathToProxyFile,
|
|
199
209
|
};
|
|
200
210
|
if (!tree.exists(pathToProxyFile)) {
|
|
@@ -371,11 +381,6 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
371
381
|
}
|
|
372
382
|
addAppFiles(tree, options);
|
|
373
383
|
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
|
-
}
|
|
379
384
|
updateTsConfigOptions(tree, options);
|
|
380
385
|
if (options.linter === eslint_1.Linter.EsLint) {
|
|
381
386
|
const lintTask = await addLintingToApplication(tree, options);
|
|
@@ -440,6 +445,11 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
440
445
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
441
446
|
: undefined);
|
|
442
447
|
}
|
|
448
|
+
// If we are using the new TS solution
|
|
449
|
+
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
450
|
+
if (options.isUsingTsSolutionConfig) {
|
|
451
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
|
|
452
|
+
}
|
|
443
453
|
(0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
|
|
444
454
|
if (!options.skipFormat) {
|
|
445
455
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -450,8 +460,8 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
450
460
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
451
461
|
}
|
|
452
462
|
async function normalizeOptions(host, options) {
|
|
453
|
-
await (0, project_name_and_root_utils_1.
|
|
454
|
-
const { projectName, projectRoot: appProjectRoot
|
|
463
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
|
464
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
455
465
|
name: options.name,
|
|
456
466
|
projectType: 'application',
|
|
457
467
|
directory: options.directory,
|
|
@@ -468,7 +478,6 @@ async function normalizeOptions(host, options) {
|
|
|
468
478
|
nxJson.useInferencePlugins !== false;
|
|
469
479
|
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
470
480
|
const swcJest = options.swcJest ?? isUsingTsSolutionConfig;
|
|
471
|
-
const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
|
|
472
481
|
return {
|
|
473
482
|
addPlugin,
|
|
474
483
|
...options,
|
|
@@ -477,7 +486,6 @@ async function normalizeOptions(host, options) {
|
|
|
477
486
|
? (0, devkit_1.names)(options.frontendProject).fileName
|
|
478
487
|
: undefined,
|
|
479
488
|
appProjectRoot,
|
|
480
|
-
importPath,
|
|
481
489
|
parsedTags,
|
|
482
490
|
linter: options.linter ?? eslint_1.Linter.EsLint,
|
|
483
491
|
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
@@ -485,7 +493,7 @@ async function normalizeOptions(host, options) {
|
|
|
485
493
|
port: options.port ?? 3000,
|
|
486
494
|
outputPath: isUsingTsSolutionConfig
|
|
487
495
|
? (0, devkit_1.joinPathFragments)(appProjectRoot, 'dist')
|
|
488
|
-
: (0, devkit_1.joinPathFragments)('dist', options.rootProject ?
|
|
496
|
+
: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : appProjectRoot),
|
|
489
497
|
isUsingTsSolutionConfig,
|
|
490
498
|
swcJest,
|
|
491
499
|
};
|
|
@@ -12,6 +12,7 @@ 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");
|
|
15
16
|
const posix_1 = require("node:path/posix");
|
|
16
17
|
const add_swc_config_1 = require("@nx/js/src/utils/swc/add-swc-config");
|
|
17
18
|
async function e2eProjectGenerator(host, options) {
|
|
@@ -28,18 +29,17 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
28
29
|
// TODO(@ndcunningham): This is broken.. the outputs are wrong.. and this isn't using the jest generator
|
|
29
30
|
if (isUsingTsSolutionConfig) {
|
|
30
31
|
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
|
|
31
|
-
name: options.
|
|
32
|
+
name: (0, get_import_path_1.getImportPath)(host, options.e2eProjectName),
|
|
32
33
|
version: '0.0.1',
|
|
33
34
|
private: true,
|
|
34
35
|
nx: {
|
|
35
|
-
name: options.e2eProjectName
|
|
36
|
-
|
|
37
|
-
: undefined,
|
|
36
|
+
name: options.e2eProjectName,
|
|
37
|
+
projectType: 'application',
|
|
38
38
|
implicitDependencies: [options.project],
|
|
39
39
|
targets: {
|
|
40
40
|
e2e: {
|
|
41
41
|
executor: '@nx/jest:jest',
|
|
42
|
-
outputs: ['{
|
|
42
|
+
outputs: ['{workspaceRoot}/coverage/{e2eProjectRoot}'],
|
|
43
43
|
options: {
|
|
44
44
|
jestConfig: `${options.e2eProjectRoot}/jest.config.ts`,
|
|
45
45
|
passWithNoTests: true,
|
|
@@ -101,11 +101,10 @@ 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();
|
|
105
104
|
if (options.projectType === 'server') {
|
|
106
105
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/common'), options.e2eProjectRoot, {
|
|
107
106
|
...options,
|
|
108
|
-
...(0, devkit_1.names)(options.rootProject ? 'server' :
|
|
107
|
+
...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
|
|
109
108
|
tsConfigFile,
|
|
110
109
|
offsetFromRoot: rootOffset,
|
|
111
110
|
jestPreset,
|
|
@@ -116,7 +115,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
116
115
|
if (options.isNest) {
|
|
117
116
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/nest'), options.e2eProjectRoot, {
|
|
118
117
|
...options,
|
|
119
|
-
...(0, devkit_1.names)(options.rootProject ? 'server' :
|
|
118
|
+
...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
|
|
120
119
|
tsConfigFile,
|
|
121
120
|
offsetFromRoot: rootOffset,
|
|
122
121
|
tmpl: '',
|
|
@@ -127,7 +126,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
127
126
|
const mainFile = appProject.targets.build?.options?.outputPath;
|
|
128
127
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/cli'), options.e2eProjectRoot, {
|
|
129
128
|
...options,
|
|
130
|
-
...(0, devkit_1.names)(options.rootProject ? 'cli' :
|
|
129
|
+
...(0, devkit_1.names)(options.rootProject ? 'cli' : options.project),
|
|
131
130
|
mainFile,
|
|
132
131
|
tsConfigFile,
|
|
133
132
|
offsetFromRoot: rootOffset,
|
|
@@ -202,15 +201,11 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
202
201
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
203
202
|
}
|
|
204
203
|
async function normalizeOptions(tree, options) {
|
|
205
|
-
|
|
206
|
-
|
|
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, {
|
|
204
|
+
options.directory = options.directory ?? `${options.project}-e2e`;
|
|
205
|
+
const { projectName: e2eProjectName, projectRoot: e2eProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
211
206
|
name: options.name,
|
|
212
|
-
projectType: '
|
|
213
|
-
directory,
|
|
207
|
+
projectType: 'library',
|
|
208
|
+
directory: options.rootProject ? 'e2e' : options.directory,
|
|
214
209
|
});
|
|
215
210
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
216
211
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
@@ -220,7 +215,6 @@ async function normalizeOptions(tree, options) {
|
|
|
220
215
|
...options,
|
|
221
216
|
e2eProjectRoot,
|
|
222
217
|
e2eProjectName,
|
|
223
|
-
importPath,
|
|
224
218
|
port: options.port ?? 3000,
|
|
225
219
|
rootProject: !!options.rootProject,
|
|
226
220
|
};
|
|
@@ -12,6 +12,7 @@ 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");
|
|
15
16
|
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
16
17
|
async function libraryGenerator(tree, schema) {
|
|
17
18
|
return await libraryGeneratorInternal(tree, {
|
|
@@ -35,7 +36,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
35
36
|
options.publishable ||
|
|
36
37
|
options.buildable) {
|
|
37
38
|
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
|
|
38
|
-
name: options.
|
|
39
|
+
name: (0, get_import_path_1.getImportPath)(tree, options.name),
|
|
39
40
|
version: '0.0.1',
|
|
40
41
|
private: true,
|
|
41
42
|
files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
|
|
@@ -74,7 +75,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
74
75
|
}
|
|
75
76
|
exports.default = libraryGenerator;
|
|
76
77
|
async function normalizeOptions(tree, options) {
|
|
77
|
-
await (0, project_name_and_root_utils_1.
|
|
78
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(tree, options, 'library');
|
|
78
79
|
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
79
80
|
name: options.name,
|
|
80
81
|
projectType: 'library',
|
|
@@ -95,7 +96,9 @@ async function normalizeOptions(tree, options) {
|
|
|
95
96
|
return {
|
|
96
97
|
...options,
|
|
97
98
|
fileName,
|
|
98
|
-
projectName: isUsingTsSolutionConfig
|
|
99
|
+
projectName: isUsingTsSolutionConfig
|
|
100
|
+
? (0, get_import_path_1.getImportPath)(tree, projectName)
|
|
101
|
+
: projectName,
|
|
99
102
|
projectRoot,
|
|
100
103
|
parsedTags,
|
|
101
104
|
importPath,
|