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