plumb-lang 0.0.0-stage → 0.1.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 +28 -0
- package/package.json +20 -4
- package/plumb.cjs +88 -0
- package/release.json +30 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Szymon Prajs and Plumb contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plumb-lang",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Plumb, a strict referee for empirical and theoretical physics",
|
|
5
|
+
"homepage": "https://plumb-lang.sh",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/plumblang/plumb.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "BSD-3-Clause",
|
|
11
|
+
"bin": {
|
|
12
|
+
"plumb": "plumb.cjs",
|
|
13
|
+
"plumb-lang": "plumb.cjs"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"plumb.cjs",
|
|
20
|
+
"release.json"
|
|
21
|
+
]
|
|
22
|
+
}
|
package/plumb.cjs
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execFileSync, spawnSync } = require('node:child_process');
|
|
3
|
+
const { createHash } = require('node:crypto');
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const os = require('node:os');
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
|
|
8
|
+
const release = require('./release.json');
|
|
9
|
+
const isSha256 = value => /^[a-f0-9]{64}$/.test(value);
|
|
10
|
+
|
|
11
|
+
function verifyBinary(binary, expected) {
|
|
12
|
+
if (!fs.lstatSync(binary).isFile() || createHash('sha256').update(fs.readFileSync(binary)).digest('hex') !== expected) {
|
|
13
|
+
throw new Error(`SHA-256 verification failed for ${binary}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function installBinary() {
|
|
18
|
+
const asset = release.assets[`${process.platform}-${process.arch}`];
|
|
19
|
+
if (!asset || !isSha256(asset.sha256) || !isSha256(asset.binarySha256)) {
|
|
20
|
+
throw new Error(`No verified release binary for ${process.platform}-${process.arch}`);
|
|
21
|
+
}
|
|
22
|
+
const windows = process.platform === 'win32';
|
|
23
|
+
const binaryName = windows ? 'plumb.exe' : 'plumb';
|
|
24
|
+
const cache = path.join(windows ? process.env.LOCALAPPDATA || os.homedir()
|
|
25
|
+
: process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache'), 'plumb-lang');
|
|
26
|
+
const destination = path.join(cache, asset.sha256);
|
|
27
|
+
const binary = path.join(destination, binaryName);
|
|
28
|
+
if (fs.existsSync(binary)) {
|
|
29
|
+
verifyBinary(binary, asset.binarySha256);
|
|
30
|
+
return binary;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fs.mkdirSync(cache, { recursive: true });
|
|
34
|
+
const scratch = fs.mkdtempSync(path.join(cache, 'download-'));
|
|
35
|
+
try {
|
|
36
|
+
const response = await fetch(`${release.url}/${asset.archive}`, {
|
|
37
|
+
signal: AbortSignal.timeout(120_000),
|
|
38
|
+
});
|
|
39
|
+
if (!response.ok) throw new Error(`Download of ${asset.archive} failed (HTTP ${response.status})`);
|
|
40
|
+
const archive = Buffer.from(await response.arrayBuffer());
|
|
41
|
+
if (createHash('sha256').update(archive).digest('hex') !== asset.sha256) {
|
|
42
|
+
throw new Error(`SHA-256 checksum mismatch for ${asset.archive}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const downloaded = path.join(scratch, asset.archive);
|
|
46
|
+
const extracted = path.join(scratch, 'binary');
|
|
47
|
+
fs.writeFileSync(downloaded, archive);
|
|
48
|
+
fs.mkdirSync(extracted);
|
|
49
|
+
const member = windows ? binaryName : `${asset.archive.slice(0, -'.tar.xz'.length)}/${binaryName}`;
|
|
50
|
+
const tarArgs = ['-xf', downloaded, '-C', extracted];
|
|
51
|
+
let tar = 'tar';
|
|
52
|
+
if (windows) {
|
|
53
|
+
tar = 'tar.exe';
|
|
54
|
+
if (process.env.SystemRoot) {
|
|
55
|
+
const systemTar = path.join(process.env.SystemRoot, 'System32', 'tar.exe');
|
|
56
|
+
if (fs.existsSync(systemTar)) tar = systemTar;
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
tarArgs.push('--strip-components=1');
|
|
60
|
+
}
|
|
61
|
+
execFileSync(tar, [...tarArgs, member], { stdio: 'inherit' });
|
|
62
|
+
const executable = path.join(extracted, binaryName);
|
|
63
|
+
verifyBinary(executable, asset.binarySha256);
|
|
64
|
+
if (!windows) fs.chmodSync(executable, 0o755);
|
|
65
|
+
try {
|
|
66
|
+
fs.renameSync(extracted, destination);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (!['EEXIST', 'ENOTEMPTY', 'EPERM'].includes(error.code) || !fs.existsSync(binary)) throw error;
|
|
69
|
+
verifyBinary(binary, asset.binarySha256);
|
|
70
|
+
}
|
|
71
|
+
return binary;
|
|
72
|
+
} finally {
|
|
73
|
+
fs.rmSync(scratch, { recursive: true, force: true });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function main() {
|
|
78
|
+
const binary = await installBinary();
|
|
79
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: 'inherit' });
|
|
80
|
+
if (result.error) throw result.error;
|
|
81
|
+
if (result.signal) process.kill(process.pid, result.signal);
|
|
82
|
+
process.exitCode = result.status ?? 1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
main().catch(error => {
|
|
86
|
+
console.error(`plumb: ${error.message}`);
|
|
87
|
+
process.exitCode = 1;
|
|
88
|
+
});
|
package/release.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"url": "https://github.com/plumblang/plumb/releases/download/v0.1.0",
|
|
3
|
+
"assets": {
|
|
4
|
+
"linux-x64": {
|
|
5
|
+
"archive": "plumb-x86_64-unknown-linux-musl.tar.xz",
|
|
6
|
+
"sha256": "436607cfc9fab3407c5525f84d38d44bfaf3698cab137e998ec15ccefc89ff13",
|
|
7
|
+
"binarySha256": "2cbd2df1e45d2a2e757a908fbf542d5210461d7930398d508ff977c61b9959f3"
|
|
8
|
+
},
|
|
9
|
+
"linux-arm64": {
|
|
10
|
+
"archive": "plumb-aarch64-unknown-linux-musl.tar.xz",
|
|
11
|
+
"sha256": "28112c591cc09e670147e40561ef725b16d3611a9bb2cf2260b422d8a8a08e4e",
|
|
12
|
+
"binarySha256": "bbef9d13e3dc6625c062fad478efe33bfc4319f56cb0e671d830c66470d51fe6"
|
|
13
|
+
},
|
|
14
|
+
"darwin-arm64": {
|
|
15
|
+
"archive": "plumb-aarch64-apple-darwin.tar.xz",
|
|
16
|
+
"sha256": "b8a4bd5be9cc2d2cce63565347f64b30c2c5dc84c5c38eb7d64204dba254eff7",
|
|
17
|
+
"binarySha256": "06c3e111baeb3b896651138bd76351cb3f14a4210822d4abf346723cc593ed0f"
|
|
18
|
+
},
|
|
19
|
+
"win32-x64": {
|
|
20
|
+
"archive": "plumb-x86_64-pc-windows-msvc.zip",
|
|
21
|
+
"sha256": "3cefb399dcb678f05c16a35460ac9165bd087297fc0e3809570da30d3addec11",
|
|
22
|
+
"binarySha256": "6b889b98fae1b095ed8f81655807d4c12d6f41b76b56d2339df36d502cd2173d"
|
|
23
|
+
},
|
|
24
|
+
"win32-arm64": {
|
|
25
|
+
"archive": "plumb-aarch64-pc-windows-msvc.zip",
|
|
26
|
+
"sha256": "c1df258854815f0eb5f0b8253829277b197d3b551ab6b4c4e9bfa14a7f7d9391",
|
|
27
|
+
"binarySha256": "ae362557493f9bbced84ed20beb60b2ff9c25ca1ebfda31436624e6faa202961"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
package/README.md
DELETED