amarit 0.0.0-stage → 0.7.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/LICENSE +21 -0
- package/README.md +14 -2
- package/assets.json +21 -0
- package/package.json +29 -4
- package/run.js +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sudipta Deb
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# amarit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
amarit: keep it alive, keep it current. Self-update from a release manifest, in-place or zero-downtime restart, health-gated rollback, and keep-alive under launchd, systemd or nothing.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install -g amarit # or run it once: npx amarit ...
|
|
7
|
+
amarit run <command>
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
The first run downloads the amarit release this package names from GitHub, checks it against the
|
|
11
|
+
sha256 pinned in the package, and installs it to `~/.local/bin/amarit`, where the
|
|
12
|
+
[install script](https://github.com/sudiptadeb/amarit/blob/main/install.sh) puts it. From then on
|
|
13
|
+
the binary there (or in `/usr/local/bin`) is the one that runs, and it keeps itself current.
|
|
14
|
+
|
|
15
|
+
Everything else: https://github.com/sudiptadeb/amarit
|
package/assets.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.7.0",
|
|
3
|
+
"assets": {
|
|
4
|
+
"darwin/amd64": {
|
|
5
|
+
"url": "https://github.com/sudiptadeb/amarit/releases/download/v0.7.0/amarit-darwin-amd64",
|
|
6
|
+
"sha256": "add2f9b03e377cf65f1f754a696f4d511e3ee988829fcfca12a6e745fe9ecf88"
|
|
7
|
+
},
|
|
8
|
+
"darwin/arm64": {
|
|
9
|
+
"url": "https://github.com/sudiptadeb/amarit/releases/download/v0.7.0/amarit-darwin-arm64",
|
|
10
|
+
"sha256": "987716a870c99b468be988734f3b315812e66d59d639c864b5daf298ea579074"
|
|
11
|
+
},
|
|
12
|
+
"linux/amd64": {
|
|
13
|
+
"url": "https://github.com/sudiptadeb/amarit/releases/download/v0.7.0/amarit-linux-amd64",
|
|
14
|
+
"sha256": "8b3edc8b05347323e8cac9fc5dbca7756841cc817755781fed3a521302a2ae65"
|
|
15
|
+
},
|
|
16
|
+
"linux/arm64": {
|
|
17
|
+
"url": "https://github.com/sudiptadeb/amarit/releases/download/v0.7.0/amarit-linux-arm64",
|
|
18
|
+
"sha256": "cc3be66cb2264971afcbeab0ddb39eed8825ba6751129b521b272592d04233c7"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amarit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "amarit: keep it alive, keep it current. Self-update from a release manifest, in-place or zero-downtime restart, health-gated rollback, and keep-alive under launchd, systemd or nothing.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"amarit": "run.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"run.js",
|
|
10
|
+
"assets.json"
|
|
11
|
+
],
|
|
12
|
+
"os": [
|
|
13
|
+
"darwin",
|
|
14
|
+
"linux"
|
|
15
|
+
],
|
|
16
|
+
"cpu": [
|
|
17
|
+
"x64",
|
|
18
|
+
"arm64"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": "Sudipta Deb",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/sudiptadeb/amarit.git",
|
|
28
|
+
"directory": "npm"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/sudiptadeb/amarit"
|
|
31
|
+
}
|
package/run.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runs amarit. The first run downloads the release this package names into ~/.local/bin,
|
|
3
|
+
// where install.sh puts it, checks it against the sha256 pinned in assets.json, and from then
|
|
4
|
+
// on amarit found there or in /usr/local/bin is the one that runs, keeping itself current.
|
|
5
|
+
'use strict';
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const crypto = require('crypto');
|
|
10
|
+
const { execFileSync, spawnSync } = require('child_process');
|
|
11
|
+
const { version, assets } = require('./assets.json');
|
|
12
|
+
|
|
13
|
+
const tool = 'amarit';
|
|
14
|
+
const home = path.join(os.homedir(), '.local', 'bin');
|
|
15
|
+
|
|
16
|
+
function platform() {
|
|
17
|
+
let arch = { x64: 'amd64', arm64: 'arm64' }[process.arch] || process.arch;
|
|
18
|
+
// Under Rosetta node reports x64; prefer the native binary.
|
|
19
|
+
if (process.platform === 'darwin' && arch === 'amd64') {
|
|
20
|
+
try {
|
|
21
|
+
if (execFileSync('sysctl', ['-n', 'sysctl.proc_translated'], { encoding: 'utf8' }).trim() === '1') arch = 'arm64';
|
|
22
|
+
} catch {}
|
|
23
|
+
}
|
|
24
|
+
return `${process.platform}/${arch}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function installed() {
|
|
28
|
+
const self = fs.realpathSync(__filename);
|
|
29
|
+
for (const dir of [home, '/usr/local/bin']) {
|
|
30
|
+
const file = path.join(dir, tool);
|
|
31
|
+
try {
|
|
32
|
+
// npm's own shim can sit in /usr/local/bin too; that is this script, not the binary.
|
|
33
|
+
if (fs.realpathSync(file) !== self) return file;
|
|
34
|
+
} catch {}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function install() {
|
|
39
|
+
const want = assets[platform()];
|
|
40
|
+
if (!want) throw new Error(`no ${tool} release for ${platform()}`);
|
|
41
|
+
console.error(`${tool}: downloading ${version} for ${platform()}`);
|
|
42
|
+
const res = await fetch(want.url);
|
|
43
|
+
if (!res.ok) throw new Error(`download failed: ${res.status} ${want.url}`);
|
|
44
|
+
const body = Buffer.from(await res.arrayBuffer());
|
|
45
|
+
const got = crypto.createHash('sha256').update(body).digest('hex');
|
|
46
|
+
if (got !== want.sha256) throw new Error(`checksum mismatch for ${want.url}`);
|
|
47
|
+
fs.mkdirSync(home, { recursive: true });
|
|
48
|
+
const file = path.join(home, tool);
|
|
49
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
50
|
+
fs.writeFileSync(tmp, body, { mode: 0o755 });
|
|
51
|
+
// Replace, don't rewrite: macOS can kill a binary changed in place.
|
|
52
|
+
fs.renameSync(tmp, file);
|
|
53
|
+
console.error(`${tool}: installed ${file}`);
|
|
54
|
+
if (!(process.env.PATH || '').split(path.delimiter).includes(home)) {
|
|
55
|
+
console.error(`${tool}: ${home} is not on your PATH; add: export PATH="${home}:$PATH"`);
|
|
56
|
+
}
|
|
57
|
+
return file;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function main() {
|
|
61
|
+
const bin = installed() || (await install());
|
|
62
|
+
const run = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
63
|
+
if (run.error) throw run.error;
|
|
64
|
+
if (run.signal) process.kill(process.pid, run.signal);
|
|
65
|
+
process.exit(run.status);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
main().catch((err) => {
|
|
69
|
+
console.error(`${tool}: ${err.message}`);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
});
|