Skip to content

Commit 0c71fb7

Browse files
🪚 Use pnpm instead of yarn (LayerZero-Labs#150)
1 parent 5096d51 commit 0c71fb7

File tree

39 files changed

+12819
-11954
lines changed

39 files changed

+12819
-11954
lines changed

‎.github/workflows/reusable-publish.yaml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,27 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v3
2626

27+
- uses: pnpm/action-setup@v2
28+
name: Install pnpm
29+
with:
30+
version: 8
31+
run_install: false
32+
2733
- name: Setup Node.js
2834
uses: actions/setup-node@v3
2935
with:
3036
node-version-file: ".nvmrc"
31-
cache: "yarn"
37+
cache: "pnpm"
3238

33-
# Install the dependencies without running the post-install scripts
34-
- name: Install Dependencies
35-
run: yarn install --frozen-lockfile --prefer-offline --ignore-scripts
39+
# Fetch the dependencies without running the post-install scripts
40+
- name: Fetch Dependencies
41+
run: pnpm fetch --frozen-lockfile --prefer-offline --ignore-scripts
3642
env:
3743
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3844

39-
# Run the post-install scripts
40-
- name: Build Dependencies
41-
run: yarn install --frozen-lockfile --offline
45+
# Install the dependencies and run the post-install scripts
46+
- name: Install Dependencies
47+
run: pnpm install --frozen-lockfile --offline
4248

4349
# Cache build artifacts from turbo
4450
#
@@ -64,7 +70,7 @@ jobs:
6470
${{ runner.os }}-hardhat-
6571
6672
- name: Build
67-
run: yarn build
73+
run: pnpm build
6874
env:
6975
NODE_ENV: production
7076

@@ -82,8 +88,8 @@ jobs:
8288
- name: Publish packages / create version bump PRs
8389
uses: changesets/action@v1
8490
with:
85-
version: yarn changeset version
86-
publish: yarn changeset publish
91+
version: pnpm changeset version
92+
publish: pnpm changeset publish
8793
title: "🚀 Version packages"
8894

8995
env:

‎.github/workflows/reusable-test.yaml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,27 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v3
2626

27+
- uses: pnpm/action-setup@v2
28+
name: Install pnpm
29+
with:
30+
version: 8
31+
run_install: false
32+
2733
- name: Setup Node.js
2834
uses: actions/setup-node@v3
2935
with:
3036
node-version-file: ".nvmrc"
31-
cache: "yarn"
37+
cache: "pnpm"
3238

33-
# Install the dependencies without running the post-install scripts
34-
- name: Install Dependencies
35-
run: yarn install --frozen-lockfile --prefer-offline --ignore-scripts
39+
# Fetch the dependencies without running the post-install scripts
40+
- name: Fetch Dependencies
41+
run: pnpm fetch --frozen-lockfile --prefer-offline --ignore-scripts
3642
env:
3743
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3844

39-
# Run the post-install scripts
40-
- name: Build Dependencies
41-
run: yarn install --frozen-lockfile --offline
45+
# Install the dependencies and run the post-install scripts
46+
- name: Install Dependencies
47+
run: pnpm install --frozen-lockfile --offline
4248

4349
# Cache build artifacts from turbo
4450
#
@@ -64,13 +70,13 @@ jobs:
6470
${{ runner.os }}-hardhat-
6571
6672
- name: Lint
67-
run: yarn lint
73+
run: pnpm lint
6874

6975
- name: Build
70-
run: yarn build
76+
run: pnpm build
7177

7278
- name: Test
73-
run: yarn test
79+
run: pnpm test
7480
# Since we're running the E2E tests in docker, we'll need to reinstall
7581
# the node modules. This is a temporary solution to bridge us between
7682
# non-containerized and containerized development

‎.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Logs
22
logs
33
*.log
4-
yarn-debug.log*
5-
yarn-error.log*
4+
pnpm-debug.log*
5+
pnpm-error.log*
66

77
# Dependency directories
88
node_modules/

‎.husky/pre-commit

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

4-
npx lint-staged
4+
pnpm lint-staged

‎.npmrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
11
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
2+
3+
# pnpm does not by default execute pre & post scripts
4+
#
5+
# since we kinda want to keep them, we need to enable this option
6+
# see https://pnpm.io/cli/run#differences-with-npm-run for more info
7+
enable-pre-post-scripts=true
8+
9+
# pnpm will by default use the workspace protocol when installing
10+
# local dependencies
11+
#
12+
# in order not to modify the publishing step just yet, we'll disable this behavior
13+
#
14+
# TODO reenable this behavior and use solutions provided in the linked PRs
15+
# in this github issue for changesets https://github.com/changesets/changesets/issues/432
16+
#
17+
# see more here https://pnpm.io/npmrc#save-workspace-protocol
18+
save-workspace-protocol=false
19+
prefer-workspace-packages=true

‎.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
yarn.lock
21
*.log
32
.eslintignore
43
.prettierignore
54
.netrc
65
*ignore
6+
pnpm-*.yaml

‎DEVELOPMENT.md

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,30 @@ The code is arranged into:
2424
# or nvm install if nvm use fails
2525
nvm use
2626

27-
yarn
27+
# If pnpm is not installed on your local machine, you can install it using corepack
28+
corepack enable
29+
30+
# Install project dependencies
31+
pnpm install
2832

2933
# Build the entire project
30-
yarn build
34+
pnpm build
3135

3236
# Lints the entire project
33-
yarn lint
37+
pnpm lint
3438

3539
# Tests the entire project
36-
yarn test
40+
pnpm test
3741

3842
# Runs the project in development mode
39-
yarn dev
43+
pnpm dev
4044
```
4145

4246
This project is built using `turborepo`. The above commands are just aliases to `turbo` CLI and as such support all the `turbo` options:
4347

4448
```bash
4549
# To start the development mode for create-lz-oapp and its dependencies
46-
yarn dev --filter=create-lz-oapp...
50+
pnpm dev --filter=create-lz-oapp...
4751
```
4852

4953
### Running tests
@@ -56,7 +60,7 @@ The tests are by default executed in a containerized environment that sets up tw
5660
You can run the whole test suite within this environment by running:
5761

5862
```bash
59-
yarn test
63+
pnpm test
6064
```
6165

6266
#### Refining tested packages
@@ -65,21 +69,21 @@ To only run a specific test suite, you can define `DOCKER_COMPOSE_RUN_TESTS_TURB
6569

6670
```bash
6771
# To only run tests for @layerzerolabs/ua-devtools-evm-hardhat-test package
68-
DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS=--filter=ua-devtools-evm-hardhat-test yarn test
72+
DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS=--filter=ua-devtools-evm-hardhat-test pnpm test
6973
```
7074

7175
#### Rebuilding containers
7276

7377
`docker compose` will by default reuse images for containers it has already built. If by any chance you are seeing code changes not being reflected in your test runs, you can force docker to rebuild the images by defining `DOCKER_COMPOSE_RUN_TESTS_ARGS` environment variable. This variable will be passed to the underlying `docker compose run` command and can contain any arguments that this command understands, for example:
7478

7579
```bash
76-
DOCKER_COMPOSE_RUN_TESTS_ARGS=--build yarn test
80+
DOCKER_COMPOSE_RUN_TESTS_ARGS=--build pnpm test
7781
```
7882

7983
You also combine the environment variables:
8084

8185
```bash
82-
DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS=--filter=ua-devtools-evm-hardhat-test DOCKER_COMPOSE_RUN_TESTS_ARGS=--build yarn test
86+
DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS=--filter=ua-devtools-evm-hardhat-test DOCKER_COMPOSE_RUN_TESTS_ARGS=--build pnpm test
8387
```
8488

8589
#### Container logs
@@ -97,7 +101,7 @@ This allows you to monitor logs coming from e.g. the `hardhat` nodes
97101
It is possible to expose the test networks defined in `docker-compose.yaml` on your host machine. To do this, you can run:
98102

99103
```bash
100-
yarn start
104+
pnpm start
101105
```
102106

103107
Once the networks are running, you can go to the `ua-devtools-evm-hardhat-test` package:
@@ -109,25 +113,25 @@ cd packages/ua-devtools-hardhat-test
109113
Setup the default `EndpointV2` and `DefaultOApp`:
110114

111115
```bash
112-
npx hardhat lz:test:oapp:deploy
116+
pnpm hardhat lz:test:oapp:deploy
113117
```
114118

115119
And execute `hardhat` tasks as usual:
116120

117121
```bash
118-
npx hardhat lz:oapp:getDefaultConfig
122+
pnpm hardhat lz:oapp:getDefaultConfig
119123
```
120124

121125
If you are developing tasks, it's useful to build the code when it changes. To do this, run the following from the project root:
122126

123127
```bash
124-
yarn dev
128+
pnpm dev
125129
```
126130

127131
To stop the network containers, just run:
128132

129133
```bash
130-
yarn stop
134+
pnpm stop
131135
```
132136

133137
**Don't forget that the state of the local networks disappears after they are stopped and any deployment files created in one session will be invalid in the next one.**
@@ -144,21 +148,9 @@ export NVM_DIR="$HOME/.nvm"
144148
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
145149
```
146150

147-
#### Problems with package updating
148-
149-
To update external `@layerzerolabs` packages, you can use the builtin `yarn` utility:
150-
151-
```bash
152-
yarn upgrade-interactive --scope @layerzerolabs --latest
153-
```
154-
155-
However, this utility has an issue with packages that are listed both at the workspace root and in the individual packages, e.g. `@layerzerolabs/prettier-config-next` - it errors out saying that a workspace package could not be found.
156-
157-
To work around this (since this version of yarn is outdated and a fix for this problem will not be provided), you can remove the entries from the root `package.json` before running the command, then add them back (just don't forget to update their versions).
158-
159151
#### Problems using the `dev` script
160152

161-
`turbo` might complain about concurrency issues when running `yarn dev`:
153+
`turbo` might complain about concurrency issues when running `pnpm dev`:
162154

163155
```diff
164156
- error preparing engine: Invalid persistent task configuration:
@@ -168,7 +160,7 @@ To work around this (since this version of yarn is outdated and a fix for this p
168160
If you see this error, just follow turbo's lead and use:
169161

170162
```bash
171-
yarn dev --concurrency 19
163+
pnpm dev --concurrency 19
172164
```
173165

174166
#### Problems with snapshots
@@ -183,5 +175,5 @@ For some packages the snapshot output depends on environment variables and other
183175
If you encounter errors when running these tests, just set the environment variable before running the test:
184176

185177
```bash
186-
CI=1 yarn test
178+
CI=1 pnpm test
187179
```

0 commit comments

Comments
 (0)