@contentful/experience-design-system-cli 2.37.1-dev-build-5db7e407.0 → 2.37.1-dev-build-eed963c1.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 +307 -409
- package/dist/index.js +89 -142
- package/dist/package.json +1 -1
- package/dist/src/tui/debug-store.d.ts +1 -18
- package/dist/src/tui/import/steps/05-token-reuse/logic.d.ts +2 -3
- package/dist/src/tui/import/steps/06-extraction/types.d.ts +0 -2
- package/dist/src/tui/import/steps/07-scope-gate/sidebar/components/GroupedSidebar.d.ts +1 -0
- package/dist/src/tui/import/steps/07-scope-gate/sidebar/step-filters.d.ts +4 -0
- package/dist/src/tui/import/steps/07-scope-gate/use-scope-gate.d.ts +1 -0
- package/dist/src/tui/settings/contentful-configuration/config-store.d.ts +0 -1
- package/legacy/package.json +1 -1
- package/package.json +3 -3
package/dist/app.js
CHANGED
|
@@ -8,71 +8,6 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
// packages/experience-design-system-cli/src/tui/package-root.ts
|
|
12
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
13
|
-
import { dirname, join } from "node:path";
|
|
14
|
-
import { fileURLToPath } from "node:url";
|
|
15
|
-
function findPackageRoot(startUrl, packageName) {
|
|
16
|
-
let dir = dirname(fileURLToPath(startUrl));
|
|
17
|
-
let found;
|
|
18
|
-
while (true) {
|
|
19
|
-
const manifestPath = join(dir, "package.json");
|
|
20
|
-
if (existsSync(manifestPath)) {
|
|
21
|
-
const pkg = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
22
|
-
if (pkg.name === packageName) found = dir;
|
|
23
|
-
}
|
|
24
|
-
const parent = dirname(dir);
|
|
25
|
-
if (parent === dir) return found ?? dir;
|
|
26
|
-
dir = parent;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
var init_package_root = __esm({
|
|
30
|
-
"packages/experience-design-system-cli/src/tui/package-root.ts"() {
|
|
31
|
-
"use strict";
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// packages/experience-design-system-cli/src/tui/upgrade/version.ts
|
|
36
|
-
import { readFileSync as readFileSync2 } from "node:fs";
|
|
37
|
-
import { join as join2 } from "node:path";
|
|
38
|
-
import semver from "semver";
|
|
39
|
-
function readPackageVersion() {
|
|
40
|
-
const root = findPackageRoot(import.meta.url, PACKAGE_NAME);
|
|
41
|
-
const pkg = JSON.parse(readFileSync2(join2(root, "package.json"), "utf8"));
|
|
42
|
-
return pkg.version ?? "unknown";
|
|
43
|
-
}
|
|
44
|
-
function parseVersionTag(tag) {
|
|
45
|
-
const match2 = /^v(\d+\.\d+\.\d+)$/.exec(tag);
|
|
46
|
-
return match2 ? match2[1] : void 0;
|
|
47
|
-
}
|
|
48
|
-
async function checkForUpgrade() {
|
|
49
|
-
const current = readPackageVersion();
|
|
50
|
-
try {
|
|
51
|
-
const response = await fetch(TAGS_URL);
|
|
52
|
-
if (!response.ok) return { status: "error" };
|
|
53
|
-
const tags = await response.json();
|
|
54
|
-
const versions = tags.map((tag) => tag.name ? parseVersionTag(tag.name) : void 0).filter((v) => v !== void 0);
|
|
55
|
-
if (versions.length === 0) return { status: "error" };
|
|
56
|
-
const latest = versions.reduce((best, v) => semver.gt(v, best) ? v : best);
|
|
57
|
-
if (!semver.valid(current)) return { status: "error" };
|
|
58
|
-
if (semver.gt(latest, current)) {
|
|
59
|
-
return { status: "update-available", current, latest };
|
|
60
|
-
}
|
|
61
|
-
return { status: "up-to-date", current };
|
|
62
|
-
} catch {
|
|
63
|
-
return { status: "error" };
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
var PACKAGE_NAME, TAGS_URL;
|
|
67
|
-
var init_version = __esm({
|
|
68
|
-
"packages/experience-design-system-cli/src/tui/upgrade/version.ts"() {
|
|
69
|
-
"use strict";
|
|
70
|
-
init_package_root();
|
|
71
|
-
PACKAGE_NAME = "@contentful/experience-design-system-cli";
|
|
72
|
-
TAGS_URL = "https://api.github.com/repos/contentful/experience-design-system-sdk-public/tags?per_page=10";
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
11
|
// packages/experience-design-system-backend-pipeline/dist/src/agents/types/agent-name.js
|
|
77
12
|
var AGENT_NAMES;
|
|
78
13
|
var init_agent_name = __esm({
|
|
@@ -837,7 +772,7 @@ async function runAgent(options) {
|
|
|
837
772
|
promptLen: prompt.length,
|
|
838
773
|
promptHead: prompt.slice(0, 500)
|
|
839
774
|
});
|
|
840
|
-
return new Promise((
|
|
775
|
+
return new Promise((resolve25) => {
|
|
841
776
|
const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
|
|
842
777
|
const child = spawn(binary, args, {
|
|
843
778
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -886,7 +821,7 @@ async function runAgent(options) {
|
|
|
886
821
|
stderrLen: stderr.length,
|
|
887
822
|
stderrTail: stderr.slice(-1e3)
|
|
888
823
|
});
|
|
889
|
-
|
|
824
|
+
resolve25(result);
|
|
890
825
|
});
|
|
891
826
|
});
|
|
892
827
|
}
|
|
@@ -908,7 +843,7 @@ async function checkAgentAuth(agent) {
|
|
|
908
843
|
return "not-found";
|
|
909
844
|
if (agent !== "claude")
|
|
910
845
|
return "ok";
|
|
911
|
-
return new Promise((
|
|
846
|
+
return new Promise((resolve25) => {
|
|
912
847
|
const child = spawn2(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
|
|
913
848
|
let stdout = "";
|
|
914
849
|
let done = false;
|
|
@@ -917,7 +852,7 @@ async function checkAgentAuth(agent) {
|
|
|
917
852
|
return;
|
|
918
853
|
done = true;
|
|
919
854
|
child.kill("SIGTERM");
|
|
920
|
-
|
|
855
|
+
resolve25("unauthenticated");
|
|
921
856
|
}, 5e3);
|
|
922
857
|
child.stdout?.on("data", (chunk) => {
|
|
923
858
|
stdout += chunk.toString();
|
|
@@ -928,14 +863,14 @@ async function checkAgentAuth(agent) {
|
|
|
928
863
|
done = true;
|
|
929
864
|
clearTimeout(timer);
|
|
930
865
|
if (code !== 0) {
|
|
931
|
-
|
|
866
|
+
resolve25("unauthenticated");
|
|
932
867
|
return;
|
|
933
868
|
}
|
|
934
869
|
try {
|
|
935
870
|
const status = JSON.parse(stdout);
|
|
936
|
-
|
|
871
|
+
resolve25(status.loggedIn ? "ok" : "unauthenticated");
|
|
937
872
|
} catch {
|
|
938
|
-
|
|
873
|
+
resolve25("unauthenticated");
|
|
939
874
|
}
|
|
940
875
|
});
|
|
941
876
|
});
|
|
@@ -945,9 +880,9 @@ async function binaryIsOnPath(binary) {
|
|
|
945
880
|
const fs = await import("node:fs/promises");
|
|
946
881
|
return fs.access(binary).then(() => true, () => false);
|
|
947
882
|
}
|
|
948
|
-
return new Promise((
|
|
883
|
+
return new Promise((resolve25) => {
|
|
949
884
|
const child = spawn2(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
|
|
950
|
-
child.on("close", (code) =>
|
|
885
|
+
child.on("close", (code) => resolve25(code === 0));
|
|
951
886
|
});
|
|
952
887
|
}
|
|
953
888
|
var init_check_agent_auth = __esm({
|
|
@@ -2081,253 +2016,6 @@ var init_cache_keys = __esm({
|
|
|
2081
2016
|
}
|
|
2082
2017
|
});
|
|
2083
2018
|
|
|
2084
|
-
// packages/experience-design-system-types/dist/src/config/index.js
|
|
2085
|
-
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
2086
|
-
import { mkdir as mkdir6, readFile as readFile18, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
|
|
2087
|
-
import { homedir as homedir3 } from "node:os";
|
|
2088
|
-
import { dirname as dirname13, join as join17 } from "node:path";
|
|
2089
|
-
function configRoot2() {
|
|
2090
|
-
return process.env["EDS_HOME"] || join17(homedir3(), ".contentful", "experience-design-system-cli");
|
|
2091
|
-
}
|
|
2092
|
-
async function readSettings2() {
|
|
2093
|
-
try {
|
|
2094
|
-
return JSON.parse(await readFile18(configFilePath2(), "utf8"));
|
|
2095
|
-
} catch {
|
|
2096
|
-
return {};
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
async function writeSettings2(settings) {
|
|
2100
|
-
const path5 = configFilePath2();
|
|
2101
|
-
await mkdir6(dirname13(path5), { recursive: true });
|
|
2102
|
-
const tmp = `${path5}.${process.pid}.${randomBytes3(4).toString("hex")}.tmp`;
|
|
2103
|
-
await writeFile6(tmp, `${JSON.stringify(settings, null, 2)}
|
|
2104
|
-
`, { mode: 384 });
|
|
2105
|
-
await rename2(tmp, path5);
|
|
2106
|
-
}
|
|
2107
|
-
async function updateSettings2(patch) {
|
|
2108
|
-
await writeSettings2({ ...await readSettings2(), ...patch });
|
|
2109
|
-
}
|
|
2110
|
-
var configFilePath2;
|
|
2111
|
-
var init_config = __esm({
|
|
2112
|
-
"packages/experience-design-system-types/dist/src/config/index.js"() {
|
|
2113
|
-
"use strict";
|
|
2114
|
-
configFilePath2 = () => join17(configRoot2(), "config.json");
|
|
2115
|
-
}
|
|
2116
|
-
});
|
|
2117
|
-
|
|
2118
|
-
// packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
|
|
2119
|
-
async function readDebugModeSetting() {
|
|
2120
|
-
const { debugMode } = await readSettings2();
|
|
2121
|
-
return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
|
|
2122
|
-
}
|
|
2123
|
-
async function writeDebugModeSetting(setting) {
|
|
2124
|
-
await updateSettings2({ debugMode: setting });
|
|
2125
|
-
}
|
|
2126
|
-
var DEFAULT_DEBUG_MODE_SETTING;
|
|
2127
|
-
var init_debug_mode_store = __esm({
|
|
2128
|
-
"packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
|
|
2129
|
-
"use strict";
|
|
2130
|
-
init_config();
|
|
2131
|
-
DEFAULT_DEBUG_MODE_SETTING = {
|
|
2132
|
-
enabled: true
|
|
2133
|
-
};
|
|
2134
|
-
}
|
|
2135
|
-
});
|
|
2136
|
-
|
|
2137
|
-
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
2138
|
-
var debug_store_exports = {};
|
|
2139
|
-
__export(debug_store_exports, {
|
|
2140
|
-
currentDebugSessionDir: () => currentDebugSessionDir,
|
|
2141
|
-
currentSessionDir: () => currentSessionDir,
|
|
2142
|
-
finishDebugRun: () => finishDebugRun,
|
|
2143
|
-
startDebugRun: () => startDebugRun,
|
|
2144
|
-
startDebugSessionIn: () => startDebugSessionIn,
|
|
2145
|
-
startImportRun: () => startImportRun
|
|
2146
|
-
});
|
|
2147
|
-
import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
|
|
2148
|
-
import { existsSync as existsSync9, readdirSync as readdirSync4 } from "node:fs";
|
|
2149
|
-
import { join as join24, resolve as resolve26 } from "node:path";
|
|
2150
|
-
function generateRunId() {
|
|
2151
|
-
const now = /* @__PURE__ */ new Date();
|
|
2152
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
2153
|
-
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
2154
|
-
}
|
|
2155
|
-
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
2156
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
2157
|
-
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
2158
|
-
}
|
|
2159
|
-
function slugify(value) {
|
|
2160
|
-
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
2161
|
-
}
|
|
2162
|
-
async function readBaseDir() {
|
|
2163
|
-
try {
|
|
2164
|
-
const dir = (await readSettings2())["contentfulBaseDir"];
|
|
2165
|
-
return typeof dir === "string" && dir !== "" ? resolve26(dir) : void 0;
|
|
2166
|
-
} catch {
|
|
2167
|
-
return void 0;
|
|
2168
|
-
}
|
|
2169
|
-
}
|
|
2170
|
-
function nextSessionId(contentfulDir) {
|
|
2171
|
-
const today = datePrefix();
|
|
2172
|
-
const existing = existsSync9(contentfulDir) ? readdirSync4(contentfulDir) : [];
|
|
2173
|
-
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
2174
|
-
const maxSeq = existing.reduce((max, entry) => {
|
|
2175
|
-
const match2 = seqPattern.exec(entry);
|
|
2176
|
-
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
2177
|
-
}, 0);
|
|
2178
|
-
return `${today}-session-${maxSeq + 1}`;
|
|
2179
|
-
}
|
|
2180
|
-
function startSession(base, { replace }) {
|
|
2181
|
-
const contentfulDir = join24(base, ".contentful");
|
|
2182
|
-
if (replace || !sessionDir) sessionDir = join24(contentfulDir, nextSessionId(contentfulDir));
|
|
2183
|
-
return sessionDir;
|
|
2184
|
-
}
|
|
2185
|
-
function currentDebugSessionDir() {
|
|
2186
|
-
return sessionDir && join24(sessionDir, "debug");
|
|
2187
|
-
}
|
|
2188
|
-
function currentSessionDir() {
|
|
2189
|
-
return sessionDir;
|
|
2190
|
-
}
|
|
2191
|
-
async function startDebugSessionIn(base, { replace = false } = {}) {
|
|
2192
|
-
try {
|
|
2193
|
-
if (!await isDebugModeEnabled()) return;
|
|
2194
|
-
await mkdir9(join24(startSession(resolve26(base), { replace }), "debug"), { recursive: true });
|
|
2195
|
-
} catch {
|
|
2196
|
-
}
|
|
2197
|
-
}
|
|
2198
|
-
function nextImportRunDir(session) {
|
|
2199
|
-
const existing = existsSync9(session) ? readdirSync4(session) : [];
|
|
2200
|
-
const maxRun = existing.reduce((max, entry) => {
|
|
2201
|
-
const match2 = /^dsi-import-(\d+)$/.exec(entry);
|
|
2202
|
-
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
2203
|
-
}, 0);
|
|
2204
|
-
return join24(session, `dsi-import-${maxRun + 1}`);
|
|
2205
|
-
}
|
|
2206
|
-
async function startImportRun(projectPath) {
|
|
2207
|
-
await startDebugSessionIn(projectPath);
|
|
2208
|
-
if (!sessionDir) return join24(resolve26(projectPath), ".contentful");
|
|
2209
|
-
const dir = nextImportRunDir(sessionDir);
|
|
2210
|
-
await mkdir9(dir, { recursive: true });
|
|
2211
|
-
return dir;
|
|
2212
|
-
}
|
|
2213
|
-
async function isDebugModeEnabled() {
|
|
2214
|
-
try {
|
|
2215
|
-
return (await readDebugModeSetting()).enabled;
|
|
2216
|
-
} catch {
|
|
2217
|
-
return true;
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
function redact(value) {
|
|
2221
|
-
const clone = { ...value };
|
|
2222
|
-
if ("cma_token" in clone) {
|
|
2223
|
-
const raw = clone.cma_token;
|
|
2224
|
-
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
2225
|
-
}
|
|
2226
|
-
return clone;
|
|
2227
|
-
}
|
|
2228
|
-
function startDebugRun({
|
|
2229
|
-
flow,
|
|
2230
|
-
step,
|
|
2231
|
-
menuOption,
|
|
2232
|
-
inputs
|
|
2233
|
-
}) {
|
|
2234
|
-
const runId = generateRunId();
|
|
2235
|
-
const startedAt = Date.now();
|
|
2236
|
-
const redactedInputs = redact(inputs);
|
|
2237
|
-
isDebugModeEnabled().then((enabled) => {
|
|
2238
|
-
if (!enabled) return;
|
|
2239
|
-
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
2240
|
-
});
|
|
2241
|
-
}
|
|
2242
|
-
async function finishDebugRun({
|
|
2243
|
-
outputs,
|
|
2244
|
-
status,
|
|
2245
|
-
exitMethod
|
|
2246
|
-
}) {
|
|
2247
|
-
const run = pendingRun;
|
|
2248
|
-
if (!run) return;
|
|
2249
|
-
pendingRun = void 0;
|
|
2250
|
-
const durationMs = Date.now() - run.startedAt;
|
|
2251
|
-
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
2252
|
-
const root = currentDebugSessionDir();
|
|
2253
|
-
if (!root) return;
|
|
2254
|
-
const flowSegments = run.flow.split("/");
|
|
2255
|
-
const dir = join24(root, ...flowSegments);
|
|
2256
|
-
await mkdir9(dir, { recursive: true });
|
|
2257
|
-
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
2258
|
-
await writeFile8(join24(dir, filename), content, { mode: 384 });
|
|
2259
|
-
}
|
|
2260
|
-
function nextAttemptFilename(dir, menuOption) {
|
|
2261
|
-
const today = datePrefix();
|
|
2262
|
-
const optionSlug = slugify(menuOption);
|
|
2263
|
-
const existing = existsSync9(dir) ? readdirSync4(dir) : [];
|
|
2264
|
-
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
2265
|
-
const maxAttempt = existing.reduce((max, entry) => {
|
|
2266
|
-
const match2 = attemptPattern.exec(entry);
|
|
2267
|
-
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
2268
|
-
}, 0);
|
|
2269
|
-
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
2270
|
-
}
|
|
2271
|
-
function renderMarkdown(run, finish) {
|
|
2272
|
-
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
2273
|
-
const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
2274
|
-
const flowSlug = run.flow.split("/").join("-");
|
|
2275
|
-
return `# Debug Log
|
|
2276
|
-
|
|
2277
|
-
- Run ID: ${run.runId}
|
|
2278
|
-
- Flow: ${flowSlug}
|
|
2279
|
-
- Step: ${stepLabel2}
|
|
2280
|
-
- Menu option: ${run.menuOption}
|
|
2281
|
-
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
2282
|
-
- CLI version: ${readPackageVersion()}
|
|
2283
|
-
- Platform: ${process.platform} / Node ${process.version}
|
|
2284
|
-
- Duration on screen: ${finish.durationMs}ms
|
|
2285
|
-
- Status: ${finish.status}
|
|
2286
|
-
- Exit method: ${finish.exitMethod}
|
|
2287
|
-
|
|
2288
|
-
## Inputs
|
|
2289
|
-
\`\`\`json
|
|
2290
|
-
${JSON.stringify(run.inputs, null, 2)}
|
|
2291
|
-
\`\`\`
|
|
2292
|
-
|
|
2293
|
-
## Outputs
|
|
2294
|
-
\`\`\`json
|
|
2295
|
-
${JSON.stringify(finish.outputs, null, 2)}
|
|
2296
|
-
\`\`\`
|
|
2297
|
-
`;
|
|
2298
|
-
}
|
|
2299
|
-
function handleCrash() {
|
|
2300
|
-
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
2301
|
-
}
|
|
2302
|
-
var pendingRun, sessionDir;
|
|
2303
|
-
var init_debug_store = __esm({
|
|
2304
|
-
"packages/experience-design-system-cli/src/tui/debug-store.ts"() {
|
|
2305
|
-
"use strict";
|
|
2306
|
-
init_config();
|
|
2307
|
-
init_version();
|
|
2308
|
-
init_debug_mode_store();
|
|
2309
|
-
void Promise.all([isDebugModeEnabled(), readBaseDir()]).then(([enabled, base]) => {
|
|
2310
|
-
if (!enabled || !base) return void 0;
|
|
2311
|
-
return mkdir9(join24(startSession(base, { replace: false }), "debug"), { recursive: true });
|
|
2312
|
-
});
|
|
2313
|
-
process.once("uncaughtException", (err) => {
|
|
2314
|
-
void handleCrash().finally(() => {
|
|
2315
|
-
throw err;
|
|
2316
|
-
});
|
|
2317
|
-
});
|
|
2318
|
-
process.once("unhandledRejection", (reason) => {
|
|
2319
|
-
void handleCrash().finally(() => {
|
|
2320
|
-
throw reason;
|
|
2321
|
-
});
|
|
2322
|
-
});
|
|
2323
|
-
process.once("SIGINT", () => {
|
|
2324
|
-
void handleCrash().finally(() => {
|
|
2325
|
-
process.exit(130);
|
|
2326
|
-
});
|
|
2327
|
-
});
|
|
2328
|
-
}
|
|
2329
|
-
});
|
|
2330
|
-
|
|
2331
2019
|
// packages/experience-design-system-cli/app.tsx
|
|
2332
2020
|
import { join as join25 } from "node:path";
|
|
2333
2021
|
import { useEffect as useEffect26, useState as useState33 } from "react";
|
|
@@ -2367,8 +2055,60 @@ function brandBar(width, ramp = BRAND_RAMP) {
|
|
|
2367
2055
|
}
|
|
2368
2056
|
var FOCUS_MARKER = "\u276F";
|
|
2369
2057
|
|
|
2370
|
-
// packages/experience-design-system-cli/src/tui/
|
|
2371
|
-
|
|
2058
|
+
// packages/experience-design-system-cli/src/tui/upgrade/version.ts
|
|
2059
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
2060
|
+
import { join as join2 } from "node:path";
|
|
2061
|
+
import semver from "semver";
|
|
2062
|
+
|
|
2063
|
+
// packages/experience-design-system-cli/src/tui/package-root.ts
|
|
2064
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2065
|
+
import { dirname, join } from "node:path";
|
|
2066
|
+
import { fileURLToPath } from "node:url";
|
|
2067
|
+
function findPackageRoot(startUrl, packageName) {
|
|
2068
|
+
let dir = dirname(fileURLToPath(startUrl));
|
|
2069
|
+
let found;
|
|
2070
|
+
while (true) {
|
|
2071
|
+
const manifestPath = join(dir, "package.json");
|
|
2072
|
+
if (existsSync(manifestPath)) {
|
|
2073
|
+
const pkg = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
2074
|
+
if (pkg.name === packageName) found = dir;
|
|
2075
|
+
}
|
|
2076
|
+
const parent = dirname(dir);
|
|
2077
|
+
if (parent === dir) return found ?? dir;
|
|
2078
|
+
dir = parent;
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
// packages/experience-design-system-cli/src/tui/upgrade/version.ts
|
|
2083
|
+
var PACKAGE_NAME = "@contentful/experience-design-system-cli";
|
|
2084
|
+
var TAGS_URL = "https://api.github.com/repos/contentful/experience-design-system-sdk-public/tags?per_page=10";
|
|
2085
|
+
function readPackageVersion() {
|
|
2086
|
+
const root = findPackageRoot(import.meta.url, PACKAGE_NAME);
|
|
2087
|
+
const pkg = JSON.parse(readFileSync2(join2(root, "package.json"), "utf8"));
|
|
2088
|
+
return pkg.version ?? "unknown";
|
|
2089
|
+
}
|
|
2090
|
+
function parseVersionTag(tag) {
|
|
2091
|
+
const match2 = /^v(\d+\.\d+\.\d+)$/.exec(tag);
|
|
2092
|
+
return match2 ? match2[1] : void 0;
|
|
2093
|
+
}
|
|
2094
|
+
async function checkForUpgrade() {
|
|
2095
|
+
const current = readPackageVersion();
|
|
2096
|
+
try {
|
|
2097
|
+
const response = await fetch(TAGS_URL);
|
|
2098
|
+
if (!response.ok) return { status: "error" };
|
|
2099
|
+
const tags = await response.json();
|
|
2100
|
+
const versions = tags.map((tag) => tag.name ? parseVersionTag(tag.name) : void 0).filter((v) => v !== void 0);
|
|
2101
|
+
if (versions.length === 0) return { status: "error" };
|
|
2102
|
+
const latest = versions.reduce((best, v) => semver.gt(v, best) ? v : best);
|
|
2103
|
+
if (!semver.valid(current)) return { status: "error" };
|
|
2104
|
+
if (semver.gt(latest, current)) {
|
|
2105
|
+
return { status: "update-available", current, latest };
|
|
2106
|
+
}
|
|
2107
|
+
return { status: "up-to-date", current };
|
|
2108
|
+
} catch {
|
|
2109
|
+
return { status: "error" };
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2372
2112
|
|
|
2373
2113
|
// packages/experience-design-system-cli/src/tui/use-terminal-width.ts
|
|
2374
2114
|
import { useEffect, useState } from "react";
|
|
@@ -12567,11 +12307,11 @@ import { access as access2, mkdir, readFile as readFile7, writeFile } from "node
|
|
|
12567
12307
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-session-paths.js
|
|
12568
12308
|
import { resolve as resolve15 } from "node:path";
|
|
12569
12309
|
async function getRefineSessionPaths(sessionId, artifactsRoot) {
|
|
12570
|
-
const
|
|
12310
|
+
const sessionDir = resolve15(artifactsRoot, sessionId);
|
|
12571
12311
|
return {
|
|
12572
|
-
sessionDir
|
|
12573
|
-
eventsPath: resolve15(
|
|
12574
|
-
statePath: resolve15(
|
|
12312
|
+
sessionDir,
|
|
12313
|
+
eventsPath: resolve15(sessionDir, "events.jsonl"),
|
|
12314
|
+
statePath: resolve15(sessionDir, "current-review-state.json")
|
|
12575
12315
|
};
|
|
12576
12316
|
}
|
|
12577
12317
|
|
|
@@ -13770,7 +13510,7 @@ function errorMessage(error) {
|
|
|
13770
13510
|
return error instanceof Error && error.message ? error.message : String(error);
|
|
13771
13511
|
}
|
|
13772
13512
|
function defaultSleep(delayMs) {
|
|
13773
|
-
return new Promise((
|
|
13513
|
+
return new Promise((resolve25) => setTimeout(resolve25, delayMs));
|
|
13774
13514
|
}
|
|
13775
13515
|
|
|
13776
13516
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/sanitize-preview.js
|
|
@@ -14011,7 +13751,7 @@ var ApiClient = class {
|
|
|
14011
13751
|
const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
|
|
14012
13752
|
const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
|
|
14013
13753
|
const jitter = Math.random() * baseDelay * 0.15;
|
|
14014
|
-
await new Promise((
|
|
13754
|
+
await new Promise((resolve25) => setTimeout(resolve25, baseDelay + jitter));
|
|
14015
13755
|
}
|
|
14016
13756
|
}
|
|
14017
13757
|
throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
|
|
@@ -16124,7 +15864,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
|
|
|
16124
15864
|
const message = error instanceof Error ? error.message : String(error);
|
|
16125
15865
|
if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
|
|
16126
15866
|
throw error;
|
|
16127
|
-
await new Promise((
|
|
15867
|
+
await new Promise((resolve25) => setTimeout(resolve25, Math.min(250 * attempt, 2e3)));
|
|
16128
15868
|
}
|
|
16129
15869
|
}
|
|
16130
15870
|
}
|
|
@@ -16951,7 +16691,6 @@ function useCredentialsControls(handlers) {
|
|
|
16951
16691
|
}
|
|
16952
16692
|
|
|
16953
16693
|
// packages/experience-design-system-cli/src/tui/user-agent.ts
|
|
16954
|
-
init_version();
|
|
16955
16694
|
function cliUserAgent() {
|
|
16956
16695
|
return buildUserAgent(readPackageVersion());
|
|
16957
16696
|
}
|
|
@@ -17296,34 +17035,11 @@ function RunningStep({
|
|
|
17296
17035
|
}
|
|
17297
17036
|
|
|
17298
17037
|
// packages/experience-design-system-cli/src/tui/import/steps/05-token-reuse/logic.ts
|
|
17299
|
-
import { access as access5,
|
|
17038
|
+
import { access as access5, stat as stat4 } from "node:fs/promises";
|
|
17300
17039
|
import { join as join16 } from "node:path";
|
|
17301
|
-
async function
|
|
17302
|
-
const candidates = [join16(contentfulDir, "tokens.json")];
|
|
17303
|
-
try {
|
|
17304
|
-
for (const session of await readdir2(contentfulDir, { withFileTypes: true })) {
|
|
17305
|
-
if (!session.isDirectory()) continue;
|
|
17306
|
-
for (const run of await readdir2(join16(contentfulDir, session.name), { withFileTypes: true }).catch(() => [])) {
|
|
17307
|
-
if (run.isDirectory() && /^dsi-import-\d+$/.test(run.name)) {
|
|
17308
|
-
candidates.push(join16(contentfulDir, session.name, run.name, "tokens.json"));
|
|
17309
|
-
}
|
|
17310
|
-
}
|
|
17311
|
-
}
|
|
17312
|
-
} catch {
|
|
17313
|
-
}
|
|
17314
|
-
const found = [];
|
|
17315
|
-
for (const path5 of candidates) {
|
|
17316
|
-
try {
|
|
17317
|
-
found.push({ path: path5, mtimeMs: (await stat4(path5)).mtimeMs });
|
|
17318
|
-
} catch {
|
|
17319
|
-
}
|
|
17320
|
-
}
|
|
17321
|
-
return found.sort((a, b) => b.mtimeMs - a.mtimeMs)[0]?.path ?? null;
|
|
17322
|
-
}
|
|
17323
|
-
async function inspectTokens({ rawTokensPath, contentfulDir, cache }) {
|
|
17040
|
+
async function inspectTokens({ rawTokensPath, outDir, cache }) {
|
|
17324
17041
|
if (!cache) return { kind: "none" };
|
|
17325
|
-
const tokensPath =
|
|
17326
|
-
if (!tokensPath) return { kind: "none" };
|
|
17042
|
+
const tokensPath = join16(outDir, "tokens.json");
|
|
17327
17043
|
try {
|
|
17328
17044
|
await access5(tokensPath);
|
|
17329
17045
|
} catch {
|
|
@@ -17474,8 +17190,34 @@ function ExtractionScreen({
|
|
|
17474
17190
|
);
|
|
17475
17191
|
}
|
|
17476
17192
|
|
|
17477
|
-
// packages/experience-design-system-
|
|
17478
|
-
|
|
17193
|
+
// packages/experience-design-system-types/dist/src/config/index.js
|
|
17194
|
+
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
17195
|
+
import { mkdir as mkdir6, readFile as readFile18, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
|
|
17196
|
+
import { homedir as homedir3 } from "node:os";
|
|
17197
|
+
import { dirname as dirname13, join as join17 } from "node:path";
|
|
17198
|
+
function configRoot2() {
|
|
17199
|
+
return process.env["EDS_HOME"] || join17(homedir3(), ".contentful", "experience-design-system-cli");
|
|
17200
|
+
}
|
|
17201
|
+
var configFilePath2 = () => join17(configRoot2(), "config.json");
|
|
17202
|
+
var debugSessionsDir2 = () => join17(configRoot2(), "debug", "sessions");
|
|
17203
|
+
async function readSettings2() {
|
|
17204
|
+
try {
|
|
17205
|
+
return JSON.parse(await readFile18(configFilePath2(), "utf8"));
|
|
17206
|
+
} catch {
|
|
17207
|
+
return {};
|
|
17208
|
+
}
|
|
17209
|
+
}
|
|
17210
|
+
async function writeSettings2(settings) {
|
|
17211
|
+
const path5 = configFilePath2();
|
|
17212
|
+
await mkdir6(dirname13(path5), { recursive: true });
|
|
17213
|
+
const tmp = `${path5}.${process.pid}.${randomBytes3(4).toString("hex")}.tmp`;
|
|
17214
|
+
await writeFile6(tmp, `${JSON.stringify(settings, null, 2)}
|
|
17215
|
+
`, { mode: 384 });
|
|
17216
|
+
await rename2(tmp, path5);
|
|
17217
|
+
}
|
|
17218
|
+
async function updateSettings2(patch) {
|
|
17219
|
+
await writeSettings2({ ...await readSettings2(), ...patch });
|
|
17220
|
+
}
|
|
17479
17221
|
|
|
17480
17222
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
|
|
17481
17223
|
import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
|
|
@@ -17602,7 +17344,7 @@ var realDeps = {
|
|
|
17602
17344
|
var fail = (step, message) => ({ ok: false, step, message });
|
|
17603
17345
|
var errorMessage2 = (error) => error instanceof Error ? error.message : String(error);
|
|
17604
17346
|
async function runExtraction(input, onProgress, deps = realDeps) {
|
|
17605
|
-
const outDir =
|
|
17347
|
+
const outDir = join19(resolve22(input.projectPath), ".contentful");
|
|
17606
17348
|
let progress = initialProgress({
|
|
17607
17349
|
hasCredentials: input.credentials !== null,
|
|
17608
17350
|
hasRawTokens: input.rawTokensPath !== "",
|
|
@@ -18930,7 +18672,8 @@ function GroupedSidebar(props) {
|
|
|
18930
18672
|
dimPredicate,
|
|
18931
18673
|
visibleRows: providedRows,
|
|
18932
18674
|
graph,
|
|
18933
|
-
filterVisibleKeys
|
|
18675
|
+
filterVisibleKeys,
|
|
18676
|
+
emptyMessage
|
|
18934
18677
|
} = props;
|
|
18935
18678
|
const allRows = providedRows ?? buildVisibleRows({
|
|
18936
18679
|
items,
|
|
@@ -18947,6 +18690,10 @@ function GroupedSidebar(props) {
|
|
|
18947
18690
|
const end = windowed ? start + (visibleCount ?? allRows.length) : allRows.length;
|
|
18948
18691
|
const rows = windowed ? allRows.slice(start, end) : allRows;
|
|
18949
18692
|
return /* @__PURE__ */ jsxs18(WindowedPanel, { width, height: props.height, title, focused, children: [
|
|
18693
|
+
allRows.length === 0 && emptyMessage !== void 0 && /* @__PURE__ */ jsxs18(Text19, { color: PALETTE2.warning, children: [
|
|
18694
|
+
" ",
|
|
18695
|
+
emptyMessage
|
|
18696
|
+
] }),
|
|
18950
18697
|
windowed && /* @__PURE__ */ jsx21(WindowIndicator, { direction: "up", count: start }),
|
|
18951
18698
|
rows.map((row, i) => {
|
|
18952
18699
|
const absoluteRowIdx = start + i;
|
|
@@ -19262,9 +19009,9 @@ function createSidebarViewsHelpSection(includeBreaking) {
|
|
|
19262
19009
|
{ keys: "L", label: "Flat view" },
|
|
19263
19010
|
{ keys: "i", label: "Focus lineage" }
|
|
19264
19011
|
];
|
|
19265
|
-
if (includeBreaking) entries.push({ keys: "w", label: "
|
|
19012
|
+
if (includeBreaking) entries.push({ keys: "w", label: "Show only components with breaking changes" });
|
|
19266
19013
|
entries.push(
|
|
19267
|
-
{ keys: "o", label: "
|
|
19014
|
+
{ keys: "o", label: "Show only components in slot cycles" },
|
|
19268
19015
|
{ keys: "space", label: "Expand/collapse group" },
|
|
19269
19016
|
{ keys: "E / C", label: "Expand/collapse all" }
|
|
19270
19017
|
);
|
|
@@ -19831,6 +19578,17 @@ function computeFilterKeys(input) {
|
|
|
19831
19578
|
if (active.has("deleted")) for (const k of input.data.deleted ?? []) out.add(k);
|
|
19832
19579
|
return out;
|
|
19833
19580
|
}
|
|
19581
|
+
var FILTER_LABELS = {
|
|
19582
|
+
broken: "components with breaking changes",
|
|
19583
|
+
cycles: "slot cycles",
|
|
19584
|
+
deleted: "removed components"
|
|
19585
|
+
};
|
|
19586
|
+
function describeEmptyFilter(input) {
|
|
19587
|
+
const names = [...input.filters].map((f) => FILTER_LABELS[f]);
|
|
19588
|
+
if (input.slotDependencies) names.push("slot dependencies");
|
|
19589
|
+
if (names.length === 0) return void 0;
|
|
19590
|
+
return `Nothing to show: no ${names.join(" or ")} in this import.`;
|
|
19591
|
+
}
|
|
19834
19592
|
function intersectFilterKeys(a, b) {
|
|
19835
19593
|
if (a === void 0) return b;
|
|
19836
19594
|
if (b === void 0) return a;
|
|
@@ -20026,6 +19784,7 @@ function useScopeGate({ components, onConfirm, onQuit }) {
|
|
|
20026
19784
|
}),
|
|
20027
19785
|
[groupedItems, cycleParticipants, expandedGroups, columnOneView, graph, filterVisibleKeys]
|
|
20028
19786
|
);
|
|
19787
|
+
const emptyMessage = visibleRows.length === 0 && filterVisibleKeys !== void 0 && !jumpFilterTarget ? describeEmptyFilter({ filters: activeFilters, slotDependencies: showDependencies }) : void 0;
|
|
20029
19788
|
const total = visibleRows.length;
|
|
20030
19789
|
const safeCursor = Math.min(nav.cursor, Math.max(0, total - 1));
|
|
20031
19790
|
const currentRow = visibleRows[safeCursor];
|
|
@@ -20347,6 +20106,7 @@ function useScopeGate({ components, onConfirm, onQuit }) {
|
|
|
20347
20106
|
expandedGroups,
|
|
20348
20107
|
toggleExpanded,
|
|
20349
20108
|
visibleRows,
|
|
20109
|
+
emptyMessage,
|
|
20350
20110
|
safeCursor,
|
|
20351
20111
|
scrollOffset: nav.scrollOffset,
|
|
20352
20112
|
selectionStateByKey,
|
|
@@ -20400,7 +20160,7 @@ var HELP_SECTIONS = [
|
|
|
20400
20160
|
title: "Panels",
|
|
20401
20161
|
entries: [
|
|
20402
20162
|
{ keys: "c", label: "Cycle list" },
|
|
20403
|
-
{ keys: "d", label: "Show slot
|
|
20163
|
+
{ keys: "d", label: "Show slot dependenciess" },
|
|
20404
20164
|
{ keys: "x", label: "Review flags" }
|
|
20405
20165
|
]
|
|
20406
20166
|
},
|
|
@@ -20469,6 +20229,7 @@ function ScopeGateView({ components, onConfirm, onQuit }) {
|
|
|
20469
20229
|
aiFlaggedByKey: gate.aiFlaggedByKey,
|
|
20470
20230
|
dimPredicate: gate.dimPredicate,
|
|
20471
20231
|
visibleRows: gate.visibleRows,
|
|
20232
|
+
emptyMessage: gate.emptyMessage,
|
|
20472
20233
|
viewMode: gate.columnOneView,
|
|
20473
20234
|
graph: graph.nodes
|
|
20474
20235
|
}
|
|
@@ -25228,12 +24989,12 @@ var HELP_SECTIONS2 = [
|
|
|
25228
24989
|
title: "Panels",
|
|
25229
24990
|
entries: [
|
|
25230
24991
|
{ keys: "c", label: "Cycle list" },
|
|
25231
|
-
{ keys: "b", label: "
|
|
25232
|
-
{ keys: "w", label: "
|
|
25233
|
-
{ keys: "o", label: "
|
|
24992
|
+
{ keys: "b", label: "Show breaking changes" },
|
|
24993
|
+
{ keys: "w", label: "Filter components with breaking changes" },
|
|
24994
|
+
{ keys: "o", label: "Filter components in slot cycles" },
|
|
25234
24995
|
{ keys: "p", label: "Prop rationale" },
|
|
25235
24996
|
{ keys: "P", label: "Component rationale" },
|
|
25236
|
-
{ keys: "s", label: "Source" },
|
|
24997
|
+
{ keys: "s", label: "Source code snippet" },
|
|
25237
24998
|
{ keys: "J", label: "Toggle JSON" },
|
|
25238
24999
|
{ keys: "t", label: "Token review" }
|
|
25239
25000
|
]
|
|
@@ -25952,18 +25713,18 @@ function GenerateReviewStepView({
|
|
|
25952
25713
|
}
|
|
25953
25714
|
return;
|
|
25954
25715
|
}
|
|
25955
|
-
if (input === "c" && !key.ctrl && !key.meta && cycleRows.length > 0) {
|
|
25716
|
+
if (input === "c" && !reviewEditor.textEntryActive && !key.ctrl && !key.meta && cycleRows.length > 0) {
|
|
25956
25717
|
cyclePanel.open();
|
|
25957
25718
|
setCyclePanelScroll(0);
|
|
25958
25719
|
setCyclesCursor(0);
|
|
25959
25720
|
return;
|
|
25960
25721
|
}
|
|
25961
|
-
if (input === "b" && sidebarFocused && breakingChanges.length > 0) {
|
|
25722
|
+
if (input === "b" && !reviewEditor.textEntryActive && sidebarFocused && breakingChanges.length > 0) {
|
|
25962
25723
|
breakingPanel.open();
|
|
25963
25724
|
setBreakingCursor(0);
|
|
25964
25725
|
return;
|
|
25965
25726
|
}
|
|
25966
|
-
if (input === "o" || input === "w") {
|
|
25727
|
+
if (!reviewEditor.textEntryActive && (input === "o" || input === "w")) {
|
|
25967
25728
|
const category = input === "o" ? "cycles" : "broken";
|
|
25968
25729
|
setActiveFilters((prev) => {
|
|
25969
25730
|
const next = new Set(prev);
|
|
@@ -26349,6 +26110,7 @@ function GenerateReviewStepView({
|
|
|
26349
26110
|
visibleCount,
|
|
26350
26111
|
dimPredicate,
|
|
26351
26112
|
visibleRows: visibleRowsMemo,
|
|
26113
|
+
emptyMessage: visibleRowsMemo.length === 0 && filterVisibleKeys !== void 0 && !jumpFilterTarget ? describeEmptyFilter({ filters: activeFilters }) : void 0,
|
|
26352
26114
|
viewMode: columnOneView,
|
|
26353
26115
|
graph: sidebarGraph
|
|
26354
26116
|
}
|
|
@@ -27381,7 +27143,7 @@ import { useEffect as useEffect20, useRef as useRef12, useSyncExternalStore } fr
|
|
|
27381
27143
|
import { appendFileSync, writeFileSync } from "node:fs";
|
|
27382
27144
|
import { mkdir as mkdir8 } from "node:fs/promises";
|
|
27383
27145
|
import { tmpdir } from "node:os";
|
|
27384
|
-
import { join as join23
|
|
27146
|
+
import { join as join23 } from "node:path";
|
|
27385
27147
|
|
|
27386
27148
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/wizard-state-transitions.ts
|
|
27387
27149
|
function shouldBypassPreview(state) {
|
|
@@ -27752,7 +27514,7 @@ var realSaveDeps = () => ({
|
|
|
27752
27514
|
writeFile: (path5, contents) => writeFile7(path5, contents),
|
|
27753
27515
|
appendRun,
|
|
27754
27516
|
buildSourceFingerprint,
|
|
27755
|
-
sleep: (ms) => new Promise((
|
|
27517
|
+
sleep: (ms) => new Promise((resolve25) => setTimeout(resolve25, ms)),
|
|
27756
27518
|
warn: (message) => process.stderr.write(message)
|
|
27757
27519
|
});
|
|
27758
27520
|
async function runPrintFiles(input, deps, onPatch) {
|
|
@@ -28086,7 +27848,7 @@ function createFlowController(start, deps) {
|
|
|
28086
27848
|
},
|
|
28087
27849
|
async submitPath(submitted) {
|
|
28088
27850
|
await deps.mkdir(submitted);
|
|
28089
|
-
if (
|
|
27851
|
+
if (await deps.detectSaveConflict(submitted)) {
|
|
28090
27852
|
const subdir = deps.buildTimestampedSubdir(submitted);
|
|
28091
27853
|
await deps.mkdir(subdir);
|
|
28092
27854
|
await proceedToWrite(subdir);
|
|
@@ -28135,19 +27897,171 @@ function useFlow(start, options = {}) {
|
|
|
28135
27897
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
28136
27898
|
import { useEffect as useEffect21, useState as useState27 } from "react";
|
|
28137
27899
|
import { Box as Box42, Text as Text44, useInput as useInput9 } from "ink";
|
|
28138
|
-
|
|
27900
|
+
|
|
27901
|
+
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
27902
|
+
import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
|
|
27903
|
+
import { existsSync as existsSync9, readdirSync as readdirSync4 } from "node:fs";
|
|
27904
|
+
import { join as join24 } from "node:path";
|
|
27905
|
+
|
|
27906
|
+
// packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
|
|
27907
|
+
var DEFAULT_DEBUG_MODE_SETTING = {
|
|
27908
|
+
enabled: true
|
|
27909
|
+
};
|
|
27910
|
+
async function readDebugModeSetting() {
|
|
27911
|
+
const { debugMode } = await readSettings2();
|
|
27912
|
+
return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
|
|
27913
|
+
}
|
|
27914
|
+
async function writeDebugModeSetting(setting) {
|
|
27915
|
+
await updateSettings2({ debugMode: setting });
|
|
27916
|
+
}
|
|
27917
|
+
|
|
27918
|
+
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
27919
|
+
var pendingRun;
|
|
27920
|
+
function generateRunId() {
|
|
27921
|
+
const now = /* @__PURE__ */ new Date();
|
|
27922
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
27923
|
+
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
27924
|
+
}
|
|
27925
|
+
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
27926
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
27927
|
+
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
27928
|
+
}
|
|
27929
|
+
function slugify(value) {
|
|
27930
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
27931
|
+
}
|
|
27932
|
+
function generateSessionId3() {
|
|
27933
|
+
const today = datePrefix();
|
|
27934
|
+
const root = debugSessionsDir2();
|
|
27935
|
+
const existing = existsSync9(root) ? readdirSync4(root) : [];
|
|
27936
|
+
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
27937
|
+
const maxSeq = existing.reduce((max, entry) => {
|
|
27938
|
+
const match2 = seqPattern.exec(entry);
|
|
27939
|
+
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
27940
|
+
}, 0);
|
|
27941
|
+
return `${today}-session-${maxSeq + 1}`;
|
|
27942
|
+
}
|
|
27943
|
+
var SESSION_ID = generateSessionId3();
|
|
27944
|
+
function sessionDebugDir() {
|
|
27945
|
+
return join24(debugSessionsDir2(), SESSION_ID);
|
|
27946
|
+
}
|
|
27947
|
+
function currentDebugSessionDir() {
|
|
27948
|
+
return sessionDebugDir();
|
|
27949
|
+
}
|
|
27950
|
+
void isDebugModeEnabled().then((enabled) => {
|
|
27951
|
+
if (!enabled) return void 0;
|
|
27952
|
+
return mkdir9(sessionDebugDir(), { recursive: true });
|
|
27953
|
+
});
|
|
27954
|
+
async function isDebugModeEnabled() {
|
|
27955
|
+
try {
|
|
27956
|
+
return (await readDebugModeSetting()).enabled;
|
|
27957
|
+
} catch {
|
|
27958
|
+
return true;
|
|
27959
|
+
}
|
|
27960
|
+
}
|
|
27961
|
+
function redact(value) {
|
|
27962
|
+
const clone = { ...value };
|
|
27963
|
+
if ("cma_token" in clone) {
|
|
27964
|
+
const raw = clone.cma_token;
|
|
27965
|
+
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
27966
|
+
}
|
|
27967
|
+
return clone;
|
|
27968
|
+
}
|
|
27969
|
+
function startDebugRun({
|
|
27970
|
+
flow,
|
|
27971
|
+
step,
|
|
27972
|
+
menuOption,
|
|
27973
|
+
inputs
|
|
27974
|
+
}) {
|
|
27975
|
+
const runId = generateRunId();
|
|
27976
|
+
const startedAt = Date.now();
|
|
27977
|
+
const redactedInputs = redact(inputs);
|
|
27978
|
+
isDebugModeEnabled().then((enabled) => {
|
|
27979
|
+
if (!enabled) return;
|
|
27980
|
+
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
27981
|
+
});
|
|
27982
|
+
}
|
|
27983
|
+
async function finishDebugRun({
|
|
27984
|
+
outputs,
|
|
27985
|
+
status,
|
|
27986
|
+
exitMethod
|
|
27987
|
+
}) {
|
|
27988
|
+
const run = pendingRun;
|
|
27989
|
+
if (!run) return;
|
|
27990
|
+
pendingRun = void 0;
|
|
27991
|
+
const durationMs = Date.now() - run.startedAt;
|
|
27992
|
+
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
27993
|
+
const flowSegments = run.flow.split("/");
|
|
27994
|
+
const dir = join24(sessionDebugDir(), ...flowSegments);
|
|
27995
|
+
await mkdir9(dir, { recursive: true });
|
|
27996
|
+
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
27997
|
+
await writeFile8(join24(dir, filename), content, { mode: 384 });
|
|
27998
|
+
}
|
|
27999
|
+
function nextAttemptFilename(dir, menuOption) {
|
|
28000
|
+
const today = datePrefix();
|
|
28001
|
+
const optionSlug = slugify(menuOption);
|
|
28002
|
+
const existing = existsSync9(dir) ? readdirSync4(dir) : [];
|
|
28003
|
+
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
28004
|
+
const maxAttempt = existing.reduce((max, entry) => {
|
|
28005
|
+
const match2 = attemptPattern.exec(entry);
|
|
28006
|
+
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
28007
|
+
}, 0);
|
|
28008
|
+
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
28009
|
+
}
|
|
28010
|
+
function renderMarkdown(run, finish) {
|
|
28011
|
+
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
28012
|
+
const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
28013
|
+
const flowSlug = run.flow.split("/").join("-");
|
|
28014
|
+
return `# Debug Log
|
|
28015
|
+
|
|
28016
|
+
- Run ID: ${run.runId}
|
|
28017
|
+
- Flow: ${flowSlug}
|
|
28018
|
+
- Step: ${stepLabel2}
|
|
28019
|
+
- Menu option: ${run.menuOption}
|
|
28020
|
+
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
28021
|
+
- CLI version: ${readPackageVersion()}
|
|
28022
|
+
- Platform: ${process.platform} / Node ${process.version}
|
|
28023
|
+
- Duration on screen: ${finish.durationMs}ms
|
|
28024
|
+
- Status: ${finish.status}
|
|
28025
|
+
- Exit method: ${finish.exitMethod}
|
|
28026
|
+
|
|
28027
|
+
## Inputs
|
|
28028
|
+
\`\`\`json
|
|
28029
|
+
${JSON.stringify(run.inputs, null, 2)}
|
|
28030
|
+
\`\`\`
|
|
28031
|
+
|
|
28032
|
+
## Outputs
|
|
28033
|
+
\`\`\`json
|
|
28034
|
+
${JSON.stringify(finish.outputs, null, 2)}
|
|
28035
|
+
\`\`\`
|
|
28036
|
+
`;
|
|
28037
|
+
}
|
|
28038
|
+
function handleCrash() {
|
|
28039
|
+
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
28040
|
+
}
|
|
28041
|
+
process.once("uncaughtException", (err) => {
|
|
28042
|
+
void handleCrash().finally(() => {
|
|
28043
|
+
throw err;
|
|
28044
|
+
});
|
|
28045
|
+
});
|
|
28046
|
+
process.once("unhandledRejection", (reason) => {
|
|
28047
|
+
void handleCrash().finally(() => {
|
|
28048
|
+
throw reason;
|
|
28049
|
+
});
|
|
28050
|
+
});
|
|
28051
|
+
process.once("SIGINT", () => {
|
|
28052
|
+
void handleCrash().finally(() => {
|
|
28053
|
+
process.exit(130);
|
|
28054
|
+
});
|
|
28055
|
+
});
|
|
28139
28056
|
|
|
28140
28057
|
// packages/experience-design-system-cli/src/tui/help/help-info.ts
|
|
28141
|
-
init_config();
|
|
28142
|
-
init_debug_store();
|
|
28143
|
-
init_debug_mode_store();
|
|
28144
|
-
init_version();
|
|
28145
28058
|
async function readHelpInfo() {
|
|
28146
28059
|
const debugMode = await readDebugModeSetting();
|
|
28147
28060
|
return {
|
|
28148
28061
|
storage: [
|
|
28149
28062
|
{ label: "Config folder", value: configRoot2() },
|
|
28150
|
-
{ label: "Settings file", value: configFilePath2() }
|
|
28063
|
+
{ label: "Settings file", value: configFilePath2() },
|
|
28064
|
+
{ label: "Debug logs", value: debugSessionsDir2() }
|
|
28151
28065
|
],
|
|
28152
28066
|
troubleshooting: [
|
|
28153
28067
|
{ label: "CLI version", value: readPackageVersion() },
|
|
@@ -28156,7 +28070,7 @@ async function readHelpInfo() {
|
|
|
28156
28070
|
{ label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
|
|
28157
28071
|
{
|
|
28158
28072
|
label: "This session",
|
|
28159
|
-
value:
|
|
28073
|
+
value: debugMode.enabled ? currentDebugSessionDir() : "no logs written while Debug Mode is off"
|
|
28160
28074
|
}
|
|
28161
28075
|
]
|
|
28162
28076
|
};
|
|
@@ -28273,7 +28187,6 @@ import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
|
|
|
28273
28187
|
import TextInput4 from "ink-text-input";
|
|
28274
28188
|
|
|
28275
28189
|
// packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
|
|
28276
|
-
init_config();
|
|
28277
28190
|
var readV1Store = readSettings2;
|
|
28278
28191
|
var writeV1Store = writeSettings2;
|
|
28279
28192
|
|
|
@@ -28286,8 +28199,7 @@ async function readCredentials() {
|
|
|
28286
28199
|
cmaToken: store.cmaToken || "",
|
|
28287
28200
|
host: store.host || "",
|
|
28288
28201
|
defaultComponentDir: store.defaultComponentDir || "",
|
|
28289
|
-
defaultTokenFile: store.defaultTokenFile || ""
|
|
28290
|
-
contentfulBaseDir: store.contentfulBaseDir || ""
|
|
28202
|
+
defaultTokenFile: store.defaultTokenFile || ""
|
|
28291
28203
|
};
|
|
28292
28204
|
}
|
|
28293
28205
|
async function writeCredentials(config) {
|
|
@@ -28303,7 +28215,6 @@ async function writeCredentials(config) {
|
|
|
28303
28215
|
}
|
|
28304
28216
|
|
|
28305
28217
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
28306
|
-
init_debug_store();
|
|
28307
28218
|
import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
28308
28219
|
var FIELD_ORDER = [
|
|
28309
28220
|
"spaceId",
|
|
@@ -28311,8 +28222,7 @@ var FIELD_ORDER = [
|
|
|
28311
28222
|
"cmaToken",
|
|
28312
28223
|
"host",
|
|
28313
28224
|
"defaultComponentDir",
|
|
28314
|
-
"defaultTokenFile"
|
|
28315
|
-
"contentfulBaseDir"
|
|
28225
|
+
"defaultTokenFile"
|
|
28316
28226
|
];
|
|
28317
28227
|
function debugFields(config) {
|
|
28318
28228
|
return {
|
|
@@ -28321,23 +28231,17 @@ function debugFields(config) {
|
|
|
28321
28231
|
cma_token: config?.cmaToken ?? "",
|
|
28322
28232
|
host: config?.host ?? "",
|
|
28323
28233
|
default_component_dir: config?.defaultComponentDir ?? "",
|
|
28324
|
-
default_token_file: config?.defaultTokenFile ?? ""
|
|
28325
|
-
contentful_base_dir: config?.contentfulBaseDir ?? ""
|
|
28234
|
+
default_token_file: config?.defaultTokenFile ?? ""
|
|
28326
28235
|
};
|
|
28327
28236
|
}
|
|
28328
28237
|
var FIELD_LABELS = {
|
|
28329
28238
|
spaceId: "Space ID",
|
|
28330
28239
|
environmentId: "Environment ID",
|
|
28331
28240
|
cmaToken: "CMA Token",
|
|
28332
|
-
host: "API Host",
|
|
28333
|
-
defaultComponentDir: "Default component directory",
|
|
28334
|
-
defaultTokenFile: "Default token file"
|
|
28335
|
-
contentfulBaseDir: "Root Project Directory"
|
|
28336
|
-
};
|
|
28337
|
-
var FIELD_HINTS = {
|
|
28338
|
-
contentfulBaseDir: "(where .contentful goes)"
|
|
28241
|
+
host: "API Host (optional)",
|
|
28242
|
+
defaultComponentDir: "Default component directory (optional)",
|
|
28243
|
+
defaultTokenFile: "Default token file (optional)"
|
|
28339
28244
|
};
|
|
28340
|
-
var LABEL_WIDTH = Math.max(...Object.values(FIELD_LABELS).map((label) => label.length));
|
|
28341
28245
|
function ConfigurationScreen({ onDone }) {
|
|
28342
28246
|
const [stage, setStage] = useState29("loading");
|
|
28343
28247
|
const [config, setConfig] = useState29(null);
|
|
@@ -28373,7 +28277,6 @@ function ConfigurationScreen({ onDone }) {
|
|
|
28373
28277
|
setNotice(null);
|
|
28374
28278
|
writeCredentials(config).then(() => {
|
|
28375
28279
|
setLastSaved(config);
|
|
28376
|
-
if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
|
|
28377
28280
|
setNotice({ kind: "success", text: "Configuration saved" });
|
|
28378
28281
|
setStage("form");
|
|
28379
28282
|
}).catch((err) => {
|
|
@@ -28439,7 +28342,10 @@ function ConfigurationScreen({ onDone }) {
|
|
|
28439
28342
|
const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
|
|
28440
28343
|
return /* @__PURE__ */ jsxs45(Box44, { gap: 1, children: [
|
|
28441
28344
|
/* @__PURE__ */ jsx55(Text46, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
|
|
28442
|
-
/* @__PURE__ */
|
|
28345
|
+
/* @__PURE__ */ jsxs45(Text46, { bold: isActive, children: [
|
|
28346
|
+
FIELD_LABELS[field],
|
|
28347
|
+
":"
|
|
28348
|
+
] }),
|
|
28443
28349
|
isActive && editing ? /* @__PURE__ */ jsx55(
|
|
28444
28350
|
TextInput4,
|
|
28445
28351
|
{
|
|
@@ -28448,8 +28354,7 @@ function ConfigurationScreen({ onDone }) {
|
|
|
28448
28354
|
onSubmit: () => setEditing(false),
|
|
28449
28355
|
mask: field === "cmaToken" ? "\u2022" : void 0
|
|
28450
28356
|
}
|
|
28451
|
-
) : /* @__PURE__ */ jsx55(Text46, {
|
|
28452
|
-
FIELD_HINTS[field] && /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: FIELD_HINTS[field] })
|
|
28357
|
+
) : /* @__PURE__ */ jsx55(Text46, { children: display || /* @__PURE__ */ jsx55(Text46, { color: PALETTE.muted, children: "(empty)" }) })
|
|
28453
28358
|
] }, field);
|
|
28454
28359
|
}) }),
|
|
28455
28360
|
notice && /* @__PURE__ */ jsxs45(Fragment17, { children: [
|
|
@@ -28501,7 +28406,6 @@ async function writeAnalyticsSetting(setting) {
|
|
|
28501
28406
|
}
|
|
28502
28407
|
|
|
28503
28408
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
28504
|
-
init_debug_store();
|
|
28505
28409
|
import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
28506
28410
|
function OptInAnalyticsScreen({ onDone }) {
|
|
28507
28411
|
const [loading, setLoading] = useState30(true);
|
|
@@ -28562,8 +28466,6 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
28562
28466
|
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
28563
28467
|
import { useEffect as useEffect24, useState as useState31 } from "react";
|
|
28564
28468
|
import { Box as Box46, Text as Text48, useInput as useInput13 } from "ink";
|
|
28565
|
-
init_version();
|
|
28566
|
-
init_debug_store();
|
|
28567
28469
|
import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
28568
28470
|
var UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
|
|
28569
28471
|
function UpgradeScreen({ onDone }) {
|
|
@@ -28635,8 +28537,6 @@ function renderBody(upgradeCheck) {
|
|
|
28635
28537
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
28636
28538
|
import { useEffect as useEffect25, useState as useState32 } from "react";
|
|
28637
28539
|
import { Box as Box47, Text as Text49, useInput as useInput14 } from "ink";
|
|
28638
|
-
init_debug_mode_store();
|
|
28639
|
-
init_debug_store();
|
|
28640
28540
|
import { jsx as jsx58, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
28641
28541
|
function DebugModeScreen({ onDone }) {
|
|
28642
28542
|
const [loading, setLoading] = useState32(true);
|
|
@@ -28739,7 +28639,7 @@ function App({ importOptions, inkClear }) {
|
|
|
28739
28639
|
const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
|
|
28740
28640
|
const state = await inspectTokens({
|
|
28741
28641
|
rawTokensPath: tokens,
|
|
28742
|
-
|
|
28642
|
+
outDir: join25(resolveUserPath(projectPath2), ".contentful"),
|
|
28743
28643
|
cache: importOptions.cache
|
|
28744
28644
|
});
|
|
28745
28645
|
if (state.kind === "cached") {
|
|
@@ -28760,7 +28660,6 @@ function App({ importOptions, inkClear }) {
|
|
|
28760
28660
|
const settings = await readSettings2();
|
|
28761
28661
|
const { agent, agentModel } = resolveAgentChoice(launch.agent, settings);
|
|
28762
28662
|
const generatePromptPath = typeof settings.generatePromptPath === "string" ? settings.generatePromptPath : void 0;
|
|
28763
|
-
const outDir = await (await Promise.resolve().then(() => (init_debug_store(), debug_store_exports))).startImportRun(resolveUserPath(launch.projectPath ?? ""));
|
|
28764
28663
|
setExtractionRun({
|
|
28765
28664
|
...generatePromptPath ? { generatePromptPath } : {},
|
|
28766
28665
|
// the later steps get the same agent, so they use what the stage used
|
|
@@ -28769,7 +28668,6 @@ function App({ importOptions, inkClear }) {
|
|
|
28769
28668
|
tokenStrategy,
|
|
28770
28669
|
input: {
|
|
28771
28670
|
projectPath: resolveUserPath(launch.projectPath ?? ""),
|
|
28772
|
-
outDir,
|
|
28773
28671
|
filePaths: launch.filePaths ?? [],
|
|
28774
28672
|
rawTokensPath: launch.tokens ?? "",
|
|
28775
28673
|
tokenStrategy,
|