@nx/node 0.0.0-pr-29720-06f67e5 → 0.0.0-pr-30418-4f79396
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 +2 -1
- package/src/generators/application/application.js +27 -22
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/application/schema.json +4 -0
- package/src/generators/e2e-project/e2e-project.js +46 -36
- package/src/generators/e2e-project/schema.d.ts +1 -0
- package/src/generators/e2e-project/schema.json +4 -0
- package/src/generators/library/library.js +9 -10
- package/src/generators/library/schema.d.ts +1 -0
- package/src/generators/library/schema.json +4 -0
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-30418-4f79396",
|
|
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-30418-4f79396",
|
|
36
|
+
"@nx/jest": "0.0.0-pr-30418-4f79396",
|
|
37
|
+
"@nx/js": "0.0.0-pr-30418-4f79396",
|
|
38
|
+
"@nx/eslint": "0.0.0-pr-30418-4f79396"
|
|
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");
|
|
@@ -138,23 +137,24 @@ function addProject(tree, options) {
|
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
139
|
project.targets.serve = getServeConfig(options);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
},
|
|
153
|
-
});
|
|
140
|
+
const packageJson = {
|
|
141
|
+
name: options.importPath,
|
|
142
|
+
version: '0.0.1',
|
|
143
|
+
private: true,
|
|
144
|
+
};
|
|
145
|
+
if (!options.useProjectJson) {
|
|
146
|
+
packageJson.nx = {
|
|
147
|
+
name: options.name !== options.importPath ? options.name : undefined,
|
|
148
|
+
targets: project.targets,
|
|
149
|
+
tags: project.tags?.length ? project.tags : undefined,
|
|
150
|
+
};
|
|
154
151
|
}
|
|
155
152
|
else {
|
|
156
153
|
(0, devkit_1.addProjectConfiguration)(tree, options.name, project, options.standaloneConfig);
|
|
157
154
|
}
|
|
155
|
+
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
156
|
+
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
|
|
157
|
+
}
|
|
158
158
|
}
|
|
159
159
|
function addAppFiles(tree, options) {
|
|
160
160
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/common'), options.appProjectRoot, {
|
|
@@ -314,6 +314,7 @@ function updateTsConfigOptions(tree, options) {
|
|
|
314
314
|
async function applicationGenerator(tree, schema) {
|
|
315
315
|
return await applicationGeneratorInternal(tree, {
|
|
316
316
|
addPlugin: false,
|
|
317
|
+
useProjectJson: true,
|
|
317
318
|
...schema,
|
|
318
319
|
});
|
|
319
320
|
}
|
|
@@ -374,6 +375,11 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
374
375
|
}
|
|
375
376
|
addAppFiles(tree, options);
|
|
376
377
|
addProject(tree, options);
|
|
378
|
+
// If we are using the new TS solution
|
|
379
|
+
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
380
|
+
if (options.isUsingTsSolutionConfig) {
|
|
381
|
+
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
|
|
382
|
+
}
|
|
377
383
|
updateTsConfigOptions(tree, options);
|
|
378
384
|
if (options.linter === eslint_1.Linter.EsLint) {
|
|
379
385
|
const lintTask = await addLintingToApplication(tree, options);
|
|
@@ -438,11 +444,6 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
438
444
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
439
445
|
: undefined);
|
|
440
446
|
}
|
|
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
447
|
(0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
|
|
447
448
|
if (!options.skipFormat) {
|
|
448
449
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -453,8 +454,8 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
453
454
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
454
455
|
}
|
|
455
456
|
async function normalizeOptions(host, options) {
|
|
456
|
-
await (0, project_name_and_root_utils_1.
|
|
457
|
-
const { projectName
|
|
457
|
+
await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
|
|
458
|
+
const { projectName, projectRoot: appProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
458
459
|
name: options.name,
|
|
459
460
|
projectType: 'application',
|
|
460
461
|
directory: options.directory,
|
|
@@ -471,6 +472,8 @@ async function normalizeOptions(host, options) {
|
|
|
471
472
|
nxJson.useInferencePlugins !== false;
|
|
472
473
|
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
473
474
|
const swcJest = options.swcJest ?? isUsingTsSolutionConfig;
|
|
475
|
+
const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
|
|
476
|
+
const useProjectJson = options.useProjectJson ?? !isUsingTsSolutionConfig;
|
|
474
477
|
return {
|
|
475
478
|
addPlugin,
|
|
476
479
|
...options,
|
|
@@ -479,6 +482,7 @@ async function normalizeOptions(host, options) {
|
|
|
479
482
|
? (0, devkit_1.names)(options.frontendProject).fileName
|
|
480
483
|
: undefined,
|
|
481
484
|
appProjectRoot,
|
|
485
|
+
importPath,
|
|
482
486
|
parsedTags,
|
|
483
487
|
linter: options.linter ?? eslint_1.Linter.EsLint,
|
|
484
488
|
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
@@ -486,9 +490,10 @@ async function normalizeOptions(host, options) {
|
|
|
486
490
|
port: options.port ?? 3000,
|
|
487
491
|
outputPath: isUsingTsSolutionConfig
|
|
488
492
|
? (0, devkit_1.joinPathFragments)(appProjectRoot, 'dist')
|
|
489
|
-
: (0, devkit_1.joinPathFragments)('dist', options.rootProject ?
|
|
493
|
+
: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? appProjectName : appProjectRoot),
|
|
490
494
|
isUsingTsSolutionConfig,
|
|
491
495
|
swcJest,
|
|
496
|
+
useProjectJson,
|
|
492
497
|
};
|
|
493
498
|
}
|
|
494
499
|
exports.default = applicationGenerator;
|
|
@@ -123,6 +123,10 @@
|
|
|
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."
|
|
126
130
|
}
|
|
127
131
|
},
|
|
128
132
|
"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");
|
|
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) {
|
|
19
18
|
return await e2eProjectGeneratorInternal(host, {
|
|
20
19
|
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);
|
|
29
28
|
// TODO(@ndcunningham): This is broken.. the outputs are wrong.. and this isn't using the jest generator
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
29
|
+
const packageJson = {
|
|
30
|
+
name: options.importPath,
|
|
31
|
+
version: '0.0.1',
|
|
32
|
+
private: true,
|
|
33
|
+
};
|
|
34
|
+
if (!options.useProjectJson) {
|
|
35
|
+
packageJson.nx = {
|
|
36
|
+
name: options.e2eProjectName !== options.importPath
|
|
37
|
+
? options.e2eProjectName
|
|
38
|
+
: undefined,
|
|
39
|
+
implicitDependencies: [options.project],
|
|
40
|
+
targets: {
|
|
41
|
+
e2e: {
|
|
42
|
+
executor: '@nx/jest:jest',
|
|
43
|
+
outputs: ['{projectRoot}/test-output/jest/coverage'],
|
|
44
|
+
options: {
|
|
45
|
+
jestConfig: `${options.e2eProjectRoot}/jest.config.ts`,
|
|
46
|
+
passWithNoTests: true,
|
|
48
47
|
},
|
|
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,6 +68,9 @@ 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
|
+
}
|
|
71
74
|
// TODO(@nicholas): Find a better way to get build target
|
|
72
75
|
// We remove the 'test' target from the e2e project because it is not needed
|
|
73
76
|
// The 'e2e' target is the one that should run the tests for the e2e project
|
|
@@ -94,28 +97,28 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
99
|
const jestPreset = (0, config_file_1.findRootJestPreset)(host) ?? 'jest.preset.js';
|
|
97
|
-
const tsConfigFile = isUsingTsSolutionConfig
|
|
100
|
+
const tsConfigFile = options.isUsingTsSolutionConfig
|
|
98
101
|
? 'tsconfig.json'
|
|
99
102
|
: 'tsconfig.spec.json';
|
|
100
103
|
const rootOffset = (0, devkit_1.offsetFromRoot)(options.e2eProjectRoot);
|
|
101
|
-
const coverageDirectory = isUsingTsSolutionConfig
|
|
104
|
+
const coverageDirectory = options.isUsingTsSolutionConfig
|
|
102
105
|
? 'test-output/jest/coverage'
|
|
103
106
|
: (0, devkit_1.joinPathFragments)(rootOffset, 'coverage', options.e2eProjectName);
|
|
107
|
+
const projectSimpleName = options.project.split('/').pop();
|
|
104
108
|
if (options.projectType === 'server') {
|
|
105
109
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/common'), options.e2eProjectRoot, {
|
|
106
110
|
...options,
|
|
107
|
-
...(0, devkit_1.names)(options.rootProject ? 'server' :
|
|
111
|
+
...(0, devkit_1.names)(options.rootProject ? 'server' : projectSimpleName),
|
|
108
112
|
tsConfigFile,
|
|
109
113
|
offsetFromRoot: rootOffset,
|
|
110
114
|
jestPreset,
|
|
111
115
|
coverageDirectory,
|
|
112
|
-
isUsingTsSolutionConfig,
|
|
113
116
|
tmpl: '',
|
|
114
117
|
});
|
|
115
118
|
if (options.isNest) {
|
|
116
119
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/server/nest'), options.e2eProjectRoot, {
|
|
117
120
|
...options,
|
|
118
|
-
...(0, devkit_1.names)(options.rootProject ? 'server' :
|
|
121
|
+
...(0, devkit_1.names)(options.rootProject ? 'server' : projectSimpleName),
|
|
119
122
|
tsConfigFile,
|
|
120
123
|
offsetFromRoot: rootOffset,
|
|
121
124
|
tmpl: '',
|
|
@@ -126,17 +129,16 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
126
129
|
const mainFile = appProject.targets.build?.options?.outputPath;
|
|
127
130
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/cli'), options.e2eProjectRoot, {
|
|
128
131
|
...options,
|
|
129
|
-
...(0, devkit_1.names)(options.rootProject ? 'cli' :
|
|
132
|
+
...(0, devkit_1.names)(options.rootProject ? 'cli' : projectSimpleName),
|
|
130
133
|
mainFile,
|
|
131
134
|
tsConfigFile,
|
|
132
135
|
offsetFromRoot: rootOffset,
|
|
133
136
|
jestPreset,
|
|
134
137
|
coverageDirectory,
|
|
135
|
-
isUsingTsSolutionConfig,
|
|
136
138
|
tmpl: '',
|
|
137
139
|
});
|
|
138
140
|
}
|
|
139
|
-
if (isUsingTsSolutionConfig) {
|
|
141
|
+
if (options.isUsingTsSolutionConfig) {
|
|
140
142
|
(0, add_swc_config_1.addSwcTestConfig)(host, options.e2eProjectRoot, 'es6');
|
|
141
143
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/ts-solution'), options.e2eProjectRoot, {
|
|
142
144
|
...options,
|
|
@@ -177,7 +179,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
177
179
|
]);
|
|
178
180
|
}
|
|
179
181
|
}
|
|
180
|
-
if (isUsingTsSolutionConfig) {
|
|
182
|
+
if (options.isUsingTsSolutionConfig) {
|
|
181
183
|
(0, devkit_1.updateJson)(host, 'tsconfig.json', (json) => {
|
|
182
184
|
json.references ??= [];
|
|
183
185
|
const e2eRef = `./${options.e2eProjectRoot}`;
|
|
@@ -189,8 +191,8 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
189
191
|
}
|
|
190
192
|
// If we are using the new TS solution
|
|
191
193
|
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
192
|
-
if (isUsingTsSolutionConfig) {
|
|
193
|
-
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.e2eProjectRoot);
|
|
194
|
+
if (options.isUsingTsSolutionConfig) {
|
|
195
|
+
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.e2eProjectRoot);
|
|
194
196
|
}
|
|
195
197
|
if (!options.skipFormat) {
|
|
196
198
|
await (0, devkit_1.formatFiles)(host);
|
|
@@ -201,22 +203,30 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
201
203
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
202
204
|
}
|
|
203
205
|
async function normalizeOptions(tree, options) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
+
let directory = options.rootProject ? 'e2e' : options.directory;
|
|
207
|
+
if (!directory) {
|
|
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, {
|
|
206
212
|
name: options.name,
|
|
207
|
-
projectType: '
|
|
208
|
-
directory
|
|
213
|
+
projectType: 'application',
|
|
214
|
+
directory,
|
|
209
215
|
});
|
|
210
216
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
211
217
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
212
218
|
nxJson.useInferencePlugins !== false;
|
|
219
|
+
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
|
|
213
220
|
return {
|
|
214
221
|
addPlugin,
|
|
215
222
|
...options,
|
|
216
223
|
e2eProjectRoot,
|
|
217
224
|
e2eProjectName,
|
|
225
|
+
importPath,
|
|
218
226
|
port: options.port ?? 3000,
|
|
219
227
|
rootProject: !!options.rootProject,
|
|
228
|
+
isUsingTsSolutionConfig,
|
|
229
|
+
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
220
230
|
};
|
|
221
231
|
}
|
|
222
232
|
exports.default = e2eProjectGenerator;
|
|
@@ -59,6 +59,10 @@
|
|
|
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."
|
|
62
66
|
}
|
|
63
67
|
},
|
|
64
68
|
"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");
|
|
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, {
|
|
19
18
|
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
|
-
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.projectRoot);
|
|
28
|
+
await (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 (options.
|
|
35
|
+
if (!options.useProjectJson ||
|
|
36
|
+
options.isUsingTsSolutionConfig ||
|
|
36
37
|
options.publishable ||
|
|
37
38
|
options.buildable) {
|
|
38
39
|
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
|
|
39
|
-
name:
|
|
40
|
+
name: options.importPath,
|
|
40
41
|
version: '0.0.1',
|
|
41
42
|
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:
|
|
53
|
+
useProjectJson: options.useProjectJson,
|
|
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.ensureRootProjectName)(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,13 +96,12 @@ async function normalizeOptions(tree, options) {
|
|
|
96
96
|
return {
|
|
97
97
|
...options,
|
|
98
98
|
fileName,
|
|
99
|
-
projectName: isUsingTsSolutionConfig
|
|
100
|
-
? (0, get_import_path_1.getImportPath)(tree, projectName)
|
|
101
|
-
: projectName,
|
|
99
|
+
projectName: isUsingTsSolutionConfig && !options.name ? importPath : projectName,
|
|
102
100
|
projectRoot,
|
|
103
101
|
parsedTags,
|
|
104
102
|
importPath,
|
|
105
103
|
isUsingTsSolutionConfig,
|
|
104
|
+
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
106
105
|
};
|
|
107
106
|
}
|
|
108
107
|
function createFiles(tree, options) {
|
|
@@ -123,6 +123,10 @@
|
|
|
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."
|
|
126
130
|
}
|
|
127
131
|
},
|
|
128
132
|
"required": ["directory"]
|