@thinhnguyencth1204/nextcli 0.7.0 → 0.9.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 (114) hide show
  1. package/README.md +37 -24
  2. package/dist/cli.js +168 -107
  3. package/package.json +5 -3
  4. package/templates/features/supabase/src/lib/supabase/rich-text-image-sync.ts +28 -0
  5. package/templates/next-base/.env +16 -0
  6. package/templates/next-base/.env.development +16 -0
  7. package/templates/next-base/.env.example +16 -0
  8. package/templates/next-base/PROJECT_STRUCTURE.md +29 -18
  9. package/templates/next-base/SETUP.md +62 -10
  10. package/templates/next-base/bun.lock +59 -414
  11. package/templates/next-base/messages/vi/auth.json +42 -0
  12. package/templates/next-base/messages/vi/common.json +34 -0
  13. package/templates/next-base/messages/vi/example.json +10 -0
  14. package/templates/next-base/next-env.d.ts +1 -1
  15. package/templates/next-base/next.config.ts +4 -1
  16. package/templates/next-base/nextcli.json +12 -4
  17. package/templates/next-base/package.json +25 -1
  18. package/templates/next-base/prisma/schema.prisma +84 -0
  19. package/templates/next-base/prisma.config.ts +16 -0
  20. package/templates/next-base/src/app/(auth)/.gitkeep +1 -0
  21. package/templates/next-base/src/app/(auth)/change-password/layout.tsx +21 -0
  22. package/templates/next-base/src/app/(auth)/change-password/page.tsx +14 -0
  23. package/templates/next-base/src/app/(auth)/layout.tsx +9 -0
  24. package/templates/next-base/src/app/(auth)/sign-in/layout.tsx +17 -0
  25. package/templates/next-base/src/app/(auth)/sign-in/page.tsx +14 -0
  26. package/templates/next-base/src/app/(dashboard)/account/page.tsx +18 -0
  27. package/templates/next-base/src/app/(dashboard)/dashboard/page.tsx +17 -0
  28. package/templates/next-base/src/app/(dashboard)/example/page.tsx +13 -0
  29. package/templates/next-base/src/app/(dashboard)/layout.tsx +22 -0
  30. package/templates/next-base/src/app/api/auth/[...all]/route.ts +4 -0
  31. package/templates/next-base/src/app/api/v1/auth/change-password/route.ts +55 -0
  32. package/templates/next-base/src/app/api/v1/auth/login/route.ts +70 -0
  33. package/templates/next-base/src/app/api/v1/auth/logout/route.ts +28 -0
  34. package/templates/next-base/src/app/api/v1/auth/me/route.ts +24 -0
  35. package/templates/next-base/src/app/api/v1/auth/refresh/route.ts +32 -0
  36. package/templates/next-base/src/app/api/v1/example/route.ts +34 -0
  37. package/templates/next-base/src/app/api/v1/users/[id]/route.ts +104 -0
  38. package/templates/next-base/src/app/api/v1/users/route.ts +58 -0
  39. package/templates/next-base/src/app/blog-demo/page.tsx +9 -0
  40. package/templates/next-base/src/app/globals.css +57 -0
  41. package/templates/next-base/src/app/layout.tsx +14 -6
  42. package/templates/next-base/src/app/page.tsx +2 -25
  43. package/templates/next-base/src/components/layout/private/app-sidebar.tsx +44 -0
  44. package/templates/next-base/src/components/layout/private/dashboard-layout.tsx +54 -0
  45. package/templates/next-base/src/components/layout/private/locale-switcher.tsx +45 -0
  46. package/templates/next-base/src/components/layout/private/nav-sidebar.tsx +55 -0
  47. package/templates/next-base/src/components/layout/private/nav-user.tsx +99 -0
  48. package/templates/next-base/src/components/providers/query-provider.tsx +17 -0
  49. package/templates/next-base/src/components/rich-text/adapters/textarea-field.tsx +50 -0
  50. package/templates/next-base/src/components/rich-text/client-only.tsx +23 -0
  51. package/templates/next-base/src/components/rich-text/editor-field.tsx +62 -0
  52. package/templates/next-base/src/components/rich-text/examples/blog-rich-text-demo.tsx +218 -0
  53. package/templates/next-base/src/components/rich-text/index.ts +11 -0
  54. package/templates/next-base/src/components/rich-text/lexical/extension.ts +37 -0
  55. package/templates/next-base/src/components/rich-text/lexical/nodes/image-node.tsx +187 -0
  56. package/templates/next-base/src/components/rich-text/lexical/plugins/image-plugin.tsx +40 -0
  57. package/templates/next-base/src/components/rich-text/lexical/plugins/initial-state-plugin.tsx +26 -0
  58. package/templates/next-base/src/components/rich-text/lexical/plugins/on-change-plugin.tsx +26 -0
  59. package/templates/next-base/src/components/rich-text/lexical/plugins/toolbar-plugin.tsx +190 -0
  60. package/templates/next-base/src/components/rich-text/lexical/rich-text-editor.tsx +121 -0
  61. package/templates/next-base/src/components/rich-text/lexical/theme.ts +18 -0
  62. package/templates/next-base/src/components/rich-text/rich-text-renderer.tsx +72 -0
  63. package/templates/next-base/src/components/rich-text/types.ts +60 -0
  64. package/templates/next-base/src/components/ui/data-table/data-table-column-header.tsx +23 -0
  65. package/templates/next-base/src/components/ui/data-table/data-table-filter-list.tsx +3 -0
  66. package/templates/next-base/src/components/ui/data-table/data-table-pagination.tsx +35 -0
  67. package/templates/next-base/src/components/ui/data-table/data-table-skeleton.tsx +11 -0
  68. package/templates/next-base/src/components/ui/data-table/data-table-toolbar.tsx +14 -0
  69. package/templates/next-base/src/components/ui/data-table/data-table-view-options.tsx +3 -0
  70. package/templates/next-base/src/components/ui/data-table/data-table.tsx +72 -0
  71. package/templates/next-base/src/components/ui/sidebar.tsx +215 -0
  72. package/templates/next-base/src/data/sidebar-modules.ts +11 -0
  73. package/templates/next-base/src/example/api/use-example.ts +21 -0
  74. package/templates/next-base/src/example/api/use-mutations.ts +20 -0
  75. package/templates/next-base/src/example/components/example-table.tsx +51 -0
  76. package/templates/next-base/src/example/services.ts +9 -0
  77. package/templates/next-base/src/example/validations.ts +8 -0
  78. package/templates/next-base/src/features/auth/components/account-panel.tsx +80 -0
  79. package/templates/next-base/src/features/auth/components/change-password-form.tsx +82 -0
  80. package/templates/next-base/src/features/auth/components/sign-in-form.tsx +95 -0
  81. package/templates/next-base/src/features/auth/validations.ts +14 -0
  82. package/templates/next-base/src/features/users/services.ts +132 -0
  83. package/templates/next-base/src/features/users/validations.ts +21 -0
  84. package/templates/next-base/src/hooks/index.ts +1 -1
  85. package/templates/next-base/src/hooks/table/use-data-table.ts +33 -0
  86. package/templates/next-base/src/hooks/use-mobile.ts +25 -0
  87. package/templates/next-base/src/i18n/config.ts +7 -0
  88. package/templates/next-base/src/i18n/namespaces.ts +5 -0
  89. package/templates/next-base/src/i18n/request.ts +25 -0
  90. package/templates/next-base/src/instrumentation.ts +14 -0
  91. package/templates/next-base/src/lib/api/axios.ts +145 -0
  92. package/templates/next-base/src/lib/api/response.ts +45 -0
  93. package/templates/next-base/src/lib/api/token-store.ts +13 -0
  94. package/templates/next-base/src/lib/auth/bootstrap.ts +95 -0
  95. package/templates/next-base/src/lib/auth/client.ts +7 -0
  96. package/templates/next-base/src/lib/auth/cookies.ts +15 -0
  97. package/templates/next-base/src/lib/auth/index.ts +1 -0
  98. package/templates/next-base/src/lib/auth/rbac.ts +59 -0
  99. package/templates/next-base/src/lib/auth/server.ts +21 -0
  100. package/templates/next-base/src/lib/constants.ts +10 -0
  101. package/templates/next-base/src/lib/db/prisma.ts +23 -0
  102. package/templates/next-base/src/lib/prisma.ts +23 -0
  103. package/templates/next-base/src/lib/rich-text/default-image-removal.ts +10 -0
  104. package/templates/next-base/src/lib/rich-text/image-urls.ts +41 -0
  105. package/templates/next-base/src/lib/rich-text/index.ts +12 -0
  106. package/templates/next-base/src/lib/rich-text/supabase-url.ts +67 -0
  107. package/templates/next-base/src/lib/rich-text/sync-removed-images.ts +48 -0
  108. package/templates/next-base/src/lib/supabase/client.ts +6 -0
  109. package/templates/next-base/src/lib/supabase/rich-text-image-sync.ts +28 -0
  110. package/templates/next-base/src/lib/supabase/storage-config.ts +69 -0
  111. package/templates/next-base/src/lib/supabase/storage.ts +164 -0
  112. package/templates/next-base/src/types/data-table.ts +4 -0
  113. package/templates/next-base/src/types/index.ts +0 -2
  114. package/templates/next-base/tsconfig.tsbuildinfo +1 -0
