@thinhnguyencth1204/nextcli 0.6.1 → 0.8.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.
- package/README.md +68 -47
- package/dist/cli.js +1002 -753
- package/package.json +6 -2
- package/templates/{next-base/src/lib/axios-instance.ts → features/api/src/lib/api/axios.ts} +7 -2
- package/templates/{next-base/src/lib/api-response.ts → features/api/src/lib/api/response.ts} +1 -5
- package/templates/{next-base → features/auth}/src/app/(auth)/change-password/layout.tsx +1 -1
- package/templates/{next-base → features/auth}/src/app/(auth)/sign-in/layout.tsx +1 -1
- package/templates/{next-base → features/auth}/src/app/api/v1/auth/change-password/route.ts +3 -3
- package/templates/{next-base → features/auth}/src/app/api/v1/auth/login/route.ts +3 -3
- package/templates/{next-base → features/auth}/src/app/api/v1/auth/logout/route.ts +2 -2
- package/templates/{next-base → features/auth}/src/app/api/v1/auth/me/route.ts +2 -2
- package/templates/{next-base → features/auth}/src/app/api/v1/auth/refresh/route.ts +2 -2
- package/templates/{next-base → features/auth}/src/app/api/v1/users/[id]/route.ts +3 -3
- package/templates/{next-base → features/auth}/src/app/api/v1/users/route.ts +3 -3
- package/templates/{next-base → features/auth}/src/features/auth/components/account-panel.tsx +1 -1
- package/templates/{next-base → features/auth}/src/features/auth/components/change-password-form.tsx +1 -1
- package/templates/{next-base → features/auth}/src/features/auth/components/sign-in-form.tsx +2 -2
- package/templates/{next-base → features/auth}/src/features/users/services.ts +1 -1
- package/templates/{next-base → features/auth}/src/instrumentation.ts +1 -1
- package/templates/{next-base/src/lib → features/auth/src/lib/auth}/bootstrap.ts +2 -3
- package/templates/features/auth/src/lib/auth/index.ts +1 -0
- package/templates/{next-base/src/lib → features/auth/src/lib/auth}/rbac.ts +2 -5
- package/templates/{next-base/src/lib/auth.ts → features/auth/src/lib/auth/server.ts} +2 -1
- package/templates/{next-base → features/auth}/src/lib/constants.ts +3 -0
- package/templates/features/chat/src/app/api/v1/chat/route.ts +1 -1
- package/templates/features/chat/src/features/chat/api/use-chat-history.ts +1 -1
- package/templates/features/chat/src/features/chat/api/use-send-message.ts +1 -1
- package/templates/{next-base → features/dashboard}/src/app/(dashboard)/layout.tsx +1 -1
- package/templates/features/dashboard/src/app/page.tsx +5 -0
- package/templates/{next-base → features/dashboard}/src/components/layout/private/nav-user.tsx +1 -1
- package/templates/{next-base → features/database}/prisma/schema.prisma +0 -12
- package/templates/{next-base → features/database}/prisma.config.ts +2 -2
- package/templates/features/database/src/lib/prisma.ts +23 -0
- package/templates/{next-base → features/example}/src/app/api/v1/example/route.ts +2 -2
- package/templates/{next-base → features/example}/src/example/api/use-example.ts +1 -1
- package/templates/{next-base → features/example}/src/example/api/use-mutations.ts +1 -1
- package/templates/{next-base → features/example}/src/example/services.ts +1 -1
- package/templates/features/i18n/next.config.ts +17 -0
- package/templates/features/i18n/src/app/layout.tsx +42 -0
- package/templates/features/supabase/src/lib/supabase/rich-text-image-sync.ts +28 -0
- package/templates/next-base/.env +0 -14
- package/templates/next-base/.env.development +0 -14
- package/templates/next-base/.env.example +0 -14
- package/templates/next-base/PROJECT_STRUCTURE.md +43 -54
- package/templates/next-base/SETUP.md +12 -60
- package/templates/next-base/bun.lock +59 -397
- package/templates/next-base/next-env.d.ts +1 -1
- package/templates/next-base/next.config.ts +1 -4
- package/templates/next-base/nextcli.json +3 -3
- package/templates/next-base/package.json +6 -21
- package/templates/next-base/src/app/blog-demo/page.tsx +9 -0
- package/templates/next-base/src/app/globals.css +57 -0
- package/templates/next-base/src/app/layout.tsx +6 -14
- package/templates/next-base/src/app/page.tsx +25 -2
- package/templates/next-base/src/components/rich-text/adapters/textarea-field.tsx +50 -0
- package/templates/next-base/src/components/rich-text/client-only.tsx +23 -0
- package/templates/next-base/src/components/rich-text/editor-field.tsx +62 -0
- package/templates/next-base/src/components/rich-text/examples/blog-rich-text-demo.tsx +218 -0
- package/templates/next-base/src/components/rich-text/index.ts +11 -0
- package/templates/next-base/src/components/rich-text/lexical/extension.ts +37 -0
- package/templates/next-base/src/components/rich-text/lexical/nodes/image-node.tsx +187 -0
- package/templates/next-base/src/components/rich-text/lexical/plugins/image-plugin.tsx +40 -0
- package/templates/next-base/src/components/rich-text/lexical/plugins/initial-state-plugin.tsx +26 -0
- package/templates/next-base/src/components/rich-text/lexical/plugins/on-change-plugin.tsx +26 -0
- package/templates/next-base/src/components/rich-text/lexical/plugins/toolbar-plugin.tsx +190 -0
- package/templates/next-base/src/components/rich-text/lexical/rich-text-editor.tsx +121 -0
- package/templates/next-base/src/components/rich-text/lexical/theme.ts +18 -0
- package/templates/next-base/src/components/rich-text/rich-text-renderer.tsx +72 -0
- package/templates/next-base/src/components/rich-text/types.ts +60 -0
- package/templates/next-base/src/hooks/index.ts +1 -1
- package/templates/next-base/src/lib/rich-text/default-image-removal.ts +10 -0
- package/templates/next-base/src/lib/rich-text/image-urls.ts +41 -0
- package/templates/next-base/src/lib/rich-text/index.ts +12 -0
- package/templates/next-base/src/lib/rich-text/supabase-url.ts +67 -0
- package/templates/next-base/src/lib/rich-text/sync-removed-images.ts +48 -0
- package/templates/next-base/src/types/index.ts +0 -2
- package/templates/next-base/tsconfig.tsbuildinfo +1 -0
- package/templates/next-base/prisma/migrations/20260612000000_init/migration.sql +0 -104
- package/templates/next-base/prisma/migrations/migration_lock.toml +0 -3
- package/templates/next-base/src/app/(auth)/.gitkeep +0 -1
- /package/templates/{next-base → features/api}/src/components/providers/query-provider.tsx +0 -0
- /package/templates/{next-base/src/lib → features/api/src/lib/api}/token-store.ts +0 -0
- /package/templates/{next-base → features/auth}/messages/vi/auth.json +0 -0
- /package/templates/{next-base/prisma/migrations → features/auth/src/app/(auth)}/.gitkeep +0 -0
- /package/templates/{next-base → features/auth}/src/app/(auth)/change-password/page.tsx +0 -0
- /package/templates/{next-base → features/auth}/src/app/(auth)/layout.tsx +0 -0
- /package/templates/{next-base → features/auth}/src/app/(auth)/sign-in/page.tsx +0 -0
- /package/templates/{next-base → features/auth}/src/app/api/auth/[...all]/route.ts +0 -0
- /package/templates/{next-base → features/auth}/src/features/auth/validations.ts +0 -0
- /package/templates/{next-base → features/auth}/src/features/users/validations.ts +0 -0
- /package/templates/{next-base/src/lib/auth-client.ts → features/auth/src/lib/auth/client.ts} +0 -0
- /package/templates/{next-base/src/lib/auth-cookies.ts → features/auth/src/lib/auth/cookies.ts} +0 -0
- /package/templates/{next-base → features/dashboard}/src/app/(dashboard)/account/page.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/app/(dashboard)/dashboard/page.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/components/layout/private/app-sidebar.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/components/layout/private/dashboard-layout.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/components/layout/private/nav-sidebar.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-column-header.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-filter-list.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-pagination.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-skeleton.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-toolbar.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-view-options.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/components/ui/sidebar.tsx +0 -0
- /package/templates/{next-base → features/dashboard}/src/data/sidebar-modules.ts +0 -0
- /package/templates/{next-base → features/dashboard}/src/hooks/table/use-data-table.ts +0 -0
- /package/templates/{next-base → features/dashboard}/src/hooks/use-mobile.ts +0 -0
- /package/templates/{next-base → features/dashboard}/src/types/data-table.ts +0 -0
- /package/templates/{next-base/src/lib → features/database/src/lib/db}/prisma.ts +0 -0
- /package/templates/{next-base → features/example}/messages/vi/example.json +0 -0
- /package/templates/{next-base → features/example}/src/app/(dashboard)/example/page.tsx +0 -0
- /package/templates/{next-base → features/example}/src/example/components/example-table.tsx +0 -0
- /package/templates/{next-base → features/example}/src/example/validations.ts +0 -0
- /package/templates/{next-base → features/i18n}/messages/vi/common.json +0 -0
- /package/templates/{next-base → features/i18n}/src/components/layout/private/locale-switcher.tsx +0 -0
- /package/templates/{next-base → features/i18n}/src/i18n/config.ts +0 -0
- /package/templates/{next-base → features/i18n}/src/i18n/namespaces.ts +0 -0
- /package/templates/{next-base → features/i18n}/src/i18n/request.ts +0 -0
- /package/templates/{next-base → features/supabase}/src/lib/supabase/client.ts +0 -0
- /package/templates/{next-base → features/supabase}/src/lib/supabase/storage-config.ts +0 -0
- /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,49 @@ 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 (
|
|
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
|
-
|
|
35
|
+
**Default output is minimal:** Next.js shell, branding, theme, UI primitives, and Lexical rich text adapters only. Database, auth, dashboard, and other stacks are added only when selected.
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
## Rich text (base)
|
|
38
|
+
|
|
39
|
+
All generated projects include Lexical rich text building blocks:
|
|
40
|
+
|
|
41
|
+
- `EditorField` — swappable `textarea` or `lexical` adapter for forms
|
|
42
|
+
- `RichTextRenderer` — read-only playback of Lexical JSON from API data
|
|
43
|
+
- Toolbar: bold/italic/underline, emoji picker, image URL insertion
|
|
44
|
+
- Demo page: `/blog-demo`
|
|
45
|
+
|
|
46
|
+
Lexical content is stored as JSON (`SerializedEditorState`). With the `supabase` module, removed Supabase-managed image URLs trigger storage cleanup via `syncRemovedSupabaseRichTextImages`.
|
|
47
|
+
|
|
48
|
+
Available during `create` and `add module`:
|
|
49
|
+
|
|
50
|
+
| Module | Adds |
|
|
51
|
+
| ------------------- | ------------------------------------------------------------- |
|
|
52
|
+
| `database` | Prisma schema, client, `DATABASE_URL`, db scripts |
|
|
53
|
+
| `supabase` | Supabase browser client + Storage helpers |
|
|
54
|
+
| `auth` | Better Auth, sign-in pages, user APIs, bootstrap admin |
|
|
55
|
+
| `api` | Axios client, API envelope helpers, React Query provider |
|
|
56
|
+
| `i18n` | next-intl config, messages, locale switcher (auto-adds `api`) |
|
|
57
|
+
| `dashboard` | Protected dashboard shell, sidebar, data-table UI |
|
|
58
|
+
| `example` | Starter CRUD demo + `Example` Prisma model |
|
|
59
|
+
| `chat` | Chat routes, hooks, Prisma chat models (+ auto deps) |
|
|
60
|
+
| `supabase-realtime` | Realtime channel helpers (+ auto `supabase`) |
|
|
61
|
+
| `seo` | robots/sitemap/JSON-LD helpers |
|
|
62
|
+
| `email` | Email helper + React Email templates (SMTP or Resend) |
|
|
63
|
+
|
|
64
|
+
Module dependencies are auto-added (e.g. `auth` → `database`, `dashboard` → `auth` + `api` + `i18n`, `chat` → `database` + `supabase-realtime` + `supabase`).
|
|
65
|
+
|
|
66
|
+
## Auth module (`auth`)
|
|
67
|
+
|
|
68
|
+
When selected, generated projects include:
|
|
38
69
|
|
|
39
70
|
- Better Auth + Prisma adapter with JWT + username plugins
|
|
40
71
|
- username/password sign-in (`/sign-in`) and forced password change (`/change-password`)
|
|
41
|
-
- default bootstrap user `admin` / `
|
|
72
|
+
- default bootstrap user `admin` / `admin1234` (must change password on first login)
|
|
42
73
|
- hierarchical RBAC (`Role.level`) and user CRUD under `/api/v1/users`
|
|
43
74
|
- account sample page (`/account`)
|
|
44
75
|
- auth API wrappers:
|
|
@@ -48,7 +79,7 @@ Generated projects now include:
|
|
|
48
79
|
- `GET /api/v1/auth/me`
|
|
49
80
|
- `POST /api/v1/auth/change-password`
|
|
50
81
|
|
|
51
|
-
Axios setup
|
|
82
|
+
Axios setup (`api` module):
|
|
52
83
|
|
|
53
84
|
- `publicApi`: public calls
|
|
54
85
|
- `protectedApi`: bearer token calls with 401 refresh queue + retry
|
|
@@ -63,18 +94,18 @@ Project-owned routes under `/api/v1/*` use a unified envelope:
|
|
|
63
94
|
- Error:
|
|
64
95
|
- `{ success: false, error: { code, message, details? }, timestamp, requestId? }`
|
|
65
96
|
|
|
66
|
-
This is powered by `src/lib/api
|
|
97
|
+
This is powered by `src/lib/api/response.ts` when the `api` module is enabled.
|
|
67
98
|
The Better Auth passthrough route `/api/auth/[...all]` remains unwrapped.
|
|
68
99
|
|
|
69
100
|
## Command: add feature
|
|
70
101
|
|
|
71
|
-
Run inside a generated project root:
|
|
102
|
+
Run inside a generated project root (requires `database` and `api` for full CRUD wiring):
|
|
72
103
|
|
|
73
104
|
```bash
|
|
74
105
|
node ../dist/cli.js add feature orders
|
|
75
106
|
```
|
|
76
107
|
|
|
77
|
-
`add feature`
|
|
108
|
+
`add feature` creates:
|
|
78
109
|
|
|
79
110
|
- `src/features/<feature>/api/use-<feature>.ts`
|
|
80
111
|
- `src/features/<feature>/components/`
|
|
@@ -92,27 +123,20 @@ node ../dist/cli.js add module
|
|
|
92
123
|
|
|
93
124
|
Module copy is non-destructive: existing files are kept and reported as skipped conflicts.
|
|
94
125
|
|
|
95
|
-
Interactive multiselect shows available module catalog:
|
|
96
|
-
|
|
97
|
-
- `chat`
|
|
98
|
-
- `supabase-realtime`
|
|
99
|
-
- `seo`
|
|
100
|
-
- `email`
|
|
101
|
-
|
|
102
126
|
Non-interactive example:
|
|
103
127
|
|
|
104
128
|
```bash
|
|
105
|
-
node ../dist/cli.js add module --module
|
|
129
|
+
node ../dist/cli.js add module --module database --module auth --module dashboard --yes
|
|
106
130
|
```
|
|
107
131
|
|
|
108
|
-
|
|
109
|
-
`resend` is
|
|
132
|
+
`--module supabase` installs the Supabase client + Storage module.
|
|
133
|
+
`resend` is handled by the `email` module (legacy `--module resend` maps to `email` with provider `resend`).
|
|
110
134
|
|
|
111
135
|
When `email` is selected, CLI asks for provider (`resend` or `smtp`) and only merges env keys/dependencies for that provider.
|
|
112
136
|
|
|
113
137
|
## Command: add auth-provider
|
|
114
138
|
|
|
115
|
-
Enable social auth providers after
|
|
139
|
+
Enable social auth providers after the `auth` module is installed:
|
|
116
140
|
|
|
117
141
|
```bash
|
|
118
142
|
node ../dist/cli.js add auth-provider
|
|
@@ -131,13 +155,13 @@ node ../dist/cli.js add auth-provider --provider google --provider facebook --ye
|
|
|
131
155
|
|
|
132
156
|
This command:
|
|
133
157
|
|
|
134
|
-
- updates `src/lib/auth.ts` provider block
|
|
158
|
+
- updates `src/lib/auth/server.ts` provider block
|
|
135
159
|
- merges provider env keys into `.env`, `.env.example`, and `.env.development`
|
|
136
160
|
- runs Better Auth schema generation helper (with install prompt if CLI is missing in interactive mode)
|
|
137
161
|
|
|
138
162
|
## Command: migrate
|
|
139
163
|
|
|
140
|
-
Run Prisma migration script automatically from project root:
|
|
164
|
+
Run Prisma migration script automatically from project root (requires `database` module):
|
|
141
165
|
|
|
142
166
|
```bash
|
|
143
167
|
node ../dist/cli.js migrate
|
|
@@ -148,37 +172,35 @@ Optional flags:
|
|
|
148
172
|
- `--name <migration-name>`: set migration name manually
|
|
149
173
|
- `--skip-generate`: pass through to `prisma migrate dev --skip-generate`
|
|
150
174
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
```bash
|
|
154
|
-
node ../dist/cli.js migrate --name init_auth --skip-generate
|
|
155
|
-
```
|
|
175
|
+
## Generated stack (when modules selected)
|
|
156
176
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
-
|
|
160
|
-
-
|
|
161
|
-
-
|
|
162
|
-
-
|
|
163
|
-
-
|
|
164
|
-
-
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
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
|
|
177
|
+
- Next.js App Router + TypeScript (base)
|
|
178
|
+
- Better Auth + Prisma (`database` + `auth`)
|
|
179
|
+
- Supabase client + Storage (`supabase`)
|
|
180
|
+
- Axios + React Query (`api`)
|
|
181
|
+
- next-intl (`i18n`)
|
|
182
|
+
- Dashboard shell + TanStack Table (`dashboard`)
|
|
183
|
+
- shadcn-style shared UI folder (base)
|
|
184
|
+
- Zod validation (base)
|
|
185
|
+
- Sonner notifications (base)
|
|
186
|
+
- Lexical rich text editor + renderer (base)
|
|
187
|
+
- Optional: chat, supabase-realtime, seo, email
|
|
173
188
|
|
|
174
189
|
## Template structure
|
|
175
190
|
|
|
176
|
-
|
|
191
|
+
Minimal base template:
|
|
177
192
|
|
|
178
193
|
- `templates/next-base`
|
|
179
194
|
|
|
180
195
|
Optional module templates:
|
|
181
196
|
|
|
197
|
+
- `templates/features/database`
|
|
198
|
+
- `templates/features/supabase`
|
|
199
|
+
- `templates/features/auth`
|
|
200
|
+
- `templates/features/api`
|
|
201
|
+
- `templates/features/i18n`
|
|
202
|
+
- `templates/features/dashboard`
|
|
203
|
+
- `templates/features/example`
|
|
182
204
|
- `templates/features/chat`
|
|
183
205
|
- `templates/features/supabase-realtime`
|
|
184
206
|
- `templates/features/seo`
|
|
@@ -189,10 +211,9 @@ Optional module templates:
|
|
|
189
211
|
Chatbox Prisma entities are appended only when you add the `chat` module
|
|
190
212
|
(during `create` or via `add module --module chat`).
|
|
191
213
|
|
|
192
|
-
When chat is selected, NexTCLI auto-adds `supabase-realtime`
|
|
214
|
+
When chat is selected, NexTCLI auto-adds `database`, `supabase-realtime`, and `supabase` when missing.
|
|
193
215
|
|
|
194
|
-
The generated chat schema is provider-agnostic
|
|
195
|
-
WebSocket, Pusher, or any transport later without redesigning data:
|
|
216
|
+
The generated chat schema is provider-agnostic:
|
|
196
217
|
|
|
197
218
|
- `ChatConversation`
|
|
198
219
|
- `ChatParticipant`
|