nx 23.2.1 → 23.3.0-beta.1
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/command-line/format/format.js +2 -18
- package/dist/src/command-line/graph/graph.js +42 -3
- package/dist/src/command-line/init/implementation/format.js +2 -3
- package/dist/src/command-line/migrate/agentic/definitions.js +75 -19
- package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
- package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +3 -3
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +3 -3
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +27 -17
- package/dist/src/command-line/migrate/agentic/handoff.js +107 -24
- package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +21 -0
- package/dist/src/command-line/migrate/agentic/instruction-files.js +36 -0
- package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +16 -0
- package/dist/src/command-line/migrate/agentic/prompts/fragments.js +70 -0
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +4 -3
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +25 -1
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +57 -34
- package/dist/src/command-line/migrate/agentic/run-step.js +28 -4
- package/dist/src/command-line/migrate/agentic/runner.d.ts +17 -8
- package/dist/src/command-line/migrate/agentic/runner.js +110 -55
- package/dist/src/command-line/migrate/agentic/types.d.ts +23 -8
- package/dist/src/command-line/migrate/agentic/types.js +10 -7
- package/dist/src/command-line/migrate/migrate-commits.d.ts +1 -0
- package/dist/src/command-line/migrate/migrate-commits.js +9 -0
- package/dist/src/command-line/migrate/migrate-output.d.ts +3 -7
- package/dist/src/command-line/migrate/migrate-output.js +3 -7
- package/dist/src/command-line/migrate/migrate.js +21 -8
- package/dist/src/command-line/migrate/run/agent-output.d.ts +10 -0
- package/dist/src/command-line/migrate/run/agent-output.js +16 -2
- package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
- package/dist/src/command-line/migrate/run/agent-work-payload.js +142 -0
- package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
- package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
- package/dist/src/command-line/migrate/run/index.d.ts +1 -1
- package/dist/src/command-line/migrate/run/issues.d.ts +106 -0
- package/dist/src/command-line/migrate/run/issues.js +980 -0
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +1 -0
- package/dist/src/command-line/migrate/run/orchestrator.js +662 -105
- package/dist/src/command-line/migrate/run/run-state.d.ts +43 -8
- package/dist/src/command-line/migrate/run/run-state.js +184 -20
- package/dist/src/command-line/migrate/run/runbook.d.ts +17 -0
- package/dist/src/command-line/migrate/run/runbook.js +97 -0
- package/dist/src/command-line/migrate/run/state-lock.d.ts +2 -2
- package/dist/src/command-line/migrate/run/state-lock.js +2 -2
- package/dist/src/command-line/migrate/run/state-machine.d.ts +5 -1
- package/dist/src/command-line/migrate/run/state-machine.js +27 -1
- package/dist/src/command-line/migrate/run/worker.js +206 -56
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +5 -1
- package/dist/src/command-line/release/publish.js +11 -4
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +3 -3
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -3
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +2 -0
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +35 -0
- package/dist/src/command-line/yargs-utils/shared-options.d.ts +1 -1
- package/dist/src/command-line/yargs-utils/shared-options.js +22 -4
- package/dist/src/config/workspace-json-project-json.d.ts +2 -0
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/daemon/client/client.d.ts +4 -2
- package/dist/src/daemon/client/client.js +20 -11
- package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +3 -2
- package/dist/src/daemon/server/handle-hash-tasks.d.ts +8 -2
- package/dist/src/daemon/server/handle-hash-tasks.js +16 -3
- package/dist/src/daemon/server/handle-outputs-changes.d.ts +2 -2
- package/dist/src/daemon/server/handle-outputs-changes.js +21 -6
- package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +3 -2
- package/dist/src/daemon/server/outputs-tracking.d.ts +6 -0
- package/dist/src/daemon/server/outputs-tracking.js +18 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -7
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +99 -69
- package/dist/src/daemon/server/restart-checks.d.ts +22 -0
- package/dist/src/daemon/server/restart-checks.js +77 -0
- package/dist/src/daemon/server/server.js +28 -18
- package/dist/src/daemon/server/shutdown-utils.d.ts +0 -5
- package/dist/src/daemon/server/shutdown-utils.js +3 -26
- package/dist/src/hasher/hash-task.js +20 -16
- package/dist/src/hasher/native-task-hasher-impl.d.ts +8 -0
- package/dist/src/hasher/native-task-hasher-impl.js +46 -3
- package/dist/src/hasher/task-hasher.d.ts +9 -0
- package/dist/src/hasher/task-hasher.js +14 -0
- package/dist/src/native/index.d.ts +202 -21
- package/dist/src/native/index.js +3 -3
- package/dist/src/native/native-bindings.js +3 -1
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -1
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +2 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +22 -0
- package/dist/src/plugins/js/utils/register.js +2 -1
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +2 -1
- package/dist/src/project-graph/plugins/isolation/messaging.d.ts +3 -2
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +5 -1
- package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +3 -2
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +5 -1
- package/dist/src/project-graph/plugins/task-results-stub.d.ts +50 -0
- package/dist/src/project-graph/plugins/task-results-stub.js +111 -0
- package/dist/src/project-graph/plugins/tasks-execution-hooks.d.ts +3 -2
- package/dist/src/project-graph/plugins/tasks-execution-hooks.js +2 -1
- package/dist/src/project-graph/project-graph.js +2 -0
- package/dist/src/tasks-runner/batch/run-batch.js +15 -0
- package/dist/src/tasks-runner/cache.d.ts +35 -0
- package/dist/src/tasks-runner/cache.js +40 -0
- package/dist/src/tasks-runner/create-task-graph.js +1 -0
- package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
- package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
- package/dist/src/tasks-runner/forked-process-task-runner.js +8 -7
- package/dist/src/tasks-runner/init-tasks-runner.js +5 -1
- package/dist/src/tasks-runner/is-tui-enabled.js +4 -3
- package/dist/src/tasks-runner/life-cycle.d.ts +7 -0
- package/dist/src/tasks-runner/life-cycle.js +7 -0
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.d.ts +35 -0
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +146 -0
- package/dist/src/tasks-runner/prune-task-graph.d.ts +17 -0
- package/dist/src/tasks-runner/prune-task-graph.js +45 -0
- package/dist/src/tasks-runner/run-command.js +14 -3
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +93 -19
- package/dist/src/tasks-runner/running-tasks/batch-process.js +184 -88
- package/dist/src/tasks-runner/task-orchestrator.d.ts +64 -2
- package/dist/src/tasks-runner/task-orchestrator.js +232 -46
- package/dist/src/tasks-runner/terminal-output-path.d.ts +11 -0
- package/dist/src/tasks-runner/terminal-output-path.js +18 -0
- package/dist/src/tasks-runner/utils.js +5 -2
- package/dist/src/utils/ab-testing.d.ts +3 -0
- package/dist/src/utils/ab-testing.js +11 -3
- package/dist/src/utils/chunkify.d.ts +1 -7
- package/dist/src/utils/chunkify.js +2 -8
- package/dist/src/utils/command-line-utils.d.ts +19 -0
- package/dist/src/utils/command-line-utils.js +10 -3
- package/dist/src/utils/formatters/index.d.ts +6 -0
- package/dist/src/utils/formatters/index.js +5 -0
- package/dist/src/utils/formatters/prettier.d.ts +0 -8
- package/dist/src/utils/formatters/prettier.js +4 -26
- package/dist/src/utils/installed-nx-version.js +2 -48
- package/dist/src/utils/min-release-age/packument.js +1 -1
- package/dist/src/utils/output.d.ts +22 -3
- package/dist/src/utils/output.js +28 -5
- package/dist/src/utils/package-json.d.ts +25 -0
- package/dist/src/utils/package-json.js +41 -6
- package/dist/src/utils/package-manager.d.ts +6 -0
- package/dist/src/utils/package-manager.js +10 -0
- package/dist/src/utils/provenance.js +20 -4
- package/dist/src/utils/workspace-context.d.ts +47 -3
- package/dist/src/utils/workspace-context.js +162 -10
- package/package.json +12 -12
- package/schemas/nx-schema.json +4 -0
- package/schemas/project-schema.json +4 -0
- package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +0 -9
- package/dist/src/daemon/server/file-watching/route-workspace-changes.js +0 -76
- package/dist/src/daemon/server/watcher.d.ts +0 -18
- package/dist/src/daemon/server/watcher.js +0 -126
|
@@ -3,18 +3,12 @@ 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
|
|
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) {
|
|
6
|
+
function chunkify(target, maxChunkLength = TERMINAL_SIZE - 500) {
|
|
13
7
|
const chunks = [];
|
|
14
8
|
let currentChunk = [];
|
|
15
9
|
let currentChunkLength = 0;
|
|
16
10
|
for (const file of target) {
|
|
17
|
-
const length =
|
|
11
|
+
const length = file.length;
|
|
18
12
|
if (
|
|
19
13
|
// Prevent empty chunk if first file path is longer than maxChunkLength
|
|
20
14
|
currentChunk.length &&
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Arguments } from 'yargs';
|
|
2
2
|
import { NxJsonConfiguration } from '../config/nx-json';
|
|
3
3
|
import { ProjectGraph } from '../config/project-graph';
|
|
4
|
+
import type { OutputStyle } from '../command-line/yargs-utils/shared-options';
|
|
4
5
|
export interface RawNxArgs extends NxArgs {
|
|
5
6
|
prod?: boolean;
|
|
6
7
|
}
|
|
@@ -28,6 +29,24 @@ export interface NxArgs {
|
|
|
28
29
|
graph?: string | boolean;
|
|
29
30
|
skipNxCache?: boolean;
|
|
30
31
|
skipRemoteCache?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The style the user named - CLI flag or `NX_DEFAULT_OUTPUT_STYLE`. Left
|
|
34
|
+
* undefined when they named none, and that absence is load-bearing: it is how
|
|
35
|
+
* the streaming and renderer-selection decisions tell "the user wants static"
|
|
36
|
+
* from "we defaulted to static", which stream continuous tasks differently.
|
|
37
|
+
*/
|
|
38
|
+
specifiedOutputStyle?: OutputStyle;
|
|
39
|
+
/**
|
|
40
|
+
* What the run actually renders with, after the TUI, agent and failures-only
|
|
41
|
+
* defaults are applied. Always set. Every decision about what to PRINT reads
|
|
42
|
+
* this; every decision about what the user ASKED FOR reads the field above.
|
|
43
|
+
*/
|
|
44
|
+
resolvedOutputStyle?: OutputStyle;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Read `specifiedOutputStyle` for what the user named, or
|
|
47
|
+
* `resolvedOutputStyle` for what the run renders with. This will be removed
|
|
48
|
+
* in Nx 24.
|
|
49
|
+
*/
|
|
31
50
|
outputStyle?: string;
|
|
32
51
|
tui?: boolean;
|
|
33
52
|
nxBail?: boolean;
|
|
@@ -198,12 +198,13 @@ function getUncommittedFiles() {
|
|
|
198
198
|
'--name-only',
|
|
199
199
|
'--no-renames',
|
|
200
200
|
'--relative',
|
|
201
|
+
'-z',
|
|
201
202
|
'HEAD',
|
|
202
203
|
'.',
|
|
203
204
|
]);
|
|
204
205
|
}
|
|
205
206
|
function getUntrackedFiles() {
|
|
206
|
-
return parseGitOutput(['ls-files', '--others', '--exclude-standard']);
|
|
207
|
+
return parseGitOutput(['ls-files', '--others', '--exclude-standard', '-z']);
|
|
207
208
|
}
|
|
208
209
|
function getMergeBase(base, head = 'HEAD') {
|
|
209
210
|
(0, git_revision_1.assertValidGitRevision)(base);
|
|
@@ -230,6 +231,7 @@ function getFilesUsingBaseAndHead(base, head) {
|
|
|
230
231
|
'--name-only',
|
|
231
232
|
'--no-renames',
|
|
232
233
|
'--relative',
|
|
234
|
+
'-z',
|
|
233
235
|
base,
|
|
234
236
|
head,
|
|
235
237
|
]);
|
|
@@ -242,11 +244,16 @@ function runGit(args) {
|
|
|
242
244
|
windowsHide: true,
|
|
243
245
|
});
|
|
244
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Parses NUL-terminated paths, so callers must pass `-z`, and must pass it
|
|
249
|
+
* before the pathspec — git fatals on a `-z` that follows one. Without `-z` git
|
|
250
|
+
* escapes paths that contain non-ASCII or quoting characters, and honours
|
|
251
|
+
* `core.quotepath`, which is on by default.
|
|
252
|
+
*/
|
|
245
253
|
function parseGitOutput(args) {
|
|
246
254
|
return runGit(args)
|
|
247
255
|
.toString('utf-8')
|
|
248
|
-
.split('\
|
|
249
|
-
.map((a) => a.trim())
|
|
256
|
+
.split('\0')
|
|
250
257
|
.filter((a) => a.length > 0);
|
|
251
258
|
}
|
|
252
259
|
function getProjectRoots(projectNames, { nodes }) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Tree } from '../../generators/tree';
|
|
2
|
+
import { getOxfmtBinPath } from './oxfmt';
|
|
3
|
+
import { getPrettierPath } from './prettier';
|
|
2
4
|
/**
|
|
3
5
|
* Adding a member here does NOT reliably break compilation: the repo builds
|
|
4
6
|
* with `strict: false`, so a `switch` that omits one is not an error. The
|
|
@@ -7,6 +9,10 @@ import type { Tree } from '../../generators/tree';
|
|
|
7
9
|
* its emitted declarations, so those only fail once it has been rebuilt.
|
|
8
10
|
*/
|
|
9
11
|
export type FormatterType = 'prettier' | 'oxfmt';
|
|
12
|
+
export declare const resolveFormatterBin: {
|
|
13
|
+
oxfmt: typeof getOxfmtBinPath;
|
|
14
|
+
prettier: typeof getPrettierPath;
|
|
15
|
+
};
|
|
10
16
|
/** Test-only: the warn-once flag is module state and would leak between cases. */
|
|
11
17
|
export declare function resetFormatterWarningsForTesting(): void;
|
|
12
18
|
export declare function detectFormatter(root: string): FormatterType | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveFormatterBin = void 0;
|
|
3
4
|
exports.resetFormatterWarningsForTesting = resetFormatterWarningsForTesting;
|
|
4
5
|
exports.detectFormatter = detectFormatter;
|
|
5
6
|
exports.detectFormatterInTree = detectFormatterInTree;
|
|
@@ -10,6 +11,10 @@ const fileutils_1 = require("../fileutils");
|
|
|
10
11
|
const oxfmt_1 = require("./oxfmt");
|
|
11
12
|
const prettier_1 = require("./prettier");
|
|
12
13
|
const logger_1 = require("../logger");
|
|
14
|
+
exports.resolveFormatterBin = {
|
|
15
|
+
oxfmt: oxfmt_1.getOxfmtBinPath,
|
|
16
|
+
prettier: prettier_1.getPrettierPath,
|
|
17
|
+
};
|
|
13
18
|
// Once per process: detection runs on every one of 200+ `formatFiles` call sites.
|
|
14
19
|
let warnedBothConfigured = false;
|
|
15
20
|
function warnBothConfigured() {
|
|
@@ -16,11 +16,3 @@ export declare function filterToPrettierSupportedFiles(files: string[]): Promise
|
|
|
16
16
|
export declare function writeWithPrettier(patterns: string[], cwd?: string): void;
|
|
17
17
|
export declare function checkWithPrettier(patterns: string[]): Promise<string[]>;
|
|
18
18
|
export declare function getPrettierPath(): string;
|
|
19
|
-
/**
|
|
20
|
-
* Quote a pattern for prettier's shell-based exec calls; oxfmt uses execFile
|
|
21
|
-
* and takes raw paths.
|
|
22
|
-
*
|
|
23
|
-
* Exported so `nx format` can size its chunks against the quoted length -
|
|
24
|
-
* patterns are chunked before they get here, and quoting grows each one.
|
|
25
|
-
*/
|
|
26
|
-
export declare function quoteForShell(pattern: string): string;
|
|
@@ -7,7 +7,6 @@ exports.filterToPrettierSupportedFiles = filterToPrettierSupportedFiles;
|
|
|
7
7
|
exports.writeWithPrettier = writeWithPrettier;
|
|
8
8
|
exports.checkWithPrettier = checkWithPrettier;
|
|
9
9
|
exports.getPrettierPath = getPrettierPath;
|
|
10
|
-
exports.quoteForShell = quoteForShell;
|
|
11
10
|
const node_child_process_1 = require("node:child_process");
|
|
12
11
|
const node_fs_1 = require("node:fs");
|
|
13
12
|
const node_path_1 = require("node:path");
|
|
@@ -98,19 +97,17 @@ cwd) {
|
|
|
98
97
|
if (patterns.length === 0) {
|
|
99
98
|
// Prettier with no file arguments reads stdin, and `stdio: [0, 1, 2]` hands
|
|
100
99
|
// it nx's own - from a terminal it blocks forever with nothing on screen. At
|
|
101
|
-
// EOF it exits 0 under `--list-different` and 2 (which `
|
|
100
|
+
// EOF it exits 0 under `--list-different` and 2 (which `execFileSync` throws on)
|
|
102
101
|
// without it, so which failure you get depends on `shouldUseListDifferent`.
|
|
103
102
|
return;
|
|
104
103
|
}
|
|
105
104
|
const prettierPath = getPrettierPath();
|
|
106
|
-
const listDifferentArg = shouldUseListDifferent() ? '--list-different
|
|
105
|
+
const listDifferentArg = shouldUseListDifferent() ? ['--list-different'] : [];
|
|
107
106
|
// No `--parser json` special case for `.swcrc`: prettier's own language table
|
|
108
107
|
// maps it to the json parser, so it formats correctly on its own (measured).
|
|
109
108
|
// Splitting the batch also meant one of the two spawns could receive zero
|
|
110
109
|
// files, which is the error above.
|
|
111
|
-
(0, node_child_process_1.
|
|
112
|
-
.map(quoteForShell)
|
|
113
|
-
.join(' ')}`, {
|
|
110
|
+
(0, node_child_process_1.execFileSync)(process.execPath, [prettierPath, '--write', ...listDifferentArg, '--', ...patterns], {
|
|
114
111
|
cwd,
|
|
115
112
|
stdio: [0, 1, 2],
|
|
116
113
|
windowsHide: true,
|
|
@@ -119,9 +116,7 @@ cwd) {
|
|
|
119
116
|
function checkWithPrettier(patterns) {
|
|
120
117
|
const prettierPath = getPrettierPath();
|
|
121
118
|
return new Promise((resolve, reject) => {
|
|
122
|
-
(0, node_child_process_1.
|
|
123
|
-
.map(quoteForShell)
|
|
124
|
-
.join(' ')}`, { encoding: 'utf-8', windowsHide: true, maxBuffer: shared_1.FORMATTER_MAX_BUFFER }, (error, stdout) => {
|
|
119
|
+
(0, node_child_process_1.execFile)(process.execPath, [prettierPath, '--list-different', '--', ...patterns], { encoding: 'utf-8', windowsHide: true, maxBuffer: shared_1.FORMATTER_MAX_BUFFER }, (error, stdout) => {
|
|
125
120
|
if (error) {
|
|
126
121
|
// As the oxfmt sibling: a spawn failure, kill or maxBuffer overrun reports a
|
|
127
122
|
// string `code` or none. Prettier signals "files differ" numerically, so
|
|
@@ -182,20 +177,3 @@ function shouldUseListDifferent() {
|
|
|
182
177
|
}
|
|
183
178
|
return useListDifferent;
|
|
184
179
|
}
|
|
185
|
-
/**
|
|
186
|
-
* Quote a pattern for prettier's shell-based exec calls; oxfmt uses execFile
|
|
187
|
-
* and takes raw paths.
|
|
188
|
-
*
|
|
189
|
-
* Exported so `nx format` can size its chunks against the quoted length -
|
|
190
|
-
* patterns are chunked before they get here, and quoting grows each one.
|
|
191
|
-
*/
|
|
192
|
-
function quoteForShell(pattern) {
|
|
193
|
-
// Interpolated into a command string, so every character special *inside
|
|
194
|
-
// double quotes* needs escaping, not just `$`: a backtick substitutes, `"`
|
|
195
|
-
// closes the quoting, `\` escapes what follows. One pass over the original,
|
|
196
|
-
// since `String.replace` never re-scans what it inserted.
|
|
197
|
-
const escaped = process.platform !== 'win32'
|
|
198
|
-
? pattern.replace(/([\\"`$])/g, '\\$1')
|
|
199
|
-
: pattern;
|
|
200
|
-
return `"${escaped}"`;
|
|
201
|
-
}
|
|
@@ -4,8 +4,6 @@ exports.getInstalledVersion = getInstalledVersion;
|
|
|
4
4
|
exports.getInstalledNxVersion = getInstalledNxVersion;
|
|
5
5
|
exports.getInstalledLegacyNrwlWorkspaceVersion = getInstalledLegacyNrwlWorkspaceVersion;
|
|
6
6
|
exports.getInstalledPackageGroup = getInstalledPackageGroup;
|
|
7
|
-
const tslib_1 = require("tslib");
|
|
8
|
-
const node_module_1 = tslib_1.__importStar(require("node:module"));
|
|
9
7
|
const fileutils_1 = require("./fileutils");
|
|
10
8
|
const package_json_1 = require("./package-json");
|
|
11
9
|
const workspace_root_1 = require("./workspace-root");
|
|
@@ -15,15 +13,11 @@ const installation_directory_1 = require("./installation-directory");
|
|
|
15
13
|
* resolver. The resolver always reflects the workspace's `node_modules`/PnP
|
|
16
14
|
* store rather than whichever copy happens to be loaded in the current process
|
|
17
15
|
* (e.g. the temp `nx@latest` install used by the migrate bootstrap). See
|
|
18
|
-
* nrwl/nx#35444 and `
|
|
16
|
+
* nrwl/nx#35444 and `resolveWithoutCachePollution`.
|
|
19
17
|
*/
|
|
20
18
|
function readInstalledPackageJson(packageName) {
|
|
21
|
-
const path = resolvePackageJsonWithoutCachePollution(packageName, (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot));
|
|
22
|
-
if (!path) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
19
|
try {
|
|
26
|
-
return (0, fileutils_1.readJsonFile)(
|
|
20
|
+
return (0, fileutils_1.readJsonFile)((0, package_json_1.resolveWithoutCachePollution)(`${packageName}/package.json`, (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot)));
|
|
27
21
|
}
|
|
28
22
|
catch {
|
|
29
23
|
return null;
|
|
@@ -71,43 +65,3 @@ function getInstalledPackageGroup(packageName) {
|
|
|
71
65
|
}
|
|
72
66
|
return set;
|
|
73
67
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Resolve `<packageName>/package.json` via Node's CJS resolver while
|
|
76
|
-
* neutralising both ways `require.resolve(req, { paths })` can lie about
|
|
77
|
-
* the `paths` argument:
|
|
78
|
-
*
|
|
79
|
-
* 1. Process-wide `Module._pathCache` — swapped out for the duration of
|
|
80
|
-
* the call, so any cache entries written are discarded and any
|
|
81
|
-
* previously-poisoned entries are not read. Without this, an
|
|
82
|
-
* in-process load of a second `nx` package (e.g. the temp `nx@latest`
|
|
83
|
-
* install used by the daemon's AI-agents and console-status checks)
|
|
84
|
-
* can poison the cache key this call uses and make us read the temp
|
|
85
|
-
* path instead of the workspace path.
|
|
86
|
-
*
|
|
87
|
-
* 2. Package self-reference — when a file inside package `nx` calls
|
|
88
|
-
* `require.resolve('nx/...')`, Node returns that calling package's
|
|
89
|
-
* own file regardless of `paths`. We avoid that by issuing the
|
|
90
|
-
* resolve from a `createRequire` rooted at a synthetic path that is
|
|
91
|
-
* outside any package, so the resolver has no "self" to reference
|
|
92
|
-
* and must honour `paths`.
|
|
93
|
-
*
|
|
94
|
-
* Node's single-threaded synchronous execution means `require.resolve` does
|
|
95
|
-
* not yield, so no other code in the process can observe the swapped cache.
|
|
96
|
-
*/
|
|
97
|
-
function resolvePackageJsonWithoutCachePollution(packageName, requirePaths) {
|
|
98
|
-
// `_pathCache` is an internal Node API not exposed in @types/node.
|
|
99
|
-
const realCache = node_module_1.default._pathCache;
|
|
100
|
-
node_module_1.default._pathCache = Object.create(null);
|
|
101
|
-
try {
|
|
102
|
-
const detachedRequire = (0, node_module_1.createRequire)('/__nx_detached_resolver__/x.js');
|
|
103
|
-
return detachedRequire.resolve(`${packageName}/package.json`, {
|
|
104
|
-
paths: requirePaths,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
catch {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
finally {
|
|
111
|
-
node_module_1.default._pathCache = realCache;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
@@ -17,7 +17,7 @@ function toArray(value) {
|
|
|
17
17
|
*/
|
|
18
18
|
async function fetchRegistryMetadata(pkg) {
|
|
19
19
|
const raw = await (0, package_manager_1.packageRegistryView)(pkg, '', ['--json']);
|
|
20
|
-
const parsed =
|
|
20
|
+
const parsed = (0, package_manager_1.parseRegistryViewJson)(raw);
|
|
21
21
|
const time = parsed.time ?? null;
|
|
22
22
|
if (time) {
|
|
23
23
|
// The time map carries 'created'/'modified' alongside versions; they are
|
|
@@ -12,14 +12,33 @@ export type CollapsibleTaskStatus = Extract<TaskStatus, 'success' | 'local-cache
|
|
|
12
12
|
* routed, the two behave identically.
|
|
13
13
|
*/
|
|
14
14
|
export declare function isStaticOutputStyle(outputStyle: string | undefined): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether a style puts task output on the terminal at all.
|
|
17
|
+
*
|
|
18
|
+
* `summary` does not - it prints a status line and the path to each task's log,
|
|
19
|
+
* deliberately addressing the output instead of reproducing it. So every
|
|
20
|
+
* decision that would put a task's bytes on the terminal has to consult this
|
|
21
|
+
* first, including ones that bypass the life cycle: both batch folds and
|
|
22
|
+
* `BatchProcess`'s live forward write to `output` directly, and under `summary`
|
|
23
|
+
* each would dump exactly what the style exists to keep off the screen.
|
|
24
|
+
*
|
|
25
|
+
* Withholding is only half of it. Whatever a caller suppresses here has to be
|
|
26
|
+
* readable somewhere else, because the style's contract is that the output
|
|
27
|
+
* moved, not that it is gone - `BatchProcess` captures to a file rather than
|
|
28
|
+
* dropping, and `runBatch` hands its path to the life cycle.
|
|
29
|
+
*/
|
|
30
|
+
export declare function printsTaskOutput(outputStyle: string | undefined): boolean;
|
|
15
31
|
/**
|
|
16
32
|
* Whether a run prints every task's output in full rather than collapsing the
|
|
17
33
|
* ones that succeeded. Both static life cycles and the batch renderer have to
|
|
18
34
|
* agree on this, so they read it from here rather than each deriving it.
|
|
19
35
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
36
|
+
* Two styles collapse. `static-failures-only` shows only what failed, and is
|
|
37
|
+
* what a run that named no style gets; `summary` withholds task output
|
|
38
|
+
* altogether, addressing each log by path instead, and outranks `verbose` -
|
|
39
|
+
* asking for more detail cannot turn a style whose whole contract is "the
|
|
40
|
+
* output is on disk" back into one that prints. Every other style prints in
|
|
41
|
+
* full because it was asked for explicitly. Note the static life cycles serve more
|
|
23
42
|
* styles than the static-sounding ones: `shouldUseDynamicLifeCycle` bails on
|
|
24
43
|
* `isCI()` before it looks at the style at all, so in CI `dynamic` and `tui`
|
|
25
44
|
* land here too. This is written as a deny-list for that reason — a new style
|
package/dist/src/utils/output.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.output = void 0;
|
|
4
4
|
exports.isStaticOutputStyle = isStaticOutputStyle;
|
|
5
|
+
exports.printsTaskOutput = printsTaskOutput;
|
|
5
6
|
exports.printsFullTaskOutput = printsFullTaskOutput;
|
|
6
7
|
exports.isLogGroupingEnabled = isLogGroupingEnabled;
|
|
7
8
|
exports.shouldGroupBatchOutput = shouldGroupBatchOutput;
|
|
@@ -23,14 +24,35 @@ const GH_GROUP_SUFFIX = '::endgroup::';
|
|
|
23
24
|
function isStaticOutputStyle(outputStyle) {
|
|
24
25
|
return outputStyle === 'static' || outputStyle === 'static-failures-only';
|
|
25
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether a style puts task output on the terminal at all.
|
|
29
|
+
*
|
|
30
|
+
* `summary` does not - it prints a status line and the path to each task's log,
|
|
31
|
+
* deliberately addressing the output instead of reproducing it. So every
|
|
32
|
+
* decision that would put a task's bytes on the terminal has to consult this
|
|
33
|
+
* first, including ones that bypass the life cycle: both batch folds and
|
|
34
|
+
* `BatchProcess`'s live forward write to `output` directly, and under `summary`
|
|
35
|
+
* each would dump exactly what the style exists to keep off the screen.
|
|
36
|
+
*
|
|
37
|
+
* Withholding is only half of it. Whatever a caller suppresses here has to be
|
|
38
|
+
* readable somewhere else, because the style's contract is that the output
|
|
39
|
+
* moved, not that it is gone - `BatchProcess` captures to a file rather than
|
|
40
|
+
* dropping, and `runBatch` hands its path to the life cycle.
|
|
41
|
+
*/
|
|
42
|
+
function printsTaskOutput(outputStyle) {
|
|
43
|
+
return outputStyle !== 'summary';
|
|
44
|
+
}
|
|
26
45
|
/**
|
|
27
46
|
* Whether a run prints every task's output in full rather than collapsing the
|
|
28
47
|
* ones that succeeded. Both static life cycles and the batch renderer have to
|
|
29
48
|
* agree on this, so they read it from here rather than each deriving it.
|
|
30
49
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
50
|
+
* Two styles collapse. `static-failures-only` shows only what failed, and is
|
|
51
|
+
* what a run that named no style gets; `summary` withholds task output
|
|
52
|
+
* altogether, addressing each log by path instead, and outranks `verbose` -
|
|
53
|
+
* asking for more detail cannot turn a style whose whole contract is "the
|
|
54
|
+
* output is on disk" back into one that prints. Every other style prints in
|
|
55
|
+
* full because it was asked for explicitly. Note the static life cycles serve more
|
|
34
56
|
* styles than the static-sounding ones: `shouldUseDynamicLifeCycle` bails on
|
|
35
57
|
* `isCI()` before it looks at the style at all, so in CI `dynamic` and `tui`
|
|
36
58
|
* land here too. This is written as a deny-list for that reason — a new style
|
|
@@ -43,8 +65,9 @@ function isStaticOutputStyle(outputStyle) {
|
|
|
43
65
|
* ever being consulted — including for the continuous tasks that must stream.
|
|
44
66
|
*/
|
|
45
67
|
function printsFullTaskOutput(args) {
|
|
46
|
-
return (
|
|
47
|
-
(args.
|
|
68
|
+
return (printsTaskOutput(args.outputStyle) &&
|
|
69
|
+
(!!args.verbose ||
|
|
70
|
+
(args.outputStyle ?? 'static-failures-only') !== 'static-failures-only'));
|
|
48
71
|
}
|
|
49
72
|
/**
|
|
50
73
|
* Whether task output should be wrapped in collapsible log groups. Grouping
|
|
@@ -143,6 +143,31 @@ export declare function readModulePackageJson(moduleSpecifier: string, requirePa
|
|
|
143
143
|
packageJson: PackageJson;
|
|
144
144
|
path: string;
|
|
145
145
|
};
|
|
146
|
+
/**
|
|
147
|
+
* Resolve `request` via Node's CJS resolver while neutralising both ways
|
|
148
|
+
* `require.resolve(req, { paths })` can lie about the `paths` argument:
|
|
149
|
+
*
|
|
150
|
+
* 1. Process-wide `Module._pathCache`. It is swapped out for the duration
|
|
151
|
+
* of the call, so any cache entries written are discarded and any
|
|
152
|
+
* previously-poisoned entries are not read. Without this, an
|
|
153
|
+
* in-process load of a second `nx` package (e.g. the temp `nx@latest`
|
|
154
|
+
* install used by the daemon's AI-agents and console-status checks)
|
|
155
|
+
* can poison the cache key this call uses and make us read the temp
|
|
156
|
+
* path instead of the workspace path.
|
|
157
|
+
*
|
|
158
|
+
* 2. Package self-reference. When a file inside package `nx` calls
|
|
159
|
+
* `require.resolve('nx/...')`, Node returns that calling package's
|
|
160
|
+
* own file regardless of `paths`. We avoid that by issuing the
|
|
161
|
+
* resolve from a `createRequire` rooted at a synthetic path that is
|
|
162
|
+
* outside any package, so the resolver has no "self" to reference
|
|
163
|
+
* and must honour `paths`.
|
|
164
|
+
*
|
|
165
|
+
* Node's single-threaded synchronous execution means `require.resolve` does
|
|
166
|
+
* not yield, so no other code in the process can observe the swapped cache.
|
|
167
|
+
*
|
|
168
|
+
* Throws like `require.resolve` when nothing matches.
|
|
169
|
+
*/
|
|
170
|
+
export declare function resolveWithoutCachePollution(request: string, requirePaths: string[]): string;
|
|
146
171
|
export declare function installPackageToTmp(pkg: string, requiredVersion: string, packageManager: PackageManager): {
|
|
147
172
|
tempDir: string;
|
|
148
173
|
cleanup: () => void;
|
|
@@ -8,12 +8,15 @@ exports.getTagsFromPackageJson = getTagsFromPackageJson;
|
|
|
8
8
|
exports.readTargetsFromPackageJson = readTargetsFromPackageJson;
|
|
9
9
|
exports.readModulePackageJsonWithoutFallbacks = readModulePackageJsonWithoutFallbacks;
|
|
10
10
|
exports.readModulePackageJson = readModulePackageJson;
|
|
11
|
+
exports.resolveWithoutCachePollution = resolveWithoutCachePollution;
|
|
11
12
|
exports.installPackageToTmp = installPackageToTmp;
|
|
12
13
|
exports.installPackageToTmpAsync = installPackageToTmpAsync;
|
|
13
14
|
exports.getDependencyVersionFromPackageJson = getDependencyVersionFromPackageJson;
|
|
15
|
+
const tslib_1 = require("tslib");
|
|
14
16
|
const child_process_1 = require("child_process");
|
|
15
17
|
const util_1 = require("util");
|
|
16
18
|
const fs_1 = require("fs");
|
|
19
|
+
const node_module_1 = tslib_1.__importStar(require("node:module"));
|
|
17
20
|
const path_1 = require("path");
|
|
18
21
|
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
19
22
|
const tmp_1 = require("tmp");
|
|
@@ -169,9 +172,7 @@ function readTargetsFromPackageJson(packageJson, nxJson, projectRoot, workspaceR
|
|
|
169
172
|
* @returns package json contents and path
|
|
170
173
|
*/
|
|
171
174
|
function readModulePackageJsonWithoutFallbacks(moduleSpecifier, requirePaths = (0, installation_directory_1.getNxRequirePaths)()) {
|
|
172
|
-
const packageJsonPath =
|
|
173
|
-
paths: requirePaths,
|
|
174
|
-
});
|
|
175
|
+
const packageJsonPath = resolveWithoutCachePollution(`${moduleSpecifier}/package.json`, requirePaths);
|
|
175
176
|
const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
|
176
177
|
return {
|
|
177
178
|
path: packageJsonPath,
|
|
@@ -200,9 +201,7 @@ function readModulePackageJson(moduleSpecifier, requirePaths = (0, installation_
|
|
|
200
201
|
readModulePackageJsonWithoutFallbacks(moduleSpecifier, requirePaths));
|
|
201
202
|
}
|
|
202
203
|
catch {
|
|
203
|
-
const entryPoint =
|
|
204
|
-
paths: requirePaths,
|
|
205
|
-
});
|
|
204
|
+
const entryPoint = resolveWithoutCachePollution(moduleSpecifier, requirePaths);
|
|
206
205
|
let moduleRootPath = (0, path_1.dirname)(entryPoint);
|
|
207
206
|
packageJsonPath = (0, path_1.join)(moduleRootPath, 'package.json');
|
|
208
207
|
while (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
@@ -219,6 +218,42 @@ function readModulePackageJson(moduleSpecifier, requirePaths = (0, installation_
|
|
|
219
218
|
path: packageJsonPath,
|
|
220
219
|
};
|
|
221
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Resolve `request` via Node's CJS resolver while neutralising both ways
|
|
223
|
+
* `require.resolve(req, { paths })` can lie about the `paths` argument:
|
|
224
|
+
*
|
|
225
|
+
* 1. Process-wide `Module._pathCache`. It is swapped out for the duration
|
|
226
|
+
* of the call, so any cache entries written are discarded and any
|
|
227
|
+
* previously-poisoned entries are not read. Without this, an
|
|
228
|
+
* in-process load of a second `nx` package (e.g. the temp `nx@latest`
|
|
229
|
+
* install used by the daemon's AI-agents and console-status checks)
|
|
230
|
+
* can poison the cache key this call uses and make us read the temp
|
|
231
|
+
* path instead of the workspace path.
|
|
232
|
+
*
|
|
233
|
+
* 2. Package self-reference. When a file inside package `nx` calls
|
|
234
|
+
* `require.resolve('nx/...')`, Node returns that calling package's
|
|
235
|
+
* own file regardless of `paths`. We avoid that by issuing the
|
|
236
|
+
* resolve from a `createRequire` rooted at a synthetic path that is
|
|
237
|
+
* outside any package, so the resolver has no "self" to reference
|
|
238
|
+
* and must honour `paths`.
|
|
239
|
+
*
|
|
240
|
+
* Node's single-threaded synchronous execution means `require.resolve` does
|
|
241
|
+
* not yield, so no other code in the process can observe the swapped cache.
|
|
242
|
+
*
|
|
243
|
+
* Throws like `require.resolve` when nothing matches.
|
|
244
|
+
*/
|
|
245
|
+
function resolveWithoutCachePollution(request, requirePaths) {
|
|
246
|
+
// `_pathCache` is an internal Node API not exposed in @types/node.
|
|
247
|
+
const realCache = node_module_1.default._pathCache;
|
|
248
|
+
node_module_1.default._pathCache = Object.create(null);
|
|
249
|
+
try {
|
|
250
|
+
const detachedRequire = (0, node_module_1.createRequire)('/__nx_detached_resolver__/x.js');
|
|
251
|
+
return detachedRequire.resolve(request, { paths: requirePaths });
|
|
252
|
+
}
|
|
253
|
+
finally {
|
|
254
|
+
node_module_1.default._pathCache = realCache;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
222
257
|
/**
|
|
223
258
|
* Prepares all necessary information for installing a package to a temporary directory.
|
|
224
259
|
* This is used by both sync and async installation functions.
|
|
@@ -130,6 +130,12 @@ export declare function getWorkspaceRegistryUrlForDisplay(pkg: string): string |
|
|
|
130
130
|
export declare function packageRegistryView(pkg: string, version: string, args: string[], options?: {
|
|
131
131
|
forceNpm?: boolean;
|
|
132
132
|
}): Promise<string>;
|
|
133
|
+
/**
|
|
134
|
+
* Parses `npm view --json` output. npm 12 wraps the result in an array even
|
|
135
|
+
* when a single version matches; npm <= 11 and pnpm print the bare value. A
|
|
136
|
+
* multi-version match (range spec) stays an array.
|
|
137
|
+
*/
|
|
138
|
+
export declare function parseRegistryViewJson<T = unknown>(raw: string): T;
|
|
133
139
|
/**
|
|
134
140
|
* Only `npm pack` supports downloading a tarball of a specified remote
|
|
135
141
|
* package. `yarn` packs the active workspace, `pnpm pack` only packs
|
|
@@ -15,6 +15,7 @@ exports.resolvePackageVersionUsingRegistry = resolvePackageVersionUsingRegistry;
|
|
|
15
15
|
exports.resolvePackageVersionUsingInstallation = resolvePackageVersionUsingInstallation;
|
|
16
16
|
exports.getWorkspaceRegistryUrlForDisplay = getWorkspaceRegistryUrlForDisplay;
|
|
17
17
|
exports.packageRegistryView = packageRegistryView;
|
|
18
|
+
exports.parseRegistryViewJson = parseRegistryViewJson;
|
|
18
19
|
exports.packageRegistryPack = packageRegistryPack;
|
|
19
20
|
exports.clearPackageManagerVersionCache = clearPackageManagerVersionCache;
|
|
20
21
|
exports.getPackageWorkspaces = getPackageWorkspaces;
|
|
@@ -705,6 +706,15 @@ options) {
|
|
|
705
706
|
throw redactErrorCause(e);
|
|
706
707
|
}
|
|
707
708
|
}
|
|
709
|
+
/**
|
|
710
|
+
* Parses `npm view --json` output. npm 12 wraps the result in an array even
|
|
711
|
+
* when a single version matches; npm <= 11 and pnpm print the bare value. A
|
|
712
|
+
* multi-version match (range spec) stays an array.
|
|
713
|
+
*/
|
|
714
|
+
function parseRegistryViewJson(raw) {
|
|
715
|
+
const parsed = JSON.parse(raw);
|
|
716
|
+
return Array.isArray(parsed) && parsed.length === 1 ? parsed[0] : parsed;
|
|
717
|
+
}
|
|
708
718
|
/**
|
|
709
719
|
* Only `npm pack` supports downloading a tarball of a specified remote
|
|
710
720
|
* package. `yarn` packs the active workspace, `pnpm pack` only packs
|
|
@@ -13,6 +13,15 @@ const package_manager_1 = require("./package-manager");
|
|
|
13
13
|
*
|
|
14
14
|
* Will throw if the package does not have valid provenance.
|
|
15
15
|
*/
|
|
16
|
+
/**
|
|
17
|
+
* A build the publish workflow cuts from master rather than from a tag:
|
|
18
|
+
* `23.3.0-pr.36841.f66e88b` from a pull request, `23.2.0-canary.20260908-89f02c1`
|
|
19
|
+
* from the nightly. Each segment is matched with its leading digits so an
|
|
20
|
+
* ordinary prerelease like `1.0.0-preview.1` does not qualify.
|
|
21
|
+
*/
|
|
22
|
+
function isPublishedFromMaster(version) {
|
|
23
|
+
return /-pr\.\d+\./.test(version) || /-canary\.\d/.test(version);
|
|
24
|
+
}
|
|
16
25
|
async function ensurePackageHasProvenance(packageName, packageVersion) {
|
|
17
26
|
// this is used for locally released versions without provenance
|
|
18
27
|
// do not set this for other reasons or you might be exposed to security risks
|
|
@@ -25,8 +34,8 @@ async function ensurePackageHasProvenance(packageName, packageVersion) {
|
|
|
25
34
|
'--silent',
|
|
26
35
|
]);
|
|
27
36
|
const parsed = JSON.parse(result);
|
|
28
|
-
// `npm view <pkg>@<spec> --json` returns a bare object on npm <= 11
|
|
29
|
-
// array on npm 12
|
|
37
|
+
// `npm view <pkg>@<spec> --json` returns a bare object on npm <= 11 and
|
|
38
|
+
// pnpm but an array on npm 12, even for a single resolved version. A version
|
|
30
39
|
// range matches several versions and the registry lists all of them
|
|
31
40
|
// (including deprecated ones the installer skips), so we cannot tell which
|
|
32
41
|
// one will actually be installed; refuse rather than verify the wrong
|
|
@@ -57,8 +66,15 @@ async function ensurePackageHasProvenance(packageName, packageVersion) {
|
|
|
57
66
|
if (workflowParameters.path !== '.github/workflows/publish.yml') {
|
|
58
67
|
throw new ProvenanceError(packageName, packageVersion, 'Publishing workflow does not match .github/workflows/publish.yml');
|
|
59
68
|
}
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
// PR and canary releases are published by this same workflow running on
|
|
70
|
+
// master, so a tag for them does not exist and never will. Repository,
|
|
71
|
+
// workflow path and the artifact digest are still checked, so this only
|
|
72
|
+
// widens which ref of nrwl/nx is allowed to have built it.
|
|
73
|
+
const allowedRefs = isPublishedFromMaster(npmViewResult.version)
|
|
74
|
+
? [`refs/tags/${npmViewResult.version}`, 'refs/heads/master']
|
|
75
|
+
: [`refs/tags/${npmViewResult.version}`];
|
|
76
|
+
if (!allowedRefs.includes(workflowParameters.ref)) {
|
|
77
|
+
throw new ProvenanceError(packageName, packageVersion, `Version ref does not match ${allowedRefs.join(' or ')}`);
|
|
62
78
|
}
|
|
63
79
|
// verify that provenance was generated from the exact same artifact as the one we are installing
|
|
64
80
|
const distSha = Buffer.from(npmViewResult.dist.integrity.replace('sha512-', ''), 'base64').toString('hex');
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type { NxWorkspaceFilesExternals } from '../native';
|
|
2
|
-
|
|
1
|
+
import type { ChangeBatch, NxWorkspaceFilesExternals, WorkspaceContext, WorkspaceContextOptions } from '../native';
|
|
2
|
+
/** The shapes the native watch calls back with, taken from the binding. A
|
|
3
|
+
* failure arrives as an Error with no batch or events, so both are nullable. */
|
|
4
|
+
export type WorkspaceChangesListener = Parameters<WorkspaceContext['onChanges']>[0];
|
|
5
|
+
export type WatchEventsListener = Parameters<WorkspaceContext['onWatchEvents']>[0];
|
|
6
|
+
export declare function setupWorkspaceContext(workspaceRoot: string, options?: WorkspaceContextOptions): void;
|
|
3
7
|
export declare function getNxWorkspaceFilesFromContext(workspaceRoot: string, projectRootMap: Record<string, string>, useDaemonProcess?: boolean): Promise<import("../native").NxWorkspaceFiles>;
|
|
4
8
|
/**
|
|
5
9
|
* Sync method to get files matching globs from workspace context.
|
|
@@ -14,8 +18,48 @@ export declare function multiGlobWithWorkspaceContext(workspaceRoot: string, glo
|
|
|
14
18
|
export declare function hashWithWorkspaceContext(workspaceRoot: string, globs: string[], exclude?: string[]): Promise<string>;
|
|
15
19
|
export declare function hashMultiGlobWithWorkspaceContext(workspaceRoot: string, globGroups: string[][]): Promise<string[]>;
|
|
16
20
|
export declare function updateContextWithChangedFiles(workspaceRoot: string, createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): Promise<void>;
|
|
17
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The subset of `paths` the workspace file map holds: what the watch tracks,
|
|
23
|
+
* with the ignore rules applied.
|
|
24
|
+
*/
|
|
25
|
+
export declare function trackedFilesInContext(workspaceRoot: string, paths: string[]): string[];
|
|
26
|
+
export declare function updateFilesInContext(workspaceRoot: string, updatedFiles: string[], deletedFiles: string[]): ChangeBatch;
|
|
18
27
|
export declare function getAllFileDataInContext(workspaceRoot: string): Promise<import("../native").FileData[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Listens for the changes a watching context applies: each change reaches the
|
|
30
|
+
* listeners once, here or in `settleWorkspaceContext`, whichever takes it
|
|
31
|
+
* first. Any number of listeners may listen. Returns a function that stops
|
|
32
|
+
* this one.
|
|
33
|
+
*/
|
|
34
|
+
export declare function subscribeToWorkspaceChanges(workspaceRoot: string, listener: WorkspaceChangesListener): () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Applies every change the watcher has delivered, waiting out the kernel hop,
|
|
37
|
+
* and takes every change applied and not yet handed out. Empty when the
|
|
38
|
+
* context is not watching.
|
|
39
|
+
*/
|
|
40
|
+
export declare function settleWorkspaceContext(workspaceRoot: string): ChangeBatch;
|
|
41
|
+
/**
|
|
42
|
+
* Takes every change applied and not yet handed out, without waiting for the
|
|
43
|
+
* watcher: for a caller that has just applied changes itself.
|
|
44
|
+
*/
|
|
45
|
+
export declare function takeAppliedWorkspaceChanges(workspaceRoot: string): ChangeBatch;
|
|
46
|
+
export declare function isWatchingWorkspaceContext(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Listens for every event the context's watch delivers, including writes
|
|
49
|
+
* under ignored directories and the `rescan` marker. Any number of listeners
|
|
50
|
+
* may listen. Returns a function that stops this one.
|
|
51
|
+
*/
|
|
52
|
+
export declare function subscribeToWatchEvents(workspaceRoot: string, listener: WatchEventsListener): () => void;
|
|
53
|
+
/** Whether a batch carries no change at all. */
|
|
54
|
+
export declare function isEmptyBatch(batch: ChangeBatch): boolean;
|
|
55
|
+
export declare function stopWatchingWorkspaceContext(): void;
|
|
19
56
|
export declare function getFilesInDirectoryUsingContext(workspaceRoot: string, dir: string): Promise<string[]>;
|
|
20
57
|
export declare function updateProjectFiles(projectRootMappings: Record<string, string>, rustReferences: NxWorkspaceFilesExternals, updatedFiles: Record<string, string>, deletedFiles: string[]): import("../native").UpdatedWorkspaceFiles;
|
|
58
|
+
/**
|
|
59
|
+
* Re-walks the host's files so the archive its plugin workers load includes
|
|
60
|
+
* writes made since the last walk, such as a migration flushing to disk. The
|
|
61
|
+
* walk is selective and shared through the files lock; one still running is
|
|
62
|
+
* reused rather than repeated.
|
|
63
|
+
*/
|
|
64
|
+
export declare function refreshWorkspaceContext(workspaceRoot: string): void;
|
|
21
65
|
export declare function resetWorkspaceContext(): void;
|