nextworks 0.1.0-alpha.9 → 0.2.0-alpha.2

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 (182) hide show
  1. package/README.md +123 -149
  2. package/dist/cli_manifests/blocks_manifest.json +8 -0
  3. package/dist/commands/blocks.d.ts +2 -0
  4. package/dist/commands/blocks.d.ts.map +1 -1
  5. package/dist/commands/blocks.js +188 -20
  6. package/dist/commands/blocks.js.map +1 -1
  7. package/dist/index.js +4 -24
  8. package/dist/index.js.map +1 -1
  9. package/dist/kits/blocks/.nextworks/docs/BLOCKS_QUICKSTART.md +19 -18
  10. package/dist/kits/blocks/.nextworks/docs/BLOCKS_README.md +21 -11
  11. package/dist/kits/blocks/.nextworks/docs/THEME_GUIDE.md +30 -2
  12. package/dist/kits/blocks/LICENSE +1 -1
  13. package/dist/kits/blocks/app/globals.css +1 -1
  14. package/dist/kits/blocks/app/templates/digitalagency/components/Hero.tsx +1 -1
  15. package/dist/kits/blocks/app/templates/productlaunch/page.tsx +0 -2
  16. package/dist/kits/blocks/app/tw-animate.css +257 -0
  17. package/dist/kits/blocks/components/app-providers.app.tsx +17 -0
  18. package/dist/kits/blocks/components/app-providers.pages.tsx +12 -0
  19. package/dist/kits/blocks/components/app-providers.tsx +1 -1
  20. package/dist/kits/blocks/components/enhanced-theme-provider.tsx +183 -195
  21. package/dist/kits/blocks/components/providers/BlocksAppProviders.tsx +27 -0
  22. package/dist/kits/blocks/components/sections/FAQ.tsx +0 -1
  23. package/dist/kits/blocks/components/sections/Features.tsx +6 -5
  24. package/dist/kits/blocks/components/sections/HeroMotion.tsx +5 -4
  25. package/dist/kits/blocks/components/sections/Newsletter.tsx +2 -2
  26. package/dist/kits/blocks/components/ui/switch.tsx +78 -78
  27. package/dist/kits/blocks/components/ui/theme-selector.tsx +2 -2
  28. package/dist/kits/blocks/lib/themes.ts +1 -0
  29. package/dist/kits/blocks/lib/utils.ts +1 -1
  30. package/dist/kits/blocks/package-deps.json +11 -5
  31. package/dist/utils/file-operations.d.ts +4 -0
  32. package/dist/utils/file-operations.d.ts.map +1 -1
  33. package/dist/utils/file-operations.js +428 -13
  34. package/dist/utils/file-operations.js.map +1 -1
  35. package/dist/utils/next-pages-document.d.ts +3 -0
  36. package/dist/utils/next-pages-document.d.ts.map +1 -0
  37. package/dist/utils/next-pages-document.js +48 -0
  38. package/dist/utils/next-pages-document.js.map +1 -0
  39. package/package.json +51 -54
  40. package/dist/cli_manifests/auth_manifest.json +0 -92
  41. package/dist/cli_manifests/data_manifest.json +0 -53
  42. package/dist/cli_manifests/forms_manifest.json +0 -64
  43. package/dist/commands/admin-posts.d.ts +0 -2
  44. package/dist/commands/admin-posts.d.ts.map +0 -1
  45. package/dist/commands/admin-posts.js +0 -15
  46. package/dist/commands/admin-posts.js.map +0 -1
  47. package/dist/commands/admin-users.d.ts +0 -2
  48. package/dist/commands/admin-users.d.ts.map +0 -1
  49. package/dist/commands/admin-users.js +0 -15
  50. package/dist/commands/admin-users.js.map +0 -1
  51. package/dist/commands/auth-core.d.ts +0 -2
  52. package/dist/commands/auth-core.d.ts.map +0 -1
  53. package/dist/commands/auth-core.js +0 -83
  54. package/dist/commands/auth-core.js.map +0 -1
  55. package/dist/commands/auth-forms.d.ts +0 -2
  56. package/dist/commands/auth-forms.d.ts.map +0 -1
  57. package/dist/commands/auth-forms.js +0 -15
  58. package/dist/commands/auth-forms.js.map +0 -1
  59. package/dist/commands/data.d.ts +0 -3
  60. package/dist/commands/data.d.ts.map +0 -1
  61. package/dist/commands/data.js +0 -88
  62. package/dist/commands/data.js.map +0 -1
  63. package/dist/commands/forms.d.ts +0 -6
  64. package/dist/commands/forms.d.ts.map +0 -1
  65. package/dist/commands/forms.js +0 -107
  66. package/dist/commands/forms.js.map +0 -1
  67. package/dist/commands/remove-auth-core.d.ts +0 -2
  68. package/dist/commands/remove-auth-core.d.ts.map +0 -1
  69. package/dist/commands/remove-auth-core.js +0 -69
  70. package/dist/commands/remove-auth-core.js.map +0 -1
  71. package/dist/kits/auth-core/.nextworks/docs/AUTH_CORE_README.md +0 -117
  72. package/dist/kits/auth-core/.nextworks/docs/AUTH_QUICKSTART.md +0 -244
  73. package/dist/kits/auth-core/LICENSE +0 -21
  74. package/dist/kits/auth-core/app/(protected)/admin/posts/page.tsx +0 -29
  75. package/dist/kits/auth-core/app/(protected)/admin/users/page.tsx +0 -29
  76. package/dist/kits/auth-core/app/(protected)/dashboard/page.tsx +0 -8
  77. package/dist/kits/auth-core/app/(protected)/layout.tsx +0 -18
  78. package/dist/kits/auth-core/app/(protected)/settings/profile/page.tsx +0 -15
  79. package/dist/kits/auth-core/app/(protected)/settings/profile/profile-form.tsx +0 -114
  80. package/dist/kits/auth-core/app/api/auth/[...nextauth]/route.ts +0 -1
  81. package/dist/kits/auth-core/app/api/auth/forgot-password/route.ts +0 -114
  82. package/dist/kits/auth-core/app/api/auth/providers/route.ts +0 -6
  83. package/dist/kits/auth-core/app/api/auth/reset-password/route.ts +0 -63
  84. package/dist/kits/auth-core/app/api/auth/send-verify-email/route.ts +0 -6
  85. package/dist/kits/auth-core/app/api/signup/route.ts +0 -41
  86. package/dist/kits/auth-core/app/api/users/[id]/route.ts +0 -127
  87. package/dist/kits/auth-core/app/auth/forgot-password/page.tsx +0 -21
  88. package/dist/kits/auth-core/app/auth/login/page.tsx +0 -5
  89. package/dist/kits/auth-core/app/auth/reset-password/page.tsx +0 -187
  90. package/dist/kits/auth-core/app/auth/signup/page.tsx +0 -5
  91. package/dist/kits/auth-core/app/auth/verify-email/page.tsx +0 -11
  92. package/dist/kits/auth-core/components/admin/admin-header.tsx +0 -57
  93. package/dist/kits/auth-core/components/auth/dashboard.tsx +0 -237
  94. package/dist/kits/auth-core/components/auth/forgot-password-form.tsx +0 -90
  95. package/dist/kits/auth-core/components/auth/login-form.tsx +0 -467
  96. package/dist/kits/auth-core/components/auth/logout-button.tsx +0 -50
  97. package/dist/kits/auth-core/components/auth/minimal-logout-button.tsx +0 -40
  98. package/dist/kits/auth-core/components/auth/signup-form.tsx +0 -468
  99. package/dist/kits/auth-core/components/require-auth.tsx +0 -59
  100. package/dist/kits/auth-core/components/session-provider.tsx +0 -11
  101. package/dist/kits/auth-core/components/ui/README.txt +0 -1
  102. package/dist/kits/auth-core/components/ui/button.tsx +0 -122
  103. package/dist/kits/auth-core/components/ui/input.tsx +0 -27
  104. package/dist/kits/auth-core/components/ui/label.tsx +0 -29
  105. package/dist/kits/auth-core/lib/api/errors.ts +0 -14
  106. package/dist/kits/auth-core/lib/auth-helpers.ts +0 -29
  107. package/dist/kits/auth-core/lib/auth.ts +0 -142
  108. package/dist/kits/auth-core/lib/email/dev-transport.ts +0 -42
  109. package/dist/kits/auth-core/lib/email/index.ts +0 -28
  110. package/dist/kits/auth-core/lib/email/provider-smtp.ts +0 -36
  111. package/dist/kits/auth-core/lib/forms/map-errors.ts +0 -11
  112. package/dist/kits/auth-core/lib/hash.ts +0 -6
  113. package/dist/kits/auth-core/lib/prisma.ts +0 -15
  114. package/dist/kits/auth-core/lib/server/result.ts +0 -45
  115. package/dist/kits/auth-core/lib/utils.ts +0 -6
  116. package/dist/kits/auth-core/lib/validation/forms.ts +0 -88
  117. package/dist/kits/auth-core/package-deps.json +0 -19
  118. package/dist/kits/auth-core/prisma/auth-models.prisma +0 -81
  119. package/dist/kits/auth-core/prisma/schema.prisma +0 -81
  120. package/dist/kits/auth-core/scripts/populate-tokenhash.mjs +0 -26
  121. package/dist/kits/auth-core/scripts/promote-admin.mjs +0 -33
  122. package/dist/kits/auth-core/scripts/seed-demo.mjs +0 -40
  123. package/dist/kits/auth-core/types/next-auth.d.ts +0 -25
  124. package/dist/kits/data/.gitkeep +0 -0
  125. package/dist/kits/data/.nextworks/docs/DATA_QUICKSTART.md +0 -112
  126. package/dist/kits/data/.nextworks/docs/DATA_README.md +0 -117
  127. package/dist/kits/data/LICENSE +0 -21
  128. package/dist/kits/data/app/(protected)/admin/posts/page.tsx +0 -5
  129. package/dist/kits/data/app/(protected)/admin/users/page.tsx +0 -5
  130. package/dist/kits/data/app/api/posts/[id]/route.ts +0 -83
  131. package/dist/kits/data/app/api/posts/route.ts +0 -138
  132. package/dist/kits/data/app/api/seed-demo/route.ts +0 -45
  133. package/dist/kits/data/app/api/users/[id]/route.ts +0 -127
  134. package/dist/kits/data/app/api/users/check-email/route.ts +0 -18
  135. package/dist/kits/data/app/api/users/check-unique/route.ts +0 -27
  136. package/dist/kits/data/app/api/users/route.ts +0 -79
  137. package/dist/kits/data/app/examples/demo/README.md +0 -4
  138. package/dist/kits/data/app/examples/demo/create-post-form.tsx +0 -106
  139. package/dist/kits/data/app/examples/demo/page.tsx +0 -118
  140. package/dist/kits/data/app/examples/demo/seed-demo-button.tsx +0 -37
  141. package/dist/kits/data/components/admin/posts-manager.tsx +0 -719
  142. package/dist/kits/data/components/admin/users-manager.tsx +0 -432
  143. package/dist/kits/data/lib/prisma.ts +0 -15
  144. package/dist/kits/data/lib/server/result.ts +0 -90
  145. package/dist/kits/data/package-deps.json +0 -11
  146. package/dist/kits/data/scripts/seed-demo.mjs +0 -41
  147. package/dist/kits/forms/.gitkeep +0 -0
  148. package/dist/kits/forms/.nextworks/docs/FORMS_QUICKSTART.md +0 -85
  149. package/dist/kits/forms/.nextworks/docs/FORMS_README.md +0 -61
  150. package/dist/kits/forms/LICENSE +0 -21
  151. package/dist/kits/forms/app/.gitkeep +0 -0
  152. package/dist/kits/forms/app/api/wizard/route.ts +0 -71
  153. package/dist/kits/forms/app/examples/forms/basic/page.tsx +0 -124
  154. package/dist/kits/forms/app/examples/forms/server-action/form-client.tsx +0 -28
  155. package/dist/kits/forms/app/examples/forms/server-action/page.tsx +0 -71
  156. package/dist/kits/forms/app/examples/forms/wizard/page.tsx +0 -15
  157. package/dist/kits/forms/app/examples/forms/wizard/wizard-client.tsx +0 -2
  158. package/dist/kits/forms/components/.gitkeep +0 -0
  159. package/dist/kits/forms/components/examples/wizard-client.tsx +0 -231
  160. package/dist/kits/forms/components/hooks/useCheckUnique.ts +0 -79
  161. package/dist/kits/forms/components/ui/button.tsx +0 -122
  162. package/dist/kits/forms/components/ui/checkbox.tsx +0 -30
  163. package/dist/kits/forms/components/ui/form/context.ts +0 -33
  164. package/dist/kits/forms/components/ui/form/form-control.tsx +0 -28
  165. package/dist/kits/forms/components/ui/form/form-description.tsx +0 -22
  166. package/dist/kits/forms/components/ui/form/form-field.tsx +0 -36
  167. package/dist/kits/forms/components/ui/form/form-item.tsx +0 -21
  168. package/dist/kits/forms/components/ui/form/form-label.tsx +0 -24
  169. package/dist/kits/forms/components/ui/form/form-message.tsx +0 -29
  170. package/dist/kits/forms/components/ui/form/form.tsx +0 -26
  171. package/dist/kits/forms/components/ui/input.tsx +0 -27
  172. package/dist/kits/forms/components/ui/label.tsx +0 -29
  173. package/dist/kits/forms/components/ui/select.tsx +0 -25
  174. package/dist/kits/forms/components/ui/switch.tsx +0 -78
  175. package/dist/kits/forms/components/ui/textarea.tsx +0 -26
  176. package/dist/kits/forms/lib/.gitkeep +0 -0
  177. package/dist/kits/forms/lib/forms/map-errors.ts +0 -29
  178. package/dist/kits/forms/lib/prisma.ts +0 -16
  179. package/dist/kits/forms/lib/utils.ts +0 -9
  180. package/dist/kits/forms/lib/validation/forms.ts +0 -88
  181. package/dist/kits/forms/lib/validation/wizard.ts +0 -32
  182. package/dist/kits/forms/package-deps.json +0 -17
