next-auto-build 1.0.1
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 +71 -0
- package/package.json +20 -0
- package/scripts/postinstall.js +25 -0
package/index.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const chokidar = require('chokidar');
|
|
4
|
+
const spawn = require('cross-spawn');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
|
|
8
|
+
const currentDir = process.cwd();
|
|
9
|
+
const nextBin = path.resolve(currentDir, 'node_modules', '.bin', 'next');
|
|
10
|
+
|
|
11
|
+
let isBuilding = false;
|
|
12
|
+
|
|
13
|
+
// আপনার কাস্টম আইকন সেট
|
|
14
|
+
function log(message, type = 'info') {
|
|
15
|
+
const icons = { info: '🤖', success: '🎉', error: '👾', build: '🚧' };
|
|
16
|
+
console.log(`${icons[type] || '•'} [${new Date().toLocaleTimeString()}] ${message}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function runProductionBuild() {
|
|
20
|
+
if (isBuilding) return;
|
|
21
|
+
|
|
22
|
+
if (!fs.existsSync(nextBin)) {
|
|
23
|
+
log('Next.js binary not found. Run npm install.', 'error');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
isBuilding = true;
|
|
28
|
+
console.clear();
|
|
29
|
+
log('Starting Production Build (Global Monitor Mode)...', 'build');
|
|
30
|
+
|
|
31
|
+
const build = spawn(nextBin, ['build', '--webpack'], {
|
|
32
|
+
stdio: 'inherit',
|
|
33
|
+
shell: true
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
build.on('close', (code) => {
|
|
37
|
+
isBuilding = false;
|
|
38
|
+
if (code === 0) {
|
|
39
|
+
log('Production Build Completed Successfully!', 'success');
|
|
40
|
+
} else {
|
|
41
|
+
log('Build Failed! Fix errors to retry.', 'error');
|
|
42
|
+
}
|
|
43
|
+
log('Waiting for ANY file change to rebuild...', 'info');
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// সব ধরনের ফাইল ওয়াচ করা (node_modules ও .next বাদে)
|
|
48
|
+
const watcher = chokidar.watch('.', {
|
|
49
|
+
ignored: ['**/node_modules/**', '**/.next/**', '**/.git/**', '**/*.log'],
|
|
50
|
+
persistent: true,
|
|
51
|
+
ignoreInitial: true,
|
|
52
|
+
usePolling: true,
|
|
53
|
+
interval: 300
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
log('Next-Auto-Builder Active (2026 Edition)', 'info');
|
|
57
|
+
|
|
58
|
+
watcher.on('all', (event, filePath) => {
|
|
59
|
+
if (filePath.includes('.next')) return;
|
|
60
|
+
log(`File Event [${event}]: ${filePath}`, 'info');
|
|
61
|
+
runProductionBuild();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// প্রথমবার বিল্ড চালু করা
|
|
65
|
+
runProductionBuild();
|
|
66
|
+
|
|
67
|
+
// ক্র্যাশ প্রোটেকশন
|
|
68
|
+
process.on('uncaughtException', (err) => {
|
|
69
|
+
log(`System Error: ${err.message}`, 'error');
|
|
70
|
+
isBuilding = false;
|
|
71
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "next-auto-build",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Auto-build and self-healing production server for Next.js 16",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "pavel-ahmmed-hridoy",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"bin": {
|
|
10
|
+
"next-auto": "index.js"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"postinstall": "node scripts/postinstall.js"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"chokidar": "^4.0.1",
|
|
17
|
+
"cross-spawn": "^7.0.6"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {}
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|