create-tnt-stack 0.1.0 → 0.1.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 +2 -2
- package/dist/index.js +16 -17
- package/package.json +1 -1
package/README.md
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
<picture>
|
3
3
|
<source
|
4
4
|
media="(prefers-color-scheme: dark)"
|
5
|
-
srcset="https://
|
5
|
+
srcset="https://github.com/SlickYeet/create-tnt-stack/blob/8fbac6741f1a0003bbd36e512e8a859b52db0793/web/public/logo.light.png"
|
6
6
|
/>
|
7
7
|
<img
|
8
|
-
src="https://
|
8
|
+
src="https://github.com/SlickYeet/create-tnt-stack/blob/8fbac6741f1a0003bbd36e512e8a859b52db0793/web/public/logo.dark.png"
|
9
9
|
width="130"
|
10
10
|
alt="TNT-Powered logo"
|
11
11
|
/>
|
package/dist/index.js
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
#!/user/bin/env node
|
2
|
-
import
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
`,h="my-tnt-stack",G="create-tnt-stack";import Te from"node:crypto";import E from"path";import $ from"fs-extra";var H=({projectDir:e,packages:t,scopedAppName:n,databaseProvider:a})=>{let i=t?.nextAuth.inUse,o=t?.prisma.inUse,r=o,l=Ce(!!i,!!o,n,a),p="";if(r?i?p="with-next-auth-db.js":p="with-db.js":i&&(p="with-next-auth.js"),p!==""){let xe=E.join(u,"template/packages/src/env",p),Pe=E.join(e,"src/env.js");$.copyFileSync(xe,Pe)}let d=E.join(e,".env"),m=E.join(e,".env.example"),g=Ee+l,_=Buffer.from(Te.getRandomValues(new Uint8Array(32))).toString("base64"),D=l.replace('AUTH_SECRET=""',`AUTH_SECRET="${_}" # Generated by create-tnt-stack`);$.writeFileSync(d,D,"utf-8"),$.writeFileSync(m,g,"utf-8")};function Ce(e,t,n,a){let i=`
|
2
|
+
import we from"path";import{execa as Qe}from"execa";import ke from"fs-extra";import*as p from"@clack/prompts";import{Command as De}from"commander";import B from"path";import{fileURLToPath as Ae}from"url";var Ie=Ae(import.meta.url),Se=B.dirname(Ie),u=B.join(Se,"../"),F=` ___ ___ ___ _ _____ ___ _____ _ _ _____ ___ _____ _ ___ _ __
|
3
|
+
/ __| _ \\ __| /_\\_ _| __| |_ _| \\| |_ _| / __|_ _/_\\ / __| |/ /
|
4
|
+
| (__| / _| / _ \\| | | _| | | | .\` | | | \\__ \\ | |/ _ \\ (__| ' <
|
5
|
+
\\___|_|_\\___/_/ \\_\\_| |___| |_| |_|\\_| |_| |___/ |_/_/ \\_\\___|_|\\_\\
|
6
|
+
`,h="my-tnt-stack",$="create-tnt-stack";import Te from"node:crypto";import E from"path";import j from"fs-extra";var H=({projectDir:e,packages:t,scopedAppName:n,databaseProvider:a})=>{let i=t?.nextAuth.inUse,o=t?.prisma.inUse,r=o,l=Ce(!!i,!!o,n,a),c="";if(r?i?c="with-next-auth-db.js":c="with-db.js":i&&(c="with-next-auth.js"),c!==""){let xe=E.join(u,"template/packages/src/env",c),Pe=E.join(e,"src/env.js");j.copyFileSync(xe,Pe)}let d=E.join(e,".env"),m=E.join(e,".env.example"),g=Ee+l,k=Buffer.from(Te.getRandomValues(new Uint8Array(32))).toString("base64"),D=l.replace('AUTH_SECRET=""',`AUTH_SECRET="${k}" # Generated by create-tnt-stack`);j.writeFileSync(d,D,"utf-8"),j.writeFileSync(m,g,"utf-8")};function Ce(e,t,n,a){let i=`
|
8
7
|
# When adding additional environment variables, the schema in "/src/env.js"
|
9
8
|
# should be updated accordingly.
|
10
9
|
`.trim().concat(`
|
@@ -36,19 +35,19 @@ AUTH_DISCORD_SECRET=""
|
|
36
35
|
# ".env" and populate it with your secrets.
|
37
36
|
`.trim().concat(`
|
38
37
|
|
39
|
-
`);import y from"path";import
|
38
|
+
`);import y from"path";import G from"fs-extra";import Y from"path";import Q from"fs-extra";import Ne from"sort-package-json";var K={"next-auth":"^4.24.11","@auth/prisma-adapter":"^2.8.0",prisma:"^6.4.1","@prisma/client":"^6.4.1"};var A=e=>{let{dependencies:t,devMode:n,projectDir:a}=e,i=Q.readJsonSync(Y.join(a,"package.json"));t.forEach(r=>{let l=K[r];n&&i.devDependencies?i.devDependencies[r]=l:i.dependencies&&(i.dependencies[r]=l)});let o=Ne(i);Q.writeJsonSync(Y.join(a,"package.json"),o,{spaces:2})};var X=({projectDir:e,packages:t})=>{let n=t?.prisma.inUse,a=["next-auth"];n&&a.push("@auth/prisma-adapter"),A({projectDir:e,dependencies:a,devMode:!1});let i=y.join(u,"template/packages"),o="src/app/api/auth/[...nextauth]/route.ts",r=y.join(i,o),l=y.join(e,o),c=y.join(i,"src/server/auth/config",n?"next-auth-with-prisma.ts":"next-auth.ts"),d=y.join(e,"src/server/auth/config.ts"),m=y.join(i,"src/server/auth/next-auth.ts"),g=y.join(e,"src/server/auth/index.ts");G.copySync(r,l),G.copySync(c,d),G.copySync(m,g)};import b from"path";import x from"fs-extra";var Z=({projectDir:e,packages:t,databaseProvider:n})=>{A({projectDir:e,dependencies:["prisma"],devMode:!0}),A({projectDir:e,dependencies:["@prisma/client"],devMode:!1});let a=b.join(u,"template/packages"),i=b.join(a,"prisma/schema",`${t?.nextAuth.inUse?"with-next-auth":"base"}.prisma`),o=x.readFileSync(i,"utf-8");n!=="sqlite"&&(o=o.replace('provider = "sqlite"',`provider = "${{mysql:"mysql",postgresql:"postgresql"}[n]}"`),["mysql"].includes(n)&&(o=o.replace("// @db.Text","@db.Text")));let r=b.join(e,"prisma/schema.prisma");x.mkdirSync(b.dirname(r),{recursive:!0}),x.writeFileSync(r,o);let l=b.join(a,"src/server/db/db-prisma.ts"),c=b.join(e,"src/server/db/index.ts"),d=b.join(e,"package.json"),m=x.readJSONSync(d);m.scripts={...m.scripts,postinstall:"prisma generate","db:push":"prisma db push","db:studio":"prisma studio","db:generate":"prisma migrate dev","db:migrate":"prisma migrate deploy"},x.copy(l,c),x.writeJSONSync(d,m,{spaces:2})};var N=["sqlite","mysql","postgresql"],ee=e=>({nextAuth:{inUse:e.includes("nextAuth"),installer:X},prisma:{inUse:e.includes("prisma"),installer:Z},envVariables:{inUse:!0,installer:H}});import Oe from"path";import Me from"fs-extra";function P(){let e=Oe.join(u,"package.json");return Me.readJSONSync(e).version??"1.0.0"}var f=()=>{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 I=class extends Error{constructor(t){super(t)}};import O from"chalk";var s={error(...e){console.log(O.red(...e))},warn(...e){console.log(O.yellow(...e))},info(...e){console.log(O.cyan(...e))},success(...e){console.log(O.green(...e))}};var M=e=>(e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e);var Re=/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;function te(e){let t=M(e),n=t.split("/"),a=n.findIndex(o=>o.startsWith("@")),i=n[n.length-1];if(n.findIndex(o=>o.startsWith("@"))!==-1&&(i=n.slice(a).join("/")),!(t=="."||Re.test(i??"")))return"App name must consist of only lowercase alphanumeric characters, '-', and '_'"}var ne=e=>{if(e.startsWith(".")||e.startsWith("/"))return"Import alias can't start with '.' or '/'"};var v={appName:h,packages:["prisma"],flags:{noGit:!1,noInstall:!1,default:!1,CI:!1,prisma:!1,nextAuth:!1,importAlias:"@/",dbProvider:"sqlite"},databaseProvider:"sqlite"};async function ae(){let e=v,t=new De().name($).description("CLI for scaffolding new web apps with the TNT-Powered stack").version(P(),"-v, --version","Display the version number").argument("[dir]","The name of the application, as well as the name of the directory to create").option("--noGit","Explicitly tell the CLI to not initialize a new git repo in the project",!1).option("--noInstall","Explicitly tell the CLI to not run the package manager's install command",!1).option("-y, --default","Bypass the CLI and use all default options to bootstrap a new tnt-stack",!1).option("--CI","Boolean value if we're running in CI",!1).option("--nextAuth [boolean]","Experimental: Boolean value if we should install NextAuth.js. Must be used in conjunction with `--CI`.",a=>!!a&&a!=="false").option("--prisma [boolean]","Experimental: Boolean value if we should install Prisma. Must be used in conjunction with `--CI`.",a=>!!a&&a!=="false").option("-i, --import-alias","Explicitly tell the CLI to use a custom import alias",v.flags.importAlias).option("--dbProvider [provider]",`Choose a database provider to use. Possible values: ${N.join(", ")}`,v.flags.dbProvider).parse(process.argv);process.env.npm_config_user_agent?.startsWith("yarn/3")&&s.warn(` WARNING: It looks like you are using Yarn 3. This is currently not supported,
|
40
39
|
and likely to result in a crash. Please run create-tnt-stack with another
|
41
40
|
package manager such as pnpm, npm, or Yarn Classic.
|
42
|
-
See: https://github.com/t3-oss/create-t3-app/issues/57`);let n=t.args[0];if(n&&(e.appName=n),e.flags=t.opts(),e.flags.CI)return e.flags.nextAuth&&e.packages.push("nextAuth"),e.flags.prisma&&e.packages.push("prisma"),
|
41
|
+
See: https://github.com/t3-oss/create-t3-app/issues/57`);let n=t.args[0];if(n&&(e.appName=n),e.flags=t.opts(),e.flags.CI)return e.flags.nextAuth&&e.packages.push("nextAuth"),e.flags.prisma&&e.packages.push("prisma"),N.includes(e.flags.dbProvider)===!1&&(s.warn(`Incompatible database provided. Use: ${N.join(", ")}. Exiting.`),process.exit(0)),e.databaseProvider=e.packages.includes("prisma")?e.flags.dbProvider:"sqlite",e;if(e.flags.default)return e;try{if(process.env.TERM_PROGRAM?.toLowerCase().includes("mintty"))throw s.warn(` WARNING: It looks like you are using MinTTY, which is non-interactive. This is most likely because you are
|
43
42
|
using Git Bash. If that's that case, please use Git Bash from another terminal, such as Windows Terminal. Alternatively, you
|
44
|
-
can provide the arguments from the CLI directly: https://create.tntstack.org/installation#experimental-usage to skip the prompts.`),new I("Non-interactive environment");let a=f(),i=await
|
45
|
-
Using: ${
|
46
|
-
`);let o
|
47
|
-
`).start();if(S.existsSync(t))if(S.readdirSync(t).length===0)e!=="."&&o.info(`${
|
48
|
-
`);else{o.stopAndPersist();let l=await
|
49
|
-
`),S.emptyDirSync(t))}o.start(),S.copySync(i,t),S.renameSync(V.join(t,"_gitignore"),V.join(t,".gitignore"));let r=e==="."?"App":
|
50
|
-
`)}async function re({projectName:e,scopedAppName:t,packages:n,noInstall:a,databaseProvider:i}){let o=f(),r=
|
43
|
+
can provide the arguments from the CLI directly: https://create.tntstack.org/installation#experimental-usage to skip the prompts.`),new I("Non-interactive environment");let a=f(),i=await p.group({...!n&&{name:()=>p.text({message:`What will your project be called? (e.g. ${h})`,defaultValue:n||h,validate:r=>te(r||h)})},authentication:()=>p.select({message:"What authentication provider would you like to use?",options:[{value:"none",label:"None"},{value:"nextAuth",label:"NextAuth.js"},{value:"lucia",label:"Lucia Auth (not a library)"}],initialValue:"none"}),database:()=>p.select({message:"What database ORM would you like to use?",options:[{value:"none",label:"None"},{value:"prisma",label:"Prisma"}],initialValue:"none"}),databaseProvider:({results:r})=>{if(r.database!=="none")return p.select({message:"",options:[{value:"sqlite",label:"SQLite (LibSQL)"},{value:"mysql",label:"MySQL"},{value:"postgresql",label:"PostgreSQL"}],initialValue:"sqlite"})},...!e.flags.noGit&&{git:()=>p.confirm({message:"Should be initialize a new Git repository and stage the changes?",initialValue:!v.flags.noGit})},...!e.flags.noInstall&&{install:()=>p.confirm({message:`Should we run '${a}`+(a==="yarn"?"'?":" install' for you?"),initialValue:!v.flags.noInstall})},importAlias:()=>p.text({message:"What import alias would you like to use?",defaultValue:v.flags.importAlias,placeholder:v.flags.importAlias,validate:ne})},{onCancel(){process.exit(1)}}),o=[];return i.authentication==="nextAuth"&&o.push("nextAuth"),i.database==="prisma"&&o.push("prisma"),{appName:i.name??e.appName,packages:o,databaseProvider:i.databaseProvider||"sqlite",flags:{...e.flags,noGit:!i.git||e.flags.noGit,noInstall:!i.install||e.flags.noInstall,importAlias:i.importAlias??e.flags.importAlias}}}catch(a){if(a instanceof I)s.warn(`${$} needs an interactive terminal to run.`),await p.confirm({message:"Continue scaffolding with default options?",initialValue:!0})||(s.info("Exiting..."),process.exit(0)),s.info(`Scaffolding default tnt app in ./${e.appName}`);else throw a}return e}import Ge from"path";import ie from"chalk";import $e from"ora";function oe(e){let{packages:t}=e;s.info("Adding boilerplate...");for(let[n,a]of Object.entries(t))if(a.inUse){let i=$e(`Boilerplating ${n}...`).start();a.installer(e),i.succeed(ie.green(`Successfully setup boilerplate for ${ie.green.bold(n)}`))}s.info("")}import V from"path";import*as w from"@clack/prompts";import _ from"chalk";import S from"fs-extra";import je from"ora";async function se({projectName:e,projectDir:t,pkgManager:n,noInstall:a}){let i=V.join(u,"template/base");a?s.info(""):s.info(`
|
44
|
+
Using: ${_.cyan.bold(n)}
|
45
|
+
`);let o=je(`Scaffolding in: ${t}...
|
46
|
+
`).start();if(S.existsSync(t))if(S.readdirSync(t).length===0)e!=="."&&o.info(`${_.cyan.bold(e)} exists but is empty, continuing...
|
47
|
+
`);else{o.stopAndPersist();let l=await w.select({message:`${_.redBright.bold("Warning:")} ${_.cyan.bold(e)} already exists and isn't empty. How would you like to proceed?`,options:[{value:"abort",label:"Abort installation (recommended)"},{value:"clear",label:"Clear the directory and continue installation"},{value:"overwrite",label:"Continue installation and overwrite conflicting files"}],initialValue:"abort"});(w.isCancel(l)||l==="abort")&&(o.fail("Aborting installation..."),process.exit(1));let c=await w.confirm({message:`Are you sure you want to ${l==="clear"?"clear the directory":"overwrite conflicting files"}`,initialValue:!1});(w.isCancel(c)||!c)&&(o.fail("Aborting installation..."),process.exit(1)),l==="clear"&&(o.info(`Emptying ${_.cyan.bold(e)} and creating tnt app...
|
48
|
+
`),S.emptyDirSync(t))}o.start(),S.copySync(i,t),S.renameSync(V.join(t,"_gitignore"),V.join(t,".gitignore"));let r=e==="."?"App":_.cyan.bold(e);o.succeed(`${r} ${_.green.bold("scaffolded successfully!")}
|
49
|
+
`)}async function re({projectName:e,scopedAppName:t,packages:n,noInstall:a,databaseProvider:i}){let o=f(),r=Ge.resolve(process.cwd(),e);return await se({projectName:e,projectDir:r,pkgManager:o,scopedAppName:t,noInstall:a,databaseProvider:i}),oe({projectName:e,scopedAppName:t,projectDir:r,pkgManager:o,packages:n,noInstall:a,databaseProvider:i}),r}import{execSync as J}from"child_process";import U from"path";import*as W from"@clack/prompts";import T from"chalk";import{execa as C}from"execa";import le from"fs-extra";import Ve from"ora";function Ue(e){try{return J("git --version",{cwd:e}),!0}catch{return!1}}function L(e){return le.existsSync(U.join(e,".git"))}async function q(e){try{return await C("git",["rev-parse","--is-inside-work-tree"],{cwd:e,stdout:"ignore"}),!0}catch{return!1}}function We(){let t=J("git --version").toString().trim().split(" ")[2],n=t?.split(".")[0],a=t?.split(".")[1];return{major:Number(n),minor:Number(a)}}function Je(){return J("git config --global init.defaultBranch || echo main").toString().trim()}async function ce(e){if(s.info("Initializing Git..."),!Ue(e)){s.warn("Git is not installed. Skipping Git initialization.");return}let t=Ve(`Creating a new git repo...
|
51
50
|
`).start(),n=L(e),a=await q(e),i=U.parse(e).name;if(a&&n){if(t.stop(),!await W.confirm({message:`${T.redBright.bold("Warning:")} Git is already initialized in "${i}". Initializing a new git repository would delete the previous history. Would you like to continue anyways?`,initialValue:!1})){t.info("Skipping Git initialization.");return}le.removeSync(U.join(e,".git"))}else if(a&&!n&&(t.stop(),!await W.confirm({message:`${T.redBright.bold("Warning:")} "${i}" 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 o=Je(),{major:r,minor:l}=We();r<2||r==2&&l<28?(await C("git",["init"],{cwd:e}),await C("git",["symbolic-ref","HEAD",`refs/heads/${o}`],{cwd:e})):await C("git",["init",`--initial-branch=${o}`],{cwd:e}),await C("git",["add","."],{cwd:e}),t.succeed(`${T.green("Successfully initialized and staged")} ${T.green.bold("git")}
|
52
51
|
`)}catch{t.fail(`${T.bold.red("Failed:")} could not initialize git. Update git to the latest version!
|
53
|
-
`)}}import Le from"chalk";import{execa as
|
54
|
-
`))};var de=async({projectName:e=h,packages:t,noInstall:n,projectDir:a,databaseProvider:i})=>{let o=f();s.info("Next steps:"),e!=="."&&s.info(` cd ${e}`),n&&(o==="yarn"?s.info(` ${o}`):s.info(` ${o} install`)),["postgresql","mysql"].includes(i)&&s.info(" Add your database connection string to .env"),t?.nextAuth.inUse&&s.info(" Fill in your .env with necessary values. See https://create.tntstack.org/usage/first-steps for more info."),["npm","bun"].includes(o)?s.info(` ${o} run dev`):s.info(` ${o} dev`),!await q(a)&&!L(a)&&s.info(" git init"),s.info(' git commit -m "initial commit"')};import R from"fs";import ze from"path";function ge(e,t,n){R.readdirSync(e).forEach(i=>{let o=ze.join(e,i);if(R.statSync(o).isDirectory())ge(o,t,n);else{let l=R.readFileSync(o,"utf8").replace(new RegExp(t,"g"),n);R.writeFileSync(o,l,"utf8")}})}function ue(e,t){let n=t.replace(/\*/g,"").replace(/[^\/]$/,"$&/");ge(e,"@/",n)}import he from"path";function ye(e){let n=M(e).split("/"),a=n[n.length-1];if(a==="."){let r=he.resolve(process.cwd());a=he.basename(r)}let i=n.findIndex(r=>r.startsWith("@"));n.findIndex(r=>r.startsWith("@"))!==-1&&(a=n.slice(i).join("/"));let o=n.filter(r=>!r.startsWith("@")).join("/");return[a,o]}import Be from"gradient-string";var Fe={blue:"#add7ff",cyan:"#89ddff",green:"#5de4c7",magenta:"#fae4fc",red:"#d0679d",yellow:"#fffac2"};function be(){let e=Be(Object.values(Fe)),t=f();(t==="yarn"||t==="pnpm")&&console.log(""),console.log(e.multiline(F))}import{execSync as He}from"child_process";import Ke from"https";function ve(e){let t=P();t.includes("beta")?(s.warn(" You are using a beta version of create-tnt-stack."),s.warn(" Please report any bugs you encounter.")):t!==e&&(s.warn(" You are using an outdated version of create-tnt-stack."),s.warn(" Your version:",t+".","Latest version in the npm registry:",e),s.warn(" Please run the CLI with @latest to get the latest updates.")),console.log("")}function Ye(){return new Promise((e,t)=>{Ke.get("https://registry.npmjs.org/-/package/tnt-stack/dist-tags",n=>{if(n.statusCode===200){let a="";n.on("data",i=>a+=i),n.on("end",()=>{e(JSON.parse(a).latest)})}else t()}).on("error",()=>{t()})})}var
|
52
|
+
`)}}import Le from"chalk";import{execa as pe}from"execa";import me from"ora";var z=async(e,t,n)=>{let{onDataHandle:a,args:i=["install"],stdout:o="pipe"}=n,r=me(`Running ${t} install...`).start(),l=pe(t,i,{cwd:e,stdout:o});return await new Promise((c,d)=>{a&&l.stdout?.on("data",a(r)),l.on("error",m=>d(m)),l.on("close",()=>c())}),r},qe=async(e,t)=>{switch(e){case"npm":return await pe(e,["install"],{cwd:t,stderr:"inherit"}),null;case"pnpm":return z(t,e,{onDataHandle:n=>a=>{let i=a.toString();i.includes("Progress")&&(n.text=i.includes("|")?i.split(" | ")[1]??"":i)}});case"yarn":return z(t,e,{onDataHandle:n=>a=>{n.text=a.toString()}});case"bun":return z(t,e,{stdout:"ignore"})}},fe=async({projectDir:e})=>{s.info("Installing dependencies...");let t=f();(await qe(t,e)??me()).succeed(Le.green(`Successfully installed dependencies!
|
53
|
+
`))};var de=async({projectName:e=h,packages:t,noInstall:n,projectDir:a,databaseProvider:i})=>{let o=f();s.info("Next steps:"),e!=="."&&s.info(` cd ${e}`),n&&(o==="yarn"?s.info(` ${o}`):s.info(` ${o} install`)),["postgresql","mysql"].includes(i)&&s.info(" Add your database connection string to .env"),t?.nextAuth.inUse&&s.info(" Fill in your .env with necessary values. See https://create.tntstack.org/usage/first-steps for more info."),["npm","bun"].includes(o)?s.info(` ${o} run dev`):s.info(` ${o} dev`),!await q(a)&&!L(a)&&s.info(" git init"),s.info(' git commit -m "initial commit"')};import R from"fs";import ze from"path";function ge(e,t,n){R.readdirSync(e).forEach(i=>{let o=ze.join(e,i);if(R.statSync(o).isDirectory())ge(o,t,n);else{let l=R.readFileSync(o,"utf8").replace(new RegExp(t,"g"),n);R.writeFileSync(o,l,"utf8")}})}function ue(e,t){let n=t.replace(/\*/g,"").replace(/[^\/]$/,"$&/");ge(e,"@/",n)}import he from"path";function ye(e){let n=M(e).split("/"),a=n[n.length-1];if(a==="."){let r=he.resolve(process.cwd());a=he.basename(r)}let i=n.findIndex(r=>r.startsWith("@"));n.findIndex(r=>r.startsWith("@"))!==-1&&(a=n.slice(i).join("/"));let o=n.filter(r=>!r.startsWith("@")).join("/");return[a,o]}import Be from"gradient-string";var Fe={blue:"#add7ff",cyan:"#89ddff",green:"#5de4c7",magenta:"#fae4fc",red:"#d0679d",yellow:"#fffac2"};function be(){let e=Be(Object.values(Fe)),t=f();(t==="yarn"||t==="pnpm")&&console.log(""),console.log(e.multiline(F))}import{execSync as He}from"child_process";import Ke from"https";function ve(e){let t=P();t.includes("beta")?(s.warn(" You are using a beta version of create-tnt-stack."),s.warn(" Please report any bugs you encounter.")):t!==e&&(s.warn(" You are using an outdated version of create-tnt-stack."),s.warn(" Your version:",t+".","Latest version in the npm registry:",e),s.warn(" Please run the CLI with @latest to get the latest updates.")),console.log("")}function Ye(){return new Promise((e,t)=>{Ke.get("https://registry.npmjs.org/-/package/tnt-stack/dist-tags",n=>{if(n.statusCode===200){let a="";n.on("data",i=>a+=i),n.on("end",()=>{e(JSON.parse(a).latest)})}else t()}).on("error",()=>{t()})})}var _e=()=>Ye().catch(()=>{try{return He("npm view create-tnt-stack version").toString().trim()}catch{return null}});async function Xe(){let e=await _e(),t=f();be(),e&&ve(e);let{appName:n,databaseProvider:a,flags:{noGit:i,noInstall:o,importAlias:r},packages:l}=await ae(),c=ee(l),[d,m]=ye(n),g=await re({projectName:m,scopedAppName:d,packages:c,noInstall:o,databaseProvider:a}),k=ke.readJSONSync(we.join(g,"package.json"));if(k.name=d,k.ctntaMetadata={initVersion:P()},t!=="bun"){let{stdout:D}=await Qe(t,["-v"],{cwd:g});k.packageManager=`${t}@${D.trim()}`}ke.writeJSONSync(we.join(g,"package.json"),k,{spaces:2}),r!=="@/"&&ue(g,r),o||await fe({projectDir:g}),i||await ce(g),await de({projectDir:g,projectName:m,packages:c,noInstall:o,databaseProvider:a}),process.exit(0)}Xe().catch(e=>{s.error("Aborting installation..."),e instanceof Error?s.error(e):(s.error("An unknown error occurred. Please open an issue on GitHub with the below:"),console.log(e)),process.exit(1)});
|