@nx/node 0.0.0-pr-30418-4e2b721 → 0.0.0-pr-3-ec41644
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 +32 -30
- 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-3-ec41644",
|
|
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-ec41644",
|
|
36
|
+
"@nx/jest": "0.0.0-pr-3-ec41644",
|
|
37
|
+
"@nx/js": "0.0.0-pr-3-ec41644",
|
|
38
|
+
"@nx/eslint": "0.0.0-pr-3-ec41644"
|
|
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
|
|
@@ -137,24 +139,23 @@ function addProject(tree, options) {
|
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
141
|
project.targets.serve = getServeConfig(options);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
142
|
+
if (options.isUsingTsSolutionConfig) {
|
|
143
|
+
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
|
|
144
|
+
name: (0, get_import_path_1.getImportPath)(tree, options.name),
|
|
145
|
+
version: '0.0.1',
|
|
146
|
+
private: true,
|
|
147
|
+
nx: {
|
|
148
|
+
name: options.name,
|
|
149
|
+
projectType: 'application',
|
|
150
|
+
sourceRoot: project.sourceRoot,
|
|
151
|
+
targets: project.targets,
|
|
152
|
+
tags: project.tags?.length ? project.tags : undefined,
|
|
153
|
+
},
|
|
154
|
+
});
|
|
151
155
|
}
|
|
152
156
|
else {
|
|
153
157
|
(0, devkit_1.addProjectConfiguration)(tree, options.name, project, options.standaloneConfig);
|
|
154
158
|
}
|
|
155
|
-
if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
|
|
156
|
-
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
|
|
157
|
-
}
|
|
158
159
|
}
|
|
159
160
|
function addAppFiles(tree, options) {
|
|
160
161
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files/common'), options.appProjectRoot, {
|
|
@@ -194,10 +195,16 @@ function addAppFiles(tree, options) {
|
|
|
194
195
|
}
|
|
195
196
|
function addProxy(tree, options) {
|
|
196
197
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.frontendProject);
|
|
197
|
-
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
|
+
];
|
|
198
205
|
const pathToProxyFile = `${projectConfig.root}/proxy.conf.json`;
|
|
199
|
-
projectConfig.targets.
|
|
200
|
-
...projectConfig.targets.
|
|
206
|
+
projectConfig.targets[targetName].options = {
|
|
207
|
+
...projectConfig.targets[targetName].options,
|
|
201
208
|
proxyConfig: pathToProxyFile,
|
|
202
209
|
};
|
|
203
210
|
if (!tree.exists(pathToProxyFile)) {
|
|
@@ -314,7 +321,6 @@ function updateTsConfigOptions(tree, options) {
|
|
|
314
321
|
async function applicationGenerator(tree, schema) {
|
|
315
322
|
return await applicationGeneratorInternal(tree, {
|
|
316
323
|
addPlugin: false,
|
|
317
|
-
useProjectJson: true,
|
|
318
324
|
...schema,
|
|
319
325
|
});
|
|
320
326
|
}
|
|
@@ -375,11 +381,6 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
375
381
|
}
|
|
376
382
|
addAppFiles(tree, options);
|
|
377
383
|
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
|
-
}
|
|
383
384
|
updateTsConfigOptions(tree, options);
|
|
384
385
|
if (options.linter === eslint_1.Linter.EsLint) {
|
|
385
386
|
const lintTask = await addLintingToApplication(tree, options);
|
|
@@ -444,6 +445,11 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
444
445
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
445
446
|
: undefined);
|
|
446
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
|
+
}
|
|
447
453
|
(0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
|
|
448
454
|
if (!options.skipFormat) {
|
|
449
455
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -454,8 +460,8 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
454
460
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
455
461
|
}
|
|
456
462
|
async function normalizeOptions(host, options) {
|
|
457
|
-
await (0, project_name_and_root_utils_1.
|
|
458
|
-
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, {
|
|
459
465
|
name: options.name,
|
|
460
466
|
projectType: 'application',
|
|
461
467
|
directory: options.directory,
|
|
@@ -472,8 +478,6 @@ async function normalizeOptions(host, options) {
|
|
|
472
478
|
nxJson.useInferencePlugins !== false;
|
|
473
479
|
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
474
480
|
const swcJest = options.swcJest ?? isUsingTsSolutionConfig;
|
|
475
|
-
const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
|
|
476
|
-
const useProjectJson = options.useProjectJson ?? !isUsingTsSolutionConfig;
|
|
477
481
|
return {
|
|
478
482
|
addPlugin,
|
|
479
483
|
...options,
|
|
@@ -482,7 +486,6 @@ async function normalizeOptions(host, options) {
|
|
|
482
486
|
? (0, devkit_1.names)(options.frontendProject).fileName
|
|
483
487
|
: undefined,
|
|
484
488
|
appProjectRoot,
|
|
485
|
-
importPath,
|
|
486
489
|
parsedTags,
|
|
487
490
|
linter: options.linter ?? eslint_1.Linter.EsLint,
|
|
488
491
|
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
@@ -490,10 +493,9 @@ async function normalizeOptions(host, options) {
|
|
|
490
493
|
port: options.port ?? 3000,
|
|
491
494
|
outputPath: isUsingTsSolutionConfig
|
|
492
495
|
? (0, devkit_1.joinPathFragments)(appProjectRoot, 'dist')
|
|
493
|
-
: (0, devkit_1.joinPathFragments)('dist', options.rootProject ?
|
|
496
|
+
: (0, devkit_1.joinPathFragments)('dist', options.rootProject ? options.name : appProjectRoot),
|
|
494
497
|
isUsingTsSolutionConfig,
|
|
495
498
|
swcJest,
|
|
496
|
-
useProjectJson,
|
|
497
499
|
};
|
|
498
500
|
}
|
|
499
501
|
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"]
|