paragma 0.1.0 → 0.1.3-rc.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.
- package/bin/pg +18 -7
- package/bin/pg-darwin-arm64 +0 -0
- package/bin/pg-darwin-x64 +0 -0
- package/bin/pg-linux-arm64 +0 -0
- package/bin/pg-linux-x64 +0 -0
- package/bin/pg-win32-arm64.exe +0 -0
- package/bin/pg-win32-x64.exe +0 -0
- package/package.json +2 -6
- package/install.js +0 -56
package/bin/pg
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Runs the native pg binary
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// Runs the native pg binary for this machine. The package carries one
|
|
3
|
+
// binary per platform (bin/pg-<platform>-<arch>[.exe]), so the install
|
|
4
|
+
// needs no download script.
|
|
5
5
|
const { spawnSync } = require("child_process");
|
|
6
|
-
const path = require("path");
|
|
7
6
|
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
8
|
|
|
9
|
-
const exe = path.join(__dirname, process.platform === "win32" ? "
|
|
9
|
+
const exe = path.join(__dirname, `pg-${process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`);
|
|
10
10
|
if (!fs.existsSync(exe)) {
|
|
11
|
-
console.error(
|
|
11
|
+
console.error(`paragma: no prebuilt pg for ${process.platform}/${process.arch}.`);
|
|
12
|
+
console.error("Download it from https://github.com/Utku4836/Paragma/releases or build it: go install github.com/Utku4836/Paragma/cmd/pg@latest");
|
|
12
13
|
process.exit(7);
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
if (process.platform !== "win32") {
|
|
16
|
+
try {
|
|
17
|
+
fs.accessSync(exe, fs.constants.X_OK);
|
|
18
|
+
} catch {
|
|
19
|
+
try { fs.chmodSync(exe, 0o755); } catch {}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const r = spawnSync(exe, process.argv.slice(2), { stdio: "inherit" });
|
|
15
23
|
if (r.error) {
|
|
16
24
|
console.error("paragma: " + r.error.message);
|
|
17
25
|
process.exit(7);
|
|
18
26
|
}
|
|
27
|
+
if (r.signal) {
|
|
28
|
+
process.kill(process.pid, r.signal);
|
|
29
|
+
}
|
|
19
30
|
process.exit(r.status === null ? 1 : r.status);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bin/pg-linux-x64
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paragma",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3-rc.1",
|
|
4
4
|
"description": "Local memory for AI coding agents: rules, decisions, past errors and project notes, one call away.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -21,12 +21,8 @@
|
|
|
21
21
|
"bin": {
|
|
22
22
|
"pg": "bin/pg"
|
|
23
23
|
},
|
|
24
|
-
"scripts": {
|
|
25
|
-
"postinstall": "node install.js"
|
|
26
|
-
},
|
|
27
24
|
"files": [
|
|
28
|
-
"bin
|
|
29
|
-
"install.js",
|
|
25
|
+
"bin",
|
|
30
26
|
"README.md"
|
|
31
27
|
],
|
|
32
28
|
"os": [
|
package/install.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// Downloads the pg binary for this platform from the GitHub release that
|
|
2
|
-
// matches this package's version. Release assets are named
|
|
3
|
-
// pg-<os>-<arch>[.exe], for example pg-windows-amd64.exe or pg-darwin-arm64.
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const https = require("https");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
|
|
8
|
-
const { version } = require("./package.json");
|
|
9
|
-
const REPO = "Utku4836/Paragma";
|
|
10
|
-
|
|
11
|
-
const os = { win32: "windows", linux: "linux", darwin: "darwin" }[process.platform];
|
|
12
|
-
const arch = { x64: "amd64", arm64: "arm64" }[process.arch];
|
|
13
|
-
if (!os || !arch) {
|
|
14
|
-
console.error(`paragma: no prebuilt pg for ${process.platform}/${process.arch}. Build it with: go install github.com/${REPO}/cmd/pg@latest`);
|
|
15
|
-
process.exit(0);
|
|
16
|
-
}
|
|
17
|
-
const asset = `pg-${os}-${arch}${os === "windows" ? ".exe" : ""}`;
|
|
18
|
-
const url = `https://github.com/${REPO}/releases/download/v${version}/${asset}`;
|
|
19
|
-
const binDir = path.join(__dirname, "bin");
|
|
20
|
-
const target = path.join(binDir, os === "windows" ? "pg.exe" : "pg-native");
|
|
21
|
-
|
|
22
|
-
function get(u, redirects, done) {
|
|
23
|
-
https
|
|
24
|
-
.get(u, { headers: { "User-Agent": "paragma-npm" } }, (res) => {
|
|
25
|
-
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location && redirects > 0) {
|
|
26
|
-
res.resume();
|
|
27
|
-
return get(res.headers.location, redirects - 1, done);
|
|
28
|
-
}
|
|
29
|
-
if (res.statusCode !== 200) {
|
|
30
|
-
res.resume();
|
|
31
|
-
return done(new Error(`HTTP ${res.statusCode} for ${u}`));
|
|
32
|
-
}
|
|
33
|
-
const tmp = target + ".download";
|
|
34
|
-
const out = fs.createWriteStream(tmp, { mode: 0o755 });
|
|
35
|
-
res.pipe(out);
|
|
36
|
-
out.on("finish", () => out.close(() => done(null, tmp)));
|
|
37
|
-
out.on("error", done);
|
|
38
|
-
})
|
|
39
|
-
.on("error", done);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get(url, 5, (err, tmp) => {
|
|
43
|
-
if (err) {
|
|
44
|
-
console.error(`paragma: could not download ${asset}: ${err.message}`);
|
|
45
|
-
console.error(`Download it from https://github.com/${REPO}/releases and put it on your PATH as pg.`);
|
|
46
|
-
process.exit(0); // do not fail the whole npm install
|
|
47
|
-
}
|
|
48
|
-
fs.renameSync(tmp, target);
|
|
49
|
-
if (os !== "windows") {
|
|
50
|
-
// the npm bin link points at bin/pg: make it the binary itself, so pg
|
|
51
|
-
// starts without Node in between
|
|
52
|
-
fs.chmodSync(target, 0o755);
|
|
53
|
-
fs.renameSync(target, path.join(binDir, "pg"));
|
|
54
|
-
}
|
|
55
|
-
console.log(`paragma: installed pg ${version} (${os}/${arch}). Next: pg setup`);
|
|
56
|
-
});
|