easyresearch 0.0.1 → 0.0.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.
- package/launcher.mjs +53 -0
- package/package.json +5 -8
- package/bin/easyresearch.exe +0 -4
- package/postinstall.mjs +0 -117
package/launcher.mjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runtime launcher for the `easyresearch` meta package.
|
|
3
|
+
// Resolves the platform-specific binary package (easyresearch-<os>-<arch>)
|
|
4
|
+
// from optionalDependencies and executes it with the given arguments.
|
|
5
|
+
// No install scripts, no postinstall: works on any npm version regardless
|
|
6
|
+
// of allowScripts/--ignore-scripts settings.
|
|
7
|
+
|
|
8
|
+
import { spawnSync } from "node:child_process";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
10
|
+
import { existsSync } from "node:fs";
|
|
11
|
+
import { dirname, join } from "node:path";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { readFileSync } from "node:fs";
|
|
14
|
+
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const require = createRequire(import.meta.url);
|
|
17
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, "package.json"), "utf8"));
|
|
18
|
+
|
|
19
|
+
const platformMap = {
|
|
20
|
+
darwin: "darwin",
|
|
21
|
+
linux: "linux",
|
|
22
|
+
win32: "windows",
|
|
23
|
+
};
|
|
24
|
+
const supportedArchs = ["x64", "arm64"];
|
|
25
|
+
|
|
26
|
+
const platform = platformMap[process.platform];
|
|
27
|
+
const arch = supportedArchs.includes(process.arch) ? process.arch : undefined;
|
|
28
|
+
const name = platform && arch ? `easyresearch-${platform}-${arch}` : undefined;
|
|
29
|
+
|
|
30
|
+
if (!name || !packageJson.optionalDependencies?.[name]) {
|
|
31
|
+
console.error(
|
|
32
|
+
`easyresearch does not ship a binary for ${process.platform}-${process.arch}. Supported platforms: linux-x64, darwin-arm64, windows-x64.`,
|
|
33
|
+
);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function binaryPath() {
|
|
38
|
+
const packageJsonPath = require.resolve(`${name}/package.json`);
|
|
39
|
+
const binary = join(dirname(packageJsonPath), "bin", platform === "windows" ? "easyresearch.exe" : "easyresearch");
|
|
40
|
+
if (!existsSync(binary)) throw new Error(`Binary not found at ${binary}`);
|
|
41
|
+
return binary;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let target;
|
|
45
|
+
try {
|
|
46
|
+
target = binaryPath();
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const result = spawnSync(target, process.argv.slice(2), { stdio: "inherit" });
|
|
53
|
+
process.exit(result.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easyresearch",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Automated academic paper writing CLI built on the Pi agent harness",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -15,14 +15,11 @@
|
|
|
15
15
|
"latex"
|
|
16
16
|
],
|
|
17
17
|
"bin": {
|
|
18
|
-
"easyresearch": "./
|
|
19
|
-
},
|
|
20
|
-
"scripts": {
|
|
21
|
-
"postinstall": "node ./postinstall.mjs"
|
|
18
|
+
"easyresearch": "./launcher.mjs"
|
|
22
19
|
},
|
|
23
20
|
"optionalDependencies": {
|
|
24
|
-
"easyresearch-linux-x64": "0.0.
|
|
25
|
-
"easyresearch-darwin-arm64": "0.0.
|
|
26
|
-
"easyresearch-windows-x64": "0.0.
|
|
21
|
+
"easyresearch-linux-x64": "0.0.2",
|
|
22
|
+
"easyresearch-darwin-arm64": "0.0.2",
|
|
23
|
+
"easyresearch-windows-x64": "0.0.2"
|
|
27
24
|
}
|
|
28
25
|
}
|
package/bin/easyresearch.exe
DELETED
package/postinstall.mjs
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// postinstall for the `easyresearch` meta package.
|
|
3
|
-
// Resolves the platform-specific binary package (easyresearch-<os>-<arch>),
|
|
4
|
-
// copies the executable into ./bin/easyresearch.exe, and verifies it with
|
|
5
|
-
// `--version`.
|
|
6
|
-
//
|
|
7
|
-
// Adapted from opencode-ai (https://github.com/sst/opencode, MIT licensed)
|
|
8
|
-
// which ships a platform meta package in the same way.
|
|
9
|
-
|
|
10
|
-
import childProcess from "child_process";
|
|
11
|
-
import fs from "fs";
|
|
12
|
-
import os from "os";
|
|
13
|
-
import path from "path";
|
|
14
|
-
import { createRequire } from "module";
|
|
15
|
-
import { fileURLToPath } from "url";
|
|
16
|
-
|
|
17
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
const require = createRequire(import.meta.url);
|
|
19
|
-
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8"));
|
|
20
|
-
|
|
21
|
-
const platformMap = {
|
|
22
|
-
darwin: "darwin",
|
|
23
|
-
linux: "linux",
|
|
24
|
-
win32: "windows",
|
|
25
|
-
};
|
|
26
|
-
const archMap = {
|
|
27
|
-
x64: "x64",
|
|
28
|
-
arm64: "arm64",
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const platform = platformMap[os.platform()] ?? os.platform();
|
|
32
|
-
const arch = archMap[os.arch()] ?? os.arch();
|
|
33
|
-
const base = `easyresearch-${platform}-${arch}`;
|
|
34
|
-
const sourceBinary = platform === "windows" ? "easyresearch.exe" : "easyresearch";
|
|
35
|
-
const targetBinary = path.join(__dirname, "bin", "easyresearch.exe");
|
|
36
|
-
|
|
37
|
-
function packageName() {
|
|
38
|
-
// Shipped platforms (see scripts/build.ts TARGETS):
|
|
39
|
-
// linux-x64, darwin-arm64, windows-x64
|
|
40
|
-
return base;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function resolveBinary(name) {
|
|
44
|
-
const packageJsonPath = require.resolve(`${name}/package.json`);
|
|
45
|
-
const binaryPath = path.join(path.dirname(packageJsonPath), "bin", sourceBinary);
|
|
46
|
-
if (!fs.existsSync(binaryPath)) throw new Error(`Binary not found at ${binaryPath}`);
|
|
47
|
-
return binaryPath;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function installPackage(name) {
|
|
51
|
-
const version = packageJson.optionalDependencies?.[name];
|
|
52
|
-
if (!version) return;
|
|
53
|
-
|
|
54
|
-
const temp = fs.mkdtempSync(path.join(os.tmpdir(), "easyresearch-install-"));
|
|
55
|
-
try {
|
|
56
|
-
const result = childProcess.spawnSync(
|
|
57
|
-
"npm",
|
|
58
|
-
["install", "--ignore-scripts", "--no-save", "--loglevel=error", "--prefix", temp, `${name}@${version}`],
|
|
59
|
-
{ stdio: "inherit", windowsHide: true },
|
|
60
|
-
);
|
|
61
|
-
if (result.status !== 0) return;
|
|
62
|
-
const packageDir = path.join(temp, "node_modules", name);
|
|
63
|
-
copyBinary(path.join(packageDir, "bin", sourceBinary), targetBinary);
|
|
64
|
-
return true;
|
|
65
|
-
} finally {
|
|
66
|
-
fs.rmSync(temp, { recursive: true, force: true });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function copyBinary(source, target) {
|
|
71
|
-
if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`);
|
|
72
|
-
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
73
|
-
if (fs.existsSync(target)) fs.unlinkSync(target);
|
|
74
|
-
try {
|
|
75
|
-
fs.linkSync(source, target);
|
|
76
|
-
} catch {
|
|
77
|
-
fs.copyFileSync(source, target);
|
|
78
|
-
}
|
|
79
|
-
fs.chmodSync(target, 0o755);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function verifyBinary() {
|
|
83
|
-
const result = childProcess.spawnSync(targetBinary, ["--version"], {
|
|
84
|
-
encoding: "utf8",
|
|
85
|
-
stdio: "ignore",
|
|
86
|
-
windowsHide: true,
|
|
87
|
-
});
|
|
88
|
-
return result.status === 0;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function main() {
|
|
92
|
-
const name = packageName();
|
|
93
|
-
if (!packageJson.optionalDependencies?.[name]) {
|
|
94
|
-
throw new Error(
|
|
95
|
-
`easyresearch does not ship a binary for ${platform}-${arch}. Supported platforms: linux-x64, darwin-arm64, windows-x64.`,
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
copyBinary(resolveBinary(name), targetBinary);
|
|
100
|
-
if (verifyBinary()) return;
|
|
101
|
-
} catch {
|
|
102
|
-
if (installPackage(name) && verifyBinary()) return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
throw new Error(
|
|
106
|
-
`It seems your package manager failed to install the right easyresearch binary package. Try manually installing ${JSON.stringify(
|
|
107
|
-
name,
|
|
108
|
-
)}.`,
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
main();
|
|
114
|
-
} catch (error) {
|
|
115
|
-
console.error(error.message);
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|