package/README.md CHANGED
@@ -3,154 +3,155 @@
3
3
  Nextworks is a CLI that installs **modular Next.js building blocks** into your app:
4
4
 
5
5
  - **Blocks** – UI sections, templates, and core UI primitives.
6
- - **Auth Core** – Email/password auth (NextAuth + Prisma), basic dashboard, and helpers.
7
- - **Forms** – Opinionated form primitives built on React Hook Form + Zod.
8
- - **Data** – Example CRUD for Users + Posts with admin UI, wired to Auth + Prisma.
9
6
 
10
7
  > **Status:** early‑access alpha. Expect rough edges and breaking changes between alpha releases.
11
8
  >
12
- > In this alpha, the most reliable setup is to install **Blocks** first using:
9
+ > **Package manager:** npm only (for now).
13
10
  >
14
- > ```bash
15
- > npx nextworks add blocks --sections --templates
16
- > ```
11
+ > In this alpha, the most reliable setup is:
12
+ >
13
+ > 1. Create a new Next.js project (App Router **or** Pages Router):
14
+ >
15
+ > ```bash
16
+ > npx create-next-app@latest
17
+ > ```
18
+ >
19
+ > 2. From your app root, install **Blocks**:
20
+ >
21
+ > ```bash
22
+ > npx nextworks@latest add blocks --sections --templates
23
+ > ```
17
24
  >
