create-stackrjs 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +154 -0
  2. package/dist/index.js +1135 -0
  3. package/package.json +62 -0
  4. package/template/architectures/microservices/_gitignore +26 -0
  5. package/template/architectures/microservices/apps/web/Dockerfile +11 -0
  6. package/template/architectures/microservices/apps/web/next-env.d.ts +5 -0
  7. package/template/architectures/microservices/apps/web/next.config.mjs +4 -0
  8. package/template/architectures/microservices/apps/web/package.json +25 -0
  9. package/template/architectures/microservices/apps/web/src/app/account/page.tsx +56 -0
  10. package/template/architectures/microservices/apps/web/src/app/globals.css +3 -0
  11. package/template/architectures/microservices/apps/web/src/app/layout.tsx +16 -0
  12. package/template/architectures/microservices/apps/web/src/app/login/page.tsx +70 -0
  13. package/template/architectures/microservices/apps/web/src/app/page.tsx +33 -0
  14. package/template/architectures/microservices/apps/web/src/app/register/page.tsx +71 -0
  15. package/template/architectures/microservices/apps/web/src/lib/api.ts +15 -0
  16. package/template/architectures/microservices/apps/web/tsconfig.json +23 -0
  17. package/template/architectures/microservices/docker-compose.yml +45 -0
  18. package/template/architectures/microservices/gateway/nginx.conf +20 -0
  19. package/template/architectures/microservices/package.json +21 -0
  20. package/template/architectures/microservices/services/api/Dockerfile +11 -0
  21. package/template/architectures/microservices/services/api/package.json +34 -0
  22. package/template/architectures/microservices/services/api/prisma/schema.prisma +17 -0
  23. package/template/architectures/microservices/services/api/prisma.config.ts +17 -0
  24. package/template/architectures/microservices/services/api/src/auth.ts +22 -0
  25. package/template/architectures/microservices/services/api/src/db.ts +12 -0
  26. package/template/architectures/microservices/services/api/src/index.ts +22 -0
  27. package/template/architectures/microservices/services/api/src/routes/auth.ts +73 -0
  28. package/template/architectures/microservices/services/api/tsconfig.json +16 -0
  29. package/template/base/_eslintrc.json +3 -0
  30. package/template/base/_gitignore +24 -0
  31. package/template/base/_prettierrc.json +6 -0
  32. package/template/base/next-env.d.ts +5 -0
  33. package/template/base/next.config.mjs +4 -0
  34. package/template/base/package.json +27 -0
  35. package/template/base/src/app/globals.css +14 -0
  36. package/template/base/src/app/layout.tsx +16 -0
  37. package/template/base/src/app/page.tsx +10 -0
  38. package/template/base/tsconfig.json +23 -0
  39. package/template/extras/account-better-auth/src/server/account.ts +52 -0
  40. package/template/extras/account-clerk/src/server/account.ts +64 -0
  41. package/template/extras/account-nextauth/src/server/account.ts +59 -0
  42. package/template/extras/account-supabase/src/lib/supabase/admin.ts +14 -0
  43. package/template/extras/account-supabase/src/server/account.ts +65 -0
  44. package/template/extras/admin/src/app/admin/page.tsx +55 -0
  45. package/template/extras/auth-pages/src/app/account/page.tsx +37 -0
  46. package/template/extras/auth-pages/src/app/forgot-password/page.tsx +33 -0
  47. package/template/extras/auth-pages/src/app/login/page.tsx +32 -0
  48. package/template/extras/auth-pages/src/app/page.tsx +46 -0
  49. package/template/extras/auth-pages/src/app/register/page.tsx +36 -0
  50. package/template/extras/auth-pages/src/app/reset-password/page.tsx +49 -0
  51. package/template/extras/auth-pages/src/components/auth/ui.tsx +57 -0
  52. package/template/extras/auth-pages-drizzle/src/server/actions.ts +122 -0
  53. package/template/extras/auth-pages-mongoose/src/server/actions.ts +121 -0
  54. package/template/extras/auth-pages-prisma/src/server/actions.ts +117 -0
  55. package/template/extras/better-auth/prisma/schema.prisma +70 -0
  56. package/template/extras/better-auth/src/app/account/page.tsx +42 -0
  57. package/template/extras/better-auth/src/app/api/auth/[...all]/route.ts +5 -0
  58. package/template/extras/better-auth/src/app/login/page.tsx +42 -0
  59. package/template/extras/better-auth/src/app/register/page.tsx +44 -0
  60. package/template/extras/better-auth/src/components/auth/ui.tsx +58 -0
  61. package/template/extras/better-auth/src/lib/auth-client.ts +7 -0
  62. package/template/extras/better-auth/src/server/auth.ts +13 -0
  63. package/template/extras/clerk/middleware.ts +14 -0
  64. package/template/extras/clerk/src/app/account/page.tsx +30 -0
  65. package/template/extras/clerk/src/app/layout.tsx +19 -0
  66. package/template/extras/clerk/src/app/page.tsx +40 -0
  67. package/template/extras/clerk/src/app/sign-in/[[...sign-in]]/page.tsx +9 -0
  68. package/template/extras/clerk/src/app/sign-up/[[...sign-up]]/page.tsx +9 -0
  69. package/template/extras/dashboard/src/app/dashboard/page.tsx +48 -0
  70. package/template/extras/databases/mongodb/docker-compose.yml +13 -0
  71. package/template/extras/databases/mysql/docker-compose.yml +14 -0
  72. package/template/extras/databases/postgres/docker-compose.yml +15 -0
  73. package/template/extras/drizzle/mysql/drizzle.config.ts +9 -0
  74. package/template/extras/drizzle/mysql/src/server/db.ts +11 -0
  75. package/template/extras/drizzle/mysql/src/server/schema.ts +17 -0
  76. package/template/extras/drizzle/postgres/drizzle.config.ts +9 -0
  77. package/template/extras/drizzle/postgres/src/server/db.ts +11 -0
  78. package/template/extras/drizzle/postgres/src/server/schema.ts +20 -0
  79. package/template/extras/landing/src/app/page.tsx +53 -0
  80. package/template/extras/mongoose/src/server/db.ts +12 -0
  81. package/template/extras/mongoose/src/server/models.ts +25 -0
  82. package/template/extras/nextauth/middleware.ts +11 -0
  83. package/template/extras/nextauth/src/app/api/auth/[...nextauth]/route.ts +3 -0
  84. package/template/extras/nextauth/src/server/auth.config.ts +39 -0
  85. package/template/extras/nextauth/src/server/roles.ts +5 -0
  86. package/template/extras/nextauth/src/types/next-auth.d.ts +22 -0
  87. package/template/extras/nextauth-drizzle/src/server/auth.ts +44 -0
  88. package/template/extras/nextauth-mongoose/src/server/auth.ts +42 -0
  89. package/template/extras/nextauth-prisma/src/server/auth.ts +43 -0
  90. package/template/extras/prisma/base/prisma/schema.prisma +67 -0
  91. package/template/extras/prisma/base/prisma.config.ts +10 -0
  92. package/template/extras/prisma/mysql/src/server/db.ts +25 -0
  93. package/template/extras/prisma/postgres/src/server/db.ts +18 -0
  94. package/template/extras/shadcn/components.json +20 -0
  95. package/template/extras/shadcn/postcss.config.mjs +7 -0
  96. package/template/extras/shadcn/src/app/globals.css +59 -0
  97. package/template/extras/shadcn/src/components/ui/button.tsx +42 -0
  98. package/template/extras/shadcn/src/components/ui/card.tsx +54 -0
  99. package/template/extras/shadcn/src/components/ui/input.tsx +19 -0
  100. package/template/extras/shadcn/src/lib/utils.ts +7 -0
  101. package/template/extras/shadcn/tailwind.config.ts +71 -0
  102. package/template/extras/supabase/middleware.ts +13 -0
  103. package/template/extras/supabase/src/app/account/page.tsx +32 -0
  104. package/template/extras/supabase/src/app/login/page.tsx +47 -0
  105. package/template/extras/supabase/src/app/register/page.tsx +52 -0
  106. package/template/extras/supabase/src/components/auth/sign-out-button.tsx +25 -0
  107. package/template/extras/supabase/src/components/auth/ui.tsx +58 -0
  108. package/template/extras/supabase/src/lib/supabase/client.ts +9 -0
  109. package/template/extras/supabase/src/lib/supabase/middleware.ts +34 -0
  110. package/template/extras/supabase/src/lib/supabase/server.ts +29 -0
  111. package/template/extras/tailwind/postcss.config.mjs +7 -0
  112. package/template/extras/tailwind/src/app/globals.css +3 -0
  113. package/template/extras/tailwind/tailwind.config.ts +9 -0
