@@ -8,13 +8,15 @@ const {
8
8
execCmdSync,
9
9
autodetectPlatformAndArch,
10
10
} = require ( "../scripts/util" ) ;
11
+ const { downloadRipgrep } = require ( "./utils/ripgrep" ) ;
12
+ const { ALL_TARGETS , TARGET_TO_LANCEDB } = require ( "./utils/targets" ) ;
11
13
12
14
const bin = path . join ( __dirname , "bin" ) ;
13
15
const out = path . join ( __dirname , "out" ) ;
14
16
const build = path . join ( __dirname , "build" ) ;
15
17
16
18
function cleanSlate ( ) {
17
- // Clean slate
19
+ // Clean slate
18
20
rimrafSync ( bin ) ;
19
21
rimrafSync ( out ) ;
20
22
rimrafSync ( build ) ;
@@ -25,13 +27,7 @@ function cleanSlate() {
25
27
}
26
28
27
29
const esbuildOutputFile = "out/index.js" ;
28
- let targets = [
29
- "darwin-x64" ,
30
- "darwin-arm64" ,
31
- "linux-x64" ,
32
- "linux-arm64" ,
33
- "win32-x64" ,
34
- ] ;
30
+ let targets = [ ...ALL_TARGETS ] ;
35
31
36
32
const [ currentPlatform , currentArch ] = autodetectPlatformAndArch ( ) ;
37
33
@@ -50,15 +46,6 @@ for (let i = 2; i < process.argv.length; i++) {
50
46
}
51
47
}
52
48
53
- const targetToLanceDb = {
54
- "darwin-arm64" : "@lancedb/vectordb-darwin-arm64" ,
55
- "darwin-x64" : "@lancedb/vectordb-darwin-x64" ,
56
- "linux-arm64" : "@lancedb/vectordb-linux-arm64-gnu" ,
57
- "linux-x64" : "@lancedb/vectordb-linux-x64-gnu" ,
58
- "win32-x64" : "@lancedb/vectordb-win32-x64-msvc" ,
59
- "win32-arm64" : "@lancedb/vectordb-win32-arm64-msvc" ,
60
- } ;
61
-
62
49
// Bundles the extension into one file
63
50
async function buildWithEsbuild ( ) {
64
51
console . log ( "[info] Building with esbuild..." ) ;
@@ -89,7 +76,6 @@ async function buildWithEsbuild() {
89
76
inject : [ "./importMetaUrl.js" ] ,
90
77
define : { "import.meta.url" : "importMetaUrl" } ,
91
78
} ) ;
92
-
93
79
}
94
80
95
81
async function installNodeModuleInTempDirAndCopyToCurrent ( packageName , toCopy ) {
@@ -153,13 +139,31 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
153
139
}
154
140
}
155
141
142
+ /**
143
+ * Downloads and installs ripgrep binaries for the specified target
144
+ *
145
+ * @param {string } target - Target platform-arch (e.g., 'darwin-x64')
146
+ * @param {string } targetDir - Directory to install ripgrep to
147
+ * @returns {Promise<void> }
148
+ */
149
+ async function downloadRipgrepForTarget ( target , targetDir ) {
150
+ console . log ( `[info] Downloading ripgrep for ${ target } ...` ) ;
151
+ try {
152
+ await downloadRipgrep ( target , targetDir ) ;
153
+ console . log ( `[info] Successfully installed ripgrep for ${ target } ` ) ;
154
+ } catch ( error ) {
155
+ console . error ( `[error] Failed to download ripgrep for ${ target } :` , error ) ;
156
+ throw error ;
157
+ }
158
+ }
159
+
156
160
( async ( ) => {
157
161
if ( esbuildOnly ) {
158
162
await buildWithEsbuild ( ) ;
159
163
return ;
160
164
}
161
165
162
- cleanSlate ( )
166
+ cleanSlate ( ) ;
163
167
164
168
// Informs of where to look for node_sqlite3.node https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found
165
169
// This is only needed for our `pkg` command at build time
@@ -179,10 +183,10 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
179
183
180
184
console . log ( "[info] Downloading prebuilt lancedb..." ) ;
181
185
for ( const target of targets ) {
182
- if ( targetToLanceDb [ target ] ) {
186
+ if ( TARGET_TO_LANCEDB [ target ] ) {
183
187
console . log ( `[info] Downloading for ${ target } ...` ) ;
184
188
await installNodeModuleInTempDirAndCopyToCurrent (
185
- targetToLanceDb [ target ] ,
189
+ TARGET_TO_LANCEDB [ target ] ,
186
190
"@lancedb" ,
187
191
) ;
188
192
}
@@ -290,10 +294,13 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
290
294
// copy @lancedb to bin folders
291
295
console . log ( "[info] Copying @lancedb files to bin" ) ;
292
296
fs . copyFileSync (
293
- `node_modules/${ targetToLanceDb [ target ] } /index.node` ,
297
+ `node_modules/${ TARGET_TO_LANCEDB [ target ] } /index.node` ,
294
298
`${ targetDir } /index.node` ,
295
299
) ;
296
300
301
+ // Download and install ripgrep for the target
302
+ await downloadRipgrepForTarget ( target , targetDir ) ;
303
+
297
304
// Informs the `continue-binary` of where to look for node_sqlite3.node
298
305
// https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found
299
306
fs . writeFileSync ( `${ targetDir } /package.json` , "" ) ;
@@ -310,6 +317,7 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
310
317
`${ targetDir } /continue-binary${ exe } ` ,
311
318
`${ targetDir } /index.node` , // @lancedb
312
319
`${ targetDir } /build/Release/node_sqlite3.node` ,
320
+ `${ targetDir } /rg${ exe } ` , // ripgrep binary
313
321
) ;
314
322
}
315
323
0 commit comments