@contentful/experience-design-system-cli 2.37.1-dev-build-cffd984a.0 → 2.37.1-dev-build-2fb4dadf.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 +287 -364
- package/dist/index.js +229 -258
- package/dist/package.json +1 -1
- package/dist/src/tui/debug-store.d.ts +0 -6
- 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,241 +2016,8 @@ 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, debugSessionsDir2;
|
|
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
|
-
debugSessionsDir2 = () => join17(configRoot2(), "debug", "sessions");
|
|
2116
|
-
}
|
|
2117
|
-
});
|
|
2118
|
-
|
|
2119
|
-
// packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
|
|
2120
|
-
async function readDebugModeSetting() {
|
|
2121
|
-
const { debugMode } = await readSettings2();
|
|
2122
|
-
return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
|
|
2123
|
-
}
|
|
2124
|
-
async function writeDebugModeSetting(setting) {
|
|
2125
|
-
await updateSettings2({ debugMode: setting });
|
|
2126
|
-
}
|
|
2127
|
-
var DEFAULT_DEBUG_MODE_SETTING;
|
|
2128
|
-
var init_debug_mode_store = __esm({
|
|
2129
|
-
"packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
|
|
2130
|
-
"use strict";
|
|
2131
|
-
init_config();
|
|
2132
|
-
DEFAULT_DEBUG_MODE_SETTING = {
|
|
2133
|
-
enabled: true
|
|
2134
|
-
};
|
|
2135
|
-
}
|
|
2136
|
-
});
|
|
2137
|
-
|
|
2138
|
-
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
2139
|
-
var debug_store_exports = {};
|
|
2140
|
-
__export(debug_store_exports, {
|
|
2141
|
-
currentDebugSessionDir: () => currentDebugSessionDir,
|
|
2142
|
-
finishDebugRun: () => finishDebugRun,
|
|
2143
|
-
setDebugOutDir: () => setDebugOutDir,
|
|
2144
|
-
startDebugRun: () => startDebugRun
|
|
2145
|
-
});
|
|
2146
|
-
import { cp, mkdir as mkdir8, rename as rename3, rm, writeFile as writeFile7 } from "node:fs/promises";
|
|
2147
|
-
import { existsSync as existsSync9, readdirSync as readdirSync3 } from "node:fs";
|
|
2148
|
-
import { join as join20, resolve as resolve23 } from "node:path";
|
|
2149
|
-
function generateRunId() {
|
|
2150
|
-
const now = /* @__PURE__ */ new Date();
|
|
2151
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
2152
|
-
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
2153
|
-
}
|
|
2154
|
-
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
2155
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
2156
|
-
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
2157
|
-
}
|
|
2158
|
-
function slugify(value) {
|
|
2159
|
-
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
2160
|
-
}
|
|
2161
|
-
function generateSessionId3() {
|
|
2162
|
-
const today = datePrefix();
|
|
2163
|
-
const root = debugSessionsDir2();
|
|
2164
|
-
const existing = existsSync9(root) ? readdirSync3(root) : [];
|
|
2165
|
-
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
2166
|
-
const maxSeq = existing.reduce((max, entry) => {
|
|
2167
|
-
const match2 = seqPattern.exec(entry);
|
|
2168
|
-
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
2169
|
-
}, 0);
|
|
2170
|
-
return `${today}-session-${maxSeq + 1}`;
|
|
2171
|
-
}
|
|
2172
|
-
function sessionDebugDir() {
|
|
2173
|
-
return join20(projectSessionsRoot ?? debugSessionsDir2(), SESSION_ID);
|
|
2174
|
-
}
|
|
2175
|
-
function currentDebugSessionDir() {
|
|
2176
|
-
return sessionDebugDir();
|
|
2177
|
-
}
|
|
2178
|
-
async function setDebugOutDir(outDir) {
|
|
2179
|
-
if (!await isDebugModeEnabled()) return;
|
|
2180
|
-
const nextRoot = join20(resolve23(outDir), "debug", "sessions");
|
|
2181
|
-
const from = sessionDebugDir();
|
|
2182
|
-
const to = join20(nextRoot, SESSION_ID);
|
|
2183
|
-
if (from === to) return;
|
|
2184
|
-
try {
|
|
2185
|
-
await mkdir8(nextRoot, { recursive: true });
|
|
2186
|
-
if (existsSync9(from)) {
|
|
2187
|
-
try {
|
|
2188
|
-
await rename3(from, to);
|
|
2189
|
-
} catch {
|
|
2190
|
-
await cp(from, to, { recursive: true });
|
|
2191
|
-
await rm(from, { recursive: true, force: true });
|
|
2192
|
-
}
|
|
2193
|
-
} else {
|
|
2194
|
-
await mkdir8(to, { recursive: true });
|
|
2195
|
-
}
|
|
2196
|
-
projectSessionsRoot = nextRoot;
|
|
2197
|
-
} catch {
|
|
2198
|
-
}
|
|
2199
|
-
}
|
|
2200
|
-
async function isDebugModeEnabled() {
|
|
2201
|
-
try {
|
|
2202
|
-
return (await readDebugModeSetting()).enabled;
|
|
2203
|
-
} catch {
|
|
2204
|
-
return true;
|
|
2205
|
-
}
|
|
2206
|
-
}
|
|
2207
|
-
function redact(value) {
|
|
2208
|
-
const clone = { ...value };
|
|
2209
|
-
if ("cma_token" in clone) {
|
|
2210
|
-
const raw = clone.cma_token;
|
|
2211
|
-
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
2212
|
-
}
|
|
2213
|
-
return clone;
|
|
2214
|
-
}
|
|
2215
|
-
function startDebugRun({
|
|
2216
|
-
flow,
|
|
2217
|
-
step,
|
|
2218
|
-
menuOption,
|
|
2219
|
-
inputs
|
|
2220
|
-
}) {
|
|
2221
|
-
const runId = generateRunId();
|
|
2222
|
-
const startedAt = Date.now();
|
|
2223
|
-
const redactedInputs = redact(inputs);
|
|
2224
|
-
isDebugModeEnabled().then((enabled) => {
|
|
2225
|
-
if (!enabled) return;
|
|
2226
|
-
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
2227
|
-
});
|
|
2228
|
-
}
|
|
2229
|
-
async function finishDebugRun({
|
|
2230
|
-
outputs,
|
|
2231
|
-
status,
|
|
2232
|
-
exitMethod
|
|
2233
|
-
}) {
|
|
2234
|
-
const run = pendingRun;
|
|
2235
|
-
if (!run) return;
|
|
2236
|
-
pendingRun = void 0;
|
|
2237
|
-
const durationMs = Date.now() - run.startedAt;
|
|
2238
|
-
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
2239
|
-
const flowSegments = run.flow.split("/");
|
|
2240
|
-
const dir = join20(sessionDebugDir(), ...flowSegments);
|
|
2241
|
-
await mkdir8(dir, { recursive: true });
|
|
2242
|
-
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
2243
|
-
await writeFile7(join20(dir, filename), content, { mode: 384 });
|
|
2244
|
-
}
|
|
2245
|
-
function nextAttemptFilename(dir, menuOption) {
|
|
2246
|
-
const today = datePrefix();
|
|
2247
|
-
const optionSlug = slugify(menuOption);
|
|
2248
|
-
const existing = existsSync9(dir) ? readdirSync3(dir) : [];
|
|
2249
|
-
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
2250
|
-
const maxAttempt = existing.reduce((max, entry) => {
|
|
2251
|
-
const match2 = attemptPattern.exec(entry);
|
|
2252
|
-
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
2253
|
-
}, 0);
|
|
2254
|
-
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
2255
|
-
}
|
|
2256
|
-
function renderMarkdown(run, finish) {
|
|
2257
|
-
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
2258
|
-
const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
2259
|
-
const flowSlug = run.flow.split("/").join("-");
|
|
2260
|
-
return `# Debug Log
|
|
2261
|
-
|
|
2262
|
-
- Run ID: ${run.runId}
|
|
2263
|
-
- Flow: ${flowSlug}
|
|
2264
|
-
- Step: ${stepLabel2}
|
|
2265
|
-
- Menu option: ${run.menuOption}
|
|
2266
|
-
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
2267
|
-
- CLI version: ${readPackageVersion()}
|
|
2268
|
-
- Platform: ${process.platform} / Node ${process.version}
|
|
2269
|
-
- Duration on screen: ${finish.durationMs}ms
|
|
2270
|
-
- Status: ${finish.status}
|
|
2271
|
-
- Exit method: ${finish.exitMethod}
|
|
2272
|
-
|
|
2273
|
-
## Inputs
|
|
2274
|
-
\`\`\`json
|
|
2275
|
-
${JSON.stringify(run.inputs, null, 2)}
|
|
2276
|
-
\`\`\`
|
|
2277
|
-
|
|
2278
|
-
## Outputs
|
|
2279
|
-
\`\`\`json
|
|
2280
|
-
${JSON.stringify(finish.outputs, null, 2)}
|
|
2281
|
-
\`\`\`
|
|
2282
|
-
`;
|
|
2283
|
-
}
|
|
2284
|
-
function handleCrash() {
|
|
2285
|
-
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
2286
|
-
}
|
|
2287
|
-
var pendingRun, SESSION_ID, projectSessionsRoot;
|
|
2288
|
-
var init_debug_store = __esm({
|
|
2289
|
-
"packages/experience-design-system-cli/src/tui/debug-store.ts"() {
|
|
2290
|
-
"use strict";
|
|
2291
|
-
init_config();
|
|
2292
|
-
init_version();
|
|
2293
|
-
init_debug_mode_store();
|
|
2294
|
-
SESSION_ID = generateSessionId3();
|
|
2295
|
-
void isDebugModeEnabled().then((enabled) => {
|
|
2296
|
-
if (!enabled) return void 0;
|
|
2297
|
-
return mkdir8(sessionDebugDir(), { recursive: true });
|
|
2298
|
-
});
|
|
2299
|
-
process.once("uncaughtException", (err) => {
|
|
2300
|
-
void handleCrash().finally(() => {
|
|
2301
|
-
throw err;
|
|
2302
|
-
});
|
|
2303
|
-
});
|
|
2304
|
-
process.once("unhandledRejection", (reason) => {
|
|
2305
|
-
void handleCrash().finally(() => {
|
|
2306
|
-
throw reason;
|
|
2307
|
-
});
|
|
2308
|
-
});
|
|
2309
|
-
process.once("SIGINT", () => {
|
|
2310
|
-
void handleCrash().finally(() => {
|
|
2311
|
-
process.exit(130);
|
|
2312
|
-
});
|
|
2313
|
-
});
|
|
2314
|
-
}
|
|
2315
|
-
});
|
|
2316
|
-
|
|
2317
2019
|
// packages/experience-design-system-cli/app.tsx
|
|
2318
|
-
import { join as
|
|
2020
|
+
import { join as join25 } from "node:path";
|
|
2319
2021
|
import { useEffect as useEffect27, useState as useState33 } from "react";
|
|
2320
2022
|
|
|
2321
2023
|
// packages/experience-design-system-cli/src/tui/home/home.tsx
|
|
@@ -2353,8 +2055,60 @@ function brandBar(width, ramp = BRAND_RAMP) {
|
|
|
2353
2055
|
}
|
|
2354
2056
|
var FOCUS_MARKER = "\u276F";
|
|
2355
2057
|
|
|
2356
|
-
// packages/experience-design-system-cli/src/tui/
|
|
2357
|
-
|
|
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
|
+
}
|
|
2358
2112
|
|
|
2359
2113
|
// packages/experience-design-system-cli/src/tui/use-terminal-width.ts
|
|
2360
2114
|
import { useEffect, useState } from "react";
|
|
@@ -4378,12 +4132,12 @@ function renameEmptySlots(db, sessionId, componentId, componentName, slotCount)
|
|
|
4378
4132
|
return { renames: [], warnings: [] };
|
|
4379
4133
|
const renames = [];
|
|
4380
4134
|
const warnings = [];
|
|
4381
|
-
const
|
|
4135
|
+
const rename3 = db.prepare(`UPDATE raw_slots SET name = ? WHERE session_id = ? AND component_id = ? AND name = ? AND position = ?`);
|
|
4382
4136
|
db.exec("BEGIN");
|
|
4383
4137
|
try {
|
|
4384
4138
|
for (const slot of emptySlots) {
|
|
4385
4139
|
const newName = slotCount === 1 ? "children" : `slot_${slot.position}`;
|
|
4386
|
-
|
|
4140
|
+
rename3.run(newName, sessionId, componentId, slot.name, slot.position);
|
|
4387
4141
|
renames.push({ oldName: slot.name, newName });
|
|
4388
4142
|
warnings.push(`${componentName}: slot at position ${slot.position} had empty name \u2014 renamed to "${newName}" for classification`);
|
|
4389
4143
|
}
|
|
@@ -13756,7 +13510,7 @@ function errorMessage(error) {
|
|
|
13756
13510
|
return error instanceof Error && error.message ? error.message : String(error);
|
|
13757
13511
|
}
|
|
13758
13512
|
function defaultSleep(delayMs) {
|
|
13759
|
-
return new Promise((
|
|
13513
|
+
return new Promise((resolve25) => setTimeout(resolve25, delayMs));
|
|
13760
13514
|
}
|
|
13761
13515
|
|
|
13762
13516
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/sanitize-preview.js
|
|
@@ -13997,7 +13751,7 @@ var ApiClient = class {
|
|
|
13997
13751
|
const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
|
|
13998
13752
|
const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
|
|
13999
13753
|
const jitter = Math.random() * baseDelay * 0.15;
|
|
14000
|
-
await new Promise((
|
|
13754
|
+
await new Promise((resolve25) => setTimeout(resolve25, baseDelay + jitter));
|
|
14001
13755
|
}
|
|
14002
13756
|
}
|
|
14003
13757
|
throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
|
|
@@ -16110,7 +15864,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
|
|
|
16110
15864
|
const message = error instanceof Error ? error.message : String(error);
|
|
16111
15865
|
if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
|
|
16112
15866
|
throw error;
|
|
16113
|
-
await new Promise((
|
|
15867
|
+
await new Promise((resolve25) => setTimeout(resolve25, Math.min(250 * attempt, 2e3)));
|
|
16114
15868
|
}
|
|
16115
15869
|
}
|
|
16116
15870
|
}
|
|
@@ -16527,12 +16281,12 @@ async function runOneGenerateComponent(options, component, index, total) {
|
|
|
16527
16281
|
if (renames.length > 0) {
|
|
16528
16282
|
const renameMap = new Map(renames.map((r) => [r.oldName, r.newName]));
|
|
16529
16283
|
effectiveSlots = component.slots.map((s) => renameMap.has(s.name) ? { ...s, name: renameMap.get(s.name) } : s);
|
|
16530
|
-
for (const
|
|
16284
|
+
for (const rename3 of renames) {
|
|
16531
16285
|
onProgress?.({
|
|
16532
16286
|
kind: "component:slot-renamed",
|
|
16533
16287
|
componentName: component.name,
|
|
16534
|
-
oldName:
|
|
16535
|
-
newName:
|
|
16288
|
+
oldName: rename3.oldName,
|
|
16289
|
+
newName: rename3.newName
|
|
16536
16290
|
});
|
|
16537
16291
|
}
|
|
16538
16292
|
}
|
|
@@ -16658,7 +16412,7 @@ async function runWithPool(items, concurrency, worker) {
|
|
|
16658
16412
|
init_cache_keys();
|
|
16659
16413
|
|
|
16660
16414
|
// packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/restore-cached-components.js
|
|
16661
|
-
function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, allowedComponentNames2) {
|
|
16415
|
+
async function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, allowedComponentNames2) {
|
|
16662
16416
|
const restorations = [];
|
|
16663
16417
|
const rekeyed = [];
|
|
16664
16418
|
const componentStatus = db.prepare("SELECT status FROM raw_components WHERE session_id = ? AND component_id = ?");
|
|
@@ -16673,6 +16427,7 @@ function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, al
|
|
|
16673
16427
|
componentId: component.component_id
|
|
16674
16428
|
});
|
|
16675
16429
|
rekeyed.push({ component, cached: resolution.entry });
|
|
16430
|
+
await new Promise((r) => setImmediate(r));
|
|
16676
16431
|
}
|
|
16677
16432
|
copyComponentsFromCache(db, restorations, { allowedComponentNames: allowedComponentNames2 });
|
|
16678
16433
|
storeCaches(db, rekeyed.map(({ component, cached }) => ({
|
|
@@ -16706,12 +16461,15 @@ async function checkGenerateComponentsCache(request) {
|
|
|
16706
16461
|
...components.map((component) => component.name),
|
|
16707
16462
|
...(existingEntities?.components ?? []).map((component) => component.name)
|
|
16708
16463
|
]);
|
|
16709
|
-
const cachedComponents =
|
|
16464
|
+
const cachedComponents = [];
|
|
16465
|
+
for (const component of components) {
|
|
16710
16466
|
const resolution = resolveComponentCache(db, component, promptHash, allowedComponentNames2);
|
|
16711
|
-
|
|
16712
|
-
|
|
16467
|
+
if (resolution)
|
|
16468
|
+
cachedComponents.push({ component, resolution });
|
|
16469
|
+
await new Promise((r) => setImmediate(r));
|
|
16470
|
+
}
|
|
16713
16471
|
if (request.restoreCache) {
|
|
16714
|
-
restoreCachedComponents(db, request.sessionId, cachedComponents, promptHash, allowedComponentNames2);
|
|
16472
|
+
await restoreCachedComponents(db, request.sessionId, cachedComponents, promptHash, allowedComponentNames2);
|
|
16715
16473
|
}
|
|
16716
16474
|
return {
|
|
16717
16475
|
sessionId: request.sessionId,
|
|
@@ -16933,7 +16691,6 @@ function useCredentialsControls(handlers) {
|
|
|
16933
16691
|
}
|
|
16934
16692
|
|
|
16935
16693
|
// packages/experience-design-system-cli/src/tui/user-agent.ts
|
|
16936
|
-
init_version();
|
|
16937
16694
|
function cliUserAgent() {
|
|
16938
16695
|
return buildUserAgent(readPackageVersion());
|
|
16939
16696
|
}
|
|
@@ -17433,11 +17190,36 @@ function ExtractionScreen({
|
|
|
17433
17190
|
);
|
|
17434
17191
|
}
|
|
17435
17192
|
|
|
17436
|
-
// packages/experience-design-system-
|
|
17437
|
-
|
|
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
|
+
}
|
|
17438
17221
|
|
|
17439
17222
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
|
|
17440
|
-
import { join as join21, resolve as resolve24 } from "node:path";
|
|
17441
17223
|
import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
|
|
17442
17224
|
|
|
17443
17225
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts
|
|
@@ -17711,9 +17493,6 @@ function useExtraction(input) {
|
|
|
17711
17493
|
reuseTokens: input.tokenStrategy === "reuse"
|
|
17712
17494
|
})
|
|
17713
17495
|
});
|
|
17714
|
-
void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then(
|
|
17715
|
-
(store) => store.setDebugOutDir(join21(resolve24(input.projectPath), ".contentful"))
|
|
17716
|
-
);
|
|
17717
17496
|
void runExtraction(input, (progress) => {
|
|
17718
17497
|
if (current.current === input) setState({ status: "running", progress });
|
|
17719
17498
|
}).then((result) => {
|
|
@@ -20600,7 +20379,7 @@ function GenerationScreen({
|
|
|
20600
20379
|
import { useEffect as useEffect9, useRef as useRef6, useState as useState14 } from "react";
|
|
20601
20380
|
|
|
20602
20381
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
|
|
20603
|
-
import { resolve as
|
|
20382
|
+
import { resolve as resolve23 } from "node:path";
|
|
20604
20383
|
|
|
20605
20384
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/map-tokens.ts
|
|
20606
20385
|
async function prepareMapTokens(input, generatedSessionId) {
|
|
@@ -20735,7 +20514,7 @@ async function buildMapTokensOptions(input) {
|
|
|
20735
20514
|
if (mapOverride?.kind === "text") prompt.skillContentOverride = mapOverride.value;
|
|
20736
20515
|
if (mapOverride?.kind === "path") {
|
|
20737
20516
|
await resolvePromptOverride(mapOverride);
|
|
20738
|
-
prompt.skillPathOverride =
|
|
20517
|
+
prompt.skillPathOverride = resolve23(mapOverride.value);
|
|
20739
20518
|
}
|
|
20740
20519
|
if (input.existingEntitiesPath) {
|
|
20741
20520
|
const entities = await readExistingContentfulEntitiesFromSession({ path: input.existingEntitiesPath });
|
|
@@ -20783,7 +20562,7 @@ function useGeneration(input) {
|
|
|
20783
20562
|
}
|
|
20784
20563
|
|
|
20785
20564
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/build-flow-start.ts
|
|
20786
|
-
import { join as
|
|
20565
|
+
import { join as join20 } from "node:path";
|
|
20787
20566
|
function buildFlowStart(input) {
|
|
20788
20567
|
const { extraction, handoff, saved, generatePromptPath } = input;
|
|
20789
20568
|
const credentials = extraction.credentials ?? {
|
|
@@ -20796,7 +20575,7 @@ function buildFlowStart(input) {
|
|
|
20796
20575
|
handoff,
|
|
20797
20576
|
agent: extraction.agent,
|
|
20798
20577
|
projectPath: extraction.projectPath,
|
|
20799
|
-
outDir: extraction.projectPath ?
|
|
20578
|
+
outDir: extraction.projectPath ? join20(extraction.projectPath, ".contentful") : "",
|
|
20800
20579
|
rawTokensPath: extraction.rawTokensPath,
|
|
20801
20580
|
credentials: {
|
|
20802
20581
|
spaceId: credentials.spaceId,
|
|
@@ -26539,11 +26318,11 @@ function DoneStep({
|
|
|
26539
26318
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/PathPrompt.tsx
|
|
26540
26319
|
import { useState as useState24 } from "react";
|
|
26541
26320
|
import { Box as Box37, Text as Text40 } from "ink";
|
|
26542
|
-
import { readdirSync as
|
|
26543
|
-
import { dirname as dirname15, basename as basename6, join as
|
|
26321
|
+
import { readdirSync as readdirSync3 } from "node:fs";
|
|
26322
|
+
import { dirname as dirname15, basename as basename6, join as join21 } from "node:path";
|
|
26544
26323
|
|
|
26545
26324
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts
|
|
26546
|
-
import { resolve as
|
|
26325
|
+
import { resolve as resolve24 } from "node:path";
|
|
26547
26326
|
import { homedir as homedir4 } from "node:os";
|
|
26548
26327
|
function expandTilde(input) {
|
|
26549
26328
|
if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
|
|
@@ -26557,7 +26336,7 @@ function normalizePath(input) {
|
|
|
26557
26336
|
p = p.slice(1, -1);
|
|
26558
26337
|
}
|
|
26559
26338
|
p = expandTilde(p);
|
|
26560
|
-
return
|
|
26339
|
+
return resolve24(p);
|
|
26561
26340
|
}
|
|
26562
26341
|
|
|
26563
26342
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
|
|
@@ -26580,19 +26359,19 @@ function autocomplete(partial) {
|
|
|
26580
26359
|
const base = basename6(normalized);
|
|
26581
26360
|
let entries;
|
|
26582
26361
|
try {
|
|
26583
|
-
entries =
|
|
26362
|
+
entries = readdirSync3(dir);
|
|
26584
26363
|
} catch {
|
|
26585
26364
|
return null;
|
|
26586
26365
|
}
|
|
26587
26366
|
const matches = entries.filter((e) => e.startsWith(base));
|
|
26588
26367
|
if (matches.length === 0) return null;
|
|
26589
|
-
if (matches.length === 1) return
|
|
26368
|
+
if (matches.length === 1) return join21(dir, matches[0]);
|
|
26590
26369
|
let prefix = matches[0];
|
|
26591
26370
|
for (const m of matches) {
|
|
26592
26371
|
while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
|
|
26593
26372
|
if (!prefix) break;
|
|
26594
26373
|
}
|
|
26595
|
-
return prefix.length > base.length ?
|
|
26374
|
+
return prefix.length > base.length ? join21(dir, prefix) : null;
|
|
26596
26375
|
}
|
|
26597
26376
|
function PathPrompt({
|
|
26598
26377
|
defaultPath,
|
|
@@ -27351,9 +27130,9 @@ import { useEffect as useEffect21, useRef as useRef13, useSyncExternalStore } fr
|
|
|
27351
27130
|
|
|
27352
27131
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
|
|
27353
27132
|
import { appendFileSync, writeFileSync } from "node:fs";
|
|
27354
|
-
import { mkdir as
|
|
27133
|
+
import { mkdir as mkdir8 } from "node:fs/promises";
|
|
27355
27134
|
import { tmpdir } from "node:os";
|
|
27356
|
-
import { join as
|
|
27135
|
+
import { join as join23 } from "node:path";
|
|
27357
27136
|
|
|
27358
27137
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/wizard-state-transitions.ts
|
|
27359
27138
|
function shouldBypassPreview(state) {
|
|
@@ -27697,8 +27476,8 @@ function pushFailure(e, deps) {
|
|
|
27697
27476
|
}
|
|
27698
27477
|
|
|
27699
27478
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts
|
|
27700
|
-
import { writeFile as
|
|
27701
|
-
import { join as
|
|
27479
|
+
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
27480
|
+
import { join as join22 } from "node:path";
|
|
27702
27481
|
|
|
27703
27482
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/run-print-files-helpers.ts
|
|
27704
27483
|
function nextStateAfterPrint(opts) {
|
|
@@ -27721,15 +27500,15 @@ function buildSavedCDF(components, tokens, opts = {}) {
|
|
|
27721
27500
|
var realSaveDeps = () => ({
|
|
27722
27501
|
openDb: openPipelineDb,
|
|
27723
27502
|
readTokens: (path5) => readTokensFromPath2({ flag: "tokens", path: path5 }),
|
|
27724
|
-
writeFile: (path5, contents) =>
|
|
27503
|
+
writeFile: (path5, contents) => writeFile7(path5, contents),
|
|
27725
27504
|
appendRun,
|
|
27726
27505
|
buildSourceFingerprint,
|
|
27727
|
-
sleep: (ms) => new Promise((
|
|
27506
|
+
sleep: (ms) => new Promise((resolve25) => setTimeout(resolve25, ms)),
|
|
27728
27507
|
warn: (message) => process.stderr.write(message)
|
|
27729
27508
|
});
|
|
27730
27509
|
async function runPrintFiles(input, deps, onPatch) {
|
|
27731
27510
|
onPatch({ step: "printing" });
|
|
27732
|
-
const componentsPath =
|
|
27511
|
+
const componentsPath = join22(input.outDir, "components.json");
|
|
27733
27512
|
try {
|
|
27734
27513
|
const db = deps.openDb();
|
|
27735
27514
|
let components = [];
|
|
@@ -27810,7 +27589,7 @@ var EMPTY_PUSH_RESULT = {
|
|
|
27810
27589
|
};
|
|
27811
27590
|
|
|
27812
27591
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
|
|
27813
|
-
var WIZARD_LOG =
|
|
27592
|
+
var WIZARD_LOG = join23(tmpdir(), "experiences-import-wizard.log");
|
|
27814
27593
|
function appendWizardLog(entry) {
|
|
27815
27594
|
appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
|
|
27816
27595
|
}
|
|
@@ -27833,7 +27612,7 @@ function realFlowDeps() {
|
|
|
27833
27612
|
}
|
|
27834
27613
|
},
|
|
27835
27614
|
mkdir: async (path5) => {
|
|
27836
|
-
await
|
|
27615
|
+
await mkdir8(path5, { recursive: true });
|
|
27837
27616
|
},
|
|
27838
27617
|
detectSaveConflict,
|
|
27839
27618
|
buildTimestampedSubdir,
|
|
@@ -28097,20 +27876,171 @@ function useFlow(start, deps = realFlowDeps) {
|
|
|
28097
27876
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
28098
27877
|
import { useEffect as useEffect22, useState as useState27 } from "react";
|
|
28099
27878
|
import { Box as Box42, Text as Text44, useInput as useInput9 } from "ink";
|
|
28100
|
-
|
|
27879
|
+
|
|
27880
|
+
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
27881
|
+
import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
|
|
27882
|
+
import { existsSync as existsSync9, readdirSync as readdirSync4 } from "node:fs";
|
|
27883
|
+
import { join as join24 } from "node:path";
|
|
27884
|
+
|
|
27885
|
+
// packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
|
|
27886
|
+
var DEFAULT_DEBUG_MODE_SETTING = {
|
|
27887
|
+
enabled: true
|
|
27888
|
+
};
|
|
27889
|
+
async function readDebugModeSetting() {
|
|
27890
|
+
const { debugMode } = await readSettings2();
|
|
27891
|
+
return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
|
|
27892
|
+
}
|
|
27893
|
+
async function writeDebugModeSetting(setting) {
|
|
27894
|
+
await updateSettings2({ debugMode: setting });
|
|
27895
|
+
}
|
|
27896
|
+
|
|
27897
|
+
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
27898
|
+
var pendingRun;
|
|
27899
|
+
function generateRunId() {
|
|
27900
|
+
const now = /* @__PURE__ */ new Date();
|
|
27901
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
27902
|
+
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
27903
|
+
}
|
|
27904
|
+
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
27905
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
27906
|
+
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
27907
|
+
}
|
|
27908
|
+
function slugify(value) {
|
|
27909
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
27910
|
+
}
|
|
27911
|
+
function generateSessionId3() {
|
|
27912
|
+
const today = datePrefix();
|
|
27913
|
+
const root = debugSessionsDir2();
|
|
27914
|
+
const existing = existsSync9(root) ? readdirSync4(root) : [];
|
|
27915
|
+
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
27916
|
+
const maxSeq = existing.reduce((max, entry) => {
|
|
27917
|
+
const match2 = seqPattern.exec(entry);
|
|
27918
|
+
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
27919
|
+
}, 0);
|
|
27920
|
+
return `${today}-session-${maxSeq + 1}`;
|
|
27921
|
+
}
|
|
27922
|
+
var SESSION_ID = generateSessionId3();
|
|
27923
|
+
function sessionDebugDir() {
|
|
27924
|
+
return join24(debugSessionsDir2(), SESSION_ID);
|
|
27925
|
+
}
|
|
27926
|
+
function currentDebugSessionDir() {
|
|
27927
|
+
return sessionDebugDir();
|
|
27928
|
+
}
|
|
27929
|
+
void isDebugModeEnabled().then((enabled) => {
|
|
27930
|
+
if (!enabled) return void 0;
|
|
27931
|
+
return mkdir9(sessionDebugDir(), { recursive: true });
|
|
27932
|
+
});
|
|
27933
|
+
async function isDebugModeEnabled() {
|
|
27934
|
+
try {
|
|
27935
|
+
return (await readDebugModeSetting()).enabled;
|
|
27936
|
+
} catch {
|
|
27937
|
+
return true;
|
|
27938
|
+
}
|
|
27939
|
+
}
|
|
27940
|
+
function redact(value) {
|
|
27941
|
+
const clone = { ...value };
|
|
27942
|
+
if ("cma_token" in clone) {
|
|
27943
|
+
const raw = clone.cma_token;
|
|
27944
|
+
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
27945
|
+
}
|
|
27946
|
+
return clone;
|
|
27947
|
+
}
|
|
27948
|
+
function startDebugRun({
|
|
27949
|
+
flow,
|
|
27950
|
+
step,
|
|
27951
|
+
menuOption,
|
|
27952
|
+
inputs
|
|
27953
|
+
}) {
|
|
27954
|
+
const runId = generateRunId();
|
|
27955
|
+
const startedAt = Date.now();
|
|
27956
|
+
const redactedInputs = redact(inputs);
|
|
27957
|
+
isDebugModeEnabled().then((enabled) => {
|
|
27958
|
+
if (!enabled) return;
|
|
27959
|
+
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
27960
|
+
});
|
|
27961
|
+
}
|
|
27962
|
+
async function finishDebugRun({
|
|
27963
|
+
outputs,
|
|
27964
|
+
status,
|
|
27965
|
+
exitMethod
|
|
27966
|
+
}) {
|
|
27967
|
+
const run = pendingRun;
|
|
27968
|
+
if (!run) return;
|
|
27969
|
+
pendingRun = void 0;
|
|
27970
|
+
const durationMs = Date.now() - run.startedAt;
|
|
27971
|
+
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
27972
|
+
const flowSegments = run.flow.split("/");
|
|
27973
|
+
const dir = join24(sessionDebugDir(), ...flowSegments);
|
|
27974
|
+
await mkdir9(dir, { recursive: true });
|
|
27975
|
+
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
27976
|
+
await writeFile8(join24(dir, filename), content, { mode: 384 });
|
|
27977
|
+
}
|
|
27978
|
+
function nextAttemptFilename(dir, menuOption) {
|
|
27979
|
+
const today = datePrefix();
|
|
27980
|
+
const optionSlug = slugify(menuOption);
|
|
27981
|
+
const existing = existsSync9(dir) ? readdirSync4(dir) : [];
|
|
27982
|
+
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
27983
|
+
const maxAttempt = existing.reduce((max, entry) => {
|
|
27984
|
+
const match2 = attemptPattern.exec(entry);
|
|
27985
|
+
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
27986
|
+
}, 0);
|
|
27987
|
+
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
27988
|
+
}
|
|
27989
|
+
function renderMarkdown(run, finish) {
|
|
27990
|
+
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
27991
|
+
const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
27992
|
+
const flowSlug = run.flow.split("/").join("-");
|
|
27993
|
+
return `# Debug Log
|
|
27994
|
+
|
|
27995
|
+
- Run ID: ${run.runId}
|
|
27996
|
+
- Flow: ${flowSlug}
|
|
27997
|
+
- Step: ${stepLabel2}
|
|
27998
|
+
- Menu option: ${run.menuOption}
|
|
27999
|
+
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
28000
|
+
- CLI version: ${readPackageVersion()}
|
|
28001
|
+
- Platform: ${process.platform} / Node ${process.version}
|
|
28002
|
+
- Duration on screen: ${finish.durationMs}ms
|
|
28003
|
+
- Status: ${finish.status}
|
|
28004
|
+
- Exit method: ${finish.exitMethod}
|
|
28005
|
+
|
|
28006
|
+
## Inputs
|
|
28007
|
+
\`\`\`json
|
|
28008
|
+
${JSON.stringify(run.inputs, null, 2)}
|
|
28009
|
+
\`\`\`
|
|
28010
|
+
|
|
28011
|
+
## Outputs
|
|
28012
|
+
\`\`\`json
|
|
28013
|
+
${JSON.stringify(finish.outputs, null, 2)}
|
|
28014
|
+
\`\`\`
|
|
28015
|
+
`;
|
|
28016
|
+
}
|
|
28017
|
+
function handleCrash() {
|
|
28018
|
+
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
28019
|
+
}
|
|
28020
|
+
process.once("uncaughtException", (err) => {
|
|
28021
|
+
void handleCrash().finally(() => {
|
|
28022
|
+
throw err;
|
|
28023
|
+
});
|
|
28024
|
+
});
|
|
28025
|
+
process.once("unhandledRejection", (reason) => {
|
|
28026
|
+
void handleCrash().finally(() => {
|
|
28027
|
+
throw reason;
|
|
28028
|
+
});
|
|
28029
|
+
});
|
|
28030
|
+
process.once("SIGINT", () => {
|
|
28031
|
+
void handleCrash().finally(() => {
|
|
28032
|
+
process.exit(130);
|
|
28033
|
+
});
|
|
28034
|
+
});
|
|
28101
28035
|
|
|
28102
28036
|
// packages/experience-design-system-cli/src/tui/help/help-info.ts
|
|
28103
|
-
init_config();
|
|
28104
|
-
init_debug_store();
|
|
28105
|
-
init_debug_mode_store();
|
|
28106
|
-
init_version();
|
|
28107
28037
|
async function readHelpInfo() {
|
|
28108
28038
|
const debugMode = await readDebugModeSetting();
|
|
28109
28039
|
return {
|
|
28110
28040
|
storage: [
|
|
28111
28041
|
{ label: "Config folder", value: configRoot2() },
|
|
28112
28042
|
{ label: "Settings file", value: configFilePath2() },
|
|
28113
|
-
{ label: "Debug logs", value:
|
|
28043
|
+
{ label: "Debug logs", value: debugSessionsDir2() }
|
|
28114
28044
|
],
|
|
28115
28045
|
troubleshooting: [
|
|
28116
28046
|
{ label: "CLI version", value: readPackageVersion() },
|
|
@@ -28236,7 +28166,6 @@ import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
|
|
|
28236
28166
|
import TextInput4 from "ink-text-input";
|
|
28237
28167
|
|
|
28238
28168
|
// packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
|
|
28239
|
-
init_config();
|
|
28240
28169
|
var readV1Store = readSettings2;
|
|
28241
28170
|
var writeV1Store = writeSettings2;
|
|
28242
28171
|
|
|
@@ -28265,7 +28194,6 @@ async function writeCredentials(config) {
|
|
|
28265
28194
|
}
|
|
28266
28195
|
|
|
28267
28196
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
28268
|
-
init_debug_store();
|
|
28269
28197
|
import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
28270
28198
|
var FIELD_ORDER = [
|
|
28271
28199
|
"spaceId",
|
|
@@ -28457,7 +28385,6 @@ async function writeAnalyticsSetting(setting) {
|
|
|
28457
28385
|
}
|
|
28458
28386
|
|
|
28459
28387
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
28460
|
-
init_debug_store();
|
|
28461
28388
|
import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
28462
28389
|
function OptInAnalyticsScreen({ onDone }) {
|
|
28463
28390
|
const [loading, setLoading] = useState30(true);
|
|
@@ -28518,8 +28445,6 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
28518
28445
|
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
28519
28446
|
import { useEffect as useEffect25, useState as useState31 } from "react";
|
|
28520
28447
|
import { Box as Box46, Text as Text48, useInput as useInput13 } from "ink";
|
|
28521
|
-
init_version();
|
|
28522
|
-
init_debug_store();
|
|
28523
28448
|
import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
28524
28449
|
var UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
|
|
28525
28450
|
function UpgradeScreen({ onDone }) {
|
|
@@ -28591,8 +28516,6 @@ function renderBody(upgradeCheck) {
|
|
|
28591
28516
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
28592
28517
|
import { useEffect as useEffect26, useState as useState32 } from "react";
|
|
28593
28518
|
import { Box as Box47, Text as Text49, useInput as useInput14 } from "ink";
|
|
28594
|
-
init_debug_mode_store();
|
|
28595
|
-
init_debug_store();
|
|
28596
28519
|
import { jsx as jsx58, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
28597
28520
|
function DebugModeScreen({ onDone }) {
|
|
28598
28521
|
const [loading, setLoading] = useState32(true);
|
|
@@ -28695,7 +28618,7 @@ function App({ importOptions, inkClear }) {
|
|
|
28695
28618
|
const launch = { projectPath: projectPath2, tokens, filePaths, ...importOptions };
|
|
28696
28619
|
const state = await inspectTokens({
|
|
28697
28620
|
rawTokensPath: tokens,
|
|
28698
|
-
outDir:
|
|
28621
|
+
outDir: join25(resolveUserPath(projectPath2), ".contentful"),
|
|
28699
28622
|
cache: importOptions.cache
|
|
28700
28623
|
});
|
|
28701
28624
|
if (state.kind === "cached") {
|