@thinhnguyencth1204/nextcli 0.6.1 → 0.7.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 (95) hide show
  1. package/README.md +58 -47
  2. package/dist/cli.js +1002 -753
  3. package/package.json +4 -2
  4. package/templates/{next-base/src/lib/axios-instance.ts → features/api/src/lib/api/axios.ts} +7 -2
  5. package/templates/{next-base/src/lib/api-response.ts → features/api/src/lib/api/response.ts} +1 -5
  6. package/templates/{next-base → features/auth}/src/app/(auth)/change-password/layout.tsx +1 -1
  7. package/templates/{next-base → features/auth}/src/app/(auth)/sign-in/layout.tsx +1 -1
  8. package/templates/{next-base → features/auth}/src/app/api/v1/auth/change-password/route.ts +3 -3
  9. package/templates/{next-base → features/auth}/src/app/api/v1/auth/login/route.ts +3 -3
  10. package/templates/{next-base → features/auth}/src/app/api/v1/auth/logout/route.ts +2 -2
  11. package/templates/{next-base → features/auth}/src/app/api/v1/auth/me/route.ts +2 -2
  12. package/templates/{next-base → features/auth}/src/app/api/v1/auth/refresh/route.ts +2 -2
  13. package/templates/{next-base → features/auth}/src/app/api/v1/users/[id]/route.ts +3 -3
  14. package/templates/{next-base → features/auth}/src/app/api/v1/users/route.ts +3 -3
  15. package/templates/{next-base → features/auth}/src/features/auth/components/account-panel.tsx +1 -1
  16. package/templates/{next-base → features/auth}/src/features/auth/components/change-password-form.tsx +1 -1
  17. package/templates/{next-base → features/auth}/src/features/auth/components/sign-in-form.tsx +2 -2
  18. package/templates/{next-base → features/auth}/src/features/users/services.ts +1 -1
  19. package/templates/{next-base → features/auth}/src/instrumentation.ts +1 -1
  20. package/templates/{next-base/src/lib → features/auth/src/lib/auth}/bootstrap.ts +2 -3
  21. package/templates/features/auth/src/lib/auth/index.ts +1 -0
  22. package/templates/{next-base/src/lib → features/auth/src/lib/auth}/rbac.ts +2 -5
  23. package/templates/{next-base/src/lib/auth.ts → features/auth/src/lib/auth/server.ts} +2 -1
  24. package/templates/{next-base → features/auth}/src/lib/constants.ts +3 -0
  25. package/templates/features/chat/src/app/api/v1/chat/route.ts +1 -1
  26. package/templates/features/chat/src/features/chat/api/use-chat-history.ts +1 -1
  27. package/templates/features/chat/src/features/chat/api/use-send-message.ts +1 -1
  28. package/templates/{next-base → features/dashboard}/src/app/(dashboard)/layout.tsx +1 -1
  29. package/templates/features/dashboard/src/app/page.tsx +5 -0
  30. package/templates/{next-base → features/dashboard}/src/components/layout/private/nav-user.tsx +1 -1
  31. package/templates/{next-base → features/database}/prisma/schema.prisma +0 -12
  32. package/templates/{next-base → features/database}/prisma.config.ts +2 -2
  33. package/templates/features/database/src/lib/prisma.ts +23 -0
  34. package/templates/{next-base → features/example}/src/app/api/v1/example/route.ts +2 -2
  35. package/templates/{next-base → features/example}/src/example/api/use-example.ts +1 -1
  36. package/templates/{next-base → features/example}/src/example/api/use-mutations.ts +1 -1
  37. package/templates/{next-base → features/example}/src/example/services.ts +1 -1
  38. package/templates/features/i18n/next.config.ts +17 -0
  39. package/templates/features/i18n/src/app/layout.tsx +42 -0
  40. package/templates/next-base/.env +0 -14
  41. package/templates/next-base/.env.development +0 -14
  42. package/templates/next-base/.env.example +0 -14
  43. package/templates/next-base/PROJECT_STRUCTURE.md +33 -55
  44. package/templates/next-base/SETUP.md +12 -60
  45. package/templates/next-base/bun.lock +17 -0
  46. package/templates/next-base/next.config.ts +1 -4
  47. package/templates/next-base/nextcli.json +3 -3
  48. package/templates/next-base/package.json +1 -21
  49. package/templates/next-base/src/app/layout.tsx +6 -14
  50. package/templates/next-base/src/app/page.tsx +25 -2
  51. package/templates/next-base/prisma/migrations/20260612000000_init/migration.sql +0 -104
  52. package/templates/next-base/prisma/migrations/migration_lock.toml +0 -3
  53. package/templates/next-base/src/app/(auth)/.gitkeep +0 -1
  54. /package/templates/{next-base → features/api}/src/components/providers/query-provider.tsx +0 -0
  55. /package/templates/{next-base/src/lib → features/api/src/lib/api}/token-store.ts +0 -0
  56. /package/templates/{next-base → features/auth}/messages/vi/auth.json +0 -0
  57. /package/templates/{next-base/prisma/migrations → features/auth/src/app/(auth)}/.gitkeep +0 -0
  58. /package/templates/{next-base → features/auth}/src/app/(auth)/change-password/page.tsx +0 -0
  59. /package/templates/{next-base → features/auth}/src/app/(auth)/layout.tsx +0 -0
  60. /package/templates/{next-base → features/auth}/src/app/(auth)/sign-in/page.tsx +0 -0
  61. /package/templates/{next-base → features/auth}/src/app/api/auth/[...all]/route.ts +0 -0
  62. /package/templates/{next-base → features/auth}/src/features/auth/validations.ts +0 -0
  63. /package/templates/{next-base → features/auth}/src/features/users/validations.ts +0 -0
  64. /package/templates/{next-base/src/lib/auth-client.ts → features/auth/src/lib/auth/client.ts} +0 -0
  65. /package/templates/{next-base/src/lib/auth-cookies.ts → features/auth/src/lib/auth/cookies.ts} +0 -0
  66. /package/templates/{next-base → features/dashboard}/src/app/(dashboard)/account/page.tsx +0 -0
  67. /package/templates/{next-base → features/dashboard}/src/app/(dashboard)/dashboard/page.tsx +0 -0
  68. /package/templates/{next-base → features/dashboard}/src/components/layout/private/app-sidebar.tsx +0 -0
  69. /package/templates/{next-base → features/dashboard}/src/components/layout/private/dashboard-layout.tsx +0 -0
  70. /package/templates/{next-base → features/dashboard}/src/components/layout/private/nav-sidebar.tsx +0 -0
  71. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-column-header.tsx +0 -0
  72. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-filter-list.tsx +0 -0
  73. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-pagination.tsx +0 -0
  74. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-skeleton.tsx +0 -0
  75. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-toolbar.tsx +0 -0
  76. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-view-options.tsx +0 -0
  77. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table.tsx +0 -0
  78. /package/templates/{next-base → features/dashboard}/src/components/ui/sidebar.tsx +0 -0
  79. /package/templates/{next-base → features/dashboard}/src/data/sidebar-modules.ts +0 -0
  80. /package/templates/{next-base → features/dashboard}/src/hooks/table/use-data-table.ts +0 -0
  81. /package/templates/{next-base → features/dashboard}/src/hooks/use-mobile.ts +0 -0
  82. /package/templates/{next-base → features/dashboard}/src/types/data-table.ts +0 -0
  83. /package/templates/{next-base/src/lib → features/database/src/lib/db}/prisma.ts +0 -0
  84. /package/templates/{next-base → features/example}/messages/vi/example.json +0 -0
  85. /package/templates/{next-base → features/example}/src/app/(dashboard)/example/page.tsx +0 -0
  86. /package/templates/{next-base → features/example}/src/example/components/example-table.tsx +0 -0
  87. /package/templates/{next-base → features/example}/src/example/validations.ts +0 -0
  88. /package/templates/{next-base → features/i18n}/messages/vi/common.json +0 -0
  89. /package/templates/{next-base → features/i18n}/src/components/layout/private/locale-switcher.tsx +0 -0
  90. /package/templates/{next-base → features/i18n}/src/i18n/config.ts +0 -0
  91. /package/templates/{next-base → features/i18n}/src/i18n/namespaces.ts +0 -0
  92. /package/templates/{next-base → features/i18n}/src/i18n/request.ts +0 -0
  93. /package/templates/{next-base → features/supabase}/src/lib/supabase/client.ts +0 -0
  94. /package/templates/{next-base → features/supabase}/src/lib/supabase/storage-config.ts +0 -0
  95. /package/templates/{next-base → features/supabase}/src/lib/supabase/storage.ts +0 -0
