next-lovable 0.0.64 → 0.0.71

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 CHANGED
@@ -7,6 +7,7 @@ An intelligent CLI tool to automatically migrate React applications to Next.js 1
7
7
  - 🚀 Smart React Router to Next.js App Router conversion
8
8
  - 📦 Automated migration from Vite to Next.js build system
9
9
  - 🔄 Intelligent component transformation with 'use client' directives
10
+ - 📁 **NEW in v0.7+**: Single file conversion with credit tracking
10
11
  - 🎯 Automatic handling of:
11
12
  - Route configurations
12
13
  - Layouts and page structures
@@ -18,7 +19,7 @@ An intelligent CLI tool to automatically migrate React applications to Next.js 1
18
19
 
19
20
  - Node.js 18.x or higher
20
21
  - npm or yarn
21
- - A nextlovable.com account
22
+ - A nextlovable.com account (for full project migrations)
22
23
  - A React project using:
23
24
  - React Router
24
25
  - Vite
@@ -32,23 +33,85 @@ npm install -g next-lovable
32
33
 
33
34
  ## Authentication
34
35
 
35
- The tool requires authentication with your nextlovable.com account:
36
+ Authentication with your nextlovable.com account is required for all conversions:
36
37
  - Login will be prompted on first use
37
38
  - Sessions are securely stored for future use
38
39
  - Automatic token refresh handling
40
+ - Required for both file conversion and full project migration
41
+
42
+ ## Credit System
43
+
44
+ - **Initial credits**: 10 file conversion credits when you sign up
45
+ - **Credit packages**: Each migration credit purchased grants 10 additional file conversion credits
46
+ - **Usage**: 1 file conversion credit consumed per file converted (dry-run is free)
47
+ - **Balance**: Check your current balance during conversion
39
48
 
40
49
  ## Usage
41
50
 
42
- ### Basic Command
51
+ ### New in v0.0.7+: Command Structure
52
+
53
+ Starting from version 0.0.7, the CLI uses subcommands:
43
54
 
55
+ ```bash
56
+ # Full project migration (requires auth + migration credits)
57
+ next-lovable migrate <source-directory> [target-directory]
58
+
59
+ # Single file conversion (requires auth + file conversion credits)
60
+ next-lovable convert <file> [options]
61
+
62
+ # Check your file conversion credit balance
63
+ next-lovable credits
64
+ ```
65
+
66
+ **Note**: In versions before 0.6, use the legacy format:
44
67
  ```bash
45
68
  next-lovable <source-directory> [target-directory]
46
69
  ```
47
70
 
71
+ ### Single File Conversion 📁
72
+
73
+ Convert individual React files to Next.js with credit tracking:
74
+
75
+ ```bash
76
+ # Convert a single component (consumes 1 file conversion credit)
77
+ next-lovable convert MyComponent.tsx
78
+
79
+ # Save to different location
80
+ next-lovable convert MyComponent.tsx --output ./converted/MyComponent.tsx
81
+
82
+ # Apply specific transformations only
83
+ next-lovable convert MyComponent.tsx --transform router,client
84
+
85
+ # Preview changes without consuming credits
86
+ next-lovable convert MyComponent.tsx --dry-run --show-diff
87
+
88
+ # List available transformations (no auth required)
89
+ next-lovable convert --list
90
+ ```
91
+
92
+ #### Available Transformations
93
+
94
+ - `router`: React Router → Next.js Router (useNavigate, Link, etc.)
95
+ - `helmet`: React Helmet → Next.js Head
96
+ - `client`: Add "use client" directive where needed
97
+ - `context`: Context provider transformations
98
+ - `all`: Apply all transformations (default)
99
+
100
+ #### Single File Options
101
+
102
+ - `-o, --output <path>`: Output file path (default: overwrite input)
103
+ - `-t, --transform <types>`: Comma-separated transformations (default: all)
104
+ - `-d, --dry-run`: Preview changes without modification
105
+ - `--show-diff`: Show before/after comparison (with --dry-run)
106
+ - `--legacy`: Use legacy transformers instead of enhanced ones
107
+ - `--list`: List available transformations
108
+
109
+ ### Full Project Migration
110
+
48
111
  ### Dry Run Mode (Recommended First Step)
