Skip to content

Commit

Permalink
Upgrade node version, switch to pnpm (#360)
Browse files Browse the repository at this point in the history
* Node 20
* Switch to pnpm
* Small improvements to CI workflow while updating
  • Loading branch information
zpao authored Aug 25, 2024
1 parent ca44887 commit 040c28d
Show file tree
Hide file tree
Showing 6 changed files with 5,648 additions and 4,623 deletions.
30 changes: 18 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install
cache: 'pnpm'
- run: pnpm install
- run: make
- uses: actions/[email protected]
with:
Expand All @@ -21,46 +22,51 @@ jobs:
lib
examples/**/*.js
test:
name: Test against React (@v${{ matrix.react_version }})
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
react_version:
- '16'
- '17'
- '18'
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install
cache: 'pnpm'
- run: pnpm install
- name: Install React deps (@v${{ matrix.react_version }})
run: npm install --no-save --no-package-lock react@${{ matrix.react_version }} react-dom@${{ matrix.react_version }} react-test-renderer@${{ matrix.react_version }}
- run: yarn test
run: pnpm add -D --no-lockfile react@${{ matrix.react_version }} react-dom@${{ matrix.react_version }} react-test-renderer@${{ matrix.react_version }}
- run: pnpm test
lint:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install
- run: yarn lint
cache: 'pnpm'
- run: pnpm install
- run: pnpm lint
typecheck:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install
cache: 'pnpm'
- run: pnpm install
- uses: actions/download-artifact@v4
with:
name: build-output
- run: yarn typecheck
- run: pnpm typecheck
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SRC_DEPS = src/index.tsx src/third-party/qrcodegen/index.ts
CFG_DEPS = yarn.lock package.json tsup.config.ts tsconfig.json
CFG_DEPS = pnpm-lock.yaml package.json tsup.config.ts tsconfig.json
EXAMPLE_DEPS = examples/*.tsx

.PHONY: all clean
Expand All @@ -10,16 +10,16 @@ lib:
mkdir -p lib

lib/index.d.ts: lib $(SRC_DEPS) $(CFG_DEPS)
yarn run build:code
pnpm run build:code

lib/esm/index.js: lib $(SRC_DEPS) $(CFG_DEPS)
yarn run build:code
pnpm run build:code

lib/index.js: lib $(SRC_DEPS) $(CFG_DEPS)
yarn run build:code
pnpm run build:code

examples/iife/demo.js: lib/esm/index.js ${EXAMPLE_DEPS}
yarn run build:examples
pnpm run build:examples

clean:
git clean -fX lib examples
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
}
},
"scripts": {
"build": "yarn run build:code && yarn run build:examples",
"build": "pnpm run build:code && pnpm run build:examples",
"build:code": "tsup src/index.tsx -d lib --format esm,cjs --dts --legacy-output --target=es2017 --platform=browser",
"build:examples": "tsup examples/demo.tsx -d examples --format iife --env.NODE_ENV production --minify --target=es2017 --legacy-output",
"build:examples:dev": "tsup examples/demo.tsx -d examples --format iife --env.NODE_ENV development --target=es2017 --legacy-output",
"lint": "eslint .",
"pretty": "prettier --write '{*,.*}.{mjs,js,json}' '**/*.{js,json}'",
"prepack": "make clean && make all && yarn run typecheck",
"prepack": "make clean && make all && pnpm run typecheck",
"prepublish-docs": "make clean && make all",
"publish-docs": "gh-pages --dist=examples --src='{index.html,iife/demo.js}'",
"test": "jest",
Expand Down Expand Up @@ -67,5 +67,5 @@
"tsup": "^8.0.2",
"typescript": "^5.0.4"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]+sha512.8e4c3550fb500e808dbc30bb0ce4dd1eb614e30b1c55245f211591ec2cdf9c611cabd34e1364b42f564bd54b3945ed0f49d61d1bbf2ec9bd74b866fcdc723276"
}
Loading

0 comments on commit 040c28d

Please sign in to comment.