nx 23.2.0-beta.8 → 23.2.0-beta.9
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/ai/set-up-ai-agents/set-up-ai-agents.js +2 -2
- package/dist/src/command-line/format/format.js +84 -101
- package/dist/src/command-line/import/import.js +12 -0
- package/dist/src/command-line/init/configure-plugins.js +4 -1
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +9 -0
- package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
- package/dist/src/command-line/init/implementation/angular/index.js +4 -0
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +2 -0
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
- package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
- package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +5 -0
- package/dist/src/command-line/init/implementation/format.d.ts +18 -0
- package/dist/src/command-line/init/implementation/format.js +114 -0
- package/dist/src/command-line/init/implementation/utils.js +8 -0
- package/dist/src/command-line/init/init-v1.js +7 -0
- package/dist/src/command-line/init/init-v2.js +11 -0
- package/dist/src/command-line/migrate/migrate.d.ts +4 -0
- package/dist/src/command-line/migrate/migrate.js +64 -24
- package/dist/src/command-line/release/version.js +2 -2
- package/dist/src/daemon/client/client.js +11 -2
- package/dist/src/devkit-internals.d.ts +5 -2
- package/dist/src/devkit-internals.js +14 -6
- package/dist/src/generators/internal-utils/{format-changed-files-with-prettier-if-available.d.ts → format-changed-files.d.ts} +6 -6
- package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
- package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
- package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
- package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
- package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
- package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
- package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
- package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
- package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
- package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
- package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
- package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
- package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
- package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
- package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
- package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
- package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
- package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
- package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +2 -2
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
- package/dist/src/utils/chunkify.d.ts +7 -1
- package/dist/src/utils/chunkify.js +10 -3
- package/dist/src/utils/formatters/index.d.ts +13 -0
- package/dist/src/utils/formatters/index.js +74 -0
- package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
- package/dist/src/utils/formatters/oxfmt.js +764 -0
- package/dist/src/utils/formatters/prettier.d.ts +26 -0
- package/dist/src/utils/formatters/prettier.js +201 -0
- package/dist/src/utils/formatters/shared.d.ts +5 -0
- package/dist/src/utils/formatters/shared.js +8 -0
- package/dist/src/utils/ignore.d.ts +47 -5
- package/dist/src/utils/ignore.js +93 -11
- package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
- package/dist/src/utils/write-formatted-json-file.js +5 -4
- package/package.json +11 -11
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -88
- package/dist/src/utils/is-using-prettier.d.ts +0 -3
- package/dist/src/utils/is-using-prettier.js +0 -62
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = update;
|
|
4
4
|
const executor_utils_1 = require("../../command-line/run/executor-utils");
|
|
5
|
-
const
|
|
5
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
6
6
|
const json_1 = require("../../generators/utils/json");
|
|
7
7
|
const project_configuration_1 = require("../../generators/utils/project-configuration");
|
|
8
8
|
const path_1 = require("../../utils/path");
|
|
@@ -67,7 +67,7 @@ async function update(tree) {
|
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
(0, project_configuration_1.updateNxJson)(tree, nxJson);
|
|
70
|
-
await (0,
|
|
70
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Whether `cache: true` can be written onto `key` without changing behavior for
|
|
Binary file
|
|
Binary file
|
|
@@ -6,7 +6,7 @@ const child_process_1 = require("child_process");
|
|
|
6
6
|
const output_1 = require("../../../utils/output");
|
|
7
7
|
const json_1 = require("../../../generators/utils/json");
|
|
8
8
|
const nx_json_1 = require("../../../generators/utils/nx-json");
|
|
9
|
-
const
|
|
9
|
+
const format_changed_files_1 = require("../../../generators/internal-utils/format-changed-files");
|
|
10
10
|
const url_shorten_1 = require("../../utilities/url-shorten");
|
|
11
11
|
const get_cloud_options_1 = require("../../utilities/get-cloud-options");
|
|
12
12
|
const path_1 = require("path");
|
|
@@ -137,14 +137,14 @@ async function connectToNxCloud(tree, schema, nxJson = (0, nx_json_1.readNxJson)
|
|
|
137
137
|
}
|
|
138
138
|
if (responseFromCreateNxCloudWorkspaceV2) {
|
|
139
139
|
addNxCloudIdToNxJson(tree, responseFromCreateNxCloudWorkspaceV2?.nxCloudId, schema.directory);
|
|
140
|
-
await (0,
|
|
140
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree, {
|
|
141
141
|
silent: schema.hideFormatLogs,
|
|
142
142
|
});
|
|
143
143
|
return responseFromCreateNxCloudWorkspaceV2.nxCloudId;
|
|
144
144
|
}
|
|
145
145
|
else if (responseFromCreateNxCloudWorkspaceV1) {
|
|
146
146
|
addNxCloudAccessTokenToNxJson(tree, responseFromCreateNxCloudWorkspaceV1?.token, schema.directory);
|
|
147
|
-
await (0,
|
|
147
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree, {
|
|
148
148
|
silent: schema.hideFormatLogs,
|
|
149
149
|
});
|
|
150
150
|
return responseFromCreateNxCloudWorkspaceV1.token;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
export declare function chunkify(target: string[], maxChunkLength?: number
|
|
1
|
+
export declare function chunkify(target: string[], maxChunkLength?: number,
|
|
2
|
+
/**
|
|
3
|
+
* How long each entry will be once it reaches the command line. Callers that
|
|
4
|
+
* quote or escape afterwards pass that transformation's length here, so the
|
|
5
|
+
* chunk is sized against what is actually spawned rather than the raw string.
|
|
6
|
+
*/
|
|
7
|
+
measure?: (item: string) => number): string[][];
|
|
2
8
|
/**
|
|
3
9
|
* Get the maximum length of a command-line argument string based on current platform
|
|
4
10
|
*
|
|
@@ -3,22 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.chunkify = chunkify;
|
|
4
4
|
exports.getMaxArgLength = getMaxArgLength;
|
|
5
5
|
const TERMINAL_SIZE = getMaxArgLength();
|
|
6
|
-
function chunkify(target, maxChunkLength = TERMINAL_SIZE - 500
|
|
6
|
+
function chunkify(target, maxChunkLength = TERMINAL_SIZE - 500,
|
|
7
|
+
/**
|
|
8
|
+
* How long each entry will be once it reaches the command line. Callers that
|
|
9
|
+
* quote or escape afterwards pass that transformation's length here, so the
|
|
10
|
+
* chunk is sized against what is actually spawned rather than the raw string.
|
|
11
|
+
*/
|
|
12
|
+
measure = (item) => item.length) {
|
|
7
13
|
const chunks = [];
|
|
8
14
|
let currentChunk = [];
|
|
9
15
|
let currentChunkLength = 0;
|
|
10
16
|
for (const file of target) {
|
|
17
|
+
const length = measure(file);
|
|
11
18
|
if (
|
|
12
19
|
// Prevent empty chunk if first file path is longer than maxChunkLength
|
|
13
20
|
currentChunk.length &&
|
|
14
21
|
// +1 accounts for the space between file names
|
|
15
|
-
currentChunkLength +
|
|
22
|
+
currentChunkLength + length + 1 >= maxChunkLength) {
|
|
16
23
|
chunks.push(currentChunk);
|
|
17
24
|
currentChunk = [];
|
|
18
25
|
currentChunkLength = 0;
|
|
19
26
|
}
|
|
20
27
|
currentChunk.push(file);
|
|
21
|
-
currentChunkLength +=
|
|
28
|
+
currentChunkLength += length + 1;
|
|
22
29
|
}
|
|
23
30
|
chunks.push(currentChunk);
|
|
24
31
|
return chunks;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Tree } from '../../generators/tree';
|
|
2
|
+
/**
|
|
3
|
+
* Adding a member here does NOT reliably break compilation: the repo builds
|
|
4
|
+
* with `strict: false`, so a `switch` that omits one is not an error. The
|
|
5
|
+
* `never` assertions and type-keyed tables that do catch it fail immediately
|
|
6
|
+
* inside `packages/nx`, but the ones in devkit and `@nx/js` read the type from
|
|
7
|
+
* its emitted declarations, so those only fail once it has been rebuilt.
|
|
8
|
+
*/
|
|
9
|
+
export type FormatterType = 'prettier' | 'oxfmt';
|
|
10
|
+
/** Test-only: the warn-once flag is module state and would leak between cases. */
|
|
11
|
+
export declare function resetFormatterWarningsForTesting(): void;
|
|
12
|
+
export declare function detectFormatter(root: string): FormatterType | null;
|
|
13
|
+
export declare function detectFormatterInTree(tree: Tree): FormatterType | null;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetFormatterWarningsForTesting = resetFormatterWarningsForTesting;
|
|
4
|
+
exports.detectFormatter = detectFormatter;
|
|
5
|
+
exports.detectFormatterInTree = detectFormatterInTree;
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const json_1 = require("../../generators/utils/json");
|
|
9
|
+
const fileutils_1 = require("../fileutils");
|
|
10
|
+
const oxfmt_1 = require("./oxfmt");
|
|
11
|
+
const prettier_1 = require("./prettier");
|
|
12
|
+
const logger_1 = require("../logger");
|
|
13
|
+
// Once per process: detection runs on every one of 200+ `formatFiles` call sites.
|
|
14
|
+
let warnedBothConfigured = false;
|
|
15
|
+
function warnBothConfigured() {
|
|
16
|
+
warnedBothConfigured = true;
|
|
17
|
+
logger_1.logger.warn('Both an oxfmt and a prettier config were found. Nx is formatting with ' +
|
|
18
|
+
'oxfmt. Delete the config you are not using to make the choice ' +
|
|
19
|
+
'explicit: https://nx.dev/docs/reference/code-formatting');
|
|
20
|
+
}
|
|
21
|
+
/** Test-only: the warn-once flag is module state and would leak between cases. */
|
|
22
|
+
function resetFormatterWarningsForTesting() {
|
|
23
|
+
warnedBothConfigured = false;
|
|
24
|
+
}
|
|
25
|
+
function detectFormatter(root) {
|
|
26
|
+
if ((0, oxfmt_1.isUsingOxfmt)(root)) {
|
|
27
|
+
// Flag first, so the lookup stops repeating once we have warned.
|
|
28
|
+
if (!warnedBothConfigured && (0, prettier_1.isUsingPrettier)(root)) {
|
|
29
|
+
warnBothConfigured();
|
|
30
|
+
}
|
|
31
|
+
return 'oxfmt';
|
|
32
|
+
}
|
|
33
|
+
if ((0, prettier_1.isUsingPrettier)(root)) {
|
|
34
|
+
return 'prettier';
|
|
35
|
+
}
|
|
36
|
+
// Neither is configured. Both formatters run on their defaults, so a
|
|
37
|
+
// dependency declared in the root package.json is the only statement of
|
|
38
|
+
// intent an unconfigured workspace gives. #30426 ruled out treating prettier
|
|
39
|
+
// as *resolvable in node_modules*, which a declared dependency is not.
|
|
40
|
+
const packageJsonPath = (0, node_path_1.join)(root, 'package.json');
|
|
41
|
+
if ((0, node_fs_1.existsSync)(packageJsonPath)) {
|
|
42
|
+
return detectFormatterFromDependencies((0, fileutils_1.readJsonFile)(packageJsonPath));
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
function detectFormatterInTree(tree) {
|
|
47
|
+
if ((0, oxfmt_1.isUsingOxfmtInTree)(tree)) {
|
|
48
|
+
if (!warnedBothConfigured && (0, prettier_1.isUsingPrettierInTree)(tree)) {
|
|
49
|
+
warnBothConfigured();
|
|
50
|
+
}
|
|
51
|
+
return 'oxfmt';
|
|
52
|
+
}
|
|
53
|
+
if ((0, prettier_1.isUsingPrettierInTree)(tree)) {
|
|
54
|
+
return 'prettier';
|
|
55
|
+
}
|
|
56
|
+
// See detectFormatter: a declared dependency is the fallback for both.
|
|
57
|
+
if (tree.exists('package.json')) {
|
|
58
|
+
return detectFormatterFromDependencies((0, json_1.readJson)(tree, 'package.json'));
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/** oxfmt first, matching the precedence the config files already have. */
|
|
63
|
+
function detectFormatterFromDependencies(packageJson) {
|
|
64
|
+
if (hasDependency(packageJson, 'oxfmt')) {
|
|
65
|
+
return 'oxfmt';
|
|
66
|
+
}
|
|
67
|
+
if (hasDependency(packageJson, 'prettier')) {
|
|
68
|
+
return 'prettier';
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function hasDependency(packageJson, name) {
|
|
73
|
+
return Boolean(packageJson.dependencies?.[name] ?? packageJson.devDependencies?.[name]);
|
|
74
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Tree } from '../../generators/tree';
|
|
2
|
+
/**
|
|
3
|
+
* Config filenames oxfmt *discovers* - narrower than the set `-c` accepts.
|
|
4
|
+
* Measured against 0.60.0: `oxfmt.config.{js,cjs,mjs,cts}` load when named
|
|
5
|
+
* but are never searched for, so treating one as config would format on
|
|
6
|
+
* options oxfmt ignores. No precedence order - oxfmt fails with
|
|
7
|
+
* "Both '<a>' and '<b>' found in <dir>" when a directory holds two.
|
|
8
|
+
*/
|
|
9
|
+
export declare const oxfmtConfigFiles: string[];
|
|
10
|
+
export declare function isUsingOxfmt(root: string): boolean;
|
|
11
|
+
export declare function isUsingOxfmtInTree(tree: Tree): boolean;
|
|
12
|
+
export declare function getOxfmtBinPath(): string;
|
|
13
|
+
export declare function writeWithOxfmt(patterns: string[], cwd?: string): void;
|
|
14
|
+
export declare function checkWithOxfmt(patterns: string[]): Promise<string[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Nothing is written to disk: staging files inside the workspace would race the
|
|
17
|
+
* daemon's watcher and the project graph mid-generator.
|
|
18
|
+
*
|
|
19
|
+
* A path is absent from the result when oxfmt has no parser for it, an ignore
|
|
20
|
+
* file covers it, or it is already formatted. One unparseable file fails only
|
|
21
|
+
* itself; the rest of the batch still applies.
|
|
22
|
+
*/
|
|
23
|
+
export declare function formatFilesWithOxfmt(files: {
|
|
24
|
+
path: string;
|
|
25
|
+
content: string;
|
|
26
|
+
}[], workspaceRoot: string, seedConfig?: {
|
|
27
|
+
name: string;
|
|
28
|
+
content: string;
|
|
29
|
+
}, rootConfigNames?: readonly string[], read?: (relativePath: string) => string | null | undefined): Promise<{
|
|
30
|
+
formatted: Map<string, string>;
|
|
31
|
+
errors?: string[];
|
|
32
|
+
}>;
|