@contentful/experience-design-system-cli 2.12.1-dev-build-bae15c7.0 → 2.12.1-dev-build-0b7de73.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.12.1-dev-build-bae15c7.0",
3
+ "version": "2.12.1-dev-build-0b7de73.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -7,6 +7,7 @@ import { DEFAULT_CONFIGURED_HOST, toConfiguredHost } from '../host-utils.js';
7
7
  import { replayRun, modifyRun } from '../runs/replay-helpers.js';
8
8
  import { resolvePromptFlags } from './print-prompt.js';
9
9
  import { shouldShowRunPicker } from '../runs/run-picker-mount.js';
10
+ import { dispatchPickerSelection } from './picker-dispatch.js';
10
11
  export function registerImportCommand(program) {
11
12
  program
12
13
  .command('import')
@@ -220,15 +221,20 @@ export function registerImportCommand(program) {
220
221
  isTTY: !!process.stdin.isTTY,
221
222
  });
222
223
  let pickerSelection = null;
224
+ // Ink `unmount` handle captured after `render(...)` below so the
225
+ // picker callback can tear down the wizard cleanly. Prior to this
226
+ // fix the callback did `setImmediate(() => process.exit(0))`, which
227
+ // killed the process before `dispatchPickerSelection` could run.
228
+ let unmountInk = null;
223
229
  const pickerProps = {};
224
230
  if (pickerDecision.shouldShow) {
225
231
  pickerProps.initialRuns = pickerDecision.runs;
226
232
  pickerProps.onRunPicked = (selection) => {
227
233
  pickerSelection = selection;
228
- setImmediate(() => process.exit(0));
234
+ unmountInk?.();
229
235
  };
230
236
  }
