next-auto-build 1.0.1 → 1.0.2
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 +33 -18
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -8,25 +8,42 @@ const fs = require('fs');
|
|
|
8
8
|
const currentDir = process.cwd();
|
|
9
9
|
const nextBin = path.resolve(currentDir, 'node_modules', '.bin', 'next');
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
// ১. অটোমেটিক package.json এ স্ক্রিপ্ট যোগ করার লজিক
|
|
12
|
+
function addAutoScript() {
|
|
13
|
+
const packageJsonPath = path.join(currentDir, 'package.json');
|
|
14
|
+
|
|
15
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
16
|
+
try {
|
|
17
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
18
|
+
if (!packageJson.scripts) packageJson.scripts = {};
|
|
19
|
+
|
|
20
|
+
// যদি 'auto' স্ক্রিপ্ট না থাকে তবে যোগ করবে
|
|
21
|
+
if (!packageJson.scripts.auto) {
|
|
22
|
+
packageJson.scripts.auto = "next-auto";
|
|
23
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
24
|
+
console.log('🤖 [next-auto-build] Added "auto" script to your package.json');
|
|
25
|
+
}
|
|
26
|
+
} catch (err) {
|
|
27
|
+
// এরর হলে সাইলেন্ট থাকবে
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
12
31
|
|
|
13
|
-
//
|
|
32
|
+
// ২. কাস্টম লগ ফাংশন
|
|
14
33
|
function log(message, type = 'info') {
|
|
15
34
|
const icons = { info: '🤖', success: '🎉', error: '👾', build: '🚧' };
|
|
16
35
|
console.log(`${icons[type] || '•'} [${new Date().toLocaleTimeString()}] ${message}`);
|
|
17
36
|
}
|
|
18
37
|
|
|
38
|
+
// ৩. প্রোডাকশন বিল্ড ফাংশন
|
|
19
39
|
function runProductionBuild() {
|
|
20
|
-
if (isBuilding) return;
|
|
21
|
-
|
|
22
40
|
if (!fs.existsSync(nextBin)) {
|
|
23
|
-
log('Next.js binary not found.
|
|
41
|
+
log('Next.js binary not found. Please run npm install.', 'error');
|
|
24
42
|
return;
|
|
25
43
|
}
|
|
26
44
|
|
|
27
|
-
isBuilding = true;
|
|
28
45
|
console.clear();
|
|
29
|
-
log('Starting Production Build
|
|
46
|
+
log('Starting Production Build...', 'build');
|
|
30
47
|
|
|
31
48
|
const build = spawn(nextBin, ['build', '--webpack'], {
|
|
32
49
|
stdio: 'inherit',
|
|
@@ -34,17 +51,21 @@ function runProductionBuild() {
|
|
|
34
51
|
});
|
|
35
52
|
|
|
36
53
|
build.on('close', (code) => {
|
|
37
|
-
isBuilding = false;
|
|
38
54
|
if (code === 0) {
|
|
39
55
|
log('Production Build Completed Successfully!', 'success');
|
|
40
56
|
} else {
|
|
41
57
|
log('Build Failed! Fix errors to retry.', 'error');
|
|
42
58
|
}
|
|
43
|
-
log('Waiting for
|
|
59
|
+
log('Waiting for file changes...', 'info');
|
|
44
60
|
});
|
|
45
61
|
}
|
|
46
62
|
|
|
47
|
-
//
|
|
63
|
+
// --- মেইন এক্সিকিউশন শুরু ---
|
|
64
|
+
|
|
65
|
+
// সবার আগে স্ক্রিপ্টটি যোগ করার চেষ্টা করবে
|
|
66
|
+
addAutoScript();
|
|
67
|
+
|
|
68
|
+
// ফাইল ওয়াচার সেটআপ
|
|
48
69
|
const watcher = chokidar.watch('.', {
|
|
49
70
|
ignored: ['**/node_modules/**', '**/.next/**', '**/.git/**', '**/*.log'],
|
|
50
71
|
persistent: true,
|
|
@@ -53,7 +74,7 @@ const watcher = chokidar.watch('.', {
|
|
|
53
74
|
interval: 300
|
|
54
75
|
});
|
|
55
76
|
|
|
56
|
-
log('Next-Auto-Builder Active (2026
|
|
77
|
+
log('Next-Auto-Builder Active (2026 Production Mode)', 'info');
|
|
57
78
|
|
|
58
79
|
watcher.on('all', (event, filePath) => {
|
|
59
80
|
if (filePath.includes('.next')) return;
|
|
@@ -61,11 +82,5 @@ watcher.on('all', (event, filePath) => {
|
|
|
61
82
|
runProductionBuild();
|
|
62
83
|
});
|
|
63
84
|
|
|
64
|
-
//
|
|
85
|
+
// শুরুতে একবার বিল্ড রান করা
|
|
65
86
|
runProductionBuild();
|
|
66
|
-
|
|
67
|
-
// ক্র্যাশ প্রোটেকশন
|
|
68
|
-
process.on('uncaughtException', (err) => {
|
|
69
|
-
log(`System Error: ${err.message}`, 'error');
|
|
70
|
-
isBuilding = false;
|
|
71
|
-
});
|