@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.
Files changed (122) hide show
  1. package/README.md +68 -47
  2. package/dist/cli.js +1002 -753
  3. package/package.json +6 -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/features/supabase/src/lib/supabase/rich-text-image-sync.ts +28 -0
  41. package/templates/next-base/.env +0 -14
  42. package/templates/next-base/.env.development +0 -14
  43. package/templates/next-base/.env.example +0 -14
  44. package/templates/next-base/PROJECT_STRUCTURE.md +43 -54
  45. package/templates/next-base/SETUP.md +12 -60
  46. package/templates/next-base/bun.lock +59 -397
  47. package/templates/next-base/next-env.d.ts +1 -1
  48. package/templates/next-base/next.config.ts +1 -4
  49. package/templates/next-base/nextcli.json +3 -3
  50. package/templates/next-base/package.json +6 -21
  51. package/templates/next-base/src/app/blog-demo/page.tsx +9 -0
  52. package/templates/next-base/src/app/globals.css +57 -0
  53. package/templates/next-base/src/app/layout.tsx +6 -14
  54. package/templates/next-base/src/app/page.tsx +25 -2
  55. package/templates/next-base/src/components/rich-text/adapters/textarea-field.tsx +50 -0
  56. package/templates/next-base/src/components/rich-text/client-only.tsx +23 -0
  57. package/templates/next-base/src/components/rich-text/editor-field.tsx +62 -0
  58. package/templates/next-base/src/components/rich-text/examples/blog-rich-text-demo.tsx +218 -0
  59. package/templates/next-base/src/components/rich-text/index.ts +11 -0
  60. package/templates/next-base/src/components/rich-text/lexical/extension.ts +37 -0
  61. package/templates/next-base/src/components/rich-text/lexical/nodes/image-node.tsx +187 -0
  62. package/templates/next-base/src/components/rich-text/lexical/plugins/image-plugin.tsx +40 -0
  63. package/templates/next-base/src/components/rich-text/lexical/plugins/initial-state-plugin.tsx +26 -0
  64. package/templates/next-base/src/components/rich-text/lexical/plugins/on-change-plugin.tsx +26 -0
  65. package/templates/next-base/src/components/rich-text/lexical/plugins/toolbar-plugin.tsx +190 -0
  66. package/templates/next-base/src/components/rich-text/lexical/rich-text-editor.tsx +121 -0
  67. package/templates/next-base/src/components/rich-text/lexical/theme.ts +18 -0
  68. package/templates/next-base/src/components/rich-text/rich-text-renderer.tsx +72 -0
  69. package/templates/next-base/src/components/rich-text/types.ts +60 -0
  70. package/templates/next-base/src/hooks/index.ts +1 -1
  71. package/templates/next-base/src/lib/rich-text/default-image-removal.ts +10 -0
  72. package/templates/next-base/src/lib/rich-text/image-urls.ts +41 -0
  73. package/templates/next-base/src/lib/rich-text/index.ts +12 -0
  74. package/templates/next-base/src/lib/rich-text/supabase-url.ts +67 -0
  75. package/templates/next-base/src/lib/rich-text/sync-removed-images.ts +48 -0
  76. package/templates/next-base/src/types/index.ts +0 -2
  77. package/templates/next-base/tsconfig.tsbuildinfo +1 -0
  78. package/templates/next-base/prisma/migrations/20260612000000_init/migration.sql +0 -104
  79. package/templates/next-base/prisma/migrations/migration_lock.toml +0 -3
  80. package/templates/next-base/src/app/(auth)/.gitkeep +0 -1
  81. /package/templates/{next-base → features/api}/src/components/providers/query-provider.tsx +0 -0
  82. /package/templates/{next-base/src/lib → features/api/src/lib/api}/token-store.ts +0 -0
  83. /package/templates/{next-base → features/auth}/messages/vi/auth.json +0 -0
  84. /package/templates/{next-base/prisma/migrations → features/auth/src/app/(auth)}/.gitkeep +0 -0
  85. /package/templates/{next-base → features/auth}/src/app/(auth)/change-password/page.tsx +0 -0
  86. /package/templates/{next-base → features/auth}/src/app/(auth)/layout.tsx +0 -0
  87. /package/templates/{next-base → features/auth}/src/app/(auth)/sign-in/page.tsx +0 -0
  88. /package/templates/{next-base → features/auth}/src/app/api/auth/[...all]/route.ts +0 -0
  89. /package/templates/{next-base → features/auth}/src/features/auth/validations.ts +0 -0
  90. /package/templates/{next-base → features/auth}/src/features/users/validations.ts +0 -0
  91. /package/templates/{next-base/src/lib/auth-client.ts → features/auth/src/lib/auth/client.ts} +0 -0
  92. /package/templates/{next-base/src/lib/auth-cookies.ts → features/auth/src/lib/auth/cookies.ts} +0 -0
  93. /package/templates/{next-base → features/dashboard}/src/app/(dashboard)/account/page.tsx +0 -0
  94. /package/templates/{next-base → features/dashboard}/src/app/(dashboard)/dashboard/page.tsx +0 -0
  95. /package/templates/{next-base → features/dashboard}/src/components/layout/private/app-sidebar.tsx +0 -0
  96. /package/templates/{next-base → features/dashboard}/src/components/layout/private/dashboard-layout.tsx +0 -0
  97. /package/templates/{next-base → features/dashboard}/src/components/layout/private/nav-sidebar.tsx +0 -0
  98. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-column-header.tsx +0 -0
  99. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-filter-list.tsx +0 -0
  100. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-pagination.tsx +0 -0
  101. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-skeleton.tsx +0 -0
  102. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-toolbar.tsx +0 -0
  103. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table-view-options.tsx +0 -0
  104. /package/templates/{next-base → features/dashboard}/src/components/ui/data-table/data-table.tsx +0 -0
  105. /package/templates/{next-base → features/dashboard}/src/components/ui/sidebar.tsx +0 -0
  106. /package/templates/{next-base → features/dashboard}/src/data/sidebar-modules.ts +0 -0
  107. /package/templates/{next-base → features/dashboard}/src/hooks/table/use-data-table.ts +0 -0
  108. /package/templates/{next-base → features/dashboard}/src/hooks/use-mobile.ts +0 -0
  109. /package/templates/{next-base → features/dashboard}/src/types/data-table.ts +0 -0
  110. /package/templates/{next-base/src/lib → features/database/src/lib/db}/prisma.ts +0 -0
  111. /package/templates/{next-base → features/example}/messages/vi/example.json +0 -0
  112. /package/templates/{next-base → features/example}/src/app/(dashboard)/example/page.tsx +0 -0
  113. /package/templates/{next-base → features/example}/src/example/components/example-table.tsx +0 -0
  114. /package/templates/{next-base → features/example}/src/example/validations.ts +0 -0
  115. /package/templates/{next-base → features/i18n}/messages/vi/common.json +0 -0
  116. /package/templates/{next-base → features/i18n}/src/components/layout/private/locale-switcher.tsx +0 -0
  117. /package/templates/{next-base → features/i18n}/src/i18n/config.ts +0 -0
  118. /package/templates/{next-base → features/i18n}/src/i18n/namespaces.ts +0 -0
  119. /package/templates/{next-base → features/i18n}/src/i18n/request.ts +0 -0
  120. /package/templates/{next-base → features/supabase}/src/lib/supabase/client.ts +0 -0
  121. /package/templates/{next-base → features/supabase}/src/lib/supabase/storage-config.ts +0 -0
  122. /package/templates/{next-base → features/supabase}/src/lib/supabase/storage.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  # Project structure
