@brrock/oj 0.0.0-stage → 0.2.16
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 +54 -2
- package/bin/oj.js +27 -0
- package/index.js +62 -0
- package/package.json +34 -4
package/README.md
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @brrock/oj
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Prebuilt Linux binaries of [oj](https://github.com/lovablelabs/oj) (lovablelabs' Rust frontend tooling), packaged for npm so it can run where you can't `cargo install`, like Vercel builds.
|
|
4
|
+
|
|
5
|
+
Upstream oj only ships to crates.io. This repo builds it from source for each oj release and publishes:
|
|
6
|
+
|
|
7
|
+
| package | contents |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `@brrock/oj` | the `oj` command (a small Node launcher) |
|
|
10
|
+
| `@brrock/oj-linux-x64-gnu` | oj for Linux x64, glibc ≥ 2.34 |
|
|
11
|
+
| `@brrock/oj-linux-arm64-gnu` | oj for Linux arm64, glibc ≥ 2.34 |
|
|
12
|
+
|
|
13
|
+
npm installs only the platform package that matches the machine. Binaries are built inside `amazonlinux:2023`, which is Vercel's build image.
|
|
14
|
+
|
|
15
|
+
## Use on Vercel
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm i -D @brrock/oj
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "oj build"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Set the Vercel project's output directory to `dist`. Versions match upstream oj versions.
|
|
30
|
+
|
|
31
|
+
Only Linux is supported. On macOS/Windows install oj with `cargo install oj --locked`; you can point the launcher at any binary with `OJ_BINARY_PATH=/path/to/oj`.
|
|
32
|
+
|
|
33
|
+
`@brrock/oj` depends on `rolldown@1.2.1` and sets `OJ_VENDORED_ROLLDOWN` to it, the same rolldown the upstream nix build vendors for oj's TanStack Start bundles. Set `OJ_VENDORED_ROLLDOWN=` (empty) to use the app's own rolldown instead.
|
|
34
|
+
|
|
35
|
+
## How releases work
|
|
36
|
+
|
|
37
|
+
`.github/workflows/release.yml` runs every 6 hours. When the latest `lovablelabs/oj` release isn't on npm yet, it:
|
|
38
|
+
|
|
39
|
+
1. builds `oj` for x64 and arm64 in `amazonlinux:2023` (fat-LTO release build, so expect 1–2 hours),
|
|
40
|
+
2. publishes the platform packages, then `@brrock/oj`, through npm trusted publishing (OIDC). Provenance is attached automatically and no npm token is stored.
|
|
41
|
+
|
|
42
|
+
To build a specific version by hand: `make release VERSION=0.2.16`.
|
|
43
|
+
|
|
44
|
+
## One-time setup
|
|
45
|
+
|
|
46
|
+
You need npm ≥ 11.10 (for `npm trust`) and 2FA enabled on your npm account.
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
make login # npm login
|
|
50
|
+
make setup # publishes empty 0.0.0 placeholders, then trusts release.yml for each package
|
|
51
|
+
make release # build + publish the latest oj
|
|
52
|
+
make watch # follow the run
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Trusted publishing can only be configured on packages that already exist, which is why `setup` publishes placeholders first. Optionally run `make lockdown` afterwards to block token-based publishes.
|
package/bin/oj.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require("child_process");
|
|
5
|
+
const { binaryPath, vendoredRolldownDir } = require("..");
|
|
6
|
+
|
|
7
|
+
let bin;
|
|
8
|
+
try {
|
|
9
|
+
bin = binaryPath();
|
|
10
|
+
} catch (e) {
|
|
11
|
+
console.error(e.message);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const env = { ...process.env };
|
|
16
|
+
if (env.OJ_VENDORED_ROLLDOWN === undefined) {
|
|
17
|
+
const dir = vendoredRolldownDir();
|
|
18
|
+
if (dir) env.OJ_VENDORED_ROLLDOWN = dir;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit", env });
|
|
22
|
+
if (result.error) {
|
|
23
|
+
console.error(`@brrock/oj: failed to run ${bin}: ${result.error.message}`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
if (result.signal) process.kill(process.pid, result.signal);
|
|
27
|
+
process.exit(result.status ?? 1);
|
package/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const PLATFORMS = {
|
|
7
|
+
"linux-x64": "@brrock/oj-linux-x64-gnu",
|
|
8
|
+
"linux-arm64": "@brrock/oj-linux-arm64-gnu",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** Absolute path to the oj binary for this machine. Throws if unsupported. */
|
|
12
|
+
function binaryPath() {
|
|
13
|
+
if (process.env.OJ_BINARY_PATH) return process.env.OJ_BINARY_PATH;
|
|
14
|
+
|
|
15
|
+
const key = `${process.platform}-${process.arch}`;
|
|
16
|
+
const pkg = PLATFORMS[key];
|
|
17
|
+
if (!pkg) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`@brrock/oj: no prebuilt oj for ${key}. Supported: ${Object.keys(PLATFORMS).join(", ")}.\n` +
|
|
20
|
+
"On other platforms install oj with `cargo install oj --locked` and set OJ_BINARY_PATH.",
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let bin;
|
|
25
|
+
try {
|
|
26
|
+
bin = require.resolve(`${pkg}/bin/oj`);
|
|
27
|
+
} catch {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`@brrock/oj: the platform package "${pkg}" is not installed.\n` +
|
|
30
|
+
"It is an optionalDependency; make sure optional dependencies are not omitted " +
|
|
31
|
+
"(--omit=optional / --no-optional) and that your lockfile was not created on a different platform only.",
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// npm normally keeps the exec bit, but some installers/caches drop it.
|
|
36
|
+
try {
|
|
37
|
+
fs.accessSync(bin, fs.constants.X_OK);
|
|
38
|
+
} catch {
|
|
39
|
+
try {
|
|
40
|
+
fs.chmodSync(bin, 0o755);
|
|
41
|
+
} catch {}
|
|
42
|
+
}
|
|
43
|
+
return bin;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Directory holding node_modules/rolldown, for OJ_VENDORED_ROLLDOWN: oj runs
|
|
48
|
+
* its own TanStack Start bundles on the rolldown it was tested against
|
|
49
|
+
* (the upstream nix build vendors it the same way). Returns undefined if
|
|
50
|
+
* rolldown can't be found, in which case oj falls back to the app's copy.
|
|
51
|
+
*/
|
|
52
|
+
function vendoredRolldownDir() {
|
|
53
|
+
try {
|
|
54
|
+
const pkgJson = fs.realpathSync(require.resolve("rolldown/package.json"));
|
|
55
|
+
// .../<dir>/node_modules/rolldown/package.json -> <dir>
|
|
56
|
+
return path.dirname(path.dirname(path.dirname(pkgJson)));
|
|
57
|
+
} catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = { binaryPath, vendoredRolldownDir };
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brrock/oj",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.16",
|
|
4
|
+
"description": "Prebuilt Linux binaries of oj (lovablelabs/oj), e.g. for running oj on Vercel",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/brrock/oj-builds.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/lovablelabs/oj",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"oj",
|
|
13
|
+
"vite",
|
|
14
|
+
"bundler",
|
|
15
|
+
"vercel"
|
|
16
|
+
],
|
|
17
|
+
"bin": {
|
|
18
|
+
"oj": "bin/oj.js"
|
|
19
|
+
},
|
|
20
|
+
"main": "index.js",
|
|
21
|
+
"files": [
|
|
22
|
+
"bin",
|
|
23
|
+
"index.js",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"rolldown": "1.2.1"
|
|
31
|
+
},
|
|
32
|
+
"optionalDependencies": {
|
|
33
|
+
"@brrock/oj-linux-x64-gnu": "0.2.16",
|
|
34
|
+
"@brrock/oj-linux-arm64-gnu": "0.2.16"
|
|
35
|
+
}
|
|
36
|
+
}
|