next-auto-build 1.0.5 → 1.0.6
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 +10 -1
- package/package.json +1 -1
- package/scripts/postinstall.js +0 -25
package/index.js
CHANGED
|
@@ -7,8 +7,17 @@ const fs = require('fs');
|
|
|
7
7
|
|
|
8
8
|
// প্রোজেক্ট রুট খুঁজে বের করার উন্নত লজিক (pnpm ও Termux ফ্রেন্ডলি)
|
|
9
9
|
function getProjectRoot() {
|
|
10
|
+
const initCwd = process.env.INIT_CWD;
|
|
11
|
+
|
|
12
|
+
if (
|
|
13
|
+
initCwd &&
|
|
14
|
+
fs.existsSync(path.join(initCwd, 'package.json'))
|
|
15
|
+
) {
|
|
16
|
+
return initCwd;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// fallback (rare case)
|
|
10
20
|
let root = process.cwd();
|
|
11
|
-
// যদি node_modules এর ভেতর থাকে তবে সেখান থেকে বের হয়ে আসবে
|
|
12
21
|
if (root.includes('node_modules')) {
|
|
13
22
|
root = root.split(`${path.sep}node_modules`)[0];
|
|
14
23
|
}
|
package/package.json
CHANGED
package/scripts/postinstall.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
}
|