Skip to content

Commit

Permalink
chore: pnpm (#6791)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->

<!--
copilot:all
-->
### <samp>🤖 Generated by Copilot at 5040901</samp>

### Summary
🚀🧹📝

<!--
1. 🚀 - This emoji can represent the changes that improve the
performance, reliability, and efficiency of the dependency installation,
the API handlers, the Next.js configuration, and the test functions. It
can also represent the changes that update the node version and the
package imports to use the latest features and compatibility.
2. 🧹 - This emoji can represent the changes that apply Prettier
formatting rules to the codebase and the workflows. It can also
represent the changes that remove the experimental property and the
sub-package imports to use the main package instead.
3. 📝 - This emoji can represent the changes that update the
documentation files to use pnpm instead of yarn as the package manager
and to simplify the build commands. It can also represent the changes
that update the pull request details in the workflows.
-->
This pull request updates the package manager from `yarn` to `pnpm` for
the project and its workflows, applies Prettier formatting rules to some
workflow files, and replaces imports from sub-packages of `ethers` with
imports from the main `ethers` package in some files. The purpose is to
improve the performance, consistency, compatibility, and stability of
the dependency management, code formatting, and utility functions for
the project and its sub-applications.

> _We're switching from `yarn` to `pnpm` for our code_
> _It's faster and more reliable, so we're told_
> _So heave away, me hearties, on the count of three_
> _And update all the workflows and dependencies_

### Walkthrough
* Replace `yarn` with `pnpm` as the package manager and add steps to set
up `pnpm` and cache the `pnpm` store directory in the workflows for
deploying, testing, formatting, linting, releasing, and updating the
APIs and the apps
([link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-d6bb07415a4782c3dccf60d4aa0aa6b46d574011187d901d20d78a166925a587L38-R50),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-0b4d7bd7148b51842880739adde7bf8cb6ef7f170295d34fb03eeb036e589563L28-R60),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-173f5db567f8459284c719180df8c27debad26456e63f98c5b87d94cf87e049bL14-R40),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-107e910e9f2ebfb9a741fa10b2aa7100cc1fc4f5f3aca2dfe78b905cbd73c0d2L17-R40),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-87db21a973eed4fef5f32b267aa60fcee5cbdf03c67fafdc2a9b553bb0b15f34L19-R53),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-a8fe81691f8f45cf75a64204bfb57a02b773e6b0f37616bf34919bdc26d10bc2L28-R54),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-f2c550cdb897cabc792731e8f52661c361c69e9cf8c88b97b47cec26f276a233L26-R52),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-a43f088b360d7a54264d6839e8f4ac725b7f10a5902102c0a342d9f8b037030dL18-R47),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-6b9d8f895868b8958019277015d96712d448426de5a77cff7360b4bba01f837fL18-R49),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-107e910e9f2ebfb9a741fa10b2aa7100cc1fc4f5f3aca2dfe78b905cbd73c0d2L41-R55))
* Update the node version from 16 to 18 in the workflows for testing the
configurations and the web app
([link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-33880375608521ad12a29d986475111b693bde023b7d5efbda5c327628579e71L14-R14),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-f2c550cdb897cabc792731e8f52661c361c69e9cf8c88b97b47cec26f276a233L16-R16))
* Replace double quotes with single quotes in the cron expressions and
the pull request messages of the workflows for updating the LP APR data
([link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-a43f088b360d7a54264d6839e8f4ac725b7f10a5902102c0a342d9f8b037030dL8-R8),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-6b9d8f895868b8958019277015d96712d448426de5a77cff7360b4bba01f837fL8-R8),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-a43f088b360d7a54264d6839e8f4ac725b7f10a5902102c0a342d9f8b037030dL38-R56),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-6b9d8f895868b8958019277015d96712d448426de5a77cff7360b4bba01f837fL40-R58))
* Replace `yarn` with `pnpm` in the pre-commit hook script
([link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-d2bc4bbf14eadc292d84e0ef5f7a93115c23557f533809fc80b896934291529dL4-R4))
* Replace imports from sub-packages of `ethers` with imports from the
main `ethers` package in the files for the farms API and the web app
([link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-9ebdd06bbca8aba4cbbbdcd49685b70d3b81f60d35ea1202b06eec97fe03c1caL1-R2),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-11c462ea3746559d529c54d13445fb2f0322bf164e4e4b2f2abe8f10d3af097eL1-R4),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-edcd1f3ca818ecf794c6c6a2d4698be2dc5d98b039d77db8892b583e5a600476L1-R1),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-289b53064a90823553c8344982b04baf62eb586397d16917c0e3b3b924aef683L1-R5))
* Replace the import of `createFilterToken` from the deprecated package
`@pancakeswap/utils/filtering` with the same function from
`@pancakeswap/token-lists` in the `CurrencySearch.tsx` file for the
Aptos app
([link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-07570ba2dcf8bd5ad81c58649e7218a5aebc9e45684b7cf607b61d15313b52fdL4),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-07570ba2dcf8bd5ad81c58649e7218a5aebc9e45684b7cf607b61d15313b52fdL11-R10))
* Remove the experimental property and move the `transpilePackages`
array to the top level in the `next.config.mjs` file for the bridge app
([link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-abe68aabdd775a8e0e520e24915bbe2c7ecc81a8e860fb21e598d9ceec273a6cL10-R16))
* Add a condition to skip the `node_modules` directory in the
`throughDirectory` function in the `translations.test.ts` file for the
web app
([link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-f1e532619ac5557c3e0600dfd646579d8b52b048779f49d33eb64e44121aced6R74))
* Replace the `AddressZero` constant from `@ethersproject/constants`
with the `ADDRESS_ZERO` constant from `@pancakeswap/v3-sdk` in the
`index.test.ts` file for the web app
([link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-289b53064a90823553c8344982b04baf62eb586397d16917c0e3b3b924aef683L27-R27))
* Replace `yarn` with `pnpm` and add a link to the `pnpm` website in the
documentation section of the `README.md` file
([link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L18-R18))
* Replace `yarn` with `pnpm` and simplify the build commands in the web
app, Aptos app, and blog app sections of the `README.md` file
([link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L27-R40),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L51-R54),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L65-R68))
* Replace `yarn` with `pnpm` in the setup and tests sections of the
`CONTRIBUTING.md` file
([link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L15-R16),
[link](https://github.com/pancakeswap/pancake-frontend/pull/6791/files?diff=unified&w=0#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L34-R34))
  • Loading branch information
0xjojoex authored May 3, 2023
1 parent 798d9f8 commit e0d323d
Show file tree
Hide file tree
Showing 254 changed files with 25,285 additions and 23,018 deletions.
1 change: 1 addition & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@pancakeswap/ui",
"@pancakeswap/ui-wallets",
"@pancakeswap/uikit",
"@pancakeswap/utils",
"farms-api",
"aptos-web",
"blog",
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/deploy-apis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,19 @@ jobs:
with:
fetch-depth: 2

- name: Set up pnpm
uses: pnpm/[email protected]
- name: Set up node@18
uses: actions/setup-node@v3
with:
cache: 'pnpm'
node-version: 18

- name: Install dependencies
run: yarn install --frozen-lockfile
run: pnpm i --ignore-scripts

- name: Build package
run: yarn build:packages
run: pnpm build:packages

- name: Publish
uses: cloudflare/[email protected]
Expand Down
31 changes: 28 additions & 3 deletions .github/workflows/farmConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,39 @@ jobs:
with:
fetch-depth: 2

- name: Set up pnpm
uses: pnpm/[email protected]
- name: Set up node@18
uses: actions/setup-node@v3
with:
cache: 'pnpm'
node-version: 18

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: yarn install --frozen-lockfile
run: pnpm i --ignore-scripts

- name: Build package
run: pnpm build:packages

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

- name: Build list
run: yarn turbo run build --filter=@pancakeswap/farms
run: pnpm turbo run build --filter=@pancakeswap/farms

- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@1
Expand Down
31 changes: 18 additions & 13 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,30 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v2
- name: Set up pnpm
uses: pnpm/[email protected]
- name: Set up node@18
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
node-version: 18

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: yarn install --frozen-lockfile
run: pnpm i --ignore-scripts

- name: Run Prettier
run: yarn format:check
run: pnpm format:check
45 changes: 25 additions & 20 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,42 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v2
- name: Set up pnpm
uses: pnpm/[email protected]
- name: Set up node@18
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
node-version: 18

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: yarn install --frozen-lockfile
run: pnpm i --ignore-scripts

- name: Get changed files
id: changed-files
uses: Ana06/[email protected]
with:
format: space-delimited
filter: |
**/*.ts
**/*.tsx
**/*.js
**/*.jsx
token: ${{ secrets.GITHUB_TOKEN }}
format: space-delimited
filter: |
**/*.ts
**/*.tsx
**/*.js
**/*.jsx
token: ${{ secrets.GITHUB_TOKEN }}

- name: Run ESLint
run: yarn lint:report ${{ steps.changed-files.outputs.added_modified }}
run: pnpm lint:report ${{ steps.changed-files.outputs.added_modified }}
32 changes: 24 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,38 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Setup Node.js 16.x
uses: actions/setup-node@v2
- name: Set up pnpm
uses: pnpm/[email protected]
- name: Set up node@18
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
node-version: 18

- name: Install Dependencies
run: yarn
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm i --ignore-scripts

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
title: "chore: Version Packages"
title: 'chore: Version Packages'
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release-packages
publish: pnpm release-packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

31 changes: 18 additions & 13 deletions .github/workflows/testConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,30 @@ jobs:
with:
fetch-depth: 2

- name: Setup Node
uses: actions/setup-node@v2
- name: Set up pnpm
uses: pnpm/[email protected]
- name: Set up node@18
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
node-version: 18

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: yarn install --frozen-lockfile
run: pnpm i --ignore-scripts

- name: Run tests
run: yarn test:config
run: pnpm test:config
2 changes: 1 addition & 1 deletion .github/workflows/testConfigPass.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: true
matrix:
node: [16]
node: [18]
name: Config (Jest)
steps:
- run: 'echo "No Test Config required" '
33 changes: 19 additions & 14 deletions .github/workflows/unitTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: true
matrix:
node: [16]
node: [18]

name: Unit tests (Jest)

Expand All @@ -23,25 +23,30 @@ jobs:
with:
fetch-depth: 2

- name: Setup Node
uses: actions/setup-node@v2
- name: Set up pnpm
uses: pnpm/[email protected]
- name: Set up node@18
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
node-version: 18

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: yarn install --frozen-lockfile
run: pnpm i --ignore-scripts

- name: Run tests
run: yarn test:ci
run: pnpm test:ci
35 changes: 26 additions & 9 deletions .github/workflows/updateAptosLPsAPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
schedule:
# 23:15 UTC
# GitHub Actions might be delayed if time is at exact hour
- cron: "15 23 * * *"
- cron: '15 23 * * *'

jobs:
updateLPsAPRs:
Expand All @@ -15,28 +15,45 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v2
- name: Set up pnpm
uses: pnpm/[email protected]
- name: Set up node@18
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'pnpm'
node-version: 18

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: yarn install --frozen-lockfile
run: pnpm i --ignore-scripts

- name: Fetch and save Aptos LP APR data
run: yarn updateAptosLPsAPR
run: pnpm updateAptosLPsAPR

- name: Format
run: yarn prettier --write "apps/aptos/config/constants/lpAprs/*.{ts,json}"
run: pnpm prettier --write "apps/aptos/config/constants/lpAprs/*.{ts,json}"

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
author: PancakeSwap Bot <[email protected]>
token: ${{ secrets.LP_APR_PANCAKE_BOT }}
delete-branch: true
commit-message: "chore: Update Aptos LP APRs for Farms"
title: "chore: Update Aptos LP APRs for Farms"
commit-message: 'chore: Update Aptos LP APRs for Farms'
title: 'chore: Update Aptos LP APRs for Farms'
body: |
- Update Aptos LP APRs for Farms
Expand Down
Loading

1 comment on commit e0d323d

@vercel
Copy link

@vercel vercel bot commented on e0d323d May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

uikit – ./packages/uikit

uikit-git-develop.pancake.run
uikit.pancake.run

Please sign in to comment.