@contentful/experience-design-system-cli 2.36.2-dev-build-d983d04c.0 → 2.36.2-dev-build-8c3560a9.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/index.js CHANGED
@@ -297,6 +297,250 @@ var init_PageContainer = __esm({
297
297
  }
298
298
  });
299
299
 
300
+ // packages/experience-design-system-cli/src/tui/import/steps/01-welcome/logic.ts
301
+ function shouldQuit(value, input, key) {
302
+ if (key.escape) return true;
303
+ return value === "" && input === "q" && !key.ctrl && !key.meta;
304
+ }
305
+ function toProjectPath(value) {
306
+ const projectPath = value.trim();
307
+ return projectPath === "" ? null : projectPath;
308
+ }
309
+ var init_logic = __esm({
310
+ "packages/experience-design-system-cli/src/tui/import/steps/01-welcome/logic.ts"() {
311
+ "use strict";
312
+ }
313
+ });
314
+
315
+ // packages/experience-design-system-cli/src/tui/import/steps/01-welcome/controls.ts
316
+ import { useInput as useInput3 } from "ink";
317
+ function useWelcomeControls(projectPath, onQuit) {
318
+ useInput3((input, key) => {
319
+ if (shouldQuit(projectPath, input, key)) onQuit();
320
+ });
321
+ }
322
+ var WELCOME_CONTROLS;
323
+ var init_controls = __esm({
324
+ "packages/experience-design-system-cli/src/tui/import/steps/01-welcome/controls.ts"() {
325
+ "use strict";
326
+ init_logic();
327
+ WELCOME_CONTROLS = [
328
+ { keys: "Enter", label: "Continue" },
329
+ { keys: "Esc/q", label: "Back to menu" }
330
+ ];
331
+ }
332
+ });
333
+
334
+ // packages/experience-design-system-cli/src/tui/import/steps/01-welcome/screen.tsx
335
+ import { useState as useState3 } from "react";
336
+ import { Box as Box3, Text as Text3 } from "ink";
337
+ import TextInput from "ink-text-input";
338
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
339
+ function WelcomeScreen({ onContinue, onQuit, initialPath = "" }) {
340
+ const [projectPath, setProjectPath] = useState3(initialPath);
341
+ useWelcomeControls(projectPath, onQuit);
342
+ const submit = (value) => {
343
+ const path = toProjectPath(value);
344
+ if (path) onContinue(path);
345
+ };
346
+ return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", gap: 1, paddingX: 2, paddingY: 1, children: [
347
+ /* @__PURE__ */ jsx3(Text3, { bold: true, color: PALETTE.success, children: "\u{1F44B} Hey! Let's import your design system into Contentful." }),
348
+ /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "I'll walk you through 5 steps to get your components into Contentful ExO." }),
349
+ /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", marginTop: 1, children: [
350
+ /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: RULE }),
351
+ OVERVIEW.map((item) => /* @__PURE__ */ jsxs3(Box3, { gap: 1, children: [
352
+ /* @__PURE__ */ jsx3(Text3, { bold: true, children: item.label }),
353
+ /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: item.description })
354
+ ] }, item.label)),
355
+ /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: RULE })
356
+ ] }),
357
+ /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", marginTop: 1, children: [
358
+ /* @__PURE__ */ jsx3(Text3, { children: "Where is your component library?" }),
359
+ /* @__PURE__ */ jsxs3(Box3, { gap: 1, children: [
360
+ /* @__PURE__ */ jsx3(Text3, { color: PALETTE.accent, children: "?" }),
361
+ /* @__PURE__ */ jsx3(Text3, { children: "Project path:" }),
362
+ /* @__PURE__ */ jsx3(TextInput, { value: projectPath, onChange: setProjectPath, onSubmit: submit })
363
+ ] })
364
+ ] }),
365
+ /* @__PURE__ */ jsx3(Box3, { marginTop: 1, gap: 3, children: WELCOME_CONTROLS.map((control) => /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
366
+ "[",
367
+ control.keys,
368
+ "] ",
369
+ control.label
370
+ ] }, control.keys)) })
371
+ ] });
372
+ }
373
+ var RULE, OVERVIEW;
374
+ var init_screen = __esm({
375
+ "packages/experience-design-system-cli/src/tui/import/steps/01-welcome/screen.tsx"() {
376
+ "use strict";
377
+ init_home_theme();
378
+ init_controls();
379
+ init_logic();
380
+ RULE = "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
381
+ OVERVIEW = [
382
+ { label: "Step 1", description: "Extract components from your codebase" },
383
+ { label: "Step 2", description: "Review what was extracted" },
384
+ { label: "Step 3", description: "Generate CDF definitions with Claude" },
385
+ { label: "Step 4", description: "Review generated definitions" },
386
+ { label: "Step 5", description: "Push to Contentful" }
387
+ ];
388
+ }
389
+ });
390
+
391
+ // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/logic.ts
392
+ function isPlainKeyOnEmptyField(value, input, key, expected) {
393
+ return value === "" && input === expected && !key.ctrl && !key.meta;
394
+ }
395
+ function shouldGoBack(value, input, key) {
396
+ return key.escape || isPlainKeyOnEmptyField(value, input, key, "q");
397
+ }
398
+ function shouldSkip(value, input, key) {
399
+ return isPlainKeyOnEmptyField(value, input, key, "s");
400
+ }
401
+ function toTokenPath(value) {
402
+ const tokenPath = value.trim();
403
+ return tokenPath === "" ? null : tokenPath;
404
+ }
405
+ var init_logic2 = __esm({
406
+ "packages/experience-design-system-cli/src/tui/import/steps/02-token-input/logic.ts"() {
407
+ "use strict";
408
+ }
409
+ });
410
+
411
+ // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/controls.ts
412
+ import { useInput as useInput4 } from "ink";
413
+ function useTokenInputControls(tokenPath, onSkip, onBack) {
414
+ useInput4((input, key) => {
415
+ if (shouldGoBack(tokenPath, input, key)) onBack();
416
+ else if (shouldSkip(tokenPath, input, key)) onSkip();
417
+ });
418
+ }
419
+ var TOKEN_INPUT_CONTROLS;
420
+ var init_controls2 = __esm({
421
+ "packages/experience-design-system-cli/src/tui/import/steps/02-token-input/controls.ts"() {
422
+ "use strict";
423
+ init_logic2();
424
+ TOKEN_INPUT_CONTROLS = [
425
+ { keys: "Enter", label: "Continue (skips if empty)" },
426
+ { keys: "s", label: "Skip" },
427
+ { keys: "Esc/q", label: "Back" }
428
+ ];
429
+ }
430
+ });
431
+
432
+ // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/validate-path.ts
433
+ import { statSync } from "node:fs";
434
+ import { homedir } from "node:os";
435
+ import { resolve } from "node:path";
436
+ function stripQuotes(value) {
437
+ const quoted = value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'");
438
+ return value.length >= 2 && quoted ? value.slice(1, -1) : value;
439
+ }
440
+ function expandHome(value) {
441
+ return value === "~" || value.startsWith("~/") || value.startsWith("~\\") ? homedir() + value.slice(1) : value;
442
+ }
443
+ function validateTokenPath(rawPath) {
444
+ const path = resolve(expandHome(stripQuotes(rawPath.trim())));
445
+ let stats;
446
+ try {
447
+ stats = statSync(path);
448
+ } catch {
449
+ return { ok: false, error: `Path not found: ${path}`, resolvedPath: path };
450
+ }
451
+ if (stats.isDirectory()) {
452
+ return {
453
+ ok: false,
454
+ error: "That's a directory \u2014 provide a path to a token file (e.g. tokens.json), not a folder.",
455
+ resolvedPath: path
456
+ };
457
+ }
458
+ if (!stats.isFile()) {
459
+ return { ok: false, error: `Not a regular file: ${path}`, resolvedPath: path };
460
+ }
461
+ return { ok: true, path };
462
+ }
463
+ var init_validate_path = __esm({
464
+ "packages/experience-design-system-cli/src/tui/import/steps/02-token-input/validate-path.ts"() {
465
+ "use strict";
466
+ }
467
+ });
468
+
469
+ // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/screen.tsx
470
+ import { useState as useState4 } from "react";
471
+ import { Box as Box4, Text as Text4 } from "ink";
472
+ import TextInput2 from "ink-text-input";
473
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
474
+ function TokenInputScreen({
475
+ onConfirm,
476
+ onSkip,
477
+ onBack,
478
+ initialPath = ""
479
+ }) {
480
+ const [tokenPath, setTokenPath] = useState4(initialPath);
481
+ const [failure, setFailure] = useState4(null);
482
+ useTokenInputControls(tokenPath, onSkip, onBack);
483
+ const change = (value) => {
484
+ setTokenPath(value);
485
+ setFailure(null);
486
+ };
487
+ const submit = (value) => {
488
+ const rawPath = toTokenPath(value);
489
+ if (!rawPath) {
490
+ onSkip();
491
+ return;
492
+ }
493
+ const check = validateTokenPath(rawPath);
494
+ if (check.ok) onConfirm(check.path);
495
+ else setFailure({ error: check.error, resolvedPath: check.resolvedPath });
496
+ };
497
+ return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", gap: 1, paddingX: 2, paddingY: 1, children: [
498
+ /* @__PURE__ */ jsx4(Text4, { bold: true, children: "Design tokens" }),
499
+ /* @__PURE__ */ jsx4(Text4, { dimColor: true, children: "Point me to your raw token file (e.g. ~/design-tokens/tokens.json). You can use ~, relative, or absolute paths. Claude will map it to DTCG format." }),
500
+ /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", marginTop: 1, children: [
501
+ /* @__PURE__ */ jsxs4(Box4, { gap: 1, children: [
502
+ /* @__PURE__ */ jsx4(Text4, { color: PALETTE.accent, children: "?" }),
503
+ /* @__PURE__ */ jsx4(Text4, { children: "Token path:" }),
504
+ /* @__PURE__ */ jsx4(TextInput2, { value: tokenPath, onChange: change, onSubmit: submit })
505
+ ] }),
506
+ failure && /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
507
+ /* @__PURE__ */ jsxs4(Text4, { color: PALETTE.error, children: [
508
+ "\u2717 ",
509
+ failure.error
510
+ ] }),
511
+ /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
512
+ " Resolved to: ",
513
+ failure.resolvedPath
514
+ ] })
515
+ ] })
516
+ ] }),
517
+ /* @__PURE__ */ jsx4(Box4, { marginTop: 1, gap: 3, children: TOKEN_INPUT_CONTROLS.map((control) => /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
518
+ "[",
519
+ control.keys,
520
+ "] ",
521
+ control.label
522
+ ] }, control.keys)) })
523
+ ] });
524
+ }
525
+ var init_screen2 = __esm({
526
+ "packages/experience-design-system-cli/src/tui/import/steps/02-token-input/screen.tsx"() {
527
+ "use strict";
528
+ init_home_theme();
529
+ init_controls2();
530
+ init_logic2();
531
+ init_validate_path();
532
+ }
533
+ });
534
+
535
+ // packages/experience-design-system-cli/src/tui/import/steps/index.ts
536
+ var init_steps = __esm({
537
+ "packages/experience-design-system-cli/src/tui/import/steps/index.ts"() {
538
+ "use strict";
539
+ init_screen();
540
+ init_screen2();
541
+ }
542
+ });
543
+
300
544
  // packages/experience-design-system-cli/src/tui/import/spawn-v1-import.ts
