create-modern-react 1.0.0 → 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.
Files changed (59) hide show
  1. package/README.md +270 -72
  2. package/bin/index.js +13 -13
  3. package/lib/install.js +103 -32
  4. package/lib/prompts.js +152 -179
  5. package/lib/setup.js +267 -159
  6. package/package.json +17 -8
  7. package/templates/base/.env.example +9 -0
  8. package/templates/base/.eslintrc.cjs +37 -0
  9. package/templates/base/.prettierrc +11 -0
  10. package/templates/base/components.json +17 -0
  11. package/templates/base/index.html +2 -1
  12. package/templates/base/package.json +33 -14
  13. package/templates/base/postcss.config.js +6 -0
  14. package/templates/base/src/App.tsx +5 -18
  15. package/templates/base/src/components/layout/error-boundary.tsx +60 -0
  16. package/templates/base/src/components/layout/index.ts +2 -0
  17. package/templates/base/src/components/layout/root-layout.tsx +36 -0
  18. package/templates/base/src/components/ui/button.tsx +55 -0
  19. package/templates/base/src/components/ui/card.tsx +85 -0
  20. package/templates/base/src/components/ui/index.ts +12 -0
  21. package/templates/base/src/components/ui/input.tsx +24 -0
  22. package/templates/base/src/components/ui/separator.tsx +29 -0
  23. package/templates/base/src/components/ui/skeleton.tsx +15 -0
  24. package/templates/base/src/hooks/index.ts +3 -0
  25. package/templates/base/src/hooks/use-cancel-token.ts +63 -0
  26. package/templates/base/src/hooks/use-debounce.ts +29 -0
  27. package/templates/base/src/hooks/use-loader.ts +39 -0
  28. package/templates/base/src/index.css +73 -60
  29. package/templates/base/src/lib/utils.ts +14 -0
  30. package/templates/base/src/main.tsx +6 -6
  31. package/templates/base/src/providers/index.tsx +27 -0
  32. package/templates/base/src/providers/theme-provider.tsx +92 -0
  33. package/templates/base/src/routes/index.tsx +40 -0
  34. package/templates/base/src/routes/routes.ts +36 -0
  35. package/templates/base/src/screens/home/index.tsx +132 -0
  36. package/templates/base/src/screens/not-found/index.tsx +29 -0
  37. package/templates/base/src/services/alertify-services.ts +133 -0
  38. package/templates/base/src/services/api/api-helpers.ts +130 -0
  39. package/templates/base/src/services/api/axios-instance.ts +77 -0
  40. package/templates/base/src/services/api/index.ts +9 -0
  41. package/templates/base/src/services/index.ts +2 -0
  42. package/templates/base/src/types/index.ts +55 -0
  43. package/templates/base/src/vite-env.d.ts +31 -0
  44. package/templates/base/tailwind.config.js +77 -0
  45. package/templates/base/tsconfig.json +4 -3
  46. package/templates/base/tsconfig.node.json +22 -0
  47. package/templates/base/vite.config.ts +65 -4
  48. package/templates/optional/antd/config-provider.tsx +33 -0
  49. package/templates/optional/antd/index.ts +2 -0
  50. package/templates/optional/antd/styles/antd-overrides.css +104 -0
  51. package/templates/optional/antd/theme.ts +75 -0
  52. package/templates/optional/husky/.husky/pre-commit +1 -0
  53. package/templates/optional/husky/.lintstagedrc.json +6 -0
  54. package/templates/optional/redux/hooks.ts +17 -0
  55. package/templates/optional/redux/index.ts +13 -0
  56. package/templates/optional/redux/provider.tsx +33 -0
  57. package/templates/optional/redux/store/index.ts +45 -0
  58. package/templates/optional/redux/store/slices/app-slice.ts +62 -0
  59. package/templates/base/src/App.css +0 -14
package/README.md CHANGED
@@ -1,113 +1,311 @@
1
- # create-modern-react
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
- Create a modern React application with Vite, TypeScript, and your choice of modern libraries.
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
- npm run dev
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
- 🚀 **Modern Stack**: Vite + React 18 + TypeScript
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
- ## Usage
157
+ ```tsx
158
+ import Logo from './logo.svg?react';
25
159
 
26
- ### Basic Usage
160
+ <Logo className="h-8 w-8 text-primary" />
161
+ ```
27
162
 
28
- ```bash
29
- npx create-modern-react my-project
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
- ### With Options
172
+ ### Toast Notifications
33
173
 
34
- ```bash
35
- npx create-modern-react my-project --skip-install --skip-git
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
- ## Interactive Prompts
182
+ ### Custom Hooks
39
183
 
