@jdxcode/aube-node 0.0.1-placeholder → 1.29.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/README.md CHANGED
@@ -1,3 +1,109 @@
1
- # @jdxcode/aube-node
1
+ # aube Node-API bindings
2
2
 
3
- Placeholder release reserving this name for [aube](https://github.com/jdx/aube)'s embedding packages. The real packages are published by aube's release automation.
3
+ `@jdxcode/aube-node` embeds aube's installer in JavaScript hosts, including
4
+ Node.js, Bun, Electron, and compiled Bun executables.
5
+
6
+ ```ts
7
+ import { install } from "@jdxcode/aube-node"
8
+
9
+ const result = await install(projectDirectory, {
10
+ add: [
11
+ { name: "react", version: "19.1.0" },
12
+ { name: "typescript", version: "5.9.3", dev: true },
13
+ ],
14
+ signal: abortController.signal,
15
+ onEvent(event) {
16
+ switch (event.kind) {
17
+ case "phase":
18
+ console.log(event.phase)
19
+ break
20
+ case "progress":
21
+ console.log(event.resolved, event.downloaded)
22
+ break
23
+ case "output":
24
+ console.log(event.level, event.code, event.message)
25
+ break
26
+ }
27
+ },
28
+ })
29
+
30
+ console.log(result.durationMs)
31
+ ```
32
+
33
+ The addon creates an empty package manifest when needed, saves added packages
34
+ at exact versions, and installs declared dependencies. Added entries with
35
+ `dev: true` are saved to `devDependencies`. Root and dependency lifecycle
36
+ scripts are always skipped. Registry/auth settings and dependency-section
37
+ omission come from the project's `.npmrc`; `omit=dev` and `omit=optional` are
38
+ honored.
39
+
40
+ Independent projects install concurrently using invocation-scoped state.
41
+ Operations targeting the same workspace serialize on its project lock.
42
+ `onEvent` uses a non-blocking Node-API thread-safe function, and `signal`
43
+ cooperatively cancels at a safe install boundary.
44
+
45
+ Rejected promises are `AubeError` objects with a stable `code` and a
46
+ human-readable `diagnostic`. Published `ERR_AUBE_*` values follow aube's
47
+ [error-code stability policy](https://github.com/jdx/aube/blob/main/docs/error-codes.md).
48
+
49
+ ## Configuration
50
+
51
+ Register embedder setting defaults before the first `install`:
52
+
53
+ ```ts
54
+ import { configure, install } from "@jdxcode/aube-node"
55
+
56
+ configure({
57
+ defaults: {
58
+ minimumReleaseAge: "259200", // seconds; 3-day cooldown for fresh releases
59
+ },
60
+ })
61
+ ```
62
+
63
+ Defaults use canonical setting names and sit at the lowest precedence —
64
+ environment variables, project files, and user configuration all override
65
+ them. Registration is process-global and first-write-wins: calling
66
+ `configure` after an install (or a second time) rejects with
67
+ `ERR_AUBE_EMBED_ALREADY_INITIALIZED`, and unknown setting names reject with
68
+ `ERR_AUBE_EMBED_INVALID_SETTING`. Without a `configure` call the addon
69
+ applies its built-in defaults (`nodeLinker=hoisted`, `minimumReleaseAge=0`).
70
+
71
+ Per-install, `osvTransitiveCheck: true` forces a live transitive OSV check
72
+ even when resolution reused every version from the existing lockfile.
73
+
74
+ ## Compiled Bun executables
75
+
76
+ Add `bunPlugin({ os, arch, libc })` from `@jdxcode/aube-node/bun-plugin` to each
77
+ target's `Bun.build` plugins. The plugin resolves the root import to the
78
+ selected native platform package so each executable embeds one addon.
79
+
80
+ Cross-compilation hosts must install every optional platform package before
81
+ building targets for other operating systems and architectures:
82
+
83
+ ```sh
84
+ bun install --os="*" --cpu="*" @jdxcode/aube-node@$AUBE_NODE_VERSION
85
+ ```
86
+
87
+ ## Compatibility and stability
88
+
89
+ - The addon targets Node-API 8.
90
+ - Node.js 18 and newer are supported.
91
+ - Bun 1.3.11 is exercised by direct and compiled-executable smoke tests.
92
+ - macOS arm64/x64, Windows arm64/x64, Linux glibc arm64/x64, and Linux musl
93
+ arm64/x64 packages are published.
94
+ - Package versions track the aube workspace version.
95
+ - The TypeScript API follows semantic versioning; stable error identifiers are
96
+ not removed or repurposed.
97
+
98
+ ## Development
99
+
100
+ Run the direct Bun and compiled-executable smoke tests from the repository
101
+ root:
102
+
103
+ ```sh
104
+ crates/aube-node/poc/run.sh
105
+ ```
106
+
107
+ CI also installs the generated npm tarballs in Node and Bun consumers and
108
+ type-checks the public declarations. For support, use
109
+ [GitHub Discussions](https://github.com/jdx/aube/discussions).
@@ -0,0 +1,22 @@
1
+ export type AubeNodeTarget = {
2
+ os: "darwin" | "linux" | "win32"
3
+ arch: "arm64" | "x64"
4
+ libc?: "glibc" | "musl"
5
+ }
6
+
7
+ export type AubeNodeBunPlugin = {
8
+ name: string
9
+ setup(build: {
10
+ onResolve(
11
+ options: { filter: RegExp },
12
+ callback: () => { path: string; namespace?: string },
13
+ ): void
14
+ onLoad(
15
+ options: { filter: RegExp; namespace: string },
16
+ callback: () => { contents: string; loader: "js" },
17
+ ): void
18
+ }): void
19
+ }
20
+
21
+ export function platformPackage(target: AubeNodeTarget): string
22
+ export function bunPlugin(target: AubeNodeTarget): AubeNodeBunPlugin
package/bun-plugin.js ADDED
@@ -0,0 +1,31 @@
1
+ function platformPackage(target) {
2
+ const { os, arch } = target
3
+ const supported = (os === "darwin" || os === "win32" || os === "linux") && (arch === "arm64" || arch === "x64")
4
+ if (!supported) throw new Error(`Unsupported aube Node-API build target: ${os}-${arch}`)
5
+ const libc = os === "linux" && target.libc === "musl" ? "-musl" : ""
6
+ return `@jdxcode/aube-node-${os}-${arch}${libc}`
7
+ }
8
+
9
+ function bunPlugin(target) {
10
+ const packageName = platformPackage(target)
11
+ const addon = require.resolve(packageName)
12
+ return {
13
+ name: "aube-node-platform",
14
+ setup(build) {
15
+ build.onResolve({ filter: /^@jdxcode\/aube-node$/ }, () => ({
16
+ path: "aube-node-platform",
17
+ namespace: "aube-node",
18
+ }))
19
+ build.onLoad({ filter: /.*/, namespace: "aube-node" }, () => ({
20
+ contents: [
21
+ `const addon = require(${JSON.stringify(addon)})`,
22
+ "export const install = addon.install",
23
+ "export default addon",
24
+ ].join("\n"),
25
+ loader: "js",
26
+ }))
27
+ },
28
+ }
29
+ }
30
+
31
+ module.exports = { bunPlugin, platformPackage }
package/index.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ export type InstallEvent =
2
+ | { kind: "phase"; phase: "resolving" | "fetching" | "linking" | "complete" }
3
+ | {
4
+ kind: "progress"
5
+ resolved: number
6
+ total: number
7
+ reused: number
8
+ downloaded: number
9
+ downloadedBytes: number
10
+ estimatedBytes?: number
11
+ }
12
+ | { kind: "output"; level: "info" | "warning" | "error"; code?: string; message: string }
13
+
14
+ export interface AubeError extends Error {
15
+ code: string
16
+ diagnostic: string
17
+ }
18
+
19
+ export type ConfigureInput = {
20
+ /**
21
+ * Embedder setting defaults by canonical setting name (e.g.
22
+ * `minimumReleaseAge`). Lowest precedence: environment variables, project
23
+ * files, and user configuration all override them.
24
+ */
25
+ defaults?: Record<string, string>
26
+ }
27
+ export type InstallInput = {
28
+ add?: { name: string; version?: string; dev?: boolean }[]
29
+ force?: boolean
30
+ offline?: boolean
31
+ osvTransitiveCheck?: boolean
32
+ onEvent?: (event: InstallEvent) => void
33
+ signal?: AbortSignal
34
+ }
35
+ export type InstallResult = {
36
+ projectDir: string
37
+ added: string[]
38
+ resolved: number
39
+ reused: number
40
+ downloaded: number
41
+ durationMs: number
42
+ }
43
+ /**
44
+ * Register embedder setting defaults for this process. Call before the first
45
+ * `install`; later (or repeated) calls throw `ERR_AUBE_EMBED_ALREADY_INITIALIZED`,
46
+ * and unknown setting names throw `ERR_AUBE_EMBED_INVALID_SETTING`.
47
+ */
48
+ export function configure(input?: ConfigureInput): void
49
+ export function install(projectDir: string, input?: InstallInput): Promise<InstallResult>
package/index.js CHANGED
@@ -1 +1,32 @@
1
- throw new Error("@jdxcode/aube-node 0.0.1-placeholder is a placeholder published to reserve the package name; install a real release instead: https://github.com/jdx/aube")
1
+ const fs = require("node:fs")
2
+ const childProcess = require("node:child_process")
3
+
4
+ function isMusl() {
5
+ if (fs.existsSync("/etc/alpine-release")) return true
6
+ try {
7
+ if (process.report.getReport().header.glibcVersionRuntime) return false
8
+ } catch (_) {}
9
+ try {
10
+ return childProcess.execFileSync("ldd", ["--version"], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] })
11
+ .toLowerCase().includes("musl")
12
+ } catch (error) {
13
+ return `${error.stdout || ""}\n${error.stderr || ""}`.toLowerCase().includes("musl")
14
+ }
15
+ }
16
+
17
+ function load() {
18
+ const key = `${process.platform}-${process.arch}`
19
+ if (key === "darwin-arm64") return require("@jdxcode/aube-node-darwin-arm64")
20
+ if (key === "darwin-x64") return require("@jdxcode/aube-node-darwin-x64")
21
+ if (key === "win32-arm64") return require("@jdxcode/aube-node-win32-arm64")
22
+ if (key === "win32-x64") return require("@jdxcode/aube-node-win32-x64")
23
+ if (key === "linux-arm64" && isMusl()) return require("@jdxcode/aube-node-linux-arm64-musl")
24
+ if (key === "linux-arm64") return require("@jdxcode/aube-node-linux-arm64")
25
+ if (key === "linux-x64" && isMusl()) return require("@jdxcode/aube-node-linux-x64-musl")
26
+ if (key === "linux-x64") return require("@jdxcode/aube-node-linux-x64")
27
+ throw new Error(`Unsupported aube Node-API platform: ${key}`)
28
+ }
29
+
30
+ const addon = load()
31
+ exports.configure = addon.configure
32
+ exports.install = addon.install
package/package.json CHANGED
@@ -1,8 +1,40 @@
1
1
  {
2
2
  "name": "@jdxcode/aube-node",
3
- "version": "0.0.1-placeholder",
4
- "description": "Placeholder reserving the name for aube's first embedding release. Do not install; see https://github.com/jdx/aube",
3
+ "version": "1.29.0",
4
+ "description": "Node-API bindings for embedding the aube package manager",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/jdx/aube",
7
- "main": "index.js"
7
+ "main": "index.js",
8
+ "types": "index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./index.d.ts",
12
+ "default": "./index.js"
13
+ },
14
+ "./bun-plugin": {
15
+ "types": "./bun-plugin.d.ts",
16
+ "default": "./bun-plugin.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "index.js",
21
+ "index.d.ts",
22
+ "bun-plugin.js",
23
+ "bun-plugin.d.ts",
24
+ "README.md"
25
+ ],
26
+ "preferUnplugged": true,
27
+ "engines": {
28
+ "node": ">=18"
29
+ },
30
+ "optionalDependencies": {
31
+ "@jdxcode/aube-node-darwin-arm64": "1.29.0",
32
+ "@jdxcode/aube-node-darwin-x64": "1.29.0",
33
+ "@jdxcode/aube-node-linux-arm64": "1.29.0",
34
+ "@jdxcode/aube-node-linux-x64": "1.29.0",
35
+ "@jdxcode/aube-node-linux-arm64-musl": "1.29.0",
36
+ "@jdxcode/aube-node-linux-x64-musl": "1.29.0",
37
+ "@jdxcode/aube-node-win32-arm64": "1.29.0",
38
+ "@jdxcode/aube-node-win32-x64": "1.29.0"
39
+ }
8
40
  }