create-better-t-stack 1.2.0 → 1.3.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.
- package/README.md +52 -38
- package/dist/index.js +61 -55
- package/package.json +1 -1
- package/template/base/apps/native/_gitignore +24 -0
- package/template/base/apps/native/app/(drawer)/(tabs)/_layout.tsx +29 -0
- package/template/base/apps/native/app/(drawer)/(tabs)/index.tsx +9 -0
- package/template/base/apps/native/app/(drawer)/(tabs)/two.tsx +16 -0
- package/template/base/apps/native/app/(drawer)/_layout.tsx +39 -0
- package/template/base/apps/native/app/(drawer)/index.tsx +36 -0
- package/template/base/apps/native/app/+html.tsx +46 -0
- package/template/base/apps/native/app/+not-found.tsx +18 -0
- package/template/base/apps/native/app/_layout.tsx +76 -0
- package/template/base/apps/native/app/modal.tsx +15 -0
- package/template/base/apps/native/app-env.d.ts +2 -0
- package/template/base/apps/native/app.json +38 -0
- package/template/base/apps/native/assets/adaptive-icon.png +0 -0
- package/template/base/apps/native/assets/favicon.png +0 -0
- package/template/base/apps/native/assets/icon.png +0 -0
- package/template/base/apps/native/assets/splash.png +0 -0
- package/template/base/apps/native/babel.config.js +12 -0
- package/template/base/apps/native/components/container.tsx +9 -0
- package/template/base/apps/native/components/header-button.tsx +31 -0
- package/template/base/apps/native/components/tabbar-icon.tsx +15 -0
- package/template/base/apps/native/global.css +25 -0
- package/template/base/apps/native/lib/android-navigation-bar.tsx +11 -0
- package/template/base/apps/native/lib/constants.ts +18 -0
- package/template/base/apps/native/lib/use-color-scheme.ts +12 -0
- package/template/base/apps/native/metro.config.js +57 -0
- package/template/base/apps/native/package.json +47 -0
- package/template/base/apps/native/tailwind.config.js +32 -0
- package/template/base/apps/native/tsconfig.json +18 -0
- package/template/base/apps/native/utils/trpc.ts +19 -0
- package/template/base/apps/{client → web}/package.json +1 -1
- package/template/base/apps/web/src/main.tsx +33 -0
- package/template/base/apps/{client → web}/src/routes/__root.tsx +3 -3
- package/template/base/apps/{client → web}/src/routes/index.tsx +7 -6
- package/template/base/apps/web/src/utils/trpc.ts +33 -0
- package/template/base/package.json +2 -1
- package/template/with-auth/apps/{client → web}/src/routes/dashboard.tsx +2 -1
- package/template/with-auth/apps/web/src/utils/trpc.ts +39 -0
- package/template/base/apps/client/src/main.tsx +0 -72
- package/template/base/apps/client/src/utils/trpc.ts +0 -4
- package/template/with-auth/apps/client/src/main.tsx +0 -78
- /package/template/base/apps/{client → web}/_gitignore +0 -0
- /package/template/base/apps/{client → web}/components.json +0 -0
- /package/template/base/apps/{client → web}/index.html +0 -0
- /package/template/base/apps/{client → web}/src/components/header.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/loader.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/mode-toggle.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/theme-provider.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/button.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/card.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/checkbox.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/dropdown-menu.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/input.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/label.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/skeleton.tsx +0 -0
- /package/template/base/apps/{client → web}/src/components/ui/sonner.tsx +0 -0
- /package/template/base/apps/{client → web}/src/index.css +0 -0
- /package/template/base/apps/{client → web}/src/lib/utils.ts +0 -0
- /package/template/base/apps/{client → web}/tsconfig.json +0 -0
- /package/template/base/apps/{client → web}/vite.config.ts +0 -0
- /package/template/examples/todo/apps/{client → web}/src/routes/todos.tsx +0 -0
- /package/template/with-auth/apps/{client → web}/src/components/auth-forms.tsx +0 -0
- /package/template/with-auth/apps/{client → web}/src/components/header.tsx +0 -0
- /package/template/with-auth/apps/{client → web}/src/components/sign-in-form.tsx +0 -0
- /package/template/with-auth/apps/{client → web}/src/components/sign-up-form.tsx +0 -0
- /package/template/with-auth/apps/{client → web}/src/components/user-menu.tsx +0 -0
- /package/template/with-auth/apps/{client → web}/src/lib/auth-client.ts +0 -0
- /package/template/with-auth/apps/{client → web}/src/routes/login.tsx +0 -0
- /package/template/with-pwa/apps/{client → web}/public/logo.png +0 -0
- /package/template/with-pwa/apps/{client → web}/pwa-assets.config.ts +0 -0
- /package/template/with-pwa/apps/{client → web}/vite.config.ts +0 -0
package/README.md
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
# Create Better-T-Stack CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A CLI tool for scaffolding type-safe full-stack apps with Hono/Elysia backends, React web frontends, and Expo native apps, all connected through tRPC.
|
|
4
4
|
|
|
5
5
|
## Quick Start
|
|
6
6
|
|
|
7
7
|
Run without installing globally:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
+
# Using npm
|
|
10
11
|
npx create-better-t-stack@latest
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
# Using bun
|
|
14
|
+
bun create better-t-stack@latest
|
|
15
|
+
|
|
16
|
+
# Using pnpm
|
|
17
|
+
pnpm create better-t-stack@latest
|
|
13
18
|
```
|
|
14
19
|
|
|
15
|
-
Follow the prompts to configure your project.
|
|
20
|
+
Follow the prompts to configure your project or use the `-y` flag for defaults.
|
|
16
21
|
|
|
17
22
|
## Features
|
|
18
23
|
|
|
19
24
|
- **Monorepo**: Turborepo for optimized build system and workspace management
|
|
20
25
|
- **Frontend**: React, TanStack Router, TanStack Query, Tailwind CSS with shadcn/ui components
|
|
21
|
-
- **
|
|
26
|
+
- **Native Apps**: Create React Native apps with Expo for iOS and Android
|
|
27
|
+
- **Backend Frameworks**: Choose between Hono or Elysia
|
|
28
|
+
- **API Layer**: End-to-end type safety with tRPC
|
|
22
29
|
- **Runtime Options**: Choose between Bun or Node.js for your server
|
|
23
30
|
- **Database Options**: SQLite (via Turso), PostgreSQL, or no database
|
|
24
31
|
- **ORM Selection**: Choose between Drizzle ORM or Prisma
|
|
@@ -36,33 +43,39 @@ Follow the prompts to configure your project.
|
|
|
36
43
|
Usage: create-better-t-stack [project-directory] [options]
|
|
37
44
|
|
|
38
45
|
Options:
|
|
39
|
-
-V, --version
|
|
40
|
-
-y, --yes
|
|
41
|
-
--no-database
|
|
42
|
-
--sqlite
|
|
43
|
-
--postgres
|
|
44
|
-
--auth
|
|
45
|
-
--no-auth
|
|
46
|
-
--pwa
|
|
47
|
-
--tauri
|
|
48
|
-
--biome
|
|
49
|
-
--husky
|
|
50
|
-
--no-addons
|
|
51
|
-
--examples <examples>
|
|
52
|
-
--no-examples
|
|
53
|
-
--git
|
|
54
|
-
--no-git
|
|
55
|
-
--npm
|
|
56
|
-
--pnpm
|
|
57
|
-
--bun
|
|
58
|
-
--drizzle
|
|
59
|
-
--prisma
|
|
60
|
-
--install
|
|
61
|
-
--no-install
|
|
62
|
-
--turso
|
|
63
|
-
--no-turso
|
|
64
|
-
--
|
|
65
|
-
|
|
46
|
+
-V, --version Output the version number
|
|
47
|
+
-y, --yes Use default configuration
|
|
48
|
+
--no-database Skip database setup
|
|
49
|
+
--sqlite Use SQLite database
|
|
50
|
+
--postgres Use PostgreSQL database
|
|
51
|
+
--auth Include authentication
|
|
52
|
+
--no-auth Exclude authentication
|
|
53
|
+
--pwa Include Progressive Web App support
|
|
54
|
+
--tauri Include Tauri desktop app support
|
|
55
|
+
--biome Include Biome for linting and formatting
|
|
56
|
+
--husky Include Husky, lint-staged for Git hooks
|
|
57
|
+
--no-addons Skip all additional addons
|
|
58
|
+
--examples <examples> Include specified examples
|
|
59
|
+
--no-examples Skip all examples
|
|
60
|
+
--git Include git setup (default)
|
|
61
|
+
--no-git Skip git initialization
|
|
62
|
+
--npm Use npm as package manager
|
|
63
|
+
--pnpm Use pnpm as package manager
|
|
64
|
+
--bun Use bun as package manager
|
|
65
|
+
--drizzle Use Drizzle ORM
|
|
66
|
+
--prisma Use Prisma ORM
|
|
67
|
+
--install Install dependencies (default)
|
|
68
|
+
--no-install Skip installing dependencies
|
|
69
|
+
--turso Set up Turso for SQLite database
|
|
70
|
+
--no-turso Skip Turso setup for SQLite database
|
|
71
|
+
--hono Use Hono backend framework (default)
|
|
72
|
+
--elysia Use Elysia backend framework
|
|
73
|
+
--runtime <runtime> Specify runtime (bun or node)
|
|
74
|
+
--web Include web frontend (default)
|
|
75
|
+
--native Include Expo frontend
|
|
76
|
+
--no-web Exclude web frontend
|
|
77
|
+
--no-native Exclude Expo frontend
|
|
78
|
+
-h, --help Display help
|
|
66
79
|
```
|
|
67
80
|
|
|
68
81
|
## Examples
|
|
@@ -74,16 +87,17 @@ npx create-better-t-stack my-app -y
|
|
|
74
87
|
|
|
75
88
|
Create a project with specific options:
|
|
76
89
|
```bash
|
|
77
|
-
npx create-better-t-stack my-app --postgres --
|
|
90
|
+
npx create-better-t-stack my-app --postgres --drizzle --auth --pwa --biome
|
|
78
91
|
```
|
|
79
92
|
|
|
80
|
-
Create a project with Node.js runtime:
|
|
93
|
+
Create a project with Elysia and Node.js runtime:
|
|
81
94
|
```bash
|
|
82
|
-
npx create-better-t-stack my-app --runtime node
|
|
95
|
+
npx create-better-t-stack my-app --elysia --runtime node
|
|
83
96
|
```
|
|
84
97
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
Create a project using Hono with no addons:
|
|
99
|
+
```bash
|
|
100
|
+
npx create-better-t-stack my-app --hono --no-addons
|
|
101
|
+
```
|
|
88
102
|
|
|
89
103
|
Created by [Aman Varshney](https://github.com/AmanVarshney01) & [Nitish Singh](https://github.com/FgrReloaded)
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{cancel as
|
|
2
|
+
import{cancel as uo,intro as mo,log as $,outro as fo,spinner as ho}from"@clack/prompts";import{Command as wo}from"commander";import F from"picocolors";import te from"node:path";import{fileURLToPath as it}from"node:url";var B=()=>{let e=process.env.npm_config_user_agent;return e?.startsWith("pnpm")?"pnpm":e?.startsWith("bun")?"bun":"npm"};var st=it(import.meta.url),ct=te.dirname(st),P=te.join(ct,"../"),c={projectName:"my-better-t-app",frontend:["web"],database:"sqlite",orm:"drizzle",auth:!0,addons:[],examples:[],git:!0,packageManager:B(),noInstall:!1,turso:!1,backendFramework:"hono",runtime:"bun"},H={"better-auth":"^1.2.4","drizzle-orm":"^0.38.4","drizzle-kit":"^0.30.5","@libsql/client":"^0.14.0",postgres:"^3.4.5","@prisma/client":"^6.5.0",prisma:"^6.5.0","vite-plugin-pwa":"^0.21.2","@vite-pwa/assets-generator":"^0.2.6","@tauri-apps/cli":"^2.4.0","@biomejs/biome":"1.9.4",husky:"^9.1.7","lint-staged":"^15.5.0","@hono/node-server":"^1.14.0",tsx:"^4.19.2","@types/node":"^22.13.11","@types/bun":"^1.2.6","@elysiajs/node":"^1.2.6","@elysiajs/cors":"^1.2.0","@elysiajs/trpc":"^1.1.0",elysia:"^1.2.25","@hono/trpc-server":"^0.3.4",hono:"^4.7.5"};import aa from"node:path";import{cancel as oa,spinner as ra}from"@clack/prompts";import na from"fs-extra";import Oe from"picocolors";import A from"node:path";import y from"fs-extra";import pt from"node:path";import ae from"fs-extra";var w=e=>{let{dependencies:a=[],devDependencies:t=[],projectDir:o}=e,r=pt.join(o,"package.json"),n=ae.readJSONSync(r);n.dependencies||(n.dependencies={}),n.devDependencies||(n.devDependencies={});for(let i of a){let s=H[i];n.dependencies[i]=s}for(let i of t){let s=H[i];n.devDependencies[i]=s}ae.writeJSONSync(r,n,{spaces:2})};import M from"node:path";import{log as lt,spinner as dt}from"@clack/prompts";import{execa as ut}from"execa";import G from"fs-extra";import oe from"picocolors";async function re(e,a){let t=dt(),o=M.join(e,"apps/web");if(await G.pathExists(o))try{t.start("Setting up Tauri desktop app support..."),w({devDependencies:["@tauri-apps/cli"],projectDir:o});let r=M.join(o,"package.json");if(await G.pathExists(r)){let s=await G.readJson(r);s.scripts={...s.scripts,tauri:"tauri","desktop:dev":"tauri dev","desktop:build":"tauri build"},await G.writeJson(r,s,{spaces:2})}let n,i;switch(a){case"npm":n="npx",i=["@tauri-apps/cli@latest"];break;case"pnpm":n="pnpm",i=["dlx","@tauri-apps/cli@latest"];break;case"bun":n="bunx",i=["@tauri-apps/cli@latest"];break;default:n="npx",i=["@tauri-apps/cli@latest"]}i=[...i,"init",`--app-name=${M.basename(e)}`,`--window-title=${M.basename(e)}`,"--frontend-dist=dist","--dev-url=http://localhost:3001",`--before-dev-command=${a} run dev`,`--before-build-command=${a} run build`],await ut(n,i,{cwd:o,env:{CI:"true"}}),t.stop("Tauri desktop app support configured successfully!")}catch(r){throw t.stop(oe.red("Failed to set up Tauri")),r instanceof Error&<.error(oe.red(r.message)),r}}async function ne(e,a,t,o){let r=o.includes("web");a.includes("pwa")&&r&&await ht(e),a.includes("tauri")&&r&&await re(e,t),a.includes("biome")&&await mt(e),a.includes("husky")&&await ft(e)}async function mt(e){let a=A.join(P,"template/with-biome");await y.pathExists(a)&&await y.copy(a,e,{overwrite:!0}),w({devDependencies:["@biomejs/biome"],projectDir:e});let t=A.join(e,"package.json");if(await y.pathExists(t)){let o=await y.readJson(t);o.scripts={...o.scripts,check:"biome check --write ."},await y.writeJson(t,o,{spaces:2})}}async function ft(e){let a=A.join(P,"template/with-husky");await y.pathExists(a)&&await y.copy(a,e,{overwrite:!0}),w({devDependencies:["husky","lint-staged"],projectDir:e});let t=A.join(e,"package.json");if(await y.pathExists(t)){let o=await y.readJson(t);o.scripts={...o.scripts,prepare:"husky"},o["lint-staged"]={"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}":["biome check --write ."]},await y.writeJson(t,o,{spaces:2})}}async function ht(e){let a=A.join(P,"template/with-pwa");await y.pathExists(a)&&await y.copy(a,e,{overwrite:!0});let t=A.join(e,"apps/web");if(!await y.pathExists(t))return;w({dependencies:["vite-plugin-pwa"],devDependencies:["@vite-pwa/assets-generator"],projectDir:t});let o=A.join(t,"package.json");if(await y.pathExists(o)){let r=await y.readJson(o);r.scripts={...r.scripts,"generate-pwa-assets":"pwa-assets-generator"},await y.writeJson(o,r,{spaces:2})}}import ie from"node:path";import{log as se}from"@clack/prompts";import ce from"picocolors";function pe(e=32){let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t="",o=a.length;for(let r=0;r<e;r++)t+=a.charAt(Math.floor(Math.random()*o));return t}async function le(e,a){if(!a)return;let t=ie.join(e,"apps/server"),o=ie.join(e,"apps/web");try{w({dependencies:["better-auth"],projectDir:t}),w({dependencies:["better-auth"],projectDir:o})}catch(r){throw se.error(ce.red("Failed to configure authentication")),r instanceof Error&&se.error(ce.red(r.message)),r}}import wt from"node:path";async function de(e,a,t){let o=wt.join(e,"apps/server"),r=[],n=[];a==="hono"?(r.push("hono","@hono/trpc-server"),t==="node"&&(r.push("@hono/node-server"),n.push("tsx","@types/node"))):a==="elysia"&&(r.push("elysia","@elysiajs/cors","@elysiajs/trpc"),t==="node"&&(r.push("@elysiajs/node"),n.push("tsx","@types/node"))),t==="bun"&&n.push("@types/bun"),w({dependencies:r,devDependencies:n,projectDir:o})}import gt from"node:path";import bt from"fs-extra";async function ue(e,a){let t=gt.join(e,"README.md"),o=yt(a);try{await bt.writeFile(t,o)}catch(r){console.error("Failed to create README.md file:",r)}}function yt(e){let{projectName:a,packageManager:t,database:o,auth:r,addons:n=[],orm:i="drizzle",runtime:s="bun"}=e,u=t==="npm"?"npm run":t;return`# ${a}
|
|
3
3
|
|
|
4
4
|
This project was created with [Better-T-Stack](https://github.com/better-t-stack/Better-T-Stack), a modern TypeScript stack that combines React, TanStack Router, Hono, tRPC, and more.
|
|
5
5
|
|
|
6
6
|
## Features
|
|
7
7
|
|
|
8
|
-
${
|
|
8
|
+
${Pt(o,r,n,i,s)}
|
|
9
9
|
|
|
10
10
|
## Getting Started
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ First, install the dependencies:
|
|
|
15
15
|
${t} install
|
|
16
16
|
\`\`\`
|
|
17
17
|
|
|
18
|
-
${
|
|
18
|
+
${kt(o,r,u,i)}
|
|
19
19
|
|
|
20
20
|
Then, run the development server:
|
|
21
21
|
|
|
@@ -23,7 +23,7 @@ Then, run the development server:
|
|
|
23
23
|
${u} dev
|
|
24
24
|
\`\`\`
|
|
25
25
|
|
|
26
|
-
Open [http://localhost:3001](http://localhost:3001) in your browser to see the
|
|
26
|
+
Open [http://localhost:3001](http://localhost:3001) in your browser to see the web application.
|
|
27
27
|
The API is running at [http://localhost:3000](http://localhost:3000).
|
|
28
28
|
|
|
29
29
|
## Project Structure
|
|
@@ -31,17 +31,17 @@ The API is running at [http://localhost:3000](http://localhost:3000).
|
|
|
31
31
|
\`\`\`
|
|
32
32
|
${a}/
|
|
33
33
|
\u251C\u2500\u2500 apps/
|
|
34
|
-
\u2502 \u251C\u2500\u2500
|
|
34
|
+
\u2502 \u251C\u2500\u2500 web/ # Frontend application (React, TanStack Router)
|
|
35
35
|
\u2502 \u2514\u2500\u2500 server/ # Backend API (Hono, tRPC)
|
|
36
36
|
\`\`\`
|
|
37
37
|
|
|
38
38
|
## Available Scripts
|
|
39
39
|
|
|
40
|
-
${
|
|
41
|
-
`}function
|
|
42
|
-
`)}function
|
|
40
|
+
${vt(u,o,i,r)}
|
|
41
|
+
`}function Pt(e,a,t,o,r){let n=["- **TypeScript** - For type safety and improved developer experience","- **TanStack Router** - File-based routing with full type safety","- **TailwindCSS** - Utility-first CSS for rapid UI development","- **shadcn/ui** - Reusable UI components","- **Hono** - Lightweight, performant server framework","- **tRPC** - End-to-end type-safe APIs",`- **${r==="bun"?"Bun":"Node.js"}** - Runtime environment`];e!=="none"&&n.push(`- **${o==="drizzle"?"Drizzle":"Prisma"}** - TypeScript-first ORM`,`- **${e==="sqlite"?"SQLite/Turso":"PostgreSQL"}** - Database engine`),a&&n.push("- **Authentication** - Email & password authentication with Better Auth");for(let i of t)i==="pwa"?n.push("- **PWA** - Progressive Web App support"):i==="tauri"?n.push("- **Tauri** - Build native desktop applications"):i==="biome"?n.push("- **Biome** - Linting and formatting"):i==="husky"&&n.push("- **Husky** - Git hooks for code quality");return n.join(`
|
|
42
|
+
`)}function kt(e,a,t,o){if(e==="none")return"";let r=`## Database Setup
|
|
43
43
|
|
|
44
|
-
`;return e==="sqlite"?
|
|
44
|
+
`;return e==="sqlite"?r+=`This project uses SQLite${o==="drizzle"?" with Drizzle ORM":" with Prisma"}.
|
|
45
45
|
|
|
46
46
|
1. Start the local SQLite database:
|
|
47
47
|
\`\`\`bash
|
|
@@ -49,29 +49,29 @@ cd apps/server && ${t} db:local
|
|
|
49
49
|
\`\`\`
|
|
50
50
|
|
|
51
51
|
2. Update your \`.env\` file in the \`apps/server\` directory with the appropriate connection details if needed.
|
|
52
|
-
`:e==="postgres"&&(
|
|
52
|
+
`:e==="postgres"&&(r+=`This project uses PostgreSQL${o==="drizzle"?" with Drizzle ORM":" with Prisma"}.
|
|
53
53
|
|
|
54
54
|
1. Make sure you have a PostgreSQL database set up.
|
|
55
55
|
2. Update your \`apps/server/.env\` file with your PostgreSQL connection details.
|
|
56
|
-
`),
|
|
57
|
-
${a?"4":"3"}. ${
|
|
56
|
+
`),r+=`
|
|
57
|
+
${a?"4":"3"}. ${o==="prisma"?`Generate the Prisma client and push the schema:
|
|
58
58
|
\`\`\`bash
|
|
59
59
|
${t} db:push
|
|
60
60
|
\`\`\``:`Apply the schema to your database:
|
|
61
61
|
\`\`\`bash
|
|
62
62
|
${t} db:push
|
|
63
63
|
\`\`\``}
|
|
64
|
-
`,
|
|
65
|
-
- \`${e} build\`: Build both
|
|
66
|
-
- \`${e} dev:
|
|
64
|
+
`,r}function vt(e,a,t,o){let r=`- \`${e} dev\`: Start both web and server in development mode
|
|
65
|
+
- \`${e} build\`: Build both web and server
|
|
66
|
+
- \`${e} dev:web\`: Start only the web application
|
|
67
67
|
- \`${e} dev:server\`: Start only the server
|
|
68
|
-
- \`${e} check-types\`: Check TypeScript types across all apps`;return a!=="none"&&(
|
|
68
|
+
- \`${e} check-types\`: Check TypeScript types across all apps`;return a!=="none"&&(r+=`
|
|
69
69
|
- \`${e} db:push\`: Push schema changes to database
|
|
70
|
-
- \`${e} db:studio\`: Open database studio UI`,a==="sqlite"&&t==="drizzle"&&(
|
|
71
|
-
- \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),
|
|
72
|
-
`);return a.length<=1?[]:a.slice(1).map(
|
|
70
|
+
- \`${e} db:studio\`: Open database studio UI`,a==="sqlite"&&t==="drizzle"&&(r+=`
|
|
71
|
+
- \`cd apps/server && ${e} db:local\`: Start the local SQLite database`)),r}import he from"node:path";import{log as It,spinner as Lt}from"@clack/prompts";import Nt from"fs-extra";import we from"picocolors";import jt from"node:os";import me from"node:path";import{cancel as Q,confirm as xt,isCancel as K,log as I,select as Tt,spinner as X,text as Et}from"@clack/prompts";import{$ as E}from"execa";import $t from"fs-extra";import x from"picocolors";async function Ft(){try{return(await E`turso --version`).exitCode===0}catch{return!1}}async function Ct(){try{return!(await E`turso auth whoami`).stdout.includes("You are not logged in")}catch{return!1}}async function Ot(){let e=X();try{return e.start("Logging in to Turso..."),await E`turso auth login`,e.stop("Logged in to Turso successfully!"),!0}catch(a){throw e.stop(x.red("Failed to log in to Turso")),a}}async function St(e){let a=X();try{if(a.start("Installing Turso CLI..."),e)await E`brew install tursodatabase/tap/turso`;else{let{stdout:t}=await E`curl -sSfL https://get.tur.so/install.sh`;await E`bash -c '${t}'`}return a.stop("Turso CLI installed successfully!"),!0}catch(t){throw t instanceof Error&&t.message.includes("User force closed")?(a.stop(),I.warn(x.yellow("Turso CLI installation cancelled by user")),new Error("Installation cancelled")):(a.stop(x.red("Failed to install Turso CLI")),t)}}async function Dt(){try{let{stdout:e}=await E`turso group list`,a=e.trim().split(`
|
|
72
|
+
`);return a.length<=1?[]:a.slice(1).map(o=>{let[r,n,i,s]=o.trim().split(/\s{2,}/);return{name:r,locations:n,version:i,status:s}})}catch(e){return console.error("Error fetching Turso groups:",e),[]}}async function At(){let e=await Dt();if(e.length===0)return null;if(e.length===1)return e[0].name;let a=e.map(o=>({value:o.name,label:`${o.name} (${o.locations})`})),t=await Tt({message:"Select a Turso database group:",options:a});return K(t)&&(Q(x.red("Operation cancelled")),process.exit(0)),t}async function Rt(e,a){try{a?await E`turso db create ${e} --group ${a}`:await E`turso db create ${e}`}catch(r){throw r instanceof Error&&r.message.includes("already exists")?new Error("DATABASE_EXISTS"):r}let{stdout:t}=await E`turso db show ${e} --url`,{stdout:o}=await E`turso db tokens create ${e}`;return{dbUrl:t.trim(),authToken:o.trim()}}async function _(e,a){let t=me.join(e,"apps/server",".env"),o=a?`TURSO_CONNECTION_URL="${a.dbUrl}"
|
|
73
73
|
TURSO_AUTH_TOKEN="${a.authToken}"`:`TURSO_CONNECTION_URL=
|
|
74
|
-
TURSO_AUTH_TOKEN=`;await
|
|
74
|
+
TURSO_AUTH_TOKEN=`;await $t.writeFile(t,o)}function J(){I.info(`Manual Turso Setup Instructions:
|
|
75
75
|
|
|
76
76
|
1. Visit https://turso.tech and create an account
|
|
77
77
|
2. Create a new database from the dashboard
|
|
@@ -79,52 +79,57 @@ TURSO_AUTH_TOKEN=`;await jt.writeFile(t,r)}function B(){I.info(`Manual Turso Set
|
|
|
79
79
|
4. Add these credentials to the .env file in apps/server/.env
|
|
80
80
|
|
|
81
81
|
TURSO_CONNECTION_URL=your_database_url
|
|
82
|
-
TURSO_AUTH_TOKEN=your_auth_token`)}async function
|
|
83
|
-
CORS_ORIGIN=http://localhost:3001`),a.auth&&(
|
|
84
|
-
BETTER_AUTH_SECRET=${
|
|
85
|
-
BETTER_AUTH_URL=http://localhost:3000`)),a.database!=="none"){if(a.orm==="prisma"&&!
|
|
86
|
-
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`;
|
|
87
|
-
TURSO_CONNECTION_URL=http://127.0.0.1:8080`))}await
|
|
88
|
-
`),await
|
|
82
|
+
TURSO_AUTH_TOKEN=your_auth_token`)}async function fe(e,a){if(!a){await _(e),I.info(x.blue("Skipping Turso setup. Setting up empty configuration.")),J();return}let t=jt.platform(),o=t==="darwin";if(!(t!=="win32")){I.warn(x.yellow("Automatic Turso setup is not supported on Windows.")),await _(e),J();return}try{if(!await Ft()){let k=await xt({message:"Would you like to install Turso CLI?",initialValue:!0});if(K(k)&&(Q(x.red("Operation cancelled")),process.exit(0)),!k){await _(e),J();return}await St(o)}await Ct()||await Ot();let s=await At(),u=!1,h="",b=me.basename(e);for(;!u;){let k=await Et({message:"Enter a name for your database:",defaultValue:b,initialValue:b,placeholder:b});K(k)&&(Q(x.red("Operation cancelled")),process.exit(0)),h=k;let C=X();try{C.start(`Creating Turso database "${h}"${s?` in group "${s}"`:""}...`);let j=await Rt(h,s);await _(e,j),C.stop("Turso database configured successfully!"),u=!0}catch(j){if(j instanceof Error&&j.message==="DATABASE_EXISTS")C.stop(x.yellow(`Database "${x.red(h)}" already exists`)),b=`${h}-${Math.floor(Math.random()*1e3)}`;else throw C.stop(x.red("Failed to create Turso database")),j}}}catch(n){I.error(x.red(`Error during Turso setup: ${n}`)),await _(e),J(),I.success("Setup completed with manual configuration required.")}}async function ge(e,a,t,o=!0){let r=Lt(),n=he.join(e,"apps/server");if(a==="none"){await Nt.remove(he.join(n,"src/db"));return}try{a==="sqlite"?(t==="drizzle"?w({dependencies:["drizzle-orm","@libsql/client"],devDependencies:["drizzle-kit"],projectDir:n}):t==="prisma"&&w({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:n}),o&&await fe(e,!0)):a==="postgres"&&(t==="drizzle"?w({dependencies:["drizzle-orm","postgres"],devDependencies:["drizzle-kit"],projectDir:n}):t==="prisma"&&w({dependencies:["@prisma/client"],devDependencies:["prisma"],projectDir:n}))}catch(i){throw r.stop(we.red("Failed to set up database")),i instanceof Error&&It.error(we.red(i.message)),i}}import L from"node:path";import O from"fs-extra";async function be(e,a){let t=L.join(e,"apps/server"),o=L.join(t,".env"),r="";if(await O.pathExists(o)&&(r=await O.readFile(o,"utf8")),r.includes("CORS_ORIGIN")||(r+=`
|
|
83
|
+
CORS_ORIGIN=http://localhost:3001`),a.auth&&(r.includes("BETTER_AUTH_SECRET")||(r+=`
|
|
84
|
+
BETTER_AUTH_SECRET=${pe()}`),r.includes("BETTER_AUTH_URL")||(r+=`
|
|
85
|
+
BETTER_AUTH_URL=http://localhost:3000`)),a.database!=="none"){if(a.orm==="prisma"&&!r.includes("DATABASE_URL")){let n=a.database==="sqlite"?"":`
|
|
86
|
+
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mydb?schema=public"`;r+=n}a.database==="sqlite"&&!a.turso&&(r.includes("TURSO_CONNECTION_URL")||(r+=`
|
|
87
|
+
TURSO_CONNECTION_URL=http://127.0.0.1:8080`))}if(await O.writeFile(o,r.trim()),a.frontend.includes("web")){let n=L.join(e,"apps/web"),i=L.join(n,".env"),s="";await O.pathExists(i)&&(s=await O.readFile(i,"utf8")),s.includes("VITE_SERVER_URL")||(s+=`VITE_SERVER_URL=http://localhost:3000
|
|
88
|
+
`),await O.writeFile(i,s.trim())}if(a.frontend.includes("native")){let n=L.join(e,"apps/native"),i=L.join(n,".env"),s="";await O.pathExists(i)&&(s=await O.readFile(i,"utf8")),s.includes("EXPO_PUBLIC_SERVER_URL")||(s+=`EXPO_PUBLIC_SERVER_URL=http://localhost:3000
|
|
89
|
+
`),await O.writeFile(i,s.trim())}}import T from"node:path";import g from"fs-extra";async function ye(e,a,t,o,r=["web"]){let n=r.includes("web"),i=await g.pathExists(T.join(e,"apps/web"));a.includes("todo")&&n&&i?await _t(e,t,o):await zt(e,t)}async function _t(e,a,t){let o=T.join(P,"template/examples/todo");if(await g.pathExists(o)){let r=T.join(o,"apps/web/src/routes"),n=T.join(e,"apps/web/src/routes");if(await g.copy(r,n,{overwrite:!0}),a!=="none"){let i=T.join(o,`apps/server/src/routers/with-${a}-todo.ts`),s=T.join(e,"apps/server/src/routers/todo.ts");await g.pathExists(i)&&await g.copy(i,s,{overwrite:!0})}await Ut(e,t),await Mt(e)}}async function Ut(e,a){let t=T.join(e,"apps/web/src/components/header.tsx");if(await g.pathExists(t)){let o=await g.readFile(t,"utf8");a?o=o.replace(/const links = \[\s*{ to: "\/", label: "Home" },\s*{ to: "\/dashboard", label: "Dashboard" },/,`const links = [
|
|
89
90
|
{ to: "/", label: "Home" },
|
|
90
91
|
{ to: "/dashboard", label: "Dashboard" },
|
|
91
|
-
{ to: "/todos", label: "Todos" },`):
|
|
92
|
+
{ to: "/todos", label: "Todos" },`):o=o.replace(/const links = \[\s*{ to: "\/", label: "Home" },/,`const links = [
|
|
92
93
|
{ to: "/", label: "Home" },
|
|
93
|
-
{ to: "/todos", label: "Todos" },`),await
|
|
94
|
+
{ to: "/todos", label: "Todos" },`),await g.writeFile(t,o)}}async function zt(e,a){if(a==="drizzle"){let o=T.join(e,"apps/server/src/db/schema/todo.ts");await g.pathExists(o)&&await g.remove(o)}else if(a==="prisma"){let o=T.join(e,"apps/server/prisma/schema/todo.prisma");await g.pathExists(o)&&await g.remove(o)}let t=T.join(e,"apps/server/src/routers/todo.ts");await g.pathExists(t)&&await g.remove(t),await Bt(e)}async function Bt(e){let a=T.join(e,"apps/server/src/routers/index.ts");if(await g.pathExists(a)){let t=await g.readFile(a,"utf8");t=t.replace(/import { todoRouter } from ".\/todo";/,""),t=t.replace(/todo: todoRouter,/,""),await g.writeFile(a,t)}}async function Mt(e){let a=T.join(e,"apps/web/src/routes/index.tsx");if(await g.pathExists(a)){let t=await g.readFile(a,"utf8");t=t.replace(/<div id="buttons"><\/div>/,`<div id="buttons" className="mt-4 flex flex-col gap-4 sm:flex-row sm:items-center">
|
|
94
95
|
<Button asChild>
|
|
95
96
|
<Link to="/todos" className="flex items-center">
|
|
96
97
|
View Todo Demo
|
|
97
98
|
<ArrowRight className="ml-1 h-4 w-4" />
|
|
98
99
|
</Link>
|
|
99
100
|
</Button>
|
|
100
|
-
</div>`),await
|
|
101
|
-
${d.cyan("1.")} ${
|
|
102
|
-
${
|
|
103
|
-
`}${d.cyan(
|
|
101
|
+
</div>`),await g.writeFile(a,t)}}import{log as Gt}from"@clack/prompts";import d from"picocolors";function Pe(e,a,t,o,r,n,i,s){let u=t==="npm"?"npm run":t,h=`cd ${a}`,b=n?.includes("husky")||n?.includes("biome"),k=e!=="none"?Vt(e,r,u,i):"",C=n?.includes("tauri")?Wt(u):"",j=b?qt(u):"",z=s?.includes("native")?Jt():"",N=s?.includes("web"),rt=s?.includes("native"),nt=N||rt;Gt.info(`${d.bold("Next steps:")}
|
|
102
|
+
${d.cyan("1.")} ${h}
|
|
103
|
+
${o?"":`${d.cyan("2.")} ${t} install
|
|
104
|
+
`}${d.cyan(o?"2.":"3.")} ${u} dev
|
|
104
105
|
|
|
105
106
|
${d.bold("Your project will be available at:")}
|
|
106
|
-
${d.cyan("\u2022")} Frontend: http://localhost:3001
|
|
107
|
-
|
|
108
|
-
${
|
|
109
|
-
${
|
|
110
|
-
${
|
|
111
|
-
${
|
|
107
|
+
${nt?`${N?`${d.cyan("\u2022")} Frontend: http://localhost:3001
|
|
108
|
+
`:""}`:`${d.yellow("NOTE:")} You are creating a backend-only app (no frontend selected)
|
|
109
|
+
`}${d.cyan("\u2022")} API: http://localhost:3000
|
|
110
|
+
${z?`
|
|
111
|
+
${z.trim()}`:""}${k?`
|
|
112
|
+
${k.trim()}`:""}${C?`
|
|
113
|
+
${C.trim()}`:""}${j?`
|
|
114
|
+
${j.trim()}`:""}`)}function Jt(){return`${d.yellow("NOTE:")} If the Expo app cannot connect to the server, update the EXPO_PUBLIC_SERVER_URL in apps/native/.env to use your local IP address instead of localhost:
|
|
115
|
+
${d.dim("EXPO_PUBLIC_SERVER_URL=http://192.168.0.103:3000")}
|
|
116
|
+
`}function qt(e){return`${d.bold("Linting and formatting:")}
|
|
112
117
|
${d.cyan("\u2022")} Format and lint fix: ${d.dim(`${e} check`)}
|
|
113
118
|
|
|
114
|
-
`}function
|
|
115
|
-
${
|
|
119
|
+
`}function Vt(e,a,t,o){let r=[];return a==="prisma"?(e==="sqlite"&&r.push(`${d.yellow("NOTE:")} Turso support with Prisma is in Early Access and requires additional setup.`,`${d.dim("Learn more at: https://www.prisma.io/docs/orm/overview/databases/turso")}`),o==="bun"&&r.push(`${d.yellow("NOTE:")} Prisma with Bun may require additional configuration. If you encounter errors, follow the guidance provided in the error messages`),r.push(`${d.cyan("\u2022")} Apply schema: ${d.dim(`${t} db:push`)}`),r.push(`${d.cyan("\u2022")} Database UI: ${d.dim(`${t} db:studio`)}`)):a==="drizzle"&&(e==="sqlite"&&r.push(`${d.cyan("\u2022")} Start local DB: ${d.dim(`cd apps/server && ${t} db:local`)}`),r.push(`${d.cyan("\u2022")} Apply schema: ${d.dim(`${t} db:push`)}`),r.push(`${d.cyan("\u2022")} Database UI: ${d.dim(`${t} db:studio`)}`)),r.length?`${d.bold("Database commands:")}
|
|
120
|
+
${r.join(`
|
|
116
121
|
`)}
|
|
117
122
|
|
|
118
|
-
`:""}function
|
|
119
|
-
${d.cyan("\u2022")} Start desktop app: ${d.dim(`cd apps/
|
|
120
|
-
${d.cyan("\u2022")} Build desktop app: ${d.dim(`cd apps/
|
|
123
|
+
`:""}function Wt(e){return`${d.bold("Desktop app with Tauri:")}
|
|
124
|
+
${d.cyan("\u2022")} Start desktop app: ${d.dim(`cd apps/web && ${e} desktop:dev`)}
|
|
125
|
+
${d.cyan("\u2022")} Build desktop app: ${d.dim(`cd apps/web && ${e} desktop:build`)}
|
|
121
126
|
${d.yellow("NOTE:")} Tauri requires Rust and platform-specific dependencies. See: ${d.dim("https://v2.tauri.app/start/prerequisites/")}
|
|
122
127
|
|
|
123
|
-
`}import
|
|
128
|
+
`}import q from"node:path";import{$ as Ht,execa as Qt}from"execa";import S from"fs-extra";async function ke(e,a){await Kt(e,a),await Xt(e,a)}async function Kt(e,a){let t=q.join(e,"package.json");if(await S.pathExists(t)){let o=await S.readJson(t);o.name=a.projectName;let{stdout:r}=await Qt(a.packageManager,["-v"],{cwd:e});if(o.packageManager=`${a.packageManager}@${r.trim()}`,await S.writeJson(t,o,{spaces:2}),a.packageManager==="pnpm"){let n=q.join(P,"template/with-pnpm/pnpm-workspace.yaml"),i=q.join(e,"pnpm-workspace.yaml");await S.pathExists(n)&&await S.copy(n,i)}}}async function Xt(e,a){let t=q.join(e,"apps/server/package.json");if(await S.pathExists(t)){let o=await S.readJson(t);a.database!=="none"&&(a.database==="sqlite"&&(o.scripts["db:local"]="turso dev --db-file local.db"),a.orm==="prisma"?(o.scripts["db:push"]="prisma db push --schema ./prisma/schema",o.scripts["db:studio"]="prisma studio"):a.orm==="drizzle"&&(o.scripts["db:push"]="drizzle-kit push",o.scripts["db:studio"]="drizzle-kit studio")),await S.writeJson(t,o,{spaces:2})}}async function ve(e,a){a&&await Ht({cwd:e})`git init`}import V from"node:path";import D from"fs-extra";async function je(e,a,t){let o=V.join(e,"apps/server"),r=V.join(o,"src/index.ts"),n=await D.readFile(r,"utf-8");a==="bun"?await Yt(o,r,n,t):a==="node"&&await Zt(o,r,n,t)}async function Yt(e,a,t,o){let r=V.join(e,"package.json"),n=await D.readJson(r);if(n.scripts={...n.scripts,dev:"bun run --hot src/index.ts",start:"bun run dist/src/index.js"},await D.writeJson(r,n,{spaces:2}),w({devDependencies:["@types/bun"],projectDir:e}),o==="hono"){let i=`${t}
|
|
124
129
|
|
|
125
130
|
export default app;
|
|
126
|
-
`;await
|
|
127
|
-
`,
|
|
131
|
+
`;await D.writeFile(a,i)}}async function Zt(e,a,t,o){let r=V.join(e,"package.json"),n=await D.readJson(r);if(n.scripts={...n.scripts,dev:"tsx watch src/index.ts",start:"node dist/src/index.js"},await D.writeJson(r,n,{spaces:2}),w({devDependencies:["tsx","@types/node"],projectDir:e}),o==="hono"){w({dependencies:["@hono/node-server"],projectDir:e});let i=`import { serve } from "@hono/node-server";
|
|
132
|
+
`,s=`
|
|
128
133
|
serve(
|
|
129
134
|
{
|
|
130
135
|
fetch: app.fetch,
|
|
@@ -134,10 +139,11 @@ serve(
|
|
|
134
139
|
console.log(\`Server is running on http://localhost:\${info.port}\`);
|
|
135
140
|
},
|
|
136
141
|
);
|
|
137
|
-
`;if(!t.includes("@hono/node-server")){let u=t.lastIndexOf("import"),
|
|
138
|
-
`,
|
|
139
|
-
`,t.indexOf("import")),u=t.substring(0,n+1),f=t.substring(n+1),b=u+s+f;b=b.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await F.writeFile(a,b)}}import m from"node:path";import g from"fs-extra";async function ve(e){let a=m.join(y,"template/base");if(!await g.pathExists(a))throw new Error(`Template directory not found: ${a}`);await g.copy(a,e)}async function xe(e,a){let t=m.join(y,`template/with-${a}`);await g.pathExists(t)&&await g.copy(t,e,{overwrite:!0})}async function Te(e,a,t,r){if(a==="none"||t==="none")return;let o=m.join(y,Wt(a,t));if(await g.pathExists(o)&&(await g.copy(o,e,{overwrite:!0}),!r)){if(a==="prisma"){let i=m.join(e,"apps/server/prisma/schema/auth.prisma");await g.pathExists(i)&&await g.remove(i)}else if(a==="drizzle"){let i=m.join(e,"apps/server/src/db/schema/auth.ts");await g.pathExists(i)&&await g.remove(i)}}}async function $e(e,a,t,r,o){if(!a)return;let i=m.join(y,"template/with-auth");if(await g.pathExists(i)){let s=m.join(i,"apps/client"),n=m.join(e,"apps/client");await g.copy(s,n,{overwrite:!0});let u=m.join(i,"apps/server/src"),f=m.join(e,"apps/server/src");await g.copy(m.join(u,"lib/trpc.ts"),m.join(f,"lib/trpc.ts"),{overwrite:!0}),await g.copy(m.join(u,"routers/index.ts"),m.join(f,"routers/index.ts"),{overwrite:!0});let b=`with-${t}-context.ts`;await g.copy(m.join(u,"lib",b),m.join(f,"lib/context.ts"),{overwrite:!0});let P=`with-${t}-index.ts`;await g.copy(m.join(u,P),m.join(f,"index.ts"),{overwrite:!0});let C=Qt(r,o),D=m.join(u,C);if(await g.pathExists(D)){let et=await g.readdir(D);for(let Z of et)await g.copy(m.join(D,Z),m.join(f,"lib",Z),{overwrite:!0})}}}async function Ee(e){let a=[m.join(e,"_gitignore"),m.join(e,"apps/client/_gitignore"),m.join(e,"apps/server/_gitignore")];for(let t of a)if(await g.pathExists(t)){let r=m.join(m.dirname(t),".gitignore");await g.move(t,r)}}function Wt(e,a){return e==="drizzle"?a==="sqlite"?"template/with-drizzle-sqlite":"template/with-drizzle-postgres":e==="prisma"?a==="sqlite"?"template/with-prisma-sqlite":"template/with-prisma-postgres":"template/base"}function Qt(e,a){if(e==="drizzle")return a==="sqlite"?"with-drizzle-sqlite-lib":"with-drizzle-postgres-lib";if(e==="prisma")return a==="sqlite"?"with-prisma-sqlite-lib":"with-prisma-postgres-lib";throw new Error("Invalid ORM or database configuration for auth setup")}async function De(e){let a=Yt(),t=Kt.resolve(process.cwd(),e.projectName);try{return await Zt.ensureDir(t),await ve(t),await Ee(t),await xe(t,e.backendFramework),await le(t,e.backendFramework,e.runtime),await Te(t,e.orm,e.database,e.auth),await ge(t,e.database,e.orm,e.turso??e.database==="sqlite"),await $e(t,e.auth,e.backendFramework,e.orm,e.database),await pe(t,e.auth),await je(t,e.runtime,e.backendFramework),await be(t,e.examples,e.orm,e.auth),await we(t,e),await Pe(t,e.git),e.addons.length>0&&await oe(t,e.addons,e.packageManager),await ke(t,e),await de(t,e),ye(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime),t}catch(r){throw a.message(Ce.red("Failed")),r instanceof Error&&(Xt(Ce.red(`Error during project creation: ${r.message}`)),process.exit(1)),r}}import{log as Oe,spinner as Fe}from"@clack/prompts";import{$ as K}from"execa";import J from"picocolors";async function Se({projectDir:e,packageManager:a,addons:t=[]}){let r=Fe();try{switch(r.start(`Running ${a} install...`),a){case"npm":await K({cwd:e,stderr:"inherit"})`${a} install`;break;case"pnpm":case"bun":await K({cwd:e})`${a} install`;break}r.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await ea(e,a)}catch(o){throw r.stop(J.red("Failed to install dependencies")),o instanceof Error&&Oe.error(J.red(`Installation error: ${o.message}`)),o}}async function ea(e,a){let t=Fe();try{t.start("Running Biome format check..."),await K({cwd:e})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(J.yellow("Biome check encountered issues")),Oe.warn(J.yellow("Some files may need manual formatting"))}}import{cancel as Ka,group as Xa}from"@clack/prompts";import Ya from"picocolors";import{cancel as ta,isCancel as aa,multiselect as ra}from"@clack/prompts";import oa from"picocolors";async function Ae(e){if(e!==void 0)return e;let a=await ra({message:"Which Addons would you like to add?",options:[{value:"pwa",label:"PWA (Progressive Web App)",hint:"Make your app installable and work offline"},{value:"tauri",label:"Tauri Desktop App",hint:"Build native desktop apps from your web frontend"},{value:"biome",label:"Biome",hint:"Add Biome for linting and formatting"},{value:"husky",label:"Husky",hint:"Add Git hooks with Husky, lint-staged (requires Biome)"}],initialValues:c.addons,required:!1});return aa(a)&&(ta(oa.red("Operation cancelled")),process.exit(0)),a.includes("husky")&&!a.includes("biome")&&a.push("biome"),a}import{cancel as ia,confirm as sa,isCancel as na}from"@clack/prompts";import ca from"picocolors";async function Ie(e,a){if(!a)return!1;if(e!==void 0)return e;let t=await sa({message:"Would you like to add authentication with Better-Auth?",initialValue:c.auth});return na(t)&&(ia(ca.red("Operation cancelled")),process.exit(0)),t}import{cancel as pa,isCancel as la,select as da}from"@clack/prompts";import ua from"picocolors";async function Re(e){if(e!==void 0)return e;let a=await da({message:"Which backend framework would you like to use?",options:[{value:"hono",label:"Hono",hint:"Lightweight, ultrafast web framework"},{value:"elysia",label:"Elysia",hint:"TypeScript framework with end-to-end type safety)"}],initialValue:c.backendFramework});return la(a)&&(pa(ua.red("Operation cancelled")),process.exit(0)),a}import{cancel as ma,isCancel as fa,select as ha}from"@clack/prompts";import ga from"picocolors";async function Le(e){if(e!==void 0)return e;let a=await ha({message:"Which database would you like to use?",options:[{value:"none",label:"None",hint:"No database setup"},{value:"sqlite",label:"SQLite",hint:"by Turso"},{value:"postgres",label:"PostgreSQL",hint:"Traditional relational database"}],initialValue:c.database});return fa(a)&&(ma(ga.red("Operation cancelled")),process.exit(0)),a}import{cancel as wa,isCancel as ba,multiselect as ya}from"@clack/prompts";import ka from"picocolors";async function Ne(e,a){if(e!==void 0)return e;if(a==="none")return[];let t=await ya({message:"Which examples would you like to include?",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:c.examples});return ba(t)&&(wa(ka.red("Operation cancelled")),process.exit(0)),t}import{cancel as Pa,confirm as ja,isCancel as va}from"@clack/prompts";import xa from"picocolors";async function ze(e){if(e!==void 0)return e;let a=await ja({message:"Initialize a new git repository?",initialValue:c.git});return va(a)&&(Pa(xa.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ta,confirm as $a,isCancel as Ea}from"@clack/prompts";import Ca from"picocolors";async function Ue(e){if(e!==void 0)return e;let a=await $a({message:"Do you want to install project dependencies?",initialValue:!c.noInstall});return Ea(a)&&(Ta(Ca.red("Operation cancelled")),process.exit(0)),!a}import{cancel as Da,isCancel as Oa,select as Fa}from"@clack/prompts";import Sa from"picocolors";async function Be(e,a){if(!a)return"none";if(e!==void 0)return e;let t=await Fa({message:"Which ORM would you like to use?",options:[{value:"drizzle",label:"Drizzle",hint:"Type-safe, lightweight ORM"},{value:"prisma",label:"Prisma",hint:"Powerful, feature-rich ORM with schema migrations"}],initialValue:c.orm});return Oa(t)&&(Da(Sa.red("Operation cancelled")),process.exit(0)),t}import{cancel as Aa,isCancel as Ia,select as Ra}from"@clack/prompts";import La from"picocolors";async function _e(e){if(e!==void 0)return e;let a=z(),t=await Ra({message:"Which package manager do you want to use?",options:[{value:"npm",label:"npm",hint:"Node Package Manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"},{value:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"}],initialValue:a});return Ia(t)&&(Aa(La.red("Operation cancelled")),process.exit(0)),t}import N from"node:path";import{cancel as Na,isCancel as za,text as Ua}from"@clack/prompts";import A from"fs-extra";import Ba from"picocolors";var _a=["<",">",":",'"',"|","?","*"],Me=255;function Ge(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>Me)return`Project name must be less than ${Me} characters`;if(_a.some(a=>e.includes(a)))return"Project name contains invalid characters";if(e.startsWith(".")||e.startsWith("-"))return"Project name cannot start with a dot or dash";if(e.toLowerCase()==="node_modules"||e.toLowerCase()==="favicon.ico")return"Project name is reserved"}}async function Je(e){if(e)if(e==="."){let i=process.cwd();if(A.readdirSync(i).length===0)return e}else{let i=N.basename(e);if(!Ge(i)){let n=N.resolve(process.cwd(),e);if(!A.pathExistsSync(n)||A.readdirSync(n).length===0)return e}}let a=!1,t="",r=c.projectName,o=1;for(;A.pathExistsSync(N.resolve(process.cwd(),r));)r=`${c.projectName}-${o}`,o++;for(;!a;){let i=await Ua({message:"Enter your project name or path (relative to current directory)",placeholder:r,initialValue:e,defaultValue:r,validate:s=>{let n=s.trim()||r;if(n==="."){if(A.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let u=N.resolve(process.cwd(),n),f=N.basename(u),b=Ge(f);if(b)return b;if(!u.startsWith(process.cwd()))return"Project path must be within current directory";if(A.pathExistsSync(u)&&A.readdirSync(u).length>0)return`Directory "${n}" already exists and is not empty. Please choose a different name or path.`;a=!0}});za(i)&&(Na(Ba.red("Operation cancelled.")),process.exit(0)),t=i||r}return t}import{cancel as Ma,isCancel as Ga,select as Ja}from"@clack/prompts";import qa from"picocolors";async function qe(e){if(e!==void 0)return e;let a=await Ja({message:"Which runtime would you like to use?",options:[{value:"bun",label:"Bun",hint:"Fast all-in-one JavaScript runtime"},{value:"node",label:"Node.js",hint:"Traditional Node.js runtime"}],initialValue:c.runtime});return Ga(a)&&(Ma(qa.red("Operation cancelled")),process.exit(0)),a}import{cancel as Va,confirm as Ha,isCancel as Wa}from"@clack/prompts";import Qa from"picocolors";async function Ve(e){if(e!==void 0)return e;let a=await Ha({message:"Set up a Turso database for this project?",initialValue:c.turso});return Wa(a)&&(Va(Qa.red("Operation cancelled")),process.exit(0)),a}async function He(e){let a=await Xa({projectName:async()=>Je(e.projectName),backendFramework:()=>Re(e.backendFramework),runtime:()=>qe(e.runtime),database:()=>Le(e.database),orm:({results:t})=>Be(e.orm,t.database!=="none"),auth:({results:t})=>Ie(e.auth,t.database!=="none"),turso:({results:t})=>t.database==="sqlite"&&t.orm!=="prisma"?Ve(e.turso):Promise.resolve(!1),addons:()=>Ae(e.addons),examples:({results:t})=>Ne(e.examples,t.database),git:()=>ze(e.git),packageManager:()=>_e(e.packageManager),noInstall:()=>Ue(e.noInstall)},{onCancel:()=>{Ka(Ya.red("Operation cancelled")),process.exit(0)}});return{projectName:a.projectName,database:a.database,orm:a.orm,auth:a.auth,addons:a.addons,examples:a.examples,git:a.git,packageManager:a.packageManager,noInstall:a.noInstall,turso:a.turso,backendFramework:a.backendFramework,runtime:a.runtime}}import v from"picocolors";function X(e){let a=[];if(e.projectName&&a.push(`${v.blue("Project Name:")} ${e.projectName}`),e.backendFramework!==void 0&&a.push(`${v.blue("Backend Framework:")} ${e.backendFramework}`),e.runtime!==void 0&&a.push(`${v.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${v.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${v.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${v.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${v.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${v.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${v.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${v.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${v.blue("Skip Install:")} ${e.noInstall}`),e.turso!==void 0&&a.push(`${v.blue("Turso Setup:")} ${e.turso}`),a.join(`
|
|
140
|
-
`)}function We(e){let a=[];if(e.database==="none"?a.push("--no-database"):(a.push(`--${e.database}`),e.orm&&a.push(`--${e.orm}`),e.database==="sqlite"&&a.push(e.turso?"--turso":"--no-turso")),a.push(e.auth?"--auth":"--no-auth"),a.push(e.git?"--git":"--no-git"),a.push(e.noInstall?"--no-install":"--install"),e.packageManager&&a.push(`--${e.packageManager}`),e.backendFramework&&a.push(`--${e.backendFramework}`),e.runtime&&a.push(`--runtime ${e.runtime}`),e.addons.length>0)for(let o of e.addons)a.push(`--${o}`);else a.push("--no-addons");e.examples&&e.examples.length>0?a.push(`--examples ${e.examples.join(",")}`):a.push("--no-examples");let t="npx create-better-t-stack",r=e.projectName?` ${e.projectName}`:"";return`${t}${r} ${a.join(" ")}`}import Za from"node:path";import er from"fs-extra";var Qe=()=>{let e=Za.join(y,"package.json");return er.readJSONSync(e).version??"1.0.0"};import Ke from"gradient-string";var Xe=`
|
|
142
|
+
`;if(!t.includes("@hono/node-server")){let u=t.lastIndexOf("import"),h=t.substring(0,u),b=t.substring(u),k=h+i+b+s;await D.writeFile(a,k)}}else if(o==="elysia"&&(w({dependencies:["@elysiajs/node"],projectDir:e}),!t.includes("@elysiajs/node"))){let i=`import { node } from "@elysiajs/node";
|
|
143
|
+
`,s=t.indexOf(`
|
|
144
|
+
`,t.indexOf("import")),u=t.substring(0,s+1),h=t.substring(s+1),b=u+i+h;b=b.replace(/const app = new Elysia\([^)]*\)/,"const app = new Elysia({ adapter: node() })"),await D.writeFile(a,b)}}import m from"node:path";import f from"fs-extra";async function xe(e){let a=m.join(P,"template/base");if(!await f.pathExists(a))throw new Error(`Template directory not found: ${a}`);await f.copy(a,e)}async function Te(e,a){if(!a.includes("web")){let t=m.join(e,"apps/web");await f.pathExists(t)&&await f.remove(t)}if(a.includes("native"))await f.writeFile(m.join(e,".npmrc"),`node-linker=hoisted
|
|
145
|
+
`);else{let t=m.join(e,"apps/native");await f.pathExists(t)&&await f.remove(t)}}async function Ee(e,a){let t=m.join(P,`template/with-${a}`);await f.pathExists(t)&&await f.copy(t,e,{overwrite:!0})}async function $e(e,a,t,o){if(a==="none"||t==="none")return;let r=m.join(P,ea(a,t));if(await f.pathExists(r)&&(await f.copy(r,e,{overwrite:!0}),!o)){if(a==="prisma"){let n=m.join(e,"apps/server/prisma/schema/auth.prisma");await f.pathExists(n)&&await f.remove(n)}else if(a==="drizzle"){let n=m.join(e,"apps/server/src/db/schema/auth.ts");await f.pathExists(n)&&await f.remove(n)}}}async function Fe(e,a,t,o,r){if(!a)return;let n=m.join(P,"template/with-auth");if(await f.pathExists(n)){let i=m.join(n,"apps/web"),s=m.join(e,"apps/web");await f.copy(i,s,{overwrite:!0});let u=m.join(n,"apps/server/src"),h=m.join(e,"apps/server/src");await f.copy(m.join(u,"lib/trpc.ts"),m.join(h,"lib/trpc.ts"),{overwrite:!0}),await f.copy(m.join(u,"routers/index.ts"),m.join(h,"routers/index.ts"),{overwrite:!0});let b=`with-${t}-context.ts`;await f.copy(m.join(u,"lib",b),m.join(h,"lib/context.ts"),{overwrite:!0});let k=`with-${t}-index.ts`;await f.copy(m.join(u,k),m.join(h,"index.ts"),{overwrite:!0});let C=ta(o,r),j=m.join(u,C);if(await f.pathExists(j)){let z=await f.readdir(j);for(let N of z)await f.copy(m.join(j,N),m.join(h,"lib",N),{overwrite:!0})}}}async function Ce(e){let a=[m.join(e,"_gitignore"),m.join(e,"apps/web/_gitignore"),m.join(e,"apps/native/_gitignore"),m.join(e,"apps/server/_gitignore")];for(let t of a)if(await f.pathExists(t)){let o=m.join(m.dirname(t),".gitignore");await f.move(t,o)}}function ea(e,a){return e==="drizzle"?a==="sqlite"?"template/with-drizzle-sqlite":"template/with-drizzle-postgres":e==="prisma"?a==="sqlite"?"template/with-prisma-sqlite":"template/with-prisma-postgres":"template/base"}function ta(e,a){if(e==="drizzle")return a==="sqlite"?"with-drizzle-sqlite-lib":"with-drizzle-postgres-lib";if(e==="prisma")return a==="sqlite"?"with-prisma-sqlite-lib":"with-prisma-postgres-lib";throw new Error("Invalid ORM or database configuration for auth setup")}async function Se(e){let a=ra(),t=aa.resolve(process.cwd(),e.projectName);try{return await na.ensureDir(t),await xe(t),await Te(t,e.frontend),await Ce(t),await Ee(t,e.backendFramework),await de(t,e.backendFramework,e.runtime),await $e(t,e.orm,e.database,e.auth),await ge(t,e.database,e.orm,e.turso??e.database==="sqlite"),await Fe(t,e.auth,e.backendFramework,e.orm,e.database),await le(t,e.auth),await je(t,e.runtime,e.backendFramework),await ye(t,e.examples,e.orm,e.auth,e.frontend),await be(t,e),await ve(t,e.git),e.addons.length>0&&await ne(t,e.addons,e.packageManager,e.frontend),await ke(t,e),await ue(t,e),Pe(e.database,e.projectName,e.packageManager,!e.noInstall,e.orm,e.addons,e.runtime,e.frontend),t}catch(o){throw a.message(Oe.red("Failed")),o instanceof Error&&(oa(Oe.red(`Error during project creation: ${o.message}`)),process.exit(1)),o}}import{log as De,spinner as Ae}from"@clack/prompts";import{$ as Y}from"execa";import W from"picocolors";async function Re({projectDir:e,packageManager:a,addons:t=[]}){let o=Ae();try{switch(o.start(`Running ${a} install...`),a){case"npm":await Y({cwd:e,stderr:"inherit"})`${a} install`;break;case"pnpm":case"bun":await Y({cwd:e})`${a} install`;break}o.stop("Dependencies installed successfully"),(t.includes("biome")||t.includes("husky"))&&await ia(e,a)}catch(r){throw o.stop(W.red("Failed to install dependencies")),r instanceof Error&&De.error(W.red(`Installation error: ${r.message}`)),r}}async function ia(e,a){let t=Ae();try{t.start("Running Biome format check..."),await Y({cwd:e})`${a} biome check --write .`,t.stop("Biome check completed successfully")}catch{t.stop(W.yellow("Biome check encountered issues")),De.warn(W.yellow("Some files may need manual formatting"))}}import{cancel as io,group as so}from"@clack/prompts";import co from"picocolors";import{cancel as sa,isCancel as ca,multiselect as pa}from"@clack/prompts";import la from"picocolors";async function Ie(e,a){if(e!==void 0)return e;let t=a?.includes("web"),o=[{value:"biome",label:"Biome",hint:"Add Biome for linting and formatting"},{value:"husky",label:"Husky",hint:"Add Git hooks with Husky, lint-staged (requires Biome)"}],n=t?[...[{value:"pwa",label:"PWA (Progressive Web App)",hint:"Make your app installable and work offline"},{value:"tauri",label:"Tauri Desktop App",hint:"Build native desktop apps from your web frontend"}],...o]:o,i=c.addons.filter(u=>t||u!=="pwa"&&u!=="tauri"),s=await pa({message:"Which Addons would you like to add?",options:n,initialValues:i,required:!1});return ca(s)&&(sa(la.red("Operation cancelled")),process.exit(0)),s.includes("husky")&&!s.includes("biome")&&s.push("biome"),s}import{cancel as da,confirm as ua,isCancel as ma,log as fa}from"@clack/prompts";import Le from"picocolors";async function Ne(e,a,t){if(!a)return!1;let o=t?.includes("native"),r=t?.includes("web");if(o&&fa.warn(Le.yellow("Note: Authentication is not yet available with native")),!r)return!1;if(e!==void 0)return e;let n=await ua({message:"Would you like to add authentication with Better-Auth?",initialValue:c.auth});return ma(n)&&(da(Le.red("Operation cancelled")),process.exit(0)),n}import{cancel as ha,isCancel as wa,select as ga}from"@clack/prompts";import ba from"picocolors";async function _e(e){if(e!==void 0)return e;let a=await ga({message:"Which backend framework would you like to use?",options:[{value:"hono",label:"Hono",hint:"Lightweight, ultrafast web framework"},{value:"elysia",label:"Elysia",hint:"TypeScript framework with end-to-end type safety)"}],initialValue:c.backendFramework});return wa(a)&&(ha(ba.red("Operation cancelled")),process.exit(0)),a}import{cancel as ya,isCancel as Pa,select as ka}from"@clack/prompts";import va from"picocolors";async function Ue(e){if(e!==void 0)return e;let a=await ka({message:"Which database would you like to use?",options:[{value:"none",label:"None",hint:"No database setup"},{value:"sqlite",label:"SQLite",hint:"by Turso"},{value:"postgres",label:"PostgreSQL",hint:"Traditional relational database"}],initialValue:c.database});return Pa(a)&&(ya(va.red("Operation cancelled")),process.exit(0)),a}import{cancel as ja,isCancel as xa,multiselect as Ta}from"@clack/prompts";import Ea from"picocolors";async function ze(e,a,t){if(e!==void 0)return e;if(a==="none")return[];if(!t?.includes("web"))return[];let r=await Ta({message:"Which examples would you like to include?",options:[{value:"todo",label:"Todo App",hint:"A simple CRUD example app"}],required:!1,initialValues:c.examples});return xa(r)&&(ja(Ea.red("Operation cancelled")),process.exit(0)),r}import{cancel as $a,isCancel as Fa,multiselect as Ca}from"@clack/prompts";import Oa from"picocolors";async function Be(e){if(e!==void 0)return e;let a=await Ca({message:"Which frontend applications would you like to create?",options:[{value:"web",label:"Web App",hint:"React + TanStack Router web application"},{value:"native",label:"Native App",hint:"React Native + Expo application"}],initialValues:c.frontend,required:!1});return Fa(a)&&($a(Oa.red("Operation cancelled")),process.exit(0)),a}import{cancel as Sa,confirm as Da,isCancel as Aa}from"@clack/prompts";import Ra from"picocolors";async function Me(e){if(e!==void 0)return e;let a=await Da({message:"Initialize a new git repository?",initialValue:c.git});return Aa(a)&&(Sa(Ra.red("Operation cancelled")),process.exit(0)),a}import{cancel as Ia,confirm as La,isCancel as Na}from"@clack/prompts";import _a from"picocolors";async function Ge(e){if(e!==void 0)return e;let a=await La({message:"Do you want to install project dependencies?",initialValue:!c.noInstall});return Na(a)&&(Ia(_a.red("Operation cancelled")),process.exit(0)),!a}import{cancel as Ua,isCancel as za,select as Ba}from"@clack/prompts";import Ma from"picocolors";async function Je(e,a){if(!a)return"none";if(e!==void 0)return e;let t=await Ba({message:"Which ORM would you like to use?",options:[{value:"drizzle",label:"Drizzle",hint:"Type-safe, lightweight ORM"},{value:"prisma",label:"Prisma",hint:"Powerful, feature-rich ORM"}],initialValue:c.orm});return za(t)&&(Ua(Ma.red("Operation cancelled")),process.exit(0)),t}import{cancel as Ga,isCancel as Ja,select as qa}from"@clack/prompts";import Va from"picocolors";async function qe(e){if(e!==void 0)return e;let a=B(),t=await qa({message:"Which package manager do you want to use?",options:[{value:"npm",label:"npm",hint:"Node Package Manager"},{value:"bun",label:"bun",hint:"All-in-one JavaScript runtime & toolkit"},{value:"pnpm",label:"pnpm",hint:"Fast, disk space efficient package manager"}],initialValue:a});return Ja(t)&&(Ga(Va.red("Operation cancelled")),process.exit(0)),t}import U from"node:path";import{cancel as Wa,isCancel as Ha,text as Qa}from"@clack/prompts";import R from"fs-extra";import Ka from"picocolors";var Xa=["<",">",":",'"',"|","?","*"],Ve=255;function We(e){if(e!=="."){if(!e)return"Project name cannot be empty";if(e.length>Ve)return`Project name must be less than ${Ve} characters`;if(Xa.some(a=>e.includes(a)))return"Project name contains invalid characters";if(e.startsWith(".")||e.startsWith("-"))return"Project name cannot start with a dot or dash";if(e.toLowerCase()==="node_modules"||e.toLowerCase()==="favicon.ico")return"Project name is reserved"}}async function He(e){if(e)if(e==="."){let n=process.cwd();if(R.readdirSync(n).length===0)return e}else{let n=U.basename(e);if(!We(n)){let s=U.resolve(process.cwd(),e);if(!R.pathExistsSync(s)||R.readdirSync(s).length===0)return e}}let a=!1,t="",o=c.projectName,r=1;for(;R.pathExistsSync(U.resolve(process.cwd(),o));)o=`${c.projectName}-${r}`,r++;for(;!a;){let n=await Qa({message:"Enter your project name or path (relative to current directory)",placeholder:o,initialValue:e,defaultValue:o,validate:i=>{let s=i.trim()||o;if(s==="."){if(R.readdirSync(process.cwd()).length>0)return"Current directory is not empty. Please choose a different directory.";a=!0;return}let u=U.resolve(process.cwd(),s),h=U.basename(u),b=We(h);if(b)return b;if(!u.startsWith(process.cwd()))return"Project path must be within current directory";if(R.pathExistsSync(u)&&R.readdirSync(u).length>0)return`Directory "${s}" already exists and is not empty. Please choose a different name or path.`;a=!0}});Ha(n)&&(Wa(Ka.red("Operation cancelled.")),process.exit(0)),t=n||o}return t}import{cancel as Ya,isCancel as Za,select as eo}from"@clack/prompts";import to from"picocolors";async function Qe(e){if(e!==void 0)return e;let a=await eo({message:"Which runtime would you like to use?",options:[{value:"bun",label:"Bun",hint:"Fast all-in-one JavaScript runtime"},{value:"node",label:"Node.js",hint:"Traditional Node.js runtime"}],initialValue:c.runtime});return Za(a)&&(Ya(to.red("Operation cancelled")),process.exit(0)),a}import{cancel as ao,confirm as oo,isCancel as ro}from"@clack/prompts";import no from"picocolors";async function Ke(e){if(e!==void 0)return e;let a=await oo({message:"Set up a Turso database for this project?",initialValue:c.turso});return ro(a)&&(ao(no.red("Operation cancelled")),process.exit(0)),a}async function Xe(e){let a=await so({projectName:async()=>He(e.projectName),frontend:()=>Be(e.frontend),backendFramework:()=>_e(e.backendFramework),runtime:()=>Qe(e.runtime),database:()=>Ue(e.database),orm:({results:t})=>Je(e.orm,t.database!=="none"),auth:({results:t})=>Ne(e.auth,t.database!=="none",t.frontend),turso:({results:t})=>t.database==="sqlite"&&t.orm!=="prisma"?Ke(e.turso):Promise.resolve(!1),addons:({results:t})=>Ie(e.addons,t.frontend),examples:({results:t})=>ze(e.examples,t.database,t.frontend),git:()=>Me(e.git),packageManager:()=>qe(e.packageManager),noInstall:()=>Ge(e.noInstall)},{onCancel:()=>{io(co.red("Operation cancelled")),process.exit(0)}});return{projectName:a.projectName,frontend:a.frontend,database:a.database,orm:a.orm,auth:a.auth,addons:a.addons,examples:a.examples,git:a.git,packageManager:a.packageManager,noInstall:a.noInstall,turso:a.turso,backendFramework:a.backendFramework,runtime:a.runtime}}import v from"picocolors";function Z(e){let a=[];if(e.projectName&&a.push(`${v.blue("Project Name:")} ${e.projectName}`),e.frontend!==void 0){let t=e.frontend.length>0?e.frontend.join(", "):"none";a.push(`${v.blue("Frontend:")} ${t}`)}if(e.backendFramework!==void 0&&a.push(`${v.blue("Backend Framework:")} ${e.backendFramework}`),e.runtime!==void 0&&a.push(`${v.blue("Runtime:")} ${e.runtime}`),e.database!==void 0&&a.push(`${v.blue("Database:")} ${e.database}`),e.orm!==void 0&&a.push(`${v.blue("ORM:")} ${e.orm}`),e.auth!==void 0&&a.push(`${v.blue("Authentication:")} ${e.auth}`),e.addons!==void 0){let t=e.addons.length>0?e.addons.join(", "):"none";a.push(`${v.blue("Addons:")} ${t}`)}if(e.examples!==void 0){let t=e.examples.length>0?e.examples.join(", "):"none";a.push(`${v.blue("Examples:")} ${t}`)}return e.git!==void 0&&a.push(`${v.blue("Git Init:")} ${e.git}`),e.packageManager!==void 0&&a.push(`${v.blue("Package Manager:")} ${e.packageManager}`),e.noInstall!==void 0&&a.push(`${v.blue("Skip Install:")} ${e.noInstall}`),e.turso!==void 0&&a.push(`${v.blue("Turso Setup:")} ${e.turso}`),a.join(`
|
|
146
|
+
`)}function Ye(e){let a=[];if(e.database==="none"?a.push("--no-database"):(a.push(`--${e.database}`),e.orm&&a.push(`--${e.orm}`),e.database==="sqlite"&&a.push(e.turso?"--turso":"--no-turso")),a.push(e.auth?"--auth":"--no-auth"),a.push(e.git?"--git":"--no-git"),a.push(e.noInstall?"--no-install":"--install"),e.packageManager&&a.push(`--${e.packageManager}`),e.backendFramework&&a.push(`--${e.backendFramework}`),e.runtime&&a.push(`--runtime ${e.runtime}`),e.frontend&&(e.frontend.includes("web")?a.push("--web"):a.push("--no-web"),e.frontend.includes("native")?a.push("--native"):a.push("--no-native")),e.addons.length>0)for(let r of e.addons)a.push(`--${r}`);else a.push("--no-addons");e.examples&&e.examples.length>0?a.push(`--examples ${e.examples.join(",")}`):a.push("--no-examples");let t="npx create-better-t-stack",o=e.projectName?` ${e.projectName}`:"";return`${t}${o} ${a.join(" ")}`}import po from"node:path";import lo from"fs-extra";var Ze=()=>{let e=po.join(P,"package.json");return lo.readJSONSync(e).version??"1.0.0"};import et from"gradient-string";var tt=`
|
|
141
147
|
\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
142
148
|
\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
|
|
143
149
|
\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D
|
|
@@ -151,10 +157,10 @@ serve(
|
|
|
151
157
|
\u2588\u2588\u2551 \u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2588\u2588\u2557
|
|
152
158
|
\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2557
|
|
153
159
|
\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D
|
|
154
|
-
`,
|
|
155
|
-
`),t=Math.max(...a.map(
|
|
160
|
+
`,at={pink:"#F5C2E7",mauve:"#CBA6F7",red:"#F38BA8",maroon:"#E78284",peach:"#FAB387",yellow:"#F9E2AF",green:"#A6E3A1",teal:"#94E2D5",sky:"#89DCEB",sapphire:"#74C7EC",lavender:"#B4BEFE"},ot=()=>{let e=process.stdout.columns||80,a=tt.split(`
|
|
161
|
+
`),t=Math.max(...a.map(o=>o.length));e<t?console.log(et(Object.values(at)).multiline(`
|
|
156
162
|
\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
157
163
|
\u2551 Better T-Stack \u2551
|
|
158
164
|
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
159
|
-
`)):console.log(
|
|
160
|
-
${
|
|
165
|
+
`)):console.log(et(Object.values(at)).multiline(tt))};process.on("SIGINT",()=>{$.error(F.red("Operation cancelled")),process.exit(0)});var ee=new wo;async function go(){let e=Date.now();ee.name("create-better-t-stack").description("Create a new Better-T Stack project").version(Ze()).argument("[project-directory]","Project name/directory").option("-y, --yes","Use default configuration").option("--no-database","Skip database setup").option("--sqlite","Use SQLite database").option("--postgres","Use PostgreSQL database").option("--auth","Include authentication").option("--no-auth","Exclude authentication").option("--pwa","Include Progressive Web App support").option("--tauri","Include Tauri desktop app support").option("--biome","Include Biome for linting and formatting").option("--husky","Include Husky, lint-staged for Git hooks").option("--no-addons","Skip all additional addons").option("--examples <examples>","Include specified examples").option("--no-examples","Skip all examples").option("--git","Include git setup").option("--no-git","Skip git initialization").option("--npm","Use npm package manager").option("--pnpm","Use pnpm package manager").option("--bun","Use bun package manager").option("--drizzle","Use Drizzle ORM").option("--prisma","Use Prisma ORM (coming soon)").option("--install","Install dependencies").option("--no-install","Skip installing dependencies").option("--turso","Set up Turso for SQLite database").option("--no-turso","Skip Turso setup for SQLite database").option("--hono","Use Hono backend framework").option("--elysia","Use Elysia backend framework").option("--runtime <runtime>","Specify runtime (bun or node)").option("--web","Include web frontend").option("--native","Include Expo frontend").option("--no-web","Exclude web frontend").option("--no-native","Exclude Expo frontend").parse();let a=ho();try{ot(),mo(F.magenta("Creating a new Better-T-Stack project"));let t=ee.opts(),o=ee.args[0],r;t.hono&&(r="hono"),t.elysia&&(r="elysia");let n={...o&&{projectName:o},...t.database===!1&&{database:"none"},...t.sqlite&&{database:"sqlite"},...t.postgres&&{database:"postgres"},...t.drizzle&&{orm:"drizzle"},...t.prisma&&{orm:"prisma"},..."auth"in t&&{auth:t.auth},...t.npm&&{packageManager:"npm"},...t.pnpm&&{packageManager:"pnpm"},...t.bun&&{packageManager:"bun"},..."git"in t&&{git:t.git},..."install"in t&&{noInstall:!t.install},..."turso"in t&&{turso:t.turso},...r&&{backendFramework:r},...t.runtime&&{runtime:t.runtime},...(t.pwa||t.tauri||t.biome||t.husky||t.addons===!1)&&{addons:t.addons===!1?[]:[...t.pwa?["pwa"]:[],...t.tauri?["tauri"]:[],...t.biome?["biome"]:[],...t.husky?["husky"]:[]]},...(t.examples||t.examples===!1)&&{examples:t.examples===!1?[]:typeof t.examples=="string"?t.examples.split(",").filter(h=>h==="todo"):[]},...(t.web!==void 0||t.native!==void 0)&&{frontend:[...t.web===!1?[]:["web"],...t.native===!1?[]:t.native===!0?["native"]:[]].filter(Boolean)}};!t.yes&&Object.keys(n).length>0&&($.info(F.yellow("Using these pre-selected options:")),$.message(Z(n)),$.message(""));let i=t.yes?{...c,projectName:o??c.projectName,database:t.database===!1?"none":t.sqlite?"sqlite":t.postgres?"postgres":c.database,orm:t.database===!1?"none":t.drizzle?"drizzle":t.prisma?"prisma":c.orm,auth:"auth"in t?t.auth:c.auth,git:"git"in t?t.git:c.git,noInstall:"install"in t?!t.install:c.noInstall,packageManager:n.packageManager??c.packageManager,addons:n.addons?.length?n.addons:c.addons,examples:n.examples?.length?n.examples:c.examples,turso:"turso"in t?t.turso:n.database==="sqlite"?c.turso:!1,backendFramework:r??c.backendFramework,runtime:t.runtime?t.runtime:c.runtime,frontend:t.web===!1||t.native===!0?[...t.web===!1?[]:["web"],...t.native?["native"]:[]]:c.frontend}:await Xe(n);t.yes&&($.info(F.yellow("Using these default options:")),$.message(Z(i)),$.message(""));let s=await Se(i);i.noInstall||await Re({projectDir:s,packageManager:i.packageManager,addons:i.addons}),$.success(F.blue(`You can reproduce this setup with the following command:
|
|
166
|
+
${F.white(Ye(i))}`));let u=((Date.now()-e)/1e3).toFixed(2);fo(F.magenta(`Project created successfully in ${F.bold(u)} seconds!`))}catch(t){a.stop(F.red("Failed")),t instanceof Error&&(uo(F.red(`An unexpected error occurred: ${t.message}`)),process.exit(1))}}go().catch(e=>{$.error("Aborting installation..."),e instanceof Error?$.error(e.message):($.error("An unknown error has occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});
|
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
node_modules/
|
|
2
|
+
.expo/
|
|
3
|
+
dist/
|
|
4
|
+
npm-debug.*
|
|
5
|
+
*.jks
|
|
6
|
+
*.p8
|
|
7
|
+
*.p12
|
|
8
|
+
*.key
|
|
9
|
+
*.mobileprovision
|
|
10
|
+
*.orig.*
|
|
11
|
+
web-build/
|
|
12
|
+
# expo router
|
|
13
|
+
expo-env.d.ts
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
ios
|
|
18
|
+
android
|
|
19
|
+
|
|
20
|
+
# macOS
|
|
21
|
+
.DS_Store
|
|
22
|
+
|
|
23
|
+
# Temporary files created by Metro to check the health of the file watcher
|
|
24
|
+
.metro-health-check*
|