@contentful/experience-design-system-cli 2.37.1-dev-build-97678ad0.0 → 2.37.1-dev-build-f86ffbb8.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 -143
- 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 +23 -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 +1140 -2029
- package/legacy/package.json +2 -1
- package/package.json +3 -2
- package/legacy/dist/src/import/tui/steps/CredentialsStep.d.ts +0 -43
- package/legacy/dist/src/import/tui/steps/PathValidationStep.d.ts +0 -10
- package/legacy/dist/src/import/tui/steps/TokenInputStep.d.ts +0 -8
- package/legacy/dist/src/import/tui/steps/WelcomeStep.d.ts +0 -7
package/dist/app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/experience-design-system-cli/app.tsx
|
|
2
|
-
import { useEffect as useEffect9, useState as
|
|
2
|
+
import { useEffect as useEffect9, useState as useState13 } from "react";
|
|
3
3
|
|
|
4
4
|
// packages/experience-design-system-cli/src/tui/home/home.tsx
|
|
5
5
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
@@ -705,6 +705,219 @@ function PathValidationScreen({
|
|
|
705
705
|
] });
|
|
706
706
|
}
|
|
707
707
|
|
|
708
|
+
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx
|
|
709
|
+
import { useRef, useState as useState6 } from "react";
|
|
710
|
+
import { Box as Box6, Text as Text7 } from "ink";
|
|
711
|
+
import TextInput3 from "ink-text-input";
|
|
712
|
+
|
|
713
|
+
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/controls.ts
|
|
714
|
+
import { useInput as useInput6 } from "ink";
|
|
715
|
+
|
|
716
|
+
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts
|
|
717
|
+
var FIELDS = ["spaceId", "environmentId", "cmaToken", "host"];
|
|
718
|
+
var DEFAULT_HOST = "api.contentful.com";
|
|
719
|
+
function keyAction2(input, key) {
|
|
720
|
+
if (key.escape) return "back";
|
|
721
|
+
if (key.tab) return "next-field";
|
|
722
|
+
if (key.ctrl && input === "s") return "skip";
|
|
723
|
+
return null;
|
|
724
|
+
}
|
|
725
|
+
function nextField(field) {
|
|
726
|
+
return FIELDS[(FIELDS.indexOf(field) + 1) % FIELDS.length];
|
|
727
|
+
}
|
|
728
|
+
function toConfiguredHost(host) {
|
|
729
|
+
const value = (host ?? "").trim().replace(/\/+$/, "");
|
|
730
|
+
return value === "" ? DEFAULT_HOST : value.replace(/^https:\/\//i, "");
|
|
731
|
+
}
|
|
732
|
+
function toApiHost(host) {
|
|
733
|
+
const value = host.trim().replace(/\/+$/, "");
|
|
734
|
+
if (value === "") return `https://${DEFAULT_HOST}`;
|
|
735
|
+
return /^[a-z][a-z\d+\-.]*:\/\//i.test(value) ? value : `https://${value}`;
|
|
736
|
+
}
|
|
737
|
+
function normalize(values) {
|
|
738
|
+
return {
|
|
739
|
+
spaceId: values.spaceId.trim(),
|
|
740
|
+
environmentId: values.environmentId.trim(),
|
|
741
|
+
cmaToken: values.cmaToken.trim(),
|
|
742
|
+
host: toConfiguredHost(values.host)
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
function missingField(values) {
|
|
746
|
+
return values.spaceId === "" || values.environmentId === "" || values.cmaToken === "";
|
|
747
|
+
}
|
|
748
|
+
function isUnchanged(current, initial) {
|
|
749
|
+
return FIELDS.every((field) => current[field] === initial[field]);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/controls.ts
|
|
753
|
+
var CREDENTIALS_CONTROLS = [
|
|
754
|
+
{ keys: "Enter", label: "Next field / Continue" },
|
|
755
|
+
{ keys: "Tab", label: "Switch field" },
|
|
756
|
+
{ keys: "Ctrl+S", label: "Skip (no push)" },
|
|
757
|
+
{ keys: "Esc", label: "Back" }
|
|
758
|
+
];
|
|
759
|
+
function useCredentialsControls(handlers) {
|
|
760
|
+
useInput6((input, key) => {
|
|
761
|
+
if (handlers.disabled) return;
|
|
762
|
+
const action = keyAction2(input, key);
|
|
763
|
+
if (action === "back") handlers.onBack();
|
|
764
|
+
else if (action === "next-field") handlers.onNextField();
|
|
765
|
+
else if (action === "skip") handlers.onSkip();
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/validate.ts
|
|
770
|
+
var USER_AGENT = "app contentful.experience-design-system-cli";
|
|
771
|
+
function headers(token) {
|
|
772
|
+
return { Authorization: `Bearer ${token}`, "X-Contentful-User-Agent": USER_AGENT };
|
|
773
|
+
}
|
|
774
|
+
function isApsDenial(body) {
|
|
775
|
+
try {
|
|
776
|
+
const id = JSON.parse(body).sys?.id;
|
|
777
|
+
return id === "NotFound" || id === "AccessDenied";
|
|
778
|
+
} catch {
|
|
779
|
+
return false;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
function messageFrom(body) {
|
|
783
|
+
try {
|
|
784
|
+
const message = JSON.parse(body).message;
|
|
785
|
+
return typeof message === "string" && message !== "" ? message : void 0;
|
|
786
|
+
} catch {
|
|
787
|
+
return void 0;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
async function validateCredentials(values) {
|
|
791
|
+
const base = toApiHost(values.host);
|
|
792
|
+
let me;
|
|
793
|
+
try {
|
|
794
|
+
me = await fetch(`${base}/users/me`, { headers: headers(values.cmaToken) });
|
|
795
|
+
} catch (error) {
|
|
796
|
+
return { ok: false, error: `Could not reach ${base}: ${error instanceof Error ? error.message : String(error)}` };
|
|
797
|
+
}
|
|
798
|
+
if (me.status === 401) return { ok: false, error: "CMA token is invalid or revoked." };
|
|
799
|
+
if (!me.ok) return { ok: false, error: `Unexpected error validating the token (${me.status}).` };
|
|
800
|
+
let preflight;
|
|
801
|
+
try {
|
|
802
|
+
preflight = await fetch(
|
|
803
|
+
`${base}/spaces/${values.spaceId}/environments/${values.environmentId}/design_systems/preflight`,
|
|
804
|
+
{ headers: headers(values.cmaToken) }
|
|
805
|
+
);
|
|
806
|
+
} catch {
|
|
807
|
+
return { ok: true };
|
|
808
|
+
}
|
|
809
|
+
if (preflight.ok || preflight.status >= 500) return { ok: true };
|
|
810
|
+
const body = await preflight.text();
|
|
811
|
+
if (preflight.status === 404 && !isApsDenial(body)) return { ok: true };
|
|
812
|
+
const detail = messageFrom(body);
|
|
813
|
+
if (preflight.status === 403) {
|
|
814
|
+
return { ok: false, error: `Access denied. ${detail ?? "Your token cannot write design system components here."}` };
|
|
815
|
+
}
|
|
816
|
+
if (preflight.status === 404) {
|
|
817
|
+
return {
|
|
818
|
+
ok: false,
|
|
819
|
+
error: `Not found. Check the space ID, environment and API host.${detail ? ` (${detail})` : ""}`
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
return { ok: false, error: `Credential check failed (${preflight.status}).${detail ? ` ${detail}` : ""}` };
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx
|
|
826
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
827
|
+
var LABELS = {
|
|
828
|
+
spaceId: "Space ID",
|
|
829
|
+
environmentId: "Environment",
|
|
830
|
+
cmaToken: "CMA Token",
|
|
831
|
+
host: "API Host"
|
|
832
|
+
};
|
|
833
|
+
function CredentialsScreen({
|
|
834
|
+
onDone,
|
|
835
|
+
onBack,
|
|
836
|
+
initial = {},
|
|
837
|
+
validate = validateCredentials
|
|
838
|
+
}) {
|
|
839
|
+
const initialValues = useRef(
|
|
840
|
+
normalize({
|
|
841
|
+
spaceId: initial.spaceId ?? "",
|
|
842
|
+
environmentId: initial.environmentId || "master",
|
|
843
|
+
cmaToken: initial.cmaToken ?? "",
|
|
844
|
+
host: initial.host ?? ""
|
|
845
|
+
})
|
|
846
|
+
).current;
|
|
847
|
+
const [values, setValues] = useState6(initialValues);
|
|
848
|
+
const [active, setActive] = useState6("spaceId");
|
|
849
|
+
const [error, setError] = useState6(null);
|
|
850
|
+
const [validating, setValidating] = useState6(false);
|
|
851
|
+
const prefilled = initialValues.spaceId !== "" && initialValues.cmaToken !== "";
|
|
852
|
+
useCredentialsControls({
|
|
853
|
+
disabled: validating,
|
|
854
|
+
onBack,
|
|
855
|
+
onNextField: () => setActive(nextField),
|
|
856
|
+
onSkip: () => onDone({ skipped: true })
|
|
857
|
+
});
|
|
858
|
+
const change = (field) => (value) => {
|
|
859
|
+
setValues((current) => ({ ...current, [field]: value }));
|
|
860
|
+
setError(null);
|
|
861
|
+
};
|
|
862
|
+
const submit = async (field) => {
|
|
863
|
+
if (field !== "host") {
|
|
864
|
+
setActive(nextField(field));
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
const credentials = normalize(values);
|
|
868
|
+
if (missingField(credentials)) {
|
|
869
|
+
setError("Space ID, environment and CMA token are all required.");
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
setValidating(true);
|
|
873
|
+
const result = await validate(credentials);
|
|
874
|
+
setValidating(false);
|
|
875
|
+
if (result.ok) onDone({ skipped: false, credentials });
|
|
876
|
+
else setError(result.error);
|
|
877
|
+
};
|
|
878
|
+
return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", gap: 1, paddingX: 2, paddingY: 1, children: [
|
|
879
|
+
/* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
|
|
880
|
+
/* @__PURE__ */ jsx7(Text7, { bold: true, children: "Contentful credentials" }),
|
|
881
|
+
/* @__PURE__ */ jsx7(Text7, { children: prefilled ? "Credentials pre-filled from the configuration settings." : "Enter the Contentful space you want to import into." }),
|
|
882
|
+
!prefilled && /* @__PURE__ */ jsxs6(Fragment, { children: [
|
|
883
|
+
/* @__PURE__ */ jsx7(Text7, { dimColor: true, children: "Used to align suggestions with what already exists in the space and to push your import at the end. Skipping runs without space context and disables push." }),
|
|
884
|
+
/* @__PURE__ */ jsx7(Text7, { dimColor: true, children: "Tip: save these under Settings \u2192 Configuration so they pre-fill here." })
|
|
885
|
+
] })
|
|
886
|
+
] }),
|
|
887
|
+
/* @__PURE__ */ jsx7(Box6, { flexDirection: "column", children: FIELDS.map((field) => /* @__PURE__ */ jsxs6(Box6, { gap: 1, children: [
|
|
888
|
+
/* @__PURE__ */ jsx7(Text7, { color: active === field ? PALETTE.accent : void 0, children: "?" }),
|
|
889
|
+
/* @__PURE__ */ jsxs6(Text7, { bold: active === field, children: [
|
|
890
|
+
LABELS[field],
|
|
891
|
+
":"
|
|
892
|
+
] }),
|
|
893
|
+
/* @__PURE__ */ jsx7(
|
|
894
|
+
TextInput3,
|
|
895
|
+
{
|
|
896
|
+
value: values[field],
|
|
897
|
+
focus: active === field && !validating,
|
|
898
|
+
mask: field === "cmaToken" ? "\u2022" : void 0,
|
|
899
|
+
placeholder: field === "host" ? DEFAULT_HOST : void 0,
|
|
900
|
+
onChange: change(field),
|
|
901
|
+
onSubmit: () => void submit(field)
|
|
902
|
+
}
|
|
903
|
+
)
|
|
904
|
+
] }, field)) }),
|
|
905
|
+
active === "host" && /* @__PURE__ */ jsx7(Text7, { dimColor: true, children: "Default: api.contentful.com \xB7 EU spaces: api.eu.contentful.com" }),
|
|
906
|
+
error && /* @__PURE__ */ jsxs6(Text7, { color: PALETTE.error, children: [
|
|
907
|
+
"\u2717 ",
|
|
908
|
+
error
|
|
909
|
+
] }),
|
|
910
|
+
validating && /* @__PURE__ */ jsx7(Text7, { color: PALETTE.accent, children: "Validating credentials..." }),
|
|
911
|
+
!validating && !error && !isUnchanged(normalize(values), initialValues) && /* @__PURE__ */ jsx7(Text7, { dimColor: true, children: "Changed values are saved after they validate." }),
|
|
912
|
+
/* @__PURE__ */ jsx7(Box6, { marginTop: 1, gap: 3, children: CREDENTIALS_CONTROLS.map((control) => /* @__PURE__ */ jsxs6(Text7, { dimColor: true, children: [
|
|
913
|
+
"[",
|
|
914
|
+
control.keys,
|
|
915
|
+
"] ",
|
|
916
|
+
control.label
|
|
917
|
+
] }, control.keys)) })
|
|
918
|
+
] });
|
|
919
|
+
}
|
|
920
|
+
|
|
708
921
|
// packages/experience-design-system-cli/src/tui/import/spawn-v1-import.ts
|
|
709
922
|
import { spawn } from "node:child_process";
|
|
710
923
|
|
|
@@ -742,7 +955,8 @@ async function spawnV1Import(options = {}) {
|
|
|
742
955
|
const args = buildArgs(options);
|
|
743
956
|
return new Promise((resolvePromise) => {
|
|
744
957
|
const child = spawn("node", [cliPath, ...args], {
|
|
745
|
-
stdio: "inherit"
|
|
958
|
+
stdio: "inherit",
|
|
959
|
+
env: options.skipCredentials ? { ...process.env, EDS_IMPORT_SKIP_CREDENTIALS: "1" } : process.env
|
|
746
960
|
});
|
|
747
961
|
child.on("close", (code) => {
|
|
748
962
|
resolvePromise({ exitCode: code ?? 1, result: void 0, stdout: "", stderr: "" });
|
|
@@ -772,8 +986,8 @@ function startReadingTerminal() {
|
|
|
772
986
|
}
|
|
773
987
|
|
|
774
988
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
775
|
-
import { useEffect as useEffect4, useState as
|
|
776
|
-
import { Box as
|
|
989
|
+
import { useEffect as useEffect4, useState as useState7 } from "react";
|
|
990
|
+
import { Box as Box7, Text as Text8, useInput as useInput7 } from "ink";
|
|
777
991
|
|
|
778
992
|
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
779
993
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
@@ -983,18 +1197,18 @@ async function readHelpInfo() {
|
|
|
983
1197
|
}
|
|
984
1198
|
|
|
985
1199
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
986
|
-
import { Fragment, jsx as
|
|
1200
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
987
1201
|
function Section({ title, rows }) {
|
|
988
|
-
return /* @__PURE__ */
|
|
989
|
-
/* @__PURE__ */
|
|
990
|
-
rows.map((row) => /* @__PURE__ */
|
|
991
|
-
/* @__PURE__ */
|
|
992
|
-
/* @__PURE__ */
|
|
1202
|
+
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", children: [
|
|
1203
|
+
/* @__PURE__ */ jsx8(Text8, { bold: true, color: PALETTE.accent, children: title }),
|
|
1204
|
+
rows.map((row) => /* @__PURE__ */ jsxs7(Box7, { gap: 1, children: [
|
|
1205
|
+
/* @__PURE__ */ jsx8(Box7, { width: 14, flexShrink: 0, children: /* @__PURE__ */ jsx8(Text8, { dimColor: true, children: row.label }) }),
|
|
1206
|
+
/* @__PURE__ */ jsx8(Text8, { children: row.value })
|
|
993
1207
|
] }, row.label))
|
|
994
1208
|
] });
|
|
995
1209
|
}
|
|
996
1210
|
function HelpScreen({ onDone }) {
|
|
997
|
-
const [info, setInfo] =
|
|
1211
|
+
const [info, setInfo] = useState7();
|
|
998
1212
|
useEffect4(() => {
|
|
999
1213
|
startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
|
|
1000
1214
|
void readHelpInfo().then(setInfo);
|
|
@@ -1003,7 +1217,7 @@ function HelpScreen({ onDone }) {
|
|
|
1003
1217
|
void finishDebugRun({ outputs: {}, status: "success", exitMethod });
|
|
1004
1218
|
onDone();
|
|
1005
1219
|
};
|
|
1006
|
-
|
|
1220
|
+
useInput7((input, key) => {
|
|
1007
1221
|
if (key.return) {
|
|
1008
1222
|
leave("saved");
|
|
1009
1223
|
return;
|
|
@@ -1013,14 +1227,14 @@ function HelpScreen({ onDone }) {
|
|
|
1013
1227
|
return;
|
|
1014
1228
|
}
|
|
1015
1229
|
});
|
|
1016
|
-
return /* @__PURE__ */
|
|
1017
|
-
/* @__PURE__ */
|
|
1018
|
-
info ? /* @__PURE__ */
|
|
1019
|
-
/* @__PURE__ */
|
|
1020
|
-
/* @__PURE__ */
|
|
1021
|
-
/* @__PURE__ */
|
|
1022
|
-
] }) : /* @__PURE__ */
|
|
1023
|
-
/* @__PURE__ */
|
|
1230
|
+
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 2, paddingY: 1, gap: 1, children: [
|
|
1231
|
+
/* @__PURE__ */ jsx8(Text8, { bold: true, children: "Help" }),
|
|
1232
|
+
info ? /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
1233
|
+
/* @__PURE__ */ jsx8(Section, { title: "Where things are stored", rows: info.storage }),
|
|
1234
|
+
/* @__PURE__ */ jsx8(Section, { title: "Troubleshooting", rows: info.troubleshooting }),
|
|
1235
|
+
/* @__PURE__ */ jsx8(Text8, { dimColor: true, 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." })
|
|
1236
|
+
] }) : /* @__PURE__ */ jsx8(Text8, { color: PALETTE.accent, children: "Loading..." }),
|
|
1237
|
+
/* @__PURE__ */ jsx8(
|
|
1024
1238
|
ControlHints,
|
|
1025
1239
|
{
|
|
1026
1240
|
hints: [
|
|
@@ -1033,20 +1247,20 @@ function HelpScreen({ onDone }) {
|
|
|
1033
1247
|
}
|
|
1034
1248
|
|
|
1035
1249
|
// packages/experience-design-system-cli/src/tui/settings/PageContainer.tsx
|
|
1036
|
-
import { useState as
|
|
1037
|
-
import { Box as
|
|
1038
|
-
import { jsx as
|
|
1250
|
+
import { useState as useState8 } from "react";
|
|
1251
|
+
import { Box as Box8, Text as Text9, useInput as useInput8 } from "ink";
|
|
1252
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1039
1253
|
function SettingsScreen({
|
|
1040
1254
|
onNavigate,
|
|
1041
1255
|
onBack
|
|
1042
1256
|
}) {
|
|
1043
|
-
const [focusIdx, setFocusIdx] =
|
|
1257
|
+
const [focusIdx, setFocusIdx] = useState8(0);
|
|
1044
1258
|
const items = [
|
|
1045
1259
|
{ label: "Configuration", screen: "settings-configuration" },
|
|
1046
1260
|
{ label: "Opt-in Analytics", screen: "settings-opt-in-analytics" },
|
|
1047
1261
|
{ label: "Debug Mode", screen: "settings-debug-mode" }
|
|
1048
1262
|
];
|
|
1049
|
-
|
|
1263
|
+
useInput8((input, key) => {
|
|
1050
1264
|
if (key.upArrow) {
|
|
1051
1265
|
setFocusIdx((i) => (i - 1 + items.length) % items.length);
|
|
1052
1266
|
return;
|
|
@@ -1066,15 +1280,15 @@ function SettingsScreen({
|
|
|
1066
1280
|
onBack();
|
|
1067
1281
|
}
|
|
1068
1282
|
});
|
|
1069
|
-
return /* @__PURE__ */
|
|
1070
|
-
/* @__PURE__ */
|
|
1071
|
-
/* @__PURE__ */
|
|
1072
|
-
items.map((item, i) => /* @__PURE__ */
|
|
1283
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1284
|
+
/* @__PURE__ */ jsx9(Text9, { bold: true, children: "Settings" }),
|
|
1285
|
+
/* @__PURE__ */ jsx9(Text9, { children: " " }),
|
|
1286
|
+
items.map((item, i) => /* @__PURE__ */ jsxs8(Text9, { color: i === focusIdx ? "cyan" : void 0, children: [
|
|
1073
1287
|
i === focusIdx ? "> " : " ",
|
|
1074
1288
|
item.label
|
|
1075
1289
|
] }, item.label)),
|
|
1076
|
-
/* @__PURE__ */
|
|
1077
|
-
/* @__PURE__ */
|
|
1290
|
+
/* @__PURE__ */ jsx9(Text9, { children: " " }),
|
|
1291
|
+
/* @__PURE__ */ jsx9(
|
|
1078
1292
|
ControlHints,
|
|
1079
1293
|
{
|
|
1080
1294
|
hints: [
|
|
@@ -1088,9 +1302,9 @@ function SettingsScreen({
|
|
|
1088
1302
|
}
|
|
1089
1303
|
|
|
1090
1304
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
1091
|
-
import { useEffect as useEffect5, useState as
|
|
1092
|
-
import { Box as
|
|
1093
|
-
import
|
|
1305
|
+
import { useEffect as useEffect5, useState as useState9 } from "react";
|
|
1306
|
+
import { Box as Box9, Text as Text10, useInput as useInput9 } from "ink";
|
|
1307
|
+
import TextInput4 from "ink-text-input";
|
|
1094
1308
|
|
|
1095
1309
|
// packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
|
|
1096
1310
|
var readV1Store = readSettings;
|
|
@@ -1121,7 +1335,7 @@ async function writeCredentials(config) {
|
|
|
1121
1335
|
}
|
|
1122
1336
|
|
|
1123
1337
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
1124
|
-
import { Fragment as
|
|
1338
|
+
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1125
1339
|
var FIELD_ORDER = [
|
|
1126
1340
|
"spaceId",
|
|
1127
1341
|
"environmentId",
|
|
@@ -1149,13 +1363,13 @@ var FIELD_LABELS = {
|
|
|
1149
1363
|
defaultTokenFile: "Default token file (optional)"
|
|
1150
1364
|
};
|
|
1151
1365
|
function ConfigurationScreen({ onDone }) {
|
|
1152
|
-
const [stage, setStage] =
|
|
1153
|
-
const [config, setConfig] =
|
|
1154
|
-
const [activeField, setActiveField] =
|
|
1155
|
-
const [notice, setNotice] =
|
|
1156
|
-
const [lastSaved, setLastSaved] =
|
|
1157
|
-
const [editing, setEditing] =
|
|
1158
|
-
const [valueBeforeEdit, setValueBeforeEdit] =
|
|
1366
|
+
const [stage, setStage] = useState9("loading");
|
|
1367
|
+
const [config, setConfig] = useState9(null);
|
|
1368
|
+
const [activeField, setActiveField] = useState9("spaceId");
|
|
1369
|
+
const [notice, setNotice] = useState9(null);
|
|
1370
|
+
const [lastSaved, setLastSaved] = useState9(null);
|
|
1371
|
+
const [editing, setEditing] = useState9(false);
|
|
1372
|
+
const [valueBeforeEdit, setValueBeforeEdit] = useState9("");
|
|
1159
1373
|
useEffect5(() => {
|
|
1160
1374
|
readCredentials().then((cfg) => {
|
|
1161
1375
|
setConfig(cfg);
|
|
@@ -1196,7 +1410,7 @@ function ConfigurationScreen({ onDone }) {
|
|
|
1196
1410
|
);
|
|
1197
1411
|
onDone();
|
|
1198
1412
|
}
|
|
1199
|
-
|
|
1413
|
+
useInput9((input, key) => {
|
|
1200
1414
|
if (stage === "loading" || stage === "saving") return;
|
|
1201
1415
|
if (editing) {
|
|
1202
1416
|
if (key.escape) {
|
|
@@ -1233,46 +1447,46 @@ function ConfigurationScreen({ onDone }) {
|
|
|
1233
1447
|
}
|
|
1234
1448
|
});
|
|
1235
1449
|
if (stage === "loading") {
|
|
1236
|
-
return /* @__PURE__ */
|
|
1237
|
-
/* @__PURE__ */
|
|
1238
|
-
/* @__PURE__ */
|
|
1239
|
-
/* @__PURE__ */
|
|
1450
|
+
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1451
|
+
/* @__PURE__ */ jsx10(Text10, { bold: true, children: "Configuration" }),
|
|
1452
|
+
/* @__PURE__ */ jsx10(Text10, { children: " " }),
|
|
1453
|
+
/* @__PURE__ */ jsx10(Text10, { color: PALETTE.accent, children: "Loading..." })
|
|
1240
1454
|
] });
|
|
1241
1455
|
}
|
|
1242
|
-
return /* @__PURE__ */
|
|
1243
|
-
/* @__PURE__ */
|
|
1244
|
-
/* @__PURE__ */
|
|
1245
|
-
/* @__PURE__ */
|
|
1456
|
+
return /* @__PURE__ */ jsxs9(Box9, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1457
|
+
/* @__PURE__ */ jsx10(Text10, { bold: true, children: "Configuration" }),
|
|
1458
|
+
/* @__PURE__ */ jsx10(Text10, { children: " " }),
|
|
1459
|
+
/* @__PURE__ */ jsx10(Box9, { flexDirection: "column", children: FIELD_ORDER.map((field) => {
|
|
1246
1460
|
const isActive = activeField === field;
|
|
1247
1461
|
const value = fieldValue(field);
|
|
1248
1462
|
const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
|
|
1249
|
-
return /* @__PURE__ */
|
|
1250
|
-
/* @__PURE__ */
|
|
1251
|
-
/* @__PURE__ */
|
|
1463
|
+
return /* @__PURE__ */ jsxs9(Box9, { gap: 1, children: [
|
|
1464
|
+
/* @__PURE__ */ jsx10(Text10, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
|
|
1465
|
+
/* @__PURE__ */ jsxs9(Text10, { bold: isActive, children: [
|
|
1252
1466
|
FIELD_LABELS[field],
|
|
1253
1467
|
":"
|
|
1254
1468
|
] }),
|
|
1255
|
-
isActive && editing ? /* @__PURE__ */
|
|
1256
|
-
|
|
1469
|
+
isActive && editing ? /* @__PURE__ */ jsx10(
|
|
1470
|
+
TextInput4,
|
|
1257
1471
|
{
|
|
1258
1472
|
value,
|
|
1259
1473
|
onChange: (next) => setFieldValue(field, next),
|
|
1260
1474
|
onSubmit: () => setEditing(false),
|
|
1261
1475
|
mask: field === "cmaToken" ? "\u2022" : void 0
|
|
1262
1476
|
}
|
|
1263
|
-
) : /* @__PURE__ */
|
|
1477
|
+
) : /* @__PURE__ */ jsx10(Text10, { children: display || /* @__PURE__ */ jsx10(Text10, { dimColor: true, children: "(empty)" }) })
|
|
1264
1478
|
] }, field);
|
|
1265
1479
|
}) }),
|
|
1266
|
-
notice && /* @__PURE__ */
|
|
1267
|
-
/* @__PURE__ */
|
|
1268
|
-
/* @__PURE__ */
|
|
1480
|
+
notice && /* @__PURE__ */ jsxs9(Fragment3, { children: [
|
|
1481
|
+
/* @__PURE__ */ jsx10(Text10, { children: " " }),
|
|
1482
|
+
/* @__PURE__ */ jsxs9(Text10, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
|
|
1269
1483
|
notice.kind === "success" ? "\u2713" : "\u2717",
|
|
1270
1484
|
" ",
|
|
1271
1485
|
notice.text
|
|
1272
1486
|
] })
|
|
1273
1487
|
] }),
|
|
1274
|
-
/* @__PURE__ */
|
|
1275
|
-
/* @__PURE__ */
|
|
1488
|
+
/* @__PURE__ */ jsx10(Text10, { children: " " }),
|
|
1489
|
+
/* @__PURE__ */ jsx10(
|
|
1276
1490
|
ControlHints,
|
|
1277
1491
|
{
|
|
1278
1492
|
hints: editing ? [
|
|
@@ -1293,8 +1507,8 @@ function ConfigurationScreen({ onDone }) {
|
|
|
1293
1507
|
}
|
|
1294
1508
|
|
|
1295
1509
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
1296
|
-
import { useEffect as useEffect6, useState as
|
|
1297
|
-
import { Box as
|
|
1510
|
+
import { useEffect as useEffect6, useState as useState10 } from "react";
|
|
1511
|
+
import { Box as Box10, Text as Text11, useInput as useInput10 } from "ink";
|
|
1298
1512
|
|
|
1299
1513
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
|
|
1300
1514
|
async function readAnalyticsSetting() {
|
|
@@ -1312,10 +1526,10 @@ async function writeAnalyticsSetting(setting) {
|
|
|
1312
1526
|
}
|
|
1313
1527
|
|
|
1314
1528
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
1315
|
-
import { Fragment as
|
|
1529
|
+
import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1316
1530
|
function OptInAnalyticsScreen({ onDone }) {
|
|
1317
|
-
const [loading, setLoading] =
|
|
1318
|
-
const [enabled, setEnabled] =
|
|
1531
|
+
const [loading, setLoading] = useState10(true);
|
|
1532
|
+
const [enabled, setEnabled] = useState10(true);
|
|
1319
1533
|
useEffect6(() => {
|
|
1320
1534
|
readAnalyticsSetting().then((setting) => {
|
|
1321
1535
|
setEnabled(setting.enabled);
|
|
@@ -1328,7 +1542,7 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
1328
1542
|
});
|
|
1329
1543
|
});
|
|
1330
1544
|
}, []);
|
|
1331
|
-
|
|
1545
|
+
useInput10((input, key) => {
|
|
1332
1546
|
if (loading) return;
|
|
1333
1547
|
if (key.return || input === " ") {
|
|
1334
1548
|
setEnabled((current) => {
|
|
@@ -1343,21 +1557,21 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
1343
1557
|
onDone();
|
|
1344
1558
|
}
|
|
1345
1559
|
});
|
|
1346
|
-
return /* @__PURE__ */
|
|
1347
|
-
/* @__PURE__ */
|
|
1348
|
-
/* @__PURE__ */
|
|
1349
|
-
loading ? /* @__PURE__ */
|
|
1350
|
-
/* @__PURE__ */
|
|
1560
|
+
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1561
|
+
/* @__PURE__ */ jsx11(Text11, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
|
|
1562
|
+
/* @__PURE__ */ jsx11(Text11, { children: " " }),
|
|
1563
|
+
loading ? /* @__PURE__ */ jsx11(Text11, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
1564
|
+
/* @__PURE__ */ jsxs10(Text11, { children: [
|
|
1351
1565
|
"Share anonymous usage data:",
|
|
1352
1566
|
" ",
|
|
1353
|
-
/* @__PURE__ */
|
|
1567
|
+
/* @__PURE__ */ jsx11(Text11, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
1354
1568
|
] }),
|
|
1355
|
-
/* @__PURE__ */
|
|
1356
|
-
/* @__PURE__ */
|
|
1357
|
-
/* @__PURE__ */
|
|
1569
|
+
/* @__PURE__ */ jsx11(Text11, { children: " " }),
|
|
1570
|
+
/* @__PURE__ */ jsx11(Text11, { dimColor: true, children: "Shares which CLI commands are used and where imports succeed or fail." }),
|
|
1571
|
+
/* @__PURE__ */ jsx11(Text11, { dimColor: true, children: "Never includes source code, file paths, credentials, or authored content." })
|
|
1358
1572
|
] }),
|
|
1359
|
-
/* @__PURE__ */
|
|
1360
|
-
/* @__PURE__ */
|
|
1573
|
+
/* @__PURE__ */ jsx11(Text11, { children: " " }),
|
|
1574
|
+
/* @__PURE__ */ jsx11(
|
|
1361
1575
|
ControlHints,
|
|
1362
1576
|
{
|
|
1363
1577
|
hints: [
|
|
@@ -1370,12 +1584,12 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
1370
1584
|
}
|
|
1371
1585
|
|
|
1372
1586
|
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
1373
|
-
import { useEffect as useEffect7, useState as
|
|
1374
|
-
import { Box as
|
|
1375
|
-
import { jsx as
|
|
1587
|
+
import { useEffect as useEffect7, useState as useState11 } from "react";
|
|
1588
|
+
import { Box as Box11, Text as Text12, useInput as useInput11 } from "ink";
|
|
1589
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1376
1590
|
var UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
|
|
1377
1591
|
function UpgradeScreen({ onDone }) {
|
|
1378
|
-
const [upgradeCheck, setUpgradeCheck] =
|
|
1592
|
+
const [upgradeCheck, setUpgradeCheck] = useState11();
|
|
1379
1593
|
useEffect7(() => {
|
|
1380
1594
|
startDebugRun({
|
|
1381
1595
|
flow: "upgrade",
|
|
@@ -1385,7 +1599,7 @@ function UpgradeScreen({ onDone }) {
|
|
|
1385
1599
|
});
|
|
1386
1600
|
checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
|
|
1387
1601
|
}, []);
|
|
1388
|
-
|
|
1602
|
+
useInput11((_input, key) => {
|
|
1389
1603
|
if (key.return) {
|
|
1390
1604
|
void finishDebugRun({
|
|
1391
1605
|
outputs: upgradeCheck ?? {},
|
|
@@ -1396,12 +1610,12 @@ function UpgradeScreen({ onDone }) {
|
|
|
1396
1610
|
return;
|
|
1397
1611
|
}
|
|
1398
1612
|
});
|
|
1399
|
-
return /* @__PURE__ */
|
|
1400
|
-
/* @__PURE__ */
|
|
1401
|
-
/* @__PURE__ */
|
|
1613
|
+
return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1614
|
+
/* @__PURE__ */ jsx12(Text12, { bold: true, children: "Upgrade" }),
|
|
1615
|
+
/* @__PURE__ */ jsx12(Text12, { children: " " }),
|
|
1402
1616
|
renderBody(upgradeCheck),
|
|
1403
|
-
/* @__PURE__ */
|
|
1404
|
-
/* @__PURE__ */
|
|
1617
|
+
/* @__PURE__ */ jsx12(Text12, { children: " " }),
|
|
1618
|
+
/* @__PURE__ */ jsxs11(Text12, { bold: true, color: PALETTE.accent, children: [
|
|
1405
1619
|
FOCUS_MARKER,
|
|
1406
1620
|
" Go Back"
|
|
1407
1621
|
] })
|
|
@@ -1409,44 +1623,44 @@ function UpgradeScreen({ onDone }) {
|
|
|
1409
1623
|
}
|
|
1410
1624
|
function renderBody(upgradeCheck) {
|
|
1411
1625
|
if (!upgradeCheck) {
|
|
1412
|
-
return /* @__PURE__ */
|
|
1626
|
+
return /* @__PURE__ */ jsx12(Text12, { color: PALETTE.muted, children: "Checking for updates\u2026" });
|
|
1413
1627
|
}
|
|
1414
1628
|
if (upgradeCheck.status === "error") {
|
|
1415
|
-
return /* @__PURE__ */
|
|
1629
|
+
return /* @__PURE__ */ jsx12(Text12, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
|
|
1416
1630
|
}
|
|
1417
1631
|
if (upgradeCheck.status === "up-to-date") {
|
|
1418
|
-
return /* @__PURE__ */
|
|
1632
|
+
return /* @__PURE__ */ jsxs11(Text12, { color: PALETTE.success, children: [
|
|
1419
1633
|
"You're already on the latest version (v",
|
|
1420
1634
|
upgradeCheck.current,
|
|
1421
1635
|
")."
|
|
1422
1636
|
] });
|
|
1423
1637
|
}
|
|
1424
|
-
return /* @__PURE__ */
|
|
1425
|
-
/* @__PURE__ */
|
|
1426
|
-
/* @__PURE__ */
|
|
1638
|
+
return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", children: [
|
|
1639
|
+
/* @__PURE__ */ jsxs11(Text12, { color: PALETTE.muted, children: [
|
|
1640
|
+
/* @__PURE__ */ jsxs11(Text12, { bold: true, color: PALETTE.success, children: [
|
|
1427
1641
|
"v",
|
|
1428
1642
|
upgradeCheck.latest
|
|
1429
1643
|
] }),
|
|
1430
1644
|
" ",
|
|
1431
1645
|
"is available (you're on ",
|
|
1432
|
-
/* @__PURE__ */
|
|
1646
|
+
/* @__PURE__ */ jsxs11(Text12, { bold: true, children: [
|
|
1433
1647
|
"v",
|
|
1434
1648
|
upgradeCheck.current
|
|
1435
1649
|
] }),
|
|
1436
1650
|
"). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
|
|
1437
1651
|
] }),
|
|
1438
|
-
/* @__PURE__ */
|
|
1439
|
-
/* @__PURE__ */
|
|
1652
|
+
/* @__PURE__ */ jsx12(Text12, { children: " " }),
|
|
1653
|
+
/* @__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)) })
|
|
1440
1654
|
] });
|
|
1441
1655
|
}
|
|
1442
1656
|
|
|
1443
1657
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
1444
|
-
import { useEffect as useEffect8, useState as
|
|
1445
|
-
import { Box as
|
|
1446
|
-
import { jsx as
|
|
1658
|
+
import { useEffect as useEffect8, useState as useState12 } from "react";
|
|
1659
|
+
import { Box as Box12, Text as Text13, useInput as useInput12 } from "ink";
|
|
1660
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1447
1661
|
function DebugModeScreen({ onDone }) {
|
|
1448
|
-
const [loading, setLoading] =
|
|
1449
|
-
const [enabled, setEnabled] =
|
|
1662
|
+
const [loading, setLoading] = useState12(true);
|
|
1663
|
+
const [enabled, setEnabled] = useState12(true);
|
|
1450
1664
|
useEffect8(() => {
|
|
1451
1665
|
readDebugModeSetting().then((setting) => {
|
|
1452
1666
|
setEnabled(setting.enabled);
|
|
@@ -1459,7 +1673,7 @@ function DebugModeScreen({ onDone }) {
|
|
|
1459
1673
|
});
|
|
1460
1674
|
});
|
|
1461
1675
|
}, []);
|
|
1462
|
-
|
|
1676
|
+
useInput12((input, key) => {
|
|
1463
1677
|
if (loading) return;
|
|
1464
1678
|
if (key.return || input === " ") {
|
|
1465
1679
|
setEnabled((current) => {
|
|
@@ -1474,16 +1688,16 @@ function DebugModeScreen({ onDone }) {
|
|
|
1474
1688
|
onDone();
|
|
1475
1689
|
}
|
|
1476
1690
|
});
|
|
1477
|
-
return /* @__PURE__ */
|
|
1478
|
-
/* @__PURE__ */
|
|
1479
|
-
/* @__PURE__ */
|
|
1480
|
-
loading ? /* @__PURE__ */
|
|
1691
|
+
return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
1692
|
+
/* @__PURE__ */ jsx13(Text13, { bold: true, children: "Settings \u203A Debug Mode" }),
|
|
1693
|
+
/* @__PURE__ */ jsx13(Text13, { children: " " }),
|
|
1694
|
+
loading ? /* @__PURE__ */ jsx13(Text13, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs12(Text13, { children: [
|
|
1481
1695
|
"Debug logging:",
|
|
1482
1696
|
" ",
|
|
1483
|
-
/* @__PURE__ */
|
|
1697
|
+
/* @__PURE__ */ jsx13(Text13, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
1484
1698
|
] }),
|
|
1485
|
-
/* @__PURE__ */
|
|
1486
|
-
/* @__PURE__ */
|
|
1699
|
+
/* @__PURE__ */ jsx13(Text13, { children: " " }),
|
|
1700
|
+
/* @__PURE__ */ jsx13(
|
|
1487
1701
|
ControlHints,
|
|
1488
1702
|
{
|
|
1489
1703
|
hints: [
|
|
@@ -1496,28 +1710,38 @@ function DebugModeScreen({ onDone }) {
|
|
|
1496
1710
|
}
|
|
1497
1711
|
|
|
1498
1712
|
// packages/experience-design-system-cli/app.tsx
|
|
1499
|
-
import { Fragment as
|
|
1713
|
+
import { Fragment as Fragment5, jsx as jsx14 } from "react/jsx-runtime";
|
|
1500
1714
|
function App({ onLaunchImport, importExitCode }) {
|
|
1501
1715
|
const returnedFromImport = importExitCode !== void 0;
|
|
1502
|
-
const [screen, setScreen] =
|
|
1503
|
-
const [showImportResult, setShowImportResult] =
|
|
1504
|
-
const [projectPath, setProjectPath] =
|
|
1505
|
-
const [tokensPath, setTokensPath] =
|
|
1506
|
-
const [
|
|
1716
|
+
const [screen, setScreen] = useState13(returnedFromImport ? "import" : "start");
|
|
1717
|
+
const [showImportResult, setShowImportResult] = useState13(returnedFromImport);
|
|
1718
|
+
const [projectPath, setProjectPath] = useState13();
|
|
1719
|
+
const [tokensPath, setTokensPath] = useState13();
|
|
1720
|
+
const [pathConfirmed, setPathConfirmed] = useState13(false);
|
|
1721
|
+
const [importDefaults, setImportDefaults] = useState13();
|
|
1507
1722
|
useEffect9(() => {
|
|
1508
1723
|
if (screen !== "import") {
|
|
1509
1724
|
setImportDefaults(void 0);
|
|
1510
1725
|
return;
|
|
1511
1726
|
}
|
|
1512
1727
|
void readCredentials().then(
|
|
1513
|
-
(saved) => setImportDefaults({
|
|
1728
|
+
(saved) => setImportDefaults({
|
|
1729
|
+
componentDir: saved.defaultComponentDir ?? "",
|
|
1730
|
+
tokenFile: saved.defaultTokenFile ?? "",
|
|
1731
|
+
credentials: saved
|
|
1732
|
+
})
|
|
1514
1733
|
);
|
|
1515
1734
|
}, [screen]);
|
|
1735
|
+
const finishCredentials = async (result, project, tokens) => {
|
|
1736
|
+
if (!result.skipped) await writeCredentials({ ...result.credentials });
|
|
1737
|
+
onLaunchImport?.({ project, tokens, skipCredentials: result.skipped });
|
|
1738
|
+
};
|
|
1516
1739
|
const goToStart = () => setScreen("start");
|
|
1517
1740
|
const goToSettings = () => setScreen("settings");
|
|
1518
1741
|
const resetImport = () => {
|
|
1519
1742
|
setProjectPath(void 0);
|
|
1520
1743
|
setTokensPath(void 0);
|
|
1744
|
+
setPathConfirmed(false);
|
|
1521
1745
|
};
|
|
1522
1746
|
const finishImportResult = () => {
|
|
1523
1747
|
setShowImportResult(false);
|
|
@@ -1530,13 +1754,13 @@ function App({ onLaunchImport, importExitCode }) {
|
|
|
1530
1754
|
};
|
|
1531
1755
|
switch (screen) {
|
|
1532
1756
|
case "import":
|
|
1533
|
-
if (showImportResult) return /* @__PURE__ */
|
|
1534
|
-
if (importDefaults === void 0) return /* @__PURE__ */
|
|
1757
|
+
if (showImportResult) return /* @__PURE__ */ jsx14(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
|
|
1758
|
+
if (importDefaults === void 0) return /* @__PURE__ */ jsx14(Fragment5, {});
|
|
1535
1759
|
if (projectPath === void 0) {
|
|
1536
|
-
return /* @__PURE__ */
|
|
1760
|
+
return /* @__PURE__ */ jsx14(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
|
|
1537
1761
|
}
|
|
1538
1762
|
if (tokensPath === void 0) {
|
|
1539
|
-
return /* @__PURE__ */
|
|
1763
|
+
return /* @__PURE__ */ jsx14(
|
|
1540
1764
|
TokenInputScreen,
|
|
1541
1765
|
{
|
|
1542
1766
|
initialPath: importDefaults.tokenFile,
|
|
@@ -1545,36 +1769,46 @@ function App({ onLaunchImport, importExitCode }) {
|
|
|
1545
1769
|
}
|
|
1546
1770
|
);
|
|
1547
1771
|
}
|
|
1548
|
-
|
|
1549
|
-
|
|
1772
|
+
if (!pathConfirmed) {
|
|
1773
|
+
return /* @__PURE__ */ jsx14(
|
|
1774
|
+
PathValidationScreen,
|
|
1775
|
+
{
|
|
1776
|
+
projectPath,
|
|
1777
|
+
onConfirm: () => setPathConfirmed(true),
|
|
1778
|
+
onChangePath: resetImport,
|
|
1779
|
+
onBack: () => setTokensPath(void 0)
|
|
1780
|
+
}
|
|
1781
|
+
);
|
|
1782
|
+
}
|
|
1783
|
+
return /* @__PURE__ */ jsx14(
|
|
1784
|
+
CredentialsScreen,
|
|
1550
1785
|
{
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
onBack: () => setTokensPath(void 0)
|
|
1786
|
+
initial: importDefaults.credentials,
|
|
1787
|
+
onBack: () => setPathConfirmed(false),
|
|
1788
|
+
onDone: (result) => void finishCredentials(result, projectPath, tokensPath)
|
|
1555
1789
|
}
|
|
1556
1790
|
);
|
|
1557
1791
|
case "help":
|
|
1558
|
-
return /* @__PURE__ */
|
|
1792
|
+
return /* @__PURE__ */ jsx14(HelpScreen, { onDone: goToStart });
|
|
1559
1793
|
case "upgrade":
|
|
1560
|
-
return /* @__PURE__ */
|
|
1794
|
+
return /* @__PURE__ */ jsx14(UpgradeScreen, { onDone: goToStart });
|
|
1561
1795
|
case "settings":
|
|
1562
|
-
return /* @__PURE__ */
|
|
1796
|
+
return /* @__PURE__ */ jsx14(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
|
|
1563
1797
|
case "settings-configuration":
|
|
1564
|
-
return /* @__PURE__ */
|
|
1798
|
+
return /* @__PURE__ */ jsx14(ConfigurationScreen, { onDone: goToSettings });
|
|
1565
1799
|
case "settings-opt-in-analytics":
|
|
1566
|
-
return /* @__PURE__ */
|
|
1800
|
+
return /* @__PURE__ */ jsx14(OptInAnalyticsScreen, { onDone: goToSettings });
|
|
1567
1801
|
case "settings-debug-mode":
|
|
1568
|
-
return /* @__PURE__ */
|
|
1802
|
+
return /* @__PURE__ */ jsx14(DebugModeScreen, { onDone: goToSettings });
|
|
1569
1803
|
case "start":
|
|
1570
|
-
return /* @__PURE__ */
|
|
1804
|
+
return /* @__PURE__ */ jsx14(HomeScreen, { onNavigate: setScreen });
|
|
1571
1805
|
}
|
|
1572
1806
|
}
|
|
1573
1807
|
var CLEAR_SCREEN = "\x1B[2J\x1B[H";
|
|
1574
1808
|
async function renderUntilImportRequestedOrExit(renderApp, importExitCode) {
|
|
1575
1809
|
let requestedImport;
|
|
1576
1810
|
const instance = renderApp(
|
|
1577
|
-
/* @__PURE__ */
|
|
1811
|
+
/* @__PURE__ */ jsx14(
|
|
1578
1812
|
App,
|
|
1579
1813
|
{
|
|
1580
1814
|
importExitCode,
|