40
- The CLI will guide you through selecting:
184
+ ```tsx
185
+ // Loading state
186
+ const [isLoading, startLoader, endLoader] = useLoader();
41
187
 
42
- - **Project Name**: Your project directory name
43
- - **Package Manager**: npm, yarn, or pnpm
44
- - **UI Library**: Ant Design, Material-UI, Chakra UI, or none
45
- - **CSS Framework**: Tailwind CSS, CSS Modules, Styled Components, or plain CSS
46
- - **State Management**: Redux Toolkit, Zustand, Jotai, or React state only
47
- - **Data Fetching**: React Query, SWR, Apollo Client, or Fetch API
48
- - **Routing**: React Router, Wouter, or none
49
- - **Development Tools**: Storybook, ESLint/Prettier, Husky, Testing
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
- ## Template Combinations
197
+ // Debounced search
198
+ const debouncedQuery = useDebounce(searchQuery, 300);
55
199
 
56
- ### Minimal Setup
200
+ // Cancel requests on unmount
201
+ const { cancelToken, cancel } = useCancelToken();
202
+ ```
57
203
 
58
- - Vite + React + TypeScript + Tailwind CSS
204
+ ### Path Aliases
59
205
 
60
- ### Enterprise Ready
206
+ ```tsx
207
+ // ❌ Instead of this:
208
+ import { Button } from '../../../components/ui/button';
61
209
 
62
- - Vite + React + TypeScript + Ant Design + Redux Toolkit + React Query + React Router
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
- ### Modern Stack
242
+ ---
65
243
 
66
- - Vite + React + TypeScript + Tailwind + Zustand + React Query + Wouter
244
+ ## Comparison
67
245
 
68
- ### Full Featured
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
- - All libraries with Storybook, testing, and PWA support
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
- - `--skip-install`: Skip automatic dependency installation
75
- - `--skip-git`: Skip Git repository initialization
76
- - `--template <name>`: Use a specific template (future feature)
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 16.0.0 or higher
290
+ - Node.js **18+**
81
291
  - npm, yarn, or pnpm
82
292
 
83
- ## Generated Project Structure
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 © [Your Name]
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
+ &nbsp;·&nbsp;
308
+ <a href="https://github.com/AabhashRai13/create-modern-react/issues">Report Bug</a>
309
+ &nbsp;·&nbsp;
310
+ <a href="https://github.com/AabhashRai13/create-modern-react/issues">Request Feature</a>
311
+ </p>
package/bin/index.js CHANGED
@@ -1,26 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { program } = require("commander");
4
- const chalk = require("chalk");
5
- const { createProject } = require("../lib/prompts");
3
+ const { program } = require('commander');
4
+ const chalk = require('chalk');
5
+ const { createProject } = require('../lib/prompts');
6
6
 
7
7
  program
8
- .name("create-modern-react")
8
+ .name('create-modern-react')
9
9
  .description(
10
- "Create a modern React application with Vite, TypeScript, and your choice of modern libraries",
10
+ 'Create production-ready React + TypeScript + Tailwind applications in seconds'
11
11
  )
12
- .version("1.0.0")
13
- .argument("[project-name]", "name of the project")
14
- .option("-t, --template <template>", "use a specific template")
15
- .option("--skip-install", "skip dependency installation")
16
- .option("--skip-git", "skip git initialization")
12
+ .version('2.0.0')
13
+ .argument('[project-name]', 'name of the project')
14
+ .option('--skip-install', 'skip dependency installation')
15
+ .option('--skip-git', 'skip git initialization')
17
16
  .action(async (projectName, options) => {
18
- console.log(chalk.blue.bold("\n🚀 Welcome to create-modern-react!\n"));
19
-
20
17
  try {
21
18
  await createProject(projectName, options);
22
19
  } catch (error) {
23
- 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
+ }
24
24
  process.exit(1);
25
25
  }
26
26
  });
package/lib/install.js CHANGED
@@ -1,15 +1,15 @@
1
- const { spawn } = require("child_process");
2
- const chalk = require("chalk");
1
+ const { spawn } = require('child_process');
2
+ const chalk = require('chalk');
3
3
 
4
4
  function runCommand(command, args, cwd) {
5
5
  return new Promise((resolve, reject) => {
6
6
  const child = spawn(command, args, {
7
7
  cwd,
8
- stdio: "inherit",
9
- shell: true,
8
+ stdio: 'inherit',
9
+ shell: true
10
10
  });
11
11
 
12
- child.on("close", (code) => {
12
+ child.on('close', (code) => {
13
13
  if (code === 0) {
14
14
  resolve();
15
15
  } else {
@@ -17,43 +17,114 @@ function runCommand(command, args, cwd) {
17
17
  }
18
18
  });
19
19
 
20
- child.on("error", (error) => {
20
+ child.on('error', (error) => {
21
21
  reject(error);
22
22
  });
23
23
  });
24
24
  }
25
25
 
26
+ // Check if a command is available
27
+ function isCommandAvailable(command) {
28
+ return new Promise((resolve) => {
29
+ const child = spawn(command, ['--version'], {
30
+ stdio: 'ignore',
31
+ shell: true
32
+ });
33
+
34
+ child.on('close', (code) => {
35
+ resolve(code === 0);
36
+ });
37
+
38
+ child.on('error', () => {
39
+ resolve(false);
40
+ });
41
+ });
42
+ }
43
+
44
+ // Get the best available package manager with fallback
45
+ async function getAvailablePackageManager(preferredManager) {
46
+ console.log(chalk.blue(`🔍 Checking for ${preferredManager}...`));
47
+
48
+ // Check if preferred package manager is available
49
+ if (await isCommandAvailable(preferredManager)) {
50
+ console.log(chalk.green(`✅ ${preferredManager} is available`));
51
+ return preferredManager;
52
+ }
53
+
54
+ // Fallback logic
55
+ console.log(chalk.yellow(`⚠️ ${preferredManager} is not installed`));
56
+
57
+ if (preferredManager !== 'npm') {
58
+ console.log(chalk.blue('🔄 Falling back to npm...'));
59
+
60
+ if (await isCommandAvailable('npm')) {
61
+ console.log(chalk.green('✅ npm is available, using npm instead'));
62
+ return 'npm';
63
+ } else {
64
+ throw new Error('Neither ' + preferredManager + ' nor npm is available');
65
+ }
66
+ } else {
67
+ throw new Error('npm is not available');
68
+ }
69
+ }
70
+
71
+ // Get install command and args for package manager
72
+ function getInstallCommand(packageManager) {
73
+ switch (packageManager) {
74
+ case 'yarn':
75
+ return { command: 'yarn', args: ['install'] };
76
+ case 'pnpm':
77
+ return { command: 'pnpm', args: ['install'] };
78
+ case 'npm':
79
+ default:
80
+ return { command: 'npm', args: ['install'] };
81
+ }
82
+ }
83
+
26
84
  async function installDependencies(config) {
27
- const { projectPath, packageManager } = config;
85
+ const { projectPath, packageManager: preferredManager, projectName } = config;
28
86
 
29
- console.log(chalk.blue("\n📦 Installing dependencies..."));
87
+ console.log(chalk.blue('\n📦 Installing dependencies...'));
30
88
 
31
89
  try {
32
- const installCommand =
33
- packageManager === "yarn"
34
- ? "yarn"
35
- : packageManager === "pnpm"
36
- ? "pnpm"
37
- : "npm";
38
- const installArgs =
39
- packageManager === "npm"
40
- ? ["install"]
41
- : packageManager === "pnpm"
42
- ? ["install"]
43
- : [];
44
-
45
- await runCommand(installCommand, installArgs, projectPath);
46
-
47
- console.log(chalk.green("✅ Dependencies installed successfully!"));
90
+ // Get the best available package manager
91
+ const availableManager = await getAvailablePackageManager(preferredManager);
92
+ const { command, args } = getInstallCommand(availableManager);
93
+
94
+ // Update config with actual package manager used
95
+ config.actualPackageManager = availableManager;
96
+
97
+ console.log(chalk.blue(`📥 Running: ${command} ${args.join(' ')}`));
98
+ await runCommand(command, args, projectPath);
99
+
100
+ console.log(chalk.green('✅ Dependencies installed successfully!'));
101
+
102
+ // Show different message if fallback was used
103
+ if (availableManager !== preferredManager) {
104
+ console.log(chalk.yellow(`ℹ️ Note: Used ${availableManager} instead of ${preferredManager}`));
105
+ }
106
+
48
107
  } catch (error) {
49
- console.error(
50
- chalk.red("❌ Failed to install dependencies:"),
51
- error.message,
52
- );
53
- console.log(chalk.yellow("You can install them manually by running:"));
54
- console.log(chalk.gray(` cd ${config.projectName}`));
55
- console.log(chalk.gray(` ${packageManager} install`));
108
+ console.error(chalk.red('❌ Failed to install dependencies:'), error.message);
109
+ console.log(chalk.yellow('\n🔧 You can install them manually by running:'));
110
+ console.log(chalk.gray(` cd ${projectName}`));
111
+
112
+ // Show command for the originally preferred package manager
113
+ if (preferredManager === 'yarn') {
114
+ console.log(chalk.gray(` yarn install`));
115
+ } else if (preferredManager === 'pnpm') {
116
+ console.log(chalk.gray(` pnpm install`));
117
+ } else {
118
+ console.log(chalk.gray(` npm install`));
119
+ }
120
+
121
+ console.log(chalk.yellow('\n💡 Make sure you have the package manager installed:'));
122
+ if (preferredManager === 'yarn') {
123
+ console.log(chalk.gray(` npm install -g yarn`));
124
+ } else if (preferredManager === 'pnpm') {
125
+ console.log(chalk.gray(` npm install -g pnpm`));
126
+ }
56
127
  }
57
128
  }
58
129
 
59
- module.exports = { installDependencies, runCommand };
130
+ module.exports = { installDependencies, runCommand };