create-whop-kit 0.4.1 → 0.5.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.
@@ -0,0 +1,370 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/templates.ts
4
+ var FRAMEWORKS = {
5
+ nextjs: {
6
+ name: "Next.js",
7
+ description: "Full-stack React with App Router, SSR, and API routes",
8
+ available: true
9
+ },
10
+ astro: {
11
+ name: "Astro",
12
+ description: "Content-focused with islands architecture",
13
+ available: true
14
+ },
15
+ tanstack: {
16
+ name: "TanStack Start",
17
+ description: "Full-stack React with TanStack Router",
18
+ available: false
19
+ },
20
+ vite: {
21
+ name: "Vite + React",
22
+ description: "Lightweight SPA with Vite bundler",
23
+ available: false
24
+ }
25
+ };
26
+ var TEMPLATES = {
27
+ "saas:nextjs": {
28
+ name: "Next.js SaaS",
29
+ description: "Full SaaS with dashboard, pricing, billing, and docs",
30
+ repo: "colinmcdermott/whop-saas-starter-v2",
31
+ available: true
32
+ },
33
+ "saas:astro": {
34
+ name: "Astro SaaS",
35
+ description: "SaaS with auth, payments, and webhooks",
36
+ repo: "colinmcdermott/whop-astro-starter",
37
+ available: true
38
+ },
39
+ "blank:nextjs": {
40
+ name: "Next.js Blank",
41
+ description: "Just auth + webhooks \u2014 build anything",
42
+ repo: "colinmcdermott/whop-blank-starter",
43
+ available: true
44
+ }
45
+ };
46
+ function getTemplate(appType, framework) {
47
+ return TEMPLATES[`${appType}:${framework}`] ?? null;
48
+ }
49
+ var APP_TYPES = {
50
+ saas: {
51
+ name: "SaaS",
52
+ description: "Subscription tiers, dashboard, billing portal",
53
+ available: true
54
+ },
55
+ blank: {
56
+ name: "Blank",
57
+ description: "Just auth + payments, you build the rest",
58
+ available: true
59
+ },
60
+ course: {
61
+ name: "Course",
62
+ description: "Lessons, progress tracking, drip content",
63
+ available: false
64
+ },
65
+ community: {
66
+ name: "Community",
67
+ description: "Member feeds, gated content, roles",
68
+ available: false
69
+ }
70
+ };
71
+
72
+ // src/utils/exec.ts
73
+ import { execSync } from "child_process";
74
+ function exec(cmd, cwd) {
75
+ try {
76
+ const stdout = execSync(cmd, {
77
+ cwd,
78
+ stdio: "pipe",
79
+ encoding: "utf-8",
80
+ timeout: 12e4
81
+ }).trim();
82
+ return { stdout, success: true };
83
+ } catch {
84
+ return { stdout: "", success: false };
85
+ }
86
+ }
87
+ function execInteractive(cmd, cwd) {
88
+ try {
89
+ execSync(cmd, { cwd, stdio: "inherit", timeout: 3e5 });
90
+ return true;
91
+ } catch {
92
+ return false;
93
+ }
94
+ }
95
+ function hasCommand(cmd) {
96
+ return exec(`which ${cmd}`).success;
97
+ }
98
+ function detectPackageManager() {
99
+ if (hasCommand("pnpm")) return "pnpm";
100
+ if (hasCommand("yarn")) return "yarn";
101
+ if (hasCommand("bun")) return "bun";
102
+ return "npm";
103
+ }
104
+
105
+ // src/scaffolding/manifest.ts
106
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
107
+ import { join } from "path";
108
+ var MANIFEST_DIR = ".whop";
109
+ var MANIFEST_FILE = "config.json";
110
+ function getManifestPath(projectDir) {
111
+ return join(projectDir, MANIFEST_DIR, MANIFEST_FILE);
112
+ }
113
+ function createManifest(projectDir, data) {
114
+ const dir = join(projectDir, MANIFEST_DIR);
115
+ if (!existsSync(dir)) {
116
+ mkdirSync(dir, { recursive: true });
117
+ }
118
+ const manifest = {
119
+ version: 1,
120
+ ...data,
121
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
122
+ };
123
+ writeFileSync(getManifestPath(projectDir), JSON.stringify(manifest, null, 2) + "\n");
124
+ }
125
+ function readManifest(projectDir) {
126
+ const path = getManifestPath(projectDir);
127
+ if (!existsSync(path)) return null;
128
+ try {
129
+ return JSON.parse(readFileSync(path, "utf-8"));
130
+ } catch {
131
+ return null;
132
+ }
133
+ }
134
+ function addFeatureToManifest(projectDir, feature) {
135
+ const manifest = readManifest(projectDir);
136
+ if (!manifest) return;
137
+ if (!manifest.features.includes(feature)) {
138
+ manifest.features.push(feature);
139
+ }
140
+ writeFileSync(getManifestPath(projectDir), JSON.stringify(manifest, null, 2) + "\n");
141
+ }
142
+
143
+ // src/scaffolding/skills.ts
144
+ import { writeFileSync as writeFileSync2, mkdirSync as mkdirSync2, existsSync as existsSync2 } from "fs";
145
+ import { join as join2 } from "path";
146
+ var PROVIDER_SKILLS = {
147
+ neon: [
148
+ { repo: "https://github.com/neondatabase/agent-skills", skill: "neon-postgres" },
149
+ { repo: "https://github.com/neondatabase/ai-rules", skill: "neon-serverless" }
150
+ ],
151
+ supabase: [
152
+ { repo: "https://github.com/supabase/agent-skills", skill: "supabase-postgres-best-practices" }
153
+ ],
154
+ "prisma-postgres": [
155
+ // Prisma skill is typically bundled in the template already
156
+ ]
157
+ };
158
+ function installProviderSkills(projectDir, provider) {
159
+ const skills = PROVIDER_SKILLS[provider];
160
+ if (!skills || skills.length === 0) return;
161
+ for (const { repo, skill } of skills) {
162
+ const result = exec(
163
+ `npx -y skills add ${repo} --skill ${skill}`,
164
+ projectDir
165
+ );
166
+ if (!result.success) {
167
+ console.log(` (Could not install ${skill} skill \u2014 you can add it later)`);
168
+ }
169
+ }
170
+ }
171
+ function writeProjectContext(projectDir, manifest, envVars) {
172
+ const dir = join2(projectDir, ".whop");
173
+ if (!existsSync2(dir)) mkdirSync2(dir, { recursive: true });
174
+ const lines = [
175
+ "# Project Context",
176
+ "",
177
+ "Auto-generated by create-whop-kit. Helps AI coding assistants understand",
178
+ "your project. Regenerated by `whop-kit status`. Do not edit manually.",
179
+ "",
180
+ "## Project",
181
+ "",
182
+ `- **Framework:** ${manifest.framework}`,
183
+ `- **App Type:** ${manifest.appType}`,
184
+ `- **Database:** ${manifest.database}`,
185
+ `- **Template Version:** ${manifest.templateVersion}`,
186
+ `- **Created:** ${manifest.createdAt}`,
187
+ "",
188
+ "## Configuration Status",
189
+ ""
190
+ ];
191
+ const checks = [
192
+ ["DATABASE_URL", "Database", true],
193
+ ["NEXT_PUBLIC_WHOP_APP_ID", "Whop App ID", true],
194
+ ["WHOP_API_KEY", "Whop API Key", true],
195
+ ["WHOP_WEBHOOK_SECRET", "Webhook Secret", true],
196
+ ["EMAIL_PROVIDER", "Email", false],
197
+ ["ANALYTICS_PROVIDER", "Analytics", false]
198
+ ];
199
+ for (const [key, label, required] of checks) {
200
+ const set = envVars[key] ?? false;
201
+ const icon = set ? "\u2713" : required ? "\u2717" : "\u25CB";
202
+ lines.push(`- ${icon} ${label} (\`${key}\`)`);
203
+ }
204
+ if (manifest.features.length > 0) {
205
+ lines.push("");
206
+ lines.push("## Installed Features");
207
+ lines.push("");
208
+ for (const feature of manifest.features) {
209
+ lines.push(`- ${feature}`);
210
+ }
211
+ }
212
+ lines.push("");
213
+ lines.push("## Key Files");
214
+ lines.push("");
215
+ if (manifest.framework === "nextjs") {
216
+ lines.push("- `lib/auth.ts` \u2014 session management (whop-kit/auth)");
217
+ lines.push("- `lib/adapters/next.ts` \u2014 Next.js cookie adapter");
218
+ lines.push("- `lib/adapters/prisma.ts` \u2014 Prisma DB + config adapters");
219
+ lines.push("- `app/api/webhooks/whop/route.ts` \u2014 webhook handler");
220
+ lines.push("- `app/api/auth/` \u2014 OAuth login/callback/logout");
221
+ lines.push("- `db/schema.prisma` \u2014 database schema");
222
+ } else if (manifest.framework === "astro") {
223
+ lines.push("- `src/lib/auth.ts` \u2014 session management (whop-kit/auth)");
224
+ lines.push("- `src/lib/adapters/astro.ts` \u2014 Astro cookie adapter");
225
+ lines.push("- `src/lib/adapters/prisma.ts` \u2014 Prisma DB adapter");
226
+ lines.push("- `src/pages/api/webhooks/whop.ts` \u2014 webhook handler");
227
+ lines.push("- `src/pages/api/auth/` \u2014 OAuth login/callback/logout");
228
+ }
229
+ lines.push("");
230
+ lines.push("## CLI Commands");
231
+ lines.push("");
232
+ lines.push("```bash");
233
+ lines.push("npx whop-kit status # check project health");
234
+ lines.push("npx whop-kit add email # add email provider");
235
+ lines.push("npx whop-kit add analytics # add analytics");
236
+ lines.push("npx whop-kit catalog # list available services");
237
+ lines.push("npx whop-kit open whop # open Whop dashboard");
238
+ lines.push("npx whop-kit upgrade # update whop-kit");
239
+ lines.push("```");
240
+ lines.push("");
241
+ writeFileSync2(join2(dir, "project-context.md"), lines.join("\n"));
242
+ }
243
+ function writeFeatureSkill(projectDir, featureKey, provider) {
244
+ const dir = join2(projectDir, ".agents", "skills", "whop-kit-features");
245
+ if (!existsSync2(dir)) mkdirSync2(dir, { recursive: true });
246
+ const content = generateFeatureSkill(featureKey, provider);
247
+ if (content) {
248
+ writeFileSync2(join2(dir, `${featureKey}-${provider}.md`), content);
249
+ }
250
+ }
251
+ function generateFeatureSkill(featureKey, provider) {
252
+ const key = `${featureKey}:${provider}`;
253
+ const skills = {
254
+ "email:resend": `---
255
+ name: resend-email
256
+ description: Resend transactional email integration. Use when working with email sending, templates, or email configuration.
257
+ ---
258
+
259
+ # Resend Email
260
+
261
+ This project uses Resend for transactional email via whop-kit/email.
262
+
263
+ ## Usage
264
+ \`\`\`typescript
265
+ import { sendEmail } from "@/lib/email";
266
+ await sendEmail({ to: "user@example.com", subject: "Hello", html: "<p>Hi!</p>" });
267
+ \`\`\`
268
+
269
+ ## Config
270
+ - \`EMAIL_PROVIDER=resend\`
271
+ - \`EMAIL_API_KEY\` \u2014 Resend API key
272
+ - \`EMAIL_FROM_ADDRESS\` \u2014 verified sender
273
+
274
+ ## Templates
275
+ Edit \`lib/email-templates.ts\`. Each function returns \`{ subject, html }\`.
276
+
277
+ ## Dashboard
278
+ https://resend.com/overview
279
+ `,
280
+ "email:sendgrid": `---
281
+ name: sendgrid-email
282
+ description: SendGrid transactional email integration. Use when working with email sending, templates, or email configuration.
283
+ ---
284
+
285
+ # SendGrid Email
286
+
287
+ This project uses SendGrid for transactional email via whop-kit/email.
288
+
289
+ ## Usage
290
+ \`\`\`typescript
291
+ import { sendEmail } from "@/lib/email";
292
+ await sendEmail({ to: "user@example.com", subject: "Hello", html: "<p>Hi!</p>" });
293
+ \`\`\`
294
+
295
+ ## Config
296
+ - \`EMAIL_PROVIDER=sendgrid\`
297
+ - \`EMAIL_API_KEY\` \u2014 SendGrid API key
298
+ - \`EMAIL_FROM_ADDRESS\` \u2014 verified sender
299
+
300
+ ## Dashboard
301
+ https://app.sendgrid.com
302
+ `,
303
+ "analytics:posthog": `---
304
+ name: posthog-analytics
305
+ description: PostHog product analytics integration. Use when working with analytics, events, or feature flags.
306
+ ---
307
+
308
+ # PostHog Analytics
309
+
310
+ Injected via whop-kit/analytics \`getAnalyticsScript()\`. No client SDK needed.
311
+
312
+ ## Config
313
+ - \`ANALYTICS_PROVIDER=posthog\`
314
+ - \`ANALYTICS_ID\` \u2014 project API key (phc_xxx)
315
+
316
+ ## Dashboard
317
+ https://us.posthog.com
318
+ `,
319
+ "analytics:google": `---
320
+ name: google-analytics
321
+ description: Google Analytics 4 integration.
322
+ ---
323
+
324
+ # Google Analytics 4
325
+
326
+ Injected via whop-kit/analytics \`getAnalyticsScript()\`.
327
+
328
+ ## Config
329
+ - \`ANALYTICS_PROVIDER=google\`
330
+ - \`ANALYTICS_ID\` \u2014 measurement ID (G-XXXXXXXXXX)
331
+
332
+ ## Dashboard
333
+ https://analytics.google.com
334
+ `,
335
+ "analytics:plausible": `---
336
+ name: plausible-analytics
337
+ description: Plausible privacy-friendly analytics integration.
338
+ ---
339
+
340
+ # Plausible Analytics
341
+
342
+ Injected via whop-kit/analytics \`getAnalyticsScript()\`. No cookies, GDPR compliant.
343
+
344
+ ## Config
345
+ - \`ANALYTICS_PROVIDER=plausible\`
346
+ - \`ANALYTICS_ID\` \u2014 your domain
347
+
348
+ ## Dashboard
349
+ https://plausible.io/sites
350
+ `
351
+ };
352
+ return skills[key] ?? null;
353
+ }
354
+
355
+ export {
356
+ FRAMEWORKS,
357
+ TEMPLATES,
358
+ getTemplate,
359
+ APP_TYPES,
360
+ exec,
361
+ execInteractive,
362
+ hasCommand,
363
+ detectPackageManager,
364
+ createManifest,
365
+ readManifest,
366
+ addFeatureToManifest,
367
+ installProviderSkills,
368
+ writeProjectContext,
369
+ writeFeatureSkill
370
+ };
@@ -1,11 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ APP_TYPES,
4
+ FRAMEWORKS,
3
5
  createManifest,
