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:
parent
1cabe34a14
commit
9f05344e16
6 changed files with 80 additions and 24 deletions
52
.github/workflows/build-dist.yml
vendored
Normal file
52
.github/workflows/build-dist.yml
vendored
Normal 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
1
.node-version
Normal file
|
|
@ -0,0 +1 @@
|
|||
20.9.0
|
||||
1
.nvmrc
Normal file
1
.nvmrc
Normal file
|
|
@ -0,0 +1 @@
|
|||
20.9.0
|
||||
|
|
@ -28,18 +28,17 @@ repos:
|
|||
args: ['--fix']
|
||||
exclude: ^dist/
|
||||
|
||||
# Disabled local hooks because dist/ formatting can vary between Node versions
|
||||
# - repo: local
|
||||
# hooks:
|
||||
# - id: build-dist
|
||||
# name: Build dist
|
||||
# entry: npm run build
|
||||
# language: system
|
||||
# pass_filenames: false
|
||||
# files: ^(index\.js|lib/.*\.js)$
|
||||
# - id: check-dist
|
||||
# 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'
|
||||
# language: system
|
||||
# pass_filenames: false
|
||||
# always_run: true
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: build-dist
|
||||
name: Build dist
|
||||
entry: npm run build
|
||||
language: system
|
||||
pass_filenames: false
|
||||
files: ^(index\.js|lib/.*\.js)$
|
||||
- id: check-dist
|
||||
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'
|
||||
language: system
|
||||
pass_filenames: false
|
||||
always_run: true
|
||||
|
|
|
|||
10
CLAUDE.md
10
CLAUDE.md
|
|
@ -84,14 +84,14 @@ 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.
|
||||
|
||||
**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/:
|
||||
|
||||
1. **Automatic (recommended)**: Push changes to main branch and the build-dist workflow will automatically rebuild with Node 20
|
||||
2. **Manual**: If you have Node 20 installed locally:
|
||||
```bash
|
||||
# Ensure you're using Node v20
|
||||
node --version # Should show v20.x.x
|
||||
|
||||
node --version # Must show v20.x.x
|
||||
npm run build
|
||||
git add dist/index.js
|
||||
```
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
"lint-staged": "^16.1.2",
|
||||
"prettier": "^3.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0 <21.0.0"
|
||||
},
|
||||
"jest": {
|
||||
"collectCoverage": true,
|
||||
"coverageThreshold": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue