create-whop-kit 0.6.3 → 0.7.0
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.
|
@@ -16,61 +16,109 @@ import pc from "picocolors";
|
|
|
16
16
|
function isVercelInstalled() {
|
|
17
17
|
return hasCommand("vercel");
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
19
|
+
async function installOrUpdateVercel() {
|
|
20
20
|
const s = p.spinner();
|
|
21
|
+
if (isVercelInstalled()) {
|
|
22
|
+
const versionResult = exec("vercel --version");
|
|
23
|
+
const currentVersion = versionResult.stdout.replace(/[^0-9.]/g, "");
|
|
24
|
+
s.start("Checking for Vercel CLI updates...");
|
|
25
|
+
const updateResult = exec("npm install -g vercel@latest", void 0, 6e4);
|
|
26
|
+
if (updateResult.success) {
|
|
27
|
+
const newVersion = exec("vercel --version");
|
|
28
|
+
const newVer = newVersion.stdout.replace(/[^0-9.]/g, "");
|
|
29
|
+
if (newVer !== currentVersion) {
|
|
30
|
+
s.stop(`Vercel CLI updated: ${currentVersion} \u2192 ${newVer}`);
|
|
31
|
+
} else {
|
|
32
|
+
s.stop(`Vercel CLI up to date (v${currentVersion})`);
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
s.stop(`Vercel CLI v${currentVersion} (update check failed, continuing)`);
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
21
39
|
s.start("Installing Vercel CLI...");
|
|
22
|
-
const result = exec("npm install -g vercel");
|
|
40
|
+
const result = exec("npm install -g vercel@latest");
|
|
23
41
|
if (result.success) {
|
|
24
42
|
s.stop("Vercel CLI installed");
|
|
25
43
|
return true;
|
|
26
44
|
}
|
|
27
45
|
s.stop("Failed to install Vercel CLI");
|
|
28
|
-
p.log.error(`Install manually: ${pc.bold("npm install -g vercel")}`);
|
|
46
|
+
p.log.error(`Install manually: ${pc.bold("npm install -g vercel@latest")}`);
|
|
29
47
|
return false;
|
|
30
48
|
}
|
|
31
49
|
function isVercelAuthenticated() {
|
|
32
50
|
const result = exec("vercel whoami");
|
|
33
51
|
return result.success;
|
|
34
52
|
}
|
|
53
|
+
function getVercelUser() {
|
|
54
|
+
const result = exec("vercel whoami");
|
|
55
|
+
return result.success ? result.stdout.trim() : null;
|
|
56
|
+
}
|
|
35
57
|
async function vercelLogin() {
|
|
36
|
-
p.log.
|
|
58
|
+
p.log.info("You'll be redirected to Vercel to sign in (or create an account).");
|
|
59
|
+
p.log.info(pc.dim("This is needed to deploy your app."));
|
|
37
60
|
console.log("");
|
|
38
61
|
const ok = execInteractive("vercel login");
|
|
39
62
|
console.log("");
|
|
40
63
|
return ok;
|
|
41
64
|
}
|
|
42
|
-
async function
|
|
43
|
-
p.log.step("Vercel:
|
|
65
|
+
async function vercelLink(projectDir) {
|
|
66
|
+
p.log.step("Vercel: linking project...");
|
|
44
67
|
console.log("");
|
|
45
|
-
const ok = execInteractive("vercel
|
|
68
|
+
const ok = execInteractive("vercel link --yes", projectDir);
|
|
46
69
|
console.log("");
|
|
47
|
-
|
|
48
|
-
|
|
70
|
+
return ok;
|
|
71
|
+
}
|
|
72
|
+
async function vercelDeploy(projectDir) {
|
|
73
|
+
const s = p.spinner();
|
|
74
|
+
s.start("Vercel: deploying to production (this may take a few minutes)...");
|
|
75
|
+
const result = exec("vercel deploy --prod --yes", projectDir, 3e5);
|
|
76
|
+
if (!result.success) {
|
|
77
|
+
s.stop("Vercel deployment failed");
|
|
78
|
+
const errorOutput = result.stderr || result.stdout;
|
|
79
|
+
if (errorOutput) {
|
|
80
|
+
p.log.error("Build output:");
|
|
81
|
+
const trimmed = errorOutput.length > 600 ? "..." + errorOutput.slice(-600) : errorOutput;
|
|
82
|
+
console.log(pc.dim(trimmed));
|
|
83
|
+
}
|
|
49
84
|
return null;
|
|
50
85
|
}
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
86
|
+
const lines = result.stdout.split("\n");
|
|
87
|
+
let url = "";
|
|
88
|
+
for (const line of lines) {
|
|
89
|
+
if (line.includes("Aliased:") || line.includes("Production:")) {
|
|
90
|
+
const match = line.match(/https:\/\/[^\s\[\]]+/);
|
|
91
|
+
if (match) {
|
|
92
|
+
url = match[0];
|
|
93
|
+
if (line.includes("Aliased:")) break;
|
|
59
94
|
}
|
|
60
|
-
} catch {
|
|
61
95
|
}
|
|
62
96
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
97
|
+
if (!url) {
|
|
98
|
+
const urls = [];
|
|
99
|
+
for (const line of lines) {
|
|
100
|
+
const match = line.match(/https:\/\/[^\s\[\]]+\.vercel\.app/);
|
|
101
|
+
if (match) urls.push(match[0]);
|
|
102
|
+
}
|
|
103
|
+
if (urls.length > 0) {
|
|
104
|
+
urls.sort((a, b) => a.length - b.length);
|
|
105
|
+
url = urls[0];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (url) {
|
|
109
|
+
s.stop(`Deployed to ${pc.cyan(url)}`);
|
|
110
|
+
return url;
|
|
111
|
+
}
|
|
112
|
+
for (const line of lines) {
|
|
113
|
+
const match = line.match(/https:\/\/[^\s\[\]]+/);
|
|
114
|
+
if (match && !match[0].includes("github.com") && !match[0].includes("vercel.com/")) {
|
|
115
|
+
s.stop(`Deployed to ${pc.cyan(match[0])}`);
|
|
116
|
+
return match[0];
|
|
69
117
|
}
|
|
70
118
|
}
|
|
71
|
-
|
|
119
|
+
s.stop("Deployed but could not extract URL");
|
|
72
120
|
const manual = await p.text({
|
|
73
|
-
message: "Paste your Vercel
|
|
121
|
+
message: "Paste your Vercel production URL",
|
|
74
122
|
placeholder: "https://your-app.vercel.app",
|
|
75
123
|
validate: (v) => {
|
|
76
124
|
if (!v?.startsWith("https://")) return "Must be a https:// URL";
|
|
@@ -185,27 +233,18 @@ function openUrl(url) {
|
|
|
185
233
|
}
|
|
186
234
|
async function runDeployPipeline(options) {
|
|
187
235
|
const { projectDir, projectName, databaseUrl, framework } = options;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
message: "Vercel CLI not found. Install it now?",
|
|
191
|
-
initialValue: true
|
|
192
|
-
});
|
|
193
|
-
if (p2.isCancel(install) || !install) return null;
|
|
194
|
-
const ok = await installVercel();
|
|
195
|
-
if (!ok) return null;
|
|
196
|
-
}
|
|
236
|
+
const ok = await installOrUpdateVercel();
|
|
237
|
+
if (!ok) return null;
|
|
197
238
|
if (!isVercelAuthenticated()) {
|
|
198
|
-
const
|
|
199
|
-
if (!
|
|
239
|
+
const loginOk = await vercelLogin();
|
|
240
|
+
if (!loginOk) {
|
|
200
241
|
p2.log.error("Vercel authentication failed. Deploy later with: " + pc2.bold("whop-kit deploy"));
|
|
201
242
|
return null;
|
|
202
243
|
}
|
|
203
244
|
}
|
|
204
|
-
|
|
205
|
-
p2.log.
|
|
206
|
-
|
|
207
|
-
const linkOk = execInteractive(`vercel link --yes`, projectDir);
|
|
208
|
-
console.log("");
|
|
245
|
+
const user = getVercelUser();
|
|
246
|
+
p2.log.success(`Vercel authenticated${user ? ` as ${pc2.bold(user)}` : ""}`);
|
|
247
|
+
const linkOk = await vercelLink(projectDir);
|
|
209
248
|
if (!linkOk) {
|
|
210
249
|
p2.log.warning("Could not link project. Will try deploying directly.");
|
|
211
250
|
}
|
package/dist/cli-create.js
CHANGED
|
@@ -675,7 +675,7 @@ var init_default = defineCommand({
|
|
|
675
675
|
})();
|
|
676
676
|
if (shouldDeploy) {
|
|
677
677
|
deployAttempted = true;
|
|
678
|
-
const { runDeployPipeline } = await import("./deploy-
|
|
678
|
+
const { runDeployPipeline } = await import("./deploy-GDDFTPNG.js");
|
|
679
679
|
deployResult = await runDeployPipeline({
|
|
680
680
|
projectDir,
|
|
681
681
|
projectName,
|
package/dist/cli-kit.js
CHANGED