@@ -1,2 +1,18 @@
1
1
  # --- App ---
2
2
  NEXT_PUBLIC_APP_URL="http://localhost:3000"
3
+
4
+ # --- module: database ---
5
+ DATABASE_URL="postgresql://postgres.your-project-ref:your-supabase-db-password@aws-0-us-east-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
6
+ DIRECT_URL="postgresql://postgres.your-project-ref:your-supabase-db-password@aws-0-us-east-1.pooler.supabase.com:5432/postgres"
7
+
8
+ # --- module: supabase ---
9
+ NEXT_PUBLIC_SUPABASE_URL=""
10
+ NEXT_PUBLIC_SUPABASE_ANON_KEY=""
11
+ NEXT_PUBLIC_SUPABASE_STORAGE_BUCKET="public"
12
+
13
+ # --- module: auth ---
14
+ BETTER_AUTH_SECRET=""
15
+ BETTER_AUTH_URL="http://localhost:3000"
16
+
17
+ # --- module: i18n ---
18
+ NEXT_PUBLIC_DEFAULT_LOCALE="vi"
@@ -1,2 +1,18 @@
1
1
  # --- App ---
2
2
  NEXT_PUBLIC_APP_URL="http://localhost:3000"
3
+
4
+ # --- module: database ---
5
+ DATABASE_URL="postgresql://postgres.your-project-ref:your-supabase-db-password@aws-0-us-east-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
6
+ DIRECT_URL="postgresql://postgres.your-project-ref:your-supabase-db-password@aws-0-us-east-1.pooler.supabase.com:5432/postgres"
7
+
8
+ # --- module: supabase ---
9
+ NEXT_PUBLIC_SUPABASE_URL=""
10
+ NEXT_PUBLIC_SUPABASE_ANON_KEY=""
11
+ NEXT_PUBLIC_SUPABASE_STORAGE_BUCKET="public"
12
+
13
+ # --- module: auth ---
14
+ BETTER_AUTH_SECRET=""
15
+ BETTER_AUTH_URL="http://localhost:3000"
16
+
17
+ # --- module: i18n ---
18
+ NEXT_PUBLIC_DEFAULT_LOCALE="vi"
@@ -1,2 +1,18 @@
1
1
  # --- App ---
