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.
Files changed (2) hide show
  1. package/index.js +33 -18
  2. 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
- let isBuilding = false;
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. Run npm install.', 'error');
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 (Global Monitor Mode)...', '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 ANY file change to rebuild...', 'info');
59
+ log('Waiting for file changes...', 'info');
44
60
  });
45
61
  }
46
62
 
47
- // সব ধরনের ফাইল ওয়াচ করা (node_modules ও .next বাদে)
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 Edition)', 'info');
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
- });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-auto-build",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Auto-build and self-healing production server for Next.js 16",
5
5
  "license": "ISC",
6
6
  "author": "pavel-ahmmed-hridoy",