@contentful/experience-design-system-cli 2.37.1-dev-build-2ec208d2.0 → 2.37.1-dev-build-f22bf3b7.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.d.ts +1 -1
- package/dist/app.js +305 -239
- package/dist/index.js +274 -200
- package/dist/package.json +1 -1
- package/dist/src/tui/settings/configuration/agents/AgentDetail.d.ts +3 -1
- package/dist/src/tui/settings/configuration/agents/agent-debug.d.ts +25 -0
- package/dist/src/tui/settings/shared/debug-trail.d.ts +35 -0
- package/package.json +3 -3
- package/dist/src/tui/upgrade/PageContainer.d.ts +0 -4
- /package/dist/src/tui/{upgrade → home}/version.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -19738,7 +19738,7 @@ var init_home_theme = __esm({
|
|
|
19738
19738
|
}
|
|
19739
19739
|
});
|
|
19740
19740
|
|
|
19741
|
-
// packages/experience-design-system-cli/src/tui/
|
|
19741
|
+
// packages/experience-design-system-cli/src/tui/home/version.ts
|
|
19742
19742
|
import { readFileSync as readFileSync8 } from "node:fs";
|
|
19743
19743
|
import { join as join17 } from "node:path";
|
|
19744
19744
|
import semver from "semver";
|
|
@@ -19771,7 +19771,7 @@ async function checkForUpgrade() {
|
|
|
19771
19771
|
}
|
|
19772
19772
|
var PACKAGE_NAME2, TAGS_URL;
|
|
19773
19773
|
var init_version = __esm({
|
|
19774
|
-
"packages/experience-design-system-cli/src/tui/
|
|
19774
|
+
"packages/experience-design-system-cli/src/tui/home/version.ts"() {
|
|
19775
19775
|
"use strict";
|
|
19776
19776
|
init_package_root();
|
|
19777
19777
|
PACKAGE_NAME2 = "@contentful/experience-design-system-cli";
|
|
@@ -19825,14 +19825,11 @@ var init_control_hints = __esm({
|
|
|
19825
19825
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
19826
19826
|
import { Box, Text as Text2, useApp, useInput } from "ink";
|
|
19827
19827
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
19828
|
-
function
|
|
19828
|
+
function versionStatus(upgradeCheck) {
|
|
19829
19829
|
if (upgradeCheck?.status === "update-available") {
|
|
19830
|
-
return {
|
|
19830
|
+
return { text: ` (upgrade available v${upgradeCheck.latest})`, color: PALETTE.success };
|
|
19831
19831
|
}
|
|
19832
|
-
|
|
19833
|
-
return { label: "Upgrade Version (up to date)", color: PALETTE.muted };
|
|
19834
|
-
}
|
|
19835
|
-
return { label: "Upgrade Version" };
|
|
19832
|
+
return void 0;
|
|
19836
19833
|
}
|
|
19837
19834
|
function HomeScreen({ onNavigate }) {
|
|
19838
19835
|
const [focusIdx, setFocusIdx] = useState2(0);
|
|
@@ -19840,7 +19837,7 @@ function HomeScreen({ onNavigate }) {
|
|
|
19840
19837
|
const { exit } = useApp();
|
|
19841
19838
|
const terminalWidth = useTerminalWidth();
|
|
19842
19839
|
const tooNarrow = terminalWidth < MIN_TERMINAL_WIDTH;
|
|
19843
|
-
const
|
|
19840
|
+
const status = versionStatus(upgradeCheck);
|
|
19844
19841
|
useEffect2(() => {
|
|
19845
19842
|
checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
|
|
19846
19843
|
}, []);
|
|
@@ -19860,7 +19857,6 @@ function HomeScreen({ onNavigate }) {
|
|
|
19860
19857
|
}
|
|
19861
19858
|
if (key.return) {
|
|
19862
19859
|
const item = START_ITEMS[focusIdx];
|
|
19863
|
-
if (item.screen === "upgrade" && upgradeDisabled) return;
|
|
19864
19860
|
onNavigate(item.screen);
|
|
19865
19861
|
return;
|
|
19866
19862
|
}
|
|
@@ -19878,26 +19874,16 @@ function HomeScreen({ onNavigate }) {
|
|
|
19878
19874
|
/* @__PURE__ */ jsx2(Text2, { color: PALETTE.muted, children: SUBTITLE }),
|
|
19879
19875
|
/* @__PURE__ */ jsxs(Text2, { color: PALETTE.muted, children: [
|
|
19880
19876
|
"v",
|
|
19881
|
-
VERSION
|
|
19877
|
+
VERSION,
|
|
19878
|
+
status && /* @__PURE__ */ jsx2(Text2, { color: status.color, children: status.text })
|
|
19882
19879
|
] })
|
|
19883
19880
|
] }),
|
|
19884
19881
|
/* @__PURE__ */ jsx2(Box, { marginTop: 1, justifyContent: "center", children: /* @__PURE__ */ jsx2(Box, { flexDirection: "column", children: START_ITEMS.map((item, i) => {
|
|
19885
19882
|
const focused = i === focusIdx;
|
|
19886
|
-
|
|
19887
|
-
|
|
19888
|
-
const dimmed = isUpgradeItem && upgradeDisabled;
|
|
19889
|
-
return /* @__PURE__ */ jsxs(
|
|
19890
|
-
Text2,
|
|
19891
|
-
{
|
|
19892
|
-
bold: focused && !dimmed,
|
|
19893
|
-
color: dimmed ? PALETTE.muted : focused ? PALETTE.accent : display.color,
|
|
19894
|
-
children: [
|
|
19895
|
-
focused ? `${FOCUS_MARKER} ` : " ",
|
|
19896
|
-
display.label
|
|
19897
|
-
]
|
|
19898
|
-
},
|
|
19883
|
+
return /* @__PURE__ */ jsxs(Text2, { bold: focused, color: focused ? PALETTE.accent : void 0, children: [
|
|
19884
|
+
focused ? `${FOCUS_MARKER} ` : " ",
|
|
19899
19885
|
item.label
|
|
19900
|
-
);
|
|
19886
|
+
] }, item.label);
|
|
19901
19887
|
}) }) }),
|
|
19902
19888
|
/* @__PURE__ */ jsx2(Box, { marginTop: 1, justifyContent: "center", children: /* @__PURE__ */ jsx2(
|
|
19903
19889
|
ControlHints,
|
|
@@ -19926,7 +19912,6 @@ var init_home = __esm({
|
|
|
19926
19912
|
MIN_TERMINAL_WIDTH = 164;
|
|
19927
19913
|
START_ITEMS = [
|
|
19928
19914
|
{ label: "Import", screen: "import" },
|
|
19929
|
-
{ label: "Upgrade Version", screen: "upgrade" },
|
|
19930
19915
|
{ label: "Settings", screen: "settings" },
|
|
19931
19916
|
{ label: "Help", screen: "help" }
|
|
19932
19917
|
];
|
|
@@ -33099,6 +33084,45 @@ var init_PageContainer3 = __esm({
|
|
|
33099
33084
|
}
|
|
33100
33085
|
});
|
|
33101
33086
|
|
|
33087
|
+
// packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts
|
|
33088
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
33089
|
+
function diffSnapshots(before, after) {
|
|
33090
|
+
const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
|
|
33091
|
+
const changed_fields = names.filter((name) => before[name] !== after[name]);
|
|
33092
|
+
return { changed: changed_fields.length > 0, changed_fields };
|
|
33093
|
+
}
|
|
33094
|
+
function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
|
|
33095
|
+
const actions = [];
|
|
33096
|
+
return {
|
|
33097
|
+
record(action) {
|
|
33098
|
+
actions.push(action);
|
|
33099
|
+
if (actions.length > limit) actions.shift();
|
|
33100
|
+
},
|
|
33101
|
+
entries: () => [...actions]
|
|
33102
|
+
};
|
|
33103
|
+
}
|
|
33104
|
+
function scrubError(error, secrets) {
|
|
33105
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
33106
|
+
for (const secret of secrets) {
|
|
33107
|
+
if (secret.length < MIN_SECRET_LENGTH) continue;
|
|
33108
|
+
for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
|
|
33109
|
+
}
|
|
33110
|
+
return message;
|
|
33111
|
+
}
|
|
33112
|
+
function describeSettingsFile() {
|
|
33113
|
+
const path5 = configFilePath2();
|
|
33114
|
+
return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync11(path5) };
|
|
33115
|
+
}
|
|
33116
|
+
var DEFAULT_TRAIL_LIMIT, MIN_SECRET_LENGTH;
|
|
33117
|
+
var init_debug_trail = __esm({
|
|
33118
|
+
"packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts"() {
|
|
33119
|
+
"use strict";
|
|
33120
|
+
init_config();
|
|
33121
|
+
DEFAULT_TRAIL_LIMIT = 30;
|
|
33122
|
+
MIN_SECRET_LENGTH = 6;
|
|
33123
|
+
}
|
|
33124
|
+
});
|
|
33125
|
+
|
|
33102
33126
|
// packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts
|
|
33103
33127
|
import { execFile as execFile2 } from "node:child_process";
|
|
33104
33128
|
import { access as access6, constants } from "node:fs/promises";
|
|
@@ -33309,6 +33333,44 @@ var init_agent_status = __esm({
|
|
|
33309
33333
|
}
|
|
33310
33334
|
});
|
|
33311
33335
|
|
|
33336
|
+
// packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-debug.ts
|
|
33337
|
+
function agentSnapshot(config) {
|
|
33338
|
+
const snapshot = { default_agent: config.defaultAgent };
|
|
33339
|
+
for (const name of AGENT_NAMES) {
|
|
33340
|
+
snapshot[`${name}.model`] = config.agents[name].model;
|
|
33341
|
+
snapshot[`${name}.binary`] = config.agents[name].binary;
|
|
33342
|
+
}
|
|
33343
|
+
return snapshot;
|
|
33344
|
+
}
|
|
33345
|
+
function environmentFrom(checks, savedBinary, envValue) {
|
|
33346
|
+
const path5 = checks.find((check) => check.step === "path");
|
|
33347
|
+
const version = checks.find((check) => check.step === "version");
|
|
33348
|
+
const overridden = envValue !== void 0 && envValue !== "" && envValue !== savedBinary.trim();
|
|
33349
|
+
return {
|
|
33350
|
+
found: path5?.ok === true,
|
|
33351
|
+
resolved_path: path5?.ok ? path5.detail : "",
|
|
33352
|
+
version: version?.ok ? version.detail : "",
|
|
33353
|
+
env_override: overridden ? envValue : ""
|
|
33354
|
+
};
|
|
33355
|
+
}
|
|
33356
|
+
async function describeAgents(config) {
|
|
33357
|
+
const entries = await Promise.all(
|
|
33358
|
+
AGENT_NAMES.map(async (name) => {
|
|
33359
|
+
const saved = config.agents[name].binary;
|
|
33360
|
+
const checks = await inspectAgent(name, saved);
|
|
33361
|
+
return [name, environmentFrom(checks, saved, process.env[`EDS_AGENT_BINARY_${name.toUpperCase()}`])];
|
|
33362
|
+
})
|
|
33363
|
+
);
|
|
33364
|
+
return Object.fromEntries(entries);
|
|
33365
|
+
}
|
|
33366
|
+
var init_agent_debug = __esm({
|
|
33367
|
+
"packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-debug.ts"() {
|
|
33368
|
+
"use strict";
|
|
33369
|
+
init_src4();
|
|
33370
|
+
init_agent_status();
|
|
33371
|
+
}
|
|
33372
|
+
});
|
|
33373
|
+
|
|
33312
33374
|
// packages/experience-design-system-cli/src/tui/settings/shared/FieldForm.tsx
|
|
33313
33375
|
import { useState as useState29 } from "react";
|
|
33314
33376
|
import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
|
|
@@ -33500,7 +33562,8 @@ function AgentDetail({
|
|
|
33500
33562
|
name,
|
|
33501
33563
|
config,
|
|
33502
33564
|
setConfig,
|
|
33503
|
-
onBack
|
|
33565
|
+
onBack,
|
|
33566
|
+
record: record3
|
|
33504
33567
|
}) {
|
|
33505
33568
|
const settings = config.agents[name];
|
|
33506
33569
|
const [saving, setSaving] = useState30(false);
|
|
@@ -33523,10 +33586,12 @@ function AgentDetail({
|
|
|
33523
33586
|
setNotice(null);
|
|
33524
33587
|
writeAgentConfig(config).then(() => {
|
|
33525
33588
|
applyBinaryOverrides(config);
|
|
33589
|
+
record3(`saved ${name}`);
|
|
33526
33590
|
setNotice({ kind: "success", text: `Saved: ${AGENT_LABELS[name]} settings are written to config.json` });
|
|
33527
|
-
}).catch(
|
|
33528
|
-
(
|
|
33529
|
-
|
|
33591
|
+
}).catch((err) => {
|
|
33592
|
+
record3(`saving ${name} failed`, err);
|
|
33593
|
+
setNotice({ kind: "error", text: `Not saved: ${err instanceof Error ? err.message : String(err)}` });
|
|
33594
|
+
}).finally(() => setSaving(false));
|
|
33530
33595
|
};
|
|
33531
33596
|
const runTest = () => {
|
|
33532
33597
|
setTesting(true);
|
|
@@ -33534,12 +33599,15 @@ function AgentDetail({
|
|
|
33534
33599
|
testAgent(name, settings.binary, settings.model).then((result) => {
|
|
33535
33600
|
setChecks(result);
|
|
33536
33601
|
const outcome = testOutcome(result);
|
|
33602
|
+
if (!outcome || !outcome.ok)
|
|
33603
|
+
record3(`test of ${name} failed: ${outcome?.text ?? "the agent could not be started"}`);
|
|
33537
33604
|
setNotice(
|
|
33538
33605
|
outcome ? { kind: outcome.ok ? "success" : "error", text: outcome.text } : { kind: "error", text: "Test not run: the agent could not be started (see Status)" }
|
|
33539
33606
|
);
|
|
33540
|
-
}).catch(
|
|
33541
|
-
(
|
|
33542
|
-
|
|
33607
|
+
}).catch((err) => {
|
|
33608
|
+
record3(`test of ${name} could not run`, err);
|
|
33609
|
+
setNotice({ kind: "error", text: `Test could not run: ${err instanceof Error ? err.message : String(err)}` });
|
|
33610
|
+
}).finally(() => setTesting(false));
|
|
33543
33611
|
};
|
|
33544
33612
|
const action = {
|
|
33545
33613
|
label: "Run test",
|
|
@@ -33560,6 +33628,7 @@ function AgentDetail({
|
|
|
33560
33628
|
onChange: (key, value) => {
|
|
33561
33629
|
setConfig({ ...config, agents: { ...config.agents, [name]: { ...settings, [key]: value } } });
|
|
33562
33630
|
setNotice(null);
|
|
33631
|
+
record3(`edited ${name}.${key}`);
|
|
33563
33632
|
},
|
|
33564
33633
|
onSave: save,
|
|
33565
33634
|
onQuit: onBack,
|
|
@@ -33593,7 +33662,7 @@ var init_AgentDetail = __esm({
|
|
|
33593
33662
|
});
|
|
33594
33663
|
|
|
33595
33664
|
// packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx
|
|
33596
|
-
import { useEffect as useEffect23, useState as useState31 } from "react";
|
|
33665
|
+
import { useEffect as useEffect23, useRef as useRef13, useState as useState31 } from "react";
|
|
33597
33666
|
import { Box as Box46, Text as Text49, useInput as useInput12 } from "ink";
|
|
33598
33667
|
import { Fragment as Fragment18, jsx as jsx58, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
33599
33668
|
function AgentsScreen({ onDone }) {
|
|
@@ -33604,6 +33673,12 @@ function AgentsScreen({ onDone }) {
|
|
|
33604
33673
|
const [saving, setSaving] = useState31(false);
|
|
33605
33674
|
const [loadError, setLoadError] = useState31(null);
|
|
33606
33675
|
const [checks, setChecks] = useState31({});
|
|
33676
|
+
const visit = useRef13({
|
|
33677
|
+
trail: createTrail(),
|
|
33678
|
+
before: void 0,
|
|
33679
|
+
environment: void 0,
|
|
33680
|
+
error: ""
|
|
33681
|
+
}).current;
|
|
33607
33682
|
const inspectAll = (loaded) => {
|
|
33608
33683
|
for (const name of AGENT_NAMES) {
|
|
33609
33684
|
void inspectAgent(name, loaded.agents[name].binary).then(
|
|
@@ -33615,14 +33690,38 @@ function AgentsScreen({ onDone }) {
|
|
|
33615
33690
|
readAgentConfig().then((loaded) => {
|
|
33616
33691
|
setConfig(loaded);
|
|
33617
33692
|
inspectAll(loaded);
|
|
33693
|
+
visit.before = agentSnapshot(loaded);
|
|
33618
33694
|
startDebugRun({
|
|
33619
33695
|
flow: "settings/agents",
|
|
33620
33696
|
step: "01-agents",
|
|
33621
33697
|
menuOption: "Configuration > Agents",
|
|
33622
|
-
inputs: {
|
|
33698
|
+
inputs: { ...visit.before, default_chosen: loaded.defaultChosen ?? false }
|
|
33623
33699
|
});
|
|
33624
|
-
|
|
33700
|
+
void describeAgents(loaded).then((found) => {
|
|
33701
|
+
visit.environment = found;
|
|
33702
|
+
});
|
|
33703
|
+
}).catch((err) => {
|
|
33704
|
+
visit.error = scrubError(err, []);
|
|
33705
|
+
startDebugRun({ flow: "settings/agents", step: "01-agents", menuOption: "Configuration > Agents", inputs: {} });
|
|
33706
|
+
setLoadError(visit.error);
|
|
33707
|
+
});
|
|
33625
33708
|
}, []);
|
|
33709
|
+
const endVisit = (current) => {
|
|
33710
|
+
const after = current ? agentSnapshot(current) : void 0;
|
|
33711
|
+
const change = visit.before && after ? diffSnapshots(visit.before, after) : { changed: false, changed_fields: [] };
|
|
33712
|
+
void finishDebugRun({
|
|
33713
|
+
outputs: {
|
|
33714
|
+
...after ?? {},
|
|
33715
|
+
...change,
|
|
33716
|
+
actions: visit.trail.entries(),
|
|
33717
|
+
// Missing only when the user left before the probes finished.
|
|
33718
|
+
...visit.environment ? { agents: visit.environment } : {},
|
|
33719
|
+
...visit.error ? { error: visit.error } : {}
|
|
33720
|
+
},
|
|
33721
|
+
status: visit.error ? "error" : "success",
|
|
33722
|
+
exitMethod: change.changed ? "saved" : "discarded"
|
|
33723
|
+
});
|
|
33724
|
+
};
|
|
33626
33725
|
const makeDefault = (name) => {
|
|
33627
33726
|
if (!config || saving) return;
|
|
33628
33727
|
if (name === config.defaultAgent) {
|
|
@@ -33634,15 +33733,16 @@ function AgentsScreen({ onDone }) {
|
|
|
33634
33733
|
writeAgentConfig({ ...config, defaultAgent: name, defaultChosen: true }).then(() => {
|
|
33635
33734
|
setConfig((current) => current ? { ...current, defaultAgent: name, defaultChosen: true } : current);
|
|
33636
33735
|
setNotice({ kind: "success", text: `Default agent is now ${AGENT_LABELS[name]}` });
|
|
33637
|
-
|
|
33638
|
-
|
|
33639
|
-
|
|
33640
|
-
|
|
33641
|
-
})
|
|
33642
|
-
).finally(() => setSaving(false));
|
|
33736
|
+
visit.trail.record(`made ${name} the default`);
|
|
33737
|
+
}).catch((err) => {
|
|
33738
|
+
visit.error = scrubError(err, []);
|
|
33739
|
+
visit.trail.record(`making ${name} the default failed`);
|
|
33740
|
+
setNotice({ kind: "error", text: `Default agent not changed: ${visit.error}` });
|
|
33741
|
+
}).finally(() => setSaving(false));
|
|
33643
33742
|
};
|
|
33644
33743
|
useInput12((input, key) => {
|
|
33645
33744
|
if (loadError && (key.escape || input === "q")) {
|
|
33745
|
+
endVisit(null);
|
|
33646
33746
|
onDone();
|
|
33647
33747
|
return;
|
|
33648
33748
|
}
|
|
@@ -33667,7 +33767,7 @@ function AgentsScreen({ onDone }) {
|
|
|
33667
33767
|
return;
|
|
33668
33768
|
}
|
|
33669
33769
|
if (key.escape || input === "q") {
|
|
33670
|
-
|
|
33770
|
+
endVisit(config);
|
|
33671
33771
|
onDone();
|
|
33672
33772
|
}
|
|
33673
33773
|
});
|
|
@@ -33692,6 +33792,10 @@ function AgentsScreen({ onDone }) {
|
|
|
33692
33792
|
name: open,
|
|
33693
33793
|
config,
|
|
33694
33794
|
setConfig,
|
|
33795
|
+
record: (action, error) => {
|
|
33796
|
+
visit.trail.record(action);
|
|
33797
|
+
if (error !== void 0) visit.error = scrubError(error, []);
|
|
33798
|
+
},
|
|
33695
33799
|
onBack: () => {
|
|
33696
33800
|
setOpen(null);
|
|
33697
33801
|
void readAgentConfig().then((saved) => {
|
|
@@ -33764,6 +33868,8 @@ var init_AgentsScreen = __esm({
|
|
|
33764
33868
|
init_theme();
|
|
33765
33869
|
init_control_hints();
|
|
33766
33870
|
init_debug_store();
|
|
33871
|
+
init_debug_trail();
|
|
33872
|
+
init_agent_debug();
|
|
33767
33873
|
init_agent_store();
|
|
33768
33874
|
init_agent_status();
|
|
33769
33875
|
init_AgentDetail();
|
|
@@ -33805,9 +33911,9 @@ var init_project_store = __esm({
|
|
|
33805
33911
|
});
|
|
33806
33912
|
|
|
33807
33913
|
// packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
|
|
33808
|
-
import { useEffect as useEffect24, useState as useState32 } from "react";
|
|
33809
|
-
import { Box as Box47, Text as Text50 } from "ink";
|
|
33810
|
-
import { jsx as jsx59, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
33914
|
+
import { useEffect as useEffect24, useRef as useRef14, useState as useState32 } from "react";
|
|
33915
|
+
import { Box as Box47, Text as Text50, useInput as useInput13 } from "ink";
|
|
33916
|
+
import { Fragment as Fragment19, jsx as jsx59, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
33811
33917
|
function debugFields(config) {
|
|
33812
33918
|
return {
|
|
33813
33919
|
space_id: config?.spaceId ?? "",
|
|
@@ -33823,40 +33929,88 @@ function ProjectScreen({ onDone }) {
|
|
|
33823
33929
|
const [config, setConfig] = useState32(null);
|
|
33824
33930
|
const [saving, setSaving] = useState32(false);
|
|
33825
33931
|
const [notice, setNotice] = useState32(null);
|
|
33826
|
-
const [
|
|
33932
|
+
const [loadError, setLoadError] = useState32(null);
|
|
33933
|
+
const visit = useRef14({
|
|
33934
|
+
trail: createTrail(),
|
|
33935
|
+
before: void 0,
|
|
33936
|
+
persisted: void 0,
|
|
33937
|
+
error: ""
|
|
33938
|
+
}).current;
|
|
33939
|
+
const scrub = (err) => scrubError(err, [config?.cmaToken ?? ""]);
|
|
33827
33940
|
useEffect24(() => {
|
|
33828
|
-
|
|
33941
|
+
readCredentials().then((cfg) => {
|
|
33829
33942
|
setConfig(cfg);
|
|
33943
|
+
visit.before = snapshotOf(cfg);
|
|
33944
|
+
visit.persisted = visit.before;
|
|
33830
33945
|
startDebugRun({
|
|
33831
33946
|
flow: "settings/contentful-configuration",
|
|
33832
33947
|
step: "01-configuration",
|
|
33833
33948
|
menuOption: "Configuration > Project",
|
|
33834
|
-
inputs: debugFields(cfg)
|
|
33949
|
+
inputs: { ...debugFields(cfg), settings_file: describeSettingsFile() }
|
|
33835
33950
|
});
|
|
33951
|
+
}).catch((err) => {
|
|
33952
|
+
visit.error = scrubError(err, []);
|
|
33953
|
+
startDebugRun({
|
|
33954
|
+
flow: "settings/contentful-configuration",
|
|
33955
|
+
step: "01-configuration",
|
|
33956
|
+
menuOption: "Configuration > Project",
|
|
33957
|
+
inputs: { settings_file: describeSettingsFile() }
|
|
33958
|
+
});
|
|
33959
|
+
setLoadError(visit.error);
|
|
33836
33960
|
});
|
|
33837
33961
|
}, []);
|
|
33962
|
+
const endVisit = (current) => {
|
|
33963
|
+
const onScreen = current ? snapshotOf(current) : void 0;
|
|
33964
|
+
const change = visit.before && visit.persisted ? diffSnapshots(visit.before, visit.persisted) : { changed: false, changed_fields: [] };
|
|
33965
|
+
const unsaved = visit.persisted && onScreen ? diffSnapshots(visit.persisted, onScreen) : { changed: false, changed_fields: [] };
|
|
33966
|
+
void finishDebugRun({
|
|
33967
|
+
outputs: {
|
|
33968
|
+
...debugFields(current),
|
|
33969
|
+
...change,
|
|
33970
|
+
unsaved_edits: unsaved.changed_fields,
|
|
33971
|
+
actions: visit.trail.entries(),
|
|
33972
|
+
...visit.error ? { error: visit.error } : {}
|
|
33973
|
+
},
|
|
33974
|
+
status: visit.error ? "error" : "success",
|
|
33975
|
+
exitMethod: change.changed ? "saved" : "discarded"
|
|
33976
|
+
});
|
|
33977
|
+
};
|
|
33978
|
+
useInput13((input, key) => {
|
|
33979
|
+
if (!config && loadError && (key.escape || input === "q")) {
|
|
33980
|
+
endVisit(null);
|
|
33981
|
+
onDone();
|
|
33982
|
+
}
|
|
33983
|
+
});
|
|
33838
33984
|
if (!config) {
|
|
33839
33985
|
return /* @__PURE__ */ jsxs48(Box47, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
33840
33986
|
/* @__PURE__ */ jsx59(Text50, { bold: true, children: "Project" }),
|
|
33841
33987
|
/* @__PURE__ */ jsx59(Text50, { children: " " }),
|
|
33842
|
-
/* @__PURE__ */
|
|
33988
|
+
loadError ? /* @__PURE__ */ jsxs48(Fragment19, { children: [
|
|
33989
|
+
/* @__PURE__ */ jsxs48(Text50, { color: PALETTE.error, children: [
|
|
33990
|
+
"\u2717 Could not read the settings: ",
|
|
33991
|
+
loadError
|
|
33992
|
+
] }),
|
|
33993
|
+
/* @__PURE__ */ jsx59(Text50, { children: " " }),
|
|
33994
|
+
/* @__PURE__ */ jsx59(ControlHints, { hints: [{ keys: "Esc/q", label: "back" }] })
|
|
33995
|
+
] }) : /* @__PURE__ */ jsx59(Text50, { color: PALETTE.accent, children: "Loading..." })
|
|
33843
33996
|
] });
|
|
33844
33997
|
}
|
|
33845
33998
|
const save = () => {
|
|
33846
33999
|
setSaving(true);
|
|
33847
34000
|
setNotice(null);
|
|
33848
34001
|
writeCredentials(config).then(() => {
|
|
33849
|
-
|
|
34002
|
+
visit.persisted = snapshotOf(config);
|
|
34003
|
+
visit.trail.record("saved");
|
|
33850
34004
|
if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
|
|
33851
34005
|
setNotice({ kind: "success", text: "Project settings saved" });
|
|
33852
34006
|
}).catch((err) => {
|
|
34007
|
+
visit.error = scrub(err);
|
|
34008
|
+
visit.trail.record("save failed");
|
|
33853
34009
|
setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
|
|
33854
34010
|
}).finally(() => setSaving(false));
|
|
33855
34011
|
};
|
|
33856
34012
|
const quit = () => {
|
|
33857
|
-
|
|
33858
|
-
lastSaved ? { outputs: debugFields(lastSaved), status: "success", exitMethod: "saved" } : { outputs: {}, status: "success", exitMethod: "discarded" }
|
|
33859
|
-
);
|
|
34013
|
+
endVisit(config);
|
|
33860
34014
|
onDone();
|
|
33861
34015
|
};
|
|
33862
34016
|
return /* @__PURE__ */ jsx59(
|
|
@@ -33869,6 +34023,7 @@ function ProjectScreen({ onDone }) {
|
|
|
33869
34023
|
onChange: (key, value) => {
|
|
33870
34024
|
setConfig({ ...config, [key]: value });
|
|
33871
34025
|
setNotice(null);
|
|
34026
|
+
visit.trail.record(`edited ${key}`);
|
|
33872
34027
|
},
|
|
33873
34028
|
onSave: save,
|
|
33874
34029
|
onQuit: quit,
|
|
@@ -33877,12 +34032,14 @@ function ProjectScreen({ onDone }) {
|
|
|
33877
34032
|
}
|
|
33878
34033
|
);
|
|
33879
34034
|
}
|
|
33880
|
-
var FIELDS2, valuesOf;
|
|
34035
|
+
var FIELDS2, snapshotOf, valuesOf;
|
|
33881
34036
|
var init_ProjectScreen = __esm({
|
|
33882
34037
|
"packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx"() {
|
|
33883
34038
|
"use strict";
|
|
33884
34039
|
init_theme();
|
|
34040
|
+
init_control_hints();
|
|
33885
34041
|
init_debug_store();
|
|
34042
|
+
init_debug_trail();
|
|
33886
34043
|
init_FieldForm();
|
|
33887
34044
|
init_project_store();
|
|
33888
34045
|
FIELDS2 = [
|
|
@@ -33894,19 +34051,20 @@ var init_ProjectScreen = __esm({
|
|
|
33894
34051
|
{ key: "defaultTokenFile", label: "Default token file" },
|
|
33895
34052
|
{ key: "contentfulBaseDir", label: "Root Project Directory", hint: "(where .contentful goes)" }
|
|
33896
34053
|
];
|
|
34054
|
+
snapshotOf = (config) => Object.fromEntries(FIELDS2.map(({ key }) => [key, config[key] || ""]));
|
|
33897
34055
|
valuesOf = (config) => Object.fromEntries(FIELDS2.map(({ key }) => [key, config[key] || ""]));
|
|
33898
34056
|
}
|
|
33899
34057
|
});
|
|
33900
34058
|
|
|
33901
34059
|
// packages/experience-design-system-cli/src/tui/settings/configuration/ConfigurationScreen.tsx
|
|
33902
34060
|
import { useState as useState33 } from "react";
|
|
33903
|
-
import { Box as Box48, Text as Text51, useInput as
|
|
34061
|
+
import { Box as Box48, Text as Text51, useInput as useInput14 } from "ink";
|
|
33904
34062
|
import { jsx as jsx60, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
33905
34063
|
function ConfigurationScreen({ onDone }) {
|
|
33906
34064
|
const [focus, setFocus] = useState33(0);
|
|
33907
34065
|
const [open, setOpen] = useState33(null);
|
|
33908
34066
|
const close = () => setOpen(null);
|
|
33909
|
-
|
|
34067
|
+
useInput14((input, key) => {
|
|
33910
34068
|
if (open) return;
|
|
33911
34069
|
if (key.upArrow) {
|
|
33912
34070
|
setFocus((i) => (i - 1 + SECTIONS.length) % SECTIONS.length);
|
|
@@ -33966,8 +34124,8 @@ var init_ConfigurationScreen = __esm({
|
|
|
33966
34124
|
|
|
33967
34125
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
33968
34126
|
import { useEffect as useEffect25, useState as useState34 } from "react";
|
|
33969
|
-
import { Box as Box49, Text as Text52, useInput as
|
|
33970
|
-
import { Fragment as
|
|
34127
|
+
import { Box as Box49, Text as Text52, useInput as useInput15 } from "ink";
|
|
34128
|
+
import { Fragment as Fragment20, jsx as jsx61, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
33971
34129
|
function OptInAnalyticsScreen({ onDone }) {
|
|
33972
34130
|
const [loading, setLoading] = useState34(true);
|
|
33973
34131
|
const [enabled, setEnabled] = useState34(true);
|
|
@@ -33983,7 +34141,7 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
33983
34141
|
});
|
|
33984
34142
|
});
|
|
33985
34143
|
}, []);
|
|
33986
|
-
|
|
34144
|
+
useInput15((input, key) => {
|
|
33987
34145
|
if (loading) return;
|
|
33988
34146
|
if (key.return || input === " ") {
|
|
33989
34147
|
setEnabled((current) => {
|
|
@@ -34001,7 +34159,7 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
34001
34159
|
return /* @__PURE__ */ jsxs50(Box49, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
34002
34160
|
/* @__PURE__ */ jsx61(Text52, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
|
|
34003
34161
|
/* @__PURE__ */ jsx61(Text52, { children: " " }),
|
|
34004
|
-
loading ? /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs50(
|
|
34162
|
+
loading ? /* @__PURE__ */ jsx61(Text52, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs50(Fragment20, { children: [
|
|
34005
34163
|
/* @__PURE__ */ jsxs50(Text52, { children: [
|
|
34006
34164
|
"Share anonymous usage data:",
|
|
34007
34165
|
" ",
|
|
@@ -34033,95 +34191,14 @@ var init_screen11 = __esm({
|
|
|
34033
34191
|
}
|
|
34034
34192
|
});
|
|
34035
34193
|
|
|
34036
|
-
// packages/experience-design-system-cli/src/tui/
|
|
34194
|
+
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
34037
34195
|
import { useEffect as useEffect26, useState as useState35 } from "react";
|
|
34038
|
-
import { Box as Box50, Text as Text53, useInput as
|
|
34196
|
+
import { Box as Box50, Text as Text53, useInput as useInput16 } from "ink";
|
|
34039
34197
|
import { jsx as jsx62, jsxs as jsxs51 } from "react/jsx-runtime";
|
|
34040
|
-
function UpgradeScreen({ onDone }) {
|
|
34041
|
-
const [upgradeCheck, setUpgradeCheck] = useState35();
|
|
34042
|
-
useEffect26(() => {
|
|
34043
|
-
startDebugRun({
|
|
34044
|
-
flow: "upgrade",
|
|
34045
|
-
step: "01-upgrade",
|
|
34046
|
-
menuOption: "Upgrade",
|
|
34047
|
-
inputs: { currentVersion: readPackageVersion() }
|
|
34048
|
-
});
|
|
34049
|
-
checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
|
|
34050
|
-
}, []);
|
|
34051
|
-
useInput15((_input, key) => {
|
|
34052
|
-
if (key.return) {
|
|
34053
|
-
void finishDebugRun({
|
|
34054
|
-
outputs: upgradeCheck ?? {},
|
|
34055
|
-
status: upgradeCheck?.status === "error" ? "error" : "success",
|
|
34056
|
-
exitMethod: "saved"
|
|
34057
|
-
});
|
|
34058
|
-
onDone();
|
|
34059
|
-
return;
|
|
34060
|
-
}
|
|
34061
|
-
});
|
|
34062
|
-
return /* @__PURE__ */ jsxs51(Box50, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
34063
|
-
/* @__PURE__ */ jsx62(Text53, { bold: true, children: "Upgrade" }),
|
|
34064
|
-
/* @__PURE__ */ jsx62(Text53, { children: " " }),
|
|
34065
|
-
renderBody(upgradeCheck),
|
|
34066
|
-
/* @__PURE__ */ jsx62(Text53, { children: " " }),
|
|
34067
|
-
/* @__PURE__ */ jsxs51(Text53, { bold: true, color: PALETTE.accent, children: [
|
|
34068
|
-
FOCUS_MARKER,
|
|
34069
|
-
" Go Back"
|
|
34070
|
-
] })
|
|
34071
|
-
] });
|
|
34072
|
-
}
|
|
34073
|
-
function renderBody(upgradeCheck) {
|
|
34074
|
-
if (!upgradeCheck) {
|
|
34075
|
-
return /* @__PURE__ */ jsx62(Text53, { color: PALETTE.muted, children: "Checking for updates\u2026" });
|
|
34076
|
-
}
|
|
34077
|
-
if (upgradeCheck.status === "error") {
|
|
34078
|
-
return /* @__PURE__ */ jsx62(Text53, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
|
|
34079
|
-
}
|
|
34080
|
-
if (upgradeCheck.status === "up-to-date") {
|
|
34081
|
-
return /* @__PURE__ */ jsxs51(Text53, { color: PALETTE.success, children: [
|
|
34082
|
-
"You're already on the latest version (v",
|
|
34083
|
-
upgradeCheck.current,
|
|
34084
|
-
")."
|
|
34085
|
-
] });
|
|
34086
|
-
}
|
|
34087
|
-
return /* @__PURE__ */ jsxs51(Box50, { flexDirection: "column", children: [
|
|
34088
|
-
/* @__PURE__ */ jsxs51(Text53, { color: PALETTE.muted, children: [
|
|
34089
|
-
/* @__PURE__ */ jsxs51(Text53, { bold: true, color: PALETTE.success, children: [
|
|
34090
|
-
"v",
|
|
34091
|
-
upgradeCheck.latest
|
|
34092
|
-
] }),
|
|
34093
|
-
" ",
|
|
34094
|
-
"is available (you're on ",
|
|
34095
|
-
/* @__PURE__ */ jsxs51(Text53, { bold: true, children: [
|
|
34096
|
-
"v",
|
|
34097
|
-
upgradeCheck.current
|
|
34098
|
-
] }),
|
|
34099
|
-
"). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
|
|
34100
|
-
] }),
|
|
34101
|
-
/* @__PURE__ */ jsx62(Text53, { children: " " }),
|
|
34102
|
-
/* @__PURE__ */ jsx62(Box50, { flexDirection: "column", borderStyle: "round", borderColor: PALETTE.border, paddingX: 1, children: UPGRADE_COMMANDS.map((cmd) => /* @__PURE__ */ jsx62(Text53, { bold: true, children: cmd }, cmd)) })
|
|
34103
|
-
] });
|
|
34104
|
-
}
|
|
34105
|
-
var UPGRADE_COMMANDS;
|
|
34106
|
-
var init_PageContainer4 = __esm({
|
|
34107
|
-
"packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx"() {
|
|
34108
|
-
"use strict";
|
|
34109
|
-
init_theme();
|
|
34110
|
-
init_home_theme();
|
|
34111
|
-
init_version();
|
|
34112
|
-
init_debug_store();
|
|
34113
|
-
UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
|
|
34114
|
-
}
|
|
34115
|
-
});
|
|
34116
|
-
|
|
34117
|
-
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
34118
|
-
import { useEffect as useEffect27, useState as useState36 } from "react";
|
|
34119
|
-
import { Box as Box51, Text as Text54, useInput as useInput16 } from "ink";
|
|
34120
|
-
import { jsx as jsx63, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
34121
34198
|
function DebugModeScreen({ onDone }) {
|
|
34122
|
-
const [loading, setLoading] =
|
|
34123
|
-
const [enabled, setEnabled] =
|
|
34124
|
-
|
|
34199
|
+
const [loading, setLoading] = useState35(true);
|
|
34200
|
+
const [enabled, setEnabled] = useState35(true);
|
|
34201
|
+
useEffect26(() => {
|
|
34125
34202
|
readDebugModeSetting().then((setting) => {
|
|
34126
34203
|
setEnabled(setting.enabled);
|
|
34127
34204
|
setLoading(false);
|
|
@@ -34148,16 +34225,16 @@ function DebugModeScreen({ onDone }) {
|
|
|
34148
34225
|
onDone();
|
|
34149
34226
|
}
|
|
34150
34227
|
});
|
|
34151
|
-
return /* @__PURE__ */
|
|
34152
|
-
/* @__PURE__ */
|
|
34153
|
-
/* @__PURE__ */
|
|
34154
|
-
loading ? /* @__PURE__ */
|
|
34228
|
+
return /* @__PURE__ */ jsxs51(Box50, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
34229
|
+
/* @__PURE__ */ jsx62(Text53, { bold: true, children: "Settings \u203A Debug Mode" }),
|
|
34230
|
+
/* @__PURE__ */ jsx62(Text53, { children: " " }),
|
|
34231
|
+
loading ? /* @__PURE__ */ jsx62(Text53, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs51(Text53, { children: [
|
|
34155
34232
|
"Debug logging:",
|
|
34156
34233
|
" ",
|
|
34157
|
-
/* @__PURE__ */
|
|
34234
|
+
/* @__PURE__ */ jsx62(Text53, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
34158
34235
|
] }),
|
|
34159
|
-
/* @__PURE__ */
|
|
34160
|
-
/* @__PURE__ */
|
|
34236
|
+
/* @__PURE__ */ jsx62(Text53, { children: " " }),
|
|
34237
|
+
/* @__PURE__ */ jsx62(
|
|
34161
34238
|
ControlHints,
|
|
34162
34239
|
{
|
|
34163
34240
|
hints: [
|
|
@@ -34184,19 +34261,19 @@ __export(app_exports, {
|
|
|
34184
34261
|
runApp: () => runApp
|
|
34185
34262
|
});
|
|
34186
34263
|
import { join as join27 } from "node:path";
|
|
34187
|
-
import { useEffect as
|
|
34188
|
-
import { Fragment as
|
|
34264
|
+
import { useEffect as useEffect27, useState as useState36 } from "react";
|
|
34265
|
+
import { Fragment as Fragment21, jsx as jsx63 } from "react/jsx-runtime";
|
|
34189
34266
|
function App({ importOptions, inkClear }) {
|
|
34190
|
-
const [screen, setScreen] =
|
|
34191
|
-
const [importExitCode, setImportExitCode] =
|
|
34267
|
+
const [screen, setScreen] = useState36("start");
|
|
34268
|
+
const [importExitCode, setImportExitCode] = useState36();
|
|
34192
34269
|
const showImportResult = importExitCode !== void 0;
|
|
34193
|
-
const [projectPath, setProjectPath] =
|
|
34194
|
-
const [tokensPath, setTokensPath] =
|
|
34195
|
-
const [scannedFiles, setScannedFiles] =
|
|
34196
|
-
const [pendingLaunch, setPendingLaunch] =
|
|
34197
|
-
const [extractionRun, setExtractionRun] =
|
|
34270
|
+
const [projectPath, setProjectPath] = useState36();
|
|
34271
|
+
const [tokensPath, setTokensPath] = useState36();
|
|
34272
|
+
const [scannedFiles, setScannedFiles] = useState36();
|
|
34273
|
+
const [pendingLaunch, setPendingLaunch] = useState36();
|
|
34274
|
+
const [extractionRun, setExtractionRun] = useState36();
|
|
34198
34275
|
const extraction = useExtraction(extractionRun?.input);
|
|
34199
|
-
const [scopeRun, setScopeRun] =
|
|
34276
|
+
const [scopeRun, setScopeRun] = useState36();
|
|
34200
34277
|
const scopeFlow = useScopeGateFlow(
|
|
34201
34278
|
scopeRun && {
|
|
34202
34279
|
sessionId: scopeRun.extraction.sessionId,
|
|
@@ -34211,12 +34288,12 @@ function App({ importOptions, inkClear }) {
|
|
|
34211
34288
|
}
|
|
34212
34289
|
}
|
|
34213
34290
|
);
|
|
34214
|
-
const [generationInput, setGenerationInput] =
|
|
34291
|
+
const [generationInput, setGenerationInput] = useState36();
|
|
34215
34292
|
const generation = useGeneration(generationInput);
|
|
34216
|
-
const [flowStart, setFlowStart] =
|
|
34293
|
+
const [flowStart, setFlowStart] = useState36();
|
|
34217
34294
|
const flow = useFlow(flowStart, { beforeStepChange: inkClear });
|
|
34218
|
-
const [importDefaults, setImportDefaults] =
|
|
34219
|
-
|
|
34295
|
+
const [importDefaults, setImportDefaults] = useState36();
|
|
34296
|
+
useEffect27(() => {
|
|
34220
34297
|
if (screen !== "import") {
|
|
34221
34298
|
setImportDefaults(void 0);
|
|
34222
34299
|
return;
|
|
@@ -34276,12 +34353,12 @@ function App({ importOptions, inkClear }) {
|
|
|
34276
34353
|
}
|
|
34277
34354
|
});
|
|
34278
34355
|
};
|
|
34279
|
-
|
|
34356
|
+
useEffect27(() => {
|
|
34280
34357
|
if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
|
|
34281
34358
|
setExtractionRun(void 0);
|
|
34282
34359
|
setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
|
|
34283
34360
|
}, [extraction, extractionRun]);
|
|
34284
|
-
|
|
34361
|
+
useEffect27(() => {
|
|
34285
34362
|
if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
|
|
34286
34363
|
const { extraction: produced, input, generatePromptPath } = scopeRun;
|
|
34287
34364
|
setGenerationInput({
|
|
@@ -34299,7 +34376,7 @@ function App({ importOptions, inkClear }) {
|
|
|
34299
34376
|
...generatePromptPath ? { generatePromptPath } : {}
|
|
34300
34377
|
});
|
|
34301
34378
|
}, [scopeFlow, scopeRun, generationInput]);
|
|
34302
|
-
|
|
34379
|
+
useEffect27(() => {
|
|
34303
34380
|
if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
|
|
34304
34381
|
const { credentialsSkipped, tokenStrategy, extraction: produced, input, generatePromptPath } = scopeRun;
|
|
34305
34382
|
inkClear();
|
|
@@ -34342,9 +34419,9 @@ function App({ importOptions, inkClear }) {
|
|
|
34342
34419
|
};
|
|
34343
34420
|
switch (screen) {
|
|
34344
34421
|
case "import":
|
|
34345
|
-
if (showImportResult) return /* @__PURE__ */
|
|
34422
|
+
if (showImportResult) return /* @__PURE__ */ jsx63(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
|
|
34346
34423
|
if (flow && flowStart) {
|
|
34347
|
-
return /* @__PURE__ */
|
|
34424
|
+
return /* @__PURE__ */ jsx63(
|
|
34348
34425
|
FlowScreen,
|
|
34349
34426
|
{
|
|
34350
34427
|
state: flow.state,
|
|
@@ -34354,12 +34431,12 @@ function App({ importOptions, inkClear }) {
|
|
|
34354
34431
|
}
|
|
34355
34432
|
);
|
|
34356
34433
|
}
|
|
34357
|
-
if (importDefaults === void 0) return /* @__PURE__ */
|
|
34434
|
+
if (importDefaults === void 0) return /* @__PURE__ */ jsx63(Fragment21, {});
|
|
34358
34435
|
if (projectPath === void 0) {
|
|
34359
|
-
return /* @__PURE__ */
|
|
34436
|
+
return /* @__PURE__ */ jsx63(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
|
|
34360
34437
|
}
|
|
34361
34438
|
if (tokensPath === void 0) {
|
|
34362
|
-
return /* @__PURE__ */
|
|
34439
|
+
return /* @__PURE__ */ jsx63(
|
|
34363
34440
|
TokenInputScreen,
|
|
34364
34441
|
{
|
|
34365
34442
|
initialPath: importDefaults.tokenFile,
|
|
@@ -34369,7 +34446,7 @@ function App({ importOptions, inkClear }) {
|
|
|
34369
34446
|
);
|
|
34370
34447
|
}
|
|
34371
34448
|
if (scannedFiles === void 0) {
|
|
34372
|
-
return /* @__PURE__ */
|
|
34449
|
+
return /* @__PURE__ */ jsx63(
|
|
34373
34450
|
PathValidationScreen,
|
|
34374
34451
|
{
|
|
34375
34452
|
projectPath,
|
|
@@ -34381,10 +34458,10 @@ function App({ importOptions, inkClear }) {
|
|
|
34381
34458
|
}
|
|
34382
34459
|
if (extractionRun) {
|
|
34383
34460
|
if (extraction?.status === "done" && !extraction.result.ok) {
|
|
34384
|
-
return /* @__PURE__ */
|
|
34461
|
+
return /* @__PURE__ */ jsx63(ErrorStep, { stepName: extraction.result.step, message: extraction.result.message, onExit: leaveImport });
|
|
34385
34462
|
}
|
|
34386
34463
|
if (extraction?.status === "running") {
|
|
34387
|
-
return /* @__PURE__ */
|
|
34464
|
+
return /* @__PURE__ */ jsx63(
|
|
34388
34465
|
ExtractionScreen,
|
|
34389
34466
|
{
|
|
34390
34467
|
progress: extraction.progress,
|
|
@@ -34393,14 +34470,14 @@ function App({ importOptions, inkClear }) {
|
|
|
34393
34470
|
}
|
|
34394
34471
|
);
|
|
34395
34472
|
}
|
|
34396
|
-
return /* @__PURE__ */
|
|
34473
|
+
return /* @__PURE__ */ jsx63(Fragment21, {});
|
|
34397
34474
|
}
|
|
34398
34475
|
if (scopeRun && scopeFlow) {
|
|
34399
34476
|
if (scopeFlow.status === "failed") {
|
|
34400
|
-
return /* @__PURE__ */
|
|
34477
|
+
return /* @__PURE__ */ jsx63(ErrorStep, { stepName: "scope gate", message: scopeFlow.message, onExit: leaveImport });
|
|
34401
34478
|
}
|
|
34402
34479
|
if (scopeFlow.status === "deciding") {
|
|
34403
|
-
return /* @__PURE__ */
|
|
34480
|
+
return /* @__PURE__ */ jsx63(
|
|
34404
34481
|
ScopeGateScreen,
|
|
34405
34482
|
{
|
|
34406
34483
|
components: scopeFlow.load.components,
|
|
@@ -34410,7 +34487,7 @@ function App({ importOptions, inkClear }) {
|
|
|
34410
34487
|
);
|
|
34411
34488
|
}
|
|
34412
34489
|
if (generation?.status === "done" && !generation.result.ok) {
|
|
34413
|
-
return /* @__PURE__ */
|
|
34490
|
+
return /* @__PURE__ */ jsx63(ErrorStep, { stepName: generation.result.step, message: generation.result.message, onExit: leaveImport });
|
|
34414
34491
|
}
|
|
34415
34492
|
if (generation?.status === "running") {
|
|
34416
34493
|
const hasRawTokens = scopeRun.input.rawTokensPath !== "";
|
|
@@ -34418,7 +34495,7 @@ function App({ importOptions, inkClear }) {
|
|
|
34418
34495
|
hasRawTokens,
|
|
34419
34496
|
mapTokensEligible: generation.progress.mapTokensEligible
|
|
34420
34497
|
});
|
|
34421
|
-
return /* @__PURE__ */
|
|
34498
|
+
return /* @__PURE__ */ jsx63(
|
|
34422
34499
|
GenerationScreen,
|
|
34423
34500
|
{
|
|
34424
34501
|
progress: generation.progress,
|
|
@@ -34430,10 +34507,10 @@ function App({ importOptions, inkClear }) {
|
|
|
34430
34507
|
}
|
|
34431
34508
|
);
|
|
34432
34509
|
}
|
|
34433
|
-
return /* @__PURE__ */
|
|
34510
|
+
return /* @__PURE__ */ jsx63(Fragment21, {});
|
|
34434
34511
|
}
|
|
34435
34512
|
if (pendingLaunch?.cached) {
|
|
34436
|
-
return /* @__PURE__ */
|
|
34513
|
+
return /* @__PURE__ */ jsx63(
|
|
34437
34514
|
TokenReuseScreen,
|
|
34438
34515
|
{
|
|
34439
34516
|
tokensPath: pendingLaunch.cached.tokensPath,
|
|
@@ -34444,7 +34521,7 @@ function App({ importOptions, inkClear }) {
|
|
|
34444
34521
|
}
|
|
34445
34522
|
);
|
|
34446
34523
|
}
|
|
34447
|
-
return /* @__PURE__ */
|
|
34524
|
+
return /* @__PURE__ */ jsx63(
|
|
34448
34525
|
CredentialsScreen,
|
|
34449
34526
|
{
|
|
34450
34527
|
initial: importDefaults.credentials,
|
|
@@ -34453,19 +34530,17 @@ function App({ importOptions, inkClear }) {
|
|
|
34453
34530
|
}
|
|
34454
34531
|
);
|
|
34455
34532
|
case "help":
|
|
34456
|
-
return /* @__PURE__ */
|
|
34457
|
-
case "upgrade":
|
|
34458
|
-
return /* @__PURE__ */ jsx64(UpgradeScreen, { onDone: goToStart });
|
|
34533
|
+
return /* @__PURE__ */ jsx63(HelpScreen, { onDone: goToStart });
|
|
34459
34534
|
case "settings":
|
|
34460
|
-
return /* @__PURE__ */
|
|
34535
|
+
return /* @__PURE__ */ jsx63(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
|
|
34461
34536
|
case "settings-configuration":
|
|
34462
|
-
return /* @__PURE__ */
|
|
34537
|
+
return /* @__PURE__ */ jsx63(ConfigurationScreen, { onDone: goToSettings });
|
|
34463
34538
|
case "settings-opt-in-analytics":
|
|
34464
|
-
return /* @__PURE__ */
|
|
34539
|
+
return /* @__PURE__ */ jsx63(OptInAnalyticsScreen, { onDone: goToSettings });
|
|
34465
34540
|
case "settings-debug-mode":
|
|
34466
|
-
return /* @__PURE__ */
|
|
34541
|
+
return /* @__PURE__ */ jsx63(DebugModeScreen, { onDone: goToSettings });
|
|
34467
34542
|
case "start":
|
|
34468
|
-
return /* @__PURE__ */
|
|
34543
|
+
return /* @__PURE__ */ jsx63(HomeScreen, { onNavigate: setScreen });
|
|
34469
34544
|
}
|
|
34470
34545
|
}
|
|
34471
34546
|
async function runApp(renderApp, importOptions) {
|
|
@@ -34473,7 +34548,7 @@ async function runApp(renderApp, importOptions) {
|
|
|
34473
34548
|
instance.clear?.();
|
|
34474
34549
|
process.stdout.write("\x1B[H\x1B[0J");
|
|
34475
34550
|
};
|
|
34476
|
-
const instance = renderApp(/* @__PURE__ */
|
|
34551
|
+
const instance = renderApp(/* @__PURE__ */ jsx63(App, { importOptions, inkClear }));
|
|
34477
34552
|
await instance.waitUntilExit();
|
|
34478
34553
|
}
|
|
34479
34554
|
var init_app = __esm({
|
|
@@ -34499,7 +34574,6 @@ var init_app = __esm({
|
|
|
34499
34574
|
init_PageContainer3();
|
|
34500
34575
|
init_ConfigurationScreen();
|
|
34501
34576
|
init_screen11();
|
|
34502
|
-
init_PageContainer4();
|
|
34503
34577
|
init_screen12();
|
|
34504
34578
|
init_project_store();
|
|
34505
34579
|
}
|
|
@@ -34613,7 +34687,7 @@ function createProgram() {
|
|
|
34613
34687
|
// packages/experience-design-system-cli/src/config/migrate.ts
|
|
34614
34688
|
init_config();
|
|
34615
34689
|
init_package_root();
|
|
34616
|
-
import { existsSync as
|
|
34690
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
34617
34691
|
import { mkdir as mkdir10, readFile as readFile19, rename as rename3, rmdir, unlink } from "node:fs/promises";
|
|
34618
34692
|
import { dirname as dirname16, join as join29 } from "node:path";
|
|
34619
34693
|
var PACKAGE_NAME3 = "@contentful/experience-design-system-cli";
|
|
@@ -34639,8 +34713,8 @@ async function migrateOldConfig() {
|
|
|
34639
34713
|
if (debugMode) migrated["debugMode"] = debugMode;
|
|
34640
34714
|
Object.assign(migrated, await readJson(oldCredentials));
|
|
34641
34715
|
if (Object.keys(migrated).length > 0) await updateSettings2({ ...migrated, ...await readSettings2() });
|
|
34642
|
-
if (
|
|
34643
|
-
if (!
|
|
34716
|
+
if (existsSync12(oldRuns)) {
|
|
34717
|
+
if (!existsSync12(runsFilePath2())) {
|
|
34644
34718
|
await mkdir10(dirname16(runsFilePath2()), { recursive: true });
|
|
34645
34719
|
await rename3(oldRuns, runsFilePath2());
|
|
34646
34720
|
} else {
|