@contentful/experience-design-system-cli 2.36.2-dev-build-3b8c3735.0 → 2.36.2-dev-build-d983d04c.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 +357 -633
- package/dist/index.js +373 -756
- package/dist/package.json +1 -2
- package/dist/src/tui/import/spawn-v1-import.d.ts +0 -1
- package/dist/src/tui/settings/contentful-configuration/config-store.d.ts +0 -2
- package/dist/src/tui/settings/utils/v1-store.d.ts +2 -3
- package/legacy/dist/src/analyze/select/tui/theme.d.ts +0 -3
- package/legacy/dist/src/import/tui/steps/DoneStep.d.ts +1 -1
- package/legacy/dist/src/import/tui/steps/RunningStep.d.ts +1 -9
- package/legacy/dist/src/index.js +7618 -8648
- package/legacy/dist/src/runs/store.d.ts +2 -2
- package/legacy/dist/src/tui/use-timed-spinner.d.ts +2 -1
- package/legacy/package.json +1 -2
- package/package.json +2 -3
- package/dist/src/config/migrate.d.ts +0 -1
- package/dist/src/tui/import/steps/01-welcome/controls.d.ts +0 -8
- package/dist/src/tui/import/steps/01-welcome/logic.d.ts +0 -8
- package/dist/src/tui/import/steps/01-welcome/screen.d.ts +0 -8
- package/dist/src/tui/import/steps/02-token-input/controls.d.ts +0 -11
- package/dist/src/tui/import/steps/02-token-input/logic.d.ts +0 -9
- package/dist/src/tui/import/steps/02-token-input/screen.d.ts +0 -9
- package/dist/src/tui/import/steps/02-token-input/validate-path.d.ts +0 -12
- package/dist/src/tui/import/steps/index.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -297,250 +297,6 @@ 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
|
-
|
|
544
300
|
// packages/experience-design-system-cli/src/tui/import/spawn-v1-import.ts
|
|
545
301
|
import { spawn as spawn2 } from "node:child_process";
|
|
546
302
|
function buildArgs(options) {
|
|
@@ -548,9 +304,6 @@ function buildArgs(options) {
|
|
|
548
304
|
if (options.project) {
|
|
549
305
|
args.push("--project", options.project);
|
|
550
306
|
}
|
|
551
|
-
if (options.tokens) {
|
|
552
|
-
args.push("--tokens", options.tokens);
|
|
553
|
-
}
|
|
554
307
|
return args;
|
|
555
308
|
}
|
|
556
309
|
async function spawnV1Import(options = {}) {
|
|
@@ -580,7 +333,7 @@ function getTerminalHandle() {
|
|
|
580
333
|
return process.stdin._handle;
|
|
581
334
|
}
|
|
582
335
|
async function stopReadingTerminal() {
|
|
583
|
-
await new Promise((
|
|
336
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
584
337
|
const handle = getTerminalHandle();
|
|
585
338
|
if (!handle?.readStop) return;
|
|
586
339
|
handle.reading = false;
|
|
@@ -598,261 +351,49 @@ var init_terminal_input = __esm({
|
|
|
598
351
|
}
|
|
599
352
|
});
|
|
600
353
|
|
|
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
|
-
|
|
804
354
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
805
|
-
import {
|
|
806
|
-
import {
|
|
807
|
-
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
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";
|
|
808
357
|
function HelpScreen({ onDone }) {
|
|
809
|
-
|
|
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) => {
|
|
358
|
+
useInput3((input, key) => {
|
|
817
359
|
if (key.return) {
|
|
818
|
-
|
|
360
|
+
onDone();
|
|
819
361
|
return;
|
|
820
362
|
}
|
|
821
363
|
if (key.escape || input === "q") {
|
|
822
|
-
|
|
364
|
+
onDone();
|
|
823
365
|
return;
|
|
824
366
|
}
|
|
825
367
|
});
|
|
826
|
-
return /* @__PURE__ */
|
|
827
|
-
/* @__PURE__ */
|
|
828
|
-
/* @__PURE__ */
|
|
829
|
-
/* @__PURE__ */
|
|
830
|
-
/* @__PURE__ */
|
|
831
|
-
/* @__PURE__ */
|
|
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" })
|
|
832
374
|
] });
|
|
833
375
|
}
|
|
834
376
|
var init_PageContainer2 = __esm({
|
|
835
377
|
"packages/experience-design-system-cli/src/tui/help/PageContainer.tsx"() {
|
|
836
378
|
"use strict";
|
|
837
|
-
init_debug_store();
|
|
838
379
|
}
|
|
839
380
|
});
|
|
840
381
|
|
|
841
382
|
// packages/experience-design-system-cli/src/tui/settings/PageContainer.tsx
|
|
842
|
-
import { useState as
|
|
843
|
-
import { Box as
|
|
844
|
-
import { jsx as
|
|
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";
|
|
845
386
|
function SettingsScreen({
|
|
846
387
|
onNavigate,
|
|
847
388
|
onBack
|
|
848
389
|
}) {
|
|
849
|
-
const [focusIdx, setFocusIdx] =
|
|
390
|
+
const [focusIdx, setFocusIdx] = useState3(0);
|
|
850
391
|
const items = [
|
|
851
392
|
{ label: "Configuration", screen: "settings-configuration" },
|
|
852
393
|
{ label: "Opt-in Analytics", screen: "settings-opt-in-analytics" },
|
|
853
394
|
{ label: "Debug Mode", screen: "settings-debug-mode" }
|
|
854
395
|
];
|
|
855
|
-
|
|
396
|
+
useInput4((input, key) => {
|
|
856
397
|
if (key.upArrow) {
|
|
857
398
|
setFocusIdx((i) => (i - 1 + items.length) % items.length);
|
|
858
399
|
return;
|
|
@@ -872,15 +413,15 @@ function SettingsScreen({
|
|
|
872
413
|
onBack();
|
|
873
414
|
}
|
|
874
415
|
});
|
|
875
|
-
return /* @__PURE__ */
|
|
876
|
-
/* @__PURE__ */
|
|
877
|
-
/* @__PURE__ */
|
|
878
|
-
items.map((item, i) => /* @__PURE__ */
|
|
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: [
|
|
879
420
|
i === focusIdx ? "> " : " ",
|
|
880
421
|
item.label
|
|
881
422
|
] }, item.label)),
|
|
882
|
-
/* @__PURE__ */
|
|
883
|
-
/* @__PURE__ */
|
|
423
|
+
/* @__PURE__ */ jsx4(Text4, { children: " " }),
|
|
424
|
+
/* @__PURE__ */ jsx4(Text4, { dimColor: true, children: "[\u2191/\u2193] Navigate [Enter] Select [Esc/q] Back to Start" })
|
|
884
425
|
] });
|
|
885
426
|
}
|
|
886
427
|
var init_PageContainer3 = __esm({
|
|
@@ -890,13 +431,27 @@ var init_PageContainer3 = __esm({
|
|
|
890
431
|
});
|
|
891
432
|
|
|
892
433
|
// packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
|
|
893
|
-
|
|
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;
|
|
894
451
|
var init_v1_store = __esm({
|
|
895
452
|
"packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts"() {
|
|
896
453
|
"use strict";
|
|
897
|
-
|
|
898
|
-
readV1Store = readSettings;
|
|
899
|
-
writeV1Store = writeSettings;
|
|
454
|
+
V1_STORE_PATH = join4(homedir(), ".config", "experiences", "credentials.json");
|
|
900
455
|
}
|
|
901
456
|
});
|
|
902
457
|
|
|
@@ -907,9 +462,7 @@ async function readCredentials() {
|
|
|
907
462
|
spaceId: store.spaceId || "",
|
|
908
463
|
environmentId: store.environmentId || "",
|
|
909
464
|
cmaToken: store.cmaToken || "",
|
|
910
|
-
host: store.host || ""
|
|
911
|
-
defaultComponentDir: store.defaultComponentDir || "",
|
|
912
|
-
defaultTokenFile: store.defaultTokenFile || ""
|
|
465
|
+
host: store.host || ""
|
|
913
466
|
};
|
|
914
467
|
}
|
|
915
468
|
async function writeCredentials(config) {
|
|
@@ -931,38 +484,18 @@ var init_config_store = __esm({
|
|
|
931
484
|
});
|
|
932
485
|
|
|
933
486
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
934
|
-
import { useEffect as
|
|
935
|
-
import { Box as
|
|
936
|
-
import
|
|
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
|
-
}
|
|
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";
|
|
948
490
|
function ConfigurationScreen({ onDone }) {
|
|
949
|
-
const [stage, setStage] =
|
|
950
|
-
const [config, setConfig] =
|
|
951
|
-
const [activeField, setActiveField] =
|
|
952
|
-
const [
|
|
953
|
-
|
|
954
|
-
const [editing, setEditing] = useState6(false);
|
|
955
|
-
const [valueBeforeEdit, setValueBeforeEdit] = useState6("");
|
|
956
|
-
useEffect4(() => {
|
|
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(() => {
|
|
957
496
|
readCredentials().then((cfg) => {
|
|
958
497
|
setConfig(cfg);
|
|
959
498
|
setStage("form");
|
|
960
|
-
startDebugRun({
|
|
961
|
-
flow: "settings/contentful-configuration",
|
|
962
|
-
step: "01-configuration",
|
|
963
|
-
menuOption: "Configuration",
|
|
964
|
-
inputs: debugFields(cfg)
|
|
965
|
-
});
|
|
966
499
|
});
|
|
967
500
|
}, []);
|
|
968
501
|
function fieldValue(field) {
|
|
@@ -972,46 +505,29 @@ function ConfigurationScreen({ onDone }) {
|
|
|
972
505
|
function setFieldValue(field, value) {
|
|
973
506
|
if (!config) return;
|
|
974
507
|
setConfig({ ...config, [field]: value });
|
|
975
|
-
setNotice(null);
|
|
976
508
|
}
|
|
977
509
|
function handleSave() {
|
|
978
510
|
if (!config) return;
|
|
979
511
|
setStage("saving");
|
|
980
|
-
|
|
512
|
+
setMessage(null);
|
|
981
513
|
writeCredentials(config).then(() => {
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
setStage("form");
|
|
514
|
+
setStage("saved");
|
|
515
|
+
setMessage("Configuration saved");
|
|
985
516
|
}).catch((err) => {
|
|
986
|
-
|
|
517
|
+
setMessage(err instanceof Error ? err.message : "Failed to save");
|
|
987
518
|
setStage("form");
|
|
988
519
|
});
|
|
989
520
|
}
|
|
990
|
-
|
|
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) => {
|
|
521
|
+
useInput5((input, key) => {
|
|
997
522
|
if (stage === "loading" || stage === "saving") return;
|
|
998
|
-
if (
|
|
999
|
-
if (key.escape) {
|
|
1000
|
-
|
|
1001
|
-
setEditing(false);
|
|
523
|
+
if (stage === "saved") {
|
|
524
|
+
if (key.return || key.escape || input === "q") {
|
|
525
|
+
onDone();
|
|
1002
526
|
}
|
|
1003
527
|
return;
|
|
1004
528
|
}
|
|
1005
529
|
if (key.escape || input === "q") {
|
|
1006
|
-
|
|
1007
|
-
return;
|
|
1008
|
-
}
|
|
1009
|
-
if (input === "s") {
|
|
1010
|
-
handleSave();
|
|
1011
|
-
return;
|
|
1012
|
-
}
|
|
1013
|
-
if (input === "c") {
|
|
1014
|
-
setFieldValue(activeField, "");
|
|
530
|
+
onDone();
|
|
1015
531
|
return;
|
|
1016
532
|
}
|
|
1017
533
|
if (key.tab || key.downArrow) {
|
|
@@ -1025,51 +541,69 @@ function ConfigurationScreen({ onDone }) {
|
|
|
1025
541
|
return;
|
|
1026
542
|
}
|
|
1027
543
|
if (key.return) {
|
|
1028
|
-
|
|
1029
|
-
|
|
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);
|
|
1030
559
|
}
|
|
1031
560
|
});
|
|
1032
561
|
if (stage === "loading") {
|
|
1033
|
-
return /* @__PURE__ */
|
|
1034
|
-
/* @__PURE__ */
|
|
1035
|
-
/* @__PURE__ */
|
|
1036
|
-
/* @__PURE__ */
|
|
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..." })
|
|
1037
566
|
] });
|
|
1038
567
|
}
|
|
1039
|
-
|
|
1040
|
-
/* @__PURE__ */
|
|
1041
|
-
|
|
1042
|
-
|
|
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" })
|
|
578
|
+
] });
|
|
579
|
+
}
|
|
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) => {
|
|
1043
586
|
const isActive = activeField === field;
|
|
1044
587
|
const value = fieldValue(field);
|
|
1045
588
|
const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
|
|
1046
|
-
return /* @__PURE__ */
|
|
1047
|
-
/* @__PURE__ */
|
|
1048
|
-
/* @__PURE__ */
|
|
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: [
|
|
1049
592
|
FIELD_LABELS[field],
|
|
1050
593
|
":"
|
|
1051
594
|
] }),
|
|
1052
|
-
|
|
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)" }) })
|
|
595
|
+
/* @__PURE__ */ jsx5(Text5, { children: display || /* @__PURE__ */ jsx5(Text5, { dimColor: true, children: "(empty)" }) })
|
|
1061
596
|
] }, field);
|
|
1062
597
|
}) }),
|
|
1063
|
-
|
|
1064
|
-
/* @__PURE__ */
|
|
1065
|
-
/* @__PURE__ */
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
notice.text
|
|
598
|
+
message && /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
599
|
+
/* @__PURE__ */ jsx5(Text5, { children: " " }),
|
|
600
|
+
/* @__PURE__ */ jsxs5(Text5, { color: PALETTE.error, children: [
|
|
601
|
+
"\u2717 ",
|
|
602
|
+
message
|
|
1069
603
|
] })
|
|
1070
604
|
] }),
|
|
1071
|
-
/* @__PURE__ */
|
|
1072
|
-
/* @__PURE__ */
|
|
605
|
+
/* @__PURE__ */ jsx5(Text5, { children: " " }),
|
|
606
|
+
/* @__PURE__ */ jsx5(Text5, { dimColor: true, children: "[\u2191/\u2193] Switch field \xB7 [Enter] Save/Next \xB7 [Esc/q] Back" })
|
|
1073
607
|
] });
|
|
1074
608
|
}
|
|
1075
609
|
var FIELD_ORDER, FIELD_LABELS;
|
|
@@ -1078,22 +612,12 @@ var init_ContentfulConfigScreen = __esm({
|
|
|
1078
612
|
"use strict";
|
|
1079
613
|
init_home_theme();
|
|
1080
614
|
init_config_store();
|
|
1081
|
-
|
|
1082
|
-
FIELD_ORDER = [
|
|
1083
|
-
"spaceId",
|
|
1084
|
-
"environmentId",
|
|
1085
|
-
"cmaToken",
|
|
1086
|
-
"host",
|
|
1087
|
-
"defaultComponentDir",
|
|
1088
|
-
"defaultTokenFile"
|
|
1089
|
-
];
|
|
615
|
+
FIELD_ORDER = ["spaceId", "environmentId", "cmaToken", "host"];
|
|
1090
616
|
FIELD_LABELS = {
|
|
1091
617
|
spaceId: "Space ID",
|
|
1092
618
|
environmentId: "Environment ID",
|
|
1093
619
|
cmaToken: "CMA Token",
|
|
1094
|
-
host: "API Host (optional)"
|
|
1095
|
-
defaultComponentDir: "Default component directory (optional)",
|
|
1096
|
-
defaultTokenFile: "Default token file (optional)"
|
|
620
|
+
host: "API Host (optional)"
|
|
1097
621
|
};
|
|
1098
622
|
}
|
|
1099
623
|
});
|
|
@@ -1120,25 +644,19 @@ var init_analytics_store = __esm({
|
|
|
1120
644
|
});
|
|
1121
645
|
|
|
1122
646
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
1123
|
-
import { useEffect as
|
|
1124
|
-
import { Box as
|
|
1125
|
-
import { Fragment as Fragment2, jsx as
|
|
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";
|
|
1126
650
|
function OptInAnalyticsScreen({ onDone }) {
|
|
1127
|
-
const [loading, setLoading] =
|
|
1128
|
-
const [enabled, setEnabled] =
|
|
1129
|
-
|
|
651
|
+
const [loading, setLoading] = useState5(true);
|
|
652
|
+
const [enabled, setEnabled] = useState5(true);
|
|
653
|
+
useEffect4(() => {
|
|
1130
654
|
readAnalyticsSetting().then((setting) => {
|
|
1131
655
|
setEnabled(setting.enabled);
|
|
1132
656
|
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
|
-
});
|
|
1139
657
|
});
|
|
1140
658
|
}, []);
|
|
1141
|
-
|
|
659
|
+
useInput6((input, key) => {
|
|
1142
660
|
if (loading) return;
|
|
1143
661
|
if (key.return || input === " ") {
|
|
1144
662
|
setEnabled((current) => {
|
|
@@ -1149,43 +667,225 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
1149
667
|
return;
|
|
1150
668
|
}
|
|
1151
669
|
if (key.escape || input === "q") {
|
|
1152
|
-
void finishDebugRun({ outputs: { enabled }, status: "success", exitMethod: "saved" });
|
|
1153
670
|
onDone();
|
|
1154
671
|
}
|
|
1155
672
|
});
|
|
1156
|
-
return /* @__PURE__ */
|
|
1157
|
-
/* @__PURE__ */
|
|
1158
|
-
/* @__PURE__ */
|
|
1159
|
-
loading ? /* @__PURE__ */
|
|
1160
|
-
/* @__PURE__ */
|
|
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: [
|
|
1161
678
|
"Share anonymous usage data:",
|
|
1162
679
|
" ",
|
|
1163
|
-
/* @__PURE__ */
|
|
680
|
+
/* @__PURE__ */ jsx6(Text6, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
1164
681
|
] }),
|
|
1165
|
-
/* @__PURE__ */
|
|
1166
|
-
/* @__PURE__ */
|
|
1167
|
-
/* @__PURE__ */
|
|
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." })
|
|
1168
685
|
] }),
|
|
1169
|
-
/* @__PURE__ */
|
|
1170
|
-
/* @__PURE__ */
|
|
686
|
+
/* @__PURE__ */ jsx6(Text6, { children: " " }),
|
|
687
|
+
/* @__PURE__ */ jsx6(Text6, { dimColor: true, children: "[Enter/Space] Toggle [Esc/q] Back to Settings" })
|
|
1171
688
|
] });
|
|
1172
689
|
}
|
|
1173
|
-
var
|
|
690
|
+
var init_screen = __esm({
|
|
1174
691
|
"packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx"() {
|
|
1175
692
|
"use strict";
|
|
1176
693
|
init_home_theme();
|
|
1177
694
|
init_analytics_store();
|
|
1178
|
-
|
|
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
|
+
});
|
|
1179
879
|
}
|
|
1180
880
|
});
|
|
1181
881
|
|
|
1182
882
|
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
1183
|
-
import { useEffect as
|
|
1184
|
-
import { Box as
|
|
1185
|
-
import { jsx as
|
|
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";
|
|
1186
886
|
function UpgradeScreen({ onDone }) {
|
|
1187
|
-
const [upgradeCheck, setUpgradeCheck] =
|
|
1188
|
-
|
|
887
|
+
const [upgradeCheck, setUpgradeCheck] = useState6();
|
|
888
|
+
useEffect5(() => {
|
|
1189
889
|
startDebugRun({
|
|
1190
890
|
flow: "upgrade",
|
|
1191
891
|
step: "01-upgrade",
|
|
@@ -1194,7 +894,7 @@ function UpgradeScreen({ onDone }) {
|
|
|
1194
894
|
});
|
|
1195
895
|
checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
|
|
1196
896
|
}, []);
|
|
1197
|
-
|
|
897
|
+
useInput7((_input, key) => {
|
|
1198
898
|
if (key.return) {
|
|
1199
899
|
void finishDebugRun({
|
|
1200
900
|
outputs: upgradeCheck ?? {},
|
|
@@ -1205,12 +905,12 @@ function UpgradeScreen({ onDone }) {
|
|
|
1205
905
|
return;
|
|
1206
906
|
}
|
|
1207
907
|
});
|
|
1208
|
-
return /* @__PURE__ */
|
|
1209
|
-
/* @__PURE__ */
|
|
1210
|
-
/* @__PURE__ */
|
|
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: " " }),
|
|
1211
911
|
renderBody(upgradeCheck),
|
|
1212
|
-
/* @__PURE__ */
|
|
1213
|
-
/* @__PURE__ */
|
|
912
|
+
/* @__PURE__ */ jsx7(Text7, { children: " " }),
|
|
913
|
+
/* @__PURE__ */ jsxs7(Text7, { bold: true, color: PALETTE.accent, children: [
|
|
1214
914
|
FOCUS_MARKER,
|
|
1215
915
|
" Go Back"
|
|
1216
916
|
] })
|
|
@@ -1218,34 +918,34 @@ function UpgradeScreen({ onDone }) {
|
|
|
1218
918
|
}
|
|
1219
919
|
function renderBody(upgradeCheck) {
|
|
1220
920
|
if (!upgradeCheck) {
|
|
1221
|
-
return /* @__PURE__ */
|
|
921
|
+
return /* @__PURE__ */ jsx7(Text7, { color: PALETTE.muted, children: "Checking for updates\u2026" });
|
|
1222
922
|
}
|
|
1223
923
|
if (upgradeCheck.status === "error") {
|
|
1224
|
-
return /* @__PURE__ */
|
|
924
|
+
return /* @__PURE__ */ jsx7(Text7, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
|
|
1225
925
|
}
|
|
1226
926
|
if (upgradeCheck.status === "up-to-date") {
|
|
1227
|
-
return /* @__PURE__ */
|
|
927
|
+
return /* @__PURE__ */ jsxs7(Text7, { color: PALETTE.success, children: [
|
|
1228
928
|
"You're already on the latest version (v",
|
|
1229
929
|
upgradeCheck.current,
|
|
1230
930
|
")."
|
|
1231
931
|
] });
|
|
1232
932
|
}
|
|
1233
|
-
return /* @__PURE__ */
|
|
1234
|
-
/* @__PURE__ */
|
|
1235
|
-
/* @__PURE__ */
|
|
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: [
|
|
1236
936
|
"v",
|
|
1237
937
|
upgradeCheck.latest
|
|
1238
938
|
] }),
|
|
1239
939
|
" ",
|
|
1240
940
|
"is available (you're on ",
|
|
1241
|
-
/* @__PURE__ */
|
|
941
|
+
/* @__PURE__ */ jsxs7(Text7, { bold: true, children: [
|
|
1242
942
|
"v",
|
|
1243
943
|
upgradeCheck.current
|
|
1244
944
|
] }),
|
|
1245
945
|
"). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
|
|
1246
946
|
] }),
|
|
1247
|
-
/* @__PURE__ */
|
|
1248
|
-
/* @__PURE__ */
|
|
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)) })
|
|
1249
949
|
] });
|
|
1250
950
|
}
|
|
1251
951
|
var UPGRADE_COMMANDS;
|
|
@@ -1260,25 +960,19 @@ var init_PageContainer4 = __esm({
|
|
|
1260
960
|
});
|
|
1261
961
|
|
|
1262
962
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
1263
|
-
import { useEffect as
|
|
1264
|
-
import { Box as
|
|
1265
|
-
import { jsx as
|
|
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";
|
|
1266
966
|
function DebugModeScreen({ onDone }) {
|
|
1267
|
-
const [loading, setLoading] =
|
|
1268
|
-
const [enabled, setEnabled] =
|
|
1269
|
-
|
|
967
|
+
const [loading, setLoading] = useState7(true);
|
|
968
|
+
const [enabled, setEnabled] = useState7(true);
|
|
969
|
+
useEffect6(() => {
|
|
1270
970
|
readDebugModeSetting().then((setting) => {
|
|
1271
971
|
setEnabled(setting.enabled);
|
|
1272
972
|
setLoading(false);
|
|
1273
|
-
startDebugRun({
|
|
1274
|
-
flow: "settings/debug-mode",
|
|
1275
|
-
step: "01-debug-mode",
|
|
1276
|
-
menuOption: "Debug Mode",
|
|
1277
|
-
inputs: { enabled: setting.enabled }
|
|
1278
|
-
});
|
|
1279
973
|
});
|
|
1280
974
|
}, []);
|
|
1281
|
-
|
|
975
|
+
useInput8((input, key) => {
|
|
1282
976
|
if (loading) return;
|
|
1283
977
|
if (key.return || input === " ") {
|
|
1284
978
|
setEnabled((current) => {
|
|
@@ -1289,28 +983,26 @@ function DebugModeScreen({ onDone }) {
|
|
|
1289
983
|
return;
|
|
1290
984
|
}
|
|
1291
985
|
if (key.escape || input === "q") {
|
|
1292
|
-
void finishDebugRun({ outputs: { enabled }, status: "success", exitMethod: "saved" });
|
|
1293
986
|
onDone();
|
|
1294
987
|
}
|
|
1295
988
|
});
|
|
1296
|
-
return /* @__PURE__ */
|
|
1297
|
-
/* @__PURE__ */
|
|
1298
|
-
/* @__PURE__ */
|
|
1299
|
-
loading ? /* @__PURE__ */
|
|
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: [
|
|
1300
993
|
"Debug logging:",
|
|
1301
994
|
" ",
|
|
1302
|
-
/* @__PURE__ */
|
|
995
|
+
/* @__PURE__ */ jsx8(Text8, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
1303
996
|
] }),
|
|
1304
|
-
/* @__PURE__ */
|
|
1305
|
-
/* @__PURE__ */
|
|
997
|
+
/* @__PURE__ */ jsx8(Text8, { children: " " }),
|
|
998
|
+
/* @__PURE__ */ jsx8(Text8, { dimColor: true, children: "[Enter/Space] Toggle [Esc/q] Back to Settings" })
|
|
1306
999
|
] });
|
|
1307
1000
|
}
|
|
1308
|
-
var
|
|
1001
|
+
var init_screen2 = __esm({
|
|
1309
1002
|
"packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx"() {
|
|
1310
1003
|
"use strict";
|
|
1311
1004
|
init_home_theme();
|
|
1312
1005
|
init_debug_mode_store();
|
|
1313
|
-
init_debug_store();
|
|
1314
1006
|
}
|
|
1315
1007
|
});
|
|
1316
1008
|
|
|
@@ -1319,75 +1011,48 @@ var app_exports = {};
|
|
|
1319
1011
|
__export(app_exports, {
|
|
1320
1012
|
runApp: () => runApp
|
|
1321
1013
|
});
|
|
1322
|
-
import {
|
|
1323
|
-
import {
|
|
1014
|
+
import { useState as useState8 } from "react";
|
|
1015
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1324
1016
|
function App({ onLaunchImport, importExitCode }) {
|
|
1325
1017
|
const returnedFromImport = importExitCode !== void 0;
|
|
1326
|
-
const [screen, setScreen] =
|
|
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);
|
|
1333
|
-
return;
|
|
1334
|
-
}
|
|
1335
|
-
void readCredentials().then(
|
|
1336
|
-
(saved) => setImportDefaults({ componentDir: saved.defaultComponentDir ?? "", tokenFile: saved.defaultTokenFile ?? "" })
|
|
1337
|
-
);
|
|
1338
|
-
}, [screen]);
|
|
1018
|
+
const [screen, setScreen] = useState8(returnedFromImport ? "import" : "start");
|
|
1339
1019
|
const goToStart = () => setScreen("start");
|
|
1340
1020
|
const goToSettings = () => setScreen("settings");
|
|
1341
|
-
const
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
setProjectPath(void 0);
|
|
1348
|
-
goToStart();
|
|
1021
|
+
const navigateFromHome = (next) => {
|
|
1022
|
+
if (next === "import" && onLaunchImport) {
|
|
1023
|
+
onLaunchImport();
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
setScreen(next);
|
|
1349
1027
|
};
|
|
1350
1028
|
switch (screen) {
|
|
1351
1029
|
case "import":
|
|
1352
|
-
|
|
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
|
-
);
|
|
1030
|
+
return /* @__PURE__ */ jsx9(ImportScreen, { exitCode: importExitCode, onDone: goToStart });
|
|
1366
1031
|
case "help":
|
|
1367
|
-
return /* @__PURE__ */
|
|
1032
|
+
return /* @__PURE__ */ jsx9(HelpScreen, { onDone: goToStart });
|
|
1368
1033
|
case "upgrade":
|
|
1369
|
-
return /* @__PURE__ */
|
|
1034
|
+
return /* @__PURE__ */ jsx9(UpgradeScreen, { onDone: goToStart });
|
|
1370
1035
|
case "settings":
|
|
1371
|
-
return /* @__PURE__ */
|
|
1036
|
+
return /* @__PURE__ */ jsx9(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
|
|
1372
1037
|
case "settings-configuration":
|
|
1373
|
-
return /* @__PURE__ */
|
|
1038
|
+
return /* @__PURE__ */ jsx9(ConfigurationScreen, { onDone: goToSettings });
|
|
1374
1039
|
case "settings-opt-in-analytics":
|
|
1375
|
-
return /* @__PURE__ */
|
|
1040
|
+
return /* @__PURE__ */ jsx9(OptInAnalyticsScreen, { onDone: goToSettings });
|
|
1376
1041
|
case "settings-debug-mode":
|
|
1377
|
-
return /* @__PURE__ */
|
|
1042
|
+
return /* @__PURE__ */ jsx9(DebugModeScreen, { onDone: goToSettings });
|
|
1378
1043
|
case "start":
|
|
1379
|
-
return /* @__PURE__ */
|
|
1044
|
+
return /* @__PURE__ */ jsx9(HomeScreen, { onNavigate: navigateFromHome });
|
|
1380
1045
|
}
|
|
1381
1046
|
}
|
|
1382
1047
|
async function renderUntilImportRequestedOrExit(renderApp, importExitCode) {
|
|
1383
|
-
let
|
|
1048
|
+
let importRequested = false;
|
|
1384
1049
|
const instance = renderApp(
|
|
1385
|
-
/* @__PURE__ */
|
|
1050
|
+
/* @__PURE__ */ jsx9(
|
|
1386
1051
|
App,
|
|
1387
1052
|
{
|
|
1388
1053
|
importExitCode,
|
|
1389
|
-
onLaunchImport: (
|
|
1390
|
-
|
|
1054
|
+
onLaunchImport: () => {
|
|
1055
|
+
importRequested = true;
|
|
1391
1056
|
instance.unmount();
|
|
1392
1057
|
}
|
|
1393
1058
|
}
|
|
@@ -1395,15 +1060,13 @@ async function renderUntilImportRequestedOrExit(renderApp, importExitCode) {
|
|
|
1395
1060
|
);
|
|
1396
1061
|
await instance.waitUntilExit();
|
|
1397
1062
|
await stopReadingTerminal();
|
|
1398
|
-
return
|
|
1063
|
+
return importRequested;
|
|
1399
1064
|
}
|
|
1400
1065
|
async function runApp(renderApp) {
|
|
1401
1066
|
let importExitCode;
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
importExitCode = (await spawnV1Import(requestedImport)).exitCode;
|
|
1067
|
+
while (await renderUntilImportRequestedOrExit(renderApp, importExitCode)) {
|
|
1068
|
+
importExitCode = (await spawnV1Import({})).exitCode;
|
|
1405
1069
|
startReadingTerminal();
|
|
1406
|
-
requestedImport = await renderUntilImportRequestedOrExit(renderApp, importExitCode);
|
|
1407
1070
|
}
|
|
1408
1071
|
}
|
|
1409
1072
|
var init_app = __esm({
|
|
@@ -1411,16 +1074,14 @@ var init_app = __esm({
|
|
|
1411
1074
|
"use strict";
|
|
1412
1075
|
init_home();
|
|
1413
1076
|
init_PageContainer();
|
|
1414
|
-
init_steps();
|
|
1415
1077
|
init_spawn_v1_import();
|
|
1416
1078
|
init_terminal_input();
|
|
1417
1079
|
init_PageContainer2();
|
|
1418
1080
|
init_PageContainer3();
|
|
1419
1081
|
init_ContentfulConfigScreen();
|
|
1420
|
-
|
|
1082
|
+
init_screen();
|
|
1421
1083
|
init_PageContainer4();
|
|
1422
|
-
|
|
1423
|
-
init_config_store();
|
|
1084
|
+
init_screen2();
|
|
1424
1085
|
}
|
|
1425
1086
|
});
|
|
1426
1087
|
|
|
@@ -1499,51 +1160,7 @@ function createProgram() {
|
|
|
1499
1160
|
return program;
|
|
1500
1161
|
}
|
|
1501
1162
|
|
|
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
|
-
|
|
1545
1163
|
// packages/experience-design-system-cli/index.ts
|
|
1546
|
-
await migrateOldConfig();
|
|
1547
1164
|
createProgram().parseAsync().catch((err) => {
|
|
1548
1165
|
process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
|
|
1549
1166
|
`);
|