fop-cli 3.9.8 → 3.9.10
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/install.js +47 -21
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -7,7 +7,7 @@ const path = require('path');
|
|
|
7
7
|
const { execSync } = require('child_process');
|
|
8
8
|
|
|
9
9
|
// Configuration - UPDATE THESE FOR YOUR RELEASE
|
|
10
|
-
const VERSION = '3.9.
|
|
10
|
+
const VERSION = '3.9.10';
|
|
11
11
|
const GITHUB_REPO = 'ryanbr/fop-rs'; // Change to your repo
|
|
12
12
|
const BINARY_NAME = 'fop';
|
|
13
13
|
|
|
@@ -16,26 +16,9 @@ const PLATFORMS = {
|
|
|
16
16
|
'darwin-x64': `-macos-x86_64`,
|
|
17
17
|
'darwin-arm64': `-macos-arm64`,
|
|
18
18
|
'linux-x64': `-linux-x86_64`,
|
|
19
|
-
'linux-arm64': `-linux-arm64`,
|
|
20
19
|
'win32-x64': `-windows-x86_64.exe`,
|
|
21
|
-
'win32-arm64': `-windows-arm64.exe`,
|
|
22
20
|
};
|
|
23
21
|
|
|
24
|
-
function getPlatformBinary() {
|
|
25
|
-
const platform = process.platform;
|
|
26
|
-
const arch = process.arch;
|
|
27
|
-
const key = `${platform}-${arch}`;
|
|
28
|
-
|
|
29
|
-
const suffix = PLATFORMS[key];
|
|
30
|
-
if (!suffix) {
|
|
31
|
-
console.error(`Unsupported platform: ${platform}-${arch}`);
|
|
32
|
-
console.error('Supported platforms:', Object.keys(PLATFORMS).join(', '));
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return `fop-${VERSION}${suffix}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
22
|
function getDownloadUrl(binaryName) {
|
|
40
23
|
// GitHub releases URL pattern
|
|
41
24
|
return `https://github.com/${GITHUB_REPO}/releases/download/v${VERSION}/${binaryName}`;
|
|
@@ -81,6 +64,35 @@ function download(url, dest) {
|
|
|
81
64
|
});
|
|
82
65
|
}
|
|
83
66
|
|
|
67
|
+
function buildFromSource(binaryPath) {
|
|
68
|
+
console.log('Building from source...');
|
|
69
|
+
console.log('This requires Rust to be installed (https://rustup.rs)');
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
execSync('cargo --version', { stdio: 'ignore' });
|
|
73
|
+
} catch (e) {
|
|
74
|
+
console.error('Error: Rust/Cargo not found.');
|
|
75
|
+
console.error('Please install Rust from https://rustup.rs and try again.');
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
const tempDir = path.join(__dirname, 'build-temp');
|
|
81
|
+
execSync(`git clone --depth 1 https://github.com/${GITHUB_REPO}.git "${tempDir}"`, { stdio: 'inherit' });
|
|
82
|
+
execSync('cargo build --release', { cwd: tempDir, stdio: 'inherit' });
|
|
83
|
+
|
|
84
|
+
const builtBinary = path.join(tempDir, 'target', 'release', process.platform === 'win32' ? 'fop.exe' : 'fop');
|
|
85
|
+
fs.copyFileSync(builtBinary, binaryPath);
|
|
86
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
87
|
+
|
|
88
|
+
console.log('Build completed successfully!');
|
|
89
|
+
return true;
|
|
90
|
+
} catch (e) {
|
|
91
|
+
console.error('Build failed:', e.message);
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
84
96
|
async function install() {
|
|
85
97
|
const binDir = path.join(__dirname, 'bin');
|
|
86
98
|
const binaryPath = path.join(binDir, 'fop-binary');
|
|
@@ -96,10 +108,24 @@ async function install() {
|
|
|
96
108
|
return;
|
|
97
109
|
}
|
|
98
110
|
|
|
99
|
-
const
|
|
100
|
-
const
|
|
111
|
+
const platform = process.platform;
|
|
112
|
+
const arch = process.arch;
|
|
113
|
+
const key = `${platform}-${arch}`;
|
|
114
|
+
const suffix = PLATFORMS[key];
|
|
101
115
|
|
|
102
|
-
console.log(`Installing FOP v${VERSION} for ${
|
|
116
|
+
console.log(`Installing FOP v${VERSION} for ${platform}-${arch}...`);
|
|
117
|
+
|
|
118
|
+
if (!suffix) {
|
|
119
|
+
console.log(`No pre-built binary for ${platform}-${arch}, building from source...`);
|
|
120
|
+
if (buildFromSource(binaryPath)) {
|
|
121
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const platformBinary = `fop-${VERSION}${suffix}`;
|
|
127
|
+
const url = getDownloadUrl(platformBinary);
|
|
128
|
+
|
|
103
129
|
|
|
104
130
|
try {
|
|
105
131
|
await download(url, binaryPath);
|