create-whop-kit 0.6.4 → 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,29 +16,59 @@ 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
  }
65
+ async function vercelLink(projectDir) {
66
+ p.log.step("Vercel: linking project...");
67
+ console.log("");
68
+ const ok = execInteractive("vercel link --yes", projectDir);
69
+ console.log("");
70
+ return ok;
71
+ }
42
72
  async function vercelDeploy(projectDir) {
43
73
  const s = p.spinner();
44
74
  s.start("Vercel: deploying to production (this may take a few minutes)...");
@@ -48,17 +78,31 @@ async function vercelDeploy(projectDir) {
48
78
  const errorOutput = result.stderr || result.stdout;
49
79
  if (errorOutput) {
50
80
  p.log.error("Build output:");
51
- console.log(pc.dim(errorOutput.substring(0, 500)));
81
+ const trimmed = errorOutput.length > 600 ? "..." + errorOutput.slice(-600) : errorOutput;
82
+ console.log(pc.dim(trimmed));
52
83
  }
53
84
  return null;
54
85
  }
55
86
  const lines = result.stdout.split("\n");
56
87
  let url = "";
57
88
  for (const line of lines) {
58
- const match = line.match(/https:\/\/[^\s\[\]]+\.vercel\.app/);
59
- if (match) {
60
- url = match[0];
61
- if (!url.includes("-git-") && url.split("-").length < 5) break;
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;
94
+ }
95
+ }
96
+ }
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];
62
106
  }
63
107
  }
64
108
  if (url) {
@@ -67,15 +111,14 @@ async function vercelDeploy(projectDir) {
67
111
  }
68
112
  for (const line of lines) {
69
113
  const match = line.match(/https:\/\/[^\s\[\]]+/);
70
- if (match) {
71
- url = match[0];
72
- s.stop(`Deployed to ${pc.cyan(url)}`);
73
- return url;
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];
74
117
  }
75
118
  }
76
119
  s.stop("Deployed but could not extract URL");
77
120
  const manual = await p.text({
78
- message: "Paste your Vercel production URL (shown in the output above)",
121
+ message: "Paste your Vercel production URL",
79
122
  placeholder: "https://your-app.vercel.app",
80
123
  validate: (v) => {
81
124
  if (!v?.startsWith("https://")) return "Must be a https:// URL";
@@ -190,27 +233,18 @@ function openUrl(url) {
190
233
  }
191
234
  async function runDeployPipeline(options) {
192
235
  const { projectDir, projectName, databaseUrl, framework } = options;
193
- if (!isVercelInstalled()) {
194
- const install = await p2.confirm({
195
- message: "Vercel CLI not found. Install it now?",
196
- initialValue: true
197
- });
198
- if (p2.isCancel(install) || !install) return null;
199
- const ok = await installVercel();
200
- if (!ok) return null;
201
- }
236
+ const ok = await installOrUpdateVercel();
237
+ if (!ok) return null;
202
238
  if (!isVercelAuthenticated()) {
203
- const ok = await vercelLogin();
204
- if (!ok) {
239
+ const loginOk = await vercelLogin();
240
+ if (!loginOk) {
205
241
  p2.log.error("Vercel authentication failed. Deploy later with: " + pc2.bold("whop-kit deploy"));
206
242
  return null;
207
243
  }
208
244
  }
209
- p2.log.success("Vercel authenticated");
210
- p2.log.step("Vercel: linking project...");
211
- console.log("");
212
- const linkOk = execInteractive(`vercel link --yes`, projectDir);
213
- console.log("");
245
+ const user = getVercelUser();
246
+ p2.log.success(`Vercel authenticated${user ? ` as ${pc2.bold(user)}` : ""}`);
247
+ const linkOk = await vercelLink(projectDir);
214
248
  if (!linkOk) {
215
249
  p2.log.warning("Could not link project. Will try deploying directly.");
216
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-ATDZ322S.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-TPBUMYCP.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-TPBUMYCP.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.4",
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",