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