vercel-vm-factory 0.1.5 → 0.2.8
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/deploy-vm.mjs +61 -13
- package/package.json +1 -1
package/deploy-vm.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { stdin as input, stdout as output } from "node:process";
|
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
|
|
9
|
-
const defaultWsShellImage = "ghcr.io/v1xingyue/ws-shell:v1.
|
|
9
|
+
const defaultWsShellImage = "ghcr.io/v1xingyue/ws-shell:v1.8.alpine";
|
|
10
10
|
|
|
11
11
|
const bases = {
|
|
12
12
|
alpine: "alpine:3.23",
|
|
@@ -57,6 +57,8 @@ try {
|
|
|
57
57
|
|
|
58
58
|
async function main() {
|
|
59
59
|
printHeader();
|
|
60
|
+
await ensureVercelInstalled();
|
|
61
|
+
await ensureVercelLogin();
|
|
60
62
|
|
|
61
63
|
if (args.doctor || command === "doctor") {
|
|
62
64
|
await doctor();
|
|
@@ -119,7 +121,6 @@ async function main() {
|
|
|
119
121
|
return;
|
|
120
122
|
}
|
|
121
123
|
|
|
122
|
-
await ensureVercelReady();
|
|
123
124
|
if (usesGitHubAuth(authMode)) printOAuthGuide(oauthRedirectUrl);
|
|
124
125
|
|
|
125
126
|
const authUsername = usesBasicAuth(authMode)
|
|
@@ -233,29 +234,76 @@ async function setContainerFramework(appDir, commonArgs) {
|
|
|
233
234
|
]);
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
async function
|
|
237
|
+
async function ensureVercelLogin() {
|
|
238
|
+
step("Checking Vercel login");
|
|
239
|
+
try {
|
|
240
|
+
const whoami = await runCapture("vercel", ["whoami"]);
|
|
241
|
+
ok(`logged in as ${whoami.trim()}`);
|
|
242
|
+
} catch {
|
|
243
|
+
warn("Vercel CLI is not logged in. Starting vercel login...");
|
|
244
|
+
await runNoUrl("vercel", ["login"]);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async function ensureVercelInstalled() {
|
|
237
249
|
step("Checking Vercel CLI");
|
|
238
250
|
try {
|
|
239
251
|
const version = await runCapture("vercel", ["--version"]);
|
|
240
252
|
ok(version.split("\n").filter(Boolean).at(-1) || "vercel installed");
|
|
241
253
|
} catch {
|
|
254
|
+
await installVercelCli();
|
|
255
|
+
const version = await runCapture("vercel", ["--version"]);
|
|
256
|
+
ok(version.split("\n").filter(Boolean).at(-1) || "vercel installed");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
async function installVercelCli() {
|
|
261
|
+
if (!input.isTTY)
|
|
242
262
|
throw new Error(
|
|
243
|
-
"Vercel CLI is not installed.
|
|
263
|
+
"Vercel CLI is not installed. Run this in a terminal to install it.",
|
|
244
264
|
);
|
|
245
|
-
}
|
|
246
265
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
266
|
+
const install = await choosePackageInstall();
|
|
267
|
+
const rl = createInterface({ input, output });
|
|
268
|
+
const answer = (
|
|
269
|
+
await rl.question(
|
|
270
|
+
`Vercel CLI is not installed. Install it with "${install.command} ${install.args.join(" ")}"? [y/N]: `,
|
|
271
|
+
)
|
|
272
|
+
)
|
|
273
|
+
.trim()
|
|
274
|
+
.toLowerCase();
|
|
275
|
+
rl.close();
|
|
276
|
+
|
|
277
|
+
if (answer !== "y" && answer !== "yes")
|
|
278
|
+
throw new Error("Vercel CLI is required. Exiting.");
|
|
279
|
+
|
|
280
|
+
step(`Installing Vercel CLI with ${install.command}`);
|
|
281
|
+
await runNoUrl(install.command, install.args);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
async function choosePackageInstall() {
|
|
285
|
+
const installs = [
|
|
286
|
+
{ command: "pnpm", args: ["add", "-g", "vercel"] },
|
|
287
|
+
{ command: "npm", args: ["install", "-g", "vercel"] },
|
|
288
|
+
{ command: "yarn", args: ["global", "add", "vercel"] },
|
|
289
|
+
{ command: "bun", args: ["add", "-g", "vercel"] },
|
|
290
|
+
];
|
|
291
|
+
|
|
292
|
+
for (const install of installs) {
|
|
293
|
+
try {
|
|
294
|
+
await runCapture(install.command, ["--version"]);
|
|
295
|
+
return install;
|
|
296
|
+
} catch {
|
|
297
|
+
// Try the next package manager.
|
|
298
|
+
}
|
|
254
299
|
}
|
|
300
|
+
|
|
301
|
+
throw new Error(
|
|
302
|
+
"No package manager found. Install pnpm, npm, yarn, or bun first.",
|
|
303
|
+
);
|
|
255
304
|
}
|
|
256
305
|
|
|
257
306
|
async function doctor() {
|
|
258
|
-
await ensureVercelReady();
|
|
259
307
|
console.log("");
|
|
260
308
|
console.log(color.bold("Saved defaults"));
|
|
261
309
|
printKeyValue("defaults file", defaultsPath);
|