vercel-vm-factory 0.5.8 → 0.6.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/README.md +5 -5
- package/deploy-vm.mjs +38 -22
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Vercel VM Factory
|
|
2
2
|
|
|
3
|
-
Create a tiny Vercel Container deployment: copy `wsterm` from `ghcr.io/v1xingyue/ws-shell:v1.8.alpine` into a selected
|
|
3
|
+
Create a tiny Vercel Container deployment: copy `wsterm` from `ghcr.io/v1xingyue/ws-shell:v1.8.alpine` into a selected VM image, then deploy with Vercel CLI.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npx vercel-vm-factory create \
|
|
7
|
-
--
|
|
7
|
+
--vm-image ubuntu \
|
|
8
8
|
--project ws-shell-ubuntu \
|
|
9
9
|
--auth-mode basic \
|
|
10
10
|
--auth-user admin \
|
|
@@ -50,16 +50,16 @@ CLI mapping:
|
|
|
50
50
|
- Application Preset -> patched through Vercel API as `framework=container`
|
|
51
51
|
- Root Directory -> generated project directory
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
VM image presets:
|
|
54
54
|
|
|
55
55
|
- `alpine` -> `alpine:3.23`
|
|
56
56
|
- `ubuntu` -> `ubuntu:24.04`
|
|
57
57
|
- `debian` -> `debian:13-slim`
|
|
58
58
|
|
|
59
|
-
Custom
|
|
59
|
+
Custom VM image:
|
|
60
60
|
|
|
61
61
|
```bash
|
|
62
|
-
npx vercel-vm-factory create --
|
|
62
|
+
npx vercel-vm-factory create --vm-image fedora:42 --project ws-shell-fedora
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
Before deploying, set the GitHub OAuth callback URL to:
|
package/deploy-vm.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import path from "node:path";
|
|
|
8
8
|
|
|
9
9
|
const defaultWsShellImage = "ghcr.io/v1xingyue/ws-shell:v1.8.alpine";
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const vmImages = {
|
|
12
12
|
alpine: "alpine:3.23",
|
|
13
13
|
ubuntu: "ubuntu:24.04",
|
|
14
14
|
debian: "debian:13-slim",
|
|
@@ -20,7 +20,7 @@ const workspaceRoot = process.cwd();
|
|
|
20
20
|
const stateRoot = path.join(homedir(), ".vercel-vm-factory");
|
|
21
21
|
const defaultsPath = path.join(stateRoot, "defaults.json");
|
|
22
22
|
const legacyDefaultsPath = path.join(scriptRoot, ".defaults.json");
|
|
23
|
-
const codeDefaults = {
|
|
23
|
+
const codeDefaults = { "vm-image": "alpine", from: defaultWsShellImage };
|
|
24
24
|
const packagedDefaults = {
|
|
25
25
|
...(await readDefaults(legacyDefaultsPath)),
|
|
26
26
|
...codeDefaults,
|
|
@@ -71,8 +71,10 @@ async function main() {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const
|
|
75
|
-
|
|
74
|
+
const vmImageName = await chooseVmImage(
|
|
75
|
+
args["vm-image"] ?? args.base ?? defaults["vm-image"] ?? "alpine",
|
|
76
|
+
);
|
|
77
|
+
const vmImage = vmImages[vmImageName] ?? vmImageName;
|
|
76
78
|
const scope = await optionalValue(
|
|
77
79
|
"scope",
|
|
78
80
|
"Vercel team/scope",
|
|
@@ -81,7 +83,7 @@ async function main() {
|
|
|
81
83
|
const project = await value(
|
|
82
84
|
"project",
|
|
83
85
|
"Vercel project name",
|
|
84
|
-
defaults.project ?? `ws-shell-${
|
|
86
|
+
defaults.project ?? `ws-shell-${vmImageName}`,
|
|
85
87
|
);
|
|
86
88
|
const wsShellImage =
|
|
87
89
|
args.from ??
|
|
@@ -105,14 +107,14 @@ async function main() {
|
|
|
105
107
|
".generated",
|
|
106
108
|
project,
|
|
107
109
|
);
|
|
108
|
-
const dockerfile = makeDockerfile({
|
|
110
|
+
const dockerfile = makeDockerfile({ vmImage, wsShellImage });
|
|
109
111
|
|
|
110
112
|
await rm(appDir, { recursive: true, force: true });
|
|
111
113
|
await mkdir(appDir, { recursive: true });
|
|
112
114
|
await writeFile(path.join(appDir, "Dockerfile.vercel"), dockerfile);
|
|
113
115
|
|
|
114
116
|
printSummary({
|
|
115
|
-
|
|
117
|
+
"vm image": `${vmImageName} -> ${vmImage}`,
|
|
116
118
|
project,
|
|
117
119
|
scope: scope || "default",
|
|
118
120
|
source: wsShellImage,
|
|
@@ -167,7 +169,7 @@ async function main() {
|
|
|
167
169
|
|
|
168
170
|
await writeDefaults(defaultsPath, {
|
|
169
171
|
...defaults,
|
|
170
|
-
|
|
172
|
+
"vm-image": vmImageName,
|
|
171
173
|
scope: scope || undefined,
|
|
172
174
|
project,
|
|
173
175
|
from: wsShellImage,
|
|
@@ -313,7 +315,7 @@ async function doctor() {
|
|
|
313
315
|
console.log("");
|
|
314
316
|
console.log(color.bold("Saved defaults"));
|
|
315
317
|
printKeyValue("defaults file", defaultsPath);
|
|
316
|
-
printKeyValue("
|
|
318
|
+
printKeyValue("vm image", defaults["vm-image"] || "not set");
|
|
317
319
|
printKeyValue("project", defaults.project || "not set");
|
|
318
320
|
printKeyValue("scope", defaults.scope || "not set");
|
|
319
321
|
printKeyValue("source image", defaults.from || defaultWsShellImage);
|
|
@@ -340,12 +342,12 @@ async function doctor() {
|
|
|
340
342
|
);
|
|
341
343
|
}
|
|
342
344
|
|
|
343
|
-
function makeDockerfile({
|
|
345
|
+
function makeDockerfile({ vmImage, wsShellImage }) {
|
|
344
346
|
return `ARG WS_SHELL_IMAGE=${wsShellImage}
|
|
345
|
-
ARG
|
|
347
|
+
ARG VM_IMAGE=${vmImage}
|
|
346
348
|
|
|
347
349
|
FROM \${WS_SHELL_IMAGE} AS ws-shell
|
|
348
|
-
FROM \${
|
|
350
|
+
FROM \${VM_IMAGE} AS vm
|
|
349
351
|
|
|
350
352
|
# wsterm already embeds the web UI; runtime config comes from environment variables.
|
|
351
353
|
COPY --from=ws-shell /app/bin/wsterm /app/bin/wsterm
|
|
@@ -449,28 +451,33 @@ function usesGitHubAuth(mode) {
|
|
|
449
451
|
return mode === "github" || mode === "both";
|
|
450
452
|
}
|
|
451
453
|
|
|
452
|
-
async function
|
|
454
|
+
async function chooseVmImage(fallback) {
|
|
455
|
+
if (args["vm-image"]) return args["vm-image"];
|
|
453
456
|
if (args.base) return args.base;
|
|
454
457
|
if (!input.isTTY) return fallback;
|
|
455
458
|
|
|
456
|
-
const names = Object.keys(
|
|
457
|
-
console.log(color.bold("Choose
|
|
459
|
+
const names = Object.keys(vmImages);
|
|
460
|
+
console.log(color.bold("Choose VM image"));
|
|
458
461
|
names.forEach((name, index) =>
|
|
459
462
|
console.log(
|
|
460
|
-
` ${color.cyan(String(index + 1))}. ${name} ${color.dim(`(${
|
|
463
|
+
` ${color.cyan(String(index + 1))}. ${name} ${color.dim(`(${vmImages[name]})`)}`,
|
|
461
464
|
),
|
|
462
465
|
);
|
|
463
466
|
console.log(` ${color.cyan("4")}. custom image`);
|
|
464
467
|
|
|
465
468
|
const rl = createInterface({ input, output });
|
|
466
|
-
const answer = (await rl.question(`
|
|
469
|
+
const answer = (await rl.question(`VM image [${fallback}]: `)).trim();
|
|
467
470
|
rl.close();
|
|
468
471
|
|
|
469
472
|
if (!answer) return fallback;
|
|
470
|
-
if (
|
|
473
|
+
if (vmImages[answer]) return answer;
|
|
471
474
|
if (/^[1-3]$/.test(answer)) return names[Number(answer) - 1];
|
|
472
475
|
if (answer === "4")
|
|
473
|
-
return value(
|
|
476
|
+
return value(
|
|
477
|
+
"custom-vm-image",
|
|
478
|
+
"Custom VM image",
|
|
479
|
+
defaults["custom-vm-image"],
|
|
480
|
+
);
|
|
474
481
|
return answer;
|
|
475
482
|
}
|
|
476
483
|
|
|
@@ -517,8 +524,16 @@ async function writeDefaults(file, data) {
|
|
|
517
524
|
}
|
|
518
525
|
|
|
519
526
|
function cleanDefaults(data) {
|
|
527
|
+
const migrated = {
|
|
528
|
+
...data,
|
|
529
|
+
"vm-image": data["vm-image"] ?? data.base,
|
|
530
|
+
"custom-vm-image": data["custom-vm-image"] ?? data["custom-base"],
|
|
531
|
+
};
|
|
532
|
+
delete migrated.base;
|
|
533
|
+
delete migrated["custom-base"];
|
|
534
|
+
|
|
520
535
|
const clean = Object.fromEntries(
|
|
521
|
-
Object.entries(
|
|
536
|
+
Object.entries(migrated).filter(([, value]) => value),
|
|
522
537
|
);
|
|
523
538
|
return Object.fromEntries(
|
|
524
539
|
Object.entries(clean).sort(([a], [b]) => a.localeCompare(b)),
|
|
@@ -681,12 +696,13 @@ function printHelp() {
|
|
|
681
696
|
printHeader();
|
|
682
697
|
console.log(`Usage:
|
|
683
698
|
vercel-vm-factory create
|
|
684
|
-
vercel-vm-factory create --
|
|
699
|
+
vercel-vm-factory create --vm-image ubuntu --project x-shell
|
|
685
700
|
vercel-vm-factory doctor
|
|
686
701
|
npx vercel-vm-factory create
|
|
687
702
|
|
|
688
703
|
Options:
|
|
689
|
-
--
|
|
704
|
+
--vm-image NAME alpine, ubuntu, debian, or a custom VM image
|
|
705
|
+
--base NAME Alias for --vm-image
|
|
690
706
|
--project NAME Vercel project name
|
|
691
707
|
--scope SLUG Optional Vercel team/user scope slug
|
|
692
708
|
--from IMAGE Source image for /app/bin/wsterm
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vercel-vm-factory",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Create Vercel Container deployments for ws-shell from selectable
|
|
3
|
+
"version": "0.6.8",
|
|
4
|
+
"description": "Create Vercel Container deployments for ws-shell from selectable VM images.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|