next-ts-cli 1.0.10 → 1.0.12

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/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
- import z from"path";import{execa as At}from"execa";import Y from"fs-extra";import*as m from"@clack/prompts";import{Command as Fe}from"commander";import X from"path";import{fileURLToPath as Le}from"url";var Je=Le(import.meta.url),Ve=X.dirname(Je),c=X.join(Ve,"../"),q=`
2
+ import Oe from"path";import{execa as Pt}from"execa";import Be from"fs-extra";import*as m from"@clack/prompts";import{Command as We}from"commander";import H from"path";import{fileURLToPath as Ge}from"url";var Le=Ge(import.meta.url),Je=H.dirname(Le),p=H.join(Je,"../"),Y=`
3
3
  __ __ __ __
4
4
  .-----.-----.--.--| |_ ______| |_.-----.______.----| |__|
5
5
  | | -__|_ _| _|______| _|__ --|______| __| | |
6
6
  |__|__|_____|__.__|____| |____|_____| |____|__|__|
7
- `,R="next-ts-cli",L="next-ts-cli";import $e from"path";import Ke from"fs-extra";var _=()=>{let e=$e.join(c,"package.json");return Ke.readJSONSync(e).version??"1.0.0"};var E=class extends Error{constructor(t){super(t)}};import U from"chalk";var a={error(...e){console.log(U.red(...e))},warn(...e){console.log(U.yellow(...e))},info(...e){console.log(U.cyan(...e))},success(...e){console.log(U.green(...e))}};var M=e=>(e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e);var We=/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/,Q=e=>{if(!e)return;let t=M(e),o=t.split("/"),n=o.findIndex(r=>r.startsWith("@")),s=o[o.length-1];if(o.findIndex(r=>r.startsWith("@"))!==-1&&(s=o.slice(n).join("/")),!(t==="."||We.test(s??"")))return"App name must consist of only lowercase alphanumeric characters, '-', and '_'"};var Z=e=>{if(e.startsWith(".")||e.startsWith("/"))return"Import alias can't start with '.' or '/'"};var C={appName:R,packages:[],flags:{default:!1,cli:!1,drizzle:!1,supabase:!1,betterauth:!1,alias:"@/",docker:!1,stripe:!1,shadcnui:!1,clerk:!1,neon:!1,vercelAi:!1}},ee=async()=>{let e=C,t=new Fe().name(L).description("A CLI for creating production-ready web applications with the Next.js").argument("[dir]","The name of the application, as well as the name of the directory to create").option("--cli","Run in CLI mode (non-interactive)",!1).option("-d, --default","Scaffold the project without any additional integrations",!1).option("-a, --alias [alias]","Explicitly tell the CLI to use a custom import alias",C.flags.alias).option("--drizzle [boolean]","Experimental: Boolean value if we should install Drizzle. Must be used in conjunction with `--cli`.",n=>!!n&&n!=="false").option("--docker [boolean]","Experimental: Boolean value if we should install Docker. Must be used in conjunction with `--cli`.",n=>!!n&&n!=="false").option("--stripe [boolean]","Experimental: Boolean value if we should install Stripe. Must be used in conjunction with `--cli`.",n=>!!n&&n!=="false").option("--shadcnui [boolean]","Experimental: Boolean value if we should install Shadcn UI. Must be used in conjunction with `--cli`.",n=>!!n&&n!=="false").option("--betterauth [boolean]","Experimental: Boolean value if we should install BetterAuth. Must be used in conjunction with `--cli`. Not valid with --clerk",n=>!!n&&n!=="false").option("--clerk [boolean]","Experimental: Boolean value if we should install Clerk.js . Must be used in conjunction with `--cli`. Not valid with --betterAuth",n=>!!n&&n!=="false").option("--supabase [boolean]","Experimental: Boolean value if we should install Supabase. Must be used in conjunction with `--cli`. Not valid with --betterAuth or --clerk",n=>!!n&&n!=="false").option("--neon [boolean]","Experimental: Boolean value if we should install Neon. Must be used in conjunction with `--cli`.",n=>!!n&&n!=="false").option("--vercelAi [boolean]","Experimental: Boolean value if we should install Vercel AI Gateway. Must be used in conjunction with `--cli`.",n=>!!n&&n!=="false").version(_(),"-v, --version","Display the version number").parse(process.argv);process.env.npm_config_user_agent?.startsWith("yarn/3")&&a.warn(` WARNING: It looks like you are using Yarn 3. This is currently not supported,
7
+ `,R="next-ts-cli",G="next-ts-cli";import Ve from"path";import $e from"fs-extra";var _=()=>{let e=Ve.join(p,"package.json");return $e.readJSONSync(e).version??"1.0.0"};var E=class extends Error{constructor(t){super(t)}};import U from"chalk";var a={error(...e){console.log(U.red(...e))},warn(...e){console.log(U.yellow(...e))},info(...e){console.log(U.cyan(...e))},success(...e){console.log(U.green(...e))}};var M=e=>(e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e);var Ke=/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/,X=e=>{if(!e)return;let t=M(e),o=t.split("/"),n=o.findIndex(r=>r.startsWith("@")),s=o[o.length-1];if(o.findIndex(r=>r.startsWith("@"))!==-1&&(s=o.slice(n).join("/")),!(t==="."||Ke.test(s??"")))return"App name must consist of only lowercase alphanumeric characters, '-', and '_'"};var q=e=>{if(e.startsWith(".")||e.startsWith("/"))return"Import alias can't start with '.' or '/'"};var C={appName:R,packages:[],flags:{default:!1,cli:!1,drizzle:!1,supabase:!1,betterauth:!1,alias:"@/",docker:!1,stripe:!1,shadcnui:!1,clerk:!1,neon:!1,vercelAi:!1}},Q=async()=>{let e=C,t=new We().name(G).description("A CLI for creating production-ready web applications with the Next.js").argument("[dir]","The name of the application, as well as the name of the directory to create").option("--cli","Run in CLI mode (non-interactive)",!1).option("-d, --default","Scaffold the project without any additional integrations",!1).option("-a, --alias [alias]","Explicitly tell the CLI to use a custom import alias",C.flags.alias).option("--drizzle [boolean]","Experimental: Boolean value if we should install Drizzle. Must be used in conjunction with `--cli`.",n=>!!n&&n!=="false").option("--docker [boolean]","Experimental: Boolean value if we should install Docker. Must be used in conjunction with `--cli`.",n=>!!n&&n!=="false").option("--stripe [boolean]","Experimental: Boolean value if we should install Stripe. Must be used in conjunction with `--cli`.",n=>!!n&&n!=="false").option("--shadcnui [boolean]","Experimental: Boolean value if we should install Shadcn UI. Must be used in conjunction with `--cli`.",n=>!!n&&n!=="false").option("--betterauth [boolean]","Experimental: Boolean value if we should install BetterAuth. Must be used in conjunction with `--cli`. Not valid with --clerk",n=>!!n&&n!=="false").option("--clerk [boolean]","Experimental: Boolean value if we should install Clerk.js . Must be used in conjunction with `--cli`. Not valid with --betterAuth",n=>!!n&&n!=="false").option("--supabase [boolean]","Experimental: Boolean value if we should install Supabase. Must be used in conjunction with `--cli`. Not valid with --betterAuth or --clerk",n=>!!n&&n!=="false").option("--neon [boolean]","Experimental: Boolean value if we should install Neon. Must be used in conjunction with `--cli`.",n=>!!n&&n!=="false").option("--vercelAi [boolean]","Experimental: Boolean value if we should install Vercel AI Gateway. Must be used in conjunction with `--cli`.",n=>!!n&&n!=="false").version(_(),"-v, --version","Display the version number").parse(process.argv);process.env.npm_config_user_agent?.startsWith("yarn/3")&&a.warn(` WARNING: It looks like you are using Yarn 3. This is currently not supported,
8
8
  and likely to result in a crash. Please run next-ts-cli with another