231
- const { waitUntilExit } = render(createElement(WizardApp, {
237
+ const { waitUntilExit, unmount } = render(createElement(WizardApp, {
232
238
  initialSpaceId: creds.spaceId,
233
239
  initialEnvironmentId: creds.environmentId || 'master',
234
240
  initialCmaToken: creds.cmaToken,
@@ -250,43 +256,24 @@ export function registerImportCommand(program) {
250
256
  ...(opts.rawTokens ? { initialRawTokensPath: resolve(opts.rawTokens) } : {}),
251
257
  ...pickerProps,
252
258
  }));
253
- try {
254
- await waitUntilExit();
255
- }
256
- catch {
257
- /* Ink throws on process.exit; swallow so picker dispatch can run. */
258
- }
259
+ unmountInk = unmount;
260
+ await waitUntilExit();
259
261
  // ── Picker dispatch ─────────────────────────────────────────────
260
- // If the operator picked a run, route into the existing entry
261
- // points so credential resolution and mutex checks stay in one
262
- // place. The --modify path resolves the run record via
263
- // resolveRunTarget and threads its session IDs through
264
- // launchModifyWizard (see runs/replay-helpers.ts).
262
+ // If the operator picked a run, route into replayRun / modifyRun.
263
+ // dispatchPickerSelection lives in ./picker-dispatch.ts so this
264
+ // decision is testable without an Ink runtime.
265
265
  if (pickerSelection) {
266
- const sel = pickerSelection;
267
- if (sel.action === 'push' && sel.runId) {
268
- await replayRun({
269
- runIdOrPath: sel.runId,
270
- ...(opts.spaceId ? { spaceId: opts.spaceId } : {}),
271
- ...(opts.environmentId ? { environmentId: opts.environmentId } : {}),
272
- ...(opts.cmaToken ? { cmaToken: opts.cmaToken } : {}),
273
- ...(opts.host ? { host: opts.host } : {}),
274
- interactive: !!process.stdout.isTTY,
275
- ...(opts.force ? { force: true } : {}),
276
- });
277
- return;
278
- }
279
- if (sel.action === 'modify' && sel.runId) {
280
- await modifyRun({
281
- runIdOrPath: sel.runId,
282
- ...(opts.outDir ? { outDir: opts.outDir } : {}),
283
- ...(opts.overwrite ? { overwrite: true } : {}),
284
- ...(opts.saveAsNew ? { saveAsNew: true } : {}),
285
- ...(opts.force ? { force: true } : {}),
286
- });
287
- return;
288
- }
289
- // action === 'new' falls through — the wizard already advanced.
266
+ await dispatchPickerSelection(pickerSelection, {
267
+ ...(opts.spaceId ? { spaceId: opts.spaceId } : {}),
268
+ ...(opts.environmentId ? { environmentId: opts.environmentId } : {}),
269
+ ...(opts.cmaToken ? { cmaToken: opts.cmaToken } : {}),
270
+ ...(opts.host ? { host: opts.host } : {}),
271
+ interactive: !!process.stdout.isTTY,
272
+ ...(opts.outDir ? { outDir: opts.outDir } : {}),
273
+ ...(opts.overwrite ? { overwrite: true } : {}),
274
+ ...(opts.saveAsNew ? { saveAsNew: true } : {}),
275
+ ...(opts.force ? { force: true } : {}),
276
+ }, { replayRun, modifyRun });
290
277
  }
291
278
  return;
292
279
  }
@@ -0,0 +1,18 @@
1
+ import type { RunPickerSelection } from '../runs/run-picker.js';
2
+ import type { replayRun as replayRunFn, modifyRun as modifyRunFn } from '../runs/replay-helpers.js';
3
+ export type PickerDispatchOptions = {
4
+ spaceId?: string;
5
+ environmentId?: string;
6
+ cmaToken?: string;
7
+ host?: string;
8
+ interactive?: boolean;
9
+ outDir?: string;
10
+ overwrite?: boolean;
11
+ saveAsNew?: boolean;
12
+ force?: boolean;
13
+ };
14
+ export type PickerDispatchDeps = {
15
+ replayRun: typeof replayRunFn;
16
+ modifyRun: typeof modifyRunFn;
17
+ };
18
+ export declare function dispatchPickerSelection(selection: RunPickerSelection, opts: PickerDispatchOptions, deps: PickerDispatchDeps): Promise<void>;
@@ -0,0 +1,29 @@
1
+ // Route a resolved RunPickerSelection into replayRun / modifyRun. Extracted
2
+ // from command.ts so the dispatch decision is testable without an Ink runtime
3
+ // and so the picker callback in command.ts is a simple state-capture (no
4
+ // process.exit shenanigans that would kill the process before dispatch runs).
5
+ export async function dispatchPickerSelection(selection, opts, deps) {
6
+ if (selection.action === 'push' && selection.runId) {
7
+ await deps.replayRun({
8
+ runIdOrPath: selection.runId,
9
+ ...(opts.spaceId ? { spaceId: opts.spaceId } : {}),
10
+ ...(opts.environmentId ? { environmentId: opts.environmentId } : {}),
11
+ ...(opts.cmaToken ? { cmaToken: opts.cmaToken } : {}),
12
+ ...(opts.host ? { host: opts.host } : {}),
13
+ ...(opts.interactive !== undefined ? { interactive: opts.interactive } : {}),
14
+ ...(opts.force ? { force: true } : {}),
15
+ });
16
+ return;
17
+ }
18
+ if (selection.action === 'modify' && selection.runId) {
19
+ await deps.modifyRun({
20
+ runIdOrPath: selection.runId,
21
+ ...(opts.outDir ? { outDir: opts.outDir } : {}),
22
+ ...(opts.overwrite ? { overwrite: true } : {}),
23
+ ...(opts.saveAsNew ? { saveAsNew: true } : {}),
24
+ ...(opts.force ? { force: true } : {}),
25
+ });
26
+ return;
27
+ }
28
+ // action === 'new' → no-op; the wizard already advanced past the picker.
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.12.1-dev-build-bae15c7.0",
3
+ "version": "2.12.1-dev-build-0b7de73.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -37,7 +37,7 @@
37
37
  "svelte": "^5.56.4",
38
38
  "ts-morph": "^27.0.2",
39
39
  "typescript": "^5.9.3",
40
- "@contentful/experience-design-system-types": "2.12.1-dev-build-bae15c7.0"
40
+ "@contentful/experience-design-system-types": "2.12.1-dev-build-0b7de73.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@tsconfig/node24": "^24.0.3",