@bobfrankston/msger 0.1.130 → 0.1.131
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.
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Post-install script to set executable permissions on Linux binaries
|
|
4
|
+
* and check for required system dependencies
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
import { execSync } from 'child_process';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
|
|
15
|
+
function detectDistro() {
|
|
16
|
+
if (!fs.existsSync('/etc/os-release')) {
|
|
17
|
+
return 'unknown';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const osRelease = fs.readFileSync('/etc/os-release', 'utf8').toLowerCase();
|
|
22
|
+
|
|
23
|
+
if (osRelease.includes('ubuntu') || osRelease.includes('debian')) {
|
|
24
|
+
return 'debian';
|
|
25
|
+
}
|
|
26
|
+
if (osRelease.includes('fedora') || osRelease.includes('rhel') || osRelease.includes('centos')) {
|
|
27
|
+
return 'fedora';
|
|
28
|
+
}
|
|
29
|
+
if (osRelease.includes('arch')) {
|
|
30
|
+
return 'arch';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return 'unknown';
|
|
34
|
+
} catch {
|
|
35
|
+
return 'unknown';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function showDependencyInstallCommand(distro) {
|
|
40
|
+
console.warn('\n⚠️ Missing system dependencies detected!');
|
|
41
|
+
console.warn(' Install required libraries with:\n');
|
|
42
|
+
|
|
43
|
+
switch (distro) {
|
|
44
|
+
case 'debian':
|
|
45
|
+
console.warn(' sudo apt update');
|
|
46
|
+
console.warn(' sudo apt install libwebkit2gtk-4.1-0 libgtk-3-0\n');
|
|
47
|
+
break;
|
|
48
|
+
case 'fedora':
|
|
49
|
+
console.warn(' sudo dnf install webkit2gtk4.1 gtk3\n');
|
|
50
|
+
break;
|
|
51
|
+
case 'arch':
|
|
52
|
+
console.warn(' sudo pacman -S webkit2gtk gtk3\n');
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
console.warn(' Install webkit2gtk and gtk3 for your distribution\n');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function checkSystemDependencies(binaryPath) {
|
|
60
|
+
try {
|
|
61
|
+
const lddOutput = execSync(`ldd "${binaryPath}" 2>&1`, { encoding: 'utf8' });
|
|
62
|
+
|
|
63
|
+
if (lddOutput.includes('not found')) {
|
|
64
|
+
const distro = detectDistro();
|
|
65
|
+
showDependencyInstallCommand(distro);
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
// ldd command failed or not installed - skip check
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function setExecutePermissions(binaryPath, binaryName) {
|
|
73
|
+
try {
|
|
74
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
75
|
+
console.log(`✅ Set execute permissions on ${binaryName} binary`);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.warn(`⚠️ Could not set execute permission on ${binaryPath}: ${error.message}`);
|
|
78
|
+
console.warn(` You may need to run: sudo chmod +x ${binaryPath}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function main() {
|
|
83
|
+
// Windows doesn't need executable permissions
|
|
84
|
+
if (process.platform === 'win32') {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Determine binary name based on architecture
|
|
89
|
+
const arch = process.arch;
|
|
90
|
+
const binaryName = arch === 'arm64' ? 'msgernative-linux-aarch64' : 'msgernative';
|
|
91
|
+
const binaryPath = path.join(__dirname, '..', 'bin', binaryName);
|
|
92
|
+
|
|
93
|
+
// Binary doesn't exist - warn user
|
|
94
|
+
if (!fs.existsSync(binaryPath)) {
|
|
95
|
+
console.warn(`⚠️ Binary not found at ${binaryPath}`);
|
|
96
|
+
console.warn(` The msger package may not support your platform (${process.platform} ${arch})`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Set executable permissions
|
|
101
|
+
setExecutePermissions(binaryPath, binaryName);
|
|
102
|
+
|
|
103
|
+
// Check for required system libraries
|
|
104
|
+
checkSystemDependencies(binaryPath);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/msger",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.131",
|
|
4
4
|
"description": "Fast, lightweight, cross-platform message box - Rust-powered alternative to msgview",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"watch": "tsc -w",
|
|
21
21
|
"clean": "node msger-native/builder/clean.ts",
|
|
22
22
|
"test": "node test.js",
|
|
23
|
-
"postinstall": "node msger-native/builder/postinstall.
|
|
23
|
+
"postinstall": "node msger-native/builder/postinstall.js",
|
|
24
24
|
"prepublishOnly": "npm run build:ts && npm run build:native",
|
|
25
25
|
"prerelease:local": "git add -A && (git diff-index --quiet HEAD || git commit -m \"Pre-release commit\")",
|
|
26
26
|
"preversion": "npm run build:ts && npm run build:native && git add -A",
|
|
File without changes
|