9
9
  package manager such as pnpm, npm, or Yarn Classic.`);let o=t.args[0];if(o&&(e.appName=o),e.flags=t.opts(),e.flags.cli)return e.packages=[],e.flags.docker&&e.packages.push("docker"),e.flags.drizzle&&e.packages.push("drizzle"),e.flags.supabase&&e.packages.push("supabase"),e.flags.betterauth&&e.packages.push("betterAuth"),e.flags.clerk&&e.packages.push("clerk"),e.flags.vercelAi&&e.packages.push("vercelAi"),e.flags.supabase&&e.flags.betterauth&&(a.warn("Incompatible combination Supabase and BetterAuth. Exiting."),process.exit(0)),e.flags.clerk&&e.flags.betterauth&&(a.warn("Incompatible combination Clerk and BetterAuth. Exiting."),process.exit(0)),e.flags.supabase&&e.flags.clerk&&(a.warn("Incompatible combination Supabase and Clerk. Exiting."),process.exit(0)),e.flags.stripe&&e.packages.push("stripe"),e.flags.shadcnui&&e.packages.push("shadcnui"),e;if(e.flags.default)return e;try{if(process.env.TERM_PROGRAM?.toLowerCase().includes("mintty"))throw a.warn(` WARNING: It looks like you are using MinTTY, which is non-interactive. This is most likely because you are
10
- using Git Bash. If that's that case, please use Git Bash from another terminal, such as Windows Terminal.`),new E("Non-interactive environment");let n=await m.group({...!o&&{name:()=>m.text({message:"Project name",defaultValue:o,placeholder:C.appName,validate:Q})},authentication:()=>m.select({message:"What authentication provider would you like to use?",options:[{value:"none",label:"None"},{value:"better-auth",label:"BetterAuth"},{value:"clerk",label:"Clerk"},{value:"supabase",label:"Supabase"}],initialValue:"none"}),database:({results:i})=>{if(i.authentication!=="supabase")return m.select({message:"What database would you like to use?",options:[{value:"none",label:"None"},{value:"neon",label:"Neon"}],initialValue:"none"})},orm:()=>m.select({message:"What ORM Database would you like to use?",options:[{value:"none",label:"None"},{value:"drizzle",label:"Drizzle"}],initialValue:"none"}),importAlias:()=>m.text({message:"Custom import aliases",defaultValue:C.flags.alias,placeholder:C.flags.alias,validate:Z}),additionalConfig:()=>m.multiselect({message:"Select additional tools to install (press enter to skip)",options:[{value:"docker",label:"Docker"},{value:"stripe",label:"Stripe"},{value:"shadcnui",label:"Shadcn UI"},{value:"vercelAi",label:"Vercel AI Gateway"}],required:!1})},{onCancel(){process.exit(1)}}),s=[],r=n.additionalConfig;return n.orm==="drizzle"&&s.push("drizzle"),n.authentication==="better-auth"&&s.push("betterAuth"),n.authentication==="clerk"&&s.push("clerk"),(r.includes("supabase")||n.authentication==="supabase")&&s.push("supabase"),n.database==="neon"&&s.push("neon"),r.includes("docker")&&s.push("docker"),r.includes("stripe")&&s.push("stripe"),r.includes("shadcnui")&&s.push("shadcnui"),r.includes("vercelAi")&&s.push("vercelAi"),{appName:n.name??e.appName,packages:s,flags:{...e.flags,alias:n.importAlias??e.flags.alias}}}catch(n){if(n instanceof E)a.warn(`
11
- ${L} needs an interactive terminal to provide options`),await m.confirm({message:"Continue scaffolding a default next-ts-cli?",initialValue:!0})||(a.info("Exiting..."),process.exit(0)),a.info(`Bootstrapping a default next-ts-cli in ./${e.appName}`);else throw n}return e};import et from"path";import te from"chalk";import He from"ora";var ne=e=>{let{packages:t}=e;a.info("Adding boilerplate...");for(let[o,n]of Object.entries(t))if(n.inUse){let s=He(`Boilerplating ${o}...`).start();n.installer(e),s.succeed(te.green(`Successfully setup boilerplate for ${te.green.bold(o)}`))}a.info("")};import Ye from"path";import*as k from"@clack/prompts";import y from"chalk";import O from"fs-extra";import Xe from"ora";var oe=async({projectName:e,projectDir:t,pkgManager:o})=>{let n=Ye.join(c,"template/base");a.info(`
10
+ using Git Bash. If that's that case, please use Git Bash from another terminal, such as Windows Terminal.`),new E("Non-interactive environment");let n=await m.group({...!o&&{name:()=>m.text({message:"Project name",defaultValue:o,placeholder:C.appName,validate:X})},authentication:()=>m.select({message:"What authentication provider would you like to use?",options:[{value:"none",label:"None"},{value:"better-auth",label:"BetterAuth"},{value:"clerk",label:"Clerk"},{value:"supabase",label:"Supabase"}],initialValue:"none"}),database:({results:i})=>{if(i.authentication!=="supabase")return m.select({message:"What database would you like to use?",options:[{value:"none",label:"None"},{value:"neon",label:"Neon"}],initialValue:"none"})},orm:()=>m.select({message:"What ORM Database would you like to use?",options:[{value:"none",label:"None"},{value:"drizzle",label:"Drizzle"}],initialValue:"none"}),importAlias:()=>m.text({message:"Custom import aliases",defaultValue:C.flags.alias,placeholder:C.flags.alias,validate:q}),additionalConfig:()=>m.multiselect({message:"Select additional tools to install (press enter to skip)",options:[{value:"docker",label:"Docker"},{value:"stripe",label:"Stripe"},{value:"shadcnui",label:"Shadcn UI"},{value:"vercelAi",label:"Vercel AI Gateway"}],required:!1})},{onCancel(){process.exit(1)}}),s=[],r=n.additionalConfig;return n.orm==="drizzle"&&s.push("drizzle"),n.authentication==="better-auth"&&s.push("betterAuth"),n.authentication==="clerk"&&s.push("clerk"),(r.includes("supabase")||n.authentication==="supabase")&&s.push("supabase"),n.database==="neon"&&s.push("neon"),r.includes("docker")&&s.push("docker"),r.includes("stripe")&&s.push("stripe"),r.includes("shadcnui")&&s.push("shadcnui"),r.includes("vercelAi")&&s.push("vercelAi"),{appName:n.name??e.appName,packages:s,flags:{...e.flags,alias:n.importAlias??e.flags.alias}}}catch(n){if(n instanceof E)a.warn(`
11
+ ${G} needs an interactive terminal to provide options`),await m.confirm({message:"Continue scaffolding a default next-ts-cli?",initialValue:!0})||(a.info("Exiting..."),process.exit(0)),a.info(`Bootstrapping a default next-ts-cli in ./${e.appName}`);else throw n}return e};import Qe from"path";import Z from"chalk";import Fe from"ora";var ee=e=>{let{packages:t}=e;a.info("Adding boilerplate...");for(let[o,n]of Object.entries(t))if(n.inUse){let s=Fe(`Boilerplating ${o}...`).start();n.installer(e),s.succeed(Z.green(`Successfully setup boilerplate for ${Z.green.bold(o)}`))}a.info("")};import N from"path";import*as k from"@clack/prompts";import y from"chalk";import j from"fs-extra";import He from"ora";var te=async({projectName:e,projectDir:t,pkgManager:o})=>{let n=N.join(p,"template/base"),s=N.join(p,"template");a.info(`
12
12
  Using: ${y.cyan.bold(o)}
