@alwith/runtime 0.1.6 → 0.1.8

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.
Files changed (3) hide show
  1. package/package.json +6 -6
  2. package/stage.d.ts +1 -1
  3. package/stage.js +37 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwith/runtime",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "The closed ALwith Runtime process for your platform: npm installs the matching binary, stageRuntime() copies it into your app's sidecars at build time",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -17,11 +17,11 @@
17
17
  }
18
18
  },
19
19
  "optionalDependencies": {
20
- "@alwith/runtime-darwin-arm64": "0.1.6",
21
- "@alwith/runtime-linux-arm64": "0.1.6",
22
- "@alwith/runtime-linux-x64": "0.1.6",
23
- "@alwith/runtime-win32-arm64": "0.1.6",
24
- "@alwith/runtime-win32-x64": "0.1.6"
20
+ "@alwith/runtime-darwin-arm64": "0.1.8",
21
+ "@alwith/runtime-linux-arm64": "0.1.8",
22
+ "@alwith/runtime-linux-x64": "0.1.8",
23
+ "@alwith/runtime-win32-arm64": "0.1.8",
24
+ "@alwith/runtime-win32-x64": "0.1.8"
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public",
package/stage.d.ts CHANGED
@@ -4,4 +4,4 @@
4
4
  * `binaries/alwith-runtime-<triple>`), and its LICENSE, THIRD_PARTY_NOTICES.md and licenses/ under
5
5
  * `licenses`/alwith-runtime. Returns `destination`.
6
6
  */
7
- export declare function stageRuntime(target: string, destination: string, licenses: string): string;
7
+ export declare function stageRuntime(target: string, destination: string, licenses: string): string
package/stage.js CHANGED
@@ -1,31 +1,41 @@
1
- import { createRequire } from "node:module";
2
- import { createHash } from "node:crypto";
3
- import { chmodSync, cpSync, mkdirSync, readFileSync } from "node:fs";
4
- import { dirname, join } from "node:path";
5
- const require = createRequire(import.meta.url);
1
+ import { createRequire } from "node:module"
2
+ import { createHash } from "node:crypto"
3
+ import { chmodSync, cpSync, mkdirSync, readFileSync } from "node:fs"
4
+ import { dirname, join } from "node:path"
5
+ const require = createRequire(import.meta.url)
6
6
  const targets = {
7
7
  "aarch64-apple-darwin": "darwin-arm64",
8
- "aarch64-unknown-linux-gnu": "linux-arm64", "x86_64-unknown-linux-gnu": "linux-x64",
9
- "aarch64-pc-windows-msvc": "win32-arm64", "x86_64-pc-windows-msvc": "win32-x64"
10
- };
8
+ "aarch64-unknown-linux-gnu": "linux-arm64",
9
+ "x86_64-unknown-linux-gnu": "linux-x64",
10
+ "aarch64-pc-windows-msvc": "win32-arm64",
11
+ "x86_64-pc-windows-msvc": "win32-x64"
12
+ }
11
13
  export function stageRuntime(target, destination, licenses) {
12
- const platform = targets[target];
13
- if (!platform) throw new Error(`Unsupported Runtime target: ${target}`);
14
- const name = `@alwith/runtime-${platform}`;
15
- let root;
16
- try { root = dirname(require.resolve(`${name}/package.json`)); }
17
- catch { throw new Error(`Missing ${name}. Install optional dependencies for the build target (Bun: bun install --os='*' --cpu='*').`); }
18
- const pin = JSON.parse(readFileSync(join(root, "artifact.json"), "utf8"));
19
- const version = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8")).version;
20
- const expectedFile = platform.startsWith("win32") ? "alwith-runtime.exe" : "alwith-runtime";
21
- if (pin.version !== version || pin.target !== target || pin.binary !== expectedFile) throw new Error("Runtime artifact identity mismatch");
22
- const binary = join(root, expectedFile);
23
- if (createHash("sha256").update(readFileSync(binary)).digest("hex") !== pin.sha256) throw new Error("Runtime binary checksum mismatch");
24
- mkdirSync(dirname(destination), { recursive: true });
25
- cpSync(binary, destination);
26
- if (!platform.startsWith("win32")) chmodSync(destination, 0o755);
27
- const legal = join(licenses, "alwith-runtime");
28
- mkdirSync(legal, { recursive: true });
29
- for (const file of ["LICENSE", "THIRD_PARTY_NOTICES.md", "licenses"]) cpSync(join(root, file), join(legal, file), { recursive: true });
30
- return destination;
14
+ const platform = targets[target]
15
+ if (!platform) throw new Error(`Unsupported Runtime target: ${target}`)
16
+ const name = `@alwith/runtime-${platform}`
17
+ let root
18
+ try {
19
+ root = dirname(require.resolve(`${name}/package.json`))
20
+ } catch {
21
+ throw new Error(
22
+ `Missing ${name}. Install optional dependencies for the build target (Bun: bun install --os='*' --cpu='*').`
23
+ )
24
+ }
25
+ const pin = JSON.parse(readFileSync(join(root, "artifact.json"), "utf8"))
26
+ const version = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8")).version
27
+ const expectedFile = platform.startsWith("win32") ? "alwith-runtime.exe" : "alwith-runtime"
28
+ if (pin.version !== version || pin.target !== target || pin.binary !== expectedFile)
29
+ throw new Error("Runtime artifact identity mismatch")
30
+ const binary = join(root, expectedFile)
31
+ if (createHash("sha256").update(readFileSync(binary)).digest("hex") !== pin.sha256)
32
+ throw new Error("Runtime binary checksum mismatch")
33
+ mkdirSync(dirname(destination), { recursive: true })
34
+ cpSync(binary, destination)
35
+ if (!platform.startsWith("win32")) chmodSync(destination, 0o755)
36
+ const legal = join(licenses, "alwith-runtime")
37
+ mkdirSync(legal, { recursive: true })
38
+ for (const file of ["LICENSE", "THIRD_PARTY_NOTICES.md", "licenses"])
39
+ cpSync(join(root, file), join(legal, file), { recursive: true })
40
+ return destination
31
41
  }