ownpast 0.0.0-stage → 0.6.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.
- package/ownpast.js +61 -0
- package/package.json +21 -4
- package/README.md +0 -3
package/ownpast.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require("node:child_process");
|
|
5
|
+
const { constants } = require("node:os");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const { version } = require("./package.json");
|
|
8
|
+
|
|
9
|
+
const NO_UV = `Ownpast runs on uv, which was not found on PATH. Install it:
|
|
10
|
+
|
|
11
|
+
macOS and Linux: curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
12
|
+
Windows: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
13
|
+
|
|
14
|
+
Other ways: https://docs.astral.sh/uv/getting-started/installation/
|
|
15
|
+
Then open a new terminal and run this command again.`;
|
|
16
|
+
|
|
17
|
+
function uv(args, stdio) {
|
|
18
|
+
// FORCE_COLOR or CLICOLOR_FORCE make uv colour even piped output, which the version and folder reads cannot parse
|
|
19
|
+
const result = spawnSync("uv", args, { stdio, encoding: "utf8", env: { ...process.env, NO_COLOR: "1" } });
|
|
20
|
+
if (result.error && result.error.code === "ENOENT") {
|
|
21
|
+
console.error(NO_UV);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
if (result.error) throw result.error;
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function exitAs(result) {
|
|
29
|
+
process.exit(result.signal ? 128 + constants.signals[result.signal] : result.status);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// compares the numbers, so 0.10.0 is newer than 0.9.0
|
|
33
|
+
function older(installed, wanted) {
|
|
34
|
+
const a = installed.split(".").map((part) => parseInt(part, 10) || 0);
|
|
35
|
+
const b = wanted.split(".").map((part) => parseInt(part, 10) || 0);
|
|
36
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
37
|
+
if ((a[i] || 0) !== (b[i] || 0)) return (a[i] || 0) < (b[i] || 0);
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// stderr is captured too: uv prints "No tools installed" there
|
|
43
|
+
const installed = /^ownpast v(\S+)/m.exec(uv(["tool", "list"], "pipe").stdout);
|
|
44
|
+
if (!installed || older(installed[1], version)) {
|
|
45
|
+
// a lower bound, not a pin, so `uv tool upgrade ownpast` keeps working and an older npx never downgrades;
|
|
46
|
+
// uv's own output goes to stderr, so stdout carries only what ownpast prints
|
|
47
|
+
const install = uv(["tool", "install", `ownpast>=${version}`], ["ignore", 2, 2]);
|
|
48
|
+
if (install.status !== 0) exitAs(install);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const toolDir = uv(["tool", "dir"], ["ignore", "pipe", "inherit"]).stdout.trim();
|
|
52
|
+
const ownpast =
|
|
53
|
+
process.platform === "win32"
|
|
54
|
+
? path.join(toolDir, "ownpast", "Scripts", "ownpast.exe")
|
|
55
|
+
: path.join(toolDir, "ownpast", "bin", "ownpast");
|
|
56
|
+
const run = spawnSync(ownpast, process.argv.slice(2), { stdio: "inherit" });
|
|
57
|
+
if (run.error) {
|
|
58
|
+
console.error(`could not run ${ownpast}: ${run.error.message}`);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
exitAs(run);
|
package/package.json
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ownpast",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Ownpast: not just an agent, an agent with a past. Installs the ownpast CLI with uv and runs it.",
|
|
5
|
+
"license": "BUSL-1.1",
|
|
6
|
+
"author": "robert.kovacs <robert.kovacs.ut@gmail.com>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/chekiboy/ownpast.git"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"ownpast": "ownpast.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"ownpast.js"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "node --test"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/README.md
DELETED