diff --git a/.github/workflows/jetbrains-release.yaml b/.github/workflows/jetbrains-release.yaml index 531129c790b..c75e5baf4a3 100644 --- a/.github/workflows/jetbrains-release.yaml +++ b/.github/workflows/jetbrains-release.yaml @@ -166,8 +166,8 @@ jobs: path: gui/node_modules key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }} - - name: Build packages (Unix) - run: cd ../.. && ./scripts/build-packages.sh + - name: Build packages + run: cd ../.. && node ./scripts/build-packages.js # npm install core - name: Install core node_modules diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index ce1e59e66a0..a21b2d3f1b5 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -104,13 +104,8 @@ jobs: path: gui/node_modules key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }} - - name: Build packages (Windows) - run: ./scripts/build-packages.ps1 - if: matrix.os == 'windows-latest' - - - name: Build packages (Unix) - 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/preview.yaml b/.github/workflows/preview.yaml index 3ef4920ede6..f69881c701b 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -99,13 +99,8 @@ jobs: path: gui/node_modules key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }} - - name: Build packages (Windows) - run: ./scripts/build-packages.ps1 - if: matrix.os == 'windows-latest' - - - name: Build packages (Unix) - 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/scripts/build-packages.js b/scripts/build-packages.js new file mode 100644 index 00000000000..bfc57511d81 --- /dev/null +++ b/scripts/build-packages.js @@ -0,0 +1,79 @@ +const { spawn } = require("child_process"); +const path = require("path"); +const fs = require("fs"); + +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); + }); + }); +} + +async function buildPackage(packageName) { + const packagePath = path.join(__dirname, "..", "packages", packageName); + + if (!fs.existsSync(packagePath)) { + throw new Error(`Package directory not found: ${packagePath}`); + } + + await runCommand(npmInstallCmd, packagePath, `${packageName} (install)`); + + return runCommand("npm run build", packagePath, `${packageName} (build)`); +} + +async function main() { + try { + console.log("🚀 Starting package builds..."); + + await Promise.all([ + buildPackage("openai-adapters"), + buildPackage("config-yaml"), + ]); + + console.log("🎉 All packages built successfully!"); + } catch (error) { + console.error("💥 Build failed:", error.message); + process.exit(1); + } +} + +if (require.main === module) { + main(); +} diff --git a/scripts/build-packages.ps1 b/scripts/build-packages.ps1 deleted file mode 100755 index cd415b3dfc6..00000000000 --- a/scripts/build-packages.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -Push-Location packages - -Push-Location "openai-adapters" -npm ci -npm run build -Pop-Location - -Push-Location "config-yaml" -npm ci -npm run build -Pop-Location - -Pop-Location \ No newline at end of file diff --git a/scripts/build-packages.sh b/scripts/build-packages.sh deleted file mode 100755 index fa6f62731c3..00000000000 --- a/scripts/build-packages.sh +++ /dev/null @@ -1,13 +0,0 @@ -# Build @continuedev packages for monorepo style linking - -cd packages -cd openai-adapters - -npm ci -npm run build - -cd .. -cd config-yaml - -npm ci -npm run build