@zalify/cli 0.2.2 → 0.2.3
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 +46 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -11424,11 +11424,51 @@ 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
|
-
|
|
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
|
+
}
|
|
11430
11470
|
console.log(`app ${config.appUrl}`);
|
|
11431
|
-
console.log(`
|
|
11471
|
+
console.log(live ? "status ✓ key verified" : `status ! not verified — ${liveError}`);
|
|
11432
11472
|
}
|
|
11433
11473
|
|
|
11434
11474
|
// src/assets.ts
|
|
@@ -11643,7 +11683,9 @@ program2.command("login").description("Authenticate via the browser and store a
|
|
|
11643
11683
|
await login(options);
|
|
11644
11684
|
});
|
|
11645
11685
|
program2.command("logout").description("Delete the stored CLI credentials").action(() => logout());
|
|
11646
|
-
program2.command("whoami").description("
|
|
11686
|
+
program2.command("whoami").description("Verify the stored key and show workspace, plan, and key details").action(async () => {
|
|
11687
|
+
await whoami();
|
|
11688
|
+
});
|
|
11647
11689
|
var assets = program2.command("assets").description("Sync images with the Zalify asset library");
|
|
11648
11690
|
assets.command("push <store-dir>").description("Upload <store-dir>/images/*.png (sha256 dedup, writes assets.json)").action(async (storeDir) => {
|
|
11649
11691
|
await assetsPush(storeDir);
|