Skip to content

switch from yarn to npm#2347

Merged
sawka merged 8 commits intomainfrom
sawka/npm
Sep 12, 2025
Merged

switch from yarn to npm#2347
sawka merged 8 commits intomainfrom
sawka/npm

Conversation

@sawka
Copy link
Member

@sawka sawka commented Sep 12, 2025

no need for yarn anymore in 2025 (especially yarn berry which is just an AI + githubactions nightmare). switch to the more standard npm.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 12, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR migrates the project from Yarn to npm: CI workflows replace Yarn steps with npm ci and npm caching; Taskfile.yml swaps yarn commands for npm equivalents and adds npm:install/npm:ci tasks; docs and README remove Yarn usage; .yarnrc.yml and Yarn lockfile references are removed. package.json now lists npm as packageManager, removes rollup-plugin-flow, react-gauge-chart, and the resolutions block. electron.vite.config.ts removes the flow plugin, adds explicit CHROME/NODE build targets and renderer optimizeDeps/dev watch tweaks. Frontend gauge UI code and related package usage were removed. go.mod promotes github.com/launchdarkly/eventsource to a direct dependency. docs/package.json script updated to use npm run.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Pre-merge checks and finishing touches and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "switch from yarn to npm" is a concise, accurate summary of the primary change in this PR: migrating the repository from Yarn to npm across CI workflows, Taskfile, documentation, and package configuration. It is short, focused, and directly related to the changeset. A teammate scanning history will understand the main intent from this title.
Description Check ✅ Passed The description clearly states the intent to remove Yarn in favor of npm and gives a brief rationale, which matches the changes in workflows, Taskfile, docs, and package.json shown in the diff. Although informal and opinionated in tone, it remains on-topic and describes the PR's purpose. Under the lenient description check this is sufficient.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sawka/npm

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63cf337 and 4920312.

