Skip to content

Commit 8d84d9b

Browse files
author
Tom Lienard
authored
chore: migrate to pnpm (#663)
* feat: migrate to pnpm * fix: pnpm-lock deps version * fix: snapshots * fix: hoisted deps * fix: resolve review * fix: add back workspaces for lerna * fix: packageManager field * chore(docs): use pnpm * ci: pnpm/action-setup version * fix: resolve review
1 parent 4bb7266 commit 8d84d9b

File tree

26 files changed

+10377
-14008
lines changed

26 files changed

+10377
-14008
lines changed

.github/renovate.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"reviewersSampleSize": 2,
88
"prHourlyLimit": 5,
99
"prConcurrentLimit": 10,
10-
"postUpdateOptions": ["yarnDedupeHighest"],
1110
"labels": ["dependencies"],
1211
"rangeStrategy": "pin",
1312
"semanticCommitType": "chore",

.github/workflows/ci.yml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,47 @@ jobs:
77
runs-on: ubuntu-20.04
88
steps:
99
- uses: actions/[email protected]
10+
- uses: pnpm/[email protected]
1011
- name: Use Node.js
1112
uses: actions/[email protected]
1213
with:
1314
node-version: 17
1415
check-latest: true
15-
cache: 'yarn'
16-
- run: yarn
17-
- run: yarn run build
18-
- run: yarn run tsc --noEmit
16+
cache: 'pnpm'
17+
- run: pnpm install
18+
- run: pnpm run build
19+
- run: pnpm tsc --noEmit
1920
lint:
2021
runs-on: ubuntu-20.04
2122
steps:
2223
- uses: actions/[email protected]
24+
- uses: pnpm/[email protected]
2325
- name: Use Node.js
2426
uses: actions/[email protected]
2527
with:
2628
node-version: 17
2729
check-latest: true
28-
cache: 'yarn'
29-
- run: yarn
30-
- run: yarn run build
31-
- run: yarn run lint
30+
cache: 'pnpm'
31+
- run: pnpm install
32+
- run: pnpm run build
33+
- run: pnpm run lint
3234
test:
3335
runs-on: ubuntu-20.04
3436
strategy:
3537
matrix:
3638
node: [ '14', '16', '17' ]
3739
steps:
3840
- uses: actions/[email protected]
41+
- uses: pnpm/[email protected]
3942
- name: Use Node.js
4043
uses: actions/[email protected]
4144
with:
4245
node-version: ${{ matrix.node }}
4346
check-latest: true
44-
cache: 'yarn'
45-
- run: yarn
46-
- run: yarn run build
47-
- run: yarn run test:coverage
47+
cache: 'pnpm'
48+
- run: pnpm install
49+
- run: pnpm run build
50+
- run: pnpm run test:coverage
4851
- uses: codecov/[email protected]
4952
deploy:
5053
runs-on: ubuntu-20.04
@@ -63,17 +66,18 @@ jobs:
6366
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
6467
env:
6568
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
69+
- uses: pnpm/[email protected]
6670
- name: Use Node.js
6771
uses: actions/[email protected]
6872
with:
6973
node-version: 17
7074
check-latest: true
71-
- run: yarn --immutable --inline-builds
72-
- run: yarn run build
75+
- run: pnpm install
76+
- run: pnpm run build
7377
- run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
7478
env:
7579
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
76-
- run: yarn run lerna publish -y --create-release github --ignore-scripts --no-verify-access
80+
- run: pnpm lerna publish -y --create-release github --ignore-scripts --no-verify-access
7781
env:
7882
HUSKY: 0
7983
GH_TOKEN: ${{ secrets.GH_TOKEN }}

.github/workflows/pull_request_title.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ jobs:
99
runs-on: ubuntu-20.04
1010
steps:
1111
- uses: actions/[email protected]
12+
- uses: pnpm/[email protected]
1213
- name: Use Node.js
1314
uses: actions/[email protected]
1415
with:
1516
node-version: 17
1617
check-latest: true
17-
cache: 'yarn'
18-
- run: yarn
19-
- run: echo '${{ github.event.pull_request.title }}' | yarn run commitlint
18+
cache: 'pnpm'
19+
- run: pnpm install
20+
- run: echo '${{ github.event.pull_request.title }}' | pnpm commitlint

.gitignore

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
# dependencies
22
node_modules
3-
.yarn/*
4-
!.yarn/patches
5-
!.yarn/releases
6-
!.yarn/plugins
7-
!.yarn/sdks
8-
!.yarn/versions
9-
.pnp.*
10-
11-
# we are using yarn here
3+
4+
# we are using pnpm here
125
package-lock.json
6+
yarn.lock
137

148
# misc
159
.DS_Store

.husky/commit-msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn commitlint --edit $1
4+
pnpm commitlint --edit $1
55

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn run lint-staged
4+
pnpm lint-staged

.husky/pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn run lint-staged
4+
pnpm lint-staged

.yarn/releases/yarn-3.2.0.cjs

Lines changed: 0 additions & 785 deletions
This file was deleted.

.yarnrc.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ scaleway-lib is a set of NPM packages used at Scaleway.
1515
- [Development](#development)
1616
- [Locally](#locally)
1717
- [Link against another project (with `yalc`) => FAVORED](#link-against-another-project-with-yalc--favored)
18-
- [Link against another project (with `yarn link`)](#link-against-another-project-with-yarn-link)
18+
- [Link against another project (with `pnpm link`)](#link-against-another-project-with-pnpm-link)
1919
- [Linting](#linting)
2020
- [Unit Test](#unit-test)
2121
- [Lerna](#lerna)
@@ -98,75 +98,75 @@ scaleway-lib is a set of NPM packages used at Scaleway.
9898
```bash
9999
$ git clone [email protected]:scaleway/scaleway-lib.git
100100
$ cd scaleway-lib
101-
$ yarn
101+
$ pnpm install
102102
$ # ... do your changes ...
103-
$ yarn run lint
104-
$ yarn run test
103+
$ pnpm run lint
104+
$ pnpm run test
105105
```
106106

107107
### Link against another project (with `yalc`) => FAVORED
108108

109-
> [`yalc`](https://github.com/whitecolor/yalc) is a tool aiming to simplify working with local npm packages by providing a different workflow than `npm/yarn link`, hence avoiding most of their issues with module resolving.
109+
> [`yalc`](https://github.com/whitecolor/yalc) is a tool aiming to simplify working with local npm packages by providing a different workflow than `npm/yarn/pnpm link`, hence avoiding most of their issues with module resolving.
110110
111111
```bash
112-
$ yarn global add yalc # Make sure to have the yalc binary
112+
$ pnpm install -g yalc # Make sure to have the yalc binary
113113
```
114114

115115
```bash
116116
$ cd scaleway-lib/packages/example_package
117-
$ yarn build && yalc publish
117+
$ pnpm run build && yalc publish
118118
$ # Now it's ready to install in your project
119119
$ cd ../../../project-something
120-
$ yalc add @scaleway/package-name --yarn
120+
$ yalc add @scaleway/package-name
121121
$ cd ../scaleway-lib/packages/example_package
122122
$ # If you do some changes into your package
123-
$ yarn build && yalc publish --push --sig # --push will automatically update the package on projects where it have been added, --sig updates the signature hash to trigger webpack update
123+
$ pnpm run build && yalc publish --push --sig # --push will automatically update the package on projects where it have been added, --sig updates the signature hash to trigger webpack update
124124
```
125125

126126
> :warning: since [1.0.0.pre.51 (2021-04-23)](https://github.com/wclr/yalc/blob/master/CHANGELOG.md#100pre51-2021-04-23), `yalc publish` needs the `--sig` option to trigger webpack module actual update.
127127
128128
> :warning: `yalc` create a `yalc.lock` and updates the `package.json` in the target project. **Make sure to not commit these changes**
129129
130-
### Link against another project (with `yarn link`)
130+
### Link against another project (with `pnpm link`)
131131

132132
```bash
133-
$ cd packages/example_package && yarn link
134-
$ cd - && yarn run build # rebuild the package
133+
$ cd packages/example_package && pnpm link
134+
$ cd - && pnpm run build # rebuild the package
135135
$ # Now it's ready to link into your project
136136
$ cd ../project-something
137-
$ yarn link @scaleway/example_package
137+
$ pnpm link @scaleway/example_package
138138
```
139139

140140
### Linting
141141

142142
```bash
143-
$ yarn run lint
144-
$ yarn run lint:fix
143+
$ pnpm run lint
144+
$ pnpm run lint:fix
145145
```
146146

147147
### Unit Test
148148

149149
```bash
150-
$ yarn run test # Will run all tests
151-
$ yarn run test --updateSnapshot # Will update all snapshots
152-
$ yarn run test:watch # Will watch tests and only rerun the one who are modified
153-
$ yarn run test:coverage # Will generate a coverage report
150+
$ pnpm run test # Will run all tests
151+
$ pnpm run test -- --updateSnapshot # Will update all snapshots
152+
$ pnpm run test:watch # Will watch tests and only rerun the one who are modified
153+
$ pnpm run test:coverage # Will generate a coverage report
154154
```
155155

156156
## Lerna
157157

158158
This project is managed with [Lerna](https://lerna.js.org). Lerna is a tool to manage multiple NPM packages inside the same repository.
159159

160-
Lerna also allows us to use [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) to manage our dependencies. This implies a few things:
160+
Lerna also allows us to use [PNPM workspaces](https://pnpm.io/workspaces) to manage our dependencies. This implies a few things:
161161

162162
- devDependencies should be included in top package.json
163-
- There should be no `node_modules` or `yarn.lock` in sub-packages
163+
- There should be no `node_modules` or `pnpm-lock.yml` in sub-packages
164164
- There is a special syntax to manage sub-packages dependencies:
165165

166166
```bash
167-
$ yarn add -W -D new_dependency # Add a new devDependency to root project
168-
$ yarn workspace @scaleway/package_name add new_dependency
169-
$ yarn workspace @scaleway/package_name remove old_dependency
167+
$ pnpm add -W -D new_dependency # Add a new devDependency to root project
168+
$ cd packages/package_name && pnpm add new_dependency
169+
$ cd packages/package_name && pnpm remove old_dependency
170170
```
171171

172172
## Notes

0 commit comments

Comments
 (0)