From c7f515addedc6bd5e011d64e56e876868aae8b2c Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Tue, 17 Feb 2026 18:52:15 -0800 Subject: [PATCH] feat: Add auto-fix for SSH URLs in lockfile before linting --- .github/actions/setup-project/action.yml | 17 ++++++++++++----- .husky/pre-commit | 12 ++++++++++++ package-lock.json | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/actions/setup-project/action.yml b/.github/actions/setup-project/action.yml index 0fcd1e4f..6a29f8e7 100644 --- a/.github/actions/setup-project/action.yml +++ b/.github/actions/setup-project/action.yml @@ -25,17 +25,24 @@ runs: cache: 'npm' cache-dependency-path: package-lock.json - - name: Check for SSH URLs in lockfile - if: inputs.check-lockfile == 'true' - shell: bash - run: npm run lint:lockfile - - name: Configure Git for HTTPS shell: bash # Convert SSH URLs to HTTPS for git dependencies (e.g., @electron/node-gyp) # This is needed because SSH authentication isn't available in CI run: git config --global url."https://github.com/".insteadOf "git@github.com:" + - name: Auto-fix SSH URLs in lockfile + if: inputs.check-lockfile == 'true' + shell: bash + # Auto-fix any git+ssh:// URLs in package-lock.json before linting + # This handles cases where npm reintroduces SSH URLs for git dependencies + run: node scripts/fix-lockfile-urls.mjs + + - name: Check for SSH URLs in lockfile + if: inputs.check-lockfile == 'true' + shell: bash + run: npm run lint:lockfile + - name: Install dependencies shell: bash # Use npm install instead of npm ci to correctly resolve platform-specific diff --git a/.husky/pre-commit b/.husky/pre-commit index f61fd35b..4c156c16 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -38,6 +38,18 @@ else export PATH="$PATH:/usr/local/bin:/opt/homebrew/bin:/usr/bin" fi +# Auto-fix git+ssh:// URLs in package-lock.json if it's being committed +# This prevents CI failures from SSH URLs that npm introduces for git dependencies +if git diff --cached --name-only | grep -q "^package-lock.json$"; then + if command -v node >/dev/null 2>&1; then + if grep -q "git+ssh://" package-lock.json 2>/dev/null; then + echo "Fixing git+ssh:// URLs in package-lock.json..." + node scripts/fix-lockfile-urls.mjs + git add package-lock.json + fi + fi +fi + # Run lint-staged - works with or without nvm # Prefer npx, fallback to npm exec, both work with system-installed Node.js if command -v npx >/dev/null 2>&1; then diff --git a/package-lock.json b/package-lock.json index 271b40f6..ee6041c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1553,7 +1553,7 @@ }, "node_modules/@electron/node-gyp": { "version": "10.2.0-electron.1", - "resolved": "git+ssh://git@github.com/electron/node-gyp.git#06b29aafb7708acef8b3669835c8a7857ebc92d2", + "resolved": "git+https://github.com/electron/node-gyp.git#06b29aafb7708acef8b3669835c8a7857ebc92d2", "integrity": "sha512-4MSBTT8y07YUDqf69/vSh80Hh791epYqGtWHO3zSKhYFwQg+gx9wi1PqbqP6YqC4WMsNxZ5l9oDmnWdK5pfCKQ==", "dev": true, "license": "MIT",