13
- `);let s=Xe(`Scaffolding in: ${t}...
14
- `).start();if(O.existsSync(t))if(O.readdirSync(t).length===0)e!=="."&&s.info(`${y.cyan.bold(e)} exists but is empty, continuing...
15
- `);else{s.stopAndPersist();let i=await k.select({message:`${y.redBright.bold("Warning:")} ${y.cyan.bold(e)} already exists and isn't empty. How would you like to proceed?`,options:[{label:"Abort installation (recommended)",value:"abort"},{label:"Clear the directory and continue installation",value:"clear"},{label:"Continue installation and overwrite conflicting files",value:"overwrite"}],initialValue:"abort"});(k.isCancel(i)||i==="abort")&&(s.fail("Aborting installation..."),process.exit(1));let p=await k.confirm({message:`Are you sure you want to ${i==="clear"?"clear the directory":"overwrite conflicting files"}?`,initialValue:!1});(k.isCancel(p)||!p)&&(s.fail("Aborting installation..."),process.exit(1)),i==="clear"&&(s.info(`Emptying ${y.cyan.bold(e)} and creating next-ts-cli app..
16
- `),O.emptyDirSync(t))}s.start(),O.copySync(n,t);let r=e==="."?"App":y.cyan.bold(e);s.succeed(`${r} ${y.green("scaffolded successfully!")}
17
- `)};import qe from"path";import Qe from"fs-extra";var se=({projectDir:e,projectName:t,packages:o})=>{let n=Ze(t,o);Qe.writeFileSync(qe.join(e,"README.md"),n)},Ze=(e,t)=>{let o=[];o.push(`# ${e}
13
+ `);let r=He(`Scaffolding in: ${t}...
14
+ `).start();if(j.existsSync(t))if(j.readdirSync(t).length===0)e!=="."&&r.info(`${y.cyan.bold(e)} exists but is empty, continuing...
15
+ `);else{r.stopAndPersist();let c=await k.select({message:`${y.redBright.bold("Warning:")} ${y.cyan.bold(e)} already exists and isn't empty. How would you like to proceed?`,options:[{label:"Abort installation (recommended)",value:"abort"},{label:"Clear the directory and continue installation",value:"clear"},{label:"Continue installation and overwrite conflicting files",value:"overwrite"}],initialValue:"abort"});(k.isCancel(c)||c==="abort")&&(r.fail("Aborting installation..."),process.exit(1));let l=await k.confirm({message:`Are you sure you want to ${c==="clear"?"clear the directory":"overwrite conflicting files"}?`,initialValue:!1});(k.isCancel(l)||!l)&&(r.fail("Aborting installation..."),process.exit(1)),c==="clear"&&(r.info(`Emptying ${y.cyan.bold(e)} and creating next-ts-cli app..
16
+ `),j.emptyDirSync(t))}r.start(),j.copySync(n,t),j.copySync(N.join(s,"_gitignore"),N.join(t,".gitignore"));let i=e==="."?"App":y.cyan.bold(e);r.succeed(`${i} ${y.green("scaffolded successfully!")}
17
+ `)};import Ye from"path";import Xe from"fs-extra";var ne=({projectDir:e,projectName:t,packages:o})=>{let n=qe(t,o);Xe.writeFileSync(Ye.join(e,"README.md"),n)},qe=(e,t)=>{let o=[];o.push(`# ${e}
18
18
 
