nx 23.3.0-beta.7 → 23.3.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/README.md +1 -1
- package/dist/nx-cloud-internals.d.ts +1 -1
- package/dist/nx-cloud-internals.js +4 -4
- package/dist/src/command-line/affected/affected.js +20 -1
- package/dist/src/command-line/affected/command-object.js +1 -1
- package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +6 -2
- package/dist/src/command-line/migrate/agentic/master/run-master-session.js +88 -14
- package/dist/src/command-line/migrate/command-object.d.ts +1 -0
- package/dist/src/command-line/migrate/command-object.js +6 -1
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +34 -9
- package/dist/src/command-line/migrate/migrate-analytics.js +71 -10
- package/dist/src/command-line/migrate/migrate-config.d.ts +5 -2
- package/dist/src/command-line/migrate/migrate-config.js +19 -11
- package/dist/src/command-line/migrate/migrate.d.ts +2 -0
- package/dist/src/command-line/migrate/migrate.js +152 -45
- package/dist/src/command-line/migrate/resolve-package-version.js +2 -19
- package/dist/src/command-line/migrate/run/broker.d.ts +14 -2
- package/dist/src/command-line/migrate/run/broker.js +95 -34
- package/dist/src/command-line/migrate/run/existing-run-report.d.ts +55 -0
- package/dist/src/command-line/migrate/run/existing-run-report.js +225 -0
- package/dist/src/command-line/migrate/run/give-up.d.ts +41 -0
- package/dist/src/command-line/migrate/run/give-up.js +148 -0
- package/dist/src/command-line/migrate/run/index.d.ts +6 -4
- package/dist/src/command-line/migrate/run/index.js +15 -2
- package/dist/src/command-line/migrate/run/issues.d.ts +14 -0
- package/dist/src/command-line/migrate/run/issues.js +59 -0
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +40 -1
- package/dist/src/command-line/migrate/run/orchestrator.js +509 -160
- package/dist/src/command-line/migrate/run/run-id.d.ts +0 -8
- package/dist/src/command-line/migrate/run/run-id.js +0 -30
- package/dist/src/command-line/migrate/run/run-state.d.ts +11 -9
- package/dist/src/command-line/migrate/run/run-state.js +25 -12
- package/dist/src/command-line/migrate/run/runbook.js +9 -4
- package/dist/src/command-line/migrate/run/state-lock.d.ts +31 -0
- package/dist/src/command-line/migrate/run/state-lock.js +126 -0
- package/dist/src/command-line/migrate/run/state-machine.d.ts +15 -0
- package/dist/src/command-line/migrate/run/state-machine.js +137 -10
- package/dist/src/command-line/migrate/run/util.d.ts +1 -0
- package/dist/src/command-line/migrate/run/util.js +21 -0
- package/dist/src/command-line/migrate/run/worker.js +3 -0
- package/dist/src/command-line/migrate/step-actions.d.ts +1 -1
- package/dist/src/command-line/migrate/step-actions.js +7 -1
- package/dist/src/command-line/migrate/text.d.ts +6 -0
- package/dist/src/command-line/migrate/text.js +25 -0
- package/dist/src/command-line/release/utils/release-graph.js +1 -1
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +2 -5
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +2 -2
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +4 -5
- package/dist/src/command-line/release/version/version-actions.d.ts +3 -0
- package/dist/src/command-line/reset/reset.js +10 -4
- package/dist/src/command-line/show/command-object.js +1 -1
- package/dist/src/command-line/show/projects.js +22 -0
- package/dist/src/command-line/yargs-utils/shared-options.d.ts +4 -0
- package/dist/src/command-line/yargs-utils/shared-options.js +16 -0
- package/dist/src/config/task-graph.d.ts +1 -1
- package/dist/src/config/workspace-json-project-json.d.ts +4 -4
- package/dist/src/daemon/client/client.d.ts +3 -3
- package/dist/src/daemon/client/client.js +4 -4
- package/dist/src/daemon/message-types/select-affected-tasks.d.ts +3 -0
- package/dist/src/daemon/message-types/ultracache-configuration-version.d.ts +8 -0
- package/dist/src/daemon/server/handle-hash-tasks.d.ts +2 -2
- package/dist/src/daemon/server/handle-hash-tasks.js +3 -3
- package/dist/src/daemon/server/handle-select-affected-tasks.js +5 -2
- package/dist/src/daemon/server/ultracache-configuration-state.d.ts +7 -0
- package/dist/src/daemon/server/{io-snapshots-state.js → ultracache-configuration-state.js} +5 -4
- package/dist/src/devkit-internals.d.ts +3 -1
- package/dist/src/devkit-internals.js +8 -3
- package/dist/src/hasher/create-task-hasher.d.ts +3 -3
- package/dist/src/hasher/create-task-hasher.js +6 -6
- package/dist/src/hasher/hash-task.d.ts +2 -2
- package/dist/src/hasher/hash-task.js +6 -5
- package/dist/src/hasher/native-task-hasher-impl.d.ts +7 -7
- package/dist/src/hasher/native-task-hasher-impl.js +19 -19
- package/dist/src/hasher/task-hasher.d.ts +14 -14
- package/dist/src/hasher/task-hasher.js +13 -13
- package/dist/src/native/index.d.ts +151 -102
- package/dist/src/native/native-bindings.js +4 -5
- 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 +15 -8
- package/dist/src/nx-cloud/update-manager.d.ts +3 -3
- package/dist/src/nx-cloud/update-manager.js +19 -13
- package/dist/src/nx-cloud/utilities/client.d.ts +1 -1
- package/dist/src/nx-cloud/utilities/client.js +1 -1
- package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +2 -1
- package/dist/src/nx-cloud/utilities/nx-cloud-http-client.d.ts +5 -0
- package/dist/src/nx-cloud/utilities/nx-cloud-http-client.js +16 -0
- package/dist/src/nx-cloud/utilities/url-shorten.js +17 -10
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +22 -18
- package/dist/src/plugins/js/utils/register.js +11 -3
- package/dist/src/project-graph/affected/affected-reasons.d.ts +116 -0
- package/dist/src/project-graph/affected/affected-reasons.js +459 -0
- package/dist/src/project-graph/affected/affected-tasks.d.ts +23 -10
- package/dist/src/project-graph/affected/affected-tasks.js +203 -31
- package/dist/src/project-graph/affected/print-explanation.d.ts +11 -0
- package/dist/src/project-graph/affected/print-explanation.js +44 -0
- package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
- package/dist/src/tasks-runner/init-tasks-runner.d.ts +5 -5
- package/dist/src/tasks-runner/init-tasks-runner.js +8 -15
- package/dist/src/tasks-runner/run-command.d.ts +7 -7
- package/dist/src/tasks-runner/run-command.js +19 -23
- package/dist/src/tasks-runner/task-orchestrator.d.ts +7 -3
- package/dist/src/tasks-runner/task-orchestrator.js +9 -8
- package/dist/src/tasks-runner/tasks-runner.d.ts +2 -0
- package/dist/src/ultracache/config.d.ts +21 -0
- package/dist/src/ultracache/config.js +29 -0
- package/dist/src/ultracache/fetch.d.ts +21 -0
- package/dist/src/{io-snapshots → ultracache}/fetch.js +9 -9
- package/dist/src/ultracache/overrides.d.ts +17 -0
- package/dist/src/{io-snapshots → ultracache}/overrides.js +14 -13
- package/dist/src/ultracache/report.d.ts +13 -0
- package/dist/src/{io-snapshots → ultracache}/report.js +15 -21
- package/dist/src/ultracache/store.d.ts +40 -0
- package/dist/src/{io-snapshots → ultracache}/store.js +45 -45
- package/dist/src/utils/ab-testing.js +11 -12
- package/dist/src/utils/command-line-utils.d.ts +1 -0
- package/dist/src/utils/create-cli-options.d.ts +6 -0
- package/dist/src/utils/create-cli-options.js +29 -0
- package/dist/src/utils/db-connection.d.ts +1 -0
- package/dist/src/utils/db-connection.js +1 -0
- package/dist/src/utils/git-utils.d.ts +7 -0
- package/dist/src/utils/git-utils.js +21 -9
- package/dist/src/utils/http-client.d.ts +27 -0
- package/dist/src/utils/http-client.js +193 -0
- package/package.json +12 -38
- package/dist/src/daemon/message-types/io-snapshot-version.d.ts +0 -5
- package/dist/src/daemon/server/io-snapshots-state.d.ts +0 -7
- package/dist/src/io-snapshots/config.d.ts +0 -23
- package/dist/src/io-snapshots/config.js +0 -32
- package/dist/src/io-snapshots/fetch.d.ts +0 -21
- package/dist/src/io-snapshots/outputs.d.ts +0 -12
- package/dist/src/io-snapshots/outputs.js +0 -33
- package/dist/src/io-snapshots/overrides.d.ts +0 -17
- package/dist/src/io-snapshots/report.d.ts +0 -13
- package/dist/src/io-snapshots/store.d.ts +0 -37
- package/dist/src/nx-cloud/utilities/axios.d.ts +0 -4
- package/dist/src/nx-cloud/utilities/axios.js +0 -17
- /package/dist/src/daemon/message-types/{io-snapshot-version.js → ultracache-configuration-version.js} +0 -0
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](<>)
|
|
13
13
|
[](http://commitizen.github.io/cz-cli/)
|
|
14
14
|
[](https://go.nx.dev/community)
|
|
15
|
-
[](https://nx.dev/nx-cloud)
|
|
16
16
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { importUltracacheConfigurations, openUltracacheConfigurations, } from './src/ultracache/store';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// a public API. The client probes these exports to tell what this nx supports,
|
|
4
4
|
// so keep them stable.
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
var store_1 = require("./src/
|
|
8
|
-
Object.defineProperty(exports, "
|
|
9
|
-
Object.defineProperty(exports, "
|
|
6
|
+
exports.openUltracacheConfigurations = exports.importUltracacheConfigurations = void 0;
|
|
7
|
+
var store_1 = require("./src/ultracache/store");
|
|
8
|
+
Object.defineProperty(exports, "importUltracacheConfigurations", { enumerable: true, get: function () { return store_1.importUltracacheConfigurations; } });
|
|
9
|
+
Object.defineProperty(exports, "openUltracacheConfigurations", { enumerable: true, get: function () { return store_1.openUltracacheConfigurations; } });
|
|
@@ -15,6 +15,8 @@ const configuration_1 = require("../../config/configuration");
|
|
|
15
15
|
const find_matching_projects_1 = require("../../utils/find-matching-projects");
|
|
16
16
|
const graph_1 = require("../graph/graph");
|
|
17
17
|
const affected_tasks_1 = require("../../project-graph/affected/affected-tasks");
|
|
18
|
+
const affected_reasons_1 = require("../../project-graph/affected/affected-reasons");
|
|
19
|
+
const print_explanation_1 = require("../../project-graph/affected/print-explanation");
|
|
18
20
|
async function affected(command, args, extraTargetDependencies = {}, extraOptions = {
|
|
19
21
|
excludeTaskDependencies: args.excludeTaskDependencies,
|
|
20
22
|
loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
|
|
@@ -31,12 +33,19 @@ async function affected(command, args, extraTargetDependencies = {}, extraOption
|
|
|
31
33
|
const useTasks = (0, affected_tasks_1.selectsAffectedTasks)() &&
|
|
32
34
|
command === 'affected' &&
|
|
33
35
|
!!nxArgs.targets?.length;
|
|
36
|
+
if ((0, affected_reasons_1.isExplaining)(nxArgs.explain) && !useTasks) {
|
|
37
|
+
throw new Error((0, affected_reasons_1.explainUnavailable)([
|
|
38
|
+
!(0, affected_tasks_1.selectsAffectedTasks)() && 'NX_LEGACY_AFFECTED=false',
|
|
39
|
+
!nxArgs.targets?.length && 'targets passed with --targets (-t)',
|
|
40
|
+
].filter(Boolean)));
|
|
41
|
+
}
|
|
34
42
|
// Outside the try so errors reach handleErrors, as they did from inside runCommand.
|
|
35
43
|
let projectGraph;
|
|
36
44
|
let taskSelection;
|
|
37
45
|
let projects = [];
|
|
38
46
|
if (useTasks) {
|
|
39
|
-
|
|
47
|
+
let explanation;
|
|
48
|
+
({ projectGraph, taskSelection, explanation } = await (0, affected_tasks_1.computeAffectedTasks)({
|
|
40
49
|
nxJson,
|
|
41
50
|
targets: nxArgs.targets,
|
|
42
51
|
touchedFiles: (0, file_utils_1.calculateFileChanges)((0, command_line_utils_1.parseFiles)(nxArgs).files, nxArgs),
|
|
@@ -50,8 +59,18 @@ async function affected(command, args, extraTargetDependencies = {}, extraOption
|
|
|
50
59
|
extraTargetDependencies,
|
|
51
60
|
excludeTaskDependencies: extraOptions.excludeTaskDependencies,
|
|
52
61
|
exclude: nxArgs.exclude,
|
|
62
|
+
explain: (0, affected_reasons_1.isExplaining)(nxArgs.explain),
|
|
53
63
|
...(await (0, run_command_1.runnerInputsForSelection)(nxArgs, nxJson)),
|
|
54
64
|
}));
|
|
65
|
+
// --explain reports the selection rather than acting on it: someone asking
|
|
66
|
+
// why a task is affected does not also want it to run.
|
|
67
|
+
if ((0, affected_reasons_1.isExplaining)(nxArgs.explain)) {
|
|
68
|
+
(0, print_explanation_1.printAffectedExplanation)(explanation, 'Affected tasks', nxArgs.explain, {
|
|
69
|
+
verbose: args.verbose,
|
|
70
|
+
});
|
|
71
|
+
await output_1.output.drain();
|
|
72
|
+
process.exit(0);
|
|
73
|
+
}
|
|
55
74
|
}
|
|
56
75
|
else {
|
|
57
76
|
projectGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
|
|
@@ -8,7 +8,7 @@ const shared_options_1 = require("../yargs-utils/shared-options");
|
|
|
8
8
|
exports.yargsAffectedCommand = {
|
|
9
9
|
command: 'affected',
|
|
10
10
|
describe: 'Run target for affected projects. Affected projects are projects that have been changed and projects that depend on the changed projects. See https://nx.dev/ci/features/affected for more details.',
|
|
11
|
-
builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withTuiOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withTargetAndConfigurationOption)((0, shared_options_1.withBatch)(yargs))))))
|
|
11
|
+
builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withTuiOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withTargetAndConfigurationOption)((0, shared_options_1.withBatch)((0, shared_options_1.withExplainOption)(yargs)))))))
|
|
12
12
|
.option('all', {
|
|
13
13
|
type: 'boolean',
|
|
14
14
|
deprecated: 'Use `nx run-many` instead',
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { type RunOrchestratorInitInput } from '../../run';
|
|
2
2
|
import type { DetectedInstalledAgent } from '../types';
|
|
3
|
-
export interface RunMasterSessionInput extends Omit<RunOrchestratorInitInput, 'emitAgentInstructions'> {
|
|
3
|
+
export interface RunMasterSessionInput extends Omit<RunOrchestratorInitInput, 'emitAgentInstructions' | 'onExistingRun'> {
|
|
4
4
|
agent: DetectedInstalledAgent;
|
|
5
|
+
interactive?: boolean;
|
|
6
|
+
runId?: string;
|
|
7
|
+
startFresh?: boolean;
|
|
8
|
+
confirmStart: () => Promise<boolean>;
|
|
5
9
|
}
|
|
6
10
|
/**
|
|
7
|
-
* Starts (or
|
|
11
|
+
* Starts (or continues) an orchestrated run and hands it to one agent session
|
|
8
12
|
* that drives it through `--run-id` reconciles. Run state is the only
|
|
9
13
|
* authority on the outcome: the exit code follows what run.json says once the
|
|
10
14
|
* session ends, not what the agent process returned.
|
|
@@ -4,26 +4,65 @@ exports.runMasterSession = runMasterSession;
|
|
|
4
4
|
const output_1 = require("../../../../utils/output");
|
|
5
5
|
const migrate_analytics_1 = require("../../migrate-analytics");
|
|
6
6
|
const run_1 = require("../../run");
|
|
7
|
+
const safe_prompt_1 = require("../../safe-prompt");
|
|
7
8
|
const spawn_master_1 = require("./spawn-master");
|
|
8
9
|
/**
|
|
9
|
-
* Starts (or
|
|
10
|
+
* Starts (or continues) an orchestrated run and hands it to one agent session
|
|
10
11
|
* that drives it through `--run-id` reconciles. Run state is the only
|
|
11
12
|
* authority on the outcome: the exit code follows what run.json says once the
|
|
12
13
|
* session ends, not what the agent process returned.
|
|
13
14
|
*/
|
|
14
15
|
async function runMasterSession(input) {
|
|
15
|
-
const { agent, ...init } = input;
|
|
16
|
-
|
|
16
|
+
const { agent, interactive, runId: requestedRunId, startFresh, ...init } = input;
|
|
17
|
+
// The invocation's policy; an interactive continue adopts the run's recorded
|
|
18
|
+
// one instead, shown in the report and the choice, so resume, broker and
|
|
19
|
+
// the resume hint agree with the run.
|
|
20
|
+
let policy = {
|
|
21
|
+
createCommits: init.createCommits,
|
|
22
|
+
skipInstall: init.skipInstall,
|
|
23
|
+
};
|
|
24
|
+
const resume = (runId) => (0, run_1.runOrchestratorResume)({
|
|
25
|
+
root: init.root,
|
|
26
|
+
runId,
|
|
27
|
+
policy,
|
|
28
|
+
emitAgentInstructions: false,
|
|
29
|
+
});
|
|
30
|
+
// With `replaceRunId`, starts fresh over that run only; the consent covers
|
|
31
|
+
// the run the user saw, and any other active run is reported instead.
|
|
32
|
+
const start = (replaceRunId) => (0, run_1.runOrchestratorInit)({
|
|
17
33
|
...init,
|
|
18
34
|
emitAgentInstructions: false,
|
|
35
|
+
onExistingRun: replaceRunId === undefined ? 'report' : 'start-fresh',
|
|
36
|
+
replaceRunId,
|
|
19
37
|
});
|
|
38
|
+
let ready = requestedRunId !== undefined && !startFresh
|
|
39
|
+
? resume(requestedRunId)
|
|
40
|
+
: await start(startFresh ? requestedRunId : undefined);
|
|
41
|
+
if (ready.kind === 'existing-run' && (0, safe_prompt_1.canPrompt)(interactive)) {
|
|
42
|
+
const decision = await decideExistingRun(ready, init.root);
|
|
43
|
+
if (decision === 'abort') {
|
|
44
|
+
output_1.output.log({
|
|
45
|
+
title: `Leaving migrate run ${ready.runId} as it is. ${continueHint(init.root, agent.id, ready.runId, ready.facts.policy)}`,
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (decision === 'continue') {
|
|
50
|
+
policy = ready.facts.policy;
|
|
51
|
+
ready = resume(ready.runId);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
ready = await start(ready.runId);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (ready.kind === 'existing-run') {
|
|
58
|
+
output_1.output.warn((0, run_1.renderExistingRunReport)(ready.facts, (0, run_1.renderExistingRunCommands)(init.root, ready.facts, init.migrationsPath, agent.id)));
|
|
59
|
+
return 1;
|
|
60
|
+
}
|
|
20
61
|
if (ready.kind === 'refused') {
|
|
21
62
|
return;
|
|
22
63
|
}
|
|
23
64
|
const { runId, runRoot, runbookPath, reconcileCommand } = ready;
|
|
24
|
-
|
|
25
|
-
// reproduced, and the same command carries both.
|
|
26
|
-
const resumeHint = 'Run the same nx migrate command again to resume it.';
|
|
65
|
+
const resumeHint = continueHint(init.root, agent.id, runId, policy);
|
|
27
66
|
output_1.output.log({
|
|
28
67
|
title: `Starting ${agent.displayName} to drive migrate run ${runId}.`,
|
|
29
68
|
});
|
|
@@ -33,10 +72,7 @@ async function runMasterSession(input) {
|
|
|
33
72
|
runId,
|
|
34
73
|
runbookPath,
|
|
35
74
|
reconcileCommand,
|
|
36
|
-
policy
|
|
37
|
-
createCommits: init.createCommits,
|
|
38
|
-
skipInstall: init.skipInstall,
|
|
39
|
-
},
|
|
75
|
+
policy,
|
|
40
76
|
});
|
|
41
77
|
if (session.kind === 'spawn-failed') {
|
|
42
78
|
output_1.output.error({
|
|
@@ -69,16 +105,19 @@ async function runMasterSession(input) {
|
|
|
69
105
|
}
|
|
70
106
|
switch (state.status) {
|
|
71
107
|
case 'active':
|
|
108
|
+
(0, migrate_analytics_1.reportMigrateOrchestratorAbandoned)({
|
|
109
|
+
...(0, run_1.runTallies)(state),
|
|
110
|
+
agentUsed: agent.id,
|
|
111
|
+
});
|
|
72
112
|
output_1.output.warn({
|
|
73
113
|
title: `Migrate run ${runId} is still active. ${resumeHint}`,
|
|
74
114
|
});
|
|
75
115
|
return 1;
|
|
76
116
|
case 'completed': {
|
|
77
|
-
const
|
|
78
|
-
const skipped = state.steps.filter((s) => s.status === 'skipped').length;
|
|
117
|
+
const tally = (0, run_1.tallySteps)(state);
|
|
79
118
|
output_1.output.log({
|
|
80
119
|
title: `Migrate run ${runId} is complete.`,
|
|
81
|
-
bodyLines:
|
|
120
|
+
bodyLines: (0, run_1.completionSummaryLines)(state),
|
|
82
121
|
});
|
|
83
122
|
for (const lines of (0, run_1.completionWarnings)(runRoot, runId, state)) {
|
|
84
123
|
output_1.output.warn({ title: lines[0], bodyLines: lines.slice(1) });
|
|
@@ -87,8 +126,14 @@ async function runMasterSession(input) {
|
|
|
87
126
|
agenticOutcome: 'enabled',
|
|
88
127
|
agentUsed: agent.id,
|
|
89
128
|
migrationCount: state.steps.length,
|
|
90
|
-
appliedCount: applied,
|
|
129
|
+
appliedCount: tally.applied + tally.adopted,
|
|
91
130
|
});
|
|
131
|
+
if (tally.unresolved.length > 0 || (0, run_1.hasUnresolvedIssues)(state)) {
|
|
132
|
+
output_1.output.warn({
|
|
133
|
+
title: `Migrate run ${runId} left work unresolved; exiting with code 1.`,
|
|
134
|
+
});
|
|
135
|
+
return 1;
|
|
136
|
+
}
|
|
92
137
|
return;
|
|
93
138
|
}
|
|
94
139
|
default: {
|
|
@@ -97,3 +142,32 @@ async function runMasterSession(input) {
|
|
|
97
142
|
}
|
|
98
143
|
}
|
|
99
144
|
}
|
|
145
|
+
function continueHint(root, agentId, runId, policy) {
|
|
146
|
+
return `Run ${(0, run_1.renderContinueCommand)(root, runId, policy, agentId)}, with NX_MIGRATE_ORCHESTRATOR=true set in the environment, to continue it.`;
|
|
147
|
+
}
|
|
148
|
+
async function decideExistingRun(found, root) {
|
|
149
|
+
output_1.output.log((0, run_1.renderExistingRunReport)(found.facts));
|
|
150
|
+
// A held run leaves nothing to ask: continue would open a second session
|
|
151
|
+
// over the live one, and start fresh refuses. The continue's own gate
|
|
152
|
+
// throws the refusal; a holder gone since the report lets the prompt run.
|
|
153
|
+
if (found.facts.otherHolders === 'unknown' ||
|
|
154
|
+
found.facts.otherHolders.length > 0) {
|
|
155
|
+
(0, run_1.holdRunToContinue)(root, found.runId);
|
|
156
|
+
}
|
|
157
|
+
return (0, safe_prompt_1.migrateChoice)({
|
|
158
|
+
message: 'What do you want to do with the active migrate run?',
|
|
159
|
+
choices: [
|
|
160
|
+
{
|
|
161
|
+
value: 'continue',
|
|
162
|
+
label: 'Continue it',
|
|
163
|
+
hint: 'picks the run up where it stopped, keeping its recorded commit and install policy',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
value: 'start-fresh',
|
|
167
|
+
label: 'Start fresh',
|
|
168
|
+
hint: 'deletes the run record only; the whole plan runs again',
|
|
169
|
+
},
|
|
170
|
+
{ value: 'abort', label: 'Abort', hint: 'leaves the run as it is' },
|
|
171
|
+
],
|
|
172
|
+
});
|
|
173
|
+
}
|
|
@@ -60,7 +60,7 @@ function withMigrationOptions(yargs) {
|
|
|
60
60
|
})
|
|
61
61
|
.option('runId', {
|
|
62
62
|
// Hidden with the orchestrator itself.
|
|
63
|
-
describe: 'The orchestrated migrate run to record a single migration into, or to reconcile when given
|
|
63
|
+
describe: 'The orchestrated migrate run to record a single migration into, to continue with --run-migrations, or to reconcile when given alone.',
|
|
64
64
|
type: 'string',
|
|
65
65
|
hidden: true,
|
|
66
66
|
})
|
|
@@ -69,6 +69,11 @@ function withMigrationOptions(yargs) {
|
|
|
69
69
|
choices: step_actions_1.STEP_ACTIONS,
|
|
70
70
|
type: 'string',
|
|
71
71
|
hidden: true,
|
|
72
|
+
})
|
|
73
|
+
.option('startFresh', {
|
|
74
|
+
describe: 'With --run-migrations and --run-id=<id> under the orchestrator: delete the record of the active migrate run the id names and start a new run over the whole plan. Migrations the deleted run applied stay applied.',
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
hidden: true,
|
|
72
77
|
})
|
|
73
78
|
.option('ifExists', {
|
|
74
79
|
describe: `Run migrations only if the migrations file exists, if not continues successfully.`,
|
|
@@ -72,23 +72,48 @@ export declare function reportMigrateOrchestratorInit(opts: {
|
|
|
72
72
|
createCommits: boolean;
|
|
73
73
|
}): void;
|
|
74
74
|
/**
|
|
75
|
-
* One event per
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* `attempt` rides the
|
|
75
|
+
* One event per dispense response, repeated on every reconcile until the
|
|
76
|
+
* step moves. The `action` (dispense case) is a closed enum carried on a
|
|
77
|
+
* reused dimension, read conditioned on the event name (the same
|
|
78
|
+
* multiplexing pattern as {@link reportMigratePrompt}); `attempt` rides the
|
|
79
|
+
* migration-count dimension and `ordinal` (the run's dispense count) the
|
|
80
|
+
* task-count one.
|
|
79
81
|
*/
|
|
80
82
|
export declare function reportMigrateOrchestratorDispense(opts: {
|
|
81
83
|
action: string;
|
|
82
84
|
attempt: number;
|
|
85
|
+
ordinal?: number;
|
|
83
86
|
}): void;
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
/** Once per durable dispense transition. */
|
|
88
|
+
export declare function reportMigrateOrchestratorStepDispensed(opts: {
|
|
89
|
+
attempt: number;
|
|
90
|
+
ordinal: number;
|
|
91
|
+
}): void;
|
|
92
|
+
export interface MigrateOrchestratorTallies {
|
|
89
93
|
completed: number;
|
|
90
94
|
skipped: number;
|
|
95
|
+
unresolved: number;
|
|
91
96
|
dispenseCount: number;
|
|
97
|
+
}
|
|
98
|
+
export declare function reportMigrateOrchestratorComplete(opts: MigrateOrchestratorTallies): void;
|
|
99
|
+
/** The agent session nx spawned ended with the run still active. */
|
|
100
|
+
export declare function reportMigrateOrchestratorAbandoned(opts: MigrateOrchestratorTallies & {
|
|
101
|
+
agentUsed: string;
|
|
102
|
+
}): void;
|
|
103
|
+
/**
|
|
104
|
+
* An explicit continue (`--run-migrations --run-id`, or "continue" at the
|
|
105
|
+
* master prompt) took up an active run; every resume reports. A bare
|
|
106
|
+
* `--run-id` reconcile is not a resume: nothing in run state marks the first
|
|
107
|
+
* call after a lost session.
|
|
108
|
+
*/
|
|
109
|
+
export declare function reportMigrateOrchestratorResume(opts: MigrateOrchestratorTallies): void;
|
|
110
|
+
/**
|
|
111
|
+
* An invocation found an active run and started nothing. `activity` says
|
|
112
|
+
* whether another nx migrate process held the run; 'unknown' where nx cannot
|
|
113
|
+
* tell.
|
|
114
|
+
*/
|
|
115
|
+
export declare function reportMigrateOrchestratorExistingRun(opts: MigrateOrchestratorTallies & {
|
|
116
|
+
activity: 'idle' | 'held' | 'unknown';
|
|
92
117
|
}): void;
|
|
93
118
|
/**
|
|
94
119
|
* Counts invocations, not completions: emitted as soon as the migration id
|
|
@@ -13,7 +13,11 @@ exports.reportMigrateRunComplete = reportMigrateRunComplete;
|
|
|
13
13
|
exports.reportMigrateRunError = reportMigrateRunError;
|
|
14
14
|
exports.reportMigrateOrchestratorInit = reportMigrateOrchestratorInit;
|
|
15
15
|
exports.reportMigrateOrchestratorDispense = reportMigrateOrchestratorDispense;
|
|
16
|
+
exports.reportMigrateOrchestratorStepDispensed = reportMigrateOrchestratorStepDispensed;
|
|
16
17
|
exports.reportMigrateOrchestratorComplete = reportMigrateOrchestratorComplete;
|
|
18
|
+
exports.reportMigrateOrchestratorAbandoned = reportMigrateOrchestratorAbandoned;
|
|
19
|
+
exports.reportMigrateOrchestratorResume = reportMigrateOrchestratorResume;
|
|
20
|
+
exports.reportMigrateOrchestratorExistingRun = reportMigrateOrchestratorExistingRun;
|
|
17
21
|
exports.reportMigrateSingleMigrationInvocation = reportMigrateSingleMigrationInvocation;
|
|
18
22
|
exports.computeMajorsCrossed = computeMajorsCrossed;
|
|
19
23
|
exports.safeReport = safeReport;
|
|
@@ -195,10 +199,12 @@ function reportMigrateOrchestratorInit(opts) {
|
|
|
195
199
|
});
|
|
196
200
|
}
|
|
197
201
|
/**
|
|
198
|
-
* One event per
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* `attempt` rides the
|
|
202
|
+
* One event per dispense response, repeated on every reconcile until the
|
|
203
|
+
* step moves. The `action` (dispense case) is a closed enum carried on a
|
|
204
|
+
* reused dimension, read conditioned on the event name (the same
|
|
205
|
+
* multiplexing pattern as {@link reportMigratePrompt}); `attempt` rides the
|
|
206
|
+
* migration-count dimension and `ordinal` (the run's dispense count) the
|
|
207
|
+
* task-count one.
|
|
202
208
|
*/
|
|
203
209
|
function reportMigrateOrchestratorDispense(opts) {
|
|
204
210
|
safeReport(() => {
|
|
@@ -207,21 +213,76 @@ function reportMigrateOrchestratorDispense(opts) {
|
|
|
207
213
|
(0, analytics_1.reportEvent)('migrate_orchestrator_dispense', {
|
|
208
214
|
[analytics_1.customDimensions.promptChoice]: opts.action,
|
|
209
215
|
[analytics_1.customDimensions.migrationCount]: opts.attempt,
|
|
216
|
+
[analytics_1.customDimensions.taskCount]: opts.ordinal,
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/** Once per durable dispense transition. */
|
|
221
|
+
function reportMigrateOrchestratorStepDispensed(opts) {
|
|
222
|
+
safeReport(() => {
|
|
223
|
+
if (!analytics_1.customDimensions)
|
|
224
|
+
return;
|
|
225
|
+
(0, analytics_1.reportEvent)('migrate_orchestrator_step_dispensed', {
|
|
226
|
+
[analytics_1.customDimensions.migrationCount]: opts.attempt,
|
|
227
|
+
[analytics_1.customDimensions.taskCount]: opts.ordinal,
|
|
210
228
|
});
|
|
211
229
|
});
|
|
212
230
|
}
|
|
213
231
|
/**
|
|
214
|
-
*
|
|
215
|
-
*
|
|
232
|
+
* The three step tallies and the total dispense count ride reused numeric
|
|
233
|
+
* dimensions, read conditioned on the event name.
|
|
216
234
|
*/
|
|
235
|
+
function orchestratorTallyParams(tallies) {
|
|
236
|
+
return {
|
|
237
|
+
[analytics_1.customDimensions.appliedCount]: tallies.completed,
|
|
238
|
+
[analytics_1.customDimensions.taskCount]: tallies.skipped,
|
|
239
|
+
[analytics_1.customDimensions.majorsCrossed]: tallies.unresolved,
|
|
240
|
+
[analytics_1.customDimensions.migrationCount]: tallies.dispenseCount,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
217
243
|
function reportMigrateOrchestratorComplete(opts) {
|
|
218
244
|
safeReport(() => {
|
|
219
245
|
if (!analytics_1.customDimensions)
|
|
220
246
|
return;
|
|
221
|
-
(0, analytics_1.reportEvent)('migrate_orchestrator_complete',
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
247
|
+
(0, analytics_1.reportEvent)('migrate_orchestrator_complete', orchestratorTallyParams(opts));
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/** The agent session nx spawned ended with the run still active. */
|
|
251
|
+
function reportMigrateOrchestratorAbandoned(opts) {
|
|
252
|
+
safeReport(() => {
|
|
253
|
+
if (!analytics_1.customDimensions)
|
|
254
|
+
return;
|
|
255
|
+
(0, analytics_1.reportEvent)('migrate_orchestrator_abandoned', {
|
|
256
|
+
...orchestratorTallyParams(opts),
|
|
257
|
+
[analytics_1.customDimensions.agentUsed]: opts.agentUsed,
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* An explicit continue (`--run-migrations --run-id`, or "continue" at the
|
|
263
|
+
* master prompt) took up an active run; every resume reports. A bare
|
|
264
|
+
* `--run-id` reconcile is not a resume: nothing in run state marks the first
|
|
265
|
+
* call after a lost session.
|
|
266
|
+
*/
|
|
267
|
+
function reportMigrateOrchestratorResume(opts) {
|
|
268
|
+
safeReport(() => {
|
|
269
|
+
if (!analytics_1.customDimensions)
|
|
270
|
+
return;
|
|
271
|
+
(0, analytics_1.reportEvent)('migrate_orchestrator_resume', orchestratorTallyParams(opts));
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* An invocation found an active run and started nothing. `activity` says
|
|
276
|
+
* whether another nx migrate process held the run; 'unknown' where nx cannot
|
|
277
|
+
* tell.
|
|
278
|
+
*/
|
|
279
|
+
function reportMigrateOrchestratorExistingRun(opts) {
|
|
280
|
+
safeReport(() => {
|
|
281
|
+
if (!analytics_1.customDimensions)
|
|
282
|
+
return;
|
|
283
|
+
(0, analytics_1.reportEvent)('migrate_orchestrator_existing_run', {
|
|
284
|
+
...orchestratorTallyParams(opts),
|
|
285
|
+
[analytics_1.customDimensions.promptChoice]: opts.activity,
|
|
225
286
|
});
|
|
226
287
|
});
|
|
227
288
|
}
|
|
@@ -10,8 +10,11 @@ import { type MigrateArgs } from './command-object';
|
|
|
10
10
|
* `parseMigrationsOptions`: `include` and `multiMajorMode` in the generate
|
|
11
11
|
* phase only; `createCommits` / `commitPrefix` and `agentic` / `validate` when
|
|
12
12
|
* running the whole migrations file or a standalone single migration. A
|
|
13
|
-
* `--run-id`
|
|
14
|
-
* config from run.json and is driven by the outer agent.
|
|
13
|
+
* `--run-id` reconcile or recorded worker takes none of them: a recorded run
|
|
14
|
+
* takes its commit config from run.json and is driven by the outer agent. A
|
|
15
|
+
* `--run-migrations --run-id` continue takes `agentic` only, to select the
|
|
16
|
+
* agent of the new session. A `--start-fresh` starts a new run and takes all
|
|
17
|
+
* four.
|
|
15
18
|
*
|
|
16
19
|
* `include` is carried as `includeFromConfig` so it is never mistaken for an
|
|
17
20
|
* explicit `--include`: `resolveInclude` applies it only when the resolved
|
|
@@ -15,8 +15,11 @@ const MULTI_MAJOR_MODE_ENV = 'NX_MULTI_MAJOR_MODE';
|
|
|
15
15
|
* `parseMigrationsOptions`: `include` and `multiMajorMode` in the generate
|
|
16
16
|
* phase only; `createCommits` / `commitPrefix` and `agentic` / `validate` when
|
|
17
17
|
* running the whole migrations file or a standalone single migration. A
|
|
18
|
-
* `--run-id`
|
|
19
|
-
* config from run.json and is driven by the outer agent.
|
|
18
|
+
* `--run-id` reconcile or recorded worker takes none of them: a recorded run
|
|
19
|
+
* takes its commit config from run.json and is driven by the outer agent. A
|
|
20
|
+
* `--run-migrations --run-id` continue takes `agentic` only, to select the
|
|
21
|
+
* agent of the new session. A `--start-fresh` starts a new run and takes all
|
|
22
|
+
* four.
|
|
20
23
|
*
|
|
21
24
|
* `include` is carried as `includeFromConfig` so it is never mistaken for an
|
|
22
25
|
* explicit `--include`: `resolveInclude` applies it only when the resolved
|
|
@@ -33,11 +36,12 @@ function applyNxJsonMigrateDefaults(args, migrateConfig, env = process.env) {
|
|
|
33
36
|
// A bare `--run-id` (orchestrated reconcile) must never take the
|
|
34
37
|
// generate-options overlay, which would leak `include` etc. from nx.json.
|
|
35
38
|
const isSingleMigration = merged.runMigration !== undefined || merged.runId !== undefined;
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
// the reconcile both read the commit config from run.json
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
// These overlays are for an invocation that decides the options for itself,
|
|
40
|
+
// which a `--run-id` invocation only does when it starts fresh: the recorded
|
|
41
|
+
// worker and the reconcile both read the commit config from run.json.
|
|
42
|
+
const startsRun = (isRunMigrations || isSingleMigration) &&
|
|
43
|
+
(merged.runId === undefined || merged.startFresh === true);
|
|
44
|
+
if (startsRun) {
|
|
41
45
|
if (merged.createCommits === undefined &&
|
|
42
46
|
migrateConfig.createCommits !== undefined) {
|
|
43
47
|
assertType(migrateConfig.createCommits, 'boolean', 'createCommits');
|
|
@@ -52,15 +56,19 @@ function applyNxJsonMigrateDefaults(args, migrateConfig, env = process.env) {
|
|
|
52
56
|
assertType(migrateConfig.commitPrefix, 'string', 'commitPrefix');
|
|
53
57
|
merged.commitPrefix = migrateConfig.commitPrefix;
|
|
54
58
|
}
|
|
55
|
-
if (merged.agentic === undefined && migrateConfig.agentic !== undefined) {
|
|
56
|
-
assertValidAgentic(migrateConfig.agentic);
|
|
57
|
-
merged.agentic = (0, cli_args_1.coerceAgenticArg)(migrateConfig.agentic);
|
|
58
|
-
}
|
|
59
59
|
if (merged.validate === undefined && migrateConfig.validate !== undefined) {
|
|
60
60
|
assertType(migrateConfig.validate, 'boolean', 'validate');
|
|
61
61
|
merged.validate = migrateConfig.validate;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
// A continue takes `agentic` too; the reconcile and the worker must not:
|
|
65
|
+
// there it trips the `--agentic`/`--run-id` parse conflict.
|
|
66
|
+
if ((startsRun || isRunMigrations) &&
|
|
67
|
+
merged.agentic === undefined &&
|
|
68
|
+
migrateConfig.agentic !== undefined) {
|
|
69
|
+
assertValidAgentic(migrateConfig.agentic);
|
|
70
|
+
merged.agentic = (0, cli_args_1.coerceAgenticArg)(migrateConfig.agentic);
|
|
71
|
+
}
|
|
64
72
|
if (!isRunMigrations && !isSingleMigration) {
|
|
65
73
|
if (merged.include === undefined && migrateConfig.include !== undefined) {
|
|
66
74
|
assertOneOf(migrateConfig.include, command_object_1.MIGRATE_INCLUDE_VALUES, 'include');
|