Skip to content

Commit f33c36f

Browse files
author
flowcore-platform
committed
fix(package): ✨ Add postinstall script for DuckDB installation and copy script to dist
1 parent d4e9f1b commit f33c36f

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"prepublishOnly": "bun run build",
2121
"inspect": "bunx @modelcontextprotocol/inspector bun src/index.ts",
2222
"lint": "biome lint",
23-
"format": "biome format"
23+
"format": "biome format",
24+
"postinstall": "node scripts/install-duckdb.js"
2425
},
2526
"devDependencies": {
2627
"@biomejs/biome": "^1.9.4",

scripts/copy-files.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ const readme = Bun.file("README.md")
2020
await Bun.write(join("dist", "README.md"), readme)
2121
console.log("✅ Copied README.md to dist folder")
2222

23+
// Copy install-duckdb.js to dist folder
24+
const installDuckdb = Bun.file("scripts/install-duckdb.js")
25+
await Bun.write(join("dist", "scripts", "install-duckdb.js"), installDuckdb)
26+
console.log("✅ Copied install-duckdb.js to dist/scripts folder")
27+
2328
console.log("🎉 All files copied successfully!")

scripts/install-duckdb.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const os = require("node:os")
2+
const { execSync } = require("node:child_process")
3+
4+
const arch = os.arch()
5+
const platform = os.platform()
6+
7+
if (platform === "darwin" && arch === "arm64") {
8+
try {
9+
execSync("npm install duckdb --target_arch=arm64", { stdio: "inherit" })
10+
} catch (error) {
11+
console.error("Failed to install duckdb with arm64, falling back to x64 via Rosetta")
12+
execSync("arch -x86_64 npm install duckdb", { stdio: "inherit" })
13+
}
14+
} else {
15+
execSync("npm install duckdb", { stdio: "inherit" })
16+
}

0 commit comments

Comments
 (0)