@contentful/experience-design-system-cli 2.36.2-dev-build-d983d04c.0 → 2.36.2-dev-build-8c3560a9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +672 -357
- package/dist/index.js +813 -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/app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/experience-design-system-cli/app.tsx
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useEffect as useEffect8, useState as useState11 } from "react";
|
|
3
3
|
|
|
4
4
|
// packages/experience-design-system-cli/src/tui/home/home.tsx
|
|
5
5
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
@@ -230,6 +230,202 @@ function ImportScreen({ exitCode, onDone }) {
|
|
|
230
230
|
] });
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
// packages/experience-design-system-cli/src/tui/import/steps/01-welcome/screen.tsx
|
|
234
|
+
import { useState as useState3 } from "react";
|
|
235
|
+
import { Box as Box3, Text as Text3 } from "ink";
|
|
236
|
+
import TextInput from "ink-text-input";
|
|
237
|
+
|
|
238
|
+
// packages/experience-design-system-cli/src/tui/import/steps/01-welcome/controls.ts
|
|
239
|
+
import { useInput as useInput3 } from "ink";
|
|
240
|
+
|
|
241
|
+
// packages/experience-design-system-cli/src/tui/import/steps/01-welcome/logic.ts
|
|
242
|
+
function shouldQuit(value, input, key) {
|
|
243
|
+
if (key.escape) return true;
|
|
244
|
+
return value === "" && input === "q" && !key.ctrl && !key.meta;
|
|
245
|
+
}
|
|
246
|
+
function toProjectPath(value) {
|
|
247
|
+
const projectPath = value.trim();
|
|
248
|
+
return projectPath === "" ? null : projectPath;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// packages/experience-design-system-cli/src/tui/import/steps/01-welcome/controls.ts
|
|
252
|
+
var WELCOME_CONTROLS = [
|
|
253
|
+
{ keys: "Enter", label: "Continue" },
|
|
254
|
+
{ keys: "Esc/q", label: "Back to menu" }
|
|
255
|
+
];
|
|
256
|
+
function useWelcomeControls(projectPath, onQuit) {
|
|
257
|
+
useInput3((input, key) => {
|
|
258
|
+
if (shouldQuit(projectPath, input, key)) onQuit();
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// packages/experience-design-system-cli/src/tui/import/steps/01-welcome/screen.tsx
|
|
263
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
264
|
+
var 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";
|
|
265
|
+
var OVERVIEW = [
|
|
266
|
+
{ label: "Step 1", description: "Extract components from your codebase" },
|
|
267
|
+
{ label: "Step 2", description: "Review what was extracted" },
|
|
268
|
+
{ label: "Step 3", description: "Generate CDF definitions with Claude" },
|
|
269
|
+
{ label: "Step 4", description: "Review generated definitions" },
|
|
270
|
+
{ label: "Step 5", description: "Push to Contentful" }
|
|
271
|
+
];
|
|
272
|
+
function WelcomeScreen({ onContinue, onQuit, initialPath = "" }) {
|
|
273
|
+
const [projectPath, setProjectPath] = useState3(initialPath);
|
|
274
|
+
useWelcomeControls(projectPath, onQuit);
|
|
275
|
+
const submit = (value) => {
|
|
276
|
+
const path = toProjectPath(value);
|
|
277
|
+
if (path) onContinue(path);
|
|
278
|
+
};
|
|
279
|
+
return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", gap: 1, paddingX: 2, paddingY: 1, children: [
|
|
280
|
+
/* @__PURE__ */ jsx3(Text3, { bold: true, color: PALETTE.success, children: "\u{1F44B} Hey! Let's import your design system into Contentful." }),
|
|
281
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "I'll walk you through 5 steps to get your components into Contentful ExO." }),
|
|
282
|
+
/* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", marginTop: 1, children: [
|
|
283
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: RULE }),
|
|
284
|
+
OVERVIEW.map((item) => /* @__PURE__ */ jsxs3(Box3, { gap: 1, children: [
|
|
285
|
+
/* @__PURE__ */ jsx3(Text3, { bold: true, children: item.label }),
|
|
286
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: item.description })
|
|
287
|
+
] }, item.label)),
|
|
288
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: RULE })
|
|
289
|
+
] }),
|
|
290
|
+
/* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", marginTop: 1, children: [
|
|
291
|
+
/* @__PURE__ */ jsx3(Text3, { children: "Where is your component library?" }),
|
|
292
|
+
/* @__PURE__ */ jsxs3(Box3, { gap: 1, children: [
|
|
293
|
+
/* @__PURE__ */ jsx3(Text3, { color: PALETTE.accent, children: "?" }),
|
|
294
|
+
/* @__PURE__ */ jsx3(Text3, { children: "Project path:" }),
|
|
295
|
+
/* @__PURE__ */ jsx3(TextInput, { value: projectPath, onChange: setProjectPath, onSubmit: submit })
|
|
296
|
+
] })
|
|
297
|
+
] }),
|
|
298
|
+
/* @__PURE__ */ jsx3(Box3, { marginTop: 1, gap: 3, children: WELCOME_CONTROLS.map((control) => /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
299
|
+
"[",
|
|
300
|
+
control.keys,
|
|
301
|
+
"] ",
|
|
302
|
+
control.label
|
|
303
|
+
] }, control.keys)) })
|
|
304
|
+
] });
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// packages/experience-design-system-cli/src/tui/import/steps/02-token-input/screen.tsx
|
|
308
|
+
import { useState as useState4 } from "react";
|
|
309
|
+
import { Box as Box4, Text as Text4 } from "ink";
|
|
310
|
+
import TextInput2 from "ink-text-input";
|
|
311
|
+
|
|
312
|
+
// packages/experience-design-system-cli/src/tui/import/steps/02-token-input/controls.ts
|
|
313
|
+
import { useInput as useInput4 } from "ink";
|
|
314
|
+
|
|
315
|
+
// packages/experience-design-system-cli/src/tui/import/steps/02-token-input/logic.ts
|
|
316
|
+
function isPlainKeyOnEmptyField(value, input, key, expected) {
|
|
317
|
+
return value === "" && input === expected && !key.ctrl && !key.meta;
|
|
318
|
+
}
|
|
319
|
+
function shouldGoBack(value, input, key) {
|
|
320
|
+
return key.escape || isPlainKeyOnEmptyField(value, input, key, "q");
|
|
321
|
+
}
|
|
322
|
+
function shouldSkip(value, input, key) {
|
|
323
|
+
return isPlainKeyOnEmptyField(value, input, key, "s");
|
|
324
|
+
}
|
|
325
|
+
function toTokenPath(value) {
|
|
326
|
+
const tokenPath = value.trim();
|
|
327
|
+
return tokenPath === "" ? null : tokenPath;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// packages/experience-design-system-cli/src/tui/import/steps/02-token-input/controls.ts
|
|
331
|
+
var TOKEN_INPUT_CONTROLS = [
|
|
332
|
+
{ keys: "Enter", label: "Continue (skips if empty)" },
|
|
333
|
+
{ keys: "s", label: "Skip" },
|
|
334
|
+
{ keys: "Esc/q", label: "Back" }
|
|
335
|
+
];
|
|
336
|
+
function useTokenInputControls(tokenPath, onSkip, onBack) {
|
|
337
|
+
useInput4((input, key) => {
|
|
338
|
+
if (shouldGoBack(tokenPath, input, key)) onBack();
|
|
339
|
+
else if (shouldSkip(tokenPath, input, key)) onSkip();
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// packages/experience-design-system-cli/src/tui/import/steps/02-token-input/validate-path.ts
|
|
344
|
+
import { statSync } from "node:fs";
|
|
345
|
+
import { homedir } from "node:os";
|
|
346
|
+
import { resolve } from "node:path";
|
|
347
|
+
function stripQuotes(value) {
|
|
348
|
+
const quoted = value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'");
|
|
349
|
+
return value.length >= 2 && quoted ? value.slice(1, -1) : value;
|
|
350
|
+
}
|
|
351
|
+
function expandHome(value) {
|
|
352
|
+
return value === "~" || value.startsWith("~/") || value.startsWith("~\\") ? homedir() + value.slice(1) : value;
|
|
353
|
+
}
|
|
354
|
+
function validateTokenPath(rawPath) {
|
|
355
|
+
const path = resolve(expandHome(stripQuotes(rawPath.trim())));
|
|
356
|
+
let stats;
|
|
357
|
+
try {
|
|
358
|
+
stats = statSync(path);
|
|
359
|
+
} catch {
|
|
360
|
+
return { ok: false, error: `Path not found: ${path}`, resolvedPath: path };
|
|
361
|
+
}
|
|
362
|
+
if (stats.isDirectory()) {
|
|
363
|
+
return {
|
|
364
|
+
ok: false,
|
|
365
|
+
error: "That's a directory \u2014 provide a path to a token file (e.g. tokens.json), not a folder.",
|
|
366
|
+
resolvedPath: path
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
if (!stats.isFile()) {
|
|
370
|
+
return { ok: false, error: `Not a regular file: ${path}`, resolvedPath: path };
|
|
371
|
+
}
|
|
372
|
+
return { ok: true, path };
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// packages/experience-design-system-cli/src/tui/import/steps/02-token-input/screen.tsx
|
|
376
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
377
|
+
function TokenInputScreen({
|
|
378
|
+
onConfirm,
|
|
379
|
+
onSkip,
|
|
380
|
+
onBack,
|
|
381
|
+
initialPath = ""
|
|
382
|
+
}) {
|
|
383
|
+
const [tokenPath, setTokenPath] = useState4(initialPath);
|
|
384
|
+
const [failure, setFailure] = useState4(null);
|
|
385
|
+
useTokenInputControls(tokenPath, onSkip, onBack);
|
|
386
|
+
const change = (value) => {
|
|
387
|
+
setTokenPath(value);
|
|
388
|
+
setFailure(null);
|
|
389
|
+
};
|
|
390
|
+
const submit = (value) => {
|
|
391
|
+
const rawPath = toTokenPath(value);
|
|
392
|
+
if (!rawPath) {
|
|
393
|
+
onSkip();
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const check = validateTokenPath(rawPath);
|
|
397
|
+
if (check.ok) onConfirm(check.path);
|
|
398
|
+
else setFailure({ error: check.error, resolvedPath: check.resolvedPath });
|
|
399
|
+
};
|
|
400
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", gap: 1, paddingX: 2, paddingY: 1, children: [
|
|
401
|
+
/* @__PURE__ */ jsx4(Text4, { bold: true, children: "Design tokens" }),
|
|
402
|
+
/* @__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." }),
|
|
403
|
+
/* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", marginTop: 1, children: [
|
|
404
|
+
/* @__PURE__ */ jsxs4(Box4, { gap: 1, children: [
|
|
405
|
+
/* @__PURE__ */ jsx4(Text4, { color: PALETTE.accent, children: "?" }),
|
|
406
|
+
/* @__PURE__ */ jsx4(Text4, { children: "Token path:" }),
|
|
407
|
+
/* @__PURE__ */ jsx4(TextInput2, { value: tokenPath, onChange: change, onSubmit: submit })
|
|
408
|
+
] }),
|
|
409
|
+
failure && /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
|
|
410
|
+
/* @__PURE__ */ jsxs4(Text4, { color: PALETTE.error, children: [
|
|
411
|
+
"\u2717 ",
|
|
412
|
+
failure.error
|
|
413
|
+
] }),
|
|
414
|
+
/* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
415
|
+
" Resolved to: ",
|
|
416
|
+
failure.resolvedPath
|
|
417
|
+
] })
|
|
418
|
+
] })
|
|
419
|
+
] }),
|
|
420
|
+
/* @__PURE__ */ jsx4(Box4, { marginTop: 1, gap: 3, children: TOKEN_INPUT_CONTROLS.map((control) => /* @__PURE__ */ jsxs4(Text4, { dimColor: true, children: [
|
|
421
|
+
"[",
|
|
422
|
+
control.keys,
|
|
423
|
+
"] ",
|
|
424
|
+
control.label
|
|
425
|
+
] }, control.keys)) })
|
|
426
|
+
] });
|
|
427
|
+
}
|
|
428
|
+
|
|
233
429
|
// packages/experience-design-system-cli/src/tui/import/spawn-v1-import.ts
|
|
234
430
|
import { spawn } from "node:child_process";
|
|
235
431
|
|
|
@@ -257,6 +453,9 @@ function buildArgs(options) {
|
|
|
257
453
|
if (options.project) {
|
|
258
454
|
args.push("--project", options.project);
|
|
259
455
|
}
|
|
456
|
+
if (options.tokens) {
|
|
457
|
+
args.push("--tokens", options.tokens);
|
|
458
|
+
}
|
|
260
459
|
return args;
|
|
261
460
|
}
|
|
262
461
|
async function spawnV1Import(options = {}) {
|
|
@@ -280,7 +479,7 @@ function getTerminalHandle() {
|
|
|
280
479
|
return process.stdin._handle;
|
|
281
480
|
}
|
|
282
481
|
async function stopReadingTerminal() {
|
|
283
|
-
await new Promise((
|
|
482
|
+
await new Promise((resolve2) => setImmediate(resolve2));
|
|
284
483
|
const handle = getTerminalHandle();
|
|
285
484
|
if (!handle?.readStop) return;
|
|
286
485
|
handle.reading = false;
|
|
@@ -294,43 +493,274 @@ function startReadingTerminal() {
|
|
|
294
493
|
}
|
|
295
494
|
|
|
296
495
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
297
|
-
import {
|
|
298
|
-
import {
|
|
496
|
+
import { useEffect as useEffect3, useState as useState5 } from "react";
|
|
497
|
+
import { Box as Box5, Text as Text5, useInput as useInput5 } from "ink";
|
|
498
|
+
|
|
499
|
+
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
500
|
+
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
501
|
+
import { existsSync as existsSync3, readdirSync } from "node:fs";
|
|
502
|
+
import { join as join5 } from "node:path";
|
|
503
|
+
|
|
504
|
+
// packages/experience-design-system-types/dist/src/config/index.js
|
|
505
|
+
import { randomBytes } from "node:crypto";
|
|
506
|
+
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
507
|
+
import { homedir as homedir2 } from "node:os";
|
|
508
|
+
import { dirname as dirname2, join as join4 } from "node:path";
|
|
509
|
+
function configRoot() {
|
|
510
|
+
return process.env["EDS_HOME"] || join4(homedir2(), ".contentful", "experience-design-system-cli");
|
|
511
|
+
}
|
|
512
|
+
var configFilePath = () => join4(configRoot(), "config.json");
|
|
513
|
+
var debugSessionsDir = () => join4(configRoot(), "debug", "sessions");
|
|
514
|
+
async function readSettings() {
|
|
515
|
+
try {
|
|
516
|
+
return JSON.parse(await readFile(configFilePath(), "utf8"));
|
|
517
|
+
} catch {
|
|
518
|
+
return {};
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
async function writeSettings(settings) {
|
|
522
|
+
const path = configFilePath();
|
|
523
|
+
await mkdir(dirname2(path), { recursive: true });
|
|
524
|
+
const tmp = `${path}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
525
|
+
await writeFile(tmp, `${JSON.stringify(settings, null, 2)}
|
|
526
|
+
`, { mode: 384 });
|
|
527
|
+
await rename(tmp, path);
|
|
528
|
+
}
|
|
529
|
+
async function updateSettings(patch) {
|
|
530
|
+
await writeSettings({ ...await readSettings(), ...patch });
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
|
|
534
|
+
var DEFAULT_DEBUG_MODE_SETTING = {
|
|
535
|
+
enabled: true
|
|
536
|
+
};
|
|
537
|
+
async function readDebugModeSetting() {
|
|
538
|
+
const { debugMode } = await readSettings();
|
|
539
|
+
return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
|
|
540
|
+
}
|
|
541
|
+
async function writeDebugModeSetting(setting) {
|
|
542
|
+
await updateSettings({ debugMode: setting });
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
546
|
+
var pendingRun;
|
|
547
|
+
function generateRunId() {
|
|
548
|
+
const now = /* @__PURE__ */ new Date();
|
|
549
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
550
|
+
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
551
|
+
}
|
|
552
|
+
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
553
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
554
|
+
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
555
|
+
}
|
|
556
|
+
function slugify(value) {
|
|
557
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
558
|
+
}
|
|
559
|
+
function generateSessionId() {
|
|
560
|
+
const today = datePrefix();
|
|
561
|
+
const root = debugSessionsDir();
|
|
562
|
+
const existing = existsSync3(root) ? readdirSync(root) : [];
|
|
563
|
+
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
564
|
+
const maxSeq = existing.reduce((max, entry) => {
|
|
565
|
+
const match = seqPattern.exec(entry);
|
|
566
|
+
return match ? Math.max(max, Number(match[1])) : max;
|
|
567
|
+
}, 0);
|
|
568
|
+
return `${today}-session-${maxSeq + 1}`;
|
|
569
|
+
}
|
|
570
|
+
var SESSION_ID = generateSessionId();
|
|
571
|
+
function sessionDebugDir() {
|
|
572
|
+
return join5(debugSessionsDir(), SESSION_ID);
|
|
573
|
+
}
|
|
574
|
+
function currentDebugSessionDir() {
|
|
575
|
+
return sessionDebugDir();
|
|
576
|
+
}
|
|
577
|
+
void isDebugModeEnabled().then((enabled) => {
|
|
578
|
+
if (!enabled) return void 0;
|
|
579
|
+
return mkdir2(sessionDebugDir(), { recursive: true });
|
|
580
|
+
});
|
|
581
|
+
async function isDebugModeEnabled() {
|
|
582
|
+
try {
|
|
583
|
+
return (await readDebugModeSetting()).enabled;
|
|
584
|
+
} catch {
|
|
585
|
+
return true;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
function redact(value) {
|
|
589
|
+
const clone = { ...value };
|
|
590
|
+
if ("cma_token" in clone) {
|
|
591
|
+
const raw = clone.cma_token;
|
|
592
|
+
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
593
|
+
}
|
|
594
|
+
return clone;
|
|
595
|
+
}
|
|
596
|
+
function startDebugRun({
|
|
597
|
+
flow,
|
|
598
|
+
step,
|
|
599
|
+
menuOption,
|
|
600
|
+
inputs
|
|
601
|
+
}) {
|
|
602
|
+
const runId = generateRunId();
|
|
603
|
+
const startedAt = Date.now();
|
|
604
|
+
const redactedInputs = redact(inputs);
|
|
605
|
+
isDebugModeEnabled().then((enabled) => {
|
|
606
|
+
if (!enabled) return;
|
|
607
|
+
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
async function finishDebugRun({
|
|
611
|
+
outputs,
|
|
612
|
+
status,
|
|
613
|
+
exitMethod
|
|
614
|
+
}) {
|
|
615
|
+
const run = pendingRun;
|
|
616
|
+
if (!run) return;
|
|
617
|
+
pendingRun = void 0;
|
|
618
|
+
const durationMs = Date.now() - run.startedAt;
|
|
619
|
+
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
620
|
+
const flowSegments = run.flow.split("/");
|
|
621
|
+
const dir = join5(sessionDebugDir(), ...flowSegments);
|
|
622
|
+
await mkdir2(dir, { recursive: true });
|
|
623
|
+
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
624
|
+
await writeFile2(join5(dir, filename), content, { mode: 384 });
|
|
625
|
+
}
|
|
626
|
+
function nextAttemptFilename(dir, menuOption) {
|
|
627
|
+
const today = datePrefix();
|
|
628
|
+
const optionSlug = slugify(menuOption);
|
|
629
|
+
const existing = existsSync3(dir) ? readdirSync(dir) : [];
|
|
630
|
+
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
631
|
+
const maxAttempt = existing.reduce((max, entry) => {
|
|
632
|
+
const match = attemptPattern.exec(entry);
|
|
633
|
+
return match ? Math.max(max, Number(match[1])) : max;
|
|
634
|
+
}, 0);
|
|
635
|
+
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
636
|
+
}
|
|
637
|
+
function renderMarkdown(run, finish) {
|
|
638
|
+
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
639
|
+
const stepLabel = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
640
|
+
const flowSlug = run.flow.split("/").join("-");
|
|
641
|
+
return `# Debug Log
|
|
642
|
+
|
|
643
|
+
- Run ID: ${run.runId}
|
|
644
|
+
- Flow: ${flowSlug}
|
|
645
|
+
- Step: ${stepLabel}
|
|
646
|
+
- Menu option: ${run.menuOption}
|
|
647
|
+
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
648
|
+
- CLI version: ${readPackageVersion()}
|
|
649
|
+
- Platform: ${process.platform} / Node ${process.version}
|
|
650
|
+
- Duration on screen: ${finish.durationMs}ms
|
|
651
|
+
- Status: ${finish.status}
|
|
652
|
+
- Exit method: ${finish.exitMethod}
|
|
653
|
+
|
|
654
|
+
## Inputs
|
|
655
|
+
\`\`\`json
|
|
656
|
+
${JSON.stringify(run.inputs, null, 2)}
|
|
657
|
+
\`\`\`
|
|
658
|
+
|
|
659
|
+
## Outputs
|
|
660
|
+
\`\`\`json
|
|
661
|
+
${JSON.stringify(finish.outputs, null, 2)}
|
|
662
|
+
\`\`\`
|
|
663
|
+
`;
|
|
664
|
+
}
|
|
665
|
+
function handleCrash() {
|
|
666
|
+
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
667
|
+
}
|
|
668
|
+
process.once("uncaughtException", (err) => {
|
|
669
|
+
void handleCrash().finally(() => {
|
|
670
|
+
throw err;
|
|
671
|
+
});
|
|
672
|
+
});
|
|
673
|
+
process.once("unhandledRejection", (reason) => {
|
|
674
|
+
void handleCrash().finally(() => {
|
|
675
|
+
throw reason;
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
process.once("SIGINT", () => {
|
|
679
|
+
void handleCrash().finally(() => {
|
|
680
|
+
process.exit(130);
|
|
681
|
+
});
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
// packages/experience-design-system-cli/src/tui/help/help-info.ts
|
|
685
|
+
async function readHelpInfo() {
|
|
686
|
+
const debugMode = await readDebugModeSetting();
|
|
687
|
+
return {
|
|
688
|
+
storage: [
|
|
689
|
+
{ label: "Config folder", value: configRoot() },
|
|
690
|
+
{ label: "Settings file", value: configFilePath() },
|
|
691
|
+
{ label: "Debug logs", value: debugSessionsDir() },
|
|
692
|
+
{ label: "Move it with", value: process.env["EDS_HOME"] ? "EDS_HOME (set)" : "EDS_HOME (not set)" }
|
|
693
|
+
],
|
|
694
|
+
troubleshooting: [
|
|
695
|
+
{ label: "CLI version", value: readPackageVersion() },
|
|
696
|
+
{ label: "Node", value: process.version },
|
|
697
|
+
{ label: "Platform", value: `${process.platform} ${process.arch}` },
|
|
698
|
+
{ label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
|
|
699
|
+
{
|
|
700
|
+
label: "This session",
|
|
701
|
+
value: debugMode.enabled ? currentDebugSessionDir() : "no logs written while Debug Mode is off"
|
|
702
|
+
}
|
|
703
|
+
]
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
708
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
709
|
+
function Section({ title, rows }) {
|
|
710
|
+
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
|
|
711
|
+
/* @__PURE__ */ jsx5(Text5, { bold: true, color: PALETTE.accent, children: title }),
|
|
712
|
+
rows.map((row) => /* @__PURE__ */ jsxs5(Box5, { gap: 1, children: [
|
|
713
|
+
/* @__PURE__ */ jsx5(Box5, { width: 14, flexShrink: 0, children: /* @__PURE__ */ jsx5(Text5, { dimColor: true, children: row.label }) }),
|
|
714
|
+
/* @__PURE__ */ jsx5(Text5, { children: row.value })
|
|
715
|
+
] }, row.label))
|
|
716
|
+
] });
|
|
717
|
+
}
|
|
299
718
|
function HelpScreen({ onDone }) {
|
|
300
|
-
|
|
719
|
+
const [info, setInfo] = useState5();
|
|
720
|
+
useEffect3(() => {
|
|
721
|
+
startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
|
|
722
|
+
void readHelpInfo().then(setInfo);
|
|
723
|
+
}, []);
|
|
724
|
+
const leave = (exitMethod) => {
|
|
725
|
+
void finishDebugRun({ outputs: {}, status: "success", exitMethod });
|
|
726
|
+
onDone();
|
|
727
|
+
};
|
|
728
|
+
useInput5((input, key) => {
|
|
301
729
|
if (key.return) {
|
|
302
|
-
|
|
730
|
+
leave("saved");
|
|
303
731
|
return;
|
|
304
732
|
}
|
|
305
733
|
if (key.escape || input === "q") {
|
|
306
|
-
|
|
734
|
+
leave("discarded");
|
|
307
735
|
return;
|
|
308
736
|
}
|
|
309
737
|
});
|
|
310
|
-
return /* @__PURE__ */
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
/* @__PURE__ */
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
738
|
+
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", paddingX: 2, paddingY: 1, gap: 1, children: [
|
|
739
|
+
/* @__PURE__ */ jsx5(Text5, { bold: true, children: "Help" }),
|
|
740
|
+
info ? /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
741
|
+
/* @__PURE__ */ jsx5(Section, { title: "Where things are stored", rows: info.storage }),
|
|
742
|
+
/* @__PURE__ */ jsx5(Section, { title: "Troubleshooting", rows: info.troubleshooting }),
|
|
743
|
+
/* @__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." })
|
|
744
|
+
] }) : /* @__PURE__ */ jsx5(Text5, { color: PALETTE.accent, children: "Loading..." }),
|
|
745
|
+
/* @__PURE__ */ jsx5(Text5, { dimColor: true, children: "[Enter] Complete [Esc/q] Exit \u2014 both return to Start" })
|
|
316
746
|
] });
|
|
317
747
|
}
|
|
318
748
|
|
|
319
749
|
// packages/experience-design-system-cli/src/tui/settings/PageContainer.tsx
|
|
320
|
-
import { useState as
|
|
321
|
-
import { Box as
|
|
322
|
-
import { jsx as
|
|
750
|
+
import { useState as useState6 } from "react";
|
|
751
|
+
import { Box as Box6, Text as Text6, useInput as useInput6 } from "ink";
|
|
752
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
323
753
|
function SettingsScreen({
|
|
324
754
|
onNavigate,
|
|
325
755
|
onBack
|
|
326
756
|
}) {
|
|
327
|
-
const [focusIdx, setFocusIdx] =
|
|
757
|
+
const [focusIdx, setFocusIdx] = useState6(0);
|
|
328
758
|
const items = [
|
|
329
759
|
{ label: "Configuration", screen: "settings-configuration" },
|
|
330
760
|
{ label: "Opt-in Analytics", screen: "settings-opt-in-analytics" },
|
|
331
761
|
{ label: "Debug Mode", screen: "settings-debug-mode" }
|
|
332
762
|
];
|
|
333
|
-
|
|
763
|
+
useInput6((input, key) => {
|
|
334
764
|
if (key.upArrow) {
|
|
335
765
|
setFocusIdx((i) => (i - 1 + items.length) % items.length);
|
|
336
766
|
return;
|
|
@@ -350,40 +780,26 @@ function SettingsScreen({
|
|
|
350
780
|
onBack();
|
|
351
781
|
}
|
|
352
782
|
});
|
|
353
|
-
return /* @__PURE__ */
|
|
354
|
-
/* @__PURE__ */
|
|
355
|
-
/* @__PURE__ */
|
|
356
|
-
items.map((item, i) => /* @__PURE__ */
|
|
783
|
+
return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
784
|
+
/* @__PURE__ */ jsx6(Text6, { bold: true, children: "Settings" }),
|
|
785
|
+
/* @__PURE__ */ jsx6(Text6, { children: " " }),
|
|
786
|
+
items.map((item, i) => /* @__PURE__ */ jsxs6(Text6, { color: i === focusIdx ? "cyan" : void 0, children: [
|
|
357
787
|
i === focusIdx ? "> " : " ",
|
|
358
788
|
item.label
|
|
359
789
|
] }, item.label)),
|
|
360
|
-
/* @__PURE__ */
|
|
361
|
-
/* @__PURE__ */
|
|
790
|
+
/* @__PURE__ */ jsx6(Text6, { children: " " }),
|
|
791
|
+
/* @__PURE__ */ jsx6(Text6, { dimColor: true, children: "[\u2191/\u2193] Navigate [Enter] Select [Esc/q] Back to Start" })
|
|
362
792
|
] });
|
|
363
793
|
}
|
|
364
794
|
|
|
365
795
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
366
|
-
import { useEffect as
|
|
367
|
-
import { Box as
|
|
796
|
+
import { useEffect as useEffect4, useState as useState7 } from "react";
|
|
797
|
+
import { Box as Box7, Text as Text7, useInput as useInput7 } from "ink";
|
|
798
|
+
import TextInput3 from "ink-text-input";
|
|
368
799
|
|
|
369
800
|
// packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
import { homedir } from "node:os";
|
|
373
|
-
var V1_STORE_PATH = join4(homedir(), ".config", "experiences", "credentials.json");
|
|
374
|
-
async function readV1Store() {
|
|
375
|
-
try {
|
|
376
|
-
const raw = await readFile(V1_STORE_PATH, "utf8");
|
|
377
|
-
return JSON.parse(raw);
|
|
378
|
-
} catch {
|
|
379
|
-
return {};
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
async function writeV1Store(data) {
|
|
383
|
-
await mkdir(join4(homedir(), ".config", "experiences"), { recursive: true });
|
|
384
|
-
await writeFile(V1_STORE_PATH, `${JSON.stringify(data, null, 2)}
|
|
385
|
-
`, { mode: 384 });
|
|
386
|
-
}
|
|
801
|
+
var readV1Store = readSettings;
|
|
802
|
+
var writeV1Store = writeSettings;
|
|
387
803
|
|
|
388
804
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/config-store.ts
|
|
389
805
|
async function readCredentials() {
|
|
@@ -392,7 +808,9 @@ async function readCredentials() {
|
|
|
392
808
|
spaceId: store.spaceId || "",
|
|
393
809
|
environmentId: store.environmentId || "",
|
|
394
810
|
cmaToken: store.cmaToken || "",
|
|
395
|
-
host: store.host || ""
|
|
811
|
+
host: store.host || "",
|
|
812
|
+
defaultComponentDir: store.defaultComponentDir || "",
|
|
813
|
+
defaultTokenFile: store.defaultTokenFile || ""
|
|
396
814
|
};
|
|
397
815
|
}
|
|
398
816
|
async function writeCredentials(config) {
|
|
@@ -408,23 +826,51 @@ async function writeCredentials(config) {
|
|
|
408
826
|
}
|
|
409
827
|
|
|
410
828
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
411
|
-
import { Fragment, jsx as
|
|
412
|
-
var FIELD_ORDER = [
|
|
829
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
830
|
+
var FIELD_ORDER = [
|
|
831
|
+
"spaceId",
|
|
832
|
+
"environmentId",
|
|
833
|
+
"cmaToken",
|
|
834
|
+
"host",
|
|
835
|
+
"defaultComponentDir",
|
|
836
|
+
"defaultTokenFile"
|
|
837
|
+
];
|
|
838
|
+
function debugFields(config) {
|
|
839
|
+
return {
|
|
840
|
+
space_id: config?.spaceId ?? "",
|
|
841
|
+
environment_id: config?.environmentId ?? "",
|
|
842
|
+
cma_token: config?.cmaToken ?? "",
|
|
843
|
+
host: config?.host ?? "",
|
|
844
|
+
default_component_dir: config?.defaultComponentDir ?? "",
|
|
845
|
+
default_token_file: config?.defaultTokenFile ?? ""
|
|
846
|
+
};
|
|
847
|
+
}
|
|
413
848
|
var FIELD_LABELS = {
|
|
414
849
|
spaceId: "Space ID",
|
|
415
850
|
environmentId: "Environment ID",
|
|
416
851
|
cmaToken: "CMA Token",
|
|
417
|
-
host: "API Host (optional)"
|
|
852
|
+
host: "API Host (optional)",
|
|
853
|
+
defaultComponentDir: "Default component directory (optional)",
|
|
854
|
+
defaultTokenFile: "Default token file (optional)"
|
|
418
855
|
};
|
|
419
856
|
function ConfigurationScreen({ onDone }) {
|
|
420
|
-
const [stage, setStage] =
|
|
421
|
-
const [config, setConfig] =
|
|
422
|
-
const [activeField, setActiveField] =
|
|
423
|
-
const [
|
|
424
|
-
|
|
857
|
+
const [stage, setStage] = useState7("loading");
|
|
858
|
+
const [config, setConfig] = useState7(null);
|
|
859
|
+
const [activeField, setActiveField] = useState7("spaceId");
|
|
860
|
+
const [notice, setNotice] = useState7(null);
|
|
861
|
+
const [lastSaved, setLastSaved] = useState7(null);
|
|
862
|
+
const [editing, setEditing] = useState7(false);
|
|
863
|
+
const [valueBeforeEdit, setValueBeforeEdit] = useState7("");
|
|
864
|
+
useEffect4(() => {
|
|
425
865
|
readCredentials().then((cfg) => {
|
|
426
866
|
setConfig(cfg);
|
|
427
867
|
setStage("form");
|
|
868
|
+
startDebugRun({
|
|
869
|
+
flow: "settings/contentful-configuration",
|
|
870
|
+
step: "01-configuration",
|
|
871
|
+
menuOption: "Configuration",
|
|
872
|
+
inputs: debugFields(cfg)
|
|
873
|
+
});
|
|
428
874
|
});
|
|
429
875
|
}, []);
|
|
430
876
|
function fieldValue(field) {
|
|
@@ -434,29 +880,46 @@ function ConfigurationScreen({ onDone }) {
|
|
|
434
880
|
function setFieldValue(field, value) {
|
|
435
881
|
if (!config) return;
|
|
436
882
|
setConfig({ ...config, [field]: value });
|
|
883
|
+
setNotice(null);
|
|
437
884
|
}
|
|
438
885
|
function handleSave() {
|
|
439
886
|
if (!config) return;
|
|
440
887
|
setStage("saving");
|
|
441
|
-
|
|
888
|
+
setNotice(null);
|
|
442
889
|
writeCredentials(config).then(() => {
|
|
443
|
-
|
|
444
|
-
|
|
890
|
+
setLastSaved(config);
|
|
891
|
+
setNotice({ kind: "success", text: "Configuration saved" });
|
|
892
|
+
setStage("form");
|
|
445
893
|
}).catch((err) => {
|
|
446
|
-
|
|
894
|
+
setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
|
|
447
895
|
setStage("form");
|
|
448
896
|
});
|
|
449
897
|
}
|
|
450
|
-
|
|
898
|
+
function quit() {
|
|
899
|
+
void finishDebugRun(
|
|
900
|
+
lastSaved ? { outputs: debugFields(lastSaved), status: "success", exitMethod: "saved" } : { outputs: {}, status: "success", exitMethod: "discarded" }
|
|
901
|
+
);
|
|
902
|
+
onDone();
|
|
903
|
+
}
|
|
904
|
+
useInput7((input, key) => {
|
|
451
905
|
if (stage === "loading" || stage === "saving") return;
|
|
452
|
-
if (
|
|
453
|
-
if (key.
|
|
454
|
-
|
|
906
|
+
if (editing) {
|
|
907
|
+
if (key.escape) {
|
|
908
|
+
setFieldValue(activeField, valueBeforeEdit);
|
|
909
|
+
setEditing(false);
|
|
455
910
|
}
|
|
456
911
|
return;
|
|
457
912
|
}
|
|
458
913
|
if (key.escape || input === "q") {
|
|
459
|
-
|
|
914
|
+
quit();
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
if (input === "s") {
|
|
918
|
+
handleSave();
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
if (input === "c") {
|
|
922
|
+
setFieldValue(activeField, "");
|
|
460
923
|
return;
|
|
461
924
|
}
|
|
462
925
|
if (key.tab || key.downArrow) {
|
|
@@ -470,75 +933,57 @@ function ConfigurationScreen({ onDone }) {
|
|
|
470
933
|
return;
|
|
471
934
|
}
|
|
472
935
|
if (key.return) {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
setActiveField(FIELD_ORDER[idx + 1]);
|
|
476
|
-
} else {
|
|
477
|
-
handleSave();
|
|
478
|
-
}
|
|
479
|
-
return;
|
|
480
|
-
}
|
|
481
|
-
if (key.backspace || key.delete) {
|
|
482
|
-
const current = fieldValue(activeField);
|
|
483
|
-
setFieldValue(activeField, current.slice(0, -1));
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
if (input && !key.ctrl && !key.meta) {
|
|
487
|
-
setFieldValue(activeField, fieldValue(activeField) + input);
|
|
936
|
+
setValueBeforeEdit(fieldValue(activeField));
|
|
937
|
+
setEditing(true);
|
|
488
938
|
}
|
|
489
939
|
});
|
|
490
940
|
if (stage === "loading") {
|
|
491
|
-
return /* @__PURE__ */
|
|
492
|
-
/* @__PURE__ */
|
|
493
|
-
/* @__PURE__ */
|
|
494
|
-
/* @__PURE__ */
|
|
941
|
+
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
942
|
+
/* @__PURE__ */ jsx7(Text7, { bold: true, children: "Configuration" }),
|
|
943
|
+
/* @__PURE__ */ jsx7(Text7, { children: " " }),
|
|
944
|
+
/* @__PURE__ */ jsx7(Text7, { color: PALETTE.accent, children: "Loading..." })
|
|
495
945
|
] });
|
|
496
946
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
/* @__PURE__ */ jsxs5(Text5, { color: PALETTE.success, children: [
|
|
502
|
-
"\u2713 ",
|
|
503
|
-
message
|
|
504
|
-
] }),
|
|
505
|
-
/* @__PURE__ */ jsx5(Text5, { children: " " }),
|
|
506
|
-
/* @__PURE__ */ jsx5(Text5, { dimColor: true, children: "[Enter] Back to Settings" })
|
|
507
|
-
] });
|
|
508
|
-
}
|
|
509
|
-
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
510
|
-
/* @__PURE__ */ jsx5(Text5, { bold: true, children: "Configuration" }),
|
|
511
|
-
/* @__PURE__ */ jsx5(Text5, { children: " " }),
|
|
512
|
-
/* @__PURE__ */ jsx5(Text5, { children: "Contentful API Credentials" }),
|
|
513
|
-
/* @__PURE__ */ jsx5(Text5, { children: " " }),
|
|
514
|
-
/* @__PURE__ */ jsx5(Box5, { flexDirection: "column", children: FIELD_ORDER.map((field) => {
|
|
947
|
+
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
948
|
+
/* @__PURE__ */ jsx7(Text7, { bold: true, children: "Configuration" }),
|
|
949
|
+
/* @__PURE__ */ jsx7(Text7, { children: " " }),
|
|
950
|
+
/* @__PURE__ */ jsx7(Box7, { flexDirection: "column", children: FIELD_ORDER.map((field) => {
|
|
515
951
|
const isActive = activeField === field;
|
|
516
952
|
const value = fieldValue(field);
|
|
517
953
|
const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
|
|
518
|
-
return /* @__PURE__ */
|
|
519
|
-
/* @__PURE__ */
|
|
520
|
-
/* @__PURE__ */
|
|
954
|
+
return /* @__PURE__ */ jsxs7(Box7, { gap: 1, children: [
|
|
955
|
+
/* @__PURE__ */ jsx7(Text7, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
|
|
956
|
+
/* @__PURE__ */ jsxs7(Text7, { bold: isActive, children: [
|
|
521
957
|
FIELD_LABELS[field],
|
|
522
958
|
":"
|
|
523
959
|
] }),
|
|
524
|
-
|
|
960
|
+
isActive && editing ? /* @__PURE__ */ jsx7(
|
|
961
|
+
TextInput3,
|
|
962
|
+
{
|
|
963
|
+
value,
|
|
964
|
+
onChange: (next) => setFieldValue(field, next),
|
|
965
|
+
onSubmit: () => setEditing(false),
|
|
966
|
+
mask: field === "cmaToken" ? "\u2022" : void 0
|
|
967
|
+
}
|
|
968
|
+
) : /* @__PURE__ */ jsx7(Text7, { children: display || /* @__PURE__ */ jsx7(Text7, { dimColor: true, children: "(empty)" }) })
|
|
525
969
|
] }, field);
|
|
526
970
|
}) }),
|
|
527
|
-
|
|
528
|
-
/* @__PURE__ */
|
|
529
|
-
/* @__PURE__ */
|
|
530
|
-
"\
|
|
531
|
-
|
|
971
|
+
notice && /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
972
|
+
/* @__PURE__ */ jsx7(Text7, { children: " " }),
|
|
973
|
+
/* @__PURE__ */ jsxs7(Text7, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
|
|
974
|
+
notice.kind === "success" ? "\u2713" : "\u2717",
|
|
975
|
+
" ",
|
|
976
|
+
notice.text
|
|
532
977
|
] })
|
|
533
978
|
] }),
|
|
534
|
-
/* @__PURE__ */
|
|
535
|
-
/* @__PURE__ */
|
|
979
|
+
/* @__PURE__ */ jsx7(Text7, { children: " " }),
|
|
980
|
+
/* @__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" })
|
|
536
981
|
] });
|
|
537
982
|
}
|
|
538
983
|
|
|
539
984
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
540
|
-
import { useEffect as
|
|
541
|
-
import { Box as
|
|
985
|
+
import { useEffect as useEffect5, useState as useState8 } from "react";
|
|
986
|
+
import { Box as Box8, Text as Text8, useInput as useInput8 } from "ink";
|
|
542
987
|
|
|
543
988
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
|
|
544
989
|
async function readAnalyticsSetting() {
|
|
@@ -556,17 +1001,23 @@ async function writeAnalyticsSetting(setting) {
|
|
|
556
1001
|
}
|
|
557
1002
|
|
|
558
1003
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
559
|
-
import { Fragment as
|
|
1004
|
+
import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
560
1005
|
function OptInAnalyticsScreen({ onDone }) {
|
|
561
|
-
const [loading, setLoading] =
|
|
562
|
-
const [enabled, setEnabled] =
|
|
563
|
-
|
|
1006
|
+
const [loading, setLoading] = useState8(true);
|
|
1007
|
+
const [enabled, setEnabled] = useState8(true);
|
|
1008
|
+
useEffect5(() => {
|
|
564
1009
|
readAnalyticsSetting().then((setting) => {
|
|
565
1010
|
setEnabled(setting.enabled);
|
|
566
1011
|
setLoading(false);
|
|
1012
|
+
startDebugRun({
|
|
1013
|
+
flow: "settings/opt-in-analytics",
|
|
1014
|
+
step: "01-opt-in-analytics",
|
|
1015
|
+
menuOption: "Opt-in Analytics",
|
|
1016
|
+
inputs: { enabled: setting.enabled }
|
|
1017
|
+
});
|
|
567
1018
|
});
|
|
568
1019
|
}, []);
|
|
569
|
-
|
|
1020
|
+
useInput8((input, key) => {
|
|
570
1021
|
if (loading) return;
|
|
571
1022
|
if (key.return || input === " ") {
|
|
572
1023
|
setEnabled((current) => {
|
|
@@ -577,208 +1028,36 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
577
1028
|
return;
|
|
578
1029
|
}
|
|
579
1030
|
if (key.escape || input === "q") {
|
|
1031
|
+
void finishDebugRun({ outputs: { enabled }, status: "success", exitMethod: "saved" });
|
|
580
1032
|
onDone();
|
|
581
1033
|
}
|
|
582
1034
|
});
|
|
583
|
-
return /* @__PURE__ */
|
|
584
|
-
/* @__PURE__ */
|
|
585
|
-
/* @__PURE__ */
|
|
586
|
-
loading ? /* @__PURE__ */
|
|
587
|
-
/* @__PURE__ */
|
|
1035
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1036
|
+
/* @__PURE__ */ jsx8(Text8, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
|
|
1037
|
+
/* @__PURE__ */ jsx8(Text8, { children: " " }),
|
|
1038
|
+
loading ? /* @__PURE__ */ jsx8(Text8, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
1039
|
+
/* @__PURE__ */ jsxs8(Text8, { children: [
|
|
588
1040
|
"Share anonymous usage data:",
|
|
589
1041
|
" ",
|
|
590
|
-
/* @__PURE__ */
|
|
1042
|
+
/* @__PURE__ */ jsx8(Text8, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
591
1043
|
] }),
|
|
592
|
-
/* @__PURE__ */
|
|
593
|
-
/* @__PURE__ */
|
|
594
|
-
/* @__PURE__ */
|
|
1044
|
+
/* @__PURE__ */ jsx8(Text8, { children: " " }),
|
|
1045
|
+
/* @__PURE__ */ jsx8(Text8, { dimColor: true, children: "Shares which CLI commands are used and where imports succeed or fail." }),
|
|
1046
|
+
/* @__PURE__ */ jsx8(Text8, { dimColor: true, children: "Never includes source code, file paths, credentials, or authored content." })
|
|
595
1047
|
] }),
|
|
596
|
-
/* @__PURE__ */
|
|
597
|
-
/* @__PURE__ */
|
|
1048
|
+
/* @__PURE__ */ jsx8(Text8, { children: " " }),
|
|
1049
|
+
/* @__PURE__ */ jsx8(Text8, { dimColor: true, children: "[Enter/Space] Toggle [Esc/q] Back to Settings" })
|
|
598
1050
|
] });
|
|
599
1051
|
}
|
|
600
1052
|
|
|
601
1053
|
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
602
|
-
import { useEffect as
|
|
603
|
-
import { Box as
|
|
604
|
-
|
|
605
|
-
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
606
|
-
import { mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
|
|
607
|
-
import { existsSync as existsSync3, readdirSync } from "node:fs";
|
|
608
|
-
import { join as join6 } from "node:path";
|
|
609
|
-
|
|
610
|
-
// packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
|
|
611
|
-
import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
612
|
-
import { dirname as dirname2, join as join5 } from "node:path";
|
|
613
|
-
var PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
|
|
614
|
-
var DEFAULT_DEBUG_MODE_SETTING = {
|
|
615
|
-
enabled: true
|
|
616
|
-
};
|
|
617
|
-
function debugModeSettingPath() {
|
|
618
|
-
return join5(findPackageRoot(import.meta.url, PACKAGE_NAME3), ".contentful", "config", "debug_mode.json");
|
|
619
|
-
}
|
|
620
|
-
async function readDebugModeSetting() {
|
|
621
|
-
try {
|
|
622
|
-
const raw = await readFile2(debugModeSettingPath(), "utf8");
|
|
623
|
-
const parsed = JSON.parse(raw);
|
|
624
|
-
return { ...DEFAULT_DEBUG_MODE_SETTING, ...parsed };
|
|
625
|
-
} catch {
|
|
626
|
-
return { ...DEFAULT_DEBUG_MODE_SETTING };
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
async function writeDebugModeSetting(setting) {
|
|
630
|
-
const path = debugModeSettingPath();
|
|
631
|
-
await mkdir2(dirname2(path), { recursive: true });
|
|
632
|
-
await writeFile2(path, `${JSON.stringify(setting, null, 2)}
|
|
633
|
-
`, { mode: 384 });
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
637
|
-
var PACKAGE_NAME4 = "@contentful/experience-design-system-cli";
|
|
638
|
-
var pendingRun;
|
|
639
|
-
function generateRunId() {
|
|
640
|
-
const now = /* @__PURE__ */ new Date();
|
|
641
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
642
|
-
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
643
|
-
}
|
|
644
|
-
function sessionsRootDir() {
|
|
645
|
-
return join6(findPackageRoot(import.meta.url, PACKAGE_NAME4), ".contentful", "debug", "sessions");
|
|
646
|
-
}
|
|
647
|
-
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
648
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
649
|
-
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
650
|
-
}
|
|
651
|
-
function slugify(value) {
|
|
652
|
-
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
653
|
-
}
|
|
654
|
-
function generateSessionId() {
|
|
655
|
-
const today = datePrefix();
|
|
656
|
-
const root = sessionsRootDir();
|
|
657
|
-
const existing = existsSync3(root) ? readdirSync(root) : [];
|
|
658
|
-
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
659
|
-
const maxSeq = existing.reduce((max, entry) => {
|
|
660
|
-
const match = seqPattern.exec(entry);
|
|
661
|
-
return match ? Math.max(max, Number(match[1])) : max;
|
|
662
|
-
}, 0);
|
|
663
|
-
return `${today}-session-${maxSeq + 1}`;
|
|
664
|
-
}
|
|
665
|
-
var SESSION_ID = generateSessionId();
|
|
666
|
-
function sessionDebugDir() {
|
|
667
|
-
return join6(sessionsRootDir(), SESSION_ID);
|
|
668
|
-
}
|
|
669
|
-
void isDebugModeEnabled().then((enabled) => {
|
|
670
|
-
if (!enabled) return void 0;
|
|
671
|
-
return mkdir3(sessionDebugDir(), { recursive: true });
|
|
672
|
-
});
|
|
673
|
-
async function isDebugModeEnabled() {
|
|
674
|
-
try {
|
|
675
|
-
return (await readDebugModeSetting()).enabled;
|
|
676
|
-
} catch {
|
|
677
|
-
return true;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
function redact(value) {
|
|
681
|
-
const clone = { ...value };
|
|
682
|
-
if ("cma_token" in clone) {
|
|
683
|
-
const raw = clone.cma_token;
|
|
684
|
-
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
685
|
-
}
|
|
686
|
-
return clone;
|
|
687
|
-
}
|
|
688
|
-
function startDebugRun({
|
|
689
|
-
flow,
|
|
690
|
-
step,
|
|
691
|
-
menuOption,
|
|
692
|
-
inputs
|
|
693
|
-
}) {
|
|
694
|
-
const runId = generateRunId();
|
|
695
|
-
const startedAt = Date.now();
|
|
696
|
-
const redactedInputs = redact(inputs);
|
|
697
|
-
isDebugModeEnabled().then((enabled) => {
|
|
698
|
-
if (!enabled) return;
|
|
699
|
-
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
async function finishDebugRun({
|
|
703
|
-
outputs,
|
|
704
|
-
status,
|
|
705
|
-
exitMethod
|
|
706
|
-
}) {
|
|
707
|
-
const run = pendingRun;
|
|
708
|
-
if (!run) return;
|
|
709
|
-
pendingRun = void 0;
|
|
710
|
-
const durationMs = Date.now() - run.startedAt;
|
|
711
|
-
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
712
|
-
const flowSegments = run.flow.split("/");
|
|
713
|
-
const dir = join6(sessionDebugDir(), ...flowSegments);
|
|
714
|
-
await mkdir3(dir, { recursive: true });
|
|
715
|
-
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
716
|
-
await writeFile3(join6(dir, filename), content, { mode: 384 });
|
|
717
|
-
}
|
|
718
|
-
function nextAttemptFilename(dir, menuOption) {
|
|
719
|
-
const today = datePrefix();
|
|
720
|
-
const optionSlug = slugify(menuOption);
|
|
721
|
-
const existing = existsSync3(dir) ? readdirSync(dir) : [];
|
|
722
|
-
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
723
|
-
const maxAttempt = existing.reduce((max, entry) => {
|
|
724
|
-
const match = attemptPattern.exec(entry);
|
|
725
|
-
return match ? Math.max(max, Number(match[1])) : max;
|
|
726
|
-
}, 0);
|
|
727
|
-
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
728
|
-
}
|
|
729
|
-
function renderMarkdown(run, finish) {
|
|
730
|
-
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
731
|
-
const stepLabel = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
732
|
-
const flowSlug = run.flow.split("/").join("-");
|
|
733
|
-
return `# Debug Log
|
|
734
|
-
|
|
735
|
-
- Run ID: ${run.runId}
|
|
736
|
-
- Flow: ${flowSlug}
|
|
737
|
-
- Step: ${stepLabel}
|
|
738
|
-
- Menu option: ${run.menuOption}
|
|
739
|
-
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
740
|
-
- CLI version: ${readPackageVersion()}
|
|
741
|
-
- Platform: ${process.platform} / Node ${process.version}
|
|
742
|
-
- Duration on screen: ${finish.durationMs}ms
|
|
743
|
-
- Status: ${finish.status}
|
|
744
|
-
- Exit method: ${finish.exitMethod}
|
|
745
|
-
|
|
746
|
-
## Inputs
|
|
747
|
-
\`\`\`json
|
|
748
|
-
${JSON.stringify(run.inputs, null, 2)}
|
|
749
|
-
\`\`\`
|
|
750
|
-
|
|
751
|
-
## Outputs
|
|
752
|
-
\`\`\`json
|
|
753
|
-
${JSON.stringify(finish.outputs, null, 2)}
|
|
754
|
-
\`\`\`
|
|
755
|
-
`;
|
|
756
|
-
}
|
|
757
|
-
function handleCrash() {
|
|
758
|
-
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
759
|
-
}
|
|
760
|
-
process.once("uncaughtException", (err) => {
|
|
761
|
-
void handleCrash().finally(() => {
|
|
762
|
-
throw err;
|
|
763
|
-
});
|
|
764
|
-
});
|
|
765
|
-
process.once("unhandledRejection", (reason) => {
|
|
766
|
-
void handleCrash().finally(() => {
|
|
767
|
-
throw reason;
|
|
768
|
-
});
|
|
769
|
-
});
|
|
770
|
-
process.once("SIGINT", () => {
|
|
771
|
-
void handleCrash().finally(() => {
|
|
772
|
-
process.exit(130);
|
|
773
|
-
});
|
|
774
|
-
});
|
|
775
|
-
|
|
776
|
-
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
777
|
-
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1054
|
+
import { useEffect as useEffect6, useState as useState9 } from "react";
|
|
1055
|
+
import { Box as Box9, Text as Text9, useInput as useInput9 } from "ink";
|
|
1056
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
778
1057
|
var UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
|
|
779
1058
|
function UpgradeScreen({ onDone }) {
|
|
780
|
-
const [upgradeCheck, setUpgradeCheck] =
|
|
781
|
-
|
|
1059
|
+
const [upgradeCheck, setUpgradeCheck] = useState9();
|
|
1060
|
+
useEffect6(() => {
|
|
782
1061
|
startDebugRun({
|
|
783
1062
|
flow: "upgrade",
|
|
784
1063
|
step: "01-upgrade",
|
|
@@ -787,7 +1066,7 @@ function UpgradeScreen({ onDone }) {
|
|
|
787
1066
|
});
|
|
788
1067
|
checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
|
|
789
1068
|
}, []);
|
|
790
|
-
|
|
1069
|
+
useInput9((_input, key) => {
|
|
791
1070
|
if (key.return) {
|
|
792
1071
|
void finishDebugRun({
|
|
793
1072
|
outputs: upgradeCheck ?? {},
|
|
@@ -798,12 +1077,12 @@ function UpgradeScreen({ onDone }) {
|
|
|
798
1077
|
return;
|
|
799
1078
|
}
|
|
800
1079
|
});
|
|
801
|
-
return /* @__PURE__ */
|
|
802
|
-
/* @__PURE__ */
|
|
803
|
-
/* @__PURE__ */
|
|
1080
|
+
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1081
|
+
/* @__PURE__ */ jsx9(Text9, { bold: true, children: "Upgrade" }),
|
|
1082
|
+
/* @__PURE__ */ jsx9(Text9, { children: " " }),
|
|
804
1083
|
renderBody(upgradeCheck),
|
|
805
|
-
/* @__PURE__ */
|
|
806
|
-
/* @__PURE__ */
|
|
1084
|
+
/* @__PURE__ */ jsx9(Text9, { children: " " }),
|
|
1085
|
+
/* @__PURE__ */ jsxs9(Text9, { bold: true, color: PALETTE.accent, children: [
|
|
807
1086
|
FOCUS_MARKER,
|
|
808
1087
|
" Go Back"
|
|
809
1088
|
] })
|
|
@@ -811,51 +1090,57 @@ function UpgradeScreen({ onDone }) {
|
|
|
811
1090
|
}
|
|
812
1091
|
function renderBody(upgradeCheck) {
|
|
813
1092
|
if (!upgradeCheck) {
|
|
814
|
-
return /* @__PURE__ */
|
|
1093
|
+
return /* @__PURE__ */ jsx9(Text9, { color: PALETTE.muted, children: "Checking for updates\u2026" });
|
|
815
1094
|
}
|
|
816
1095
|
if (upgradeCheck.status === "error") {
|
|
817
|
-
return /* @__PURE__ */
|
|
1096
|
+
return /* @__PURE__ */ jsx9(Text9, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
|
|
818
1097
|
}
|
|
819
1098
|
if (upgradeCheck.status === "up-to-date") {
|
|
820
|
-
return /* @__PURE__ */
|
|
1099
|
+
return /* @__PURE__ */ jsxs9(Text9, { color: PALETTE.success, children: [
|
|
821
1100
|
"You're already on the latest version (v",
|
|
822
1101
|
upgradeCheck.current,
|
|
823
1102
|
")."
|
|
824
1103
|
] });
|
|
825
1104
|
}
|
|
826
|
-
return /* @__PURE__ */
|
|
827
|
-
/* @__PURE__ */
|
|
828
|
-
/* @__PURE__ */
|
|
1105
|
+
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", children: [
|
|
1106
|
+
/* @__PURE__ */ jsxs9(Text9, { color: PALETTE.muted, children: [
|
|
1107
|
+
/* @__PURE__ */ jsxs9(Text9, { bold: true, color: PALETTE.success, children: [
|
|
829
1108
|
"v",
|
|
830
1109
|
upgradeCheck.latest
|
|
831
1110
|
] }),
|
|
832
1111
|
" ",
|
|
833
1112
|
"is available (you're on ",
|
|
834
|
-
/* @__PURE__ */
|
|
1113
|
+
/* @__PURE__ */ jsxs9(Text9, { bold: true, children: [
|
|
835
1114
|
"v",
|
|
836
1115
|
upgradeCheck.current
|
|
837
1116
|
] }),
|
|
838
1117
|
"). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
|
|
839
1118
|
] }),
|
|
840
|
-
/* @__PURE__ */
|
|
841
|
-
/* @__PURE__ */
|
|
1119
|
+
/* @__PURE__ */ jsx9(Text9, { children: " " }),
|
|
1120
|
+
/* @__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)) })
|
|
842
1121
|
] });
|
|
843
1122
|
}
|
|
844
1123
|
|
|
845
1124
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
846
|
-
import { useEffect as
|
|
847
|
-
import { Box as
|
|
848
|
-
import { jsx as
|
|
1125
|
+
import { useEffect as useEffect7, useState as useState10 } from "react";
|
|
1126
|
+
import { Box as Box10, Text as Text10, useInput as useInput10 } from "ink";
|
|
1127
|
+
import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
849
1128
|
function DebugModeScreen({ onDone }) {
|
|
850
|
-
const [loading, setLoading] =
|
|
851
|
-
const [enabled, setEnabled] =
|
|
852
|
-
|
|
1129
|
+
const [loading, setLoading] = useState10(true);
|
|
1130
|
+
const [enabled, setEnabled] = useState10(true);
|
|
1131
|
+
useEffect7(() => {
|
|
853
1132
|
readDebugModeSetting().then((setting) => {
|
|
854
1133
|
setEnabled(setting.enabled);
|
|
855
1134
|
setLoading(false);
|
|
1135
|
+
startDebugRun({
|
|
1136
|
+
flow: "settings/debug-mode",
|
|
1137
|
+
step: "01-debug-mode",
|
|
1138
|
+
menuOption: "Debug Mode",
|
|
1139
|
+
inputs: { enabled: setting.enabled }
|
|
1140
|
+
});
|
|
856
1141
|
});
|
|
857
1142
|
}, []);
|
|
858
|
-
|
|
1143
|
+
useInput10((input, key) => {
|
|
859
1144
|
if (loading) return;
|
|
860
1145
|
if (key.return || input === " ") {
|
|
861
1146
|
setEnabled((current) => {
|
|
@@ -866,64 +1151,92 @@ function DebugModeScreen({ onDone }) {
|
|
|
866
1151
|
return;
|
|
867
1152
|
}
|
|
868
1153
|
if (key.escape || input === "q") {
|
|
1154
|
+
void finishDebugRun({ outputs: { enabled }, status: "success", exitMethod: "saved" });
|
|
869
1155
|
onDone();
|
|
870
1156
|
}
|
|
871
1157
|
});
|
|
872
|
-
return /* @__PURE__ */
|
|
873
|
-
/* @__PURE__ */
|
|
874
|
-
/* @__PURE__ */
|
|
875
|
-
loading ? /* @__PURE__ */
|
|
1158
|
+
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1159
|
+
/* @__PURE__ */ jsx10(Text10, { bold: true, children: "Settings \u203A Debug Mode" }),
|
|
1160
|
+
/* @__PURE__ */ jsx10(Text10, { children: " " }),
|
|
1161
|
+
loading ? /* @__PURE__ */ jsx10(Text10, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs10(Text10, { children: [
|
|
876
1162
|
"Debug logging:",
|
|
877
1163
|
" ",
|
|
878
|
-
/* @__PURE__ */
|
|
1164
|
+
/* @__PURE__ */ jsx10(Text10, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
879
1165
|
] }),
|
|
880
|
-
/* @__PURE__ */
|
|
881
|
-
/* @__PURE__ */
|
|
1166
|
+
/* @__PURE__ */ jsx10(Text10, { children: " " }),
|
|
1167
|
+
/* @__PURE__ */ jsx10(Text10, { dimColor: true, children: "[Enter/Space] Toggle [Esc/q] Back to Settings" })
|
|
882
1168
|
] });
|
|
883
1169
|
}
|
|
884
1170
|
|
|
885
1171
|
// packages/experience-design-system-cli/app.tsx
|
|
886
|
-
import { jsx as
|
|
1172
|
+
import { Fragment as Fragment4, jsx as jsx11 } from "react/jsx-runtime";
|
|
887
1173
|
function App({ onLaunchImport, importExitCode }) {
|
|
888
1174
|
const returnedFromImport = importExitCode !== void 0;
|
|
889
|
-
const [screen, setScreen] =
|
|
890
|
-
const
|
|
891
|
-
const
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
-
|
|
1175
|
+
const [screen, setScreen] = useState11(returnedFromImport ? "import" : "start");
|
|
1176
|
+
const [showImportResult, setShowImportResult] = useState11(returnedFromImport);
|
|
1177
|
+
const [projectPath, setProjectPath] = useState11();
|
|
1178
|
+
const [importDefaults, setImportDefaults] = useState11();
|
|
1179
|
+
useEffect8(() => {
|
|
1180
|
+
if (screen !== "import") {
|
|
1181
|
+
setImportDefaults(void 0);
|
|
895
1182
|
return;
|
|
896
1183
|
}
|
|
897
|
-
|
|
1184
|
+
void readCredentials().then(
|
|
1185
|
+
(saved) => setImportDefaults({ componentDir: saved.defaultComponentDir ?? "", tokenFile: saved.defaultTokenFile ?? "" })
|
|
1186
|
+
);
|
|
1187
|
+
}, [screen]);
|
|
1188
|
+
const goToStart = () => setScreen("start");
|
|
1189
|
+
const goToSettings = () => setScreen("settings");
|
|
1190
|
+
const finishImportResult = () => {
|
|
1191
|
+
setShowImportResult(false);
|
|
1192
|
+
setProjectPath(void 0);
|
|
1193
|
+
goToStart();
|
|
1194
|
+
};
|
|
1195
|
+
const leaveImport = () => {
|
|
1196
|
+
setProjectPath(void 0);
|
|
1197
|
+
goToStart();
|
|
898
1198
|
};
|
|
899
1199
|
switch (screen) {
|
|
900
1200
|
case "import":
|
|
901
|
-
return /* @__PURE__ */
|
|
1201
|
+
if (showImportResult) return /* @__PURE__ */ jsx11(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
|
|
1202
|
+
if (importDefaults === void 0) return /* @__PURE__ */ jsx11(Fragment4, {});
|
|
1203
|
+
if (projectPath === void 0) {
|
|
1204
|
+
return /* @__PURE__ */ jsx11(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
|
|
1205
|
+
}
|
|
1206
|
+
return /* @__PURE__ */ jsx11(
|
|
1207
|
+
TokenInputScreen,
|
|
1208
|
+
{
|
|
1209
|
+
initialPath: importDefaults.tokenFile,
|
|
1210
|
+
onConfirm: (tokens) => onLaunchImport?.({ project: projectPath, tokens }),
|
|
1211
|
+
onSkip: () => onLaunchImport?.({ project: projectPath }),
|
|
1212
|
+
onBack: () => setProjectPath(void 0)
|
|
1213
|
+
}
|
|
1214
|
+
);
|
|
902
1215
|
case "help":
|
|
903
|
-
return /* @__PURE__ */
|
|
1216
|
+
return /* @__PURE__ */ jsx11(HelpScreen, { onDone: goToStart });
|
|
904
1217
|
case "upgrade":
|
|
905
|
-
return /* @__PURE__ */
|
|
1218
|
+
return /* @__PURE__ */ jsx11(UpgradeScreen, { onDone: goToStart });
|
|
906
1219
|
case "settings":
|
|
907
|
-
return /* @__PURE__ */
|
|
1220
|
+
return /* @__PURE__ */ jsx11(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
|
|
908
1221
|
case "settings-configuration":
|
|
909
|
-
return /* @__PURE__ */
|
|
1222
|
+
return /* @__PURE__ */ jsx11(ConfigurationScreen, { onDone: goToSettings });
|
|
910
1223
|
case "settings-opt-in-analytics":
|
|
911
|
-
return /* @__PURE__ */
|
|
1224
|
+
return /* @__PURE__ */ jsx11(OptInAnalyticsScreen, { onDone: goToSettings });
|
|
912
1225
|
case "settings-debug-mode":
|
|
913
|
-
return /* @__PURE__ */
|
|
1226
|
+
return /* @__PURE__ */ jsx11(DebugModeScreen, { onDone: goToSettings });
|
|
914
1227
|
case "start":
|
|
915
|
-
return /* @__PURE__ */
|
|
1228
|
+
return /* @__PURE__ */ jsx11(HomeScreen, { onNavigate: setScreen });
|
|
916
1229
|
}
|
|
917
1230
|
}
|
|
918
1231
|
async function renderUntilImportRequestedOrExit(renderApp, importExitCode) {
|
|
919
|
-
let
|
|
1232
|
+
let requestedImport;
|
|
920
1233
|
const instance = renderApp(
|
|
921
|
-
/* @__PURE__ */
|
|
1234
|
+
/* @__PURE__ */ jsx11(
|
|
922
1235
|
App,
|
|
923
1236
|
{
|
|
924
1237
|
importExitCode,
|
|
925
|
-
onLaunchImport: () => {
|
|
926
|
-
|
|
1238
|
+
onLaunchImport: (options) => {
|
|
1239
|
+
requestedImport = options;
|
|
927
1240
|
instance.unmount();
|
|
928
1241
|
}
|
|
929
1242
|
}
|
|
@@ -931,13 +1244,15 @@ async function renderUntilImportRequestedOrExit(renderApp, importExitCode) {
|
|
|
931
1244
|
);
|
|
932
1245
|
await instance.waitUntilExit();
|
|
933
1246
|
await stopReadingTerminal();
|
|
934
|
-
return
|
|
1247
|
+
return requestedImport;
|
|
935
1248
|
}
|
|
936
1249
|
async function runApp(renderApp) {
|
|
937
1250
|
let importExitCode;
|
|
938
|
-
|
|
939
|
-
|
|
1251
|
+
let requestedImport = await renderUntilImportRequestedOrExit(renderApp, importExitCode);
|
|
1252
|
+
while (requestedImport !== void 0) {
|
|
1253
|
+
importExitCode = (await spawnV1Import(requestedImport)).exitCode;
|
|
940
1254
|
startReadingTerminal();
|
|
1255
|
+
requestedImport = await renderUntilImportRequestedOrExit(renderApp, importExitCode);
|
|
941
1256
|
}
|
|
942
1257
|
}
|
|
943
1258
|
export {
|