2
2
  NEXT_PUBLIC_APP_URL="http://localhost:3000"
3
+
4
+ # --- module: database ---
5
+ DATABASE_URL="postgresql://postgres.your-project-ref:your-supabase-db-password@aws-0-us-east-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
6
+ DIRECT_URL="postgresql://postgres.your-project-ref:your-supabase-db-password@aws-0-us-east-1.pooler.supabase.com:5432/postgres"
7
+
8
+ # --- module: supabase ---
9
+ NEXT_PUBLIC_SUPABASE_URL=""
10
+ NEXT_PUBLIC_SUPABASE_ANON_KEY=""
11
+ NEXT_PUBLIC_SUPABASE_STORAGE_BUCKET="public"
12
+
13
+ # --- module: auth ---
14
+ BETTER_AUTH_SECRET=""
15
+ BETTER_AUTH_URL="http://localhost:3000"
16
+
17
+ # --- module: i18n ---
18
+ NEXT_PUBLIC_DEFAULT_LOCALE="vi"
@@ -17,6 +17,7 @@ Generated by NexTCLI. Folders marked **(module)** appear only when that add-on i
17
17
  | ------------- | --------------------------------------- |
18
18
  | `layout.tsx` | Root layout, metadata from `branding` |
19
19
  | `page.tsx` | Welcome landing page |