4
6
  detectPackageManager,
5
7
  exec,
6
8
  execInteractive,
7
- hasCommand
8
- } from "./chunk-KO52YVBE.js";
9
+ getTemplate,
10
+ hasCommand,
11
+ installProviderSkills,
12
+ writeProjectContext
13
+ } from "./chunk-BR467LBM.js";
9
14
 
10
15
  // src/cli-create.ts
11
16
  import { runMain } from "citty";
@@ -17,75 +22,6 @@ import * as p5 from "@clack/prompts";
17
22
  import pc5 from "picocolors";
18
23
  import { defineCommand } from "citty";
19
24
 
20
- // src/templates.ts
21
- var FRAMEWORKS = {
22
- nextjs: {
23
- name: "Next.js",
24
- description: "Full-stack React with App Router, SSR, and API routes",
25
- available: true
26
- },
27
- astro: {
28
- name: "Astro",
29
- description: "Content-focused with islands architecture",
30
- available: true
31
- },
32
- tanstack: {
33
- name: "TanStack Start",
34
- description: "Full-stack React with TanStack Router",
35
- available: false
36
- },
37
- vite: {
38
- name: "Vite + React",
39
- description: "Lightweight SPA with Vite bundler",
40
- available: false
41
- }
42
- };
43
- var TEMPLATES = {
44
- "saas:nextjs": {
45
- name: "Next.js SaaS",
46
- description: "Full SaaS with dashboard, pricing, billing, and docs",
47
- repo: "colinmcdermott/whop-saas-starter-v2",
48
- available: true
49
- },
50
- "saas:astro": {
51
- name: "Astro SaaS",
52
- description: "SaaS with auth, payments, and webhooks",
53
- repo: "colinmcdermott/whop-astro-starter",
54
- available: true
55
- },
56
- "blank:nextjs": {
57
- name: "Next.js Blank",
58
- description: "Just auth + webhooks \u2014 build anything",
59
- repo: "colinmcdermott/whop-blank-starter",
60
- available: true
61
- }
62
- };
63
- function getTemplate(appType, framework) {
64
- return TEMPLATES[`${appType}:${framework}`] ?? null;
65
- }
66
- var APP_TYPES = {
67
- saas: {
68
- name: "SaaS",
69
- description: "Subscription tiers, dashboard, billing portal",
70
- available: true
71
- },
72
- blank: {
73
- name: "Blank",
74
- description: "Just auth + payments, you build the rest",
75
- available: true
76
- },
77
- course: {
78
- name: "Course",
79
- description: "Lessons, progress tracking, drip content",
80
- available: false
81
- },
82
- community: {
83
- name: "Community",
84
- description: "Member feeds, gated content, roles",
85
- available: false
86
- }
87
- };
88
-
89
25
  // src/providers/neon.ts
