@metorial/cli-core 0.1.1 → 0.1.3

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/dist/index.d.ts CHANGED
@@ -3,10 +3,11 @@ type RunCLIOptions = {
3
3
  cwd?: string;
4
4
  env?: NodeJS.ProcessEnv;
5
5
  version?: string;
6
+ binary?: string;
6
7
  stdoutTransform?: OutputTransform;
7
8
  stderrTransform?: OutputTransform;
8
9
  };
9
- declare function resolveCLIPath(version?: string): Promise<string>;
10
+ declare function resolveCLIPath(version?: string, binary?: string): Promise<string>;
10
11
  declare function runCLI(args: string[], options?: RunCLIOptions): Promise<number>;
11
12
  declare function runCLIAndExit(args: string[], options?: RunCLIOptions): Promise<void>;
12
13
  declare function replaceOutput(searchValue: string, replaceValue: string): OutputTransform;
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ var tar = __toESM(require("tar"));
48
48
  // package.json
49
49
  var package_default = {
50
50
  name: "@metorial/cli-core",
51
- version: "0.1.1",
51
+ version: "0.1.3",
52
52
  description: "Runtime helpers for downloading and invoking the Metorial CLI",
53
53
  license: "MIT",
54
54
  main: "./dist/index.js",
@@ -70,12 +70,12 @@ var package_default = {
70
70
 
71
71
  // src/index.ts
72
72
  var DEFAULT_BASE_URL = "https://cli.metorial.com";
73
- async function resolveCLIPath(version) {
73
+ async function resolveCLIPath(version, binary = "metorial") {
74
74
  let tag = normalizeVersion(
75
75
  version || process.env.METORIAL_CLI_VERSION || package_default.version
76
76
  );
77
- let spec = getPlatformSpec(tag);
78
- let installDir = import_node_path.default.join(getCacheRoot(), "versions", tag);
77
+ let spec = getPlatformSpec(tag, binary);
78
+ let installDir = import_node_path.default.join(getCacheRoot(), "versions", tag, spec.binaryName.replace(/\.exe$/, ""));
79
79
  let binaryPath = import_node_path.default.join(installDir, spec.binaryName);
80
80
  if (await exists(binaryPath)) {
81
81
  return binaryPath;
@@ -84,7 +84,7 @@ async function resolveCLIPath(version) {
84
84
  return binaryPath;
85
85
  }
86
86
  async function runCLI(args, options = {}) {
87
- let binaryPath = await resolveCLIPath(options.version);
87
+ let binaryPath = await resolveCLIPath(options.version, options.binary || "metorial");
88
88
  if (!options.stdoutTransform && !options.stderrTransform) {
89
89
  return await spawnWithInheritedOutput(binaryPath, args, options);
90
90
  }
@@ -209,13 +209,13 @@ function getCacheRoot() {
209
209
  }
210
210
  return import_node_path.default.join(import_node_os.default.homedir(), ".metorial", "cli-npm");
211
211
  }
212
- function getPlatformSpec(tag) {
212
+ function getPlatformSpec(tag, binary = "metorial") {
213
213
  let goos = resolveGoOS();
214
214
  let goarch = resolveGoArch();
215
215
  let extension = goos === "windows" ? "zip" : "tar.gz";
216
- let binaryName = goos === "windows" ? "metorial.exe" : "metorial";
216
+ let binaryName = goos === "windows" ? `${binary}.exe` : binary;
217
217
  return {
218
- archiveName: `metorial_${tag.replace(/^v/, "")}_${goos}_${goarch}.${extension}`,
218
+ archiveName: `${binary}_${tag.replace(/^v/, "")}_${goos}_${goarch}.${extension}`,
219
219
  binaryName
220
220
  };
221
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metorial/cli-core",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Runtime helpers for downloading and invoking the Metorial CLI",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",