next-auto-build 1.0.1 → 1.0.3
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 +35 -13
- package/package.json +5 -9
package/index.js
CHANGED
|
@@ -8,30 +8,43 @@ 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
|
+
// ১. অটো-স্ক্রিপ্ট যোগ করার লজিক
|
|
12
|
+
function addAutoScript() {
|
|
13
|
+
const packageJsonPath = path.join(currentDir, 'package.json');
|
|
14
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
15
|
+
try {
|
|
16
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
17
|
+
if (!packageJson.scripts) packageJson.scripts = {};
|
|
18
|
+
|
|
19
|
+
if (!packageJson.scripts.auto) {
|
|
20
|
+
packageJson.scripts.auto = "next-auto";
|
|
21
|
+
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');
|
|
23
|
+
}
|
|
24
|
+
} catch (err) { /* সাইলেন্ট এরর */ }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
12
27
|
|
|
13
|
-
//
|
|
28
|
+
// ২. কাস্টম লগ ফাংশন
|
|
14
29
|
function log(message, type = 'info') {
|
|
15
30
|
const icons = { info: '🤖', success: '🎉', error: '👾', build: '🚧' };
|
|
16
31
|
console.log(`${icons[type] || '•'} [${new Date().toLocaleTimeString()}] ${message}`);
|
|
17
32
|
}
|
|
18
33
|
|
|
34
|
+
// ৩. প্রোডাকশন বিল্ড ফাংশন
|
|
35
|
+
let isBuilding = false;
|
|
19
36
|
function runProductionBuild() {
|
|
20
37
|
if (isBuilding) return;
|
|
21
|
-
|
|
22
38
|
if (!fs.existsSync(nextBin)) {
|
|
23
|
-
log('Next.js binary not found.
|
|
39
|
+
log('Next.js binary not found. Please run npm install.', 'error');
|
|
24
40
|
return;
|
|
25
41
|
}
|
|
26
42
|
|
|
27
43
|
isBuilding = true;
|
|
28
44
|
console.clear();
|
|
29
|
-
log('Starting Production Build (
|
|
45
|
+
log('Starting Production Build (All file types mode)...', 'build');
|
|
30
46
|
|
|
31
|
-
const build = spawn(nextBin, ['build', '--webpack'], {
|
|
32
|
-
stdio: 'inherit',
|
|
33
|
-
shell: true
|
|
34
|
-
});
|
|
47
|
+
const build = spawn(nextBin, ['build', '--webpack'], { stdio: 'inherit', shell: true });
|
|
35
48
|
|
|
36
49
|
build.on('close', (code) => {
|
|
37
50
|
isBuilding = false;
|
|
@@ -44,7 +57,18 @@ function runProductionBuild() {
|
|
|
44
57
|
});
|
|
45
58
|
}
|
|
46
59
|
|
|
47
|
-
//
|
|
60
|
+
// ৪. মেইন এক্সিকিউশন কন্ট্রোল
|
|
61
|
+
const args = process.argv.slice(2);
|
|
62
|
+
|
|
63
|
+
// যদি এটি শুধু পোস্ট-ইন্সটল হিসেবে রান হয়
|
|
64
|
+
if (args.includes('--postinstall')) {
|
|
65
|
+
addAutoScript();
|
|
66
|
+
process.exit(0); // বিল্ড শুরু না করে এখানেই থেমে যাবে
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// যদি ইউজার সরাসরি বা 'pnpm auto' দিয়ে রান করে
|
|
70
|
+
addAutoScript(); // নিশ্চিত করার জন্য আবার চেক করবে
|
|
71
|
+
|
|
48
72
|
const watcher = chokidar.watch('.', {
|
|
49
73
|
ignored: ['**/node_modules/**', '**/.next/**', '**/.git/**', '**/*.log'],
|
|
50
74
|
persistent: true,
|
|
@@ -53,7 +77,7 @@ const watcher = chokidar.watch('.', {
|
|
|
53
77
|
interval: 300
|
|
54
78
|
});
|
|
55
79
|
|
|
56
|
-
log('Next-Auto-Builder Active (
|
|
80
|
+
log('Next-Auto-Builder Active (Production Mode)', 'info');
|
|
57
81
|
|
|
58
82
|
watcher.on('all', (event, filePath) => {
|
|
59
83
|
if (filePath.includes('.next')) return;
|
|
@@ -61,10 +85,8 @@ watcher.on('all', (event, filePath) => {
|
|
|
61
85
|
runProductionBuild();
|
|
62
86
|
});
|
|
63
87
|
|
|
64
|
-
// প্রথমবার বিল্ড চালু করা
|
|
65
88
|
runProductionBuild();
|
|
66
89
|
|
|
67
|
-
// ক্র্যাশ প্রোটেকশন
|
|
68
90
|
process.on('uncaughtException', (err) => {
|
|
69
91
|
log(`System Error: ${err.message}`, 'error');
|
|
70
92
|
isBuilding = false;
|
package/package.json
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-auto-build",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Auto-build
|
|
5
|
-
"license": "ISC",
|
|
6
|
-
"author": "pavel-ahmmed-hridoy",
|
|
7
|
-
"type": "commonjs",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Auto-build for Next.js in Production Mode with Auto-Script injection",
|
|
8
5
|
"main": "index.js",
|
|
9
6
|
"bin": {
|
|
10
|
-
"next-auto": "index.js"
|
|
7
|
+
"next-auto": "./index.js"
|
|
11
8
|
},
|
|
12
9
|
"scripts": {
|
|
13
|
-
"postinstall": "node
|
|
10
|
+
"postinstall": "node index.js --postinstall"
|
|
14
11
|
},
|
|
15
12
|
"dependencies": {
|
|
16
13
|
"chokidar": "^4.0.1",
|
|
17
14
|
"cross-spawn": "^7.0.6"
|
|
18
|
-
}
|
|
19
|
-
"devDependencies": {}
|
|
15
|
+
}
|
|
20
16
|
}
|