topaz-lang 5.2.1 → 5.4.1

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/README.md +3 -2
  2. package/install.js +22 -9
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -15,7 +15,8 @@ npx -p topaz-lang topaz run main.tpz
15
15
 
16
16
  On install, a `postinstall` step downloads the `topaz` binary for your platform
17
17
  (matching this package's version) and verifies its SHA256. `topaz run`,
18
- `topaz check`, and `topaz emit` are standalone; `topaz build` additionally needs
19
- a Rust toolchain present on your machine.
18
+ `topaz check`, and `topaz emit` are standalone; native `topaz build` additionally
19
+ needs a Rust toolchain present on your machine. Topaz 5.4.1 also includes the
20
+ experimental `topaz build --target python --experimental` witness artifact path.
20
21
 
21
22
  License: Apache-2.0.
package/install.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // postinstall: download the prebuilt `topaz` binary that matches THIS package
2
- // version (so `npm i topaz-lang@5.2.1` pins topaz v5.2.1), verify its SHA256,
2
+ // version (so `npm i topaz-lang@5.4.1` pins topaz v5.4.1), verify its SHA256,
3
3
  // and drop it next to the bin shim. No Rust source, no build.
4
4
  'use strict';
5
5
  const { mkdir, writeFile, chmod, rename } = require('node:fs/promises');
@@ -8,7 +8,10 @@ const path = require('node:path');
8
8
 
9
9
  const VERSION = require('./package.json').version;
10
10
  const TAG = `v${VERSION}`;
11
- const DL_BASE = (process.env.TOPAZ_DL_BASE || 'https://topaz.ooo/dl').replace(/\/$/, '');
11
+ const DL_BASE = (process.env.TOPAZ_DL_BASE || 'https://topaz.ooo/dl').replace(
12
+ /\/$/,
13
+ ''
14
+ );
12
15
  const TIMEOUT_MS = 60_000;
13
16
  const MAX_BYTES = 100 * 1024 * 1024; // a sane ceiling for a single CLI binary
14
17
 
@@ -26,7 +29,7 @@ function linuxAsset(name) {
26
29
  if (!glibc) {
27
30
  throw new Error(
28
31
  'this looks like a musl/Alpine system; the published Linux binaries are ' +
29
- 'glibc-based. Use a glibc distro or build from source (https://topaz.ooo).',
32
+ 'glibc-based. Use a glibc distro or container, or the browser playground at https://topaz.ooo/playground.'
30
33
  );
31
34
  }
32
35
  return name;
@@ -39,7 +42,8 @@ function assetName() {
39
42
  if (p === 'linux' && a === 'arm64') return linuxAsset('topaz-linux-aarch64');
40
43
  if (p === 'darwin' && a === 'arm64') return 'topaz-macos-aarch64';
41
44
  if (p === 'darwin' && a === 'x64') return 'topaz-macos-x86_64';
42
- if (p === 'win32' && (a === 'x64' || a === 'arm64')) return 'topaz-windows-x86_64.exe';
45
+ if (p === 'win32' && (a === 'x64' || a === 'arm64'))
46
+ return 'topaz-windows-x86_64.exe';
43
47
  throw new Error(`unsupported platform ${p}/${a}`);
44
48
  }
45
49
 
@@ -50,7 +54,8 @@ async function get(url) {
50
54
  const res = await fetch(url, { signal: ctrl.signal }); // node >=18, follows redirects
51
55
  if (!res.ok) throw new Error(`fetch ${res.status} for ${url}`);
52
56
  const len = Number(res.headers.get('content-length'));
53
- if (len && len > MAX_BYTES) throw new Error(`refusing ${len} bytes from ${url}`);
57
+ if (len && len > MAX_BYTES)
58
+ throw new Error(`refusing ${len} bytes from ${url}`);
54
59
  return res;
55
60
  } finally {
56
61
  clearTimeout(timer);
@@ -61,15 +66,23 @@ async function main() {
61
66
  const name = assetName();
62
67
  const url = `${DL_BASE}/${TAG}/${name}`;
63
68
  const binDir = path.join(__dirname, 'bin');
64
- const out = path.join(binDir, process.platform === 'win32' ? 'topaz.exe' : 'topaz-bin');
69
+ const out = path.join(
70
+ binDir,
71
+ process.platform === 'win32' ? 'topaz.exe' : 'topaz-bin'
72
+ );
65
73
 
66
74
  const buf = Buffer.from(await (await get(url)).arrayBuffer());
67
- if (buf.length > MAX_BYTES) throw new Error(`downloaded ${buf.length} bytes (over the cap)`);
75
+ if (buf.length > MAX_BYTES)
76
+ throw new Error(`downloaded ${buf.length} bytes (over the cap)`);
68
77
 
69
- const want = (await (await get(`${url}.sha256`)).text()).trim().split(/\s+/)[0].toLowerCase();
78
+ const want = (await (await get(`${url}.sha256`)).text())
79
+ .trim()
80
+ .split(/\s+/)[0]
81
+ .toLowerCase();
70
82
  if (!/^[0-9a-f]{64}$/.test(want)) throw new Error('malformed checksum');
71
83
  const got = createHash('sha256').update(buf).digest('hex');
72
- if (got !== want) throw new Error(`checksum mismatch (expected ${want}, got ${got})`);
84
+ if (got !== want)
85
+ throw new Error(`checksum mismatch (expected ${want}, got ${got})`);
73
86
 
74
87
  await mkdir(binDir, { recursive: true });
75
88
  const tmp = `${out}.tmp`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "topaz-lang",
3
- "version": "5.2.1",
3
+ "version": "5.4.1",
4
4
  "description": "The Topaz language toolchain (topaz run / check / emit / build).",
5
5
  "homepage": "https://topaz.ooo",
6
6
  "license": "Apache-2.0",