301
545
  import { spawn as spawn2 } from "node:child_process";
302
546
  function buildArgs(options) {
@@ -304,6 +548,9 @@ function buildArgs(options) {
304
548
  if (options.project) {
305
549
  args.push("--project", options.project);
306
550
  }
551
+ if (options.tokens) {
552
+ args.push("--tokens", options.tokens);
553
+ }
307
554
  return args;
308
555
  }
309
556
  async function spawnV1Import(options = {}) {
@@ -333,7 +580,7 @@ function getTerminalHandle() {
333
580
  return process.stdin._handle;
334
581
  }
335
582
  async function stopReadingTerminal() {
336
- await new Promise((resolve) => setImmediate(resolve));
583
+ await new Promise((resolve2) => setImmediate(resolve2));
337
584
  const handle = getTerminalHandle();
338
585
  if (!handle?.readStop) return;
339
586
  handle.reading = false;
@@ -351,49 +598,311 @@ var init_terminal_input = __esm({
351
598
  }
352
599
  });
353
600
 
601
+ // packages/experience-design-system-types/dist/src/config/index.js
602
+ import { randomBytes } from "node:crypto";
603
+ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
604
+ import { homedir as homedir2 } from "node:os";
605
+ import { dirname as dirname2, join as join4 } from "node:path";
606
+ function configRoot() {
607
+ return process.env["EDS_HOME"] || join4(homedir2(), ".contentful", "experience-design-system-cli");
608
+ }
609
+ async function readSettings() {
610
+ try {
611
+ return JSON.parse(await readFile(configFilePath(), "utf8"));
612
+ } catch {
613
+ return {};
614
+ }
615
+ }
616
+ async function writeSettings(settings) {
617
+ const path = configFilePath();
618
+ await mkdir(dirname2(path), { recursive: true });
619
+ const tmp = `${path}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
620
+ await writeFile(tmp, `${JSON.stringify(settings, null, 2)}
621
+ `, { mode: 384 });
622
+ await rename(tmp, path);
623
+ }
624
+ async function updateSettings(patch) {
625
+ await writeSettings({ ...await readSettings(), ...patch });
626
+ }
627
+ var configFilePath, runsFilePath, debugSessionsDir, oldConfigDir;
628
+ var init_config = __esm({
629
+ "packages/experience-design-system-types/dist/src/config/index.js"() {
630
+ "use strict";
631
+ configFilePath = () => join4(configRoot(), "config.json");
632
+ runsFilePath = () => join4(configRoot(), "state", "runs.json");
633
+ debugSessionsDir = () => join4(configRoot(), "debug", "sessions");
634
+ oldConfigDir = () => join4(homedir2(), ".config", "experiences");
635
+ }
636
+ });
637
+
638
+ // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
639
+ async function readDebugModeSetting() {
640
+ const { debugMode } = await readSettings();
641
+ return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
642
+ }
643
+ async function writeDebugModeSetting(setting) {
644
+ await updateSettings({ debugMode: setting });
645
+ }
646
+ var DEFAULT_DEBUG_MODE_SETTING;
647
+ var init_debug_mode_store = __esm({
648
+ "packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
649
+ "use strict";
650
+ init_config();
651
+ DEFAULT_DEBUG_MODE_SETTING = {
652
+ enabled: true
653
+ };
654
+ }
655
+ });
656
+
657
+ // packages/experience-design-system-cli/src/tui/debug-store.ts
658
+ import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
659
+ import { existsSync as existsSync3, readdirSync } from "node:fs";
660
+ import { join as join5 } from "node:path";
661
+ function generateRunId() {
662
+ const now = /* @__PURE__ */ new Date();
663
+ const pad = (n) => String(n).padStart(2, "0");
664
+ return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
665
+ }
666
+ function datePrefix(now = /* @__PURE__ */ new Date()) {
667
+ const pad = (n) => String(n).padStart(2, "0");
668
+ return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
669
+ }
670
+ function slugify(value) {
671
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
672
+ }
673
+ function generateSessionId() {
674
+ const today = datePrefix();
675
+ const root = debugSessionsDir();
676
+ const existing = existsSync3(root) ? readdirSync(root) : [];
677
+ const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
678
+ const maxSeq = existing.reduce((max, entry) => {
679
+ const match = seqPattern.exec(entry);
680
+ return match ? Math.max(max, Number(match[1])) : max;
681
+ }, 0);
682
+ return `${today}-session-${maxSeq + 1}`;
683
+ }
684
+ function sessionDebugDir() {
685
+ return join5(debugSessionsDir(), SESSION_ID);
686
+ }
687
+ function currentDebugSessionDir() {
688
+ return sessionDebugDir();
689
+ }
690
+ async function isDebugModeEnabled() {
691
+ try {
692
+ return (await readDebugModeSetting()).enabled;
693
+ } catch {
694
+ return true;
695
+ }
696
+ }
697
+ function redact(value) {
698
+ const clone = { ...value };
699
+ if ("cma_token" in clone) {
700
+ const raw = clone.cma_token;
701
+ clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
702
+ }
703
+ return clone;
704
+ }
705
+ function startDebugRun({
706
+ flow,
707
+ step,
708
+ menuOption,
709
+ inputs
710
+ }) {
711
+ const runId = generateRunId();
712
+ const startedAt = Date.now();
713
+ const redactedInputs = redact(inputs);
714
+ isDebugModeEnabled().then((enabled) => {
715
+ if (!enabled) return;
716
+ pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
717
+ });
718
+ }
719
+ async function finishDebugRun({
720
+ outputs,
721
+ status,
722
+ exitMethod
723
+ }) {
724
+ const run = pendingRun;
725
+ if (!run) return;
726
+ pendingRun = void 0;
727
+ const durationMs = Date.now() - run.startedAt;
728
+ const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
729
+ const flowSegments = run.flow.split("/");
730
+ const dir = join5(sessionDebugDir(), ...flowSegments);
731
+ await mkdir2(dir, { recursive: true });
732
+ const filename = nextAttemptFilename(dir, run.menuOption);
733
+ await writeFile2(join5(dir, filename), content, { mode: 384 });
734
+ }
735
+ function nextAttemptFilename(dir, menuOption) {
736
+ const today = datePrefix();
737
+ const optionSlug = slugify(menuOption);
738
+ const existing = existsSync3(dir) ? readdirSync(dir) : [];
739
+ const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
740
+ const maxAttempt = existing.reduce((max, entry) => {
741
+ const match = attemptPattern.exec(entry);
742
+ return match ? Math.max(max, Number(match[1])) : max;
743
+ }, 0);
744
+ return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
745
+ }
746
+ function renderMarkdown(run, finish) {
747
+ const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
748
+ const stepLabel = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
749
+ const flowSlug = run.flow.split("/").join("-");
750
+ return `# Debug Log
751
+
752
+ - Run ID: ${run.runId}
753
+ - Flow: ${flowSlug}
754
+ - Step: ${stepLabel}
755
+ - Menu option: ${run.menuOption}
756
+ - Date: ${(/* @__PURE__ */ new Date()).toISOString()}
757
+ - CLI version: ${readPackageVersion()}
758
+ - Platform: ${process.platform} / Node ${process.version}
759
+ - Duration on screen: ${finish.durationMs}ms
760
+ - Status: ${finish.status}
761
+ - Exit method: ${finish.exitMethod}
762
+
763
+ ## Inputs
764
+ \`\`\`json
765
+ ${JSON.stringify(run.inputs, null, 2)}
766
+ \`\`\`
767
+
768
+ ## Outputs
769
+ \`\`\`json
770
+ ${JSON.stringify(finish.outputs, null, 2)}
771
+ \`\`\`
772
+ `;
773
+ }
774
+ function handleCrash() {
775
+ return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
776
+ }
777
+ var pendingRun, SESSION_ID;
778
+ var init_debug_store = __esm({
779
+ "packages/experience-design-system-cli/src/tui/debug-store.ts"() {
780
+ "use strict";
781
+ init_config();
782
+ init_version();
783
+ init_debug_mode_store();
784
+ SESSION_ID = generateSessionId();
785
+ void isDebugModeEnabled().then((enabled) => {
786
+ if (!enabled) return void 0;
787
+ return mkdir2(sessionDebugDir(), { recursive: true });
788
+ });
789
+ process.once("uncaughtException", (err) => {
790
+ void handleCrash().finally(() => {
791
+ throw err;
792
+ });
793
+ });
794
+ process.once("unhandledRejection", (reason) => {
795
+ void handleCrash().finally(() => {
796
+ throw reason;
797
+ });
798
+ });
799
+ process.once("SIGINT", () => {
800
+ void handleCrash().finally(() => {
801
+ process.exit(130);
802
+ });
803
+ });
804
+ }
805
+ });
806
+
807
+ // packages/experience-design-system-cli/src/tui/help/help-info.ts
808
+ async function readHelpInfo() {
809
+ const debugMode = await readDebugModeSetting();
810
+ return {
811
+ storage: [
812
+ { label: "Config folder", value: configRoot() },
813
+ { label: "Settings file", value: configFilePath() },
814
+ { label: "Debug logs", value: debugSessionsDir() },
815
+ { label: "Move it with", value: process.env["EDS_HOME"] ? "EDS_HOME (set)" : "EDS_HOME (not set)" }
816
+ ],
817
+ troubleshooting: [
818
+ { label: "CLI version", value: readPackageVersion() },
819
+ { label: "Node", value: process.version },
820
+ { label: "Platform", value: `${process.platform} ${process.arch}` },
821
+ { label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
822
+ {
823
+ label: "This session",
824
+ value: debugMode.enabled ? currentDebugSessionDir() : "no logs written while Debug Mode is off"
825
+ }
826
+ ]
827
+ };
828
+ }
829
+ var init_help_info = __esm({
830
+ "packages/experience-design-system-cli/src/tui/help/help-info.ts"() {
831
+ "use strict";
832
+ init_config();
833
+ init_debug_store();
834
+ init_debug_mode_store();
835
+ init_version();
836
+ }
837
+ });
838
+
354
839
  // packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
355
- import { Box as Box3, Text as Text3, useInput as useInput3 } from "ink";
356
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
840
+ import { useEffect as useEffect3, useState as useState5 } from "react";
841
+ import { Box as Box5, Text as Text5, useInput as useInput5 } from "ink";
842
+ import { Fragment, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
843
+ function Section({ title, rows }) {
844
+ return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
845
+ /* @__PURE__ */ jsx5(Text5, { bold: true, color: PALETTE.accent, children: title }),
846
+ rows.map((row) => /* @__PURE__ */ jsxs5(Box5, { gap: 1, children: [
847
+ /* @__PURE__ */ jsx5(Box5, { width: 14, flexShrink: 0, children: /* @__PURE__ */ jsx5(Text5, { dimColor: true, children: row.label }) }),
848
+ /* @__PURE__ */ jsx5(Text5, { children: row.value })
849
+ ] }, row.label))
850
+ ] });
851
+ }
357
852
  function HelpScreen({ onDone }) {
358
- useInput3((input, key) => {
853
+ const [info, setInfo] = useState5();
854
+ useEffect3(() => {
855
+ startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
856
+ void readHelpInfo().then(setInfo);
857
+ }, []);
858
+ const leave = (exitMethod) => {
859
+ void finishDebugRun({ outputs: {}, status: "success", exitMethod });
860
+ onDone();
861
+ };
862
+ useInput5((input, key) => {
359
863
  if (key.return) {
360
- onDone();
864
+ leave("saved");
361
865
  return;
362
866
  }
363
867
  if (key.escape || input === "q") {
364
- onDone();
868
+ leave("discarded");
365
869
  return;
366
870
  }
367
871
  });
368
- return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
369
- /* @__PURE__ */ jsx3(Text3, { bold: true, children: "Help" }),
370
- /* @__PURE__ */ jsx3(Text3, { children: " " }),
371
- /* @__PURE__ */ jsx3(Text3, { children: "This is a placeholder screen for v2 help content." }),
372
- /* @__PURE__ */ jsx3(Text3, { children: " " }),
373
- /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "[Enter] Complete [Esc/q] Exit \u2014 both return to Start" })
872
+ return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", paddingX: 2, paddingY: 1, gap: 1, children: [
873
+ /* @__PURE__ */ jsx5(Text5, { bold: true, children: "Help" }),
874
+ info ? /* @__PURE__ */ jsxs5(Fragment, { children: [
875
+ /* @__PURE__ */ jsx5(Section, { title: "Where things are stored", rows: info.storage }),
876
+ /* @__PURE__ */ jsx5(Section, { title: "Troubleshooting", rows: info.troubleshooting }),
877
+ /* @__PURE__ */ jsx5(Text5, { dimColor: true, children: "Hit a problem? Turn on Debug Mode in Settings, reproduce it, then share the session folder above. The CMA token is redacted from those logs." })
878
+ ] }) : /* @__PURE__ */ jsx5(Text5, { color: PALETTE.accent, children: "Loading..." }),
879
+ /* @__PURE__ */ jsx5(Text5, { dimColor: true, children: "[Enter] Complete [Esc/q] Exit \u2014 both return to Start" })
374
880
  ] });
