Skip to content

Commit

Permalink
🚒 Preview (#1355)
Browse files Browse the repository at this point in the history
* πŸ“ rename googlepalmapi.md to googlegeminiapi.md

* πŸ“ update mistral models

* Rename to geminiapi & change filename this time

* ✨ global request options (#1153)

* ✨ global request options

* πŸ› fix jira context provider by injecting fetch

* ✨ request options for embeddings providers

* ✨ add Cohere as Reranker (#1159)

* ♻️ use custom requestOptions with CohereEmbeddingsProvider

* Update preIndexedDocs.ts (#1154)

Add WordPress and WooCommerce as preIndexedDocs.

* 🩹 remove example "outputDir" from default config

* Fix slash command params loading (#1084)

Existing slash commands expect an object named
"params" so mapping to "options" here caused
params to be undefined within the run scope. I
renamed from 'm' to 's' just to avoid potential
confusion with the model property mapping above.

* πŸ› don't index if no open workspace folders

* πŸ’„ improve onboarding language

* 🚸 improve onboarding

* πŸ› stop loading when error

* πŸ’„ replace text in input box

* Respect Retry-After header when available from 429 responses (#1182)

* 🩹 remove dead code for exponential backoff

This has been replaced by the withExponentialBackoff helper

* 🩹 respect Retry-After header when available

* 🚸 update inline tips language

* ✨ input box history

* πŸ“Œ update package-locks

* πŸ”Š log errors in prepackage

* πŸ› err to string

* πŸ“Œ pin llama-tokenizer-js

* πŸ“Œ update lockfile

* 🚚 change /docs to docs.

* πŸ“¦ package win-ca dependencies in binary

* πŸ”₯ remove unpopular models from UI

* 🍱 new logo in jetbrains

* 🎨 use node-fetch everywhere

* 🚸 immediately select newly added models

* 🚸 spell out Alt instead of using symbol

* πŸ”₯ remove config shortcut

* πŸ› fix changing model bug

* 🩹 de-duplicate before adding models

* πŸ”§ add embeddingsProvider specific request options

* 🎨 refactor to always use node-fetch from LLM

* πŸ”₯ remove duplicate tokens generated

* πŸ”Š add timestamp to JetBrains logs

* 🎨 maxStopWords for Groq

* πŸ› fix groq provider calling /completions

* πŸ› correctly adhere to LanceDB table name spec

* πŸ› fix sqlite NOT NULL constraint failed error with custom model

* Fix issue where Accept/Reject All only accepts/rejects a single diff hunk. (#1197)

* Fix issues parsing Ollama /api/show endpoint payloads. (#1199)

* ✨ model role for inlineEdit

* 🩹 various small updates

* πŸ› fix openai image support

* πŸ”– update gradle version

* 🍱 update jetbrains icon

* πŸ› fix autocomplete in notebook cells

* πŸ”₯ remove unused media

* πŸ”₯ remove unused files

* Fix schema to allow 'AUTODETECT' sentinel for model when provider is 'groq'. (#1203)

* πŸ› small improvements

* Fix issue with @codebase provider when n becomes odd due to a divide by 2 during the full text search portion of the query. (#1204)

* πŸ› add skipLines

* ✨ URLContextProvider

* πŸ₯… improved error handling for codebase indexing

* 🏷️ use official Git extension types

* βž• declare vscode.git extension dependency

* ⚑️ use reranker for docs context provider

* 🚸 Use templating in default customCommand

* 🎨 use U+23CE

* 🚸 disable autocomplete in commit message box

* 🩹 add gems to default ignored paths

* ⚑️ format markdown blocks as comments in .ipynb completions

* πŸ› don't strip port in URL

* πŸ› fix "gemini" provider spacing issues

* πŸ“¦ update posthog version

* CON-1067: Failed state seems to be toggling as intended

* 🏷️ update types.ts

* πŸ› fix copy/paste/cut behavior in VS Code notebooks

* ✨ llama3 prompt template

* Rework for proper initialization on start up

* CON-1067 Clean-up

* CON-1067 more clean-up

* Add indexingNotLoaded state

* CON-1067 communicate progress to frontend

* πŸ› fix undefined prefix, suffix and language for `/edit` (#1216)

* πŸ› add .bind to fix templating in systemMessage

* CON-1067 clean up

* πŸ› small improvements to autocomplete

* Update DocsContextProvider.ts (#1217)

I fixed a bug where you were sending the query variable (which holds the base URL of the doc) to the rerank method, and it made no sense to rerank the chunks based on a URL. So I changed it to extras.fullInput because it should rerank based on the user input, which should provide better results.

* πŸ“ select-provider.md update

* πŸ› fix merge errors

* Nate/autocomplete-metrics (#1230)

* ⚑️ use context.selectedCompletionInfo, deduplicate logs

* ⚑️ don't reject if user keeps typing same as completion

* ⚑️ vscode autocomplete edge cases

* 🚧 WIP on vscode autocomplete

* ⚑️ better bracket handlng

* ⚑️ improved multi-line detection

* Active file default context (#1231)

* 🚸 include currently active file by default

* 🚸 warn if non-autocomplete model being used

* ✨ try hole filling template for gpt

* πŸ’„ ui for no context

* ⚑️ leave out bottom of excessively large files

* 🚧 experimenting with perplexity style streaming

* πŸ› fix #1237

* πŸ’š fix type error

* ⚑️ improve LSP usage in autocomplete

* πŸ› fix content parsing regression in /edit

* add PySide6 docs to preindexed docs (#1236)

* CON-232 bring custom docs to top, alphabetize doc results, make scrol… (#1239)

* CON-232 bring custom docs to top, alphabetize doc results, make scrollable

* CON-232 cleanup

---------

Co-authored-by: Justin Milner <[email protected]>

* CON-1067 condense some things

* 🚚 [Auxiliary -> Continue] Sidebar

* πŸ”Š log completion options in ~/.continue/sessions

* CON-1067 wrong ret val fix

* CON-1067: fixes from testing

* ⚑️ filter out completions that are only punctuation/space

* ⚑️ inject intellisense docs, no multi-line on comments

* ⚑️ crawl type definitions for autocomplete

* ⚑️ truncate function text

* ⚑️ cache LSP calls

* ⚑️ find recently edited ranges with perfect prefix match

* πŸ› fix gif paths

* ⚑️ bring back double new line stop words

* πŸ“Œ add yarn lock files

* πŸ› allow language keywords to be generated

* πŸ’„ toggle on help button

* 🎨 defaultContext option

* πŸ› fix lancedb bug by upgrading

* πŸ› fix groq stop tokens

* πŸ› preventDefault to avoid double paste

* 🚸 don't repeatedly override cmd+J

* πŸ§‘β€πŸ’» fix npm run test in core

* πŸ“ change description

* πŸ› silence Ollama invalid server state warning

* ⚑️ more accurate getTerminalContents

* ⚑️ make getTerminalContents more accurate

* πŸ§‘β€πŸ’» use yarn instead of npm

* πŸ‘· fix yarn add --no-save in prepackge

* πŸ› correctly read entire notebook file contents

* βž• import handlebars

* πŸ”₯ remove unnecessary migrations

* ⚑️ improve /comment prompt

* Add debug terminal context menu (#1261)

* Add --no-dependencies to vsce package (#1255)

This is not needed because we bundle first with esbuild, and
vsce pack has issues with modern package managers.

see: microsoft/vscode-vsce#421 (comment)

* ui: change line decoration color to use vscode theme (#1253)

* ui: change line decoration color to use vscode theme

to give user a more consistent experience by letting the decoration color to user the color defined in the theme.

* fix: incorrect color item

should be line background not text background
because the decoration is for the whole line

* 🎨 refactor indexing state into a single object

* CON-223 Correct diff streaming abort (#1263)

Co-authored-by: Justin Milner <[email protected]>

* πŸ“¦ switch to pnpm (#1265)

* 🎨 use pnpm instead of yarn

* βž• make dependencies explicit for pnpm

* πŸ› add powershell to extension mapping, and default to ext

* Add stream support for Bedrock Anthropic

* 🎨 make llamatokenizer commonjs compatible

* βž• add esbuild optional deps

* 🚚 rename vendor/node_modules -> modules

* πŸ”– update core version

* πŸ› fixes for transformers.js compatibility

* πŸ”– update core version

* 🎨 set modelPath in constructor

* 🎨 fix transformers.js import

* 🎨 eslint enforce import extensions

* 🎨 require -> import

* 🚸 notify user if not diff in /commit

* πŸ’„ Improve colors of the IntelliJ tool window icon (#1273)

Without this fix, the continue icon sticks out from the other toolwindow icons,
resulting in an inconsistent appearance of the whole IDE and creates a feeling
that the continue plugin "doesn't fit, something must be broken".

According to
https://plugins.jetbrains.com/docs/intellij/icons.html#new-ui-icon-colors
specific colors are needed to work nicely with dark and light modes. Bonus is
that the active tool window icon color then changes automatically to white.

Co-authored-by: Lukas Baron <[email protected]>

* ✨ send Bearer token to Ollama if apiKey set

* πŸ› fix slash command bug

* πŸ§‘β€πŸ’» add onnxruntime (--save-dev) for types

* πŸ› don't apply to file when running code block in terminal

* πŸ› avoid double paste

* ✨ gpt-4o

* 🎨 pass uniqueId to constructor

* 🚸 focus without scrolling into vie

* 🎨 refactoring for continue-proxy LLM (#1277)

* πŸ› continue server client fixes

* 🎨 refactor OpenAI _getHeaders

* 🎨 pass ideSettings to llmFromDescription

* ⚑️ improve add docstring command

* πŸ’š ci updates

* πŸ› fix repeated paste bug

* πŸ› fix build script

* 🩹 various small improvements

* πŸ“Œ pin esbuild 0.17.19

* πŸ§‘β€πŸ’» pnpm i gui in prepackage

* πŸ› show all diff changes in vscode

* 🩹 getMetaKeyName

* πŸ› fix reading of unopened ipynb files

* ⚑️ gpt-4o system prompt

* πŸ’„ make font size configurable in config.json ui.fontSize

* 🩹 properly dispose of diff handler

* πŸ› fix indexing status display

* ⚑️ context pruning

* 🎨 update free trial models

* fix: remove some backup files generated by pkg if present (#1287)

* adjust toCopy (#1305)

Co-authored-by: Justin Milner <[email protected]>

* Nate/prompt-file (#1308)

* ✨ .prompt files

* πŸ§‘β€πŸ’» back to npm  : (

* 🎨 nicer dropdown icon

* 🎨 full switch back to npm

* πŸ§‘β€πŸ’» uninstall script for fresh start

* 🎨 updated package-locks

* πŸ”₯ remove hello from continuerc.json

* πŸ”₯ remove example files

* 🎨 update test prompt

* 🎨 update prompt

* 🎨 update test prompt

* πŸ‘· create out/node_modules in prepackage.js

* Log prompt-tokens to devdb and show in 'My Usage' view (#1309)

* Also log the number of prompt tokens to the dev-db

* Show prompt tokens in 'My Usage' view

* πŸ”₯ remove console logs

* add lm studio tab-autocomplete walkthrough (#1298)

* πŸ“ update autocomplete LM Studio docs

* πŸ’š fix prepackage.js

* ⬆️ upgrade lancedb version

* 🚸 make it easier to continue past trial

* 🚸 improve model setup process

* πŸ“Œ update package-lock.jsons

* πŸ› fix prompt file loading bug

* docs: add setup guide for OpenRouter (#1284)

* Update preIndexedDocs.ts (#1292)

Add Bootstrap and Alpine.js as pre indexed docs.

* add toString (#1324)

* add toString

* Fix indentation

---------

Co-authored-by: Justin Milner <[email protected]>

* don't overwrite all models in onboarding

* πŸ”§ override headers with custom headers

* ✨ allow overwriting slash command description

* feature flag (#1327)

* βž• feature flags dependency

* 🎨 make getHeaders awaitable

* πŸ”’οΈ token count for abuse monitoring

* πŸ‘· remove win32-arm64 target

* Update build.js (#1330)

Fix error: EBUSY: resource busy or locked, rmdir '...\continue\binary\tmp\continue-node_modules-lancedb'

* πŸ“Œ pin onnxruntime version to match transformers.js

* 🎨 transformers cleanup, extensionVersion header

* πŸ”₯ remove lingering pnpm

* 🎨 update default models

* 🎨 update defaults

* πŸ‘· fix version in build post-check

* 🎨 test.js in dev

* πŸ§‘β€πŸ’» cleaning

* Add Gemini 1.5 Flash as a model (#1337)

* 🎨 log dev data for tokens generated

* Expose custom context provider registration through a vscode extension api. (#1288)

* Fix typo "Experimantal" (#1353)

* 🎨 Refactor core (#1281)

* 🎨 refactor out react context

* 🎨 refactor local storage

* 🎨 refactor IdeMessenger

* πŸ”₯ removing unused files

* 🚚 move scripts

* βœ… setup VSCode integration testing

* 🎨 fix test-related stuff

* 🚧 testing

* 🎨 tweak terminal cmd+L

* πŸ§‘β€πŸ’» install biome in core

* 🎨 run biome check on core

* 🎨 run biome check in vscode

* 🎨 run biome check in binary

* πŸ§‘β€πŸ’» global biome config

* 🎨 run biome check on core

* 🎨 run biome check in vscode

* 🎨 fix a few biome warnings

* 🚧 WIP on protocols

* 🚧 progress, organizing, about to remove webviewCore protocol

* 🚧 now running

* 🚧 move indexing code to core

* 🚧 WIP on JetBrains indexing implementation

* 🎨 finish listDir

* 🚧 gui fixes

* 🏷️ update IMessenger.on return type

* πŸ› fix jetbrains types + IDE detection

* πŸ§‘β€πŸ’» set up debugging for binary with TcpMessenger

* πŸ‘· fix prepackage.js

* πŸ§‘β€πŸ’» turn off debug mode for intellij

* πŸ› merge fixes

* πŸ› fixes after refactor

* πŸ› merge fixes

* πŸ’„ increase font size in JB

* πŸ”€ merge changes

* 🩹 small fixes

* πŸ› fix jetbrains build

* 🩹 more jetbrains fixes

* 🎨 jetbrains improvements

* πŸ› fix lancedb prob in jetbrains build

* πŸ‘· update jetbrains build process

* ✨ intellij problems context provider

* πŸ‘· add script utils file

* πŸ’š fix jetbrains build regression

* 🎨 dynamic import transformers.js

* 🩹 small jetbrains updates

* ✨ folder context provider in jetbrains

* 🎨 many more jetbrains improvements

* πŸ”€ merge fixes

* ⚑️ small improvements

* 🎨 tell users transformers.js not supported

* 🎨 trial updates

* πŸ“ update jetbrains readmej

* ⚑️ only use smaller context for local autocomplete models

* ⚑️ improve bracket filter

* ✨ global .continue/.prompts folder

* πŸ’„ improved model setup process

* πŸ₯… display VSCode req errs

* ⚑️ improved autocomplete stopping

* 🎨 count cmd+I

---------

Co-authored-by: Peter Zaback <[email protected]>
Co-authored-by: Maxime Brunet <[email protected]>
Co-authored-by: Jose Vega <[email protected]>
Co-authored-by: Nejc Habjan <[email protected]>
Co-authored-by: Chad Yates <[email protected]>
Co-authored-by: Justin Milner <[email protected]>
Co-authored-by: ε°ι’šθ™« <[email protected]>
Co-authored-by: 5eqn <[email protected]>
Co-authored-by: Pixel <[email protected]>
Co-authored-by: Justin Milner <[email protected]>
Co-authored-by: Devin Gould <[email protected]>
Co-authored-by: Dipta Mahardhika <[email protected]>
Co-authored-by: Ruben Kostandyan <[email protected]>
Co-authored-by: tnglemongrass <[email protected]>
Co-authored-by: Lukas Baron <[email protected]>
Co-authored-by: Fernando <[email protected]>
Co-authored-by: Tijs Zwinkels <[email protected]>
Co-authored-by: DJ Johnson <[email protected]>
Co-authored-by: sam <[email protected]>
Co-authored-by: Pratik Parmar <[email protected]>
Co-authored-by: Sam El-Husseini <[email protected]>
  • Loading branch information
22 people authored May 25, 2024
1 parent 311fc0a commit 08dc5db
Show file tree
Hide file tree
Showing 274 changed files with 11,294 additions and 36,335 deletions.
15 changes: 9 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
"name": "Core Binary",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/binary/out/index.js",
"preLaunchTask": "binary:esbuild",
// "preLaunchTask": "binary:esbuild",
"outFiles": ["${workspaceFolder}/binary/out/**/*.js"],
"sourceMaps": true,
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"cwd": "${workspaceFolder}/binary",
"env": {
"CONTINUE_DEVELOPMENT": "true"
}
},
{
"type": "node",
Expand Down Expand Up @@ -69,18 +73,17 @@
// Pass a directory to run tests in
"${workspaceFolder}/extensions/vscode/manual-testing-sandbox",
"--extensionDevelopmentPath=${workspaceFolder}/extensions/vscode",
"--extensionTestsPath=${workspaceFolder}/extensions/vscode/out/test-runner/mochaRunner"
"--extensionTestsPath=${workspaceFolder}/extensions/vscode/out/test/runner/mochaRunner"
],
"outFiles": [
// Allows setting breakpoints in test suites across the /src folder
"${workspaceFolder}/extensions/vscode/out/test-suites/**/*.js",
"${workspaceFolder}/extensions/vscode/out/test/test-suites/**/*.js",
// Allows setting breakpoints in mocha test runner file
"${workspaceFolder}/extensions/vscode/out/test-runner/**/*.js"
"${workspaceFolder}/extensions/vscode/out/test/runner/**/*.js"
],
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "vscode-extension:tests:build",
"env": {
"CONTINUE_SERVER_URL": "http://localhost:65432",
// Avoid timing out when stopping on breakpoints during debugging in VSCode
"MOCHA_TIMEOUT": "0"
}
Expand Down
1 change: 1 addition & 0 deletions binary/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
bin
data
out
tmp
4 changes: 4 additions & 0 deletions binary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ The build process is otherwise defined entirely in `build.js`.
- tree-sitter-wasms/

(\*) = need to download for each platform manually

## Debugging

To debug the binary with IntelliJ, set `useTcp` to `true` in `CoreMessenger.kt`, and then in VS Code run the "Core Binary" debug script. Instead of starting a subprocess for the binary and communicating over stdin/stdout, the IntelliJ extension will connect over TCP to the server started from the VS Code window. You can place breakpoints anywhere in the `core` or `binary` folders.
150 changes: 84 additions & 66 deletions binary/build.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const esbuild = require("esbuild");
const { execSync } = require("child_process");
const fs = require("fs");
const path = require("path");
const ncp = require("ncp").ncp;
const { rimrafSync } = require("rimraf");
const { validateFilesPresent, execCmdSync } = require("../scripts/util");

function execCmdSync(cmd) {
try {
execSync(cmd);
} catch (err) {
console.error(`Error executing command '${cmd}': `, err.output.toString());
process.exit(1);
}
}
// Clean slate
const bin = path.join(__dirname, "bin");
const out = path.join(__dirname, "out");
rimrafSync(bin);
rimrafSync(out);
rimrafSync(path.join(__dirname, "tmp"));
fs.mkdirSync(bin);
fs.mkdirSync(out);

const esbuildOutputFile = "out/index.js";
const targets = [
let targets = [
"darwin-x64",
"darwin-arm64",
"linux-x64",
Expand Down Expand Up @@ -44,38 +44,43 @@ const targetToLanceDb = {
"linux-arm64": "@lancedb/vectordb-linux-arm64-gnu",
"linux-x64": "@lancedb/vectordb-linux-x64-gnu",
"win32-x64": "@lancedb/vectordb-win32-x64-msvc",
"win32-arm64": "@lancedb/vectordb-win32-x64-msvc", // they don't have a win32-arm64 build
};

async function installNodeModuleInTempDirAndCopyToCurrent(package, toCopy) {
console.log(`Copying ${package} to ${toCopy}`);
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 = toCopy.replace(/^@/, "").replace("/", "-");
const adjustedName = packageName.replace(/^@/, "").replace("/", "-");
const tempDir = path.join(
__dirname,
"tmp",
`continue-node_modules-${adjustedName}`,
);
const currentDir = process.cwd();

// Remove the dir we will be copying to
rimrafSync(`node_modules/${toCopy}`);
// // Remove the dir we will be copying to
// rimrafSync(`node_modules/${toCopy}`);

// Ensure the temporary directory exists
// // Ensure the temporary directory exists
fs.mkdirSync(tempDir, { recursive: true });

try {
// Move to the temporary directory
process.chdir(tempDir);

// Initialize a new package.json and install the package
execCmdSync(`npm init -y && npm i -f ${package} --no-save`);
execCmdSync(`npm init -y && npm i -f ${packageName} --no-save`);

console.log(
`Contents of: ${package}`,
`Contents of: ${packageName}`,
fs.readdirSync(path.join(tempDir, "node_modules", toCopy)),
);

// Without this it seems the file isn't completely written to disk
// Ideally we validate file integrity in the validation at the end
await new Promise((resolve) => setTimeout(resolve, 2000));

// Copy the installed package back to the current directory
await new Promise((resolve, reject) => {
ncp(
Expand All @@ -84,7 +89,10 @@ async function installNodeModuleInTempDirAndCopyToCurrent(package, toCopy) {
{ dereference: true },
(error) => {
if (error) {
console.error(`[error] Error copying ${package} package`, error);
console.error(
`[error] Error copying ${packageName} package`,
error,
);
reject(error);
} else {
resolve();
Expand All @@ -102,78 +110,66 @@ async function installNodeModuleInTempDirAndCopyToCurrent(package, toCopy) {
}

(async () => {
// console.log("[info] Building with ncc...");
// execCmdSync(`npx ncc build src/index.ts -o out`);

// Copy node_modules for pre-built binaries
const DYNAMIC_IMPORTS = [
// "esbuild",
// "@esbuild",
// // "@lancedb",
// "posthog-node",
// "@octokit",
];
fs.mkdirSync("out/node_modules", { recursive: true });
fs.mkdirSync("bin/node_modules", { recursive: true });

await Promise.all(
DYNAMIC_IMPORTS.map(
(mod) =>
new Promise((resolve, reject) => {
ncp(
`node_modules/${mod}`,
`out/node_modules/${mod}`,
function (error) {
if (error) {
console.error(`[error] Error copying ${mod}`, error);
reject(error);
} else {
resolve();
}
},
);
ncp(
`node_modules/${mod}`,
`bin/node_modules/${mod}`,
function (error) {
if (error) {
console.error(`[error] Error copying ${mod}`, error);
reject(error);
} else {
resolve();
}
},
);
}),
),
);
console.log(`[info] Copied ${DYNAMIC_IMPORTS.join(", ")}`);

console.log("[info] Downloading prebuilt lancedb...");
for (const target of targets) {
if (targetToLanceDb[target]) {
console.log(`[info] Downloading ${target}...`);
console.log(`[info] Downloading for ${target}...`);
await installNodeModuleInTempDirAndCopyToCurrent(
targetToLanceDb[target],
"@lancedb",
);
}
}

// tree-sitter-wasm
const treeSitterWasmsDir = path.join(out, "tree-sitter-wasms");
fs.mkdirSync(treeSitterWasmsDir);
await new Promise((resolve, reject) => {
ncp(
path.join(
__dirname,
"..",
"core",
"node_modules",
"tree-sitter-wasms",
"out",
),
treeSitterWasmsDir,
{ dereference: true },
(error) => {
if (error) {
console.warn("[error] Error copying tree-sitter-wasm files", error);
reject(error);
} else {
resolve();
}
},
);
});

fs.copyFileSync(
path.join(__dirname, "../core/vendor/tree-sitter.wasm"),
path.join(__dirname, "out/tree-sitter.wasm"),
);
console.log("[info] Copied tree-sitter wasms");

console.log("[info] Cleaning up artifacts from previous builds...");

// delete asset backups generated by previous pkg invocations, if present
for (const assetPath of assetBackups) {
fs.rmSync(assetPath, { force: true });
}

console.log("[info] Building with esbuild...");
// Bundles the extension into one file
console.log("[info] Building with esbuild...");
await esbuild.build({
entryPoints: ["src/index.ts"],
bundle: true,
outfile: esbuildOutputFile,
external: ["esbuild", ...DYNAMIC_IMPORTS, "./xhr-sync-worker.js", "vscode"],
external: ["esbuild", "./xhr-sync-worker.js", "vscode"],
format: "cjs",
platform: "node",
sourcemap: true,
Expand Down Expand Up @@ -208,6 +204,7 @@ async function installNodeModuleInTempDirAndCopyToCurrent(package, toCopy) {
);

// Download and unzip prebuilt sqlite3 binary for the target
console.log("[info] Downloading node-sqlite3");
const downloadUrl = `https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v6-${
target === "win32-arm64" ? "win32-ia32" : target
}.tar.gz`;
Expand Down Expand Up @@ -240,9 +237,30 @@ async function installNodeModuleInTempDirAndCopyToCurrent(package, toCopy) {
force: true,
recursive: true,
});

// copy @lancedb to bin folders
console.log("[info] Copying @lancedb files to bin");
fs.copyFileSync(
`node_modules/${targetToLanceDb[target]}/index.node`,
`${targetDir}/index.node`,
);
}
// execCmdSync(
// `npx pkg out/index.js --target node18-darwin-arm64 --no-bytecode --public-packages "*" --public -o bin/pkg`
// );

const pathsToVerify = [];
for (target of targets) {
const exe = target.startsWith("win") ? ".exe" : "";
const targetDir = `bin/${target}`;
pathsToVerify.push(
`${targetDir}/continue-binary${exe}`,
`${targetDir}/esbuild${exe}`,
`${targetDir}/index.node`, // @lancedb
`${targetDir}/node_sqlite3.node`,
);
}
validateFilesPresent(pathsToVerify);

console.log("[info] Done!");
})();
Loading

0 comments on commit 08dc5db

Please sign in to comment.