@prisma-next/cli 0.12.0-dev.4 → 0.12.0-dev.41
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 +2 -2
- package/dist/cli.mjs +180 -163
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-KgJorIvG.mjs → client-Dk-zRFuT.mjs} +83 -58
- package/dist/client-Dk-zRFuT.mjs.map +1 -0
- package/dist/{command-helpers-Bbw1GbwL.mjs → command-helpers-xvg9oq4T.mjs} +301 -23
- package/dist/command-helpers-xvg9oq4T.mjs.map +1 -0
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.mjs +4 -5
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.mjs +3 -3
- package/dist/commands/db-sign.mjs +4 -4
- package/dist/commands/db-update.d.mts.map +1 -1
- package/dist/commands/db-update.mjs +10 -7
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.mjs +1 -1
- package/dist/commands/migrate.d.mts +2 -2
- package/dist/commands/migrate.d.mts.map +1 -1
- package/dist/commands/migrate.mjs +6 -8
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/migration-check.d.mts +55 -1
- package/dist/commands/migration-check.d.mts.map +1 -1
- package/dist/commands/migration-check.mjs +2 -2
- package/dist/commands/migration-graph.d.mts +25 -7
- package/dist/commands/migration-graph.d.mts.map +1 -1
- package/dist/commands/migration-graph.mjs +170 -2
- package/dist/commands/migration-graph.mjs.map +1 -0
- package/dist/commands/migration-list.d.mts +24 -26
- package/dist/commands/migration-list.d.mts.map +1 -1
- package/dist/commands/migration-list.mjs +2 -190
- package/dist/commands/migration-log.d.mts +20 -15
- package/dist/commands/migration-log.d.mts.map +1 -1
- package/dist/commands/migration-log.mjs +1 -137
- package/dist/commands/migration-new.mjs +3 -3
- package/dist/commands/migration-plan.d.mts +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.d.mts +1 -4
- package/dist/commands/migration-show.d.mts.map +1 -1
- package/dist/commands/migration-show.mjs +13 -25
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +41 -141
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +2 -759
- package/dist/commands/ref.d.mts +1 -1
- package/dist/commands/ref.mjs +3 -3
- package/dist/commands/telemetry/index.d.mts +7 -0
- package/dist/commands/telemetry/index.d.mts.map +1 -0
- package/dist/commands/telemetry/index.mjs +2 -0
- package/dist/{contract-at-errors-BxP-TOMl.mjs → contract-at-errors-Wj3u4Xco.mjs} +2 -2
- package/dist/{contract-at-errors-BxP-TOMl.mjs.map → contract-at-errors-Wj3u4Xco.mjs.map} +1 -1
- package/dist/{contract-emit-DxcGl4Uq.mjs → contract-emit-CZU0UO6M.mjs} +3 -3
- package/dist/{contract-emit-DxcGl4Uq.mjs.map → contract-emit-CZU0UO6M.mjs.map} +1 -1
- package/dist/{contract-emit-D-4jrNve.mjs → contract-emit-FetLZ3jn.mjs} +5 -5
- package/dist/{contract-emit-D-4jrNve.mjs.map → contract-emit-FetLZ3jn.mjs.map} +1 -1
- package/dist/{contract-infer-D8uEbJuu.mjs → contract-infer-3wtOsS_H.mjs} +3 -3
- package/dist/{contract-infer-D8uEbJuu.mjs.map → contract-infer-3wtOsS_H.mjs.map} +1 -1
- package/dist/{contract-space-aggregate-loader-DvZwdkrr.mjs → contract-space-aggregate-loader-BdRPfM3Q.mjs} +63 -5
- package/dist/{contract-space-aggregate-loader-DvZwdkrr.mjs.map → contract-space-aggregate-loader-BdRPfM3Q.mjs.map} +1 -1
- package/dist/{db-verify-v_vUKXTU.mjs → db-verify-BisylXFZ.mjs} +4 -4
- package/dist/{db-verify-v_vUKXTU.mjs.map → db-verify-BisylXFZ.mjs.map} +1 -1
- package/dist/exports/control-api.d.mts +2 -2
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +2 -2
- package/dist/exports/index.mjs +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/{framework-components-fYXjz_in.mjs → framework-components-Be4inY3I.mjs} +2 -2
- package/dist/{framework-components-fYXjz_in.mjs.map → framework-components-Be4inY3I.mjs.map} +1 -1
- package/dist/{global-flags-DEHjV8_s.d.mts → global-flags-DG4uY5tV.d.mts} +1 -1
- package/dist/{global-flags-DEHjV8_s.d.mts.map → global-flags-DG4uY5tV.d.mts.map} +1 -1
- package/dist/{init-Cv9UzWL5.mjs → init-BTE2U7lG.mjs} +5 -58
- package/dist/init-BTE2U7lG.mjs.map +1 -0
- package/dist/{inspect-live-schema-C6ohV_oQ.mjs → inspect-live-schema-Cy9Y4wsL.mjs} +3 -3
- package/dist/{inspect-live-schema-C6ohV_oQ.mjs.map → inspect-live-schema-Cy9Y4wsL.mjs.map} +1 -1
- package/dist/{migration-check-BiBJoYYW.mjs → migration-check-CUavU7U9.mjs} +236 -88
- package/dist/migration-check-CUavU7U9.mjs.map +1 -0
- package/dist/{migration-command-scaffold-CjvwO6at.mjs → migration-command-scaffold-BxOxtyJ6.mjs} +3 -3
- package/dist/{migration-command-scaffold-CjvwO6at.mjs.map → migration-command-scaffold-BxOxtyJ6.mjs.map} +1 -1
- package/dist/migration-graph-space-render-ByJ83gxp.mjs +1966 -0
- package/dist/migration-graph-space-render-ByJ83gxp.mjs.map +1 -0
- package/dist/migration-list-jK6QeczE.mjs +228 -0
- package/dist/migration-list-jK6QeczE.mjs.map +1 -0
- package/dist/migration-list-types-DS63IdFd.d.mts +23 -0
- package/dist/migration-list-types-DS63IdFd.d.mts.map +1 -0
- package/dist/migration-log-DWI6dZyi.mjs +215 -0
- package/dist/migration-log-DWI6dZyi.mjs.map +1 -0
- package/dist/migration-path-target-DqcrbOis.mjs +24 -0
- package/dist/migration-path-target-DqcrbOis.mjs.map +1 -0
- package/dist/{migration-plan-9DJ7q7_z.mjs → migration-plan-NHdlUwPG.mjs} +5 -6
- package/dist/{migration-plan-9DJ7q7_z.mjs.map → migration-plan-NHdlUwPG.mjs.map} +1 -1
- package/dist/migration-status-DI6Ldjbo.mjs +439 -0
- package/dist/migration-status-DI6Ldjbo.mjs.map +1 -0
- package/dist/{output-B60Gw5fu.mjs → output-CF_hqzI-.mjs} +1 -1
- package/dist/{output-B60Gw5fu.mjs.map → output-CF_hqzI-.mjs.map} +1 -1
- package/dist/{ref-advancement-DUZqsue6.mjs → ref-advancement-CJY9zOv7.mjs} +1 -1
- package/dist/{ref-advancement-DUZqsue6.mjs.map → ref-advancement-CJY9zOv7.mjs.map} +1 -1
- package/dist/telemetry-DQP0BvKv.mjs +122 -0
- package/dist/telemetry-DQP0BvKv.mjs.map +1 -0
- package/dist/{types-Dt_SfqFm.d.mts → types-Cculk5KV.d.mts} +44 -31
- package/dist/types-Cculk5KV.d.mts.map +1 -0
- package/dist/{verify-DCA9Sldu.mjs → verify-tvHRBBVP.mjs} +2 -2
- package/dist/{verify-DCA9Sldu.mjs.map → verify-tvHRBBVP.mjs.map} +1 -1
- package/package.json +22 -19
- package/src/cli.ts +5 -0
- package/src/commands/db-update.ts +7 -1
- package/src/commands/init/index.ts +6 -35
- package/src/commands/init/init.ts +1 -14
- package/src/commands/init/inputs.ts +0 -75
- package/src/commands/migrate.ts +6 -6
- package/src/commands/migration-check.ts +340 -117
- package/src/commands/migration-graph.ts +163 -90
- package/src/commands/migration-list.ts +55 -25
- package/src/commands/migration-log.ts +49 -98
- package/src/commands/migration-show.ts +10 -38
- package/src/commands/migration-status-overlay.ts +61 -0
- package/src/commands/migration-status.ts +440 -1056
- package/src/commands/telemetry/index.ts +107 -0
- package/src/commands/telemetry/status.ts +67 -0
- package/src/control-api/client.ts +20 -9
- package/src/control-api/operations/contract-emit.ts +2 -2
- package/src/control-api/operations/db-init.ts +3 -3
- package/src/control-api/operations/{db-apply.ts → db-run.ts} +37 -10
- package/src/control-api/operations/db-update.ts +4 -4
- package/src/control-api/operations/{migration-apply.ts → migrate.ts} +32 -24
- package/src/control-api/operations/{apply.ts → run-migration.ts} +33 -27
- package/src/control-api/types.ts +46 -29
- package/src/utils/cli-errors.ts +47 -2
- package/src/utils/formatters/errors.ts +11 -0
- package/src/utils/formatters/migration-graph-lane-colors.ts +194 -0
- package/src/utils/formatters/migration-graph-layout.ts +51 -7
- package/src/utils/formatters/migration-graph-rows.ts +128 -15
- package/src/utils/formatters/migration-graph-space-render.ts +138 -0
- package/src/utils/formatters/migration-graph-tree-render.ts +405 -77
- package/src/utils/formatters/migration-list-data-column.ts +4 -91
- package/src/utils/formatters/migration-list-graph-topology.ts +68 -90
- package/src/utils/formatters/migration-list-render.ts +122 -70
- package/src/utils/formatters/migration-list-styler.ts +48 -5
- package/src/utils/formatters/migration-log-table.ts +200 -0
- package/src/utils/formatters/migrations.ts +25 -1
- package/src/utils/global-flags.ts +35 -0
- package/src/utils/legend.ts +38 -0
- package/src/utils/migration-path-target.ts +39 -0
- package/src/utils/telemetry.ts +68 -32
- package/dist/client-KgJorIvG.mjs.map +0 -1
- package/dist/command-helpers-Bbw1GbwL.mjs.map +0 -1
- package/dist/commands/migration-list.mjs.map +0 -1
- package/dist/commands/migration-log.mjs.map +0 -1
- package/dist/commands/migration-status.mjs.map +0 -1
- package/dist/extension-pack-inputs-IDvjRCi3.mjs +0 -62
- package/dist/extension-pack-inputs-IDvjRCi3.mjs.map +0 -1
- package/dist/graph-render-rFAqZujX.mjs +0 -1081
- package/dist/graph-render-rFAqZujX.mjs.map +0 -1
- package/dist/init-Cv9UzWL5.mjs.map +0 -1
- package/dist/migration-check-BiBJoYYW.mjs.map +0 -1
- package/dist/migration-graph-D7DVUElV.mjs +0 -1232
- package/dist/migration-graph-D7DVUElV.mjs.map +0 -1
- package/dist/migration-list-styler-BRwF4-gy.mjs +0 -399
- package/dist/migration-list-styler-BRwF4-gy.mjs.map +0 -1
- package/dist/migration-types-D2FW63pr.d.mts +0 -15
- package/dist/migration-types-D2FW63pr.d.mts.map +0 -1
- package/dist/migrations-Cv2jxNNK.mjs +0 -228
- package/dist/migrations-Cv2jxNNK.mjs.map +0 -1
- package/dist/types-Dt_SfqFm.d.mts.map +0 -1
- package/src/utils/formatters/graph-migration-mapper.ts +0 -235
- package/src/utils/formatters/graph-render.ts +0 -1323
- package/src/utils/formatters/graph-types.ts +0 -120
|
@@ -71,7 +71,12 @@ function mapDbUpdateFailure(failure: DbUpdateFailure): CliStructuredError {
|
|
|
71
71
|
return errorRunnerFailed(failure.summary, {
|
|
72
72
|
why: failure.why ?? 'Migration runner failed',
|
|
73
73
|
fix,
|
|
74
|
-
|
|
74
|
+
meta: {
|
|
75
|
+
...failure.meta,
|
|
76
|
+
...(failure.warnings && failure.warnings.length > 0
|
|
77
|
+
? { plannerWarnings: failure.warnings }
|
|
78
|
+
: {}),
|
|
79
|
+
},
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
82
|
|
|
@@ -236,6 +241,7 @@ async function executeDbUpdateCommand(
|
|
|
236
241
|
: undefined,
|
|
237
242
|
),
|
|
238
243
|
...ifDefined('perSpace', result.value.perSpace),
|
|
244
|
+
...ifDefined('warnings', result.value.warnings),
|
|
239
245
|
advancedRef: refAdvancementFields.advancedRef,
|
|
240
246
|
plannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,
|
|
241
247
|
summary: result.value.summary,
|
|
@@ -4,8 +4,11 @@ import {
|
|
|
4
4
|
setCommandDescriptions,
|
|
5
5
|
setCommandExamples,
|
|
6
6
|
} from '../../utils/command-helpers';
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
type CommonCommandOptions,
|
|
9
|
+
deriveCanPrompt,
|
|
10
|
+
parseGlobalFlagsOrExit,
|
|
11
|
+
} from '../../utils/global-flags';
|
|
9
12
|
import {
|
|
10
13
|
INIT_EXIT_EMIT_FAILED,
|
|
11
14
|
INIT_EXIT_INSTALL_FAILED,
|
|
@@ -93,7 +96,7 @@ export function createInitCommand(): Command {
|
|
|
93
96
|
'--no-skill',
|
|
94
97
|
'Skip Prisma Next skills install (air-gapped CI, restricted registries, etc.)',
|
|
95
98
|
)
|
|
96
|
-
.action(async (options: InitCommandOptions
|
|
99
|
+
.action(async (options: InitCommandOptions) => {
|
|
97
100
|
const { runInit } = await import('./init');
|
|
98
101
|
const flags = parseGlobalFlagsOrExit(options);
|
|
99
102
|
const canPrompt = deriveCanPrompt({
|
|
@@ -105,39 +108,7 @@ export function createInitCommand(): Command {
|
|
|
105
108
|
options,
|
|
106
109
|
flags,
|
|
107
110
|
canPrompt,
|
|
108
|
-
afterFirstTelemetryConsent: (inputs) => {
|
|
109
|
-
fireTelemetryAfterInitConsent(actionCommand, { databaseTarget: inputs.target });
|
|
110
|
-
},
|
|
111
111
|
});
|
|
112
112
|
process.exit(exitCode);
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Bridges the action handler's two TTY checks (stdout via `flags`, stdin
|
|
118
|
-
* via `process.stdin.isTTY`) into the `canPrompt` boolean `runInit`
|
|
119
|
-
* consumes.
|
|
120
|
-
*
|
|
121
|
-
* Per the [Style Guide § Interactivity](../../../../../../../docs/CLI%20Style%20Guide.md#interactivity):
|
|
122
|
-
*
|
|
123
|
-
* - `flags.interactive` governs *decoration* (TerminalUI, intro/outro,
|
|
124
|
-
* spinners) and is derived from stdout-TTY by `parseGlobalFlags`,
|
|
125
|
-
* honouring `--interactive` / `--no-interactive`.
|
|
126
|
-
* - Prompting additionally requires a stdin TTY — closing stdin is a
|
|
127
|
-
* common signal in CI / agent environments even when stdout stays
|
|
128
|
-
* attached.
|
|
129
|
-
* - `--interactive` is the explicit override: when the user passes it,
|
|
130
|
-
* we honour it (e.g. testing flows where stdin is stubbed).
|
|
131
|
-
*
|
|
132
|
-
* Exported so callers and tests can derive the same value without
|
|
133
|
-
* touching `process` globals.
|
|
134
|
-
*/
|
|
135
|
-
export function deriveCanPrompt(opts: {
|
|
136
|
-
readonly flagsInteractive: boolean | undefined;
|
|
137
|
-
readonly optionInteractive: boolean | undefined;
|
|
138
|
-
readonly stdinIsTTY: boolean;
|
|
139
|
-
}): boolean {
|
|
140
|
-
if (opts.optionInteractive === true) return true;
|
|
141
|
-
if (opts.flagsInteractive === false) return false;
|
|
142
|
-
return opts.stdinIsTTY;
|
|
143
|
-
}
|
|
@@ -113,11 +113,6 @@ export async function runInit(
|
|
|
113
113
|
* mode) — see [Style Guide § Interactivity](../../../../../../../docs/CLI%20Style%20Guide.md#interactivity).
|
|
114
114
|
*/
|
|
115
115
|
readonly canPrompt: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Called once after the first affirmative telemetry consent is persisted.
|
|
118
|
-
* Failures are swallowed by the caller; init success must not depend on telemetry.
|
|
119
|
-
*/
|
|
120
|
-
readonly afterFirstTelemetryConsent?: (inputs: ResolvedInitInputs) => void | Promise<void>;
|
|
121
116
|
/**
|
|
122
117
|
* FR8.3 — test-only seam for the optional database version probe.
|
|
123
118
|
* Production callers omit this; tests inject stub `probePostgres` /
|
|
@@ -129,7 +124,7 @@ export async function runInit(
|
|
|
129
124
|
readonly probeOverrides?: ProbeOverrides;
|
|
130
125
|
},
|
|
131
126
|
): Promise<number> {
|
|
132
|
-
const { options, flags, canPrompt, probeOverrides
|
|
127
|
+
const { options, flags, canPrompt, probeOverrides } = runOptions;
|
|
133
128
|
const ui = createTerminalUI(flags);
|
|
134
129
|
const warnings: string[] = [];
|
|
135
130
|
const filesWritten: string[] = [];
|
|
@@ -149,14 +144,6 @@ export async function runInit(
|
|
|
149
144
|
throw error;
|
|
150
145
|
}
|
|
151
146
|
|
|
152
|
-
if (inputs.enableTelemetry === true && afterFirstTelemetryConsent !== undefined) {
|
|
153
|
-
try {
|
|
154
|
-
await afterFirstTelemetryConsent(inputs);
|
|
155
|
-
} catch {
|
|
156
|
-
// telemetry is best-effort and must never affect init
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
147
|
const pm = await detectPackageManager(baseDir);
|
|
161
148
|
const pkgRun = formatRunCommand(pm, 'prisma-next', '').trimEnd();
|
|
162
149
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import * as clack from '@clack/prompts';
|
|
3
|
-
import { readUserConfig, resolveGating, writeUserConfig } from '@prisma-next/cli-telemetry';
|
|
4
3
|
import { extname, join, normalize } from 'pathe';
|
|
5
4
|
import type { GlobalFlags } from '../../utils/global-flags';
|
|
6
|
-
import { isCI } from '../../utils/is-ci';
|
|
7
5
|
import {
|
|
8
6
|
errorInitAuthoringSchemaPathMismatch,
|
|
9
7
|
errorInitInvalidFlagValue,
|
|
@@ -71,18 +69,6 @@ export interface ResolvedInitInputs {
|
|
|
71
69
|
* is added separately via the install step.
|
|
72
70
|
*/
|
|
73
71
|
readonly removePreviousFacade: string | null;
|
|
74
|
-
/**
|
|
75
|
-
* Telemetry consent answer recorded during this `init` run, or `null`
|
|
76
|
-
* when no prompt was shown. The prompt fires only on the
|
|
77
|
-
* canPrompt + !autoAcceptPrompts + no env/CI opt-out +
|
|
78
|
-
* `enableTelemetry === undefined` intersection; outside that window
|
|
79
|
-
* the field is `null` and the stored preference (if any) stays
|
|
80
|
-
* unchanged. The answer has already been persisted to
|
|
81
|
-
* `$XDG_CONFIG_HOME/prisma-next/config.json` by
|
|
82
|
-
* the time `runInit` sees this value — it's surfaced here purely so
|
|
83
|
-
* the post-init summary can mention what the user chose.
|
|
84
|
-
*/
|
|
85
|
-
readonly enableTelemetry: boolean | null;
|
|
86
72
|
/**
|
|
87
73
|
* Whether to run `npx skills add prisma/prisma-next#v<version>` at the
|
|
88
74
|
* project level after install + emit. True by default; `--no-skill`
|
|
@@ -106,12 +92,6 @@ const AUTHORING_VALUES: ReadonlyMap<string, AuthoringId> = new Map([
|
|
|
106
92
|
['ts', 'typescript'],
|
|
107
93
|
]);
|
|
108
94
|
|
|
109
|
-
export const TELEMETRY_CONSENT_MESSAGE = [
|
|
110
|
-
'Help us prioritize features by sharing anonymous CLI usage data?',
|
|
111
|
-
'The telemetry implementation is open source and fully transparent.',
|
|
112
|
-
'(packages/1-framework/3-tooling/cli-telemetry and apps/telemetry-backend).',
|
|
113
|
-
].join(' ');
|
|
114
|
-
|
|
115
95
|
/**
|
|
116
96
|
* Resolves every required input for `runInit`. In interactive mode, missing
|
|
117
97
|
* inputs are prompted via clack; in non-interactive mode, missing required
|
|
@@ -197,11 +177,6 @@ export async function resolveInitInputs(ctx: {
|
|
|
197
177
|
autoAcceptPrompts,
|
|
198
178
|
});
|
|
199
179
|
|
|
200
|
-
const enableTelemetry = await resolveTelemetryConsent({
|
|
201
|
-
canPrompt,
|
|
202
|
-
autoAcceptPrompts,
|
|
203
|
-
});
|
|
204
|
-
|
|
205
180
|
// Skill-install gating. `--no-skill` (commander parses
|
|
206
181
|
// `options.skill === false`) is the only escape hatch; otherwise
|
|
207
182
|
// project-level install is unconditional. The skill is always
|
|
@@ -219,60 +194,10 @@ export async function resolveInitInputs(ctx: {
|
|
|
219
194
|
strictProbe: Boolean(options.strictProbe),
|
|
220
195
|
reinit,
|
|
221
196
|
removePreviousFacade,
|
|
222
|
-
enableTelemetry,
|
|
223
197
|
installProjectSkill,
|
|
224
198
|
};
|
|
225
199
|
}
|
|
226
200
|
|
|
227
|
-
/**
|
|
228
|
-
* The interactive telemetry consent prompt. Shown as the last
|
|
229
|
-
* question of the `init` sequence iff:
|
|
230
|
-
* 1. `canPrompt === true` (interactive stdin / stdout combo),
|
|
231
|
-
* 2. `autoAcceptPrompts === false` (the user did not pass `--yes`),
|
|
232
|
-
* 3. neither telemetry env opt-out is active,
|
|
233
|
-
* 4. the process is not running in CI,
|
|
234
|
-
* 5. the stored `enableTelemetry` value is `undefined` (the user
|
|
235
|
-
* has never been asked, or skipped the prompt previously).
|
|
236
|
-
*
|
|
237
|
-
* Outside that intersection the function returns `null` and leaves the
|
|
238
|
-
* stored preference untouched. Inside it, the user's answer is
|
|
239
|
-
* persisted via `writeUserConfig({ enableTelemetry })` before this
|
|
240
|
-
* function returns; on an affirmative answer `writeUserConfig`
|
|
241
|
-
* generates and stores the v4 `installationId` in the same write.
|
|
242
|
-
*
|
|
243
|
-
* The wording names CLI usage data and points to the open-source
|
|
244
|
-
* client/backend paths. Default value is `true` to match precedent
|
|
245
|
-
* and to make the consent answer a single keystroke once it's been
|
|
246
|
-
* disclosed.
|
|
247
|
-
*/
|
|
248
|
-
async function resolveTelemetryConsent(opts: {
|
|
249
|
-
readonly canPrompt: boolean;
|
|
250
|
-
readonly autoAcceptPrompts: boolean;
|
|
251
|
-
}): Promise<boolean | null> {
|
|
252
|
-
if (!opts.canPrompt || opts.autoAcceptPrompts || isCI()) {
|
|
253
|
-
return null;
|
|
254
|
-
}
|
|
255
|
-
const config = readUserConfig();
|
|
256
|
-
const gating = resolveGating({ env: process.env, config });
|
|
257
|
-
if (!gating.enabled && gating.reason === 'env-override') {
|
|
258
|
-
return null;
|
|
259
|
-
}
|
|
260
|
-
const stored = config.enableTelemetry;
|
|
261
|
-
if (stored !== undefined) {
|
|
262
|
-
return null;
|
|
263
|
-
}
|
|
264
|
-
const result = await clack.confirm({
|
|
265
|
-
message: TELEMETRY_CONSENT_MESSAGE,
|
|
266
|
-
initialValue: true,
|
|
267
|
-
output: process.stderr,
|
|
268
|
-
});
|
|
269
|
-
if (clack.isCancel(result)) {
|
|
270
|
-
throw errorInitUserAborted();
|
|
271
|
-
}
|
|
272
|
-
writeUserConfig({ enableTelemetry: Boolean(result) });
|
|
273
|
-
return Boolean(result);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
201
|
async function resolveWriteEnv(opts: {
|
|
277
202
|
readonly flag: boolean | undefined;
|
|
278
203
|
readonly canPrompt: boolean;
|
package/src/commands/migrate.ts
CHANGED
|
@@ -11,8 +11,8 @@ import { Command } from 'commander';
|
|
|
11
11
|
import { loadConfig } from '../config-loader';
|
|
12
12
|
import { createControlClient } from '../control-api/client';
|
|
13
13
|
import type {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
MigrateFailure,
|
|
15
|
+
MigratePathDecision,
|
|
16
16
|
PerSpaceExecutionEntry,
|
|
17
17
|
} from '../control-api/types';
|
|
18
18
|
import {
|
|
@@ -76,14 +76,14 @@ export interface MigrateResult {
|
|
|
76
76
|
}[];
|
|
77
77
|
readonly summary: string;
|
|
78
78
|
readonly perSpace: readonly PerSpaceExecutionEntry[];
|
|
79
|
-
readonly pathDecision?:
|
|
79
|
+
readonly pathDecision?: MigratePathDecision;
|
|
80
80
|
readonly timings: {
|
|
81
81
|
readonly total: number;
|
|
82
82
|
};
|
|
83
83
|
readonly advancedRef?: { readonly name: string; readonly hash: string } | null;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
function mapApplyFailure(failure:
|
|
86
|
+
function mapApplyFailure(failure: MigrateFailure): CliStructuredErrorType {
|
|
87
87
|
if (failure.code === 'MIGRATION_PATH_NOT_FOUND') {
|
|
88
88
|
return errorPathUnreachable(failure);
|
|
89
89
|
}
|
|
@@ -136,7 +136,7 @@ async function executeMigrateCommand(
|
|
|
136
136
|
|
|
137
137
|
// Construct the family instance up-front so the on-disk contract read
|
|
138
138
|
// crosses the serializer seam (`familyInstance.deserializeContract`) at
|
|
139
|
-
// the read site. The downstream `client.
|
|
139
|
+
// the read site. The downstream `client.migrate({ contract })`
|
|
140
140
|
// re-validates internally (no harm — validation is idempotent), but
|
|
141
141
|
// closing the gap at the read site is what makes the cast-pattern
|
|
142
142
|
// lint enforceable and matches the other CLI commands. See TML-2536.
|
|
@@ -312,7 +312,7 @@ async function executeMigrateCommand(
|
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
const applyResult = await client.
|
|
315
|
+
const applyResult = await client.migrate({
|
|
316
316
|
contract: applyContract,
|
|
317
317
|
migrationsDir,
|
|
318
318
|
...ifDefined('refHash', refEntry?.hash),
|