diff --git a/.github/workflows/sync-vscode-engine.yml b/.github/workflows/sync-vscode-engine.yml new file mode 100644 index 0000000..6dc7997 --- /dev/null +++ b/.github/workflows/sync-vscode-engine.yml @@ -0,0 +1,99 @@ +# This workflow automatically updates engines.vscode when @types/vscode has a major or minor version change +name: Sync VSCode Engine Version + +on: + pull_request: + types: [opened, synchronize, reopened] + paths: + - 'package.json' + - 'package-lock.json' + +permissions: + contents: write + pull-requests: write + +jobs: + sync-vscode-engine: + # Only run for dependabot PRs + if: github.actor == 'dependabot[bot]' + runs-on: ubuntu-latest + + steps: + - name: Checkout PR branch + uses: actions/checkout@v6 + with: + ref: ${{ github.head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: '22' + + - name: Check if @types/vscode was updated + id: check_update + run: | + # Get the PR title + PR_TITLE="${{ github.event.pull_request.title }}" + echo "PR Title: $PR_TITLE" + + # Check if this PR is about @types/vscode + if [[ "$PR_TITLE" == *"@types/vscode"* ]]; then + echo "types_vscode_updated=true" >> $GITHUB_OUTPUT + + # Extract version from package.json + TYPES_VERSION=$(node -p "require('./package.json').devDependencies['@types/vscode']" | sed 's/[\^~]//g') + echo "types_version=$TYPES_VERSION" >> $GITHUB_OUTPUT + echo "Found @types/vscode version: $TYPES_VERSION" + else + echo "types_vscode_updated=false" >> $GITHUB_OUTPUT + fi + + - name: Update engines.vscode + if: steps.check_update.outputs.types_vscode_updated == 'true' + id: update_engine + run: | + TYPES_VERSION="${{ steps.check_update.outputs.types_version }}" + + # Extract major.minor from the version (e.g., 1.109.0 -> 1.109) + MAJOR_MINOR=$(echo "$TYPES_VERSION" | cut -d. -f1,2) + ENGINE_VERSION="^${MAJOR_MINOR}.0" + + echo "Setting engines.vscode to: $ENGINE_VERSION" + + # Update package.json using node + node -e " + const fs = require('fs'); + const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); + const currentEngine = pkg.engines.vscode; + const newEngine = '$ENGINE_VERSION'; + + console.log('Current engines.vscode:', currentEngine); + console.log('New engines.vscode:', newEngine); + + if (currentEngine !== newEngine) { + pkg.engines.vscode = newEngine; + fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); + console.log('Updated engines.vscode'); + console.log('changes_made=true'); + } else { + console.log('No update needed'); + console.log('changes_made=false'); + } + " | tee /tmp/update-output.txt + + # Extract the changes_made value from output + if grep -q "changes_made=true" /tmp/update-output.txt; then + echo "changes_made=true" >> $GITHUB_OUTPUT + else + echo "changes_made=false" >> $GITHUB_OUTPUT + fi + + - name: Commit changes + if: steps.check_update.outputs.types_vscode_updated == 'true' && steps.update_engine.outputs.changes_made == 'true' + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add package.json + git commit -m "chore: update engines.vscode to match @types/vscode version" + git push diff --git a/package-lock.json b/package-lock.json index 8e8aa02..4e38820 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@eslint/js": "^9.17.0", "@types/mocha": "^10.0.10", "@types/node": "22.x", - "@types/vscode": "^1.108.0", + "@types/vscode": "^1.109.0", "@vscode/test-cli": "^0.0.12", "@vscode/test-electron": "^2.4.1", "@vscode/vsce": "^3.2.2", @@ -990,9 +990,9 @@ "license": "MIT" }, "node_modules/@types/vscode": { - "version": "1.108.1", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.108.1.tgz", - "integrity": "sha512-DerV0BbSzt87TbrqmZ7lRDIYaMiqvP8tmJTzW2p49ZBVtGUnGAu2RGQd1Wv4XMzEVUpaHbsemVM5nfuQJj7H6w==", + "version": "1.109.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.109.0.tgz", + "integrity": "sha512-0Pf95rnwEIwDbmXGC08r0B4TQhAbsHQ5UyTIgVgoieDe4cOnf92usuR5dEczb6bTKEp7ziZH4TV1TRGPPCExtw==", "dev": true, "license": "MIT" }, diff --git a/package.json b/package.json index 25f5571..7ff4f77 100644 --- a/package.json +++ b/package.json @@ -135,7 +135,7 @@ "@eslint/js": "^9.17.0", "@types/mocha": "^10.0.10", "@types/node": "22.x", - "@types/vscode": "^1.108.0", + "@types/vscode": "^1.109.0", "@vscode/test-cli": "^0.0.12", "@vscode/test-electron": "^2.4.1", "@vscode/vsce": "^3.2.2",