@enactprotocol/enact 2.0.5
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/enact.js +62 -0
- package/package.json +24 -0
package/bin/enact.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("node:child_process");
|
|
4
|
+
|
|
5
|
+
function pkgNameFor(platform, arch) {
|
|
6
|
+
// Keep names aligned with the optionalDependencies list in this package.json
|
|
7
|
+
if (platform === "darwin" && arch === "arm64") return "@enactprotocol/enact-darwin-arm64";
|
|
8
|
+
if (platform === "darwin" && arch === "x64") return "@enactprotocol/enact-darwin-x64";
|
|
9
|
+
if (platform === "linux" && arch === "arm64") return "@enactprotocol/enact-linux-arm64";
|
|
10
|
+
if (platform === "linux" && arch === "x64") return "@enactprotocol/enact-linux-x64";
|
|
11
|
+
if (platform === "win32" && arch === "x64") return "@enactprotocol/enact-win32-x64";
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function loadPlatformBinary(pkgName) {
|
|
16
|
+
// Platform packages are expected to export { binPath }.
|
|
17
|
+
// They may be ESM or CJS; handle both.
|
|
18
|
+
try {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
20
|
+
const mod = require(pkgName);
|
|
21
|
+
return mod && mod.binPath ? mod : mod && mod.default ? mod.default : mod;
|
|
22
|
+
} catch (err) {
|
|
23
|
+
return { loadError: err };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function run() {
|
|
28
|
+
const pkgName = pkgNameFor(process.platform, process.arch);
|
|
29
|
+
if (!pkgName) {
|
|
30
|
+
console.error(
|
|
31
|
+
`enact: unsupported platform ${process.platform}/${process.arch}. ` +
|
|
32
|
+
`No prebuilt binary is available.`
|
|
33
|
+
);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const platformPkg = loadPlatformBinary(pkgName);
|
|
38
|
+
if (!platformPkg || !platformPkg.binPath) {
|
|
39
|
+
const msg = platformPkg && platformPkg.loadError ? String(platformPkg.loadError) : "Unknown error";
|
|
40
|
+
console.error(`enact: failed to load platform package ${pkgName}.`);
|
|
41
|
+
console.error(msg);
|
|
42
|
+
console.error(`\nTry reinstalling: npm i -g @enactprotocol/enact`);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const binPath = platformPkg.binPath;
|
|
47
|
+
const args = process.argv.slice(2);
|
|
48
|
+
|
|
49
|
+
// Allow platform packages to ship a JS shim during development.
|
|
50
|
+
const isNodeScript = /\.c?js$/i.test(binPath);
|
|
51
|
+
const cmd = isNodeScript ? process.execPath : binPath;
|
|
52
|
+
const cmdArgs = isNodeScript ? [binPath, ...args] : args;
|
|
53
|
+
|
|
54
|
+
const result = spawnSync(cmd, cmdArgs, { stdio: "inherit" });
|
|
55
|
+
if (result.error) {
|
|
56
|
+
console.error(String(result.error));
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
process.exit(result.status ?? 1);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
run();
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@enactprotocol/enact",
|
|
3
|
+
"version": "2.0.5",
|
|
4
|
+
"description": "Enact CLI (thin wrapper that loads the correct platform binary)",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/EnactProtocol/enact.git",
|
|
9
|
+
"directory": "packages/enact"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"enact": "./bin/enact.js"
|
|
13
|
+
},
|
|
14
|
+
"optionalDependencies": {
|
|
15
|
+
"@enactprotocol/enact-darwin-arm64": "2.0.5",
|
|
16
|
+
"@enactprotocol/enact-darwin-x64": "2.0.5",
|
|
17
|
+
"@enactprotocol/enact-linux-arm64": "2.0.5",
|
|
18
|
+
"@enactprotocol/enact-linux-x64": "2.0.5",
|
|
19
|
+
"@enactprotocol/enact-win32-x64": "2.0.5"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18.0.0"
|
|
23
|
+
}
|
|
24
|
+
}
|