@taleshape/shaper 0.24.6 → 0.24.8
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/bin/get-binary.js +60 -0
- package/bin/shaper.js +28 -0
- package/package.json +5 -5
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
|
|
6
|
+
const PLATFORMS = {
|
|
7
|
+
'darwin-arm64': '@taleshape/shaper-darwin-arm64',
|
|
8
|
+
'darwin-x64': '@taleshape/shaper-darwin-x64',
|
|
9
|
+
'linux-arm64': '@taleshape/shaper-linux-arm64',
|
|
10
|
+
'linux-x64': '@taleshape/shaper-linux-x64',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function getBinaryPath() {
|
|
14
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
15
|
+
const packageName = PLATFORMS[platformKey];
|
|
16
|
+
|
|
17
|
+
if (!packageName) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`Unsupported platform or architecture: ${process.platform}-${process.arch}. ` +
|
|
20
|
+
`Supported platforms are: ${Object.keys(PLATFORMS).join(', ')}.`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let packageJsonPath;
|
|
25
|
+
try {
|
|
26
|
+
packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
27
|
+
} catch (err) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Failed to locate binary package "${packageName}" for platform ${platformKey}.\n` +
|
|
30
|
+
`This usually happens if optional dependencies were skipped during installation.\n` +
|
|
31
|
+
`Try reinstalling with optional dependencies enabled.\n` +
|
|
32
|
+
`Original error: ${err.message}`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const binaryName = process.platform === 'win32' ? 'shaper.exe' : 'shaper';
|
|
37
|
+
const binaryPath = path.join(path.dirname(packageJsonPath), 'bin', binaryName);
|
|
38
|
+
|
|
39
|
+
if (!fs.existsSync(binaryPath)) {
|
|
40
|
+
throw new Error(`Binary not found at expected path: ${binaryPath}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (process.platform !== 'win32') {
|
|
44
|
+
try {
|
|
45
|
+
const stat = fs.statSync(binaryPath);
|
|
46
|
+
if ((stat.mode & 0o111) === 0) {
|
|
47
|
+
fs.chmodSync(binaryPath, stat.mode | 0o755);
|
|
48
|
+
}
|
|
49
|
+
} catch {
|
|
50
|
+
// Ignore if chmod fails (e.g. read-only filesystem)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return binaryPath;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
getBinaryPath,
|
|
59
|
+
PLATFORMS,
|
|
60
|
+
};
|
package/bin/shaper.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
const { spawnSync } = require('child_process');
|
|
6
|
+
const { getBinaryPath } = require('./get-binary');
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
const binaryPath = getBinaryPath();
|
|
10
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
11
|
+
stdio: 'inherit',
|
|
12
|
+
windowsHide: true,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (result.error) {
|
|
16
|
+
console.error(`Failed to execute shaper binary: ${result.error.message}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (result.signal) {
|
|
21
|
+
process.kill(process.pid, result.signal);
|
|
22
|
+
} else {
|
|
23
|
+
process.exit(result.status ?? 0);
|
|
24
|
+
}
|
|
25
|
+
} catch (err) {
|
|
26
|
+
console.error(`Error: ${err.message}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taleshape/shaper",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.8",
|
|
4
4
|
"description": "Minimal Embedded Analytics and Data Platform",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@taleshape/shaper-darwin-arm64": "0.24.
|
|
37
|
-
"@taleshape/shaper-darwin-x64": "0.24.
|
|
38
|
-
"@taleshape/shaper-linux-arm64": "0.24.
|
|
39
|
-
"@taleshape/shaper-linux-x64": "0.24.
|
|
36
|
+
"@taleshape/shaper-darwin-arm64": "0.24.8",
|
|
37
|
+
"@taleshape/shaper-darwin-x64": "0.24.8",
|
|
38
|
+
"@taleshape/shaper-linux-arm64": "0.24.8",
|
|
39
|
+
"@taleshape/shaper-linux-x64": "0.24.8"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=18"
|