Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/opencode/script/publish.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bun
import { $ } from "bun"
import fs from "fs"
import pkg from "../package.json"
import { Script } from "@opencode-ai/script"
import { fileURLToPath } from "url"
Expand Down Expand Up @@ -56,10 +57,16 @@ async function copyAssets(targetDir: string) {
await $`cp -r ./bin ${targetDir}/bin`
await $`cp -r ../../.opencode/skills ${targetDir}/skills`
await $`cp ./script/postinstall.mjs ${targetDir}/postinstall.mjs`
// Bundle dbt-tools: copy its bin wrapper + built dist
// Bundle dbt-tools: copy its bin wrapper + only the files it actually needs.
// The full dist/ contains ~220 MB of .node native binaries from altimate-core
// that bun copies as transitive build artifacts but dbt-tools never loads.
await $`mkdir -p ${targetDir}/dbt-tools/bin`
await $`cp ../dbt-tools/bin/altimate-dbt ${targetDir}/dbt-tools/bin/altimate-dbt`
await $`cp -r ../dbt-tools/dist ${targetDir}/dbt-tools/dist`
await $`mkdir -p ${targetDir}/dbt-tools/dist`
await $`cp ../dbt-tools/dist/index.js ${targetDir}/dbt-tools/dist/`
if (fs.existsSync("../dbt-tools/dist/altimate_python_packages")) {
await $`cp -r ../dbt-tools/dist/altimate_python_packages ${targetDir}/dbt-tools/dist/`
}
await Bun.file(`${targetDir}/LICENSE`).write(await Bun.file("../../LICENSE").text())
await Bun.file(`${targetDir}/CHANGELOG.md`).write(await Bun.file("../../CHANGELOG.md").text())
}
Expand Down
9 changes: 9 additions & 0 deletions packages/opencode/test/branding/build-integrity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,15 @@ describe("Bundle Completeness", () => {
expect(publishScript).toContain("bun run build")
})

test("publish.ts copies only needed dbt-tools dist files (not .node binaries)", () => {
const publishScript = readFileSync(join(repoRoot, "packages/opencode/script/publish.ts"), "utf-8")
// Should copy index.js and altimate_python_packages selectively, not `cp -r dist`
expect(publishScript).toContain("dist/index.js")
expect(publishScript).toContain("altimate_python_packages")
// Should NOT do a blanket `cp -r ../dbt-tools/dist` (would include ~220MB of .node files)
expect(publishScript).not.toMatch(/cp -r \.\.\/dbt-tools\/dist [^/]/)
})

test("postinstall.mjs sets up dbt-tools symlink", () => {
const postinstall = readFileSync(join(repoRoot, "packages/opencode/script/postinstall.mjs"), "utf-8")
expect(postinstall).toContain("setupDbtTools")
Expand Down
Loading