20
+ | `blog-demo/` | Rich text create/edit/read demo |
20
21
  | `globals.css` | Design tokens (`nextcli:theme` markers) |
21
22
 
22
23
  ## `src/config/`
@@ -27,27 +28,37 @@ Generated by NexTCLI. Folders marked **(module)** appear only when that add-on i
27
28
 
28
29
  ## `src/components/`
29
30
 
30
- | Path | Purpose |
31
- | ------------------- | ----------------------- |
32
- | `branding/logo.tsx` | Logo + project name |
33
- | `ui/` | shadcn-style primitives |
34
- | `providers/` | Theme provider |
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 |
37
+
38
+ ## `src/lib/rich-text/` (base)
39
+
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) |
35
46
 
36
47
  ## Optional modules (via `nextcli add module`)
37
48
 
38
- | Module | Adds |
39
- | ------------------- | ------------------------------------------------------------ |
40
- | `database` | Prisma schema, client, `DATABASE_URL`, db scripts |
41
- | `supabase` | Supabase browser client + Storage helpers |
42
- | `auth` | Better Auth, sign-in pages, user APIs, bootstrap admin |
43
- | `api` | Axios client, API envelope helpers, React Query provider |
44
- | `i18n` | next-intl config, messages, locale switcher |
45
- | `dashboard` | Protected dashboard shell, sidebar, data-table UI |
46
- | `example` | Starter CRUD demo feature + `Example` Prisma model |
47
- | `chat` | Chat routes, hooks, Prisma chat models (+ auto deps) |
48
- | `supabase-realtime` | Realtime channel helpers (+ auto `supabase`) |
49
- | `seo` | robots/sitemap/JSON-LD helpers |
50
- | `email` | `src/lib/email/*`, `src/emails/*` (provider: SMTP or Resend) |
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) |
51
62
 
52
63
  Module **env variables** and where to find them: see `SETUP.md` → **Optional module environment**.
53
64
 
@@ -2,16 +2,18 @@
2
2
 
3
3
  Quick reference for env vars and branding after `nextcli create`.
4
4
 
5
- ## Minimal base project
5
+ ## Default stack
6
6
 
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`.
7
+ The base template ships with database (Prisma + Postgres), Supabase client + Storage, Better Auth + RBAC, API client (Axios + React Query), i18n (next-intl), dashboard shell, and an example CRUD demo. Optional modules (`chat`, `supabase-realtime`, `seo`, `email`) can be added at create time or via `nextcli add module`.
8
8
 
9
9
  ## First run
10
10
 
11
- 1. `bun run dev` (or your package manager equivalent)
12
- 2. Open `http://localhost:3000`
11
+ 1. Fill env keys in `.env` (see tables below).
12
+ 2. `bun run db:migrate` (or your package manager equivalent)
13
+ 3. `bun run dev`
14
+ 4. Open `http://localhost:3000` (redirects to `/dashboard`)
13
15
 
14
- When you add the `database` module, run `bun run db:migrate` before relying on Prisma models.
16
+ Bootstrap seeds `admin` / `admin1234` on first dev start.
15
17
 
16
18
  ## Branding (edit in repo, not env)
17
19
 
@@ -29,21 +31,71 @@ Set in `.env` / `.env.development`.
29
31
  | --------------------- | ---------------------- | ------------------------------------- |