18
- > and then add **Auth Core**, **Forms**, and **Data** on top. Partial setups (e.g. Auth/Data without Blocks) may require manual tweaks and are not yet fully supported.
25
+ > Non-interactive / CI-friendly:
26
+ >
27
+ > ```bash
28
+ > npx nextworks@latest add blocks --sections --templates --yes
29
+ > ```
30
+ >
31
+ > 3. Optionally, adjust flags to install only what you want (UI-only, sections, templates).
19
32
 
20
33
  ---
21
34
 
22
- ## Feedback / Contact
35
+ ## Safety (read this first)
23
36
 
24
- Nextworks is early‑access alpha and I’m actively looking for feedback from early testers. If you run into issues, have questions, or want to suggest improvements or pro‑level features, I’m happy to help and would really appreciate hearing from you:
37
+ `nextworks` installs kits by copying files into your Next.js project. If a destination path already exists, kit installs may **overwrite** your files.
25
38
 
26
- - Email: nextjsworks@gmail.com
39
+ Before running installs, strongly consider:
27
40
 
28
- ---
29
-
30
- ## Install and run the CLI
41
+ - **Commit first**, then install:
42
+ - `git add -A && git commit -m "baseline"`
43
+ - Review changes after install:
44
+ - `git diff --name-status`
45
+ - To undo everything quickly:
46
+ - `git reset --hard`
47
+ - (optional) remove untracked files created by installs: `git clean -fd`
31
48
 
