move copy-lancedb to root scripts/util
This commit is contained in:
parent
c0700e1634
commit
112bdcb0ef
|
@ -4,9 +4,12 @@ const path = require("path");
|
|||
const ncp = require("ncp").ncp;
|
||||
const { rimrafSync } = require("rimraf");
|
||||
const { validateFilesPresent } = require("../scripts/util");
|
||||
const { downloadRipgrep } = require("./utils/ripgrep");
|
||||
const { ALL_TARGETS, TARGET_TO_LANCEDB } = require("./utils/targets");
|
||||
const { fork } = require("child_process");
|
||||
const {
|
||||
copyLanceDBFilePath,
|
||||
copyLanceDB,
|
||||
} = require("../scripts/util/copy-lancedb");
|
||||
|
||||
const bin = path.join(__dirname, "bin");
|
||||
const out = path.join(__dirname, "out");
|
||||
|
@ -73,24 +76,6 @@ async function buildWithEsbuild() {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and installs ripgrep binaries for the specified target
|
||||
*
|
||||
* @param {string} target - Target platform-arch (e.g., 'darwin-x64')
|
||||
* @param {string} targetDir - Directory to install ripgrep to
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function downloadRipgrepForTarget(target, targetDir) {
|
||||
console.log(`[info] Downloading ripgrep for ${target}...`);
|
||||
try {
|
||||
await downloadRipgrep(target, targetDir);
|
||||
console.log(`[info] Successfully installed ripgrep for ${target}`);
|
||||
} catch (error) {
|
||||
console.error(`[error] Failed to download ripgrep for ${target}:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
(async () => {
|
||||
if (esbuildOnly) {
|
||||
await buildWithEsbuild();
|
||||
|
@ -121,22 +106,8 @@ async function downloadRipgrepForTarget(target, targetDir) {
|
|||
continue;
|
||||
}
|
||||
console.log(`[info] Downloading for ${target}...`);
|
||||
const child = fork("./utils/copy-lancedb.js", { stdio: "inherit" });
|
||||
child.send({
|
||||
payload: {
|
||||
packageName: TARGET_TO_LANCEDB[target],
|
||||
toCopy: "@lancedb",
|
||||
},
|
||||
});
|
||||
copyLanceDBPromises.push(
|
||||
new Promise((resolve, reject) => {
|
||||
child.on("message", (msg) => {
|
||||
if (msg.error) {
|
||||
reject();
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}),
|
||||
copyLanceDB(TARGET_TO_LANCEDB[target], "@lancedb"),
|
||||
);
|
||||
}
|
||||
await Promise.all(copyLanceDBPromises).catch(() => {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"@typescript-eslint/parser": "^7.8.0",
|
||||
"concurrently": "^9.1.2",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"ncp": "^2.0.0",
|
||||
"prettier": "^3.3.3",
|
||||
"prettier-plugin-tailwindcss": "^0.6.8",
|
||||
"typescript": "^5.6.3"
|
||||
|
|
|
@ -5,20 +5,20 @@
|
|||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const ncp = require("ncp").ncp;
|
||||
const { execCmdSync } = require("../../scripts/util");
|
||||
const { execCmdSync } = require(".");
|
||||
const { fork } = require("child_process");
|
||||
|
||||
async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
||||
console.log(`Copying ${packageName} to ${toCopy}`);
|
||||
// This is a way to install only one package without npm trying to install all the dependencies
|
||||
// Create a temporary directory for installing the package
|
||||
const adjustedName = packageName.replace(/@/g, "").replace("/", "-");
|
||||
const currentDir = process.cwd();
|
||||
const tempDir = path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
currentDir,
|
||||
"tmp",
|
||||
`continue-node_modules-${adjustedName}`,
|
||||
);
|
||||
const currentDir = process.cwd();
|
||||
|
||||
// // Remove the dir we will be copying to
|
||||
// rimrafSync(`node_modules/${toCopy}`);
|
||||
|
@ -80,3 +80,31 @@ process.on("message", (msg) => {
|
|||
process.send({ error: true });
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* invoke a child process to install and copy lancedb into node modules
|
||||
* @param {string} packageName the lancedb platform to install and copy
|
||||
* @param {string} toCopy directory to copy into inside node modules
|
||||
*/
|
||||
async function copyLanceDB(packageName, toCopy) {
|
||||
const child = fork(__filename, { stdio: "inherit", cwd: process.cwd() });
|
||||
child.send({
|
||||
payload: {
|
||||
packageName,
|
||||
toCopy,
|
||||
},
|
||||
});
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
child.on("message", (msg) => {
|
||||
if (msg.error) {
|
||||
reject();
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
copyLanceDB,
|
||||
};
|
Loading…
Reference in New Issue