@nx/js 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/internal.d.ts +9 -3
- package/dist/internal.js +28 -17
- package/dist/src/executors/copy-workspace-modules/copy-workspace-modules.js +122 -21
- package/dist/src/executors/node/lib/output-file.js +4 -4
- package/dist/src/executors/node/node.impl.js +9 -10
- package/dist/src/executors/prune-lockfile/prune-lockfile.d.ts +1 -1
- package/dist/src/executors/prune-lockfile/prune-lockfile.js +40 -33
- package/dist/src/executors/tsc/lib/batch/watch.js +3 -3
- package/dist/src/executors/tsc/tsc.batch-impl.d.ts +1 -1
- package/dist/src/executors/tsc/tsc.batch-impl.js +2 -2
- package/dist/src/executors/verdaccio/verdaccio.impl.js +8 -1
- package/dist/src/generators/init/init.js +32 -15
- package/dist/src/generators/init/schema.d.ts +1 -1
- package/dist/src/generators/init/schema.json +1 -1
- package/dist/src/generators/library/library.d.ts +1 -1
- package/dist/src/generators/library/library.js +34 -20
- package/dist/src/generators/library/schema.d.ts +11 -3
- package/dist/src/generators/library/schema.json +15 -4
- package/dist/src/generators/library/utils/add-release-config.js +2 -2
- package/dist/src/generators/setup-build/generator.js +2 -7
- package/dist/src/generators/typescript-sync/typescript-sync.d.ts +1 -1
- package/dist/src/generators/typescript-sync/typescript-sync.js +2 -2
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.js +8 -8
- package/dist/src/migrations/update-23-1-0/add-ignore-deprecations-for-ts6.d.ts +3 -2
- package/dist/src/migrations/update-23-1-0/add-ignore-deprecations-for-ts6.js +17 -11
- package/dist/src/migrations/update-23-2-0/add-pnpm-deploy-output-cache-inputs.d.ts +14 -0
- package/dist/src/migrations/update-23-2-0/add-pnpm-deploy-output-cache-inputs.js +242 -0
- package/dist/src/migrations/update-23-2-0/add-pnpm-deploy-output-cache-inputs.md +64 -0
- package/dist/src/migrations/update-23-2-0/add-pnpm-prune-lockfile-cache-config.d.ts +2 -0
- package/dist/src/migrations/update-23-2-0/add-pnpm-prune-lockfile-cache-config.js +305 -0
- package/dist/src/migrations/update-23-2-0/add-pnpm-prune-lockfile-cache-config.md +59 -0
- package/dist/src/plugins/typescript/plugin.js +9 -14
- package/dist/src/plugins/typescript/util.d.ts +1 -1
- package/dist/src/release/utils/update-lock-file.js +5 -7
- package/dist/src/release/version-actions.d.ts +12 -3
- package/dist/src/release/version-actions.js +236 -76
- package/dist/src/utils/add-linting-to-project.d.ts +46 -0
- package/dist/src/utils/add-linting-to-project.js +112 -0
- package/dist/src/utils/assets/copy-assets-handler.d.ts +1 -1
- package/dist/src/utils/assets/copy-assets-handler.js +2 -2
- package/dist/src/utils/buildable-libs-utils.js +10 -13
- package/dist/src/utils/find-npm-dependencies.js +7 -10
- package/dist/src/utils/formatter-setup.d.ts +26 -0
- package/dist/src/utils/formatter-setup.js +43 -0
- package/dist/src/utils/generate-globs.js +11 -14
- package/dist/src/utils/generator-prompts.d.ts +2 -1
- package/dist/src/utils/generator-prompts.js +23 -22
- package/dist/src/utils/get-main-file-dir.js +2 -2
- package/dist/src/utils/linter.d.ts +30 -0
- package/dist/src/utils/linter.js +43 -0
- package/dist/src/utils/npm-config.d.ts +1 -1
- package/dist/src/utils/nx-formatter-internals.d.ts +8 -0
- package/dist/src/utils/nx-formatter-internals.js +18 -0
- package/dist/src/utils/oxfmt.d.ts +4 -0
- package/dist/src/utils/oxfmt.js +35 -0
- package/dist/src/utils/package-json/update-package-json.d.ts +1 -1
- package/dist/src/utils/package-json/update-package-json.js +11 -22
- package/dist/src/utils/package-manager-workspaces.js +2 -2
- package/dist/src/utils/pnpm-deploy-output-cache-inputs.d.ts +29 -0
- package/dist/src/utils/pnpm-deploy-output-cache-inputs.js +177 -0
- package/dist/src/utils/pnpm-install-settings-inputs.d.ts +45 -0
- package/dist/src/utils/pnpm-install-settings-inputs.js +77 -0
- package/dist/src/utils/prettier.js +14 -33
- package/dist/src/utils/target-defaults-matching.d.ts +57 -0
- package/dist/src/utils/target-defaults-matching.js +126 -0
- package/dist/src/utils/typescript/configuration.js +3 -5
- package/dist/src/utils/typescript/create-ts-config.d.ts +1 -1
- package/dist/src/utils/typescript/create-ts-config.js +5 -5
- package/dist/src/utils/typescript/plugin.js +2 -2
- package/dist/src/utils/typescript/run-type-check.js +2 -2
- package/dist/src/utils/typescript/ts-config.d.ts +51 -1
- package/dist/src/utils/typescript/ts-config.js +114 -0
- package/dist/src/utils/typescript/ts-solution-setup.d.ts +1 -1
- package/dist/src/utils/typescript/ts-solution-setup.js +3 -3
- package/dist/src/utils/versions.d.ts +1 -0
- package/dist/src/utils/versions.js +2 -1
- package/dist/src/utils/watch-for-single-file-changes.js +2 -2
- package/dist/src/utils/workspace-module-sections.d.ts +16 -0
- package/dist/src/utils/workspace-module-sections.js +24 -0
- package/migrations.json +13 -1
- package/package.json +12 -5
|
@@ -7,15 +7,27 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const plugin_1 = require("../../plugins/typescript/plugin");
|
|
9
9
|
const assert_supported_typescript_version_1 = require("../../utils/assert-supported-typescript-version");
|
|
10
|
-
const
|
|
10
|
+
const formatter_setup_1 = require("../../utils/formatter-setup");
|
|
11
|
+
const nx_formatter_internals_1 = require("../../utils/nx-formatter-internals");
|
|
11
12
|
const create_ts_config_1 = require("../../utils/typescript/create-ts-config");
|
|
12
13
|
const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
13
14
|
const ts_solution_setup_1 = require("../../utils/typescript/ts-solution-setup");
|
|
14
15
|
const versions_1 = require("../../utils/versions");
|
|
15
16
|
async function initGenerator(tree, schema) {
|
|
16
17
|
schema.addTsPlugin ??= false;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
// Detection is the only thing here that needs the nx-side helpers, so the
|
|
19
|
+
// assert belongs with it: `'none'` must still work on an older peer-compatible
|
|
20
|
+
// nx, and it reaches no formatter code at all. An explicit `'prettier'` or
|
|
21
|
+
// `'oxfmt'` does not - both setups assert for themselves.
|
|
22
|
+
if (schema.formatter == null) {
|
|
23
|
+
(0, nx_formatter_internals_1.assertNxSupportsFormatters)();
|
|
24
|
+
// Defer to `detectFormatterInTree` rather than re-deriving: it encodes the
|
|
25
|
+
// oxfmt-over-prettier precedence, which a prettier-first check gets
|
|
26
|
+
// backwards for a workspace configured with both. Falling back to "none"
|
|
27
|
+
// rather than a formatter keeps this from installing one the caller never
|
|
28
|
+
// asked for.
|
|
29
|
+
schema.formatter = (0, internal_1.detectFormatterInTree)(tree) ?? 'none';
|
|
30
|
+
}
|
|
19
31
|
return initGeneratorInternal(tree, {
|
|
20
32
|
addTsConfigBase: true,
|
|
21
33
|
...schema,
|
|
@@ -90,11 +102,13 @@ async function initGeneratorInternal(tree, schema) {
|
|
|
90
102
|
if (!schema.js) {
|
|
91
103
|
devDependencies['typescript'] = versions_1.typescriptVersion;
|
|
92
104
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
105
|
+
// One table drives both halves of formatter setup - writing the config and
|
|
106
|
+
// making the package resolvable further down. They were separate `if` chains
|
|
107
|
+
// over the same union, forty lines apart, so a third formatter meant finding
|
|
108
|
+
// both.
|
|
109
|
+
const formatterSetup = (0, formatter_setup_1.getFormatterSetup)(schema.formatter);
|
|
110
|
+
if (formatterSetup) {
|
|
111
|
+
tasks.push(formatterSetup.setUp(tree, { skipPackageJson: schema.skipPackageJson }));
|
|
98
112
|
}
|
|
99
113
|
const rootTsConfigFileName = (0, ts_config_1.getRootTsConfigFileName)(tree);
|
|
100
114
|
// If the root tsconfig file uses `importHelpers` then we must install tslib
|
|
@@ -109,15 +123,18 @@ async function initGeneratorInternal(tree, schema) {
|
|
|
109
123
|
? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, schema.keepExistingVersions ?? true)
|
|
110
124
|
: () => { };
|
|
111
125
|
tasks.push(installTask);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
126
|
+
// `installTask` is queued, not run, so the formatter just added to
|
|
127
|
+
// package.json is not on disk yet; ensurePackage installs it out of band.
|
|
128
|
+
// Not gated on `skipFormat` - callers that pass it format later in this same
|
|
129
|
+
// process.
|
|
130
|
+
const isDryRun = !!process.env.NX_DRY_RUN && process.env.NX_DRY_RUN !== 'false';
|
|
131
|
+
if (formatterSetup &&
|
|
132
|
+
!schema.skipPackageJson &&
|
|
133
|
+
!isDryRun &&
|
|
134
|
+
process.env.NX_SKIP_FORMAT !== 'true') {
|
|
135
|
+
(0, devkit_1.ensurePackage)(schema.formatter, formatterSetup.version);
|
|
117
136
|
}
|
|
118
137
|
if (!schema.skipFormat) {
|
|
119
|
-
// even if skipPackageJson === true, we can safely run formatFiles, prettier might
|
|
120
|
-
// have been installed earlier and if not, the formatFiles function still handles it
|
|
121
138
|
await (0, devkit_1.formatFiles)(tree);
|
|
122
139
|
}
|
|
123
140
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
@@ -2,6 +2,6 @@ import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
|
2
2
|
import type { LibraryGeneratorSchema, NormalizedLibraryGeneratorOptions } from './schema';
|
|
3
3
|
export declare function libraryGenerator(tree: Tree, schema: LibraryGeneratorSchema): Promise<GeneratorCallback>;
|
|
4
4
|
export declare function libraryGeneratorInternal(tree: Tree, schema: LibraryGeneratorSchema): Promise<GeneratorCallback>;
|
|
5
|
-
export type AddLintOptions = Pick<NormalizedLibraryGeneratorOptions, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'setParserOptionsProject' | 'rootProject' | 'bundler' | 'addPlugin' | 'isUsingTsSolutionConfig'>;
|
|
5
|
+
export type AddLintOptions = Pick<NormalizedLibraryGeneratorOptions, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'enableTypedLinting' | 'setParserOptionsProject' | 'rootProject' | 'bundler' | 'addPlugin' | 'isUsingTsSolutionConfig'>;
|
|
6
6
|
export declare function addLint(tree: Tree, options: AddLintOptions): Promise<GeneratorCallback>;
|
|
7
7
|
export default libraryGenerator;
|
|
@@ -7,6 +7,7 @@ const tslib_1 = require("tslib");
|
|
|
7
7
|
const internal_1 = require("@nx/devkit/internal");
|
|
8
8
|
const devkit_1 = require("@nx/devkit");
|
|
9
9
|
const path_1 = require("path");
|
|
10
|
+
const add_linting_to_project_1 = require("../../utils/add-linting-to-project");
|
|
10
11
|
const assert_supported_typescript_version_1 = require("../../utils/assert-supported-typescript-version");
|
|
11
12
|
const generator_prompts_1 = require("../../utils/generator-prompts");
|
|
12
13
|
const sort_fields_1 = require("../../utils/package-json/sort-fields");
|
|
@@ -40,8 +41,6 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
40
41
|
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
41
42
|
addTsConfigBase: true,
|
|
42
43
|
addTsPlugin,
|
|
43
|
-
// In the new setup, Prettier is prompted for and installed during `create-nx-workspace`.
|
|
44
|
-
formatter: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree) ? 'none' : 'prettier',
|
|
45
44
|
}));
|
|
46
45
|
const options = await normalizeOptions(tree, schema);
|
|
47
46
|
createFiles(tree, options);
|
|
@@ -110,6 +109,8 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
110
109
|
testEnvironment: options.testEnvironment,
|
|
111
110
|
runtimeTsconfigFileName: 'tsconfig.lib.json',
|
|
112
111
|
compiler: options.compiler === 'swc' ? 'swc' : 'babel',
|
|
112
|
+
passWithNoTests: options.passWithNoTests,
|
|
113
|
+
skipPackageJson: options.skipPackageJson,
|
|
113
114
|
addPlugin: options.addPlugin,
|
|
114
115
|
});
|
|
115
116
|
tasks.push(vitestTask);
|
|
@@ -248,7 +249,21 @@ async function configureProject(tree, options) {
|
|
|
248
249
|
}
|
|
249
250
|
}
|
|
250
251
|
async function addLint(tree, options) {
|
|
252
|
+
// Everything below reaches into `@nx/eslint`'s config utilities, which have
|
|
253
|
+
// no equivalent for other linters. Dispatch before touching any of it.
|
|
254
|
+
if (options.linter !== 'eslint') {
|
|
255
|
+
return (0, add_linting_to_project_1.addLintingToProject)(tree, {
|
|
256
|
+
linter: options.linter,
|
|
257
|
+
project: options.name,
|
|
258
|
+
addPlugin: options.addPlugin,
|
|
259
|
+
rootProject: options.rootProject,
|
|
260
|
+
unitTestRunner: options.unitTestRunner,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
251
263
|
const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', versions_1.nxVersion);
|
|
264
|
+
const { addOverrideToLintConfig, lintConfigHasOverride, isEslintConfigSupported, updateOverrideInLintConfig, addIgnoresToLintConfig, isTypedLintingEnabled,
|
|
265
|
+
// nx-ignore-next-line
|
|
266
|
+
} = require('@nx/eslint/internal');
|
|
252
267
|
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, options.name);
|
|
253
268
|
const task = await lintProjectGenerator(tree, {
|
|
254
269
|
project: options.name,
|
|
@@ -258,15 +273,12 @@ async function addLint(tree, options) {
|
|
|
258
273
|
(0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'),
|
|
259
274
|
],
|
|
260
275
|
unitTestRunner: options.unitTestRunner,
|
|
261
|
-
|
|
276
|
+
enableTypedLinting: isTypedLintingEnabled(options),
|
|
262
277
|
rootProject: options.rootProject,
|
|
263
278
|
addPlugin: options.addPlugin,
|
|
264
279
|
// Since the build target is inferred now, we need to let the generator know to add @nx/dependency-checks regardless.
|
|
265
280
|
addPackageJsonDependencyChecks: options.bundler !== 'none',
|
|
266
281
|
});
|
|
267
|
-
const { addOverrideToLintConfig, lintConfigHasOverride, isEslintConfigSupported, updateOverrideInLintConfig, addIgnoresToLintConfig,
|
|
268
|
-
// nx-ignore-next-line
|
|
269
|
-
} = require('@nx/eslint/internal');
|
|
270
282
|
// if config is not supported, we don't need to do anything
|
|
271
283
|
if (!isEslintConfigSupported(tree)) {
|
|
272
284
|
return task;
|
|
@@ -548,22 +560,20 @@ async function normalizeOptions(tree, options) {
|
|
|
548
560
|
const hasPlugin = (0, ts_solution_setup_1.isUsingTypeScriptPlugin)(tree);
|
|
549
561
|
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
|
|
550
562
|
if (isUsingTsSolutionConfig) {
|
|
551
|
-
options.unitTestRunner ??=
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}, { unitTestRunner: 'none' }).then(({ unitTestRunner }) => unitTestRunner);
|
|
563
|
+
options.unitTestRunner ??= (0, internal_1.isInteractive)()
|
|
564
|
+
? await (0, internal_1.selectPrompt)({
|
|
565
|
+
message: `Which unit test runner would you like to use?`,
|
|
566
|
+
choices: [{ value: 'none' }, { value: 'vitest' }, { value: 'jest' }],
|
|
567
|
+
})
|
|
568
|
+
: 'none';
|
|
558
569
|
}
|
|
559
570
|
else {
|
|
560
|
-
options.unitTestRunner ??=
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}, { unitTestRunner: undefined }).then(({ unitTestRunner }) => unitTestRunner);
|
|
571
|
+
options.unitTestRunner ??= (0, internal_1.isInteractive)()
|
|
572
|
+
? await (0, internal_1.selectPrompt)({
|
|
573
|
+
message: `Which unit test runner would you like to use?`,
|
|
574
|
+
choices: [{ value: 'jest' }, { value: 'vitest' }, { value: 'none' }],
|
|
575
|
+
})
|
|
576
|
+
: undefined;
|
|
567
577
|
if (!options.unitTestRunner && options.bundler === 'vite') {
|
|
568
578
|
options.unitTestRunner = 'vitest';
|
|
569
579
|
}
|
|
@@ -638,6 +648,10 @@ async function normalizeOptions(tree, options) {
|
|
|
638
648
|
isUsingTsSolutionConfig;
|
|
639
649
|
return {
|
|
640
650
|
...options,
|
|
651
|
+
// Read from `options`, not a hoisted local: the `npm-scripts` block resets
|
|
652
|
+
// it to 'none' after `normalizeLinterOption` runs. Naming the key also
|
|
653
|
+
// satisfies the normalized type, since the spread carries `linter?`.
|
|
654
|
+
linter: options.linter,
|
|
641
655
|
fileName,
|
|
642
656
|
name: isUsingTsSolutionConfig && !options.name ? importPath : projectName,
|
|
643
657
|
projectNames,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ProjectNameAndRootOptions } from '@nx/devkit/internal';
|
|
2
|
-
|
|
3
|
-
const { Linter, LinterType } = require('@nx/eslint'); // use require to import to avoid circular dependency
|
|
2
|
+
import type { LinterType } from '../../utils/linter';
|
|
4
3
|
import type { ProjectPackageManagerWorkspaceState } from '../../utils/package-manager-workspaces';
|
|
5
4
|
|
|
6
5
|
export type Compiler = 'tsc' | 'swc';
|
|
@@ -15,7 +14,8 @@ export interface LibraryGeneratorSchema {
|
|
|
15
14
|
skipPackageJson?: boolean;
|
|
16
15
|
includeBabelRc?: boolean;
|
|
17
16
|
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
18
|
-
linter?:
|
|
17
|
+
linter?: LinterType;
|
|
18
|
+
formatter?: 'none' | 'prettier' | 'oxfmt';
|
|
19
19
|
testEnvironment?: 'jsdom' | 'node';
|
|
20
20
|
importPath?: string;
|
|
21
21
|
js?: boolean;
|
|
@@ -23,6 +23,10 @@ export interface LibraryGeneratorSchema {
|
|
|
23
23
|
strict?: boolean;
|
|
24
24
|
publishable?: boolean;
|
|
25
25
|
buildable?: boolean;
|
|
26
|
+
enableTypedLinting?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
|
|
29
|
+
*/
|
|
26
30
|
setParserOptionsProject?: boolean;
|
|
27
31
|
config?: 'workspace' | 'project' | 'npm-scripts';
|
|
28
32
|
compiler?: Compiler;
|
|
@@ -33,11 +37,15 @@ export interface LibraryGeneratorSchema {
|
|
|
33
37
|
addPlugin?: boolean;
|
|
34
38
|
useProjectJson?: boolean;
|
|
35
39
|
useTscExecutor?: boolean;
|
|
40
|
+
/** @internal Only honored by the vitest setup. */
|
|
41
|
+
passWithNoTests?: boolean;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
export interface NormalizedLibraryGeneratorOptions
|
|
39
45
|
extends LibraryGeneratorSchema {
|
|
40
46
|
name: string;
|
|
47
|
+
/** `normalizeOptions` always resolves this, so it is no longer optional. */
|
|
48
|
+
linter: LinterType;
|
|
41
49
|
projectNames: ProjectNameAndRootOptions['names'];
|
|
42
50
|
fileName: string;
|
|
43
51
|
projectRoot: string;
|
|
@@ -29,11 +29,16 @@
|
|
|
29
29
|
"x-priority": "important"
|
|
30
30
|
},
|
|
31
31
|
"linter": {
|
|
32
|
-
"description": "The tool to use for running lint checks.",
|
|
32
|
+
"description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
|
|
33
33
|
"type": "string",
|
|
34
|
-
"enum": ["none", "eslint"],
|
|
34
|
+
"enum": ["none", "eslint", "oxlint"],
|
|
35
35
|
"x-priority": "important"
|
|
36
36
|
},
|
|
37
|
+
"formatter": {
|
|
38
|
+
"description": "The tool to use for code formatting.",
|
|
39
|
+
"type": "string",
|
|
40
|
+
"enum": ["none", "prettier", "oxfmt"]
|
|
41
|
+
},
|
|
37
42
|
"unitTestRunner": {
|
|
38
43
|
"description": "Test runner to use for unit tests.",
|
|
39
44
|
"type": "string",
|
|
@@ -99,11 +104,17 @@
|
|
|
99
104
|
"description": "Generate a buildable library.",
|
|
100
105
|
"x-deprecated": "Use the `bundler` option for greater control (swc, tsc, rollup, vite, esbuild, none)."
|
|
101
106
|
},
|
|
102
|
-
"
|
|
107
|
+
"enableTypedLinting": {
|
|
103
108
|
"type": "boolean",
|
|
104
|
-
"description": "Whether
|
|
109
|
+
"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.",
|
|
105
110
|
"default": false
|
|
106
111
|
},
|
|
112
|
+
"setParserOptionsProject": {
|
|
113
|
+
"type": "boolean",
|
|
114
|
+
"description": "Deprecated alias for `enableTypedLinting`.",
|
|
115
|
+
"default": false,
|
|
116
|
+
"x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
|
|
117
|
+
},
|
|
107
118
|
"config": {
|
|
108
119
|
"type": "string",
|
|
109
120
|
"enum": ["workspace", "project", "npm-scripts"],
|
|
@@ -5,8 +5,8 @@ exports.addReleaseConfigForNonTsSolution = addReleaseConfigForNonTsSolution;
|
|
|
5
5
|
exports.releaseTasks = releaseTasks;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const find_matching_projects_1 = require("nx/src/utils/find-matching-projects");
|
|
9
8
|
const generator_1 = tslib_1.__importDefault(require("../../setup-verdaccio/generator"));
|
|
9
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
10
10
|
/**
|
|
11
11
|
* Adds release option in nx.json to build the project before versioning
|
|
12
12
|
*/
|
|
@@ -122,7 +122,7 @@ function projectsConfigMatchesProject(projectsConfig, project) {
|
|
|
122
122
|
const graph = {
|
|
123
123
|
[project.name]: project,
|
|
124
124
|
};
|
|
125
|
-
const matchingProjects = (0,
|
|
125
|
+
const matchingProjects = (0, internal_1.findMatchingProjects)(projectsConfig, graph);
|
|
126
126
|
return matchingProjects.includes(project.name);
|
|
127
127
|
}
|
|
128
128
|
async function releaseTasks(tree) {
|
|
@@ -4,7 +4,6 @@ exports.setupBuildGenerator = setupBuildGenerator;
|
|
|
4
4
|
const internal_1 = require("@nx/devkit/internal");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const posix_1 = require("node:path/posix");
|
|
7
|
-
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
8
7
|
const assert_supported_typescript_version_1 = require("../../utils/assert-supported-typescript-version");
|
|
9
8
|
const get_import_path_1 = require("../../utils/get-import-path");
|
|
10
9
|
const update_package_json_1 = require("../../utils/package-json/update-package-json");
|
|
@@ -181,11 +180,7 @@ function updatePackageJsonForTsc(tree, options, project) {
|
|
|
181
180
|
if (!ts) {
|
|
182
181
|
ts = (0, ensure_typescript_1.ensureTypescript)();
|
|
183
182
|
}
|
|
184
|
-
const tsconfig = (0, ts_config_1.readTsConfig)(options.tsConfig,
|
|
185
|
-
...ts.sys,
|
|
186
|
-
readFile: (p) => tree.read(p, 'utf-8'),
|
|
187
|
-
fileExists: (p) => tree.exists(p),
|
|
188
|
-
});
|
|
183
|
+
const tsconfig = (0, ts_config_1.readTsConfig)(options.tsConfig, (0, ts_config_1.createTreeParseConfigHost)(tree));
|
|
189
184
|
let main;
|
|
190
185
|
let rootDir;
|
|
191
186
|
let outputPath;
|
|
@@ -249,5 +244,5 @@ function updatePackageJson(tree, projectName, projectRoot, main, outputPath, roo
|
|
|
249
244
|
function mergeTargetDefaults(tree, project, buildTarget) {
|
|
250
245
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
251
246
|
const projectTarget = project.targets[buildTarget];
|
|
252
|
-
return (0,
|
|
247
|
+
return (0, internal_1.mergeTargetConfigurations)(projectTarget, (0, internal_1.readTargetDefaultsForTarget)(buildTarget, nxJson.targetDefaults, projectTarget.executor));
|
|
253
248
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
|
2
|
-
import { type SyncGeneratorResult } from 'nx/
|
|
2
|
+
import { type SyncGeneratorResult } from '@nx/devkit/internal';
|
|
3
3
|
export declare function syncGenerator(tree: Tree): Promise<SyncGeneratorResult>;
|
|
4
4
|
export default syncGenerator;
|
|
@@ -6,9 +6,9 @@ const devkit_1 = require("@nx/devkit");
|
|
|
6
6
|
const ignore_1 = tslib_1.__importDefault(require("ignore"));
|
|
7
7
|
const jsonc_parser_1 = require("jsonc-parser");
|
|
8
8
|
const posix_1 = require("node:path/posix");
|
|
9
|
-
const sync_generators_1 = require("nx/src/utils/sync-generators");
|
|
10
9
|
const ts = tslib_1.__importStar(require("typescript"));
|
|
11
10
|
const assert_supported_typescript_version_1 = require("../../utils/assert-supported-typescript-version");
|
|
11
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
12
12
|
const COMMON_RUNTIME_TS_CONFIG_FILE_NAMES = [
|
|
13
13
|
'tsconfig.app.json',
|
|
14
14
|
'tsconfig.lib.json',
|
|
@@ -29,7 +29,7 @@ async function syncGenerator(tree) {
|
|
|
29
29
|
// Root tsconfig containing project references for the whole workspace
|
|
30
30
|
const rootTsconfigPath = 'tsconfig.json';
|
|
31
31
|
if (!tsconfigExists(tree, tsconfigInfoCaches, rootTsconfigPath)) {
|
|
32
|
-
throw new
|
|
32
|
+
throw new internal_1.SyncError('Missing root "tsconfig.json"', [
|
|
33
33
|
`A "tsconfig.json" file must exist in the workspace root in order to sync the project graph information to the TypeScript configuration files.`,
|
|
34
34
|
]);
|
|
35
35
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -13,8 +13,9 @@ export * from './utils/package-json/update-package-json';
|
|
|
13
13
|
export * from './utils/package-json/create-entry-points';
|
|
14
14
|
export { libraryGenerator } from './generators/library/library';
|
|
15
15
|
export { initGenerator } from './generators/init/init';
|
|
16
|
+
export { setUpFormatter } from './utils/formatter-setup';
|
|
16
17
|
export { setupPrettierGenerator } from './generators/setup-prettier/generator';
|
|
17
18
|
export { setupVerdaccio } from './generators/setup-verdaccio/generator';
|
|
18
19
|
export { isValidVariable } from './utils/is-valid-variable';
|
|
19
|
-
export {
|
|
20
|
-
export { createPackageJson } from 'nx/
|
|
20
|
+
export { type LinterType } from './utils/linter';
|
|
21
|
+
export { createLockFile, createPackageJson, generatePrunedDeployOutput, getLockFileName, } from '@nx/devkit/internal';
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getLockFileName = exports.generatePrunedDeployOutput = exports.createPackageJson = exports.createLockFile = exports.isValidVariable = exports.setupVerdaccio = exports.setupPrettierGenerator = exports.setUpFormatter = exports.initGenerator = exports.libraryGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./utils/typescript/add-tslib-dependencies"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./utils/typescript/load-ts-transformers"), exports);
|
|
@@ -19,16 +19,16 @@ var library_1 = require("./generators/library/library");
|
|
|
19
19
|
Object.defineProperty(exports, "libraryGenerator", { enumerable: true, get: function () { return library_1.libraryGenerator; } });
|
|
20
20
|
var init_1 = require("./generators/init/init");
|
|
21
21
|
Object.defineProperty(exports, "initGenerator", { enumerable: true, get: function () { return init_1.initGenerator; } });
|
|
22
|
+
var formatter_setup_1 = require("./utils/formatter-setup");
|
|
23
|
+
Object.defineProperty(exports, "setUpFormatter", { enumerable: true, get: function () { return formatter_setup_1.setUpFormatter; } });
|
|
22
24
|
var generator_1 = require("./generators/setup-prettier/generator");
|
|
23
25
|
Object.defineProperty(exports, "setupPrettierGenerator", { enumerable: true, get: function () { return generator_1.setupPrettierGenerator; } });
|
|
24
26
|
var generator_2 = require("./generators/setup-verdaccio/generator");
|
|
25
27
|
Object.defineProperty(exports, "setupVerdaccio", { enumerable: true, get: function () { return generator_2.setupVerdaccio; } });
|
|
26
28
|
var is_valid_variable_1 = require("./utils/is-valid-variable");
|
|
27
29
|
Object.defineProperty(exports, "isValidVariable", { enumerable: true, get: function () { return is_valid_variable_1.isValidVariable; } });
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Object.defineProperty(exports, "
|
|
31
|
-
Object.defineProperty(exports, "
|
|
32
|
-
|
|
33
|
-
var create_package_json_1 = require("nx/src/plugins/js/package-json/create-package-json");
|
|
34
|
-
Object.defineProperty(exports, "createPackageJson", { enumerable: true, get: function () { return create_package_json_1.createPackageJson; } });
|
|
30
|
+
var internal_1 = require("@nx/devkit/internal");
|
|
31
|
+
Object.defineProperty(exports, "createLockFile", { enumerable: true, get: function () { return internal_1.createLockFile; } });
|
|
32
|
+
Object.defineProperty(exports, "createPackageJson", { enumerable: true, get: function () { return internal_1.createPackageJson; } });
|
|
33
|
+
Object.defineProperty(exports, "generatePrunedDeployOutput", { enumerable: true, get: function () { return internal_1.generatePrunedDeployOutput; } });
|
|
34
|
+
Object.defineProperty(exports, "getLockFileName", { enumerable: true, get: function () { return internal_1.getLockFileName; } });
|
|
@@ -21,8 +21,9 @@ import { type Tree } from '@nx/devkit';
|
|
|
21
21
|
* the pre-TS6 behavior. It is itself deprecated (removed in TS7), so pass
|
|
22
22
|
* 2 silences it, deferring the interop change to the eventual TS7 work.
|
|
23
23
|
* - Config-load flag: set `ignoreDeprecations: "6.0"` on every file named
|
|
24
|
-
* exactly `tsconfig.json`, the name
|
|
25
|
-
*
|
|
24
|
+
* exactly `tsconfig.json`, the name ts-node auto-resolves when jest compiles
|
|
25
|
+
* a config file like jest.config.ts (walking up from the working directory,
|
|
26
|
+
* not the config file's own directory). ts-node injects a
|
|
26
27
|
* `target: es5` when the config leaves it unset, and es5 is a TS6-deprecated
|
|
27
28
|
* value (TS5107); the flag (which ts-node passes through) keeps that load
|
|
28
29
|
* silent. Set unconditionally, since any `tsconfig.json` is a potential
|
|
@@ -5,6 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const jsonc_parser_1 = require("jsonc-parser");
|
|
7
7
|
const ensure_typescript_1 = require("../../utils/typescript/ensure-typescript");
|
|
8
|
+
const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
8
9
|
const FORMATTING_OPTIONS = {
|
|
9
10
|
formattingOptions: { keepLines: true, insertSpaces: true, tabSize: 2 },
|
|
10
11
|
};
|
|
@@ -31,8 +32,9 @@ let tsModule;
|
|
|
31
32
|
* the pre-TS6 behavior. It is itself deprecated (removed in TS7), so pass
|
|
32
33
|
* 2 silences it, deferring the interop change to the eventual TS7 work.
|
|
33
34
|
* - Config-load flag: set `ignoreDeprecations: "6.0"` on every file named
|
|
34
|
-
* exactly `tsconfig.json`, the name
|
|
35
|
-
*
|
|
35
|
+
* exactly `tsconfig.json`, the name ts-node auto-resolves when jest compiles
|
|
36
|
+
* a config file like jest.config.ts (walking up from the working directory,
|
|
37
|
+
* not the config file's own directory). ts-node injects a
|
|
36
38
|
* `target: es5` when the config leaves it unset, and es5 is a TS6-deprecated
|
|
37
39
|
* value (TS5107); the flag (which ts-node passes through) keeps that load
|
|
38
40
|
* silent. Set unconditionally, since any `tsconfig.json` is a potential
|
|
@@ -53,14 +55,11 @@ let tsModule;
|
|
|
53
55
|
async function default_1(tree) {
|
|
54
56
|
tsModule ??= (0, ensure_typescript_1.ensureTypescript)();
|
|
55
57
|
const ts = tsModule;
|
|
56
|
-
// Tree-
|
|
57
|
-
// writes
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
readFile: (filePath) => tree.read(filePath, 'utf-8') ?? undefined,
|
|
62
|
-
readDirectory: () => [],
|
|
63
|
-
};
|
|
58
|
+
// Tree-faithful host so TypeScript resolves `extends` against pass 1's pending
|
|
59
|
+
// writes and against package-provided bases (a naive `tree.read` host misses
|
|
60
|
+
// the latter). The host's `readDirectory` no-op skips the source-file scan,
|
|
61
|
+
// since only the merged compiler options matter here, not the file list.
|
|
62
|
+
const parseHost = (0, ts_config_1.createTreeParseConfigHost)(tree);
|
|
64
63
|
const tsconfigPaths = await (0, devkit_1.globAsync)(tree, ['**/tsconfig*.json']);
|
|
65
64
|
// Pass 1: pins and config-load flags, so pass 2's inheritance check sees them.
|
|
66
65
|
let defaultsPinCount = 0;
|
|
@@ -178,7 +177,14 @@ function silenceDeprecations(tree, ts, parseHost, tsconfigPath) {
|
|
|
178
177
|
// The `extends`-merged main options, normalized by TypeScript. Passing the
|
|
179
178
|
// config object (not the path) keeps TypeScript from re-reading this file; it
|
|
180
179
|
// reads only the ancestors.
|
|
181
|
-
const
|
|
180
|
+
const mainParsed = ts.parseJsonConfigFileContent({ extends: own.extends, compilerOptions: mainIsObject ? mainBlock : {} }, parseHost, (0, node_path_1.dirname)(tsconfigPath));
|
|
181
|
+
// A base that neither the tree nor `tsc` can read leaves the merged options
|
|
182
|
+
// incomplete, so a value it deprecates would be missed. The config does not
|
|
183
|
+
// compile in that state anyway; surface it rather than silently guessing.
|
|
184
|
+
if ((0, ts_config_1.extendsResolutionFailed)(mainParsed.errors)) {
|
|
185
|
+
devkit_1.logger.warn(`Could not resolve the "extends" chain of "${tsconfigPath}"; a TypeScript 6 deprecated option inherited from the unresolved base may have been missed. Make sure the config compiles.`);
|
|
186
|
+
}
|
|
187
|
+
const mainOptions = mainParsed.options;
|
|
182
188
|
const mainDeprecated = hasDeprecatedOption(ts, mainOptions);
|
|
183
189
|
let contents = original;
|
|
184
190
|
let changed = false;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Adds the workspace-root pnpm install settings sources to the `inputs` of
|
|
4
|
+
* build targets that emit the pruned pnpm deploy output. The build approvals
|
|
5
|
+
* and `supportedArchitectures` those outputs carry reach no lockfile, so
|
|
6
|
+
* without these a revoked approval leaves the task hash unchanged and a cached
|
|
7
|
+
* run replays an output that still grants it. Inferred targets are covered by
|
|
8
|
+
* the `@nx/webpack` and `@nx/rspack` plugins themselves; this migration covers
|
|
9
|
+
* the explicitly configured executor targets, plus overlays of inferred
|
|
10
|
+
* targets (a project-level entry, under the exact name or a glob-pattern key
|
|
11
|
+
* matching it, or a matching `targetDefaults` entry) whose replacing `inputs`
|
|
12
|
+
* array discards the plugin-generated one.
|
|
13
|
+
*/
|
|
14
|
+
export default function update(tree: Tree): Promise<void>;
|