49
112
 
50
113
  ```bash
51
- next-lovable ./my-react-app --dry-run
114
+ next-lovable migrate ./my-react-app --dry-run
52
115
  ```
53
116
 
54
117
  The `--dry-run` option provides:
@@ -59,22 +122,24 @@ The `--dry-run` option provides:
59
122
  - 🎯 Preview of transformations
60
123
  - 0️⃣ No actual changes made
61
124
 
62
- ### Full Migration
125
+ ### Complete Migration
63
126
 
64
127
  ```bash
65
- next-lovable ./my-react-app ./next-app --yes --install
128
+ next-lovable migrate ./my-react-app ./next-app --yes --install
66
129
  ```
67
130
 
68
- ### Available Options
131
+ ### Project Migration Options
69
132
 
70
133
  - `-y, --yes`: Skip confirmation prompts
71
134
  - `-i, --install`: Install dependencies after migration
72
135
  - `-d, --dry-run`: Simulation mode without changes
136
+ - `-e, --enhanced`: Use enhanced migration (default)
137
+ - `--legacy`: Use legacy migration mode
73
138
  - `--help`: Show help information
74
139
 
75
140
  ## Migration Process
76
141
 
77
- 1. **Authentication & Validation**
142
+ 1. **Authentication & Validation** (Full Migration Only)
78
143
  - Account verification
79
144
  - Project structure validation
80
145
  - Dependencies check
@@ -92,11 +157,43 @@ next-lovable ./my-react-app ./next-app --yes --install
92
157
  - Dependency updates
93
158
  - Configuration generation
94
159
 
95
- 4. **Post-Migration Setup**
160
+ 4. **Post-Migration Setup** (Full Migration Only)
96
161
  - Next.js configuration
97
162
  - TypeScript adjustments
98
163
  - Development environment setup
99
164
 
165
+ ## Workflow Examples
166
+
167
+ ### Testing Individual Components
168
+
169
+ ```bash
170
+ # Test router conversion on a specific component (free with dry-run)
171
+ next-lovable convert src/components/Navigation.tsx --dry-run
172
+
173
+ # Convert only routing-related code (consumes 1 credit)
174
+ next-lovable convert src/pages/Dashboard.tsx --transform router --output ./test-output.tsx
175
+
176
+ # Preview all transformations with diff (free)
177
+ next-lovable convert src/App.tsx --dry-run --show-diff
178
+ ```
179
+
180
+ ### Before Full Migration
181
+
182
+ ```bash
183
+ # 0. Check your file conversion credit balance
184
+ next-lovable credits
185
+
186
+ # 1. Test key components individually (free with dry-run)
187
+ next-lovable convert src/App.tsx --dry-run
188
+ next-lovable convert src/components/Layout.tsx --dry-run
189
+
190
+ # 2. Run full project dry-run (consumes migration credits)
191
+ next-lovable migrate ./my-react-app --dry-run
192
+
193
+ # 3. Execute full migration
194
+ next-lovable migrate ./my-react-app ./next-app --install
195
+ ```
196
+
100
197
  ## Intelligent Features
101
198
 
102
199
  - 🧠 Smart component analysis for 'use client' directives
@@ -104,6 +201,33 @@ next-lovable ./my-react-app ./next-app --yes --install
104
201
  - 📱 Layout preservation and enhancement
105
202
  - 🛠️ Dependency resolution and cleanup
106
203
  - 🎯 Typescript support and type preservation
