@zalify/cli 0.2.2 → 0.2.4
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/cli.js +50 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -11424,11 +11424,52 @@ function logout() {
|
|
|
11424
11424
|
console.log("✓ Logged out (local credentials deleted).");
|
|
11425
11425
|
console.log(" To revoke the key itself: app.zalify.com → Settings → Developer.");
|
|
11426
11426
|
}
|
|
11427
|
-
function
|
|
11427
|
+
function ago(iso) {
|
|
11428
|
+
if (!iso)
|
|
11429
|
+
return "never";
|
|
11430
|
+
const ms = Date.now() - new Date(iso).getTime();
|
|
11431
|
+
const minutes = Math.round(ms / 60000);
|
|
11432
|
+
if (minutes < 1)
|
|
11433
|
+
return "just now";
|
|
11434
|
+
if (minutes < 60)
|
|
11435
|
+
return `${minutes}m ago`;
|
|
11436
|
+
const hours = Math.round(minutes / 60);
|
|
11437
|
+
if (hours < 24)
|
|
11438
|
+
return `${hours}h ago`;
|
|
11439
|
+
return `${Math.round(hours / 24)}d ago`;
|
|
11440
|
+
}
|
|
11441
|
+
async function whoami() {
|
|
11428
11442
|
const config = requireConfig();
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11443
|
+
let live = null;
|
|
11444
|
+
let liveError = null;
|
|
11445
|
+
try {
|
|
11446
|
+
const res = await fetch(`${config.appUrl}/api/cli/whoami`, {
|
|
11447
|
+
headers: { Authorization: `Bearer ${config.key}` }
|
|
11448
|
+
});
|
|
11449
|
+
if (res.ok) {
|
|
11450
|
+
live = await res.json();
|
|
11451
|
+
} else if (res.status === 401) {
|
|
11452
|
+
liveError = "key is invalid or was revoked — run `zalify login`";
|
|
11453
|
+
} else {
|
|
11454
|
+
liveError = `server returned ${res.status}`;
|
|
11455
|
+
}
|
|
11456
|
+
} catch {
|
|
11457
|
+
liveError = "could not reach the server (offline?)";
|
|
11458
|
+
}
|
|
11459
|
+
const ws = live?.workspace;
|
|
11460
|
+
console.log(`workspace ${ws?.name ?? config.workspaceName ?? "(unknown)"} (${ws?.slug ?? config.workspaceSlug ?? "?"}) [${ws?.id ?? config.workspaceId}]`);
|
|
11461
|
+
if (live) {
|
|
11462
|
+
console.log(`plan ${live.plan.name} (${live.plan.type})`);
|
|
11463
|
+
if (live.key.createdByName) {
|
|
11464
|
+
console.log(`user ${live.key.createdByName}`);
|
|
11465
|
+
}
|
|
11466
|
+
console.log(`key ${live.key.name ?? config.key.slice(0, 16) + "…"} — created ${live.key.createdAt ? new Date(live.key.createdAt).toISOString().slice(0, 10) : "?"}, last used ${ago(live.key.lastRequest)}`);
|
|
11467
|
+
} else {
|
|
11468
|
+
console.log(`key ${config.key.slice(0, 16)}…`);
|
|
11469
|
+
}
|
|
11470
|
+
const slug = ws?.slug ?? config.workspaceSlug;
|
|
11471
|
+
console.log(`app ${slug ? `${config.appUrl}/store/${slug}` : config.appUrl}`);
|
|
11472
|
+
console.log(live ? "status ✓ key verified" : `status ! not verified — ${liveError}`);
|
|
11432
11473
|
}
|
|
11433
11474
|
|
|
11434
11475
|
// src/assets.ts
|
|
@@ -11488,8 +11529,9 @@ async function assetsPush(storeDir) {
|
|
|
11488
11529
|
const json = await res.json().catch(() => ({}));
|
|
11489
11530
|
if (!res.ok) {
|
|
11490
11531
|
if (json.code === "UPGRADE_REQUIRED") {
|
|
11532
|
+
const billingUrl = config.workspaceSlug ? `${config.appUrl}/store/${config.workspaceSlug}/settings/billing` : `${config.appUrl} (Settings → Billing)`;
|
|
11491
11533
|
throw new Error(`${json.error ?? "This feature requires a paid plan."}
|
|
11492
|
-
` + ` Upgrade this workspace
|
|
11534
|
+
` + ` Upgrade this workspace: ${billingUrl}`);
|
|
11493
11535
|
}
|
|
11494
11536
|
throw new Error(`${path9} ${res.status}: ${JSON.stringify(json)}`);
|
|
11495
11537
|
}
|
|
@@ -11643,7 +11685,9 @@ program2.command("login").description("Authenticate via the browser and store a
|
|
|
11643
11685
|
await login(options);
|
|
11644
11686
|
});
|
|
11645
11687
|
program2.command("logout").description("Delete the stored CLI credentials").action(() => logout());
|
|
11646
|
-
program2.command("whoami").description("
|
|
11688
|
+
program2.command("whoami").description("Verify the stored key and show workspace, plan, and key details").action(async () => {
|
|
11689
|
+
await whoami();
|
|
11690
|
+
});
|
|
11647
11691
|
var assets = program2.command("assets").description("Sync images with the Zalify asset library");
|
|
11648
11692
|
assets.command("push <store-dir>").description("Upload <store-dir>/images/*.png (sha256 dedup, writes assets.json)").action(async (storeDir) => {
|
|
11649
11693
|
await assetsPush(storeDir);
|