1
0
Fork 0
mirror of https://github.com/imjasonh/apidiff-action synced 2026-07-06 22:52:43 +00:00

Configure Node.js v20 for local development

- Add .node-version and .nvmrc files specifying Node 20.9.0
- Add engines field to package.json requiring Node 20
- Re-enable dist build/check hooks in pre-commit
- Add build-dist workflow for automated builds with Node 20
- Update documentation with Node version requirements

This ensures consistent builds between local development and CI.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jason Hall 2025-07-30 09:13:03 -04:00
parent 1cabe34a14
commit 9f05344e16
Failed to extract signature
6 changed files with 80 additions and 24 deletions

52
.github/workflows/build-dist.yml vendored Normal file
View file

@ -0,0 +1,52 @@
name: Build dist
on:
push:
branches: [main]
paths:
- 'index.js'
- 'lib/**'
- 'package.json'
- 'package-lock.json'
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build dist
run: npm run build
- name: Check for changes
id: check-changes
run: |
if [ -n "$(git status --porcelain dist)" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Commit and push if changed
if: steps.check-changes.outputs.changes == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add dist/
git commit -m "Build dist with Node 20
🤖 Automated build from workflow"
git push

1
.node-version Normal file
View file

@ -0,0 +1 @@
20.9.0

1
.nvmrc Normal file
View file

@ -0,0 +1 @@
20.9.0

View file

@ -28,18 +28,17 @@ repos:
args: ['--fix'] args: ['--fix']
exclude: ^dist/ exclude: ^dist/
# Disabled local hooks because dist/ formatting can vary between Node versions - repo: local
# - repo: local hooks:
# hooks: - id: build-dist
# - id: build-dist name: Build dist
# name: Build dist entry: npm run build
# entry: npm run build language: system
# language: system pass_filenames: false
# pass_filenames: false files: ^(index\.js|lib/.*\.js)$
# files: ^(index\.js|lib/.*\.js)$ - id: check-dist
# - id: check-dist name: Check dist is up to date
# name: Check dist is up to date entry: bash -c 'if [ -n "$(git status --porcelain dist)" ]; then echo "dist is out of date. Run npm run build and commit the changes."; exit 1; fi'
# entry: bash -c 'if [ -n "$(git status --porcelain dist)" ]; then echo "dist is out of date. Run npm run build and commit the changes."; exit 1; fi' language: system
# language: system pass_filenames: false
# pass_filenames: false always_run: true
# always_run: true

View file

@ -84,17 +84,17 @@ Each test case has `old/` and `new/` subdirectories with Go code.
The action uses `@vercel/ncc` to compile all dependencies into a single `dist/index.js` file. This is required for GitHub Actions and must be committed to the repository. The dist/ folder is intentionally NOT in .gitignore. The action uses `@vercel/ncc` to compile all dependencies into a single `dist/index.js` file. This is required for GitHub Actions and must be committed to the repository. The dist/ folder is intentionally NOT in .gitignore.
**Important**: Build with Node.js v20 to ensure consistent output with CI. **Important**: The dist must be built with Node.js v20 to match GitHub Actions runtime.
To update dist/ after making changes: There are two ways to update dist/:
```bash 1. **Automatic (recommended)**: Push changes to main branch and the build-dist workflow will automatically rebuild with Node 20
# Ensure you're using Node v20 2. **Manual**: If you have Node 20 installed locally:
node --version # Should show v20.x.x ```bash
node --version # Must show v20.x.x
npm run build npm run build
git add dist/index.js git add dist/index.js
``` ```
### Pre-commit Hooks ### Pre-commit Hooks

View file

@ -16,6 +16,9 @@
"lint-staged": "^16.1.2", "lint-staged": "^16.1.2",
"prettier": "^3.1.1" "prettier": "^3.1.1"
}, },
"engines": {
"node": ">=20.0.0 <21.0.0"
},
"jest": { "jest": {
"collectCoverage": true, "collectCoverage": true,
"coverageThreshold": { "coverageThreshold": {