drft-cli 0.1.0 → 0.1.2

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 (3) hide show
  1. package/bin/drft +2 -2
  2. package/install.js +10 -6
  3. package/package.json +2 -1
package/bin/drft CHANGED
@@ -7,11 +7,11 @@ const path = require("path");
7
7
  const fs = require("fs");
8
8
 
9
9
  const ext = process.platform === "win32" ? ".exe" : "";
10
- const binPath = path.join(__dirname, `drft${ext}`);
10
+ const binPath = path.join(__dirname, "..", "native", `drft${ext}`);
11
11
 
12
12
  if (!fs.existsSync(binPath)) {
13
13
  console.error(
14
- "drft: binary not found. Run `npm rebuild drft` or install from source: cargo install drft-cli"
14
+ "drft: binary not found. Run `npm rebuild drft-cli` or install from source: cargo install drft-cli"
15
15
  );
16
16
  process.exit(2);
17
17
  }
package/install.js CHANGED
@@ -8,7 +8,8 @@ const fs = require("fs");
8
8
  const path = require("path");
9
9
  const https = require("https");
10
10
 
11
- const VERSION = require("./package.json").version;
11
+ const pkg = require("./package.json");
12
+ const VERSION = pkg.binaryVersion || pkg.version;
12
13
  const REPO = "johnmdonahue/drft-cli";
13
14
 
14
15
  const PLATFORMS = {
@@ -64,14 +65,17 @@ async function main() {
64
65
  process.exit(0); // Don't fail the install — just won't have the binary
65
66
  }
66
67
 
67
- const binDir = path.join(__dirname, "bin");
68
- const binPath = path.join(binDir, process.platform === "win32" ? "drft.exe" : "drft");
68
+ const nativeDir = path.join(__dirname, "native");
69
+ const binaryName = process.platform === "win32" ? "drft.exe" : "drft";
70
+ const binPath = path.join(nativeDir, binaryName);
69
71
 
70
72
  // Skip if binary already exists (e.g., reinstall)
71
73
  if (fs.existsSync(binPath)) {
72
74
  return;
73
75
  }
74
76
 
77
+ fs.mkdirSync(nativeDir, { recursive: true });
78
+
75
79
  const url = getDownloadUrl(assetName);
76
80
  console.log(`drft: downloading ${platformKey} binary...`);
77
81
 
@@ -79,14 +83,14 @@ async function main() {
79
83
  const data = await download(url);
80
84
 
81
85
  // Write archive to temp file
82
- const tmpFile = path.join(binDir, assetName);
86
+ const tmpFile = path.join(nativeDir, assetName);
83
87
  fs.writeFileSync(tmpFile, data);
84
88
 
85
89
  // Extract
86
90
  if (assetName.endsWith(".tar.xz")) {
87
- execSync(`tar xf "${tmpFile}" -C "${binDir}" --strip-components=1`, { stdio: "pipe" });
91
+ execSync(`tar xf "${tmpFile}" -C "${nativeDir}" --strip-components=1`, { stdio: "pipe" });
88
92
  } else if (assetName.endsWith(".zip")) {
89
- execSync(`unzip -o "${tmpFile}" -d "${binDir}"`, { stdio: "pipe" });
93
+ execSync(`unzip -o "${tmpFile}" -d "${nativeDir}"`, { stdio: "pipe" });
90
94
  }
91
95
 
92
96
  // Clean up archive
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "drft-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
+ "binaryVersion": "0.1.0",
4
5
  "description": "A structural integrity checker for markdown directories",
5
6
  "license": "MIT",
6
7
  "repository": {