2
2
 
3
- Generated by NexTCLI. Folders marked **(module)** or **(feature)** appear only when that add-on is enabled.
3
+ Generated by NexTCLI. Folders marked **(module)** appear only when that add-on is enabled.
4
4
 
5
5
  ## Root
6
6
 
@@ -9,22 +9,16 @@ Generated by NexTCLI. Folders marked **(module)** or **(feature)** appear only w
9
9
  | `nextcli.json` | Manifest: CLI version, locales, namespaces, modules, features |
10
10
  | `SETUP.md` | Env + branding setup (this repo) |
11
11
  | `PROJECT_STRUCTURE.md` | Folder map (this file) |
12
- | `prisma/` | Schema + migrations |
13
- | `messages/` | i18n JSON per locale/namespace |
14
12
  | `public/` | Static assets (`logo.svg`, etc.) |
15
13
 
16
- ## `src/app/` — App Router
14
+ ## `src/app/` — App Router (base)
17
15
 
18
- | Path | Purpose |
19
- | -------------------- | ------------------------------------------ |
20
- | `layout.tsx` | Root layout, metadata from `branding` |
21
- | `globals.css` | Design tokens (`nextcli:theme` markers) |
22
- | `(auth)/` | Sign-in, forced password change |
23
- | `(dashboard)/` | Protected shell (session + password guard) |
24
- | `api/auth/[...all]/` | Better Auth passthrough (not wrapped) |
25
- | `api/v1/` | Project API envelope (`ok` / `fail`) |
26
- | `api/v1/users/` | User CRUD + RBAC **(base)** |
27
- | `api/v1/example/` | Demo CRUD sample |
16
+ | Path | Purpose |
17
+ | ------------- | --------------------------------------- |
18
+ | `layout.tsx` | Root layout, metadata from `branding` |
19
+ | `page.tsx` | Welcome landing page |
20
+ | `blog-demo/` | Rich text create/edit/read demo |
21
+ | `globals.css` | Design tokens (`nextcli:theme` markers) |
28
22
 
