@theopenbee/cli 0.0.0-test.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/bin/openbee +53 -0
- package/lib/index.js +40 -0
- package/package.json +28 -0
package/bin/openbee
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require('child_process');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const PLATFORM_MAP = {
|
|
8
|
+
'linux-x64': '@theopenbee/cli-linux-x64',
|
|
9
|
+
'linux-arm64': '@theopenbee/cli-linux-arm64',
|
|
10
|
+
'darwin-x64': '@theopenbee/cli-darwin-x64',
|
|
11
|
+
'darwin-arm64': '@theopenbee/cli-darwin-arm64',
|
|
12
|
+
'win32-x64': '@theopenbee/cli-win32-x64',
|
|
13
|
+
'win32-arm64': '@theopenbee/cli-win32-arm64',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const BINARY_NAME = {
|
|
17
|
+
'win32-x64': 'openbee.exe',
|
|
18
|
+
'win32-arm64': 'openbee.exe',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const key = `${process.platform}-${process.arch}`;
|
|
22
|
+
const pkgName = PLATFORM_MAP[key];
|
|
23
|
+
|
|
24
|
+
if (!pkgName) {
|
|
25
|
+
process.stderr.write(
|
|
26
|
+
`openbee: unsupported platform ${process.platform}/${process.arch}\n`
|
|
27
|
+
);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let pkgDir;
|
|
32
|
+
try {
|
|
33
|
+
// require.resolve finds the package.json, giving us the package root
|
|
34
|
+
pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
|
|
35
|
+
} catch (e) {
|
|
36
|
+
process.stderr.write(
|
|
37
|
+
`openbee: optional dependency ${pkgName} is not installed.\n` +
|
|
38
|
+
`Try: npm install ${pkgName}\n`
|
|
39
|
+
);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const binaryName = BINARY_NAME[key] || 'openbee';
|
|
44
|
+
const binaryPath = path.join(pkgDir, 'bin', binaryName);
|
|
45
|
+
|
|
46
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
|
|
47
|
+
|
|
48
|
+
if (result.error) {
|
|
49
|
+
process.stderr.write(`openbee: failed to launch binary: ${result.error.message}\n`);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
process.exit(result.status ?? 1);
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const PLATFORM_MAP = {
|
|
6
|
+
'linux-x64': '@theopenbee/cli-linux-x64',
|
|
7
|
+
'linux-arm64': '@theopenbee/cli-linux-arm64',
|
|
8
|
+
'darwin-x64': '@theopenbee/cli-darwin-x64',
|
|
9
|
+
'darwin-arm64': '@theopenbee/cli-darwin-arm64',
|
|
10
|
+
'win32-x64': '@theopenbee/cli-win32-x64',
|
|
11
|
+
'win32-arm64': '@theopenbee/cli-win32-arm64',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const BINARY_NAME = {
|
|
15
|
+
'win32-x64': 'openbee.exe',
|
|
16
|
+
'win32-arm64': 'openbee.exe',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function getBinaryPath() {
|
|
20
|
+
const key = `${process.platform}-${process.arch}`;
|
|
21
|
+
const pkgName = PLATFORM_MAP[key];
|
|
22
|
+
|
|
23
|
+
if (!pkgName) {
|
|
24
|
+
throw new Error(`openbee: unsupported platform ${process.platform}/${process.arch}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let pkgDir;
|
|
28
|
+
try {
|
|
29
|
+
pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`openbee: optional dependency ${pkgName} is not installed. Try: npm install ${pkgName}`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const binaryName = BINARY_NAME[key] || 'openbee';
|
|
37
|
+
return path.join(pkgDir, 'bin', binaryName);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = { getBinaryPath };
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@theopenbee/cli",
|
|
3
|
+
"version": "0.0.0-test.1",
|
|
4
|
+
"description": "openbee CLI",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"openbee": "./bin/openbee"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"lib/"
|
|
12
|
+
],
|
|
13
|
+
"optionalDependencies": {
|
|
14
|
+
"@theopenbee/cli-linux-x64": "0.0.0-test.1",
|
|
15
|
+
"@theopenbee/cli-linux-arm64": "0.0.0-test.1",
|
|
16
|
+
"@theopenbee/cli-darwin-x64": "0.0.0-test.1",
|
|
17
|
+
"@theopenbee/cli-darwin-arm64": "0.0.0-test.1",
|
|
18
|
+
"@theopenbee/cli-win32-x64": "0.0.0-test.1",
|
|
19
|
+
"@theopenbee/cli-win32-arm64": "0.0.0-test.1"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=14"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/theopenbee/openbee"
|
|
27
|
+
}
|
|
28
|
+
}
|