204
+ - ⚡ **Enhanced transformers** (v0.6+):
205
+ - Advanced React Router pattern detection
206
+ - Smarter client/server component separation
207
+ - Better handling of complex routing scenarios
208
+ - Improved template literal preservation in routes
209
+
210
+ ## Transformation Details
211
+
212
+ ### Router Conversion (`router`)
213
+ - `useNavigate()` → `useRouter()` from `next/navigation`
214
+ - `<Link to="/path">` → `<Link href="/path">` from `next/link`
215
+ - `useLocation()` → `usePathname()` + `useSearchParams()`
216
+ - `useParams()` → Next.js `useParams()`
217
+ - Template literals in paths preserved: `to={\`/user/\${id}\`}` → `href={\`/user/\${id}\`}`
218
+
219
+ ### Helmet Conversion (`helmet`)
220
+ - `<Helmet>` → `<Head>` from `next/head`
221
+ - Meta tags and title preservation
222
+ - SEO attributes maintained
223
+
224
+ ### Client Directive (`client`)
225
+ - Automatic "use client" directive addition
226
+ - Smart detection of client-side features:
227
+ - React hooks (useState, useEffect, etc.)
228
+ - Event handlers (onClick, onChange, etc.)
229
+ - Browser APIs (window, document, localStorage)
230
+ - Third-party client libraries
107
231
 
108
232
  ## Post-Migration
109
233
 
@@ -112,6 +236,92 @@ next-lovable ./my-react-app ./next-app --yes --install
112
236
  3. Check converted routes
113
237
  4. Verify component functionality
114
238
 
239
+ ## Real-World Examples
240
+
241
+ ### Converting a React Router Navigation Component
242
+
243
+ **Before** (React Router):
244
+ ```tsx
245
+ import { Link, useNavigate, useLocation } from 'react-router-dom';
246
+
247
+ export const Navigation = () => {
248
+ const navigate = useNavigate();
249
+ const location = useLocation();
250
+
251
+ return (
252
+ <nav>
253
+ <Link to="/dashboard">Dashboard</Link>
254
+ <Link to={`/profile/${userId}`}>Profile</Link>
255
+ <button onClick={() => navigate('/settings')}>
256
+ Settings
257
+ </button>
258
+ <p>Current: {location.pathname}</p>
259
+ </nav>
260
+ );
261
+ };
262
+ ```
263
+
264
+ **After** (Next.js) - using `next-lovable convert`:
265
+ ```tsx
266
+ 'use client';
267
+
268
+ import Link from 'next/link';
269
+ import { useRouter, usePathname } from 'next/navigation';
270
+
271
+ export const Navigation = () => {
272
+ const router = useRouter();
273
+ const pathname = usePathname();
274
+
275
+ return (
276
+ <nav>
277
+ <Link href="/dashboard">Dashboard</Link>
278
+ <Link href={`/profile/${userId}`}>Profile</Link>
279
+ <button onClick={() => router.push('/settings')}>
280
+ Settings
281
+ </button>
282
+ <p>Current: {pathname}</p>
283
+ </nav>
284
+ );
285
+ };
286
+ ```
287
+
288
+ ### Converting React Helmet SEO Component
289
+
290
+ **Before**:
291
+ ```tsx
292
+ import { Helmet } from 'react-helmet';
293
+
294
+ export const PageMeta = ({ title, description }) => (
295
+ <Helmet>
296
+ <title>{title}</title>
297
+ <meta name="description" content={description} />
298
+ </Helmet>
299
+ );
300
+ ```
301
+
302
+ **After**:
303
+ ```tsx
304
+ import Head from 'next/head';
305
+
306
+ export const PageMeta = ({ title, description }) => (
307
+ <Head>
308
+ <title>{title}</title>
309
+ <meta name="description" content={description} />
310
+ </Head>
311
+ );
312
+ ```
313
+
314
+ ## Quick Command Reference
315
+
316
+ | Task | Command | Credits Required |
317
+ |------|---------|------------------|
318
+ | List transformations | `next-lovable convert --list` | ❌ No |
319
+ | Check credit balance | `next-lovable credits` | ❌ No (auth required) |
320
+ | Test single file | `next-lovable convert MyComponent.tsx --dry-run` | ❌ No |
321
+ | Convert single file | `next-lovable convert MyComponent.tsx` | ✅ 1 file credit |
322
+ | Preview project migration | `next-lovable migrate ./my-app --dry-run` | ✅ Migration credits |
323
+ | Full project migration | `next-lovable migrate ./my-app ./next-app` | ✅ Migration credits |
324
+
115
325
  ## Limitations
