@hexclave/cli 1.0.64 → 1.0.66
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 +13 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/lib/app.test.ts +68 -0
- package/src/lib/app.ts +22 -1
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import { Command } from "commander";
|
|
|
17
17
|
import { StackClientApp } from "@hexclave/js";
|
|
18
18
|
import fs from "node:fs";
|
|
19
19
|
import path from "node:path";
|
|
20
|
+
import { createUrlIfValid } from "@hexclave/shared/dist/utils/urls";
|
|
20
21
|
import { createTar } from "@hexclave/shared/dist/utils/tar";
|
|
21
22
|
import { gzipSync } from "node:zlib";
|
|
22
23
|
import { hexclaveDevEnvStatePath } from "@hexclave/shared/dist/utils/dev-env-state-path";
|
|
@@ -287,6 +288,14 @@ var app_exports = /* @__PURE__ */ __exportAll({
|
|
|
287
288
|
getInternalApp: () => getInternalApp,
|
|
288
289
|
getInternalUser: () => getInternalUser
|
|
289
290
|
});
|
|
291
|
+
function onboardingUrlFor(dashboardUrl) {
|
|
292
|
+
const parsedDashboardUrl = createUrlIfValid(dashboardUrl);
|
|
293
|
+
if (parsedDashboardUrl == null) return `${dashboardUrl.replace(/\/+$/, "")}/onboarding`;
|
|
294
|
+
parsedDashboardUrl.pathname = `${parsedDashboardUrl.pathname.replace(/\/+$/, "")}/onboarding`;
|
|
295
|
+
parsedDashboardUrl.search = "";
|
|
296
|
+
parsedDashboardUrl.hash = "";
|
|
297
|
+
return parsedDashboardUrl.toString();
|
|
298
|
+
}
|
|
290
299
|
function getInternalApp(auth) {
|
|
291
300
|
return new StackClientApp({
|
|
292
301
|
projectId: "internal",
|
|
@@ -300,7 +309,10 @@ function getInternalApp(auth) {
|
|
|
300
309
|
});
|
|
301
310
|
}
|
|
302
311
|
async function getInternalUser(auth) {
|
|
303
|
-
|
|
312
|
+
const user = await getInternalApp(auth).getUser({ includeRestricted: true });
|
|
313
|
+
if (user == null) throw new AuthError("Your session is invalid or expired. Run `hexclave login` again.");
|
|
314
|
+
if (user.isRestricted) throw new AuthError(`Finish setting up your account at ${onboardingUrlFor(auth.dashboardUrl)} before using the CLI.`);
|
|
315
|
+
return user;
|
|
304
316
|
}
|
|
305
317
|
async function getAdminProject(auth) {
|
|
306
318
|
const project = (await (await getInternalUser(auth)).listOwnedProjects()).find((p) => p.id === auth.projectId);
|