375
881
  }
376
882
  var init_PageContainer2 = __esm({
377
883
  "packages/experience-design-system-cli/src/tui/help/PageContainer.tsx"() {
378
884
  "use strict";
885
+ init_home_theme();
886
+ init_debug_store();
887
+ init_help_info();
379
888
  }
380
889
  });
381
890
 
382
891
  // packages/experience-design-system-cli/src/tui/settings/PageContainer.tsx
383
- import { useState as useState3 } from "react";
384
- import { Box as Box4, Text as Text4, useInput as useInput4 } from "ink";
385
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
892
+ import { useState as useState6 } from "react";
893
+ import { Box as Box6, Text as Text6, useInput as useInput6 } from "ink";
894
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
386
895
  function SettingsScreen({
387
896
  onNavigate,
388
897
  onBack
389
898
  }) {
390
- const [focusIdx, setFocusIdx] = useState3(0);
899
+ const [focusIdx, setFocusIdx] = useState6(0);
391
900
  const items = [
392
901
  { label: "Configuration", screen: "settings-configuration" },
393
902
  { label: "Opt-in Analytics", screen: "settings-opt-in-analytics" },
394
903
  { label: "Debug Mode", screen: "settings-debug-mode" }
395
904
  ];
396
- useInput4((input, key) => {
905
+ useInput6((input, key) => {
397
906
  if (key.upArrow) {
398
907
  setFocusIdx((i) => (i - 1 + items.length) % items.length);
399
908
  return;
@@ -413,45 +922,31 @@ function SettingsScreen({
413
922
  onBack();
414
923
  }
415
924
  });
416
- return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
417
- /* @__PURE__ */ jsx4(Text4, { bold: true, children: "Settings" }),
418
- /* @__PURE__ */ jsx4(Text4, { children: " " }),
419
- items.map((item, i) => /* @__PURE__ */ jsxs4(Text4, { color: i === focusIdx ? "cyan" : void 0, children: [
925
+ return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
926
+ /* @__PURE__ */ jsx6(Text6, { bold: true, children: "Settings" }),
927
+ /* @__PURE__ */ jsx6(Text6, { children: " " }),
928
+ items.map((item, i) => /* @__PURE__ */ jsxs6(Text6, { color: i === focusIdx ? "cyan" : void 0, children: [
420
929
  i === focusIdx ? "> " : " ",
421
930
  item.label
422
931
  ] }, item.label)),
423
- /* @__PURE__ */ jsx4(Text4, { children: " " }),
424
- /* @__PURE__ */ jsx4(Text4, { dimColor: true, children: "[\u2191/\u2193] Navigate [Enter] Select [Esc/q] Back to Start" })
932
+ /* @__PURE__ */ jsx6(Text6, { children: " " }),
933
+ /* @__PURE__ */ jsx6(Text6, { dimColor: true, children: "[\u2191/\u2193] Navigate [Enter] Select [Esc/q] Back to Start" })
425
934
  ] });
426
935
  }
427
- var init_PageContainer3 = __esm({
428
- "packages/experience-design-system-cli/src/tui/settings/PageContainer.tsx"() {
429
- "use strict";
430
- }
431
- });
432
-
433
- // packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
434
- import { readFile, writeFile, mkdir } from "node:fs/promises";
435
- import { join as join4 } from "node:path";
436
- import { homedir } from "node:os";
437
- async function readV1Store() {
438
- try {
439
- const raw = await readFile(V1_STORE_PATH, "utf8");
440
- return JSON.parse(raw);
441
- } catch {
442
- return {};
443
- }
444
- }
445
- async function writeV1Store(data) {
446
- await mkdir(join4(homedir(), ".config", "experiences"), { recursive: true });
447
- await writeFile(V1_STORE_PATH, `${JSON.stringify(data, null, 2)}
448
- `, { mode: 384 });
449
- }
450
- var V1_STORE_PATH;
936
+ var init_PageContainer3 = __esm({
937
+ "packages/experience-design-system-cli/src/tui/settings/PageContainer.tsx"() {
938
+ "use strict";
939
+ }
940
+ });
941
+
942
+ // packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
943
+ var readV1Store, writeV1Store;
451
944
  var init_v1_store = __esm({
452
945
  "packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts"() {
453
946
  "use strict";
454
- V1_STORE_PATH = join4(homedir(), ".config", "experiences", "credentials.json");
947
+ init_config();
948
+ readV1Store = readSettings;
949
+ writeV1Store = writeSettings;
455
950
  }
456
951
  });
457
952
 
@@ -462,7 +957,9 @@ async function readCredentials() {
462
957
  spaceId: store.spaceId || "",
463
958
  environmentId: store.environmentId || "",
464
959
  cmaToken: store.cmaToken || "",
465
- host: store.host || ""
960
+ host: store.host || "",
961
+ defaultComponentDir: store.defaultComponentDir || "",
962
+ defaultTokenFile: store.defaultTokenFile || ""
466
963
  };
467
964
  }
468
965
  async function writeCredentials(config) {
@@ -484,18 +981,38 @@ var init_config_store = __esm({
484
981
  });
485
982
 
486
983
  // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
487
- import { useEffect as useEffect3, useState as useState4 } from "react";
488
- import { Box as Box5, Text as Text5, useInput as useInput5 } from "ink";
489
- import { Fragment, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
984
+ import { useEffect as useEffect4, useState as useState7 } from "react";
985
+ import { Box as Box7, Text as Text7, useInput as useInput7 } from "ink";
986
+ import TextInput3 from "ink-text-input";
987
+ import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
988
+ function debugFields(config) {
989
+ return {
990
+ space_id: config?.spaceId ?? "",
991
+ environment_id: config?.environmentId ?? "",
992
+ cma_token: config?.cmaToken ?? "",
993
+ host: config?.host ?? "",
994
+ default_component_dir: config?.defaultComponentDir ?? "",
995
+ default_token_file: config?.defaultTokenFile ?? ""
996
+ };
997
+ }
490
998
  function ConfigurationScreen({ onDone }) {
491
- const [stage, setStage] = useState4("loading");
492
- const [config, setConfig] = useState4(null);
493
- const [activeField, setActiveField] = useState4("spaceId");
494
- const [message, setMessage] = useState4(null);
495
- useEffect3(() => {
999
+ const [stage, setStage] = useState7("loading");
1000
+ const [config, setConfig] = useState7(null);
1001
+ const [activeField, setActiveField] = useState7("spaceId");
1002
+ const [notice, setNotice] = useState7(null);
1003
+ const [lastSaved, setLastSaved] = useState7(null);
1004
+ const [editing, setEditing] = useState7(false);
1005
+ const [valueBeforeEdit, setValueBeforeEdit] = useState7("");
1006
+ useEffect4(() => {
496
1007
  readCredentials().then((cfg) => {
497
1008
  setConfig(cfg);
498
1009
  setStage("form");
1010
+ startDebugRun({
1011
+ flow: "settings/contentful-configuration",
1012
+ step: "01-configuration",
1013
+ menuOption: "Configuration",
1014
+ inputs: debugFields(cfg)
1015
+ });
499
1016
  });
500
1017
  }, []);
501
1018
  function fieldValue(field) {
@@ -505,29 +1022,46 @@ function ConfigurationScreen({ onDone }) {
505
1022
  function setFieldValue(field, value) {
506
1023
  if (!config) return;
507
1024
  setConfig({ ...config, [field]: value });
1025
+ setNotice(null);
508
1026
  }
509
1027
  function handleSave() {
510
1028
  if (!config) return;
511
1029
  setStage("saving");
512
- setMessage(null);
1030
+ setNotice(null);
513
1031
  writeCredentials(config).then(() => {
514
- setStage("saved");
515
- setMessage("Configuration saved");
1032
+ setLastSaved(config);
1033
+ setNotice({ kind: "success", text: "Configuration saved" });
1034
+ setStage("form");
516
1035
  }).catch((err) => {
517
- setMessage(err instanceof Error ? err.message : "Failed to save");
1036
+ setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
518
1037
  setStage("form");
519
1038
  });
520
1039
  }
521
- useInput5((input, key) => {
1040
+ function quit() {
1041
+ void finishDebugRun(
1042
+ lastSaved ? { outputs: debugFields(lastSaved), status: "success", exitMethod: "saved" } : { outputs: {}, status: "success", exitMethod: "discarded" }
1043
+ );
1044
+ onDone();
1045
+ }
1046
+ useInput7((input, key) => {
522
1047
  if (stage === "loading" || stage === "saving") return;
523
- if (stage === "saved") {
524
- if (key.return || key.escape || input === "q") {
525
- onDone();
1048
+ if (editing) {
1049
+ if (key.escape) {
1050
+ setFieldValue(activeField, valueBeforeEdit);
1051
+ setEditing(false);
526
1052
  }
527
1053
  return;
528
1054
  }
529
1055
  if (key.escape || input === "q") {
530
- onDone();
1056
+ quit();
1057
+ return;
1058
+ }
1059
+ if (input === "s") {
1060
+ handleSave();
1061
+ return;
1062
+ }
1063
+ if (input === "c") {
1064
+ setFieldValue(activeField, "");
531
1065
  return;
532
1066
  }
533
1067
  if (key.tab || key.downArrow) {
@@ -541,69 +1075,51 @@ function ConfigurationScreen({ onDone }) {
541
1075
  return;
542
1076
  }
543
1077
  if (key.return) {
544
- const idx = FIELD_ORDER.indexOf(activeField);
545
- if (idx < FIELD_ORDER.length - 1) {
546
- setActiveField(FIELD_ORDER[idx + 1]);
547
- } else {
548
- handleSave();
549
- }
550
- return;
551
- }
552
- if (key.backspace || key.delete) {
553
- const current = fieldValue(activeField);
554
- setFieldValue(activeField, current.slice(0, -1));
555
- return;
556
- }
557
- if (input && !key.ctrl && !key.meta) {
558
- setFieldValue(activeField, fieldValue(activeField) + input);
1078
+ setValueBeforeEdit(fieldValue(activeField));
1079
+ setEditing(true);
559
1080
  }
560
1081
  });
561
1082
  if (stage === "loading") {
562
- return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
563
- /* @__PURE__ */ jsx5(Text5, { bold: true, children: "Configuration" }),
564
- /* @__PURE__ */ jsx5(Text5, { children: " " }),
565
- /* @__PURE__ */ jsx5(Text5, { color: PALETTE.accent, children: "Loading..." })
566
- ] });
567
- }
568
- if (stage === "saved") {
569
- return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
570
- /* @__PURE__ */ jsx5(Text5, { bold: true, children: "Configuration" }),
571
- /* @__PURE__ */ jsx5(Text5, { children: " " }),
572
- /* @__PURE__ */ jsxs5(Text5, { color: PALETTE.success, children: [
573
- "\u2713 ",
574
- message
575
- ] }),
576
- /* @__PURE__ */ jsx5(Text5, { children: " " }),
577
- /* @__PURE__ */ jsx5(Text5, { dimColor: true, children: "[Enter] Back to Settings" })
1083
+ return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
1084
+ /* @__PURE__ */ jsx7(Text7, { bold: true, children: "Configuration" }),
1085
+ /* @__PURE__ */ jsx7(Text7, { children: " " }),
1086
+ /* @__PURE__ */ jsx7(Text7, { color: PALETTE.accent, children: "Loading..." })
578
1087
  ] });
579
1088
  }
580
- return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
581
- /* @__PURE__ */ jsx5(Text5, { bold: true, children: "Configuration" }),
582
- /* @__PURE__ */ jsx5(Text5, { children: " " }),
583
- /* @__PURE__ */ jsx5(Text5, { children: "Contentful API Credentials" }),
584
- /* @__PURE__ */ jsx5(Text5, { children: " " }),
585
- /* @__PURE__ */ jsx5(Box5, { flexDirection: "column", children: FIELD_ORDER.map((field) => {
1089
+ return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
1090
+ /* @__PURE__ */ jsx7(Text7, { bold: true, children: "Configuration" }),
1091
+ /* @__PURE__ */ jsx7(Text7, { children: " " }),
1092
+ /* @__PURE__ */ jsx7(Box7, { flexDirection: "column", children: FIELD_ORDER.map((field) => {
586
1093
  const isActive = activeField === field;
587
1094
  const value = fieldValue(field);
588
1095
  const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
589
- return /* @__PURE__ */ jsxs5(Box5, { gap: 1, children: [
590
- /* @__PURE__ */ jsx5(Text5, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
591
- /* @__PURE__ */ jsxs5(Text5, { bold: isActive, children: [
1096
+ return /* @__PURE__ */ jsxs7(Box7, { gap: 1, children: [
1097
+ /* @__PURE__ */ jsx7(Text7, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
1098
+ /* @__PURE__ */ jsxs7(Text7, { bold: isActive, children: [
592
1099
  FIELD_LABELS[field],
593
1100
  ":"
594
1101
  ] }),
595
- /* @__PURE__ */ jsx5(Text5, { children: display || /* @__PURE__ */ jsx5(Text5, { dimColor: true, children: "(empty)" }) })
1102
+ isActive && editing ? /* @__PURE__ */ jsx7(
1103
+ TextInput3,
1104
+ {
1105
+ value,
1106
+ onChange: (next) => setFieldValue(field, next),
1107
+ onSubmit: () => setEditing(false),
1108
+ mask: field === "cmaToken" ? "\u2022" : void 0
1109
+ }
1110
+ ) : /* @__PURE__ */ jsx7(Text7, { children: display || /* @__PURE__ */ jsx7(Text7, { dimColor: true, children: "(empty)" }) })
596
1111
  ] }, field);
597
1112
  }) }),
598
- message && /* @__PURE__ */ jsxs5(Fragment, { children: [
599
- /* @__PURE__ */ jsx5(Text5, { children: " " }),
600
- /* @__PURE__ */ jsxs5(Text5, { color: PALETTE.error, children: [
601
- "\u2717 ",
602
- message
1113
+ notice && /* @__PURE__ */ jsxs7(Fragment2, { children: [
1114
+ /* @__PURE__ */ jsx7(Text7, { children: " " }),
1115
+ /* @__PURE__ */ jsxs7(Text7, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
1116
+ notice.kind === "success" ? "\u2713" : "\u2717",
1117
+ " ",
1118
+ notice.text
603
1119
  ] })
604
1120
  ] }),
605
- /* @__PURE__ */ jsx5(Text5, { children: " " }),
606
- /* @__PURE__ */ jsx5(Text5, { dimColor: true, children: "[\u2191/\u2193] Switch field \xB7 [Enter] Save/Next \xB7 [Esc/q] Back" })
1121
+ /* @__PURE__ */ jsx7(Text7, { children: " " }),
1122
+ /* @__PURE__ */ jsx7(Text7, { dimColor: true, children: editing ? "[type] Edit \xB7 [\u2190/\u2192] Move cursor \xB7 [Enter] Done \xB7 [Esc] Cancel edit" : "[\u2191/\u2193] Switch field \xB7 [Enter] Edit \xB7 [c] Clear field \xB7 [s] Save \xB7 [Esc/q] Quit without saving" })
607
1123
  ] });
608
1124
  }
609
1125
  var FIELD_ORDER, FIELD_LABELS;
@@ -612,12 +1128,22 @@ var init_ContentfulConfigScreen = __esm({
612
1128
  "use strict";
613
1129
  init_home_theme();
614
1130
  init_config_store();
615
- FIELD_ORDER = ["spaceId", "environmentId", "cmaToken", "host"];
1131
+ init_debug_store();
1132
+ FIELD_ORDER = [
1133
+ "spaceId",
1134
+ "environmentId",
1135
+ "cmaToken",
1136
+ "host",
1137
+ "defaultComponentDir",
1138
+ "defaultTokenFile"
1139
+ ];
616
1140
  FIELD_LABELS = {
617
1141
  spaceId: "Space ID",
618
1142
  environmentId: "Environment ID",
619
1143
  cmaToken: "CMA Token",
620
- host: "API Host (optional)"
1144
+ host: "API Host (optional)",
1145
+ defaultComponentDir: "Default component directory (optional)",
1146
+ defaultTokenFile: "Default token file (optional)"
621
1147
  };
622
1148
  }
623
1149
  });
@@ -644,19 +1170,25 @@ var init_analytics_store = __esm({
644
1170
  });
645
1171
 
646
1172
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
647
- import { useEffect as useEffect4, useState as useState5 } from "react";
648
- import { Box as Box6, Text as Text6, useInput as useInput6 } from "ink";
649
- import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1173
+ import { useEffect as useEffect5, useState as useState8 } from "react";
1174
+ import { Box as Box8, Text as Text8, useInput as useInput8 } from "ink";
1175
+ import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
650
1176
  function OptInAnalyticsScreen({ onDone }) {
651
- const [loading, setLoading] = useState5(true);
652
- const [enabled, setEnabled] = useState5(true);
653
- useEffect4(() => {
1177
+ const [loading, setLoading] = useState8(true);
1178
+ const [enabled, setEnabled] = useState8(true);
1179
+ useEffect5(() => {
654
1180
  readAnalyticsSetting().then((setting) => {
655
1181
  setEnabled(setting.enabled);
656
1182
  setLoading(false);
1183
+ startDebugRun({
1184
+ flow: "settings/opt-in-analytics",
1185
+ step: "01-opt-in-analytics",
1186
+ menuOption: "Opt-in Analytics",
1187
+ inputs: { enabled: setting.enabled }
1188
+ });
657
1189
  });
658
1190
  }, []);
659
- useInput6((input, key) => {
1191
+ useInput8((input, key) => {
660
1192
  if (loading) return;
661
1193
  if (key.return || input === " ") {
662
1194
  setEnabled((current) => {
@@ -667,225 +1199,43 @@ function OptInAnalyticsScreen({ onDone }) {
667
1199
  return;
668
1200
  }
669
1201
  if (key.escape || input === "q") {
1202
+ void finishDebugRun({ outputs: { enabled }, status: "success", exitMethod: "saved" });
670
1203
  onDone();
671
1204
  }
672
1205
  });
673
- return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
674
- /* @__PURE__ */ jsx6(Text6, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
675
- /* @__PURE__ */ jsx6(Text6, { children: " " }),
676
- loading ? /* @__PURE__ */ jsx6(Text6, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs6(Fragment2, { children: [
677
- /* @__PURE__ */ jsxs6(Text6, { children: [
1206
+ return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
1207
+ /* @__PURE__ */ jsx8(Text8, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
1208
+ /* @__PURE__ */ jsx8(Text8, { children: " " }),
1209
+ loading ? /* @__PURE__ */ jsx8(Text8, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs8(Fragment3, { children: [
1210
+ /* @__PURE__ */ jsxs8(Text8, { children: [
678
1211
  "Share anonymous usage data:",
679
1212
  " ",
680
- /* @__PURE__ */ jsx6(Text6, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
1213
+ /* @__PURE__ */ jsx8(Text8, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
681
1214
  ] }),
682
- /* @__PURE__ */ jsx6(Text6, { children: " " }),
683
- /* @__PURE__ */ jsx6(Text6, { dimColor: true, children: "Shares which CLI commands are used and where imports succeed or fail." }),
684
- /* @__PURE__ */ jsx6(Text6, { dimColor: true, children: "Never includes source code, file paths, credentials, or authored content." })
1215
+ /* @__PURE__ */ jsx8(Text8, { children: " " }),
1216
+ /* @__PURE__ */ jsx8(Text8, { dimColor: true, children: "Shares which CLI commands are used and where imports succeed or fail." }),
1217
+ /* @__PURE__ */ jsx8(Text8, { dimColor: true, children: "Never includes source code, file paths, credentials, or authored content." })
685
1218
  ] }),
686
- /* @__PURE__ */ jsx6(Text6, { children: " " }),
687
- /* @__PURE__ */ jsx6(Text6, { dimColor: true, children: "[Enter/Space] Toggle [Esc/q] Back to Settings" })
1219
+ /* @__PURE__ */ jsx8(Text8, { children: " " }),
1220
+ /* @__PURE__ */ jsx8(Text8, { dimColor: true, children: "[Enter/Space] Toggle [Esc/q] Back to Settings" })
688
1221
  ] });
689
1222
  }
690
- var init_screen = __esm({
1223
+ var init_screen3 = __esm({
691
1224
  "packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx"() {
692
1225
  "use strict";
693
1226
  init_home_theme();
694
1227
  init_analytics_store();
695
- }
696
- });
697
-
698
- // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
699
- import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
700
- import { dirname as dirname2, join as join5 } from "node:path";
701
- function debugModeSettingPath() {
702
- return join5(findPackageRoot(import.meta.url, PACKAGE_NAME3), ".contentful", "config", "debug_mode.json");
703
- }
704
- async function readDebugModeSetting() {
705
- try {
706
- const raw = await readFile2(debugModeSettingPath(), "utf8");
707
- const parsed = JSON.parse(raw);
708
- return { ...DEFAULT_DEBUG_MODE_SETTING, ...parsed };
709
- } catch {
710
- return { ...DEFAULT_DEBUG_MODE_SETTING };
711
- }
712
- }
713
- async function writeDebugModeSetting(setting) {
714
- const path = debugModeSettingPath();
715
- await mkdir2(dirname2(path), { recursive: true });
716
- await writeFile2(path, `${JSON.stringify(setting, null, 2)}
717
- `, { mode: 384 });
718
- }
719
- var PACKAGE_NAME3, DEFAULT_DEBUG_MODE_SETTING;
720
- var init_debug_mode_store = __esm({
721
- "packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
722
- "use strict";
723
- init_package_root();
724
- PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
725
- DEFAULT_DEBUG_MODE_SETTING = {
726
- enabled: true
727
- };
728
- }
729
- });
730
-
731
- // packages/experience-design-system-cli/src/tui/debug-store.ts
732
- import { mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
733
- import { existsSync as existsSync3, readdirSync } from "node:fs";
734
- import { join as join6 } from "node:path";
735
- function generateRunId() {
736
- const now = /* @__PURE__ */ new Date();
737
- const pad = (n) => String(n).padStart(2, "0");
738
- return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
739
- }
740
- function sessionsRootDir() {
741
- return join6(findPackageRoot(import.meta.url, PACKAGE_NAME4), ".contentful", "debug", "sessions");
742
- }
743
- function datePrefix(now = /* @__PURE__ */ new Date()) {
744
- const pad = (n) => String(n).padStart(2, "0");
745
- return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
746
- }
747
- function slugify(value) {
748
- return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
749
- }
750
- function generateSessionId() {
751
- const today = datePrefix();
752
- const root = sessionsRootDir();
753
- const existing = existsSync3(root) ? readdirSync(root) : [];
754
- const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
755
- const maxSeq = existing.reduce((max, entry) => {
756
- const match = seqPattern.exec(entry);
757
- return match ? Math.max(max, Number(match[1])) : max;
758
- }, 0);
759
- return `${today}-session-${maxSeq + 1}`;
760
- }
761
- function sessionDebugDir() {
762
- return join6(sessionsRootDir(), SESSION_ID);
763
- }
764
- async function isDebugModeEnabled() {
765
- try {
766
- return (await readDebugModeSetting()).enabled;
767
- } catch {
768
- return true;
769
- }
770
- }
771
- function redact(value) {
772
- const clone = { ...value };
773
- if ("cma_token" in clone) {
774
- const raw = clone.cma_token;
775
- clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
776
- }
777
- return clone;
778
- }
779
- function startDebugRun({
780
- flow,
781
- step,
782
- menuOption,
783
- inputs
784
- }) {
785
- const runId = generateRunId();
786
- const startedAt = Date.now();
787
- const redactedInputs = redact(inputs);
788
- isDebugModeEnabled().then((enabled) => {
789
- if (!enabled) return;
790
- pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
791
- });
792
- }
793
- async function finishDebugRun({
794
- outputs,
795
- status,
796
- exitMethod
797
- }) {
798
- const run = pendingRun;
799
- if (!run) return;
800
- pendingRun = void 0;
801
- const durationMs = Date.now() - run.startedAt;
802
- const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
803
- const flowSegments = run.flow.split("/");
804
- const dir = join6(sessionDebugDir(), ...flowSegments);
805
- await mkdir3(dir, { recursive: true });
806
- const filename = nextAttemptFilename(dir, run.menuOption);
807
- await writeFile3(join6(dir, filename), content, { mode: 384 });
808
- }
809
- function nextAttemptFilename(dir, menuOption) {
810
- const today = datePrefix();
811
- const optionSlug = slugify(menuOption);
812
- const existing = existsSync3(dir) ? readdirSync(dir) : [];
813
- const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
814
- const maxAttempt = existing.reduce((max, entry) => {
815
- const match = attemptPattern.exec(entry);
816
- return match ? Math.max(max, Number(match[1])) : max;
817
- }, 0);
818
- return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
819
- }
820
- function renderMarkdown(run, finish) {
821
- const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
822
- const stepLabel = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
823
- const flowSlug = run.flow.split("/").join("-");
824
- return `# Debug Log
825
-
826
- - Run ID: ${run.runId}
827
- - Flow: ${flowSlug}
828
- - Step: ${stepLabel}
829
- - Menu option: ${run.menuOption}
830
- - Date: ${(/* @__PURE__ */ new Date()).toISOString()}
831
- - CLI version: ${readPackageVersion()}
832
- - Platform: ${process.platform} / Node ${process.version}
833
- - Duration on screen: ${finish.durationMs}ms
834
- - Status: ${finish.status}
835
- - Exit method: ${finish.exitMethod}
836
-
837
- ## Inputs
838
- \`\`\`json
839
- ${JSON.stringify(run.inputs, null, 2)}
840
- \`\`\`
841
-
842
- ## Outputs
843
- \`\`\`json
844
- ${JSON.stringify(finish.outputs, null, 2)}
845
- \`\`\`
846
- `;
847
- }
848
- function handleCrash() {
849
- return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
850
- }
851
- var PACKAGE_NAME4, pendingRun, SESSION_ID;
852
- var init_debug_store = __esm({
853
- "packages/experience-design-system-cli/src/tui/debug-store.ts"() {
854
- "use strict";
855
- init_package_root();
856
- init_version();
857
- init_debug_mode_store();
858
- PACKAGE_NAME4 = "@contentful/experience-design-system-cli";
859
- SESSION_ID = generateSessionId();
860
- void isDebugModeEnabled().then((enabled) => {
861
- if (!enabled) return void 0;
862
- return mkdir3(sessionDebugDir(), { recursive: true });
863
- });
864
- process.once("uncaughtException", (err) => {
865
- void handleCrash().finally(() => {
866
- throw err;
867
- });
868
- });
869
- process.once("unhandledRejection", (reason) => {
870
- void handleCrash().finally(() => {
871
- throw reason;
872
- });
873
- });
874
- process.once("SIGINT", () => {
875
- void handleCrash().finally(() => {
876
- process.exit(130);
877
- });
878
- });
1228
+ init_debug_store();
879
1229
  }
880
1230
  });
881
1231
 
882
1232
  // packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
883
- import { useEffect as useEffect5, useState as useState6 } from "react";
884
- import { Box as Box7, Text as Text7, useInput as useInput7 } from "ink";
885
- import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1233
+ import { useEffect as useEffect6, useState as useState9 } from "react";
1234
+ import { Box as Box9, Text as Text9, useInput as useInput9 } from "ink";
1235
+ import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
886
1236
  function UpgradeScreen({ onDone }) {
887
- const [upgradeCheck, setUpgradeCheck] = useState6();
888
- useEffect5(() => {
1237
+ const [upgradeCheck, setUpgradeCheck] = useState9();
1238
+ useEffect6(() => {
889
1239
  startDebugRun({
890
1240
  flow: "upgrade",
891
1241
  step: "01-upgrade",
@@ -894,7 +1244,7 @@ function UpgradeScreen({ onDone }) {
894
1244
  });
895
1245
  checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
896
1246
  }, []);
897
- useInput7((_input, key) => {
1247
+ useInput9((_input, key) => {
898
1248
  if (key.return) {
899
1249
  void finishDebugRun({
900
1250
  outputs: upgradeCheck ?? {},
@@ -905,12 +1255,12 @@ function UpgradeScreen({ onDone }) {
905
1255
  return;
906
1256
  }
907
1257
  });
908
- return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
909
- /* @__PURE__ */ jsx7(Text7, { bold: true, children: "Upgrade" }),
910
- /* @__PURE__ */ jsx7(Text7, { children: " " }),
1258
+ return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
1259
+ /* @__PURE__ */ jsx9(Text9, { bold: true, children: "Upgrade" }),
1260
+ /* @__PURE__ */ jsx9(Text9, { children: " " }),
911
1261
  renderBody(upgradeCheck),
912
- /* @__PURE__ */ jsx7(Text7, { children: " " }),
913
- /* @__PURE__ */ jsxs7(Text7, { bold: true, color: PALETTE.accent, children: [
1262
+ /* @__PURE__ */ jsx9(Text9, { children: " " }),
1263
+ /* @__PURE__ */ jsxs9(Text9, { bold: true, color: PALETTE.accent, children: [
914
1264
  FOCUS_MARKER,
915
1265
  " Go Back"
916
1266
  ] })
@@ -918,34 +1268,34 @@ function UpgradeScreen({ onDone }) {
918
1268
  }
919
1269
  function renderBody(upgradeCheck) {
920
1270
  if (!upgradeCheck) {
921
- return /* @__PURE__ */ jsx7(Text7, { color: PALETTE.muted, children: "Checking for updates\u2026" });
1271
+ return /* @__PURE__ */ jsx9(Text9, { color: PALETTE.muted, children: "Checking for updates\u2026" });
922
1272
  }
923
1273
  if (upgradeCheck.status === "error") {
924
- return /* @__PURE__ */ jsx7(Text7, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
1274
+ return /* @__PURE__ */ jsx9(Text9, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
925
1275
  }
926
1276
  if (upgradeCheck.status === "up-to-date") {
927
- return /* @__PURE__ */ jsxs7(Text7, { color: PALETTE.success, children: [
1277
+ return /* @__PURE__ */ jsxs9(Text9, { color: PALETTE.success, children: [
928
1278
  "You're already on the latest version (v",
929
1279
  upgradeCheck.current,
930
1280
  ")."
931
1281
  ] });
932
1282
  }
933
- return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", children: [
934
- /* @__PURE__ */ jsxs7(Text7, { color: PALETTE.muted, children: [
935
- /* @__PURE__ */ jsxs7(Text7, { bold: true, color: PALETTE.success, children: [
1283
+ return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", children: [
1284
+ /* @__PURE__ */ jsxs9(Text9, { color: PALETTE.muted, children: [
1285
+ /* @__PURE__ */ jsxs9(Text9, { bold: true, color: PALETTE.success, children: [
936
1286
  "v",
937
1287
  upgradeCheck.latest
938
1288
  ] }),
939
1289
  " ",
940
1290
  "is available (you're on ",
941
- /* @__PURE__ */ jsxs7(Text7, { bold: true, children: [
1291
+ /* @__PURE__ */ jsxs9(Text9, { bold: true, children: [
942
1292
  "v",
943
1293
  upgradeCheck.current
944
1294
  ] }),
945
1295
  "). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
946
1296
  ] }),
947
- /* @__PURE__ */ jsx7(Text7, { children: " " }),
948
- /* @__PURE__ */ jsx7(Box7, { flexDirection: "column", borderStyle: "round", borderColor: PALETTE.border, paddingX: 1, children: UPGRADE_COMMANDS.map((cmd) => /* @__PURE__ */ jsx7(Text7, { bold: true, children: cmd }, cmd)) })
1297
+ /* @__PURE__ */ jsx9(Text9, { children: " " }),
1298
+ /* @__PURE__ */ jsx9(Box9, { flexDirection: "column", borderStyle: "round", borderColor: PALETTE.border, paddingX: 1, children: UPGRADE_COMMANDS.map((cmd) => /* @__PURE__ */ jsx9(Text9, { bold: true, children: cmd }, cmd)) })
949
1299
  ] });
950
1300
  }
951
1301
  var UPGRADE_COMMANDS;
@@ -960,19 +1310,25 @@ var init_PageContainer4 = __esm({
960
1310
  });
961
1311
 
962
1312
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
963
- import { useEffect as useEffect6, useState as useState7 } from "react";
964
- import { Box as Box8, Text as Text8, useInput as useInput8 } from "ink";
965
- import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1313
+ import { useEffect as useEffect7, useState as useState10 } from "react";
1314
+ import { Box as Box10, Text as Text10, useInput as useInput10 } from "ink";
1315
+ import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
966
1316
  function DebugModeScreen({ onDone }) {
967
- const [loading, setLoading] = useState7(true);
968
- const [enabled, setEnabled] = useState7(true);
969
- useEffect6(() => {
1317
+ const [loading, setLoading] = useState10(true);
1318
+ const [enabled, setEnabled] = useState10(true);
1319
+ useEffect7(() => {
970
1320
  readDebugModeSetting().then((setting) => {
971
1321
  setEnabled(setting.enabled);
972
1322
  setLoading(false);
1323
+ startDebugRun({
1324
+ flow: "settings/debug-mode",
1325
+ step: "01-debug-mode",
1326
+ menuOption: "Debug Mode",
1327
+ inputs: { enabled: setting.enabled }
1328
+ });
973
1329
  });
974
1330
  }, []);
975
- useInput8((input, key) => {
1331
+ useInput10((input, key) => {
976
1332
  if (loading) return;
977
1333
  if (key.return || input === " ") {
978
1334
  setEnabled((current) => {
@@ -983,26 +1339,28 @@ function DebugModeScreen({ onDone }) {
983
1339
  return;
984
1340
  }
985
1341
  if (key.escape || input === "q") {
1342
+ void finishDebugRun({ outputs: { enabled }, status: "success", exitMethod: "saved" });
986
1343
  onDone();
987
1344
  }
988
1345
  });
989
- return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
990
- /* @__PURE__ */ jsx8(Text8, { bold: true, children: "Settings \u203A Debug Mode" }),
991
- /* @__PURE__ */ jsx8(Text8, { children: " " }),
992
- loading ? /* @__PURE__ */ jsx8(Text8, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs8(Text8, { children: [
1346
+ return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
1347
+ /* @__PURE__ */ jsx10(Text10, { bold: true, children: "Settings \u203A Debug Mode" }),
1348
+ /* @__PURE__ */ jsx10(Text10, { children: " " }),
1349
+ loading ? /* @__PURE__ */ jsx10(Text10, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs10(Text10, { children: [
993
1350
  "Debug logging:",
994
1351
  " ",
995
- /* @__PURE__ */ jsx8(Text8, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
1352
+ /* @__PURE__ */ jsx10(Text10, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
996
1353
  ] }),
997
- /* @__PURE__ */ jsx8(Text8, { children: " " }),
998
- /* @__PURE__ */ jsx8(Text8, { dimColor: true, children: "[Enter/Space] Toggle [Esc/q] Back to Settings" })
1354
+ /* @__PURE__ */ jsx10(Text10, { children: " " }),
1355
+ /* @__PURE__ */ jsx10(Text10, { dimColor: true, children: "[Enter/Space] Toggle [Esc/q] Back to Settings" })
999
1356
  ] });
1000
1357
  }
1001
- var init_screen2 = __esm({
1358
+ var init_screen4 = __esm({
1002
1359
  "packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx"() {
1003
1360
  "use strict";
1004
1361
  init_home_theme();
1005
1362
  init_debug_mode_store();
1363
+ init_debug_store();
1006
1364
  }
1007
1365
  });
1008
1366
 
@@ -1011,48 +1369,75 @@ var app_exports = {};
1011
1369
  __export(app_exports, {
1012
1370
  runApp: () => runApp
1013
1371
  });
1014
- import { useState as useState8 } from "react";
1015
- import { jsx as jsx9 } from "react/jsx-runtime";
1372
+ import { useEffect as useEffect8, useState as useState11 } from "react";
1373
+ import { Fragment as Fragment4, jsx as jsx11 } from "react/jsx-runtime";
1016
1374
  function App({ onLaunchImport, importExitCode }) {
1017
1375
  const returnedFromImport = importExitCode !== void 0;
1018
- const [screen, setScreen] = useState8(returnedFromImport ? "import" : "start");
1019
- const goToStart = () => setScreen("start");
1020
- const goToSettings = () => setScreen("settings");
1021
- const navigateFromHome = (next) => {
1022
- if (next === "import" && onLaunchImport) {
1023
- onLaunchImport();
1376
+ const [screen, setScreen] = useState11(returnedFromImport ? "import" : "start");
1377
+ const [showImportResult, setShowImportResult] = useState11(returnedFromImport);
1378
+ const [projectPath, setProjectPath] = useState11();
1379
+ const [importDefaults, setImportDefaults] = useState11();
1380
+ useEffect8(() => {
1381
+ if (screen !== "import") {
1382
+ setImportDefaults(void 0);
1024
1383
  return;
1025
1384
  }
1026
- setScreen(next);
1385
+ void readCredentials().then(
1386
+ (saved) => setImportDefaults({ componentDir: saved.defaultComponentDir ?? "", tokenFile: saved.defaultTokenFile ?? "" })
1387
+ );
1388
+ }, [screen]);
1389
+ const goToStart = () => setScreen("start");
1390
+ const goToSettings = () => setScreen("settings");
1391
+ const finishImportResult = () => {
1392
+ setShowImportResult(false);
1393
+ setProjectPath(void 0);
1394
+ goToStart();
1395
+ };
1396
+ const leaveImport = () => {
1397
+ setProjectPath(void 0);
1398
+ goToStart();
1027
1399
  };
1028
1400
  switch (screen) {
1029
1401
  case "import":
1030
- return /* @__PURE__ */ jsx9(ImportScreen, { exitCode: importExitCode, onDone: goToStart });
1402
+ if (showImportResult) return /* @__PURE__ */ jsx11(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
1403
+ if (importDefaults === void 0) return /* @__PURE__ */ jsx11(Fragment4, {});
1404
+ if (projectPath === void 0) {
1405
+ return /* @__PURE__ */ jsx11(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
1406
+ }
1407
+ return /* @__PURE__ */ jsx11(
1408
+ TokenInputScreen,
1409
+ {
1410
+ initialPath: importDefaults.tokenFile,
1411
+ onConfirm: (tokens) => onLaunchImport?.({ project: projectPath, tokens }),
1412
+ onSkip: () => onLaunchImport?.({ project: projectPath }),
1413
+ onBack: () => setProjectPath(void 0)
1414
+ }
1415
+ );
1031
1416
  case "help":
1032
- return /* @__PURE__ */ jsx9(HelpScreen, { onDone: goToStart });
1417
+ return /* @__PURE__ */ jsx11(HelpScreen, { onDone: goToStart });
1033
1418
  case "upgrade":
1034
- return /* @__PURE__ */ jsx9(UpgradeScreen, { onDone: goToStart });
1419
+ return /* @__PURE__ */ jsx11(UpgradeScreen, { onDone: goToStart });
1035
1420
  case "settings":
1036
- return /* @__PURE__ */ jsx9(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
1421
+ return /* @__PURE__ */ jsx11(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
1037
1422
  case "settings-configuration":
1038
- return /* @__PURE__ */ jsx9(ConfigurationScreen, { onDone: goToSettings });
1423
+ return /* @__PURE__ */ jsx11(ConfigurationScreen, { onDone: goToSettings });
1039
1424
  case "settings-opt-in-analytics":
1040
- return /* @__PURE__ */ jsx9(OptInAnalyticsScreen, { onDone: goToSettings });
1425
+ return /* @__PURE__ */ jsx11(OptInAnalyticsScreen, { onDone: goToSettings });
1041
1426
  case "settings-debug-mode":
1042
- return /* @__PURE__ */ jsx9(DebugModeScreen, { onDone: goToSettings });
1427
+ return /* @__PURE__ */ jsx11(DebugModeScreen, { onDone: goToSettings });
1043
1428
  case "start":
1044
- return /* @__PURE__ */ jsx9(HomeScreen, { onNavigate: navigateFromHome });
1429
+ return /* @__PURE__ */ jsx11(HomeScreen, { onNavigate: setScreen });
1045
1430
  }
1046
1431
  }
1047
1432
  async function renderUntilImportRequestedOrExit(renderApp, importExitCode) {
1048
- let importRequested = false;
1433
+ let requestedImport;
1049
1434
  const instance = renderApp(
1050
- /* @__PURE__ */ jsx9(
1435
+ /* @__PURE__ */ jsx11(
1051
1436
  App,
1052
1437
  {
1053
1438
  importExitCode,
1054
- onLaunchImport: () => {
1055
- importRequested = true;
1439
+ onLaunchImport: (options) => {
1440
+ requestedImport = options;
1056
1441
  instance.unmount();
1057
1442
  }
1058
1443
  }
@@ -1060,13 +1445,15 @@ async function renderUntilImportRequestedOrExit(renderApp, importExitCode) {
1060
1445
  );
1061
1446
  await instance.waitUntilExit();
1062
1447
  await stopReadingTerminal();
1063
- return importRequested;
1448
+ return requestedImport;
1064
1449
  }
1065
1450
  async function runApp(renderApp) {
1066
1451
  let importExitCode;
1067
- while (await renderUntilImportRequestedOrExit(renderApp, importExitCode)) {
1068
- importExitCode = (await spawnV1Import({})).exitCode;
1452
+ let requestedImport = await renderUntilImportRequestedOrExit(renderApp, importExitCode);
1453
+ while (requestedImport !== void 0) {
1454
+ importExitCode = (await spawnV1Import(requestedImport)).exitCode;
1069
1455
  startReadingTerminal();
1456
+ requestedImport = await renderUntilImportRequestedOrExit(renderApp, importExitCode);
1070
1457
  }
1071
1458
  }
1072
1459
  var init_app = __esm({
@@ -1074,14 +1461,16 @@ var init_app = __esm({
1074
1461
  "use strict";
1075
1462
  init_home();
1076
1463
  init_PageContainer();
1464
+ init_steps();
1077
1465
  init_spawn_v1_import();
1078
1466
  init_terminal_input();
1079
1467
  init_PageContainer2();
1080
1468
  init_PageContainer3();
1081
1469
  init_ContentfulConfigScreen();
1082
- init_screen();
1470
+ init_screen3();
1083
1471
  init_PageContainer4();
1084
- init_screen2();
1472
+ init_screen4();
1473
+ init_config_store();
1085
1474
  }
1086
1475
  });
1087
1476
 
@@ -1160,7 +1549,51 @@ function createProgram() {
1160
1549
  return program;
1161
1550
  }
1162
1551
 
1552
+ // packages/experience-design-system-cli/src/config/migrate.ts
1553
+ init_config();
1554
+ init_package_root();
1555
+ import { existsSync as existsSync4 } from "node:fs";
1556
+ import { mkdir as mkdir3, readFile as readFile2, rename as rename2, rmdir, unlink } from "node:fs/promises";
1557
+ import { dirname as dirname3, join as join6 } from "node:path";
1558
+ var PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
1559
+ async function readJson(path) {
1560
+ try {
1561
+ return JSON.parse(await readFile2(path, "utf8"));
1562
+ } catch {
1563
+ return void 0;
1564
+ }
1565
+ }
1566
+ async function migrateOldConfig() {
1567
+ try {
1568
+ const oldCredentials = join6(oldConfigDir(), "credentials.json");
1569
+ const oldRuns = join6(oldConfigDir(), "runs.json");
1570
+ const oldDebugMode = join6(
1571
+ findPackageRoot(import.meta.url, PACKAGE_NAME3),
1572
+ ".contentful",
1573
+ "config",
1574
+ "debug_mode.json"
1575
+ );
1576
+ const migrated = {};
1577
+ const debugMode = await readJson(oldDebugMode);
1578
+ if (debugMode) migrated["debugMode"] = debugMode;
1579
+ Object.assign(migrated, await readJson(oldCredentials));
1580
+ if (Object.keys(migrated).length > 0) await updateSettings({ ...migrated, ...await readSettings() });
1581
+ if (existsSync4(oldRuns)) {
1582
+ if (!existsSync4(runsFilePath())) {
1583
+ await mkdir3(dirname3(runsFilePath()), { recursive: true });
1584
+ await rename2(oldRuns, runsFilePath());
1585
+ } else {
1586
+ await unlink(oldRuns);
1587
+ }
1588
+ }
1589
+ await Promise.all([oldCredentials, oldDebugMode].map((f) => unlink(f).catch(() => void 0)));
1590
+ await rmdir(oldConfigDir()).catch(() => void 0);
1591
+ } catch {
1592
+ }
1593
+ }
1594
+
1163
1595
  // packages/experience-design-system-cli/index.ts
1596
+ await migrateOldConfig();
1164
1597
  createProgram().parseAsync().catch((err) => {
1165
1598
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
1166
1599
  `);