diff --git a/.github/workflows/build-vscode-extension.yml b/.github/workflows/build-vscode-extension.yml index fd959807e..4bb008d46 100644 --- a/.github/workflows/build-vscode-extension.yml +++ b/.github/workflows/build-vscode-extension.yml @@ -106,13 +106,8 @@ jobs: key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }} # Build all packages using the authoritative build script - - name: Build packages (Windows) - run: ./scripts/build-packages.ps1 - if: matrix.os == 'windows-latest' - - - name: Build packages (Linux/macOS) - run: ./scripts/build-packages.sh - if: matrix.os != 'windows-latest' + - name: Build packages + run: node ./scripts/build-packages.js - name: Install extension Dependencies run: | diff --git a/.github/workflows/jetbrains-release.yaml b/.github/workflows/jetbrains-release.yaml index 531129c79..afdb544f3 100644 --- a/.github/workflows/jetbrains-release.yaml +++ b/.github/workflows/jetbrains-release.yaml @@ -167,7 +167,7 @@ jobs: key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }} - name: Build packages (Unix) - run: cd ../.. && ./scripts/build-packages.sh + run: cd ../.. && node ./scripts/build-packages.js # npm install core - name: Install core node_modules diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index 9733f856c..a78035a6e 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -59,7 +59,7 @@ jobs: node-version-file: ".nvmrc" - name: Build packages (Unix) - run: ./scripts/build-packages.sh + run: node ./scripts/build-packages.js config-yaml-checks: needs: build-packages @@ -78,7 +78,7 @@ jobs: - name: Build packages and check config-yaml run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js cd packages/config-yaml npx tsc --noEmit # Tests are currently failing, commenting out for now @@ -137,7 +137,7 @@ jobs: - name: Build packages and install core dependencies run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js cd core npm ci @@ -177,7 +177,7 @@ jobs: - name: Build packages and install dependencies run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js if [ "${{ steps.gui-cache.outputs.cache-hit }}" != "true" ]; then cd core npm ci @@ -211,7 +211,7 @@ jobs: - name: Build packages and install dependencies run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js cd core npm ci cd ../gui @@ -251,7 +251,7 @@ jobs: - name: Build packages and install dependencies run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js if [ "${{ steps.binary-cache.outputs.cache-hit }}" != "true" ]; then cd core npm ci @@ -295,7 +295,7 @@ jobs: - name: Build packages and install dependencies run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js if [ "${{ steps.vscode-cache.outputs.cache-hit }}" != "true" ]; then cd core npm ci @@ -333,7 +333,7 @@ jobs: - name: Build packages and install dependencies run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js cd core npm ci cd ../extensions/vscode @@ -370,7 +370,7 @@ jobs: - name: Build packages and install core dependencies run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js cd core npm ci @@ -401,7 +401,7 @@ jobs: - name: Build packages and run tests run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js cd packages/config-yaml npm test @@ -421,7 +421,7 @@ jobs: - name: Build packages and run tests run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js cd packages/openai-adapters npm test env: @@ -453,7 +453,7 @@ jobs: - name: Build packages and get test files id: vscode-get-test-file-matrix run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js cd core npm ci cd ../extensions/vscode @@ -525,7 +525,7 @@ jobs: - name: Build packages and download e2e dependencies run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js if [ "${{ steps.storage-cache.outputs.cache-hit }}" != "true" ]; then cd core npm ci @@ -590,7 +590,7 @@ jobs: - name: Build packages and install core dependencies run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js cd core npm ci @@ -678,7 +678,7 @@ jobs: - name: Build packages and install dependencies run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js cd core npm ci cd ../gui @@ -703,7 +703,7 @@ jobs: - name: Build packages and install core dependencies run: | - ./scripts/build-packages.sh + node ./scripts/build-packages.js cd core npm ci diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 9cb87f64c..5fd0c86b7 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -227,8 +227,7 @@ { "label": "build-packages", "type": "shell", - "windows": { "command": "./scripts/build-packages.ps1" }, - "command": "./scripts/build-packages.sh", + "command": "node ./scripts/build-packages.js", "problemMatcher": [], "presentation": { "reveal": "silent", diff --git a/packages/openai-adapters/package-lock.json b/packages/openai-adapters/package-lock.json index 1aec0451a..731bfe01b 100644 --- a/packages/openai-adapters/package-lock.json +++ b/packages/openai-adapters/package-lock.json @@ -80,7 +80,7 @@ }, "../fetch": { "name": "@continuedev/fetch", - "version": "1.0.15", + "version": "1.0.16", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "file:../config-types", diff --git a/scripts/build-packages.js b/scripts/build-packages.js new file mode 100644 index 000000000..e268cd215 --- /dev/null +++ b/scripts/build-packages.js @@ -0,0 +1,100 @@ +const { spawn } = require("child_process"); +const path = require("path"); +const fs = require("fs"); +const fsPromises = require("fs/promises"); + +const npmInstallCmd = process.env.CI === "true" ? "npm ci" : "npm install"; + +function runCommand(command, cwd, packageName) { + return new Promise((resolve, reject) => { + console.log(`Starting ${packageName}: ${command}`); + + const [cmd, ...args] = command.split(" "); + const child = spawn(cmd, args, { + cwd, + stdio: "pipe", + shell: true, + }); + + let stdout = ""; + let stderr = ""; + + child.stdout.on("data", (data) => { + stdout += data.toString(); + }); + + child.stderr.on("data", (data) => { + stderr += data.toString(); + }); + + child.on("close", (code) => { + if (code === 0) { + console.log(`โœ… ${packageName}: ${command} completed successfully`); + resolve({ packageName, command, stdout, stderr }); + } else { + console.error(`โŒ ${packageName}: ${command} failed with code ${code}`); + console.error(`stderr: ${stderr}`); + reject( + new Error(`${packageName} failed: ${command} (exit code ${code})`), + ); + } + }); + + child.on("error", (error) => { + console.error(`โŒ ${packageName}: Failed to start ${command}:`, error); + reject(error); + }); + }); +} + +// Helper function to build a package (install + build) +async function buildPackage(packageName, cleanNodeModules = false) { + const packagePath = path.join(__dirname, "..", "packages", packageName); + + if (!fs.existsSync(packagePath)) { + throw new Error(`Package directory not found: ${packagePath}`); + } + + if (cleanNodeModules) { + const nodeModulesPath = path.join(packagePath, "node_modules"); + if (fs.existsSync(nodeModulesPath)) { + console.log(`๐Ÿงน Cleaning node_modules for ${packageName}`); + await fsPromises.rm(nodeModulesPath, { recursive: true, force: true }); + } + } + + await runCommand(npmInstallCmd, packagePath, `${packageName} (install)`); + + return runCommand("npm run build", packagePath, `${packageName} (build)`); +} + +async function buildPackagesInParallel(packages, cleanNodeModules = false) { + const buildPromises = packages.map((pkg) => + buildPackage(pkg, cleanNodeModules), + ); + return Promise.all(buildPromises); +} + +async function main() { + try { + console.log("๐Ÿš€ Starting package builds...\n"); + + // Phase 1: Build config-types (foundation - no dependencies) + await buildPackagesInParallel(["config-types"]); + + // Phase 2: Build packages that depend on config-types + await buildPackagesInParallel(["fetch", "config-yaml", "llm-info"]); + + // Phase 3: Build packages that depend on other local packages + await buildPackagesInParallel(["openai-adapters", "continue-sdk"], true); + + console.log("๐ŸŽ‰ All packages built successfully!"); + } catch (error) { + console.error("๐Ÿ’ฅ Build failed:", error.message); + process.exit(1); + } +} + +if (require.main === module) { + main(); +} \ No newline at end of file diff --git a/scripts/build-packages.ps1 b/scripts/build-packages.ps1 deleted file mode 100755 index 740587330..000000000 --- a/scripts/build-packages.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -# Use npm ci in CI, npm install in development -if ($env:CI -eq "true") { - $npmInstallCmd = "npm ci" -} else { - $npmInstallCmd = "npm install" -} - -Push-Location packages - -# Phase 1: Build config-types (foundation - no dependencies) -Push-Location "config-types" -& cmd /c $npmInstallCmd -npm run build -Pop-Location - -# Phase 2: Build packages that depend on config-types -Push-Location "fetch" -& cmd /c $npmInstallCmd -npm run build -Pop-Location - -Push-Location "config-yaml" -& cmd /c $npmInstallCmd -npm run build -Pop-Location - -Push-Location "llm-info" -& cmd /c $npmInstallCmd -npm run build -Pop-Location - -# Phase 3: Build packages that depend on other local packages -Push-Location "openai-adapters" -& cmd /c $npmInstallCmd -npm run build -Pop-Location - -Push-Location "continue-sdk" -& cmd /c $npmInstallCmd -npm run build -Pop-Location - -Pop-Location diff --git a/scripts/build-packages.sh b/scripts/build-packages.sh deleted file mode 100755 index a2390ad5a..000000000 --- a/scripts/build-packages.sh +++ /dev/null @@ -1,45 +0,0 @@ -# Build @continuedev packages for monorepo style linking - -# Use npm ci in CI, npm install in development -if [ "$CI" = "true" ]; then - NPM_INSTALL_CMD="npm ci" -else - NPM_INSTALL_CMD="npm install" -fi - -cd packages - -# Phase 1: Build config-types (foundation - no dependencies) -cd config-types -$NPM_INSTALL_CMD -npm run build -cd .. - -# Phase 2: Build packages that depend on config-types -cd fetch -$NPM_INSTALL_CMD -npm run build -cd .. - -cd config-yaml -$NPM_INSTALL_CMD -npm run build -cd .. - -cd llm-info -$NPM_INSTALL_CMD -npm run build -cd .. - -# Phase 3: Build packages that depend on other local packages -cd openai-adapters -rm -rf node_modules -$NPM_INSTALL_CMD -npm run build -cd .. - -cd continue-sdk -rm -rf node_modules -$NPM_INSTALL_CMD -npm run build -cd .. \ No newline at end of file diff --git a/scripts/install-dependencies.ps1 b/scripts/install-dependencies.ps1 index bb957b090..33a269219 100644 --- a/scripts/install-dependencies.ps1 +++ b/scripts/install-dependencies.ps1 @@ -77,7 +77,7 @@ Write-Host "`nInstalling root-level dependencies..." -ForegroundColor White npm install Write-Host "`nBuilding packages (fetch, openai-adapters, config-yaml)..." -ForegroundColor White -& .\scripts\build-packages.ps1 +node ./scripts/build-packages.js Write-Host "`nInstalling Core extension dependencies..." -ForegroundColor White Push-Location core diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh index 294ce5628..836b8e11b 100755 --- a/scripts/install-dependencies.sh +++ b/scripts/install-dependencies.sh @@ -31,7 +31,7 @@ echo "Installing root-level dependencies..." npm install echo "Building packages (fetch, openai-adapters, config-yaml)..." -./scripts/build-packages.sh +node ./scripts/build-packages.js echo "Installing Core extension dependencies..." pushd core