@powerformer/vela-cli 0.0.1-test
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/vela.cjs +29 -0
- package/index.cjs +83 -0
- package/index.d.ts +1 -0
- package/index.mjs +81 -0
- package/package.json +34 -0
package/bin/vela.cjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require("node:child_process");
|
|
5
|
+
const { resolveVelaCliBin } = require("../index.cjs");
|
|
6
|
+
|
|
7
|
+
let binary;
|
|
8
|
+
try {
|
|
9
|
+
binary = resolveVelaCliBin({ strict: true });
|
|
10
|
+
} catch (error) {
|
|
11
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
12
|
+
console.error(message);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const result = spawnSync(binary, process.argv.slice(2), {
|
|
17
|
+
stdio: "inherit",
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (result.error) {
|
|
21
|
+
console.error(result.error.message);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (result.signal) {
|
|
26
|
+
process.kill(process.pid, result.signal);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
process.exit(result.status ?? 1);
|
package/index.cjs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("node:fs");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
|
|
6
|
+
const platformPackages = {
|
|
7
|
+
"darwin-arm64": "@powerformer/vela-cli-darwin-arm64",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function platformKey() {
|
|
11
|
+
return `${process.platform}-${process.arch}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function unsupportedPlatformError() {
|
|
15
|
+
return new Error(
|
|
16
|
+
`Vela CLI is not packaged for ${process.platform}/${process.arch}`,
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function missingBinaryError(packageName, cause) {
|
|
21
|
+
const details =
|
|
22
|
+
cause instanceof Error && cause.message ? `: ${cause.message}` : "";
|
|
23
|
+
return new Error(
|
|
24
|
+
`Vela CLI binary package ${packageName} is not installed or is incomplete${details}`,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function resolvePackageBinary(packageName) {
|
|
29
|
+
const packageJSON = resolvePackageJSON(packageName);
|
|
30
|
+
const binary = path.join(
|
|
31
|
+
path.dirname(packageJSON),
|
|
32
|
+
"bin",
|
|
33
|
+
process.platform === "win32" ? "vela.exe" : "vela",
|
|
34
|
+
);
|
|
35
|
+
if (!fs.existsSync(binary)) {
|
|
36
|
+
throw missingBinaryError(packageName);
|
|
37
|
+
}
|
|
38
|
+
return binary;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function resolvePackageJSON(packageName) {
|
|
42
|
+
try {
|
|
43
|
+
return require.resolve(`${packageName}/package.json`);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
const sourcePackageJSON = path.resolve(
|
|
46
|
+
__dirname,
|
|
47
|
+
"..",
|
|
48
|
+
"vela-cli-darwin-arm64",
|
|
49
|
+
"package.json",
|
|
50
|
+
);
|
|
51
|
+
if (
|
|
52
|
+
packageName === "@powerformer/vela-cli-darwin-arm64" &&
|
|
53
|
+
fs.existsSync(sourcePackageJSON)
|
|
54
|
+
) {
|
|
55
|
+
return sourcePackageJSON;
|
|
56
|
+
}
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function resolveVelaCliBin(options = {}) {
|
|
62
|
+
const strict = options.strict === true;
|
|
63
|
+
const packageName = platformPackages[platformKey()];
|
|
64
|
+
if (!packageName) {
|
|
65
|
+
if (strict) {
|
|
66
|
+
throw unsupportedPlatformError();
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
return resolvePackageBinary(packageName);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (strict) {
|
|
75
|
+
throw missingBinaryError(packageName, error);
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
resolveVelaCliBin,
|
|
83
|
+
};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveVelaCliBin(options?: { strict?: boolean }): string | null;
|
package/index.mjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
|
|
8
|
+
const platformPackages = {
|
|
9
|
+
"darwin-arm64": "@powerformer/vela-cli-darwin-arm64",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function platformKey() {
|
|
13
|
+
return `${process.platform}-${process.arch}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function unsupportedPlatformError() {
|
|
17
|
+
return new Error(
|
|
18
|
+
`Vela CLI is not packaged for ${process.platform}/${process.arch}`,
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function missingBinaryError(packageName, cause) {
|
|
23
|
+
const details =
|
|
24
|
+
cause instanceof Error && cause.message ? `: ${cause.message}` : "";
|
|
25
|
+
return new Error(
|
|
26
|
+
`Vela CLI binary package ${packageName} is not installed or is incomplete${details}`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function resolvePackageBinary(packageName) {
|
|
31
|
+
const packageJSON = resolvePackageJSON(packageName);
|
|
32
|
+
const binary = path.join(
|
|
33
|
+
path.dirname(packageJSON),
|
|
34
|
+
"bin",
|
|
35
|
+
process.platform === "win32" ? "vela.exe" : "vela",
|
|
36
|
+
);
|
|
37
|
+
if (!fs.existsSync(binary)) {
|
|
38
|
+
throw missingBinaryError(packageName);
|
|
39
|
+
}
|
|
40
|
+
return binary;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function resolvePackageJSON(packageName) {
|
|
44
|
+
try {
|
|
45
|
+
return require.resolve(`${packageName}/package.json`);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
const sourcePackageJSON = path.resolve(
|
|
48
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
49
|
+
"..",
|
|
50
|
+
"vela-cli-darwin-arm64",
|
|
51
|
+
"package.json",
|
|
52
|
+
);
|
|
53
|
+
if (
|
|
54
|
+
packageName === "@powerformer/vela-cli-darwin-arm64" &&
|
|
55
|
+
fs.existsSync(sourcePackageJSON)
|
|
56
|
+
) {
|
|
57
|
+
return sourcePackageJSON;
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function resolveVelaCliBin(options = {}) {
|
|
64
|
+
const strict = options.strict === true;
|
|
65
|
+
const packageName = platformPackages[platformKey()];
|
|
66
|
+
if (!packageName) {
|
|
67
|
+
if (strict) {
|
|
68
|
+
throw unsupportedPlatformError();
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
return resolvePackageBinary(packageName);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
if (strict) {
|
|
77
|
+
throw missingBinaryError(packageName, error);
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@powerformer/vela-cli",
|
|
3
|
+
"version": "0.0.1-test",
|
|
4
|
+
"description": "Vela CLI npm meta package",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./index.cjs",
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"vela": "./bin/vela.cjs"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./index.d.ts",
|
|
15
|
+
"import": "./index.mjs",
|
|
16
|
+
"require": "./index.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"bin/vela.cjs",
|
|
21
|
+
"index.cjs",
|
|
22
|
+
"index.d.ts",
|
|
23
|
+
"index.mjs"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"test": "node --test test/*.test.cjs"
|
|
27
|
+
},
|
|
28
|
+
"optionalDependencies": {
|
|
29
|
+
"@powerformer/vela-cli-darwin-arm64": "0.0.1-test"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
}
|
|
34
|
+
}
|