32
- From your Next.js app root, use `npx`:
49
+ Kits may also:
33
50
 
34
- ```bash
35
- npx nextworks --help
36
- ```
51
+ - **merge dependencies** into `package.json`
52
+ - **edit your router entrypoint** (Blocks):
53
+ - App Router: `app/layout.tsx`
54
+ - Pages Router: `pages/_app.tsx` (and may create/update `pages/_document.tsx`)
55
+ - create/update `.nextworks/config.json`
37
56
 
38
- Example commands:
57
+ For a transparent breakdown of what each kit writes/edits, see:
39
58
 
40
- ```bash
41
- npx nextworks add blocks --sections --templates
42
- npx nextworks add auth-core
43
- npx nextworks add forms
44
- npx nextworks add data
45
- ```
59
+ - https://github.com/jblh/nextworks-cli/blob/main/docs/FILE_CHANGES.md
46
60
 
47
61
  ---
48
62
 
49
- ## Getting started in an existing Next.js app
63
+ ## Feedback
50
64
 
51
- Prerequisites:
65
+ Nextworks is early‑access alpha and I’m actively looking for feedback from early testers.
52
66
 
53
- - A Next.js App Router project (e.g. from `create-next-app`).
54
- - TypeScript + Tailwind recommended.
55
- - A **PostgreSQL database** if you plan to use **Auth Core** and **Data**.
56
- - The kits are designed and tested with Postgres using a database hosted on [Neon](https://neon.tech/).
67
+ ### Where to post feedback
57
68
 
58
- From your app root:
69
+ - **Start here (installation + where to post feedback):** https://github.com/jblh/nextworks-cli/discussions/1
70
+ - **Alpha feedback thread (what broke / what’s missing):** https://github.com/jblh/nextworks-cli/discussions/2
59
71
 
60
- ### 1) Install Blocks (UI kit)
72
+ ### Bug reports
61
73
 
62
- ```bash
63
- npx nextworks add blocks --sections --templates
64
- ```
74
+ For reproducible bugs / errors (especially install/runtime issues), please open a GitHub Issue using the templates in `.github/ISSUE_TEMPLATE/`.
65
75
 
66
- This copies:
76
+ ### Private contact (optional)
67
77
 
68
- - `components/ui/*` (core UI primitives)
69
- - `components/sections/*` (reusable sections)
70
- - Page templates under `app/templates/*`
71
- - Theme helpers and `app/globals.css` (if not already present)
78
+ If you need to share something privately (e.g. security-related), email: nextjsworks@gmail.com
72
79
 
73
- After this step you should be able to start your dev server and visit:
80
+ ---
74
81
 
75
- - `/` (if wired as the home page), or
76
- - `/templates/productlaunch`, `/templates/saasdashboard`, `/templates/digitalagency`
82
+ ## Install and run the CLI
77
83
 
78
- ### 2) Add Auth Core
84
+ From your Next.js app root, use `npx`:
79
85
 
80
86
  ```bash
81
- npx nextworks add auth-core
87
+ npx nextworks@latest --help
82
88
  ```
83
89
 
84
- Then:
85
-
86
- 1. Copy and edit your environment variables:
87
-
88
- ```bash
89
- cp .env.example .env
90
- ```
91
-
92
- Set at minimum:
93
-
94
- ```bash
95
- DATABASE_URL=postgres://...
96
- NEXTAUTH_URL=http://localhost:3000
97
- NEXTAUTH_SECRET=your-strong-secret
98
- ```
99
-
100
- 2. Install Prisma (if you haven’t already):
101
-
102
- ```bash
103
- npm install @prisma/client prisma
104
- ```
105
-
106
- 3. Run Prisma:
107
-
108
- ```bash
109
- npx prisma generate
110
- npx prisma migrate dev -n init
111
- ```
112
-
113
- Start your dev server:
90
+ Example commands:
114
91
 
115
92
  ```bash
116
- npm run dev
93
+ npx nextworks@latest add blocks --sections --templates
94
+ npx nextworks@latest add blocks --sections --templates --yes # non-interactive / CI
117
95
  ```
118
96
 
119
- Visit:
97
+ ---
120
98
 
121
- - `/auth/signup`
122
- - `/auth/login`
123
- - `/dashboard` (protected)
99
+ ## Getting started in an existing Next.js app
124
100
 
125
- ### 3) Add Forms (optional)
101
+ Prerequisites:
126
102
 
127
- ```bash
128
- npx nextworks add forms
129
- ```
103
+ - A Next.js project (App Router **or** Pages Router).
104
+ - TypeScript required.
105
+ - Tailwind CSS required (the Blocks kit and templates rely on Tailwind classes).
130
106
 
131
- This adds form primitives and example pages:
107
+ From your app root:
132
108
 
133
- - `/examples/forms/basic`
134
- - `/examples/forms/server-action`
135
- - `/examples/forms/wizard`
109
+ ### 1) Install Blocks (UI kit)
136
110
 
137
- ### 4) Add Data (optional, requires Auth Core)
111
+ Non-interactive / CI-friendly (auto-accept defaults where possible):
138
112
 
139
113
  ```bash
140
- npx nextworks add data
114
+ npx nextworks@latest add blocks --sections --templates --yes
141
115
  ```
142
116
 
143
- Make sure your Prisma migrations are up to date:
117
+ > **Turbopack / Next 16 note (fonts + AppProviders)**
118
+ >
119
+ > Shared packages intentionally avoid importing `next/font/*`.
120
+ > Fonts are configured directly in your app’s router entrypoint (the CLI patches this for you):
121
+ >
122
+ > - App Router: `app/layout.tsx`
123
+ > - Pages Router: `pages/_app.tsx`
124
+ > This avoids Turbopack dev issues related to internal Next font modules.
125
+ >
126
+ > If you ever see a font-related Turbopack error after upgrades or manual edits, re-run:
127
+ >
128
+ > ```bash
129
+ > npx nextworks@latest add blocks --sections --templates
130
+ > ```
131
+ >
132
+ > to re-apply the patch, and ensure your router entrypoint contains a valid
133
+ > `import { ... } from "next/font/google";` plus the corresponding `const geistSans = ...` etc.
134
+ >
135
+ > - App Router: `app/layout.tsx`
136
+ > - Pages Router: `pages/_app.tsx`
144
137
 
145
138
  ```bash
146
- npx prisma generate
147
- npx prisma migrate dev
139
+ npx nextworks@latest add blocks --sections --templates
148
140
  ```
149
141
 
150
- Then visit:
142
+ This copies:
143
+
144
+ - `components/ui/*` (core UI primitives)
145
+ - `components/sections/*` (reusable sections)
146
+ - Templates (router-native):
147
+ - App Router projects: `app/templates/*`
148
+ - Pages Router projects: `pages/templates/<template>/index.tsx`
149
+ - Theme helpers and `app/globals.css` (if not already present)
150
+
151
+ After this step you should be able to start your dev server and visit:
151
152
 
152
- - `/admin/posts`
153
- - `/admin/users`
153
+ - `/` (if wired as the home page), or
154
+ - `/templates/productlaunch`, `/templates/saasdashboard`, `/templates/digitalagency`
154
155
 
155
156
  ---
156
157
 
@@ -159,15 +160,21 @@ Then visit:
159
160
  For a full UI kit including core primitives, sections, and templates, use:
160
161
 
161
162
  ```bash
162
- npx nextworks add blocks --sections --templates
163
+ npx nextworks@latest add blocks --sections --templates
164
+ ```
165
+
166
+ Non-interactive / CI-friendly:
167
+
168
+ ```bash
169
+ npx nextworks@latest add blocks --sections --templates --yes
163
170
  ```
164
171
 
165
172
  If you want finer control:
166
173
 
167
- - `npx nextworks add blocks --ui-only` – install core UI primitives only (no sections/templates).
168
- - `npx nextworks add blocks --sections` – install core + sections only.
169
- - `npx nextworks add blocks --templates` – install core + templates only.
170
- - `npx nextworks add blocks --sections --templates` – install core + sections + templates.
174
+ - `npx nextworks@latest add blocks --ui-only` – install core UI primitives only (no sections/templates).
175
+ - `npx nextworks@latest add blocks --sections` – install core + sections only.
176
+ - `npx nextworks@latest add blocks --templates` – install core + templates only.
177
+ - `npx nextworks@latest add blocks --sections --templates` – install core + sections + templates.
171
178
 
172
179
  ---
173
180
 
@@ -176,41 +183,29 @@ If you want finer control:
176
183
  You can add a short “Nextworks setup” section to your app README:
177
184
 
178
185
  ```md
179
- ### Nextworks setup (Blocks + Auth + optional Forms/Data)
186
+ ### Nextworks setup (Blocks)
180
187
 
181
188
  1. Install and run the CLI from your Next.js app root:
182
189
 
183
- npx nextworks add blocks --sections --templates
184
- npx nextworks add auth-core
185
-
186
- 2. Copy environment variables:
187
-
188
- cp .env.example .env
189
-
190
- Set DATABASE_URL, NEXTAUTH_URL, NEXTAUTH_SECRET (and any OAuth or email provider vars you need).
191
-
192
- 3. Install Prisma (if not present) and run migrations:
190
+ npx nextworks@latest add blocks --sections --templates
193
191
 
194
- npm install @prisma/client prisma
195
- npx prisma generate
196
- npx prisma migrate dev -n init
192
+ # CI / non-interactive:
197
193
 
198
- 4. (Optional) Add Forms and Data kits:
194
+ npx nextworks@latest add blocks --sections --templates --yes
199
195
 
200
- npx nextworks add forms
201
- npx nextworks add data
202
- npx prisma generate
203
- npx prisma migrate dev -n init_data
204
-
205
- 5. Start dev server:
196
+ 2. Start dev server:
206
197
 
207
198
  npm run dev
208
199
 
209
- 6. Try these routes:
210
- - `/` or `/templates/productlaunch` (Blocks template)
211
- - `/auth/signup`, `/auth/login`, `/dashboard` (Auth)
212
- - `/examples/forms/basic` (if you ran `npx nextworks add forms`)
213
- - `/admin/posts`, `/admin/users` (if you ran `npx nextworks add data`)
200
+ 3. Try these routes:
201
+ - `/templates/productlaunch`
202
+ - `/templates/saasdashboard`
203
+ - `/templates/digitalagency`
204
+ - `/templates/gallery`
205
+
206
+ Template files live at:
207
+ - App Router: `app/templates/...`
208
+ - Pages Router: `pages/templates/<template>/index.tsx`
214
209
  ```
215
210
 
216
211
  ---
@@ -228,27 +223,6 @@ the MIT License.
228
223
 
229
224
  ## Troubleshooting
230
225
 
231
- - **Prisma errors or missing migrations**
232
-
233
- Ensure you’ve run:
234
-
235
- ```bash
236
- npx prisma generate
237
- npx prisma migrate dev
238
- ```
239
-
240
- and that `DATABASE_URL` in `.env` points to a reachable PostgreSQL instance.
241
-
242
- - **Auth routes 404**
243
-
244
- Make sure you ran:
245
-
246
- ```bash
247
- npx nextworks add auth-core
248
- ```
249
-
250
- from your app root, and restart your dev server.
251
-
252
226
  - **Type errors from imported components**
253
227
 
254
228
  Confirm your project is using TypeScript and that your TypeScript config picks up the new `components/` and `lib/` paths.
@@ -27,11 +27,15 @@
27
27
  "components/ui/theme-toggle.tsx",
28
28
  "components/ui/toaster.tsx",
29
29
  "components/enhanced-theme-provider.tsx",
30
+ "components/providers/BlocksAppProviders.tsx",
30
31
  "components/app-providers.tsx",
32
+ "components/app-providers.app.tsx",
33
+ "components/app-providers.pages.tsx",
31
34
  "components/theme-provider.tsx",
32
35
  "lib/themes.ts",
33
36
  "lib/utils.ts",
34
37
  "app/globals.css",
38
+ "app/tw-animate.css",
35
39
  "next.config.ts",
36
40
  ".nextworks/docs/THEME_GUIDE.md",
37
41
  ".nextworks/docs/BLOCKS_README.md",
@@ -85,11 +89,15 @@
85
89
  "components/ui/theme-toggle.tsx",
86
90
  "components/ui/toaster.tsx",
87
91
  "components/enhanced-theme-provider.tsx",
92
+ "components/providers/BlocksAppProviders.tsx",
88
93
  "components/app-providers.tsx",
94
+ "components/app-providers.app.tsx",
95
+ "components/app-providers.pages.tsx",
89
96
  "components/theme-provider.tsx",
90
97
  "lib/themes.ts",
91
98
  "lib/utils.ts",
92
99
  "app/globals.css",
100
+ "app/tw-animate.css",
93
101
  "next.config.ts",
94
102
 
95
103
  "app/templates/productlaunch/page.tsx",
@@ -3,6 +3,8 @@ export interface AddBlocksOptions {
3
3
  templates?: boolean;
4
4
  gallery?: boolean;
5
5
  uiOnly?: boolean;
6
+ /** Skip interactive prompts and accept defaults. */
7
+ yes?: boolean;
6
8
  }
7
9
  export declare function addBlocks(options?: AddBlocksOptions): Promise<void>;
8
10
  //# sourceMappingURL=blocks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/commands/blocks.ts"],"names":[],"mappings":"AAyBA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2Q7E"}
1
+ {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/commands/blocks.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oDAAoD;IACpD,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,wBAAsB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAya7E"}
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -143,29 +176,88 @@ async function addBlocks(options = {}) {
143
176
  await (0, installation_tracker_1.addInstalledKit)("blocks", Object.keys(deps.dependencies || {}), Object.keys(deps.devDependencies || {}), filesToCopy);
144
177
  console.log("✓ blocks kit installed successfully!");
145
178
  let layoutUpgraded = false;
146
- // Offer to auto-upgrade app/layout.tsx to use AppProviders
147
- if (await (0, file_operations_1.fileExists)("app/layout.tsx")) {
148
- // Dynamically load inquirer to avoid ESM/CJS interop issues when
149
- // the CLI is compiled to CommonJS but inquirer is ESM-only.
150
- let promptFn;
179
+ let pagesAppUpgraded = false;
180
+ // Offer to auto-upgrade the root layout to use AppProviders (App Router)
181
+ // (supports both root app/layout.tsx and src/app/layout.tsx)
182
+ const mode = await (0, file_operations_1.detectProjectRootMode)(process.cwd());
183
+ const detectedLayoutPath = mode === "src" ? "src/app/layout.tsx" : "app/layout.tsx";
184
+ const detectedPagesAppPath = mode === "src" ? "src/pages/_app.tsx" : "pages/_app.tsx";
185
+ // Dynamically load inquirer to avoid ESM/CJS interop issues when
186
+ // the CLI is compiled to CommonJS but inquirer is ESM-only.
187
+ let promptFn;
188
+ try {
189
+ // Use a runtime dynamic import via the Function constructor to ensure
190
+ // we call the native import() at runtime and avoid TypeScript
191
+ // transpilation turning this into a require() call.
192
+ const inquirerModule = await new Function('return import("inquirer")')();
193
+ // inquirer exports a default object with prompt; support both shapes
194
+ promptFn = inquirerModule?.default?.prompt ?? inquirerModule?.prompt;
195
+ }
196
+ catch (err) {
197
+ console.log("⚠️ Could not load optional interactive prompt (inquirer). Skipping optional layout/_app upgrades.");
198
+ promptFn = null;
199
+ }
200
+ const appRouterLayoutExists = await (0, file_operations_1.fileExists)(detectedLayoutPath);
201
+ const pagesRouterAppExists = await (0, file_operations_1.fileExists)(detectedPagesAppPath);
202
+ // Hybrid projects (common with create-next-app) may have both /app and /pages.
203
+ // In that case we should patch BOTH entrypoints so routes in either router
204
+ // are wrapped with providers.
205
+ if (appRouterLayoutExists && pagesRouterAppExists) {
151
206
  try {
152
- // Use a runtime dynamic import via the Function constructor to ensure
153
- // we call the native import() at runtime and avoid TypeScript
154
- // transpilation turning this into a require() call.
155
- const inquirerModule = await new Function('return import("inquirer")')();
156
- // inquirer exports a default object with prompt; support both shapes
157
- promptFn = inquirerModule?.default?.prompt ?? inquirerModule?.prompt;
207
+ await (0, file_operations_1.updateLayoutWithAppProviders)();
208
+ layoutUpgraded = true;
158
209
  }
159
210
  catch (err) {
160
- console.log("⚠️ Could not load optional interactive prompt (inquirer). Skipping layout upgrade.");
161
- promptFn = null;
211
+ console.log("⚠️ Failed to update app/layout.tsx automatically:", err);
212
+ }
213
+ try {
214
+ await (0, file_operations_1.updatePagesAppWithAppProviders)();
215
+ await (0, file_operations_1.ensurePagesDocumentSuppressHydrationWarning)();
216
+ // Ensure pages/_app.tsx uses the Pages-safe AppProviders implementation.
217
+ const candidatePagesAppProvidersPaths = [
218
+ "components/app-providers.pages.tsx",
219
+ "src/components/app-providers.pages.tsx",
220
+ ];
221
+ for (const appProvidersPath of candidatePagesAppProvidersPaths) {
222
+ if (await (0, file_operations_1.fileExists)(appProvidersPath)) {
223
+ const fsExtraModule = await Promise.resolve().then(() => __importStar(require("fs-extra")));
224
+ await fsExtraModule.default.writeFile(appProvidersPath, "\"use client\";\n\nimport * as React from \"react\";\n\nimport { BlocksAppProviders } from \"./providers/BlocksAppProviders\";\n\nexport default function AppProviders({ children }: { children: React.ReactNode }) {\n return (\n <div className=\"antialiased\">\n <BlocksAppProviders>{children}</BlocksAppProviders>\n </div>\n );\n}\n");
225
+ }
226
+ }
227
+ // Ensure root components/app-providers.tsx points to the App Router variant
228
+ // so app/layout.tsx imports the correct implementation.
229
+ const candidateRootAppProvidersPaths = [
230
+ "components/app-providers.tsx",
231
+ "src/components/app-providers.tsx",
232
+ ];
233
+ for (const appProvidersPath of candidateRootAppProvidersPaths) {
234
+ if (await (0, file_operations_1.fileExists)(appProvidersPath)) {
235
+ const fsExtraModule = await Promise.resolve().then(() => __importStar(require("fs-extra")));
236
+ await fsExtraModule.default.writeFile(appProvidersPath, 'export { default } from "./app-providers.app";\n');
237
+ }
238
+ }
239
+ pagesAppUpgraded = true;
162
240
  }
163
- if (promptFn) {
241
+ catch (err) {
242
+ console.log("⚠️ Failed to update pages/_app.tsx automatically:", err);
243
+ }
244
+ }
245
+ else if (appRouterLayoutExists) {
246
+ if (options.yes) {
247
+ try {
248
+ await (0, file_operations_1.updateLayoutWithAppProviders)();
249
+ layoutUpgraded = true;
250
+ }
251
+ catch (err) {
252
+ console.log("⚠️ Failed to update app/layout.tsx automatically:", err);
253
+ }
254
+ }
255
+ else if (promptFn) {
164
256
  const { upgradeLayout } = await promptFn([
165
257
  {
166
258
  type: "confirm",
167
259
  name: "upgradeLayout",
168
- message: "Would you like the CLI to automatically wrap your app/layout.tsx with AppProviders and add suppressHydrationWarning to the <html> tag?",
260
+ message: `Would you like the CLI to automatically wrap your ${detectedLayoutPath} with AppProviders and add suppressHydrationWarning to the <html> tag?`,
169
261
  default: true,
170
262
  },
171
263
  ]);
@@ -180,21 +272,97 @@ async function addBlocks(options = {}) {
180
272
  }
181
273
  }
182
274
  }
275
+ else if (await (0, file_operations_1.fileExists)(detectedPagesAppPath)) {
276
+ // Pages Router support:
277
+ // - patch pages/_app.tsx (+ ensure _document.tsx hydration safety)
278
+ // - switch the kit-provided app-providers entrypoint to the Pages-safe variant
279
+ if (options.yes) {
280
+ try {
281
+ await (0, file_operations_1.updatePagesAppWithAppProviders)();
282
+ await (0, file_operations_1.ensurePagesDocumentSuppressHydrationWarning)();
283
+ // Make app-providers.tsx point at the Pages-safe implementation.
284
+ // (The kit defaults to App Router; Pages Router can't import @nextworks/blocks-core/server.)
285
+ //
286
+ // Patch whichever path exists (some repos have src/pages but root-level components/).
287
+ const candidateAppProvidersPaths = [
288
+ "components/app-providers.tsx",
289
+ "src/components/app-providers.tsx",
290
+ ];
291
+ for (const appProvidersPath of candidateAppProvidersPaths) {
292
+ if (await (0, file_operations_1.fileExists)(appProvidersPath)) {
293
+ const fsExtraModule = await Promise.resolve().then(() => __importStar(require("fs-extra")));
294
+ await fsExtraModule.default.writeFile(appProvidersPath, 'export { default } from "./app-providers.pages";\n');
295
+ }
296
+ }
297
+ pagesAppUpgraded = true;
298
+ }
299
+ catch (err) {
300
+ console.log("⚠️ Failed to update pages/_app.tsx automatically:", err);
301
+ }
302
+ }
303
+ else if (promptFn) {
304
+ const { upgradePagesApp } = await promptFn([
305
+ {
306
+ type: "confirm",
307
+ name: "upgradePagesApp",
308
+ message: `Would you like the CLI to automatically wrap your ${detectedPagesAppPath} with AppProviders (and ensure suppressHydrationWarning in pages/_document.tsx)?`,
309
+ default: true,
310
+ },
311
+ ]);
312
+ if (upgradePagesApp) {
313
+ try {
314
+ await (0, file_operations_1.updatePagesAppWithAppProviders)();
315
+ await (0, file_operations_1.ensurePagesDocumentSuppressHydrationWarning)();
316
+ // Make app-providers.tsx point at the Pages-safe implementation.
317
+ // (The kit defaults to App Router; Pages Router can't import @nextworks/blocks-core/server.)
318
+ //
319
+ // Patch whichever path exists (some repos have src/pages but root-level components/).
320
+ const candidateAppProvidersPaths = [
321
+ "components/app-providers.tsx",
322
+ "src/components/app-providers.tsx",
323
+ ];
324
+ for (const appProvidersPath of candidateAppProvidersPaths) {
325
+ if (await (0, file_operations_1.fileExists)(appProvidersPath)) {
326
+ const fsExtraModule = await Promise.resolve().then(() => __importStar(require("fs-extra")));
327
+ await fsExtraModule.default.writeFile(appProvidersPath, 'export { default } from "./app-providers.pages";\n');
328
+ }
329
+ }
330
+ pagesAppUpgraded = true;
331
+ }
332
+ catch (err) {
333
+ console.log("⚠️ Failed to update pages/_app.tsx automatically:", err);
334
+ }
335
+ }
336
+ }
337
+ }
183
338
  console.log("\n📋 Next steps:");
184
339
  console.log("- Templates added. Try these routes in your browser:");
185
340
  console.log(" /templates/productlaunch");
186
341
  console.log(" /templates/saasdashboard");
187
342
  console.log(" /templates/digitalagency");
188
343
  console.log(" /templates/gallery (blocks gallery)");
189
- if (!layoutUpgraded) {
190
- console.log("1. Wrap your app with the AppProviders wrapper in app/layout.tsx (or your root layout):");
191
- console.log(' import AppProviders from "@/components/app-providers";');
192
- console.log(" Wrap your application with <AppProviders> to enable fonts, presets, CSS variable injection, session provider, and the app toaster.");
344
+ // Note: depending on router type, the templates are installed into different folders,
345
+ // but the URLs are the same.
346
+ if (pagesRouterAppExists && !appRouterLayoutExists) {
347
+ console.log(` (Pages Router install: files live under ${mode === "src" ? "src/pages/templates/<template>/index.tsx" : "pages/templates/<template>/index.tsx"})`);
348
+ }
349
+ else {
350
+ console.log(` (App Router install: files live under ${mode === "src" ? "src/app/templates" : "app/templates"})`);
351
+ }
352
+ if (layoutUpgraded) {
353
+ console.log(`1. ${detectedLayoutPath} was updated to wrap the app with AppProviders and add suppressHydrationWarning.`);
193
354
  console.log("2. Ensure Tailwind is configured and app/globals.css is present (copied if available).");
194
355
  console.log("3. Install new dependencies: npm install");
195
356
  }
357
+ else if (pagesAppUpgraded) {
358
+ console.log(`1. ${detectedPagesAppPath} was updated to wrap the app with AppProviders (and fonts).`);
359
+ console.log("2. pages/_document.tsx was ensured/updated to include suppressHydrationWarning.");
360
+ console.log("3. Install new dependencies: npm install");
361
+ }
196
362
  else {
197
- console.log("1. app/layout.tsx was updated to wrap the app with AppProviders and add suppressHydrationWarning.");
363
+ console.log(`1. Wrap your app with the AppProviders wrapper in ${detectedLayoutPath} (App Router) or ${detectedPagesAppPath} (Pages Router):`);
364
+ console.log(' import AppProviders from "@/components/app-providers";');
365
+ console.log(" Wrap your application with <AppProviders> to enable fonts, presets, CSS variable injection, session provider, and the app toaster.");
198
366
  console.log("2. Ensure Tailwind is configured and app/globals.css is present (copied if available).");
199
367
  console.log("3. Install new dependencies: npm install");
200
368
  }