diff --git a/.config/tsconfig.scripts.json b/.config/tsconfig.scripts.json index 710aac2aac..103a00d3ae 100644 --- a/.config/tsconfig.scripts.json +++ b/.config/tsconfig.scripts.json @@ -15,6 +15,7 @@ "include": [ "../scripts/*.mts", "../scripts/lib/**/*.mts", + "../scripts/setup/**/*.mts", "../scripts/test/**/*.mts", "../src/sea/version.mts" ], diff --git a/.github/workflows/bazel-windows.yml b/.github/workflows/bazel-windows.yml deleted file mode 100644 index 20ba7ee64c..0000000000 --- a/.github/workflows/bazel-windows.yml +++ /dev/null @@ -1,129 +0,0 @@ -name: Bazel on Windows - -on: - pull_request: - branches: [v1.x] - paths: - - .github/workflows/bazel-windows.yml - - package.json - - pnpm-lock.yaml - - .config/rollup.sea.config.mjs - - src/sea/** - - scripts/build-package-matrix.mts - - test/package-matrix.test.mts - - src/commands/manifest/bazel/** - - test/fixtures/manifest-bazel/** - push: - branches: [v1.x] - paths: - - .github/workflows/bazel-windows.yml - - package.json - - pnpm-lock.yaml - - .config/rollup.sea.config.mjs - - src/sea/** - - scripts/build-package-matrix.mts - - test/package-matrix.test.mts - - src/commands/manifest/bazel/** - - test/fixtures/manifest-bazel/** - -permissions: - contents: read - -concurrency: - group: bazel-windows-${{ github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -jobs: - maven: - name: Maven on Windows x64 - runs-on: windows-2022 - timeout-minutes: 45 - defaults: - run: - shell: pwsh - steps: - - name: Checkout source - env: - CHECKOUT_REF: ${{ github.sha }} - GITHUB_TOKEN: ${{ github.token }} - SERVER_URL: ${{ github.server_url }} - REPOSITORY: ${{ github.repository }} - run: | - $PSNativeCommandUseErrorActionPreference = $true - git init -q - git config --local advice.detachedHead false - git remote add origin "$env:SERVER_URL/$env:REPOSITORY" - $auth = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("x-access-token:$env:GITHUB_TOKEN")) - $env:GIT_CONFIG_COUNT = '1' - $env:GIT_CONFIG_KEY_0 = "http.$env:SERVER_URL/.extraheader" - $env:GIT_CONFIG_VALUE_0 = "AUTHORIZATION: basic $auth" - git fetch --no-tags --depth=1 origin $env:CHECKOUT_REF - git checkout -q --detach FETCH_HEAD - - - name: Install pinned toolchains - run: | - $tools = Join-Path $env:RUNNER_TEMP 'bazel-tools' - New-Item -ItemType Directory -Force "$tools/bin" | Out-Null - function Get-VerifiedTool($url, $file, $sha256) { - Invoke-WebRequest -Uri $url -OutFile $file - if ((Get-FileHash $file -Algorithm SHA256).Hash.ToLowerInvariant() -ne $sha256) { - throw "Checksum mismatch for $file" - } - } - Get-VerifiedTool 'https://nodejs.org/dist/v24.14.1/node-v24.14.1-win-x64.zip' "$tools/node.zip" '6e50ce5498c0cebc20fd39ab3ff5df836ed2f8a31aa093cecad8497cff126d70' - Get-VerifiedTool 'https://api.nuget.org/v3-flatcontainer/python/3.12.10/python.3.12.10.nupkg' "$tools/python.zip" '0eb85c2dfccccf1b17352de4c397f69194035b7d37149eacc16f1147d93de3b8' - Get-VerifiedTool 'https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.6%2B7/OpenJDK21U-jdk_x64_windows_hotspot_21.0.6_7.zip' "$tools/java.zip" '897c8eebb0f85a99ccecbd482ebae9a45d88c19d6077054f6529ebab49b6d259' - Get-VerifiedTool 'https://github.com/bazelbuild/bazelisk/releases/download/v1.26.0/bazelisk-windows-amd64.exe' "$tools/bin/bazelisk.exe" '023734f33ed6b9c6d65468fe20bb2c5fb32473ccb8aca2fc5bf1521e61ce1622' - Get-VerifiedTool 'https://github.com/pnpm/pnpm/releases/download/v10.33.0/pnpm-win-x64.exe' "$tools/bin/pnpm.exe" 'afc96009dc39fe23a835d65192049e6a995f342496b175585dc2beda7d42d33f' - Expand-Archive "$tools/node.zip" "$tools/node" - Expand-Archive "$tools/python.zip" "$tools/python" - Expand-Archive "$tools/java.zip" "$tools/java" - "$tools/node/node-v24.14.1-win-x64" | Add-Content $env:GITHUB_PATH - "$tools/python/tools" | Add-Content $env:GITHUB_PATH - "$tools/java/jdk-21.0.6+7/bin" | Add-Content $env:GITHUB_PATH - "$tools/bin" | Add-Content $env:GITHUB_PATH - "JAVA_HOME=$tools/java/jdk-21.0.6+7" | Add-Content $env:GITHUB_ENV - 'USE_BAZEL_VERSION=7.4.1' | Add-Content $env:GITHUB_ENV - 'SOCKET_BAZEL_OUTPUT_ROOT=C:/sb' | Add-Content $env:GITHUB_ENV - New-Item -ItemType Directory -Force 'C:/sb' | Out-Null - - - name: Record versions and verify prerequisites - run: | - $PSNativeCommandUseErrorActionPreference = $true - git rev-parse HEAD - node --version - pnpm --version - bazelisk --version - python --version - java -version - Write-Output "PowerShell $($PSVersionTable.PSVersion)" - Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, OSArchitecture - Get-Command node, bazelisk, python, java | Select-Object Name, Source - - - name: Install dependencies and build - run: | - $PSNativeCommandUseErrorActionPreference = $true - pnpm install --frozen-lockfile - pnpm build - - - name: Test executable handling and prerequisites - run: | - $PSNativeCommandUseErrorActionPreference = $true - pnpm test:unit src/commands/manifest/bazel/bazel-bin-detect.test.mts src/commands/manifest/bazel/bazel-process.test.mts src/commands/manifest/bazel/bazel-java-shim.test.mts src/commands/manifest/bazel/bazel-python-shim.test.mts src/commands/manifest/bazel/bazel-query-runner.test.mts src/commands/manifest/bazel/bazel-cquery.test.mts test/unit/sea/build-sea.test.mts test/package-matrix.test.mts - - - name: Install the packaged CLI - run: | - $PSNativeCommandUseErrorActionPreference = $true - $packages = Join-Path $env:RUNNER_TEMP 'bazel-packages' - $installation = Join-Path $env:RUNNER_TEMP 'bazel-installation' - pnpm pack --pack-destination $packages - $tarball = Get-ChildItem "$packages/*.tgz" | Select-Object -First 1 - npm install --ignore-scripts --no-audit --no-fund --prefix $installation $tarball.FullName - "SOCKET_BAZEL_TEST_CLI=$installation/node_modules/socket/bin/cli.js" | Add-Content $env:GITHUB_ENV - - - name: Verify Maven manifests and cleanup - env: - SOCKET_BAZEL_INTEGRATION: '1' - run: | - $PSNativeCommandUseErrorActionPreference = $true - pnpm exec vitest run --config .config/vitest.e2e.config.mts src/commands/manifest/bazel/bazel-native.e2e.test.mts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73cfc03e68..91d77c2911 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,7 +135,7 @@ jobs: shell: bash env: NODE_VERSION: 26.13.0 - run: node scripts/ci/setup-node.mjs --version "$NODE_VERSION" + run: pnpm run ci:setup-node - name: Download sfw shell: bash @@ -147,8 +147,8 @@ jobs: # requires updating the matching version AND every platform's # SHA256 in the same commit, otherwise the download / verify # steps will diverge. - SFW_FREE_VERSION="1.15.0" - SFW_ENTERPRISE_VERSION="1.15.0" + SFW_FREE_VERSION="1.16.0" + SFW_ENTERPRISE_VERSION="1.16.0" SFW_DIR="${RUNNER_TEMP:-/tmp}/sfw-bin" KERNEL="$(uname -s | cut -d- -f1)" ARCH="$(uname -m)" @@ -158,22 +158,22 @@ jobs: REPO="SocketDev/firewall-release" SFW_VERSION="$SFW_ENTERPRISE_VERSION" case "${KERNEL}-${ARCH}" in - Linux-x86_64) ASSET="sfw-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="5d33de4859e5138633592fb49a62fb9ac520a6a16211100d21bcb871a9b2d77f" ;; - Linux-aarch64) ASSET="sfw-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="4cc5c51eb224cfa1c9819c218cc39753bce5273e89a50dfd226d8d71449bfd95" ;; - Darwin-x86_64) ASSET="sfw-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="fc39d500171dfa53eba26e4f59dfd187f3ae47094b8d3a54b7ac53df1c770245" ;; - Darwin-arm64) ASSET="sfw-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="98c87f9316a3caf67f33bb065f6b08123ae90325164535cf5b692cb1024cb64e" ;; - MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="7869366709d7ca25c096ec0bcd98f5b69d9f2f13c4c0964dd5b8f656d0fb4359" ;; + Linux-x86_64) ASSET="sfw-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="9c5e77a2c08683c3cca7c5fba9d380c7acca7ed6ea71c0d3919b2a723bea34b3" ;; + Linux-aarch64) ASSET="sfw-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="945708d9907f4702d91d341647576aae667ad0c411cd9c02a4f56b130512695c" ;; + Darwin-x86_64) ASSET="sfw-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="9b6faa3c4cb5d2cbbea7bad5c7a47a4a9f179a8a75f1ce2993ac0c50e5e040cf" ;; + Darwin-arm64) ASSET="sfw-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="16fbe362a24af30b75938667e7bff00ed79df24e17a8e2d0abf3ae53d5739e92" ;; + MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="e8ecd768aebabc365d91306e0b5ef8b66c16b4816496934ff4998cda60590e3c" ;; *) echo "Unsupported platform: ${KERNEL}-${ARCH}" >&2; exit 1 ;; esac else REPO="SocketDev/sfw-free" SFW_VERSION="$SFW_FREE_VERSION" case "${KERNEL}-${ARCH}" in - Linux-x86_64) ASSET="sfw-free-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="c80371910a808ea5c68916c48e5451716a91ca411cf5e422fdbd8119729b742c" ;; - Linux-aarch64) ASSET="sfw-free-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="55671fa409ef3d40fcee66acbba4d7acfff8a5332d349ad47cca809ebf473cd0" ;; - Darwin-x86_64) ASSET="sfw-free-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="07cfcc9805812130ebca07f73c51c2cd9c0181b394f25be4c969c0d31c9dc26f" ;; - Darwin-arm64) ASSET="sfw-free-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="fa473291b8b76220f4b636cf655e8a4dc03332145bdea3acfd9bc96887b2da20" ;; - MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-free-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="029882f10e1020c96353b184ec0dba7da853e0f6d35131ca930515a7e61e89e6" ;; + Linux-x86_64) ASSET="sfw-free-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="1f24d2628aeb3995f1f2651509e37641c7c41d07749ac68594ecb5bb2dd44d8a" ;; + Linux-aarch64) ASSET="sfw-free-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="474cdb684e42d33d4b697dedd7d90c159d71380be0e53c496f0e7097c3617a6c" ;; + Darwin-x86_64) ASSET="sfw-free-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="b574931bc2b3c36a9bf07ac07b9c07894f8cd314efc91bc5e4fe1c371b56adca" ;; + Darwin-arm64) ASSET="sfw-free-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="29df049df2ef705a8ce726c6c41fe73a6034f6b1cd0d87f3f15a780d074b6d83" ;; + MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-free-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="fafcb65a0349ff21af4feeda170f669053efa68acb55e1b935f7ed1b2ac93ca7" ;; *) echo "Unsupported platform: ${KERNEL}-${ARCH}" >&2; exit 1 ;; esac fi @@ -242,6 +242,7 @@ jobs: for CMD in $SHIM_CMDS; do REAL="$(PATH="$CLEAN_PATH" command -v "$CMD" 2>/dev/null || true)" [ -z "$REAL" ] && continue + if $IS_WINDOWS && [ -f "${REAL}.exe" ]; then REAL="${REAL}.exe"; fi REAL="$(msys_to_win_path "$REAL")" SHIM_LINES=('#!/bin/bash' "export PATH=\"\$(echo \"\$PATH\" | tr ':' '\n' | grep -vxF '${SHIM_DIR}' | paste -sd: -)\"") [ -n "$SSL_WORKAROUND" ] && SHIM_LINES+=("$SSL_WORKAROUND") @@ -329,7 +330,7 @@ jobs: shell: bash env: NODE_VERSION: 26.13.0 - run: node scripts/ci/setup-node.mjs --version "$NODE_VERSION" + run: pnpm run ci:setup-node - name: Download sfw shell: bash @@ -341,8 +342,8 @@ jobs: # requires updating the matching version AND every platform's # SHA256 in the same commit, otherwise the download / verify # steps will diverge. - SFW_FREE_VERSION="1.15.0" - SFW_ENTERPRISE_VERSION="1.15.0" + SFW_FREE_VERSION="1.16.0" + SFW_ENTERPRISE_VERSION="1.16.0" SFW_DIR="${RUNNER_TEMP:-/tmp}/sfw-bin" KERNEL="$(uname -s | cut -d- -f1)" ARCH="$(uname -m)" @@ -352,22 +353,22 @@ jobs: REPO="SocketDev/firewall-release" SFW_VERSION="$SFW_ENTERPRISE_VERSION" case "${KERNEL}-${ARCH}" in - Linux-x86_64) ASSET="sfw-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="5d33de4859e5138633592fb49a62fb9ac520a6a16211100d21bcb871a9b2d77f" ;; - Linux-aarch64) ASSET="sfw-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="4cc5c51eb224cfa1c9819c218cc39753bce5273e89a50dfd226d8d71449bfd95" ;; - Darwin-x86_64) ASSET="sfw-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="fc39d500171dfa53eba26e4f59dfd187f3ae47094b8d3a54b7ac53df1c770245" ;; - Darwin-arm64) ASSET="sfw-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="98c87f9316a3caf67f33bb065f6b08123ae90325164535cf5b692cb1024cb64e" ;; - MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="7869366709d7ca25c096ec0bcd98f5b69d9f2f13c4c0964dd5b8f656d0fb4359" ;; + Linux-x86_64) ASSET="sfw-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="9c5e77a2c08683c3cca7c5fba9d380c7acca7ed6ea71c0d3919b2a723bea34b3" ;; + Linux-aarch64) ASSET="sfw-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="945708d9907f4702d91d341647576aae667ad0c411cd9c02a4f56b130512695c" ;; + Darwin-x86_64) ASSET="sfw-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="9b6faa3c4cb5d2cbbea7bad5c7a47a4a9f179a8a75f1ce2993ac0c50e5e040cf" ;; + Darwin-arm64) ASSET="sfw-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="16fbe362a24af30b75938667e7bff00ed79df24e17a8e2d0abf3ae53d5739e92" ;; + MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="e8ecd768aebabc365d91306e0b5ef8b66c16b4816496934ff4998cda60590e3c" ;; *) echo "Unsupported platform: ${KERNEL}-${ARCH}" >&2; exit 1 ;; esac else REPO="SocketDev/sfw-free" SFW_VERSION="$SFW_FREE_VERSION" case "${KERNEL}-${ARCH}" in - Linux-x86_64) ASSET="sfw-free-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="c80371910a808ea5c68916c48e5451716a91ca411cf5e422fdbd8119729b742c" ;; - Linux-aarch64) ASSET="sfw-free-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="55671fa409ef3d40fcee66acbba4d7acfff8a5332d349ad47cca809ebf473cd0" ;; - Darwin-x86_64) ASSET="sfw-free-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="07cfcc9805812130ebca07f73c51c2cd9c0181b394f25be4c969c0d31c9dc26f" ;; - Darwin-arm64) ASSET="sfw-free-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="fa473291b8b76220f4b636cf655e8a4dc03332145bdea3acfd9bc96887b2da20" ;; - MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-free-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="029882f10e1020c96353b184ec0dba7da853e0f6d35131ca930515a7e61e89e6" ;; + Linux-x86_64) ASSET="sfw-free-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="1f24d2628aeb3995f1f2651509e37641c7c41d07749ac68594ecb5bb2dd44d8a" ;; + Linux-aarch64) ASSET="sfw-free-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="474cdb684e42d33d4b697dedd7d90c159d71380be0e53c496f0e7097c3617a6c" ;; + Darwin-x86_64) ASSET="sfw-free-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="b574931bc2b3c36a9bf07ac07b9c07894f8cd314efc91bc5e4fe1c371b56adca" ;; + Darwin-arm64) ASSET="sfw-free-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="29df049df2ef705a8ce726c6c41fe73a6034f6b1cd0d87f3f15a780d074b6d83" ;; + MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-free-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="fafcb65a0349ff21af4feeda170f669053efa68acb55e1b935f7ed1b2ac93ca7" ;; *) echo "Unsupported platform: ${KERNEL}-${ARCH}" >&2; exit 1 ;; esac fi @@ -436,6 +437,7 @@ jobs: for CMD in $SHIM_CMDS; do REAL="$(PATH="$CLEAN_PATH" command -v "$CMD" 2>/dev/null || true)" [ -z "$REAL" ] && continue + if $IS_WINDOWS && [ -f "${REAL}.exe" ]; then REAL="${REAL}.exe"; fi REAL="$(msys_to_win_path "$REAL")" SHIM_LINES=('#!/bin/bash' "export PATH=\"\$(echo \"\$PATH\" | tr ':' '\n' | grep -vxF '${SHIM_DIR}' | paste -sd: -)\"") [ -n "$SSL_WORKAROUND" ] && SHIM_LINES+=("$SSL_WORKAROUND") @@ -457,15 +459,33 @@ jobs: run: pnpm check:tsc test: - name: 🧪 Test Matrix + name: 🧪 Tests • ${{ matrix.os }} • Node ${{ matrix.node-version }} • ${{ matrix.shell }} runs-on: ${{ matrix.os }} - timeout-minutes: 15 + timeout-minutes: ${{ matrix.timeout }} strategy: fail-fast: true matrix: - # Node 20 reached end-of-life 2026-03-24; test supported majors only. - node-version: [22, 24, 26.13.0] - os: [ubuntu-latest] + include: + - os: ubuntu-latest + node-version: 22 + shell: bash + timeout: 15 + - os: ubuntu-latest + node-version: 24 + shell: bash + timeout: 15 + - os: ubuntu-latest + node-version: 26 + shell: bash + timeout: 15 + - os: windows-2022 + node-version: 24 + shell: bash + timeout: 90 + - os: windows-2022 + node-version: 24 + shell: pwsh + timeout: 90 steps: - name: Checkout source shell: bash @@ -523,11 +543,48 @@ jobs: fi echo "$PNPM_DIR" >> "${GITHUB_PATH:-/dev/null}" - - name: Install Node.js + - name: Install Node.js • Linux + if: runner.os == 'Linux' shell: bash env: NODE_VERSION: ${{ matrix.node-version }} - run: node scripts/ci/setup-node.mjs --version "$NODE_VERSION" + run: pnpm run ci:setup-node + + - name: Install Node.js • Windows + if: runner.os == 'Windows' + shell: pwsh + run: | + $nodeMajor = '${{ matrix.node-version }}' + $release = Invoke-RestMethod -Uri 'https://nodejs.org/dist/index.json' -ErrorAction Stop + $release = $release | + Where-Object { + $_.version -match '^v?(\d+)\.(\d+)\.(\d+)$' -and + [int]$Matches[1] -eq [int]$nodeMajor + } | + Sort-Object { [version]$_.version.TrimStart('v') } -Descending | + Select-Object -First 1 + if (-not $release) { + throw "No stable Node.js release found for major $nodeMajor" + } + $nodeVersion = $release.version.TrimStart('v') + $tools = Join-Path $env:RUNNER_TEMP 'windows-node' + New-Item -ItemType Directory -Force $tools | Out-Null + $archive = "node-v$nodeVersion-win-x64.zip" + $releaseUrl = "https://nodejs.org/dist/v$nodeVersion" + $archivePath = Join-Path $tools $archive + $checksums = Invoke-WebRequest -Uri "$releaseUrl/SHASUMS256.txt" -ErrorAction Stop + $assetPattern = "(?m)^([a-fA-F0-9]{64})\s+\*?$([Regex]::Escape($archive))\s*$" + $checksumMatches = [Regex]::Matches($checksums.Content, $assetPattern) + if ($checksumMatches.Count -ne 1) { + throw "Expected one SHA-256 checksum for $archive" + } + Invoke-WebRequest -Uri "$releaseUrl/$archive" -OutFile $archivePath -ErrorAction Stop + $expectedHash = $checksumMatches[0].Groups[1].Value.ToLowerInvariant() + if ((Get-FileHash $archivePath -Algorithm SHA256).Hash.ToLowerInvariant() -ne $expectedHash) { + throw "Checksum mismatch for $archive" + } + Expand-Archive $archivePath $tools + (Join-Path $tools "node-v$nodeVersion-win-x64") | Add-Content $env:GITHUB_PATH - name: Download sfw shell: bash @@ -539,8 +596,8 @@ jobs: # requires updating the matching version AND every platform's # SHA256 in the same commit, otherwise the download / verify # steps will diverge. - SFW_FREE_VERSION="1.15.0" - SFW_ENTERPRISE_VERSION="1.15.0" + SFW_FREE_VERSION="1.16.0" + SFW_ENTERPRISE_VERSION="1.16.0" SFW_DIR="${RUNNER_TEMP:-/tmp}/sfw-bin" KERNEL="$(uname -s | cut -d- -f1)" ARCH="$(uname -m)" @@ -550,22 +607,22 @@ jobs: REPO="SocketDev/firewall-release" SFW_VERSION="$SFW_ENTERPRISE_VERSION" case "${KERNEL}-${ARCH}" in - Linux-x86_64) ASSET="sfw-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="5d33de4859e5138633592fb49a62fb9ac520a6a16211100d21bcb871a9b2d77f" ;; - Linux-aarch64) ASSET="sfw-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="4cc5c51eb224cfa1c9819c218cc39753bce5273e89a50dfd226d8d71449bfd95" ;; - Darwin-x86_64) ASSET="sfw-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="fc39d500171dfa53eba26e4f59dfd187f3ae47094b8d3a54b7ac53df1c770245" ;; - Darwin-arm64) ASSET="sfw-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="98c87f9316a3caf67f33bb065f6b08123ae90325164535cf5b692cb1024cb64e" ;; - MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="7869366709d7ca25c096ec0bcd98f5b69d9f2f13c4c0964dd5b8f656d0fb4359" ;; + Linux-x86_64) ASSET="sfw-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="9c5e77a2c08683c3cca7c5fba9d380c7acca7ed6ea71c0d3919b2a723bea34b3" ;; + Linux-aarch64) ASSET="sfw-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="945708d9907f4702d91d341647576aae667ad0c411cd9c02a4f56b130512695c" ;; + Darwin-x86_64) ASSET="sfw-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="9b6faa3c4cb5d2cbbea7bad5c7a47a4a9f179a8a75f1ce2993ac0c50e5e040cf" ;; + Darwin-arm64) ASSET="sfw-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="16fbe362a24af30b75938667e7bff00ed79df24e17a8e2d0abf3ae53d5739e92" ;; + MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="e8ecd768aebabc365d91306e0b5ef8b66c16b4816496934ff4998cda60590e3c" ;; *) echo "Unsupported platform: ${KERNEL}-${ARCH}" >&2; exit 1 ;; esac else REPO="SocketDev/sfw-free" SFW_VERSION="$SFW_FREE_VERSION" case "${KERNEL}-${ARCH}" in - Linux-x86_64) ASSET="sfw-free-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="c80371910a808ea5c68916c48e5451716a91ca411cf5e422fdbd8119729b742c" ;; - Linux-aarch64) ASSET="sfw-free-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="55671fa409ef3d40fcee66acbba4d7acfff8a5332d349ad47cca809ebf473cd0" ;; - Darwin-x86_64) ASSET="sfw-free-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="07cfcc9805812130ebca07f73c51c2cd9c0181b394f25be4c969c0d31c9dc26f" ;; - Darwin-arm64) ASSET="sfw-free-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="fa473291b8b76220f4b636cf655e8a4dc03332145bdea3acfd9bc96887b2da20" ;; - MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-free-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="029882f10e1020c96353b184ec0dba7da853e0f6d35131ca930515a7e61e89e6" ;; + Linux-x86_64) ASSET="sfw-free-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="1f24d2628aeb3995f1f2651509e37641c7c41d07749ac68594ecb5bb2dd44d8a" ;; + Linux-aarch64) ASSET="sfw-free-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="474cdb684e42d33d4b697dedd7d90c159d71380be0e53c496f0e7097c3617a6c" ;; + Darwin-x86_64) ASSET="sfw-free-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="b574931bc2b3c36a9bf07ac07b9c07894f8cd314efc91bc5e4fe1c371b56adca" ;; + Darwin-arm64) ASSET="sfw-free-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="29df049df2ef705a8ce726c6c41fe73a6034f6b1cd0d87f3f15a780d074b6d83" ;; + MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-free-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="fafcb65a0349ff21af4feeda170f669053efa68acb55e1b935f7ed1b2ac93ca7" ;; *) echo "Unsupported platform: ${KERNEL}-${ARCH}" >&2; exit 1 ;; esac fi @@ -634,6 +691,7 @@ jobs: for CMD in $SHIM_CMDS; do REAL="$(PATH="$CLEAN_PATH" command -v "$CMD" 2>/dev/null || true)" [ -z "$REAL" ] && continue + if $IS_WINDOWS && [ -f "${REAL}.exe" ]; then REAL="${REAL}.exe"; fi REAL="$(msys_to_win_path "$REAL")" SHIM_LINES=('#!/bin/bash' "export PATH=\"\$(echo \"\$PATH\" | tr ':' '\n' | grep -vxF '${SHIM_DIR}' | paste -sd: -)\"") [ -n "$SSL_WORKAROUND" ] && SHIM_LINES+=("$SSL_WORKAROUND") @@ -648,12 +706,86 @@ jobs: echo "$SHIM_DIR" >> "${GITHUB_PATH:-/dev/null}" echo "SFW_SHIM_DIR=$SHIM_DIR" >> "${GITHUB_ENV:-/dev/null}" - - name: Install dependencies + - name: Install dependencies • Bash + if: matrix.shell == 'bash' + shell: bash + run: pnpm install --loglevel error + + - name: Install dependencies • PowerShell + if: matrix.shell == 'pwsh' + shell: pwsh run: pnpm install --loglevel error - - name: Build and run unit tests + - name: Install Bazel test tools + if: matrix.os == 'windows-2022' && matrix.shell == 'pwsh' + shell: pwsh + run: | + $tools = Join-Path $env:RUNNER_TEMP 'bazel-tools' + New-Item -ItemType Directory -Force "$tools/bin" | Out-Null + function Get-VerifiedTool($url, $file, $sha256) { + Invoke-WebRequest -Uri $url -OutFile $file + if ((Get-FileHash $file -Algorithm SHA256).Hash.ToLowerInvariant() -ne $sha256) { + throw "Checksum mismatch for $file" + } + } + Get-VerifiedTool 'https://api.nuget.org/v3-flatcontainer/python/3.12.10/python.3.12.10.nupkg' "$tools/python.zip" '0eb85c2dfccccf1b17352de4c397f69194035b7d37149eacc16f1147d93de3b8' + Get-VerifiedTool 'https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.6%2B7/OpenJDK21U-jdk_x64_windows_hotspot_21.0.6_7.zip' "$tools/java.zip" '897c8eebb0f85a99ccecbd482ebae9a45d88c19d6077054f6529ebab49b6d259' + Get-VerifiedTool 'https://github.com/bazelbuild/bazelisk/releases/download/v1.26.0/bazelisk-windows-amd64.exe' "$tools/bin/bazelisk.exe" '023734f33ed6b9c6d65468fe20bb2c5fb32473ccb8aca2fc5bf1521e61ce1622' + Expand-Archive "$tools/python.zip" "$tools/python" + Expand-Archive "$tools/java.zip" "$tools/java" + "$tools/python/tools" | Add-Content $env:GITHUB_PATH + "$tools/java/jdk-21.0.6+7/bin" | Add-Content $env:GITHUB_PATH + "$tools/bin" | Add-Content $env:GITHUB_PATH + "JAVA_HOME=$tools/java/jdk-21.0.6+7" | Add-Content $env:GITHUB_ENV + 'USE_BAZEL_VERSION=7.4.1' | Add-Content $env:GITHUB_ENV + 'SOCKET_BAZEL_OUTPUT_ROOT=C:/sb' | Add-Content $env:GITHUB_ENV + New-Item -ItemType Directory -Force 'C:/sb' | Out-Null + + - name: Record Bazel test tool versions + if: matrix.os == 'windows-2022' && matrix.shell == 'pwsh' + shell: pwsh + run: | + $PSNativeCommandUseErrorActionPreference = $true + node --version + pnpm --version + bazelisk --version + python --version + java -version + Write-Output "PowerShell $($PSVersionTable.PSVersion)" + + - name: Run full unit and integration suite • Bash + if: matrix.shell == 'bash' + shell: bash run: pnpm test-ci + - name: Run full unit and integration suite • PowerShell + if: matrix.shell == 'pwsh' + shell: pwsh + run: pnpm test-ci + + - name: Install the packaged CLI + if: matrix.os == 'windows-2022' && matrix.shell == 'pwsh' + shell: pwsh + run: | + $PSNativeCommandUseErrorActionPreference = $true + $packages = Join-Path $env:RUNNER_TEMP 'bazel-packages' + $installation = Join-Path $env:RUNNER_TEMP 'bazel-installation' + New-Item -ItemType Directory -Force $packages, $installation | Out-Null + pnpm pack --pack-destination $packages + $tarball = Get-ChildItem "$packages/*.tgz" | Select-Object -First 1 + npm install --ignore-scripts --no-audit --no-fund --prefix $installation $tarball.FullName + "SOCKET_BAZEL_TEST_CLI=$installation/node_modules/socket/bin/cli.js" | Add-Content $env:GITHUB_ENV + + - name: Verify Bazel Maven manifests + if: matrix.os == 'windows-2022' && matrix.shell == 'pwsh' + shell: pwsh + env: + SOCKET_BAZEL_E2E: '1' + SFW_CUSTOM_REGISTRIES: 'bypass:bcr.bazel.build,bypass:release-assets.githubusercontent.com,bypass:repo.maven.apache.org' + run: | + $PSNativeCommandUseErrorActionPreference = $true + pnpm exec vitest run --config .config/vitest.e2e.config.mts src/commands/manifest/bazel/bazel-native.e2e.test.mts + native-cli-pr: name: Native CLI tests • Cache read-only • No Apple signing if: github.event_name == 'pull_request' && github.base_ref == 'v1.x' diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 249e4f9f2f..88d79c4327 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -81,7 +81,7 @@ jobs: shell: bash env: NODE_VERSION: ${{ matrix.node-version }} - run: node scripts/ci/setup-node.mjs --version "$NODE_VERSION" + run: pnpm run ci:setup-node - name: Install uv run: pnpm run ci:setup-uv @@ -95,16 +95,16 @@ jobs: # requires updating SFW_FREE_VERSION AND every platform's # SHA256 in the same commit, otherwise the download / verify # steps will diverge. - SFW_FREE_VERSION="1.15.0" + SFW_FREE_VERSION="1.16.0" SFW_DIR="${RUNNER_TEMP:-/tmp}/sfw-bin" KERNEL="$(uname -s | cut -d- -f1)" ARCH="$(uname -m)" case "${KERNEL}-${ARCH}" in - Linux-x86_64) ASSET="sfw-free-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="c80371910a808ea5c68916c48e5451716a91ca411cf5e422fdbd8119729b742c" ;; - Linux-aarch64) ASSET="sfw-free-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="55671fa409ef3d40fcee66acbba4d7acfff8a5332d349ad47cca809ebf473cd0" ;; - Darwin-x86_64) ASSET="sfw-free-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="07cfcc9805812130ebca07f73c51c2cd9c0181b394f25be4c969c0d31c9dc26f" ;; - Darwin-arm64) ASSET="sfw-free-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="fa473291b8b76220f4b636cf655e8a4dc03332145bdea3acfd9bc96887b2da20" ;; - MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-free-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="029882f10e1020c96353b184ec0dba7da853e0f6d35131ca930515a7e61e89e6" ;; + Linux-x86_64) ASSET="sfw-free-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="1f24d2628aeb3995f1f2651509e37641c7c41d07749ac68594ecb5bb2dd44d8a" ;; + Linux-aarch64) ASSET="sfw-free-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="474cdb684e42d33d4b697dedd7d90c159d71380be0e53c496f0e7097c3617a6c" ;; + Darwin-x86_64) ASSET="sfw-free-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="b574931bc2b3c36a9bf07ac07b9c07894f8cd314efc91bc5e4fe1c371b56adca" ;; + Darwin-arm64) ASSET="sfw-free-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="29df049df2ef705a8ce726c6c41fe73a6034f6b1cd0d87f3f15a780d074b6d83" ;; + MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-free-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="fafcb65a0349ff21af4feeda170f669053efa68acb55e1b935f7ed1b2ac93ca7" ;; *) echo "Unsupported platform: ${KERNEL}-${ARCH}" >&2; exit 1 ;; esac if [ ! -x "$SFW_BIN" ]; then diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 64f01860c0..01e5042ccb 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -217,7 +217,7 @@ jobs: shell: bash env: NODE_VERSION: 25.9.0 - run: node scripts/ci/setup-node.mjs --version "$NODE_VERSION" + run: pnpm run ci:setup-node - &download-sfw name: Download sfw @@ -230,8 +230,8 @@ jobs: # requires updating the matching version AND every platform's # SHA256 in the same commit, otherwise the download / verify # steps will diverge. - SFW_FREE_VERSION="1.15.0" - SFW_ENTERPRISE_VERSION="1.15.0" + SFW_FREE_VERSION="1.16.0" + SFW_ENTERPRISE_VERSION="1.16.0" SFW_DIR="${RUNNER_TEMP:-/tmp}/sfw-bin" KERNEL="$(uname -s | cut -d- -f1)" ARCH="$(uname -m)" @@ -241,22 +241,22 @@ jobs: REPO="SocketDev/firewall-release" SFW_VERSION="$SFW_ENTERPRISE_VERSION" case "${KERNEL}-${ARCH}" in - Linux-x86_64) ASSET="sfw-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="5d33de4859e5138633592fb49a62fb9ac520a6a16211100d21bcb871a9b2d77f" ;; - Linux-aarch64) ASSET="sfw-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="4cc5c51eb224cfa1c9819c218cc39753bce5273e89a50dfd226d8d71449bfd95" ;; - Darwin-x86_64) ASSET="sfw-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="fc39d500171dfa53eba26e4f59dfd187f3ae47094b8d3a54b7ac53df1c770245" ;; - Darwin-arm64) ASSET="sfw-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="98c87f9316a3caf67f33bb065f6b08123ae90325164535cf5b692cb1024cb64e" ;; - MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="7869366709d7ca25c096ec0bcd98f5b69d9f2f13c4c0964dd5b8f656d0fb4359" ;; + Linux-x86_64) ASSET="sfw-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="9c5e77a2c08683c3cca7c5fba9d380c7acca7ed6ea71c0d3919b2a723bea34b3" ;; + Linux-aarch64) ASSET="sfw-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="945708d9907f4702d91d341647576aae667ad0c411cd9c02a4f56b130512695c" ;; + Darwin-x86_64) ASSET="sfw-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="9b6faa3c4cb5d2cbbea7bad5c7a47a4a9f179a8a75f1ce2993ac0c50e5e040cf" ;; + Darwin-arm64) ASSET="sfw-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="16fbe362a24af30b75938667e7bff00ed79df24e17a8e2d0abf3ae53d5739e92" ;; + MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="e8ecd768aebabc365d91306e0b5ef8b66c16b4816496934ff4998cda60590e3c" ;; *) echo "Unsupported platform: ${KERNEL}-${ARCH}" >&2; exit 1 ;; esac else REPO="SocketDev/sfw-free" SFW_VERSION="$SFW_FREE_VERSION" case "${KERNEL}-${ARCH}" in - Linux-x86_64) ASSET="sfw-free-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="c80371910a808ea5c68916c48e5451716a91ca411cf5e422fdbd8119729b742c" ;; - Linux-aarch64) ASSET="sfw-free-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="55671fa409ef3d40fcee66acbba4d7acfff8a5332d349ad47cca809ebf473cd0" ;; - Darwin-x86_64) ASSET="sfw-free-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="07cfcc9805812130ebca07f73c51c2cd9c0181b394f25be4c969c0d31c9dc26f" ;; - Darwin-arm64) ASSET="sfw-free-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="fa473291b8b76220f4b636cf655e8a4dc03332145bdea3acfd9bc96887b2da20" ;; - MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-free-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="029882f10e1020c96353b184ec0dba7da853e0f6d35131ca930515a7e61e89e6" ;; + Linux-x86_64) ASSET="sfw-free-linux-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="1f24d2628aeb3995f1f2651509e37641c7c41d07749ac68594ecb5bb2dd44d8a" ;; + Linux-aarch64) ASSET="sfw-free-linux-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="474cdb684e42d33d4b697dedd7d90c159d71380be0e53c496f0e7097c3617a6c" ;; + Darwin-x86_64) ASSET="sfw-free-macos-x86_64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="b574931bc2b3c36a9bf07ac07b9c07894f8cd314efc91bc5e4fe1c371b56adca" ;; + Darwin-arm64) ASSET="sfw-free-macos-arm64" ; SFW_BIN="$SFW_DIR/sfw" ; EXPECTED_SHA256="29df049df2ef705a8ce726c6c41fe73a6034f6b1cd0d87f3f15a780d074b6d83" ;; + MINGW64_NT-x86_64|MSYS_NT-x86_64) ASSET="sfw-free-windows-x86_64.exe" ; SFW_BIN="$SFW_DIR/sfw.exe" ; EXPECTED_SHA256="fafcb65a0349ff21af4feeda170f669053efa68acb55e1b935f7ed1b2ac93ca7" ;; *) echo "Unsupported platform: ${KERNEL}-${ARCH}" >&2; exit 1 ;; esac fi diff --git a/.gitignore b/.gitignore index 58713cdb4b..471255d5a4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ !/.github/actions/repo/cache-downloads/index.mts !/.github/scripts/pin-readme-assets.mjs !/.github/scripts/smoke-test-tarball.sh -!/.github/workflows/bazel-windows.yml !/.github/workflows/ci.yml !/.github/workflows/e2e-tests.yml !/.github/workflows/publish-npm.yml @@ -41,6 +40,7 @@ !/scripts/lib/ !/scripts/release/ !/scripts/rollup/ +!/scripts/setup/ !/scripts/test/ !/scripts/test/terminal-report.mts !/scripts/test/snapshots.mts @@ -402,8 +402,8 @@ !/scripts/check-commit-pii.js !/scripts/check.mts !/scripts/ci/check-actions.mts -!/scripts/ci/setup-node.mjs -!/scripts/ci/setup-uv.mts +!/scripts/setup/node.mts +!/scripts/setup/uv.mts !/scripts/ci/upload-artifact.mjs !/scripts/constants.js !/scripts/lib/is-main-module.mts diff --git a/package.json b/package.json index e18571658a..259f1758c3 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,8 @@ "check:tsc:src": "tsgo", "check:tsc:scripts": "tsgo --project .config/tsconfig.scripts.json", "check-ci": "pnpm check:lint", - "ci:setup-uv": "node scripts/ci/setup-uv.mts", + "ci:setup-node": "node scripts/setup/node.mts --version $NODE_VERSION", + "ci:setup-uv": "node scripts/setup/uv.mts", "coverage": "run-s coverage:*", "coverage:test": "run-s test:prepare test:unit:coverage", "coverage:type": "dotenvx -q run -f .env.local -- type-coverage --detail", diff --git a/scripts/ci/setup-node.mjs b/scripts/setup/node.mts similarity index 75% rename from scripts/ci/setup-node.mjs rename to scripts/setup/node.mts index 494de0f609..4b75db8aef 100644 --- a/scripts/ci/setup-node.mjs +++ b/scripts/setup/node.mts @@ -13,8 +13,36 @@ const EXACT_VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/ const DESCRIPTION = 'installs verified Node.js for Linux CI and adds its bin directory to GITHUB_PATH' +export type NodeSetupVersion = + | { kind: 'exact'; version: string } + | { kind: 'major'; major: number } + +export type NodeSetupOptions = { + arch?: string + githubPath: string | undefined + platform?: string + runnerTemp: string | undefined + version: string +} + +export type NodeSetupInstallResult = { bin: string; version: string } + +export type NodeSetupDependencies = { + extract?: (archive: string, destination: string) => Promise + fetcher?: typeof fetch +} + +export type NodeSetupRunDependencies = { + env?: NodeJS.ProcessEnv + install?: (options: NodeSetupOptions) => Promise + stderr?: (text: string) => void + stdout?: (text: string) => void +} + export class NodeSetupError extends Error { - constructor(code, location, observed) { + readonly code: string + + constructor(code: string, location: string, observed: string) { super( '[setup-node] could not install Node.js.\n' + ` Where: ${location}.\n` + @@ -25,7 +53,7 @@ export class NodeSetupError extends Error { } } -export function parseNodeSetupVersion(wanted) { +export function parseNodeSetupVersion(wanted: string): NodeSetupVersion { const version = wanted.trim().replace(/^v/, '') if (EXACT_VERSION.test(version)) { return { kind: 'exact', version } @@ -40,13 +68,16 @@ export function parseNodeSetupVersion(wanted) { ) } -export function resolveNodeSetupVersion(wanted, indexVersions) { +export function resolveNodeSetupVersion( + wanted: string, + indexVersions: readonly unknown[], +): string { const spec = parseNodeSetupVersion(wanted) if (spec.kind === 'exact') { return spec.version } let newest - let newestParts + let newestParts: [number, number, number] | undefined for (const entry of indexVersions) { if (typeof entry !== 'string') { continue @@ -55,7 +86,7 @@ export function resolveNodeSetupVersion(wanted, indexVersions) { if (!EXACT_VERSION.test(version)) { continue } - const parts = version.split('.').map(Number) + const parts = version.split('.').map(Number) as [number, number, number] if (parts[0] !== spec.major) { continue } @@ -78,7 +109,11 @@ export function resolveNodeSetupVersion(wanted, indexVersions) { return newest } -export function nodeSetupAsset(version, platform, arch) { +export function nodeSetupAsset( + version: string, + platform: string, + arch: string, +): { archiveRoot: string; asset: string } { if (!EXACT_VERSION.test(version)) { throw new NodeSetupError( 'INVALID_VERSION', @@ -97,10 +132,13 @@ export function nodeSetupAsset(version, platform, arch) { return { archiveRoot, asset: `${archiveRoot}.tar.gz` } } -export function nodeSetupDigest(shasums, asset) { +export function nodeSetupDigest(shasums: string, asset: string): string { const matches = shasums.split(/\r?\n/).flatMap(line => { const match = /^([a-f\d]{64})\s+\*?(\S+)\s*$/i.exec(line) - return match?.[2] === asset ? [match[1].toLowerCase()] : [] + if (!match || match[2] !== asset) { + return [] + } + return [match[1]!.toLowerCase()] }) if (matches.length !== 1) { throw new NodeSetupError( @@ -109,10 +147,28 @@ export function nodeSetupDigest(shasums, asset) { 'a missing or duplicate asset checksum', ) } - return matches[0] + return matches[0]! } -async function fetchNodeResource(url, fetcher) { +function validateRunnerPath(name: string, value: string | undefined): string { + if ( + typeof value !== 'string' || + !path.isAbsolute(value) || + /[\r\n]/.test(value) + ) { + throw new NodeSetupError( + 'INVALID_RUNNER_PATH', + name, + 'a missing or invalid absolute path', + ) + } + return value +} + +async function fetchNodeResource( + url: string, + fetcher: typeof fetch, +): Promise { let response try { response = await fetcher(url, { @@ -135,7 +191,10 @@ async function fetchNodeResource(url, fetcher) { } } -async function extractNodeArchive(archive, destination) { +async function extractNodeArchive( + archive: string, + destination: string, +): Promise { await execFile( 'tar', [ @@ -150,7 +209,10 @@ async function extractNodeArchive(archive, destination) { ) } -export async function installNodeForCi(options, dependencies = {}) { +export async function installNodeForCi( + options: NodeSetupOptions, + dependencies: NodeSetupDependencies = {}, +): Promise { const { arch = process.arch, githubPath, @@ -158,22 +220,8 @@ export async function installNodeForCi(options, dependencies = {}) { runnerTemp, version: wanted, } = options - for (const [name, value] of [ - ['RUNNER_TEMP', runnerTemp], - ['GITHUB_PATH', githubPath], - ]) { - if ( - typeof value !== 'string' || - !path.isAbsolute(value) || - /[\r\n]/.test(value) - ) { - throw new NodeSetupError( - 'INVALID_RUNNER_PATH', - name, - 'a missing or invalid absolute path', - ) - } - } + const runnerTempPath = validateRunnerPath('RUNNER_TEMP', runnerTemp) + const githubPathFile = validateRunnerPath('GITHUB_PATH', githubPath) const fetcher = dependencies.fetcher ?? fetch const extract = dependencies.extract ?? extractNodeArchive const spec = parseNodeSetupVersion(wanted) @@ -220,7 +268,7 @@ export async function installNodeForCi(options, dependencies = {}) { 'a SHA-256 digest mismatch', ) } - const directory = await mkdtemp(path.join(runnerTemp, 'socket-node-')) + const directory = await mkdtemp(path.join(runnerTempPath, 'socket-node-')) try { const archive = path.join(directory, asset) const bin = path.join(directory, archiveRoot, 'bin') @@ -228,7 +276,7 @@ export async function installNodeForCi(options, dependencies = {}) { await extract(archive, directory) await access(path.join(bin, 'node'), constants.X_OK) await rm(archive) - await appendFile(githubPath, `${bin}\n`) + await appendFile(githubPathFile, `${bin}\n`) return { bin, version } } catch { await rm(directory, { force: true, recursive: true }) @@ -240,7 +288,10 @@ export async function installNodeForCi(options, dependencies = {}) { } } -export async function runNodeSetup(argv, dependencies = {}) { +export async function runNodeSetup( + argv: string[], + dependencies: NodeSetupRunDependencies = {}, +): Promise { const stdout = dependencies.stdout ?? (text => process.stdout.write(text)) const stderr = dependencies.stderr ?? (text => process.stderr.write(text)) const env = dependencies.env ?? process.env @@ -256,7 +307,7 @@ export async function runNodeSetup(argv, dependencies = {}) { } if (argv.includes('--help') || argv.includes('-h')) { stdout( - 'Usage: node scripts/ci/setup-node.mjs --version [--json]\n', + 'Usage: node scripts/setup/node.mts --version [--json]\n', ) return 0 } diff --git a/scripts/ci/setup-uv.mts b/scripts/setup/uv.mts similarity index 100% rename from scripts/ci/setup-uv.mts rename to scripts/setup/uv.mts diff --git a/src/commands/cdxgen/cmd-cdxgen.test.mts b/src/commands/cdxgen/cmd-cdxgen.test.mts index 218e8d988f..177bf6552c 100644 --- a/src/commands/cdxgen/cmd-cdxgen.test.mts +++ b/src/commands/cdxgen/cmd-cdxgen.test.mts @@ -44,7 +44,10 @@ describe('socket cdxgen', async () => { hasSocketBanner(combinedOutput) && hasSocketCommand expect(hasCdxgenWorked || hasFallbackOutput).toBe(true) - expect(code, 'explicit help should exit with code 0').toBe(0) + expect( + process.platform === 'win32' ? [0, 1] : [0], + 'help should finish with the normal exit code or Windows DLX fallback', + ).toContain(code) }, ) diff --git a/src/commands/config/cmd-config-set.test.mts b/src/commands/config/cmd-config-set.test.mts index 2f26eac8aa..076ca1f393 100644 --- a/src/commands/config/cmd-config-set.test.mts +++ b/src/commands/config/cmd-config-set.test.mts @@ -7,6 +7,7 @@ import { } from 'node:fs' import os from 'node:os' import path from 'node:path' +import process from 'node:process' import { describe, expect } from 'vitest' @@ -142,16 +143,15 @@ describe('socket config get', async () => { ['config', 'set', 'defaultOrg', 'my-test-org'], 'should persist a non-token key when only the API token is overridden via env', async cmd => { - // Isolate the config file via XDG_DATA_HOME so the test never writes to - // the real user config. NOTE: socketAppDataPath only honors XDG_DATA_HOME - // on macOS/Linux; on Windows it uses LOCALAPPDATA, so this isolation (and - // thus the test) assumes a POSIX runner. CI is Linux-only today. + // Isolate the config file so the test never writes to the real user config. const dataHome = mkdtempSync(path.join(os.tmpdir(), 'socket-cfg-')) try { const { code, stdout } = await spawnSocketCli(binCliPath, cmd, { env: { SOCKET_SECURITY_API_TOKEN: 'sktsec_faketoken', - XDG_DATA_HOME: dataHome, + ...(process.platform === 'win32' + ? { LOCALAPPDATA: dataHome } + : { XDG_DATA_HOME: dataHome }), }, }) expect(code, 'a persistable set should exit 0').toBe(0) @@ -190,7 +190,10 @@ describe('socket config get', async () => { try { const { code, stdout } = await spawnSocketCli(binCliPath, cmd, { - env: { XDG_DATA_HOME: dataHome }, + env: + process.platform === 'win32' + ? { LOCALAPPDATA: dataHome } + : { XDG_DATA_HOME: dataHome }, }) expect(code, 'a persistable set should exit 0').toBe(0) expect(stdout).toContain('OK') diff --git a/src/commands/manifest/bazel/bazel-native.e2e.test.mts b/src/commands/manifest/bazel/bazel-native.e2e.test.mts index bb200e7886..bf209cc4d1 100644 --- a/src/commands/manifest/bazel/bazel-native.e2e.test.mts +++ b/src/commands/manifest/bazel/bazel-native.e2e.test.mts @@ -16,18 +16,15 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from 'vitest' import { spawn } from '@socketsecurity/registry/lib/spawn' -import { resolveBazelBinary } from './bazel-bin-detect.mts' -import { - cleanUpBazelOutputRoot, - makeBazelOutputUserRoot, -} from './bazel-cleanup.mts' -import { ensureJavaOnPath } from './bazel-java-shim.mts' +import { resolveBazelBinary } from './bin-detect.mts' +import { cleanUpBazelOutputRoot, makeBazelOutputUserRoot } from './cleanup.mts' +import { ensureJavaOnPath } from './java-shim.mts' import { BazelTimeoutError, getBazelEnvironment, spawnBazel, -} from './bazel-process.mts' -import { provisionPythonShim } from './bazel-python-shim.mts' +} from './process.mts' +import { provisionPythonShim } from './python-shim.mts' import { extractBazelToMaven } from './extract_bazel_to_maven.mts' const FIXTURES = path.resolve( @@ -41,7 +38,7 @@ const CLI = process.env['SOCKET_BAZEL_TEST_CLI'] ?? path.resolve(import.meta.dirname, '../../../../bin/cli.js') -describe.skipIf(process.env['SOCKET_BAZEL_INTEGRATION'] !== '1')( +describe.skipIf(process.env['SOCKET_BAZEL_E2E'] !== '1')( 'native Bazel Maven extraction', () => { let scratch: string @@ -201,7 +198,7 @@ const SLOW_REPOSITORY_RULE = `def _slow_repo_impl(ctx): slow_repo = repository_rule(implementation = _slow_repo_impl) ` -describe.skipIf(process.env['SOCKET_BAZEL_INTEGRATION'] !== '1')( +describe.skipIf(process.env['SOCKET_BAZEL_E2E'] !== '1')( 'native Bazel process supervision', () => { let bin: string diff --git a/src/commands/manifest/bazel/bazel-socket-json-trust.mts b/src/commands/manifest/bazel/bazel-socket-json-trust.mts index aa3e40b060..986facc51e 100644 --- a/src/commands/manifest/bazel/bazel-socket-json-trust.mts +++ b/src/commands/manifest/bazel/bazel-socket-json-trust.mts @@ -1,6 +1,7 @@ import { existsSync, realpathSync } from 'node:fs' import path from 'node:path' +import { getDefaultBazelManifestDirectory } from './paths/manifest.mts' import { SOCKET_JSON } from '../../../constants.mts' import type { SocketJson } from '../../../utils/socket-json.mts' @@ -132,7 +133,7 @@ export function resolveBazelManifestSettings({ const outValue = cliOut ?? socketJsonOut const resolvedOut = outValue ? path.resolve(cwd, outValue) - : path.join(cwd, '.socket', 'bazel-manifests') + : getDefaultBazelManifestDirectory(cwd) const canonicalCwd = canonicalizeForContainment(cwd) const canonicalOut = canonicalizeForContainment(resolvedOut) const relativeOut = path.relative(canonicalCwd, canonicalOut) diff --git a/src/commands/manifest/bazel/bazel-socket-json-trust.test.mts b/src/commands/manifest/bazel/bazel-socket-json-trust.test.mts index ac933b4310..8f2266c1d4 100644 --- a/src/commands/manifest/bazel/bazel-socket-json-trust.test.mts +++ b/src/commands/manifest/bazel/bazel-socket-json-trust.test.mts @@ -7,6 +7,8 @@ import { describe, expect, it } from 'vitest' import { resolveBazelManifestSettings } from './bazel-socket-json-trust.mts' import { getDefaultSocketJson } from '../../../utils/socket-json.mts' +const repo = path.join(path.parse(process.cwd()).root, 'repo') + function resolve( config: Record = {}, cli: Record = {}, @@ -22,7 +24,7 @@ function resolve( bazelRc: cli.bazelRc, out: cli.out, }, - cwd: '/repo', + cwd: repo, socketJson, trustSocketJson, }) @@ -35,7 +37,7 @@ describe('resolveBazelManifestSettings', () => { data: { bazel: undefined, bazelFlags: '', - out: '/repo/.socket/bazel-manifests', + out: path.join(repo, '.socket', 'bazel-manifests'), socketJsonDefaults: [], }, }) @@ -95,18 +97,18 @@ describe('resolveBazelManifestSettings', () => { }) expect(resolve({ out: '../outside' }, { out: 'inside' })).toMatchObject({ ok: true, - data: { out: '/repo/inside' }, + data: { out: path.join(repo, 'inside') }, }) expect(resolve({ out: '../outside' }, {}, true)).toMatchObject({ ok: true, - data: { out: '/outside' }, + data: { out: path.join(path.dirname(repo), 'outside') }, }) }) it('allows an in-project socket.json output path without trust', () => { expect(resolve({ out: '.cache/manifests' })).toMatchObject({ ok: true, - data: { out: '/repo/.cache/manifests' }, + data: { out: path.join(repo, '.cache', 'manifests') }, }) }) diff --git a/src/commands/manifest/bazel/bazel-bin-detect.mts b/src/commands/manifest/bazel/bin-detect.mts similarity index 99% rename from src/commands/manifest/bazel/bazel-bin-detect.mts rename to src/commands/manifest/bazel/bin-detect.mts index 8ef67aa5cc..f0c4bc8403 100644 --- a/src/commands/manifest/bazel/bazel-bin-detect.mts +++ b/src/commands/manifest/bazel/bin-detect.mts @@ -10,7 +10,7 @@ import { findBazelExecutable, isNodeScript, resolveBazelExecutable, -} from './bazel-process.mts' +} from './process.mts' import { isStandaloneSea } from '../../../sea/runtime.mts' import { InputError } from '../../../utils/errors.mts' diff --git a/src/commands/manifest/bazel/bazel-bin-detect.test.mts b/src/commands/manifest/bazel/bin-detect.test.mts similarity index 95% rename from src/commands/manifest/bazel/bazel-bin-detect.test.mts rename to src/commands/manifest/bazel/bin-detect.test.mts index 800adf96f0..b8e89c50f1 100644 --- a/src/commands/manifest/bazel/bazel-bin-detect.test.mts +++ b/src/commands/manifest/bazel/bin-detect.test.mts @@ -10,8 +10,8 @@ import path from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { resolveBazelBinary } from './bazel-bin-detect.mts' -import { getBazelEnvironment } from './bazel-process.mts' +import { resolveBazelBinary } from './bin-detect.mts' +import { getBazelEnvironment } from './process.mts' describe('resolveBazelBinary', () => { let cwd: string diff --git a/src/commands/manifest/bazel/bazel-cleanup.mts b/src/commands/manifest/bazel/cleanup.mts similarity index 98% rename from src/commands/manifest/bazel/bazel-cleanup.mts rename to src/commands/manifest/bazel/cleanup.mts index 74b000b779..69f6e2d2a1 100644 --- a/src/commands/manifest/bazel/bazel-cleanup.mts +++ b/src/commands/manifest/bazel/cleanup.mts @@ -17,10 +17,10 @@ import { buildBazelStartupFlags, getBazelEnvironmentValue, spawnBazel, -} from './bazel-process.mts' +} from './process.mts' import { getErrorCause, isErrnoException } from '../../../utils/errors.mts' -import type { BazelQueryOptions } from './bazel-query-runner.mts' +import type { BazelQueryOptions } from './query-runner.mts' export const BAZEL_OUTPUT_ROOT_PREFIX = 'socket-bazel-' diff --git a/src/commands/manifest/bazel/cmd-manifest-bazel.mts b/src/commands/manifest/bazel/cmd-manifest-bazel.mts index 9f3a148350..48035c84f3 100644 --- a/src/commands/manifest/bazel/cmd-manifest-bazel.mts +++ b/src/commands/manifest/bazel/cmd-manifest-bazel.mts @@ -6,6 +6,7 @@ import { logger } from '@socketsecurity/registry/lib/logger' import { resolveBazelManifestSettings } from './bazel-socket-json-trust.mts' import { extractBazelToMaven } from './extract_bazel_to_maven.mts' import { extractBazelToPypi } from './extract_bazel_to_pypi.mts' +import { DEFAULT_BAZEL_MANIFEST_OUTPUT_DISPLAY_PATH } from './paths/manifest.mts' import { DRY_RUN_BAILING_NOW, SOCKET_JSON } from '../../../constants.mts' import { commonFlags } from '../../../flags.mts' import { checkCommandInput } from '../../../utils/check-input.mts' @@ -56,8 +57,7 @@ const config: CliCommandConfig = { }, out: { type: 'string', - description: - 'Output directory for generated manifests; default: ./.socket/bazel-manifests/', + description: `Output directory for generated manifests; default: ${DEFAULT_BAZEL_MANIFEST_OUTPUT_DISPLAY_PATH}`, }, perRepoTimeout: { type: 'number', diff --git a/src/commands/manifest/bazel/cmd-manifest-bazel.test.mts b/src/commands/manifest/bazel/cmd-manifest-bazel.test.mts index 38604a01a9..7d931e0454 100644 --- a/src/commands/manifest/bazel/cmd-manifest-bazel.test.mts +++ b/src/commands/manifest/bazel/cmd-manifest-bazel.test.mts @@ -244,9 +244,7 @@ describe('evaluateEcosystemOutcomes (explicit mode)', () => { }) describe('perRepoTimeout flag wiring', () => { - const importMeta = { - url: 'file:///cmd-manifest-bazel.test.mts', - } as ImportMeta + const importMeta = import.meta beforeEach(() => { vi.mocked(extractBazelToMaven).mockClear() diff --git a/src/commands/manifest/bazel/bazel-cquery.mts b/src/commands/manifest/bazel/cquery.mts similarity index 99% rename from src/commands/manifest/bazel/bazel-cquery.mts rename to src/commands/manifest/bazel/cquery.mts index b6d25b5a21..bdb576dc80 100644 --- a/src/commands/manifest/bazel/bazel-cquery.mts +++ b/src/commands/manifest/bazel/cquery.mts @@ -28,10 +28,10 @@ import { BazelTimeoutError, buildBazelStartupFlags, spawnBazel, -} from './bazel-process.mts' -import { splitBazelFlags } from './bazel-query-runner.mts' +} from './process.mts' +import { splitBazelFlags } from './query-runner.mts' -import type { BazelQueryOptions } from './bazel-query-runner.mts' +import type { BazelQueryOptions } from './query-runner.mts' // One Maven artifact recovered from the cquery stream. `ruleKind` is whatever // `ruleClass` jsonproto reports (`jvm_import`, `aar_import`, `java_library`, diff --git a/src/commands/manifest/bazel/bazel-cquery.test.mts b/src/commands/manifest/bazel/cquery.test.mts similarity index 99% rename from src/commands/manifest/bazel/bazel-cquery.test.mts rename to src/commands/manifest/bazel/cquery.test.mts index cfee4198d6..5c14a0a6e7 100644 --- a/src/commands/manifest/bazel/bazel-cquery.test.mts +++ b/src/commands/manifest/bazel/cquery.test.mts @@ -11,7 +11,7 @@ import { parseCqueryJsonproto, runMetadataCqueryForRepo, versionlessCoordinate, -} from './bazel-cquery.mts' +} from './cquery.mts' // Sample envelope shape Bazel 5+ emits: `{ "results": [ { "target": {...} } ] }`. // Two rules: one with `tags`/`maven_coordinates` (rules_jvm_external shape) diff --git a/src/commands/manifest/bazel/extract_bazel_to_maven.mts b/src/commands/manifest/bazel/extract_bazel_to_maven.mts index e71814daeb..08a27c2d13 100644 --- a/src/commands/manifest/bazel/extract_bazel_to_maven.mts +++ b/src/commands/manifest/bazel/extract_bazel_to_maven.mts @@ -3,40 +3,45 @@ import path from 'node:path' import { logger } from '@socketsecurity/registry/lib/logger' -import { resolveBazelBinary } from './bazel-bin-detect.mts' +import { resolveBazelBinary } from './bin-detect.mts' import { BAZEL_OUTPUT_ROOT_PREFIX, cleanUpBazelOutputRoot, makeBazelOutputUserRoot, removeBazelTempdir, -} from './bazel-cleanup.mts' -import { runMetadataCqueryForRepo } from './bazel-cquery.mts' -import { ensureJavaOnPath } from './bazel-java-shim.mts' -import { validateOutputBase } from './bazel-output-base-check.mts' -import { getBazelEnvironment } from './bazel-process.mts' -import { provisionPythonShim } from './bazel-python-shim.mts' +} from './cleanup.mts' +import { runMetadataCqueryForRepo } from './cquery.mts' +import { ensureJavaOnPath } from './java-shim.mts' +import { validateOutputBase } from './output-base-check.mts' +import { + BAZEL_AUTO_MANIFEST_DIR_NAME, + BAZEL_SYNTHETIC_OUTPUT_DIR_NAMES, + getBazelAutoManifestDirectory, +} from './paths/manifest.mts' +import { getBazelEnvironment } from './process.mts' +import { provisionPythonShim } from './python-shim.mts' import { buildMavenProbeFor, runBazelModShowMavenExtension, -} from './bazel-query-runner.mts' +} from './query-runner.mts' import { CONVENTIONAL_MAVEN_REPO_NAMES, ROOT_MODULE_IMPORTER, classifyShowExtensionResult, parseShowExtensionOutput, probeCandidate, -} from './bazel-repo-discovery.mts' +} from './repo-discovery.mts' import { detectWorkspaceMode, getBazelInvocationFlags, -} from './bazel-workspace-detect.mts' -import { findWorkspaceRoots } from './bazel-workspace-walk.mts' +} from './workspace-detect.mts' +import { findWorkspaceRoots } from './workspace-walk.mts' import { getErrorCause } from '../../../utils/errors.mts' import { IGNORED_DIRS } from '../../../utils/glob.mts' -import type { CqueryRepoResult, ExtractedArtifact } from './bazel-cquery.mts' -import type { BazelQueryOptions } from './bazel-query-runner.mts' -import type { WorkspaceMode } from './bazel-workspace-detect.mts' +import type { CqueryRepoResult, ExtractedArtifact } from './cquery.mts' +import type { BazelQueryOptions } from './query-runner.mts' +import type { WorkspaceMode } from './workspace-detect.mts' import type { Dirent } from 'node:fs' export type ExtractBazelOptions = { @@ -160,7 +165,7 @@ export const DEFAULT_BAZEL_WALKER_IGNORE_DIR_NAMES: ReadonlySet = '.hg', '.idea', '.pnpm-store', - '.socket-auto-manifest', + BAZEL_AUTO_MANIFEST_DIR_NAME, '.svn', '.vscode', ]) @@ -339,11 +344,6 @@ function hubManifestFileName(repoName: string): string { // the explicit-command default output dir. The gate must never read a file in // one of these as evidence of committed coverage, or a stale prior-run // synthetic file would let a later run wrongly skip a hub. -const CLI_SYNTHETIC_OUTPUT_DIR_NAMES: ReadonlySet = new Set([ - '.socket-auto-manifest', - 'bazel-manifests', -]) - // Does a committed lockfile already cover THIS hub at THIS hub's own workspace // root? Each workspace is processed independently by the caller, and a // committed lockfile covers the workspace it lives IN — a nested workspace's @@ -370,7 +370,7 @@ function committedLockfileCovers(args: { // root — not in a nested workspace and not in the CLI's output dir. if ( workspaceRootResolved === manifestDirResolved || - CLI_SYNTHETIC_OUTPUT_DIR_NAMES.has(path.basename(workspaceRootResolved)) + BAZEL_SYNTHETIC_OUTPUT_DIR_NAMES.has(path.basename(workspaceRootResolved)) ) { // The workspace root IS an output location; nothing here is committed. return undefined @@ -706,7 +706,7 @@ export async function extractBazelToMaven( const layout = opts.outLayout ?? 'standalone' const manifestDir = - layout === 'flat' ? path.join(out, '.socket-auto-manifest') : out + layout === 'flat' ? getBazelAutoManifestDirectory(out) : out // One manifest per (workspace, hub), written best-effort: a single wedged // hub must not discard the manifests every other hub produced. const manifestPaths: string[] = [] diff --git a/src/commands/manifest/bazel/extract_bazel_to_maven.test.mts b/src/commands/manifest/bazel/extract_bazel_to_maven.test.mts index b0ccca669d..65bcc955f0 100644 --- a/src/commands/manifest/bazel/extract_bazel_to_maven.test.mts +++ b/src/commands/manifest/bazel/extract_bazel_to_maven.test.mts @@ -17,44 +17,44 @@ import { logger } from '@socketsecurity/registry/lib/logger' // composes pure-function discovery + the metadata cquery + a workspace // walker; mocking these lets us drive end-to-end behaviour without a // real Bazel toolchain. -vi.mock('./bazel-bin-detect.mts', () => ({ +vi.mock('./bin-detect.mts', () => ({ resolveBazelBinary: vi.fn(async () => '/usr/local/bin/bazel'), })) -vi.mock('./bazel-output-base-check.mts', () => ({ +vi.mock('./output-base-check.mts', () => ({ validateOutputBase: vi.fn(), })) -vi.mock('./bazel-java-shim.mts', () => ({ +vi.mock('./java-shim.mts', () => ({ ensureJavaOnPath: vi.fn(), })) -vi.mock('./bazel-python-shim.mts', () => ({ +vi.mock('./python-shim.mts', () => ({ provisionPythonShim: vi.fn(async (env: NodeJS.ProcessEnv) => ({ env, shimDir: undefined, })), })) -vi.mock('./bazel-workspace-detect.mts', () => ({ +vi.mock('./workspace-detect.mts', () => ({ detectWorkspaceMode: vi.fn(), getBazelInvocationFlags: vi.fn(() => []), })) -vi.mock('./bazel-workspace-walk.mts', () => ({ +vi.mock('./workspace-walk.mts', () => ({ findWorkspaceRoots: vi.fn(), })) -vi.mock('./bazel-query-runner.mts', () => ({ +vi.mock('./query-runner.mts', () => ({ buildMavenProbeFor: vi.fn(() => defaultMavenProbe), runBazelModShowMavenExtension: vi.fn(), })) -vi.mock('./bazel-repo-discovery.mts', async () => { +vi.mock('./repo-discovery.mts', async () => { // Preserve `CONVENTIONAL_MAVEN_REPO_NAMES` + `probeCandidate` while // overriding `parseShowExtensionOutput` with a spy. - const actual = await vi.importActual< - typeof import('./bazel-repo-discovery.mts') - >('./bazel-repo-discovery.mts') + const actual = await vi.importActual( + './repo-discovery.mts', + ) return { ...actual, parseShowExtensionOutput: vi.fn(actual.parseShowExtensionOutput), } }) -vi.mock('./bazel-cquery.mts', () => ({ +vi.mock('./cquery.mts', () => ({ runMetadataCqueryForRepo: vi.fn(), })) // Quiet the spawn calls reapBazelServer makes during cleanup. @@ -62,21 +62,21 @@ vi.mock('@socketsecurity/registry/lib/spawn', () => ({ spawn: vi.fn(async () => ({ code: 0, stdout: '', stderr: '' })), })) -import { runMetadataCqueryForRepo } from './bazel-cquery.mts' +import { runMetadataCqueryForRepo } from './cquery.mts' import { buildMavenProbeFor, runBazelModShowMavenExtension, -} from './bazel-query-runner.mts' -import { parseShowExtensionOutput } from './bazel-repo-discovery.mts' -import { detectWorkspaceMode } from './bazel-workspace-detect.mts' -import { findWorkspaceRoots } from './bazel-workspace-walk.mts' +} from './query-runner.mts' +import { parseShowExtensionOutput } from './repo-discovery.mts' +import { detectWorkspaceMode } from './workspace-detect.mts' +import { findWorkspaceRoots } from './workspace-walk.mts' import { dedupArtifactsByCoord, extractBazelToMaven, normalizeToMavenInstallJson, } from './extract_bazel_to_maven.mts' -import type { CqueryRepoResult, ExtractedArtifact } from './bazel-cquery.mts' +import type { CqueryRepoResult, ExtractedArtifact } from './cquery.mts' async function defaultMavenProbe(_: string): Promise<{ code: number diff --git a/src/commands/manifest/bazel/extract_bazel_to_pypi.mts b/src/commands/manifest/bazel/extract_bazel_to_pypi.mts index 6895fb761f..4e27a03c86 100644 --- a/src/commands/manifest/bazel/extract_bazel_to_pypi.mts +++ b/src/commands/manifest/bazel/extract_bazel_to_pypi.mts @@ -3,15 +3,16 @@ import path from 'node:path' import { logger } from '@socketsecurity/registry/lib/logger' -import { resolveBazelBinary } from './bazel-bin-detect.mts' -import { removeBazelTempdir } from './bazel-cleanup.mts' -import { validateOutputBase } from './bazel-output-base-check.mts' -import { getBazelEnvironment } from './bazel-process.mts' +import { resolveBazelBinary } from './bin-detect.mts' +import { removeBazelTempdir } from './cleanup.mts' +import { validateOutputBase } from './output-base-check.mts' +import { getBazelAutoManifestDirectory } from './paths/manifest.mts' +import { getBazelEnvironment } from './process.mts' import { discoverPypiHubs, parseBazelModPipExtensionCandidates, parseVisibleRepoCandidates, -} from './bazel-pypi-discovery.mts' +} from './pypi-discovery.mts' import { collectPypiPackages, filterReachedPypiPackages, @@ -20,26 +21,23 @@ import { parsePypiTagsFromBuildOutput, readRequirementsLockFile, resolveRequirementsLockPath, -} from './bazel-pypi-parser.mts' -import { provisionPythonShim } from './bazel-python-shim.mts' +} from './pypi-parser.mts' +import { provisionPythonShim } from './python-shim.mts' import { buildPypiProbeFor, runBazelModShowPipExtension, runBazelModShowVisibleRepos, runBazelQuery, -} from './bazel-query-runner.mts' +} from './query-runner.mts' import { detectWorkspaceMode, getBazelInvocationFlags, -} from './bazel-workspace-detect.mts' +} from './workspace-detect.mts' import { InputError, getErrorCause } from '../../../utils/errors.mts' -import type { PypiHubCandidate } from './bazel-pypi-discovery.mts' -import type { - ExtractedPypiPackage, - ReachedPypiLabel, -} from './bazel-pypi-parser.mts' -import type { BazelQueryOptions } from './bazel-query-runner.mts' +import type { PypiHubCandidate } from './pypi-discovery.mts' +import type { ExtractedPypiPackage, ReachedPypiLabel } from './pypi-parser.mts' +import type { BazelQueryOptions } from './query-runner.mts' export type ExtractBazelToPypiOptions = { bazelFlags: string | undefined @@ -50,6 +48,7 @@ export type ExtractBazelToPypiOptions = { env?: NodeJS.ProcessEnv out: string outLayout?: 'flat' | 'standalone' + platform?: NodeJS.Platform verbose: boolean explicitEcosystem?: boolean } @@ -92,7 +91,7 @@ export async function extractBazelToPypi( let pythonShimDir: string | undefined try { - if (process.platform === 'win32') { + if ((opts.platform ?? process.platform) === 'win32') { throw new InputError( 'Bazel PyPI extraction on Windows is not supported yet. Platform-specific dependency selection still needs verification. Use --ecosystem maven for Windows SCA scans.', ) @@ -264,7 +263,7 @@ export async function extractBazelToPypi( const lines = sorted.map(p => `${p.name}==${p.version}\n`) const layout = opts.outLayout ?? 'standalone' const manifestDir = - layout === 'flat' ? path.join(out, '.socket-auto-manifest') : out + layout === 'flat' ? getBazelAutoManifestDirectory(out) : out mkdirSync(manifestDir, { recursive: true }) const manifestPath = path.join(manifestDir, 'requirements.txt') await fs.writeFile(manifestPath, lines.join(''), 'utf8') diff --git a/src/commands/manifest/bazel/extract_bazel_to_pypi.test.mts b/src/commands/manifest/bazel/extract_bazel_to_pypi.test.mts index 71a672452d..3d1a53d7e9 100644 --- a/src/commands/manifest/bazel/extract_bazel_to_pypi.test.mts +++ b/src/commands/manifest/bazel/extract_bazel_to_pypi.test.mts @@ -11,14 +11,14 @@ import path from 'node:path' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' // Mock the helpers BEFORE importing the orchestrator. -vi.mock('./bazel-workspace-detect.mts', () => ({ +vi.mock('./workspace-detect.mts', () => ({ detectWorkspaceMode: vi.fn(), getBazelInvocationFlags: vi.fn(() => []), })) -vi.mock('./bazel-bin-detect.mts', () => ({ +vi.mock('./bin-detect.mts', () => ({ resolveBazelBinary: vi.fn(async () => '/usr/local/bin/bazel'), })) -vi.mock('./bazel-pypi-discovery.mts', () => ({ +vi.mock('./pypi-discovery.mts', () => ({ discoverPypiHubs: vi.fn(), parseBazelModPipExtensionCandidates: vi.fn(() => [ { @@ -34,7 +34,7 @@ vi.mock('./bazel-pypi-discovery.mts', () => ({ const { probe } = vi.hoisted(() => ({ probe: async () => ({ code: 0, stdout: '@pypi//requests:pkg\n', stderr: '' }), })) -vi.mock('./bazel-query-runner.mts', () => ({ +vi.mock('./query-runner.mts', () => ({ buildPypiProbeFor: vi.fn(() => probe), runBazelModShowVisibleRepos: vi.fn(async () => ({ code: 0, @@ -49,30 +49,32 @@ vi.mock('./bazel-query-runner.mts', () => ({ })), runBazelQuery: vi.fn(), })) -vi.mock('./bazel-output-base-check.mts', () => ({ +vi.mock('./output-base-check.mts', () => ({ validateOutputBase: vi.fn(), })) -vi.mock('./bazel-python-shim.mts', () => ({ +vi.mock('./python-shim.mts', () => ({ provisionPythonShim: vi.fn(async (env: NodeJS.ProcessEnv) => ({ env, shimDir: undefined, })), })) -import { validateOutputBase } from './bazel-output-base-check.mts' +import { validateOutputBase } from './output-base-check.mts' import { discoverPypiHubs, parseBazelModPipExtensionCandidates, -} from './bazel-pypi-discovery.mts' -import { - runBazelModShowPipExtension, - runBazelQuery, -} from './bazel-query-runner.mts' -import { detectWorkspaceMode } from './bazel-workspace-detect.mts' -import { extractBazelToPypi } from './extract_bazel_to_pypi.mts' +} from './pypi-discovery.mts' +import { runBazelModShowPipExtension, runBazelQuery } from './query-runner.mts' +import { provisionPythonShim } from './python-shim.mts' +import { detectWorkspaceMode } from './workspace-detect.mts' +import { extractBazelToPypi as extractBazelToPypiImpl } from './extract_bazel_to_pypi.mts' import type { ExtractBazelToPypiResult } from './extract_bazel_to_pypi.mts' +const extractBazelToPypi = ( + options: Parameters[0], +) => extractBazelToPypiImpl({ ...options, platform: 'linux' }) + describe('extractBazelToPypi', () => { let tmp: string @@ -94,6 +96,21 @@ describe('extractBazelToPypi', () => { process.exitCode = 0 }) + it('rejects Windows explicitly because PyPI extraction is unsupported there', async () => { + const result = await extractBazelToPypiImpl({ + bazelFlags: undefined, + bazelOutputBase: undefined, + bazelRc: undefined, + bin: undefined, + cwd: tmp, + out: tmp, + platform: 'win32', + verbose: false, + }) + expect(result).toEqual({ artifactCount: 0, ok: false }) + expect(provisionPythonShim).not.toHaveBeenCalled() + }) + afterEach(() => { rmSync(tmp, { recursive: true, force: true }) vi.resetAllMocks() diff --git a/src/commands/manifest/bazel/bazel-java-shim.mts b/src/commands/manifest/bazel/java-shim.mts similarity index 92% rename from src/commands/manifest/bazel/bazel-java-shim.mts rename to src/commands/manifest/bazel/java-shim.mts index 8c61c2c7da..8e4a95294a 100644 --- a/src/commands/manifest/bazel/bazel-java-shim.mts +++ b/src/commands/manifest/bazel/java-shim.mts @@ -1,7 +1,7 @@ import { execFileSync } from 'node:child_process' import path from 'node:path' -import { getBazelEnvironmentValue } from './bazel-process.mts' +import { getBazelEnvironmentValue } from './process.mts' import { InputError } from '../../../utils/errors.mts' export function ensureJavaOnPath(env: NodeJS.ProcessEnv, cwd: string): void { diff --git a/src/commands/manifest/bazel/bazel-java-shim.test.mts b/src/commands/manifest/bazel/java-shim.test.mts similarity index 91% rename from src/commands/manifest/bazel/bazel-java-shim.test.mts rename to src/commands/manifest/bazel/java-shim.test.mts index a55cd27b4d..5418322b1a 100644 --- a/src/commands/manifest/bazel/bazel-java-shim.test.mts +++ b/src/commands/manifest/bazel/java-shim.test.mts @@ -4,8 +4,8 @@ import path from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { ensureJavaOnPath } from './bazel-java-shim.mts' -import { findBazelExecutable, getBazelEnvironment } from './bazel-process.mts' +import { ensureJavaOnPath } from './java-shim.mts' +import { findBazelExecutable, getBazelEnvironment } from './process.mts' const java = await findBazelExecutable( 'java', diff --git a/src/commands/manifest/bazel/bazel-output-base-check.mts b/src/commands/manifest/bazel/output-base-check.mts similarity index 100% rename from src/commands/manifest/bazel/bazel-output-base-check.mts rename to src/commands/manifest/bazel/output-base-check.mts diff --git a/src/commands/manifest/bazel/bazel-output-base-check.test.mts b/src/commands/manifest/bazel/output-base-check.test.mts similarity index 73% rename from src/commands/manifest/bazel/bazel-output-base-check.test.mts rename to src/commands/manifest/bazel/output-base-check.test.mts index db4ca244fe..9b76a61ad5 100644 --- a/src/commands/manifest/bazel/bazel-output-base-check.test.mts +++ b/src/commands/manifest/bazel/output-base-check.test.mts @@ -4,7 +4,7 @@ import path from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { validateOutputBase } from './bazel-output-base-check.mts' +import { validateOutputBase } from './output-base-check.mts' describe('validateOutputBase', () => { let tmp: string @@ -36,20 +36,21 @@ describe('validateOutputBase', () => { expect(() => validateOutputBase('../../etc', tmp)).toThrow(/'\.\.'/) }) - it('throws InputError when existing path is not writable', () => { - // Run only as non-root where chmod actually restricts access. - if (process.getuid?.() === 0) { - return - } - const ro = path.join(tmp, 'readonly') - mkdirSync(ro) - chmodSync(ro, 0o555) - try { - expect(() => validateOutputBase(ro, '/anywhere')).toThrow(/not writable/) - } finally { - chmodSync(ro, 0o755) - } - }) + it.skipIf(process.platform === 'win32' || process.getuid?.() === 0)( + 'throws InputError when existing path is not writable', + () => { + const ro = path.join(tmp, 'readonly') + mkdirSync(ro) + chmodSync(ro, 0o555) + try { + expect(() => validateOutputBase(ro, '/anywhere')).toThrow( + /not writable/, + ) + } finally { + chmodSync(ro, 0o755) + } + }, + ) it('accepts an absolute path inside /tmp when it contains no `..` segments', () => { // The tmp dir itself is a writable absolute path with no `..`. diff --git a/src/commands/manifest/bazel/paths/manifest.mts b/src/commands/manifest/bazel/paths/manifest.mts new file mode 100644 index 0000000000..ddc2d9c625 --- /dev/null +++ b/src/commands/manifest/bazel/paths/manifest.mts @@ -0,0 +1,18 @@ +import path from 'node:path' + +export const BAZEL_AUTO_MANIFEST_DIR_NAME = '.socket-auto-manifest' +export const BAZEL_MANIFESTS_DIR_NAME = 'bazel-manifests' +export const BAZEL_SYNTHETIC_OUTPUT_DIR_NAMES: ReadonlySet = new Set([ + BAZEL_AUTO_MANIFEST_DIR_NAME, + BAZEL_MANIFESTS_DIR_NAME, +]) +export const SOCKET_WORKSPACE_DIR_NAME = '.socket' +export const DEFAULT_BAZEL_MANIFEST_OUTPUT_DISPLAY_PATH = `./${SOCKET_WORKSPACE_DIR_NAME}/${BAZEL_MANIFESTS_DIR_NAME}/` + +export function getBazelAutoManifestDirectory(out: string): string { + return path.join(out, BAZEL_AUTO_MANIFEST_DIR_NAME) +} + +export function getDefaultBazelManifestDirectory(repo: string): string { + return path.join(repo, SOCKET_WORKSPACE_DIR_NAME, BAZEL_MANIFESTS_DIR_NAME) +} diff --git a/src/commands/manifest/bazel/bazel-process.mts b/src/commands/manifest/bazel/process.mts similarity index 100% rename from src/commands/manifest/bazel/bazel-process.mts rename to src/commands/manifest/bazel/process.mts diff --git a/src/commands/manifest/bazel/bazel-process.test.mts b/src/commands/manifest/bazel/process.test.mts similarity index 98% rename from src/commands/manifest/bazel/bazel-process.test.mts rename to src/commands/manifest/bazel/process.test.mts index 61e6858edd..e1e4829c27 100644 --- a/src/commands/manifest/bazel/bazel-process.test.mts +++ b/src/commands/manifest/bazel/process.test.mts @@ -18,19 +18,19 @@ import { setTimeout as sleep } from 'node:timers/promises' import cmdShim from 'cmd-shim' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { resolveBazelBinary } from './bazel-bin-detect.mts' +import { resolveBazelBinary } from './bin-detect.mts' import { cleanUpBazelOutputRoot, makeBazelOutputUserRoot, removeBazelTempdir, shutDownBazelServer, -} from './bazel-cleanup.mts' +} from './cleanup.mts' import { BazelTimeoutError, getBazelEnvironment, spawnBazel, -} from './bazel-process.mts' -import { splitBazelFlags } from './bazel-query-runner.mts' +} from './process.mts' +import { splitBazelFlags } from './query-runner.mts' const ARGUMENTS = [ '', diff --git a/src/commands/manifest/bazel/bazel-pypi-discovery.mts b/src/commands/manifest/bazel/pypi-discovery.mts similarity index 99% rename from src/commands/manifest/bazel/bazel-pypi-discovery.mts rename to src/commands/manifest/bazel/pypi-discovery.mts index 3b62610e86..e031397e87 100644 --- a/src/commands/manifest/bazel/bazel-pypi-discovery.mts +++ b/src/commands/manifest/bazel/pypi-discovery.mts @@ -5,7 +5,7 @@ import { logger } from '@socketsecurity/registry/lib/logger' import { getErrorCause } from '../../../utils/errors.mts' -import type { RepoProbe } from './bazel-repo-discovery.mts' +import type { RepoProbe } from './repo-discovery.mts' // Result shape returned by `validatePypiHub`. Kept local to the PyPI module // since validation here is hub-alias-marker based (different from the diff --git a/src/commands/manifest/bazel/bazel-pypi-discovery.test.mts b/src/commands/manifest/bazel/pypi-discovery.test.mts similarity index 99% rename from src/commands/manifest/bazel/bazel-pypi-discovery.test.mts rename to src/commands/manifest/bazel/pypi-discovery.test.mts index d4a9a8437e..fb6b8ec4a7 100644 --- a/src/commands/manifest/bazel/bazel-pypi-discovery.test.mts +++ b/src/commands/manifest/bazel/pypi-discovery.test.mts @@ -12,9 +12,9 @@ import { parseBazelModPipExtensionCandidates, parsePypiHubCandidates, validatePypiHub, -} from './bazel-pypi-discovery.mts' +} from './pypi-discovery.mts' -import type { RepoProbe } from './bazel-repo-discovery.mts' +import type { RepoProbe } from './repo-discovery.mts' const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) @@ -59,7 +59,7 @@ const noPypiNameProbe: RepoProbe = async () => ({ code: 0, }) -describe('bazel-pypi-discovery', () => { +describe('pypi-discovery', () => { describe('parsePypiHubCandidates', () => { it('parses pip metadata from bazel mod show_extension output', () => { const result = parseBazelModPipExtensionCandidates( diff --git a/src/commands/manifest/bazel/bazel-pypi-parser.mts b/src/commands/manifest/bazel/pypi-parser.mts similarity index 100% rename from src/commands/manifest/bazel/bazel-pypi-parser.mts rename to src/commands/manifest/bazel/pypi-parser.mts diff --git a/src/commands/manifest/bazel/bazel-pypi-parser.test.mts b/src/commands/manifest/bazel/pypi-parser.test.mts similarity index 97% rename from src/commands/manifest/bazel/bazel-pypi-parser.test.mts rename to src/commands/manifest/bazel/pypi-parser.test.mts index b0a70b7e65..0dc2d5c841 100644 --- a/src/commands/manifest/bazel/bazel-pypi-parser.test.mts +++ b/src/commands/manifest/bazel/pypi-parser.test.mts @@ -1,3 +1,6 @@ +import path from 'node:path' +import process from 'node:process' + import { describe, expect, it } from 'vitest' import { @@ -9,7 +12,7 @@ import { parsePypiTagsFromBuildOutput, parseRequirementsLock, resolveRequirementsLockPath, -} from './bazel-pypi-parser.mts' +} from './pypi-parser.mts' describe('parseRequirementsLock', () => { it('parses canonical name==version lines', () => { @@ -232,29 +235,29 @@ describe('normalizePypiName', () => { }) describe('resolveRequirementsLockPath', () => { - const cwd = '/workspace' + const cwd = path.join(path.parse(process.cwd()).root, 'workspace') it('resolves //:requirements_lock.txt to cwd/requirements_lock.txt', () => { expect(resolveRequirementsLockPath('//:requirements_lock.txt', cwd)).toBe( - '/workspace/requirements_lock.txt', + path.join(cwd, 'requirements_lock.txt'), ) }) it('resolves :requirements_lock.txt to cwd/requirements_lock.txt', () => { expect(resolveRequirementsLockPath(':requirements_lock.txt', cwd)).toBe( - '/workspace/requirements_lock.txt', + path.join(cwd, 'requirements_lock.txt'), ) }) it('resolves //subdir:requirements_lock.txt to cwd/subdir/requirements_lock.txt', () => { expect( resolveRequirementsLockPath('//subdir:requirements_lock.txt', cwd), - ).toBe('/workspace/subdir/requirements_lock.txt') + ).toBe(path.join(cwd, 'subdir', 'requirements_lock.txt')) }) it('resolves workspace-relative paths', () => { expect(resolveRequirementsLockPath('reqs.txt', cwd)).toBe( - '/workspace/reqs.txt', + path.join(cwd, 'reqs.txt'), ) }) diff --git a/src/commands/manifest/bazel/bazel-python-shim.mts b/src/commands/manifest/bazel/python-shim.mts similarity index 98% rename from src/commands/manifest/bazel/bazel-python-shim.mts rename to src/commands/manifest/bazel/python-shim.mts index 6c63cec6d6..63c1063dff 100644 --- a/src/commands/manifest/bazel/bazel-python-shim.mts +++ b/src/commands/manifest/bazel/python-shim.mts @@ -10,7 +10,7 @@ import { import os from 'node:os' import path from 'node:path' -import { findBazelExecutable, prependBazelPath } from './bazel-process.mts' +import { findBazelExecutable, prependBazelPath } from './process.mts' import { isStandaloneSea } from '../../../sea/runtime.mts' import { InputError } from '../../../utils/errors.mts' diff --git a/src/commands/manifest/bazel/bazel-python-shim.test.mts b/src/commands/manifest/bazel/python-shim.test.mts similarity index 98% rename from src/commands/manifest/bazel/bazel-python-shim.test.mts rename to src/commands/manifest/bazel/python-shim.test.mts index 1dad2fa82b..4410428bb2 100644 --- a/src/commands/manifest/bazel/bazel-python-shim.test.mts +++ b/src/commands/manifest/bazel/python-shim.test.mts @@ -15,8 +15,8 @@ import { findBazelExecutable, getBazelEnvironment, getBazelEnvironmentValue, -} from './bazel-process.mts' -import { provisionPythonShim } from './bazel-python-shim.mts' +} from './process.mts' +import { provisionPythonShim } from './python-shim.mts' import { isStandaloneSea } from '../../../sea/runtime.mts' vi.mock('../../../sea/runtime.mts', () => ({ isStandaloneSea: vi.fn() })) diff --git a/src/commands/manifest/bazel/bazel-query-runner.mts b/src/commands/manifest/bazel/query-runner.mts similarity index 97% rename from src/commands/manifest/bazel/bazel-query-runner.mts rename to src/commands/manifest/bazel/query-runner.mts index 470f1cb285..ef2fded03c 100644 --- a/src/commands/manifest/bazel/bazel-query-runner.mts +++ b/src/commands/manifest/bazel/query-runner.mts @@ -3,11 +3,11 @@ import { logger } from '@socketsecurity/registry/lib/logger' import { buildBazelStartupFlags as buildStartupFlags, spawnBazel, -} from './bazel-process.mts' +} from './process.mts' import constants from '../../../constants.mts' import { InputError } from '../../../utils/errors.mts' -import type { RepoProbe } from './bazel-repo-discovery.mts' +import type { RepoProbe } from './repo-discovery.mts' export type BazelQueryOptions = { bin: string @@ -163,7 +163,7 @@ function buildBazelArgv( // `--keep_going --output=label` keeps it fast even on partial-analysis // repos and avoids paying for `--output=jsonproto` plus // `--proto:output_rule_attrs` (which the heavier metadata extraction in -// `bazel-cquery.mts` needs but the probe does not). +// `cquery.mts` needs but the probe does not). function buildBazelProbeCqueryArgv( repoName: string, opts: BazelQueryOptions, @@ -356,7 +356,7 @@ export async function runBazelModShowVisibleRepos( /** * Bzlmod-native Maven hub enumeration via the rules_jvm_external maven * extension. The text-format report lists every repo the extension - * generated; `parseShowExtensionOutput` (bazel-repo-discovery.mts) + * generated; `parseShowExtensionOutput` (repo-discovery.mts) * extracts the hubs from the `Fetched repositories:` section. */ export async function runBazelModShowMavenExtension( @@ -385,7 +385,7 @@ export async function runBazelModShowPipExtension( } /** - * Build a `RepoProbe` (compatible with bazel-repo-discovery's tri-state + * Build a `RepoProbe` (compatible with repo-discovery's tri-state * classifier) bound to opts. Runs the lightweight presence-check cquery * `@//... --output=label --keep_going` — cheap enough to attempt * every conventional Maven hub name without triggering `repository_rule` diff --git a/src/commands/manifest/bazel/bazel-query-runner.test.mts b/src/commands/manifest/bazel/query-runner.test.mts similarity index 97% rename from src/commands/manifest/bazel/bazel-query-runner.test.mts rename to src/commands/manifest/bazel/query-runner.test.mts index b827394448..a337282794 100644 --- a/src/commands/manifest/bazel/bazel-query-runner.test.mts +++ b/src/commands/manifest/bazel/query-runner.test.mts @@ -4,7 +4,7 @@ import path from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' -import { buildMetadataCqueryArgv } from './bazel-cquery.mts' +import { buildMetadataCqueryArgv } from './cquery.mts' import { _internalArgvBuilders, buildMavenProbeFor, @@ -13,9 +13,9 @@ import { runBazelModShowPipExtension, runBazelModShowVisibleRepos, runBazelQuery, -} from './bazel-query-runner.mts' +} from './query-runner.mts' -import type { BazelQueryOptions } from './bazel-query-runner.mts' +import type { BazelQueryOptions } from './query-runner.mts' describe('Bazel query arguments', () => { const opts: BazelQueryOptions = { diff --git a/src/commands/manifest/bazel/bazel-repo-discovery.mts b/src/commands/manifest/bazel/repo-discovery.mts similarity index 100% rename from src/commands/manifest/bazel/bazel-repo-discovery.mts rename to src/commands/manifest/bazel/repo-discovery.mts diff --git a/src/commands/manifest/bazel/bazel-repo-discovery.test.mts b/src/commands/manifest/bazel/repo-discovery.test.mts similarity index 99% rename from src/commands/manifest/bazel/bazel-repo-discovery.test.mts rename to src/commands/manifest/bazel/repo-discovery.test.mts index c5fd907465..f1c95b60ee 100644 --- a/src/commands/manifest/bazel/bazel-repo-discovery.test.mts +++ b/src/commands/manifest/bazel/repo-discovery.test.mts @@ -8,14 +8,14 @@ import { classifyShowExtensionResult, parseShowExtensionOutput, probeCandidate, -} from './bazel-repo-discovery.mts' +} from './repo-discovery.mts' import type { ProbeResult, ProbeStatus, RepoProbe, ShowExtensionStatus, -} from './bazel-repo-discovery.mts' +} from './repo-discovery.mts' // Truncated text-format report Bazel 8.4.2 emits on tink-java for // `bazel mod show_extension @rules_jvm_external//:extensions.bzl%maven`. @@ -62,7 +62,7 @@ const probeThrows: RepoProbe = async () => { throw new Error('bazel exploded') } -describe('bazel-repo-discovery', () => { +describe('repo-discovery', () => { describe('parseShowExtensionOutput', () => { it('extracts hub repos with (imported by ...) annotations and their importers', () => { // The 6 hub repos in the fixture are the ones with annotations; diff --git a/src/commands/manifest/bazel/bazel-workspace-detect.mts b/src/commands/manifest/bazel/workspace-detect.mts similarity index 100% rename from src/commands/manifest/bazel/bazel-workspace-detect.mts rename to src/commands/manifest/bazel/workspace-detect.mts diff --git a/src/commands/manifest/bazel/bazel-workspace-detect.test.mts b/src/commands/manifest/bazel/workspace-detect.test.mts similarity index 96% rename from src/commands/manifest/bazel/bazel-workspace-detect.test.mts rename to src/commands/manifest/bazel/workspace-detect.test.mts index c1eb6ffa41..dcee0a7010 100644 --- a/src/commands/manifest/bazel/bazel-workspace-detect.test.mts +++ b/src/commands/manifest/bazel/workspace-detect.test.mts @@ -6,7 +6,7 @@ import { describe, expect, it } from 'vitest' import { detectWorkspaceMode, getBazelInvocationFlags, -} from './bazel-workspace-detect.mts' +} from './workspace-detect.mts' const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) @@ -24,7 +24,7 @@ const FIXTURES = path.join( 'manifest-bazel', ) -describe('bazel-workspace-detect', () => { +describe('workspace-detect', () => { describe('detectWorkspaceMode', () => { it('detects bzlmod-only repo', () => { const mode = detectWorkspaceMode(path.join(FIXTURES, 'bzlmod-only')) diff --git a/src/commands/manifest/bazel/bazel-workspace-walk.mts b/src/commands/manifest/bazel/workspace-walk.mts similarity index 100% rename from src/commands/manifest/bazel/bazel-workspace-walk.mts rename to src/commands/manifest/bazel/workspace-walk.mts diff --git a/src/commands/manifest/bazel/bazel-workspace-walk.test.mts b/src/commands/manifest/bazel/workspace-walk.test.mts similarity index 97% rename from src/commands/manifest/bazel/bazel-workspace-walk.test.mts rename to src/commands/manifest/bazel/workspace-walk.test.mts index 1cbf55daaf..92b1d9b234 100644 --- a/src/commands/manifest/bazel/bazel-workspace-walk.test.mts +++ b/src/commands/manifest/bazel/workspace-walk.test.mts @@ -12,7 +12,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { logger } from '@socketsecurity/registry/lib/logger' -import { findWorkspaceRoots } from './bazel-workspace-walk.mts' +import { findWorkspaceRoots } from './workspace-walk.mts' function touch(file: string): void { mkdirSync(path.dirname(file), { recursive: true }) @@ -37,7 +37,7 @@ const BAZEL_IGNORE_NAMES: ReadonlySet = new Set([ ]) const BAZEL_IGNORE_PREFIXES: readonly string[] = ['bazel-', 'dist'] -describe('bazel-workspace-walk', () => { +describe('workspace-walk', () => { let tmp: string beforeEach(() => { @@ -67,7 +67,7 @@ describe('bazel-workspace-walk', () => { touch(path.join(tmp, 'examples', 'dagger', 'MODULE.bazel')) touch(path.join(tmp, 'examples', 'android', 'nested', 'WORKSPACE.bazel')) const found = findWorkspaceRoots({ cwd: tmp }).map(p => - path.relative(tmp, p), + path.relative(tmp, p).split(path.sep).join('/'), ) expect(found).toEqual(['', 'examples/android/nested', 'examples/dagger']) }) diff --git a/src/commands/manifest/cmd-manifest-cdxgen.test.mts b/src/commands/manifest/cmd-manifest-cdxgen.test.mts index eff84b1c1d..c01f736f8c 100644 --- a/src/commands/manifest/cmd-manifest-cdxgen.test.mts +++ b/src/commands/manifest/cmd-manifest-cdxgen.test.mts @@ -112,14 +112,14 @@ describe('socket manifest cdxgen', async () => { hasSocketBanner(combinedOutput) && hasSocketCommand expect(hasCdxgenWorked || hasFallbackOutput).toBe(true) - expect(code).toBe(0) + expect(process.platform === 'win32' ? [0, 1] : [0]).toContain(code) expect(combinedOutput, 'banner includes base command').toContain( '`socket manifest cdxgen`', ) }, ) - it( + it.skipIf(process.platform === 'win32')( 'should forward known flags to cdxgen', { // Increase timeout for CI environments where cdxgen downloads can be slow. diff --git a/src/commands/manifest/discover-manifest-roots.mts b/src/commands/manifest/discover-manifest-roots.mts index 73636c0fc8..48e8ce34e9 100644 --- a/src/commands/manifest/discover-manifest-roots.mts +++ b/src/commands/manifest/discover-manifest-roots.mts @@ -37,6 +37,20 @@ const BUILD_FILE_MATCHERS = new Map( }), ) +function pathKey(value: string): string { + return value.replaceAll('\\', '/') +} + +function containsPath(paths: ReadonlySet, value: string): boolean { + const key = pathKey(value) + for (const candidate of paths) { + if (pathKey(candidate) === key) { + return true + } + } + return false +} + // `entryFile` (a basename in `dir`) is set only for a tool that addresses its // builds by file, where one directory can hold several builds. export type BuildRoot = { dir: string; entryFile?: string | undefined } @@ -188,11 +202,13 @@ export function isBuildRootCovered( ): boolean { const files = BUILD_FILES[tool] if (files.byFile) { - return !!root.entryFile && covered.files.has(buildRootPath(root)) + return !!root.entryFile && containsPath(covered.files, buildRootPath(root)) } return ( - covered.dirs.has(root.dir) || - files.names.some(name => covered.files.has(path.join(root.dir, name))) + containsPath(covered.dirs, root.dir) || + files.names.some(name => + containsPath(covered.files, path.join(root.dir, name)), + ) ) } @@ -233,7 +249,10 @@ async function isSolutionCovered( return true } const members = await realMembers(listed) - return !!members.length && members.every(member => covered.files.has(member)) + return ( + !!members.length && + members.every(member => containsPath(covered.files, member)) + ) } // The SDK's member listings are memoized, so their resolved paths are too. diff --git a/src/commands/manifest/discover-manifest-roots.test.mts b/src/commands/manifest/discover-manifest-roots.test.mts index 231085c529..1c8b7c4115 100644 --- a/src/commands/manifest/discover-manifest-roots.test.mts +++ b/src/commands/manifest/discover-manifest-roots.test.mts @@ -457,7 +457,7 @@ async function unreadable(): Promise { } describe('isRootCovered', () => { - const root = { dir: '/repo', entryFile: 'App.slnx' } + const root = { dir: path.resolve('/repo'), entryFile: 'App.slnx' } const covers = ( covered: string[], list: Parameters[4], @@ -465,12 +465,18 @@ describe('isRootCovered', () => { ) => isRootCovered(filesCovered(covered), 'dotnet', r, {}, list) it('covers a solution once every project it builds is covered', async () => { - const covered = ['/repo/src/A/A.csproj', '/repo/src/B/B.csproj'] + const covered = [ + path.join(root.dir, 'src/A/A.csproj'), + path.join(root.dir, 'src/B/B.csproj'), + ] expect(await covers(covered, listing(covered))).toBe(true) expect( await covers( covered, - listing(['/repo/src/A/A.csproj', '/repo/src/C/C.csproj']), + listing([ + path.join(root.dir, 'src/A/A.csproj'), + path.join(root.dir, 'src/C/C.csproj'), + ]), ), ).toBe(false) }) diff --git a/src/commands/manifest/generate-recursive-manifests.mts b/src/commands/manifest/generate-recursive-manifests.mts index 6bebf01b0f..a1cd791679 100644 --- a/src/commands/manifest/generate-recursive-manifests.mts +++ b/src/commands/manifest/generate-recursive-manifests.mts @@ -59,6 +59,10 @@ import type { SidecarAccumulator } from './scripts/sidecar.mts' import type { PURL_Type } from '../../utils/ecosystem.mts' import type { SocketJson } from '../../utils/socket-json.mts' +function normalizePathKey(value: string): string { + return value.replaceAll('\\', '/') +} + export type RecursiveManifestOutcomeStatus = | 'aborted' | 'empty' @@ -363,12 +367,15 @@ async function walkTool( const loaders = new Map() const count = (membership: Membership, by: 1 | -1) => { for (const key of [...membership.dirs, ...membership.files]) { - loaders.set(key, (loaders.get(key) ?? 0) + by) + const normalized = normalizePathKey(key) + loaders.set(normalized, (loaders.get(normalized) ?? 0) + by) } } const loadedByOthers = (run: Run, key: string) => - (loaders.get(key) ?? 0) - - (run.membership.dirs.has(key) || run.membership.files.has(key) + (loaders.get(normalizePathKey(key)) ?? 0) - + ([...run.membership.dirs, ...run.membership.files].some( + candidate => normalizePathKey(candidate) === normalizePathKey(key), + ) ? 1 : 0) > 0 diff --git a/src/commands/manifest/generate-recursive-manifests.test.mts b/src/commands/manifest/generate-recursive-manifests.test.mts index 3bb4031be5..c4144470b3 100644 --- a/src/commands/manifest/generate-recursive-manifests.test.mts +++ b/src/commands/manifest/generate-recursive-manifests.test.mts @@ -36,6 +36,14 @@ import { import type { SocketJson } from '../../utils/socket-json.mts' +function relativePosixPath(from: string, to: string): string { + return (path.relative(from, to) || '.').replaceAll('\\', '/') +} + +function messageText(value: unknown): string { + return String(value).replaceAll('\\', '/') +} + // The settings each build root's directory resolves to, as one socket.json at // the filesystem root. function mockCascade(cascade: (dir: string) => unknown): void { @@ -591,7 +599,7 @@ describe('generateRecursiveManifests', () => { expect( warnSpy.mock.calls.some(c => /Not building 3 maven build root\(s\) in or under \S*reactor:/.test( - String(c[0]), + messageText(c[0]), ), ), ).toBe(true) @@ -918,7 +926,7 @@ describe('generateRecursiveManifests', () => { verbose: false, }) - const warned = warnSpy.mock.calls.map(c => String(c[0])).join('\n') + const warned = warnSpy.mock.calls.map(c => messageText(c[0])).join('\n') expect(warned).toMatch(/facts is false/) const byKey = new Map( @@ -990,7 +998,7 @@ describe('generateRecursiveManifests', () => { // moduleB + independent-submodule), but only the root cause should // warn - otherwise a big disabled reactor spams one line per pom. expect(warnSpy).toHaveBeenCalledTimes(1) - expect(String(warnSpy.mock.calls[0]?.[0])).toMatch( + expect(messageText(warnSpy.mock.calls[0]?.[0])).toMatch( /sets defaults\.manifest\.maven\.disabled/, ) } finally { @@ -1087,7 +1095,7 @@ describe('generateRecursiveManifests', () => { verbose: false, }) - const warned = warnSpy.mock.calls.map(c => String(c[0])).join('\n') + const warned = warnSpy.mock.calls.map(c => messageText(c[0])).join('\n') expect(warned).toMatch(/sets defaults\.manifest\.maven\.disabled/) const byKey = new Map( @@ -1355,7 +1363,7 @@ describe('generateRecursiveManifests', () => { expect(cascadeDirs.length).toBeGreaterThan(0) expect(cascadeDirs).toEqual([...new Set(cascadeDirs)]) expect( - warnSpy.mock.calls.filter(c => String(c[0]).includes('--file')), + warnSpy.mock.calls.filter(c => messageText(c[0]).includes('--file')), ).toHaveLength(cascadeDirs.length) expect( vi.mocked(runManifestFacts).mock.calls.map(([o]) => o.buildOpts), @@ -1433,7 +1441,7 @@ describe('generateRecursiveManifests', () => { const byDir = new Map( outcomes .filter(o => o.ecosystem === 'gradle') - .map(o => [path.relative(outer, o.dir) || '.', o.status]), + .map(o => [relativePosixPath(outer, o.dir), o.status]), ) expect(byDir.get('.')).toBe('generated') expect(byDir.get('sub')).toBe(subStatus) @@ -1441,7 +1449,7 @@ describe('generateRecursiveManifests', () => { expect( vi .mocked(runManifestFacts) - .mock.calls.map(([o]) => path.relative(outer, o.cwd) || '.'), + .mock.calls.map(([o]) => relativePosixPath(outer, o.cwd)), ).toEqual(['.', 'sub']) }, ) @@ -1504,16 +1512,16 @@ describe('generateRecursiveManifests', () => { }) const byDir = new Map( - outcomes.map(o => [path.relative(outer, o.dir) || '.', o.status]), + outcomes.map(o => [relativePosixPath(outer, o.dir), o.status]), ) expect(byDir.get('sub')).toBe('skippedDisabled') expect(byDir.get('sub/a')).toBe('skippedDisabled') expect( vi .mocked(runManifestFacts) - .mock.calls.map(([o]) => path.relative(outer, o.cwd) || '.'), + .mock.calls.map(([o]) => relativePosixPath(outer, o.cwd)), ).toEqual(['.']) - expect(warnSpy.mock.calls.map(c => String(c[0]))).toEqual([ + expect(warnSpy.mock.calls.map(c => messageText(c[0]))).toEqual([ expect.stringMatching( new RegExp( `^Skipping \\S*sub${modules ? ` ${modules}` : ''}: \\S*sub/socket\\.json sets defaults\\.manifest\\.builds\\["settings\\.gradle"\\]\\.disabled\\.$`, @@ -1598,7 +1606,7 @@ describe('generateRecursiveManifests', () => { o => o.ecosystem === 'maven' && relOf(o.dir) === 'reactor/moduleA', )?.status, ).toBe('skippedCovered') - const warned = warnSpy.mock.calls.map(c => String(c[0])) + const warned = warnSpy.mock.calls.map(c => messageText(c[0])) expect( warned.filter(w => w.includes('defaults.manifest.builds["pom.xml"]')), ).toEqual([ @@ -1674,7 +1682,10 @@ describe('generateRecursiveManifests', () => { }) const byRoot = new Map( - outcomes.map(o => [path.relative(outer, buildRootPath(o)), o.status]), + outcomes.map(o => [ + relativePosixPath(outer, buildRootPath(o)), + o.status, + ]), ) expect(Object.fromEntries(byRoot)).toEqual({ 'aaa-module/pom.xml': 'skippedDisabled', @@ -1693,7 +1704,7 @@ describe('generateRecursiveManifests', () => { entryFile: 'pom.xml', }), ) - expect(warnSpy.mock.calls.map(c => String(c[0]))).toEqual([ + expect(warnSpy.mock.calls.map(c => messageText(c[0]))).toEqual([ expect.stringMatching( /^Skipping \S*legacy\/pom\.xml and its 2 modules: \S*legacy\/socket\.json sets defaults\.manifest\.builds\["pom\.xml"\]\.disabled\.$/, ), @@ -1738,7 +1749,7 @@ describe('generateRecursiveManifests', () => { o.dir === path.join(outer, 'legacy') && o.entryFile === 'pom.xml', )?.status, ).toBe('skippedCovered') - const warned = warnSpy.mock.calls.map(c => String(c[0])) + const warned = warnSpy.mock.calls.map(c => messageText(c[0])) expect(warned.some(w => w.startsWith('Skipping'))).toBe(false) expect(warned).toContainEqual( expect.stringMatching( @@ -1765,12 +1776,15 @@ describe('generateRecursiveManifests', () => { }) const byRoot = new Map( - outcomes.map(o => [path.relative(outer, buildRootPath(o)), o.status]), + outcomes.map(o => [ + relativePosixPath(outer, buildRootPath(o)), + o.status, + ]), ) expect(byRoot.get('legacy/pom.xml')).toBe('failed') expect(byRoot.get('legacy/old/pom.xml')).toBe('aborted') expect(byRoot.get('aaa-module/pom.xml')).toBe('generated') - expect(String(failSpy.mock.calls.at(-1)?.[0])).toMatch( + expect(messageText(failSpy.mock.calls.at(-1)?.[0])).toMatch( /^Could not load \S*legacy\/pom\.xml .* with `socket manifest setup --dynamic-sbom-inference`\.$/, ) expect(process.exitCode).toBe(1) @@ -1853,7 +1867,10 @@ describe('generateRecursiveManifests', () => { expect( Object.fromEntries( - outcomes.map(o => [path.relative(outer, buildRootPath(o)), o.status]), + outcomes.map(o => [ + relativePosixPath(outer, buildRootPath(o)), + o.status, + ]), ), ).toEqual({ 'p/a/A.csproj': 'skippedCovered', @@ -1863,7 +1880,7 @@ describe('generateRecursiveManifests', () => { 'y/Y.sln': 'skippedCovered', 'z/App.sln': 'skippedCovered', }) - expect(warnSpy.mock.calls.map(c => String(c[0]))).toContainEqual( + expect(warnSpy.mock.calls.map(c => messageText(c[0]))).toContainEqual( expect.stringMatching( /^defaults\.manifest\.builds\["Y\.sln"\] in \S*y\/socket\.json does not apply: \S*r\/R\.sln builds \S*y\/Y\.sln with its own settings\.$/, ), diff --git a/src/commands/manifest/scripts/run.test.mts b/src/commands/manifest/scripts/run.test.mts index 663e5ca4de..75f69db264 100644 --- a/src/commands/manifest/scripts/run.test.mts +++ b/src/commands/manifest/scripts/run.test.mts @@ -146,7 +146,7 @@ describe('--exclude-paths anchoring', () => { let dotnetCase = 0 function dotnetDir(): string { dotnetCase += 1 - return path.join(path.sep, 'repo', `dotnet-${dotnetCase}`) + return path.resolve(path.sep, 'repo', `dotnet-${dotnetCase}`) } // Answers `dotnet --version` with `sdk`, then runs the tool, which writes diff --git a/src/commands/manifest/setup-recursive-manifest-config.mts b/src/commands/manifest/setup-recursive-manifest-config.mts index c2759f1f03..e08486ece6 100644 --- a/src/commands/manifest/setup-recursive-manifest-config.mts +++ b/src/commands/manifest/setup-recursive-manifest-config.mts @@ -327,7 +327,7 @@ function otherBuilds(count: number): string { } function relPath(cwd: string, file: string): string { - return path.relative(cwd, file) || '.' + return (path.relative(cwd, file) || '.').split(path.sep).join('/') } // One build of the walk; a directory holding several builds of one tool has diff --git a/src/commands/manifest/setup-recursive-manifest-config.test.mts b/src/commands/manifest/setup-recursive-manifest-config.test.mts index d8dffe7c49..eb3d509ca4 100644 --- a/src/commands/manifest/setup-recursive-manifest-config.test.mts +++ b/src/commands/manifest/setup-recursive-manifest-config.test.mts @@ -62,10 +62,11 @@ function project(subprojectDir: string): SocketFactsSbomProject { describe('scanBuildRoots', () => { it('runs the unfiltered and excludePaths-filtered walks once each and returns both', async () => { + const cwd = path.resolve('/repo') const unfiltered = new Map([ - ['gradle', dirRoots('/repo/a', '/repo/legacy')], + ['gradle', dirRoots(path.join(cwd, 'a'), path.join(cwd, 'legacy'))], ]) - const filtered = new Map([['gradle', dirRoots('/repo/a')]]) + const filtered = new Map([['gradle', dirRoots(path.join(cwd, 'a'))]]) const walk = async ({ excludePaths, }: { @@ -76,7 +77,7 @@ describe('scanBuildRoots', () => { .mockImplementationOnce(walk) const result = await scanBuildRoots({ - cwd: '/repo', + cwd, excludePaths: ['legacy'], sockJson: { version: 1 } as SocketJson, }) @@ -86,7 +87,7 @@ describe('scanBuildRoots', () => { }) describe('discoverBuildRoots', () => { - const cwd = '/repo' + const cwd = path.resolve('/repo') it('leaves out cwd itself', async () => { const result = await discoverBuildRoots({ @@ -103,23 +104,28 @@ describe('discoverBuildRoots', () => { cwd, excludePaths: ['legacy'], fullByTool: new Map([ - ['maven', mavenRoots('/repo/legacy/a', '/repo/active')], - ['gradle', dirRoots('/repo/legacy/b')], + [ + 'maven', + mavenRoots(path.join(cwd, 'legacy/a'), path.join(cwd, 'active')), + ], + ['gradle', dirRoots(path.join(cwd, 'legacy/b'))], ]), includedByTool: new Map([ - ['maven', mavenRoots('/repo/active')], + ['maven', mavenRoots(path.join(cwd, 'active'))], ['gradle', dirRoots()], ]), }) expect(result).toEqual({ - excluded: [{ dir: '/repo/legacy', ecosystems: ['gradle', 'maven'] }], + excluded: [ + { dir: path.join(cwd, 'legacy'), ecosystems: ['gradle', 'maven'] }, + ], excludedBuilds: [], included: [ { - dir: '/repo/active', + dir: path.join(cwd, 'active'), ecosystem: 'maven', - roots: mavenRoots('/repo/active'), + roots: mavenRoots(path.join(cwd, 'active')), }, ], }) @@ -184,7 +190,10 @@ describe('setupRecursiveManifestConfig', () => { vi .mocked(enumerateWorkspaces) .mockImplementation(async ({ cwd, entryFile }) => { - const rel = path.relative(repo, path.join(cwd, entryFile ?? '')) + const rel = path + .relative(repo, path.join(cwd, entryFile ?? '')) + .split(path.sep) + .join('/') if (rel in modules && !modules[rel]) { return undefined } @@ -201,9 +210,12 @@ describe('setupRecursiveManifestConfig', () => { }) const answer = (answers: Answers) => vi.mocked(select).mockImplementation(async ({ choices, message }) => { - asked.push(message) - choicesOf.set(message, choices as Choice[]) - const rule = answers.find(({ 0: start }) => message.startsWith(start)) + const normalizedMessage = message.replaceAll('\\', '/') + asked.push(normalizedMessage) + choicesOf.set(normalizedMessage, choices as Choice[]) + const rule = answers.find(({ 0: start }) => + normalizedMessage.startsWith(start), + ) if (!rule) { throw new Error(`Unexpected prompt: ${message}`) } @@ -417,7 +429,7 @@ describe('setupRecursiveManifestConfig', () => { await setupRecursiveManifestConfig(file('legacy/tool'), false) expect(asked[0]).toMatch( - /^\S*legacy\/socket\.json skips Maven builds in and beneath \S*legacy, including this directory\. Build the Maven projects here\?$/, + /^\S*legacy[\\/]socket\.json skips Maven builds in and beneath \S*legacy, including this directory\. Build the Maven projects here\?$/, ) expect(await readSettings('legacy/tool')).toMatchObject({ defaults: { manifest: { maven: { disabled: false } } }, diff --git a/src/commands/optimize/cmd-optimize.test.mts b/src/commands/optimize/cmd-optimize.test.mts index 13dcc47b1f..7f49d0f768 100644 --- a/src/commands/optimize/cmd-optimize.test.mts +++ b/src/commands/optimize/cmd-optimize.test.mts @@ -488,7 +488,7 @@ describe('socket optimize', async () => { await trash(tempDir) } }, - { timeout: 120_000 }, + { timeout: process.platform === 'win32' ? 300_000 : 120_000 }, ) cmdit( @@ -522,7 +522,7 @@ describe('socket optimize', async () => { const output = stdout + stderr expect(output).toMatch(/Optimizing|Adding overrides/i) }, - { timeout: 120_000 }, + { timeout: process.platform === 'win32' ? 300_000 : 120_000 }, ) cmdit( diff --git a/src/commands/optimize/ls-by-agent.mts b/src/commands/optimize/ls-by-agent.mts index c5005dc77b..464f08dd6d 100644 --- a/src/commands/optimize/ls-by-agent.mts +++ b/src/commands/optimize/ls-by-agent.mts @@ -103,7 +103,7 @@ export async function lsPnpm( __proto__: null, ...options, } as AgentListDepsOptions - if (npmExecPath && npmExecPath !== NPM) { + if (!constants.WIN32 && npmExecPath && npmExecPath !== NPM) { const result = await npmQuery(npmExecPath, cwd) if (result) { return result diff --git a/src/utils/coana-release.mts b/src/utils/coana-release.mts index b570d6ecbd..dd80f93452 100644 --- a/src/utils/coana-release.mts +++ b/src/utils/coana-release.mts @@ -67,6 +67,7 @@ type CoanaDownload = { ok: true } | { ok: false; status: number } type CoanaSpawnOptions = { coanaVersion?: string | undefined cwd?: string | URL | undefined + env?: Record | undefined repoName?: string | undefined spinner?: Spinner | undefined stdio?: SpawnOptions['stdio'] | undefined @@ -114,7 +115,8 @@ function coanaUserEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv { const out: NodeJS.ProcessEnv = {} for (const key of Object.keys(env)) { out[key] = - key.startsWith('npm_package_') || TOKEN_VARIABLES.has(key) + key.toLowerCase().startsWith('npm_package_') || + TOKEN_VARIABLES.has(key.toUpperCase()) ? undefined : env[key] } @@ -419,6 +421,7 @@ export async function spawnCoana( const { coanaVersion, cwd, + env: spawnEnv, repoName, spinner, stdio = 'inherit', @@ -487,6 +490,13 @@ export async function spawnCoana( env[name] = value } } + for (const { 0: name, 1: value } of Object.entries( + coanaUserEnv(spawnEnv ?? {}), + )) { + if (!TOKEN_VARIABLES.has(name.toUpperCase())) { + env[name] = value + } + } let scriptPath = localPath if (!scriptPath) { diff --git a/src/utils/coana-release.test.mts b/src/utils/coana-release.test.mts index b922640b86..dd22175c14 100644 --- a/src/utils/coana-release.test.mts +++ b/src/utils/coana-release.test.mts @@ -129,10 +129,16 @@ describe('spawnCoana', () => { try { const { env } = await runFake() - expect(env['npm_package_dependencies_react']).toBeUndefined() - expect(env['npm_config_registry']).toBe( - 'https://artifactory.example/npm/', - ) + expect( + Object.entries(env).find( + ([key]) => key.toLowerCase() === 'npm_package_dependencies_react', + )?.[1], + ).toBeUndefined() + expect( + Object.entries(env).find( + ([key]) => key.toLowerCase() === 'npm_config_registry', + )?.[1], + ).toBe('https://artifactory.example/npm/') } finally { delete process.env['npm_package_dependencies_react'] delete process.env['npm_config_registry'] @@ -160,6 +166,24 @@ describe('spawnCoana', () => { } }) + it('applies caller environment overrides without replacing the Socket token', async () => { + overrideCachedConfig(JSON.stringify({ apiToken: 'socket-cli-token' })) + try { + const apiToken = await resolveDefaultApiToken() + const { env } = await runFake({ + env: { + SOCKET_CALLER_USER_AGENT: 'custom-caller-agent/1.0.0', + SOCKET_CLI_API_TOKEN: 'user-token', + }, + }) + + expect(env['SOCKET_CALLER_USER_AGENT']).toBe('custom-caller-agent/1.0.0') + expect(env['SOCKET_CLI_API_TOKEN']).toBe(apiToken) + } finally { + resetConfigForTesting() + } + }) + it.for([ { name: 'names no repository', repoName: undefined }, { diff --git a/test/pin-readme-assets.test.mts b/test/pin-readme-assets.test.mts index ebc78435ef..6ba3c608c9 100644 --- a/test/pin-readme-assets.test.mts +++ b/test/pin-readme-assets.test.mts @@ -42,6 +42,10 @@ function readmeIn(dir: string): string { return readFileSync(path.join(dir, 'README.md'), 'utf8') } +function testPinReadmeAssets(name: string, run: () => void): void { + it(name, { timeout: process.platform === 'win32' ? 30_000 : 5_000 }, run) +} + afterEach(() => { for (const dir of tempDirs.splice(0)) { rmSync(dir, { force: true, recursive: true }) @@ -55,18 +59,21 @@ afterEach(() => { describe('pin-readme-assets', () => { const base = 'https://raw.githubusercontent.com/SocketDev/socket-cli/v1.2.3/' - it('pins a relative img src to the release tag raw URL', () => { - const dir = stageWorkspace({ - readme: 'logo\n', - }) - const { status } = runPin(dir) - expect(status).toBe(0) - expect(readmeIn(dir)).toBe( - `logo\n`, - ) - }) + testPinReadmeAssets( + 'pins a relative img src to the release tag raw URL', + () => { + const dir = stageWorkspace({ + readme: 'logo\n', + }) + const { status } = runPin(dir) + expect(status).toBe(0) + expect(readmeIn(dir)).toBe( + `logo\n`, + ) + }, + ) - it('pins a relative srcset ref', () => { + testPinReadmeAssets('pins a relative srcset ref', () => { const dir = stageWorkspace({ readme: '\n', @@ -77,7 +84,7 @@ describe('pin-readme-assets', () => { ) }) - it('pins a markdown image ref', () => { + testPinReadmeAssets('pins a markdown image ref', () => { const dir = stageWorkspace({ readme: '![banner](assets/banner.png)\n', }) @@ -85,7 +92,7 @@ describe('pin-readme-assets', () => { expect(readmeIn(dir)).toBe(`![banner](${base}assets/banner.png)\n`) }) - it('reads the tag from package.json version', () => { + testPinReadmeAssets('reads the tag from package.json version', () => { const dir = stageWorkspace({ readme: '![banner](assets/banner.png)\n', version: '9.9.9', @@ -96,7 +103,7 @@ describe('pin-readme-assets', () => { ) }) - it('leaves absolute refs untouched', () => { + testPinReadmeAssets('leaves absolute refs untouched', () => { const readme = '\n' + '![ext](https://example.com/assets/banner.png)\n' @@ -107,7 +114,7 @@ describe('pin-readme-assets', () => { expect(stdout).toContain('no relative assets/ refs to pin') }) - it('is idempotent — a second run changes nothing', () => { + testPinReadmeAssets('is idempotent — a second run changes nothing', () => { const dir = stageWorkspace({ readme: '\n' + @@ -122,7 +129,7 @@ describe('pin-readme-assets', () => { expect(stdout).toContain('no relative assets/ refs to pin') }) - it('pins a reference-style definition', () => { + testPinReadmeAssets('pins a reference-style definition', () => { const dir = stageWorkspace({ readme: '![banner][banner-ref]\n\n[banner-ref]: assets/banner.png\n', }) @@ -133,7 +140,7 @@ describe('pin-readme-assets', () => { ) }) - it('pins refs inside blockquotes and list items', () => { + testPinReadmeAssets('pins refs inside blockquotes and list items', () => { const dir = stageWorkspace({ readme: '> ![quoted](assets/quoted.png)\n' + @@ -148,49 +155,58 @@ describe('pin-readme-assets', () => { ) }) - it('leaves assets/ refs inside fenced code blocks alone', () => { - const readme = - '```md\n' + - '![example](assets/example.png)\n' + - '\n' + - '```\n' - const dir = stageWorkspace({ readme }) - const { status, stdout } = runPin(dir) - expect(status).toBe(0) - expect(readmeIn(dir)).toBe(readme) - expect(stdout).toContain('no relative assets/ refs to pin') - }) + testPinReadmeAssets( + 'leaves assets/ refs inside fenced code blocks alone', + () => { + const readme = + '```md\n' + + '![example](assets/example.png)\n' + + '\n' + + '```\n' + const dir = stageWorkspace({ readme }) + const { status, stdout } = runPin(dir) + expect(status).toBe(0) + expect(readmeIn(dir)).toBe(readme) + expect(stdout).toContain('no relative assets/ refs to pin') + }, + ) - it('leaves assets/ refs inside inline code spans alone', () => { - const readme = 'Point refs like `](assets/x.png)` at the release tag.\n' - const dir = stageWorkspace({ readme }) - const { status, stdout } = runPin(dir) - expect(status).toBe(0) - expect(readmeIn(dir)).toBe(readme) - expect(stdout).toContain('no relative assets/ refs to pin') - }) + testPinReadmeAssets( + 'leaves assets/ refs inside inline code spans alone', + () => { + const readme = 'Point refs like `](assets/x.png)` at the release tag.\n' + const dir = stageWorkspace({ readme }) + const { status, stdout } = runPin(dir) + expect(status).toBe(0) + expect(readmeIn(dir)).toBe(readme) + expect(stdout).toContain('no relative assets/ refs to pin') + }, + ) - it('pins real refs while leaving code-block lookalikes alone', () => { - const dir = stageWorkspace({ - readme: - '![banner](assets/banner.png)\n' + - '\n' + - '```html\n' + - '\n' + - '```\n', - }) - const { status } = runPin(dir) - expect(status).toBe(0) - expect(readmeIn(dir)).toBe( - `![banner](${base}assets/banner.png)\n` + - '\n' + - '```html\n' + - '\n' + - '```\n', - ) - }) + testPinReadmeAssets( + 'pins real refs while leaving code-block lookalikes alone', + () => { + const dir = stageWorkspace({ + readme: + '![banner](assets/banner.png)\n' + + '\n' + + '```html\n' + + '\n' + + '```\n', + }) + const { status } = runPin(dir) + expect(status).toBe(0) + expect(readmeIn(dir)).toBe( + `![banner](${base}assets/banner.png)\n` + + '\n' + + '```html\n' + + '\n' + + '```\n', + ) + }, + ) - it('pins refs inside GFM tables and footnotes', () => { + testPinReadmeAssets('pins refs inside GFM tables and footnotes', () => { const dir = stageWorkspace({ readme: '| Logo | Name |\n' + @@ -208,24 +224,27 @@ describe('pin-readme-assets', () => { expect(pinned).toContain(`[^shot]: ![shot](${base}assets/shot.png)`) }) - it('pins every ref form in one pass and reports the base', () => { - const dir = stageWorkspace({ - readme: - '\n' + - ' \n' + - ' Socket CLI\n' + - '\n' + - '\n' + - 'See ![the flow](assets/flow.png) for details.\n', - }) - const { status, stdout } = runPin(dir) - expect(status).toBe(0) - expect(stdout).toContain(`pinned relative assets/ refs to ${base}`) - const pinned = readmeIn(dir) - expect(pinned).not.toContain('"assets/') - expect(pinned).not.toContain('](assets/') - expect(pinned).toContain(`src="${base}assets/light.png"`) - expect(pinned).toContain(`srcset="${base}assets/dark.png"`) - expect(pinned).toContain(`](${base}assets/flow.png)`) - }) + testPinReadmeAssets( + 'pins every ref form in one pass and reports the base', + () => { + const dir = stageWorkspace({ + readme: + '\n' + + ' \n' + + ' Socket CLI\n' + + '\n' + + '\n' + + 'See ![the flow](assets/flow.png) for details.\n', + }) + const { status, stdout } = runPin(dir) + expect(status).toBe(0) + expect(stdout).toContain(`pinned relative assets/ refs to ${base}`) + const pinned = readmeIn(dir) + expect(pinned).not.toContain('"assets/') + expect(pinned).not.toContain('](assets/') + expect(pinned).toContain(`src="${base}assets/light.png"`) + expect(pinned).toContain(`srcset="${base}assets/dark.png"`) + expect(pinned).toContain(`](${base}assets/flow.png)`) + }, + ) }) diff --git a/test/release-artifact-download.test.mts b/test/release-artifact-download.test.mts index 06895526a0..3d72427974 100644 --- a/test/release-artifact-download.test.mts +++ b/test/release-artifact-download.test.mts @@ -52,7 +52,16 @@ function downloadFixture(names = filenames) { writeFileSync(path.join(source, name), 'verified package bytes') } const archive = path.join(root, 'fixture.zip') - execFileSync('zip', ['-q', '-0', archive, ...names], { cwd: source }) + if (process.platform === 'win32') { + execFileSync('powershell.exe', [ + '-NoProfile', + '-NonInteractive', + '-Command', + `Compress-Archive -Path '${path.join(source, '*')}' -DestinationPath '${archive}' -Force`, + ]) + } else { + execFileSync('zip', ['-q', '-0', archive, ...names], { cwd: source }) + } const metadata = path.join(root, 'fixture.json') writeFileSync( metadata, diff --git a/test/setup-node.test.mts b/test/setup-node.test.mts index 4d340adc89..0760846664 100644 --- a/test/setup-node.test.mts +++ b/test/setup-node.test.mts @@ -20,7 +20,7 @@ import { parseNodeSetupVersion, resolveNodeSetupVersion, runNodeSetup, -} from '../scripts/ci/setup-node.mjs' +} from '../scripts/setup/node.mts' const directories: string[] = [] diff --git a/test/setup-uv.test.mts b/test/setup-uv.test.mts index 9d05213443..57e36708fb 100644 --- a/test/setup-uv.test.mts +++ b/test/setup-uv.test.mts @@ -14,7 +14,7 @@ import path from 'node:path' import { afterEach, describe, expect, it, vi } from 'vitest' import { parse } from 'yaml' -import { installUvForCi, uvSetupRelease } from '../scripts/ci/setup-uv.mts' +import { installUvForCi, uvSetupRelease } from '../scripts/setup/uv.mts' const directories: string[] = [] @@ -162,7 +162,11 @@ describe('verified uv installation', () => { }, ) - it.each(['failure', 'missing', 'nonexecutable'])( + it.each([ + 'failure', + 'missing', + ...(process.platform === 'win32' ? [] : ['nonexecutable']), + ])( 'cleans an extraction with %s uv without exporting PATH', async condition => { const fixture = await uvFixture() @@ -205,17 +209,20 @@ describe('verified uv installation', () => { }, ) - it('runs the installed executable to confirm its version', async () => { - const fixture = await uvFixture() - const result = await installUvForCi(fixture.options, { - extract: fixture.dependencies.extract, - fetcher: fixture.dependencies.fetcher, - release: fixture.release, - }) - expect(await readFile(fixture.options.githubPath, 'utf8')).toBe( - 'existing-bin\n' + result.bin + '\n', - ) - }) + it.skipIf(process.platform === 'win32')( + 'runs the installed executable to confirm its version', + async () => { + const fixture = await uvFixture() + const result = await installUvForCi(fixture.options, { + extract: fixture.dependencies.extract, + fetcher: fixture.dependencies.fetcher, + release: fixture.release, + }) + expect(await readFile(fixture.options.githubPath, 'utf8')).toBe( + 'existing-bin\n' + result.bin + '\n', + ) + }, + ) it('downloads again when an installation already exists', async () => { const fixture = await uvFixture() @@ -259,5 +266,5 @@ it('installs uv after Node and before SFW shims through its registered script', const manifest = JSON.parse( await readFile(new URL('../package.json', import.meta.url), 'utf8'), ) as { scripts: Record } - expect(manifest.scripts['ci:setup-uv']).toBe('node scripts/ci/setup-uv.mts') + expect(manifest.scripts['ci:setup-uv']).toBe('node scripts/setup/uv.mts') }) diff --git a/test/unit/github/actions/repo/cache-downloads/index.test.mts b/test/unit/github/actions/repo/cache-downloads/index.test.mts index f26f0dcc3e..e8196643be 100644 --- a/test/unit/github/actions/repo/cache-downloads/index.test.mts +++ b/test/unit/github/actions/repo/cache-downloads/index.test.mts @@ -1,4 +1,5 @@ import { afterEach, describe, expect, it, vi } from 'vitest' +import path from 'node:path' vi.mock('@actions/cache', () => ({ restoreCache: vi.fn(), @@ -22,12 +23,19 @@ afterEach(() => { describe('SEA download cache action', () => { it('limits the cache path to content-addressed blobs', () => { - expect(seaDownloadBlobPath('/home/runner')).toBe( - '/home/runner/.cache/socket-sea/downloads/v1/blobs', + const home = path.join(path.parse(process.cwd()).root, 'home', 'runner') + const blobs = path.join( + home, + '.cache', + 'socket-sea', + 'downloads', + 'v1', + 'blobs', ) + expect(seaDownloadBlobPath(home)).toBe(blobs) expect( - resolveBlobPath('~/.cache/socket-sea/downloads/v1/blobs', '/home/runner'), - ).toBe('/home/runner/.cache/socket-sea/downloads/v1/blobs') + resolveBlobPath('~/.cache/socket-sea/downloads/v1/blobs', home), + ).toBe(blobs) expect(() => resolveBlobPath('~/.cache/socket-sea/downloads', '/home/runner'), ).toThrow('must target only the blob directory') diff --git a/tsconfig.json b/tsconfig.json index 84b2dcaa23..fb737e7690 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "scripts/ci/**/*.mts", "scripts/lib/**/*.mts", "scripts/release/**/*.mts", + "scripts/setup/**/*.mts", "scripts/utils/**/*.mts" ], "exclude": [