@contentful/experience-design-system-cli 2.37.1-dev-build-b65632a0.0 → 2.37.1-dev-build-200af99b.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 +370 -136
- package/dist/index.js +401 -140
- package/dist/package.json +2 -1
- package/dist/src/tui/import/spawn-v1-import.d.ts +1 -0
- package/dist/src/tui/import/steps/04-credentials/controls.d.ts +21 -0
- package/dist/src/tui/import/steps/04-credentials/logic.d.ts +18 -0
- package/dist/src/tui/import/steps/04-credentials/screen.d.ts +17 -0
- package/dist/src/tui/import/steps/04-credentials/validate.d.ts +8 -0
- package/dist/src/tui/import/steps/index.d.ts +1 -0
- package/legacy/dist/src/index.js +973 -1375
- package/legacy/package.json +2 -1
- package/package.json +3 -2
- package/legacy/dist/src/import/tui/steps/CredentialsStep.d.ts +0 -43
package/dist/index.js
CHANGED
|
@@ -841,6 +841,245 @@ var init_screen3 = __esm({
|
|
|
841
841
|
}
|
|
842
842
|
});
|
|
843
843
|
|
|
844
|
+
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts
|
|
845
|
+
function keyAction2(input, key) {
|
|
846
|
+
if (key.escape) return "back";
|
|
847
|
+
if (key.tab) return "next-field";
|
|
848
|
+
if (key.ctrl && input === "s") return "skip";
|
|
849
|
+
return null;
|
|
850
|
+
}
|
|
851
|
+
function nextField(field) {
|
|
852
|
+
return FIELDS[(FIELDS.indexOf(field) + 1) % FIELDS.length];
|
|
853
|
+
}
|
|
854
|
+
function toConfiguredHost(host) {
|
|
855
|
+
const value = (host ?? "").trim().replace(/\/+$/, "");
|
|
856
|
+
return value === "" ? DEFAULT_HOST : value.replace(/^https:\/\//i, "");
|
|
857
|
+
}
|
|
858
|
+
function toApiHost(host) {
|
|
859
|
+
const value = host.trim().replace(/\/+$/, "");
|
|
860
|
+
if (value === "") return `https://${DEFAULT_HOST}`;
|
|
861
|
+
return /^[a-z][a-z\d+\-.]*:\/\//i.test(value) ? value : `https://${value}`;
|
|
862
|
+
}
|
|
863
|
+
function normalize(values) {
|
|
864
|
+
return {
|
|
865
|
+
spaceId: values.spaceId.trim(),
|
|
866
|
+
environmentId: values.environmentId.trim(),
|
|
867
|
+
cmaToken: values.cmaToken.trim(),
|
|
868
|
+
host: toConfiguredHost(values.host)
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
function missingField(values) {
|
|
872
|
+
return values.spaceId === "" || values.environmentId === "" || values.cmaToken === "";
|
|
873
|
+
}
|
|
874
|
+
function isUnchanged(current, initial) {
|
|
875
|
+
return FIELDS.every((field) => current[field] === initial[field]);
|
|
876
|
+
}
|
|
877
|
+
var FIELDS, DEFAULT_HOST;
|
|
878
|
+
var init_logic4 = __esm({
|
|
879
|
+
"packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts"() {
|
|
880
|
+
"use strict";
|
|
881
|
+
FIELDS = ["spaceId", "environmentId", "cmaToken", "host"];
|
|
882
|
+
DEFAULT_HOST = "api.contentful.com";
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/controls.ts
|
|
887
|
+
import { useInput as useInput6 } from "ink";
|
|
888
|
+
function useCredentialsControls(handlers) {
|
|
889
|
+
useInput6((input, key) => {
|
|
890
|
+
if (handlers.disabled) return;
|
|
891
|
+
const action = keyAction2(input, key);
|
|
892
|
+
if (action === "back") handlers.onBack();
|
|
893
|
+
else if (action === "next-field") handlers.onNextField();
|
|
894
|
+
else if (action === "skip") handlers.onSkip();
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
var CREDENTIALS_CONTROLS;
|
|
898
|
+
var init_controls4 = __esm({
|
|
899
|
+
"packages/experience-design-system-cli/src/tui/import/steps/04-credentials/controls.ts"() {
|
|
900
|
+
"use strict";
|
|
901
|
+
init_logic4();
|
|
902
|
+
CREDENTIALS_CONTROLS = [
|
|
903
|
+
{ keys: "Enter", label: "Next field / Continue" },
|
|
904
|
+
{ keys: "Tab", label: "Switch field" },
|
|
905
|
+
{ keys: "Ctrl+S", label: "Skip (no push)" },
|
|
906
|
+
{ keys: "Esc", label: "Back" }
|
|
907
|
+
];
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
|
|
911
|
+
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/validate.ts
|
|
912
|
+
function headers(token) {
|
|
913
|
+
return { Authorization: `Bearer ${token}`, "X-Contentful-User-Agent": USER_AGENT };
|
|
914
|
+
}
|
|
915
|
+
function isApsDenial(body) {
|
|
916
|
+
try {
|
|
917
|
+
const id = JSON.parse(body).sys?.id;
|
|
918
|
+
return id === "NotFound" || id === "AccessDenied";
|
|
919
|
+
} catch {
|
|
920
|
+
return false;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
function messageFrom(body) {
|
|
924
|
+
try {
|
|
925
|
+
const message = JSON.parse(body).message;
|
|
926
|
+
return typeof message === "string" && message !== "" ? message : void 0;
|
|
927
|
+
} catch {
|
|
928
|
+
return void 0;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
async function validateCredentials(values) {
|
|
932
|
+
const base = toApiHost(values.host);
|
|
933
|
+
let me;
|
|
934
|
+
try {
|
|
935
|
+
me = await fetch(`${base}/users/me`, { headers: headers(values.cmaToken) });
|
|
936
|
+
} catch (error) {
|
|
937
|
+
return { ok: false, error: `Could not reach ${base}: ${error instanceof Error ? error.message : String(error)}` };
|
|
938
|
+
}
|
|
939
|
+
if (me.status === 401) return { ok: false, error: "CMA token is invalid or revoked." };
|
|
940
|
+
if (!me.ok) return { ok: false, error: `Unexpected error validating the token (${me.status}).` };
|
|
941
|
+
let preflight;
|
|
942
|
+
try {
|
|
943
|
+
preflight = await fetch(
|
|
944
|
+
`${base}/spaces/${values.spaceId}/environments/${values.environmentId}/design_systems/preflight`,
|
|
945
|
+
{ headers: headers(values.cmaToken) }
|
|
946
|
+
);
|
|
947
|
+
} catch {
|
|
948
|
+
return { ok: true };
|
|
949
|
+
}
|
|
950
|
+
if (preflight.ok || preflight.status >= 500) return { ok: true };
|
|
951
|
+
const body = await preflight.text();
|
|
952
|
+
if (preflight.status === 404 && !isApsDenial(body)) return { ok: true };
|
|
953
|
+
const detail = messageFrom(body);
|
|
954
|
+
if (preflight.status === 403) {
|
|
955
|
+
return { ok: false, error: `Access denied. ${detail ?? "Your token cannot write design system components here."}` };
|
|
956
|
+
}
|
|
957
|
+
if (preflight.status === 404) {
|
|
958
|
+
return {
|
|
959
|
+
ok: false,
|
|
960
|
+
error: `Not found. Check the space ID, environment and API host.${detail ? ` (${detail})` : ""}`
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
return { ok: false, error: `Credential check failed (${preflight.status}).${detail ? ` ${detail}` : ""}` };
|
|
964
|
+
}
|
|
965
|
+
var USER_AGENT;
|
|
966
|
+
var init_validate = __esm({
|
|
967
|
+
"packages/experience-design-system-cli/src/tui/import/steps/04-credentials/validate.ts"() {
|
|
968
|
+
"use strict";
|
|
969
|
+
init_logic4();
|
|
970
|
+
USER_AGENT = "app contentful.experience-design-system-cli";
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
|
|
974
|
+
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx
|
|
975
|
+
import { useRef, useState as useState6 } from "react";
|
|
976
|
+
import { Box as Box6, Text as Text7 } from "ink";
|
|
977
|
+
import TextInput3 from "ink-text-input";
|
|
978
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
979
|
+
function CredentialsScreen({
|
|
980
|
+
onDone,
|
|
981
|
+
onBack,
|
|
982
|
+
initial = {},
|
|
983
|
+
validate = validateCredentials
|
|
984
|
+
}) {
|
|
985
|
+
const initialValues = useRef(
|
|
986
|
+
normalize({
|
|
987
|
+
spaceId: initial.spaceId ?? "",
|
|
988
|
+
environmentId: initial.environmentId || "master",
|
|
989
|
+
cmaToken: initial.cmaToken ?? "",
|
|
990
|
+
host: initial.host ?? ""
|
|
991
|
+
})
|
|
992
|
+
).current;
|
|
993
|
+
const [values, setValues] = useState6(initialValues);
|
|
994
|
+
const [active, setActive] = useState6("spaceId");
|
|
995
|
+
const [error, setError] = useState6(null);
|
|
996
|
+
const [validating, setValidating] = useState6(false);
|
|
997
|
+
const prefilled = initialValues.spaceId !== "" && initialValues.cmaToken !== "";
|
|
998
|
+
useCredentialsControls({
|
|
999
|
+
disabled: validating,
|
|
1000
|
+
onBack,
|
|
1001
|
+
onNextField: () => setActive(nextField),
|
|
1002
|
+
onSkip: () => onDone({ skipped: true })
|
|
1003
|
+
});
|
|
1004
|
+
const change = (field) => (value) => {
|
|
1005
|
+
setValues((current) => ({ ...current, [field]: value }));
|
|
1006
|
+
setError(null);
|
|
1007
|
+
};
|
|
1008
|
+
const submit = async (field) => {
|
|
1009
|
+
if (field !== "host") {
|
|
1010
|
+
setActive(nextField(field));
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
const credentials = normalize(values);
|
|
1014
|
+
if (missingField(credentials)) {
|
|
1015
|
+
setError("Space ID, environment and CMA token are all required.");
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
setValidating(true);
|
|
1019
|
+
const result = await validate(credentials);
|
|
1020
|
+
setValidating(false);
|
|
1021
|
+
if (result.ok) onDone({ skipped: false, credentials });
|
|
1022
|
+
else setError(result.error);
|
|
1023
|
+
};
|
|
1024
|
+
return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", gap: 1, paddingX: 2, paddingY: 1, children: [
|
|
1025
|
+
/* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
|
|
1026
|
+
/* @__PURE__ */ jsx7(Text7, { bold: true, children: "Contentful credentials" }),
|
|
1027
|
+
/* @__PURE__ */ jsx7(Text7, { children: prefilled ? "Credentials pre-filled from the configuration settings." : "Enter the Contentful space you want to import into." }),
|
|
1028
|
+
!prefilled && /* @__PURE__ */ jsxs6(Fragment, { children: [
|
|
1029
|
+
/* @__PURE__ */ jsx7(Text7, { dimColor: true, children: "We use it to check what components already exist and to push your import. If you skip, files are saved locally and nothing is pushed." }),
|
|
1030
|
+
/* @__PURE__ */ jsx7(Text7, { dimColor: true, children: "Tip: save these under Settings \u2192 Configuration so they pre-fill here." })
|
|
1031
|
+
] })
|
|
1032
|
+
] }),
|
|
1033
|
+
/* @__PURE__ */ jsx7(Box6, { flexDirection: "column", children: FIELDS.map((field) => /* @__PURE__ */ jsxs6(Box6, { gap: 1, children: [
|
|
1034
|
+
/* @__PURE__ */ jsx7(Text7, { color: active === field ? PALETTE.accent : void 0, children: "?" }),
|
|
1035
|
+
/* @__PURE__ */ jsxs6(Text7, { bold: active === field, children: [
|
|
1036
|
+
LABELS[field],
|
|
1037
|
+
":"
|
|
1038
|
+
] }),
|
|
1039
|
+
/* @__PURE__ */ jsx7(
|
|
1040
|
+
TextInput3,
|
|
1041
|
+
{
|
|
1042
|
+
value: values[field],
|
|
1043
|
+
focus: active === field && !validating,
|
|
1044
|
+
mask: field === "cmaToken" ? "\u2022" : void 0,
|
|
1045
|
+
placeholder: field === "host" ? DEFAULT_HOST : void 0,
|
|
1046
|
+
onChange: change(field),
|
|
1047
|
+
onSubmit: () => void submit(field)
|
|
1048
|
+
}
|
|
1049
|
+
)
|
|
1050
|
+
] }, field)) }),
|
|
1051
|
+
active === "host" && /* @__PURE__ */ jsx7(Text7, { dimColor: true, children: "Default: api.contentful.com \xB7 EU spaces: api.eu.contentful.com" }),
|
|
1052
|
+
error && /* @__PURE__ */ jsxs6(Text7, { color: PALETTE.error, children: [
|
|
1053
|
+
"\u2717 ",
|
|
1054
|
+
error
|
|
1055
|
+
] }),
|
|
1056
|
+
validating && /* @__PURE__ */ jsx7(Text7, { color: PALETTE.accent, children: "Validating credentials..." }),
|
|
1057
|
+
!validating && !error && !isUnchanged(normalize(values), initialValues) && /* @__PURE__ */ jsx7(Text7, { dimColor: true, children: "Changed values are saved after they validate." }),
|
|
1058
|
+
/* @__PURE__ */ jsx7(Box6, { marginTop: 1, gap: 3, children: CREDENTIALS_CONTROLS.map((control) => /* @__PURE__ */ jsxs6(Text7, { dimColor: true, children: [
|
|
1059
|
+
"[",
|
|
1060
|
+
control.keys,
|
|
1061
|
+
"] ",
|
|
1062
|
+
control.label
|
|
1063
|
+
] }, control.keys)) })
|
|
1064
|
+
] });
|
|
1065
|
+
}
|
|
1066
|
+
var LABELS;
|
|
1067
|
+
var init_screen4 = __esm({
|
|
1068
|
+
"packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx"() {
|
|
1069
|
+
"use strict";
|
|
1070
|
+
init_home_theme();
|
|
1071
|
+
init_controls4();
|
|
1072
|
+
init_logic4();
|
|
1073
|
+
init_validate();
|
|
1074
|
+
LABELS = {
|
|
1075
|
+
spaceId: "Space ID",
|
|
1076
|
+
environmentId: "Environment",
|
|
1077
|
+
cmaToken: "CMA Token",
|
|
1078
|
+
host: "API Host"
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
});
|
|
1082
|
+
|
|
844
1083
|
// packages/experience-design-system-cli/src/tui/import/steps/index.ts
|
|
845
1084
|
var init_steps = __esm({
|
|
846
1085
|
"packages/experience-design-system-cli/src/tui/import/steps/index.ts"() {
|
|
@@ -848,6 +1087,7 @@ var init_steps = __esm({
|
|
|
848
1087
|
init_screen();
|
|
849
1088
|
init_screen2();
|
|
850
1089
|
init_screen3();
|
|
1090
|
+
init_screen4();
|
|
851
1091
|
}
|
|
852
1092
|
});
|
|
853
1093
|
|
|
@@ -868,7 +1108,8 @@ async function spawnV1Import(options = {}) {
|
|
|
868
1108
|
const args = buildArgs(options);
|
|
869
1109
|
return new Promise((resolvePromise) => {
|
|
870
1110
|
const child = spawn3("node", [cliPath, ...args], {
|
|
871
|
-
stdio: "inherit"
|
|
1111
|
+
stdio: "inherit",
|
|
1112
|
+
env: options.skipCredentials ? { ...process.env, EDS_IMPORT_SKIP_CREDENTIALS: "1" } : process.env
|
|
872
1113
|
});
|
|
873
1114
|
child.on("close", (code) => {
|
|
874
1115
|
resolvePromise({ exitCode: code ?? 1, result: void 0, stdout: "", stderr: "" });
|
|
@@ -1146,20 +1387,20 @@ var init_help_info = __esm({
|
|
|
1146
1387
|
});
|
|
1147
1388
|
|
|
1148
1389
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
1149
|
-
import { useEffect as useEffect4, useState as
|
|
1150
|
-
import { Box as
|
|
1151
|
-
import { Fragment, jsx as
|
|
1390
|
+
import { useEffect as useEffect4, useState as useState7 } from "react";
|
|
1391
|
+
import { Box as Box7, Text as Text8, useInput as useInput7 } from "ink";
|
|
1392
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1152
1393
|
function Section({ title, rows }) {
|
|
1153
|
-
return /* @__PURE__ */
|
|
1154
|
-
/* @__PURE__ */
|
|
1155
|
-
rows.map((row) => /* @__PURE__ */
|
|
1156
|
-
/* @__PURE__ */
|
|
1157
|
-
/* @__PURE__ */
|
|
1394
|
+
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", children: [
|
|
1395
|
+
/* @__PURE__ */ jsx8(Text8, { bold: true, color: PALETTE.accent, children: title }),
|
|
1396
|
+
rows.map((row) => /* @__PURE__ */ jsxs7(Box7, { gap: 1, children: [
|
|
1397
|
+
/* @__PURE__ */ jsx8(Box7, { width: 14, flexShrink: 0, children: /* @__PURE__ */ jsx8(Text8, { color: PALETTE.muted, children: row.label }) }),
|
|
1398
|
+
/* @__PURE__ */ jsx8(Text8, { children: row.value })
|
|
1158
1399
|
] }, row.label))
|
|
1159
1400
|
] });
|
|
1160
1401
|
}
|
|
1161
1402
|
function HelpScreen({ onDone }) {
|
|
1162
|
-
const [info, setInfo] =
|
|
1403
|
+
const [info, setInfo] = useState7();
|
|
1163
1404
|
useEffect4(() => {
|
|
1164
1405
|
startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
|
|
1165
1406
|
void readHelpInfo().then(setInfo);
|
|
@@ -1168,7 +1409,7 @@ function HelpScreen({ onDone }) {
|
|
|
1168
1409
|
void finishDebugRun({ outputs: {}, status: "success", exitMethod });
|
|
1169
1410
|
onDone();
|
|
1170
1411
|
};
|
|
1171
|
-
|
|
1412
|
+
useInput7((input, key) => {
|
|
1172
1413
|
if (key.return) {
|
|
1173
1414
|
leave("saved");
|
|
1174
1415
|
return;
|
|
@@ -1178,14 +1419,14 @@ function HelpScreen({ onDone }) {
|
|
|
1178
1419
|
return;
|
|
1179
1420
|
}
|
|
1180
1421
|
});
|
|
1181
|
-
return /* @__PURE__ */
|
|
1182
|
-
/* @__PURE__ */
|
|
1183
|
-
info ? /* @__PURE__ */
|
|
1184
|
-
/* @__PURE__ */
|
|
1185
|
-
/* @__PURE__ */
|
|
1186
|
-
/* @__PURE__ */
|
|
1187
|
-
] }) : /* @__PURE__ */
|
|
1188
|
-
/* @__PURE__ */
|
|
1422
|
+
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 2, paddingY: 1, gap: 1, children: [
|
|
1423
|
+
/* @__PURE__ */ jsx8(Text8, { bold: true, children: "Help" }),
|
|
1424
|
+
info ? /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
1425
|
+
/* @__PURE__ */ jsx8(Section, { title: "Where things are stored", rows: info.storage }),
|
|
1426
|
+
/* @__PURE__ */ jsx8(Section, { title: "Troubleshooting", rows: info.troubleshooting }),
|
|
1427
|
+
/* @__PURE__ */ jsx8(Text8, { color: PALETTE.muted, children: "Hit a problem? Turn on Debug Mode in Settings, reproduce it, then share the session folder above. The CMA token is redacted from those logs." })
|
|
1428
|
+
] }) : /* @__PURE__ */ jsx8(Text8, { color: PALETTE.accent, children: "Loading..." }),
|
|
1429
|
+
/* @__PURE__ */ jsx8(
|
|
1189
1430
|
ControlHints,
|
|
1190
1431
|
{
|
|
1191
1432
|
hints: [
|
|
@@ -1207,20 +1448,20 @@ var init_PageContainer2 = __esm({
|
|
|
1207
1448
|
});
|
|
1208
1449
|
|
|
1209
1450
|
// packages/experience-design-system-cli/src/tui/settings/PageContainer.tsx
|
|
1210
|
-
import { useState as
|
|
1211
|
-
import { Box as
|
|
1212
|
-
import { jsx as
|
|
1451
|
+
import { useState as useState8 } from "react";
|
|
1452
|
+
import { Box as Box8, Text as Text9, useInput as useInput8 } from "ink";
|
|
1453
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1213
1454
|
function SettingsScreen({
|
|
1214
1455
|
onNavigate,
|
|
1215
1456
|
onBack
|
|
1216
1457
|
}) {
|
|
1217
|
-
const [focusIdx, setFocusIdx] =
|
|
1458
|
+
const [focusIdx, setFocusIdx] = useState8(0);
|
|
1218
1459
|
const items = [
|
|
1219
1460
|
{ label: "Configuration", screen: "settings-configuration" },
|
|
1220
1461
|
{ label: "Opt-in Analytics", screen: "settings-opt-in-analytics" },
|
|
1221
1462
|
{ label: "Debug Mode", screen: "settings-debug-mode" }
|
|
1222
1463
|
];
|
|
1223
|
-
|
|
1464
|
+
useInput8((input, key) => {
|
|
1224
1465
|
if (key.upArrow) {
|
|
1225
1466
|
setFocusIdx((i) => (i - 1 + items.length) % items.length);
|
|
1226
1467
|
return;
|
|
@@ -1240,15 +1481,15 @@ function SettingsScreen({
|
|
|
1240
1481
|
onBack();
|
|
1241
1482
|
}
|
|
1242
1483
|
});
|
|
1243
|
-
return /* @__PURE__ */
|
|
1244
|
-
/* @__PURE__ */
|
|
1245
|
-
/* @__PURE__ */
|
|
1246
|
-
items.map((item, i) => /* @__PURE__ */
|
|
1484
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1485
|
+
/* @__PURE__ */ jsx9(Text9, { bold: true, children: "Settings" }),
|
|
1486
|
+
/* @__PURE__ */ jsx9(Text9, { children: " " }),
|
|
1487
|
+
items.map((item, i) => /* @__PURE__ */ jsxs8(Text9, { color: i === focusIdx ? "cyan" : void 0, children: [
|
|
1247
1488
|
i === focusIdx ? "> " : " ",
|
|
1248
1489
|
item.label
|
|
1249
1490
|
] }, item.label)),
|
|
1250
|
-
/* @__PURE__ */
|
|
1251
|
-
/* @__PURE__ */
|
|
1491
|
+
/* @__PURE__ */ jsx9(Text9, { children: " " }),
|
|
1492
|
+
/* @__PURE__ */ jsx9(
|
|
1252
1493
|
ControlHints,
|
|
1253
1494
|
{
|
|
1254
1495
|
hints: [
|
|
@@ -1309,10 +1550,10 @@ var init_config_store = __esm({
|
|
|
1309
1550
|
});
|
|
1310
1551
|
|
|
1311
1552
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
1312
|
-
import { useEffect as useEffect5, useState as
|
|
1313
|
-
import { Box as
|
|
1314
|
-
import
|
|
1315
|
-
import { Fragment as
|
|
1553
|
+
import { useEffect as useEffect5, useState as useState9 } from "react";
|
|
1554
|
+
import { Box as Box9, Text as Text10, useInput as useInput9 } from "ink";
|
|
1555
|
+
import TextInput4 from "ink-text-input";
|
|
1556
|
+
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1316
1557
|
function debugFields(config) {
|
|
1317
1558
|
return {
|
|
1318
1559
|
space_id: config?.spaceId ?? "",
|
|
@@ -1324,13 +1565,13 @@ function debugFields(config) {
|
|
|
1324
1565
|
};
|
|
1325
1566
|
}
|
|
1326
1567
|
function ConfigurationScreen({ onDone }) {
|
|
1327
|
-
const [stage, setStage] =
|
|
1328
|
-
const [config, setConfig] =
|
|
1329
|
-
const [activeField, setActiveField] =
|
|
1330
|
-
const [notice, setNotice] =
|
|
1331
|
-
const [lastSaved, setLastSaved] =
|
|
1332
|
-
const [editing, setEditing] =
|
|
1333
|
-
const [valueBeforeEdit, setValueBeforeEdit] =
|
|
1568
|
+
const [stage, setStage] = useState9("loading");
|
|
1569
|
+
const [config, setConfig] = useState9(null);
|
|
1570
|
+
const [activeField, setActiveField] = useState9("spaceId");
|
|
1571
|
+
const [notice, setNotice] = useState9(null);
|
|
1572
|
+
const [lastSaved, setLastSaved] = useState9(null);
|
|
1573
|
+
const [editing, setEditing] = useState9(false);
|
|
1574
|
+
const [valueBeforeEdit, setValueBeforeEdit] = useState9("");
|
|
1334
1575
|
useEffect5(() => {
|
|
1335
1576
|
readCredentials().then((cfg) => {
|
|
1336
1577
|
setConfig(cfg);
|
|
@@ -1371,7 +1612,7 @@ function ConfigurationScreen({ onDone }) {
|
|
|
1371
1612
|
);
|
|
1372
1613
|
onDone();
|
|
1373
1614
|
}
|
|
1374
|
-
|
|
1615
|
+
useInput9((input, key) => {
|
|
1375
1616
|
if (stage === "loading" || stage === "saving") return;
|
|
1376
1617
|
if (editing) {
|
|
1377
1618
|
if (key.escape) {
|
|
@@ -1408,46 +1649,46 @@ function ConfigurationScreen({ onDone }) {
|
|
|
1408
1649
|
}
|
|
1409
1650
|
});
|
|
1410
1651
|
if (stage === "loading") {
|
|
1411
|
-
return /* @__PURE__ */
|
|
1412
|
-
/* @__PURE__ */
|
|
1413
|
-
/* @__PURE__ */
|
|
1414
|
-
/* @__PURE__ */
|
|
1652
|
+
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1653
|
+
/* @__PURE__ */ jsx10(Text10, { bold: true, children: "Configuration" }),
|
|
1654
|
+
/* @__PURE__ */ jsx10(Text10, { children: " " }),
|
|
1655
|
+
/* @__PURE__ */ jsx10(Text10, { color: PALETTE.accent, children: "Loading..." })
|
|
1415
1656
|
] });
|
|
1416
1657
|
}
|
|
1417
|
-
return /* @__PURE__ */
|
|
1418
|
-
/* @__PURE__ */
|
|
1419
|
-
/* @__PURE__ */
|
|
1420
|
-
/* @__PURE__ */
|
|
1658
|
+
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1659
|
+
/* @__PURE__ */ jsx10(Text10, { bold: true, children: "Configuration" }),
|
|
1660
|
+
/* @__PURE__ */ jsx10(Text10, { children: " " }),
|
|
1661
|
+
/* @__PURE__ */ jsx10(Box9, { flexDirection: "column", children: FIELD_ORDER.map((field) => {
|
|
1421
1662
|
const isActive = activeField === field;
|
|
1422
1663
|
const value = fieldValue(field);
|
|
1423
1664
|
const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
|
|
1424
|
-
return /* @__PURE__ */
|
|
1425
|
-
/* @__PURE__ */
|
|
1426
|
-
/* @__PURE__ */
|
|
1665
|
+
return /* @__PURE__ */ jsxs9(Box9, { gap: 1, children: [
|
|
1666
|
+
/* @__PURE__ */ jsx10(Text10, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
|
|
1667
|
+
/* @__PURE__ */ jsxs9(Text10, { bold: isActive, children: [
|
|
1427
1668
|
FIELD_LABELS[field],
|
|
1428
1669
|
":"
|
|
1429
1670
|
] }),
|
|
1430
|
-
isActive && editing ? /* @__PURE__ */
|
|
1431
|
-
|
|
1671
|
+
isActive && editing ? /* @__PURE__ */ jsx10(
|
|
1672
|
+
TextInput4,
|
|
1432
1673
|
{
|
|
1433
1674
|
value,
|
|
1434
1675
|
onChange: (next) => setFieldValue(field, next),
|
|
1435
1676
|
onSubmit: () => setEditing(false),
|
|
1436
1677
|
mask: field === "cmaToken" ? "\u2022" : void 0
|
|
1437
1678
|
}
|
|
1438
|
-
) : /* @__PURE__ */
|
|
1679
|
+
) : /* @__PURE__ */ jsx10(Text10, { children: display || /* @__PURE__ */ jsx10(Text10, { color: PALETTE.muted, children: "(empty)" }) })
|
|
1439
1680
|
] }, field);
|
|
1440
1681
|
}) }),
|
|
1441
|
-
notice && /* @__PURE__ */
|
|
1442
|
-
/* @__PURE__ */
|
|
1443
|
-
/* @__PURE__ */
|
|
1682
|
+
notice && /* @__PURE__ */ jsxs9(Fragment3, { children: [
|
|
1683
|
+
/* @__PURE__ */ jsx10(Text10, { children: " " }),
|
|
1684
|
+
/* @__PURE__ */ jsxs9(Text10, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
|
|
1444
1685
|
notice.kind === "success" ? "\u2713" : "\u2717",
|
|
1445
1686
|
" ",
|
|
1446
1687
|
notice.text
|
|
1447
1688
|
] })
|
|
1448
1689
|
] }),
|
|
1449
|
-
/* @__PURE__ */
|
|
1450
|
-
/* @__PURE__ */
|
|
1690
|
+
/* @__PURE__ */ jsx10(Text10, { children: " " }),
|
|
1691
|
+
/* @__PURE__ */ jsx10(
|
|
1451
1692
|
ControlHints,
|
|
1452
1693
|
{
|
|
1453
1694
|
hints: editing ? [
|
|
@@ -1515,12 +1756,12 @@ var init_analytics_store = __esm({
|
|
|
1515
1756
|
});
|
|
1516
1757
|
|
|
1517
1758
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
1518
|
-
import { useEffect as useEffect6, useState as
|
|
1519
|
-
import { Box as
|
|
1520
|
-
import { Fragment as
|
|
1759
|
+
import { useEffect as useEffect6, useState as useState10 } from "react";
|
|
1760
|
+
import { Box as Box10, Text as Text11, useInput as useInput10 } from "ink";
|
|
1761
|
+
import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1521
1762
|
function OptInAnalyticsScreen({ onDone }) {
|
|
1522
|
-
const [loading, setLoading] =
|
|
1523
|
-
const [enabled, setEnabled] =
|
|
1763
|
+
const [loading, setLoading] = useState10(true);
|
|
1764
|
+
const [enabled, setEnabled] = useState10(true);
|
|
1524
1765
|
useEffect6(() => {
|
|
1525
1766
|
readAnalyticsSetting().then((setting) => {
|
|
1526
1767
|
setEnabled(setting.enabled);
|
|
@@ -1533,7 +1774,7 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
1533
1774
|
});
|
|
1534
1775
|
});
|
|
1535
1776
|
}, []);
|
|
1536
|
-
|
|
1777
|
+
useInput10((input, key) => {
|
|
1537
1778
|
if (loading) return;
|
|
1538
1779
|
if (key.return || input === " ") {
|
|
1539
1780
|
setEnabled((current) => {
|
|
@@ -1548,21 +1789,21 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
1548
1789
|
onDone();
|
|
1549
1790
|
}
|
|
1550
1791
|
});
|
|
1551
|
-
return /* @__PURE__ */
|
|
1552
|
-
/* @__PURE__ */
|
|
1553
|
-
/* @__PURE__ */
|
|
1554
|
-
loading ? /* @__PURE__ */
|
|
1555
|
-
/* @__PURE__ */
|
|
1792
|
+
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1793
|
+
/* @__PURE__ */ jsx11(Text11, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
|
|
1794
|
+
/* @__PURE__ */ jsx11(Text11, { children: " " }),
|
|
1795
|
+
loading ? /* @__PURE__ */ jsx11(Text11, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
1796
|
+
/* @__PURE__ */ jsxs10(Text11, { children: [
|
|
1556
1797
|
"Share anonymous usage data:",
|
|
1557
1798
|
" ",
|
|
1558
|
-
/* @__PURE__ */
|
|
1799
|
+
/* @__PURE__ */ jsx11(Text11, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
1559
1800
|
] }),
|
|
1560
|
-
/* @__PURE__ */
|
|
1561
|
-
/* @__PURE__ */
|
|
1562
|
-
/* @__PURE__ */
|
|
1801
|
+
/* @__PURE__ */ jsx11(Text11, { children: " " }),
|
|
1802
|
+
/* @__PURE__ */ jsx11(Text11, { color: PALETTE.muted, children: "Shares which CLI commands are used and where imports succeed or fail." }),
|
|
1803
|
+
/* @__PURE__ */ jsx11(Text11, { color: PALETTE.muted, children: "Never includes source code, file paths, credentials, or authored content." })
|
|
1563
1804
|
] }),
|
|
1564
|
-
/* @__PURE__ */
|
|
1565
|
-
/* @__PURE__ */
|
|
1805
|
+
/* @__PURE__ */ jsx11(Text11, { children: " " }),
|
|
1806
|
+
/* @__PURE__ */ jsx11(
|
|
1566
1807
|
ControlHints,
|
|
1567
1808
|
{
|
|
1568
1809
|
hints: [
|
|
@@ -1573,7 +1814,7 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
1573
1814
|
)
|
|
1574
1815
|
] });
|
|
1575
1816
|
}
|
|
1576
|
-
var
|
|
1817
|
+
var init_screen5 = __esm({
|
|
1577
1818
|
"packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx"() {
|
|
1578
1819
|
"use strict";
|
|
1579
1820
|
init_home_theme();
|
|
@@ -1584,11 +1825,11 @@ var init_screen4 = __esm({
|
|
|
1584
1825
|
});
|
|
1585
1826
|
|
|
1586
1827
|
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
1587
|
-
import { useEffect as useEffect7, useState as
|
|
1588
|
-
import { Box as
|
|
1589
|
-
import { jsx as
|
|
1828
|
+
import { useEffect as useEffect7, useState as useState11 } from "react";
|
|
1829
|
+
import { Box as Box11, Text as Text12, useInput as useInput11 } from "ink";
|
|
1830
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1590
1831
|
function UpgradeScreen({ onDone }) {
|
|
1591
|
-
const [upgradeCheck, setUpgradeCheck] =
|
|
1832
|
+
const [upgradeCheck, setUpgradeCheck] = useState11();
|
|
1592
1833
|
useEffect7(() => {
|
|
1593
1834
|
startDebugRun({
|
|
1594
1835
|
flow: "upgrade",
|
|
@@ -1598,7 +1839,7 @@ function UpgradeScreen({ onDone }) {
|
|
|
1598
1839
|
});
|
|
1599
1840
|
checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
|
|
1600
1841
|
}, []);
|
|
1601
|
-
|
|
1842
|
+
useInput11((_input, key) => {
|
|
1602
1843
|
if (key.return) {
|
|
1603
1844
|
void finishDebugRun({
|
|
1604
1845
|
outputs: upgradeCheck ?? {},
|
|
@@ -1609,12 +1850,12 @@ function UpgradeScreen({ onDone }) {
|
|
|
1609
1850
|
return;
|
|
1610
1851
|
}
|
|
1611
1852
|
});
|
|
1612
|
-
return /* @__PURE__ */
|
|
1613
|
-
/* @__PURE__ */
|
|
1614
|
-
/* @__PURE__ */
|
|
1853
|
+
return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1854
|
+
/* @__PURE__ */ jsx12(Text12, { bold: true, children: "Upgrade" }),
|
|
1855
|
+
/* @__PURE__ */ jsx12(Text12, { children: " " }),
|
|
1615
1856
|
renderBody(upgradeCheck),
|
|
1616
|
-
/* @__PURE__ */
|
|
1617
|
-
/* @__PURE__ */
|
|
1857
|
+
/* @__PURE__ */ jsx12(Text12, { children: " " }),
|
|
1858
|
+
/* @__PURE__ */ jsxs11(Text12, { bold: true, color: PALETTE.accent, children: [
|
|
1618
1859
|
FOCUS_MARKER,
|
|
1619
1860
|
" Go Back"
|
|
1620
1861
|
] })
|
|
@@ -1622,34 +1863,34 @@ function UpgradeScreen({ onDone }) {
|
|
|
1622
1863
|
}
|
|
1623
1864
|
function renderBody(upgradeCheck) {
|
|
1624
1865
|
if (!upgradeCheck) {
|
|
1625
|
-
return /* @__PURE__ */
|
|
1866
|
+
return /* @__PURE__ */ jsx12(Text12, { color: PALETTE.muted, children: "Checking for updates\u2026" });
|
|
1626
1867
|
}
|
|
1627
1868
|
if (upgradeCheck.status === "error") {
|
|
1628
|
-
return /* @__PURE__ */
|
|
1869
|
+
return /* @__PURE__ */ jsx12(Text12, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
|
|
1629
1870
|
}
|
|
1630
1871
|
if (upgradeCheck.status === "up-to-date") {
|
|
1631
|
-
return /* @__PURE__ */
|
|
1872
|
+
return /* @__PURE__ */ jsxs11(Text12, { color: PALETTE.success, children: [
|
|
1632
1873
|
"You're already on the latest version (v",
|
|
1633
1874
|
upgradeCheck.current,
|
|
1634
1875
|
")."
|
|
1635
1876
|
] });
|
|
1636
1877
|
}
|
|
1637
|
-
return /* @__PURE__ */
|
|
1638
|
-
/* @__PURE__ */
|
|
1639
|
-
/* @__PURE__ */
|
|
1878
|
+
return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", children: [
|
|
1879
|
+
/* @__PURE__ */ jsxs11(Text12, { color: PALETTE.muted, children: [
|
|
1880
|
+
/* @__PURE__ */ jsxs11(Text12, { bold: true, color: PALETTE.success, children: [
|
|
1640
1881
|
"v",
|
|
1641
1882
|
upgradeCheck.latest
|
|
1642
1883
|
] }),
|
|
1643
1884
|
" ",
|
|
1644
1885
|
"is available (you're on ",
|
|
1645
|
-
/* @__PURE__ */
|
|
1886
|
+
/* @__PURE__ */ jsxs11(Text12, { bold: true, children: [
|
|
1646
1887
|
"v",
|
|
1647
1888
|
upgradeCheck.current
|
|
1648
1889
|
] }),
|
|
1649
1890
|
"). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
|
|
1650
1891
|
] }),
|
|
1651
|
-
/* @__PURE__ */
|
|
1652
|
-
/* @__PURE__ */
|
|
1892
|
+
/* @__PURE__ */ jsx12(Text12, { children: " " }),
|
|
1893
|
+
/* @__PURE__ */ jsx12(Box11, { flexDirection: "column", borderStyle: "round", borderColor: PALETTE.border, paddingX: 1, children: UPGRADE_COMMANDS.map((cmd) => /* @__PURE__ */ jsx12(Text12, { bold: true, children: cmd }, cmd)) })
|
|
1653
1894
|
] });
|
|
1654
1895
|
}
|
|
1655
1896
|
var UPGRADE_COMMANDS;
|
|
@@ -1664,12 +1905,12 @@ var init_PageContainer4 = __esm({
|
|
|
1664
1905
|
});
|
|
1665
1906
|
|
|
1666
1907
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
1667
|
-
import { useEffect as useEffect8, useState as
|
|
1668
|
-
import { Box as
|
|
1669
|
-
import { jsx as
|
|
1908
|
+
import { useEffect as useEffect8, useState as useState12 } from "react";
|
|
1909
|
+
import { Box as Box12, Text as Text13, useInput as useInput12 } from "ink";
|
|
1910
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1670
1911
|
function DebugModeScreen({ onDone }) {
|
|
1671
|
-
const [loading, setLoading] =
|
|
1672
|
-
const [enabled, setEnabled] =
|
|
1912
|
+
const [loading, setLoading] = useState12(true);
|
|
1913
|
+
const [enabled, setEnabled] = useState12(true);
|
|
1673
1914
|
useEffect8(() => {
|
|
1674
1915
|
readDebugModeSetting().then((setting) => {
|
|
1675
1916
|
setEnabled(setting.enabled);
|
|
@@ -1682,7 +1923,7 @@ function DebugModeScreen({ onDone }) {
|
|
|
1682
1923
|
});
|
|
1683
1924
|
});
|
|
1684
1925
|
}, []);
|
|
1685
|
-
|
|
1926
|
+
useInput12((input, key) => {
|
|
1686
1927
|
if (loading) return;
|
|
1687
1928
|
if (key.return || input === " ") {
|
|
1688
1929
|
setEnabled((current) => {
|
|
@@ -1697,16 +1938,16 @@ function DebugModeScreen({ onDone }) {
|
|
|
1697
1938
|
onDone();
|
|
1698
1939
|
}
|
|
1699
1940
|
});
|
|
1700
|
-
return /* @__PURE__ */
|
|
1701
|
-
/* @__PURE__ */
|
|
1702
|
-
/* @__PURE__ */
|
|
1703
|
-
loading ? /* @__PURE__ */
|
|
1941
|
+
return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1942
|
+
/* @__PURE__ */ jsx13(Text13, { bold: true, children: "Settings \u203A Debug Mode" }),
|
|
1943
|
+
/* @__PURE__ */ jsx13(Text13, { children: " " }),
|
|
1944
|
+
loading ? /* @__PURE__ */ jsx13(Text13, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs12(Text13, { children: [
|
|
1704
1945
|
"Debug logging:",
|
|
1705
1946
|
" ",
|
|
1706
|
-
/* @__PURE__ */
|
|
1947
|
+
/* @__PURE__ */ jsx13(Text13, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
1707
1948
|
] }),
|
|
1708
|
-
/* @__PURE__ */
|
|
1709
|
-
/* @__PURE__ */
|
|
1949
|
+
/* @__PURE__ */ jsx13(Text13, { children: " " }),
|
|
1950
|
+
/* @__PURE__ */ jsx13(
|
|
1710
1951
|
ControlHints,
|
|
1711
1952
|
{
|
|
1712
1953
|
hints: [
|
|
@@ -1717,7 +1958,7 @@ function DebugModeScreen({ onDone }) {
|
|
|
1717
1958
|
)
|
|
1718
1959
|
] });
|
|
1719
1960
|
}
|
|
1720
|
-
var
|
|
1961
|
+
var init_screen6 = __esm({
|
|
1721
1962
|
"packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx"() {
|
|
1722
1963
|
"use strict";
|
|
1723
1964
|
init_home_theme();
|
|
@@ -1732,29 +1973,39 @@ var app_exports = {};
|
|
|
1732
1973
|
__export(app_exports, {
|
|
1733
1974
|
runApp: () => runApp
|
|
1734
1975
|
});
|
|
1735
|
-
import { useEffect as useEffect9, useState as
|
|
1736
|
-
import { Fragment as
|
|
1976
|
+
import { useEffect as useEffect9, useState as useState13 } from "react";
|
|
1977
|
+
import { Fragment as Fragment5, jsx as jsx14 } from "react/jsx-runtime";
|
|
1737
1978
|
function App({ onLaunchImport, importExitCode }) {
|
|
1738
1979
|
const returnedFromImport = importExitCode !== void 0;
|
|
1739
|
-
const [screen, setScreen] =
|
|
1740
|
-
const [showImportResult, setShowImportResult] =
|
|
1741
|
-
const [projectPath, setProjectPath] =
|
|
1742
|
-
const [tokensPath, setTokensPath] =
|
|
1743
|
-
const [
|
|
1980
|
+
const [screen, setScreen] = useState13(returnedFromImport ? "import" : "start");
|
|
1981
|
+
const [showImportResult, setShowImportResult] = useState13(returnedFromImport);
|
|
1982
|
+
const [projectPath, setProjectPath] = useState13();
|
|
1983
|
+
const [tokensPath, setTokensPath] = useState13();
|
|
1984
|
+
const [pathConfirmed, setPathConfirmed] = useState13(false);
|
|
1985
|
+
const [importDefaults, setImportDefaults] = useState13();
|
|
1744
1986
|
useEffect9(() => {
|
|
1745
1987
|
if (screen !== "import") {
|
|
1746
1988
|
setImportDefaults(void 0);
|
|
1747
1989
|
return;
|
|
1748
1990
|
}
|
|
1749
1991
|
void readCredentials().then(
|
|
1750
|
-
(saved) => setImportDefaults({
|
|
1992
|
+
(saved) => setImportDefaults({
|
|
1993
|
+
componentDir: saved.defaultComponentDir ?? "",
|
|
1994
|
+
tokenFile: saved.defaultTokenFile ?? "",
|
|
1995
|
+
credentials: saved
|
|
1996
|
+
})
|
|
1751
1997
|
);
|
|
1752
1998
|
}, [screen]);
|
|
1999
|
+
const finishCredentials = async (result, project, tokens) => {
|
|
2000
|
+
if (!result.skipped) await writeCredentials({ ...result.credentials });
|
|
2001
|
+
onLaunchImport?.({ project, tokens, skipCredentials: result.skipped });
|
|
2002
|
+
};
|
|
1753
2003
|
const goToStart = () => setScreen("start");
|
|
1754
2004
|
const goToSettings = () => setScreen("settings");
|
|
1755
2005
|
const resetImport = () => {
|
|
1756
2006
|
setProjectPath(void 0);
|
|
1757
2007
|
setTokensPath(void 0);
|
|
2008
|
+
setPathConfirmed(false);
|
|
1758
2009
|
};
|
|
1759
2010
|
const finishImportResult = () => {
|
|
1760
2011
|
setShowImportResult(false);
|
|
@@ -1767,13 +2018,13 @@ function App({ onLaunchImport, importExitCode }) {
|
|
|
1767
2018
|
};
|
|
1768
2019
|
switch (screen) {
|
|
1769
2020
|
case "import":
|
|
1770
|
-
if (showImportResult) return /* @__PURE__ */
|
|
1771
|
-
if (importDefaults === void 0) return /* @__PURE__ */
|
|
2021
|
+
if (showImportResult) return /* @__PURE__ */ jsx14(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
|
|
2022
|
+
if (importDefaults === void 0) return /* @__PURE__ */ jsx14(Fragment5, {});
|
|
1772
2023
|
if (projectPath === void 0) {
|
|
1773
|
-
return /* @__PURE__ */
|
|
2024
|
+
return /* @__PURE__ */ jsx14(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
|
|
1774
2025
|
}
|
|
1775
2026
|
if (tokensPath === void 0) {
|
|
1776
|
-
return /* @__PURE__ */
|
|
2027
|
+
return /* @__PURE__ */ jsx14(
|
|
1777
2028
|
TokenInputScreen,
|
|
1778
2029
|
{
|
|
1779
2030
|
initialPath: importDefaults.tokenFile,
|
|
@@ -1782,35 +2033,45 @@ function App({ onLaunchImport, importExitCode }) {
|
|
|
1782
2033
|
}
|
|
1783
2034
|
);
|
|
1784
2035
|
}
|
|
1785
|
-
|
|
1786
|
-
|
|
2036
|
+
if (!pathConfirmed) {
|
|
2037
|
+
return /* @__PURE__ */ jsx14(
|
|
2038
|
+
PathValidationScreen,
|
|
2039
|
+
{
|
|
2040
|
+
projectPath,
|
|
2041
|
+
onConfirm: () => setPathConfirmed(true),
|
|
2042
|
+
onChangePath: resetImport,
|
|
2043
|
+
onBack: () => setTokensPath(void 0)
|
|
2044
|
+
}
|
|
2045
|
+
);
|
|
2046
|
+
}
|
|
2047
|
+
return /* @__PURE__ */ jsx14(
|
|
2048
|
+
CredentialsScreen,
|
|
1787
2049
|
{
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
onBack: () => setTokensPath(void 0)
|
|
2050
|
+
initial: importDefaults.credentials,
|
|
2051
|
+
onBack: () => setPathConfirmed(false),
|
|
2052
|
+
onDone: (result) => void finishCredentials(result, projectPath, tokensPath)
|
|
1792
2053
|
}
|
|
1793
2054
|
);
|
|
1794
2055
|
case "help":
|
|
1795
|
-
return /* @__PURE__ */
|
|
2056
|
+
return /* @__PURE__ */ jsx14(HelpScreen, { onDone: goToStart });
|
|
1796
2057
|
case "upgrade":
|
|
1797
|
-
return /* @__PURE__ */
|
|
2058
|
+
return /* @__PURE__ */ jsx14(UpgradeScreen, { onDone: goToStart });
|
|
1798
2059
|
case "settings":
|
|
1799
|
-
return /* @__PURE__ */
|
|
2060
|
+
return /* @__PURE__ */ jsx14(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
|
|
1800
2061
|
case "settings-configuration":
|
|
1801
|
-
return /* @__PURE__ */
|
|
2062
|
+
return /* @__PURE__ */ jsx14(ConfigurationScreen, { onDone: goToSettings });
|
|
1802
2063
|
case "settings-opt-in-analytics":
|
|
1803
|
-
return /* @__PURE__ */
|
|
2064
|
+
return /* @__PURE__ */ jsx14(OptInAnalyticsScreen, { onDone: goToSettings });
|
|
1804
2065
|
case "settings-debug-mode":
|
|
1805
|
-
return /* @__PURE__ */
|
|
2066
|
+
return /* @__PURE__ */ jsx14(DebugModeScreen, { onDone: goToSettings });
|
|
1806
2067
|
case "start":
|
|
1807
|
-
return /* @__PURE__ */
|
|
2068
|
+
return /* @__PURE__ */ jsx14(HomeScreen, { onNavigate: setScreen });
|
|
1808
2069
|
}
|
|
1809
2070
|
}
|
|
1810
2071
|
async function renderUntilImportRequestedOrExit(renderApp, importExitCode) {
|
|
1811
2072
|
let requestedImport;
|
|
1812
2073
|
const instance = renderApp(
|
|
1813
|
-
/* @__PURE__ */
|
|
2074
|
+
/* @__PURE__ */ jsx14(
|
|
1814
2075
|
App,
|
|
1815
2076
|
{
|
|
1816
2077
|
importExitCode,
|
|
@@ -1849,9 +2110,9 @@ var init_app = __esm({
|
|
|
1849
2110
|
init_PageContainer2();
|
|
1850
2111
|
init_PageContainer3();
|
|
1851
2112
|
init_ContentfulConfigScreen();
|
|
1852
|
-
init_screen4();
|
|
1853
|
-
init_PageContainer4();
|
|
1854
2113
|
init_screen5();
|
|
2114
|
+
init_PageContainer4();
|
|
2115
|
+
init_screen6();
|
|
1855
2116
|
init_config_store();
|
|
1856
2117
|
CLEAR_SCREEN = "\x1B[2J\x1B[H";
|
|
1857
2118
|
}
|