29
23
  ## `src/config/`
30
24
 
@@ -32,56 +26,51 @@ Generated by NexTCLI. Folders marked **(module)** or **(feature)** appear only w
32
26
  | ------------- | ------------------------------------ |
33
27
  | `branding.ts` | Project name, logo path, description |
34
28
 
35
- ## `src/lib/` — Shared runtime
36
-
37
- | Path | Purpose |
38
- | ---------------------------- | --------------------------------------------------------------- |
39
- | `auth.ts` / `auth-client.ts` | Better Auth (username + JWT) |
40
- | `bootstrap.ts` | Seeds `admin` role/user on startup |
41
- | `rbac.ts` | Role hierarchy guards |
42
- | `prisma.ts` | DB client |
43
- | `api-response.ts` | `/api/v1/*` envelope helpers |
44
- | `supabase/` | Supabase client + Storage helpers |
45
- | `email/` | **(module: `email`)** provider-agnostic email helper + adapters |
46
-
47
- ## `src/features/` vs `src/example/`
48
-
49
- | Path | Purpose |
50
- | ------------------ | --------------------------------------------------------- |
51
- | `features/auth/` | Sign-in + change-password UI |
52
- | `features/users/` | User validations/services for API |
53
- | `example/` | Starter demo feature (rename for production) |
54
- | `features/<name>/` | **(feature: `nextcli add feature <name>`)** CRUD scaffold |
55
-
56
29
  ## `src/components/`
57
30
 
58
- | Path | Purpose |
59
- | ------------------- | --------------------------------- |
60
- | `branding/logo.tsx` | Logo + project name |
61
- | `layout/private/` | Dashboard shell (sidebar, header) |
62
- | `ui/` | shadcn-style primitives |
31
+ | Path | Purpose |
32
+ | ------------------- | --------------------------------------- |
33
+ | `branding/logo.tsx` | Logo + project name |
34
+ | `rich-text/` | Lexical editor adapters, renderer, demo |
35
+ | `ui/` | shadcn-style primitives |
36
+ | `providers/` | Theme provider |
63
37
 
64
- ## `src/i18n/`
38
+ ## `src/lib/rich-text/` (base)
65
39
 
66
- Locale config with `nextcli:locales` / `nextcli:namespaces` markers (patched by `nextcli add language` / `add feature`).
40
+ | Path | Purpose |
41
+ | -------------------------- | ---------------------------------------------------- |
42
+ | `image-urls.ts` | Extract image URLs from Lexical JSON |
43
+ | `supabase-url.ts` | Map Supabase public URLs to storage paths |
44
+ | `sync-removed-images.ts` | Lifecycle helper for removed images |
45
+ | `default-image-removal.ts` | No-op remover (swap when `supabase` module is added) |
67
46
 
68
- ## `src/emails/`
47
+ ## Optional modules (via `nextcli add module`)
69
48
 