package/README.md CHANGED
@@ -17,7 +17,7 @@ node dist/cli.js --help
17
17
 
18
18
  ## Command: create
19
19
 
20
- Create a new project from the base template:
20
+ Create a new project from the minimal base template:
21
21
 
22
22
  ```bash
23
23
  node dist/cli.js create
@@ -27,18 +27,40 @@ This command is fully interactive:
27
27
 
28
28
  - enter project name
29
29
  - select package manager in CLI UI (`npm`, `pnpm`, `yarn`, `bun`)
30
- - multi-select optional modules (`chat`, `supabase-realtime`, `seo`, `email`)
30
+ - multi-select optional modules (see module list below)
31
31
  - confirm install step
32
32
  - normalizes project directory name into a safe project slug for generated `package.json` and env placeholders
33
33
  - ships `SETUP.md` and `PROJECT_STRUCTURE.md` in the generated project root
34
34
 
35
- ## Core auth in base template
35
+ **Default output is minimal:** Next.js shell, branding, theme, and UI primitives only. Database, auth, dashboard, and other stacks are added only when selected.
36
36
 
37
- Generated projects now include:
37
+ ## Optional modules
38
+
39
+ Available during `create` and `add module`:
40
+
41
+ | Module | Adds |
42
+ | ------------------- | ------------------------------------------------------------- |
43
+ | `database` | Prisma schema, client, `DATABASE_URL`, db scripts |
44
+ | `supabase` | Supabase browser client + Storage helpers |
45
+ | `auth` | Better Auth, sign-in pages, user APIs, bootstrap admin |
46
+ | `api` | Axios client, API envelope helpers, React Query provider |
47
+ | `i18n` | next-intl config, messages, locale switcher (auto-adds `api`) |
48
+ | `dashboard` | Protected dashboard shell, sidebar, data-table UI |
49
+ | `example` | Starter CRUD demo + `Example` Prisma model |
50
+ | `chat` | Chat routes, hooks, Prisma chat models (+ auto deps) |
51
+ | `supabase-realtime` | Realtime channel helpers (+ auto `supabase`) |
52
+ | `seo` | robots/sitemap/JSON-LD helpers |
53
+ | `email` | Email helper + React Email templates (SMTP or Resend) |
54
+
55
+ Module dependencies are auto-added (e.g. `auth` → `database`, `dashboard` → `auth` + `api` + `i18n`, `chat` → `database` + `supabase-realtime` + `supabase`).
56
+
57
+ ## Auth module (`auth`)
58
+
59
+ When selected, generated projects include:
38
60
 
39
61
  - Better Auth + Prisma adapter with JWT + username plugins
40
62
  - username/password sign-in (`/sign-in`) and forced password change (`/change-password`)
41
- - default bootstrap user `admin` / `admin` (must change password on first login)
63
+ - default bootstrap user `admin` / `admin1234` (must change password on first login)
42
64
  - hierarchical RBAC (`Role.level`) and user CRUD under `/api/v1/users`
43
65
  - account sample page (`/account`)
44
66
  - auth API wrappers:
@@ -48,7 +70,7 @@ Generated projects now include:
48
70
  - `GET /api/v1/auth/me`
49
71
  - `POST /api/v1/auth/change-password`
50
72
 
51
- Axios setup is split:
73
+ Axios setup (`api` module):
52
74
 
53
75
  - `publicApi`: public calls
54
76
  - `protectedApi`: bearer token calls with 401 refresh queue + retry
@@ -63,18 +85,18 @@ Project-owned routes under `/api/v1/*` use a unified envelope:
63
85
  - Error:
64
86
  - `{ success: false, error: { code, message, details? }, timestamp, requestId? }`
65
87
 
66
- This is powered by `src/lib/api-response.ts` in generated apps.
88
+ This is powered by `src/lib/api/response.ts` when the `api` module is enabled.
67
89
  The Better Auth passthrough route `/api/auth/[...all]` remains unwrapped.
68
90
 
69
91
  ## Command: add feature
70
92
 
71
- Run inside a generated project root:
93
+ Run inside a generated project root (requires `database` and `api` for full CRUD wiring):
72
94
 
73
95
  ```bash
74
96
  node ../dist/cli.js add feature orders
75
97
  ```
76
98
 
77
- `add feature` now always creates:
99
+ `add feature` creates:
78
100
 
79
101
  - `src/features/<feature>/api/use-<feature>.ts`
80
102
  - `src/features/<feature>/components/`
@@ -92,27 +114,20 @@ node ../dist/cli.js add module
92
114
 
93
115
  Module copy is non-destructive: existing files are kept and reported as skipped conflicts.
94
116
 
95
- Interactive multiselect shows available module catalog:
96
-
97
- - `chat`
98
- - `supabase-realtime`
99
- - `seo`
100
- - `email`
101
-
102
117
  Non-interactive example:
103
118
 
104
119
  ```bash
105
- node ../dist/cli.js add module --module seo --module supabase-realtime --yes
120
+ node ../dist/cli.js add module --module database --module auth --module dashboard --yes
106
121
  ```
107
122
 
108
- `supabase` is no longer an optional module; Supabase client, Storage helpers, and Supabase Postgres env placeholders are part of the base template.
109
- `resend` is now handled by the `email` module (legacy `--module resend` maps to `email` with provider `resend`).
123
+ `--module supabase` installs the Supabase client + Storage module.
124
+ `resend` is handled by the `email` module (legacy `--module resend` maps to `email` with provider `resend`).
110
125
 
111
126
  When `email` is selected, CLI asks for provider (`resend` or `smtp`) and only merges env keys/dependencies for that provider.
112
127
 
113
128
  ## Command: add auth-provider
114
129
 
115
- Enable social auth providers after project creation (not created by default):
130
+ Enable social auth providers after the `auth` module is installed:
116
131
 
117
132
  ```bash
118
133
  node ../dist/cli.js add auth-provider
@@ -131,13 +146,13 @@ node ../dist/cli.js add auth-provider --provider google --provider facebook --ye
131
146
 
132
147
  This command:
133
148
 
134
- - updates `src/lib/auth.ts` provider block
149
+ - updates `src/lib/auth/server.ts` provider block
135
150
  - merges provider env keys into `.env`, `.env.example`, and `.env.development`
136
151
  - runs Better Auth schema generation helper (with install prompt if CLI is missing in interactive mode)
137
152
 
138
153
  ## Command: migrate
139
154
 
140
- Run Prisma migration script automatically from project root:
155
+ Run Prisma migration script automatically from project root (requires `database` module):
141
156
 
142
157
  ```bash
143
158
  node ../dist/cli.js migrate
@@ -148,37 +163,34 @@ Optional flags:
148
163
  - `--name <migration-name>`: set migration name manually
149
164
  - `--skip-generate`: pass through to `prisma migrate dev --skip-generate`
150
165
 
151
- Example:
152
-
153
- ```bash
154
- node ../dist/cli.js migrate --name init_auth --skip-generate
155
- ```
166
+ ## Generated stack (when modules selected)
156
167
 
157
- ## Generated stack
158
-
159
- - Next.js App Router + TypeScript
160
- - Better Auth + Prisma adapter
161
- - Supabase as the default Postgres/Storage stack
162
- - Prisma ORM (`prisma/schema.prisma`, `prisma/migrations`)
163
- - Axios fetch wrapper
164
- - TanStack React Query
165
- - TanStack React Table
166
- - TanStack React Form (dependency included for form workflows)
167
- - shadcn-style shared UI folder
168
- - Zod validation
169
- - i18n base with `next-intl`
170
- - Sonner notifications
171
- - date-fns utility library
172
- - Optional modules: chat, supabase-realtime, seo, email
168
+ - Next.js App Router + TypeScript (base)
169
+ - Better Auth + Prisma (`database` + `auth`)
170
+ - Supabase client + Storage (`supabase`)
171
+ - Axios + React Query (`api`)
172
+ - next-intl (`i18n`)
173
+ - Dashboard shell + TanStack Table (`dashboard`)
174
+ - shadcn-style shared UI folder (base)
175
+ - Zod validation (base)
176
+ - Sonner notifications (base)
177
+ - Optional: chat, supabase-realtime, seo, email
173
178
 
174
179
  ## Template structure
175
180
 
176
- Base template lives in:
181
+ Minimal base template:
177
182
 
178
183
  - `templates/next-base`
179
184
 
180
185
  Optional module templates:
181
186
 
187
+ - `templates/features/database`
188
+ - `templates/features/supabase`
189
+ - `templates/features/auth`
190
+ - `templates/features/api`
191
+ - `templates/features/i18n`
192
+ - `templates/features/dashboard`
193
+ - `templates/features/example`
182
194
  - `templates/features/chat`
183
195
  - `templates/features/supabase-realtime`
184
196
  - `templates/features/seo`
@@ -189,10 +201,9 @@ Optional module templates:
189
201
  Chatbox Prisma entities are appended only when you add the `chat` module
190
202
  (during `create` or via `add module --module chat`).
191
203
 
192
- When chat is selected, NexTCLI auto-adds `supabase-realtime` if missing.
204
+ When chat is selected, NexTCLI auto-adds `database`, `supabase-realtime`, and `supabase` when missing.
193
205
 
194
- The generated chat schema is provider-agnostic so you can plug in Supabase Realtime,
195
- WebSocket, Pusher, or any transport later without redesigning data:
206
+ The generated chat schema is provider-agnostic:
196
207
 
197
208
  - `ChatConversation`
198
209
  - `ChatParticipant`