@thinhnguyencth1204/nextcli 0.1.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 +197 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1439 -0
- package/package.json +43 -0
- package/templates/features/chat/src/app/api/v1/chat/route.ts +40 -0
- package/templates/features/chat/src/features/chat/api/use-chat-history.ts +18 -0
- package/templates/features/chat/src/features/chat/api/use-realtime-sync.ts +15 -0
- package/templates/features/chat/src/features/chat/api/use-send-message.ts +35 -0
- package/templates/features/chat/src/features/chat/components/ChatWidget.tsx +40 -0
- package/templates/features/chat/src/features/chat/services.ts +27 -0
- package/templates/features/seo/public/robots.txt +3 -0
- package/templates/features/seo/public/sitemap.xml +6 -0
- package/templates/features/seo/src/app/robots.ts +13 -0
- package/templates/features/seo/src/app/sitemap.ts +21 -0
- package/templates/features/seo/src/components/seo/json-ld.tsx +14 -0
- package/templates/features/supabase/src/lib/supabase/client.ts +9 -0
- package/templates/features/supabase/src/lib/supabase/storage-config.ts +69 -0
- package/templates/features/supabase/src/lib/supabase/storage.ts +167 -0
- package/templates/features/supabase-realtime/src/features/supabase-realtime/client.ts +9 -0
- package/templates/features/supabase-realtime/src/features/supabase-realtime/use-supabase-channel.ts +19 -0
- package/templates/next-base/.env +11 -0
- package/templates/next-base/.env.development +11 -0
- package/templates/next-base/.env.example +11 -0
- package/templates/next-base/eslint.config.mjs +20 -0
- package/templates/next-base/middleware.ts +10 -0
- package/templates/next-base/next-env.d.ts +4 -0
- package/templates/next-base/next.config.ts +7 -0
- package/templates/next-base/package.json +45 -0
- package/templates/next-base/prisma/migrations/.gitkeep +1 -0
- package/templates/next-base/prisma/schema.prisma +72 -0
- package/templates/next-base/prisma.config.ts +16 -0
- package/templates/next-base/src/app/(auth)/.gitkeep +1 -0
- package/templates/next-base/src/app/(auth)/sign-in/page.tsx +11 -0
- package/templates/next-base/src/app/(dashboard)/account/page.tsx +14 -0
- package/templates/next-base/src/app/(dashboard)/example/page.tsx +10 -0
- package/templates/next-base/src/app/api/auth/[...all]/route.ts +4 -0
- package/templates/next-base/src/app/api/v1/auth/login/route.ts +60 -0
- package/templates/next-base/src/app/api/v1/auth/logout/route.ts +28 -0
- package/templates/next-base/src/app/api/v1/auth/me/route.ts +26 -0
- package/templates/next-base/src/app/api/v1/auth/refresh/route.ts +32 -0
- package/templates/next-base/src/app/api/v1/example/route.ts +34 -0
- package/templates/next-base/src/app/layout.tsx +28 -0
- package/templates/next-base/src/app/page.tsx +21 -0
- package/templates/next-base/src/app/styles.css +12 -0
- package/templates/next-base/src/components/providers/query-provider.tsx +17 -0
- package/templates/next-base/src/components/ui/button.tsx +16 -0
- package/templates/next-base/src/example/api/use-example.ts +21 -0
- package/templates/next-base/src/example/api/use-mutations.ts +20 -0
- package/templates/next-base/src/example/components/example-table.tsx +66 -0
- package/templates/next-base/src/example/services.ts +9 -0
- package/templates/next-base/src/example/validations.ts +8 -0
- package/templates/next-base/src/features/auth/components/account-panel.tsx +62 -0
- package/templates/next-base/src/features/auth/components/sign-in-form.tsx +77 -0
- package/templates/next-base/src/features/auth/validations.ts +8 -0
- package/templates/next-base/src/hooks/index.ts +1 -0
- package/templates/next-base/src/i18n/request.ts +8 -0
- package/templates/next-base/src/lib/api-response.ts +49 -0
- package/templates/next-base/src/lib/auth-client.ts +7 -0
- package/templates/next-base/src/lib/auth-cookies.ts +15 -0
- package/templates/next-base/src/lib/auth.ts +20 -0
- package/templates/next-base/src/lib/axios-instance.ts +140 -0
- package/templates/next-base/src/lib/prisma.ts +13 -0
- package/templates/next-base/src/lib/token-store.ts +13 -0
- package/templates/next-base/src/types/index.ts +40 -0
- package/templates/next-base/src/utils/cn.ts +6 -0
- package/templates/next-base/tsconfig.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# NexTCLI
|
|
2
|
+
|
|
3
|
+
NexTCLI is an npm-installable CLI to scaffold outsource-ready Next.js projects with a consistent architecture, core integrations, and fast feature generation.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install
|
|
9
|
+
npm run build
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
For local execution:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node dist/cli.js --help
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Command: create
|
|
19
|
+
|
|
20
|
+
Create a new project from the base template:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
node dist/cli.js create my-nextjs-app
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
This command is interactive by default:
|
|
27
|
+
- select package manager in CLI UI (`npm`, `pnpm`, `yarn`, `bun`)
|
|
28
|
+
- multi-select optional modules (`chat`, `supabase`, `supabase-realtime`, `seo`)
|
|
29
|
+
- confirm install step
|
|
30
|
+
- normalizes project directory name into a safe project slug for generated `package.json` and env placeholders
|
|
31
|
+
|
|
32
|
+
### Non-interactive create options (for CI/automation)
|
|
33
|
+
|
|
34
|
+
- `--yes`: skip prompts and use defaults
|
|
35
|
+
- `--package-manager <npm|pnpm|yarn|bun>`: set package manager explicitly
|
|
36
|
+
- `--module <id...>`: preselect optional modules (repeat or comma-separated)
|
|
37
|
+
- `--install` / `--no-install`: force install behavior
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
node dist/cli.js create my-nextjs-app --yes --module supabase --module seo --no-install
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Core auth in base template
|
|
44
|
+
|
|
45
|
+
Generated projects now include:
|
|
46
|
+
- Better Auth + Prisma adapter with JWT plugin enabled
|
|
47
|
+
- email/password sign-in scaffold (`/sign-in`)
|
|
48
|
+
- account sample page (`/account`)
|
|
49
|
+
- auth API wrappers:
|
|
50
|
+
- `POST /api/v1/auth/login`
|
|
51
|
+
- `POST /api/v1/auth/refresh`
|
|
52
|
+
- `POST /api/v1/auth/logout`
|
|
53
|
+
- `GET /api/v1/auth/me`
|
|
54
|
+
|
|
55
|
+
Axios setup is split:
|
|
56
|
+
- `publicApi`: public calls
|
|
57
|
+
- `protectedApi`: bearer token calls with 401 refresh queue + retry
|
|
58
|
+
- refresh uses HttpOnly cookie strategy (`withCredentials: true`)
|
|
59
|
+
|
|
60
|
+
## API response standard
|
|
61
|
+
|
|
62
|
+
Project-owned routes under `/api/v1/*` use a unified envelope:
|
|
63
|
+
|
|
64
|
+
- Success:
|
|
65
|
+
- `{ success: true, data: T, meta: { timestamp, requestId?, pagination? } }`
|
|
66
|
+
- Error:
|
|
67
|
+
- `{ success: false, error: { code, message, details? }, timestamp, requestId? }`
|
|
68
|
+
|
|
69
|
+
This is powered by `src/lib/api-response.ts` in generated apps.
|
|
70
|
+
The Better Auth passthrough route `/api/auth/[...all]` remains unwrapped.
|
|
71
|
+
|
|
72
|
+
## Command: add feature
|
|
73
|
+
|
|
74
|
+
Run inside a generated project root:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
node ../dist/cli.js add feature orders
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`add feature` now always creates:
|
|
81
|
+
- `src/features/<feature>/api/use-<feature>.ts`
|
|
82
|
+
- `src/features/<feature>/components/`
|
|
83
|
+
- `src/features/<feature>/services.ts`
|
|
84
|
+
- `src/features/<feature>/validations.ts`
|
|
85
|
+
- `src/app/api/v1/<feature>/route.ts`
|
|
86
|
+
|
|
87
|
+
## Command: add module
|
|
88
|
+
|
|
89
|
+
Add optional modules after project initialization:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
node ../dist/cli.js add module
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Module copy is non-destructive: existing files are kept and reported as skipped conflicts.
|
|
96
|
+
|
|
97
|
+
Interactive multiselect shows available module catalog:
|
|
98
|
+
- `chat`
|
|
99
|
+
- `supabase`
|
|
100
|
+
- `supabase-realtime`
|
|
101
|
+
- `seo`
|
|
102
|
+
|
|
103
|
+
Non-interactive example:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
node ../dist/cli.js add module --module seo --module supabase --yes
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Command: add auth-provider
|
|
110
|
+
|
|
111
|
+
Enable social auth providers after project creation (not created by default):
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
node ../dist/cli.js add auth-provider
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Supported providers:
|
|
118
|
+
- `google`
|
|
119
|
+
- `facebook`
|
|
120
|
+
|
|
121
|
+
Non-interactive example:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
node ../dist/cli.js add auth-provider --provider google --provider facebook --yes
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
This command:
|
|
128
|
+
- updates `src/lib/auth.ts` provider block
|
|
129
|
+
- merges provider env keys into `.env` and `.env.example`
|
|
130
|
+
- runs Better Auth schema generation helper (with install prompt if CLI is missing in interactive mode)
|
|
131
|
+
|
|
132
|
+
## Command: migrate
|
|
133
|
+
|
|
134
|
+
Run Prisma migration script automatically from project root:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
node ../dist/cli.js migrate
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Optional flags:
|
|
141
|
+
- `--name <migration-name>`: set migration name manually
|
|
142
|
+
- `--skip-generate`: pass through to `prisma migrate dev --skip-generate`
|
|
143
|
+
|
|
144
|
+
Example:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
node ../dist/cli.js migrate --name init_auth --skip-generate
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Generated stack
|
|
151
|
+
|
|
152
|
+
- Next.js App Router + TypeScript
|
|
153
|
+
- Better Auth + Prisma adapter
|
|
154
|
+
- Prisma ORM (`prisma/schema.prisma`, `prisma/migrations`)
|
|
155
|
+
- Axios fetch wrapper
|
|
156
|
+
- TanStack React Query
|
|
157
|
+
- TanStack React Table
|
|
158
|
+
- TanStack React Form (dependency included for form workflows)
|
|
159
|
+
- shadcn-style shared UI folder
|
|
160
|
+
- Zod validation
|
|
161
|
+
- i18n base with `next-intl`
|
|
162
|
+
- Sonner notifications
|
|
163
|
+
- date-fns utility library
|
|
164
|
+
- Optional modules: chat, supabase, supabase-realtime, seo
|
|
165
|
+
|
|
166
|
+
## Template structure
|
|
167
|
+
|
|
168
|
+
Base template lives in:
|
|
169
|
+
|
|
170
|
+
- `templates/next-base`
|
|
171
|
+
|
|
172
|
+
Optional module templates:
|
|
173
|
+
|
|
174
|
+
- `templates/features/chat`
|
|
175
|
+
- `templates/features/supabase`
|
|
176
|
+
- `templates/features/supabase-realtime`
|
|
177
|
+
- `templates/features/seo`
|
|
178
|
+
|
|
179
|
+
## Realtime chat schema foundation
|
|
180
|
+
|
|
181
|
+
Chatbox Prisma entities are appended only when you add the `chat` module
|
|
182
|
+
(`create --module chat` or `add module --module chat`).
|
|
183
|
+
|
|
184
|
+
When chat is selected, NexTCLI auto-adds `supabase-realtime` if missing.
|
|
185
|
+
|
|
186
|
+
The generated chat schema is provider-agnostic so you can plug in Supabase Realtime,
|
|
187
|
+
WebSocket, Pusher, or any transport later without redesigning data:
|
|
188
|
+
|
|
189
|
+
- `ChatConversation`
|
|
190
|
+
- `ChatParticipant`
|
|
191
|
+
- `ChatMessage`
|
|
192
|
+
|
|
193
|
+
Core relations and constraints are included:
|
|
194
|
+
|
|
195
|
+
- participant uniqueness per conversation (`conversationId`, `userId`)
|
|
196
|
+
- ordered message lookup index (`conversationId`, `createdAt`)
|
|
197
|
+
- sender and participant linkage to `User`
|
package/dist/cli.d.ts
ADDED