create-better-nest 0.0.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 ADDED
@@ -0,0 +1,59 @@
1
+ # create-better-nest
2
+
3
+ The ultimate CLI tool for scaffolding modern, production-ready NestJS applications. Whether you need a simple backend or a full-stack monorepo with end-to-end type safety, `create-better-nest` has you covered.
4
+
5
+ ## ✨ Features
6
+
7
+ - 🏗️ **Three Powerful Templates:**
8
+ - **Monorepo (oRPC):** The cutting edge. NestJS + Next.js with complete type safety from backend to frontend using oRPC.
9
+ - **Monorepo (Basic):** A solid foundation using Turbo, NestJS, and Next.js.
10
+ - **Standalone Backend:** A clean, pre-configured NestJS setup with Prisma, Swagger, and Docker.
11
+ - 🚀 **Modern Tooling:** Pre-configured with `pnpm`, `Turborepo`, `Prisma`, `Zod`, and `Better Auth`.
12
+ - 🛡️ **Best Practices:** Strict TypeScript configs, ESLint, and organized project structures out of the box.
13
+
14
+ ## 🚀 Quick Start
15
+
16
+ Run the magic command:
17
+
18
+ ```bash
19
+ npm create better-nest@latest
20
+ ```
21
+
22
+ Follow the interactive prompts to choose your preferred architecture and project name.
23
+
24
+ ## 📦 What you get
25
+
26
+ ### 1. Monorepo (oRPC)
27
+ Perfect for teams wanting tight integration between backend and frontend.
28
+ - **Stack:** NestJS, Next.js, Turborepo, oRPC.
29
+ - **Highlights:** Define your API contract once, and get fully typed clients on the frontend automatically.
30
+
31
+ ### 2. Monorepo (Basic)
32
+ The industry standard for full-stack TypeScript.
33
+ - **Stack:** NestJS, Next.js, Turborepo.
34
+ - **Highlights:** Shared UI libraries, shared types, and shared ESLint configs.
35
+
36
+ ### 3. Standalone Backend
37
+ For when you just need a powerful API.
38
+ - **Stack:** NestJS, Prisma, Swagger.
39
+ - **Highlights:** Clean architecture, Docker-ready, and set up for scale.
40
+
41
+ ## 🔧 Requirements
42
+
43
+ - Node.js >= 18
44
+ - pnpm (The generated projects rely on pnpm workspaces)
45
+
46
+ ## 🤝 Contributing
47
+
48
+ We welcome contributions! This repository is a monorepo containing the CLI tool and the templates.
49
+
50
+ 1. Clone the repo
51
+ 2. Run `pnpm install`
52
+ 3. Test the CLI locally:
53
+ ```bash
54
+ pnpm --filter create-better-nest cli
55
+ ```
56
+
57
+ ## 📄 License
58
+
59
+ MIT
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import{intro as u,outro as h,text as v,select as g,isCancel as m,cancel as n,spinner as y}from"@clack/prompts";import{program as d}from"commander";import o from"picocolors";import w from"tiged";import f from"fs-extra";import b from"path";import{execSync as S}from"child_process";async function j(){d.name("better-nest").description("CLI to scaffold better NestJS applications").version("0.0.1"),d.parse(),u(o.bgCyan(o.black(" better-nest ")));let a=await v({message:"What is the name of your project?",placeholder:"my-nest-app",defaultValue:"my-nest-app"});m(a)&&(n("Operation cancelled."),process.exit(0));let s=await g({message:"Select the architecture:",options:[{value:"monorepo",label:"Monorepo"},{value:"standalone",label:"Standalone Backend"}]});m(s)&&(n("Operation cancelled."),process.exit(0));let i="basic";s==="monorepo"&&(i=await g({message:"Select the monorepo variant:",options:[{value:"basic",label:"Basic (Standard)"},{value:"orpc",label:"With oRPC"}]}),m(i)&&(n("Operation cancelled."),process.exit(0)));let e=y();e.start("Scaffolding your project...");let r="github:AnasX7/better-nest/templates";s==="monorepo"?i==="orpc"?r+="/monorepo-orpc":r+="/monorepo-basic":r+="/single-backend";try{let t=w(r,{disableCache:!0,force:!0,verbose:!1}),c=b.resolve(process.cwd(),a);await t.clone(c),e.message("Configuring project...");let p=b.join(c,"package.json");if(await f.pathExists(p)){let l=await f.readJson(p);l.name=a,await f.writeJson(p,l,{spaces:2})}e.message("Initializing git repository...");try{S("git init",{cwd:c,stdio:"ignore"})}catch{}e.stop("Scaffolding complete!"),h(`You're all set! To get started, run:
3
+
4
+ ${o.green(`cd ${a}`)}
5
+ ${o.green("pnpm install")}
6
+ ${o.green("pnpm dev")}
7
+ `)}catch(t){e.stop("Scaffolding failed."),n(`Error: ${t instanceof Error?t.message:String(t)}`),process.exit(1)}}j().catch(console.error);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport {\n intro,\n outro,\n text,\n select,\n isCancel,\n cancel,\n spinner,\n} from '@clack/prompts'\nimport { program } from 'commander'\nimport pc from 'picocolors'\nimport tiged from 'tiged'\nimport fs from 'fs-extra'\nimport path from 'path'\nimport { execSync } from 'child_process'\n\nasync function main() {\n program\n .name('better-nest')\n .description('CLI to scaffold better NestJS applications')\n .version('0.0.1')\n\n program.parse()\n\n intro(pc.bgCyan(pc.black(' better-nest ')))\n\n const projectName = await text({\n message: 'What is the name of your project?',\n placeholder: 'my-nest-app',\n defaultValue: 'my-nest-app',\n })\n\n if (isCancel(projectName)) {\n cancel('Operation cancelled.')\n process.exit(0)\n }\n\n const architecture = await select({\n message: 'Select the architecture:',\n options: [\n { value: 'monorepo', label: 'Monorepo' },\n { value: 'standalone', label: 'Standalone Backend' },\n ],\n })\n\n if (isCancel(architecture)) {\n cancel('Operation cancelled.')\n process.exit(0)\n }\n\n let variant: string | symbol = 'basic'\n\n if (architecture === 'monorepo') {\n variant = await select({\n message: 'Select the monorepo variant:',\n options: [\n { value: 'basic', label: 'Basic (Standard)' },\n { value: 'orpc', label: 'With oRPC' },\n ],\n })\n\n if (isCancel(variant)) {\n cancel('Operation cancelled.')\n process.exit(0)\n }\n }\n\n const s = spinner()\n s.start('Scaffolding your project...')\n\n let templatePath = 'github:AnasX7/better-nest/templates'\n\n if (architecture === 'monorepo') {\n if (variant === 'orpc') {\n templatePath += '/monorepo-orpc'\n } else {\n templatePath += '/monorepo-basic'\n }\n } else {\n templatePath += '/single-backend'\n }\n\n try {\n const emitter = tiged(templatePath, {\n disableCache: true,\n force: true,\n verbose: false,\n })\n\n const projectDir = path.resolve(process.cwd(), projectName as string)\n await emitter.clone(projectDir)\n\n s.message('Configuring project...')\n\n const packageJsonPath = path.join(projectDir, 'package.json')\n if (await fs.pathExists(packageJsonPath)) {\n const pkg = await fs.readJson(packageJsonPath)\n pkg.name = projectName\n await fs.writeJson(packageJsonPath, pkg, { spaces: 2 })\n }\n\n s.message('Initializing git repository...')\n try {\n execSync('git init', { cwd: projectDir, stdio: 'ignore' })\n } catch (e) {\n // Ignore git init errors if git is not installed or configured\n }\n\n s.stop('Scaffolding complete!')\n\n outro(`You're all set! To get started, run:\n\n ${pc.green(`cd ${projectName}`)}\n ${pc.green('pnpm install')}\n ${pc.green('pnpm dev')}\n`)\n } catch (error) {\n s.stop('Scaffolding failed.')\n cancel(`Error: ${error instanceof Error ? error.message : String(error)}`)\n process.exit(1)\n }\n}\n\nmain().catch(console.error)\n"],"mappings":";AACA,OACE,SAAAA,EACA,SAAAC,EACA,QAAAC,EACA,UAAAC,EACA,YAAAC,EACA,UAAAC,EACA,WAAAC,MACK,iBACP,OAAS,WAAAC,MAAe,YACxB,OAAOC,MAAQ,aACf,OAAOC,MAAW,QAClB,OAAOC,MAAQ,WACf,OAAOC,MAAU,OACjB,OAAS,YAAAC,MAAgB,gBAEzB,eAAeC,GAAO,CACpBN,EACG,KAAK,aAAa,EAClB,YAAY,4CAA4C,EACxD,QAAQ,OAAO,EAElBA,EAAQ,MAAM,EAEdP,EAAMQ,EAAG,OAAOA,EAAG,MAAM,eAAe,CAAC,CAAC,EAE1C,IAAMM,EAAc,MAAMZ,EAAK,CAC7B,QAAS,oCACT,YAAa,cACb,aAAc,aAChB,CAAC,EAEGE,EAASU,CAAW,IACtBT,EAAO,sBAAsB,EAC7B,QAAQ,KAAK,CAAC,GAGhB,IAAMU,EAAe,MAAMZ,EAAO,CAChC,QAAS,2BACT,QAAS,CACP,CAAE,MAAO,WAAY,MAAO,UAAW,EACvC,CAAE,MAAO,aAAc,MAAO,oBAAqB,CACrD,CACF,CAAC,EAEGC,EAASW,CAA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qBAAqB,EAC5BZ,EAAO,UAAUkB,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CAAC,EAAE,EACzE,QAAQ,KAAK,CAAC,CAChB,CACF,CAEAV,EAAK,EAAE,MAAM,QAAQ,KAAK","names":["intro","outro","text","select","isCancel","cancel","spinner","program","pc","tiged","fs","path","execSync","main","projectName","architecture","variant","s","templatePath","emitter","projectDir","packageJsonPath","pkg","error"]}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "create-better-nest",
3
+ "version": "0.0.1",
4
+ "description": "A CLI tool for creating better NestJS applications",
5
+ "main": "./dist/index.js",
6
+ "bin": {
7
+ "better-nest": "./dist/index.js",
8
+ "create-better-nest": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md"
13
+ ],
14
+ "type": "module",
15
+ "scripts": {
16
+ "build": "tsup",
17
+ "prepublishOnly": "npm run build",
18
+ "dev": "tsx watch src/index.ts",
19
+ "cli": "tsx src/index.ts",
20
+ "start": "node dist/index.js",
21
+ "lint": "eslint .",
22
+ "dev:build": "tsup --watch --onSuccess \"node dist/index.js\""
23
+ },
24
+ "dependencies": {
25
+ "@clack/prompts": "^0.7.0",
26
+ "commander": "^11.1.0",
27
+ "fs-extra": "^11.2.0",
28
+ "picocolors": "^1.0.0",
29
+ "tiged": "^2.12.0"
30
+ },
31
+ "devDependencies": {
32
+ "@types/fs-extra": "^11.0.0",
33
+ "@types/node": "^20.0.0",
34
+ "tsup": "^8.0.0",
35
+ "tsx": "^4.19.3",
36
+ "typescript": "^5.0.0"
37
+ }
38
+ }