@contentful/experience-design-system-cli 2.35.1-dev-build-1f9cff15.0 → 2.35.1-dev-build-76df9d03.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/bin/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- await import('../dist/index.js');
2
+ await import("../dist/index.js");
package/dist/app.js CHANGED
@@ -496,43 +496,54 @@ import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
496
496
  import { existsSync as existsSync3, readdirSync } from "node:fs";
497
497
  import { join as join5 } from "node:path";
498
498
 
499
- // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
500
- import { mkdir, readFile, writeFile } from "node:fs/promises";
499
+ // packages/experience-design-system-types/dist/src/config/index.js
500
+ import { randomBytes } from "node:crypto";
501
+ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
502
+ import { homedir as homedir2 } from "node:os";
501
503
  import { dirname as dirname2, join as join4 } from "node:path";
502
- var PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
503
- var DEFAULT_DEBUG_MODE_SETTING = {
504
- enabled: true
505
- };
506
- function debugModeSettingPath() {
507
- return join4(findPackageRoot(import.meta.url, PACKAGE_NAME3), ".contentful", "config", "debug_mode.json");
504
+ function configRoot() {
505
+ return process.env["EDS_HOME"] || join4(homedir2(), ".contentful", "experience-design-system-cli");
508
506
  }
509
- async function readDebugModeSetting() {
507
+ var configFilePath = () => join4(configRoot(), "config.json");
508
+ var debugSessionsDir = () => join4(configRoot(), "debug", "sessions");
509
+ async function readSettings() {
510
510
  try {
511
- const raw = await readFile(debugModeSettingPath(), "utf8");
512
- const parsed = JSON.parse(raw);
513
- return { ...DEFAULT_DEBUG_MODE_SETTING, ...parsed };
511
+ return JSON.parse(await readFile(configFilePath(), "utf8"));
514
512
  } catch {
515
- return { ...DEFAULT_DEBUG_MODE_SETTING };
513
+ return {};
516
514
  }
517
515
  }
518
- async function writeDebugModeSetting(setting) {
519
- const path = debugModeSettingPath();
516
+ async function writeSettings(settings) {
517
+ const path = configFilePath();
520
518
  await mkdir(dirname2(path), { recursive: true });
521
- await writeFile(path, `${JSON.stringify(setting, null, 2)}
519
+ const tmp = `${path}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
520
+ await writeFile(tmp, `${JSON.stringify(settings, null, 2)}
522
521
  `, { mode: 384 });
522
+ await rename(tmp, path);
523
+ }
524
+ async function updateSettings(patch) {
525
+ await writeSettings({ ...await readSettings(), ...patch });
526
+ }
527
+
528
+ // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
529
+ var DEFAULT_DEBUG_MODE_SETTING = {
530
+ enabled: true
531
+ };
532
+ async function readDebugModeSetting() {
533
+ const { debugMode } = await readSettings();
534
+ return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
535
+ }
536
+ async function writeDebugModeSetting(setting) {
537
+ await updateSettings({ debugMode: setting });
523
538
  }
524
539
 
525
540
  // packages/experience-design-system-cli/src/tui/debug-store.ts
526
- var PACKAGE_NAME4 = "@contentful/experience-design-system-cli";
527
541
  var pendingRun;
528
542
  function generateRunId() {
529
543
  const now = /* @__PURE__ */ new Date();
530
544
  const pad = (n) => String(n).padStart(2, "0");
531
545
  return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
532
546
  }
533
- function sessionsRootDir() {
534
- return join5(findPackageRoot(import.meta.url, PACKAGE_NAME4), ".contentful", "debug", "sessions");
535
- }
536
547
  function datePrefix(now = /* @__PURE__ */ new Date()) {
537
548
  const pad = (n) => String(n).padStart(2, "0");
538
549
  return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
@@ -542,7 +553,7 @@ function slugify(value) {
542
553
  }
543
554
  function generateSessionId() {
544
555
  const today = datePrefix();
545
- const root = sessionsRootDir();
556
+ const root = debugSessionsDir();
546
557
  const existing = existsSync3(root) ? readdirSync(root) : [];
547
558
  const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
548
559
  const maxSeq = existing.reduce((max, entry) => {
@@ -553,7 +564,7 @@ function generateSessionId() {
553
564
  }
554
565
  var SESSION_ID = generateSessionId();
555
566
  function sessionDebugDir() {
556
- return join5(sessionsRootDir(), SESSION_ID);
567
+ return join5(debugSessionsDir(), SESSION_ID);
557
568
  }
558
569
  void isDebugModeEnabled().then((enabled) => {
559
570
  if (!enabled) return void 0;
@@ -742,23 +753,8 @@ import { useEffect as useEffect4, useState as useState6 } from "react";
742
753
  import { Box as Box7, Text as Text7, useInput as useInput7 } from "ink";
743
754
 
744
755
  // packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
745
- import { readFile as readFile2, writeFile as writeFile3, mkdir as mkdir3 } from "node:fs/promises";
746
- import { join as join6 } from "node:path";
747
- import { homedir as homedir2 } from "node:os";
748
- var V1_STORE_PATH = join6(homedir2(), ".config", "experiences", "credentials.json");
749
- async function readV1Store() {
750
- try {
751
- const raw = await readFile2(V1_STORE_PATH, "utf8");
752
- return JSON.parse(raw);
753
- } catch {
754
- return {};
755
- }
756
- }
757
- async function writeV1Store(data) {
758
- await mkdir3(join6(homedir2(), ".config", "experiences"), { recursive: true });
759
- await writeFile3(V1_STORE_PATH, `${JSON.stringify(data, null, 2)}
760
- `, { mode: 384 });
761
- }
756
+ var readV1Store = readSettings;
757
+ var writeV1Store = writeSettings;
762
758
 
763
759
  // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/config-store.ts
764
760
  async function readCredentials() {
package/dist/index.js CHANGED
@@ -593,33 +593,56 @@ var init_terminal_input = __esm({
593
593
  }
594
594
  });
595
595
 
596
- // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
597
- import { mkdir, readFile, writeFile } from "node:fs/promises";
596
+ // packages/experience-design-system-types/dist/src/config/index.js
597
+ import { randomBytes } from "node:crypto";
598
+ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
599
+ import { homedir as homedir2 } from "node:os";
598
600
  import { dirname as dirname2, join as join4 } from "node:path";
599
- function debugModeSettingPath() {
600
- return join4(findPackageRoot(import.meta.url, PACKAGE_NAME3), ".contentful", "config", "debug_mode.json");
601
+ function configRoot() {
602
+ return process.env["EDS_HOME"] || join4(homedir2(), ".contentful", "experience-design-system-cli");
601
603
  }
602
- async function readDebugModeSetting() {
604
+ async function readSettings() {
603
605
  try {
604
- const raw = await readFile(debugModeSettingPath(), "utf8");
605
- const parsed = JSON.parse(raw);
606
- return { ...DEFAULT_DEBUG_MODE_SETTING, ...parsed };
606
+ return JSON.parse(await readFile(configFilePath(), "utf8"));
607
607
  } catch {
608
- return { ...DEFAULT_DEBUG_MODE_SETTING };
608
+ return {};
609
609
  }
610
610
  }
611
- async function writeDebugModeSetting(setting) {
612
- const path = debugModeSettingPath();
611
+ async function writeSettings(settings) {
612
+ const path = configFilePath();
613
613
  await mkdir(dirname2(path), { recursive: true });
614
- await writeFile(path, `${JSON.stringify(setting, null, 2)}
614
+ const tmp = `${path}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
615
+ await writeFile(tmp, `${JSON.stringify(settings, null, 2)}
615
616
  `, { mode: 384 });
617
+ await rename(tmp, path);
616
618
  }
617
- var PACKAGE_NAME3, DEFAULT_DEBUG_MODE_SETTING;
619
+ async function updateSettings(patch) {
620
+ await writeSettings({ ...await readSettings(), ...patch });
621
+ }
622
+ var configFilePath, runsFilePath, debugSessionsDir, oldConfigDir;
623
+ var init_config = __esm({
624
+ "packages/experience-design-system-types/dist/src/config/index.js"() {
625
+ "use strict";
626
+ configFilePath = () => join4(configRoot(), "config.json");
627
+ runsFilePath = () => join4(configRoot(), "state", "runs.json");
628
+ debugSessionsDir = () => join4(configRoot(), "debug", "sessions");
629
+ oldConfigDir = () => join4(homedir2(), ".config", "experiences");
630
+ }
631
+ });
632
+
633
+ // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
634
+ async function readDebugModeSetting() {
635
+ const { debugMode } = await readSettings();
636
+ return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
637
+ }
638
+ async function writeDebugModeSetting(setting) {
639
+ await updateSettings({ debugMode: setting });
640
+ }
641
+ var DEFAULT_DEBUG_MODE_SETTING;
618
642
  var init_debug_mode_store = __esm({
619
643
  "packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
620
644
  "use strict";
621
- init_package_root();
622
- PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
645
+ init_config();
623
646
  DEFAULT_DEBUG_MODE_SETTING = {
624
647
  enabled: true
625
648
  };
@@ -635,9 +658,6 @@ function generateRunId() {
635
658
  const pad = (n) => String(n).padStart(2, "0");
636
659
  return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
637
660
  }
638
- function sessionsRootDir() {
639
- return join5(findPackageRoot(import.meta.url, PACKAGE_NAME4), ".contentful", "debug", "sessions");
640
- }
641
661
  function datePrefix(now = /* @__PURE__ */ new Date()) {
642
662
  const pad = (n) => String(n).padStart(2, "0");
643
663
  return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
@@ -647,7 +667,7 @@ function slugify(value) {
647
667
  }
648
668
  function generateSessionId() {
649
669
  const today = datePrefix();
650
- const root = sessionsRootDir();
670
+ const root = debugSessionsDir();
651
671
  const existing = existsSync3(root) ? readdirSync(root) : [];
652
672
  const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
653
673
  const maxSeq = existing.reduce((max, entry) => {
@@ -657,7 +677,7 @@ function generateSessionId() {
657
677
  return `${today}-session-${maxSeq + 1}`;
658
678
  }
659
679
  function sessionDebugDir() {
660
- return join5(sessionsRootDir(), SESSION_ID);
680
+ return join5(debugSessionsDir(), SESSION_ID);
661
681
  }
662
682
  async function isDebugModeEnabled() {
663
683
  try {
@@ -746,14 +766,13 @@ ${JSON.stringify(finish.outputs, null, 2)}
746
766
  function handleCrash() {
747
767
  return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
748
768
  }
749
- var PACKAGE_NAME4, pendingRun, SESSION_ID;
769
+ var pendingRun, SESSION_ID;
750
770
  var init_debug_store = __esm({
751
771
  "packages/experience-design-system-cli/src/tui/debug-store.ts"() {
752
772
  "use strict";
753
- init_package_root();
773
+ init_config();
754
774
  init_version();
755
775
  init_debug_mode_store();
756
- PACKAGE_NAME4 = "@contentful/experience-design-system-cli";
757
776
  SESSION_ID = generateSessionId();
758
777
  void isDebugModeEnabled().then((enabled) => {
759
778
  if (!enabled) return void 0;
@@ -866,27 +885,13 @@ var init_PageContainer3 = __esm({
866
885
  });
867
886
 
868
887
  // packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
869
- import { readFile as readFile2, writeFile as writeFile3, mkdir as mkdir3 } from "node:fs/promises";
870
- import { join as join6 } from "node:path";
871
- import { homedir as homedir2 } from "node:os";
872
- async function readV1Store() {
873
- try {
874
- const raw = await readFile2(V1_STORE_PATH, "utf8");
875
- return JSON.parse(raw);
876
- } catch {
877
- return {};
878
- }
879
- }
880
- async function writeV1Store(data) {
881
- await mkdir3(join6(homedir2(), ".config", "experiences"), { recursive: true });
882
- await writeFile3(V1_STORE_PATH, `${JSON.stringify(data, null, 2)}
883
- `, { mode: 384 });
884
- }
885
- var V1_STORE_PATH;
888
+ var readV1Store, writeV1Store;
886
889
  var init_v1_store = __esm({
887
890
  "packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts"() {
888
891
  "use strict";
889
- V1_STORE_PATH = join6(homedir2(), ".config", "experiences", "credentials.json");
892
+ init_config();
893
+ readV1Store = readSettings;
894
+ writeV1Store = writeSettings;
890
895
  }
891
896
  });
892
897
 
@@ -1451,7 +1456,51 @@ function createProgram() {
1451
1456
  return program;
1452
1457
  }
1453
1458
 
1459
+ // packages/experience-design-system-cli/src/config/migrate.ts
1460
+ init_config();
1461
+ init_package_root();
1462
+ import { existsSync as existsSync4 } from "node:fs";
1463
+ import { mkdir as mkdir3, readFile as readFile2, rename as rename2, rmdir, unlink } from "node:fs/promises";
1464
+ import { dirname as dirname3, join as join6 } from "node:path";
1465
+ var PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
1466
+ async function readJson(path) {
1467
+ try {
1468
+ return JSON.parse(await readFile2(path, "utf8"));
1469
+ } catch {
1470
+ return void 0;
1471
+ }
1472
+ }
1473
+ async function migrateOldConfig() {
1474
+ try {
1475
+ const oldCredentials = join6(oldConfigDir(), "credentials.json");
1476
+ const oldRuns = join6(oldConfigDir(), "runs.json");
1477
+ const oldDebugMode = join6(
1478
+ findPackageRoot(import.meta.url, PACKAGE_NAME3),
1479
+ ".contentful",
1480
+ "config",
1481
+ "debug_mode.json"
1482
+ );
1483
+ const migrated = {};
1484
+ const debugMode = await readJson(oldDebugMode);
1485
+ if (debugMode) migrated["debugMode"] = debugMode;
1486
+ Object.assign(migrated, await readJson(oldCredentials));
1487
+ if (Object.keys(migrated).length > 0) await updateSettings({ ...migrated, ...await readSettings() });
1488
+ if (existsSync4(oldRuns)) {
1489
+ if (!existsSync4(runsFilePath())) {
1490
+ await mkdir3(dirname3(runsFilePath()), { recursive: true });
1491
+ await rename2(oldRuns, runsFilePath());
1492
+ } else {
1493
+ await unlink(oldRuns);
1494
+ }
1495
+ }
1496
+ await Promise.all([oldCredentials, oldDebugMode].map((f) => unlink(f).catch(() => void 0)));
1497
+ await rmdir(oldConfigDir()).catch(() => void 0);
1498
+ } catch {
1499
+ }
1500
+ }
1501
+
1454
1502
  // packages/experience-design-system-cli/index.ts
1503
+ await migrateOldConfig();
1455
1504
  createProgram().parseAsync().catch((err) => {
1456
1505
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
1457
1506
  `);
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.35.1-dev-build-1f9cff15.0",
3
+ "version": "2.35.1-dev-build-76df9d03.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1 @@
1
+ export declare function migrateOldConfig(): Promise<void>;
@@ -1,2 +1,3 @@
1
- export declare function readV1Store(): Promise<Record<string, unknown>>;
2
- export declare function writeV1Store(data: Record<string, unknown>): Promise<void>;
1
+ import { readSettings, writeSettings } from '@contentful/experience-design-system-types/config';
2
+ export declare const readV1Store: typeof readSettings;
3
+ export declare const writeV1Store: typeof writeSettings;
package/legacy/bin/cli.js CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  // Suppress the SQLite ExperimentalWarning before any modules load.
3
3
  // Must use dynamic import so this handler registers before sqlite is imported.
4
- process.removeAllListeners('warning');
5
- process.on('warning', (w) => {
6
- if (w.name === 'ExperimentalWarning' && w.message.includes('SQLite')) return;
4
+ process.removeAllListeners("warning");
5
+ process.on("warning", (w) => {
6
+ if (w.name === "ExperimentalWarning" && w.message.includes("SQLite")) return;
7
7
  process.stderr.write(`${w.name}: ${w.message}\n`);
8
8
  });
9
9
 
10
10
  // Auto-rebuild when running from source (dev mode only).
11
11
  // Skipped when src/ doesn't exist (e.g. npm-installed users).
12
- import { existsSync, statSync, readdirSync } from 'node:fs';
13
- import { execFileSync } from 'node:child_process';
14
- import { fileURLToPath } from 'node:url';
15
- import { dirname, resolve, join } from 'node:path';
12
+ import { existsSync, statSync, readdirSync } from "node:fs";
13
+ import { execFileSync } from "node:child_process";
14
+ import { fileURLToPath } from "node:url";
15
+ import { dirname, resolve, join } from "node:path";
16
16
 
17
17
  function newestMtime(dir, depth = 0) {
18
18
  if (depth > 10) return 0;
@@ -22,7 +22,7 @@ function newestMtime(dir, depth = 0) {
22
22
  const full = join(dir, entry.name);
23
23
  if (entry.isDirectory()) {
24
24
  max = Math.max(max, newestMtime(full, depth + 1));
25
- } else if (entry.name.endsWith('.ts') || entry.name.endsWith('.tsx')) {
25
+ } else if (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx")) {
26
26
  max = Math.max(max, statSync(full).mtimeMs);
27
27
  }
28
28
  }
@@ -30,25 +30,29 @@ function newestMtime(dir, depth = 0) {
30
30
  }
31
31
 
32
32
  const __dirname = dirname(fileURLToPath(import.meta.url));
33
- const pkgRoot = resolve(__dirname, '..');
34
- const srcDir = join(pkgRoot, 'src');
35
- const distEntry = join(pkgRoot, 'dist', 'src', 'index.js');
33
+ const pkgRoot = resolve(__dirname, "..");
34
+ const srcDir = join(pkgRoot, "src");
35
+ const distEntry = join(pkgRoot, "dist", "src", "index.js");
36
36
 
37
- if (existsSync(srcDir) && existsSync(distEntry) && process.env.NODE_ENV !== 'test') {
37
+ if (
38
+ existsSync(srcDir) &&
39
+ existsSync(distEntry) &&
40
+ process.env.NODE_ENV !== "test"
41
+ ) {
38
42
  const distMtime = statSync(distEntry).mtimeMs;
39
43
  if (newestMtime(srcDir) > distMtime) {
40
- process.stderr.write('⚙ Source changed — rebuilding...\n');
41
- const tsc = join(pkgRoot, 'node_modules', '.bin', 'tsc');
44
+ process.stderr.write("⚙ Source changed — rebuilding...\n");
45
+ const tsc = join(pkgRoot, "node_modules", ".bin", "tsc");
42
46
  try {
43
- execFileSync(tsc, ['-p', join(pkgRoot, 'tsconfig.build.json')], {
44
- stdio: ['ignore', 'ignore', 'inherit'],
47
+ execFileSync(tsc, ["-p", join(pkgRoot, "tsconfig.build.json")], {
48
+ stdio: ["ignore", "ignore", "inherit"],
45
49
  cwd: pkgRoot,
46
50
  });
47
- process.stderr.write('✓ Build complete\n');
51
+ process.stderr.write("✓ Build complete\n");
48
52
  } catch {
49
- process.stderr.write('✗ Build failed — running with existing dist\n');
53
+ process.stderr.write("✗ Build failed — running with existing dist\n");
50
54
  }
51
55
  }
52
56
  }
53
57
 
54
- await import('../dist/src/index.js');
58
+ await import("../dist/src/index.js");
@@ -1,5 +1,6 @@
1
1
  export type AiFlaggable = {
2
2
  aiDecision?: 'accepted' | 'rejected' | 'failed' | null;
3
+ needsReview?: boolean;
3
4
  };
4
5
  export declare function isAiFlagged(row: AiFlaggable): boolean;
5
6
  export declare function isDefaultIncluded(row: AiFlaggable): boolean;
@@ -4,6 +4,7 @@ export type ScopeComponent = {
4
4
  componentId: string;
5
5
  aiDecision?: 'accepted' | 'rejected' | 'failed' | null;
6
6
  aiReason?: string | null;
7
+ needsReview?: boolean;
7
8
  slots?: Array<{
8
9
  name: string;
9
10
  allowedComponents: string[];