vercel-vm-factory 0.16.8 → 0.18.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/config.mjs +11 -0
- package/deploy-vm.mjs +40 -24
- package/package.json +1 -1
package/config.mjs
CHANGED
|
@@ -14,6 +14,17 @@ export const toolChoices = {
|
|
|
14
14
|
"claude-code": "Claude Code",
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
export const projectNameSuffixes = [
|
|
18
|
+
"juddy",
|
|
19
|
+
"nova",
|
|
20
|
+
"orbit",
|
|
21
|
+
"pixel",
|
|
22
|
+
"spark",
|
|
23
|
+
"ripple",
|
|
24
|
+
"atlas",
|
|
25
|
+
"echo",
|
|
26
|
+
];
|
|
27
|
+
|
|
17
28
|
export const codeDefaults = {
|
|
18
29
|
"vm-image": "alpine",
|
|
19
30
|
from: defaultWsShellImage,
|
package/deploy-vm.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import * as p from "@clack/prompts";
|
|
|
9
9
|
import {
|
|
10
10
|
codeDefaults,
|
|
11
11
|
defaultWsShellImage,
|
|
12
|
+
projectNameSuffixes,
|
|
12
13
|
shells,
|
|
13
14
|
toolChoices,
|
|
14
15
|
vmImages,
|
|
@@ -79,7 +80,7 @@ async function main() {
|
|
|
79
80
|
const project = await value(
|
|
80
81
|
"project",
|
|
81
82
|
"Vercel project name",
|
|
82
|
-
defaults.project
|
|
83
|
+
defaultProjectName(vmImageName, defaults.project),
|
|
83
84
|
);
|
|
84
85
|
const wsShellImage =
|
|
85
86
|
args.from ??
|
|
@@ -138,7 +139,7 @@ async function main() {
|
|
|
138
139
|
if (usesGitHubAuth(authMode)) printOAuthGuide(oauthRedirectUrl);
|
|
139
140
|
|
|
140
141
|
const authUsername = usesBasicAuth(authMode)
|
|
141
|
-
? await
|
|
142
|
+
? await value(
|
|
142
143
|
"auth-user",
|
|
143
144
|
"Basic auth username",
|
|
144
145
|
process.env.AUTH_USERNAME ?? defaults["auth-user"],
|
|
@@ -340,10 +341,7 @@ async function doctor() {
|
|
|
340
341
|
printKeyValue("shell", defaults.shell || "/bin/sh");
|
|
341
342
|
printKeyValue("tools", defaults.tools || "none");
|
|
342
343
|
printKeyValue("auth mode", defaults["auth-mode"] || "not set");
|
|
343
|
-
printKeyValue(
|
|
344
|
-
"auth user",
|
|
345
|
-
defaults["auth-user"] ? mask(defaults["auth-user"]) : "not set",
|
|
346
|
-
);
|
|
344
|
+
printKeyValue("auth user", defaults["auth-user"] || "not set");
|
|
347
345
|
printKeyValue(
|
|
348
346
|
"auth password",
|
|
349
347
|
defaults["auth-password"] ? mask(defaults["auth-password"]) : "not set",
|
|
@@ -531,6 +529,23 @@ function usesGitHubAuth(mode) {
|
|
|
531
529
|
return mode === "github" || mode === "both";
|
|
532
530
|
}
|
|
533
531
|
|
|
532
|
+
function defaultProjectName(vmImageName, savedProject) {
|
|
533
|
+
if (savedProject && !["undefined", "null"].includes(String(savedProject)))
|
|
534
|
+
return savedProject;
|
|
535
|
+
const suffix =
|
|
536
|
+
projectNameSuffixes[
|
|
537
|
+
Math.abs(hashText(vmImageName)) % projectNameSuffixes.length
|
|
538
|
+
];
|
|
539
|
+
return `${vmImageName}-${suffix}`;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function hashText(text) {
|
|
543
|
+
return [...String(text)].reduce(
|
|
544
|
+
(hash, char) => (hash * 31 + char.charCodeAt(0)) | 0,
|
|
545
|
+
0,
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
|
|
534
549
|
async function chooseVmImage(fallback) {
|
|
535
550
|
if (args["vm-image"]) return args["vm-image"];
|
|
536
551
|
if (args.base) return args.base;
|
|
@@ -719,7 +734,9 @@ function cleanDefaults(data) {
|
|
|
719
734
|
delete migrated["custom-base"];
|
|
720
735
|
|
|
721
736
|
const clean = Object.fromEntries(
|
|
722
|
-
Object.entries(migrated).filter(
|
|
737
|
+
Object.entries(migrated).filter(
|
|
738
|
+
([, value]) => value && !["undefined", "null"].includes(String(value)),
|
|
739
|
+
),
|
|
723
740
|
);
|
|
724
741
|
return Object.fromEntries(
|
|
725
742
|
Object.entries(clean).sort(([a], [b]) => a.localeCompare(b)),
|
|
@@ -906,26 +923,25 @@ function printKeyValue(key, value) {
|
|
|
906
923
|
}
|
|
907
924
|
|
|
908
925
|
async function askText(question, fallback = "") {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
).trim();
|
|
926
|
+
const answer = await promptResult(
|
|
927
|
+
p.text({
|
|
928
|
+
message: question,
|
|
929
|
+
initialValue: fallback || undefined,
|
|
930
|
+
placeholder: fallback || undefined,
|
|
931
|
+
}),
|
|
932
|
+
);
|
|
933
|
+
return answer === undefined ? "" : String(answer).trim();
|
|
917
934
|
}
|
|
918
935
|
|
|
919
936
|
async function askSecret(question, fallback = "") {
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
).trim();
|
|
937
|
+
const answer = await promptResult(
|
|
938
|
+
p.password({
|
|
939
|
+
message: question,
|
|
940
|
+
mask: "*",
|
|
941
|
+
placeholder: fallback || undefined,
|
|
942
|
+
}),
|
|
943
|
+
);
|
|
944
|
+
return answer === undefined ? "" : String(answer).trim();
|
|
929
945
|
}
|
|
930
946
|
|
|
931
947
|
async function promptResult(resultPromise) {
|