@zalify/cli 0.2.1 → 0.2.2
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 +48 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -11486,8 +11486,13 @@ async function assetsPush(storeDir) {
|
|
|
11486
11486
|
body: JSON.stringify(body)
|
|
11487
11487
|
});
|
|
11488
11488
|
const json = await res.json().catch(() => ({}));
|
|
11489
|
-
if (!res.ok)
|
|
11489
|
+
if (!res.ok) {
|
|
11490
|
+
if (json.code === "UPGRADE_REQUIRED") {
|
|
11491
|
+
throw new Error(`${json.error ?? "This feature requires a paid plan."}
|
|
11492
|
+
` + ` Upgrade this workspace at ${config.appUrl} (Settings → Billing).`);
|
|
11493
|
+
}
|
|
11490
11494
|
throw new Error(`${path9} ${res.status}: ${JSON.stringify(json)}`);
|
|
11495
|
+
}
|
|
11491
11496
|
return json;
|
|
11492
11497
|
}
|
|
11493
11498
|
const files = readdirSync(imagesDir).filter((f) => f.endsWith(".png")).map((name) => {
|
|
@@ -11566,10 +11571,51 @@ async function assetsPush(storeDir) {
|
|
|
11566
11571
|
console.log("Done.");
|
|
11567
11572
|
}
|
|
11568
11573
|
|
|
11574
|
+
// src/self-update.ts
|
|
11575
|
+
import { spawnSync } from "node:child_process";
|
|
11576
|
+
import { realpathSync } from "node:fs";
|
|
11577
|
+
function detectManager() {
|
|
11578
|
+
let binPath = process.argv[1] ?? "";
|
|
11579
|
+
try {
|
|
11580
|
+
binPath = realpathSync(binPath);
|
|
11581
|
+
} catch {}
|
|
11582
|
+
if (binPath.includes("/pnpm/") || binPath.includes("/.pnpm/")) {
|
|
11583
|
+
return { cmd: "pnpm", args: ["add", "-g", "@zalify/cli@latest"] };
|
|
11584
|
+
}
|
|
11585
|
+
if (binPath.includes("/.bun/")) {
|
|
11586
|
+
return { cmd: "bun", args: ["add", "-g", "@zalify/cli@latest"] };
|
|
11587
|
+
}
|
|
11588
|
+
return { cmd: "npm", args: ["install", "-g", "@zalify/cli@latest"] };
|
|
11589
|
+
}
|
|
11590
|
+
function selfUpdate(currentVersion) {
|
|
11591
|
+
const { cmd, args } = detectManager();
|
|
11592
|
+
console.log(`Current version: ${currentVersion}`);
|
|
11593
|
+
console.log(`Updating via: ${cmd} ${args.join(" ")}
|
|
11594
|
+
`);
|
|
11595
|
+
const result = spawnSync(cmd, args, { stdio: "inherit" });
|
|
11596
|
+
if (result.error || result.status !== 0) {
|
|
11597
|
+
console.error(`
|
|
11598
|
+
Update failed${result.error ? `: ${result.error.message}` : ""}.` + `
|
|
11599
|
+
Try manually: ${cmd} ${args.join(" ")}`);
|
|
11600
|
+
process.exit(result.status ?? 1);
|
|
11601
|
+
}
|
|
11602
|
+
const check = spawnSync("zalify", ["--version"], { encoding: "utf8" });
|
|
11603
|
+
const updated = check.stdout?.trim();
|
|
11604
|
+
console.log(updated && updated !== currentVersion ? `
|
|
11605
|
+
✓ Updated ${currentVersion} → ${updated}` : `
|
|
11606
|
+
✓ Done${updated ? ` (version: ${updated})` : ""}`);
|
|
11607
|
+
}
|
|
11608
|
+
|
|
11569
11609
|
// src/cli.ts
|
|
11570
11610
|
var __dirname4 = dirname(fileURLToPath3(import.meta.url));
|
|
11571
11611
|
var require2 = createRequire2(import.meta.url);
|
|
11572
11612
|
var pkg = require2(join3(__dirname4, "..", "package.json"));
|
|
11613
|
+
try {
|
|
11614
|
+
updateNotifier({ pkg }).notify({
|
|
11615
|
+
isGlobal: true,
|
|
11616
|
+
message: "Update available {currentVersion} → {latestVersion}\nRun `zalify self-update`"
|
|
11617
|
+
});
|
|
11618
|
+
} catch {}
|
|
11573
11619
|
var program2 = new Command;
|
|
11574
11620
|
program2.name("zalify").description("Zalify CLI - command-line interface for Zalify").version(pkg.version, "-v, --version", "output the current version");
|
|
11575
11621
|
program2.command("version").description("Print Zalify CLI version and check for updates").action(async () => {
|
|
@@ -11592,6 +11638,7 @@ A new version (${update.latest}) is available. Run "npm i -g @zalify/cli@latest"
|
|
|
11592
11638
|
}
|
|
11593
11639
|
} catch {}
|
|
11594
11640
|
});
|
|
11641
|
+
program2.command("self-update").description("Update the CLI to the latest version (auto-detects pnpm/bun/npm)").action(() => selfUpdate(pkg.version));
|
|
11595
11642
|
program2.command("login").description("Authenticate via the browser and store a workspace API key").option("--app-url <url>", "Zalify app origin (default: https://app.zalify.com)").action(async (options) => {
|
|
11596
11643
|
await login(options);
|
|
11597
11644
|
});
|