From 9fae1a2f05f9c88e7a68ce360127db1174ef0e52 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Fri, 6 Jun 2025 22:30:40 +0530 Subject: [PATCH] refactor utils to child process files --- binary/package-lock.json | 5 +- extensions/vscode/package-lock.json | 6 +- .../vscode/scripts/generate-copy-config.js | 43 ++++++++++ .../vscode/scripts/install-nodemodules.js | 42 ++++++++++ extensions/vscode/scripts/prepackage.js | 9 +- extensions/vscode/scripts/utils.js | 84 +------------------ gui/package-lock.json | 2 +- 7 files changed, 96 insertions(+), 95 deletions(-) diff --git a/binary/package-lock.json b/binary/package-lock.json index abb11ce8e..2d84672f0 100644 --- a/binary/package-lock.json +++ b/binary/package-lock.json @@ -52,7 +52,7 @@ "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", "@continuedev/config-yaml": "file:../packages/config-yaml", - "@continuedev/fetch": "^1.0.10", + "@continuedev/fetch": "^1.0.13", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.25", "@modelcontextprotocol/sdk": "^1.12.0", @@ -144,7 +144,8 @@ "onnxruntime-common": "1.14.0", "onnxruntime-web": "1.14.0", "ts-jest": "^29.1.1", - "typescript": "^5.6.3" + "typescript": "^5.6.3", + "vitest": "^3.1.4" }, "engines": { "node": ">=20.19.0" diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index e516f171e..38efaa08a 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.41", + "version": "1.1.44", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.41", + "version": "1.1.44", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", @@ -107,7 +107,7 @@ "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", "@continuedev/config-yaml": "file:../packages/config-yaml", - "@continuedev/fetch": "^1.0.10", + "@continuedev/fetch": "^1.0.13", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.25", "@modelcontextprotocol/sdk": "^1.12.0", diff --git a/extensions/vscode/scripts/generate-copy-config.js b/extensions/vscode/scripts/generate-copy-config.js index 16d8e1df6..73fe4602d 100644 --- a/extensions/vscode/scripts/generate-copy-config.js +++ b/extensions/vscode/scripts/generate-copy-config.js @@ -2,6 +2,7 @@ * @file Generate config.yaml file from template. Intended to run as a child process. */ +const { fork } = require("child_process"); const fs = require("fs"); const path = require("path"); @@ -81,3 +82,45 @@ process.on("message", (msg) => { }); } }); + +async function generateAndCopyConfigYamlSchema() { + // Generate and copy over config-yaml-schema.json + const generateConfigYamlChild = fork( + path.join(__dirname, "generate-copy-config.js"), + { + stdio: "inherit", + }, + ); + generateConfigYamlChild.send({ payload: { operation: "generate" } }); + + await new Promise((resolve, reject) => { + generateConfigYamlChild.on("message", (msg) => { + if (msg.error) { + reject(); + } + resolve(); + }); + }); + + // Copy config schemas to intellij + const copyConfigSchemaChild = fork( + path.join(__dirname, "generate-copy-config.js"), + { + stdio: "inherit", + }, + ); + copyConfigSchemaChild.send({ payload: { operation: "copy" } }); + + await new Promise((resolve, reject) => { + copyConfigSchemaChild.on("message", (msg) => { + if (msg.error) { + reject(); + } + resolve(); + }); + }); +} + +module.exports = { + generateAndCopyConfigYamlSchema, +}; diff --git a/extensions/vscode/scripts/install-nodemodules.js b/extensions/vscode/scripts/install-nodemodules.js index cae222b39..f23de3b3b 100644 --- a/extensions/vscode/scripts/install-nodemodules.js +++ b/extensions/vscode/scripts/install-nodemodules.js @@ -2,6 +2,7 @@ * @file Install node modules for the VS Code extension. This is intended to run as a child process. */ +const { fork } = require("child_process"); const path = require("path"); const { execCmdSync } = require("../../../scripts/util"); @@ -38,3 +39,44 @@ process.on("message", (msg) => { }); } }); + +async function installNodeModules() { + const installVscodeChild = fork( + path.join(__dirname, "install-nodemodules.js"), + { + stdio: "inherit", + }, + ); + installVscodeChild.send({ payload: { targetDir: "vscode" } }); + + const installGuiChild = fork(path.join(__dirname, "install-nodemodules.js"), { + stdio: "inherit", + }); + installGuiChild.send({ payload: { targetDir: "gui" } }); + + await Promise.all([ + new Promise((resolve, reject) => { + installVscodeChild.on("message", (msg) => { + if (msg.error) { + reject(); + } + resolve(); + }); + }), + new Promise((resolve, reject) => { + installGuiChild.on("message", (msg) => { + if (msg.error) { + reject(); + } + resolve(); + }); + }), + ]).catch((error) => { + console.error(error); + process.exit(1); + }); +} + +module.exports = { + installNodeModules, +}; diff --git a/extensions/vscode/scripts/prepackage.js b/extensions/vscode/scripts/prepackage.js index ece5d91e5..622393a19 100644 --- a/extensions/vscode/scripts/prepackage.js +++ b/extensions/vscode/scripts/prepackage.js @@ -11,13 +11,10 @@ const { autodetectPlatformAndArch, } = require("../../../scripts/util/index"); +const { generateAndCopyConfigYamlSchema } = require("./generate-copy-config"); const { copySqlite, copyEsbuild } = require("./install-copy-sqlite-esbuild"); -const { - writeBuildTimestamp, - installNodeModules, - continueDir, - generateAndCopyConfigYamlSchema, -} = require("./utils"); +const { installNodeModules } = require("./install-nodemodules"); +const { writeBuildTimestamp, continueDir } = require("./utils"); // Clear folders that will be packaged to ensure clean slate rimrafSync(path.join(__dirname, "..", "bin")); diff --git a/extensions/vscode/scripts/utils.js b/extensions/vscode/scripts/utils.js index 422e6370b..cae982a97 100644 --- a/extensions/vscode/scripts/utils.js +++ b/extensions/vscode/scripts/utils.js @@ -1,56 +1,13 @@ -const { fork } = require("child_process"); const fs = require("fs"); const path = require("path"); const ncp = require("ncp").ncp; const { rimrafSync } = require("rimraf"); -const { - validateFilesPresent, - execCmdSync, - autodetectPlatformAndArch, -} = require("../../../scripts/util/index"); +const { execCmdSync } = require("../../../scripts/util/index"); const continueDir = path.join(__dirname, "..", "..", ".."); -async function generateAndCopyConfigYamlSchema() { - // Generate and copy over config-yaml-schema.json - const generateConfigYamlChild = fork( - path.join(__dirname, "generate-copy-config.js"), - { - stdio: "inherit", - }, - ); - generateConfigYamlChild.send({ payload: { operation: "generate" } }); - - await new Promise((resolve, reject) => { - generateConfigYamlChild.on("message", (msg) => { - if (msg.error) { - reject(); - } - resolve(); - }); - }); - - // Copy config schemas to intellij - const copyConfigSchemaChild = fork( - path.join(__dirname, "generate-copy-config.js"), - { - stdio: "inherit", - }, - ); - copyConfigSchemaChild.send({ payload: { operation: "copy" } }); - - await new Promise((resolve, reject) => { - copyConfigSchemaChild.on("message", (msg) => { - if (msg.error) { - reject(); - } - resolve(); - }); - }); -} - function copyTokenizers() { fs.copyFileSync( path.join(__dirname, "../../../core/llm/llamaTokenizerWorkerPool.mjs"), @@ -65,43 +22,6 @@ function copyTokenizers() { console.log("[info] Copied llamaTokenizer"); } -async function installNodeModules() { - const installVscodeChild = fork( - path.join(__dirname, "install-nodemodules.js"), - { - stdio: "inherit", - }, - ); - installVscodeChild.send({ payload: { targetDir: "vscode" } }); - - const installGuiChild = fork(path.join(__dirname, "install-nodemodules.js"), { - stdio: "inherit", - }); - installGuiChild.send({ payload: { targetDir: "gui" } }); - - await Promise.all([ - new Promise((resolve, reject) => { - installVscodeChild.on("message", (msg) => { - if (msg.error) { - reject(); - } - resolve(); - }); - }), - new Promise((resolve, reject) => { - installGuiChild.on("message", (msg) => { - if (msg.error) { - reject(); - } - resolve(); - }); - }), - ]).catch((error) => { - console.error(error); - process.exit(1); - }); -} - async function buildGui(isGhAction) { // Make sure we are in the right directory if (!process.cwd().endsWith("gui")) { @@ -552,8 +472,6 @@ function writeBuildTimestamp() { module.exports = { continueDir, - generateAndCopyConfigYamlSchema, - installNodeModules, buildGui, copyOnnxRuntimeFromNodeModules, copyTreeSitterWasms, diff --git a/gui/package-lock.json b/gui/package-lock.json index 020586519..a9d589b98 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -111,7 +111,7 @@ "@aws-sdk/credential-providers": "^3.778.0", "@continuedev/config-types": "^1.0.13", "@continuedev/config-yaml": "file:../packages/config-yaml", - "@continuedev/fetch": "^1.0.10", + "@continuedev/fetch": "^1.0.13", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.25", "@modelcontextprotocol/sdk": "^1.12.0",