Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: switch package manager from yarn to pnpm #94

Merged
merged 4 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,40 @@ on:
pull_request:
types: [opened, synchronize, reopened]

env:
PNPM_VERSION: 9.1.1

jobs:
build:
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}

runs-on: ${{ matrix.os }}
name: Build, lint, and test on Node ${{ matrix.node }}
runs-on: ubuntu-latest
strategy:
matrix:
node: ["20.x"]
wescopeland marked this conversation as resolved.
Show resolved Hide resolved
os: [ubuntu-latest]

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/[email protected]
with:
version: ${{ env.PNPM_VERSION }}
wescopeland marked this conversation as resolved.
Show resolved Hide resolved

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: "yarn"
cache: "pnpm"

- name: Install
run: yarn install --frozen-lockfile
run: pnpm install

- name: Lint
run: yarn lint
run: pnpm lint

- name: Test
run: yarn test
run: pnpm test

- name: Build
run: yarn build
run: pnpm build
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm pretty-quick --staged && pnpm lint
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
coverage
dist
website/.docusaurus
website/build
website/build
pnpm-lock.yaml
wescopeland marked this conversation as resolved.
Show resolved Hide resolved
wescopeland marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
Before beginning, please make sure you have the following tools installed.

- Node.js (the latest LTS release, [download](https://nodejs.org/en/download/))
- yarn classic (1.x, [instructions](https://yarnpkg.com/lang/en/docs/install/))
- pnpm (9.x, [instructions](https://pnpm.io/installation))

## Installation

```bash
git clone https://github.com/RetroAchievements/api-js.git
cd retroachievements-api-js
yarn
pnpm install
```

## Local development
Expand All @@ -25,7 +25,7 @@ const webApiKey = "myWebApiKey";
You can now modify the playground file how you see fit to test your changes. To run the file in watch mode, execute the following command in your terminal:

```bash
yarn dev
pnpm dev
```

## Commit messages
Expand All @@ -50,13 +50,13 @@ Prettier is used for code style. ESLint with a strict set of anti-code smell rul
To manually run Prettier, do:

```bash
yarn format:write
pnpm format:write
```

To manually run ESLint, do:

```bash
yarn lint:fix
pnpm lint:fix
```

This works but is cumbersome. It is recommended that you set your editor to run Prettier and ESLint automatically on save.
Expand All @@ -71,13 +71,13 @@ Given that this library is an official reference implementation, we strive for h
To run the current suite of tests, in the terminal execute:

```bash
yarn test
pnpm test
```

If you're actively writing tests, you can use watch mode like:

```bash
yarn test --watch
pnpm test --watch
```

Take note of the [ARRANGE, ACT, ASSERT pattern](https://github.com/goldbergyoni/javascript-testing-best-practices#-%EF%B8%8F-12-structure-tests-by-the-aaa-pattern) followed throughout the testing suite and be sure to use it in any new tests so they are easy to understand for future maintainers.
Expand All @@ -89,14 +89,14 @@ This project uses [microbundle](https://github.com/developit/microbundle) for bu
You can build the app using:

```bash
yarn build
pnpm build
```

## Opening a PR

Before opening a PR, the following are good things to check for:

- Does `yarn verify` pass successfully?
- Does `pnpm verify` pass successfully?
- Does any new code have tests?
- Is new code documented on the VitePress site?

Expand All @@ -106,6 +106,6 @@ If you are a RetroAchievements org member, you should be able to release a new p

1. Change the package version number in _package.json_. Respect semantic versioning: [major].[minor].[patch]. A major release usually assumes breaking changes.

2. Run `yarn build`.
2. Run `pnpm build`.

3. Run `npm publish --access public`.
16 changes: 5 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"dev": "esrun --watch src/__playground.ts",
"prebuild": "node src/set-version.js",
"build": "microbundle",
"prepare": "microbundle",
"prepare": "microbundle && husky install",
"format": "prettier --write . '**/*.{json,md,js,ts,tsx}'",
"format:write": "prettier --write . '**/*.{json,md,js,ts,tsx}'",
"format:check": "prettier --check . '**/*.{json,md,js,ts,tsx}'",
Expand All @@ -41,10 +41,9 @@
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"verify": "yarn format:check && yarn lint && yarn test:coverage && yarn build",
"verify": "pnpm format:check && pnpm lint && pnpm test:coverage && pnpm build",
"start": "microbundle watch"
},
"peerDependencies": {},
"devDependencies": {
"@commitlint/cli": "^17.4.2",
"@commitlint/config-conventional": "^17.4.2",
Expand All @@ -62,7 +61,7 @@
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-sonarjs": "^0.23.0",
"eslint-plugin-unicorn": "^49.0.0",
"husky": "4.3.8",
"husky": "9.0.11",
wescopeland marked this conversation as resolved.
Show resolved Hide resolved
wescopeland marked this conversation as resolved.
Show resolved Hide resolved
"microbundle": "^0.15.1",
"msw": "^2.0.3",
"prettier": "2.8.3",
Expand All @@ -74,12 +73,6 @@
"vite": "^4.5.0",
"vitest": "^0.34.6"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged && yarn lint",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
Expand All @@ -102,5 +95,6 @@
"url": "https://github.com/RetroAchievements/api-js/issues"
},
"homepage": "https://github.com/RetroAchievements/api-js#readme",
"author": "RAWeb Team"
"author": "RAWeb Team",
"packageManager": "[email protected]+sha256.9551e803dcb7a1839fdf5416153a844060c7bce013218ce823410532504ac10b"
wescopeland marked this conversation as resolved.
Show resolved Hide resolved
wescopeland marked this conversation as resolved.
Show resolved Hide resolved
}
Loading