* @param {string} target the platform to build for
(target)
| 44 | * @param {string} target the platform to build for |
| 45 | */ |
| 46 | async function bundleForBinary(target) { |
| 47 | const targetDir = `bin/${target}`; |
| 48 | fs.mkdirSync(targetDir, { recursive: true }); |
| 49 | console.log(`[info] Building ${target}...`); |
| 50 | execCmdSync( |
| 51 | `npx pkg --no-bytecode --public-packages "*" --public --compress GZip pkgJson/${target} --out-path ${targetDir}`, |
| 52 | ); |
| 53 | |
| 54 | // copy @lancedb to bin folders |
| 55 | console.log("[info] Copying @lancedb files to bin"); |
| 56 | fs.copyFileSync( |
| 57 | `node_modules/${TARGET_TO_LANCEDB[target]}/index.node`, |
| 58 | `${targetDir}/index.node`, |
| 59 | ); |
| 60 | |
| 61 | const downloadPromises = []; |
| 62 | downloadPromises.push(downloadRipgrep(target, targetDir)); |
| 63 | downloadPromises.push(downloadNodeSqlite(target, targetDir)); |
| 64 | await Promise.all(downloadPromises); |
| 65 | |
| 66 | // Informs the `continue-binary` of where to look for node_sqlite3.node |
| 67 | // https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found |
| 68 | fs.writeFileSync(`${targetDir}/package.json`, ""); |
| 69 | } |
| 70 | |
| 71 | process.on("message", (msg) => { |
| 72 | bundleForBinary(msg.payload.target) |
no test coverage detected