@contentful/experience-design-system-cli 2.36.2-dev-build-3425e8d3.0 → 2.36.2-dev-build-3b8c3735.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/app.js +633 -357
- package/dist/index.js +756 -373
- package/dist/package.json +2 -1
- package/dist/src/config/migrate.d.ts +1 -0
- package/dist/src/tui/import/spawn-v1-import.d.ts +1 -0
- package/dist/src/tui/import/steps/01-welcome/controls.d.ts +8 -0
- package/dist/src/tui/import/steps/01-welcome/logic.d.ts +8 -0
- package/dist/src/tui/import/steps/01-welcome/screen.d.ts +8 -0
- package/dist/src/tui/import/steps/02-token-input/controls.d.ts +11 -0
- package/dist/src/tui/import/steps/02-token-input/logic.d.ts +9 -0
- package/dist/src/tui/import/steps/02-token-input/screen.d.ts +9 -0
- package/dist/src/tui/import/steps/02-token-input/validate-path.d.ts +12 -0
- package/dist/src/tui/import/steps/index.d.ts +2 -0
- package/dist/src/tui/settings/contentful-configuration/config-store.d.ts +2 -0
- package/dist/src/tui/settings/utils/v1-store.d.ts +3 -2
- package/legacy/dist/src/analyze/select/tui/theme.d.ts +3 -0
- package/legacy/dist/src/import/tui/steps/DoneStep.d.ts +1 -1
- package/legacy/dist/src/import/tui/steps/RunningStep.d.ts +9 -1
- package/legacy/dist/src/index.js +8646 -7616
- package/legacy/dist/src/runs/store.d.ts +2 -2
- package/legacy/dist/src/tui/use-timed-spinner.d.ts +1 -2
- package/legacy/package.json +2 -1
- package/package.json +3 -2
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((
|
|
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,261 @@ 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
|
+
async function isDebugModeEnabled() {
|
|
688
|
+
try {
|
|
689
|
+
return (await readDebugModeSetting()).enabled;
|
|
690
|
+
} catch {
|
|
691
|
+
return true;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
function redact(value) {
|
|
695
|
+
const clone = { ...value };
|
|
696
|
+
if ("cma_token" in clone) {
|
|
697
|
+
const raw = clone.cma_token;
|
|
698
|
+
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
699
|
+
}
|
|
700
|
+
return clone;
|
|
701
|
+
}
|
|
702
|
+
function startDebugRun({
|
|
703
|
+
flow,
|
|
704
|
+
step,
|
|
705
|
+
menuOption,
|
|
706
|
+
inputs
|
|
707
|
+
}) {
|
|
708
|
+
const runId = generateRunId();
|
|
709
|
+
const startedAt = Date.now();
|
|
710
|
+
const redactedInputs = redact(inputs);
|
|
711
|
+
isDebugModeEnabled().then((enabled) => {
|
|
712
|
+
if (!enabled) return;
|
|
713
|
+
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
async function finishDebugRun({
|
|
717
|
+
outputs,
|
|
718
|
+
status,
|
|
719
|
+
exitMethod
|
|
720
|
+
}) {
|
|
721
|
+
const run = pendingRun;
|
|
722
|
+
if (!run) return;
|
|
723
|
+
pendingRun = void 0;
|
|
724
|
+
const durationMs = Date.now() - run.startedAt;
|
|
725
|
+
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
726
|
+
const flowSegments = run.flow.split("/");
|
|
727
|
+
const dir = join5(sessionDebugDir(), ...flowSegments);
|
|
728
|
+
await mkdir2(dir, { recursive: true });
|
|
729
|
+
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
730
|
+
await writeFile2(join5(dir, filename), content, { mode: 384 });
|
|
731
|
+
}
|
|
732
|
+
function nextAttemptFilename(dir, menuOption) {
|
|
733
|
+
const today = datePrefix();
|
|
734
|
+
const optionSlug = slugify(menuOption);
|
|
735
|
+
const existing = existsSync3(dir) ? readdirSync(dir) : [];
|
|
736
|
+
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
737
|
+
const maxAttempt = existing.reduce((max, entry) => {
|
|
738
|
+
const match = attemptPattern.exec(entry);
|
|
739
|
+
return match ? Math.max(max, Number(match[1])) : max;
|
|
740
|
+
}, 0);
|
|
741
|
+
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
742
|
+
}
|
|
743
|
+
function renderMarkdown(run, finish) {
|
|
744
|
+
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
745
|
+
const stepLabel = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
746
|
+
const flowSlug = run.flow.split("/").join("-");
|
|
747
|
+
return `# Debug Log
|
|
748
|
+
|
|
749
|
+
- Run ID: ${run.runId}
|
|
750
|
+
- Flow: ${flowSlug}
|
|
751
|
+
- Step: ${stepLabel}
|
|
752
|
+
- Menu option: ${run.menuOption}
|
|
753
|
+
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
754
|
+
- CLI version: ${readPackageVersion()}
|
|
755
|
+
- Platform: ${process.platform} / Node ${process.version}
|
|
756
|
+
- Duration on screen: ${finish.durationMs}ms
|
|
757
|
+
- Status: ${finish.status}
|
|
758
|
+
- Exit method: ${finish.exitMethod}
|
|
759
|
+
|
|
760
|
+
## Inputs
|
|
761
|
+
\`\`\`json
|
|
762
|
+
${JSON.stringify(run.inputs, null, 2)}
|
|
763
|
+
\`\`\`
|
|
764
|
+
|
|
765
|
+
## Outputs
|
|
766
|
+
\`\`\`json
|
|
767
|
+
${JSON.stringify(finish.outputs, null, 2)}
|
|
768
|
+
\`\`\`
|
|
769
|
+
`;
|
|
770
|
+
}
|
|
771
|
+
function handleCrash() {
|
|
772
|
+
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
773
|
+
}
|
|
774
|
+
var pendingRun, SESSION_ID;
|
|
775
|
+
var init_debug_store = __esm({
|
|
776
|
+
"packages/experience-design-system-cli/src/tui/debug-store.ts"() {
|
|
777
|
+
"use strict";
|
|
778
|
+
init_config();
|
|
779
|
+
init_version();
|
|
780
|
+
init_debug_mode_store();
|
|
781
|
+
SESSION_ID = generateSessionId();
|
|
782
|
+
void isDebugModeEnabled().then((enabled) => {
|
|
783
|
+
if (!enabled) return void 0;
|
|
784
|
+
return mkdir2(sessionDebugDir(), { recursive: true });
|
|
785
|
+
});
|
|
786
|
+
process.once("uncaughtException", (err) => {
|
|
787
|
+
void handleCrash().finally(() => {
|
|
788
|
+
throw err;
|
|
789
|
+
});
|
|
790
|
+
});
|
|
791
|
+
process.once("unhandledRejection", (reason) => {
|
|
792
|
+
void handleCrash().finally(() => {
|
|
793
|
+
throw reason;
|
|
794
|
+
});
|
|
795
|
+
});
|
|
796
|
+
process.once("SIGINT", () => {
|
|
797
|
+
void handleCrash().finally(() => {
|
|
798
|
+
process.exit(130);
|
|
799
|
+
});
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
|
|
354
804
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
355
|
-
import {
|
|
356
|
-
import {
|
|
805
|
+
import { useEffect as useEffect3 } from "react";
|
|
806
|
+
import { Box as Box5, Text as Text5, useInput as useInput5 } from "ink";
|
|
807
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
357
808
|
function HelpScreen({ onDone }) {
|
|
358
|
-
|
|
809
|
+
useEffect3(() => {
|
|
810
|
+
startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
|
|
811
|
+
}, []);
|
|
812
|
+
const leave = (exitMethod) => {
|
|
813
|
+
void finishDebugRun({ outputs: {}, status: "success", exitMethod });
|
|
814
|
+
onDone();
|
|
815
|
+
};
|
|
816
|
+
useInput5((input, key) => {
|
|
359
817
|
if (key.return) {
|
|
360
|
-
|
|
818
|
+
leave("saved");
|
|
361
819
|
return;
|
|
362
820
|
}
|
|
363
821
|
if (key.escape || input === "q") {
|
|
364
|
-
|
|
822
|
+
leave("discarded");
|
|
365
823
|
return;
|
|
366
824
|
}
|
|
367
825
|
});
|
|
368
|
-
return /* @__PURE__ */
|
|
369
|
-
/* @__PURE__ */
|
|
370
|
-
/* @__PURE__ */
|
|
371
|
-
/* @__PURE__ */
|
|
372
|
-
/* @__PURE__ */
|
|
373
|
-
/* @__PURE__ */
|
|
826
|
+
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
827
|
+
/* @__PURE__ */ jsx5(Text5, { bold: true, children: "Help" }),
|
|
828
|
+
/* @__PURE__ */ jsx5(Text5, { children: " " }),
|
|
829
|
+
/* @__PURE__ */ jsx5(Text5, { children: "This is a placeholder screen for v2 help content." }),
|
|
830
|
+
/* @__PURE__ */ jsx5(Text5, { children: " " }),
|
|
831
|
+
/* @__PURE__ */ jsx5(Text5, { dimColor: true, children: "[Enter] Complete [Esc/q] Exit \u2014 both return to Start" })
|
|
374
832
|
] });
|
|
375
833
|
}
|
|
376
834
|
var init_PageContainer2 = __esm({
|
|
377
835
|
"packages/experience-design-system-cli/src/tui/help/PageContainer.tsx"() {
|
|
378
836
|
"use strict";
|
|
837
|
+
init_debug_store();
|
|
379
838
|
}
|
|
380
839
|
});
|
|
381
840
|
|
|
382
841
|
// packages/experience-design-system-cli/src/tui/settings/PageContainer.tsx
|
|
383
|
-
import { useState as
|
|
384
|
-
import { Box as
|
|
385
|
-
import { jsx as
|
|
842
|
+
import { useState as useState5 } from "react";
|
|
843
|
+
import { Box as Box6, Text as Text6, useInput as useInput6 } from "ink";
|
|
844
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
386
845
|
function SettingsScreen({
|
|
387
846
|
onNavigate,
|
|
388
847
|
onBack
|
|
389
848
|
}) {
|
|
390
|
-
const [focusIdx, setFocusIdx] =
|
|
849
|
+
const [focusIdx, setFocusIdx] = useState5(0);
|
|
391
850
|
const items = [
|
|
392
851
|
{ label: "Configuration", screen: "settings-configuration" },
|
|
393
852
|
{ label: "Opt-in Analytics", screen: "settings-opt-in-analytics" },
|
|
394
853
|
{ label: "Debug Mode", screen: "settings-debug-mode" }
|
|
395
854
|
];
|
|
396
|
-
|
|
855
|
+
useInput6((input, key) => {
|
|
397
856
|
if (key.upArrow) {
|
|
398
857
|
setFocusIdx((i) => (i - 1 + items.length) % items.length);
|
|
399
858
|
return;
|
|
@@ -413,15 +872,15 @@ function SettingsScreen({
|
|
|
413
872
|
onBack();
|
|
414
873
|
}
|
|
415
874
|
});
|
|
416
|
-
return /* @__PURE__ */
|
|
417
|
-
/* @__PURE__ */
|
|
418
|
-
/* @__PURE__ */
|
|
419
|
-
items.map((item, i) => /* @__PURE__ */
|
|
875
|
+
return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
876
|
+
/* @__PURE__ */ jsx6(Text6, { bold: true, children: "Settings" }),
|
|
877
|
+
/* @__PURE__ */ jsx6(Text6, { children: " " }),
|
|
878
|
+
items.map((item, i) => /* @__PURE__ */ jsxs6(Text6, { color: i === focusIdx ? "cyan" : void 0, children: [
|
|
420
879
|
i === focusIdx ? "> " : " ",
|
|
421
880
|
item.label
|
|
422
881
|
] }, item.label)),
|
|
423
|
-
/* @__PURE__ */
|
|
424
|
-
/* @__PURE__ */
|
|
882
|
+
/* @__PURE__ */ jsx6(Text6, { children: " " }),
|
|
883
|
+
/* @__PURE__ */ jsx6(Text6, { dimColor: true, children: "[\u2191/\u2193] Navigate [Enter] Select [Esc/q] Back to Start" })
|
|
425
884
|
] });
|
|
426
885
|
}
|
|
427
886
|
var init_PageContainer3 = __esm({
|
|
@@ -431,27 +890,13 @@ var init_PageContainer3 = __esm({
|
|
|
431
890
|
});
|
|
432
891
|
|
|
433
892
|
// packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
|
|
434
|
-
|
|
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;
|
|
893
|
+
var readV1Store, writeV1Store;
|
|
451
894
|
var init_v1_store = __esm({
|
|
452
895
|
"packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts"() {
|
|
453
896
|
"use strict";
|
|
454
|
-
|
|
897
|
+
init_config();
|
|
898
|
+
readV1Store = readSettings;
|
|
899
|
+
writeV1Store = writeSettings;
|
|
455
900
|
}
|
|
456
901
|
});
|
|
457
902
|
|
|
@@ -462,7 +907,9 @@ async function readCredentials() {
|
|
|
462
907
|
spaceId: store.spaceId || "",
|
|
463
908
|
environmentId: store.environmentId || "",
|
|
464
909
|
cmaToken: store.cmaToken || "",
|
|
465
|
-
host: store.host || ""
|
|
910
|
+
host: store.host || "",
|
|
911
|
+
defaultComponentDir: store.defaultComponentDir || "",
|
|
912
|
+
defaultTokenFile: store.defaultTokenFile || ""
|
|
466
913
|
};
|
|
467
914
|
}
|
|
468
915
|
async function writeCredentials(config) {
|
|
@@ -484,18 +931,38 @@ var init_config_store = __esm({
|
|
|
484
931
|
});
|
|
485
932
|
|
|
486
933
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
487
|
-
import { useEffect as
|
|
488
|
-
import { Box as
|
|
489
|
-
import
|
|
934
|
+
import { useEffect as useEffect4, useState as useState6 } from "react";
|
|
935
|
+
import { Box as Box7, Text as Text7, useInput as useInput7 } from "ink";
|
|
936
|
+
import TextInput3 from "ink-text-input";
|
|
937
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
938
|
+
function debugFields(config) {
|
|
939
|
+
return {
|
|
940
|
+
space_id: config?.spaceId ?? "",
|
|
941
|
+
environment_id: config?.environmentId ?? "",
|
|
942
|
+
cma_token: config?.cmaToken ?? "",
|
|
943
|
+
host: config?.host ?? "",
|
|
944
|
+
default_component_dir: config?.defaultComponentDir ?? "",
|
|
945
|
+
default_token_file: config?.defaultTokenFile ?? ""
|
|
946
|
+
};
|
|
947
|
+
}
|
|
490
948
|
function ConfigurationScreen({ onDone }) {
|
|
491
|
-
const [stage, setStage] =
|
|
492
|
-
const [config, setConfig] =
|
|
493
|
-
const [activeField, setActiveField] =
|
|
494
|
-
const [
|
|
495
|
-
|
|
949
|
+
const [stage, setStage] = useState6("loading");
|
|
950
|
+
const [config, setConfig] = useState6(null);
|
|
951
|
+
const [activeField, setActiveField] = useState6("spaceId");
|
|
952
|
+
const [notice, setNotice] = useState6(null);
|
|
953
|
+
const [lastSaved, setLastSaved] = useState6(null);
|
|
954
|
+
const [editing, setEditing] = useState6(false);
|
|
955
|
+
const [valueBeforeEdit, setValueBeforeEdit] = useState6("");
|
|
956
|
+
useEffect4(() => {
|
|
496
957
|
readCredentials().then((cfg) => {
|
|
497
958
|
setConfig(cfg);
|
|
498
959
|
setStage("form");
|
|
960
|
+
startDebugRun({
|
|
961
|
+
flow: "settings/contentful-configuration",
|
|
962
|
+
step: "01-configuration",
|
|
963
|
+
menuOption: "Configuration",
|
|
964
|
+
inputs: debugFields(cfg)
|
|
965
|
+
});
|
|
499
966
|
});
|
|
500
967
|
}, []);
|
|
501
968
|
function fieldValue(field) {
|
|
@@ -505,29 +972,46 @@ function ConfigurationScreen({ onDone }) {
|
|
|
505
972
|
function setFieldValue(field, value) {
|
|
506
973
|
if (!config) return;
|
|
507
974
|
setConfig({ ...config, [field]: value });
|
|
975
|
+
setNotice(null);
|
|
508
976
|
}
|
|
509
977
|
function handleSave() {
|
|
510
978
|
if (!config) return;
|
|
511
979
|
setStage("saving");
|
|
512
|
-
|
|
980
|
+
setNotice(null);
|
|
513
981
|
writeCredentials(config).then(() => {
|
|
514
|
-
|
|
515
|
-
|
|
982
|
+
setLastSaved(config);
|
|
983
|
+
setNotice({ kind: "success", text: "Configuration saved" });
|
|
984
|
+
setStage("form");
|
|
516
985
|
}).catch((err) => {
|
|
517
|
-
|
|
986
|
+
setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
|
|
518
987
|
setStage("form");
|
|
519
988
|
});
|
|
520
989
|
}
|
|
521
|
-
|
|
990
|
+
function quit() {
|
|
991
|
+
void finishDebugRun(
|
|
992
|
+
lastSaved ? { outputs: debugFields(lastSaved), status: "success", exitMethod: "saved" } : { outputs: {}, status: "success", exitMethod: "discarded" }
|
|
993
|
+
);
|
|
994
|
+
onDone();
|
|
995
|
+
}
|
|
996
|
+
useInput7((input, key) => {
|
|
522
997
|
if (stage === "loading" || stage === "saving") return;
|
|
523
|
-
if (
|
|
524
|
-
if (key.
|
|
525
|
-
|
|
998
|
+
if (editing) {
|
|
999
|
+
if (key.escape) {
|
|
1000
|
+
setFieldValue(activeField, valueBeforeEdit);
|
|
1001
|
+
setEditing(false);
|
|
526
1002
|
}
|
|
527
1003
|
return;
|
|
528
1004
|
}
|
|
529
1005
|
if (key.escape || input === "q") {
|
|
530
|
-
|
|
1006
|
+
quit();
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
if (input === "s") {
|
|
1010
|
+
handleSave();
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
if (input === "c") {
|
|
1014
|
+
setFieldValue(activeField, "");
|
|
531
1015
|
return;
|
|
532
1016
|
}
|
|
533
1017
|
if (key.tab || key.downArrow) {
|
|
@@ -541,69 +1025,51 @@ function ConfigurationScreen({ onDone }) {
|
|
|
541
1025
|
return;
|
|
542
1026
|
}
|
|
543
1027
|
if (key.return) {
|
|
544
|
-
|
|
545
|
-
|
|
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);
|
|
1028
|
+
setValueBeforeEdit(fieldValue(activeField));
|
|
1029
|
+
setEditing(true);
|
|
559
1030
|
}
|
|
560
1031
|
});
|
|
561
1032
|
if (stage === "loading") {
|
|
562
|
-
return /* @__PURE__ */
|
|
563
|
-
/* @__PURE__ */
|
|
564
|
-
/* @__PURE__ */
|
|
565
|
-
/* @__PURE__ */
|
|
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" })
|
|
1033
|
+
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1034
|
+
/* @__PURE__ */ jsx7(Text7, { bold: true, children: "Configuration" }),
|
|
1035
|
+
/* @__PURE__ */ jsx7(Text7, { children: " " }),
|
|
1036
|
+
/* @__PURE__ */ jsx7(Text7, { color: PALETTE.accent, children: "Loading..." })
|
|
578
1037
|
] });
|
|
579
1038
|
}
|
|
580
|
-
return /* @__PURE__ */
|
|
581
|
-
/* @__PURE__ */
|
|
582
|
-
/* @__PURE__ */
|
|
583
|
-
/* @__PURE__ */
|
|
584
|
-
/* @__PURE__ */ jsx5(Text5, { children: " " }),
|
|
585
|
-
/* @__PURE__ */ jsx5(Box5, { flexDirection: "column", children: FIELD_ORDER.map((field) => {
|
|
1039
|
+
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1040
|
+
/* @__PURE__ */ jsx7(Text7, { bold: true, children: "Configuration" }),
|
|
1041
|
+
/* @__PURE__ */ jsx7(Text7, { children: " " }),
|
|
1042
|
+
/* @__PURE__ */ jsx7(Box7, { flexDirection: "column", children: FIELD_ORDER.map((field) => {
|
|
586
1043
|
const isActive = activeField === field;
|
|
587
1044
|
const value = fieldValue(field);
|
|
588
1045
|
const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
|
|
589
|
-
return /* @__PURE__ */
|
|
590
|
-
/* @__PURE__ */
|
|
591
|
-
/* @__PURE__ */
|
|
1046
|
+
return /* @__PURE__ */ jsxs7(Box7, { gap: 1, children: [
|
|
1047
|
+
/* @__PURE__ */ jsx7(Text7, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
|
|
1048
|
+
/* @__PURE__ */ jsxs7(Text7, { bold: isActive, children: [
|
|
592
1049
|
FIELD_LABELS[field],
|
|
593
1050
|
":"
|
|
594
1051
|
] }),
|
|
595
|
-
|
|
1052
|
+
isActive && editing ? /* @__PURE__ */ jsx7(
|
|
1053
|
+
TextInput3,
|
|
1054
|
+
{
|
|
1055
|
+
value,
|
|
1056
|
+
onChange: (next) => setFieldValue(field, next),
|
|
1057
|
+
onSubmit: () => setEditing(false),
|
|
1058
|
+
mask: field === "cmaToken" ? "\u2022" : void 0
|
|
1059
|
+
}
|
|
1060
|
+
) : /* @__PURE__ */ jsx7(Text7, { children: display || /* @__PURE__ */ jsx7(Text7, { dimColor: true, children: "(empty)" }) })
|
|
596
1061
|
] }, field);
|
|
597
1062
|
}) }),
|
|
598
|
-
|
|
599
|
-
/* @__PURE__ */
|
|
600
|
-
/* @__PURE__ */
|
|
601
|
-
"\
|
|
602
|
-
|
|
1063
|
+
notice && /* @__PURE__ */ jsxs7(Fragment, { children: [
|
|
1064
|
+
/* @__PURE__ */ jsx7(Text7, { children: " " }),
|
|
1065
|
+
/* @__PURE__ */ jsxs7(Text7, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
|
|
1066
|
+
notice.kind === "success" ? "\u2713" : "\u2717",
|
|
1067
|
+
" ",
|
|
1068
|
+
notice.text
|
|
603
1069
|
] })
|
|
604
1070
|
] }),
|
|
605
|
-
/* @__PURE__ */
|
|
606
|
-
/* @__PURE__ */
|
|
1071
|
+
/* @__PURE__ */ jsx7(Text7, { children: " " }),
|
|
1072
|
+
/* @__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
1073
|
] });
|
|
608
1074
|
}
|
|
609
1075
|
var FIELD_ORDER, FIELD_LABELS;
|
|
@@ -612,12 +1078,22 @@ var init_ContentfulConfigScreen = __esm({
|
|
|
612
1078
|
"use strict";
|
|
613
1079
|
init_home_theme();
|
|
614
1080
|
init_config_store();
|
|
615
|
-
|
|
1081
|
+
init_debug_store();
|
|
1082
|
+
FIELD_ORDER = [
|
|
1083
|
+
"spaceId",
|
|
1084
|
+
"environmentId",
|
|
1085
|
+
"cmaToken",
|
|
1086
|
+
"host",
|
|
1087
|
+
"defaultComponentDir",
|
|
1088
|
+
"defaultTokenFile"
|
|
1089
|
+
];
|
|
616
1090
|
FIELD_LABELS = {
|
|
617
1091
|
spaceId: "Space ID",
|
|
618
1092
|
environmentId: "Environment ID",
|
|
619
1093
|
cmaToken: "CMA Token",
|
|
620
|
-
host: "API Host (optional)"
|
|
1094
|
+
host: "API Host (optional)",
|
|
1095
|
+
defaultComponentDir: "Default component directory (optional)",
|
|
1096
|
+
defaultTokenFile: "Default token file (optional)"
|
|
621
1097
|
};
|
|
622
1098
|
}
|
|
623
1099
|
});
|
|
@@ -644,19 +1120,25 @@ var init_analytics_store = __esm({
|
|
|
644
1120
|
});
|
|
645
1121
|
|
|
646
1122
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
647
|
-
import { useEffect as
|
|
648
|
-
import { Box as
|
|
649
|
-
import { Fragment as Fragment2, jsx as
|
|
1123
|
+
import { useEffect as useEffect5, useState as useState7 } from "react";
|
|
1124
|
+
import { Box as Box8, Text as Text8, useInput as useInput8 } from "ink";
|
|
1125
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
650
1126
|
function OptInAnalyticsScreen({ onDone }) {
|
|
651
|
-
const [loading, setLoading] =
|
|
652
|
-
const [enabled, setEnabled] =
|
|
653
|
-
|
|
1127
|
+
const [loading, setLoading] = useState7(true);
|
|
1128
|
+
const [enabled, setEnabled] = useState7(true);
|
|
1129
|
+
useEffect5(() => {
|
|
654
1130
|
readAnalyticsSetting().then((setting) => {
|
|
655
1131
|
setEnabled(setting.enabled);
|
|
656
1132
|
setLoading(false);
|
|
1133
|
+
startDebugRun({
|
|
1134
|
+
flow: "settings/opt-in-analytics",
|
|
1135
|
+
step: "01-opt-in-analytics",
|
|
1136
|
+
menuOption: "Opt-in Analytics",
|
|
1137
|
+
inputs: { enabled: setting.enabled }
|
|
1138
|
+
});
|
|
657
1139
|
});
|
|
658
1140
|
}, []);
|
|
659
|
-
|
|
1141
|
+
useInput8((input, key) => {
|
|
660
1142
|
if (loading) return;
|
|
661
1143
|
if (key.return || input === " ") {
|
|
662
1144
|
setEnabled((current) => {
|
|
@@ -667,225 +1149,43 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
667
1149
|
return;
|
|
668
1150
|
}
|
|
669
1151
|
if (key.escape || input === "q") {
|
|
1152
|
+
void finishDebugRun({ outputs: { enabled }, status: "success", exitMethod: "saved" });
|
|
670
1153
|
onDone();
|
|
671
1154
|
}
|
|
672
1155
|
});
|
|
673
|
-
return /* @__PURE__ */
|
|
674
|
-
/* @__PURE__ */
|
|
675
|
-
/* @__PURE__ */
|
|
676
|
-
loading ? /* @__PURE__ */
|
|
677
|
-
/* @__PURE__ */
|
|
1156
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1157
|
+
/* @__PURE__ */ jsx8(Text8, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
|
|
1158
|
+
/* @__PURE__ */ jsx8(Text8, { children: " " }),
|
|
1159
|
+
loading ? /* @__PURE__ */ jsx8(Text8, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs8(Fragment2, { children: [
|
|
1160
|
+
/* @__PURE__ */ jsxs8(Text8, { children: [
|
|
678
1161
|
"Share anonymous usage data:",
|
|
679
1162
|
" ",
|
|
680
|
-
/* @__PURE__ */
|
|
1163
|
+
/* @__PURE__ */ jsx8(Text8, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
681
1164
|
] }),
|
|
682
|
-
/* @__PURE__ */
|
|
683
|
-
/* @__PURE__ */
|
|
684
|
-
/* @__PURE__ */
|
|
1165
|
+
/* @__PURE__ */ jsx8(Text8, { children: " " }),
|
|
1166
|
+
/* @__PURE__ */ jsx8(Text8, { dimColor: true, children: "Shares which CLI commands are used and where imports succeed or fail." }),
|
|
1167
|
+
/* @__PURE__ */ jsx8(Text8, { dimColor: true, children: "Never includes source code, file paths, credentials, or authored content." })
|
|
685
1168
|
] }),
|
|
686
|
-
/* @__PURE__ */
|
|
687
|
-
/* @__PURE__ */
|
|
1169
|
+
/* @__PURE__ */ jsx8(Text8, { children: " " }),
|
|
1170
|
+
/* @__PURE__ */ jsx8(Text8, { dimColor: true, children: "[Enter/Space] Toggle [Esc/q] Back to Settings" })
|
|
688
1171
|
] });
|
|
689
1172
|
}
|
|
690
|
-
var
|
|
1173
|
+
var init_screen3 = __esm({
|
|
691
1174
|
"packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx"() {
|
|
692
1175
|
"use strict";
|
|
693
1176
|
init_home_theme();
|
|
694
1177
|
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
|
-
});
|
|
1178
|
+
init_debug_store();
|
|
879
1179
|
}
|
|
880
1180
|
});
|
|
881
1181
|
|
|
882
1182
|
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
883
|
-
import { useEffect as
|
|
884
|
-
import { Box as
|
|
885
|
-
import { jsx as
|
|
1183
|
+
import { useEffect as useEffect6, useState as useState8 } from "react";
|
|
1184
|
+
import { Box as Box9, Text as Text9, useInput as useInput9 } from "ink";
|
|
1185
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
886
1186
|
function UpgradeScreen({ onDone }) {
|
|
887
|
-
const [upgradeCheck, setUpgradeCheck] =
|
|
888
|
-
|
|
1187
|
+
const [upgradeCheck, setUpgradeCheck] = useState8();
|
|
1188
|
+
useEffect6(() => {
|
|
889
1189
|
startDebugRun({
|
|
890
1190
|
flow: "upgrade",
|
|
891
1191
|
step: "01-upgrade",
|
|
@@ -894,7 +1194,7 @@ function UpgradeScreen({ onDone }) {
|
|
|
894
1194
|
});
|
|
895
1195
|
checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
|
|
896
1196
|
}, []);
|
|
897
|
-
|
|
1197
|
+
useInput9((_input, key) => {
|
|
898
1198
|
if (key.return) {
|
|
899
1199
|
void finishDebugRun({
|
|
900
1200
|
outputs: upgradeCheck ?? {},
|
|
@@ -905,12 +1205,12 @@ function UpgradeScreen({ onDone }) {
|
|
|
905
1205
|
return;
|
|
906
1206
|
}
|
|
907
1207
|
});
|
|
908
|
-
return /* @__PURE__ */
|
|
909
|
-
/* @__PURE__ */
|
|
910
|
-
/* @__PURE__ */
|
|
1208
|
+
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1209
|
+
/* @__PURE__ */ jsx9(Text9, { bold: true, children: "Upgrade" }),
|
|
1210
|
+
/* @__PURE__ */ jsx9(Text9, { children: " " }),
|
|
911
1211
|
renderBody(upgradeCheck),
|
|
912
|
-
/* @__PURE__ */
|
|
913
|
-
/* @__PURE__ */
|
|
1212
|
+
/* @__PURE__ */ jsx9(Text9, { children: " " }),
|
|
1213
|
+
/* @__PURE__ */ jsxs9(Text9, { bold: true, color: PALETTE.accent, children: [
|
|
914
1214
|
FOCUS_MARKER,
|
|
915
1215
|
" Go Back"
|
|
916
1216
|
] })
|
|
@@ -918,34 +1218,34 @@ function UpgradeScreen({ onDone }) {
|
|
|
918
1218
|
}
|
|
919
1219
|
function renderBody(upgradeCheck) {
|
|
920
1220
|
if (!upgradeCheck) {
|
|
921
|
-
return /* @__PURE__ */
|
|
1221
|
+
return /* @__PURE__ */ jsx9(Text9, { color: PALETTE.muted, children: "Checking for updates\u2026" });
|
|
922
1222
|
}
|
|
923
1223
|
if (upgradeCheck.status === "error") {
|
|
924
|
-
return /* @__PURE__ */
|
|
1224
|
+
return /* @__PURE__ */ jsx9(Text9, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
|
|
925
1225
|
}
|
|
926
1226
|
if (upgradeCheck.status === "up-to-date") {
|
|
927
|
-
return /* @__PURE__ */
|
|
1227
|
+
return /* @__PURE__ */ jsxs9(Text9, { color: PALETTE.success, children: [
|
|
928
1228
|
"You're already on the latest version (v",
|
|
929
1229
|
upgradeCheck.current,
|
|
930
1230
|
")."
|
|
931
1231
|
] });
|
|
932
1232
|
}
|
|
933
|
-
return /* @__PURE__ */
|
|
934
|
-
/* @__PURE__ */
|
|
935
|
-
/* @__PURE__ */
|
|
1233
|
+
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", children: [
|
|
1234
|
+
/* @__PURE__ */ jsxs9(Text9, { color: PALETTE.muted, children: [
|
|
1235
|
+
/* @__PURE__ */ jsxs9(Text9, { bold: true, color: PALETTE.success, children: [
|
|
936
1236
|
"v",
|
|
937
1237
|
upgradeCheck.latest
|
|
938
1238
|
] }),
|
|
939
1239
|
" ",
|
|
940
1240
|
"is available (you're on ",
|
|
941
|
-
/* @__PURE__ */
|
|
1241
|
+
/* @__PURE__ */ jsxs9(Text9, { bold: true, children: [
|
|
942
1242
|
"v",
|
|
943
1243
|
upgradeCheck.current
|
|
944
1244
|
] }),
|
|
945
1245
|
"). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
|
|
946
1246
|
] }),
|
|
947
|
-
/* @__PURE__ */
|
|
948
|
-
/* @__PURE__ */
|
|
1247
|
+
/* @__PURE__ */ jsx9(Text9, { children: " " }),
|
|
1248
|
+
/* @__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
1249
|
] });
|
|
950
1250
|
}
|
|
951
1251
|
var UPGRADE_COMMANDS;
|
|
@@ -960,19 +1260,25 @@ var init_PageContainer4 = __esm({
|
|
|
960
1260
|
});
|
|
961
1261
|
|
|
962
1262
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
963
|
-
import { useEffect as
|
|
964
|
-
import { Box as
|
|
965
|
-
import { jsx as
|
|
1263
|
+
import { useEffect as useEffect7, useState as useState9 } from "react";
|
|
1264
|
+
import { Box as Box10, Text as Text10, useInput as useInput10 } from "ink";
|
|
1265
|
+
import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
966
1266
|
function DebugModeScreen({ onDone }) {
|
|
967
|
-
const [loading, setLoading] =
|
|
968
|
-
const [enabled, setEnabled] =
|
|
969
|
-
|
|
1267
|
+
const [loading, setLoading] = useState9(true);
|
|
1268
|
+
const [enabled, setEnabled] = useState9(true);
|
|
1269
|
+
useEffect7(() => {
|
|
970
1270
|
readDebugModeSetting().then((setting) => {
|
|
971
1271
|
setEnabled(setting.enabled);
|
|
972
1272
|
setLoading(false);
|
|
1273
|
+
startDebugRun({
|
|
1274
|
+
flow: "settings/debug-mode",
|
|
1275
|
+
step: "01-debug-mode",
|
|
1276
|
+
menuOption: "Debug Mode",
|
|
1277
|
+
inputs: { enabled: setting.enabled }
|
|
1278
|
+
});
|
|
973
1279
|
});
|
|
974
1280
|
}, []);
|
|
975
|
-
|
|
1281
|
+
useInput10((input, key) => {
|
|
976
1282
|
if (loading) return;
|
|
977
1283
|
if (key.return || input === " ") {
|
|
978
1284
|
setEnabled((current) => {
|
|
@@ -983,26 +1289,28 @@ function DebugModeScreen({ onDone }) {
|
|
|
983
1289
|
return;
|
|
984
1290
|
}
|
|
985
1291
|
if (key.escape || input === "q") {
|
|
1292
|
+
void finishDebugRun({ outputs: { enabled }, status: "success", exitMethod: "saved" });
|
|
986
1293
|
onDone();
|
|
987
1294
|
}
|
|
988
1295
|
});
|
|
989
|
-
return /* @__PURE__ */
|
|
990
|
-
/* @__PURE__ */
|
|
991
|
-
/* @__PURE__ */
|
|
992
|
-
loading ? /* @__PURE__ */
|
|
1296
|
+
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1297
|
+
/* @__PURE__ */ jsx10(Text10, { bold: true, children: "Settings \u203A Debug Mode" }),
|
|
1298
|
+
/* @__PURE__ */ jsx10(Text10, { children: " " }),
|
|
1299
|
+
loading ? /* @__PURE__ */ jsx10(Text10, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs10(Text10, { children: [
|
|
993
1300
|
"Debug logging:",
|
|
994
1301
|
" ",
|
|
995
|
-
/* @__PURE__ */
|
|
1302
|
+
/* @__PURE__ */ jsx10(Text10, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
996
1303
|
] }),
|
|
997
|
-
/* @__PURE__ */
|
|
998
|
-
/* @__PURE__ */
|
|
1304
|
+
/* @__PURE__ */ jsx10(Text10, { children: " " }),
|
|
1305
|
+
/* @__PURE__ */ jsx10(Text10, { dimColor: true, children: "[Enter/Space] Toggle [Esc/q] Back to Settings" })
|
|
999
1306
|
] });
|
|
1000
1307
|
}
|
|
1001
|
-
var
|
|
1308
|
+
var init_screen4 = __esm({
|
|
1002
1309
|
"packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx"() {
|
|
1003
1310
|
"use strict";
|
|
1004
1311
|
init_home_theme();
|
|
1005
1312
|
init_debug_mode_store();
|
|
1313
|
+
init_debug_store();
|
|
1006
1314
|
}
|
|
1007
1315
|
});
|
|
1008
1316
|
|
|
@@ -1011,48 +1319,75 @@ var app_exports = {};
|
|
|
1011
1319
|
__export(app_exports, {
|
|
1012
1320
|
runApp: () => runApp
|
|
1013
1321
|
});
|
|
1014
|
-
import { useState as
|
|
1015
|
-
import { jsx as
|
|
1322
|
+
import { useEffect as useEffect8, useState as useState10 } from "react";
|
|
1323
|
+
import { Fragment as Fragment3, jsx as jsx11 } from "react/jsx-runtime";
|
|
1016
1324
|
function App({ onLaunchImport, importExitCode }) {
|
|
1017
1325
|
const returnedFromImport = importExitCode !== void 0;
|
|
1018
|
-
const [screen, setScreen] =
|
|
1019
|
-
const
|
|
1020
|
-
const
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1023
|
-
|
|
1326
|
+
const [screen, setScreen] = useState10(returnedFromImport ? "import" : "start");
|
|
1327
|
+
const [showImportResult, setShowImportResult] = useState10(returnedFromImport);
|
|
1328
|
+
const [projectPath, setProjectPath] = useState10();
|
|
1329
|
+
const [importDefaults, setImportDefaults] = useState10();
|
|
1330
|
+
useEffect8(() => {
|
|
1331
|
+
if (screen !== "import") {
|
|
1332
|
+
setImportDefaults(void 0);
|
|
1024
1333
|
return;
|
|
1025
1334
|
}
|
|
1026
|
-
|
|
1335
|
+
void readCredentials().then(
|
|
1336
|
+
(saved) => setImportDefaults({ componentDir: saved.defaultComponentDir ?? "", tokenFile: saved.defaultTokenFile ?? "" })
|
|
1337
|
+
);
|
|
1338
|
+
}, [screen]);
|
|
1339
|
+
const goToStart = () => setScreen("start");
|
|
1340
|
+
const goToSettings = () => setScreen("settings");
|
|
1341
|
+
const finishImportResult = () => {
|
|
1342
|
+
setShowImportResult(false);
|
|
1343
|
+
setProjectPath(void 0);
|
|
1344
|
+
goToStart();
|
|
1345
|
+
};
|
|
1346
|
+
const leaveImport = () => {
|
|
1347
|
+
setProjectPath(void 0);
|
|
1348
|
+
goToStart();
|
|
1027
1349
|
};
|
|
1028
1350
|
switch (screen) {
|
|
1029
1351
|
case "import":
|
|
1030
|
-
return /* @__PURE__ */
|
|
1352
|
+
if (showImportResult) return /* @__PURE__ */ jsx11(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
|
|
1353
|
+
if (importDefaults === void 0) return /* @__PURE__ */ jsx11(Fragment3, {});
|
|
1354
|
+
if (projectPath === void 0) {
|
|
1355
|
+
return /* @__PURE__ */ jsx11(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
|
|
1356
|
+
}
|
|
1357
|
+
return /* @__PURE__ */ jsx11(
|
|
1358
|
+
TokenInputScreen,
|
|
1359
|
+
{
|
|
1360
|
+
initialPath: importDefaults.tokenFile,
|
|
1361
|
+
onConfirm: (tokens) => onLaunchImport?.({ project: projectPath, tokens }),
|
|
1362
|
+
onSkip: () => onLaunchImport?.({ project: projectPath }),
|
|
1363
|
+
onBack: () => setProjectPath(void 0)
|
|
1364
|
+
}
|
|
1365
|
+
);
|
|
1031
1366
|
case "help":
|
|
1032
|
-
return /* @__PURE__ */
|
|
1367
|
+
return /* @__PURE__ */ jsx11(HelpScreen, { onDone: goToStart });
|
|
1033
1368
|
case "upgrade":
|
|
1034
|
-
return /* @__PURE__ */
|
|
1369
|
+
return /* @__PURE__ */ jsx11(UpgradeScreen, { onDone: goToStart });
|
|
1035
1370
|
case "settings":
|
|
1036
|
-
return /* @__PURE__ */
|
|
1371
|
+
return /* @__PURE__ */ jsx11(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
|
|
1037
1372
|
case "settings-configuration":
|
|
1038
|
-
return /* @__PURE__ */
|
|
1373
|
+
return /* @__PURE__ */ jsx11(ConfigurationScreen, { onDone: goToSettings });
|
|
1039
1374
|
case "settings-opt-in-analytics":
|
|
1040
|
-
return /* @__PURE__ */
|
|
1375
|
+
return /* @__PURE__ */ jsx11(OptInAnalyticsScreen, { onDone: goToSettings });
|
|
1041
1376
|
case "settings-debug-mode":
|
|
1042
|
-
return /* @__PURE__ */
|
|
1377
|
+
return /* @__PURE__ */ jsx11(DebugModeScreen, { onDone: goToSettings });
|
|
1043
1378
|
case "start":
|
|
1044
|
-
return /* @__PURE__ */
|
|
1379
|
+
return /* @__PURE__ */ jsx11(HomeScreen, { onNavigate: setScreen });
|
|
1045
1380
|
}
|
|
1046
1381
|
}
|
|
1047
1382
|
async function renderUntilImportRequestedOrExit(renderApp, importExitCode) {
|
|
1048
|
-
let
|
|
1383
|
+
let requestedImport;
|
|
1049
1384
|
const instance = renderApp(
|
|
1050
|
-
/* @__PURE__ */
|
|
1385
|
+
/* @__PURE__ */ jsx11(
|
|
1051
1386
|
App,
|
|
1052
1387
|
{
|
|
1053
1388
|
importExitCode,
|
|
1054
|
-
onLaunchImport: () => {
|
|
1055
|
-
|
|
1389
|
+
onLaunchImport: (options) => {
|
|
1390
|
+
requestedImport = options;
|
|
1056
1391
|
instance.unmount();
|
|
1057
1392
|
}
|
|
1058
1393
|
}
|
|
@@ -1060,13 +1395,15 @@ async function renderUntilImportRequestedOrExit(renderApp, importExitCode) {
|
|
|
1060
1395
|
);
|
|
1061
1396
|
await instance.waitUntilExit();
|
|
1062
1397
|
await stopReadingTerminal();
|
|
1063
|
-
return
|
|
1398
|
+
return requestedImport;
|
|
1064
1399
|
}
|
|
1065
1400
|
async function runApp(renderApp) {
|
|
1066
1401
|
let importExitCode;
|
|
1067
|
-
|
|
1068
|
-
|
|
1402
|
+
let requestedImport = await renderUntilImportRequestedOrExit(renderApp, importExitCode);
|
|
1403
|
+
while (requestedImport !== void 0) {
|
|
1404
|
+
importExitCode = (await spawnV1Import(requestedImport)).exitCode;
|
|
1069
1405
|
startReadingTerminal();
|
|
1406
|
+
requestedImport = await renderUntilImportRequestedOrExit(renderApp, importExitCode);
|
|
1070
1407
|
}
|
|
1071
1408
|
}
|
|
1072
1409
|
var init_app = __esm({
|
|
@@ -1074,14 +1411,16 @@ var init_app = __esm({
|
|
|
1074
1411
|
"use strict";
|
|
1075
1412
|
init_home();
|
|
1076
1413
|
init_PageContainer();
|
|
1414
|
+
init_steps();
|
|
1077
1415
|
init_spawn_v1_import();
|
|
1078
1416
|
init_terminal_input();
|
|
1079
1417
|
init_PageContainer2();
|
|
1080
1418
|
init_PageContainer3();
|
|
1081
1419
|
init_ContentfulConfigScreen();
|
|
1082
|
-
|
|
1420
|
+
init_screen3();
|
|
1083
1421
|
init_PageContainer4();
|
|
1084
|
-
|
|
1422
|
+
init_screen4();
|
|
1423
|
+
init_config_store();
|
|
1085
1424
|
}
|
|
1086
1425
|
});
|
|
1087
1426
|
|
|
@@ -1160,7 +1499,51 @@ function createProgram() {
|
|
|
1160
1499
|
return program;
|
|
1161
1500
|
}
|
|
1162
1501
|
|
|
1502
|
+
// packages/experience-design-system-cli/src/config/migrate.ts
|
|
1503
|
+
init_config();
|
|
1504
|
+
init_package_root();
|
|
1505
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
1506
|
+
import { mkdir as mkdir3, readFile as readFile2, rename as rename2, rmdir, unlink } from "node:fs/promises";
|
|
1507
|
+
import { dirname as dirname3, join as join6 } from "node:path";
|
|
1508
|
+
var PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
|
|
1509
|
+
async function readJson(path) {
|
|
1510
|
+
try {
|
|
1511
|
+
return JSON.parse(await readFile2(path, "utf8"));
|
|
1512
|
+
} catch {
|
|
1513
|
+
return void 0;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
async function migrateOldConfig() {
|
|
1517
|
+
try {
|
|
1518
|
+
const oldCredentials = join6(oldConfigDir(), "credentials.json");
|
|
1519
|
+
const oldRuns = join6(oldConfigDir(), "runs.json");
|
|
1520
|
+
const oldDebugMode = join6(
|
|
1521
|
+
findPackageRoot(import.meta.url, PACKAGE_NAME3),
|
|
1522
|
+
".contentful",
|
|
1523
|
+
"config",
|
|
1524
|
+
"debug_mode.json"
|
|
1525
|
+
);
|
|
1526
|
+
const migrated = {};
|
|
1527
|
+
const debugMode = await readJson(oldDebugMode);
|
|
1528
|
+
if (debugMode) migrated["debugMode"] = debugMode;
|
|
1529
|
+
Object.assign(migrated, await readJson(oldCredentials));
|
|
1530
|
+
if (Object.keys(migrated).length > 0) await updateSettings({ ...migrated, ...await readSettings() });
|
|
1531
|
+
if (existsSync4(oldRuns)) {
|
|
1532
|
+
if (!existsSync4(runsFilePath())) {
|
|
1533
|
+
await mkdir3(dirname3(runsFilePath()), { recursive: true });
|
|
1534
|
+
await rename2(oldRuns, runsFilePath());
|
|
1535
|
+
} else {
|
|
1536
|
+
await unlink(oldRuns);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
await Promise.all([oldCredentials, oldDebugMode].map((f) => unlink(f).catch(() => void 0)));
|
|
1540
|
+
await rmdir(oldConfigDir()).catch(() => void 0);
|
|
1541
|
+
} catch {
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1163
1545
|
// packages/experience-design-system-cli/index.ts
|
|
1546
|
+
await migrateOldConfig();
|
|
1164
1547
|
createProgram().parseAsync().catch((err) => {
|
|
1165
1548
|
process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
|
|
1166
1549
|
`);
|