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