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