@openduo/searchis 0.2.0 → 0.3.0

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.
Binary file
Binary file
Binary file
Binary file
Binary file
package/install.js CHANGED
@@ -1,109 +1,40 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
 
4
- const https = require("https");
5
- const http = require("http");
6
4
  const fs = require("fs");
7
5
  const path = require("path");
8
- const { URL } = require("url");
9
6
 
10
- const pkg = require("./package.json");
11
- const version = pkg.version;
7
+ const platform = process.platform;
8
+ const arch = process.arch;
12
9
 
13
10
  const PLATFORM_MAP = {
14
- darwin: "darwin",
15
- linux: "linux",
16
- win32: "windows",
11
+ "linux/x64": "linux-amd64",
12
+ "linux/arm64": "linux-arm64",
13
+ "darwin/x64": "darwin-amd64",
14
+ "darwin/arm64": "darwin-arm64",
15
+ "win32/x64": "windows-amd64",
17
16
  };
18
17
 
19
- const ARCH_MAP = {
20
- x64: "amd64",
21
- arm64: "arm64",
22
- };
23
-
24
- function getBinaryName() {
25
- const platform = PLATFORM_MAP[process.platform];
26
- const arch = ARCH_MAP[process.arch];
18
+ const key = `${platform}/${arch}`;
19
+ const subdir = PLATFORM_MAP[key];
27
20
 
28
- if (!platform || !arch) {
29
- throw new Error(
30
- `Unsupported platform/arch: ${process.platform}/${process.arch}`
31
- );
32
- }
33
-
34
- const ext = process.platform === "win32" ? ".exe" : "";
35
- return `searchis-${platform}-${arch}${ext}`;
21
+ if (!subdir) {
22
+ console.error(`Unsupported platform/arch: ${platform}/${arch}`);
23
+ console.error(`Supported: ${Object.keys(PLATFORM_MAP).join(", ")}`);
24
+ process.exit(1);
36
25
  }
37
26
 
38
- function download(url, dest, maxRedirects = 5) {
39
- return new Promise((resolve, reject) => {
40
- if (maxRedirects <= 0) {
41
- return reject(new Error("Too many redirects"));
42
- }
43
-
44
- const parsedUrl = new URL(url);
45
- const client = parsedUrl.protocol === "https:" ? https : http;
46
-
47
- client
48
- .get(url, { headers: { "User-Agent": "searchis-npm-installer" } }, (res) => {
49
- // Follow redirects (GitHub releases redirect to S3)
50
- if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
51
- return download(res.headers.location, dest, maxRedirects - 1).then(
52
- resolve,
53
- reject
54
- );
55
- }
56
-
57
- if (res.statusCode !== 200) {
58
- return reject(
59
- new Error(`Download failed: HTTP ${res.statusCode} for ${url}`)
60
- );
61
- }
62
-
63
- const file = fs.createWriteStream(dest);
64
- res.pipe(file);
65
- file.on("finish", () => {
66
- file.close(resolve);
67
- });
68
- file.on("error", (err) => {
69
- fs.unlink(dest, () => {});
70
- reject(err);
71
- });
72
- })
73
- .on("error", reject);
74
- });
75
- }
27
+ const ext = platform === "win32" ? ".exe" : "";
28
+ const src = path.join(__dirname, "bin", subdir, `searchis${ext}`);
29
+ const dst = path.join(__dirname, "bin", `searchis${ext}`);
76
30
 
77
- async function main() {
78
- const binaryName = getBinaryName();
79
- const url = `https://github.com/rectified-flow/searchis/releases/download/v${version}/${binaryName}`;
80
- const binDir = path.join(__dirname, "bin");
81
- const ext = process.platform === "win32" ? ".exe" : "";
82
- const dest = path.join(binDir, `searchis${ext}`);
83
-
84
- // Ensure bin directory exists
85
- if (!fs.existsSync(binDir)) {
86
- fs.mkdirSync(binDir, { recursive: true });
87
- }
88
-
89
- console.log(`Downloading searchis v${version} for ${process.platform}/${process.arch}...`);
90
- console.log(` ${url}`);
91
-
92
- await download(url, dest);
93
-
94
- // Make executable on unix
95
- if (process.platform !== "win32") {
96
- fs.chmodSync(dest, 0o755);
97
- }
98
-
99
- console.log(`searchis v${version} installed successfully.`);
31
+ if (!fs.existsSync(src)) {
32
+ // In dev/CI the binaries aren't built yet — not an error
33
+ console.log(`Binary not found: ${src} (run build.sh to compile)`);
34
+ process.exit(0);
100
35
  }
101
36
 
102
- main().catch((err) => {
103
- console.error(`Warning: Failed to download searchis binary: ${err.message}`);
104
- console.error("The 'searchis' command will not work until the binary is available.");
105
- console.error("You can manually download it from:");
106
- console.error(` https://github.com/rectified-flow/searchis/releases/tag/v${version}`);
107
- // Exit 0 so npm install doesn't fail
108
- process.exit(0);
109
- });
37
+ fs.mkdirSync(path.dirname(dst), { recursive: true });
38
+ fs.copyFileSync(src, dst);
39
+ fs.chmodSync(dst, 0o755);
40
+ console.log(`Installed searchis for ${subdir}`);
package/package.json CHANGED
@@ -1,17 +1,27 @@
1
1
  {
2
2
  "name": "@openduo/searchis",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Searchis evidence retrieval CLI",
5
5
  "bin": {
6
6
  "searchis": "bin/searchis"
7
7
  },
8
8
  "scripts": {
9
- "postinstall": "node install.js"
9
+ "postinstall": "node install.js",
10
+ "build": "./build.sh",
11
+ "pack": "npm run build && npm pack",
12
+ "publish": "npm run pack && npm publish --access public"
10
13
  },
11
14
  "files": [
12
- "bin/",
15
+ "bin/linux-amd64/searchis",
16
+ "bin/linux-arm64/searchis",
17
+ "bin/darwin-amd64/searchis",
18
+ "bin/darwin-arm64/searchis",
19
+ "bin/windows-amd64/searchis.exe",
20
+ "bin/searchis",
13
21
  "install.js",
14
- "run.js"
22
+ "run.js",
23
+ "package.json",
24
+ "README.md"
15
25
  ],
16
26
  "os": [
17
27
  "darwin",