90
26
  import * as p from "@clack/prompts";
91
27
  import pc from "picocolors";
@@ -390,12 +326,6 @@ function validateDatabaseUrl(url) {
390
326
  }
391
327
  return void 0;
392
328
  }
393
- function validateWhopAppId(id) {
394
- if (id && !id.startsWith("app_")) {
395
- return 'Whop App IDs start with "app_"';
396
- }
397
- return void 0;
398
- }
399
329
 
400
330
  // src/utils/cleanup.ts
401
331
  import { rmSync, existsSync as existsSync2 } from "fs";
@@ -661,39 +591,9 @@ var init_default = defineCommand({
661
591
  }
662
592
  dbUrl = result;
663
593
  }
664
- let appId = args["app-id"] ?? "";
665
- let apiKey = args["api-key"] ?? "";
666
- let webhookSecret = args["webhook-secret"] ?? "";
667
- if (!isNonInteractive && !args.yes) {
668
- const setupWhop = await p5.confirm({
669
- message: "Configure Whop credentials now? (you can do this later via the setup wizard)",
670
- initialValue: false
671
- });
672
- if (!isCancelled(setupWhop) && setupWhop) {
673
- if (!appId) {
674
- const result = await p5.text({
675
- message: "Whop App ID",
676
- placeholder: "app_xxxxxxxxx",
677
- validate: (v) => v ? validateWhopAppId(v) : void 0
678
- });
679
- if (!isCancelled(result)) appId = result ?? "";
680
- }
681
- if (!apiKey) {
682
- const result = await p5.text({
683
- message: "Whop API Key",
684
- placeholder: "apik_xxxxxxxxx (optional, press Enter to skip)"
685
- });
686
- if (!isCancelled(result)) apiKey = result ?? "";
687
- }
688
- if (!webhookSecret) {
689
- const result = await p5.text({
690
- message: "Whop Webhook Secret",
691
- placeholder: "optional, press Enter to skip"
692
- });
693
- if (!isCancelled(result)) webhookSecret = result ?? "";
694
- }
695
- }
696
- }
594
+ const appId = args["app-id"] ?? "";
595
+ const apiKey = args["api-key"] ?? "";
596
+ const webhookSecret = args["webhook-secret"] ?? "";
697
597
  if (args["dry-run"]) {
698
598
  p5.log.info(pc5.dim("Dry run \u2014 showing what would be created:\n"));
699
599
  console.log(` ${pc5.bold("Project:")} ${projectName}`);
@@ -740,6 +640,28 @@ var init_default = defineCommand({
740
640
  features: [],
741
641
  templateVersion: "0.2.0"
742
642
  });
643
+ if (database !== "later" && database !== "manual") {
644
+ s.start("Installing provider skills for AI assistants...");
645
+ installProviderSkills(projectDir, database);
646
+ s.stop("Provider skills installed");
647
+ }
648
+ const envStatus = {};
649
+ if (dbUrl) envStatus["DATABASE_URL"] = true;
650
+ if (appId) {
651
+ envStatus["NEXT_PUBLIC_WHOP_APP_ID"] = true;
652
+ envStatus["WHOP_APP_ID"] = true;
653
+ }
654
+ if (apiKey) envStatus["WHOP_API_KEY"] = true;
655
+ if (webhookSecret) envStatus["WHOP_WEBHOOK_SECRET"] = true;
656
+ const manifest = {
657
+ framework,
658
+ appType,
659
+ database,
660
+ features: [],
661
+ templateVersion: "0.4.0",
662
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
663
+ };
664
+ writeProjectContext(projectDir, { version: 1, ...manifest }, envStatus);
743
665
  const pm = detectPackageManager();
744
666
  s.start(`Installing dependencies with ${pm}...`);
745
667
  const installResult = exec(`${pm} install`, projectDir);
@@ -763,12 +685,6 @@ var init_default = defineCommand({
763
685
  let summary = "";
764
686
  if (configured.length > 0) {
765
687
  summary += `${pc5.green("\u2713")} ${configured.join(", ")}
766
- `;
767
- }
768
- if (missing.length > 0) {
769
- summary += `${pc5.yellow("\u25CB")} Missing: ${missing.join(", ")}
770
- `;
771
- summary += ` ${pc5.dim("The setup wizard at http://localhost:3000 will guide you through it")}
772
688
  `;
773
689
  }
774
690
  if (dbNote) {
@@ -787,7 +703,9 @@ var init_default = defineCommand({
787
703
  `;
788
704
  summary += `
789
705
  `;
790
- summary += ` ${pc5.dim("Then open http://localhost:3000")}`;
706
+ summary += ` ${pc5.dim("Open http://localhost:3000 \u2014 the setup wizard will")}
707
+ `;
708
+ summary += ` ${pc5.dim("walk you through connecting your Whop app.")}`;
791
709
  p5.note(summary, "Your app is ready");
792
710
  p5.outro(`${pc5.green("Happy building!")} ${pc5.dim("\u2014 whop-kit")}`);
793
711
  }
package/dist/cli-kit.js CHANGED
@@ -1,13 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ APP_TYPES,
4
+ FRAMEWORKS,
5
+ TEMPLATES,
3
6
  addFeatureToManifest,
4
7
  detectPackageManager,
5
8
  exec,
6
- readManifest
7
- } from "./chunk-KO52YVBE.js";
9
+ readManifest,
10
+ writeFeatureSkill
11
+ } from "./chunk-BR467LBM.js";
8
12
 
9
13
  // src/cli-kit.ts
10
- import { defineCommand as defineCommand5, runMain } from "citty";
14
+ import { defineCommand as defineCommand7, runMain } from "citty";
11
15
 
12
16
  // src/commands/add.ts
13
17
  import * as p4 from "@clack/prompts";
@@ -78,6 +82,7 @@ var emailFeature = {
78
82
  if (fromAddress) {
79
83
  appendEnvVar(projectDir, "EMAIL_FROM_ADDRESS", fromAddress);
80
84
  }
85
+ writeFeatureSkill(projectDir, "email", provider);
81
86
  }
82
87
  };
83
88
 
@@ -116,6 +121,7 @@ var analyticsFeature = {
116
121
  }
117
122
  appendEnvVar(projectDir, "ANALYTICS_PROVIDER", provider);
118
123
  appendEnvVar(projectDir, "ANALYTICS_ID", id);
124
+ writeFeatureSkill(projectDir, "analytics", provider);
119
125
  }
120
126
  };
121
127
 
@@ -304,10 +310,152 @@ var status_default = defineCommand2({
304
310
  }
305
311
  });
306
312
 
307
- // src/commands/open.ts
313
+ // src/commands/env.ts
314
+ import { readFileSync as readFileSync3, existsSync as existsSync3 } from "fs";
315
+ import { join as join3 } from "path";
308
316
  import * as p6 from "@clack/prompts";
309
317
  import pc4 from "picocolors";
310
318
  import { defineCommand as defineCommand3 } from "citty";
319
+ function parseEnvFile(projectDir) {
320
+ for (const name of [".env.local", ".env"]) {
321
+ const path = join3(projectDir, name);
322
+ if (existsSync3(path)) {
323
+ const content = readFileSync3(path, "utf-8");
324
+ const vars = {};
325
+ for (const line of content.split("\n")) {
326
+ const trimmed = line.trim();
327
+ if (!trimmed || trimmed.startsWith("#")) continue;
328
+ const match = trimmed.match(/^([A-Z_][A-Z0-9_]*)=["']?(.*)["']?$/);
329
+ if (match) vars[match[1]] = match[2].replace(/["']$/, "");
330
+ }
331
+ return vars;
332
+ }
333
+ }
334
+ return {};
335
+ }
336
+ function maskValue(value) {
337
+ if (value.length <= 8) return "****";
338
+ return value.substring(0, 8) + "..." + "*".repeat(4);
339
+ }
340
+ var env_default = defineCommand3({
341
+ meta: {
342
+ name: "env",
343
+ description: "View environment variables (masked by default)"
344
+ },
345
+ args: {
346
+ reveal: {
347
+ type: "boolean",
348
+ description: "Show actual values instead of masked",
349
+ default: false
350
+ }
351
+ },
352
+ async run({ args }) {
353
+ console.log("");
354
+ p6.intro(`${pc4.bgCyan(pc4.black(" whop-kit env "))}`);
355
+ const manifest = readManifest(".");
356
+ if (!manifest) {
357
+ p6.log.error("No .whop/config.json found. Are you in a whop-kit project?");
358
+ process.exit(1);
359
+ }
360
+ const vars = parseEnvFile(".");
361
+ if (Object.keys(vars).length === 0) {
362
+ p6.log.warning("No environment variables found. Create .env.local with your configuration.");
363
+ p6.outro("");
364
+ return;
365
+ }
366
+ if (args.reveal) {
367
+ p6.log.warning("Revealing secret values:");
368
+ console.log("");
369
+ }
370
+ for (const [key, value] of Object.entries(vars)) {
371
+ const displayValue = args.reveal ? pc4.cyan(value) : pc4.dim(maskValue(value));
372
+ console.log(` ${pc4.bold(key.padEnd(40))} ${displayValue}`);
373
+ }
374
+ console.log("");
375
+ if (!args.reveal) {
376
+ p6.log.info(`Use ${pc4.bold("whop-kit env --reveal")} to show actual values`);
377
+ }
378
+ p6.outro("");
379
+ }
380
+ });
381
+
382
+ // src/commands/catalog.ts
383
+ import * as p7 from "@clack/prompts";
384
+ import pc5 from "picocolors";
385
+ import { defineCommand as defineCommand4 } from "citty";
386
+ var catalog_default = defineCommand4({
387
+ meta: {
388
+ name: "catalog",
389
+ description: "List available templates, frameworks, databases, and features"
390
+ },
391
+ async run() {
392
+ console.log("");
393
+ p7.intro(`${pc5.bgCyan(pc5.black(" whop-kit catalog "))} Available services`);
394
+ console.log(`
395
+ ${pc5.bold(pc5.underline("App Types"))}
396
+ `);
397
+ for (const [key, type] of Object.entries(APP_TYPES)) {
398
+ const status = type.available ? pc5.green("available") : pc5.dim("coming soon");
399
+ console.log(` ${pc5.bold(key.padEnd(15))} ${type.description.padEnd(45)} ${status}`);
400
+ }
401
+ console.log(`
402
+ ${pc5.bold(pc5.underline("Frameworks"))}
403
+ `);
404
+ for (const [key, fw] of Object.entries(FRAMEWORKS)) {
405
+ const status = fw.available ? pc5.green("available") : pc5.dim("coming soon");
406
+ console.log(` ${pc5.bold(key.padEnd(15))} ${fw.description.padEnd(45)} ${status}`);
407
+ }
408
+ console.log(`
409
+ ${pc5.bold(pc5.underline("Templates"))}
410
+ `);
411
+ for (const [key, tmpl] of Object.entries(TEMPLATES)) {
412
+ const status = tmpl.available ? pc5.green("available") : pc5.dim("coming soon");
413
+ console.log(` ${pc5.bold(key.padEnd(20))} ${tmpl.description.padEnd(40)} ${status}`);
414
+ }
415
+ console.log(`
416
+ ${pc5.bold(pc5.underline("Database Providers"))}
417
+ `);
418
+ const dbProviders = [
419
+ { key: "neon", name: "Neon", desc: "Serverless Postgres, auto-provisioned", status: "auto" },
420
+ { key: "prisma-postgres", name: "Prisma Postgres", desc: "Instant database, no auth needed", status: "auto" },
421
+ { key: "supabase", name: "Supabase", desc: "Open-source Firebase alternative", status: "guided" },
422
+ { key: "manual", name: "Manual", desc: "Paste any PostgreSQL connection string", status: "manual" }
423
+ ];
424
+ for (const db of dbProviders) {
425
+ const badge = db.status === "auto" ? pc5.green("auto-provision") : db.status === "guided" ? pc5.yellow("guided setup") : pc5.dim("manual");
426
+ console.log(` ${pc5.bold(db.key.padEnd(20))} ${db.desc.padEnd(40)} ${badge}`);
427
+ }
428
+ console.log(`
429
+ ${pc5.bold(pc5.underline("Features (whop-kit add)"))}
430
+ `);
431
+ const features = [
432
+ { key: "email", desc: "Transactional email", providers: "Resend, SendGrid" },
433
+ { key: "analytics", desc: "Product analytics", providers: "PostHog, Google Analytics, Plausible" },
434
+ { key: "webhook-event", desc: "Add webhook event handler", providers: "\u2014" }
435
+ ];
436
+ for (const feat of features) {
437
+ console.log(` ${pc5.bold(feat.key.padEnd(20))} ${feat.desc.padEnd(30)} ${pc5.dim(feat.providers)}`);
438
+ }
439
+ console.log(`
440
+ ${pc5.bold(pc5.underline("Agent Skills (auto-installed)"))}
441
+ `);
442
+ const skills = [
443
+ { provider: "Neon", skills: "neon-postgres, neon-serverless" },
444
+ { provider: "Supabase", skills: "supabase-postgres-best-practices" },
445
+ { provider: "Whop", skills: "whop-saas-starter, whop-dev" }
446
+ ];
447
+ for (const s of skills) {
448
+ console.log(` ${pc5.bold(s.provider.padEnd(20))} ${pc5.dim(s.skills)}`);
449
+ }
450
+ console.log("");
451
+ p7.outro(`Run ${pc5.bold("npx create-whop-kit")} to get started`);
452
+ }
453
+ });
454
+
455
+ // src/commands/open.ts
456
+ import * as p8 from "@clack/prompts";
457
+ import pc6 from "picocolors";
458
+ import { defineCommand as defineCommand5 } from "citty";
311
459
  var DASHBOARDS = {
312
460
  whop: { name: "Whop Developer Dashboard", url: "https://whop.com/dashboard/developer" },
313
461
  neon: { name: "Neon Console", url: "https://console.neon.tech" },
@@ -320,7 +468,7 @@ function openUrl(url) {
320
468
  else if (platform === "win32") exec(`start "${url}"`);
321
469
  else exec(`xdg-open "${url}"`);
322
470
  }
323
- var open_default = defineCommand3({
471
+ var open_default = defineCommand5({
324
472
  meta: {
325
473
  name: "open",
326
474
  description: "Open a provider dashboard in your browser"
@@ -335,7 +483,7 @@ var open_default = defineCommand3({
335
483
  async run({ args }) {
336
484
  let target = args.target;
337
485
  if (!target) {
338
- const result = await p6.select({
486
+ const result = await p8.select({
339
487
  message: "Which dashboard?",
340
488
  options: Object.entries(DASHBOARDS).map(([value, d]) => ({
341
489
  value,
@@ -343,43 +491,43 @@ var open_default = defineCommand3({
343
491
  hint: d.url
344
492
  }))
345
493
  });
346
- if (p6.isCancel(result)) {
347
- p6.cancel("Cancelled.");
494
+ if (p8.isCancel(result)) {
495
+ p8.cancel("Cancelled.");
348
496
  process.exit(0);
349
497
  }
350
498
  target = result;
351
499
  }
352
500
  const dashboard = DASHBOARDS[target];
353
501
  if (!dashboard) {
354
- p6.log.error(`Unknown dashboard "${target}". Options: ${Object.keys(DASHBOARDS).join(", ")}`);
502
+ p8.log.error(`Unknown dashboard "${target}". Options: ${Object.keys(DASHBOARDS).join(", ")}`);
355
503
  process.exit(1);
356
504
  }
357
505
  openUrl(dashboard.url);
358
506
  console.log(`
359
- Opening ${pc4.bold(dashboard.name)} \u2192 ${pc4.cyan(dashboard.url)}
507
+ Opening ${pc6.bold(dashboard.name)} \u2192 ${pc6.cyan(dashboard.url)}
360
508
  `);
361
509
  }
362
510
  });
363
511
 
364
512
  // src/commands/upgrade.ts
365
- import * as p7 from "@clack/prompts";
366
- import pc5 from "picocolors";
367
- import { defineCommand as defineCommand4 } from "citty";
368
- var upgrade_default = defineCommand4({
513
+ import * as p9 from "@clack/prompts";
514
+ import pc7 from "picocolors";
515
+ import { defineCommand as defineCommand6 } from "citty";
516
+ var upgrade_default = defineCommand6({
369
517
  meta: {
370
518
  name: "upgrade",
371
519
  description: "Update whop-kit to the latest version in your project"
372
520
  },
373
521
  async run() {
374
522
  console.log("");
375
- p7.intro(`${pc5.bgCyan(pc5.black(" whop-kit upgrade "))}`);
523
+ p9.intro(`${pc7.bgCyan(pc7.black(" whop-kit upgrade "))}`);
376
524
  const manifest = readManifest(".");
377
525
  if (!manifest) {
378
- p7.log.error("No .whop/config.json found. Are you in a whop-kit project?");
526
+ p9.log.error("No .whop/config.json found. Are you in a whop-kit project?");
379
527
  process.exit(1);
380
528
  }
381
529
  const pm = detectPackageManager();
382
- const s = p7.spinner();
530
+ const s = p9.spinner();
383
531
  s.start("Checking for updates...");
384
532
  const latest = exec("npm view whop-kit version");
385
533
  s.stop(latest.success ? `Latest: whop-kit@${latest.stdout}` : "Could not check latest version");
@@ -387,25 +535,27 @@ var upgrade_default = defineCommand4({
387
535
  const cmd = pm === "npm" ? "npm install whop-kit@latest" : pm === "yarn" ? "yarn add whop-kit@latest" : pm === "bun" ? "bun add whop-kit@latest" : "pnpm add whop-kit@latest";
388
536
  const result = exec(cmd);
389
537
  if (result.success) {
390
- s.stop(pc5.green("whop-kit upgraded"));
538
+ s.stop(pc7.green("whop-kit upgraded"));
391
539
  } else {
392
- s.stop(pc5.red("Upgrade failed"));
393
- p7.log.error("Try running manually: " + pc5.bold(cmd));
540
+ s.stop(pc7.red("Upgrade failed"));
541
+ p9.log.error("Try running manually: " + pc7.bold(cmd));
394
542
  }
395
- p7.outro("Done");
543
+ p9.outro("Done");
396
544
  }
397
545
  });
398
546
 
399
547
  // src/cli-kit.ts
400
- var main = defineCommand5({
548
+ var main = defineCommand7({
401
549
  meta: {
402
550
  name: "whop-kit",
403
- version: "0.2.0",
551
+ version: "0.5.0",
404
552
  description: "Manage your Whop project"
405
553
  },
406
554
  subCommands: {
407
555
  add: add_default,
408
556
  status: status_default,
557
+ env: env_default,
558
+ catalog: catalog_default,
409
559
  open: open_default,
410
560
  upgrade: upgrade_default
411
561
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-whop-kit",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "Scaffold and manage Whop-powered apps with whop-kit",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,82 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/utils/exec.ts
4
- import { execSync } from "child_process";
5
- function exec(cmd, cwd) {
6
- try {
7
- const stdout = execSync(cmd, {
8
- cwd,
9
- stdio: "pipe",
10
- encoding: "utf-8",
11
- timeout: 12e4
12
- }).trim();
13
- return { stdout, success: true };
14
- } catch {
15
- return { stdout: "", success: false };
16
- }
17
- }
18
- function execInteractive(cmd, cwd) {
19
- try {
20
- execSync(cmd, { cwd, stdio: "inherit", timeout: 3e5 });
21
- return true;
22
- } catch {
23
- return false;
24
- }
25
- }
26
- function hasCommand(cmd) {
27
- return exec(`which ${cmd}`).success;
28
- }
29
- function detectPackageManager() {
30
- if (hasCommand("pnpm")) return "pnpm";
31
- if (hasCommand("yarn")) return "yarn";
32
- if (hasCommand("bun")) return "bun";
33
- return "npm";
34
- }
35
-
36
- // src/scaffolding/manifest.ts
37
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
38
- import { join } from "path";
39
- var MANIFEST_DIR = ".whop";
40
- var MANIFEST_FILE = "config.json";
41
- function getManifestPath(projectDir) {
42
- return join(projectDir, MANIFEST_DIR, MANIFEST_FILE);
43
- }
44
- function createManifest(projectDir, data) {
45
- const dir = join(projectDir, MANIFEST_DIR);
46
- if (!existsSync(dir)) {
47
- mkdirSync(dir, { recursive: true });
48
- }
49
- const manifest = {
50
- version: 1,
51
- ...data,
52
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
53
- };
54
- writeFileSync(getManifestPath(projectDir), JSON.stringify(manifest, null, 2) + "\n");
55
- }
56
- function readManifest(projectDir) {
57
- const path = getManifestPath(projectDir);
58
- if (!existsSync(path)) return null;
59
- try {
60
- return JSON.parse(readFileSync(path, "utf-8"));
61
- } catch {
62
- return null;
63
- }
64
- }
65
- function addFeatureToManifest(projectDir, feature) {
66
- const manifest = readManifest(projectDir);
67
- if (!manifest) return;
68
- if (!manifest.features.includes(feature)) {
69
- manifest.features.push(feature);
70
- }
71
- writeFileSync(getManifestPath(projectDir), JSON.stringify(manifest, null, 2) + "\n");
72
- }
73
-
74
- export {
75
- exec,
76
- execInteractive,
77
- hasCommand,
78
- detectPackageManager,
79
- createManifest,
80
- readManifest,
81
- addFeatureToManifest
82
- };