@nx/node 0.0.0-pr-29993-0fbf3d3 → 0.0.0-pr-29720-06f67e5
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 +5 -5
- package/src/generators/application/application.d.ts +1 -2
- package/src/generators/application/application.js +25 -37
- package/src/generators/application/schema.d.ts +0 -1
- package/src/generators/application/schema.json +0 -4
- package/src/generators/e2e-project/e2e-project.js +36 -46
- package/src/generators/e2e-project/schema.d.ts +0 -1
- package/src/generators/e2e-project/schema.json +0 -4
- package/src/generators/library/library.js +10 -9
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +0 -4
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-29720-06f67e5",
|
|
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-29720-06f67e5",
|
|
36
|
+
"@nx/jest": "0.0.0-pr-29720-06f67e5",
|
|
37
|
+
"@nx/js": "0.0.0-pr-29720-06f67e5",
|
|
38
|
+
"@nx/eslint": "0.0.0-pr-29720-06f67e5"
|
|
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,7 +79,6 @@ function getEsBuildConfig(project, options) {
|
|
|
78
79
|
}
|
|
79
80
|
function getServeConfig(options) {
|
|
80
81
|
return {
|
|
81
|
-
continuous: true,
|
|
82
82
|
executor: '@nx/js:node',
|
|
83
83
|
defaultConfiguration: 'development',
|
|
84
84
|
// Run build, which includes dependency on "^build" by default, so the first run
|
|
@@ -138,24 +138,23 @@ function addProject(tree, options) {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
project.targets.serve = getServeConfig(options);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
141
|
+
if (options.isUsingTsSolutionConfig) {
|
|
142
|
+
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
|
|
143
|
+
name: (0, get_import_path_1.getImportPath)(tree, options.name),
|
|
144
|
+
version: '0.0.1',
|
|
145
|
+
private: true,
|
|
146
|
+
nx: {
|
|
147
|
+
name: options.name,
|
|
148
|
+
projectType: 'application',
|
|
149
|
+
sourceRoot: project.sourceRoot,
|
|
150
|
+
targets: project.targets,
|
|
151
|
+
tags: project.tags?.length ? project.tags : undefined,
|
|
152
|
+
},
|
|
153
|
+
});
|
|
152
154
|
}
|
|
153
155
|
else {
|
|
154
156
|
(0, devkit_1.addProjectConfiguration)(tree, options.name, project, options.standaloneConfig);
|
|
155
157
|
}
|
|
156
|
-
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
157
|
-
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
|
|
158
|
-
}
|
|
159
158
|
}
|
|
160
159
|
function addAppFiles(tree, options) {
|
|
161
160
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/common'), options.appProjectRoot, {
|
|
@@ -195,16 +194,10 @@ function addAppFiles(tree, options) {
|
|
|
195
194
|
}
|
|
196
195
|
function addProxy(tree, options) {
|
|
197
196
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.frontendProject);
|
|
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
|
-
];
|
|
197
|
+
if (projectConfig.targets && projectConfig.targets.serve) {
|
|
205
198
|
const pathToProxyFile = `${projectConfig.root}/proxy.conf.json`;
|
|
206
|
-
projectConfig.targets
|
|
207
|
-
...projectConfig.targets
|
|
199
|
+
projectConfig.targets.serve.options = {
|
|
200
|
+
...projectConfig.targets.serve.options,
|
|
208
201
|
proxyConfig: pathToProxyFile,
|
|
209
202
|
};
|
|
210
203
|
if (!tree.exists(pathToProxyFile)) {
|
|
@@ -321,7 +314,6 @@ function updateTsConfigOptions(tree, options) {
|
|
|
321
314
|
async function applicationGenerator(tree, schema) {
|
|
322
315
|
return await applicationGeneratorInternal(tree, {
|
|
323
316
|
addPlugin: false,
|
|
324
|
-
useProjectJson: true,
|
|
325
317
|
...schema,
|
|
326
318
|
});
|
|
327
319
|
}
|
|
@@ -382,11 +374,6 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
382
374
|
}
|
|
383
375
|
addAppFiles(tree, options);
|
|
384
376
|
addProject(tree, options);
|
|
385
|
-
// If we are using the new TS solution
|
|
386
|
-
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
387
|
-
if (options.isUsingTsSolutionConfig) {
|
|
388
|
-
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
|
|
389
|
-
}
|
|
390
377
|
updateTsConfigOptions(tree, options);
|
|
391
378
|
if (options.linter === eslint_1.Linter.EsLint) {
|
|
392
379
|
const lintTask = await addLintingToApplication(tree, options);
|
|
@@ -451,6 +438,11 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
451
438
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
452
439
|
: undefined);
|
|
453
440
|
}
|
|
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
|
+
}
|
|
454
446
|
(0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
|
|
455
447
|
if (!options.skipFormat) {
|
|
456
448
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -461,8 +453,8 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
461
453
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
462
454
|
}
|
|
463
455
|
async function normalizeOptions(host, options) {
|
|
464
|
-
await (0, project_name_and_root_utils_1.
|
|
465
|
-
const { projectName, projectRoot: appProjectRoot
|
|
456
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
|
457
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
466
458
|
name: options.name,
|
|
467
459
|
projectType: 'application',
|
|
468
460
|
directory: options.directory,
|
|
@@ -479,8 +471,6 @@ async function normalizeOptions(host, options) {
|
|
|
479
471
|
nxJson.useInferencePlugins !== false;
|
|
480
472
|
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
481
473
|
const swcJest = options.swcJest ?? isUsingTsSolutionConfig;
|
|
482
|
-
const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
|
|
483
|
-
const useProjectJson = options.useProjectJson ?? !isUsingTsSolutionConfig;
|
|
484
474
|
return {
|
|
485
475
|
addPlugin,
|
|
486
476
|
...options,
|
|
@@ -489,7 +479,6 @@ async function normalizeOptions(host, options) {
|
|
|
489
479
|
? (0, devkit_1.names)(options.frontendProject).fileName
|
|
490
480
|
: undefined,
|
|
491
481
|
appProjectRoot,
|
|
492
|
-
importPath,
|
|
493
482
|
parsedTags,
|
|
494
483
|
linter: options.linter ?? eslint_1.Linter.EsLint,
|
|
495
484
|
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
@@ -497,10 +486,9 @@ async function normalizeOptions(host, options) {
|
|
|
497
486
|
port: options.port ?? 3000,
|
|
498
487
|
outputPath: isUsingTsSolutionConfig
|
|
499
488
|
? (0, devkit_1.joinPathFragments)(appProjectRoot, 'dist')
|
|
500
|
-
: (0, devkit_1.joinPathFragments)('dist', options.rootProject ?
|
|
489
|
+
: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : appProjectRoot),
|
|
501
490
|
isUsingTsSolutionConfig,
|
|
502
491
|
swcJest,
|
|
503
|
-
useProjectJson,
|
|
504
492
|
};
|
|
505
493
|
}
|
|
506
494
|
exports.default = applicationGenerator;
|
|
@@ -123,10 +123,6 @@
|
|
|
123
123
|
"docker": {
|
|
124
124
|
"type": "boolean",
|
|
125
125
|
"description": "Add a docker build target"
|
|
126
|
-
},
|
|
127
|
-
"useProjectJson": {
|
|
128
|
-
"type": "boolean",
|
|
129
|
-
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
130
126
|
}
|
|
131
127
|
},
|
|
132
128
|
"required": ["directory"]
|
|
@@ -12,12 +12,12 @@ 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) {
|
|
18
19
|
return await e2eProjectGeneratorInternal(host, {
|
|
19
20
|
addPlugin: false,
|
|
20
|
-
useProjectJson: true,
|
|
21
21
|
...options,
|
|
22
22
|
});
|
|
23
23
|
}
|
|
@@ -25,30 +25,30 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
25
25
|
const tasks = [];
|
|
26
26
|
const options = await normalizeOptions(host, _options);
|
|
27
27
|
const appProject = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
28
|
+
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
28
29
|
// TODO(@ndcunningham): This is broken.. the outputs are wrong.. and this isn't using the jest generator
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
if (isUsingTsSolutionConfig) {
|
|
31
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
|
|
32
|
+
name: (0, get_import_path_1.getImportPath)(host, options.e2eProjectName),
|
|
33
|
+
version: '0.0.1',
|
|
34
|
+
private: true,
|
|
35
|
+
nx: {
|
|
36
|
+
name: options.e2eProjectName,
|
|
37
|
+
projectType: 'application',
|
|
38
|
+
implicitDependencies: [options.project],
|
|
39
|
+
targets: {
|
|
40
|
+
e2e: {
|
|
41
|
+
executor: '@nx/jest:jest',
|
|
42
|
+
outputs: ['{workspaceRoot}/coverage/{e2eProjectRoot}'],
|
|
43
|
+
options: {
|
|
44
|
+
jestConfig: `${options.e2eProjectRoot}/jest.config.ts`,
|
|
45
|
+
passWithNoTests: true,
|
|
46
|
+
},
|
|
47
|
+
dependsOn: [`${options.project}:build`],
|
|
47
48
|
},
|
|
48
|
-
dependsOn: [`${options.project}:build`],
|
|
49
49
|
},
|
|
50
50
|
},
|
|
51
|
-
};
|
|
51
|
+
});
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
54
|
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
@@ -68,9 +68,6 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
68
68
|
},
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
72
|
-
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
|
|
73
|
-
}
|
|
74
71
|
// TODO(@nicholas): Find a better way to get build target
|
|
75
72
|
// We remove the 'test' target from the e2e project because it is not needed
|
|
76
73
|
// The 'e2e' target is the one that should run the tests for the e2e project
|
|
@@ -97,28 +94,28 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
97
94
|
});
|
|
98
95
|
}
|
|
99
96
|
const jestPreset = (0, config_file_1.findRootJestPreset)(host) ?? 'jest.preset.js';
|
|
100
|
-
const tsConfigFile =
|
|
97
|
+
const tsConfigFile = isUsingTsSolutionConfig
|
|
101
98
|
? 'tsconfig.json'
|
|
102
99
|
: 'tsconfig.spec.json';
|
|
103
100
|
const rootOffset = (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot);
|
|
104
|
-
const coverageDirectory =
|
|
101
|
+
const coverageDirectory = isUsingTsSolutionConfig
|
|
105
102
|
? 'test-output/jest/coverage'
|
|
106
103
|
: (0, devkit_1.joinPathFragments)(rootOffset, 'coverage', options.e2eProjectName);
|
|
107
|
-
const projectSimpleName = options.project.split('/').pop();
|
|
108
104
|
if (options.projectType === 'server') {
|
|
109
105
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/common'), options.e2eProjectRoot, {
|
|
110
106
|
...options,
|
|
111
|
-
...(0, devkit_1.names)(options.rootProject ? 'server' :
|
|
107
|
+
...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
|
|
112
108
|
tsConfigFile,
|
|
113
109
|
offsetFromRoot: rootOffset,
|
|
114
110
|
jestPreset,
|
|
115
111
|
coverageDirectory,
|
|
112
|
+
isUsingTsSolutionConfig,
|
|
116
113
|
tmpl: '',
|
|
117
114
|
});
|
|
118
115
|
if (options.isNest) {
|
|
119
116
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/nest'), options.e2eProjectRoot, {
|
|
120
117
|
...options,
|
|
121
|
-
...(0, devkit_1.names)(options.rootProject ? 'server' :
|
|
118
|
+
...(0, devkit_1.names)(options.rootProject ? 'server' : options.project),
|
|
122
119
|
tsConfigFile,
|
|
123
120
|
offsetFromRoot: rootOffset,
|
|
124
121
|
tmpl: '',
|
|
@@ -129,16 +126,17 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
129
126
|
const mainFile = appProject.targets.build?.options?.outputPath;
|
|
130
127
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/cli'), options.e2eProjectRoot, {
|
|
131
128
|
...options,
|
|
132
|
-
...(0, devkit_1.names)(options.rootProject ? 'cli' :
|
|
129
|
+
...(0, devkit_1.names)(options.rootProject ? 'cli' : options.project),
|
|
133
130
|
mainFile,
|
|
134
131
|
tsConfigFile,
|
|
135
132
|
offsetFromRoot: rootOffset,
|
|
136
133
|
jestPreset,
|
|
137
134
|
coverageDirectory,
|
|
135
|
+
isUsingTsSolutionConfig,
|
|
138
136
|
tmpl: '',
|
|
139
137
|
});
|
|
140
138
|
}
|
|
141
|
-
if (
|
|
139
|
+
if (isUsingTsSolutionConfig) {
|
|
142
140
|
(0, add_swc_config_1.addSwcTestConfig)(host, options.e2eProjectRoot, 'es6');
|
|
143
141
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/ts-solution'), options.e2eProjectRoot, {
|
|
144
142
|
...options,
|
|
@@ -179,7 +177,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
179
177
|
]);
|
|
180
178
|
}
|
|
181
179
|
}
|
|
182
|
-
if (
|
|
180
|
+
if (isUsingTsSolutionConfig) {
|
|
183
181
|
(0, devkit_1.updateJson)(host, 'tsconfig.json', (json) => {
|
|
184
182
|
json.references ??= [];
|
|
185
183
|
const e2eRef = `./${options.e2eProjectRoot}`;
|
|
@@ -191,8 +189,8 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
191
189
|
}
|
|
192
190
|
// If we are using the new TS solution
|
|
193
191
|
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
194
|
-
if (
|
|
195
|
-
|
|
192
|
+
if (isUsingTsSolutionConfig) {
|
|
193
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.e2eProjectRoot);
|
|
196
194
|
}
|
|
197
195
|
if (!options.skipFormat) {
|
|
198
196
|
await (0, devkit_1.formatFiles)(host);
|
|
@@ -203,30 +201,22 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
203
201
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
204
202
|
}
|
|
205
203
|
async function normalizeOptions(tree, options) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
209
|
-
directory = `${projectConfig.root}-e2e`;
|
|
210
|
-
}
|
|
211
|
-
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, {
|
|
212
206
|
name: options.name,
|
|
213
|
-
projectType: '
|
|
214
|
-
directory,
|
|
207
|
+
projectType: 'library',
|
|
208
|
+
directory: options.rootProject ? 'e2e' : options.directory,
|
|
215
209
|
});
|
|
216
210
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
217
211
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
218
212
|
nxJson.useInferencePlugins !== false;
|
|
219
|
-
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
|
|
220
213
|
return {
|
|
221
214
|
addPlugin,
|
|
222
215
|
...options,
|
|
223
216
|
e2eProjectRoot,
|
|
224
217
|
e2eProjectName,
|
|
225
|
-
importPath,
|
|
226
218
|
port: options.port ?? 3000,
|
|
227
219
|
rootProject: !!options.rootProject,
|
|
228
|
-
isUsingTsSolutionConfig,
|
|
229
|
-
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
230
220
|
};
|
|
231
221
|
}
|
|
232
222
|
exports.default = e2eProjectGenerator;
|
|
@@ -59,10 +59,6 @@
|
|
|
59
59
|
"default": false,
|
|
60
60
|
"hidden": true,
|
|
61
61
|
"x-priority": "internal"
|
|
62
|
-
},
|
|
63
|
-
"useProjectJson": {
|
|
64
|
-
"type": "boolean",
|
|
65
|
-
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
66
62
|
}
|
|
67
63
|
},
|
|
68
64
|
"required": ["project"]
|
|
@@ -12,11 +12,11 @@ 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, {
|
|
18
19
|
addPlugin: false,
|
|
19
|
-
useProjectJson: true,
|
|
20
20
|
...schema,
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -25,21 +25,21 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
25
25
|
// If we are using the new TS solution
|
|
26
26
|
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
27
27
|
if (options.isUsingTsSolutionConfig) {
|
|
28
|
-
|
|
28
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.projectRoot);
|
|
29
29
|
}
|
|
30
30
|
const tasks = [];
|
|
31
31
|
if (options.publishable === true && !schema.importPath) {
|
|
32
32
|
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)`);
|
|
33
33
|
}
|
|
34
34
|
// Create `package.json` first because @nx/js:lib generator will update it.
|
|
35
|
-
if (
|
|
36
|
-
options.isUsingTsSolutionConfig ||
|
|
35
|
+
if (options.isUsingTsSolutionConfig ||
|
|
37
36
|
options.publishable ||
|
|
38
37
|
options.buildable) {
|
|
39
38
|
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
|
|
40
|
-
name: options.
|
|
39
|
+
name: (0, get_import_path_1.getImportPath)(tree, options.name),
|
|
41
40
|
version: '0.0.1',
|
|
42
41
|
private: true,
|
|
42
|
+
files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
tasks.push(await (0, js_1.libraryGenerator)(tree, {
|
|
@@ -50,7 +50,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
50
50
|
testEnvironment: 'node',
|
|
51
51
|
skipFormat: true,
|
|
52
52
|
setParserOptionsProject: schema.setParserOptionsProject,
|
|
53
|
-
useProjectJson: options.
|
|
53
|
+
useProjectJson: !options.isUsingTsSolutionConfig,
|
|
54
54
|
}));
|
|
55
55
|
updatePackageJson(tree, options);
|
|
56
56
|
tasks.push(await (0, init_1.initGenerator)(tree, {
|
|
@@ -75,7 +75,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
75
75
|
}
|
|
76
76
|
exports.default = libraryGenerator;
|
|
77
77
|
async function normalizeOptions(tree, options) {
|
|
78
|
-
await (0, project_name_and_root_utils_1.
|
|
78
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(tree, options, 'library');
|
|
79
79
|
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
80
80
|
name: options.name,
|
|
81
81
|
projectType: 'library',
|
|
@@ -96,12 +96,13 @@ async function normalizeOptions(tree, options) {
|
|
|
96
96
|
return {
|
|
97
97
|
...options,
|
|
98
98
|
fileName,
|
|
99
|
-
projectName: isUsingTsSolutionConfig
|
|
99
|
+
projectName: isUsingTsSolutionConfig
|
|
100
|
+
? (0, get_import_path_1.getImportPath)(tree, projectName)
|
|
101
|
+
: projectName,
|
|
100
102
|
projectRoot,
|
|
101
103
|
parsedTags,
|
|
102
104
|
importPath,
|
|
103
105
|
isUsingTsSolutionConfig,
|
|
104
|
-
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
108
|
function createFiles(tree, options) {
|
|
@@ -123,10 +123,6 @@
|
|
|
123
123
|
"type": "boolean",
|
|
124
124
|
"description": "Whether or not to configure the ESLint `parserOptions.project`. We do not do this by default for lint performance reasons.",
|
|
125
125
|
"default": false
|
|
126
|
-
},
|
|
127
|
-
"useProjectJson": {
|
|
128
|
-
"type": "boolean",
|
|
129
|
-
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
130
126
|
}
|
|
131
127
|
},
|
|
132
128
|
"required": ["directory"]
|