70
- **(module: `email`)** React Email templates.
49
+ | Module | Adds |
50
+ | ------------------- | --------------------------------------------------------------------- |
51
+ | `database` | Prisma schema, client, `DATABASE_URL`, db scripts |
52
+ | `supabase` | Supabase browser client + Storage helpers + `rich-text-image-sync.ts` |
53
+ | `auth` | Better Auth, sign-in pages, user APIs, bootstrap admin |
54
+ | `api` | Axios client, API envelope helpers, React Query provider |
55
+ | `i18n` | next-intl config, messages, locale switcher |
56
+ | `dashboard` | Protected dashboard shell, sidebar, data-table UI |
57
+ | `example` | Starter CRUD demo feature + `Example` Prisma model |
58
+ | `chat` | Chat routes, hooks, Prisma chat models (+ auto deps) |
59
+ | `supabase-realtime` | Realtime channel helpers (+ auto `supabase`) |
60
+ | `seo` | robots/sitemap/JSON-LD helpers |
61
+ | `email` | `src/lib/email/*`, `src/emails/*` (provider: SMTP or Resend) |
71
62
 
72
- ## Optional modules (via `nextcli add module`)
63
+ Module **env variables** and where to find them: see `SETUP.md` **Optional module environment**.
64
+
65
+ ## Generated features
73
66
 
74
- | Module | Adds |
75
- | ------------------- | ------------------------------------------------------------------- |
76
- | `chat` | Chat routes, hooks, Prisma chat models (+ auto `supabase-realtime`) |
77
- | `supabase-realtime` | Realtime channel helpers |
78
- | `seo` | robots/sitemap/JSON-LD helpers |
79
- | `email` | `src/lib/email/*`, `src/emails/*` (provider: SMTP or Resend) |
67
+ | Path | Purpose |
68
+ | ------------------ | --------------------------------------------------------- |
69
+ | `features/<name>/` | **(feature: `nextcli add feature <name>`)** CRUD scaffold |
80
70
 
81
- Module **env variables** and where to find them: see `SETUP.md` → **Optional module environment** (full catalog; `Enabled modules` line updates when you create/add modules).
71
+ Requires `database` and `api` modules in the project.
82
72
 
83
73
  ## Notes
84
74
 
75
+ - Review `prisma/schema.prisma` before production migrations when `database` is enabled.
85
76
  - Do not wrap `api/auth/[...all]` responses — Better Auth expects raw format.
86
- - Review `prisma/schema.prisma` before production migrations (demo `Example` model).
87
- - Super-admin account `admin` cannot be modified/deleted via user APIs.
@@ -2,13 +2,16 @@
2
2
 
3
3
  Quick reference for env vars and branding after `nextcli create`.
4
4
 
5
- ## First run (required)
5
+ ## Minimal base project
6
6
 
7
- 1. Create a Supabase project and set `DATABASE_URL` and `DIRECT_URL` in `.env`.
8
- 2. `bun run db:migrate` — applies `prisma/migrations` (includes `Role`, `User.username`, `requirePasswordChange`).
9
- 3. `bun run dev` — bootstrap seeds `admin` / `admin` on first start.
7
+ The default template ships a lightweight Next.js shell with branding, theme, and UI primitives only. No database, auth, or dashboard code is included until you select modules at create time or run `nextcli add module`.
10
8
 
11
- `postinstall` runs `prisma generate` so TypeScript knows models like `Role` and `requirePasswordChange`. If types look stale, run `bun run db:generate` manually.
9
+ ## First run
10
+
11
+ 1. `bun run dev` (or your package manager equivalent)
12
+ 2. Open `http://localhost:3000`
13
+
14
+ When you add the `database` module, run `bun run db:migrate` before relying on Prisma models.
12
15
 
13
16
  ## Branding (edit in repo, not env)
14
17
 
@@ -17,26 +20,14 @@ Quick reference for env vars and branding after `nextcli create`.
17
20
  | Display name, slug, description, logo path | `src/config/branding.ts` |
18
21
  | Logo file | `public/logo.svg` (or update `logoPath`) |
19
22
  | Theme colors (primary, sidebar, …) | `src/app/globals.css` between `nextcli:theme:start` / `nextcli:theme:end` |
20
- | Sidebar/header labels (i18n) | `messages/<locale>/common.json` → `appName` |
21
23
 
22
24
  ## Core environment variables
23
25
 
