@nx/node 23.2.0-beta.0 → 23.2.0-beta.10
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/application/application.js +21 -1
- package/dist/src/generators/application/files/fastify/src/app/app.spec.ts__tmpl__ +2 -1
- package/dist/src/generators/application/files/fastify/src/app/app.ts__tmpl__ +1 -1
- package/dist/src/generators/application/files/fastify/src/app/plugins/sensible.ts__tmpl__ +1 -1
- package/dist/src/generators/application/files/fastify/src/app/routes/root.ts__tmpl__ +1 -1
- package/dist/src/generators/application/lib/add-linting.js +4 -5
- package/dist/src/generators/application/lib/create-project.js +38 -0
- package/dist/src/generators/application/lib/create-targets.js +35 -5
- package/dist/src/generators/application/lib/normalize-options.js +1 -1
- package/dist/src/generators/application/schema.d.ts +8 -4
- package/dist/src/generators/application/schema.json +16 -7
- package/dist/src/generators/e2e-project/e2e-project.js +30 -14
- package/dist/src/generators/e2e-project/schema.d.ts +1 -1
- package/dist/src/generators/e2e-project/schema.json +6 -4
- package/dist/src/generators/library/library.js +9 -8
- package/dist/src/generators/library/schema.d.ts +7 -4
- package/dist/src/generators/library/schema.json +11 -13
- package/package.json +9 -8
|
@@ -118,7 +118,7 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
118
118
|
await (0, internal_2.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
|
|
119
119
|
}
|
|
120
120
|
updateTsConfigOptions(tree, options);
|
|
121
|
-
if (options.linter
|
|
121
|
+
if (options.linter !== 'none') {
|
|
122
122
|
const lintTask = await (0, lib_1.addLintingToApplication)(tree, options);
|
|
123
123
|
tasks.push(lintTask);
|
|
124
124
|
}
|
|
@@ -146,6 +146,26 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
146
146
|
};
|
|
147
147
|
(0, devkit_1.updateProjectConfiguration)(tree, options.name, projectConfig);
|
|
148
148
|
}
|
|
149
|
+
else if (options.unitTestRunner === 'vitest') {
|
|
150
|
+
(0, devkit_1.ensurePackage)('@nx/vitest', versions_1.nxVersion);
|
|
151
|
+
// CommonJS `require` instead of dynamic ESM `import`: `ensurePackage`
|
|
152
|
+
// exposes the temp install via `Module._initPaths`, which ESM ignores.
|
|
153
|
+
const { configurationGenerator, } = require('@nx/vitest/generators');
|
|
154
|
+
const vitestTask = await configurationGenerator(tree, {
|
|
155
|
+
project: options.name,
|
|
156
|
+
uiFramework: 'none',
|
|
157
|
+
coverageProvider: 'v8',
|
|
158
|
+
testEnvironment: 'node',
|
|
159
|
+
runtimeTsconfigFileName: 'tsconfig.app.json',
|
|
160
|
+
// Only the fastify template ships a spec, so the other frameworks would
|
|
161
|
+
// otherwise fail `nx test` on a freshly generated app.
|
|
162
|
+
passWithNoTests: true,
|
|
163
|
+
addPlugin: options.addPlugin,
|
|
164
|
+
skipPackageJson: options.skipPackageJson,
|
|
165
|
+
skipFormat: true,
|
|
166
|
+
});
|
|
167
|
+
tasks.push(vitestTask);
|
|
168
|
+
}
|
|
149
169
|
else {
|
|
150
170
|
// No need for default spec file if unit testing is not setup.
|
|
151
171
|
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/app/app.spec.ts'));
|
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addLintingToApplication = addLintingToApplication;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/eslint/internal");
|
|
6
|
+
const internal_2 = require("@nx/js/internal");
|
|
6
7
|
async function addLintingToApplication(tree, options) {
|
|
7
|
-
|
|
8
|
+
return (0, internal_2.addLintingToProject)(tree, {
|
|
8
9
|
linter: options.linter,
|
|
9
10
|
project: options.name,
|
|
10
11
|
tsConfigPaths: [
|
|
11
12
|
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
12
13
|
],
|
|
13
14
|
unitTestRunner: options.unitTestRunner,
|
|
14
|
-
|
|
15
|
-
setParserOptionsProject: options.setParserOptionsProject,
|
|
15
|
+
enableTypedLinting: (0, internal_1.isTypedLintingEnabled)(options),
|
|
16
16
|
rootProject: options.rootProject,
|
|
17
17
|
addPlugin: options.addPlugin,
|
|
18
18
|
});
|
|
19
|
-
return lintTask;
|
|
20
19
|
}
|
|
@@ -14,18 +14,28 @@ function addProject(tree, options, frameworkDependencies) {
|
|
|
14
14
|
targets: {},
|
|
15
15
|
tags: options.parsedTags,
|
|
16
16
|
};
|
|
17
|
+
// The generated build target emits the pruned pnpm deploy output when
|
|
18
|
+
// generatePackageJson is on; the install settings it carries are hashed by
|
|
19
|
+
// no default input (see PNPM_INSTALL_SETTINGS_INPUTS).
|
|
20
|
+
const pnpmDeployInputs = tree.exists('pnpm-lock.yaml')
|
|
21
|
+
? internal_2.PNPM_INSTALL_SETTINGS_INPUTS
|
|
22
|
+
: [];
|
|
17
23
|
if (options.bundler === 'esbuild') {
|
|
18
24
|
(0, internal_1.addBuildTargetDefaults)(tree, '@nx/esbuild:esbuild', 'build', [
|
|
19
25
|
internal_2.TS_SOLUTION_SETUP_TSCONFIG_INPUT,
|
|
26
|
+
...pnpmDeployInputs,
|
|
20
27
|
]);
|
|
21
28
|
project.targets.build = (0, create_targets_1.getEsBuildConfig)(tree, project, options);
|
|
29
|
+
ensurePnpmDeployInputs(tree, options, project.targets.build);
|
|
22
30
|
}
|
|
23
31
|
else if (options.bundler === 'webpack') {
|
|
24
32
|
if (!(0, has_webpack_plugin_1.hasWebpackPlugin)(tree) && options.addPlugin === false) {
|
|
25
33
|
(0, internal_1.addBuildTargetDefaults)(tree, `@nx/webpack:webpack`, 'build', [
|
|
26
34
|
internal_2.TS_SOLUTION_SETUP_TSCONFIG_INPUT,
|
|
35
|
+
...pnpmDeployInputs,
|
|
27
36
|
]);
|
|
28
37
|
project.targets.build = (0, create_targets_1.getWebpackBuildConfig)(tree, project, options);
|
|
38
|
+
ensurePnpmDeployInputs(tree, options, project.targets.build);
|
|
29
39
|
}
|
|
30
40
|
else if (options.isNest) {
|
|
31
41
|
// If we are using Nest that has the webpack plugin we need to override the
|
|
@@ -58,3 +68,31 @@ function addProject(tree, options, frameworkDependencies) {
|
|
|
58
68
|
(0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
|
|
59
69
|
}
|
|
60
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Guarantees the pnpm deploy-settings inputs reach the generated build target
|
|
73
|
+
* even when `addBuildTargetDefaults` skipped writing them because an
|
|
74
|
+
* executor-keyed `targetDefaults` entry already existed. Resolution and
|
|
75
|
+
* placement follow nx's own targetDefaults matching (see
|
|
76
|
+
* `addPnpmDeployOutputCacheInputs`).
|
|
77
|
+
*/
|
|
78
|
+
function ensurePnpmDeployInputs(tree, options, buildTarget) {
|
|
79
|
+
if (!tree.exists('pnpm-lock.yaml')) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
83
|
+
const ref = {
|
|
84
|
+
targetName: 'build',
|
|
85
|
+
projectName: options.name,
|
|
86
|
+
projectNode: {
|
|
87
|
+
name: options.name,
|
|
88
|
+
type: 'app',
|
|
89
|
+
data: { root: options.appProjectRoot, tags: options.parsedTags },
|
|
90
|
+
},
|
|
91
|
+
matcherExecutor: buildTarget.executor,
|
|
92
|
+
target: buildTarget,
|
|
93
|
+
};
|
|
94
|
+
const changed = (0, internal_2.addPnpmDeployOutputCacheInputs)(ref, nxJson?.targetDefaults, buildTarget.executor);
|
|
95
|
+
if (changed === 'defaults') {
|
|
96
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -109,16 +109,46 @@ function getNestWebpackBuildConfig(project) {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
function getPruneTargets(buildTarget, outputPath) {
|
|
112
|
-
const
|
|
112
|
+
const packageManager = (0, devkit_1.detectPackageManager)() ?? 'npm';
|
|
113
|
+
const lockFileName = (0, js_1.getLockFileName)(packageManager) ?? 'package-lock.json';
|
|
114
|
+
const pruneLockfileOutputs = [
|
|
115
|
+
`{workspaceRoot}/${(0, devkit_1.joinPathFragments)(outputPath, 'package.json')}`,
|
|
116
|
+
`{workspaceRoot}/${(0, devkit_1.joinPathFragments)(outputPath, lockFileName)}`,
|
|
117
|
+
];
|
|
118
|
+
let pruneLockfileInputs;
|
|
119
|
+
if (packageManager === 'pnpm') {
|
|
120
|
+
// Beside the pruned lockfile the executor emits a settings-only
|
|
121
|
+
// pnpm-workspace.yaml, a `pnpm patch` workspace emits the referenced `.patch`
|
|
122
|
+
// files under `patches/`, and any non-workspace local-path deps (`file:`
|
|
123
|
+
// tarballs/dirs, `link:` targets) ship under `local_path_modules/`; declare
|
|
124
|
+
// all three so a cache replay restores them and native build-script
|
|
125
|
+
// approvals, patches, or vendored dependencies are not silently dropped.
|
|
126
|
+
// The last two are declared for any pnpm since the generator can't know
|
|
127
|
+
// whether the workspace uses them; Nx tolerates absent outputs.
|
|
128
|
+
pruneLockfileOutputs.push(`{workspaceRoot}/${(0, devkit_1.joinPathFragments)(outputPath, 'pnpm-workspace.yaml')}`, `{workspaceRoot}/${(0, devkit_1.joinPathFragments)(outputPath, 'patches')}`, `{workspaceRoot}/${(0, devkit_1.joinPathFragments)(outputPath, 'local_path_modules')}`);
|
|
129
|
+
// The build approvals and `supportedArchitectures` those artifacts carry are
|
|
130
|
+
// recorded nowhere in the lockfile, so without the root files in the hash a
|
|
131
|
+
// revoked approval replays the previous artifact, and the ambient pnpm
|
|
132
|
+
// major (probed at hash time) decides which emitted file carries them.
|
|
133
|
+
// `default` and `^default` keep what an undeclared `inputs` would have
|
|
134
|
+
// hashed. Deliberately coarser than the settings-narrowed json input the
|
|
135
|
+
// bundler build targets use: over-invalidating this small, rarely-run task
|
|
136
|
+
// costs nothing.
|
|
137
|
+
pruneLockfileInputs = [
|
|
138
|
+
'default',
|
|
139
|
+
'^default',
|
|
140
|
+
`{workspaceRoot}/pnpm-workspace.yaml`,
|
|
141
|
+
`{workspaceRoot}/package.json`,
|
|
142
|
+
internal_1.PNPM_MAJOR_RUNTIME_INPUT,
|
|
143
|
+
];
|
|
144
|
+
}
|
|
113
145
|
return {
|
|
114
146
|
'prune-lockfile': {
|
|
115
147
|
dependsOn: ['build'],
|
|
116
148
|
cache: true,
|
|
117
149
|
executor: '@nx/js:prune-lockfile',
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
`{workspaceRoot}/${(0, devkit_1.joinPathFragments)(outputPath, lockFileName)}`,
|
|
121
|
-
],
|
|
150
|
+
...(pruneLockfileInputs ? { inputs: pruneLockfileInputs } : {}),
|
|
151
|
+
outputs: pruneLockfileOutputs,
|
|
122
152
|
options: {
|
|
123
153
|
buildTarget,
|
|
124
154
|
},
|
|
@@ -36,7 +36,7 @@ async function normalizeOptions(host, options) {
|
|
|
36
36
|
appProjectRoot,
|
|
37
37
|
importPath,
|
|
38
38
|
parsedTags,
|
|
39
|
-
linter: options.linter
|
|
39
|
+
linter: await (0, internal_2.normalizeLinterOption)(host, options.linter),
|
|
40
40
|
unitTestRunner: options.unitTestRunner ?? 'jest',
|
|
41
41
|
rootProject: options.rootProject ?? false,
|
|
42
42
|
port: options.port ?? 3000,
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LinterType } from '@nx/js';
|
|
2
2
|
|
|
3
3
|
export interface Schema {
|
|
4
4
|
directory: string;
|
|
5
5
|
name?: string;
|
|
6
6
|
skipFormat?: boolean;
|
|
7
7
|
skipPackageJson?: boolean;
|
|
8
|
-
unitTestRunner?: 'jest' | 'none';
|
|
8
|
+
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
9
9
|
e2eTestRunner?: 'jest' | 'none';
|
|
10
|
-
linter?:
|
|
11
|
-
formatter?: 'none' | 'prettier';
|
|
10
|
+
linter?: LinterType;
|
|
11
|
+
formatter?: 'none' | 'prettier' | 'oxfmt';
|
|
12
12
|
tags?: string;
|
|
13
13
|
frontendProject?: string;
|
|
14
14
|
swcJest?: boolean;
|
|
15
15
|
/** @deprecated use `swcJest` instead */
|
|
16
16
|
babelJest?: boolean;
|
|
17
17
|
js?: boolean;
|
|
18
|
+
enableTypedLinting?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
|
|
21
|
+
*/
|
|
18
22
|
setParserOptionsProject?: boolean;
|
|
19
23
|
bundler?: 'esbuild' | 'webpack';
|
|
20
24
|
framework?: NodeJsFrameWorks;
|
|
@@ -34,16 +34,19 @@
|
|
|
34
34
|
"x-priority": "internal"
|
|
35
35
|
},
|
|
36
36
|
"linter": {
|
|
37
|
-
"description": "The tool to use for running lint checks.",
|
|
37
|
+
"description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
|
|
38
38
|
"type": "string",
|
|
39
|
-
"enum": ["eslint", "none"],
|
|
40
|
-
"default": "none",
|
|
41
|
-
"x-prompt": "Which linter would you like to use?",
|
|
39
|
+
"enum": ["eslint", "oxlint", "none"],
|
|
42
40
|
"x-priority": "important"
|
|
43
41
|
},
|
|
42
|
+
"formatter": {
|
|
43
|
+
"description": "The tool to use for code formatting.",
|
|
44
|
+
"type": "string",
|
|
45
|
+
"enum": ["none", "prettier", "oxfmt"]
|
|
46
|
+
},
|
|
44
47
|
"unitTestRunner": {
|
|
45
48
|
"type": "string",
|
|
46
|
-
"enum": ["jest", "none"],
|
|
49
|
+
"enum": ["jest", "vitest", "none"],
|
|
47
50
|
"description": "Test runner to use for unit tests.",
|
|
48
51
|
"default": "none",
|
|
49
52
|
"x-priority": "important",
|
|
@@ -82,11 +85,17 @@
|
|
|
82
85
|
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
83
86
|
"default": false
|
|
84
87
|
},
|
|
85
|
-
"
|
|
88
|
+
"enableTypedLinting": {
|
|
86
89
|
"type": "boolean",
|
|
87
|
-
"description": "Whether
|
|
90
|
+
"description": "Whether to enable typed linting. For flat configs, this configures the recommended `parserOptions.projectService` and `tsconfigRootDir`. For legacy `.eslintrc` configs, this configures `parserOptions.project`. We do not enable this by default for lint performance reasons.",
|
|
88
91
|
"default": false
|
|
89
92
|
},
|
|
93
|
+
"setParserOptionsProject": {
|
|
94
|
+
"type": "boolean",
|
|
95
|
+
"description": "Deprecated alias for `enableTypedLinting`.",
|
|
96
|
+
"default": false,
|
|
97
|
+
"x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
|
|
98
|
+
},
|
|
90
99
|
"bundler": {
|
|
91
100
|
"description": "Bundler which is used to package the application",
|
|
92
101
|
"type": "string",
|
|
@@ -6,11 +6,11 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
const internal_1 = require("@nx/devkit/internal");
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
8
|
const eslint_1 = require("@nx/eslint");
|
|
9
|
-
const internal_2 = require("@nx/
|
|
9
|
+
const internal_2 = require("@nx/js/internal");
|
|
10
|
+
const internal_3 = require("@nx/eslint/internal");
|
|
10
11
|
const path = tslib_1.__importStar(require("path"));
|
|
11
12
|
const versions_1 = require("../../utils/versions");
|
|
12
|
-
const
|
|
13
|
-
const internal_4 = require("@nx/js/internal");
|
|
13
|
+
const internal_4 = require("@nx/jest/internal");
|
|
14
14
|
const posix_1 = require("node:path/posix");
|
|
15
15
|
async function e2eProjectGenerator(host, options) {
|
|
16
16
|
return await e2eProjectGeneratorInternal(host, {
|
|
@@ -24,7 +24,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
24
24
|
const options = await normalizeOptions(host, _options);
|
|
25
25
|
const appProject = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
26
26
|
// Detect Jest 30+ to use .cts config files (CommonJS TypeScript)
|
|
27
|
-
const jestMajorVersion = (0,
|
|
27
|
+
const jestMajorVersion = (0, internal_4.getInstalledJestMajorVersion)(host);
|
|
28
28
|
const useCommonJsConfig = jestMajorVersion === null || jestMajorVersion >= 30;
|
|
29
29
|
const jestConfigExt = useCommonJsConfig ? 'cts' : 'ts';
|
|
30
30
|
// TODO(@ndcunningham): This is broken.. the outputs are wrong.. and this isn't using the jest generator
|
|
@@ -98,7 +98,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
98
98
|
};
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
const jestPreset = (0,
|
|
101
|
+
const jestPreset = (0, internal_4.findRootJestPreset)(host) ?? 'jest.preset.js';
|
|
102
102
|
const tsConfigFile = options.isUsingTsSolutionConfig
|
|
103
103
|
? 'tsconfig.json'
|
|
104
104
|
: 'tsconfig.spec.json';
|
|
@@ -146,7 +146,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
146
146
|
host.rename(jestConfigPath, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'jest.config.cts'));
|
|
147
147
|
}
|
|
148
148
|
if (options.isUsingTsSolutionConfig) {
|
|
149
|
-
(0,
|
|
149
|
+
(0, internal_2.addSwcTestConfig)(host, options.e2eProjectRoot, 'es6');
|
|
150
150
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/ts-solution'), options.e2eProjectRoot, {
|
|
151
151
|
...options,
|
|
152
152
|
relativeProjectReferencePath: (0, posix_1.relative)(options.e2eProjectRoot, appProject.root),
|
|
@@ -164,6 +164,19 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
164
164
|
// axios is more than likely used in the application code, so install it as a regular dependency.
|
|
165
165
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, { axios: versions_1.axiosVersion }, {});
|
|
166
166
|
tasks.push(installTask);
|
|
167
|
+
if (options.linter &&
|
|
168
|
+
options.linter !== 'eslint' &&
|
|
169
|
+
options.linter !== 'none') {
|
|
170
|
+
tasks.push(await (0, internal_2.addLintingToProject)(host, {
|
|
171
|
+
linter: options.linter,
|
|
172
|
+
project: options.e2eProjectName,
|
|
173
|
+
rootProject: options.rootProject,
|
|
174
|
+
addPlugin: options.addPlugin,
|
|
175
|
+
// The generated e2e specs are Jest; this is what enables the linter's
|
|
176
|
+
// Jest rules.
|
|
177
|
+
unitTestRunner: 'jest',
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
167
180
|
if (options.linter === 'eslint') {
|
|
168
181
|
const linterTask = await (0, eslint_1.lintProjectGenerator)(host, {
|
|
169
182
|
project: options.e2eProjectName,
|
|
@@ -172,17 +185,17 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
172
185
|
tsConfigPaths: [
|
|
173
186
|
(0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'tsconfig.json'),
|
|
174
187
|
],
|
|
175
|
-
|
|
188
|
+
enableTypedLinting: false,
|
|
176
189
|
skipPackageJson: false,
|
|
177
190
|
rootProject: options.rootProject,
|
|
178
191
|
addPlugin: options.addPlugin,
|
|
179
192
|
});
|
|
180
193
|
tasks.push(linterTask);
|
|
181
|
-
if (options.rootProject && (0,
|
|
182
|
-
(0,
|
|
183
|
-
(0,
|
|
184
|
-
|
|
185
|
-
|
|
194
|
+
if (options.rootProject && (0, internal_3.isEslintConfigSupported)(host)) {
|
|
195
|
+
(0, internal_3.addPluginsToLintConfig)(host, options.e2eProjectRoot, '@nx');
|
|
196
|
+
(0, internal_3.replaceOverridesInLintConfig)(host, options.e2eProjectRoot, [
|
|
197
|
+
internal_3.typeScriptOverride,
|
|
198
|
+
internal_3.javaScriptOverride,
|
|
186
199
|
]);
|
|
187
200
|
}
|
|
188
201
|
}
|
|
@@ -199,7 +212,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
|
|
|
199
212
|
// If we are using the new TS solution
|
|
200
213
|
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
201
214
|
if (options.isUsingTsSolutionConfig) {
|
|
202
|
-
await (0,
|
|
215
|
+
await (0, internal_2.addProjectToTsSolutionWorkspace)(host, options.e2eProjectRoot);
|
|
203
216
|
}
|
|
204
217
|
if (!options.skipFormat) {
|
|
205
218
|
await (0, devkit_1.formatFiles)(host);
|
|
@@ -223,10 +236,13 @@ async function normalizeOptions(tree, options) {
|
|
|
223
236
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
224
237
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
225
238
|
nxJson.useInferencePlugins !== false;
|
|
226
|
-
const isUsingTsSolutionConfig = (0,
|
|
239
|
+
const isUsingTsSolutionConfig = (0, internal_2.isUsingTsSolutionSetup)(tree);
|
|
227
240
|
return {
|
|
228
241
|
addPlugin,
|
|
229
242
|
...options,
|
|
243
|
+
// Both arms below test for a concrete linter, so an unresolved `undefined`
|
|
244
|
+
// would fall through them and leave the e2e project with no linter at all.
|
|
245
|
+
linter: await (0, internal_2.normalizeLinterOption)(tree, options.linter),
|
|
230
246
|
e2eProjectRoot,
|
|
231
247
|
e2eProjectName,
|
|
232
248
|
importPath,
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
"project": {
|
|
10
10
|
"type": "string",
|
|
11
11
|
"description": "The name of the project.",
|
|
12
|
-
"$default": {
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
13
16
|
"x-dropdown": "project",
|
|
14
17
|
"x-prompt": "What project is this for?"
|
|
15
18
|
},
|
|
@@ -34,10 +37,9 @@
|
|
|
34
37
|
"default": 3000
|
|
35
38
|
},
|
|
36
39
|
"linter": {
|
|
37
|
-
"description": "Linter to be used for the E2E project",
|
|
40
|
+
"description": "Linter to be used for the E2E project. Defaults to the linter the workspace already uses.",
|
|
38
41
|
"type": "string",
|
|
39
|
-
"enum": ["eslint", "none"]
|
|
40
|
-
"default": "eslint"
|
|
42
|
+
"enum": ["eslint", "oxlint", "none"]
|
|
41
43
|
},
|
|
42
44
|
"isNest": {
|
|
43
45
|
"description": "Is the E2E server project nest",
|
|
@@ -4,8 +4,9 @@ exports.libraryGenerator = libraryGenerator;
|
|
|
4
4
|
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
5
5
|
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const internal_2 = require("@nx/eslint/internal");
|
|
7
8
|
const js_1 = require("@nx/js");
|
|
8
|
-
const
|
|
9
|
+
const internal_3 = require("@nx/js/internal");
|
|
9
10
|
const path_1 = require("path");
|
|
10
11
|
const versions_1 = require("../../utils/versions");
|
|
11
12
|
const init_1 = require("../init/init");
|
|
@@ -21,7 +22,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
21
22
|
// If we are using the new TS solution
|
|
22
23
|
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
23
24
|
if (options.isUsingTsSolutionConfig) {
|
|
24
|
-
await (0,
|
|
25
|
+
await (0, internal_3.addProjectToTsSolutionWorkspace)(tree, options.projectRoot);
|
|
25
26
|
}
|
|
26
27
|
const tasks = [];
|
|
27
28
|
if (options.publishable === true && !schema.importPath) {
|
|
@@ -45,7 +46,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
45
46
|
importPath: schema.importPath,
|
|
46
47
|
testEnvironment: 'node',
|
|
47
48
|
skipFormat: true,
|
|
48
|
-
|
|
49
|
+
enableTypedLinting: (0, internal_2.isTypedLintingEnabled)(schema),
|
|
49
50
|
useProjectJson: options.useProjectJson,
|
|
50
51
|
}));
|
|
51
52
|
updatePackageJson(tree, options);
|
|
@@ -63,7 +64,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
63
64
|
if (options.isUsingTsSolutionConfig) {
|
|
64
65
|
tasks.push(() => (0, devkit_1.installPackagesTask)(tree, true));
|
|
65
66
|
}
|
|
66
|
-
(0,
|
|
67
|
+
(0, internal_3.sortPackageJsonFields)(tree, options.projectRoot);
|
|
67
68
|
if (!schema.skipFormat) {
|
|
68
69
|
await (0, devkit_1.formatFiles)(tree);
|
|
69
70
|
}
|
|
@@ -91,8 +92,8 @@ async function normalizeOptions(tree, options) {
|
|
|
91
92
|
// this helper is called before the jsLibraryGenerator is called, so, if the
|
|
92
93
|
// TS solution setup is not configured, we additionally check if the TS
|
|
93
94
|
// solution setup will be configured by the jsLibraryGenerator
|
|
94
|
-
const isUsingTsSolutionConfig = (0,
|
|
95
|
-
(0,
|
|
95
|
+
const isUsingTsSolutionConfig = (0, internal_3.isUsingTsSolutionSetup)(tree) ||
|
|
96
|
+
(0, internal_3.shouldConfigureTsSolutionSetup)(tree, options.addPlugin);
|
|
96
97
|
return {
|
|
97
98
|
...options,
|
|
98
99
|
fileName,
|
|
@@ -149,8 +150,8 @@ function updateProject(tree, options) {
|
|
|
149
150
|
};
|
|
150
151
|
}
|
|
151
152
|
if (options.compiler === 'swc') {
|
|
152
|
-
(0,
|
|
153
|
-
(0,
|
|
153
|
+
(0, internal_3.addSwcDependencies)(tree);
|
|
154
|
+
(0, internal_3.addSwcConfig)(tree, options.projectRoot);
|
|
154
155
|
}
|
|
155
156
|
if (options.rootDir) {
|
|
156
157
|
project.targets.build.options.srcRootForCompilationRoot = options.rootDir;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LinterType } from '@nx/js';
|
|
2
2
|
|
|
3
3
|
export interface Schema {
|
|
4
4
|
directory: string;
|
|
@@ -7,16 +7,19 @@ export interface Schema {
|
|
|
7
7
|
skipTsConfig?: boolean;
|
|
8
8
|
skipFormat?: boolean;
|
|
9
9
|
tags?: string;
|
|
10
|
-
unitTestRunner?: 'jest' | 'none';
|
|
11
|
-
linter?:
|
|
10
|
+
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
11
|
+
linter?: LinterType;
|
|
12
12
|
buildable?: boolean;
|
|
13
13
|
publishable?: boolean;
|
|
14
14
|
importPath?: string;
|
|
15
|
-
testEnvironment?: 'jsdom' | 'node';
|
|
16
15
|
rootDir?: string;
|
|
17
16
|
babelJest?: boolean;
|
|
18
17
|
js?: boolean;
|
|
19
18
|
strict?: boolean;
|
|
19
|
+
enableTypedLinting?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
|
|
22
|
+
*/
|
|
20
23
|
setParserOptionsProject?: boolean;
|
|
21
24
|
compiler: 'tsc' | 'swc';
|
|
22
25
|
addPlugin?: boolean;
|
|
@@ -34,16 +34,14 @@
|
|
|
34
34
|
"default": false
|
|
35
35
|
},
|
|
36
36
|
"linter": {
|
|
37
|
-
"description": "The tool to use for running lint checks.",
|
|
37
|
+
"description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
|
|
38
38
|
"type": "string",
|
|
39
|
-
"enum": ["eslint", "none"],
|
|
40
|
-
"default": "none",
|
|
41
|
-
"x-prompt": "Which linter would you like to use?",
|
|
39
|
+
"enum": ["eslint", "oxlint", "none"],
|
|
42
40
|
"x-priority": "important"
|
|
43
41
|
},
|
|
44
42
|
"unitTestRunner": {
|
|
45
43
|
"type": "string",
|
|
46
|
-
"enum": ["jest", "none"],
|
|
44
|
+
"enum": ["jest", "vitest", "none"],
|
|
47
45
|
"description": "Test runner to use for unit tests.",
|
|
48
46
|
"default": "none",
|
|
49
47
|
"x-prompt": "Which unit test runner would you like to use?",
|
|
@@ -92,12 +90,6 @@
|
|
|
92
90
|
"type": "string",
|
|
93
91
|
"description": "Sets the `rootDir` for TypeScript compilation. When not defined, it uses the project's root property, or `srcRootForCompilationRoot` if it is defined."
|
|
94
92
|
},
|
|
95
|
-
"testEnvironment": {
|
|
96
|
-
"type": "string",
|
|
97
|
-
"enum": ["jsdom", "node"],
|
|
98
|
-
"description": "The test environment to use if `unitTestRunner` is set to `jest`.",
|
|
99
|
-
"default": "jsdom"
|
|
100
|
-
},
|
|
101
93
|
"babelJest": {
|
|
102
94
|
"type": "boolean",
|
|
103
95
|
"description": "Use `babel` instead of `ts-jest`.",
|
|
@@ -113,11 +105,17 @@
|
|
|
113
105
|
"description": "Whether to enable tsconfig strict mode or not.",
|
|
114
106
|
"default": false
|
|
115
107
|
},
|
|
116
|
-
"
|
|
108
|
+
"enableTypedLinting": {
|
|
117
109
|
"type": "boolean",
|
|
118
|
-
"description": "Whether
|
|
110
|
+
"description": "Whether to enable typed linting. For flat configs, this configures the recommended `parserOptions.projectService` and `tsconfigRootDir`. For legacy `.eslintrc` configs, this configures `parserOptions.project`. We do not enable this by default for lint performance reasons.",
|
|
119
111
|
"default": false
|
|
120
112
|
},
|
|
113
|
+
"setParserOptionsProject": {
|
|
114
|
+
"type": "boolean",
|
|
115
|
+
"description": "Deprecated alias for `enableTypedLinting`.",
|
|
116
|
+
"default": false,
|
|
117
|
+
"x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
|
|
118
|
+
},
|
|
121
119
|
"useProjectJson": {
|
|
122
120
|
"type": "boolean",
|
|
123
121
|
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/node",
|
|
3
|
-
"version": "23.2.0-beta.
|
|
3
|
+
"version": "23.2.0-beta.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -73,15 +73,16 @@
|
|
|
73
73
|
"semver": "^7.6.3",
|
|
74
74
|
"tcp-port-used": "^1.0.2",
|
|
75
75
|
"kill-port": "^1.6.1",
|
|
76
|
-
"@nx/devkit": "23.2.0-beta.
|
|
77
|
-
"@nx/jest": "23.2.0-beta.
|
|
78
|
-
"@nx/js": "23.2.0-beta.
|
|
79
|
-
"@nx/eslint": "23.2.0-beta.
|
|
80
|
-
"@nx/docker": "23.2.0-beta.
|
|
76
|
+
"@nx/devkit": "23.2.0-beta.10",
|
|
77
|
+
"@nx/jest": "23.2.0-beta.10",
|
|
78
|
+
"@nx/js": "23.2.0-beta.10",
|
|
79
|
+
"@nx/eslint": "23.2.0-beta.10",
|
|
80
|
+
"@nx/docker": "23.2.0-beta.10"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"nx": "23.2.0-beta.
|
|
84
|
-
"@nx/webpack": "23.2.0-beta.
|
|
83
|
+
"nx": "23.2.0-beta.10",
|
|
84
|
+
"@nx/webpack": "23.2.0-beta.10",
|
|
85
|
+
"@nx/vitest": "23.2.0-beta.10"
|
|
85
86
|
},
|
|
86
87
|
"peerDependencies": {
|
|
87
88
|
"express": ">=4.0.0 <6.0.0",
|