ramorie 9.4.0 → 9.5.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/package.json +1 -1
- package/postinstall.js +36 -1
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
const https = require('https');
|
|
11
11
|
const fs = require('fs');
|
|
12
12
|
const path = require('path');
|
|
13
|
-
const { execSync } = require('child_process');
|
|
13
|
+
const { execFileSync, execSync } = require('child_process');
|
|
14
14
|
|
|
15
15
|
const VERSION = require('./package.json').version;
|
|
16
16
|
const REPO = 'kutbudev/ramorie-cli';
|
|
@@ -27,6 +27,8 @@ const ARCH_MAP = {
|
|
|
27
27
|
arm64: 'arm64'
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
const SKIP_HOOK_REFRESH_ENV = 'RAMORIE_SKIP_HOOK_REFRESH';
|
|
31
|
+
|
|
30
32
|
function download(url) {
|
|
31
33
|
return new Promise((resolve, reject) => {
|
|
32
34
|
const request = (url) => {
|
|
@@ -53,6 +55,34 @@ function download(url) {
|
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
function refreshProtocolHooks(binaryPath) {
|
|
59
|
+
if (process.env[SKIP_HOOK_REFRESH_ENV]) {
|
|
60
|
+
console.log(` Skipping protocol hook refresh (${SKIP_HOOK_REFRESH_ENV} is set)`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!fs.existsSync(binaryPath)) {
|
|
65
|
+
console.log(' ⚠ Protocol hook refresh skipped: binary not found');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
console.log(' Refreshing protocol hooks...');
|
|
71
|
+
execFileSync(binaryPath, ['setup-hooks', 'install', '--client', 'all'], {
|
|
72
|
+
env: {
|
|
73
|
+
...process.env,
|
|
74
|
+
RAMORIE_NO_UPDATE_CHECK: '1'
|
|
75
|
+
},
|
|
76
|
+
stdio: 'pipe'
|
|
77
|
+
});
|
|
78
|
+
console.log(' ✓ Protocol hooks refreshed');
|
|
79
|
+
} catch (error) {
|
|
80
|
+
const message = error && error.message ? error.message : String(error);
|
|
81
|
+
console.log(` ⚠ Protocol hook refresh failed: ${message}`);
|
|
82
|
+
console.log(' Run "ramorie setup-hooks install --client all" manually to update hook templates.');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
56
86
|
async function main() {
|
|
57
87
|
const platform = PLATFORM_MAP[process.platform];
|
|
58
88
|
const arch = ARCH_MAP[process.arch];
|
|
@@ -115,6 +145,11 @@ async function main() {
|
|
|
115
145
|
fs.chmodSync(binaryPath, 0o755);
|
|
116
146
|
}
|
|
117
147
|
|
|
148
|
+
// Keep already-installed editor hooks in sync with the just-installed
|
|
149
|
+
// binary. Best-effort: a package upgrade must not fail because a local
|
|
150
|
+
// editor config is absent, locked, or intentionally skipped.
|
|
151
|
+
refreshProtocolHooks(binaryPath);
|
|
152
|
+
|
|
118
153
|
// Cleanup temp files and directory
|
|
119
154
|
if (fs.existsSync(tempFile)) {
|
|
120
155
|
fs.unlinkSync(tempFile);
|