next-auto-build 1.0.3 → 1.0.6
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/index.js +34 -15
- package/package.json +3 -3
- package/scripts/postinstall.js +0 -25
package/index.js
CHANGED
|
@@ -5,12 +5,32 @@ const spawn = require('cross-spawn');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// প্রোজেক্ট রুট খুঁজে বের করার উন্নত লজিক (pnpm ও Termux ফ্রেন্ডলি)
|
|
9
|
+
function getProjectRoot() {
|
|
10
|
+
const initCwd = process.env.INIT_CWD;
|
|
11
|
+
|
|
12
|
+
if (
|
|
13
|
+
initCwd &&
|
|
14
|
+
fs.existsSync(path.join(initCwd, 'package.json'))
|
|
15
|
+
) {
|
|
16
|
+
return initCwd;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// fallback (rare case)
|
|
20
|
+
let root = process.cwd();
|
|
21
|
+
if (root.includes('node_modules')) {
|
|
22
|
+
root = root.split(`${path.sep}node_modules`)[0];
|
|
23
|
+
}
|
|
24
|
+
return root;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const projectRoot = getProjectRoot();
|
|
28
|
+
const nextBin = path.resolve(projectRoot, 'node_modules', '.bin', 'next');
|
|
10
29
|
|
|
11
|
-
// ১. অটো-স্ক্রিপ্ট
|
|
30
|
+
// ১. অটো-স্ক্রিপ্ট ইনজেক্টর (FIXED PATH)
|
|
12
31
|
function addAutoScript() {
|
|
13
|
-
const packageJsonPath = path.join(
|
|
32
|
+
const packageJsonPath = path.join(projectRoot, 'package.json');
|
|
33
|
+
|
|
14
34
|
if (fs.existsSync(packageJsonPath)) {
|
|
15
35
|
try {
|
|
16
36
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
@@ -19,30 +39,30 @@ function addAutoScript() {
|
|
|
19
39
|
if (!packageJson.scripts.auto) {
|
|
20
40
|
packageJson.scripts.auto = "next-auto";
|
|
21
41
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
22
|
-
console.log('\x1b[32m%s\x1b[0m', '🤖 [next-auto-build] Success: "auto" script added to package.json');
|
|
42
|
+
console.log('\x1b[32m%s\x1b[0m', '🤖 [next-auto-build] Success: "auto" script added to your package.json');
|
|
23
43
|
}
|
|
24
44
|
} catch (err) { /* সাইলেন্ট এরর */ }
|
|
25
45
|
}
|
|
26
46
|
}
|
|
27
47
|
|
|
28
|
-
// ২. কাস্টম লগ
|
|
48
|
+
// ২. কাস্টম লগ সিস্টেম
|
|
29
49
|
function log(message, type = 'info') {
|
|
30
50
|
const icons = { info: '🤖', success: '🎉', error: '👾', build: '🚧' };
|
|
31
51
|
console.log(`${icons[type] || '•'} [${new Date().toLocaleTimeString()}] ${message}`);
|
|
32
52
|
}
|
|
33
53
|
|
|
34
|
-
// ৩. প্রোডাকশন বিল্ড
|
|
54
|
+
// ৩. প্রোডাকশন বিল্ড লজিক
|
|
35
55
|
let isBuilding = false;
|
|
36
56
|
function runProductionBuild() {
|
|
37
57
|
if (isBuilding) return;
|
|
38
58
|
if (!fs.existsSync(nextBin)) {
|
|
39
|
-
log('Next.js binary not found. Please run
|
|
59
|
+
log('Next.js binary not found. Please run install first.', 'error');
|
|
40
60
|
return;
|
|
41
61
|
}
|
|
42
62
|
|
|
43
63
|
isBuilding = true;
|
|
44
64
|
console.clear();
|
|
45
|
-
log('Starting Production Build (
|
|
65
|
+
log('Starting Production Build (Global Monitor Mode)...', 'build');
|
|
46
66
|
|
|
47
67
|
const build = spawn(nextBin, ['build', '--webpack'], { stdio: 'inherit', shell: true });
|
|
48
68
|
|
|
@@ -57,17 +77,16 @@ function runProductionBuild() {
|
|
|
57
77
|
});
|
|
58
78
|
}
|
|
59
79
|
|
|
60
|
-
// ৪. মেইন এক্সিকিউশন
|
|
80
|
+
// ৪. মেইন এক্সিকিউশন
|
|
61
81
|
const args = process.argv.slice(2);
|
|
62
82
|
|
|
63
|
-
// যদি এটি শুধু পোস্ট-ইন্সটল হিসেবে রান হয়
|
|
64
83
|
if (args.includes('--postinstall')) {
|
|
65
84
|
addAutoScript();
|
|
66
|
-
process.exit(0);
|
|
85
|
+
process.exit(0);
|
|
67
86
|
}
|
|
68
87
|
|
|
69
|
-
//
|
|
70
|
-
addAutoScript();
|
|
88
|
+
// অটো-স্ক্রিপ্ট চেক এবং রান
|
|
89
|
+
addAutoScript();
|
|
71
90
|
|
|
72
91
|
const watcher = chokidar.watch('.', {
|
|
73
92
|
ignored: ['**/node_modules/**', '**/.next/**', '**/.git/**', '**/*.log'],
|
|
@@ -77,7 +96,7 @@ const watcher = chokidar.watch('.', {
|
|
|
77
96
|
interval: 300
|
|
78
97
|
});
|
|
79
98
|
|
|
80
|
-
log('Next-Auto-Builder Active (Production Mode)', 'info');
|
|
99
|
+
log('Next-Auto-Builder Active (Production Mode Only)', 'info');
|
|
81
100
|
|
|
82
101
|
watcher.on('all', (event, filePath) => {
|
|
83
102
|
if (filePath.includes('.next')) return;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-auto-build",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Auto-build for Next.js in Production Mode with Auto-Script injection",
|
|
3
|
+
"version": "1.0.6",
|
|
5
4
|
"main": "index.js",
|
|
6
5
|
"bin": {
|
|
7
6
|
"next-auto": "./index.js"
|
|
8
7
|
},
|
|
9
8
|
"scripts": {
|
|
10
|
-
"postinstall": "node index.js --postinstall"
|
|
9
|
+
"postinstall": "node index.js --postinstall",
|
|
10
|
+
"auto": "next-auto"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"chokidar": "^4.0.1",
|
package/scripts/postinstall.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// scripts/postinstall.js
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
// যে প্রোজেক্টে ইন্সটল হচ্ছে তার package.json খুঁজে বের করা
|
|
6
|
-
// node_modules/next-auto-deployer/scripts/.. -> প্রোজেক্ট রুট
|
|
7
|
-
const projectRoot = path.resolve(__dirname, '..', '..', '..');
|
|
8
|
-
const packageJsonPath = path.join(projectRoot, 'package.json');
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
12
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
13
|
-
|
|
14
|
-
if (!packageJson.scripts) packageJson.scripts = {};
|
|
15
|
-
|
|
16
|
-
// যদি 'auto' স্ক্রিপ্ট না থাকে তবেই যোগ করবে
|
|
17
|
-
if (!packageJson.scripts.auto) {
|
|
18
|
-
packageJson.scripts.auto = "next-auto";
|
|
19
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
20
|
-
console.log('\x1b[32m%s\x1b[0m', '🎉 [next-auto-deployer] Success: "auto" script added to your package.json');
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
} catch (err) {
|
|
24
|
-
// ইন্সটলেশন যেন বাধাগ্রস্ত না হয় তাই সাইলেন্ট এরর
|
|
25
|
-
}
|