@stackable-labs/cli-app-extension 1.99.2 → 1.100.1
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/index.js +44 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3732,7 +3732,7 @@ var performCLIOAuthFlow = async ({ dashboardUrl, adminApiBaseUrl }) => {
|
|
|
3732
3732
|
await writeAuthState(authState);
|
|
3733
3733
|
return { authState, loginUrl };
|
|
3734
3734
|
};
|
|
3735
|
-
var AuthLogin = ({ dashboardUrl, adminApiBaseUrl }) => {
|
|
3735
|
+
var AuthLogin = ({ dashboardUrl, adminApiBaseUrl, reason, onSuccess, onError }) => {
|
|
3736
3736
|
const { exit } = useApp();
|
|
3737
3737
|
const [state, setState] = useState("waiting");
|
|
3738
3738
|
const [loginUrl, setLoginUrl] = useState("");
|
|
@@ -3751,12 +3751,15 @@ var AuthLogin = ({ dashboardUrl, adminApiBaseUrl }) => {
|
|
|
3751
3751
|
setUserIdLabel(result.authState.userId);
|
|
3752
3752
|
setOrgIdLabel(result.authState.orgId);
|
|
3753
3753
|
setState("success");
|
|
3754
|
+
onSuccess?.(result.authState);
|
|
3754
3755
|
} catch (err) {
|
|
3755
3756
|
if (cancelled) {
|
|
3756
3757
|
return;
|
|
3757
3758
|
}
|
|
3758
|
-
|
|
3759
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
3760
|
+
setErrorMessage(error.message);
|
|
3759
3761
|
setState("error");
|
|
3762
|
+
onError?.(error);
|
|
3760
3763
|
}
|
|
3761
3764
|
exit();
|
|
3762
3765
|
};
|
|
@@ -3766,16 +3769,19 @@ var AuthLogin = ({ dashboardUrl, adminApiBaseUrl }) => {
|
|
|
3766
3769
|
};
|
|
3767
3770
|
}, []);
|
|
3768
3771
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
3769
|
-
/* @__PURE__ */ jsx(Banner, {}),
|
|
3772
|
+
!reason && /* @__PURE__ */ jsx(Banner, {}),
|
|
3770
3773
|
/* @__PURE__ */ jsxs(StepShell, { title: "Authenticate with Stackable", children: [
|
|
3771
|
-
state === "waiting" && /* @__PURE__ */ jsxs(
|
|
3772
|
-
/* @__PURE__ */
|
|
3773
|
-
|
|
3774
|
-
/* @__PURE__ */
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
loginUrl
|
|
3774
|
+
state === "waiting" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3775
|
+
reason && /* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { color: "yellow", children: reason === "expired" ? "Session expired \u2014 re-authenticating before continuing\u2026" : "Not signed in \u2014 opening browser to authenticate\u2026" }) }),
|
|
3776
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, children: [
|
|
3777
|
+
/* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
3778
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: /* @__PURE__ */ jsx(Spinner5, { type: "dots" }) }),
|
|
3779
|
+
/* @__PURE__ */ jsx(Text, { children: "Waiting for browser authentication..." })
|
|
3780
|
+
] }),
|
|
3781
|
+
loginUrl && /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
3782
|
+
" ",
|
|
3783
|
+
loginUrl
|
|
3784
|
+
] })
|
|
3779
3785
|
] })
|
|
3780
3786
|
] }),
|
|
3781
3787
|
state === "success" && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, children: [
|
|
@@ -3913,6 +3919,7 @@ var checkForUpdate = (currentVersion) => {
|
|
|
3913
3919
|
var require2 = createRequire(import.meta.url);
|
|
3914
3920
|
var { version } = require2("../package.json");
|
|
3915
3921
|
checkForUpdate(version);
|
|
3922
|
+
var DASHBOARD_URL = process.env.ADMIN_DASHBOARD_URL ?? "https://admin.stackablelabs.com";
|
|
3916
3923
|
var ensureToken = async () => {
|
|
3917
3924
|
try {
|
|
3918
3925
|
const token = await getToken();
|
|
@@ -3921,10 +3928,33 @@ var ensureToken = async () => {
|
|
|
3921
3928
|
} catch (err) {
|
|
3922
3929
|
const message = err instanceof Error ? err.message : String(err);
|
|
3923
3930
|
const isExpired = message.toLowerCase().includes("expired");
|
|
3924
|
-
|
|
3925
|
-
|
|
3931
|
+
let recoveredState = null;
|
|
3932
|
+
let flowError = null;
|
|
3933
|
+
const instance = render(
|
|
3934
|
+
/* @__PURE__ */ jsx(
|
|
3935
|
+
AuthLogin,
|
|
3936
|
+
{
|
|
3937
|
+
dashboardUrl: DASHBOARD_URL,
|
|
3938
|
+
adminApiBaseUrl: getAdminApiBaseUrl(),
|
|
3939
|
+
reason: isExpired ? "expired" : "not-logged-in",
|
|
3940
|
+
onSuccess: (authState) => {
|
|
3941
|
+
recoveredState = authState;
|
|
3942
|
+
},
|
|
3943
|
+
onError: (err2) => {
|
|
3944
|
+
flowError = err2;
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
)
|
|
3926
3948
|
);
|
|
3927
|
-
|
|
3949
|
+
await instance.waitUntilExit();
|
|
3950
|
+
if (flowError || !recoveredState) {
|
|
3951
|
+
return null;
|
|
3952
|
+
}
|
|
3953
|
+
return {
|
|
3954
|
+
token: recoveredState.token,
|
|
3955
|
+
userId: recoveredState.userId,
|
|
3956
|
+
orgId: recoveredState.orgId
|
|
3957
|
+
};
|
|
3928
3958
|
}
|
|
3929
3959
|
};
|
|
3930
3960
|
program.name("stackable-app-extension").description("Stackable Labs - App Extension developer CLI").version(version);
|
|
@@ -4007,7 +4037,6 @@ program.command("dev" /* DEV */).description("Start dev servers with a public tu
|
|
|
4007
4037
|
{ exitOnCtrlC: false }
|
|
4008
4038
|
);
|
|
4009
4039
|
});
|
|
4010
|
-
var DASHBOARD_URL = process.env.ADMIN_DASHBOARD_URL ?? "https://admin.stackablelabs.com";
|
|
4011
4040
|
var auth = program.command("auth").description("Manage CLI authentication");
|
|
4012
4041
|
auth.command("login").description("Authenticate with Stackable via browser").action(async () => {
|
|
4013
4042
|
render(/* @__PURE__ */ jsx(AuthLogin, { dashboardUrl: DASHBOARD_URL, adminApiBaseUrl: getAdminApiBaseUrl() }));
|