19
19
  This project was bootstrapped with [next-ts-cli](https://github.com/RossiFire/next-ts-cli).
20
20
 
@@ -49,14 +49,14 @@ Open [http://localhost:3000](http://localhost:3000) in your browser.
49
49
  | \`npm run start\` | Start production server |
50
50
  | \`npm run lint\` | Lint code |
51
51
  | \`npm run test\` | Run tests |`),t.docker.inUse&&o.push("| `npm run docker:build` | Build Docker image |\n| `npm run docker:up` | Start containers |\n| `npm run docker:down` | Stop containers |"),t.drizzle.inUse&&o.push("| `npm run db:generate` | Generate migrations |\n| `npm run db:migrate` | Run migrations |\n| `npm run db:studio` | Open Drizzle Studio |");let s=[];return t.drizzle.inUse&&s.push("DATABASE_URL="),t.betterAuth.inUse&&s.push("BETTER_AUTH_SECRET=","BETTER_AUTH_URL=http://localhost:3000"),t.supabase.inUse&&s.push("NEXT_PUBLIC_SUPABASE_URL=","NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY="),t.stripe.inUse&&s.push("STRIPE_SECRET_KEY=","STRIPE_WEBHOOK_SECRET=","NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY="),t.clerk.inUse&&s.push("NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=","CLERK_SECRET_KEY="),t.vercelAi.inUse&&s.push("AI_GATEWAY_API_KEY="),o.join(`
52
- `)};var u=()=>{let e=process.env.npm_config_user_agent;return e?e.startsWith("yarn")?"yarn":e.startsWith("pnpm")?"pnpm":e.startsWith("bun")?"bun":"npm":"npm"};var re=async({projectName:e,scopedAppName:t,packages:o})=>{let n=u(),s=et.resolve(process.cwd(),e);return await oe({projectName:e,projectDir:s,pkgManager:n,scopedAppName:t}),ne({projectName:e,scopedAppName:t,projectDir:s,pkgManager:n,packages:o}),se({projectDir:s,projectName:e,packages:o}),s};import{execSync as $}from"child_process";import J from"path";import*as V from"@clack/prompts";import j from"chalk";import{execa as T}from"execa";import ie from"fs-extra";import tt from"ora";var nt=e=>{try{return $("git --version",{cwd:e}),!0}catch{return!1}},ot=e=>ie.existsSync(J.join(e,".git")),st=async e=>{try{return await T("git",["rev-parse","--is-inside-work-tree"],{cwd:e,stdout:"ignore"}),!0}catch{return!1}},rt=()=>{let t=$("git --version").toString().trim().split(" ")[2],o=t?.split(".")[0],n=t?.split(".")[1];return{major:Number(o),minor:Number(n)}},it=()=>$("git config --global init.defaultBranch || echo main").toString().trim(),ae=async e=>{if(a.info("Initializing Git..."),!nt(e)){a.warn("Git is not installed. Skipping Git initialization.");return}let t=tt(`Creating a new git repo...
53
- `).start(),o=ot(e),n=await st(e),s=J.parse(e).name;if(n&&o){if(t.stop(),!await V.confirm({message:`${j.redBright.bold("Warning:")} Git is already initialized in "${s}". Initializing a new git repository would delete the previous history. Would you like to continue anyways?`,initialValue:!1})){t.info("Skipping Git initialization.");return}ie.removeSync(J.join(e,".git"))}else if(n&&!o&&(t.stop(),!await V.confirm({message:`${j.redBright.bold("Warning:")} "${s}" is already in a git worktree. Would you still like to initialize a new git repository in this directory?`,initialValue:!1}))){t.info("Skipping Git initialization.");return}try{let r=it(),{major:i,minor:p}=rt();i<2||i===2&&p<28?(await T("git",["init"],{cwd:e}),await T("git",["symbolic-ref","HEAD",`refs/heads/${r}`],{cwd:e})):await T("git",["init",`--initial-branch=${r}`],{cwd:e}),await T("git",["add","."],{cwd:e}),t.succeed(`${j.green("Successfully initialized and staged")} ${j.green.bold("git")}
54
- `)}catch{t.fail(`${j.bold.red("Failed:")} could not initialize git. Update git to the latest version!
55
- `)}};var le=async({projectName:e=R})=>{let t=u();a.info("Next steps:"),e!=="."&&a.info(` cd ${e}`),["npm","bun"].includes(t)?a.info(` ${t} run dev`):a.info(` ${t} dev`)};import N from"fs";import at from"path";function ce(e,t,o){let n=N.readdirSync(e);try{n.forEach(s=>{let r=at.join(e,s);if(N.statSync(r).isDirectory())ce(r,t,o);else{let p=N.readFileSync(r,"utf8").replace(new RegExp(t,"g"),o);N.writeFileSync(r,p,"utf8")}})}catch(s){a.error(`Error setting import alias: ${s}`)}}var pe=(e,t)=>{try{let o=t.replace(/\*/g,"").replace(/[^/]$/,"$&/");ce(e,"@/",o)}catch(o){a.error(`Error setting import alias: ${o}`)}};import lt from"crypto";import ct from"path";import pt from"fs-extra";var de=({projectDir:e,packages:t,scopedAppName:o})=>{let n=t?.betterAuth.inUse,s=t?.supabase.inUse,r=t?.drizzle.inUse,i=t?.stripe.inUse,p=t?.clerk.inUse,l=t?.neon.inUse,f=t?.vercelAi.inUse,b=dt(!!n,!!s,!!r,!!i,!!p,!!l,!!f,o),G=ct.join(e,".env");pt.writeFileSync(G,b,"utf-8")},dt=(e,t,o,n,s,r,i,p)=>{let l=`
52
+ `)};var u=()=>{let e=process.env.npm_config_user_agent;return e?e.startsWith("yarn")?"yarn":e.startsWith("pnpm")?"pnpm":e.startsWith("bun")?"bun":"npm":"npm"};var oe=async({projectName:e,scopedAppName:t,packages:o})=>{let n=u(),s=Qe.resolve(process.cwd(),e);return await te({projectName:e,projectDir:s,pkgManager:n,scopedAppName:t}),ee({projectName:e,scopedAppName:t,projectDir:s,pkgManager:n,packages:o}),ne({projectDir:s,projectName:e,packages:o}),s};import{execSync as V}from"child_process";import L from"path";import*as J from"@clack/prompts";import T from"chalk";import{execa as z}from"execa";import se from"fs-extra";import Ze from"ora";var et=e=>{try{return V("git --version",{cwd:e}),!0}catch{return!1}},tt=e=>se.existsSync(L.join(e,".git")),nt=async e=>{try{return await z("git",["rev-parse","--is-inside-work-tree"],{cwd:e,stdout:"ignore"}),!0}catch{return!1}},ot=()=>{let t=V("git --version").toString().trim().split(" ")[2],o=t?.split(".")[0],n=t?.split(".")[1];return{major:Number(o),minor:Number(n)}},st=()=>V("git config --global init.defaultBranch || echo main").toString().trim(),re=async e=>{if(a.info("Initializing Git..."),!et(e)){a.warn("Git is not installed. Skipping Git initialization.");return}let t=Ze(`Creating a new git repo...
53
+ `).start(),o=tt(e),n=await nt(e),s=L.parse(e).name;if(n&&o){if(t.stop(),!await J.confirm({message:`${T.redBright.bold("Warning:")} Git is already initialized in "${s}". Initializing a new git repository would delete the previous history. Would you like to continue anyways?`,initialValue:!1})){t.info("Skipping Git initialization.");return}se.removeSync(L.join(e,".git"))}else if(n&&!o&&(t.stop(),!await J.confirm({message:`${T.redBright.bold("Warning:")} "${s}" is already in a git worktree. Would you still like to initialize a new git repository in this directory?`,initialValue:!1}))){t.info("Skipping Git initialization.");return}try{let r=st(),{major:i,minor:c}=ot();i<2||i===2&&c<28?(await z("git",["init"],{cwd:e}),await z("git",["symbolic-ref","HEAD",`refs/heads/${r}`],{cwd:e})):await z("git",["init",`--initial-branch=${r}`],{cwd:e}),await z("git",["add","."],{cwd:e}),t.succeed(`${T.green("Successfully initialized and staged")} ${T.green.bold("git")}
54
+ `)}catch{t.fail(`${T.bold.red("Failed:")} could not initialize git. Update git to the latest version!
55
+ `)}};var ie=async({projectName:e=R})=>{let t=u();a.info("Next steps:"),e!=="."&&a.info(` cd ${e}`),["npm","bun"].includes(t)?a.info(` ${t} run dev`):a.info(` ${t} dev`)};import O from"fs";import rt from"path";function ae(e,t,o){let n=O.readdirSync(e);try{n.forEach(s=>{let r=rt.join(e,s);if(O.statSync(r).isDirectory())ae(r,t,o);else{let c=O.readFileSync(r,"utf8").replace(new RegExp(t,"g"),o);O.writeFileSync(r,c,"utf8")}})}catch(s){a.error(`Error setting import alias: ${s}`)}}var le=(e,t)=>{try{let o=t.replace(/\*/g,"").replace(/[^/]$/,"$&/");ae(e,"@/",o)}catch(o){a.error(`Error setting import alias: ${o}`)}};import it from"crypto";import at from"path";import lt from"fs-extra";var ce=({projectDir:e,packages:t,scopedAppName:o})=>{let n=t?.betterAuth.inUse,s=t?.supabase.inUse,r=t?.drizzle.inUse,i=t?.stripe.inUse,c=t?.clerk.inUse,l=t?.neon.inUse,f=t?.vercelAi.inUse,b=ct(!!n,!!s,!!r,!!i,!!c,!!l,!!f,o),De=at.join(e,".env");lt.writeFileSync(De,b,"utf-8")},ct=(e,t,o,n,s,r,i,c)=>{let l=`
56
56
  # Base variables
57
57
  NEXT_PUBLIC_BASE_URL="http://localhost:3000"
58
58
  GOOGLE_ANALYTICS_TAG="G-xxxxxxx" # Google Analytics G-Tag ID
59
- `;if(e){let f=Buffer.from(lt.getRandomValues(new Uint8Array(32))).toString("base64");l+=`
59
+ `;if(e){let f=Buffer.from(it.getRandomValues(new Uint8Array(32))).toString("base64");l+=`
60
60
  # Better Auth
61
61
  BETTER_AUTH_SECRET="${f}" # Generated by next-ts-cli.
62
62
 
@@ -70,7 +70,7 @@ BETTER_AUTH_GITHUB_CLIENT_SECRET=""
70
70
  NEXT_PUBLIC_SUPABASE_URL="https://<app-id>.supabase.co",
71
71
  NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=""
72
72
  `),o&&(l+="# Drizzle"),r&&(l+=" + Neon"),l+=`
73
- `,(o||r)&&(l+=`DATABASE_URL="postgresql://postgres:password@localhost:5432/${p}"
73
+ `,(o||r)&&(l+=`DATABASE_URL="postgresql://postgres:password@localhost:5432/${c}"
74
74
  `),n&&(l+=`
75
75
  # https://dashboard.stripe.com/apikeys
76
76
 
@@ -87,5 +87,5 @@ CLERK_SECRET_KEY="sk_test_..."
87
87
  # Vercel AI Gateway
88
88
  # https://ai-sdk.dev/docs/getting-started/nextjs-app-router
89
89
  AI_GATEWAY_API_KEY="sk_..."
90
- `),l};import S from"path";import ge from"fs-extra";import fe from"path";import ue from"fs-extra";import mt from"sort-package-json";var me={"better-auth":"^1.4.10","drizzle-kit":"^0.31.5","drizzle-orm":"^0.41.0",postgres:"^3.4.7",tailwindcss:"^4.0.15",postcss:"^8.5.3","@tailwindcss/postcss":"^4.0.15","@biomejs/biome":"^2.3.10","@supabase/ssr":"^0.8.0","@supabase/supabase-js":"^2.89.0","@stripe/react-stripe-js":"^5.4.1","@stripe/stripe-js":"^8.6.0",stripe:"^20.1.0","@clerk/nextjs":"^6.36.5","@neondatabase/serverless":"^1.0.2",ai:"^6.0.6","@ai-sdk/react":"^3.0.6"};var d=e=>{let{dependencies:t,devMode:o,projectDir:n}=e,s=ue.readJSONSync(fe.join(n,"package.json"));t.forEach(i=>{let p=me[i];o&&s.devDependencies?s.devDependencies[i]=p:s.dependencies&&(s.dependencies[i]=p)});let r=mt(s);ue.writeJSONSync(fe.join(n,"package.json"),r,{spaces:2})};var he=({projectDir:e,packages:t})=>{let o=t?.drizzle.inUse;d({projectDir:e,dependencies:["better-auth"],devMode:!1});let s=S.join(c,"template/extras"),r=S.join(s,"better-auth"),i="api/auth/[...all]/route.ts",p=S.join(r,i),l=S.join(e,"app",i);ge.copySync(p,l);let f=S.join(r,o?"with-drizzle-auth.ts":"base-auth.ts"),b=S.join(e,"lib","auth.ts");ge.copySync(f,b)};import v from"path";import ye from"fs-extra";import ft from"path";import be from"fs-extra";import ut from"sort-package-json";var x=e=>{let{scripts:t,projectDir:o}=e,n=ft.join(o,"package.json"),s=be.readJSONSync(n);s.scripts={...s.scripts,...t};let r=ut(s);be.writeJSONSync(n,r,{spaces:2})};var ke=({projectDir:e})=>{d({projectDir:e,dependencies:["drizzle-kit"],devMode:!0}),d({projectDir:e,dependencies:["drizzle-orm","postgres"],devMode:!1});let t=v.join(c,"template/extras"),o=v.join(t,"drizzle"),n=v.join(o,"drizzle.config.ts"),s=v.join(e,"drizzle.config.ts");ye.copySync(n,s);let r=v.join(o,"db"),i=v.join(e,"lib/db");ye.copySync(r,i),x({projectDir:e,scripts:{"db:push":"drizzle-kit push","db:studio":"drizzle-kit studio","db:generate":"drizzle-kit generate","db:migrate":"drizzle-kit migrate"}})};import g from"path";import K from"fs-extra";var _e=({projectDir:e})=>{let t=g.join(c,"template/extras"),o=g.join(t,"docker");K.copySync(g.join(o,"Dockerfile"),g.join(e,"Dockerfile")),K.copySync(g.join(o,"docker-compose.prod.yml"),g.join(e,"docker-compose.prod.yml")),K.copySync(g.join(o,".dockerignore"),g.join(e,".dockerignore")),x({projectDir:e,scripts:{"docker:build":"docker compose -f docker-compose.prod.yml build","docker:up":"docker compose -f docker-compose.prod.yml up -d","docker:down":"docker compose -f docker-compose.prod.yml down","docker:logs":"docker compose -f docker-compose.prod.yml logs -f","docker:exec":"docker compose -f docker-compose.prod.yml exec app sh","docker:exec:bash":"docker compose -f docker-compose.prod.yml exec app bash","docker:exec:sh":"docker compose -f docker-compose.prod.yml exec app sh","docker:exec:npm":"docker compose -f docker-compose.prod.yml exec app npm"}})};import W from"path";import bt from"fs-extra";import B from"path";import h from"fs-extra";var w=e=>{let{serverName:t,serverConfig:o,projectDir:n}=e;gt({serverName:t,serverConfig:o,projectDir:n}),ht({serverName:t,serverConfig:o,projectDir:n})},gt=e=>{let{serverName:t,serverConfig:o,projectDir:n}=e,s=B.join(n,".cusror/mpc.json");h.ensureDirSync(B.dirname(s));let r={args:o.args,command:o.command,env:o.env,url:o.url},i={};h.existsSync(s)&&(i=h.readJSONSync(s)),i.mcpServers||(i.mcpServers={}),i.mcpServers[t]={...r},h.writeJSONSync(s,i,{spaces:" "})},ht=e=>{let{serverName:t,serverConfig:o,projectDir:n}=e,s=B.join(n,".vscode/mcp.json");h.ensureDirSync(B.dirname(s));let r={};h.existsSync(s)&&(r=h.readJSONSync(s)),r.servers||(r.servers={}),r.servers[t]={...o},h.writeJSONSync(s,r,{spaces:" "})};var Se=({projectDir:e})=>{d({projectDir:e,dependencies:["@supabase/ssr","@supabase/supabase-js"],devMode:!1});let t=W.join(c,"template/extras"),o=W.join(t,"supabase"),n=W.join(e,"lib","supabase");bt.copySync(o,n),w({serverName:"supabase",serverConfig:{type:"http",url:"https://mcp.supabase.com/mcp?project_ref=<YOUR_SUPABASE_PROJECT_ID>"},projectDir:e})};import P from"path";import xe from"fs-extra";var ve=({projectDir:e})=>{d({projectDir:e,dependencies:["stripe","@stripe/stripe-js","@stripe/react-stripe-js"],devMode:!1});let t=P.join(c,"template/extras"),o=P.join(t,"stripe"),n=P.join(o,"checkout_session"),s=P.join(e,"app/api/checkout_session");xe.copySync(n,s);let r=P.join(o,"webhook/stripe/route.ts"),i=P.join(e,"app/api/webhook/stripe/route.ts");xe.copySync(r,i),x({projectDir:e,scripts:{"webhook:local":"stripe listen --forward-to localhost:3000/api/webhook/stripe"}}),w({serverName:"stripe",serverConfig:{type:"http",url:"https://mcp.stripe.com"},projectDir:e})};import I from"path";import F from"fs-extra";var we=({projectDir:e})=>{let t=I.join(c,"template/extras"),o=I.join(t,"shadcnui"),n=I.join(o,"components.json"),s=I.join(e,"components.json");F.copySync(n,s);let r=I.join(o,"globals.css"),i=I.join(e,"app/globals.css");F.writeFileSync(i,F.readFileSync(r,"utf8")),w({serverName:"shadcn",serverConfig:{command:"npx",args:["shadcn@latest","mcp"]},projectDir:e})};import A from"path";import Pe from"fs-extra";var Ie=({projectDir:e})=>{d({projectDir:e,dependencies:["@clerk/nextjs"],devMode:!1});let t=A.join(c,"template/extras"),o=A.join(t,"clerk"),n=A.join(o,"proxy.ts"),s=A.join(e,"proxy.ts");Pe.copySync(n,s);let r=A.join(o,"layout.tsx"),i=A.join(e,"app/layout.tsx");Pe.copySync(r,i)};import Ae from"path";import yt from"fs-extra";var Ee=({projectDir:e,packages:t})=>{if(d({projectDir:e,dependencies:["@neondatabase/serverless"],devMode:!1}),t?.drizzle.inUse){let o=Ae.join(c,"template/extras/neon/index.ts"),n=Ae.join(e,"lib/db/index.ts");yt.copySync(o,n)}};import D from"path";import kt from"fs-extra";var Ce=({projectDir:e})=>{d({projectDir:e,dependencies:["ai","@ai-sdk/react"],devMode:!1});let t=D.join(c,"template/extras"),o=D.join(t,"vercel-ai"),n=D.join(o,"route.ts"),s=D.join(e,"app/api/chat/route.ts");kt.copySync(n,s)};var je=e=>({docker:{inUse:e.includes("docker"),installer:_e},betterAuth:{inUse:e.includes("betterAuth"),installer:he},drizzle:{inUse:e.includes("drizzle"),installer:ke},envVariables:{inUse:!0,installer:de},supabase:{inUse:e.includes("supabase"),installer:Se},stripe:{inUse:e.includes("stripe"),installer:ve},shadcnui:{inUse:e.includes("shadcnui"),installer:we},clerk:{inUse:e.includes("clerk"),installer:Ie},neon:{inUse:e.includes("neon"),installer:Ee},vercelAi:{inUse:e.includes("vercelAi"),installer:Ce}});import Te from"path";var ze=e=>{let o=M(e).split("/"),n=o[o.length-1];if(n==="."){let i=Te.resolve(process.cwd());n=Te.basename(i)}let s=o.findIndex(i=>i.startsWith("@"));o.findIndex(i=>i.startsWith("@"))!==-1&&(n=o.slice(s).join("/"));let r=o.filter(i=>!i.startsWith("@")).join("/");return[n,r]};import _t from"gradient-string";var St=["#003f5b","#5f5195","#cc4c91","#ff6f4e","#ff7030","#f10062","#b1008f","#2c19a8"],Re=()=>{let e=_t(St),t=u();(t==="yarn"||t==="pnpm")&&console.log(""),console.log(e.multiline(q))};import xt from"chalk";import{execa as Ue}from"execa";import Me from"ora";var H=async(e,t,o)=>{let{onDataHandle:n,args:s=["install"],stdout:r="pipe"}=o,i=Me(`Running ${t} install...`).start(),p=Ue(t,s,{cwd:e,stdout:r});return await new Promise((l,f)=>{n&&p.stdout?.on("data",n(i)),p.on("error",b=>f(b)),p.on("close",()=>l())}),i},vt=async(e,t)=>{switch(e){case"npm":return await Ue(e,["install"],{cwd:t,stderr:"inherit"}),null;case"pnpm":return H(t,e,{onDataHandle:o=>n=>{let s=n.toString();s.includes("Progress")&&(o.text=s.includes("|")?s.split(" | ")[1]??"":s)}});case"yarn":return H(t,e,{onDataHandle:o=>n=>{o.text=n.toString()}});case"bun":return H(t,e,{stdout:"ignore"})}},Oe=async({projectDir:e})=>{a.info("Installing dependencies...");let t=u();(await vt(t,e)??Me()).succeed(xt.green(`Successfully installed dependencies!
91
- `))};import{execSync as wt}from"child_process";import Pt from"https";var Ne=e=>{let t=_();t.includes("beta")?(a.warn(" You are using a beta version of next-ts-cli."),a.warn(" Please report any bugs you encounter.")):t.includes("next")?(a.warn(" You are running next-ts-cli with the @next tag which is no longer maintained."),a.warn(" Please run the CLI with @latest instead.")):t!==e&&(a.warn(" You are using an outdated version of next-ts-cli."),a.warn(" Your version:",t+".","Latest version in the npm registry:",e),a.warn(" Please run the CLI with @latest to get the latest updates.")),console.log("")};function It(){return new Promise((e,t)=>{Pt.get("https://registry.npmjs.org/-/package/next-ts-cli/dist-tags",o=>{if(o.statusCode===200){let n="";o.on("data",s=>{n+=s}),o.on("end",()=>{e(JSON.parse(n).latest)})}else t()}).on("error",()=>{t()})})}var Be=()=>It().catch(()=>{try{return wt("npm view next-ts-cli version").toString().trim()}catch{return null}});var Et=async()=>{let e=await Be(),t=u();Re(),e&&Ne(e);let{appName:o,packages:n,flags:{alias:s}}=await ee(),r=je(n),[i,p]=ze(o),l=await re({projectName:p,scopedAppName:i,packages:r,alias:s}),f=Y.readJSONSync(z.join(l,"package.json"));if(f.name=i,f.nextTsMetadata={initVersion:_()},t!=="bun"){let{stdout:Ge}=await At(t,["-v"],{cwd:l});f.packageManager=`${t}@${Ge.trim()}`}Y.writeJSONSync(z.join(l,"package.json"),f,{spaces:2}),s!=="@/"&&pe(l,s),await Oe({projectDir:l}),await ae(l),await le({projectName:p});let b=z.join(c,"template/base"),G=z.join(b,".gitignore"),De=z.join(l,".gitignore");Y.copySync(G,De),process.exit(0)};Et().catch(e=>{a.error("Aborting installation..."),e instanceof Error?a.error(e):(a.error("An unknown error has occurred. Please open an issue on github with the below:"),console.log(e)),process.exit(1)});
90
+ `),l};import S from"path";import fe from"fs-extra";import de from"path";import me from"fs-extra";import pt from"sort-package-json";var pe={"better-auth":"^1.4.10","drizzle-kit":"^0.31.5","drizzle-orm":"^0.41.0",postgres:"^3.4.7",tailwindcss:"^4.0.15",postcss:"^8.5.3","@tailwindcss/postcss":"^4.0.15","@biomejs/biome":"^2.3.10","@supabase/ssr":"^0.8.0","@supabase/supabase-js":"^2.89.0","@stripe/react-stripe-js":"^5.4.1","@stripe/stripe-js":"^8.6.0",stripe:"^20.1.0","@clerk/nextjs":"^6.36.5","@neondatabase/serverless":"^1.0.2",ai:"^6.0.6","@ai-sdk/react":"^3.0.6"};var d=e=>{let{dependencies:t,devMode:o,projectDir:n}=e,s=me.readJSONSync(de.join(n,"package.json"));t.forEach(i=>{let c=pe[i];o&&s.devDependencies?s.devDependencies[i]=c:s.dependencies&&(s.dependencies[i]=c)});let r=pt(s);me.writeJSONSync(de.join(n,"package.json"),r,{spaces:2})};var ue=({projectDir:e,packages:t})=>{let o=t?.drizzle.inUse;d({projectDir:e,dependencies:["better-auth"],devMode:!1});let s=S.join(p,"template/extras"),r=S.join(s,"better-auth"),i="api/auth/[...all]/route.ts",c=S.join(r,i),l=S.join(e,"app",i);fe.copySync(c,l);let f=S.join(r,o?"with-drizzle-auth.ts":"base-auth.ts"),b=S.join(e,"lib","auth.ts");fe.copySync(f,b)};import v from"path";import he from"fs-extra";import dt from"path";import ge from"fs-extra";import mt from"sort-package-json";var x=e=>{let{scripts:t,projectDir:o}=e,n=dt.join(o,"package.json"),s=ge.readJSONSync(n);s.scripts={...s.scripts,...t};let r=mt(s);ge.writeJSONSync(n,r,{spaces:2})};var be=({projectDir:e})=>{d({projectDir:e,dependencies:["drizzle-kit"],devMode:!0}),d({projectDir:e,dependencies:["drizzle-orm","postgres"],devMode:!1});let t=v.join(p,"template/extras"),o=v.join(t,"drizzle"),n=v.join(o,"drizzle.config.ts"),s=v.join(e,"drizzle.config.ts");he.copySync(n,s);let r=v.join(o,"db"),i=v.join(e,"lib/db");he.copySync(r,i),x({projectDir:e,scripts:{"db:push":"drizzle-kit push","db:studio":"drizzle-kit studio","db:generate":"drizzle-kit generate","db:migrate":"drizzle-kit migrate"}})};import g from"path";import $ from"fs-extra";var ye=({projectDir:e})=>{let t=g.join(p,"template/extras"),o=g.join(t,"docker");$.copySync(g.join(o,"Dockerfile"),g.join(e,"Dockerfile")),$.copySync(g.join(o,"docker-compose.prod.yml"),g.join(e,"docker-compose.prod.yml")),$.copySync(g.join(o,".dockerignore"),g.join(e,".dockerignore")),x({projectDir:e,scripts:{"docker:build":"docker compose -f docker-compose.prod.yml build","docker:up":"docker compose -f docker-compose.prod.yml up -d","docker:down":"docker compose -f docker-compose.prod.yml down","docker:logs":"docker compose -f docker-compose.prod.yml logs -f","docker:exec":"docker compose -f docker-compose.prod.yml exec app sh","docker:exec:bash":"docker compose -f docker-compose.prod.yml exec app bash","docker:exec:sh":"docker compose -f docker-compose.prod.yml exec app sh","docker:exec:npm":"docker compose -f docker-compose.prod.yml exec app npm"}})};import K from"path";import gt from"fs-extra";import B from"path";import h from"fs-extra";var w=e=>{let{serverName:t,serverConfig:o,projectDir:n}=e;ft({serverName:t,serverConfig:o,projectDir:n}),ut({serverName:t,serverConfig:o,projectDir:n})},ft=e=>{let{serverName:t,serverConfig:o,projectDir:n}=e,s=B.join(n,".cusror/mpc.json");h.ensureDirSync(B.dirname(s));let r={args:o.args,command:o.command,env:o.env,url:o.url},i={};h.existsSync(s)&&(i=h.readJSONSync(s)),i.mcpServers||(i.mcpServers={}),i.mcpServers[t]={...r},h.writeJSONSync(s,i,{spaces:" "})},ut=e=>{let{serverName:t,serverConfig:o,projectDir:n}=e,s=B.join(n,".vscode/mcp.json");h.ensureDirSync(B.dirname(s));let r={};h.existsSync(s)&&(r=h.readJSONSync(s)),r.servers||(r.servers={}),r.servers[t]={...o},h.writeJSONSync(s,r,{spaces:" "})};var ke=({projectDir:e})=>{d({projectDir:e,dependencies:["@supabase/ssr","@supabase/supabase-js"],devMode:!1});let t=K.join(p,"template/extras"),o=K.join(t,"supabase"),n=K.join(e,"lib","supabase");gt.copySync(o,n),w({serverName:"supabase",serverConfig:{type:"http",url:"https://mcp.supabase.com/mcp?project_ref=<YOUR_SUPABASE_PROJECT_ID>"},projectDir:e})};import P from"path";import _e from"fs-extra";var Se=({projectDir:e})=>{d({projectDir:e,dependencies:["stripe","@stripe/stripe-js","@stripe/react-stripe-js"],devMode:!1});let t=P.join(p,"template/extras"),o=P.join(t,"stripe"),n=P.join(o,"checkout_session"),s=P.join(e,"app/api/checkout_session");_e.copySync(n,s);let r=P.join(o,"webhook/stripe/route.ts"),i=P.join(e,"app/api/webhook/stripe/route.ts");_e.copySync(r,i),x({projectDir:e,scripts:{"webhook:local":"stripe listen --forward-to localhost:3000/api/webhook/stripe"}}),w({serverName:"stripe",serverConfig:{type:"http",url:"https://mcp.stripe.com"},projectDir:e})};import I from"path";import W from"fs-extra";var xe=({projectDir:e})=>{let t=I.join(p,"template/extras"),o=I.join(t,"shadcnui"),n=I.join(o,"components.json"),s=I.join(e,"components.json");W.copySync(n,s);let r=I.join(o,"globals.css"),i=I.join(e,"app/globals.css");W.writeFileSync(i,W.readFileSync(r,"utf8")),w({serverName:"shadcn",serverConfig:{command:"npx",args:["shadcn@latest","mcp"]},projectDir:e})};import A from"path";import ve from"fs-extra";var we=({projectDir:e})=>{d({projectDir:e,dependencies:["@clerk/nextjs"],devMode:!1});let t=A.join(p,"template/extras"),o=A.join(t,"clerk"),n=A.join(o,"proxy.ts"),s=A.join(e,"proxy.ts");ve.copySync(n,s);let r=A.join(o,"layout.tsx"),i=A.join(e,"app/layout.tsx");ve.copySync(r,i)};import Pe from"path";import ht from"fs-extra";var Ie=({projectDir:e,packages:t})=>{if(d({projectDir:e,dependencies:["@neondatabase/serverless"],devMode:!1}),t?.drizzle.inUse){let o=Pe.join(p,"template/extras/neon/index.ts"),n=Pe.join(e,"lib/db/index.ts");ht.copySync(o,n)}};import D from"path";import bt from"fs-extra";var Ae=({projectDir:e})=>{d({projectDir:e,dependencies:["ai","@ai-sdk/react"],devMode:!1});let t=D.join(p,"template/extras"),o=D.join(t,"vercel-ai"),n=D.join(o,"route.ts"),s=D.join(e,"app/api/chat/route.ts");bt.copySync(n,s)};var Ee=e=>({docker:{inUse:e.includes("docker"),installer:ye},betterAuth:{inUse:e.includes("betterAuth"),installer:ue},drizzle:{inUse:e.includes("drizzle"),installer:be},envVariables:{inUse:!0,installer:ce},supabase:{inUse:e.includes("supabase"),installer:ke},stripe:{inUse:e.includes("stripe"),installer:Se},shadcnui:{inUse:e.includes("shadcnui"),installer:xe},clerk:{inUse:e.includes("clerk"),installer:we},neon:{inUse:e.includes("neon"),installer:Ie},vercelAi:{inUse:e.includes("vercelAi"),installer:Ae}});import Ce from"path";var je=e=>{let o=M(e).split("/"),n=o[o.length-1];if(n==="."){let i=Ce.resolve(process.cwd());n=Ce.basename(i)}let s=o.findIndex(i=>i.startsWith("@"));o.findIndex(i=>i.startsWith("@"))!==-1&&(n=o.slice(s).join("/"));let r=o.filter(i=>!i.startsWith("@")).join("/");return[n,r]};import yt from"gradient-string";var kt=["#003f5b","#5f5195","#cc4c91","#ff6f4e","#ff7030","#f10062","#b1008f","#2c19a8"],Te=()=>{let e=yt(kt),t=u();(t==="yarn"||t==="pnpm")&&console.log(""),console.log(e.multiline(Y))};import _t from"chalk";import{execa as ze}from"execa";import Re from"ora";var F=async(e,t,o)=>{let{onDataHandle:n,args:s=["install"],stdout:r="pipe"}=o,i=Re(`Running ${t} install...`).start(),c=ze(t,s,{cwd:e,stdout:r});return await new Promise((l,f)=>{n&&c.stdout?.on("data",n(i)),c.on("error",b=>f(b)),c.on("close",()=>l())}),i},St=async(e,t)=>{switch(e){case"npm":return await ze(e,["install"],{cwd:t,stderr:"inherit"}),null;case"pnpm":return F(t,e,{onDataHandle:o=>n=>{let s=n.toString();s.includes("Progress")&&(o.text=s.includes("|")?s.split(" | ")[1]??"":s)}});case"yarn":return F(t,e,{onDataHandle:o=>n=>{o.text=n.toString()}});case"bun":return F(t,e,{stdout:"ignore"})}},Ue=async({projectDir:e})=>{a.info("Installing dependencies...");let t=u();(await St(t,e)??Re()).succeed(_t.green(`Successfully installed dependencies!
91
+ `))};import{execSync as xt}from"child_process";import vt from"https";var Me=e=>{let t=_();t.includes("beta")?(a.warn(" You are using a beta version of next-ts-cli."),a.warn(" Please report any bugs you encounter.")):t.includes("next")?(a.warn(" You are running next-ts-cli with the @next tag which is no longer maintained."),a.warn(" Please run the CLI with @latest instead.")):t!==e&&(a.warn(" You are using an outdated version of next-ts-cli."),a.warn(" Your version:",t+".","Latest version in the npm registry:",e),a.warn(" Please run the CLI with @latest to get the latest updates.")),console.log("")};function wt(){return new Promise((e,t)=>{vt.get("https://registry.npmjs.org/-/package/next-ts-cli/dist-tags",o=>{if(o.statusCode===200){let n="";o.on("data",s=>{n+=s}),o.on("end",()=>{e(JSON.parse(n).latest)})}else t()}).on("error",()=>{t()})})}var Ne=()=>wt().catch(()=>{try{return xt("npm view next-ts-cli version").toString().trim()}catch{return null}});var It=async()=>{let e=await Ne(),t=u();Te(),e&&Me(e);let{appName:o,packages:n,flags:{alias:s}}=await Q(),r=Ee(n),[i,c]=je(o),l=await oe({projectName:c,scopedAppName:i,packages:r,alias:s}),f=Be.readJSONSync(Oe.join(l,"package.json"));if(f.name=i,f.nextTsMetadata={initVersion:_()},t!=="bun"){let{stdout:b}=await Pt(t,["-v"],{cwd:l});f.packageManager=`${t}@${b.trim()}`}Be.writeJSONSync(Oe.join(l,"package.json"),f,{spaces:2}),s!=="@/"&&le(l,s),await Ue({projectDir:l}),await re(l),await ie({projectName:c}),process.exit(0)};It().catch(e=>{a.error("Aborting installation..."),e instanceof Error?a.error(e):(a.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-ts-cli",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Create production-ready web application with the Next.js",
5
5
  "author": "Daniele Rossino <daniele.rossino10@gmail.com>",
6
6
  "maintainers": [],
@@ -0,0 +1,46 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /.pnp
6
+ .pnp.js
7
+
8
+ # testing
9
+ /coverage
10
+
11
+ # database
12
+ /prisma/db.sqlite
13
+ /prisma/db.sqlite-journal
14
+ db.sqlite
15
+ /generated/
16
+
17
+ # next.js
18
+ /.next/
19
+ /out/
20
+ next-env.d.ts
21
+
22
+ # production
23
+ /build
24
+
25
+ # misc
26
+ .DS_Store
27
+ *.pem
28
+
29
+ # debug
30
+ npm-debug.log*
31
+ yarn-debug.log*
32
+ yarn-error.log*
33
+ .pnpm-debug.log*
34
+
35
+ # local env files
36
+ .env
37
+ .env*.local
38
+
39
+ # vercel
40
+ .vercel
41
+
42
+ # typescript
43
+ *.tsbuildinfo
44
+
45
+ # idea files
46
+ .idea