116
326
 
117
327
  - Complex custom route configurations may need manual adjustments
@@ -121,7 +331,40 @@ next-lovable ./my-react-app ./next-app --yes --install
121
331
 
122
332
  ## Best Practices
123
333
 
124
- 1. Always run `--dry-run` first
125
- 2. Keep a backup of your original project
126
- 3. Review generated files before deployment
127
- 4. Test thoroughly after migration
334
+ 1. **Start with Dry-Run Testing (Free)**
335
+ - Test key components individually with `convert --dry-run`
336
+ - No credits consumed for dry-run operations
337
+ - Perfect for understanding what changes will be made
338
+
339
+ 2. **Efficient Credit Usage**
340
+ - Use dry-run mode extensively before actual conversion
341
+ - Convert multiple files at once when possible
342
+ - Plan your transformations to minimize credit usage
343
+
344
+ 3. **Full Project Migration**
345
+ - Always run `migrate --dry-run` first
346
+ - Keep a backup of your original project
347
+ - Review generated files before deployment
348
+ - Test thoroughly after migration
349
+
350
+ 4. **Incremental Approach**
351
+ ```bash
352
+ # Test individual files first (free with dry-run)
353
+ next-lovable convert src/App.tsx --dry-run
354
+ next-lovable convert src/components/*.tsx --dry-run
355
+
356
+ # Convert specific files (consumes file credits)
357
+ next-lovable convert src/App.tsx
358
+ next-lovable convert src/components/Navigation.tsx
359
+
360
+ # Then migrate the full project (consumes migration credits)
361
+ next-lovable migrate ./my-react-app --dry-run
362
+ next-lovable migrate ./my-react-app ./next-app --install
363
+ ```
364
+
365
+ ## Version Notes
366
+
367
+ - **v0.6+**: New subcommand structure (`migrate`, `convert`)
368
+ - **v0.5 and earlier**: Legacy command format (direct arguments)
369
+ - **v0.6+**: File conversion with credit tracking system added
370
+ - **Credit System**: 10 initial credits + 10 credits per migration credit purchased
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "next-lovable",
3
- "version": "0.0.64",
4
- "description": "Cross-platform tool to migrate Lovable React projects to Next.js",
3
+ "version": "0.0.71",
4
+ "description": "Cross-platform tool to migrate Lovable React projects to Next.js with credit-free single file conversion",
5
5
  "main": "./dist/index.js",
6
6
  "homepage": "https://nextlovable.com",
7
7
  "scripts": {
8
+ "test": "node ./tests/test-runner.js",
9
+ "test:unit": "node ./tests/unit/codemods.test.js && node ./tests/unit/router.test.js && node ./tests/unit/file-ops.test.js",
10
+ "test:integration": "node ./tests/integration/migration.test.js",
11
+ "test:e2e": "node ./tests/e2e/cli.test.js",
12
+ "test:pre-publish": "node ./tests/pre-publish.js",
8
13
  "prepare-publish": "node ./scripts/prepare-publish.js",
9
14
  "post-publish": "node ./scripts/post-publish.js",
10
- "prepublishOnly": "npm run build && npm run prepare-publish",
15
+ "prepublishOnly": "npm run build && npm run test:pre-publish && npm run prepare-publish",
11
16
  "postpublish": "npm run post-publish",
12
17
  "build": "bash ./build.sh"
13
18
  },
@@ -37,6 +42,7 @@
37
42
  "license": "ISC",
38
43
  "dependencies": {
39
44
  "@sentry/node": "^9.17.0",
45
+ "chalk": "^4.1.2",
40
46
  "commander": "^13.1.0",
41
47
  "fs-extra": "^11.3.0",
42
48
  "glob": "^11.0.1",