30
32
  | `NEXT_PUBLIC_APP_URL` | Client-visible app URL | Your public site URL (e.g. localhost) |
31
33
 
32
- ## Optional module environment
33
-
34
- Reference for all optional modules. Matching keys are merged into `.env` when selected at `nextcli create` or via `nextcli add module`.
34
+ ## Base module environment
35
35
 
36
36
  <!-- nextcli:enabled-modules:start -->
37
37
 
38
- **Enabled modules:** none
38
+ **Enabled modules:** `database`, `supabase`, `auth`, `api`, `i18n`, `dashboard`, `example`
39
39
 
40
40
  <!-- nextcli:enabled-modules:end -->
41
41
 
42
42
  <!-- nextcli:module-env:start -->
43
43
 
44
+ ### Module: Database (Prisma + Postgres) (`database`)
45
+
46
+ | Variable | Where to get |
47
+ | -------------- | -------------------------------------------------------------------------------------- |
48
+ | `DATABASE_URL` | Supabase Dashboard → Connect → ORMs → Prisma → pooled URL (`:6543`, `?pgbouncer=true`) |
49
+ | `DIRECT_URL` | Supabase Dashboard → Connect → direct/session URL (`:5432`) |
50
+
51
+ Run `bun run db:migrate` after setting `DATABASE_URL`.
52
+
53
+ ### Module: Supabase client + Storage (`supabase`)
54
+
55
+ | Variable | Where to get |
56
+ | ------------------------------------- | --------------------------------------------------------- |
57
+ | `NEXT_PUBLIC_SUPABASE_URL` | Supabase Dashboard → Project Settings → API → Project URL |
58
+ | `NEXT_PUBLIC_SUPABASE_ANON_KEY` | Same page → `anon` `public` key |
59
+ | `NEXT_PUBLIC_SUPABASE_STORAGE_BUCKET` | Storage bucket name (default scaffold: `public`) |
60
+
61
+ Create the bucket and RLS policies in Supabase Dashboard before uploads.
62
+
63
+ ### Module: Auth (Better Auth + RBAC) (`auth`)
64
+
65
+ | Variable | Where to get |
66
+ | -------------------- | ---------------------------------------------- |
67
+ | `BETTER_AUTH_SECRET` | Auto-generated on create; rotate in production |
68
+ | `BETTER_AUTH_URL` | Your app URL (e.g. `http://localhost:3000`) |
69
+
70
+ Requires `database` (included in base). Bootstrap seeds `admin` / `admin1234` on first dev start.
71
+
72
+ ### Module: API client (Axios + React Query) (`api`)
73
+
74
+ No extra env keys. Use `publicApi` / `protectedApi` from `src/lib/api/axios.ts` and `ok` / `fail` from `src/lib/api/response.ts`.
75
+
76
+ ### Module: Internationalization (next-intl) (`i18n`)
77
+
78
+ | Variable | Where to get |
79
+ | ---------------------------- | ------------------------------------ |
80
+ | `NEXT_PUBLIC_DEFAULT_LOCALE` | Default locale code (scaffold: `vi`) |
81
+
82
+ Add more locales with `nextcli add language`.
83
+
84
+ ### Module: Dashboard shell (`dashboard`)
85
+
86
+ Requires `auth`, `api`, and `i18n` (included in base). Protected routes redirect unauthenticated users to `/sign-in`.
87
+
88
+ ### Module: Example CRUD demo (`example`)
89
+
90
+ Requires `dashboard` and `database` (included in base). Includes demo `Example` model in `prisma/schema.prisma` — run `db:migrate` after create.
91
+
44
92
  <!-- nextcli:module-env:end -->
45
93
 
46
- ## After adding modules
94
+ ## Optional module environment
95
+
96
+ Additional keys are merged when optional modules are selected at `nextcli create` or via `nextcli add module`.
97
+
98
+ ## After adding optional modules
47
99
 
48
100
  1. Fill new env keys in `.env` and `.env.example`.
49
101
  2. Run `bun run db:migrate` when a module adds Prisma models.