create-modern-react 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +270 -72
- package/bin/index.js +9 -7
- package/lib/prompts.js +132 -150
- package/lib/setup.js +264 -143
- package/package.json +17 -8
- package/templates/base/.env.example +9 -0
- package/templates/base/.eslintrc.cjs +37 -0
- package/templates/base/.prettierrc +11 -0
- package/templates/base/components.json +17 -0
- package/templates/base/index.html +3 -2
- package/templates/base/package.json +34 -15
- package/templates/base/postcss.config.js +6 -0
- package/templates/base/src/App.tsx +7 -22
- package/templates/base/src/components/layout/error-boundary.tsx +60 -0
- package/templates/base/src/components/layout/index.ts +2 -0
- package/templates/base/src/components/layout/root-layout.tsx +36 -0
- package/templates/base/src/components/ui/button.tsx +55 -0
- package/templates/base/src/components/ui/card.tsx +85 -0
- package/templates/base/src/components/ui/index.ts +12 -0
- package/templates/base/src/components/ui/input.tsx +24 -0
- package/templates/base/src/components/ui/separator.tsx +29 -0
- package/templates/base/src/components/ui/skeleton.tsx +15 -0
- package/templates/base/src/hooks/index.ts +3 -0
- package/templates/base/src/hooks/use-cancel-token.ts +63 -0
- package/templates/base/src/hooks/use-debounce.ts +29 -0
- package/templates/base/src/hooks/use-loader.ts +39 -0
- package/templates/base/src/index.css +74 -61
- package/templates/base/src/lib/utils.ts +14 -0
- package/templates/base/src/main.tsx +6 -6
- package/templates/base/src/providers/index.tsx +27 -0
- package/templates/base/src/providers/theme-provider.tsx +92 -0
- package/templates/base/src/routes/index.tsx +40 -0
- package/templates/base/src/routes/routes.ts +36 -0
- package/templates/base/src/screens/home/index.tsx +132 -0
- package/templates/base/src/screens/not-found/index.tsx +29 -0
- package/templates/base/src/services/alertify-services.ts +133 -0
- package/templates/base/src/services/api/api-helpers.ts +130 -0
- package/templates/base/src/services/api/axios-instance.ts +77 -0
- package/templates/base/src/services/api/index.ts +9 -0
- package/templates/base/src/services/index.ts +2 -0
- package/templates/base/src/types/index.ts +55 -0
- package/templates/base/src/vite-env.d.ts +31 -0
- package/templates/base/tailwind.config.js +77 -0
- package/templates/base/tsconfig.json +5 -4
- package/templates/base/tsconfig.node.json +22 -0
- package/templates/base/vite.config.ts +68 -7
- package/templates/optional/antd/config-provider.tsx +33 -0
- package/templates/optional/antd/index.ts +2 -0
- package/templates/optional/antd/styles/antd-overrides.css +104 -0
- package/templates/optional/antd/theme.ts +75 -0
- package/templates/optional/husky/.husky/pre-commit +1 -0
- package/templates/optional/husky/.lintstagedrc.json +6 -0
- package/templates/optional/redux/hooks.ts +17 -0
- package/templates/optional/redux/index.ts +13 -0
- package/templates/optional/redux/provider.tsx +33 -0
- package/templates/optional/redux/store/index.ts +45 -0
- package/templates/optional/redux/store/slices/app-slice.ts +62 -0
- package/templates/base/src/App.css +0 -14
package/README.md
CHANGED
|
@@ -1,113 +1,311 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/facebook/react/main/fixtures/dom/public/react-logo.svg" width="80" alt="React Logo" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<h1 align="center">create-modern-react</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Production-ready React + TypeScript + Tailwind in 30 seconds</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/create-modern-react"><img src="https://img.shields.io/npm/v/create-modern-react.svg?style=flat-square&color=00d8ff" alt="npm version" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/create-modern-react"><img src="https://img.shields.io/npm/dm/create-modern-react.svg?style=flat-square&color=00d8ff" alt="npm downloads" /></a>
|
|
14
|
+
<a href="https://github.com/AabhashRai13/create-modern-react/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/create-modern-react.svg?style=flat-square&color=00d8ff" alt="license" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<code>npx create-modern-react my-app</code>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="https://www.npmjs.com/package/create-modern-react">
|
|
23
|
+
<img src="https://img.shields.io/badge/View%20on-npm-CB3837?style=for-the-badge&logo=npm&logoColor=white" alt="View on npm" />
|
|
24
|
+
</a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Why?
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
33
|
+
│ │
|
|
34
|
+
│ npm create vite@latest vs npx create-modern-react │
|
|
35
|
+
│ │
|
|
36
|
+
│ ✗ Empty src/ folder ✓ Complete project │
|
|
37
|
+
│ ✗ No styling solution ✓ Tailwind CSS ready │
|
|
38
|
+
│ ✗ No routing ✓ Wouter + lazy loading │
|
|
39
|
+
│ ✗ No API layer ✓ Axios + interceptors │
|
|
40
|
+
│ ✗ No UI components ✓ Shadcn/ui (5 components)│
|
|
41
|
+
│ ✗ No icons ✓ Lucide React │
|
|
42
|
+
│ ✗ No toast notifications ✓ react-hot-toast │
|
|
43
|
+
│ ✗ No error boundary ✓ Built-in │
|
|
44
|
+
│ ✗ Basic ESLint ✓ 25+ rules configured │
|
|
45
|
+
│ ✗ ~2 hours setup ✓ 30 seconds │
|
|
46
|
+
│ │
|
|
47
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Stop configuring. Start building.**
|
|
51
|
+
|
|
52
|
+
---
|
|
4
53
|
|
|
5
54
|
## Quick Start
|
|
6
55
|
|
|
7
56
|
```bash
|
|
8
57
|
npx create-modern-react my-app
|
|
9
58
|
cd my-app
|
|
10
|
-
|
|
59
|
+
yarn dev
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
That's it. Your app is running at `http://localhost:3000`
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## What's Included
|
|
67
|
+
|
|
68
|
+
### Core Stack (Every Project)
|
|
69
|
+
|
|
70
|
+
| Technology | Version | Purpose |
|
|
71
|
+
|------------|---------|---------|
|
|
72
|
+
| **React** | 18.3 | Latest features, concurrent rendering |
|
|
73
|
+
| **TypeScript** | 5.5 | Strict mode, full type safety |
|
|
74
|
+
| **Vite + SWC** | 5.4 | 20x faster than Babel |
|
|
75
|
+
| **Tailwind CSS** | 3.4 | Dark mode, CSS variables |
|
|
76
|
+
| **Shadcn/ui** | Latest | Button, Input, Card, Skeleton, Separator |
|
|
77
|
+
| **Wouter** | 3.3 | 2KB router (vs 28KB React Router) |
|
|
78
|
+
| **Axios** | 1.7 | Interceptors, cancel tokens |
|
|
79
|
+
| **Lucide React** | Latest | Beautiful, consistent icons |
|
|
80
|
+
|
|
81
|
+
### Build Optimizations
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
┌────────────────────┬────────────────────────────────────────┐
|
|
85
|
+
│ SWC Compiler │ 20x faster than Babel │
|
|
86
|
+
├────────────────────┼────────────────────────────────────────┤
|
|
87
|
+
│ Gzip Compression │ Pre-compressed .gz files (1KB thresh.) │
|
|
88
|
+
├────────────────────┼────────────────────────────────────────┤
|
|
89
|
+
│ Chunk Splitting │ Separate vendor + router bundles │
|
|
90
|
+
├────────────────────┼────────────────────────────────────────┤
|
|
91
|
+
│ Tree Shaking │ Dead code elimination │
|
|
92
|
+
├────────────────────┼────────────────────────────────────────┤
|
|
93
|
+
│ Console Removal │ Auto-stripped in production │
|
|
94
|
+
├────────────────────┼────────────────────────────────────────┤
|
|
95
|
+
│ SVG Components │ Import SVGs as React components │
|
|
96
|
+
└────────────────────┴────────────────────────────────────────┘
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Optional Features
|
|
100
|
+
|
|
101
|
+
Select during project creation:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
[ ] Redux Toolkit + Redux Persist ── State management with persistence
|
|
105
|
+
[ ] Ant Design v5 ───────────────── Enterprise UI (replaces Shadcn/ui)
|
|
106
|
+
[ ] Husky + lint-staged ─────────── Git hooks for code quality
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Generated Structure
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
my-app/
|
|
115
|
+
├── src/
|
|
116
|
+
│ ├── components/
|
|
117
|
+
│ │ ├── ui/ # Shadcn/ui components
|
|
118
|
+
│ │ │ ├── button.tsx
|
|
119
|
+
│ │ │ ├── input.tsx
|
|
120
|
+
│ │ │ ├── card.tsx
|
|
121
|
+
│ │ │ ├── skeleton.tsx
|
|
122
|
+
│ │ │ └── separator.tsx
|
|
123
|
+
│ │ └── layout/
|
|
124
|
+
│ │ ├── root-layout.tsx
|
|
125
|
+
│ │ └── error-boundary.tsx
|
|
126
|
+
│ ├── hooks/
|
|
127
|
+
│ │ ├── use-loader.ts # Loading state management
|
|
128
|
+
│ │ ├── use-debounce.ts # Value debouncing
|
|
129
|
+
│ │ └── use-cancel-token.ts # Axios request cancellation
|
|
130
|
+
│ ├── routes/
|
|
131
|
+
│ │ └── index.tsx # Wouter + lazy loading
|
|
132
|
+
│ ├── screens/
|
|
133
|
+
│ │ ├── home/
|
|
134
|
+
│ │ └── not-found/
|
|
135
|
+
│ ├── services/
|
|
136
|
+
│ │ ├── api/
|
|
137
|
+
│ │ │ ├── axios-instance.ts
|
|
138
|
+
│ │ │ └── api-helpers.ts # getApi, postApi, patchApi...
|
|
139
|
+
│ │ └── alertify-services.ts
|
|
140
|
+
│ ├── providers/
|
|
141
|
+
│ │ └── theme-provider.tsx
|
|
142
|
+
│ ├── lib/
|
|
143
|
+
│ │ └── utils.ts # cn() utility
|
|
144
|
+
│ └── types/
|
|
145
|
+
├── vite.config.ts # SWC + SVGR + Compression
|
|
146
|
+
├── tailwind.config.js # Dark mode + CSS variables
|
|
147
|
+
├── tsconfig.json # Strict mode + path aliases
|
|
148
|
+
└── .eslintrc.cjs # 25+ rules configured
|
|
11
149
|
```
|
|
12
150
|
|
|
151
|
+
---
|
|
152
|
+
|
|
13
153
|
## Features
|
|
14
154
|
|
|
15
|
-
|
|
16
|
-
📦 **Interactive Setup**: Choose your preferred libraries
|
|
17
|
-
🎨 **UI Libraries**: Ant Design, Material-UI, Chakra UI support
|
|
18
|
-
🎯 **State Management**: Redux Toolkit, Zustand, Jotai options
|
|
19
|
-
🛣️ **Routing**: React Router or Wouter
|
|
20
|
-
🔧 **Development Tools**: ESLint, Prettier, Storybook, Testing
|
|
21
|
-
🎨 **Styling**: Tailwind CSS, CSS Modules, Styled Components
|
|
22
|
-
📱 **PWA Ready**: Optional Progressive Web App support
|
|
155
|
+
### SVG as React Components
|
|
23
156
|
|
|
24
|
-
|
|
157
|
+
```tsx
|
|
158
|
+
import Logo from './logo.svg?react';
|
|
25
159
|
|
|
26
|
-
|
|
160
|
+
<Logo className="h-8 w-8 text-primary" />
|
|
161
|
+
```
|
|
27
162
|
|
|
28
|
-
|
|
29
|
-
|
|
163
|
+
### Type-Safe API Layer
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
import { getApi, postApi } from '~/services/api';
|
|
167
|
+
|
|
168
|
+
const users = await getApi<User[]>('/users');
|
|
169
|
+
const newUser = await postApi<User>('/users', { name: 'John' });
|
|
30
170
|
```
|
|
31
171
|
|
|
32
|
-
###
|
|
172
|
+
### Toast Notifications
|
|
33
173
|
|
|
34
|
-
```
|
|
35
|
-
|
|
174
|
+
```tsx
|
|
175
|
+
import { Alertify } from '~/services/alertify-services';
|
|
176
|
+
|
|
177
|
+
Alertify.success('Saved successfully');
|
|
178
|
+
Alertify.error('Something went wrong');
|
|
179
|
+
Alertify.loading('Processing...');
|
|
36
180
|
```
|
|
37
181
|
|
|
38
|
-
|
|
182
|
+
### Custom Hooks
|
|
39
183
|
|
|
40
|
-
|
|
184
|
+
```tsx
|
|
185
|
+
// Loading state
|
|
186
|
+
const [isLoading, startLoader, endLoader] = useLoader();
|
|
41
187
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- **Icons**: Lucide React, React Icons, Heroicons, or none
|
|
51
|
-
- **PWA**: Progressive Web App features
|
|
52
|
-
- **Git**: Initialize Git repository
|
|
188
|
+
const fetchData = async () => {
|
|
189
|
+
startLoader();
|
|
190
|
+
try {
|
|
191
|
+
await getApi('/users');
|
|
192
|
+
} finally {
|
|
193
|
+
endLoader();
|
|
194
|
+
}
|
|
195
|
+
};
|
|
53
196
|
|
|
54
|
-
|
|
197
|
+
// Debounced search
|
|
198
|
+
const debouncedQuery = useDebounce(searchQuery, 300);
|
|
55
199
|
|
|
56
|
-
|
|
200
|
+
// Cancel requests on unmount
|
|
201
|
+
const { cancelToken, cancel } = useCancelToken();
|
|
202
|
+
```
|
|
57
203
|
|
|
58
|
-
|
|
204
|
+
### Path Aliases
|
|
59
205
|
|
|
60
|
-
|
|
206
|
+
```tsx
|
|
207
|
+
// ❌ Instead of this:
|
|
208
|
+
import { Button } from '../../../components/ui/button';
|
|
61
209
|
|
|
62
|
-
|
|
210
|
+
// ✅ Write this:
|
|
211
|
+
import { Button } from '~/components/ui';
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Scripts
|
|
217
|
+
|
|
218
|
+
| Command | Description |
|
|
219
|
+
|---------|-------------|
|
|
220
|
+
| `yarn dev` | Start dev server (port 3000) |
|
|
221
|
+
| `yarn build` | Production build with gzip |
|
|
222
|
+
| `yarn preview` | Preview production build |
|
|
223
|
+
| `yarn lint` | Run ESLint |
|
|
224
|
+
| `yarn lint:fix` | Fix ESLint issues |
|
|
225
|
+
| `yarn format` | Format with Prettier |
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Build Output
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
dist/
|
|
233
|
+
├── assets/
|
|
234
|
+
│ ├── index-[hash].js # Main bundle
|
|
235
|
+
│ ├── index-[hash].js.gz # Gzipped (~70% smaller)
|
|
236
|
+
│ ├── vendor-[hash].js # React + ReactDOM (cached)
|
|
237
|
+
│ ├── router-[hash].js # Wouter (cached)
|
|
238
|
+
│ └── index-[hash].css.gz
|
|
239
|
+
└── index.html
|
|
240
|
+
```
|
|
63
241
|
|
|
64
|
-
|
|
242
|
+
---
|
|
65
243
|
|
|
66
|
-
|
|
244
|
+
## Comparison
|
|
67
245
|
|
|
68
|
-
|
|
246
|
+
| Feature | Vite | CRA | **create-modern-react** |
|
|
247
|
+
|---------|:----:|:---:|:-----------------------:|
|
|
248
|
+
| Build Speed | Fast | Slow | **Fastest (SWC)** |
|
|
249
|
+
| TypeScript | ✅ | ✅ | ✅ Strict |
|
|
250
|
+
| Tailwind CSS | ❌ | ❌ | ✅ |
|
|
251
|
+
| UI Components | ❌ | ❌ | ✅ |
|
|
252
|
+
| Routing | ❌ | ❌ | ✅ |
|
|
253
|
+
| API Layer | ❌ | ❌ | ✅ |
|
|
254
|
+
| Toast System | ❌ | ❌ | ✅ |
|
|
255
|
+
| Error Boundary | ❌ | ❌ | ✅ |
|
|
256
|
+
| Gzip Build | ❌ | ❌ | ✅ |
|
|
257
|
+
| SVG Components | ❌ | ✅ | ✅ |
|
|
258
|
+
| Dark Mode | ❌ | ❌ | ✅ |
|
|
259
|
+
| Path Aliases | ❌ | ❌ | ✅ |
|
|
260
|
+
| **Setup Time** | ~1hr | ~2hr | **30 sec** |
|
|
69
261
|
|
|
70
|
-
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Built With This Boilerplate
|
|
265
|
+
|
|
266
|
+
<p align="center">
|
|
267
|
+
<a href="https://resumefreepro.com">
|
|
268
|
+
<strong>ResumeFreePro.com</strong>
|
|
269
|
+
</a>
|
|
270
|
+
<br />
|
|
271
|
+
<em>Free AI-powered resume builder — built entirely with create-modern-react</em>
|
|
272
|
+
</p>
|
|
273
|
+
|
|
274
|
+
> Want to showcase your project? [Open an issue](https://github.com/AabhashRai13/create-modern-react/issues) to get featured!
|
|
275
|
+
|
|
276
|
+
---
|
|
71
277
|
|
|
72
278
|
## CLI Options
|
|
73
279
|
|
|
74
|
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
280
|
+
```bash
|
|
281
|
+
npx create-modern-react my-app # Interactive mode
|
|
282
|
+
npx create-modern-react my-app --skip-install # Skip npm install
|
|
283
|
+
npx create-modern-react my-app --skip-git # Skip git init
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
---
|
|
77
287
|
|
|
78
288
|
## Requirements
|
|
79
289
|
|
|
80
|
-
- Node.js
|
|
290
|
+
- Node.js **18+**
|
|
81
291
|
- npm, yarn, or pnpm
|
|
82
292
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
my-app/
|
|
87
|
-
├── public/
|
|
88
|
-
├── src/
|
|
89
|
-
│ ├── components/
|
|
90
|
-
│ ├── hooks/
|
|
91
|
-
│ ├── utils/
|
|
92
|
-
│ ├── types/
|
|
93
|
-
│ ├── styles/
|
|
94
|
-
│ ├── App.tsx
|
|
95
|
-
│ ├── main.tsx
|
|
96
|
-
│ └── index.css
|
|
97
|
-
├── package.json
|
|
98
|
-
├── vite.config.ts
|
|
99
|
-
├── tsconfig.json
|
|
100
|
-
└── README.md
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Contributing
|
|
104
|
-
|
|
105
|
-
1. Fork the repository
|
|
106
|
-
2. Create your feature branch
|
|
107
|
-
3. Commit your changes
|
|
108
|
-
4. Push to the branch
|
|
109
|
-
5. Create a Pull Request
|
|
293
|
+
---
|
|
110
294
|
|
|
111
295
|
## License
|
|
112
296
|
|
|
113
|
-
MIT © [
|
|
297
|
+
MIT © [Aabhash Rai](https://github.com/AabhashRai13)
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
<p align="center">
|
|
302
|
+
<strong>From <code>npx</code> to production-ready in 30 seconds.</strong>
|
|
303
|
+
</p>
|
|
304
|
+
|
|
305
|
+
<p align="center">
|
|
306
|
+
<a href="https://github.com/AabhashRai13/create-modern-react">⭐ Star on GitHub</a>
|
|
307
|
+
·
|
|
308
|
+
<a href="https://github.com/AabhashRai13/create-modern-react/issues">Report Bug</a>
|
|
309
|
+
·
|
|
310
|
+
<a href="https://github.com/AabhashRai13/create-modern-react/issues">Request Feature</a>
|
|
311
|
+
</p>
|
package/bin/index.js
CHANGED
|
@@ -6,21 +6,23 @@ const { createProject } = require('../lib/prompts');
|
|
|
6
6
|
|
|
7
7
|
program
|
|
8
8
|
.name('create-modern-react')
|
|
9
|
-
.description(
|
|
10
|
-
|
|
9
|
+
.description(
|
|
10
|
+
'Create production-ready React + TypeScript + Tailwind applications in seconds'
|
|
11
|
+
)
|
|
12
|
+
.version('2.0.0')
|
|
11
13
|
.argument('[project-name]', 'name of the project')
|
|
12
|
-
.option('-t, --template <template>', 'use a specific template')
|
|
13
14
|
.option('--skip-install', 'skip dependency installation')
|
|
14
15
|
.option('--skip-git', 'skip git initialization')
|
|
15
16
|
.action(async (projectName, options) => {
|
|
16
|
-
console.log(chalk.blue.bold('\n🚀 Welcome to create-modern-react!\n'));
|
|
17
|
-
|
|
18
17
|
try {
|
|
19
18
|
await createProject(projectName, options);
|
|
20
19
|
} catch (error) {
|
|
21
|
-
console.error(chalk.red('❌ Error creating project:'), error.message);
|
|
20
|
+
console.error(chalk.red('\n❌ Error creating project:'), error.message);
|
|
21
|
+
if (process.env.DEBUG) {
|
|
22
|
+
console.error(error.stack);
|
|
23
|
+
}
|
|
22
24
|
process.exit(1);
|
|
23
25
|
}
|
|
24
26
|
});
|
|
25
27
|
|
|
26
|
-
program.parse();
|
|
28
|
+
program.parse();
|