@contentful/experience-design-system-cli 2.37.1-dev-build-97b615d3.0 → 2.37.1-dev-build-5bd13138.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 +442 -326
- package/dist/index.js +338 -262
- package/dist/package.json +1 -1
- package/dist/src/tui/debug-store.d.ts +6 -0
- package/dist/src/tui/import/debug-hooks.d.ts +17 -0
- package/dist/src/tui/import/steps/06-extraction/run.d.ts +3 -0
- package/dist/src/tui/import/steps/07-scope-gate/sidebar/components/CompactControlBar.d.ts +1 -1
- package/dist/src/tui/import/steps/10-flow/flow/controller.d.ts +3 -6
- package/dist/src/tui/import/steps/10-flow/flow/screen.d.ts +3 -1
- package/dist/src/tui/import/steps/10-flow/flow/use-flow.d.ts +1 -4
- package/legacy/bin/cli.js +0 -0
- package/legacy/dist/src/setup/steps/preferences/PreferencesMenu.d.ts +4 -4
- package/legacy/package.json +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2121,7 +2121,7 @@ async function runAgent(options) {
|
|
|
2121
2121
|
promptLen: prompt.length,
|
|
2122
2122
|
promptHead: prompt.slice(0, 500)
|
|
2123
2123
|
});
|
|
2124
|
-
return new Promise((
|
|
2124
|
+
return new Promise((resolve26) => {
|
|
2125
2125
|
const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
|
|
2126
2126
|
const child = spawn3(binary, args, {
|
|
2127
2127
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -2170,7 +2170,7 @@ async function runAgent(options) {
|
|
|
2170
2170
|
stderrLen: stderr.length,
|
|
2171
2171
|
stderrTail: stderr.slice(-1e3)
|
|
2172
2172
|
});
|
|
2173
|
-
|
|
2173
|
+
resolve26(result);
|
|
2174
2174
|
});
|
|
2175
2175
|
});
|
|
2176
2176
|
}
|
|
@@ -2192,7 +2192,7 @@ async function checkAgentAuth(agent) {
|
|
|
2192
2192
|
return "not-found";
|
|
2193
2193
|
if (agent !== "claude")
|
|
2194
2194
|
return "ok";
|
|
2195
|
-
return new Promise((
|
|
2195
|
+
return new Promise((resolve26) => {
|
|
2196
2196
|
const child = spawn4(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
|
|
2197
2197
|
let stdout = "";
|
|
2198
2198
|
let done = false;
|
|
@@ -2201,7 +2201,7 @@ async function checkAgentAuth(agent) {
|
|
|
2201
2201
|
return;
|
|
2202
2202
|
done = true;
|
|
2203
2203
|
child.kill("SIGTERM");
|
|
2204
|
-
|
|
2204
|
+
resolve26("unauthenticated");
|
|
2205
2205
|
}, 5e3);
|
|
2206
2206
|
child.stdout?.on("data", (chunk) => {
|
|
2207
2207
|
stdout += chunk.toString();
|
|
@@ -2212,14 +2212,14 @@ async function checkAgentAuth(agent) {
|
|
|
2212
2212
|
done = true;
|
|
2213
2213
|
clearTimeout(timer);
|
|
2214
2214
|
if (code !== 0) {
|
|
2215
|
-
|
|
2215
|
+
resolve26("unauthenticated");
|
|
2216
2216
|
return;
|
|
2217
2217
|
}
|
|
2218
2218
|
try {
|
|
2219
2219
|
const status = JSON.parse(stdout);
|
|
2220
|
-
|
|
2220
|
+
resolve26(status.loggedIn ? "ok" : "unauthenticated");
|
|
2221
2221
|
} catch {
|
|
2222
|
-
|
|
2222
|
+
resolve26("unauthenticated");
|
|
2223
2223
|
}
|
|
2224
2224
|
});
|
|
2225
2225
|
});
|
|
@@ -2229,9 +2229,9 @@ async function binaryIsOnPath(binary) {
|
|
|
2229
2229
|
const fs = await import("node:fs/promises");
|
|
2230
2230
|
return fs.access(binary).then(() => true, () => false);
|
|
2231
2231
|
}
|
|
2232
|
-
return new Promise((
|
|
2232
|
+
return new Promise((resolve26) => {
|
|
2233
2233
|
const child = spawn4(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
|
|
2234
|
-
child.on("close", (code) =>
|
|
2234
|
+
child.on("close", (code) => resolve26(code === 0));
|
|
2235
2235
|
});
|
|
2236
2236
|
}
|
|
2237
2237
|
var init_check_agent_auth = __esm({
|
|
@@ -4153,12 +4153,12 @@ function renameEmptySlots(db, sessionId, componentId, componentName, slotCount)
|
|
|
4153
4153
|
return { renames: [], warnings: [] };
|
|
4154
4154
|
const renames = [];
|
|
4155
4155
|
const warnings = [];
|
|
4156
|
-
const
|
|
4156
|
+
const rename5 = db.prepare(`UPDATE raw_slots SET name = ? WHERE session_id = ? AND component_id = ? AND name = ? AND position = ?`);
|
|
4157
4157
|
db.exec("BEGIN");
|
|
4158
4158
|
try {
|
|
4159
4159
|
for (const slot of emptySlots) {
|
|
4160
4160
|
const newName = slotCount === 1 ? "children" : `slot_${slot.position}`;
|
|
4161
|
-
|
|
4161
|
+
rename5.run(newName, sessionId, componentId, slot.name, slot.position);
|
|
4162
4162
|
renames.push({ oldName: slot.name, newName });
|
|
4163
4163
|
warnings.push(`${componentName}: slot at position ${slot.position} had empty name \u2014 renamed to "${newName}" for classification`);
|
|
4164
4164
|
}
|
|
@@ -5197,7 +5197,7 @@ function getTsxExtractionContext(filePaths, componentFilePattern) {
|
|
|
5197
5197
|
project: createTsxProject(getTsxProjectFiles(filePaths))
|
|
5198
5198
|
};
|
|
5199
5199
|
}
|
|
5200
|
-
function extractTsxComponents(filePaths, componentFilePattern,
|
|
5200
|
+
function extractTsxComponents(filePaths, componentFilePattern, extract2) {
|
|
5201
5201
|
const extractionContext = getTsxExtractionContext(filePaths, componentFilePattern);
|
|
5202
5202
|
if (!extractionContext) {
|
|
5203
5203
|
return { components: [], warnings: [], exclusions: [] };
|
|
@@ -5211,7 +5211,7 @@ function extractTsxComponents(filePaths, componentFilePattern, extract) {
|
|
|
5211
5211
|
const sourceFile = project.getSourceFile(filePath);
|
|
5212
5212
|
if (!sourceFile)
|
|
5213
5213
|
continue;
|
|
5214
|
-
components.push(...
|
|
5214
|
+
components.push(...extract2(sourceFile, exclusions));
|
|
5215
5215
|
} catch (e) {
|
|
5216
5216
|
warnings.push(`Failed to extract from ${filePath}: ${e instanceof Error ? e.message : String(e)}`);
|
|
5217
5217
|
}
|
|
@@ -14901,7 +14901,7 @@ function errorMessage(error) {
|
|
|
14901
14901
|
return error instanceof Error && error.message ? error.message : String(error);
|
|
14902
14902
|
}
|
|
14903
14903
|
function defaultSleep(delayMs) {
|
|
14904
|
-
return new Promise((
|
|
14904
|
+
return new Promise((resolve26) => setTimeout(resolve26, delayMs));
|
|
14905
14905
|
}
|
|
14906
14906
|
var MAX_RETRY_AFTER_MS;
|
|
14907
14907
|
var init_http_utils = __esm({
|
|
@@ -15177,7 +15177,7 @@ var init_api_client = __esm({
|
|
|
15177
15177
|
const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
|
|
15178
15178
|
const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
|
|
15179
15179
|
const jitter = Math.random() * baseDelay * 0.15;
|
|
15180
|
-
await new Promise((
|
|
15180
|
+
await new Promise((resolve26) => setTimeout(resolve26, baseDelay + jitter));
|
|
15181
15181
|
}
|
|
15182
15182
|
}
|
|
15183
15183
|
throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
|
|
@@ -18734,7 +18734,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
|
|
|
18734
18734
|
const message = error instanceof Error ? error.message : String(error);
|
|
18735
18735
|
if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
|
|
18736
18736
|
throw error;
|
|
18737
|
-
await new Promise((
|
|
18737
|
+
await new Promise((resolve26) => setTimeout(resolve26, Math.min(250 * attempt, 2e3)));
|
|
18738
18738
|
}
|
|
18739
18739
|
}
|
|
18740
18740
|
}
|
|
@@ -19251,12 +19251,12 @@ async function runOneGenerateComponent(options, component, index, total) {
|
|
|
19251
19251
|
if (renames.length > 0) {
|
|
19252
19252
|
const renameMap = new Map(renames.map((r) => [r.oldName, r.newName]));
|
|
19253
19253
|
effectiveSlots = component.slots.map((s) => renameMap.has(s.name) ? { ...s, name: renameMap.get(s.name) } : s);
|
|
19254
|
-
for (const
|
|
19254
|
+
for (const rename5 of renames) {
|
|
19255
19255
|
onProgress?.({
|
|
19256
19256
|
kind: "component:slot-renamed",
|
|
19257
19257
|
componentName: component.name,
|
|
19258
|
-
oldName:
|
|
19259
|
-
newName:
|
|
19258
|
+
oldName: rename5.oldName,
|
|
19259
|
+
newName: rename5.newName
|
|
19260
19260
|
});
|
|
19261
19261
|
}
|
|
19262
19262
|
}
|
|
@@ -20527,17 +20527,228 @@ var init_config = __esm({
|
|
|
20527
20527
|
}
|
|
20528
20528
|
});
|
|
20529
20529
|
|
|
20530
|
+
// packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
|
|
20531
|
+
async function readDebugModeSetting() {
|
|
20532
|
+
const { debugMode } = await readSettings2();
|
|
20533
|
+
return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
|
|
20534
|
+
}
|
|
20535
|
+
async function writeDebugModeSetting(setting) {
|
|
20536
|
+
await updateSettings2({ debugMode: setting });
|
|
20537
|
+
}
|
|
20538
|
+
var DEFAULT_DEBUG_MODE_SETTING;
|
|
20539
|
+
var init_debug_mode_store = __esm({
|
|
20540
|
+
"packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
|
|
20541
|
+
"use strict";
|
|
20542
|
+
init_config();
|
|
20543
|
+
DEFAULT_DEBUG_MODE_SETTING = {
|
|
20544
|
+
enabled: true
|
|
20545
|
+
};
|
|
20546
|
+
}
|
|
20547
|
+
});
|
|
20548
|
+
|
|
20549
|
+
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
20550
|
+
var debug_store_exports = {};
|
|
20551
|
+
__export(debug_store_exports, {
|
|
20552
|
+
currentDebugSessionDir: () => currentDebugSessionDir,
|
|
20553
|
+
finishDebugRun: () => finishDebugRun,
|
|
20554
|
+
setDebugOutDir: () => setDebugOutDir,
|
|
20555
|
+
startDebugRun: () => startDebugRun
|
|
20556
|
+
});
|
|
20557
|
+
import { cp, mkdir as mkdir7, rename as rename3, rm, writeFile as writeFile7 } from "node:fs/promises";
|
|
20558
|
+
import { existsSync as existsSync10, readdirSync as readdirSync3 } from "node:fs";
|
|
20559
|
+
import { join as join20, resolve as resolve20 } from "node:path";
|
|
20560
|
+
function generateRunId() {
|
|
20561
|
+
const now = /* @__PURE__ */ new Date();
|
|
20562
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
20563
|
+
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
20564
|
+
}
|
|
20565
|
+
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
20566
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
20567
|
+
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
20568
|
+
}
|
|
20569
|
+
function slugify(value) {
|
|
20570
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
20571
|
+
}
|
|
20572
|
+
function generateSessionId3() {
|
|
20573
|
+
const today = datePrefix();
|
|
20574
|
+
const root = debugSessionsDir2();
|
|
20575
|
+
const existing = existsSync10(root) ? readdirSync3(root) : [];
|
|
20576
|
+
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
20577
|
+
const maxSeq = existing.reduce((max, entry) => {
|
|
20578
|
+
const match2 = seqPattern.exec(entry);
|
|
20579
|
+
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
20580
|
+
}, 0);
|
|
20581
|
+
return `${today}-session-${maxSeq + 1}`;
|
|
20582
|
+
}
|
|
20583
|
+
function sessionDebugDir() {
|
|
20584
|
+
return join20(projectSessionsRoot ?? debugSessionsDir2(), SESSION_ID);
|
|
20585
|
+
}
|
|
20586
|
+
function currentDebugSessionDir() {
|
|
20587
|
+
return sessionDebugDir();
|
|
20588
|
+
}
|
|
20589
|
+
async function setDebugOutDir(outDir) {
|
|
20590
|
+
if (!await isDebugModeEnabled()) return;
|
|
20591
|
+
const nextRoot = join20(resolve20(outDir), "debug", "sessions");
|
|
20592
|
+
const from = sessionDebugDir();
|
|
20593
|
+
const to = join20(nextRoot, SESSION_ID);
|
|
20594
|
+
if (from === to) return;
|
|
20595
|
+
try {
|
|
20596
|
+
await mkdir7(nextRoot, { recursive: true });
|
|
20597
|
+
if (existsSync10(from)) {
|
|
20598
|
+
try {
|
|
20599
|
+
await rename3(from, to);
|
|
20600
|
+
} catch {
|
|
20601
|
+
await cp(from, to, { recursive: true });
|
|
20602
|
+
await rm(from, { recursive: true, force: true });
|
|
20603
|
+
}
|
|
20604
|
+
} else {
|
|
20605
|
+
await mkdir7(to, { recursive: true });
|
|
20606
|
+
}
|
|
20607
|
+
projectSessionsRoot = nextRoot;
|
|
20608
|
+
} catch {
|
|
20609
|
+
}
|
|
20610
|
+
}
|
|
20611
|
+
async function isDebugModeEnabled() {
|
|
20612
|
+
try {
|
|
20613
|
+
return (await readDebugModeSetting()).enabled;
|
|
20614
|
+
} catch {
|
|
20615
|
+
return true;
|
|
20616
|
+
}
|
|
20617
|
+
}
|
|
20618
|
+
function redact(value) {
|
|
20619
|
+
const clone = { ...value };
|
|
20620
|
+
if ("cma_token" in clone) {
|
|
20621
|
+
const raw = clone.cma_token;
|
|
20622
|
+
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
20623
|
+
}
|
|
20624
|
+
return clone;
|
|
20625
|
+
}
|
|
20626
|
+
function startDebugRun({
|
|
20627
|
+
flow,
|
|
20628
|
+
step,
|
|
20629
|
+
menuOption,
|
|
20630
|
+
inputs
|
|
20631
|
+
}) {
|
|
20632
|
+
const runId = generateRunId();
|
|
20633
|
+
const startedAt = Date.now();
|
|
20634
|
+
const redactedInputs = redact(inputs);
|
|
20635
|
+
isDebugModeEnabled().then((enabled) => {
|
|
20636
|
+
if (!enabled) return;
|
|
20637
|
+
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
20638
|
+
});
|
|
20639
|
+
}
|
|
20640
|
+
async function finishDebugRun({
|
|
20641
|
+
outputs,
|
|
20642
|
+
status,
|
|
20643
|
+
exitMethod
|
|
20644
|
+
}) {
|
|
20645
|
+
const run = pendingRun;
|
|
20646
|
+
if (!run) return;
|
|
20647
|
+
pendingRun = void 0;
|
|
20648
|
+
const durationMs = Date.now() - run.startedAt;
|
|
20649
|
+
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
20650
|
+
const flowSegments = run.flow.split("/");
|
|
20651
|
+
const dir = join20(sessionDebugDir(), ...flowSegments);
|
|
20652
|
+
await mkdir7(dir, { recursive: true });
|
|
20653
|
+
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
20654
|
+
await writeFile7(join20(dir, filename), content, { mode: 384 });
|
|
20655
|
+
}
|
|
20656
|
+
function nextAttemptFilename(dir, menuOption) {
|
|
20657
|
+
const today = datePrefix();
|
|
20658
|
+
const optionSlug = slugify(menuOption);
|
|
20659
|
+
const existing = existsSync10(dir) ? readdirSync3(dir) : [];
|
|
20660
|
+
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
20661
|
+
const maxAttempt = existing.reduce((max, entry) => {
|
|
20662
|
+
const match2 = attemptPattern.exec(entry);
|
|
20663
|
+
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
20664
|
+
}, 0);
|
|
20665
|
+
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
20666
|
+
}
|
|
20667
|
+
function renderMarkdown(run, finish) {
|
|
20668
|
+
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
20669
|
+
const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
20670
|
+
const flowSlug = run.flow.split("/").join("-");
|
|
20671
|
+
return `# Debug Log
|
|
20672
|
+
|
|
20673
|
+
- Run ID: ${run.runId}
|
|
20674
|
+
- Flow: ${flowSlug}
|
|
20675
|
+
- Step: ${stepLabel2}
|
|
20676
|
+
- Menu option: ${run.menuOption}
|
|
20677
|
+
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
20678
|
+
- CLI version: ${readPackageVersion()}
|
|
20679
|
+
- Platform: ${process.platform} / Node ${process.version}
|
|
20680
|
+
- Duration on screen: ${finish.durationMs}ms
|
|
20681
|
+
- Status: ${finish.status}
|
|
20682
|
+
- Exit method: ${finish.exitMethod}
|
|
20683
|
+
|
|
20684
|
+
## Inputs
|
|
20685
|
+
\`\`\`json
|
|
20686
|
+
${JSON.stringify(run.inputs, null, 2)}
|
|
20687
|
+
\`\`\`
|
|
20688
|
+
|
|
20689
|
+
## Outputs
|
|
20690
|
+
\`\`\`json
|
|
20691
|
+
${JSON.stringify(finish.outputs, null, 2)}
|
|
20692
|
+
\`\`\`
|
|
20693
|
+
`;
|
|
20694
|
+
}
|
|
20695
|
+
function handleCrash() {
|
|
20696
|
+
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
20697
|
+
}
|
|
20698
|
+
var pendingRun, SESSION_ID, projectSessionsRoot;
|
|
20699
|
+
var init_debug_store = __esm({
|
|
20700
|
+
"packages/experience-design-system-cli/src/tui/debug-store.ts"() {
|
|
20701
|
+
"use strict";
|
|
20702
|
+
init_config();
|
|
20703
|
+
init_version();
|
|
20704
|
+
init_debug_mode_store();
|
|
20705
|
+
SESSION_ID = generateSessionId3();
|
|
20706
|
+
void isDebugModeEnabled().then((enabled) => {
|
|
20707
|
+
if (!enabled) return void 0;
|
|
20708
|
+
return mkdir7(sessionDebugDir(), { recursive: true });
|
|
20709
|
+
});
|
|
20710
|
+
process.once("uncaughtException", (err) => {
|
|
20711
|
+
void handleCrash().finally(() => {
|
|
20712
|
+
throw err;
|
|
20713
|
+
});
|
|
20714
|
+
});
|
|
20715
|
+
process.once("unhandledRejection", (reason) => {
|
|
20716
|
+
void handleCrash().finally(() => {
|
|
20717
|
+
throw reason;
|
|
20718
|
+
});
|
|
20719
|
+
});
|
|
20720
|
+
process.once("SIGINT", () => {
|
|
20721
|
+
void handleCrash().finally(() => {
|
|
20722
|
+
process.exit(130);
|
|
20723
|
+
});
|
|
20724
|
+
});
|
|
20725
|
+
}
|
|
20726
|
+
});
|
|
20727
|
+
|
|
20728
|
+
// packages/experience-design-system-cli/src/tui/import/debug-hooks.ts
|
|
20729
|
+
var realDebugHooks;
|
|
20730
|
+
var init_debug_hooks = __esm({
|
|
20731
|
+
"packages/experience-design-system-cli/src/tui/import/debug-hooks.ts"() {
|
|
20732
|
+
"use strict";
|
|
20733
|
+
realDebugHooks = {
|
|
20734
|
+
setOutDir: async (outDir) => (await Promise.resolve().then(() => (init_debug_store(), debug_store_exports))).setDebugOutDir(outDir),
|
|
20735
|
+
start: (run) => void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then((m) => m.startDebugRun(run)),
|
|
20736
|
+
finish: async (run) => (await Promise.resolve().then(() => (init_debug_store(), debug_store_exports))).finishDebugRun(run)
|
|
20737
|
+
};
|
|
20738
|
+
}
|
|
20739
|
+
});
|
|
20740
|
+
|
|
20530
20741
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/find-skill-path.ts
|
|
20531
|
-
import { existsSync as
|
|
20532
|
-
import { dirname as dirname14, join as
|
|
20742
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
20743
|
+
import { dirname as dirname14, join as join21, resolve as resolve21 } from "node:path";
|
|
20533
20744
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
20534
20745
|
function findSkillPath(fileName) {
|
|
20535
20746
|
const thisDir = dirname14(fileURLToPath4(import.meta.url));
|
|
20536
20747
|
let dir = thisDir;
|
|
20537
20748
|
for (; ; ) {
|
|
20538
|
-
const candidate =
|
|
20539
|
-
if (
|
|
20540
|
-
const parent =
|
|
20749
|
+
const candidate = join21(dir, "skills", fileName);
|
|
20750
|
+
if (existsSync11(candidate)) return candidate;
|
|
20751
|
+
const parent = resolve21(dir, "..");
|
|
20541
20752
|
if (parent === dir) {
|
|
20542
20753
|
throw new Error(`skill file not found (looked for skills/${fileName} from ${thisDir})`);
|
|
20543
20754
|
}
|
|
@@ -20551,9 +20762,9 @@ var init_find_skill_path = __esm({
|
|
|
20551
20762
|
});
|
|
20552
20763
|
|
|
20553
20764
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/selection.ts
|
|
20554
|
-
import { resolve as
|
|
20765
|
+
import { resolve as resolve22 } from "node:path";
|
|
20555
20766
|
async function hashSelectPrompt(options) {
|
|
20556
|
-
const promptHash = options.promptText ? hashContent(options.promptText) : options.promptPath ? await hashFile(
|
|
20767
|
+
const promptHash = options.promptText ? hashContent(options.promptText) : options.promptPath ? await hashFile(resolve22(options.promptPath)) : await hashFile(SELECT_SKILL_PATH);
|
|
20557
20768
|
return hashContent(`${promptHash}|${options.agent}|${options.model ?? ""}`);
|
|
20558
20769
|
}
|
|
20559
20770
|
async function runSelection(options) {
|
|
@@ -20647,10 +20858,29 @@ var init_selection2 = __esm({
|
|
|
20647
20858
|
});
|
|
20648
20859
|
|
|
20649
20860
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts
|
|
20650
|
-
import { mkdir as
|
|
20651
|
-
import { join as
|
|
20861
|
+
import { mkdir as mkdir8 } from "node:fs/promises";
|
|
20862
|
+
import { join as join22, resolve as resolve23 } from "node:path";
|
|
20652
20863
|
async function runExtraction(input, onProgress, deps = realDeps) {
|
|
20653
|
-
const outDir =
|
|
20864
|
+
const outDir = join22(resolve23(input.projectPath), ".contentful");
|
|
20865
|
+
await deps.debug?.setOutDir(outDir);
|
|
20866
|
+
deps.debug?.start({
|
|
20867
|
+
flow: "import",
|
|
20868
|
+
step: "06-extraction",
|
|
20869
|
+
menuOption: "Import",
|
|
20870
|
+
inputs: {
|
|
20871
|
+
projectPath: input.projectPath,
|
|
20872
|
+
agent: input.agent,
|
|
20873
|
+
files: input.filePaths.length,
|
|
20874
|
+
noCache: input.noCache
|
|
20875
|
+
}
|
|
20876
|
+
});
|
|
20877
|
+
const result = await extract(input, outDir, onProgress, deps);
|
|
20878
|
+
await deps.debug?.finish(
|
|
20879
|
+
result.ok ? { outputs: { sessionId: result.extraction.sessionId, outDir }, status: "success", exitMethod: "saved" } : { outputs: { step: result.step, message: result.message }, status: "error", exitMethod: "discarded" }
|
|
20880
|
+
);
|
|
20881
|
+
return result;
|
|
20882
|
+
}
|
|
20883
|
+
async function extract(input, outDir, onProgress, deps) {
|
|
20654
20884
|
let progress = initialProgress({
|
|
20655
20885
|
hasCredentials: input.credentials !== null,
|
|
20656
20886
|
hasRawTokens: input.rawTokensPath !== "",
|
|
@@ -20745,7 +20975,7 @@ async function runExtraction(input, onProgress, deps = realDeps) {
|
|
|
20745
20975
|
const extraction = {
|
|
20746
20976
|
sessionId: extracted.sessionId,
|
|
20747
20977
|
outDir,
|
|
20748
|
-
tokensPath: tokens?.ok ? tokens.tokensPath : hasTokenSource ?
|
|
20978
|
+
tokensPath: tokens?.ok ? tokens.tokensPath : hasTokenSource ? join22(outDir, "tokens.json") : "",
|
|
20749
20979
|
tokenSessionId: tokens?.ok ? tokens.tokenSessionId : null,
|
|
20750
20980
|
tokenCount: tokens?.ok ? tokens.tokenCount : 0,
|
|
20751
20981
|
existingEntitiesPath,
|
|
@@ -20756,7 +20986,7 @@ async function runExtraction(input, onProgress, deps = realDeps) {
|
|
|
20756
20986
|
}
|
|
20757
20987
|
async function fetchEntities(credentials, outDir) {
|
|
20758
20988
|
try {
|
|
20759
|
-
await
|
|
20989
|
+
await mkdir8(outDir, { recursive: true });
|
|
20760
20990
|
const result = await fetchAndPersistExistingContentfulEntities({
|
|
20761
20991
|
spaceId: credentials.spaceId,
|
|
20762
20992
|
environmentId: credentials.environmentId,
|
|
@@ -20776,7 +21006,7 @@ async function resolveSelectionPrompt(overrides) {
|
|
|
20776
21006
|
if (select?.kind === "text") return { promptText: select.value };
|
|
20777
21007
|
if (select?.kind === "path") {
|
|
20778
21008
|
await resolvePromptOverride(select);
|
|
20779
|
-
return { promptPath:
|
|
21009
|
+
return { promptPath: resolve23(select.value) };
|
|
20780
21010
|
}
|
|
20781
21011
|
return {};
|
|
20782
21012
|
}
|
|
@@ -20785,6 +21015,7 @@ var init_run = __esm({
|
|
|
20785
21015
|
"packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts"() {
|
|
20786
21016
|
"use strict";
|
|
20787
21017
|
init_src4();
|
|
21018
|
+
init_debug_hooks();
|
|
20788
21019
|
init_find_skill_path();
|
|
20789
21020
|
init_logic9();
|
|
20790
21021
|
init_selection2();
|
|
@@ -20794,7 +21025,8 @@ var init_run = __esm({
|
|
|
20794
21025
|
fetchEntities,
|
|
20795
21026
|
runExtractAndComposeSession,
|
|
20796
21027
|
runGenerateTokensSession,
|
|
20797
|
-
runSelection
|
|
21028
|
+
runSelection,
|
|
21029
|
+
debug: realDebugHooks
|
|
20798
21030
|
};
|
|
20799
21031
|
fail = (step, message) => ({ ok: false, step, message });
|
|
20800
21032
|
errorMessage2 = (error) => error instanceof Error ? error.message : String(error);
|
|
@@ -24041,7 +24273,7 @@ var init_save_decisions = __esm({
|
|
|
24041
24273
|
});
|
|
24042
24274
|
|
|
24043
24275
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
|
|
24044
|
-
import { resolve as
|
|
24276
|
+
import { resolve as resolve24 } from "node:path";
|
|
24045
24277
|
async function runGeneration(input, onProgress, deps = realDeps3) {
|
|
24046
24278
|
let progress = { components: null, mapTokens: "idle", mapTokensEligible: null };
|
|
24047
24279
|
const update = (change) => {
|
|
@@ -24127,7 +24359,7 @@ async function buildMapTokensOptions(input) {
|
|
|
24127
24359
|
if (mapOverride?.kind === "text") prompt.skillContentOverride = mapOverride.value;
|
|
24128
24360
|
if (mapOverride?.kind === "path") {
|
|
24129
24361
|
await resolvePromptOverride(mapOverride);
|
|
24130
|
-
prompt.skillPathOverride =
|
|
24362
|
+
prompt.skillPathOverride = resolve24(mapOverride.value);
|
|
24131
24363
|
}
|
|
24132
24364
|
if (input.existingEntitiesPath) {
|
|
24133
24365
|
const entities = await readExistingContentfulEntitiesFromSession({ path: input.existingEntitiesPath });
|
|
@@ -24205,7 +24437,7 @@ var init_use_generation = __esm({
|
|
|
24205
24437
|
});
|
|
24206
24438
|
|
|
24207
24439
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/build-flow-start.ts
|
|
24208
|
-
import { join as
|
|
24440
|
+
import { join as join23 } from "node:path";
|
|
24209
24441
|
function buildFlowStart(input) {
|
|
24210
24442
|
const { extraction, handoff, saved, generatePromptPath } = input;
|
|
24211
24443
|
const credentials = extraction.credentials ?? {
|
|
@@ -24218,7 +24450,7 @@ function buildFlowStart(input) {
|
|
|
24218
24450
|
handoff,
|
|
24219
24451
|
agent: extraction.agent,
|
|
24220
24452
|
projectPath: extraction.projectPath,
|
|
24221
|
-
outDir: extraction.projectPath ?
|
|
24453
|
+
outDir: extraction.projectPath ? join23(extraction.projectPath, ".contentful") : "",
|
|
24222
24454
|
rawTokensPath: extraction.rawTokensPath,
|
|
24223
24455
|
credentials: {
|
|
24224
24456
|
spaceId: credentials.spaceId,
|
|
@@ -30414,7 +30646,7 @@ var init_DoneStep = __esm({
|
|
|
30414
30646
|
});
|
|
30415
30647
|
|
|
30416
30648
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts
|
|
30417
|
-
import { resolve as
|
|
30649
|
+
import { resolve as resolve25 } from "node:path";
|
|
30418
30650
|
import { homedir as homedir4 } from "node:os";
|
|
30419
30651
|
function expandTilde(input) {
|
|
30420
30652
|
if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
|
|
@@ -30428,7 +30660,7 @@ function normalizePath(input) {
|
|
|
30428
30660
|
p = p.slice(1, -1);
|
|
30429
30661
|
}
|
|
30430
30662
|
p = expandTilde(p);
|
|
30431
|
-
return
|
|
30663
|
+
return resolve25(p);
|
|
30432
30664
|
}
|
|
30433
30665
|
var init_path_utils = __esm({
|
|
30434
30666
|
"packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts"() {
|
|
@@ -30455,8 +30687,8 @@ var init_use_blinking_cursor = __esm({
|
|
|
30455
30687
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/PathPrompt.tsx
|
|
30456
30688
|
import { useState as useState24 } from "react";
|
|
30457
30689
|
import { Box as Box37, Text as Text40 } from "ink";
|
|
30458
|
-
import { readdirSync as
|
|
30459
|
-
import { dirname as dirname15, basename as basename6, join as
|
|
30690
|
+
import { readdirSync as readdirSync4 } from "node:fs";
|
|
30691
|
+
import { dirname as dirname15, basename as basename6, join as join24 } from "node:path";
|
|
30460
30692
|
import { jsx as jsx47, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
30461
30693
|
function autocomplete(partial) {
|
|
30462
30694
|
if (!partial) return null;
|
|
@@ -30465,19 +30697,19 @@ function autocomplete(partial) {
|
|
|
30465
30697
|
const base = basename6(normalized);
|
|
30466
30698
|
let entries;
|
|
30467
30699
|
try {
|
|
30468
|
-
entries =
|
|
30700
|
+
entries = readdirSync4(dir);
|
|
30469
30701
|
} catch {
|
|
30470
30702
|
return null;
|
|
30471
30703
|
}
|
|
30472
30704
|
const matches = entries.filter((e) => e.startsWith(base));
|
|
30473
30705
|
if (matches.length === 0) return null;
|
|
30474
|
-
if (matches.length === 1) return
|
|
30706
|
+
if (matches.length === 1) return join24(dir, matches[0]);
|
|
30475
30707
|
let prefix = matches[0];
|
|
30476
30708
|
for (const m of matches) {
|
|
30477
30709
|
while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
|
|
30478
30710
|
if (!prefix) break;
|
|
30479
30711
|
}
|
|
30480
|
-
return prefix.length > base.length ?
|
|
30712
|
+
return prefix.length > base.length ? join24(dir, prefix) : null;
|
|
30481
30713
|
}
|
|
30482
30714
|
function PathPrompt({
|
|
30483
30715
|
defaultPath,
|
|
@@ -31134,6 +31366,7 @@ var init_run_teaser = __esm({
|
|
|
31134
31366
|
});
|
|
31135
31367
|
|
|
31136
31368
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/screen.tsx
|
|
31369
|
+
import { useEffect as useEffect20, useRef as useRef12 } from "react";
|
|
31137
31370
|
import { Box as Box41 } from "ink";
|
|
31138
31371
|
import { jsx as jsx52, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
31139
31372
|
function totalStepsFor(state) {
|
|
@@ -31149,10 +31382,18 @@ function FlowScreen({
|
|
|
31149
31382
|
controller,
|
|
31150
31383
|
livePreview = true,
|
|
31151
31384
|
generatePromptPath,
|
|
31152
|
-
onExit
|
|
31385
|
+
onExit,
|
|
31386
|
+
onStepChange
|
|
31153
31387
|
}) {
|
|
31154
31388
|
const totalSteps = totalStepsFor(state);
|
|
31155
31389
|
const quit = () => onExit(0);
|
|
31390
|
+
const previousStep = useRef12(state.step);
|
|
31391
|
+
useEffect20(() => {
|
|
31392
|
+
if (previousStep.current !== state.step) {
|
|
31393
|
+
onStepChange?.();
|
|
31394
|
+
previousStep.current = state.step;
|
|
31395
|
+
}
|
|
31396
|
+
}, [state.step, onStepChange]);
|
|
31156
31397
|
const content = (() => {
|
|
31157
31398
|
switch (state.step) {
|
|
31158
31399
|
case "final-review":
|
|
@@ -31671,8 +31912,8 @@ var init_run_print_files_helpers = __esm({
|
|
|
31671
31912
|
});
|
|
31672
31913
|
|
|
31673
31914
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts
|
|
31674
|
-
import { writeFile as
|
|
31675
|
-
import { join as
|
|
31915
|
+
import { writeFile as writeFile8 } from "node:fs/promises";
|
|
31916
|
+
import { join as join25 } from "node:path";
|
|
31676
31917
|
function buildSavedCDF(components, tokens, opts = {}) {
|
|
31677
31918
|
const cdf = buildCDF2(components, toCdfTokens(tokens), opts);
|
|
31678
31919
|
if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
|
|
@@ -31684,7 +31925,7 @@ function buildSavedCDF(components, tokens, opts = {}) {
|
|
|
31684
31925
|
}
|
|
31685
31926
|
async function runPrintFiles(input, deps, onPatch) {
|
|
31686
31927
|
onPatch({ step: "printing" });
|
|
31687
|
-
const componentsPath =
|
|
31928
|
+
const componentsPath = join25(input.outDir, "components.json");
|
|
31688
31929
|
try {
|
|
31689
31930
|
const db = deps.openDb();
|
|
31690
31931
|
let components = [];
|
|
@@ -31768,10 +32009,10 @@ var init_save = __esm({
|
|
|
31768
32009
|
realSaveDeps = () => ({
|
|
31769
32010
|
openDb: openPipelineDb,
|
|
31770
32011
|
readTokens: (path5) => readTokensFromPath2({ flag: "tokens", path: path5 }),
|
|
31771
|
-
writeFile: (path5, contents) =>
|
|
32012
|
+
writeFile: (path5, contents) => writeFile8(path5, contents),
|
|
31772
32013
|
appendRun,
|
|
31773
32014
|
buildSourceFingerprint,
|
|
31774
|
-
sleep: (ms) => new Promise((
|
|
32015
|
+
sleep: (ms) => new Promise((resolve26) => setTimeout(resolve26, ms)),
|
|
31775
32016
|
warn: (message) => process.stderr.write(message)
|
|
31776
32017
|
});
|
|
31777
32018
|
}
|
|
@@ -31791,9 +32032,9 @@ var init_types9 = __esm({
|
|
|
31791
32032
|
|
|
31792
32033
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
|
|
31793
32034
|
import { appendFileSync, writeFileSync } from "node:fs";
|
|
31794
|
-
import { mkdir as
|
|
32035
|
+
import { mkdir as mkdir9 } from "node:fs/promises";
|
|
31795
32036
|
import { tmpdir } from "node:os";
|
|
31796
|
-
import { join as
|
|
32037
|
+
import { join as join26 } from "node:path";
|
|
31797
32038
|
function appendWizardLog(entry) {
|
|
31798
32039
|
appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
|
|
31799
32040
|
}
|
|
@@ -31816,13 +32057,14 @@ function realFlowDeps() {
|
|
|
31816
32057
|
}
|
|
31817
32058
|
},
|
|
31818
32059
|
mkdir: async (path5) => {
|
|
31819
|
-
await
|
|
32060
|
+
await mkdir9(path5, { recursive: true });
|
|
31820
32061
|
},
|
|
31821
32062
|
detectSaveConflict,
|
|
31822
32063
|
buildTimestampedSubdir,
|
|
31823
32064
|
rejectComponentsByName,
|
|
31824
32065
|
log,
|
|
31825
|
-
stderr: (text) => process.stderr.write(text)
|
|
32066
|
+
stderr: (text) => process.stderr.write(text),
|
|
32067
|
+
debug: realDebugHooks
|
|
31826
32068
|
};
|
|
31827
32069
|
}
|
|
31828
32070
|
function initialFlowState(start) {
|
|
@@ -31920,12 +32162,6 @@ function createFlowController(start, deps) {
|
|
|
31920
32162
|
deps.log({ update: sanitizeForLog(patch) });
|
|
31921
32163
|
} catch {
|
|
31922
32164
|
}
|
|
31923
|
-
if (patch.step !== void 0 && patch.step !== state.step) {
|
|
31924
|
-
try {
|
|
31925
|
-
deps.beforeStepChange?.();
|
|
31926
|
-
} catch {
|
|
31927
|
-
}
|
|
31928
|
-
}
|
|
31929
32165
|
state = { ...state, ...patch };
|
|
31930
32166
|
for (const listener of listeners) listener();
|
|
31931
32167
|
};
|
|
@@ -31972,6 +32208,13 @@ function createFlowController(start, deps) {
|
|
|
31972
32208
|
};
|
|
31973
32209
|
const proceedToWrite = async (path5) => {
|
|
31974
32210
|
update({ outDir: path5 });
|
|
32211
|
+
await deps.debug?.setOutDir(path5);
|
|
32212
|
+
deps.debug?.start({
|
|
32213
|
+
flow: "import",
|
|
32214
|
+
step: "10-flow",
|
|
32215
|
+
menuOption: "Save",
|
|
32216
|
+
inputs: { outDir: path5, extractSessionId: state.extractSessionId, andPush: !!pendingSave.andPush }
|
|
32217
|
+
});
|
|
31975
32218
|
const { skipGate, andPush } = pendingSave;
|
|
31976
32219
|
const written = await runPrintFiles(
|
|
31977
32220
|
{
|
|
@@ -31986,6 +32229,9 @@ function createFlowController(start, deps) {
|
|
|
31986
32229
|
update
|
|
31987
32230
|
);
|
|
31988
32231
|
update(written.patch);
|
|
32232
|
+
await deps.debug?.finish(
|
|
32233
|
+
written.ok ? { outputs: { componentsPath: join26(path5, "components.json") }, status: "success", exitMethod: "saved" } : { outputs: { error: written.patch.errorMessage ?? "unknown" }, status: "error", exitMethod: "discarded" }
|
|
32234
|
+
);
|
|
31989
32235
|
if (!written.ok) return;
|
|
31990
32236
|
const runId = await recordRun({ state, savePath: path5 }, deps.save);
|
|
31991
32237
|
if (runId) update({ lastRunId: runId });
|
|
@@ -32069,35 +32315,32 @@ var init_controller = __esm({
|
|
|
32069
32315
|
init_slot_graph();
|
|
32070
32316
|
init_cycle_detection();
|
|
32071
32317
|
init_wizard_state_transitions();
|
|
32318
|
+
init_debug_hooks();
|
|
32072
32319
|
init_preview2();
|
|
32073
32320
|
init_push();
|
|
32074
32321
|
init_save();
|
|
32075
32322
|
init_types9();
|
|
32076
|
-
WIZARD_LOG =
|
|
32323
|
+
WIZARD_LOG = join26(tmpdir(), "experiences-import-wizard.log");
|
|
32077
32324
|
}
|
|
32078
32325
|
});
|
|
32079
32326
|
|
|
32080
32327
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
|
|
32081
|
-
import { useEffect as
|
|
32082
|
-
function useFlow(start,
|
|
32083
|
-
const controller =
|
|
32328
|
+
import { useEffect as useEffect21, useRef as useRef13, useSyncExternalStore } from "react";
|
|
32329
|
+
function useFlow(start, deps = realFlowDeps) {
|
|
32330
|
+
const controller = useRef13();
|
|
32084
32331
|
if (start && !controller.current) {
|
|
32085
32332
|
try {
|
|
32086
32333
|
startWizardLog();
|
|
32087
32334
|
} catch {
|
|
32088
32335
|
}
|
|
32089
|
-
|
|
32090
|
-
controller.current = createFlowController(start, {
|
|
32091
|
-
...flowDeps,
|
|
32092
|
-
...options.beforeStepChange ? { beforeStepChange: options.beforeStepChange } : {}
|
|
32093
|
-
});
|
|
32336
|
+
controller.current = createFlowController(start, deps());
|
|
32094
32337
|
}
|
|
32095
32338
|
const current = controller.current;
|
|
32096
32339
|
const state = useSyncExternalStore(
|
|
32097
32340
|
(listener) => current?.subscribe(listener) ?? (() => void 0),
|
|
32098
32341
|
() => current?.getState()
|
|
32099
32342
|
);
|
|
32100
|
-
|
|
32343
|
+
useEffect21(() => {
|
|
32101
32344
|
if (!start) controller.current = void 0;
|
|
32102
32345
|
}, [start]);
|
|
32103
32346
|
return current && state ? { controller: current, state } : void 0;
|
|
@@ -32109,175 +32352,6 @@ var init_use_flow = __esm({
|
|
|
32109
32352
|
}
|
|
32110
32353
|
});
|
|
32111
32354
|
|
|
32112
|
-
// packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
|
|
32113
|
-
async function readDebugModeSetting() {
|
|
32114
|
-
const { debugMode } = await readSettings2();
|
|
32115
|
-
return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
|
|
32116
|
-
}
|
|
32117
|
-
async function writeDebugModeSetting(setting) {
|
|
32118
|
-
await updateSettings2({ debugMode: setting });
|
|
32119
|
-
}
|
|
32120
|
-
var DEFAULT_DEBUG_MODE_SETTING;
|
|
32121
|
-
var init_debug_mode_store = __esm({
|
|
32122
|
-
"packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
|
|
32123
|
-
"use strict";
|
|
32124
|
-
init_config();
|
|
32125
|
-
DEFAULT_DEBUG_MODE_SETTING = {
|
|
32126
|
-
enabled: true
|
|
32127
|
-
};
|
|
32128
|
-
}
|
|
32129
|
-
});
|
|
32130
|
-
|
|
32131
|
-
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
32132
|
-
import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
|
|
32133
|
-
import { existsSync as existsSync11, readdirSync as readdirSync4 } from "node:fs";
|
|
32134
|
-
import { join as join26 } from "node:path";
|
|
32135
|
-
function generateRunId() {
|
|
32136
|
-
const now = /* @__PURE__ */ new Date();
|
|
32137
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
32138
|
-
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
32139
|
-
}
|
|
32140
|
-
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
32141
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
32142
|
-
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
32143
|
-
}
|
|
32144
|
-
function slugify(value) {
|
|
32145
|
-
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
32146
|
-
}
|
|
32147
|
-
function generateSessionId3() {
|
|
32148
|
-
const today = datePrefix();
|
|
32149
|
-
const root = debugSessionsDir2();
|
|
32150
|
-
const existing = existsSync11(root) ? readdirSync4(root) : [];
|
|
32151
|
-
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
32152
|
-
const maxSeq = existing.reduce((max, entry) => {
|
|
32153
|
-
const match2 = seqPattern.exec(entry);
|
|
32154
|
-
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
32155
|
-
}, 0);
|
|
32156
|
-
return `${today}-session-${maxSeq + 1}`;
|
|
32157
|
-
}
|
|
32158
|
-
function sessionDebugDir() {
|
|
32159
|
-
return join26(debugSessionsDir2(), SESSION_ID);
|
|
32160
|
-
}
|
|
32161
|
-
function currentDebugSessionDir() {
|
|
32162
|
-
return sessionDebugDir();
|
|
32163
|
-
}
|
|
32164
|
-
async function isDebugModeEnabled() {
|
|
32165
|
-
try {
|
|
32166
|
-
return (await readDebugModeSetting()).enabled;
|
|
32167
|
-
} catch {
|
|
32168
|
-
return true;
|
|
32169
|
-
}
|
|
32170
|
-
}
|
|
32171
|
-
function redact(value) {
|
|
32172
|
-
const clone = { ...value };
|
|
32173
|
-
if ("cma_token" in clone) {
|
|
32174
|
-
const raw = clone.cma_token;
|
|
32175
|
-
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
32176
|
-
}
|
|
32177
|
-
return clone;
|
|
32178
|
-
}
|
|
32179
|
-
function startDebugRun({
|
|
32180
|
-
flow,
|
|
32181
|
-
step,
|
|
32182
|
-
menuOption,
|
|
32183
|
-
inputs
|
|
32184
|
-
}) {
|
|
32185
|
-
const runId = generateRunId();
|
|
32186
|
-
const startedAt = Date.now();
|
|
32187
|
-
const redactedInputs = redact(inputs);
|
|
32188
|
-
isDebugModeEnabled().then((enabled) => {
|
|
32189
|
-
if (!enabled) return;
|
|
32190
|
-
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
32191
|
-
});
|
|
32192
|
-
}
|
|
32193
|
-
async function finishDebugRun({
|
|
32194
|
-
outputs,
|
|
32195
|
-
status,
|
|
32196
|
-
exitMethod
|
|
32197
|
-
}) {
|
|
32198
|
-
const run = pendingRun;
|
|
32199
|
-
if (!run) return;
|
|
32200
|
-
pendingRun = void 0;
|
|
32201
|
-
const durationMs = Date.now() - run.startedAt;
|
|
32202
|
-
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
32203
|
-
const flowSegments = run.flow.split("/");
|
|
32204
|
-
const dir = join26(sessionDebugDir(), ...flowSegments);
|
|
32205
|
-
await mkdir9(dir, { recursive: true });
|
|
32206
|
-
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
32207
|
-
await writeFile8(join26(dir, filename), content, { mode: 384 });
|
|
32208
|
-
}
|
|
32209
|
-
function nextAttemptFilename(dir, menuOption) {
|
|
32210
|
-
const today = datePrefix();
|
|
32211
|
-
const optionSlug = slugify(menuOption);
|
|
32212
|
-
const existing = existsSync11(dir) ? readdirSync4(dir) : [];
|
|
32213
|
-
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
32214
|
-
const maxAttempt = existing.reduce((max, entry) => {
|
|
32215
|
-
const match2 = attemptPattern.exec(entry);
|
|
32216
|
-
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
32217
|
-
}, 0);
|
|
32218
|
-
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
32219
|
-
}
|
|
32220
|
-
function renderMarkdown(run, finish) {
|
|
32221
|
-
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
32222
|
-
const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
32223
|
-
const flowSlug = run.flow.split("/").join("-");
|
|
32224
|
-
return `# Debug Log
|
|
32225
|
-
|
|
32226
|
-
- Run ID: ${run.runId}
|
|
32227
|
-
- Flow: ${flowSlug}
|
|
32228
|
-
- Step: ${stepLabel2}
|
|
32229
|
-
- Menu option: ${run.menuOption}
|
|
32230
|
-
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
32231
|
-
- CLI version: ${readPackageVersion()}
|
|
32232
|
-
- Platform: ${process.platform} / Node ${process.version}
|
|
32233
|
-
- Duration on screen: ${finish.durationMs}ms
|
|
32234
|
-
- Status: ${finish.status}
|
|
32235
|
-
- Exit method: ${finish.exitMethod}
|
|
32236
|
-
|
|
32237
|
-
## Inputs
|
|
32238
|
-
\`\`\`json
|
|
32239
|
-
${JSON.stringify(run.inputs, null, 2)}
|
|
32240
|
-
\`\`\`
|
|
32241
|
-
|
|
32242
|
-
## Outputs
|
|
32243
|
-
\`\`\`json
|
|
32244
|
-
${JSON.stringify(finish.outputs, null, 2)}
|
|
32245
|
-
\`\`\`
|
|
32246
|
-
`;
|
|
32247
|
-
}
|
|
32248
|
-
function handleCrash() {
|
|
32249
|
-
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
32250
|
-
}
|
|
32251
|
-
var pendingRun, SESSION_ID;
|
|
32252
|
-
var init_debug_store = __esm({
|
|
32253
|
-
"packages/experience-design-system-cli/src/tui/debug-store.ts"() {
|
|
32254
|
-
"use strict";
|
|
32255
|
-
init_config();
|
|
32256
|
-
init_version();
|
|
32257
|
-
init_debug_mode_store();
|
|
32258
|
-
SESSION_ID = generateSessionId3();
|
|
32259
|
-
void isDebugModeEnabled().then((enabled) => {
|
|
32260
|
-
if (!enabled) return void 0;
|
|
32261
|
-
return mkdir9(sessionDebugDir(), { recursive: true });
|
|
32262
|
-
});
|
|
32263
|
-
process.once("uncaughtException", (err) => {
|
|
32264
|
-
void handleCrash().finally(() => {
|
|
32265
|
-
throw err;
|
|
32266
|
-
});
|
|
32267
|
-
});
|
|
32268
|
-
process.once("unhandledRejection", (reason) => {
|
|
32269
|
-
void handleCrash().finally(() => {
|
|
32270
|
-
throw reason;
|
|
32271
|
-
});
|
|
32272
|
-
});
|
|
32273
|
-
process.once("SIGINT", () => {
|
|
32274
|
-
void handleCrash().finally(() => {
|
|
32275
|
-
process.exit(130);
|
|
32276
|
-
});
|
|
32277
|
-
});
|
|
32278
|
-
}
|
|
32279
|
-
});
|
|
32280
|
-
|
|
32281
32355
|
// packages/experience-design-system-cli/src/tui/help/help-info.ts
|
|
32282
32356
|
async function readHelpInfo() {
|
|
32283
32357
|
const debugMode = await readDebugModeSetting();
|
|
@@ -32285,7 +32359,8 @@ async function readHelpInfo() {
|
|
|
32285
32359
|
storage: [
|
|
32286
32360
|
{ label: "Config folder", value: configRoot2() },
|
|
32287
32361
|
{ label: "Settings file", value: configFilePath2() },
|
|
32288
|
-
{ label: "Debug logs", value:
|
|
32362
|
+
{ label: "Debug logs", value: "<project>/.contentful/debug/sessions, next to components.json" },
|
|
32363
|
+
{ label: "No project", value: `${debugSessionsDir2()} (sessions that never pick a project)` }
|
|
32289
32364
|
],
|
|
32290
32365
|
troubleshooting: [
|
|
32291
32366
|
{ label: "CLI version", value: readPackageVersion() },
|
|
@@ -32310,7 +32385,7 @@ var init_help_info = __esm({
|
|
|
32310
32385
|
});
|
|
32311
32386
|
|
|
32312
32387
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
32313
|
-
import { useEffect as
|
|
32388
|
+
import { useEffect as useEffect22, useState as useState27 } from "react";
|
|
32314
32389
|
import { Box as Box42, Text as Text44, useInput as useInput9 } from "ink";
|
|
32315
32390
|
import { Fragment as Fragment16, jsx as jsx53, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
32316
32391
|
function Section({ title, rows }) {
|
|
@@ -32324,7 +32399,7 @@ function Section({ title, rows }) {
|
|
|
32324
32399
|
}
|
|
32325
32400
|
function HelpScreen({ onDone }) {
|
|
32326
32401
|
const [info, setInfo] = useState27();
|
|
32327
|
-
|
|
32402
|
+
useEffect22(() => {
|
|
32328
32403
|
startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
|
|
32329
32404
|
void readHelpInfo().then(setInfo);
|
|
32330
32405
|
}, []);
|
|
@@ -32473,7 +32548,7 @@ var init_config_store = __esm({
|
|
|
32473
32548
|
});
|
|
32474
32549
|
|
|
32475
32550
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
32476
|
-
import { useEffect as
|
|
32551
|
+
import { useEffect as useEffect23, useState as useState29 } from "react";
|
|
32477
32552
|
import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
|
|
32478
32553
|
import TextInput4 from "ink-text-input";
|
|
32479
32554
|
import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
@@ -32495,7 +32570,7 @@ function ConfigurationScreen({ onDone }) {
|
|
|
32495
32570
|
const [lastSaved, setLastSaved] = useState29(null);
|
|
32496
32571
|
const [editing, setEditing] = useState29(false);
|
|
32497
32572
|
const [valueBeforeEdit, setValueBeforeEdit] = useState29("");
|
|
32498
|
-
|
|
32573
|
+
useEffect23(() => {
|
|
32499
32574
|
readCredentials().then((cfg) => {
|
|
32500
32575
|
setConfig(cfg);
|
|
32501
32576
|
setStage("form");
|
|
@@ -32679,13 +32754,13 @@ var init_analytics_store = __esm({
|
|
|
32679
32754
|
});
|
|
32680
32755
|
|
|
32681
32756
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
32682
|
-
import { useEffect as
|
|
32757
|
+
import { useEffect as useEffect24, useState as useState30 } from "react";
|
|
32683
32758
|
import { Box as Box45, Text as Text47, useInput as useInput12 } from "ink";
|
|
32684
32759
|
import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
32685
32760
|
function OptInAnalyticsScreen({ onDone }) {
|
|
32686
32761
|
const [loading, setLoading] = useState30(true);
|
|
32687
32762
|
const [enabled, setEnabled] = useState30(true);
|
|
32688
|
-
|
|
32763
|
+
useEffect24(() => {
|
|
32689
32764
|
readAnalyticsSetting().then((setting) => {
|
|
32690
32765
|
setEnabled(setting.enabled);
|
|
32691
32766
|
setLoading(false);
|
|
@@ -32748,12 +32823,12 @@ var init_screen11 = __esm({
|
|
|
32748
32823
|
});
|
|
32749
32824
|
|
|
32750
32825
|
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
32751
|
-
import { useEffect as
|
|
32826
|
+
import { useEffect as useEffect25, useState as useState31 } from "react";
|
|
32752
32827
|
import { Box as Box46, Text as Text48, useInput as useInput13 } from "ink";
|
|
32753
32828
|
import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
32754
32829
|
function UpgradeScreen({ onDone }) {
|
|
32755
32830
|
const [upgradeCheck, setUpgradeCheck] = useState31();
|
|
32756
|
-
|
|
32831
|
+
useEffect25(() => {
|
|
32757
32832
|
startDebugRun({
|
|
32758
32833
|
flow: "upgrade",
|
|
32759
32834
|
step: "01-upgrade",
|
|
@@ -32828,13 +32903,13 @@ var init_PageContainer4 = __esm({
|
|
|
32828
32903
|
});
|
|
32829
32904
|
|
|
32830
32905
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
32831
|
-
import { useEffect as
|
|
32906
|
+
import { useEffect as useEffect26, useState as useState32 } from "react";
|
|
32832
32907
|
import { Box as Box47, Text as Text49, useInput as useInput14 } from "ink";
|
|
32833
32908
|
import { jsx as jsx58, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
32834
32909
|
function DebugModeScreen({ onDone }) {
|
|
32835
32910
|
const [loading, setLoading] = useState32(true);
|
|
32836
32911
|
const [enabled, setEnabled] = useState32(true);
|
|
32837
|
-
|
|
32912
|
+
useEffect26(() => {
|
|
32838
32913
|
readDebugModeSetting().then((setting) => {
|
|
32839
32914
|
setEnabled(setting.enabled);
|
|
32840
32915
|
setLoading(false);
|
|
@@ -32897,7 +32972,7 @@ __export(app_exports, {
|
|
|
32897
32972
|
runApp: () => runApp
|
|
32898
32973
|
});
|
|
32899
32974
|
import { join as join27 } from "node:path";
|
|
32900
|
-
import { useEffect as
|
|
32975
|
+
import { useEffect as useEffect27, useState as useState33 } from "react";
|
|
32901
32976
|
import { Fragment as Fragment19, jsx as jsx59 } from "react/jsx-runtime";
|
|
32902
32977
|
function App({ importOptions, inkClear }) {
|
|
32903
32978
|
const [screen, setScreen] = useState33("start");
|
|
@@ -32927,9 +33002,9 @@ function App({ importOptions, inkClear }) {
|
|
|
32927
33002
|
const [generationInput, setGenerationInput] = useState33();
|
|
32928
33003
|
const generation = useGeneration(generationInput);
|
|
32929
33004
|
const [flowStart, setFlowStart] = useState33();
|
|
32930
|
-
const flow = useFlow(flowStart
|
|
33005
|
+
const flow = useFlow(flowStart);
|
|
32931
33006
|
const [importDefaults, setImportDefaults] = useState33();
|
|
32932
|
-
|
|
33007
|
+
useEffect27(() => {
|
|
32933
33008
|
if (screen !== "import") {
|
|
32934
33009
|
setImportDefaults(void 0);
|
|
32935
33010
|
return;
|
|
@@ -32987,12 +33062,12 @@ function App({ importOptions, inkClear }) {
|
|
|
32987
33062
|
}
|
|
32988
33063
|
});
|
|
32989
33064
|
};
|
|
32990
|
-
|
|
33065
|
+
useEffect27(() => {
|
|
32991
33066
|
if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
|
|
32992
33067
|
setExtractionRun(void 0);
|
|
32993
33068
|
setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
|
|
32994
33069
|
}, [extraction, extractionRun]);
|
|
32995
|
-
|
|
33070
|
+
useEffect27(() => {
|
|
32996
33071
|
if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
|
|
32997
33072
|
const { extraction: produced, input, generatePromptPath } = scopeRun;
|
|
32998
33073
|
setGenerationInput({
|
|
@@ -33010,7 +33085,7 @@ function App({ importOptions, inkClear }) {
|
|
|
33010
33085
|
...generatePromptPath ? { generatePromptPath } : {}
|
|
33011
33086
|
});
|
|
33012
33087
|
}, [scopeFlow, scopeRun, generationInput]);
|
|
33013
|
-
|
|
33088
|
+
useEffect27(() => {
|
|
33014
33089
|
if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
|
|
33015
33090
|
const { credentialsSkipped, tokenStrategy, extraction: produced, input, generatePromptPath } = scopeRun;
|
|
33016
33091
|
inkClear();
|
|
@@ -33061,7 +33136,8 @@ function App({ importOptions, inkClear }) {
|
|
|
33061
33136
|
state: flow.state,
|
|
33062
33137
|
controller: flow.controller,
|
|
33063
33138
|
generatePromptPath: flowStart.generatePromptPath,
|
|
33064
|
-
onExit: setImportExitCode
|
|
33139
|
+
onExit: setImportExitCode,
|
|
33140
|
+
onStepChange: inkClear
|
|
33065
33141
|
}
|
|
33066
33142
|
);
|
|
33067
33143
|
}
|
|
@@ -33322,14 +33398,14 @@ function runDevWatch(args) {
|
|
|
33322
33398
|
process.stderr.write("--watch only works from a checkout of the repo (scripts/dev.mjs is not in the package).\n");
|
|
33323
33399
|
return Promise.resolve(1);
|
|
33324
33400
|
}
|
|
33325
|
-
return new Promise((
|
|
33401
|
+
return new Promise((resolve26) => {
|
|
33326
33402
|
const child = spawn2(process.execPath, [script, ...args], { stdio: "inherit" });
|
|
33327
33403
|
process.on("SIGINT", () => void 0);
|
|
33328
|
-
child.on("exit", (code) =>
|
|
33404
|
+
child.on("exit", (code) => resolve26(code ?? 0));
|
|
33329
33405
|
child.on("error", (err) => {
|
|
33330
33406
|
process.stderr.write(`${err.message}
|
|
33331
33407
|
`);
|
|
33332
|
-
|
|
33408
|
+
resolve26(1);
|
|
33333
33409
|
});
|
|
33334
33410
|
});
|
|
33335
33411
|
}
|
|
@@ -33373,7 +33449,7 @@ function createProgram() {
|
|
|
33373
33449
|
init_config();
|
|
33374
33450
|
init_package_root();
|
|
33375
33451
|
import { existsSync as existsSync12 } from "node:fs";
|
|
33376
|
-
import { mkdir as mkdir10, readFile as readFile19, rename as
|
|
33452
|
+
import { mkdir as mkdir10, readFile as readFile19, rename as rename4, rmdir, unlink } from "node:fs/promises";
|
|
33377
33453
|
import { dirname as dirname16, join as join29 } from "node:path";
|
|
33378
33454
|
var PACKAGE_NAME4 = "@contentful/experience-design-system-cli";
|
|
33379
33455
|
async function readJson(path5) {
|
|
@@ -33401,7 +33477,7 @@ async function migrateOldConfig() {
|
|
|
33401
33477
|
if (existsSync12(oldRuns)) {
|
|
33402
33478
|
if (!existsSync12(runsFilePath2())) {
|
|
33403
33479
|
await mkdir10(dirname16(runsFilePath2()), { recursive: true });
|
|
33404
|
-
await
|
|
33480
|
+
await rename4(oldRuns, runsFilePath2());
|
|
33405
33481
|
} else {
|
|
33406
33482
|
await unlink(oldRuns);
|
|
33407
33483
|
}
|