📒 Files selected for processing (1)
  • Taskfile.yml (9 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docs/package.json (1)

62-65: Replace Yarn “resolutions” with npm “overrides”.

After switching to npm, “resolutions” is ignored; pins won’t apply, potentially reintroducing unwanted versions.

-    "resolutions": {
-        "path-to-regexp@npm:2.2.1": "^3",
-        "cookie@0.6.0": "^0.7.0"
-    },
+    "overrides": {
+        "path-to-regexp": "^3",
+        "cookie": "^0.7.0"
+    },
Taskfile.yml (1)

447-456: tsunami/frontend tasks lack an install step.

Add a scoped install to avoid dev/build failures.

Apply:

@@
     tsunami:frontend:dev:
         desc: Run the tsunami frontend vite dev server
         cmd: npm run dev
         dir: tsunami/frontend
+        deps:
+            - tsunami:frontend:npm:install
@@
     tsunami:frontend:build:
         desc: Build the tsunami frontend
-        cmd: npm run build
+        cmd: npm run build
         dir: tsunami/frontend
+        deps:
+            - tsunami:frontend:npm:install
@@
     tsunami:frontend:devbuild:
         desc: Build the tsunami frontend in development mode (with source maps and symbols)
-        cmd: npm run build:dev
+        cmd: npm run build:dev
         dir: tsunami/frontend
+        deps:
+            - tsunami:frontend:npm:install
+
+    tsunami:frontend:npm:install:
+        desc: Install deps for tsunami/frontend
+        dir: tsunami/frontend
+        internal: true
+        generates:
+            - node_modules/**/*
+            - package-lock.json
+        sources:
+            - package-lock.json
+            - package.json
+        cmd: npm install

Also applies to: 457-461

🧹 Nitpick comments (11)
.github/workflows/bump-version.yml (1)

45-46: Add npm cache and retry for robustness and speed in CI.

Use actions/setup-node cache: npm and wrap npm ci with a retry to mitigate transient registry failures.

-            - uses: actions/setup-node@v5
-              with:
-                  node-version: ${{env.NODE_VERSION}}
+            - uses: actions/setup-node@v5
+              with:
+                  node-version: ${{env.NODE_VERSION}}
+                  cache: npm
+                  cache-dependency-path: package-lock.json
-            - name: npm ci
-              run: npm ci
+            - uses: nick-fields/retry@v3
+              name: npm ci
+              with:
+                  command: npm ci --no-audit --no-fund
+                  retry_on: error
+                  max_attempts: 3
+                  timeout_minutes: 10
.github/workflows/build-helper.yml (1)

70-71: Enable npm caching and add retry to reduce flakiness across platforms.

This job is long-running; shaving repeated installs helps and retries guard against network hiccups.

-            - uses: actions/setup-node@v5
-              with:
-                  node-version: ${{env.NODE_VERSION}}
+            - uses: actions/setup-node@v5
+              with:
+                  node-version: ${{env.NODE_VERSION}}
+                  cache: npm
+                  cache-dependency-path: package-lock.json
-            - name: npm ci
-              run: npm ci
+            - uses: nick-fields/retry@v3
+              name: npm ci
+              with:
+                  command: npm ci --no-audit --no-fund
+                  retry_on: error
+                  max_attempts: 3
+                  timeout_minutes: 15
.github/workflows/testdriver-build.yml (1)

53-54: Add npm cache and retry on Windows runner.

Improves reliability for TestDriver builds.

-            - uses: actions/setup-node@v5
-              with:
-                  node-version: ${{env.NODE_VERSION}}
+            - uses: actions/setup-node@v5
+              with:
+                  node-version: ${{env.NODE_VERSION}}
+                  cache: npm
+                  cache-dependency-path: package-lock.json
-            - name: npm ci
-              run: npm ci
+            - uses: nick-fields/retry@v3
+              name: npm ci
+              with:
+                  command: npm ci --no-audit --no-fund
+                  retry_on: error
+                  max_attempts: 3
+                  timeout_minutes: 10
package.json (1)

159-159: Verify npm version alignment with packageManager and CI runners.

packageManager pins npm@10.9.2. actions/setup-node installs the npm bundled with Node 22, which may differ slightly. Either align runners to a Node release that bundles 10.9.2+ or explicitly upgrade npm in CI to avoid warnings/mismatch.

Example step to pin npm:

-            - name: npm ci
+            - name: Use npm@10.9.2
+              run: npm i -g npm@10.9.2
+            - name: npm ci
               run: npm ci
.github/workflows/deploy-docsite.yml (1)

47-48: Use npm cache and add retry for docsite build.

Speeds PR builds and reduces transient failures.

-            - uses: actions/setup-node@v5
-              with:
-                  node-version: ${{env.NODE_VERSION}}
+            - uses: actions/setup-node@v5
+              with:
+                  node-version: ${{env.NODE_VERSION}}
+                  cache: npm
+                  cache-dependency-path: package-lock.json
-            - name: npm ci
-              run: npm ci
+            - uses: nick-fields/retry@v3
+              name: npm ci
+              with:
+                  command: npm ci --no-audit --no-fund
+                  retry_on: error
+                  max_attempts: 3
+                  timeout_minutes: 10
.github/workflows/codeql.yml (1)

77-78: Cache npm deps and add retry before CodeQL build to stabilize analysis runs.

Large dependency graphs can cause flaky installs; cache + retry helps.

-            - uses: actions/setup-node@v5
-              with:
-                  node-version: ${{env.NODE_VERSION}}
+            - uses: actions/setup-node@v5
+              with:
+                  node-version: ${{env.NODE_VERSION}}
+                  cache: npm
+                  cache-dependency-path: package-lock.json
-            - name: npm ci
-              run: npm ci
+            - uses: nick-fields/retry@v3
+              name: npm ci
+              with:
+                  command: npm ci --no-audit --no-fund
+                  retry_on: error
+                  max_attempts: 3
+                  timeout_minutes: 10
docs/package.json (1)

8-8: Make EMBEDDED env var cross-platform.

Inline env assignment in scripts fails on Windows shells. Use cross-env.

-        "build-embedded": "EMBEDDED=true npm run build",
+        "build-embedded": "cross-env EMBEDDED=true npm run build",

Add devDependency:

   "devDependencies": {
+        "cross-env": "^7.0.3",
BUILD.md (1)

74-74: Clarify npm usage: prefer “npm ci” for CI and “npm install” locally.

Small doc tweak to set expectations and reproducibility.

-We now use `npm`, so you can just run an `npm install` to install node dependencies.
+We now use `npm`. For local development, run `npm install`. In CI, use `npm ci` for reproducible, lockfile-only installs.
electron.vite.config.ts (1)

92-103: Scope image optimization to build-only to speed up dev.

Avoid running heavy image optimization during serve.

Apply:

-            ViteImageOptimizer(),
+            { ...ViteImageOptimizer(), apply: "build" },

If you prefer full control, convert to a function config and inject the plugin only when command === "build".

Taskfile.yml (2)

113-117: Use npm ci for reproducible packaging; keep npm install for dev.

Introduce npm:ci and switch the packaging flow to it.

Apply:

@@
     package:
@@
-            - npm run build:prod && npm exec electron-builder -- -c electron-builder.config.cjs -p never {{.CLI_ARGS}}
+            - npm run build:prod && npm exec electron-builder -- -c electron-builder.config.cjs -p never {{.CLI_ARGS}}
@@
-            - npm:install
+            - npm:ci
@@
     npm:install:
         desc: Runs `npm install`
         internal: true
         generates:
             - node_modules/**/*
             - package-lock.json
         sources:
             - package-lock.json
             - package.json
         cmd: npm install
+
+    npm:ci:
+        desc: Runs `npm ci` (clean, lockfile-resolved install)
+        internal: true
+        generates:
+            - node_modules/**/*
+        sources:
+            - package-lock.json
+            - package.json
+        cmd: npm ci

Also applies to: 407-417


301-301: Pin ncu invocation to reduce flakiness.

Narrow version drift for CI/dev parity.

Apply:

-        cmd: npx npm-check-updates
+        cmd: npx npm-check-updates@latest
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e35544 and 365d10e.

⛔ Files ignored due to path filters (3)
  • go.sum is excluded by !**/*.sum
  • package-lock.json is excluded by !**/package-lock.json
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (15)
  • .github/workflows/build-helper.yml (1 hunks)
  • .github/workflows/bump-version.yml (1 hunks)
  • .github/workflows/codeql.yml (1 hunks)
  • .github/workflows/deploy-docsite.yml (1 hunks)
  • .github/workflows/testdriver-build.yml (1 hunks)
  • .roo/rules/rules.md (0 hunks)
  • .yarnrc.yml (0 hunks)
  • BUILD.md (1 hunks)
  • Taskfile.yml (9 hunks)
  • docs/README.md (0 hunks)
  • docs/package.json (1 hunks)
  • electron.vite.config.ts (5 hunks)
  • frontend/app/view/term/termsticker.tsx (0 hunks)
  • go.mod (1 hunks)
  • package.json (1 hunks)
💤 Files with no reviewable changes (4)
  • .roo/rules/rules.md
  • .yarnrc.yml
  • docs/README.md
  • frontend/app/view/term/termsticker.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build for TestDriver.ai
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: merge-gatekeeper
🔇 Additional comments (5)
go.mod (1)

24-24: Confirmed: keep direct dependency
Import found at pkg/waveai/usechat-anthropic.go:26 (github.com/launchdarkly/eventsource); no change required.

electron.vite.config.ts (3)

75-77: Confirm optimizeDeps include is effective for the worker.

Vite’s optimizeDeps pre-bundles ESM deps for dev. Including "monaco-yaml/yaml.worker.js" may be a no-op if that path isn’t resolved as a bare dep. Keep only if it measurably improves dev startup.


81-81: Good call ignoring dist/ in dev watch.**

Prevents rebuild loops and unnecessary reloads.


12-15: Targets correctly match Electron v38 (Node 22 / Chromium 140).
package.json contains electron ^38.1.0 and Electron v38 bundles Node 22 + Chromium 140, so CHROME="chrome140" and NODE="node22" are correct.
File: electron.vite.config.ts (lines 12-15)

Taskfile.yml (1)

21-21: LGTM on Yarn→npm task switches.

The replaced invocations (npm run dev/start) look correct and align with the PR goal.

Also applies to: 35-35, 47-47

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
Taskfile.yml (1)

69-79: Docs installer task: good fix and matches prior review.

This unblocks fresh clones for docsite tasks.

🧹 Nitpick comments (7)
.github/workflows/testdriver.yml (1)

136-141: Optional: Wait for app readiness or add a brief delay before TestDriver runs.

Launching the app asynchronously may race with the following prompt. Consider a short wait or readiness probe.

.github/workflows/codeql.yml (1)

75-86: Broaden npm cache dependency paths for multi-package repo.

Cache will miss docs and tsunami/frontend lockfiles.

Apply:

-              with:
-                  node-version: ${{env.NODE_VERSION}}
-                  cache: npm
-                  cache-dependency-path: package-lock.json
+              with:
+                  node-version: ${{env.NODE_VERSION}}
+                  cache: npm
+                  cache-dependency-path: |
+                      package-lock.json
+                      docs/package-lock.json
+                      tsunami/frontend/package-lock.json
.github/workflows/testdriver-build.yml (2)

53-61: Avoid duplicate installs: workflow runs npm ci and Taskfile package depends on npm:ci.

You’re doing two installs per run, adding minutes to wall time.

Option A (remove workflow install):

-            - uses: nick-fields/retry@v3
-              name: npm ci
-              with:
-                  command: npm ci --no-audit --no-fund
-                  retry_on: error
-                  max_attempts: 3
-                  timeout_minutes: 5

Option B (keep workflow install, skip inside Taskfile): see Taskfile comment to switch package deps to npm:install.


53-55: Broaden npm cache dependency paths to include docs/ and tsunami/frontend/.

Ensures tarball cache hits for secondary installs during packaging.

Apply:

               with:
                   node-version: ${{env.NODE_VERSION}}
-                  cache: npm
-                  cache-dependency-path: package-lock.json
+                  cache: npm
+                  cache-dependency-path: |
+                      package-lock.json
+                      docs/package-lock.json
+                      tsunami/frontend/package-lock.json
Taskfile.yml (3)

125-129: Single source of truth for install: prefer one place (CI or Taskfile).

If CI already runs npm ci, change this dep to npm:install to skip a second clean install during packaging.

Apply:

     package:
@@
-        deps:
+        deps:
             - clean
-            - npm:ci
+            - npm:install
             - docsite:build:embedded
             - build:backend

471-483: Add a dedicated installer for tsunami/frontend and depend on it.

Fresh clones may fail without node_modules in tsunami/frontend.

Apply within these tasks:

     tsunami:frontend:dev:
         desc: Run the tsunami frontend vite dev server
-        cmd: npm run dev
+        cmd: npm run dev
         dir: tsunami/frontend
+        deps:
+            - tsunami:frontend:npm:install
@@
     tsunami:frontend:build:
         desc: Build the tsunami frontend
-        cmd: npm run build
+        cmd: npm run build
         dir: tsunami/frontend
+        deps:
+            - tsunami:frontend:npm:install
@@
     tsunami:frontend:devbuild:
         desc: Build the tsunami frontend in development mode (with source maps and symbols)
-        cmd: npm run build:dev
+        cmd: npm run build:dev
         dir: tsunami/frontend
+        deps:
+            - tsunami:frontend:npm:install

Add this internal task (outside the shown range):

# new
tsunami:frontend:npm:install:
  desc: Runs `npm install` in tsunami/frontend
  dir: tsunami/frontend
  internal: true
  generates:
    - tsunami/frontend/node_modules/**/*
    - tsunami/frontend/package-lock.json
  sources:
    - tsunami/frontend/package-lock.json
    - tsunami/frontend/package.json
  cmd: npm install

311-314: Optional: add flags to ncu for non-interactive CI runs.

Prevents prompts and ensures predictable output.

Apply:

-        cmd: npx npm-check-updates@latest
+        cmd: npx npm-check-updates@latest --format group
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 365d10e and 63cf337.

📒 Files selected for processing (8)
  • .github/workflows/build-helper.yml (2 hunks)
  • .github/workflows/bump-version.yml (1 hunks)
  • .github/workflows/codeql.yml (2 hunks)
  • .github/workflows/deploy-docsite.yml (1 hunks)
  • .github/workflows/testdriver-build.yml (2 hunks)
  • .github/workflows/testdriver.yml (2 hunks)
  • Taskfile.yml (9 hunks)
  • electron.vite.config.ts (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • .github/workflows/deploy-docsite.yml
  • .github/workflows/bump-version.yml
  • electron.vite.config.ts
  • .github/workflows/build-helper.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build for TestDriver.ai
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
.github/workflows/testdriver.yml (1)

10-10: Go toolchain bump looks fine.

Confirm local dev and other workflows are also on Go 1.24 to avoid drift.

.github/workflows/codeql.yml (1)

37-37: Go 1.24 alignment check.

Ensure go.mod/go toolchain align with 1.24 to avoid mixed toolchains in CI vs. local.

Taskfile.yml (1)

21-26: LGTM on Yarn→npm task migration.

Switch to npm run dev with npm:install dep is correct.

Comment on lines +50 to +56
- uses: testdriverai/action@main
id: testdriver
env:
FORCE_COLOR: "3"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
key: ${{ secrets.DASHCAM_API }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Pin the TestDriver action to a tag or commit SHA (avoid @main).

Prevents supply-chain breakage from upstream changes.

Apply:

-            - uses: testdriverai/action@main
+            - uses: testdriverai/action@<tag-or-commit>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: testdriverai/action@main
id: testdriver
env:
FORCE_COLOR: "3"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
key: ${{ secrets.DASHCAM_API }}
- uses: testdriverai/action@<tag-or-commit>
id: testdriver
env:
FORCE_COLOR: "3"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
key: ${{ secrets.DASHCAM_API }}
🤖 Prompt for AI Agents
.github/workflows/testdriver.yml around lines 50 to 56: the workflow currently
references the TestDriver action with an unpinned ref
("testdriverai/action@main"), which risks supply-chain breakage; update the uses
line to pin the action to a stable tag (e.g., @v1.2.3) or a specific commit SHA
(e.g., @<commit-sha>) and update any documentation or workflow comments noting
the chosen pinned ref; ensure the chosen tag/SHA exists in the
testdriverai/action repo and consider adding a brief comment explaining why the
ref is pinned for future maintenance.

Comment on lines +58 to +121
$headers = @{
Authorization = "token ${{ secrets.GITHUB_TOKEN }}"
}

$downloadFolder = "./download"
$artifactFileName = "waveterm.exe"
$artifactFilePath = "$downloadFolder/$artifactFileName"

Write-Host "Starting the artifact download process..."

# Create the download directory if it doesn't exist
if (-not (Test-Path -Path $downloadFolder)) {
Write-Host "Creating download folder..."
mkdir $downloadFolder
} else {
Write-Host "Download folder already exists."
}

# Fetch the artifact upload URL
Write-Host "Fetching the artifact upload URL..."
$artifactUrl = (Invoke-RestMethod -Uri "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/artifacts" -Headers $headers).artifacts[0].archive_download_url

if ($artifactUrl) {
Write-Host "Artifact URL successfully fetched: $artifactUrl"
} else {
Write-Error "Failed to fetch the artifact URL."
exit 1
}

# Download the artifact (zipped file)
Write-Host "Starting artifact download..."
$artifactZipPath = "$env:TEMP\artifact.zip"
try {
Invoke-WebRequest -Uri $artifactUrl `
-Headers $headers `
-OutFile $artifactZipPath `
-MaximumRedirection 5

Write-Host "Artifact downloaded successfully to $artifactZipPath"
} catch {
Write-Error "Error downloading artifact: $_"
exit 1
}

# Unzip the artifact
$artifactUnzipPath = "$env:TEMP\artifact"
Write-Host "Unzipping the artifact to $artifactUnzipPath..."
try {
Expand-Archive -Path $artifactZipPath -DestinationPath $artifactUnzipPath -Force
Write-Host "Artifact unzipped successfully to $artifactUnzipPath"
} catch {
Write-Error "Failed to unzip the artifact: $_"
exit 1
}

# Find the installer or app executable
$artifactInstallerPath = Get-ChildItem -Path $artifactUnzipPath -Filter *.exe -Recurse | Select-Object -First 1

if ($artifactInstallerPath) {
Write-Host "Executable file found: $($artifactInstallerPath.FullName)"
} else {
Write-Error "Executable file not found. Exiting."
exit 1
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Artifact selection is brittle; pick by name instead of index and remove unused vars.

artifacts[0] can be the wrong file if multiple artifacts exist. Also $artifactFileName/$artifactFilePath are unused.

Apply:

-                      $downloadFolder = "./download"
-                      $artifactFileName = "waveterm.exe"
-                      $artifactFilePath = "$downloadFolder/$artifactFileName"
+                      $downloadFolder = "./download"

-                      # Fetch the artifact upload URL
-                      Write-Host "Fetching the artifact upload URL..."
-                      $artifactUrl = (Invoke-RestMethod -Uri "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/artifacts" -Headers $headers).artifacts[0].archive_download_url
+                      # Fetch artifacts and select the Windows EXE bundle by name
+                      Write-Host "Fetching the artifact metadata..."
+                      $artifacts = (Invoke-RestMethod -Uri "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/artifacts" -Headers $headers).artifacts
+                      $artifact = $artifacts | Where-Object { $_.name -eq "windows-exe" } | Select-Object -First 1
+                      if (-not $artifact) {
+                          Write-Error "Artifact named 'windows-exe' not found."
+                          exit 1
+                      }
+                      $artifactUrl = $artifact.archive_download_url
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$headers = @{
Authorization = "token ${{ secrets.GITHUB_TOKEN }}"
}
$downloadFolder = "./download"
$artifactFileName = "waveterm.exe"
$artifactFilePath = "$downloadFolder/$artifactFileName"
Write-Host "Starting the artifact download process..."
# Create the download directory if it doesn't exist
if (-not (Test-Path -Path $downloadFolder)) {
Write-Host "Creating download folder..."
mkdir $downloadFolder
} else {
Write-Host "Download folder already exists."
}
# Fetch the artifact upload URL
Write-Host "Fetching the artifact upload URL..."
$artifactUrl = (Invoke-RestMethod -Uri "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/artifacts" -Headers $headers).artifacts[0].archive_download_url
if ($artifactUrl) {
Write-Host "Artifact URL successfully fetched: $artifactUrl"
} else {
Write-Error "Failed to fetch the artifact URL."
exit 1
}
# Download the artifact (zipped file)
Write-Host "Starting artifact download..."
$artifactZipPath = "$env:TEMP\artifact.zip"
try {
Invoke-WebRequest -Uri $artifactUrl `
-Headers $headers `
-OutFile $artifactZipPath `
-MaximumRedirection 5
Write-Host "Artifact downloaded successfully to $artifactZipPath"
} catch {
Write-Error "Error downloading artifact: $_"
exit 1
}
# Unzip the artifact
$artifactUnzipPath = "$env:TEMP\artifact"
Write-Host "Unzipping the artifact to $artifactUnzipPath..."
try {
Expand-Archive -Path $artifactZipPath -DestinationPath $artifactUnzipPath -Force
Write-Host "Artifact unzipped successfully to $artifactUnzipPath"
} catch {
Write-Error "Failed to unzip the artifact: $_"
exit 1
}
# Find the installer or app executable
$artifactInstallerPath = Get-ChildItem -Path $artifactUnzipPath -Filter *.exe -Recurse | Select-Object -First 1
if ($artifactInstallerPath) {
Write-Host "Executable file found: $($artifactInstallerPath.FullName)"
} else {
Write-Error "Executable file not found. Exiting."
exit 1
}
$headers = @{
Authorization = "token ${{ secrets.GITHUB_TOKEN }}"
}
$downloadFolder = "./download"
Write-Host "Starting the artifact download process..."
# Create the download directory if it doesn't exist
if (-not (Test-Path -Path $downloadFolder)) {
Write-Host "Creating download folder..."
mkdir $downloadFolder
} else {
Write-Host "Download folder already exists."
}
# Fetch artifacts and select the Windows EXE bundle by name
Write-Host "Fetching the artifact metadata..."
$artifacts = (Invoke-RestMethod -Uri "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/artifacts" -Headers $headers).artifacts
$artifact = $artifacts | Where-Object { $_.name -eq "windows-exe" } | Select-Object -First 1
if (-not $artifact) {
Write-Error "Artifact named 'windows-exe' not found."
exit 1
}
$artifactUrl = $artifact.archive_download_url
if ($artifactUrl) {
Write-Host "Artifact URL successfully fetched: $artifactUrl"
} else {
Write-Error "Failed to fetch the artifact URL."
exit 1
}
# Download the artifact (zipped file)
Write-Host "Starting artifact download..."
$artifactZipPath = "$env:TEMP\artifact.zip"
try {
Invoke-WebRequest -Uri $artifactUrl `
-Headers $headers `
-OutFile $artifactZipPath `
-MaximumRedirection 5
Write-Host "Artifact downloaded successfully to $artifactZipPath"
} catch {
Write-Error "Error downloading artifact: $_"
exit 1
}
# Unzip the artifact
$artifactUnzipPath = "$env:TEMP\artifact"
Write-Host "Unzipping the artifact to $artifactUnzipPath..."
try {
Expand-Archive -Path $artifactZipPath -DestinationPath $artifactUnzipPath -Force
Write-Host "Artifact unzipped successfully to $artifactUnzipPath"
} catch {
Write-Error "Failed to unzip the artifact: $_"
exit 1
}
# Find the installer or app executable
$artifactInstallerPath = Get-ChildItem -Path $artifactUnzipPath -Filter *.exe -Recurse | Select-Object -First 1
if ($artifactInstallerPath) {
Write-Host "Executable file found: $($artifactInstallerPath.FullName)"
} else {
Write-Error "Executable file not found. Exiting."
exit 1
}
🤖 Prompt for AI Agents
.github/workflows/testdriver.yml around lines 58 to 121: the current script
selects the first artifact by index (artifacts[0]) and declares unused variables
($artifactFileName, $artifactFilePath), which is brittle when multiple artifacts
exist; update the artifact selection to search the returned artifacts array for
the artifact whose name matches the expected artifact name (e.g., "waveterm" or
the exact filename) and use its archive_download_url, remove the unused
$artifactFileName and $artifactFilePath variables, and ensure the rest of the
download/unzip flow uses the selected artifact URL variable.

@sawka sawka merged commit 8874774 into main Sep 12, 2025
5 of 8 checks passed
@sawka sawka deleted the sawka/npm branch September 12, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant