@contentful/experience-design-system-cli 2.37.1-dev-build-5bd13138.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 +302 -414
- package/dist/index.js +238 -310
- package/dist/package.json +1 -1
- package/dist/src/tui/debug-store.d.ts +0 -6
- package/dist/src/tui/import/steps/06-extraction/run.d.ts +0 -3
- package/dist/src/tui/import/steps/10-flow/flow/controller.d.ts +0 -3
- package/legacy/package.json +1 -1
- package/package.json +3 -3
- package/dist/src/tui/import/debug-hooks.d.ts +0 -17
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,239 +2016,6 @@ var init_cache_keys = __esm({
|
|
|
2081
2016
|
}
|
|
2082
2017
|
});
|
|
2083
2018
|
|
|
2084
|
-
// packages/experience-design-system-types/dist/src/config/index.js
|
|
2085
|
-
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
2086
|
-
import { mkdir as mkdir6, readFile as readFile18, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
|
|
2087
|
-
import { homedir as homedir3 } from "node:os";
|
|
2088
|
-
import { dirname as dirname13, join as join17 } from "node:path";
|
|
2089
|
-
function configRoot2() {
|
|
2090
|
-
return process.env["EDS_HOME"] || join17(homedir3(), ".contentful", "experience-design-system-cli");
|
|
2091
|
-
}
|
|
2092
|
-
async function readSettings2() {
|
|
2093
|
-
try {
|
|
2094
|
-
return JSON.parse(await readFile18(configFilePath2(), "utf8"));
|
|
2095
|
-
} catch {
|
|
2096
|
-
return {};
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
async function writeSettings2(settings) {
|
|
2100
|
-
const path5 = configFilePath2();
|
|
2101
|
-
await mkdir6(dirname13(path5), { recursive: true });
|
|
2102
|
-
const tmp = `${path5}.${process.pid}.${randomBytes3(4).toString("hex")}.tmp`;
|
|
2103
|
-
await writeFile6(tmp, `${JSON.stringify(settings, null, 2)}
|
|
2104
|
-
`, { mode: 384 });
|
|
2105
|
-
await rename2(tmp, path5);
|
|
2106
|
-
}
|
|
2107
|
-
async function updateSettings2(patch) {
|
|
2108
|
-
await writeSettings2({ ...await readSettings2(), ...patch });
|
|
2109
|
-
}
|
|
2110
|
-
var configFilePath2, 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 mkdir7, rename as rename3, rm, writeFile as writeFile7 } from "node:fs/promises";
|
|
2147
|
-
import { existsSync as existsSync8, readdirSync as readdirSync3 } from "node:fs";
|
|
2148
|
-
import { join as join18, resolve as resolve20 } 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 = existsSync8(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 join18(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 = join18(resolve20(outDir), "debug", "sessions");
|
|
2181
|
-
const from = sessionDebugDir();
|
|
2182
|
-
const to = join18(nextRoot, SESSION_ID);
|
|
2183
|
-
if (from === to) return;
|
|
2184
|
-
try {
|
|
2185
|
-
await mkdir7(nextRoot, { recursive: true });
|
|
2186
|
-
if (existsSync8(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 mkdir7(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 = join18(sessionDebugDir(), ...flowSegments);
|
|
2241
|
-
await mkdir7(dir, { recursive: true });
|
|
2242
|
-
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
2243
|
-
await writeFile7(join18(dir, filename), content, { mode: 384 });
|
|
2244
|
-
}
|
|
2245
|
-
function nextAttemptFilename(dir, menuOption) {
|
|
2246
|
-
const today = datePrefix();
|
|
2247
|
-
const optionSlug = slugify(menuOption);
|
|
2248
|
-
const existing = existsSync8(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 mkdir7(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
2020
|
import { join as join25 } from "node:path";
|
|
2319
2021
|
import { useEffect as useEffect27, useState as useState33 } from "react";
|
|
@@ -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
|
}
|
|
@@ -5133,7 +4887,7 @@ function getTsxExtractionContext(filePaths, componentFilePattern) {
|
|
|
5133
4887
|
project: createTsxProject(getTsxProjectFiles(filePaths))
|
|
5134
4888
|
};
|
|
5135
4889
|
}
|
|
5136
|
-
function extractTsxComponents(filePaths, componentFilePattern,
|
|
4890
|
+
function extractTsxComponents(filePaths, componentFilePattern, extract) {
|
|
5137
4891
|
const extractionContext = getTsxExtractionContext(filePaths, componentFilePattern);
|
|
5138
4892
|
if (!extractionContext) {
|
|
5139
4893
|
return { components: [], warnings: [], exclusions: [] };
|
|
@@ -5147,7 +4901,7 @@ function extractTsxComponents(filePaths, componentFilePattern, extract2) {
|
|
|
5147
4901
|
const sourceFile = project.getSourceFile(filePath);
|
|
5148
4902
|
if (!sourceFile)
|
|
5149
4903
|
continue;
|
|
5150
|
-
components.push(...
|
|
4904
|
+
components.push(...extract(sourceFile, exclusions));
|
|
5151
4905
|
} catch (e) {
|
|
5152
4906
|
warnings.push(`Failed to extract from ${filePath}: ${e instanceof Error ? e.message : String(e)}`);
|
|
5153
4907
|
}
|
|
@@ -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,34 +17190,53 @@ 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
17223
|
import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
|
|
17441
17224
|
|
|
17442
17225
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts
|
|
17443
|
-
import { mkdir as
|
|
17444
|
-
import { join as
|
|
17445
|
-
|
|
17446
|
-
// packages/experience-design-system-cli/src/tui/import/debug-hooks.ts
|
|
17447
|
-
var realDebugHooks = {
|
|
17448
|
-
setOutDir: async (outDir) => (await Promise.resolve().then(() => (init_debug_store(), debug_store_exports))).setDebugOutDir(outDir),
|
|
17449
|
-
start: (run) => void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then((m) => m.startDebugRun(run)),
|
|
17450
|
-
finish: async (run) => (await Promise.resolve().then(() => (init_debug_store(), debug_store_exports))).finishDebugRun(run)
|
|
17451
|
-
};
|
|
17226
|
+
import { mkdir as mkdir7 } from "node:fs/promises";
|
|
17227
|
+
import { join as join19, resolve as resolve22 } from "node:path";
|
|
17452
17228
|
|
|
17453
17229
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/find-skill-path.ts
|
|
17454
|
-
import { existsSync as
|
|
17455
|
-
import { dirname as dirname14, join as
|
|
17230
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
17231
|
+
import { dirname as dirname14, join as join18, resolve as resolve20 } from "node:path";
|
|
17456
17232
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
17457
17233
|
function findSkillPath(fileName) {
|
|
17458
17234
|
const thisDir = dirname14(fileURLToPath4(import.meta.url));
|
|
17459
17235
|
let dir = thisDir;
|
|
17460
17236
|
for (; ; ) {
|
|
17461
|
-
const candidate =
|
|
17462
|
-
if (
|
|
17463
|
-
const parent =
|
|
17237
|
+
const candidate = join18(dir, "skills", fileName);
|
|
17238
|
+
if (existsSync8(candidate)) return candidate;
|
|
17239
|
+
const parent = resolve20(dir, "..");
|
|
17464
17240
|
if (parent === dir) {
|
|
17465
17241
|
throw new Error(`skill file not found (looked for skills/${fileName} from ${thisDir})`);
|
|
17466
17242
|
}
|
|
@@ -17469,11 +17245,11 @@ function findSkillPath(fileName) {
|
|
|
17469
17245
|
}
|
|
17470
17246
|
|
|
17471
17247
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/selection.ts
|
|
17472
|
-
import { resolve as
|
|
17248
|
+
import { resolve as resolve21 } from "node:path";
|
|
17473
17249
|
var SELECT_SKILL_PATH = findSkillPath("select-components.md");
|
|
17474
17250
|
var DEFAULT_TIMEOUT_MS5 = Number(process.env.EDS_AGENT_TIMEOUT_MS ?? 5 * 60 * 1e3);
|
|
17475
17251
|
async function hashSelectPrompt(options) {
|
|
17476
|
-
const promptHash = options.promptText ? hashContent(options.promptText) : options.promptPath ? await hashFile(
|
|
17252
|
+
const promptHash = options.promptText ? hashContent(options.promptText) : options.promptPath ? await hashFile(resolve21(options.promptPath)) : await hashFile(SELECT_SKILL_PATH);
|
|
17477
17253
|
return hashContent(`${promptHash}|${options.agent}|${options.model ?? ""}`);
|
|
17478
17254
|
}
|
|
17479
17255
|
async function runSelection(options) {
|
|
@@ -17563,32 +17339,12 @@ var realDeps = {
|
|
|
17563
17339
|
fetchEntities,
|
|
17564
17340
|
runExtractAndComposeSession,
|
|
17565
17341
|
runGenerateTokensSession,
|
|
17566
|
-
runSelection
|
|
17567
|
-
debug: realDebugHooks
|
|
17342
|
+
runSelection
|
|
17568
17343
|
};
|
|
17569
17344
|
var fail = (step, message) => ({ ok: false, step, message });
|
|
17570
17345
|
var errorMessage2 = (error) => error instanceof Error ? error.message : String(error);
|
|
17571
17346
|
async function runExtraction(input, onProgress, deps = realDeps) {
|
|
17572
|
-
const outDir =
|
|
17573
|
-
await deps.debug?.setOutDir(outDir);
|
|
17574
|
-
deps.debug?.start({
|
|
17575
|
-
flow: "import",
|
|
17576
|
-
step: "06-extraction",
|
|
17577
|
-
menuOption: "Import",
|
|
17578
|
-
inputs: {
|
|
17579
|
-
projectPath: input.projectPath,
|
|
17580
|
-
agent: input.agent,
|
|
17581
|
-
files: input.filePaths.length,
|
|
17582
|
-
noCache: input.noCache
|
|
17583
|
-
}
|
|
17584
|
-
});
|
|
17585
|
-
const result = await extract(input, outDir, onProgress, deps);
|
|
17586
|
-
await deps.debug?.finish(
|
|
17587
|
-
result.ok ? { outputs: { sessionId: result.extraction.sessionId, outDir }, status: "success", exitMethod: "saved" } : { outputs: { step: result.step, message: result.message }, status: "error", exitMethod: "discarded" }
|
|
17588
|
-
);
|
|
17589
|
-
return result;
|
|
17590
|
-
}
|
|
17591
|
-
async function extract(input, outDir, onProgress, deps) {
|
|
17347
|
+
const outDir = join19(resolve22(input.projectPath), ".contentful");
|
|
17592
17348
|
let progress = initialProgress({
|
|
17593
17349
|
hasCredentials: input.credentials !== null,
|
|
17594
17350
|
hasRawTokens: input.rawTokensPath !== "",
|
|
@@ -17683,7 +17439,7 @@ async function extract(input, outDir, onProgress, deps) {
|
|
|
17683
17439
|
const extraction = {
|
|
17684
17440
|
sessionId: extracted.sessionId,
|
|
17685
17441
|
outDir,
|
|
17686
|
-
tokensPath: tokens?.ok ? tokens.tokensPath : hasTokenSource ?
|
|
17442
|
+
tokensPath: tokens?.ok ? tokens.tokensPath : hasTokenSource ? join19(outDir, "tokens.json") : "",
|
|
17687
17443
|
tokenSessionId: tokens?.ok ? tokens.tokenSessionId : null,
|
|
17688
17444
|
tokenCount: tokens?.ok ? tokens.tokenCount : 0,
|
|
17689
17445
|
existingEntitiesPath,
|
|
@@ -17694,7 +17450,7 @@ async function extract(input, outDir, onProgress, deps) {
|
|
|
17694
17450
|
}
|
|
17695
17451
|
async function fetchEntities(credentials, outDir) {
|
|
17696
17452
|
try {
|
|
17697
|
-
await
|
|
17453
|
+
await mkdir7(outDir, { recursive: true });
|
|
17698
17454
|
const result = await fetchAndPersistExistingContentfulEntities({
|
|
17699
17455
|
spaceId: credentials.spaceId,
|
|
17700
17456
|
environmentId: credentials.environmentId,
|
|
@@ -17714,7 +17470,7 @@ async function resolveSelectionPrompt(overrides) {
|
|
|
17714
17470
|
if (select?.kind === "text") return { promptText: select.value };
|
|
17715
17471
|
if (select?.kind === "path") {
|
|
17716
17472
|
await resolvePromptOverride(select);
|
|
17717
|
-
return { promptPath:
|
|
17473
|
+
return { promptPath: resolve22(select.value) };
|
|
17718
17474
|
}
|
|
17719
17475
|
return {};
|
|
17720
17476
|
}
|
|
@@ -20623,7 +20379,7 @@ function GenerationScreen({
|
|
|
20623
20379
|
import { useEffect as useEffect9, useRef as useRef6, useState as useState14 } from "react";
|
|
20624
20380
|
|
|
20625
20381
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
|
|
20626
|
-
import { resolve as
|
|
20382
|
+
import { resolve as resolve23 } from "node:path";
|
|
20627
20383
|
|
|
20628
20384
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/map-tokens.ts
|
|
20629
20385
|
async function prepareMapTokens(input, generatedSessionId) {
|
|
@@ -20758,7 +20514,7 @@ async function buildMapTokensOptions(input) {
|
|
|
20758
20514
|
if (mapOverride?.kind === "text") prompt.skillContentOverride = mapOverride.value;
|
|
20759
20515
|
if (mapOverride?.kind === "path") {
|
|
20760
20516
|
await resolvePromptOverride(mapOverride);
|
|
20761
|
-
prompt.skillPathOverride =
|
|
20517
|
+
prompt.skillPathOverride = resolve23(mapOverride.value);
|
|
20762
20518
|
}
|
|
20763
20519
|
if (input.existingEntitiesPath) {
|
|
20764
20520
|
const entities = await readExistingContentfulEntitiesFromSession({ path: input.existingEntitiesPath });
|
|
@@ -20806,7 +20562,7 @@ function useGeneration(input) {
|
|
|
20806
20562
|
}
|
|
20807
20563
|
|
|
20808
20564
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/build-flow-start.ts
|
|
20809
|
-
import { join as
|
|
20565
|
+
import { join as join20 } from "node:path";
|
|
20810
20566
|
function buildFlowStart(input) {
|
|
20811
20567
|
const { extraction, handoff, saved, generatePromptPath } = input;
|
|
20812
20568
|
const credentials = extraction.credentials ?? {
|
|
@@ -20819,7 +20575,7 @@ function buildFlowStart(input) {
|
|
|
20819
20575
|
handoff,
|
|
20820
20576
|
agent: extraction.agent,
|
|
20821
20577
|
projectPath: extraction.projectPath,
|
|
20822
|
-
outDir: extraction.projectPath ?
|
|
20578
|
+
outDir: extraction.projectPath ? join20(extraction.projectPath, ".contentful") : "",
|
|
20823
20579
|
rawTokensPath: extraction.rawTokensPath,
|
|
20824
20580
|
credentials: {
|
|
20825
20581
|
spaceId: credentials.spaceId,
|
|
@@ -26562,11 +26318,11 @@ function DoneStep({
|
|
|
26562
26318
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/PathPrompt.tsx
|
|
26563
26319
|
import { useState as useState24 } from "react";
|
|
26564
26320
|
import { Box as Box37, Text as Text40 } from "ink";
|
|
26565
|
-
import { readdirSync as
|
|
26566
|
-
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";
|
|
26567
26323
|
|
|
26568
26324
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts
|
|
26569
|
-
import { resolve as
|
|
26325
|
+
import { resolve as resolve24 } from "node:path";
|
|
26570
26326
|
import { homedir as homedir4 } from "node:os";
|
|
26571
26327
|
function expandTilde(input) {
|
|
26572
26328
|
if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
|
|
@@ -26580,7 +26336,7 @@ function normalizePath(input) {
|
|
|
26580
26336
|
p = p.slice(1, -1);
|
|
26581
26337
|
}
|
|
26582
26338
|
p = expandTilde(p);
|
|
26583
|
-
return
|
|
26339
|
+
return resolve24(p);
|
|
26584
26340
|
}
|
|
26585
26341
|
|
|
26586
26342
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
|
|
@@ -26603,19 +26359,19 @@ function autocomplete(partial) {
|
|
|
26603
26359
|
const base = basename6(normalized);
|
|
26604
26360
|
let entries;
|
|
26605
26361
|
try {
|
|
26606
|
-
entries =
|
|
26362
|
+
entries = readdirSync3(dir);
|
|
26607
26363
|
} catch {
|
|
26608
26364
|
return null;
|
|
26609
26365
|
}
|
|
26610
26366
|
const matches = entries.filter((e) => e.startsWith(base));
|
|
26611
26367
|
if (matches.length === 0) return null;
|
|
26612
|
-
if (matches.length === 1) return
|
|
26368
|
+
if (matches.length === 1) return join21(dir, matches[0]);
|
|
26613
26369
|
let prefix = matches[0];
|
|
26614
26370
|
for (const m of matches) {
|
|
26615
26371
|
while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
|
|
26616
26372
|
if (!prefix) break;
|
|
26617
26373
|
}
|
|
26618
|
-
return prefix.length > base.length ?
|
|
26374
|
+
return prefix.length > base.length ? join21(dir, prefix) : null;
|
|
26619
26375
|
}
|
|
26620
26376
|
function PathPrompt({
|
|
26621
26377
|
defaultPath,
|
|
@@ -27374,9 +27130,9 @@ import { useEffect as useEffect21, useRef as useRef13, useSyncExternalStore } fr
|
|
|
27374
27130
|
|
|
27375
27131
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
|
|
27376
27132
|
import { appendFileSync, writeFileSync } from "node:fs";
|
|
27377
|
-
import { mkdir as
|
|
27133
|
+
import { mkdir as mkdir8 } from "node:fs/promises";
|
|
27378
27134
|
import { tmpdir } from "node:os";
|
|
27379
|
-
import { join as
|
|
27135
|
+
import { join as join23 } from "node:path";
|
|
27380
27136
|
|
|
27381
27137
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/wizard-state-transitions.ts
|
|
27382
27138
|
function shouldBypassPreview(state) {
|
|
@@ -27720,8 +27476,8 @@ function pushFailure(e, deps) {
|
|
|
27720
27476
|
}
|
|
27721
27477
|
|
|
27722
27478
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts
|
|
27723
|
-
import { writeFile as
|
|
27724
|
-
import { join as
|
|
27479
|
+
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
27480
|
+
import { join as join22 } from "node:path";
|
|
27725
27481
|
|
|
27726
27482
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/run-print-files-helpers.ts
|
|
27727
27483
|
function nextStateAfterPrint(opts) {
|
|
@@ -27744,15 +27500,15 @@ function buildSavedCDF(components, tokens, opts = {}) {
|
|
|
27744
27500
|
var realSaveDeps = () => ({
|
|
27745
27501
|
openDb: openPipelineDb,
|
|
27746
27502
|
readTokens: (path5) => readTokensFromPath2({ flag: "tokens", path: path5 }),
|
|
27747
|
-
writeFile: (path5, contents) =>
|
|
27503
|
+
writeFile: (path5, contents) => writeFile7(path5, contents),
|
|
27748
27504
|
appendRun,
|
|
27749
27505
|
buildSourceFingerprint,
|
|
27750
|
-
sleep: (ms) => new Promise((
|
|
27506
|
+
sleep: (ms) => new Promise((resolve25) => setTimeout(resolve25, ms)),
|
|
27751
27507
|
warn: (message) => process.stderr.write(message)
|
|
27752
27508
|
});
|
|
27753
27509
|
async function runPrintFiles(input, deps, onPatch) {
|
|
27754
27510
|
onPatch({ step: "printing" });
|
|
27755
|
-
const componentsPath =
|
|
27511
|
+
const componentsPath = join22(input.outDir, "components.json");
|
|
27756
27512
|
try {
|
|
27757
27513
|
const db = deps.openDb();
|
|
27758
27514
|
let components = [];
|
|
@@ -27833,7 +27589,7 @@ var EMPTY_PUSH_RESULT = {
|
|
|
27833
27589
|
};
|
|
27834
27590
|
|
|
27835
27591
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
|
|
27836
|
-
var WIZARD_LOG =
|
|
27592
|
+
var WIZARD_LOG = join23(tmpdir(), "experiences-import-wizard.log");
|
|
27837
27593
|
function appendWizardLog(entry) {
|
|
27838
27594
|
appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
|
|
27839
27595
|
}
|
|
@@ -27856,14 +27612,13 @@ function realFlowDeps() {
|
|
|
27856
27612
|
}
|
|
27857
27613
|
},
|
|
27858
27614
|
mkdir: async (path5) => {
|
|
27859
|
-
await
|
|
27615
|
+
await mkdir8(path5, { recursive: true });
|
|
27860
27616
|
},
|
|
27861
27617
|
detectSaveConflict,
|
|
27862
27618
|
buildTimestampedSubdir,
|
|
27863
27619
|
rejectComponentsByName,
|
|
27864
27620
|
log,
|
|
27865
|
-
stderr: (text) => process.stderr.write(text)
|
|
27866
|
-
debug: realDebugHooks
|
|
27621
|
+
stderr: (text) => process.stderr.write(text)
|
|
27867
27622
|
};
|
|
27868
27623
|
}
|
|
27869
27624
|
function initialFlowState(start) {
|
|
@@ -28007,13 +27762,6 @@ function createFlowController(start, deps) {
|
|
|
28007
27762
|
};
|
|
28008
27763
|
const proceedToWrite = async (path5) => {
|
|
28009
27764
|
update({ outDir: path5 });
|
|
28010
|
-
await deps.debug?.setOutDir(path5);
|
|
28011
|
-
deps.debug?.start({
|
|
28012
|
-
flow: "import",
|
|
28013
|
-
step: "10-flow",
|
|
28014
|
-
menuOption: "Save",
|
|
28015
|
-
inputs: { outDir: path5, extractSessionId: state.extractSessionId, andPush: !!pendingSave.andPush }
|
|
28016
|
-
});
|
|
28017
27765
|
const { skipGate, andPush } = pendingSave;
|
|
28018
27766
|
const written = await runPrintFiles(
|
|
28019
27767
|
{
|
|
@@ -28028,9 +27776,6 @@ function createFlowController(start, deps) {
|
|
|
28028
27776
|
update
|
|
28029
27777
|
);
|
|
28030
27778
|
update(written.patch);
|
|
28031
|
-
await deps.debug?.finish(
|
|
28032
|
-
written.ok ? { outputs: { componentsPath: join24(path5, "components.json") }, status: "success", exitMethod: "saved" } : { outputs: { error: written.patch.errorMessage ?? "unknown" }, status: "error", exitMethod: "discarded" }
|
|
28033
|
-
);
|
|
28034
27779
|
if (!written.ok) return;
|
|
28035
27780
|
const runId = await recordRun({ state, savePath: path5 }, deps.save);
|
|
28036
27781
|
if (runId) update({ lastRunId: runId });
|
|
@@ -28131,21 +27876,171 @@ function useFlow(start, deps = realFlowDeps) {
|
|
|
28131
27876
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
28132
27877
|
import { useEffect as useEffect22, useState as useState27 } from "react";
|
|
28133
27878
|
import { Box as Box42, Text as Text44, useInput as useInput9 } from "ink";
|
|
28134
|
-
|
|
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
|
+
});
|
|
28135
28035
|
|
|
28136
28036
|
// packages/experience-design-system-cli/src/tui/help/help-info.ts
|
|
28137
|
-
init_config();
|
|
28138
|
-
init_debug_store();
|
|
28139
|
-
init_debug_mode_store();
|
|
28140
|
-
init_version();
|
|
28141
28037
|
async function readHelpInfo() {
|
|
28142
28038
|
const debugMode = await readDebugModeSetting();
|
|
28143
28039
|
return {
|
|
28144
28040
|
storage: [
|
|
28145
28041
|
{ label: "Config folder", value: configRoot2() },
|
|
28146
28042
|
{ label: "Settings file", value: configFilePath2() },
|
|
28147
|
-
{ label: "Debug logs", value:
|
|
28148
|
-
{ label: "No project", value: `${debugSessionsDir2()} (sessions that never pick a project)` }
|
|
28043
|
+
{ label: "Debug logs", value: debugSessionsDir2() }
|
|
28149
28044
|
],
|
|
28150
28045
|
troubleshooting: [
|
|
28151
28046
|
{ label: "CLI version", value: readPackageVersion() },
|
|
@@ -28271,7 +28166,6 @@ import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
|
|
|
28271
28166
|
import TextInput4 from "ink-text-input";
|
|
28272
28167
|
|
|
28273
28168
|
// packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
|
|
28274
|
-
init_config();
|
|
28275
28169
|
var readV1Store = readSettings2;
|
|
28276
28170
|
var writeV1Store = writeSettings2;
|
|
28277
28171
|
|
|
@@ -28300,7 +28194,6 @@ async function writeCredentials(config) {
|
|
|
28300
28194
|
}
|
|
28301
28195
|
|
|
28302
28196
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
28303
|
-
init_debug_store();
|
|
28304
28197
|
import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
28305
28198
|
var FIELD_ORDER = [
|
|
28306
28199
|
"spaceId",
|
|
@@ -28492,7 +28385,6 @@ async function writeAnalyticsSetting(setting) {
|
|
|
28492
28385
|
}
|
|
28493
28386
|
|
|
28494
28387
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
28495
|
-
init_debug_store();
|
|
28496
28388
|
import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
28497
28389
|
function OptInAnalyticsScreen({ onDone }) {
|
|
28498
28390
|
const [loading, setLoading] = useState30(true);
|
|
@@ -28553,8 +28445,6 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
28553
28445
|
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
28554
28446
|
import { useEffect as useEffect25, useState as useState31 } from "react";
|
|
28555
28447
|
import { Box as Box46, Text as Text48, useInput as useInput13 } from "ink";
|
|
28556
|
-
init_version();
|
|
28557
|
-
init_debug_store();
|
|
28558
28448
|
import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
28559
28449
|
var UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
|
|
28560
28450
|
function UpgradeScreen({ onDone }) {
|
|
@@ -28626,8 +28516,6 @@ function renderBody(upgradeCheck) {
|
|
|
28626
28516
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
28627
28517
|
import { useEffect as useEffect26, useState as useState32 } from "react";
|
|
28628
28518
|
import { Box as Box47, Text as Text49, useInput as useInput14 } from "ink";
|
|
28629
|
-
init_debug_mode_store();
|
|
28630
|
-
init_debug_store();
|
|
28631
28519
|
import { jsx as jsx58, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
28632
28520
|
function DebugModeScreen({ onDone }) {
|
|
28633
28521
|
const [loading, setLoading] = useState32(true);
|