create-next-mui 0.1.1 → 0.1.3

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 (53) hide show
  1. package/README.md +141 -54
  2. package/{next-mui-template-ts → next-mui-templates/base-js}/package-lock.json +39 -5
  3. package/{next-mui-template-js → next-mui-templates/base-js}/package.json +1 -1
  4. package/{next-mui-template-js → next-mui-templates/base-ts}/package-lock.json +37 -3
  5. package/{next-mui-template-ts → next-mui-templates/base-ts}/package.json +1 -1
  6. package/package.json +2 -4
  7. package/src/index.js +136 -52
  8. /package/{next-mui-template-js → next-mui-templates/base-js}/.vscode/settings.json +0 -0
  9. /package/{next-mui-template-js → next-mui-templates/base-js}/.vscode/typescript.code-snippets +0 -0
  10. /package/{next-mui-template-js → next-mui-templates/base-js}/eslint.config.mjs +0 -0
  11. /package/{next-mui-template-js → next-mui-templates/base-js}/jsconfig.json +0 -0
  12. /package/{next-mui-template-js → next-mui-templates/base-js}/next.config.js +0 -0
  13. /package/{next-mui-template-js → next-mui-templates/base-js}/public/mui.svg +0 -0
  14. /package/{next-mui-template-js → next-mui-templates/base-js}/public/next.svg +0 -0
  15. /package/{next-mui-template-js → next-mui-templates/base-js}/public/vercel.svg +0 -0
  16. /package/{next-mui-template-js → next-mui-templates/base-js}/src/app/favicon.ico +0 -0
  17. /package/{next-mui-template-js → next-mui-templates/base-js}/src/app/globals.css +0 -0
  18. /package/{next-mui-template-js → next-mui-templates/base-js}/src/app/layout.jsx +0 -0
  19. /package/{next-mui-template-js → next-mui-templates/base-js}/src/app/page.jsx +0 -0
  20. /package/{next-mui-template-js → next-mui-templates/base-js}/src/config-global.js +0 -0
  21. /package/{next-mui-template-js → next-mui-templates/base-js}/src/lib/router-link/index.js +0 -0
  22. /package/{next-mui-template-js → next-mui-templates/base-js}/src/sections/home/view.jsx +0 -0
  23. /package/{next-mui-template-js → next-mui-templates/base-js}/src/theme/core/colors.json +0 -0
  24. /package/{next-mui-template-js → next-mui-templates/base-js}/src/theme/core/components/button.js +0 -0
  25. /package/{next-mui-template-js → next-mui-templates/base-js}/src/theme/core/components/card.js +0 -0
  26. /package/{next-mui-template-js → next-mui-templates/base-js}/src/theme/core/components/index.js +0 -0
  27. /package/{next-mui-template-js → next-mui-templates/base-js}/src/theme/core/palette.js +0 -0
  28. /package/{next-mui-template-js → next-mui-templates/base-js}/src/theme/core/typography.js +0 -0
  29. /package/{next-mui-template-js → next-mui-templates/base-js}/src/theme/create-theme.js +0 -0
  30. /package/{next-mui-template-js → next-mui-templates/base-js}/src/theme/theme-provider.jsx +0 -0
  31. /package/{next-mui-template-ts → next-mui-templates/base-ts}/.vscode/settings.json +0 -0
  32. /package/{next-mui-template-ts → next-mui-templates/base-ts}/.vscode/typescript.code-snippets +0 -0
  33. /package/{next-mui-template-ts → next-mui-templates/base-ts}/eslint.config.mjs +0 -0
  34. /package/{next-mui-template-ts → next-mui-templates/base-ts}/next.config.ts +0 -0
  35. /package/{next-mui-template-ts → next-mui-templates/base-ts}/public/mui.svg +0 -0
  36. /package/{next-mui-template-ts → next-mui-templates/base-ts}/public/next.svg +0 -0
  37. /package/{next-mui-template-ts → next-mui-templates/base-ts}/public/vercel.svg +0 -0
  38. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/app/favicon.ico +0 -0
  39. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/app/globals.css +0 -0
  40. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/app/layout.tsx +0 -0
  41. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/app/page.tsx +0 -0
  42. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/config-global.ts +0 -0
  43. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/lib/router-link/index.ts +0 -0
  44. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/sections/home/view.tsx +0 -0
  45. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/theme/core/colors.json +0 -0
  46. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/theme/core/components/button.ts +0 -0
  47. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/theme/core/components/card.ts +0 -0
  48. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/theme/core/components/index.ts +0 -0
  49. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/theme/core/palette.ts +0 -0
  50. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/theme/core/typography.ts +0 -0
  51. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/theme/create-theme.ts +0 -0
  52. /package/{next-mui-template-ts → next-mui-templates/base-ts}/src/theme/theme-provider.tsx +0 -0
  53. /package/{next-mui-template-ts → next-mui-templates/base-ts}/tsconfig.json +0 -0
