next-lovable 0.0.31
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 +98 -0
- package/bin/next-lovable +64 -0
- package/dist/next-lovable-linux +0 -0
- package/dist/next-lovable-macos +0 -0
- package/dist/next-lovable-win.exe +0 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# next-lovable
|
|
2
|
+
|
|
3
|
+
A CLI tool to migrate React applications to Next.js 13+ (App Router).
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Converts React Router routes to Next.js App Router
|
|
8
|
+
- Migrates from Vite to Next.js build system
|
|
9
|
+
- Handles package.json dependencies
|
|
10
|
+
- Preserves existing components and layouts
|
|
11
|
+
- Adds necessary Next.js configuration files
|
|
12
|
+
- Supports TypeScript projects
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
- Node.js 18.x or higher
|
|
17
|
+
- npm or yarn
|
|
18
|
+
- A React project using:
|
|
19
|
+
- React Router
|
|
20
|
+
- Vite (as build tool)
|
|
21
|
+
- TypeScript (optional)
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g next-lovable
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Basic usage:
|
|
32
|
+
```bash
|
|
33
|
+
next-lovable <source-directory> [target-directory]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
With options:
|
|
37
|
+
```bash
|
|
38
|
+
next-lovable ./my-react-app ./next-app --yes --install
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Options
|
|
42
|
+
|
|
43
|
+
- `-y, --yes`: Skip confirmation prompts
|
|
44
|
+
- `-i, --install`: Install dependencies after migration
|
|
45
|
+
- `--help`: Show help information
|
|
46
|
+
|
|
47
|
+
### Examples
|
|
48
|
+
|
|
49
|
+
1. Basic migration:
|
|
50
|
+
```bash
|
|
51
|
+
next-lovable ./my-react-app
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
2. Specify target directory:
|
|
55
|
+
```bash
|
|
56
|
+
next-lovable ./my-react-app ./converted-app
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
3. Non-interactive migration with dependency installation:
|
|
60
|
+
```bash
|
|
61
|
+
next-lovable ./my-react-app --yes --install
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Migration Process
|
|
65
|
+
|
|
66
|
+
1. **Setup and Validation**
|
|
67
|
+
- Validates source project
|
|
68
|
+
- Creates target directory
|
|
69
|
+
|
|
70
|
+
2. **Project Structure**
|
|
71
|
+
- Copies project files
|
|
72
|
+
- Restructures directories to Next.js format
|
|
73
|
+
- Converts route structure
|
|
74
|
+
|
|
75
|
+
3. **Code Transformation**
|
|
76
|
+
- Adds 'use client' directives
|
|
77
|
+
- Updates import paths
|
|
78
|
+
- Converts router code
|
|
79
|
+
- Creates Next.js page files
|
|
80
|
+
|
|
81
|
+
4. **Configuration**
|
|
82
|
+
- Updates package.json
|
|
83
|
+
- Creates Next.js config files
|
|
84
|
+
- Sets up root layout
|
|
85
|
+
|
|
86
|
+
## Post-Migration Steps
|
|
87
|
+
|
|
88
|
+
1. Review generated files in `src/app`
|
|
89
|
+
2. Check component imports and paths
|
|
90
|
+
3. Update any remaining router-specific code
|
|
91
|
+
4. Test the application with `npm run dev`
|
|
92
|
+
|
|
93
|
+
## Known Limitations
|
|
94
|
+
|
|
95
|
+
- Complex React Router configurations may need manual adjustment
|
|
96
|
+
- Custom route handling might require additional setup
|
|
97
|
+
- State management libraries may need manual updates
|
|
98
|
+
- Some components might need manual 'use client' directive additions
|
package/bin/next-lovable
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// File: bin/next-lovable.js
|
|
3
|
+
|
|
4
|
+
const { spawn } = require('child_process');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
|
|
9
|
+
// Determine the platform-specific executable
|
|
10
|
+
let binName;
|
|
11
|
+
switch (os.platform()) {
|
|
12
|
+
case 'win32':
|
|
13
|
+
binName = 'next-lovable-win.exe';
|
|
14
|
+
break;
|
|
15
|
+
case 'darwin':
|
|
16
|
+
binName = 'next-lovable-macos';
|
|
17
|
+
break;
|
|
18
|
+
case 'linux':
|
|
19
|
+
binName = 'next-lovable-linux';
|
|
20
|
+
break;
|
|
21
|
+
default:
|
|
22
|
+
console.error(`Unsupported platform: ${os.platform()}`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Get the absolute path to the binary
|
|
27
|
+
const binPath = path.join(__dirname, '..', 'dist', binName);
|
|
28
|
+
|
|
29
|
+
// Check if the binary exists and is executable
|
|
30
|
+
try {
|
|
31
|
+
fs.accessSync(binPath, fs.constants.X_OK);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
if (os.platform() !== 'win32') {
|
|
34
|
+
// Make binary executable if it's not Windows
|
|
35
|
+
try {
|
|
36
|
+
fs.chmodSync(binPath, '755');
|
|
37
|
+
} catch (chmodErr) {
|
|
38
|
+
console.error(`Error making binary executable: ${chmodErr.message}`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
console.error(`Error accessing binary: ${err.message}`);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Execute the binary with the same arguments
|
|
48
|
+
const child = spawn(binPath, process.argv.slice(2), {
|
|
49
|
+
stdio: 'inherit'
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Forward the exit code
|
|
53
|
+
child.on('close', (code) => {
|
|
54
|
+
process.exit(code);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Forward SIGINT and SIGTERM
|
|
58
|
+
process.on('SIGINT', () => {
|
|
59
|
+
child.kill('SIGINT');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
process.on('SIGTERM', () => {
|
|
63
|
+
child.kill('SIGTERM');
|
|
64
|
+
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "next-lovable",
|
|
3
|
+
"version": "0.0.31",
|
|
4
|
+
"description": "Cross-platform tool to migrate Lovable React projects to Next.js",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"homepage": "https://nextlovable.com",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"prepare-publish": "node ./scripts/prepare-publish.js",
|
|
9
|
+
"post-publish": "node ./scripts/post-publish.js",
|
|
10
|
+
"prepublishOnly": "npm run build && npm run prepare-publish",
|
|
11
|
+
"postpublish": "npm run post-publish",
|
|
12
|
+
"build": "node ./scripts/ensure-dist.js && npx tsup && npm run build:win && npm run build:macos && npm run build:linux && node ./scripts/post-build.js",
|
|
13
|
+
"build:win": "npx @yao-pkg/pkg ./dist/index.js --targets node20-win-x64 --output dist/next-lovable-win.exe",
|
|
14
|
+
"build:macos": "npx @yao-pkg/pkg ./dist/index.js --targets node20-macos-x64 --output dist/next-lovable-macos",
|
|
15
|
+
"build:linux": "npx @yao-pkg/pkg ./dist/index.js --targets node20-linux-x64 --output dist/next-lovable-linux"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20.0.0"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"next-lovable": "./bin/next-lovable"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/next-lovable-win.exe",
|
|
25
|
+
"dist/next-lovable-macos",
|
|
26
|
+
"dist/next-lovable-linux",
|
|
27
|
+
"bin/next-lovable",
|
|
28
|
+
"bin/next-lovable.js"
|
|
29
|
+
],
|
|
30
|
+
"keywords": [
|
|
31
|
+
"next.js",
|
|
32
|
+
"migration",
|
|
33
|
+
"react",
|
|
34
|
+
"vite",
|
|
35
|
+
"typescript",
|
|
36
|
+
"tailwind",
|
|
37
|
+
"cross-platform"
|
|
38
|
+
],
|
|
39
|
+
"author": "",
|
|
40
|
+
"license": "ISC",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"commander": "^13.1.0",
|
|
43
|
+
"fs-extra": "^11.3.0",
|
|
44
|
+
"glob": "^11.0.1",
|
|
45
|
+
"inquirer": "^8.2.4",
|
|
46
|
+
"jscodeshift": "^17.3.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@yao-pkg/pkg": "^6.4.0",
|
|
50
|
+
"tsup": "^8.4.0"
|
|
51
|
+
}
|
|
52
|
+
}
|