24
- Set in `.env` / `.env.development` (secrets are generated at create time).
25
-
26
- | Variable | Purpose | Where to get |
27
- | ------------------------------------- | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
28
- | `DATABASE_URL` | Postgres URL for app runtime and Prisma CLI (`prisma.config.ts` → `datasource.url`) | Supabase Dashboard → Connect → ORMs → Prisma → pooled URL (`:6543`, `?pgbouncer=true`) |
29
- | `DIRECT_URL` | Direct/session Postgres URL from Supabase Connect (keep in env for reference/tooling) | Supabase Dashboard → Connect → ORMs → Prisma → direct/session URL (`:5432`) |
30
- | `NEXT_PUBLIC_SUPABASE_URL` | Supabase client URL | Supabase Dashboard → Project Settings → API → Project URL |
31
- | `NEXT_PUBLIC_SUPABASE_ANON_KEY` | Browser-safe anon API key (public key used by client SDK) | Same page → Project API keys → `anon` `public` |
32
- | `NEXT_PUBLIC_SUPABASE_STORAGE_BUCKET` | Storage bucket name used by app uploads/reads (`public` is the default bucket name) | Storage → create/select bucket → use that bucket name |
33
- | `BETTER_AUTH_SECRET` | Auth signing secret | Auto-generated on create; rotate in production |
34
- | `BETTER_AUTH_URL` | Server auth base URL | Your app URL (e.g. `http://localhost:3000`) |
35
- | `NEXT_PUBLIC_APP_URL` | Client-visible app URL | Same as public site URL |
26
+ Set in `.env` / `.env.development`.
36
27
 
37
- ### Default admin account
38
-
39
- On first `dev` / `start`, bootstrap creates role `admin` and user `admin` / `admin` (must change password on first login).
28
+ | Variable | Purpose | Where to get |
29
+ | --------------------- | ---------------------- | ------------------------------------- |
30
+ | `NEXT_PUBLIC_APP_URL` | Client-visible app URL | Your public site URL (e.g. localhost) |
40
31
 
41
32
  ## Optional module environment
42
33
 
@@ -50,45 +41,6 @@ Reference for all optional modules. Matching keys are merged into `.env` when se
50
41
 
51
42
  <!-- nextcli:module-env:start -->
52
43
 
53
- ### Module: Chat module (`chat`)
54
-
55
- | Variable | Where to get |
56
- | ------------------------- | ---------------------------------------------------- |
57
- | `NEXT_PUBLIC_ENABLE_CHAT` | Set `true` when chat module is enabled (auto on add) |
58
-
59
- Requires `supabase-realtime` (auto-added). Run `db:migrate` after add — chat Prisma models are appended.
60
-
61
- ### Module: Supabase Realtime (`supabase-realtime`)
62
-
63
- Uses the base Supabase URL/anon key. Enable Realtime on tables in Supabase Dashboard → Database → Replication.
64
-
65
- ### Module: SEO pack (`seo`)
66
-
67
- No extra env keys. Edit `src/app/robots.ts`, `sitemap.ts`, and JSON-LD helpers after add.
68
-
69
- ### Module: Email module (`email`)
70
-
71
- | Variable | Where to get |
72
- | ---------------- | ------------------ |
73
- | `EMAIL_PROVIDER` | `resend` or `smtp` |
74
-
75
- When `EMAIL_PROVIDER=resend`:
76
-
77
- | Variable | Where to get |
78
- | ------------------- | ------------------------------------------------------------------ |
79
- | `RESEND_API_KEY` | resend.com → API Keys → Create |
80
- | `RESEND_FROM_EMAIL` | resend.com → Domains → verify domain → use `Name <you@domain.com>` |
81
-
82
- When `EMAIL_PROVIDER=smtp`:
83
-
84
- | Variable | Where to get |
85
- | --------------- | -------------------------------------------- |
86
- | `SMTP_HOST` | SMTP provider host (Mailgun, SES, etc.) |
87
- | `SMTP_PORT` | SMTP provider port (commonly `587` or `465`) |
88
- | `SMTP_USER` | SMTP username |
89
- | `SMTP_PASSWORD` | SMTP password or app-specific token |
90
- | `SMTP_FROM` | Sender email (or `Name <mail@domain.com>`) |
91
-
92
44
  <!-- nextcli:module-env:end -->
93
45
 
94
46
  ## After adding modules