package/README.md CHANGED
@@ -1,122 +1,209 @@
1
- <img width="1420" height="308" alt="CREATE-NEXT-MUI-BANNER" src="https://github.com/user-attachments/assets/11e72fc8-6b6d-40c4-97a1-c05f7b943e02" />
1
+ <img width="1420" alt="CREATE-NEXT-MUI-BANNER" src="https://github.com/user-attachments/assets/11e72fc8-6b6d-40c4-97a1-c05f7b943e02" />
2
2
 
3
- # create-next-mui 🚀
3
+ # create-next-mui
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/create-next-mui?style=flat&logo=npm&color=CB3837)](https://www.npmjs.com/package/create-next-mui)
6
- [![Next.js v19](https://img.shields.io/badge/Next.js-v19-000000?style=flat&logo=nextdotjs&logoColor=white)](https://nextjs.org/)
7
- [![MUI v9](https://img.shields.io/badge/MUI-v9-007FFF?style=flat&logo=mui&logoColor=white)](https://mui.com/)
6
+ [![Next.js](https://img.shields.io/badge/Next.js-v19-000000?style=flat&logo=nextdotjs&logoColor=white)](https://nextjs.org/)
7
+ [![MUI](https://img.shields.io/badge/MUI-v9-007FFF?style=flat&logo=mui&logoColor=white)](https://mui.com/)
8
8
 
9
- A blazing-fast, interactive CLI tool to instantly scaffold production-ready **Next.js** applications pre-configured with **Material UI (MUI)**, robust theme providers, and an elite architectural linting layout.
9
+ Scaffold a production-ready **Next.js + Material UI** application in seconds.
10
10
 
11
- Stop wasting time wiring up Emotion caches, Next.js App Router layout configs, or sorting your imports manually. Launch your next project perfectly in under 10 seconds.
11
+ The generated project comes preconfigured with:
12
+
13
+ - ⚡ Next.js App Router
14
+ - 🎨 Material UI
15
+ - 📦 TypeScript or JavaScript templates
16
+ - 🧹 ESLint Flat Config
17
+ - 📁 Scalable project structure
18
+
19
+ No global installation required.
12
20
 
13
21
  ---
14
22
 
15
- ## 🚀 Quick Start
23
+ # Quick Start
24
+
25
+ Create a new project:
26
+
27
+ ```bash
28
+ npx create-next-mui my-app
29
+ ```
16
30
 
17
- You don't need to install anything globally. Just run the following command in your terminal:
31
+ or
18
32
 
19
33
  ```bash
20
- npx create-next-mui my-next-mui-app
34
+ npm init next-mui
35
+ ```
21
36
 
22
- # or use prompts
37
+ If no project name is provided, the CLI will guide you through the setup interactively.
23
38
 
39
+ ```bash
24
40
  npx create-next-mui
41
+ ```
25
42
 
26
- # or
43
+ ---
27
44
 
28
- npm init next-mui
45
+ # Non-interactive Mode
46
+
47
+ Use the `--yes` (or `-y`) flag to skip prompts and accept the default configuration.
48
+
49
+ ```bash
50
+ npx create-next-mui my-app --yes
29
51
  ```
30
52
 
31
- Passing a project name creates that folder and uses the same name in the generated project metadata. If you omit the name, the interactive prompt engine (powered by `@clack/prompts`) will guide you through naming your project and selecting your preferred flavor.
53
+ This will automatically:
32
54
 
33
- ---
55
+ - use the provided project name
56
+ - select the **TypeScript** template
57
+ - generate the project without prompting
34
58
 
35
- ## Key Features
59
+ This is especially useful for:
36
60
 
37
- - **⚡ Modern Architecture:** Built natively on top of the Next.js App Router structure.
38
- - **🎨 Material UI Ready:** Seamless compilation of MUI components inside Server and Client Components with pre-configured UI themes.
39
- - **🧩 Dual-Template Architecture:** Full support for both **TypeScript** and **JavaScript** boilerplates.
40
- - **🧼 Perfectionist Linting Config:** Pre-packaged with **ESLint v9 Flat Config** (`eslint.config.mjs`) utilizing `eslint-plugin-perfectionist` and `eslint-plugin-unused-imports`.
41
- - **📦 Pure & Lightweight:** Zero bloat. Template files are automatically stripped of development artifacts (`node_modules`, caches) before build deployment.
61
+ - CI/CD pipelines
62
+ - automation scripts
63
+ - testing
64
+ - quick project generation
42
65
 
43
66
  ---
44
67
 
45
- ## 📦 Choice of Flavors
68
+ # Interactive Setup
69
+
70
+ Without `--yes`, the CLI walks you through the available options.
46
71
 
47
- During the prompt sequence, you can choose between two completely separate architectures, both fine-tuned for high-performance builds:
72
+ Current prompts include:
48
73
 
49
- 1. **TypeScript Template (`next-mui-template-ts`)** Out-of-the-box strong typing, custom theme module augmentations, and strict `@typescript-eslint` checking.
50
- 2. **JavaScript Template (`next-mui-template-js`)** Lightweight, clean vanilla ES modern syntax with optimized configuration overhead.
74
+ - Project name
75
+ - Language selection
76
+ - TypeScript (recommended)
77
+ - JavaScript
51
78
 
52
79
  ---
53
80
 
54
- ## 📐 Generated Project Structure
81
+ # Available Templates
82
+
83
+ ## TypeScript
84
+
85
+ Recommended for most projects.
86
+
87
+ Includes:
88
+
89
+ - TypeScript
90
+ - strict type checking
91
+ - MUI theme typings
92
+ - ESLint Flat Config
93
+
94
+ ## JavaScript
55
95
 
56
- No matter which path you choose, `create-next-mui` prints out an organized, production-grade layout optimized for scalability:
96
+ For developers who prefer JavaScript.
97
+
98
+ Includes:
99
+
100
+ - modern JavaScript
101
+ - Material UI
102
+ - ESLint Flat Config
103
+
104
+ ---
105
+
106
+ # Generated Project Structure
57
107
 
58
108
  ```text
59
- my-awesome-app/
109
+ my-app/
60
110
  ├── src/
61
111
  │ ├── app/
62
- ├── layout.js/ts # Handles App Router initialization & MUI Cache Provider
63
- │ │ └── page.js/ts # Pre-built home view utilizing responsive MUI layouts
64
- │ ├── components/ # Reusable global presentation components
112
+ │ ├── components/
65
113
  │ └── theme/
66
- ├── index.js/ts # Deep theme customization (palette, typography, overrides)
67
- │ └── theme-provider.js # Keeps layout tree hydrations isolated and performant
68
- ├── eslint.config.mjs # Elite natural line-length linting layout
69
- ├── next.config.js # Configured optimization vectors
114
+ ├── eslint.config.mjs
115
+ ├── next.config.js
70
116
  ├── package.json
71
117
  └── README.md
72
-
73
118
  ```
74
119
 
75
120
  ---
76
121
 
77
- ## 🎨 Elite Linting Layout (Perfectionist Grouping)
122
+ # What's Included
78
123
 
79
- Both boilerplate environments contain a fine-tuned, strict importing arrangement rule framework using `line-length` natural alpha sorting. Your files are automatically linted and organized cleanly on save down this architectural chain:
124
+ Every generated project comes configured with:
80
125
 
81
- 1. **React Core APIs** (`react`)
82
- 2. **Next.js Framework Hooks & Context** (`next/*`)
83
- 3. **Material UI Design Tokens & Engine** (`@mui/*`, `@emotion/*`)
84
- 4. **External Third-Party Libraries**
85
- 5. **Internal Layer Architectures** (`@/types`, `@/lib`, `@/components`, `@/theme`)
126
+ - Next.js App Router
127
+ - Material UI
128
+ - Theme Provider
129
+ - Emotion integration
130
+ - ESLint v9 Flat Config
131
+ - eslint-plugin-perfectionist
132
+ - eslint-plugin-unused-imports
133
+ - organized project structure
86
134
 
87
- Say goodbye to disorganized, messy blocks of import statements!
135
+ Development artifacts such as `node_modules`, `.next`, and build caches are excluded from generated projects.
88
136
 
89
137
  ---
90
138
 
91
- ## ⚙️ Development Scripts
139
+ # Getting Started
92
140
 
93
- Once your scaffolding finishes generating, step inside your directory and run the standard lifecycle workflows:
141
+ After scaffolding:
94
142
 
95
143
  ```bash
96
- # Install dependencies
144
+ cd my-app
97
145
  npm install
146
+ npm run dev
147
+ ```
148
+
149
+ Useful scripts:
98
150
 
99
- # Boot up local development server
151
+ ```bash
100
152
  npm run dev
153
+ ```
101
154
 
102
- # Run ESLint validation checks with automated file ordering adjustment
155
+ Start the development server.
156
+
157
+ ```bash
103
158
  npm run lint
159
+ ```
160
+
161
+ Run ESLint.
104
162
 
105
- # Compile production-ready code bundles
163
+ ```bash
106
164
  npm run build
165
+ ```
166
+
167
+ Create a production build.
168
+
169
+ ---
170
+
171
+ # CLI Reference
172
+
173
+ ## Create a project
107
174
 
175
+ ```bash
176
+ npx create-next-mui my-app
177
+ ```
178
+
179
+ ## Interactive mode
180
+
181
+ ```bash
182
+ npx create-next-mui
183
+ ```
184
+
185
+ ## Accept defaults
186
+
187
+ ```bash
188
+ npx create-next-mui my-app --yes
189
+ ```
190
+
191
+ or
192
+
193
+ ```bash
194
+ npx create-next-mui my-app -y
108
195
  ```
109
196
 
110
197
  ---
111
198
 
112
- ## 🤝 Contributing & Feedback
199
+ # Contributing
113
200
 
114
- Issues and pull requests are highly welcome! If you want to expand the templates or suggest additional components, feel free to open an issue or submit a pull request on the official repository.
201
+ Issues and pull requests are welcome.
115
202
 
116
- Maintained with 💻 by [thatonevikash](https://github.com/thatonevikash).
203
+ If you'd like to improve the templates or add new features, feel free to open an issue or submit a PR.
117
204
 
118
205
  ---
119
206
 
120
- ## 📜 License
207
+ # License
121
208
 
122
- This project is licensed under the MIT License - see the LICENSE file for details.
209
+ MIT
@@ -1,11 +1,11 @@
1
1
  {
2
- "name": "next-mui-template",
2
+ "name": "create-next-mui",
3
3
  "version": "0.0.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
- "name": "next-mui-template",
8
+ "name": "create-next-mui",
9
9
  "version": "0.0.1",
10
10
  "dependencies": {
11
11
  "@emotion/react": "^11.14.0",
@@ -276,9 +276,9 @@
276
276
  }
277
277
  },
278
278
  "node_modules/@emnapi/wasi-threads": {
279
- "version": "1.2.1",
280
- "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
281
- "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==",
279
+ "version": "1.2.2",
280
+ "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.2.tgz",
281
+ "integrity": "sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==",
282
282
  "dev": true,
283
283
  "license": "MIT",
284
284
  "optional": true,
@@ -2312,6 +2312,40 @@
2312
2312
  "node": ">=14.0.0"
2313
2313
  }
2314
2314
  },
2315
+ "node_modules/@unrs/resolver-binding-wasm32-wasi/node_modules/@emnapi/core": {
2316
+ "version": "1.10.0",
2317
+ "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz",
2318
+ "integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==",
2319
+ "dev": true,
2320
+ "license": "MIT",
2321
+ "optional": true,
2322
+ "dependencies": {
2323
+ "@emnapi/wasi-threads": "1.2.1",
2324
+ "tslib": "^2.4.0"
2325
+ }
2326
+ },
2327
+ "node_modules/@unrs/resolver-binding-wasm32-wasi/node_modules/@emnapi/runtime": {
2328
+ "version": "1.10.0",
2329
+ "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz",
2330
+ "integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==",
2331
+ "dev": true,
2332
+ "license": "MIT",
2333
+ "optional": true,
2334
+ "dependencies": {
2335
+ "tslib": "^2.4.0"
2336
+ }
2337
+ },
2338
+ "node_modules/@unrs/resolver-binding-wasm32-wasi/node_modules/@emnapi/wasi-threads": {
2339
+ "version": "1.2.1",
2340
+ "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
2341
+ "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==",
2342
+ "dev": true,
2343
+ "license": "MIT",
2344
+ "optional": true,
2345
+ "dependencies": {
2346
+ "tslib": "^2.4.0"
2347
+ }
2348
+ },
2315
2349
  "node_modules/@unrs/resolver-binding-win32-arm64-msvc": {
2316
2350
  "version": "1.12.2",
2317
2351
  "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-win32-arm64-msvc/-/resolver-binding-win32-arm64-msvc-1.12.2.tgz",
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "next-mui-template",
2
+ "name": "create-next-mui",
3
3
  "version": "0.0.1",
4
4
  "private": true,
5
5
  "scripts": {
@@ -276,9 +276,9 @@
276
276
  }
277
277
  },
278
278
  "node_modules/@emnapi/wasi-threads": {
279
- "version": "1.2.1",
280
- "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
281
- "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==",
279
+ "version": "1.2.2",
280
+ "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.2.tgz",
281
+ "integrity": "sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==",
282
282
  "dev": true,
283
283
  "license": "MIT",
284
284
  "optional": true,
@@ -2312,6 +2312,40 @@
2312
2312
  "node": ">=14.0.0"
2313
2313
  }
2314
2314
  },
2315
+ "node_modules/@unrs/resolver-binding-wasm32-wasi/node_modules/@emnapi/core": {
2316
+ "version": "1.10.0",
2317
+ "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz",
2318
+ "integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==",
2319
+ "dev": true,
2320
+ "license": "MIT",
2321
+ "optional": true,
2322
+ "dependencies": {
2323
+ "@emnapi/wasi-threads": "1.2.1",
2324
+ "tslib": "^2.4.0"
2325
+ }
2326
+ },
2327
+ "node_modules/@unrs/resolver-binding-wasm32-wasi/node_modules/@emnapi/runtime": {
2328
+ "version": "1.10.0",
2329
+ "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz",
2330
+ "integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==",
2331
+ "dev": true,
2332
+ "license": "MIT",
2333
+ "optional": true,
2334
+ "dependencies": {
2335
+ "tslib": "^2.4.0"
2336
+ }
2337
+ },
2338
+ "node_modules/@unrs/resolver-binding-wasm32-wasi/node_modules/@emnapi/wasi-threads": {
2339
+ "version": "1.2.1",
2340
+ "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz",
2341
+ "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==",
2342
+ "dev": true,
2343
+ "license": "MIT",
2344
+ "optional": true,
2345
+ "dependencies": {
2346
+ "tslib": "^2.4.0"
2347
+ }
2348
+ },
2315
2349
  "node_modules/@unrs/resolver-binding-win32-arm64-msvc": {
2316
2350
  "version": "1.12.2",
2317
2351
  "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-win32-arm64-msvc/-/resolver-binding-win32-arm64-msvc-1.12.2.tgz",
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "next-mui-template",
2
+ "name": "create-next-mui",
3
3
  "version": "0.0.1",
4
4
  "private": true,
5
5
  "scripts": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-next-mui",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "spin up your nextjs project with mui setup",
5
5
  "keywords": [
6
6
  "nextjs",
@@ -23,8 +23,7 @@
23
23
  },
24
24
  "files": [
25
25
  "src",
26
- "next-mui-template-ts",
27
- "next-mui-template-js"
26
+ "next-mui-templates"
28
27
  ],
29
28
  "main": "index.js",
30
29
  "scripts": {
@@ -32,7 +31,6 @@
32
31
  },
33
32
  "dependencies": {
34
33
  "@clack/prompts": "^1.5.0",
35
- "degit": "^3.3.2",
36
34
  "picocolors": "^1.1.1"
37
35
  }
38
36
  }
package/src/index.js CHANGED
@@ -6,12 +6,54 @@ import fs from "node:fs/promises";
6
6
  import path from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
 
9
- // Resolve the directory where this CLI package actually lives on the user's system
9
+ // ----------------------------------------------------------------------
10
+
10
11
  const __filename = fileURLToPath(import.meta.url);
11
12
  const __dirname = path.dirname(__filename);
12
13
 
13
- const initialProjectName = process.argv[2];
14
- const hasInitialProjectName = typeof initialProjectName === "string";
14
+ const args = process.argv.slice(2);
15
+
16
+ const positionalArgs = args.filter(
17
+ (arg) => !["--yes", "-y", "--js"].includes(arg),
18
+ );
19
+
20
+ const PROJECT_NAME = positionalArgs[0];
21
+ const hasInitialProjectName = PROJECT_NAME !== undefined;
22
+
23
+ const hasYesFlag = args.includes("--yes") || args.includes("-y");
24
+ const hasJsFlag = args.includes("--js");
25
+
26
+ const DEFAULT_LANGUAGE = hasJsFlag ? "js" : "ts";
27
+
28
+ // ----------------------------------------------------------------------
29
+
30
+ const LANG = [
31
+ {
32
+ value: "ts",
33
+ label: "TypeScript (Recommended)",
34
+ hint: "Strict typings, clean architecture",
35
+ },
36
+ {
37
+ value: "js",
38
+ label: "JavaScript",
39
+ hint: "Vanilla JS configuration",
40
+ },
41
+ ];
42
+
43
+ const FEATURES = [
44
+ {
45
+ value: "react-query",
46
+ label: "React Query",
47
+ hint: "TanStack Query configuration",
48
+ },
49
+ {
50
+ value: "zustand",
51
+ label: "Zustand",
52
+ hint: "Lightweight global state management",
53
+ },
54
+ ];
55
+
56
+ // ----------------------------------------------------------------------
15
57
 
16
58
  function validateProjectName(value) {
17
59
  if (value.length === 0) return "Project name is required!";
@@ -48,19 +90,21 @@ async function updateProjectName(targetProjectDir, packageName) {
48
90
  await fs.writeFile(filePath, `${JSON.stringify(json, null, 2)}\n`);
49
91
  } catch (error) {
50
92
  if (error.code === "ENOENT") return;
51
-
52
93
  throw error;
53
94
  }
54
95
  }),
55
96
  );
56
97
  }
57
98
 
99
+ // ----------------------------------------------------------------------
100
+
58
101
  async function main() {
59
102
  console.clear();
103
+
60
104
  p.intro(color.bgBlue(color.white(" create-next-mui ")));
61
105
 
62
106
  const projectNameError = hasInitialProjectName
63
- ? validateProjectName(initialProjectName)
107
+ ? validateProjectName(PROJECT_NAME)
64
108
  : undefined;
65
109
 
66
110
  if (projectNameError) {
@@ -72,28 +116,29 @@ async function main() {
72
116
  {
73
117
  name: () =>
74
118
  hasInitialProjectName
75
- ? Promise.resolve(initialProjectName)
119
+ ? Promise.resolve(PROJECT_NAME)
76
120
  : p.text({
77
121
  message: "What is your project name?",
78
122
  placeholder: "my-next-mui-app (or '.' for current directory)",
79
123
  validate: validateProjectName,
80
124
  }),
125
+
81
126
  language: () =>
82
- p.select({
83
- message: "Choose your language flavor:",
84
- options: [
85
- {
86
- value: "ts",
87
- label: "TypeScript (Recommended)",
88
- hint: "Strict typings, clean architecture",
89
- },
90
- {
91
- value: "js",
92
- label: "JavaScript",
93
- hint: "Vanilla JS configuration",
94
- },
95
- ],
96
- }),
127
+ hasYesFlag
128
+ ? Promise.resolve(DEFAULT_LANGUAGE)
129
+ : p.select({
130
+ message: "Choose your language flavor:",
131
+ options: LANG,
132
+ }),
133
+
134
+ features: () =>
135
+ hasYesFlag
136
+ ? Promise.resolve([])
137
+ : p.multiselect({
138
+ message: "Select optional features:",
139
+ required: false,
140
+ options: FEATURES,
141
+ }),
97
142
  },
98
143
  {
99
144
  onCancel: () => {
@@ -103,71 +148,110 @@ async function main() {
103
148
  },
104
149
  );
105
150
 
106
- // Define local source paths (inside this CLI package folder)
107
- const templateFolderName =
108
- project.language === "ts" ? "next-mui-template-ts" : "next-mui-template-js";
109
- const sourceTemplateDir = path.resolve(__dirname, "..", templateFolderName);
151
+ // --------------------------------------------------------------------
152
+ // Paths
153
+ // --------------------------------------------------------------------
154
+
155
+ const baseTemplateDir = path.resolve(
156
+ __dirname,
157
+ "..",
158
+ "next-mui-templates",
159
+ `base-${project.language}`,
160
+ );
110
161
 
111
- // Define destination paths (where the user is running the command)
112
162
  const targetProjectDir = path.resolve(process.cwd(), project.name);
163
+
113
164
  const packageName = getPackageName(project.name, targetProjectDir);
114
165
 
115
- // If targeting current directory, make sure it's clean
166
+ // --------------------------------------------------------------------
167
+ // Current directory validation
168
+ // --------------------------------------------------------------------
169
+
116
170
  if (project.name === ".") {
117
171
  try {
118
- const existingFiles = await fs.readdir(targetProjectDir);
119
- if (existingFiles.length > 0) {
172
+ const files = await fs.readdir(targetProjectDir);
173
+
174
+ if (files.length > 0) {
120
175
  p.log.error(
121
176
  color.red(
122
- "The current directory is not empty! Please clear it or specify a project name.",
177
+ "The current directory is not empty! Please clear it or specify another project name.",
123
178
  ),
124
179
  );
180
+
125
181
  process.exit(1);
126
182
  }
127
- } catch (err) {
128
- // If the directory reading fails completely, we exit safely
183
+ } catch {
129
184
  process.exit(1);
130
185
  }
131
186
  }
132
187
 
188
+ // --------------------------------------------------------------------
189
+
133
190
  const s = p.spinner();
134
- s.start("Unboxing your Next.js + MUI foundation locally...");
191
+
192
+ s.start("Scaffolding your Next.js + MUI workspace...");
135
193
 
136
194
  try {
137
- // Native high-speed recursive copy
138
- await fs.cp(sourceTemplateDir, targetProjectDir, {
195
+ // ------------------------------------------------------------------
196
+ // Copy base template
197
+ // ------------------------------------------------------------------
198
+
199
+ await fs.cp(baseTemplateDir, targetProjectDir, {
139
200
  recursive: true,
140
201
  filter: (src) => {
141
- const targetName = path.basename(src);
142
- return (
143
- targetName !== "node_modules" &&
144
- targetName !== ".next" &&
145
- targetName !== "out" &&
146
- targetName !== "build"
147
- );
202
+ const name = path.basename(src);
203
+
204
+ return !["node_modules", ".next", "out", "build"].includes(name);
148
205
  },
149
206
  });
207
+
208
+ // ------------------------------------------------------------------
209
+ // Apply selected features
210
+ // ------------------------------------------------------------------
211
+
212
+ for (const feature of project.features) {
213
+ const featureDir = path.resolve(
214
+ __dirname,
215
+ "..",
216
+ "next-mui-features",
217
+ feature,
218
+ project.language,
219
+ );
220
+
221
+ await fs.cp(featureDir, targetProjectDir, {
222
+ recursive: true,
223
+ filter: (src) => {
224
+ const name = path.basename(src);
225
+
226
+ return !["node_modules", ".next", "out", "build"].includes(name);
227
+ },
228
+ });
229
+ }
230
+
231
+ // ------------------------------------------------------------------
232
+
150
233
  await updateProjectName(targetProjectDir, packageName);
151
234
 
152
235
  s.stop(color.green("Workspace scaffolded successfully!"));
153
236
  } catch (error) {
154
- s.stop(color.red("Failed to build workspace structure."));
155
- p.note(color.yellow(`Error details: ${error.message}`), "Troubleshooting:");
237
+ s.stop(color.red("Failed to scaffold workspace."));
238
+
239
+ p.note(color.yellow(error.message), "Troubleshooting");
240
+
156
241
  process.exit(1);
157
242
  }
158
243
 
159
- // Clear instructions for the developer
160
- const isCurrentDir = project.name === ".";
161
- const cdInstruction = isCurrentDir
162
- ? ""
163
- : `${color.cyan(`cd ${project.name}`)}\n`;
244
+ // --------------------------------------------------------------------
245
+
246
+ const cd =
247
+ project.name === "." ? "" : `${color.cyan(`cd ${project.name}`)}\n`;
164
248
 
165
249
  p.note(
166
- `${cdInstruction}${color.cyan("npm install")}\n${color.cyan("npm run dev")}`,
167
- "Next Steps to Get Started:",
250
+ `${cd}${color.cyan("npm install")}\n${color.cyan("npm run dev")}`,
251
+ "Next Steps",
168
252
  );
169
253
 
170
- p.outro(`✨ Code cleanly, sort perfectly. Built with create-next-mui!`);
254
+ p.outro("✨ Build clean and fast with create-next-mui!");
171
255
  }
172
256
 
173
257
  main().catch(console.error);