package/README.md ADDED
@@ -0,0 +1,154 @@
1
+ # Stackr
2
+
3
+ Scaffold a **runnable** full-stack Next.js project in one command. Stackr assembles
4
+ a base Next.js app and composes feature "installers" (database, ORM, auth, styling,
5
+ pre-built interfaces) into a coherent, immediately bootable project.
6
+
7
+ ```bash
8
+ npm create stackrjs@latest my-app
9
+ ```
10
+
11
+ Published on npm as [`create-stackrjs`](https://www.npmjs.com/package/create-stackrjs). A
12
+ [web configurator](#web-configurator) lets you pick a stack and copy the exact command.
13
+
14
+ ## What you get
15
+
16
+ Stackr composes a single coherent, runnable stack from your choices:
17
+
18
+ | Dimension | Options |
19
+ | --------- | ------- |
20
+ | Architecture | Monolith (single Next.js App Router app, TypeScript strict) — or **microservices** (web + Hono API + nginx gateway, npm workspaces) |
21
+ | Database | PostgreSQL, MySQL or MongoDB (via bundled `docker-compose.yml`) |
22
+ | ORM | Prisma 7 or Drizzle (SQL), or Mongoose (MongoDB) |
23
+ | Auth | NextAuth / Auth.js v5, Better Auth, Clerk or Supabase Auth |
24
+ | Styling | Tailwind CSS or shadcn/ui |
25
+ | Interfaces | Auth portal (login / register / forgot / reset + `/account`), user dashboard, admin / back-office, landing page |
26
+
27
+ The generated app boots with:
28
+
29
+ ```bash
30
+ docker compose up -d
31
+ npm install
32
+ npx prisma migrate dev --name init
33
+ npm run dev
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ```bash
39
+ npm create stackrjs@latest [name] -- [options]
40
+ # or: npx create-stackrjs [name] [options]
41
+
42
+ --architecture <a> monolith | microservices
43
+ --database <db> postgres | mysql | mongodb
44
+ --orm <orm> prisma | drizzle | mongoose
45
+ --auth <auth> nextauth | better-auth | clerk | supabase
46
+ --styling <s> tailwind | shadcn (shadcn ships the full Tailwind stack)
47
+ --interfaces <list> auth-pages,dashboard,admin,landing
48
+ -y, --yes skip the wizard, use flags + defaults
49
+ --ci non-interactive: implies --yes --no-install --no-git
50
+ --no-install skip npm install
51
+ --no-git skip git init
52
+ ```
53
+
54
+ Run with no options for an interactive wizard (`@clack/prompts`).
55
+
56
+ ### Compatible by construction
57
+
58
+ The dimensions are linked, so you can't assemble an incompatible stack. Picking a
59
+ technology constrains the rest (MongoDB rules out Drizzle; Supabase Auth needs
60
+ Postgres; shadcn implies Tailwind). Incompatible flag combinations are rejected
61
+ with a clear message, and both the wizard and the [web configurator](#web-configurator)
62
+ grey out options that clash with your current choices or aren't generatable yet.
63
+ The catalogue + rules live in one place — `src/shared/registry.ts` — consumed by the
64
+ CLI and mirrored into the web app.
65
+
66
+ ## How it works
67
+
68
+ Stackr is **composition over templating**. A `template/base` Next.js app is copied,
69
+ then each selected installer (`src/installers/*`) contributes:
70
+
71
+ 1. files copied from `template/extras/<feature>` into the project,
72
+ 2. dependencies / scripts pushed onto a shared `package.json` draft,
73
+ 3. environment variables pushed onto a shared `.env` accumulator.
74
+
75
+ The orchestrator (`src/helpers/scaffoldProject.ts`) merges and writes everything once
76
+ at the end. Adding a new option = add a `template/extras/<x>` folder + an
77
+ `installers/<x>.ts` and register it — no engine changes. This is the
78
+ [create-t3-app](https://create.t3.gg/) model.
79
+
80
+ ## Web configurator
81
+
82
+ `web/` is a Next.js app (deployable to Vercel) that lets users pick a stack and copy the
83
+ matching `create-stackrjs` command (npm / pnpm / yarn / bun).
84
+
85
+ ```bash
86
+ cd web
87
+ npm install
88
+ npm run dev # http://localhost:3000
89
+ ```
90
+
91
+ The configurator reads the same option catalogue + compatibility rules as the CLI.
92
+ `web/src/lib/stack.ts` is a mirror of `src/shared/registry.ts` (the deployable Next
93
+ app imports no TypeScript from the engine); the `test/registry-sync.test.ts` suite
94
+ fails if the two ever drift, so the registry stays the single source of truth.
95
+
96
+ ## Develop Stackr
97
+
98
+ ```bash
99
+ npm install
100
+ npm run build # bundle the CLI with tsup -> dist/
101
+ npm run typecheck # type-check the engine
102
+ npm run smoke # generate every stack and verify each installs + builds
103
+ node dist/index.js demo --ci # try it locally
104
+ ```
105
+
106
+ ## Testing
107
+
108
+ [Vitest](https://vitest.dev) suites live in `test/` (engine) and `web/test/` (configurator):
109
+
110
+ ```bash
111
+ npm test # engine: flags, selections, package.json/env merge, installers,
112
+ # plus an integration test that scaffolds a project to a temp dir
113
+ npm run smoke # heavier: generate each stack (monolith, shadcn, microservices),
114
+ # then npm install, tsc and build the output
115
+ cd web && npm test # the command builder
116
+ ```
117
+
118
+ ## CI/CD & automated releases
119
+
120
+ Two GitHub Actions workflows:
121
+
122
+ - **`.github/workflows/ci.yml`** — on every push/PR: typecheck, test and build the CLI
123
+ (Node 18/20/22) and the web app.
124
+ - **`.github/workflows/release.yml`** — on push to `main`: runs the checks, then
125
+ [`semantic-release`](https://semantic-release.gitbook.io) versions, publishes to npm
126
+ (with provenance), tags, writes `CHANGELOG.md` and creates a GitHub Release —
127
+ **fully automatic, no manual version bumps**.
128
+
129
+ The version is derived from your **commit messages** ([Conventional Commits](https://www.conventionalcommits.org)):
130
+
131
+ | Commit prefix | Release |
132
+ | ------------- | ------- |
133
+ | `fix: ...` | patch (1.2.**3**) |
134
+ | `feat: ...` | minor (1.**3**.0) |
135
+ | `feat!: ...` or `BREAKING CHANGE:` in body | major (**2**.0.0) |
136
+ | `chore:`, `docs:`, `test:`, `refactor:` ... | no release |
137
+
138
+ ### One-time setup
139
+
140
+ 1. Create the repo on GitHub and push `main`.
141
+ 2. Add an **`NPM_TOKEN`** secret (npm → Access Tokens → *Automation* token) under
142
+ *Settings → Secrets and variables → Actions*. `GITHUB_TOKEN` is provided automatically.
143
+
144
+ That's it — from then on, just commit with the right prefix and merge to `main`. The
145
+ published tarball is limited to `dist/` + `template/` (`files` in `package.json`; verify
146
+ with `npm pack --dry-run`).
147
+
148
+ ## Roadmap
149
+
150
+ Every dimension above ships at least two generatable options today. Next up:
151
+ OAuth providers for the credentials stacks, third-party services (Stripe, Resend,
152
+ …), more API styles and additional architectures. Each new option is a
153
+ `template/extras/<x>` folder plus an `installers/<x>.ts` registered in
154
+ `src/shared/registry.ts` — the installer engine absorbs them without a rewrite.