Drop the custom EAC-3 Chromium build and macOS packaging. Windows NSIS installers and Flatpaks for x64 and ARM64 now build in one Linux container image. Packaged installers previously lost the bundled Next.js dependencies: electron-builder drops the pnpm store and NSIS cannot carry symlinks. The bundle now replaces pnpm links with nested real copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
105 lines
3.5 KiB
JavaScript
105 lines
3.5 KiB
JavaScript
import { test } from "node:test"
|
|
import assert from "node:assert/strict"
|
|
import {
|
|
mkdtemp,
|
|
mkdir,
|
|
writeFile,
|
|
readFile,
|
|
rm,
|
|
access,
|
|
symlink,
|
|
lstat,
|
|
} from "node:fs/promises"
|
|
import os from "node:os"
|
|
import path from "node:path"
|
|
import { pruneNativeImages } from "./prune-native-images.mjs"
|
|
import { materializeLinks } from "./materialize-links.mjs"
|
|
|
|
async function fixture(run) {
|
|
const directory = await mkdtemp(path.join(os.tmpdir(), "otunes-build-"))
|
|
try {
|
|
await run(directory)
|
|
} finally {
|
|
await rm(directory, { recursive: true, force: true })
|
|
}
|
|
}
|
|
|
|
test("the UI bundle drops unused Sharp binaries but keeps JavaScript and package metadata", async () => {
|
|
await fixture(async (directory) => {
|
|
const lib = path.join(
|
|
directory,
|
|
"node_modules",
|
|
"@img",
|
|
"sharp-linux-x64",
|
|
"lib"
|
|
)
|
|
await mkdir(lib, { recursive: true })
|
|
for (const file of [
|
|
"sharp.node",
|
|
"libvips-cpp.so.8.17.3",
|
|
"index.js",
|
|
"debug.node.js",
|
|
"package.json",
|
|
])
|
|
await writeFile(path.join(lib, file), file)
|
|
await pruneNativeImages(directory)
|
|
for (const file of ["sharp.node", "libvips-cpp.so.8.17.3"])
|
|
await assert.rejects(access(path.join(lib, file)))
|
|
assert.equal(await readFile(path.join(lib, "index.js"), "utf8"), "index.js")
|
|
await access(path.join(lib, "debug.node.js"))
|
|
await access(path.join(lib, "package.json"))
|
|
})
|
|
})
|
|
|
|
test("new native dependencies fail the UI build instead of shipping a build-host binary", async () => {
|
|
await fixture(async (directory) => {
|
|
await writeFile(path.join(directory, "new-dependency.node"), "fixture")
|
|
await assert.rejects(
|
|
pruneNativeImages(directory),
|
|
/Unexpected native dependency/
|
|
)
|
|
await access(path.join(directory, "new-dependency.node"))
|
|
})
|
|
})
|
|
|
|
test("pnpm links become real copies that keep each package's dependency versions", async () => {
|
|
await fixture(async (directory) => {
|
|
const store = path.join(directory, "node_modules", ".pnpm")
|
|
async function storePackage(id, name, version, dependencies = {}) {
|
|
const root = path.join(store, id, "node_modules")
|
|
await mkdir(path.join(root, name), { recursive: true })
|
|
await writeFile(path.join(root, name, "package.json"), version)
|
|
for (const [dependency, target] of Object.entries(dependencies))
|
|
await symlink(
|
|
path.relative(
|
|
root,
|
|
path.join(store, target, "node_modules", dependency)
|
|
),
|
|
path.join(root, dependency)
|
|
)
|
|
}
|
|
await storePackage("react@1", "react", "1")
|
|
await storePackage("react@2", "react", "2")
|
|
await storePackage("next@1", "next", "next", { react: "react@1" })
|
|
await storePackage("convex@1", "convex", "convex", { react: "react@2" })
|
|
const app = path.join(directory, "apps", "web", "node_modules")
|
|
await mkdir(app, { recursive: true })
|
|
await symlink(
|
|
"../../../node_modules/.pnpm/next@1/node_modules/next",
|
|
path.join(app, "next")
|
|
)
|
|
await symlink(
|
|
"../../../node_modules/.pnpm/convex@1/node_modules/convex",
|
|
path.join(app, "convex")
|
|
)
|
|
|
|
await materializeLinks(directory)
|
|
|
|
const read = (file) => readFile(path.join(app, file), "utf8")
|
|
assert.equal(await read("next/node_modules/react/package.json"), "1")
|
|
assert.equal(await read("convex/node_modules/react/package.json"), "2")
|
|
assert.equal((await lstat(path.join(app, "next"))).isSymbolicLink(), false)
|
|
await assert.rejects(access(store))
|
|
})
|
|
})
|