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 installVercel() {
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.step("Vercel: authenticating (opening browser)...");
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 vercelDeploy(projectDir) {
43
- p.log.step("Vercel: deploying to production (this may take a few minutes)...");
65
+ async function vercelLink(projectDir) {
66
+ p.log.step("Vercel: linking project...");
44
67
  console.log("");
45
- const ok = execInteractive("vercel deploy --prod --yes", projectDir);
68
+ const ok = execInteractive("vercel link --yes", projectDir);
46
69
  console.log("");
47
- if (!ok) {
48
- p.log.error("Vercel deployment failed. Check the output above for details.");
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 inspect = exec("vercel inspect --json", projectDir);
52
- if (inspect.success) {
53
- try {
54
- const data = JSON.parse(inspect.stdout);
55
- if (data.url) {
56
- const url = data.url.startsWith("https://") ? data.url : `https://${data.url}`;
57
- p.log.success(`Deployed to ${pc.cyan(url)}`);
58
- return url;
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
- const ls = exec("vercel ls --json 2>/dev/null | head -1", projectDir);
64
- if (ls.success) {
65
- const urlMatch = ls.stdout.match(/https:\/\/[^\s"]+\.vercel\.app/);
66
- if (urlMatch) {
67
- p.log.success(`Deployed to ${pc.cyan(urlMatch[0])}`);
68
- return urlMatch[0];
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
- p.log.warning("Could not determine deployment URL automatically.");
119
+ s.stop("Deployed but could not extract URL");
72
120
  const manual = await p.text({
73
- message: "Paste your Vercel deployment URL",
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
- if (!isVercelInstalled()) {
189
- const install = await p2.confirm({
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 ok = await vercelLogin();
199
- if (!ok) {
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
- p2.log.success("Vercel authenticated");
205
- p2.log.step("Vercel: linking project...");
206
- console.log("");
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
  }
@@ -675,7 +675,7 @@ var init_default = defineCommand({
675
675
  })();
676
676
  if (shouldDeploy) {
677
677
  deployAttempted = true;
678
- const { runDeployPipeline } = await import("./deploy-2HX64HTI.js");
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
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-HOQ5QQ2M.js";
10
10
  import {
11
11
  runDeployPipeline
12
- } from "./chunk-3USQ425V.js";
12
+ } from "./chunk-6EDYLQLE.js";
13
13
  import {
14
14
  detectPackageManager,
15
15
  exec
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runDeployPipeline
4
- } from "./chunk-3USQ425V.js";
4
+ } from "./chunk-6EDYLQLE.js";
5
5
  import "./chunk-42L7PRMT.js";
6
6
  export {
7
7
  runDeployPipeline
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-whop-kit",
3
- "version": "0.6.3",
3
+ "version": "0.7.0",
4
4
  "description": "Scaffold and manage Whop-powered apps with whop-kit",
5
5
  "type": "module",
6
6
  "license": "MIT",