@electivus/apex-log-viewer 0.1.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/apex-log-viewer.js +50 -0
- package/package.json +16 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
export const PACKAGE_BY_TARGET = {
|
|
10
|
+
'linux-x64': '@electivus/apex-log-viewer-linux-x64',
|
|
11
|
+
'linux-arm64': '@electivus/apex-log-viewer-linux-arm64',
|
|
12
|
+
'darwin-x64': '@electivus/apex-log-viewer-darwin-x64',
|
|
13
|
+
'darwin-arm64': '@electivus/apex-log-viewer-darwin-arm64',
|
|
14
|
+
'win32-x64': '@electivus/apex-log-viewer-win32-x64',
|
|
15
|
+
'win32-arm64': '@electivus/apex-log-viewer-win32-arm64'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function resolvePackageForTarget(platform = process.platform, arch = process.arch) {
|
|
19
|
+
const target = `${platform}-${arch}`;
|
|
20
|
+
const packageName = PACKAGE_BY_TARGET[target];
|
|
21
|
+
if (!packageName) {
|
|
22
|
+
throw new Error(`Unsupported platform/arch target: ${target}`);
|
|
23
|
+
}
|
|
24
|
+
return packageName;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function resolveBinaryPath(platform = process.platform, arch = process.arch) {
|
|
28
|
+
const packageName = resolvePackageForTarget(platform, arch);
|
|
29
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
30
|
+
const binaryName = platform === 'win32' ? 'apex-log-viewer.exe' : 'apex-log-viewer';
|
|
31
|
+
return path.join(path.dirname(packageJsonPath), 'bin', binaryName);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function resolveExitCode(result) {
|
|
35
|
+
return result.status ?? (result.signal ? 1 : 0);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function main(argv = process.argv.slice(2)) {
|
|
39
|
+
const binaryPath = resolveBinaryPath();
|
|
40
|
+
const result = spawnSync(binaryPath, argv, { stdio: 'inherit' });
|
|
41
|
+
if (result.error) {
|
|
42
|
+
throw result.error;
|
|
43
|
+
}
|
|
44
|
+
process.exit(resolveExitCode(result));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const entryPath = process.argv[1] ? path.resolve(process.argv[1]) : '';
|
|
48
|
+
if (entryPath && entryPath === fileURLToPath(import.meta.url)) {
|
|
49
|
+
main();
|
|
50
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@electivus/apex-log-viewer",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"alv": "bin/apex-log-viewer.js"
|
|
7
|
+
},
|
|
8
|
+
"optionalDependencies": {
|
|
9
|
+
"@electivus/apex-log-viewer-linux-x64": "0.1.1",
|
|
10
|
+
"@electivus/apex-log-viewer-linux-arm64": "0.1.1",
|
|
11
|
+
"@electivus/apex-log-viewer-darwin-x64": "0.1.1",
|
|
12
|
+
"@electivus/apex-log-viewer-darwin-arm64": "0.1.1",
|
|
13
|
+
"@electivus/apex-log-viewer-win32-x64": "0.1.1",
|
|
14
|
+
"@electivus/apex-log-viewer-win32-arm64": "0.1.1"
|
|
15
|
+
}
|
|
16
|
+
}
|