generatesaas 0.2.3 → 0.3.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.
- package/README.md +10 -0
- package/dist/index.js +33 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,6 +57,16 @@ generatesaas init -n my-app --payment stripe --database neon --deploy cloudflare
|
|
|
57
57
|
| `--currency <code>` | Default billing currency (`USD`, `EUR`, `GBP`, `CAD`, `AUD`, `BRL`, `JPY`) |
|
|
58
58
|
| `-y, --yes` | Accept defaults for all unspecified options |
|
|
59
59
|
|
|
60
|
+
### `generatesaas auth`
|
|
61
|
+
|
|
62
|
+
Set or update your API key. Validates the key before saving.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
generatesaas auth
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Your API key is saved to `~/.generatesaas` and used automatically by all commands. You can also set `GENERATESAAS_API_KEY` as an environment variable to override the saved key.
|
|
69
|
+
|
|
60
70
|
### `generatesaas update`
|
|
61
71
|
|
|
62
72
|
Check for template updates and refresh AI coding skill files.
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Command as
|
|
3
|
-
`)}async function
|
|
2
|
+
import{Command as Jr}from"commander";import*as Dt from"@clack/prompts";import{existsSync as Cr,readdirSync as Or,rmSync as Lr}from"fs";import{join as jr,resolve as $r}from"path";import{Option as L}from"commander";import*as y from"@clack/prompts";import*as te from"@clack/prompts";import Se from"picocolors";function xe(){te.intro(Se.bgYellow(Se.black(" GenerateSaaS ")))}function ke(){te.outro(Se.yellow("Happy building!"))}import*as m from"@clack/prompts";var re={nuxt:{label:"Nuxt",hint:"Vue 3 + Nuxt 4"},nextjs:{label:"Next.js",hint:"coming soon"}},Ie={fullstack:{label:"Fullstack",hint:"Nuxt handles API via server routes"},separate:{label:"Separate",hint:"Standalone Hono backend"}},Ee={stripe:{label:"Stripe"},polar:{label:"Polar"},none:{label:"None",hint:"disable payments"}},Ae={smtp:{label:"SMTP",hint:"Mailpit for local dev"},ses:{label:"Amazon SES"},resend:{label:"Resend"}},be={user:{label:"Per user",hint:"each user has their own subscription"},organization:{label:"Per organization",hint:"org subscription shared by members"}},Pe={postgres:{label:"PostgreSQL",hint:"port 5432",port:5432},redis:{label:"Redis",hint:"port 6379",port:6379},inngest:{label:"Inngest",hint:"port 8288",port:8288},mailpit:{label:"Mailpit",hint:"port 1025",port:1025}},Ce={"claude-code":{label:"Claude Code"},cursor:{label:"Cursor"},codex:{label:"Codex"},"gemini-cli":{label:"Gemini CLI"},windsurf:{label:"Windsurf"}};var N={USD:{symbol:"$",name:"US Dollar",place:"left",space:!1},EUR:{symbol:"\u20AC",name:"Euro",place:"right",space:!1},GBP:{symbol:"\xA3",name:"British Pound",place:"left",space:!1},CAD:{symbol:"CA$",name:"Canadian Dollar",place:"left",space:!1},AUD:{symbol:"A$",name:"Australian Dollar",place:"left",space:!1},BRL:{symbol:"R$",name:"Brazilian Real",place:"left",space:!1},JPY:{symbol:"\xA5",name:"Japanese Yen",place:"left",space:!1}};var ne={node:{label:"Node.js / Docker",hint:"self-hosted with Dockerfile",edgeRuntime:!1},cloudflare:{label:"Cloudflare Workers",hint:"edge runtime, wrangler.toml",edgeRuntime:!0},vercel:{label:"Vercel",hint:"serverless, vercel.json",edgeRuntime:!0},netlify:{label:"Netlify",hint:"serverless, netlify.toml",edgeRuntime:!0}},V={postgres:{label:"PostgreSQL (self-hosted)",hint:"local Docker, drizzle-orm/node-postgres",managed:!1,envVars:[{key:"DATABASE_URL",defaultValue:"postgres://postgres:postgres@localhost:5432/saas"}]},neon:{label:"Neon",hint:"serverless Postgres",managed:!0,envVars:[{key:"DATABASE_URL",comment:"# TODO: Add your Neon connection string"}]},supabase:{label:"Supabase",hint:"managed Postgres",managed:!0,envVars:[{key:"DATABASE_URL",comment:"# TODO: Add your Supabase connection string"}]}},U={redis:{label:"Redis (self-hosted)",hint:"local Docker, ioredis",managed:!1,envVars:[{key:"REDIS_URL",defaultValue:"redis://localhost:6379"}]},upstash:{label:"Upstash",hint:"serverless Redis",managed:!0,envVars:[{key:"UPSTASH_REDIS_REST_URL",comment:"# TODO: Add your Upstash REST URL"},{key:"UPSTASH_REDIS_REST_TOKEN",comment:"# TODO: Add your Upstash REST token"}]}},Oe=[{target:"cloudflare",provider:"postgres",reason:"Cloudflare Workers cannot connect to self-hosted PostgreSQL. Use Neon or Supabase instead."},{target:"cloudflare",provider:"redis",reason:"Cloudflare Workers cannot connect to self-hosted Redis. Use Upstash instead."},{target:"vercel",provider:"redis",reason:"Vercel serverless cannot maintain persistent Redis connections. Consider Upstash."},{target:"netlify",provider:"redis",reason:"Netlify serverless cannot maintain persistent Redis connections. Consider Upstash."}],Le=["Local file storage (sharp, geoip-lite)","SMTP email (use Resend or SES instead)","Content API git integration"];var ie=["fullstack","separate"],oe=["stripe","polar","none"],se=["smtp","ses","resend"],ae=["postgres","redis","inngest","mailpit"],ce=["claude-code","cursor","codex","gemini-cli","windsurf"],pe=["user","organization"],M=["USD","EUR","GBP","CAD","AUD","BRL","JPY"],F=["node","cloudflare","vercel","netlify"],B=["postgres","neon","supabase"],G=["redis","upstash"];function je(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function le(e){return/^[a-z][a-z0-9-]*$/.test(e)}function v(e){return e instanceof Error?e.message:String(e)}function h(e){m.isCancel(e)&&(m.cancel("Setup cancelled."),process.exit(0))}async function $e(e){let t=e?.projectName??await(async()=>{let a=await m.text({message:"Project name:",placeholder:"my-saas",validate:c=>{if(!c?.trim())return"Project name is required.";if(!le(c))return"Use lowercase letters, numbers, and hyphens only. Must start with a letter."}});return h(a),a})(),r=e?.projectDir??await(async()=>{let a=await m.text({message:"Project location:",initialValue:`./${t}`});return h(a),a==="."?process.cwd():a})(),n=e?.frontend??await(async()=>{let a=Object.keys(re),c=await m.select({message:"Frontend framework:",options:a.map(T=>({value:T,label:re[T].label,hint:re[T].hint}))});return h(c),c==="nextjs"&&(m.cancel("Next.js support is coming soon. Please select Nuxt for now."),process.exit(0)),c})(),i=e?.architecture??await(async()=>{let a=await m.select({message:"Architecture:",options:ie.map(c=>({value:c,label:Ie[c].label,hint:Ie[c].hint}))});return h(a),a})(),o=e?.deploymentTarget??"node";if(i==="separate"&&e?.deploymentTarget===void 0){let a=await m.select({message:"Deployment target:",options:F.map(c=>({value:c,label:ne[c].label,hint:ne[c].hint}))});h(a),o=a}let s=e?.databaseProvider??await(async()=>{let a=await m.select({message:"Database provider:",options:B.map(c=>({value:c,label:V[c].label,hint:V[c].hint}))});return h(a),a})(),l=e?.cacheProvider??await(async()=>{let a=await m.select({message:"Cache provider:",options:G.map(c=>({value:c,label:U[c].label,hint:U[c].hint}))});return h(a),a})();if(i==="separate"){for(let a of Oe)a.target===o&&(a.provider===s||a.provider===l)&&m.log.warn(a.reason);ne[o].edgeRuntime&&m.log.warn(`Edge runtime selected. These features are not available: ${Le.join(", ")}`)}let d=e?.paymentProvider??await(async()=>{let a=await m.select({message:"Payment provider:",options:oe.map(c=>({value:c,label:Ee[c].label,hint:Ee[c].hint}))});return h(a),a})(),u=e?.defaultCurrency??await(async()=>{let a=await m.select({message:"Default currency:",options:M.map(c=>({value:c,label:c,hint:N[c].name}))});return h(a),a})(),S=e?.emailProvider??await(async()=>{let a=await m.select({message:"Email provider:",options:se.map(c=>({value:c,label:Ae[c].label,hint:Ae[c].hint}))});return h(a),a})(),j=e?.multiTenancy??await(async()=>{let a=await m.confirm({message:"Enable multi-tenancy (organizations)?",initialValue:!1});return h(a),a})(),q=e?.billingScope??"user";if(j&&e?.billingScope===void 0){let a=await m.select({message:"Billing scope:",options:pe.map(c=>({value:c,label:be[c].label,hint:be[c].hint}))});h(a),q=a}let g=e?.blog??await(async()=>{let a=await m.confirm({message:"Enable blog?",initialValue:!1});return h(a),a})(),f=e?.revenueSharing??await(async()=>{let a=await m.confirm({message:"Enable revenue sharing? (opt-in MRR leaderboard with dofollow backlinks)",initialValue:!1});return h(a),a})(),we=e?.dockerServices??await(async()=>{let a=[...ae].filter($=>$!=="mailpit");S==="smtp"&&a.push("mailpit");let c=a.map($=>({value:$,label:Pe[$].label,hint:Pe[$].hint})),T=await m.multiselect({message:"Which services should we set up in Docker for you?",options:c,initialValues:c.map($=>$.value),required:!1});return h(T),T})(),Tt=e?.aiTools??await(async()=>{let a=ce.map(T=>({value:T,label:Ce[T].label})),c=await m.multiselect({message:"Which AI coding tools do you use?",options:a,initialValues:[],required:!1});return h(c),c})();return{projectName:t,projectDir:r,frontend:n,architecture:i,deploymentTarget:o,databaseProvider:s,cacheProvider:l,paymentProvider:d,emailProvider:S,multiTenancy:j,billingScope:q,blog:g,revenueSharing:f,dockerServices:we,aiTools:Tt,defaultCurrency:u}}import{mkdir as Mt}from"fs/promises";import{Readable as Ft}from"stream";import{pipeline as Bt}from"stream/promises";import{extract as Gt}from"tar";import{join as Y}from"path";import{homedir as xt}from"os";var de=process.env.GENERATESAAS_API_URL??"https://cli.generatesaas.com",K=".generatesaas",J=Y(K,"manifest.json"),Ne=Y(K,"hashes.json"),me=Y(K,"template-hashes.json"),Ve=Y(K,"staging"),Ue=Y(K,"staging.json"),W=Y(xt(),".generatesaas");var w=class extends Error{constructor(r,n){super(n);this.status=r}name="ApiError"};function b(e){return{apiKey:e,baseUrl:de}}async function C(e,t,r){let n=`${e.baseUrl}${t}`,i=await fetch(n,{...r,headers:{...r?.headers,Authorization:`Bearer ${e.apiKey}`,"User-Agent":"generatesaas-cli"}});if(!i.ok){let o;try{o=(await i.json()).error??`API ${i.status}: ${t}`}catch{o=`API ${i.status}: ${t}`}throw new w(i.status,o)}return i}import{existsSync as kt,readFileSync as Ct,writeFileSync as Ot,mkdirSync as Lt}from"fs";import{dirname as jt}from"path";import*as O from"@clack/prompts";function $t(){if(!kt(W))return null;try{let e=JSON.parse(Ct(W,"utf-8"));return e.apiKey?e.apiKey:(e.token&&!e.apiKey&&O.log.warning(`Found old GitHub token in ${W}. Run 'generatesaas init' to set up your API key.`),null)}catch{return null}}function x(e){Lt(jt(W),{recursive:!0}),Ot(W,JSON.stringify({apiKey:e},null," ")+`
|
|
3
|
+
`)}async function X(e){let t=process.env.GENERATESAAS_API_KEY;if(t)return t;let r=$t();if(r)return r;if(!e?.prompt)throw new Error("API key not found. Set GENERATESAAS_API_KEY or run 'generatesaas init' to configure.");return k()}async function k(){let e=await O.text({message:"Enter your GenerateSaaS API key:",placeholder:"gs_live_...",validate:t=>{if(!t?.trim())return"API key is required."}});return O.isCancel(e)&&(O.cancel("Setup cancelled."),process.exit(0)),e}async function P(e){return await(await C(e,"/versions")).json()}async function Me(e,t){try{return await(await C(e,`/changelog/${encodeURIComponent(t)}`)).text()}catch(r){if(r instanceof w&&r.status===404)return null;throw r}}async function Fe(e,t){return await(await C(e,`/skill/${encodeURIComponent(t)}`)).json()}async function Be(e,t){return await(await C(e,"/license/sign",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json()}async function Ge(e,t){return await(await C(e,"/license/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json()}async function Ke(e,t){let r=await fetch(`${e}/license/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t})});if(!r.ok)throw new Error(`Verification service returned ${r.status}`);return await r.json()}var Nt=new Set([".git","node_modules",".pnpm-store",".env",".env.test",".turbo",".nuxt",".output",".data","dist",".next",".svelte-kit",".netlify",".wrangler",".devcontainer","playwright-report","test-results"]),Vt=new Set(["data","mksaas",".claude",".cursor",".agents",".codex",".generatesaas",".vscode",".mcp.json","AGENTS.md","TODO.md","OVERVIEW.md","pnpm-lock.yaml"]),Ut=["apps/cms","packages/blog","packages/cli","packages/cli-api","scripts/.env","scripts/.meta","infra/docker-compose.yml"];function ue(e){let t=e.split("/");for(let r of t)if(Nt.has(r))return!0;if(Vt.has(t[0]))return!0;for(let r of Ut)if(e===r||e.startsWith(r+"/"))return!0;return!1}async function Z(e,t,r){let n=await C(e,`/template/${encodeURIComponent(t)}`);if(!n.body)throw new Error("Empty response body");await Mt(r,{recursive:!0});let i=Ft.fromWeb(n.body);await Bt(i,Gt({cwd:r,strip:1,filter:o=>{let s=o.replace(/^[^/]+\//,"");return s?!ue(s):!0}}))}import{mkdir as Kt,writeFile as Ht}from"fs/promises";import{dirname as zt}from"path";async function fe(e){await Kt(e,{recursive:!0})}async function p(e,t){await fe(zt(e)),await Ht(e,t,"utf-8")}async function He(e){switch(e.cacheProvider){case"redis":await qt(e),await Yt(e);break;case"upstash":await Jt(e),await Wt(e);break}}async function qt(e){await p(`${e.projectDir}/packages/api/src/services/redis.ts`,`import { Redis } from "ioredis";
|
|
4
4
|
import { RedisStore } from "rate-limit-redis";
|
|
5
5
|
import { env } from "../env.js";
|
|
6
6
|
|
|
@@ -14,14 +14,14 @@ export const limiterStore = new RedisStore({
|
|
|
14
14
|
export function closeRedis(): void {
|
|
15
15
|
redis.disconnect();
|
|
16
16
|
}
|
|
17
|
-
`)}async function
|
|
17
|
+
`)}async function Yt(e){await p(`${e.projectDir}/packages/api/src/services/mutex.ts`,`import { Mutex } from "redis-semaphore";
|
|
18
18
|
import { redis } from "./redis.js";
|
|
19
19
|
|
|
20
20
|
/** Acquire a distributed mutex lock. */
|
|
21
21
|
export function createMutex(key: string): Mutex {
|
|
22
22
|
return new Mutex(redis, key);
|
|
23
23
|
}
|
|
24
|
-
`)}async function
|
|
24
|
+
`)}async function Jt(e){await p(`${e.projectDir}/packages/api/src/services/redis.ts`,`import { Redis } from "@upstash/redis";
|
|
25
25
|
import { Ratelimit } from "@upstash/ratelimit";
|
|
26
26
|
import { env } from "../env.js";
|
|
27
27
|
|
|
@@ -40,7 +40,7 @@ export function createRatelimit(maxRequests: number, window: string): Ratelimit
|
|
|
40
40
|
|
|
41
41
|
/** No persistent connection to close with Upstash REST. */
|
|
42
42
|
export function closeRedis(): void {}
|
|
43
|
-
`)}async function
|
|
43
|
+
`)}async function Wt(e){await p(`${e.projectDir}/packages/api/src/services/mutex.ts`,`import { redis } from "./redis.js";
|
|
44
44
|
|
|
45
45
|
/** Simple distributed mutex using Upstash Redis SET NX. */
|
|
46
46
|
export async function withMutex<T>(key: string, ttlMs: number, fn: () => Promise<T>): Promise<T> {
|
|
@@ -57,7 +57,7 @@ export async function withMutex<T>(key: string, ttlMs: number, fn: () => Promise
|
|
|
57
57
|
if (current === lockValue) await redis.del(lockKey);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
`)}async function
|
|
60
|
+
`)}async function ze(e){let t=je(e.projectName),r=e.paymentProvider!=="none",n=`import type { AppConfig } from "../types/index.js";
|
|
61
61
|
|
|
62
62
|
export const config: AppConfig = {
|
|
63
63
|
siteName: "${t}",
|
|
@@ -156,7 +156,7 @@ export const config: AppConfig = {
|
|
|
156
156
|
currency: {
|
|
157
157
|
base: "${e.defaultCurrency}",
|
|
158
158
|
list: [
|
|
159
|
-
{ symbol: "${
|
|
159
|
+
{ symbol: "${N[e.defaultCurrency].symbol}", name: "${N[e.defaultCurrency].name}", code: "${e.defaultCurrency}", place: "${N[e.defaultCurrency].place}", space: ${N[e.defaultCurrency].space} }
|
|
160
160
|
],
|
|
161
161
|
countryMap: {
|
|
162
162
|
default: "${e.defaultCurrency}"
|
|
@@ -209,7 +209,7 @@ export * from "./section-tabs.js";
|
|
|
209
209
|
export * from "./sidebar.js";
|
|
210
210
|
export * from "./tenancy.js";
|
|
211
211
|
export * from "./user-menu.js";
|
|
212
|
-
`,i=`${e.projectDir}/packages/core/src/config/index.ts`;await p(i,n)}async function
|
|
212
|
+
`,i=`${e.projectDir}/packages/core/src/config/index.ts`;await p(i,n)}async function qe(e){let t;switch(e.databaseProvider){case"postgres":t=Xt();break;case"neon":t=Qt();break;case"supabase":t=Zt();break}await p(`${e.projectDir}/packages/db/src/index.ts`,t)}function Xt(){return`import { drizzle } from "drizzle-orm/node-postgres";
|
|
213
213
|
import { z } from "zod";
|
|
214
214
|
import * as schema from "./db/schema.js";
|
|
215
215
|
|
|
@@ -221,7 +221,7 @@ export const pool = db.$client;
|
|
|
221
221
|
|
|
222
222
|
export * from "./db/schema.js";
|
|
223
223
|
export type { User, Account, Organization, Member } from "./db/auth.js";
|
|
224
|
-
`}function
|
|
224
|
+
`}function Qt(){return`import { neon } from "@neondatabase/serverless";
|
|
225
225
|
import { drizzle } from "drizzle-orm/neon-http";
|
|
226
226
|
import { z } from "zod";
|
|
227
227
|
import * as schema from "./db/schema.js";
|
|
@@ -234,7 +234,7 @@ export const db = drizzle(sql, { schema });
|
|
|
234
234
|
|
|
235
235
|
export * from "./db/schema.js";
|
|
236
236
|
export type { User, Account, Organization, Member } from "./db/auth.js";
|
|
237
|
-
`}function
|
|
237
|
+
`}function Zt(){return`import { drizzle } from "drizzle-orm/postgres-js";
|
|
238
238
|
import postgres from "postgres";
|
|
239
239
|
import { z } from "zod";
|
|
240
240
|
import * as schema from "./db/schema.js";
|
|
@@ -247,7 +247,7 @@ export const db = drizzle(client, { schema });
|
|
|
247
247
|
|
|
248
248
|
export * from "./db/schema.js";
|
|
249
249
|
export type { User, Account, Organization, Member } from "./db/auth.js";
|
|
250
|
-
`}async function
|
|
250
|
+
`}async function Ye(e){let t=[...e.dockerServices];if(V[e.databaseProvider].managed&&(t=t.filter(o=>o!=="postgres")),U[e.cacheProvider].managed&&(t=t.filter(o=>o!=="redis")),t.length===0)return!1;let r=[],n=[];t.includes("postgres")&&(r.push(` postgres:
|
|
251
251
|
image: postgres:18-alpine
|
|
252
252
|
ports:
|
|
253
253
|
- "\${POSTGRES_PORT:-5432}:5432"
|
|
@@ -290,7 +290,7 @@ ${r.join(`
|
|
|
290
290
|
volumes:
|
|
291
291
|
${n.join(`
|
|
292
292
|
`)}
|
|
293
|
-
`),await p(`${e.projectDir}/infra/docker-compose.yml`,i),!0}async function
|
|
293
|
+
`),await p(`${e.projectDir}/infra/docker-compose.yml`,i),!0}async function Je(e){if(e.architecture!=="separate")return;let t;switch(e.deploymentTarget){case"node":t=er();break;case"cloudflare":t=tr();break;case"vercel":t=rr();break;case"netlify":t=nr();break}await p(`${e.projectDir}/apps/backend/src/index.ts`,t)}function er(){return`import { serve } from "@hono/node-server";
|
|
294
294
|
import { app, closeRedis, env, logger } from "@repo/api";
|
|
295
295
|
|
|
296
296
|
const server = serve(
|
|
@@ -308,30 +308,30 @@ function shutdown() {
|
|
|
308
308
|
|
|
309
309
|
process.on("SIGINT", shutdown);
|
|
310
310
|
process.on("SIGTERM", shutdown);
|
|
311
|
-
`}function
|
|
311
|
+
`}function tr(){return`import { app } from "@repo/api";
|
|
312
312
|
|
|
313
313
|
export default app;
|
|
314
|
-
`}function
|
|
314
|
+
`}function rr(){return`import { handle } from "hono/vercel";
|
|
315
315
|
import { app } from "@repo/api";
|
|
316
316
|
|
|
317
317
|
export default handle(app);
|
|
318
|
-
`}function
|
|
318
|
+
`}function nr(){return`import { handle } from "hono/netlify";
|
|
319
319
|
import { app } from "@repo/api";
|
|
320
320
|
|
|
321
321
|
export default handle(app);
|
|
322
|
-
`}function
|
|
323
|
-
`)}function
|
|
324
|
-
`)}async function
|
|
325
|
-
`+t;await p(`${e.projectDir}/apps/web-nuxt/.env`,n)}else await p(`${e.projectDir}/apps/web-nuxt/.env`,r),await p(`${e.projectDir}/apps/backend/.env`,t)}import{readdir as
|
|
326
|
-
`),await p(
|
|
327
|
-
`)}async function
|
|
322
|
+
`}function We(e,t){for(let r of e)r.comment&&t.push(r.comment),r.defaultValue!==void 0?t.push(`${r.key}=${r.defaultValue}`):t.push(`#${r.key}=`)}function ir(e){let t=crypto.randomUUID(),n=["# API Configuration",`API_URL=${e.architecture==="fullstack"?"http://localhost:3000/api":"http://localhost:3010"}`];switch(n.push("","# Database"),We(V[e.databaseProvider].envVars,n),n.push("","# Cache"),We(U[e.cacheProvider].envVars,n),n.push("","# Authentication",`BETTER_AUTH_SECRET=${t}`,"","# Job Queue - Inngest","INNGEST_APP_ID=api","INNGEST_EVENT_KEY=local","INNGEST_BASE_URL=http://127.0.0.1:8288"),e.architecture==="separate"&&n.push("","# API Port (standalone backend)","API_PORT=3010"),n.push("","# Email"),e.emailProvider){case"smtp":n.push("SMTP_HOST=localhost","SMTP_PORT=1025");break;case"ses":n.push("# TODO: Configure Amazon SES credentials","#AMAZON_SES_REGION=us-east-1","#AMAZON_SES_KEY=","#AMAZON_SES_SECRET=");break;case"resend":n.push("# TODO: Add your Resend API key","#RESEND_API_KEY=");break}if(e.paymentProvider!=="none")switch(n.push("","# Payment"),e.paymentProvider){case"stripe":n.push("# TODO: Add your Stripe keys","#STRIPE_SECRET_KEY=sk_test_...","#STRIPE_WEBHOOK_SECRET=whsec_...");break;case"polar":n.push("# TODO: Add your Polar keys","#POLAR_ACCESS_TOKEN=","#POLAR_WEBHOOK_SECRET=");break}return n.push(""),n.join(`
|
|
323
|
+
`)}function or(e){return["# API Configuration",`NUXT_PUBLIC_API_URL=${e.architecture==="fullstack"?"http://localhost:3000/api":"http://localhost:3010"}`,""].join(`
|
|
324
|
+
`)}async function Xe(e){let t=ir(e),r=or(e);if(e.architecture==="fullstack"){let n=r+`
|
|
325
|
+
`+t;await p(`${e.projectDir}/apps/web-nuxt/.env`,n)}else await p(`${e.projectDir}/apps/web-nuxt/.env`,r),await p(`${e.projectDir}/apps/backend/.env`,t)}import{readdir as ar}from"fs/promises";import{join as _e,relative as et}from"path";import{createHash as Qe}from"crypto";import{readFile as sr}from"fs/promises";async function ge(e){let t=await sr(e);return Qe("sha256").update(t).digest("hex")}function Ze(e){return Qe("sha256").update(e).digest("hex")}var cr=new Set([".git","node_modules",".pnpm-store",".env","data",K]);function pr(e){let t=e.split("/");for(let r of t)if(cr.has(r)||r.startsWith(".env")&&!r.includes("example"))return!0;return!1}async function tt(e,t){let r=[],n=await ar(e,{withFileTypes:!0});for(let i of n){let o=_e(e,i.name),s=et(t,o);pr(s)||(i.isDirectory()?r.push(...await tt(o,t)):i.isFile()&&r.push(o))}return r}async function rt(e,t){let n=(await tt(e.projectDir,e.projectDir)).sort(),i=await Promise.all(n.map(async l=>[et(e.projectDir,l),await ge(l)])),o=Object.fromEntries(i),s={version:e.version,initialVersion:e.version,repo:"Duzbee/GenerateSaaS",frontend:e.frontend,aiTools:e.aiTools,deploymentTarget:e.deploymentTarget,databaseProvider:e.databaseProvider,cacheProvider:e.cacheProvider,revenueSharing:e.revenueSharing,...t&&{licenseToken:t.token,licenseKeyHash:t.keyHash,installId:t.installId}};await p(_e(e.projectDir,J),JSON.stringify(s,null," ")+`
|
|
326
|
+
`),await p(_e(e.projectDir,Ne),JSON.stringify(o,null," ")+`
|
|
327
|
+
`)}async function nt(e){if(!(e.architecture!=="separate"||e.deploymentTarget==="node"))switch(e.deploymentTarget){case"cloudflare":await lr(e);break;case"vercel":await dr(e);break;case"netlify":await mr(e);break}}async function lr(e){let t=`name = "${e.projectName}-api"
|
|
328
328
|
main = "src/index.ts"
|
|
329
329
|
compatibility_date = "2024-12-01"
|
|
330
330
|
|
|
331
331
|
[vars]
|
|
332
332
|
API_URL = "https://api.example.com"
|
|
333
|
-
`;await p(`${e.projectDir}/apps/backend/wrangler.toml`,t)}async function
|
|
334
|
-
`;await p(`${e.projectDir}/apps/backend/vercel.json`,t)}async function
|
|
333
|
+
`;await p(`${e.projectDir}/apps/backend/wrangler.toml`,t)}async function dr(e){let t=JSON.stringify({buildCommand:"pnpm build",outputDirectory:"dist",framework:null,rewrites:[{source:"/(.*)",destination:"/api"}]},null," ")+`
|
|
334
|
+
`;await p(`${e.projectDir}/apps/backend/vercel.json`,t)}async function mr(e){await p(`${e.projectDir}/apps/backend/netlify.toml`,`[build]
|
|
335
335
|
command = "pnpm build"
|
|
336
336
|
publish = "dist"
|
|
337
337
|
|
|
@@ -342,7 +342,7 @@ API_URL = "https://api.example.com"
|
|
|
342
342
|
from = "/*"
|
|
343
343
|
to = "/.netlify/functions/index"
|
|
344
344
|
status = 200
|
|
345
|
-
`)}function
|
|
345
|
+
`)}function ur(e){return e==="stripe"?' stripePriceId: "",':' polarProductId: "",'}function fr(e){return e==="stripe"?' stripePriceId: "",':' polarProductId: "",'}function gr(e){return e==="stripe"?' stripeProductId: "",':' polarProductId: "",'}async function it(e){if(e.paymentProvider==="none")return;let t=e.paymentProvider,r=e.defaultCurrency,n=ur(t),i=fr(t),o=gr(t),s=`import type { PricingConfig } from "../types/index.js";
|
|
346
346
|
|
|
347
347
|
export const pricingConfig: PricingConfig = {
|
|
348
348
|
defaultPlan: "free",
|
|
@@ -540,12 +540,12 @@ ${i}
|
|
|
540
540
|
]
|
|
541
541
|
}
|
|
542
542
|
};
|
|
543
|
-
`,l=`${e.projectDir}/packages/core/src/config/pricing.ts`;await p(l,
|
|
544
|
-
`)}import{readdir as
|
|
545
|
-
`),
|
|
546
|
-
`),r.start("Generating configuration..."),await
|
|
547
|
-
`),
|
|
548
|
-
`)}finally{await
|
|
549
|
-
`),
|
|
550
|
-
`),
|
|
551
|
-
`).map(
|
|
543
|
+
`,l=`${e.projectDir}/packages/core/src/config/pricing.ts`;await p(l,s)}function yr(e){let t=[];e.architecture==="separate"&&t.push({type:"node-terminal",request:"launch",name:"Backend",command:"pnpm dev",cwd:"${workspaceFolder}/apps/backend",skipFiles:["<node_internals>/**"],env:{NODE_ENV:"development"}});let r=e.frontend==="nuxt"?"Nuxt":e.frontend;if(t.push({type:"node-terminal",request:"launch",name:r,command:"pnpm dev",cwd:`\${workspaceFolder}/apps/web-${e.frontend}`,skipFiles:["<node_internals>/**"],env:{NODE_ENV:"development"}}),t.push({type:"node-terminal",request:"launch",name:"Inngest",command:"pnpm dev:inngest",cwd:"${workspaceFolder}",skipFiles:["<node_internals>/**"],env:{NODE_ENV:"development"}}),t.push({type:"node-terminal",request:"launch",name:"Email",command:"pnpm dev:email",cwd:"${workspaceFolder}",skipFiles:["<node_internals>/**"],env:{NODE_ENV:"development"}}),e.paymentProvider==="stripe"){let n=e.architecture==="separate"?"localhost:3010/auth/stripe/webhook":"localhost:3000/api/auth/stripe/webhook";t.push({type:"node-terminal",request:"launch",name:"Stripe",command:`stripe listen --forward-to ${n}`,cwd:"${workspaceFolder}",skipFiles:["<node_internals>/**"]})}return t}function hr(e){let t=e.frontend==="nuxt"?"Nuxt":e.frontend,r=[];return e.architecture==="separate"?r.push({name:`Dev (${t} + Backend + Inngest)`,configurations:["Backend",t,"Inngest"]}):r.push({name:`Dev (${t} + Inngest)`,configurations:[t,"Inngest"]}),r}async function ot(e){let t={version:"0.2.0",configurations:yr(e),compounds:hr(e)};await p(`${e.projectDir}/.vscode/launch.json`,JSON.stringify(t,null," ")+`
|
|
544
|
+
`)}import{readdir as vr}from"fs/promises";import{join as wr,relative as st}from"path";async function at(e,t){let r=[],n=await vr(e,{withFileTypes:!0});for(let i of n){let o=wr(e,i.name),s=st(t,o);ue(s)||(i.isDirectory()?r.push(...await at(o,t)):i.isFile()&&r.push(o))}return r}async function ye(e){let r=(await at(e,e)).sort(),n=await Promise.all(r.map(async i=>[st(e,i),await ge(i)]));return Object.fromEntries(n)}import{existsSync as Sr}from"fs";import{readFile as ct,readdir as Ir}from"fs/promises";import{join as _,dirname as Er}from"path";import{fileURLToPath as Ar}from"url";var lt={"claude-code":".claude/skills",cursor:".cursor/skills",codex:".agents/skills","gemini-cli":".gemini/skills",windsurf:".windsurf/skills"},br=Object.values(lt),Pr="generatesaas-update",pt=Er(Ar(import.meta.url));function _r(){let e=_(pt,"skill","content");return Sr(e)?e:_(pt,"content")}function Re(e){return!e||e.length===0?br:e.map(t=>lt[t])}async function De(e,t,r,n){let i=Re(n);for(let o of i){let s=_(e,o,Pr),l=_(s,"scripts"),d=_(s,"references");await fe(l),await fe(d),await p(_(s,"SKILL.md"),t),await p(_(d,".gitkeep"),"");for(let[u,S]of Object.entries(r))await p(_(l,u),S)}}async function dt(e,t){let r=_r(),n=await ct(_(r,"SKILL.md"),"utf-8"),i=_(r,"scripts"),o=await Ir(i),s={};for(let l of o)l!==".gitkeep"&&(s[l]=await ct(_(i,l),"utf-8"));await De(e,n,s,t)}import{execFile as Rr,execFileSync as Dr}from"child_process";import{access as Tr}from"fs/promises";import{join as xr}from"path";import*as R from"@clack/prompts";function mt(e){try{return Dr("which",[e],{stdio:"ignore"}),!0}catch{return!1}}function he(e,t,r,n=3e5){return new Promise((i,o)=>{Rr(e,t,{cwd:r,timeout:n},s=>{s?o(s):i()})})}async function ut(e){if(!mt("pnpm"))return R.log.warn("pnpm not found. Skipping dependency installation."),R.log.info("Install pnpm: https://pnpm.io/installation"),!1;let t=R.spinner();t.start("Installing dependencies (this may take a minute)...");try{return await he("pnpm",["install"],e),t.stop("Dependencies installed."),!0}catch{return t.stop("Dependency installation failed."),R.log.warn("pnpm install failed. You can run it manually later."),!1}}async function ft(e){try{return await Tr(xr(e,".git")),R.log.info("Git repository already exists, skipping init."),!0}catch{}if(!mt("git"))return R.log.warn("git not found. Skipping repository initialization."),!1;let t=R.spinner();t.start("Initializing git repository...");try{return await he("git",["init"],e),await he("git",["add","-A"],e),await he("git",["commit","-m","Initial commit from GenerateSaaS"],e),t.stop("Git repository initialized."),!0}catch{return t.stop("Git initialization failed."),R.log.warn("You can run git init manually later."),!1}}import*as gt from"@clack/prompts";import kr from"picocolors";function yt(e,t,r){let n=[];n.push(`cd ${e.projectDir}`),t||n.push("pnpm install"),n.push("Fill in .env with your API keys"),r?n.push("pnpm infra # Start Docker services"):n.push("# Using your existing services \u2014 no Docker setup needed"),n.push("pnpm dev # Start development server"),gt.note(n.join(`
|
|
545
|
+
`),kr.yellow("Next steps"))}function wt(e){let t={};if(e.name!==void 0){if(!le(e.name))throw new Error(`Invalid project name "${e.name}". Use lowercase letters, numbers, and hyphens only. Must start with a letter.`);t.projectName=e.name}if(e.location!==void 0?t.projectDir=e.location==="."?process.cwd():e.location:t.projectName!==void 0&&(t.projectDir=`./${t.projectName}`),e.frontend!==void 0&&(t.frontend=e.frontend),e.architecture!==void 0&&(t.architecture=e.architecture),e.payment!==void 0&&(t.paymentProvider=e.payment),e.email!==void 0&&(t.emailProvider=e.email),e.org!==void 0&&(t.multiTenancy=e.org),e.billingScope!==void 0){if(e.org===!1)throw new Error("--billing-scope requires --org to be enabled.");t.billingScope=e.billingScope}if(e.blog!==void 0&&(t.blog=e.blog),e.revenueSharing!==void 0&&(t.revenueSharing=e.revenueSharing),e.docker!==void 0&&(t.dockerServices=vt(e.docker,ae,"docker service")),e.aiTools!==void 0&&(t.aiTools=vt(e.aiTools,ce,"AI tool")),e.currency!==void 0){if(!M.includes(e.currency))throw new Error(`Invalid currency "${e.currency}". Valid values: ${M.join(", ")}`);t.defaultCurrency=e.currency}if(e.deploy!==void 0){if(!F.includes(e.deploy))throw new Error(`Invalid deployment target "${e.deploy}". Valid values: ${F.join(", ")}`);t.deploymentTarget=e.deploy}if(e.database!==void 0){if(!B.includes(e.database))throw new Error(`Invalid database provider "${e.database}". Valid values: ${B.join(", ")}`);t.databaseProvider=e.database}if(e.cache!==void 0){if(!G.includes(e.cache))throw new Error(`Invalid cache provider "${e.cache}". Valid values: ${G.join(", ")}`);t.cacheProvider=e.cache}return t}var ht={projectName:"my-saas",frontend:"nuxt",architecture:"fullstack",paymentProvider:"stripe",emailProvider:"smtp",multiTenancy:!1,billingScope:"user",blog:!1,revenueSharing:!1,dockerServices:["postgres","redis","inngest"],aiTools:[],defaultCurrency:"USD",deploymentTarget:"node",databaseProvider:"postgres",cacheProvider:"redis"};function St(e){let t=e.projectName??ht.projectName,r=e.projectDir??`./${t}`;return{...ht,...e,projectName:t,projectDir:r}}function vt(e,t,r){if(e.trim()==="")return[];let n=e.split(",").map(o=>o.trim()).filter(Boolean),i=n.filter(o=>!t.includes(o));if(i.length>0)throw new Error(`Invalid ${r}(s): ${i.join(", ")}. Valid values: ${t.join(", ")}`);return n}function It(e){e.command("init").description("Scaffold a new GenerateSaaS project").option("-n, --name <name>","project name (lowercase, hyphens, starts with letter)").option("-l, --location <path>","project directory (default: ./{name})").addOption(new L("--architecture <type>","fullstack or separate").choices([...ie])).addOption(new L("--payment <provider>","payment provider").choices([...oe])).addOption(new L("--email <provider>","email provider").choices([...se])).option("--org","enable multi-tenancy (organizations)").option("--no-org","disable multi-tenancy").addOption(new L("--billing-scope <scope>","billing scope (requires --org)").choices([...pe])).option("--blog","enable blog").option("--no-blog","disable blog").option("--revenue-sharing","enable revenue sharing").option("--no-revenue-sharing","disable revenue sharing").option("--docker <services>","comma-separated: postgres,redis,inngest,mailpit").option("--ai-tools <tools>","comma-separated: claude-code,cursor,codex,gemini-cli,windsurf").addOption(new L("--currency <code>","default currency for billing").choices([...M])).addOption(new L("--deploy <target>","deployment target").choices([...F])).addOption(new L("--database <provider>","database provider").choices([...B])).addOption(new L("--cache <provider>","cache provider").choices([...G])).option("-y, --yes","accept defaults for unspecified options (non-interactive)").action(async t=>{await Nr(t)})}async function Nr(e){xe();let t;try{t=wt(e)}catch(g){y.cancel(v(g)),process.exit(1)}let r=y.spinner(),n;try{n=await X({prompt:!e.yes})}catch(g){y.cancel(v(g)),process.exit(1)}let i=b(n);r.start("Verifying access...");let o;try{o=(await P(i)).latest,r.stop("Access verified."),x(n)}catch(g){if(r.stop("Access verification failed."),g instanceof w&&g.status===401){y.log.warning("Invalid API key."),n=await k(),i=b(n),r.start("Verifying access...");try{o=(await P(i)).latest,r.stop("Access verified."),x(n)}catch(f){r.stop("Access verification failed."),y.cancel(f instanceof w&&f.status===401?"Invalid API key.":v(f)),process.exit(1)}}else y.cancel(v(g)),process.exit(1)}y.log.success(`Latest version: ${o}`);let s;r.start("Activating license...");try{let g=crypto.randomUUID();s={token:(await Be(i,{frontend:"nuxt",version:o,installId:g})).token,keyHash:Ze(n),installId:g},r.stop("License activated.")}catch{r.stop("License activation skipped."),y.log.warn("Could not activate license. You can retry with 'generatesaas update'.")}let l;e.yes?l=St(t):l=await $e(t);let d=$r(l.projectDir);if(Cr(d)&&Or(d).length>0)if(e.yes)y.log.info(`Directory ${d} is not empty. Merging (keeping existing files, overwriting conflicts).`);else{let f=await y.select({message:`Directory ${d} is not empty.`,options:[{value:"merge",label:"Merge",hint:"keep existing files, overwrite conflicts"},{value:"overwrite",label:"Overwrite",hint:"delete everything and start fresh"},{value:"cancel",label:"Cancel"}]});(y.isCancel(f)||f==="cancel")&&(y.cancel("Setup cancelled."),process.exit(0)),f==="overwrite"&&Lr(d,{recursive:!0,force:!0})}let u={...l,projectDir:d,version:o};r.start("Downloading template...");try{await Z(i,o,d),r.stop("Template downloaded.")}catch(g){r.stop("Download failed."),y.cancel(v(g)),process.exit(1)}let S=await ye(d);await p(jr(d,me),JSON.stringify(S,null," ")+`
|
|
546
|
+
`),r.start("Generating configuration..."),await ze(u),await it(u),r.stop("Configuration generated."),r.start("Generating environment files..."),await Xe(u),r.stop("Environment files generated.");let j=await Ye(u);j&&y.log.success("Docker Compose generated."),await ot(u),r.start("Generating infrastructure..."),await Je(u),await qe(u),await He(u),await nt(u),r.stop("Infrastructure generated."),r.start("Installing AI skills..."),await dt(d,u.aiTools),r.stop("AI skills installed."),r.start("Generating manifest..."),await rt(u,s),r.stop("Manifest generated.");let q=await ut(d);await ft(d),yt(u,q,j),ke()}import{existsSync as Vr}from"fs";import{readFile as Ur,rm as Mr}from"fs/promises";import{join as ee,resolve as Fr}from"path";import{mkdtemp as Br}from"fs/promises";import{tmpdir as Gr}from"os";import*as I from"@clack/prompts";import ve from"picocolors";function Et(e){e.command("update").description("Update AI skill files and stage template updates").option("--cwd <path>","project directory (default: current directory)").action(async t=>{let r=Fr(t.cwd??process.cwd()),n=ee(r,J),i;try{i=JSON.parse(await Ur(n,"utf-8"))}catch{I.cancel(".generatesaas/manifest.json not found. Run this from a GenerateSaaS project."),process.exit(1)}let o=I.spinner();try{let s=await X(),l=b(s);o.start("Verifying access...");let d;try{d=await P(l)}catch(f){if(f instanceof w&&f.status===401)o.stop("Invalid API key."),s=await k(),l=b(s),o.start("Verifying access..."),d=await P(l),x(s);else throw f}o.stop("Access verified."),o.start("Fetching latest skill files...");let u=await Fe(l,d.latest);await De(r,u.skillMd,u.scripts,i.aiTools);let S=Re(i.aiTools);if(o.stop("Skills updated."),I.log.success(`Skill files installed to ${ve.cyan(S.length.toString())} locations.`),i.licenseToken)try{let f=await Ge(l,{currentToken:i.licenseToken,newVersion:d.latest});i.licenseToken=f.token,await p(n,JSON.stringify(i,null," ")+`
|
|
547
|
+
`),I.log.success("License refreshed.")}catch{I.log.warn("License refresh skipped.")}if(i.version===d.latest){I.log.info(`Already on the latest version (${i.version}).`);return}let j=ee(r,Ve);o.start(`Downloading v${d.latest} template...`),await Z(l,d.latest,j),o.stop("Template staged.");let q=await Me(l,d.latest),g=ee(r,me);if(!Vr(g)){o.start("Computing baseline template hashes (one-time migration)...");let f=await Br(ee(Gr(),"gs-update-"));try{await Z(l,i.version,f);let we=await ye(f);await p(g,JSON.stringify(we,null," ")+`
|
|
548
|
+
`)}finally{await Mr(f,{recursive:!0,force:!0})}o.stop("Baseline hashes computed.")}await p(ee(r,Ue),JSON.stringify({currentVersion:i.version,targetVersion:d.latest,changelog:q,stagedAt:new Date().toISOString()},null," ")+`
|
|
549
|
+
`),I.log.info(`Update staged: ${ve.cyan(i.version)} \u2192 ${ve.cyan(d.latest)}`),I.log.info("Ask your AI assistant to "+ve.cyan("'update my GenerateSaaS project'")+".")}catch(s){o.stop("Failed."),I.cancel(`Update failed: ${v(s)}`),process.exit(1)}})}import*as E from"@clack/prompts";import H from"picocolors";import{readFile as Kr}from"fs/promises";import{join as Hr,resolve as zr}from"path";function At(e){e.command("status").description("Show project status and check for updates").option("--cwd <path>","project directory (default: current directory)").action(async t=>{let r=zr(t.cwd??process.cwd()),n=Hr(r,J),i;try{i=JSON.parse(await Kr(n,"utf-8"))}catch{E.cancel(".generatesaas/manifest.json not found. Run this from a GenerateSaaS project."),process.exit(1)}E.log.info(`${H.bold("Project Status")}`),E.log.info(` Version: ${H.cyan(i.version)}`),E.log.info(` Frontend: ${H.cyan(i.frontend)}`);let o=E.spinner();o.start("Checking for updates...");try{let s=await X(),l=b(s),d;try{d=await P(l)}catch(S){if(S instanceof w&&S.status===401)o.stop("Invalid API key."),s=await k(),l=b(s),o.start("Checking for updates..."),d=await P(l),x(s);else throw S}let u=d.latest;i.version===u?(o.stop("Up to date."),E.log.success(`Already on the latest version (${H.green(u)})`)):(o.stop("Update available."),E.log.warning(`Update available: ${H.yellow(i.version)} \u2192 ${H.green(u)}`),E.log.info(`Run ${H.cyan("generatesaas update")} to update skill files, then ask your AI assistant to apply the update.`))}catch(s){o.stop("Check failed."),E.log.warning(`Could not check for updates: ${v(s)}`)}})}import{readFile as qr}from"fs/promises";import*as A from"@clack/prompts";import D from"picocolors";function Yr(e){let t=e.split(".");if(t.length!==3||!t[1])throw new Error("Invalid JWT format");let r=Buffer.from(t[1],"base64url").toString("utf-8");return JSON.parse(r)}function Te(e){return typeof e!="number"?"unknown":new Date(e*1e3).toISOString().split("T")[0]}function bt(e){A.note([`License ID: ${D.cyan(String(e.lid??"unknown"))}`,`Version: ${D.cyan(String(e.ver??"unknown"))}`,`Init version: ${String(e.iver??"unknown")}`,`Frontend: ${String(e.fe??"unknown")}`,`Created: ${Te(e.pat)}`,`Last updated: ${Te(e.uat)}`,`Expires: ${Te(e.exp)}`,`Install ID: ${String(e.nid??"unknown")}`].join(`
|
|
550
|
+
`),D.yellow("License Details"))}async function Pt(e){let t=A.spinner(),r=e.replace(/\/+$/,"");t.start(`Checking ${r}/license...`);let n;try{let o=await fetch(`${r}/license`);if(!o.ok)return t.stop(`${D.red("Not found")} \u2014 ${r}/license returned ${o.status}`),!1;if(n=await o.text(),!n||n.split(".").length!==3)return t.stop(`${D.red("Invalid")} \u2014 response is not a JWT`),!1;t.stop(`${D.green("Found")} \u2014 license endpoint responded`)}catch(o){return t.stop(`${D.red("Failed")} \u2014 ${v(o)}`),!1}let i;try{i=Yr(n)}catch{return A.log.error("Could not decode JWT payload."),!1}t.start("Verifying signature...");try{let o=process.env.GENERATESAAS_API_URL??de,s=await Ke(o,n);if(s.valid)t.stop(`${D.green("Valid")} \u2014 signature verified`);else return t.stop(`${D.red("Invalid")} \u2014 ${s.reason}`),!1}catch{return t.stop(`${D.yellow("Skipped")} \u2014 could not reach verification service`),A.log.warn("Signature not verified. Displaying unverified claims:"),bt(i),!1}return bt(i),!0}function _t(e){e.command("verify").description("Verify a GenerateSaaS license on a deployed site").argument("[url]","URL of the site to verify (e.g. https://example.com/api)").option("--file <path>","file with URLs to check, one per line").action(async(t,r)=>{if(!t&&!r.file&&(A.cancel("Provide a URL or --file <path>."),process.exit(1)),r.file){let i=(await qr(r.file,"utf-8")).split(`
|
|
551
|
+
`).map(s=>s.trim()).filter(s=>s&&!s.startsWith("#"));i.length===0&&(A.cancel("No URLs found in file."),process.exit(1));let o=0;for(let s of i)await Pt(s)&&o++,A.log.info("");A.log.success(`${o}/${i.length} sites verified.`)}else await Pt(t)||process.exit(1)})}import*as z from"@clack/prompts";function Rt(e){e.command("auth").description("Set or update your GenerateSaaS API key").action(async()=>{let t=await k(),r=b(t),n=z.spinner();n.start("Verifying API key...");try{await P(r),n.stop("API key verified."),x(t),z.log.success("API key saved.")}catch(i){n.stop("Verification failed."),i instanceof w&&i.status===401?z.cancel("Invalid API key."):z.cancel(v(i)),process.exit(1)}})}var Q=new Jr().name("generatesaas").description("CLI for scaffolding and managing GenerateSaaS projects").version("0.3.0");It(Q);Et(Q);At(Q);_t(Q);Rt(Q);Q.parseAsync().catch(e=>{Dt.cancel("An unexpected error occurred."),console.error(e),process.exit(1)});
|