turnout-cli 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/install.js +16 -5
  2. package/package.json +4 -1
package/install.js CHANGED
@@ -4,9 +4,11 @@ const https = require("https");
4
4
  const path = require("path");
5
5
  const { spawnSync } = require("child_process");
6
6
 
7
- const { version } = require("./package.json");
7
+ const pkg = require("./package.json");
8
8
  const REPO = "lacodda/turnout";
9
- const TAG = `v${version}`;
9
+ // The wrapper can be patched independently of the Rust binary: an explicit
10
+ // turnout.binary field pins the release tag, otherwise it follows the version.
11
+ const TAG = (pkg.turnout && pkg.turnout.binary) || `v${pkg.version}`;
10
12
 
11
13
  const TARGETS = {
12
14
  "win32-x64": ["x86_64-pc-windows-msvc", "zip"],
@@ -52,10 +54,19 @@ download(url, archive, 0, (err) => {
52
54
  console.error(`turnout-cli: download failed: ${err.message}`);
53
55
  process.exit(1);
54
56
  }
55
- // bsdtar (shipped with Windows 10+, macOS and most Linux distros) reads both formats.
56
- const result = spawnSync("tar", ["-xf", archive, "-C", __dirname], { stdio: "inherit" });
57
+ // Extraction must not depend on which tar happens to be first in PATH
58
+ // (Git Bash ships a GNU tar that cannot read zip): zip goes through
59
+ // PowerShell's Expand-Archive, tar.gz through tar on Unix systems.
60
+ const result =
61
+ ext === "zip"
62
+ ? spawnSync(
63
+ "powershell.exe",
64
+ ["-NoProfile", "-NonInteractive", "-Command", "Expand-Archive -LiteralPath 'archive.zip' -DestinationPath . -Force"],
65
+ { cwd: __dirname, stdio: "inherit" },
66
+ )
67
+ : spawnSync("tar", ["-xzf", `archive.${ext}`], { cwd: __dirname, stdio: "inherit" });
57
68
  if (result.status !== 0) {
58
- console.error("turnout-cli: cannot extract the archive (is `tar` available?)");
69
+ console.error("turnout-cli: cannot extract the archive");
59
70
  process.exit(1);
60
71
  }
61
72
  fs.renameSync(path.join(__dirname, name, exe), path.join(__dirname, exe));
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "turnout-cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
+ "turnout": {
5
+ "binary": "v0.2.0"
6
+ },
4
7
  "description": "A developer's switchyard: point local apps at any backend stand, keep servers and secrets at hand, build and deploy from any directory",
5
8
  "license": "MIT",
6
9
  "author": "Kirill Lakhtachev <lahtachev@gmail.com> (https://lacodda.com)",