vercel-vm-factory 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. package/README.md +31 -1
  2. package/deploy-vm.mjs +24 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -6,6 +6,14 @@ Create a tiny Vercel Container deployment: copy `wsterm` from `ghcr.io/v1xingyue
6
6
  npx vercel-vm-factory create \
7
7
  --base ubuntu \
8
8
  --project ws-shell-ubuntu \
9
+ --auth-user admin \
10
+ --auth-password change-me
11
+ ```
12
+
13
+ GitHub OAuth is optional:
14
+
15
+ ```bash
16
+ npx vercel-vm-factory create \
9
17
  --client-id YOUR_GITHUB_CLIENT_ID \
10
18
  --client-secret YOUR_GITHUB_CLIENT_SECRET \
11
19
  --github-userid 12345678
@@ -27,7 +35,7 @@ The script checks `vercel --version` and `vercel whoami`; if you are not logged
27
35
 
28
36
  Use `--help` to show all flags.
29
37
 
30
- Entered GitHub values are reused from `~/.vercel-vm-factory/defaults.json`; press Enter to keep the placeholder value or skip an empty one.
38
+ Entered auth values are reused from `~/.vercel-vm-factory/defaults.json`; press Enter to keep the placeholder value or skip an empty one.
31
39
 
32
40
  The generated project contains only `Dockerfile.vercel`.
33
41
 
@@ -56,4 +64,26 @@ Before deploying, set the GitHub OAuth callback URL to:
56
64
  https://PROJECT.vercel.app/auth/github/callback
57
65
  ```
58
66
 
67
+ For example, if `--project x-shell`, set:
68
+
69
+ ```text
70
+ https://x-shell.vercel.app/auth/github/callback
71
+ ```
72
+
73
+ GitHub OAuth fields:
74
+
75
+ - Username -> `--auth-user`
76
+ - Password -> `--auth-password`
77
+ - Client ID -> `--client-id`
78
+ - Client Secret -> `--client-secret`
79
+ - Numeric GitHub user ID -> `--github-userid`
80
+
81
+ Get your numeric user ID:
82
+
83
+ ```text
84
+ https://api.github.com/users/YOUR_LOGIN
85
+ ```
86
+
87
+ The callback URL must match exactly. If you deploy under another project name or custom domain, update the GitHub OAuth App or pass `--redirect-url`.
88
+
59
89
  Use `--dry-run` to generate files without deploying.
package/deploy-vm.mjs CHANGED
@@ -94,7 +94,10 @@ async function main() {
94
94
  }
95
95
 
96
96
  await ensureVercelReady();
97
+ printOAuthGuide(oauthRedirectUrl);
97
98
 
99
+ const authUsername = await secret("auth-user", "Basic auth username", process.env.AUTH_USERNAME ?? defaults["auth-user"]);
100
+ const authPassword = await secret("auth-password", "Basic auth password", process.env.AUTH_PASSWORD ?? defaults["auth-password"]);
98
101
  const githubClientId = await secret("client-id", "GitHub client id", process.env.GITHUB_CLIENT_ID ?? defaults["client-id"]);
99
102
  const githubClientSecret = await secret(
100
103
  "client-secret",
@@ -109,6 +112,8 @@ async function main() {
109
112
  scope: scope || undefined,
110
113
  project,
111
114
  from: wsShellImage,
115
+ "auth-user": authUsername,
116
+ "auth-password": authPassword,
112
117
  "client-id": githubClientId,
113
118
  "client-secret": githubClientSecret,
114
119
  "github-userid": allowedUserIds,
@@ -137,6 +142,8 @@ async function main() {
137
142
  `OAUTH_REDIRECT_URL=${oauthRedirectUrl}`,
138
143
  ];
139
144
 
145
+ if (authUsername) vercelArgs.push("--env", `AUTH_USERNAME=${authUsername}`);
146
+ if (authPassword) vercelArgs.push("--env", `AUTH_PASSWORD=${authPassword}`);
140
147
  if (githubClientId) vercelArgs.push("--env", `GITHUB_CLIENT_ID=${githubClientId}`);
141
148
  if (githubClientSecret) vercelArgs.push("--env", `GITHUB_CLIENT_SECRET=${githubClientSecret}`);
142
149
  if (allowedUserIds) vercelArgs.push("--env", `ALLOWED_USER_IDS=${allowedUserIds}`);
@@ -192,6 +199,8 @@ async function doctor() {
192
199
  printKeyValue("project", defaults.project || "not set");
193
200
  printKeyValue("scope", defaults.scope || "not set");
194
201
  printKeyValue("source image", defaults.from || "ghcr.io/v1xingyue/ws-shell:v1.1.alpine");
202
+ printKeyValue("auth user", defaults["auth-user"] ? mask(defaults["auth-user"]) : "not set");
203
+ printKeyValue("auth password", defaults["auth-password"] ? mask(defaults["auth-password"]) : "not set");
195
204
  printKeyValue("client id", defaults["client-id"] ? mask(defaults["client-id"]) : "not set");
196
205
  printKeyValue("client secret", defaults["client-secret"] ? mask(defaults["client-secret"]) : "not set");
197
206
  printKeyValue("github userid", defaults["github-userid"] ? mask(defaults["github-userid"]) : "not set");
@@ -381,6 +390,15 @@ function printSummary(items) {
381
390
  console.log("");
382
391
  }
383
392
 
393
+ function printOAuthGuide(callbackUrl) {
394
+ console.log(color.bold("GitHub OAuth"));
395
+ console.log(`${color.yellow("!")} Set this callback URL in your GitHub OAuth App before deploying:`);
396
+ console.log(` ${color.bold(callbackUrl)}`);
397
+ console.log(color.dim(" GitHub: Settings -> Developer settings -> OAuth Apps -> Authorization callback URL"));
398
+ console.log(color.dim(" User ID: open https://api.github.com/users/YOUR_LOGIN and copy the numeric id"));
399
+ console.log("");
400
+ }
401
+
384
402
  function printKeyValue(key, value) {
385
403
  console.log(`${color.dim(`${key.padEnd(14)} `)}${value}`);
386
404
  }
@@ -414,6 +432,8 @@ Options:
414
432
  --project NAME Vercel project name
415
433
  --scope SLUG Optional Vercel team/user scope slug
416
434
  --from IMAGE Source image for /app/bin/wsterm
435
+ --auth-user VALUE Username/password auth user
436
+ --auth-password VAL Username/password auth password
417
437
  --client-id VALUE GitHub OAuth client id
418
438
  --client-secret VAL GitHub OAuth client secret
419
439
  --github-userid VAL Allowed GitHub numeric user id(s)
@@ -423,5 +443,9 @@ Options:
423
443
  --dry-run Generate Dockerfile.vercel only
424
444
  --doctor Check Vercel CLI/login and saved defaults
425
445
  --help Show this help
446
+
447
+ GitHub OAuth:
448
+ Callback URL must match the deployed project:
449
+ https://PROJECT.vercel.app/auth/github/callback
426
450
  `);
427
451
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vercel-vm-factory",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Create Vercel Container deployments for ws-shell from selectable base images.",
5
5
  "license": "MIT",
6
6
  "type": "module",