@contentful/experience-design-system-cli 2.37.1-dev-build-2fb4dadf.0 → 2.37.1-dev-build-36f90a5a.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 +357 -281
- package/dist/index.js +245 -217
- package/dist/package.json +1 -1
- package/dist/src/tui/debug-store.d.ts +6 -1
- package/dist/src/tui/settings/contentful-configuration/config-store.d.ts +1 -0
- package/legacy/package.json +1 -1
- package/package.json +3 -3
package/dist/app.js
CHANGED
|
@@ -8,6 +8,71 @@ 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
|
+
|
|
11
76
|
// packages/experience-design-system-backend-pipeline/dist/src/agents/types/agent-name.js
|
|
12
77
|
var AGENT_NAMES;
|
|
13
78
|
var init_agent_name = __esm({
|
|
@@ -772,7 +837,7 @@ async function runAgent(options) {
|
|
|
772
837
|
promptLen: prompt.length,
|
|
773
838
|
promptHead: prompt.slice(0, 500)
|
|
774
839
|
});
|
|
775
|
-
return new Promise((
|
|
840
|
+
return new Promise((resolve26) => {
|
|
776
841
|
const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
|
|
777
842
|
const child = spawn(binary, args, {
|
|
778
843
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -821,7 +886,7 @@ async function runAgent(options) {
|
|
|
821
886
|
stderrLen: stderr.length,
|
|
822
887
|
stderrTail: stderr.slice(-1e3)
|
|
823
888
|
});
|
|
824
|
-
|
|
889
|
+
resolve26(result);
|
|
825
890
|
});
|
|
826
891
|
});
|
|
827
892
|
}
|
|
@@ -843,7 +908,7 @@ async function checkAgentAuth(agent) {
|
|
|
843
908
|
return "not-found";
|
|
844
909
|
if (agent !== "claude")
|
|
845
910
|
return "ok";
|
|
846
|
-
return new Promise((
|
|
911
|
+
return new Promise((resolve26) => {
|
|
847
912
|
const child = spawn2(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
|
|
848
913
|
let stdout = "";
|
|
849
914
|
let done = false;
|
|
@@ -852,7 +917,7 @@ async function checkAgentAuth(agent) {
|
|
|
852
917
|
return;
|
|
853
918
|
done = true;
|
|
854
919
|
child.kill("SIGTERM");
|
|
855
|
-
|
|
920
|
+
resolve26("unauthenticated");
|
|
856
921
|
}, 5e3);
|
|
857
922
|
child.stdout?.on("data", (chunk) => {
|
|
858
923
|
stdout += chunk.toString();
|
|
@@ -863,14 +928,14 @@ async function checkAgentAuth(agent) {
|
|
|
863
928
|
done = true;
|
|
864
929
|
clearTimeout(timer);
|
|
865
930
|
if (code !== 0) {
|
|
866
|
-
|
|
931
|
+
resolve26("unauthenticated");
|
|
867
932
|
return;
|
|
868
933
|
}
|
|
869
934
|
try {
|
|
870
935
|
const status = JSON.parse(stdout);
|
|
871
|
-
|
|
936
|
+
resolve26(status.loggedIn ? "ok" : "unauthenticated");
|
|
872
937
|
} catch {
|
|
873
|
-
|
|
938
|
+
resolve26("unauthenticated");
|
|
874
939
|
}
|
|
875
940
|
});
|
|
876
941
|
});
|
|
@@ -880,9 +945,9 @@ async function binaryIsOnPath(binary) {
|
|
|
880
945
|
const fs = await import("node:fs/promises");
|
|
881
946
|
return fs.access(binary).then(() => true, () => false);
|
|
882
947
|
}
|
|
883
|
-
return new Promise((
|
|
948
|
+
return new Promise((resolve26) => {
|
|
884
949
|
const child = spawn2(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
|
|
885
|
-
child.on("close", (code) =>
|
|
950
|
+
child.on("close", (code) => resolve26(code === 0));
|
|
886
951
|
});
|
|
887
952
|
}
|
|
888
953
|
var init_check_agent_auth = __esm({
|
|
@@ -2016,6 +2081,233 @@ var init_cache_keys = __esm({
|
|
|
2016
2081
|
}
|
|
2017
2082
|
});
|
|
2018
2083
|
|
|
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
|
+
finishDebugRun: () => finishDebugRun,
|
|
2142
|
+
startDebugRun: () => startDebugRun,
|
|
2143
|
+
startDebugSessionIn: () => startDebugSessionIn
|
|
2144
|
+
});
|
|
2145
|
+
import { mkdir as mkdir8, writeFile as writeFile7 } from "node:fs/promises";
|
|
2146
|
+
import { existsSync as existsSync9, readdirSync as readdirSync3 } from "node:fs";
|
|
2147
|
+
import { join as join20, resolve as resolve23 } from "node:path";
|
|
2148
|
+
function generateRunId() {
|
|
2149
|
+
const now = /* @__PURE__ */ new Date();
|
|
2150
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
2151
|
+
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
2152
|
+
}
|
|
2153
|
+
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
2154
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
2155
|
+
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
2156
|
+
}
|
|
2157
|
+
function slugify(value) {
|
|
2158
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
2159
|
+
}
|
|
2160
|
+
async function readBaseDir() {
|
|
2161
|
+
try {
|
|
2162
|
+
const dir = (await readSettings2())["contentfulBaseDir"];
|
|
2163
|
+
return typeof dir === "string" && dir !== "" ? resolve23(dir) : void 0;
|
|
2164
|
+
} catch {
|
|
2165
|
+
return void 0;
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
function nextSessionId(contentfulDir) {
|
|
2169
|
+
const today = datePrefix();
|
|
2170
|
+
const existing = existsSync9(contentfulDir) ? readdirSync3(contentfulDir) : [];
|
|
2171
|
+
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
2172
|
+
const maxSeq = existing.reduce((max, entry) => {
|
|
2173
|
+
const match2 = seqPattern.exec(entry);
|
|
2174
|
+
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
2175
|
+
}, 0);
|
|
2176
|
+
return `${today}-session-${maxSeq + 1}`;
|
|
2177
|
+
}
|
|
2178
|
+
function startSession(base) {
|
|
2179
|
+
const contentfulDir = join20(base, ".contentful");
|
|
2180
|
+
sessionDir ??= join20(contentfulDir, nextSessionId(contentfulDir));
|
|
2181
|
+
return sessionDir;
|
|
2182
|
+
}
|
|
2183
|
+
function currentDebugSessionDir() {
|
|
2184
|
+
return sessionDir && join20(sessionDir, "debug");
|
|
2185
|
+
}
|
|
2186
|
+
async function startDebugSessionIn(base) {
|
|
2187
|
+
try {
|
|
2188
|
+
if (!await isDebugModeEnabled()) return;
|
|
2189
|
+
await mkdir8(join20(startSession(resolve23(base)), "debug"), { recursive: true });
|
|
2190
|
+
} catch {
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
async function isDebugModeEnabled() {
|
|
2194
|
+
try {
|
|
2195
|
+
return (await readDebugModeSetting()).enabled;
|
|
2196
|
+
} catch {
|
|
2197
|
+
return true;
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
function redact(value) {
|
|
2201
|
+
const clone = { ...value };
|
|
2202
|
+
if ("cma_token" in clone) {
|
|
2203
|
+
const raw = clone.cma_token;
|
|
2204
|
+
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
2205
|
+
}
|
|
2206
|
+
return clone;
|
|
2207
|
+
}
|
|
2208
|
+
function startDebugRun({
|
|
2209
|
+
flow,
|
|
2210
|
+
step,
|
|
2211
|
+
menuOption,
|
|
2212
|
+
inputs
|
|
2213
|
+
}) {
|
|
2214
|
+
const runId = generateRunId();
|
|
2215
|
+
const startedAt = Date.now();
|
|
2216
|
+
const redactedInputs = redact(inputs);
|
|
2217
|
+
isDebugModeEnabled().then((enabled) => {
|
|
2218
|
+
if (!enabled) return;
|
|
2219
|
+
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
2220
|
+
});
|
|
2221
|
+
}
|
|
2222
|
+
async function finishDebugRun({
|
|
2223
|
+
outputs,
|
|
2224
|
+
status,
|
|
2225
|
+
exitMethod
|
|
2226
|
+
}) {
|
|
2227
|
+
const run = pendingRun;
|
|
2228
|
+
if (!run) return;
|
|
2229
|
+
pendingRun = void 0;
|
|
2230
|
+
const durationMs = Date.now() - run.startedAt;
|
|
2231
|
+
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
2232
|
+
const root = currentDebugSessionDir();
|
|
2233
|
+
if (!root) return;
|
|
2234
|
+
const flowSegments = run.flow.split("/");
|
|
2235
|
+
const dir = join20(root, ...flowSegments);
|
|
2236
|
+
await mkdir8(dir, { recursive: true });
|
|
2237
|
+
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
2238
|
+
await writeFile7(join20(dir, filename), content, { mode: 384 });
|
|
2239
|
+
}
|
|
2240
|
+
function nextAttemptFilename(dir, menuOption) {
|
|
2241
|
+
const today = datePrefix();
|
|
2242
|
+
const optionSlug = slugify(menuOption);
|
|
2243
|
+
const existing = existsSync9(dir) ? readdirSync3(dir) : [];
|
|
2244
|
+
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
2245
|
+
const maxAttempt = existing.reduce((max, entry) => {
|
|
2246
|
+
const match2 = attemptPattern.exec(entry);
|
|
2247
|
+
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
2248
|
+
}, 0);
|
|
2249
|
+
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
2250
|
+
}
|
|
2251
|
+
function renderMarkdown(run, finish) {
|
|
2252
|
+
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
2253
|
+
const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
2254
|
+
const flowSlug = run.flow.split("/").join("-");
|
|
2255
|
+
return `# Debug Log
|
|
2256
|
+
|
|
2257
|
+
- Run ID: ${run.runId}
|
|
2258
|
+
- Flow: ${flowSlug}
|
|
2259
|
+
- Step: ${stepLabel2}
|
|
2260
|
+
- Menu option: ${run.menuOption}
|
|
2261
|
+
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
2262
|
+
- CLI version: ${readPackageVersion()}
|
|
2263
|
+
- Platform: ${process.platform} / Node ${process.version}
|
|
2264
|
+
- Duration on screen: ${finish.durationMs}ms
|
|
2265
|
+
- Status: ${finish.status}
|
|
2266
|
+
- Exit method: ${finish.exitMethod}
|
|
2267
|
+
|
|
2268
|
+
## Inputs
|
|
2269
|
+
\`\`\`json
|
|
2270
|
+
${JSON.stringify(run.inputs, null, 2)}
|
|
2271
|
+
\`\`\`
|
|
2272
|
+
|
|
2273
|
+
## Outputs
|
|
2274
|
+
\`\`\`json
|
|
2275
|
+
${JSON.stringify(finish.outputs, null, 2)}
|
|
2276
|
+
\`\`\`
|
|
2277
|
+
`;
|
|
2278
|
+
}
|
|
2279
|
+
function handleCrash() {
|
|
2280
|
+
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
2281
|
+
}
|
|
2282
|
+
var pendingRun, sessionDir;
|
|
2283
|
+
var init_debug_store = __esm({
|
|
2284
|
+
"packages/experience-design-system-cli/src/tui/debug-store.ts"() {
|
|
2285
|
+
"use strict";
|
|
2286
|
+
init_config();
|
|
2287
|
+
init_version();
|
|
2288
|
+
init_debug_mode_store();
|
|
2289
|
+
void Promise.all([isDebugModeEnabled(), readBaseDir()]).then(([enabled, base]) => {
|
|
2290
|
+
if (!enabled || !base) return void 0;
|
|
2291
|
+
return mkdir8(join20(startSession(base), "debug"), { recursive: true });
|
|
2292
|
+
});
|
|
2293
|
+
process.once("uncaughtException", (err) => {
|
|
2294
|
+
void handleCrash().finally(() => {
|
|
2295
|
+
throw err;
|
|
2296
|
+
});
|
|
2297
|
+
});
|
|
2298
|
+
process.once("unhandledRejection", (reason) => {
|
|
2299
|
+
void handleCrash().finally(() => {
|
|
2300
|
+
throw reason;
|
|
2301
|
+
});
|
|
2302
|
+
});
|
|
2303
|
+
process.once("SIGINT", () => {
|
|
2304
|
+
void handleCrash().finally(() => {
|
|
2305
|
+
process.exit(130);
|
|
2306
|
+
});
|
|
2307
|
+
});
|
|
2308
|
+
}
|
|
2309
|
+
});
|
|
2310
|
+
|
|
2019
2311
|
// packages/experience-design-system-cli/app.tsx
|
|
2020
2312
|
import { join as join25 } from "node:path";
|
|
2021
2313
|
import { useEffect as useEffect27, useState as useState33 } from "react";
|
|
@@ -2055,60 +2347,8 @@ function brandBar(width, ramp = BRAND_RAMP) {
|
|
|
2055
2347
|
}
|
|
2056
2348
|
var FOCUS_MARKER = "\u276F";
|
|
2057
2349
|
|
|
2058
|
-
// packages/experience-design-system-cli/src/tui/
|
|
2059
|
-
|
|
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
|
-
}
|
|
2350
|
+
// packages/experience-design-system-cli/src/tui/home/home.tsx
|
|
2351
|
+
init_version();
|
|
2112
2352
|
|
|
2113
2353
|
// packages/experience-design-system-cli/src/tui/use-terminal-width.ts
|
|
2114
2354
|
import { useEffect, useState } from "react";
|
|
@@ -12307,11 +12547,11 @@ import { access as access2, mkdir, readFile as readFile7, writeFile } from "node
|
|
|
12307
12547
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-session-paths.js
|
|
12308
12548
|
import { resolve as resolve15 } from "node:path";
|
|
12309
12549
|
async function getRefineSessionPaths(sessionId, artifactsRoot) {
|
|
12310
|
-
const
|
|
12550
|
+
const sessionDir2 = resolve15(artifactsRoot, sessionId);
|
|
12311
12551
|
return {
|
|
12312
|
-
sessionDir,
|
|
12313
|
-
eventsPath: resolve15(
|
|
12314
|
-
statePath: resolve15(
|
|
12552
|
+
sessionDir: sessionDir2,
|
|
12553
|
+
eventsPath: resolve15(sessionDir2, "events.jsonl"),
|
|
12554
|
+
statePath: resolve15(sessionDir2, "current-review-state.json")
|
|
12315
12555
|
};
|
|
12316
12556
|
}
|
|
12317
12557
|
|
|
@@ -13510,7 +13750,7 @@ function errorMessage(error) {
|
|
|
13510
13750
|
return error instanceof Error && error.message ? error.message : String(error);
|
|
13511
13751
|
}
|
|
13512
13752
|
function defaultSleep(delayMs) {
|
|
13513
|
-
return new Promise((
|
|
13753
|
+
return new Promise((resolve26) => setTimeout(resolve26, delayMs));
|
|
13514
13754
|
}
|
|
13515
13755
|
|
|
13516
13756
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/sanitize-preview.js
|
|
@@ -13751,7 +13991,7 @@ var ApiClient = class {
|
|
|
13751
13991
|
const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
|
|
13752
13992
|
const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
|
|
13753
13993
|
const jitter = Math.random() * baseDelay * 0.15;
|
|
13754
|
-
await new Promise((
|
|
13994
|
+
await new Promise((resolve26) => setTimeout(resolve26, baseDelay + jitter));
|
|
13755
13995
|
}
|
|
13756
13996
|
}
|
|
13757
13997
|
throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
|
|
@@ -15864,7 +16104,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
|
|
|
15864
16104
|
const message = error instanceof Error ? error.message : String(error);
|
|
15865
16105
|
if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
|
|
15866
16106
|
throw error;
|
|
15867
|
-
await new Promise((
|
|
16107
|
+
await new Promise((resolve26) => setTimeout(resolve26, Math.min(250 * attempt, 2e3)));
|
|
15868
16108
|
}
|
|
15869
16109
|
}
|
|
15870
16110
|
}
|
|
@@ -16691,6 +16931,7 @@ function useCredentialsControls(handlers) {
|
|
|
16691
16931
|
}
|
|
16692
16932
|
|
|
16693
16933
|
// packages/experience-design-system-cli/src/tui/user-agent.ts
|
|
16934
|
+
init_version();
|
|
16694
16935
|
function cliUserAgent() {
|
|
16695
16936
|
return buildUserAgent(readPackageVersion());
|
|
16696
16937
|
}
|
|
@@ -17190,34 +17431,8 @@ function ExtractionScreen({
|
|
|
17190
17431
|
);
|
|
17191
17432
|
}
|
|
17192
17433
|
|
|
17193
|
-
// packages/experience-design-system-
|
|
17194
|
-
|
|
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
|
-
}
|
|
17434
|
+
// packages/experience-design-system-cli/app.tsx
|
|
17435
|
+
init_config();
|
|
17221
17436
|
|
|
17222
17437
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
|
|
17223
17438
|
import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
|
|
@@ -17493,6 +17708,7 @@ function useExtraction(input) {
|
|
|
17493
17708
|
reuseTokens: input.tokenStrategy === "reuse"
|
|
17494
17709
|
})
|
|
17495
17710
|
});
|
|
17711
|
+
void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then((store) => store.startDebugSessionIn(input.projectPath));
|
|
17496
17712
|
void runExtraction(input, (progress) => {
|
|
17497
17713
|
if (current.current === input) setState({ status: "running", progress });
|
|
17498
17714
|
}).then((result) => {
|
|
@@ -20379,7 +20595,7 @@ function GenerationScreen({
|
|
|
20379
20595
|
import { useEffect as useEffect9, useRef as useRef6, useState as useState14 } from "react";
|
|
20380
20596
|
|
|
20381
20597
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
|
|
20382
|
-
import { resolve as
|
|
20598
|
+
import { resolve as resolve24 } from "node:path";
|
|
20383
20599
|
|
|
20384
20600
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/map-tokens.ts
|
|
20385
20601
|
async function prepareMapTokens(input, generatedSessionId) {
|
|
@@ -20514,7 +20730,7 @@ async function buildMapTokensOptions(input) {
|
|
|
20514
20730
|
if (mapOverride?.kind === "text") prompt.skillContentOverride = mapOverride.value;
|
|
20515
20731
|
if (mapOverride?.kind === "path") {
|
|
20516
20732
|
await resolvePromptOverride(mapOverride);
|
|
20517
|
-
prompt.skillPathOverride =
|
|
20733
|
+
prompt.skillPathOverride = resolve24(mapOverride.value);
|
|
20518
20734
|
}
|
|
20519
20735
|
if (input.existingEntitiesPath) {
|
|
20520
20736
|
const entities = await readExistingContentfulEntitiesFromSession({ path: input.existingEntitiesPath });
|
|
@@ -20562,7 +20778,7 @@ function useGeneration(input) {
|
|
|
20562
20778
|
}
|
|
20563
20779
|
|
|
20564
20780
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/build-flow-start.ts
|
|
20565
|
-
import { join as
|
|
20781
|
+
import { join as join21 } from "node:path";
|
|
20566
20782
|
function buildFlowStart(input) {
|
|
20567
20783
|
const { extraction, handoff, saved, generatePromptPath } = input;
|
|
20568
20784
|
const credentials = extraction.credentials ?? {
|
|
@@ -20575,7 +20791,7 @@ function buildFlowStart(input) {
|
|
|
20575
20791
|
handoff,
|
|
20576
20792
|
agent: extraction.agent,
|
|
20577
20793
|
projectPath: extraction.projectPath,
|
|
20578
|
-
outDir: extraction.projectPath ?
|
|
20794
|
+
outDir: extraction.projectPath ? join21(extraction.projectPath, ".contentful") : "",
|
|
20579
20795
|
rawTokensPath: extraction.rawTokensPath,
|
|
20580
20796
|
credentials: {
|
|
20581
20797
|
spaceId: credentials.spaceId,
|
|
@@ -26318,11 +26534,11 @@ function DoneStep({
|
|
|
26318
26534
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/PathPrompt.tsx
|
|
26319
26535
|
import { useState as useState24 } from "react";
|
|
26320
26536
|
import { Box as Box37, Text as Text40 } from "ink";
|
|
26321
|
-
import { readdirSync as
|
|
26322
|
-
import { dirname as dirname15, basename as basename6, join as
|
|
26537
|
+
import { readdirSync as readdirSync4 } from "node:fs";
|
|
26538
|
+
import { dirname as dirname15, basename as basename6, join as join22 } from "node:path";
|
|
26323
26539
|
|
|
26324
26540
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts
|
|
26325
|
-
import { resolve as
|
|
26541
|
+
import { resolve as resolve25 } from "node:path";
|
|
26326
26542
|
import { homedir as homedir4 } from "node:os";
|
|
26327
26543
|
function expandTilde(input) {
|
|
26328
26544
|
if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
|
|
@@ -26336,7 +26552,7 @@ function normalizePath(input) {
|
|
|
26336
26552
|
p = p.slice(1, -1);
|
|
26337
26553
|
}
|
|
26338
26554
|
p = expandTilde(p);
|
|
26339
|
-
return
|
|
26555
|
+
return resolve25(p);
|
|
26340
26556
|
}
|
|
26341
26557
|
|
|
26342
26558
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
|
|
@@ -26359,19 +26575,19 @@ function autocomplete(partial) {
|
|
|
26359
26575
|
const base = basename6(normalized);
|
|
26360
26576
|
let entries;
|
|
26361
26577
|
try {
|
|
26362
|
-
entries =
|
|
26578
|
+
entries = readdirSync4(dir);
|
|
26363
26579
|
} catch {
|
|
26364
26580
|
return null;
|
|
26365
26581
|
}
|
|
26366
26582
|
const matches = entries.filter((e) => e.startsWith(base));
|
|
26367
26583
|
if (matches.length === 0) return null;
|
|
26368
|
-
if (matches.length === 1) return
|
|
26584
|
+
if (matches.length === 1) return join22(dir, matches[0]);
|
|
26369
26585
|
let prefix = matches[0];
|
|
26370
26586
|
for (const m of matches) {
|
|
26371
26587
|
while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
|
|
26372
26588
|
if (!prefix) break;
|
|
26373
26589
|
}
|
|
26374
|
-
return prefix.length > base.length ?
|
|
26590
|
+
return prefix.length > base.length ? join22(dir, prefix) : null;
|
|
26375
26591
|
}
|
|
26376
26592
|
function PathPrompt({
|
|
26377
26593
|
defaultPath,
|
|
@@ -27130,9 +27346,9 @@ import { useEffect as useEffect21, useRef as useRef13, useSyncExternalStore } fr
|
|
|
27130
27346
|
|
|
27131
27347
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
|
|
27132
27348
|
import { appendFileSync, writeFileSync } from "node:fs";
|
|
27133
|
-
import { mkdir as
|
|
27349
|
+
import { mkdir as mkdir9 } from "node:fs/promises";
|
|
27134
27350
|
import { tmpdir } from "node:os";
|
|
27135
|
-
import { join as
|
|
27351
|
+
import { join as join24 } from "node:path";
|
|
27136
27352
|
|
|
27137
27353
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/wizard-state-transitions.ts
|
|
27138
27354
|
function shouldBypassPreview(state) {
|
|
@@ -27476,8 +27692,8 @@ function pushFailure(e, deps) {
|
|
|
27476
27692
|
}
|
|
27477
27693
|
|
|
27478
27694
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts
|
|
27479
|
-
import { writeFile as
|
|
27480
|
-
import { join as
|
|
27695
|
+
import { writeFile as writeFile8 } from "node:fs/promises";
|
|
27696
|
+
import { join as join23 } from "node:path";
|
|
27481
27697
|
|
|
27482
27698
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/run-print-files-helpers.ts
|
|
27483
27699
|
function nextStateAfterPrint(opts) {
|
|
@@ -27500,15 +27716,15 @@ function buildSavedCDF(components, tokens, opts = {}) {
|
|
|
27500
27716
|
var realSaveDeps = () => ({
|
|
27501
27717
|
openDb: openPipelineDb,
|
|
27502
27718
|
readTokens: (path5) => readTokensFromPath2({ flag: "tokens", path: path5 }),
|
|
27503
|
-
writeFile: (path5, contents) =>
|
|
27719
|
+
writeFile: (path5, contents) => writeFile8(path5, contents),
|
|
27504
27720
|
appendRun,
|
|
27505
27721
|
buildSourceFingerprint,
|
|
27506
|
-
sleep: (ms) => new Promise((
|
|
27722
|
+
sleep: (ms) => new Promise((resolve26) => setTimeout(resolve26, ms)),
|
|
27507
27723
|
warn: (message) => process.stderr.write(message)
|
|
27508
27724
|
});
|
|
27509
27725
|
async function runPrintFiles(input, deps, onPatch) {
|
|
27510
27726
|
onPatch({ step: "printing" });
|
|
27511
|
-
const componentsPath =
|
|
27727
|
+
const componentsPath = join23(input.outDir, "components.json");
|
|
27512
27728
|
try {
|
|
27513
27729
|
const db = deps.openDb();
|
|
27514
27730
|
let components = [];
|
|
@@ -27589,7 +27805,7 @@ var EMPTY_PUSH_RESULT = {
|
|
|
27589
27805
|
};
|
|
27590
27806
|
|
|
27591
27807
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
|
|
27592
|
-
var WIZARD_LOG =
|
|
27808
|
+
var WIZARD_LOG = join24(tmpdir(), "experiences-import-wizard.log");
|
|
27593
27809
|
function appendWizardLog(entry) {
|
|
27594
27810
|
appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
|
|
27595
27811
|
}
|
|
@@ -27612,7 +27828,7 @@ function realFlowDeps() {
|
|
|
27612
27828
|
}
|
|
27613
27829
|
},
|
|
27614
27830
|
mkdir: async (path5) => {
|
|
27615
|
-
await
|
|
27831
|
+
await mkdir9(path5, { recursive: true });
|
|
27616
27832
|
},
|
|
27617
27833
|
detectSaveConflict,
|
|
27618
27834
|
buildTimestampedSubdir,
|
|
@@ -27876,171 +28092,19 @@ function useFlow(start, deps = realFlowDeps) {
|
|
|
27876
28092
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
27877
28093
|
import { useEffect as useEffect22, useState as useState27 } from "react";
|
|
27878
28094
|
import { Box as Box42, Text as Text44, useInput as useInput9 } from "ink";
|
|
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
|
-
});
|
|
28095
|
+
init_debug_store();
|
|
28035
28096
|
|
|
28036
28097
|
// packages/experience-design-system-cli/src/tui/help/help-info.ts
|
|
28098
|
+
init_config();
|
|
28099
|
+
init_debug_store();
|
|
28100
|
+
init_debug_mode_store();
|
|
28101
|
+
init_version();
|
|
28037
28102
|
async function readHelpInfo() {
|
|
28038
28103
|
const debugMode = await readDebugModeSetting();
|
|
28039
28104
|
return {
|
|
28040
28105
|
storage: [
|
|
28041
28106
|
{ label: "Config folder", value: configRoot2() },
|
|
28042
|
-
{ label: "Settings file", value: configFilePath2() }
|
|
28043
|
-
{ label: "Debug logs", value: debugSessionsDir2() }
|
|
28107
|
+
{ label: "Settings file", value: configFilePath2() }
|
|
28044
28108
|
],
|
|
28045
28109
|
troubleshooting: [
|
|
28046
28110
|
{ label: "CLI version", value: readPackageVersion() },
|
|
@@ -28049,7 +28113,7 @@ async function readHelpInfo() {
|
|
|
28049
28113
|
{ label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
|
|
28050
28114
|
{
|
|
28051
28115
|
label: "This session",
|
|
28052
|
-
value: debugMode.enabled ?
|
|
28116
|
+
value: !debugMode.enabled ? "no logs written while Debug Mode is off" : currentDebugSessionDir() ?? "not started: set the default project directory in Settings, or start an import"
|
|
28053
28117
|
}
|
|
28054
28118
|
]
|
|
28055
28119
|
};
|
|
@@ -28166,6 +28230,7 @@ import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
|
|
|
28166
28230
|
import TextInput4 from "ink-text-input";
|
|
28167
28231
|
|
|
28168
28232
|
// packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
|
|
28233
|
+
init_config();
|
|
28169
28234
|
var readV1Store = readSettings2;
|
|
28170
28235
|
var writeV1Store = writeSettings2;
|
|
28171
28236
|
|
|
@@ -28178,7 +28243,8 @@ async function readCredentials() {
|
|
|
28178
28243
|
cmaToken: store.cmaToken || "",
|
|
28179
28244
|
host: store.host || "",
|
|
28180
28245
|
defaultComponentDir: store.defaultComponentDir || "",
|
|
28181
|
-
defaultTokenFile: store.defaultTokenFile || ""
|
|
28246
|
+
defaultTokenFile: store.defaultTokenFile || "",
|
|
28247
|
+
contentfulBaseDir: store.contentfulBaseDir || ""
|
|
28182
28248
|
};
|
|
28183
28249
|
}
|
|
28184
28250
|
async function writeCredentials(config) {
|
|
@@ -28194,6 +28260,7 @@ async function writeCredentials(config) {
|
|
|
28194
28260
|
}
|
|
28195
28261
|
|
|
28196
28262
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
28263
|
+
init_debug_store();
|
|
28197
28264
|
import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
28198
28265
|
var FIELD_ORDER = [
|
|
28199
28266
|
"spaceId",
|
|
@@ -28201,7 +28268,8 @@ var FIELD_ORDER = [
|
|
|
28201
28268
|
"cmaToken",
|
|
28202
28269
|
"host",
|
|
28203
28270
|
"defaultComponentDir",
|
|
28204
|
-
"defaultTokenFile"
|
|
28271
|
+
"defaultTokenFile",
|
|
28272
|
+
"contentfulBaseDir"
|
|
28205
28273
|
];
|
|
28206
28274
|
function debugFields(config) {
|
|
28207
28275
|
return {
|
|
@@ -28210,7 +28278,8 @@ function debugFields(config) {
|
|
|
28210
28278
|
cma_token: config?.cmaToken ?? "",
|
|
28211
28279
|
host: config?.host ?? "",
|
|
28212
28280
|
default_component_dir: config?.defaultComponentDir ?? "",
|
|
28213
|
-
default_token_file: config?.defaultTokenFile ?? ""
|
|
28281
|
+
default_token_file: config?.defaultTokenFile ?? "",
|
|
28282
|
+
contentful_base_dir: config?.contentfulBaseDir ?? ""
|
|
28214
28283
|
};
|
|
28215
28284
|
}
|
|
28216
28285
|
var FIELD_LABELS = {
|
|
@@ -28219,7 +28288,8 @@ var FIELD_LABELS = {
|
|
|
28219
28288
|
cmaToken: "CMA Token",
|
|
28220
28289
|
host: "API Host (optional)",
|
|
28221
28290
|
defaultComponentDir: "Default component directory (optional)",
|
|
28222
|
-
defaultTokenFile: "Default token file (optional)"
|
|
28291
|
+
defaultTokenFile: "Default token file (optional)",
|
|
28292
|
+
contentfulBaseDir: "Default project directory, where .contentful goes (optional)"
|
|
28223
28293
|
};
|
|
28224
28294
|
function ConfigurationScreen({ onDone }) {
|
|
28225
28295
|
const [stage, setStage] = useState29("loading");
|
|
@@ -28256,6 +28326,7 @@ function ConfigurationScreen({ onDone }) {
|
|
|
28256
28326
|
setNotice(null);
|
|
28257
28327
|
writeCredentials(config).then(() => {
|
|
28258
28328
|
setLastSaved(config);
|
|
28329
|
+
if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir);
|
|
28259
28330
|
setNotice({ kind: "success", text: "Configuration saved" });
|
|
28260
28331
|
setStage("form");
|
|
28261
28332
|
}).catch((err) => {
|
|
@@ -28385,6 +28456,7 @@ async function writeAnalyticsSetting(setting) {
|
|
|
28385
28456
|
}
|
|
28386
28457
|
|
|
28387
28458
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
28459
|
+
init_debug_store();
|
|
28388
28460
|
import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
28389
28461
|
function OptInAnalyticsScreen({ onDone }) {
|
|
28390
28462
|
const [loading, setLoading] = useState30(true);
|
|
@@ -28445,6 +28517,8 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
28445
28517
|
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
28446
28518
|
import { useEffect as useEffect25, useState as useState31 } from "react";
|
|
28447
28519
|
import { Box as Box46, Text as Text48, useInput as useInput13 } from "ink";
|
|
28520
|
+
init_version();
|
|
28521
|
+
init_debug_store();
|
|
28448
28522
|
import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
28449
28523
|
var UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
|
|
28450
28524
|
function UpgradeScreen({ onDone }) {
|
|
@@ -28516,6 +28590,8 @@ function renderBody(upgradeCheck) {
|
|
|
28516
28590
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
28517
28591
|
import { useEffect as useEffect26, useState as useState32 } from "react";
|
|
28518
28592
|
import { Box as Box47, Text as Text49, useInput as useInput14 } from "ink";
|
|
28593
|
+
init_debug_mode_store();
|
|
28594
|
+
init_debug_store();
|
|
28519
28595
|
import { jsx as jsx58, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
28520
28596
|
function DebugModeScreen({ onDone }) {
|
|
28521
28597
|
const [loading, setLoading] = useState32(true);
|