@dev.fast/diffr 0.1.10 → 0.1.11
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/README.md +9 -23
- package/dist/binary.d.ts +2 -0
- package/dist/binary.js +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +9 -8
- package/src/binary.ts +13 -0
- package/src/index.ts +1 -0
- package/bin/fetch.mjs +0 -93
- package/pins.json +0 -20
package/README.md
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
# @dev.fast/diffr
|
|
2
2
|
|
|
3
|
-
TypeScript types
|
|
4
|
-
The package version matches the diffr release.
|
|
3
|
+
TypeScript types and zod validators for diffr's NDJSON protocol, plus the diffr
|
|
4
|
+
executable. The package version matches the diffr release.
|
|
5
5
|
|
|
6
6
|
```ts
|
|
7
7
|
import { decodeStructuralDiffEvent } from "@dev.fast/diffr";
|
|
8
8
|
const event = decodeStructuralDiffEvent(line);
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
network access. Downloads warn on network failure unless `--required`; invalid
|
|
17
|
-
hashes or archives always fail.
|
|
18
|
-
|
|
19
|
-
`--full` fetches the full edition, which adds the parsers lean builds omit (Apex,
|
|
20
|
-
Fortran, F#, Haskell, Julia, OCaml, QML, Verilog, VHDL). It requires full-edition
|
|
21
|
-
pins, which start with the next release.
|
|
11
|
+
`diffrBinaryPath()` returns the executable from the `@dev.fast/diffr-<platform>-<arch>`
|
|
12
|
+
optional dependency npm installed for this machine, or `undefined` when there is none
|
|
13
|
+
(musl Linux, Windows arm64, or `--omit=optional`). Platforms: macOS arm64 and x64,
|
|
14
|
+
glibc Linux arm64 and x64, Windows x64. It is the full edition, with every
|
|
15
|
+
language.
|
|
22
16
|
|
|
23
17
|
## Wire changes
|
|
24
18
|
|
|
@@ -33,13 +27,5 @@ Keep these files in sync:
|
|
|
33
27
|
|
|
34
28
|
## Release
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
older pins continue to use the combined archives:
|
|
39
|
-
|
|
40
|
-
```sh
|
|
41
|
-
bun install --frozen-lockfile
|
|
42
|
-
npm run pin
|
|
43
|
-
bun run typecheck && bun test
|
|
44
|
-
npm publish --access public
|
|
45
|
-
```
|
|
30
|
+
Bump `diffr-ts/package.json` with `Cargo.toml`. The release workflow publishes the
|
|
31
|
+
platform packages and this package from the tag, using npm trusted publishing.
|
package/dist/binary.d.ts
ADDED
package/dist/binary.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
/** The diffr executable from the installed platform package, if npm installed one for this machine. */
|
|
3
|
+
export function diffrBinaryPath() {
|
|
4
|
+
const name = process.platform === "win32" ? "diffr.exe" : "diffr";
|
|
5
|
+
try {
|
|
6
|
+
// Resolve from this package's own directory, which also holds when a bundler inlines it.
|
|
7
|
+
const self = createRequire(import.meta.url).resolve("@dev.fast/diffr/package.json");
|
|
8
|
+
return createRequire(self).resolve(`@dev.fast/diffr-${process.platform}-${process.arch}/${name}`);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev.fast/diffr",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "diffr's NDJSON wire contract, validators, and
|
|
3
|
+
"version": "0.1.11",
|
|
4
|
+
"description": "diffr's NDJSON wire contract, validators, and the diffr binary for this platform",
|
|
5
5
|
"repository": "https://github.com/devdotfast/diffr",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -14,23 +14,17 @@
|
|
|
14
14
|
"./package.json": "./package.json",
|
|
15
15
|
"./src/*": "./src/*"
|
|
16
16
|
},
|
|
17
|
-
"bin": {
|
|
18
|
-
"diffr-fetch": "bin/fetch.mjs"
|
|
19
|
-
},
|
|
20
17
|
"files": [
|
|
21
18
|
"dist",
|
|
22
19
|
"src",
|
|
23
20
|
"!src/*.test.ts",
|
|
24
21
|
"!src/test-binary.ts",
|
|
25
|
-
"bin",
|
|
26
|
-
"pins.json",
|
|
27
22
|
"README.md"
|
|
28
23
|
],
|
|
29
24
|
"scripts": {
|
|
30
25
|
"build": "tsc -p tsconfig.build.json",
|
|
31
26
|
"typecheck": "tsc --noEmit",
|
|
32
27
|
"test": "bun test",
|
|
33
|
-
"pin": "node scripts/pin.mjs",
|
|
34
28
|
"prepack": "npm run build"
|
|
35
29
|
},
|
|
36
30
|
"peerDependencies": {
|
|
@@ -43,5 +37,12 @@
|
|
|
43
37
|
},
|
|
44
38
|
"engines": {
|
|
45
39
|
"node": ">=20"
|
|
40
|
+
},
|
|
41
|
+
"optionalDependencies": {
|
|
42
|
+
"@dev.fast/diffr-darwin-arm64": "0.1.11",
|
|
43
|
+
"@dev.fast/diffr-darwin-x64": "0.1.11",
|
|
44
|
+
"@dev.fast/diffr-linux-x64": "0.1.11",
|
|
45
|
+
"@dev.fast/diffr-linux-arm64": "0.1.11",
|
|
46
|
+
"@dev.fast/diffr-win32-x64": "0.1.11"
|
|
46
47
|
}
|
|
47
48
|
}
|
package/src/binary.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
/** The diffr executable from the installed platform package, if npm installed one for this machine. */
|
|
4
|
+
export function diffrBinaryPath(): string | undefined {
|
|
5
|
+
const name = process.platform === "win32" ? "diffr.exe" : "diffr";
|
|
6
|
+
try {
|
|
7
|
+
// Resolve from this package's own directory, which also holds when a bundler inlines it.
|
|
8
|
+
const self = createRequire(import.meta.url).resolve("@dev.fast/diffr/package.json");
|
|
9
|
+
return createRequire(self).resolve(`@dev.fast/diffr-${process.platform}-${process.arch}/${name}`);
|
|
10
|
+
} catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/src/index.ts
CHANGED
package/bin/fetch.mjs
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createHash } from "node:crypto";
|
|
3
|
-
import { spawnSync } from "node:child_process";
|
|
4
|
-
import { chmodSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
5
|
-
import { dirname, join, resolve } from "node:path";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
import { parseArgs } from "node:util";
|
|
8
|
-
|
|
9
|
-
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
10
|
-
const targets = { "darwin-arm64": "aarch64-apple-darwin", "darwin-x64": "x86_64-apple-darwin", "linux-x64": "x86_64-unknown-linux-gnu", "linux-arm64": "aarch64-unknown-linux-gnu", "win32-x64": "x86_64-pc-windows-msvc" };
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
await main();
|
|
14
|
-
} catch (error) {
|
|
15
|
-
console.error(`diffr-fetch: ${error.message}`);
|
|
16
|
-
process.exitCode = 1;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function main() {
|
|
20
|
-
const { values } = parseArgs({ options: {
|
|
21
|
-
into: { type: "string" },
|
|
22
|
-
full: { type: "boolean", default: false },
|
|
23
|
-
check: { type: "boolean" },
|
|
24
|
-
required: { type: "boolean" },
|
|
25
|
-
pins: { type: "string", default: join(root, "pins.json") },
|
|
26
|
-
} });
|
|
27
|
-
if (!values.into) throw new Error("--into <dir> is required");
|
|
28
|
-
const into = resolve(values.into);
|
|
29
|
-
const { version } = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
30
|
-
const pins = JSON.parse(readFileSync(values.pins, "utf8"));
|
|
31
|
-
if (pins.version !== version) throw new Error(`pins.json is for ${pins.version}, package is ${version}; run \`npm run pin\``);
|
|
32
|
-
const target = targets[`${process.platform}-${process.arch}`];
|
|
33
|
-
if (!target) throw new Error(`no diffr release for ${process.platform}-${process.arch}`);
|
|
34
|
-
const pin = values.full ? pins.full : pins;
|
|
35
|
-
if (!pin) throw new Error(`pins.json has no full edition for ${version}`);
|
|
36
|
-
const expected = pin.sha256?.[target];
|
|
37
|
-
if (typeof expected !== "string" || !/^[a-f0-9]{64}$/.test(expected)) {
|
|
38
|
-
throw new Error(`pins.json has no valid sha256 for ${target}`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const name = process.platform === "win32" ? "diffr.exe" : "diffr";
|
|
42
|
-
const binary = join(into, name);
|
|
43
|
-
const stampPath = join(into, "diffr.stamp.json");
|
|
44
|
-
let installed = false;
|
|
45
|
-
try {
|
|
46
|
-
const stamp = JSON.parse(readFileSync(stampPath, "utf8"));
|
|
47
|
-
const stat = lstatSync(binary);
|
|
48
|
-
installed = stat.isFile() && (process.platform === "win32" || (stat.mode & 0o111) !== 0) && stamp.version === version && stamp.target === target
|
|
49
|
-
&& Boolean(stamp.full) === values.full;
|
|
50
|
-
} catch { /* Missing or damaged installations are fetched again. */ }
|
|
51
|
-
if (installed) {
|
|
52
|
-
console.log(`diffr ${version} (${target}) already at ${binary}`);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (values.check) throw new Error(`${binary} is missing or not diffr ${version} (${target})`);
|
|
56
|
-
|
|
57
|
-
const artifact = values.full ? "diffr-cli-full" : pins.artifact ?? "diffr";
|
|
58
|
-
if (!["diffr", "diffr-cli", "diffr-cli-full"].includes(artifact)) throw new Error(`unknown pinned artifact: ${artifact}`);
|
|
59
|
-
const asset = `${artifact}-${version}-${target}.tar.gz`;
|
|
60
|
-
const url = `https://github.com/devdotfast/diffr/releases/download/${version}/${asset}`;
|
|
61
|
-
let bytes;
|
|
62
|
-
try {
|
|
63
|
-
const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(120_000) });
|
|
64
|
-
if (!response.ok) throw new Error(`HTTP ${response.status} ${response.statusText}`);
|
|
65
|
-
bytes = Buffer.from(await response.arrayBuffer());
|
|
66
|
-
} catch (error) {
|
|
67
|
-
if (values.required) throw new Error(`could not download ${url}: ${error.message}`);
|
|
68
|
-
console.warn(`diffr-fetch: could not download ${url}: ${error.message}; continuing without a bundled diffr`);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const actual = createHash("sha256").update(bytes).digest("hex");
|
|
72
|
-
if (actual !== expected) throw new Error(`${asset} sha256 ${actual} does not match pinned ${expected}`);
|
|
73
|
-
|
|
74
|
-
mkdirSync(into, { recursive: true });
|
|
75
|
-
const staging = mkdtempSync(join(into, ".diffr-"));
|
|
76
|
-
try {
|
|
77
|
-
writeFileSync(join(staging, "archive.tar.gz"), bytes);
|
|
78
|
-
// Relative paths: GNU tar on Windows reads "C:" in an archive path as a remote host.
|
|
79
|
-
const tar = spawnSync("tar", ["-xzf", "archive.tar.gz", name], { cwd: staging, encoding: "utf8" });
|
|
80
|
-
const extracted = join(staging, name);
|
|
81
|
-
if (tar.status !== 0 || !lstatSync(extracted).isFile()) {
|
|
82
|
-
throw new Error(`${asset} does not contain a regular ${name} file at its root`);
|
|
83
|
-
}
|
|
84
|
-
chmodSync(extracted, 0o755);
|
|
85
|
-
const stamp = join(staging, "stamp.json");
|
|
86
|
-
writeFileSync(stamp, `${JSON.stringify({ version, target, ...(values.full && { full: true }) }, null, 2)}\n`);
|
|
87
|
-
renameSync(extracted, binary);
|
|
88
|
-
renameSync(stamp, stampPath);
|
|
89
|
-
} finally {
|
|
90
|
-
rmSync(staging, { recursive: true, force: true });
|
|
91
|
-
}
|
|
92
|
-
console.log(`diffr ${version} (${target}) installed at ${binary}`);
|
|
93
|
-
}
|
package/pins.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.1.10",
|
|
3
|
-
"artifact": "diffr-cli",
|
|
4
|
-
"sha256": {
|
|
5
|
-
"aarch64-apple-darwin": "2f67b7f4c096445047c618687a35eff40fd3a637683a738a59c40f702d97dd72",
|
|
6
|
-
"x86_64-apple-darwin": "674b719f45944ac387e58f21529e2a52a15c72d9cb28906e5e8ce7b28773c4da",
|
|
7
|
-
"x86_64-unknown-linux-gnu": "190c506b238d95f15a552b3983cd3351a5eb385f2057b5a08c90d87a2b466075",
|
|
8
|
-
"aarch64-unknown-linux-gnu": "91abbca8f38cb3de355cbc8a47086686c7e0f88961d6e2012fbefcdee1979607",
|
|
9
|
-
"x86_64-pc-windows-msvc": "0e129b2cf5c86af44643861da42656fc266f2e1f94ab501f0a2b34dc6efff1b7"
|
|
10
|
-
},
|
|
11
|
-
"full": {
|
|
12
|
-
"sha256": {
|
|
13
|
-
"aarch64-apple-darwin": "6675ba404990be3e7b7f8e26b113b7f083e609e88c7eae366e3367a4e32364d5",
|
|
14
|
-
"x86_64-apple-darwin": "c9188df81078fe6bb3fbae2b44e7c1fff9b37cbe66c7cd9c11091c3d151e4dcf",
|
|
15
|
-
"x86_64-unknown-linux-gnu": "a56aa73980850ecdfdce201253d37d06a38ef30cdb0507d61bc973e944f4174a",
|
|
16
|
-
"aarch64-unknown-linux-gnu": "d6788ac5e17e986ce2f2ebc6069dc27bcb127847f38632a7cfecf434820e3f81",
|
|
17
|
-
"x86_64-pc-windows-msvc": "d10f2fbb55df4a42e3305c531ffd1e615bca494b8161d4817ed946239063b67b"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|