@nx/plugin 24.0.0-beta.2 → 24.0.0-beta.3
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/dist/src/generators/create-package/create-package.js +8 -1
- package/dist/src/generators/create-package/schema.d.ts +0 -1
- package/dist/src/generators/create-package/utils/normalize-schema.d.ts +0 -1
- package/dist/src/generators/create-package/utils/normalize-schema.js +1 -9
- package/dist/src/generators/e2e-project/e2e.js +26 -37
- package/dist/src/generators/e2e-project/schema.d.ts +0 -1
- package/dist/src/generators/lint-checks/generator.js +2 -4
- package/dist/src/generators/plugin/plugin.js +8 -3
- package/dist/src/generators/plugin/schema.d.ts +0 -1
- package/dist/src/generators/plugin/utils/normalize-schema.d.ts +1 -2
- package/dist/src/generators/plugin/utils/normalize-schema.js +1 -9
- package/dist/src/generators/preset/generator.js +0 -3
- package/dist/src/generators/preset/schema.d.ts +0 -1
- package/package.json +7 -7
|
@@ -5,6 +5,7 @@ exports.createPackageGeneratorInternal = createPackageGeneratorInternal;
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const js_1 = require("@nx/js");
|
|
7
7
|
const internal_1 = require("@nx/js/internal");
|
|
8
|
+
const jest_1 = require("@nx/jest");
|
|
8
9
|
const path_1 = require("path");
|
|
9
10
|
const has_generator_1 = require("../../utils/has-generator");
|
|
10
11
|
const generator_1 = require("../generator/generator");
|
|
@@ -13,7 +14,6 @@ const internal_2 = require("@nx/devkit/internal");
|
|
|
13
14
|
async function createPackageGenerator(host, schema) {
|
|
14
15
|
return await createPackageGeneratorInternal(host, {
|
|
15
16
|
useProjectJson: true,
|
|
16
|
-
addPlugin: false,
|
|
17
17
|
...schema,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
@@ -73,6 +73,13 @@ async function createCliPackage(host, options, pluginPackageName) {
|
|
|
73
73
|
useTscExecutor: true,
|
|
74
74
|
});
|
|
75
75
|
host.delete((0, devkit_1.joinPathFragments)(options.projectRoot, 'src'));
|
|
76
|
+
if (options.unitTestRunner === 'jest') {
|
|
77
|
+
// src and its spec are removed above, so the package has no tests yet.
|
|
78
|
+
const jestConfig = (0, jest_1.findJestConfig)(host, options.projectRoot);
|
|
79
|
+
if (jestConfig) {
|
|
80
|
+
(0, jest_1.addPropertyToJestConfig)(host, jestConfig, 'passWithNoTests', true);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
76
83
|
const isTsSolutionSetup = (0, internal_1.isUsingTsSolutionSetup)(host);
|
|
77
84
|
// Add the bin entry to the package.json
|
|
78
85
|
(0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), (packageJson) => {
|
|
@@ -8,7 +8,6 @@ export interface NormalizedSchema extends CreatePackageSchema {
|
|
|
8
8
|
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
9
9
|
linter: LinterType;
|
|
10
10
|
useProjectJson: boolean;
|
|
11
|
-
addPlugin: boolean;
|
|
12
11
|
isTsSolutionSetup: boolean;
|
|
13
12
|
}
|
|
14
13
|
export declare function normalizeSchema(host: Tree, schema: CreatePackageSchema): Promise<NormalizedSchema>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeSchema = normalizeSchema;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
5
|
const internal_2 = require("@nx/js/internal");
|
|
7
6
|
async function normalizeSchema(host, schema) {
|
|
@@ -19,13 +18,7 @@ async function normalizeSchema(host, schema) {
|
|
|
19
18
|
// jsLibraryGenerator, so, if the TS solution setup is not configured, we
|
|
20
19
|
// additionally check if the TS solution setup will be configured by the
|
|
21
20
|
// jsLibraryGenerator
|
|
22
|
-
const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(host) ||
|
|
23
|
-
(0, internal_2.shouldConfigureTsSolutionSetup)(host, schema.addPlugin);
|
|
24
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
25
|
-
const addPlugin = schema.addPlugin ??
|
|
26
|
-
(isTsSolutionSetup &&
|
|
27
|
-
process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
28
|
-
nxJson.useInferencePlugins !== false);
|
|
21
|
+
const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(host) || (0, internal_2.shouldConfigureTsSolutionSetup)(host);
|
|
29
22
|
return {
|
|
30
23
|
...schema,
|
|
31
24
|
bundler: schema.compiler ?? 'tsc',
|
|
@@ -36,7 +29,6 @@ async function normalizeSchema(host, schema) {
|
|
|
36
29
|
unitTestRunner,
|
|
37
30
|
// We default to generate a project.json file if the new setup is not being used
|
|
38
31
|
useProjectJson: schema.useProjectJson ?? !isTsSolutionSetup,
|
|
39
|
-
addPlugin,
|
|
40
32
|
isTsSolutionSetup,
|
|
41
33
|
};
|
|
42
34
|
}
|
|
@@ -12,10 +12,6 @@ const versions_1 = require("../../utils/versions");
|
|
|
12
12
|
async function normalizeOptions(host, options) {
|
|
13
13
|
const linter = await (0, internal_2.normalizeLinterOption)(host, options.linter);
|
|
14
14
|
const projectName = options.rootProject ? 'e2e' : `${options.pluginName}-e2e`;
|
|
15
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
16
|
-
const addPlugin = options.addPlugin ??
|
|
17
|
-
(process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
18
|
-
nxJson.useInferencePlugins !== false);
|
|
19
15
|
let projectRoot;
|
|
20
16
|
const projectNameAndRootOptions = await (0, internal_1.determineProjectNameAndRootOptions)(host, {
|
|
21
17
|
name: projectName,
|
|
@@ -33,7 +29,6 @@ async function normalizeOptions(host, options) {
|
|
|
33
29
|
linter,
|
|
34
30
|
pluginPropertyName,
|
|
35
31
|
projectRoot,
|
|
36
|
-
addPlugin,
|
|
37
32
|
useProjectJson: options.useProjectJson ?? !isTsSolutionSetup,
|
|
38
33
|
isTsSolutionSetup,
|
|
39
34
|
};
|
|
@@ -90,7 +85,6 @@ async function addJest(host, options) {
|
|
|
90
85
|
supportTsx: false,
|
|
91
86
|
skipSerializers: true,
|
|
92
87
|
skipFormat: true,
|
|
93
|
-
addPlugin: options.addPlugin,
|
|
94
88
|
compiler: options.isTsSolutionSetup ? 'swc' : undefined,
|
|
95
89
|
});
|
|
96
90
|
const { startLocalRegistryPath, stopLocalRegistryPath } = (0, internal_2.addLocalRegistryScripts)(host);
|
|
@@ -102,18 +96,17 @@ async function addJest(host, options) {
|
|
|
102
96
|
(0, jest_1.addPropertyToJestConfig)(host, jestConfigPath, 'globalTeardown', (0, path_1.join)((0, devkit_1.offsetFromRoot)(options.projectRoot), stopLocalRegistryPath));
|
|
103
97
|
const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
104
98
|
project.targets ??= {};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
99
|
+
// The e2e target is inferred, so this partial target merges onto it.
|
|
100
|
+
const e2eTarget = project.targets.e2e;
|
|
101
|
+
project.targets.e2e = {
|
|
102
|
+
...e2eTarget,
|
|
103
|
+
dependsOn: [`^build`],
|
|
104
|
+
options: {
|
|
105
|
+
...e2eTarget?.options,
|
|
106
|
+
runInBand: true,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, project);
|
|
117
110
|
return jestTask;
|
|
118
111
|
}
|
|
119
112
|
async function addVitest(host, options) {
|
|
@@ -145,7 +138,6 @@ async function addVitest(host, options) {
|
|
|
145
138
|
project: options.projectName,
|
|
146
139
|
testTarget: 'e2e',
|
|
147
140
|
skipFormat: true,
|
|
148
|
-
addPlugin: options.addPlugin,
|
|
149
141
|
testEnvironment: 'node',
|
|
150
142
|
coverageProvider: 'none',
|
|
151
143
|
});
|
|
@@ -203,22 +195,21 @@ export { default as teardown } from './stop-local-registry';
|
|
|
203
195
|
}
|
|
204
196
|
const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
205
197
|
project.targets ??= {};
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
198
|
+
const e2eTarget = project.targets.e2e;
|
|
199
|
+
// The suites share a single tmp/test-project directory, so they have to run
|
|
200
|
+
// one at a time. Vitest 4 removed `poolOptions`, and nested options do not
|
|
201
|
+
// survive the argv round-trip anyway, so use the scalar options. The e2e
|
|
202
|
+
// target is inferred, so this partial target merges onto it.
|
|
203
|
+
project.targets.e2e = {
|
|
204
|
+
...e2eTarget,
|
|
205
|
+
dependsOn: [`^build`],
|
|
206
|
+
options: {
|
|
207
|
+
...e2eTarget?.options,
|
|
208
|
+
maxWorkers: 1,
|
|
209
|
+
isolate: false,
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, project);
|
|
222
213
|
return vitestTask;
|
|
223
214
|
}
|
|
224
215
|
async function addLintingToApplication(tree, options) {
|
|
@@ -230,7 +221,6 @@ async function addLintingToApplication(tree, options) {
|
|
|
230
221
|
],
|
|
231
222
|
unitTestRunner: options.testRunner ?? 'jest',
|
|
232
223
|
enableTypedLinting: false,
|
|
233
|
-
addPlugin: options.addPlugin,
|
|
234
224
|
});
|
|
235
225
|
}
|
|
236
226
|
function updatePluginPackageJson(tree, options) {
|
|
@@ -243,7 +233,6 @@ function updatePluginPackageJson(tree, options) {
|
|
|
243
233
|
}
|
|
244
234
|
async function e2eProjectGenerator(host, schema) {
|
|
245
235
|
return await e2eProjectGeneratorInternal(host, {
|
|
246
|
-
addPlugin: false,
|
|
247
236
|
useProjectJson: true,
|
|
248
237
|
...schema,
|
|
249
238
|
});
|
|
@@ -37,11 +37,9 @@ function addMigrationJsonChecks(host, options, packageJson) {
|
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
const migrationsJsonPath = (0, devkit_1.joinPathFragments)(projectConfiguration.root, relativeMigrationsJsonPath);
|
|
40
|
-
if (!eslintTarget) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
40
|
// Add path to lintFilePatterns if different than default "{projectRoot}"
|
|
44
|
-
if (
|
|
41
|
+
if (eslintTarget &&
|
|
42
|
+
eslintTargetConfiguration.options?.lintFilePatterns &&
|
|
45
43
|
!eslintTargetConfiguration.options.lintFilePatterns.includes(migrationsJsonPath)) {
|
|
46
44
|
eslintTargetConfiguration.options.lintFilePatterns.push(migrationsJsonPath);
|
|
47
45
|
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfiguration);
|
|
@@ -5,6 +5,7 @@ exports.pluginGeneratorInternal = pluginGeneratorInternal;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
7
|
const internal_1 = require("@nx/devkit/internal");
|
|
8
|
+
const jest_1 = require("@nx/jest");
|
|
8
9
|
const js_1 = require("@nx/js");
|
|
9
10
|
const internal_2 = require("@nx/js/internal");
|
|
10
11
|
const path = tslib_1.__importStar(require("path"));
|
|
@@ -42,7 +43,6 @@ function updatePluginConfig(host, options) {
|
|
|
42
43
|
async function pluginGenerator(tree, schema) {
|
|
43
44
|
return await pluginGeneratorInternal(tree, {
|
|
44
45
|
useProjectJson: true,
|
|
45
|
-
addPlugin: false,
|
|
46
46
|
...schema,
|
|
47
47
|
});
|
|
48
48
|
}
|
|
@@ -60,7 +60,6 @@ async function pluginGeneratorInternal(host, schema) {
|
|
|
60
60
|
linter: options.linter,
|
|
61
61
|
unitTestRunner: options.unitTestRunner,
|
|
62
62
|
useProjectJson: options.useProjectJson,
|
|
63
|
-
addPlugin: options.addPlugin,
|
|
64
63
|
skipFormat: true,
|
|
65
64
|
useTscExecutor: true,
|
|
66
65
|
}));
|
|
@@ -106,6 +105,13 @@ async function pluginGeneratorInternal(host, schema) {
|
|
|
106
105
|
tasks.push((0, internal_2.addSwcRegisterDependencies)(host));
|
|
107
106
|
await addFiles(host, options);
|
|
108
107
|
updatePluginConfig(host, options);
|
|
108
|
+
if (options.unitTestRunner === 'jest') {
|
|
109
|
+
// addFiles removes src/lib and its spec, so a fresh plugin has no tests yet.
|
|
110
|
+
const jestConfig = (0, jest_1.findJestConfig)(host, options.projectRoot);
|
|
111
|
+
if (jestConfig) {
|
|
112
|
+
(0, jest_1.addPropertyToJestConfig)(host, jestConfig, 'passWithNoTests', true);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
109
115
|
if (options.e2eTestRunner !== 'none') {
|
|
110
116
|
tasks.push(await (0, e2e_1.e2eProjectGenerator)(host, {
|
|
111
117
|
pluginName: options.projectName,
|
|
@@ -116,7 +122,6 @@ async function pluginGeneratorInternal(host, schema) {
|
|
|
116
122
|
rootProject: options.rootProject,
|
|
117
123
|
linter: options.linter,
|
|
118
124
|
useProjectJson: options.useProjectJson,
|
|
119
|
-
addPlugin: options.addPlugin,
|
|
120
125
|
testRunner: options.e2eTestRunner,
|
|
121
126
|
}));
|
|
122
127
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Tree } from '@nx/devkit';
|
|
2
2
|
import type { LinterType } from '@nx/js';
|
|
3
3
|
import type { Schema } from '../schema';
|
|
4
4
|
export interface NormalizedSchema extends Schema {
|
|
@@ -14,7 +14,6 @@ export interface NormalizedSchema extends Schema {
|
|
|
14
14
|
unitTestRunner: 'jest' | 'vitest' | 'none';
|
|
15
15
|
linter: LinterType;
|
|
16
16
|
useProjectJson: boolean;
|
|
17
|
-
addPlugin: boolean;
|
|
18
17
|
isTsSolutionSetup: boolean;
|
|
19
18
|
}
|
|
20
19
|
export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = normalizeOptions;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
5
|
const internal_2 = require("@nx/js/internal");
|
|
7
6
|
async function normalizeOptions(host, options) {
|
|
@@ -10,13 +9,7 @@ async function normalizeOptions(host, options) {
|
|
|
10
9
|
// this helper is called before the jsLibraryGenerator is called, so, if the
|
|
11
10
|
// TS solution setup is not configured, we additionally check if the TS
|
|
12
11
|
// solution setup will be configured by the jsLibraryGenerator
|
|
13
|
-
const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(host) ||
|
|
14
|
-
(0, internal_2.shouldConfigureTsSolutionSetup)(host, options.addPlugin);
|
|
15
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
16
|
-
const addPlugin = options.addPlugin ??
|
|
17
|
-
(isTsSolutionSetup &&
|
|
18
|
-
process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
19
|
-
nxJson.useInferencePlugins !== false);
|
|
12
|
+
const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(host) || (0, internal_2.shouldConfigureTsSolutionSetup)(host);
|
|
20
13
|
await (0, internal_1.ensureRootProjectName)(options, 'library');
|
|
21
14
|
const { projectName, projectRoot, importPath } = await (0, internal_1.determineProjectNameAndRootOptions)(host, {
|
|
22
15
|
name: options.name,
|
|
@@ -45,7 +38,6 @@ async function normalizeOptions(host, options) {
|
|
|
45
38
|
unitTestRunner,
|
|
46
39
|
// We default to generate a project.json file if the new setup is not being used
|
|
47
40
|
useProjectJson: options.useProjectJson ?? !isTsSolutionSetup,
|
|
48
|
-
addPlugin,
|
|
49
41
|
isTsSolutionSetup,
|
|
50
42
|
};
|
|
51
43
|
}
|
|
@@ -8,7 +8,6 @@ const plugin_1 = require("../plugin/plugin");
|
|
|
8
8
|
const internal_1 = require("@nx/js/internal");
|
|
9
9
|
async function presetGenerator(tree, rawOptions) {
|
|
10
10
|
return await presetGeneratorInternal(tree, {
|
|
11
|
-
addPlugin: false,
|
|
12
11
|
useProjectJson: true,
|
|
13
12
|
...rawOptions,
|
|
14
13
|
});
|
|
@@ -30,7 +29,6 @@ async function presetGeneratorInternal(tree, rawOptions) {
|
|
|
30
29
|
: options.pluginName,
|
|
31
30
|
rootProject: options.createPackageName ? false : true,
|
|
32
31
|
useProjectJson: options.useProjectJson,
|
|
33
|
-
addPlugin: options.addPlugin,
|
|
34
32
|
});
|
|
35
33
|
tasks.push(pluginTask);
|
|
36
34
|
moveNxPluginToDevDeps(tree);
|
|
@@ -46,7 +44,6 @@ async function presetGeneratorInternal(tree, rawOptions) {
|
|
|
46
44
|
linter: options.linter,
|
|
47
45
|
compiler: 'tsc',
|
|
48
46
|
useProjectJson: options.useProjectJson,
|
|
49
|
-
addPlugin: options.addPlugin,
|
|
50
47
|
});
|
|
51
48
|
tasks.push(cliTask);
|
|
52
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/plugin",
|
|
3
|
-
"version": "24.0.0-beta.
|
|
3
|
+
"version": "24.0.0-beta.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This plugin is used to create Nx plugins! It contains generators for generating common plugin features like generators, executors, migrations and more.",
|
|
6
6
|
"repository": {
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"tslib": "^2.3.0",
|
|
39
|
-
"@nx/devkit": "24.0.0-beta.
|
|
40
|
-
"@nx/jest": "24.0.0-beta.
|
|
41
|
-
"@nx/js": "24.0.0-beta.
|
|
42
|
-
"@nx/eslint": "24.0.0-beta.
|
|
39
|
+
"@nx/devkit": "24.0.0-beta.3",
|
|
40
|
+
"@nx/jest": "24.0.0-beta.3",
|
|
41
|
+
"@nx/js": "24.0.0-beta.3",
|
|
42
|
+
"@nx/eslint": "24.0.0-beta.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"nx": "24.0.0-beta.
|
|
45
|
+
"nx": "24.0.0-beta.3"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@nx/vitest": "24.0.0-beta.
|
|
48
|
+
"@nx/vitest": "24.0.0-beta.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"@nx/vitest": {
|