Skip to content

Commit

Permalink
Bump Yarn to v4 (#3612)
Browse files Browse the repository at this point in the history
This allows us to use newer features of Yarn, such as writing
constraints in JavaScript format instead of Prolog.
  • Loading branch information
mcmire authored Jun 27, 2024
1 parent ea5e923 commit 27dd62c
Show file tree
Hide file tree
Showing 14 changed files with 4,536 additions and 5,359 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/ensure-blocking-pr-labels-absent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ jobs:
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: yarn
- name: Install dependencies
run: yarn --immutable
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- name: Restore Yarn cache
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn --immutable
- name: Run command
uses: actions/github-script@v7
with:
Expand Down
60 changes: 45 additions & 15 deletions .github/workflows/lint-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ jobs:
outputs:
child-workspace-package-names: ${{ steps.workspace-package-names.outputs.child-workspace-package-names }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Yarn
run: corepack enable
- name: Restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
Expand All @@ -34,9 +40,15 @@ jobs:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Yarn
run: corepack enable
- name: Restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
Expand All @@ -59,9 +71,15 @@ jobs:
node-version: [20.x]
package-name: ${{ fromJson(needs.prepare.outputs.child-workspace-package-names) }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Yarn
run: corepack enable
- name: Restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
Expand All @@ -83,9 +101,15 @@ jobs:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Yarn
run: corepack enable
- name: Restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
Expand All @@ -108,9 +132,15 @@ jobs:
node-version: [18.x, 20.x]
package-name: ${{ fromJson(needs.prepare.outputs.child-workspace-package-names) }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Yarn
run: corepack enable
- name: Restore Yarn cache
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/publish-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
outputs:
IS_FORK: ${{ steps.is-fork.outputs.IS_FORK }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Determine whether this PR is from a fork
id: is-fork
run: echo "IS_FORK=$(gh pr view --json isCrossRepository --jq '.isCrossRepository' "${PR_NUMBER}" )" >> "$GITHUB_OUTPUT"
Expand All @@ -29,14 +29,20 @@ jobs:
if: ${{ needs.is-fork-pull-request.outputs.IS_FORK == 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout pull request
- uses: actions/checkout@v4
- name: Check out pull request
run: gh pr checkout "${PR_NUMBER}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
- name: Setup Node
uses: actions/setup-node@v3
- name: Install Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- name: Restore Yarn cache
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: yarn
Expand Down
38 changes: 28 additions & 10 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@ jobs:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Setup Node
uses: actions/setup-node@v3
- name: Install Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- name: Restore Yarn cache
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: yarn
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: |
./packages/**/dist
Expand All @@ -38,10 +44,16 @@ jobs:
runs-on: ubuntu-latest
needs: publish-release
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- uses: actions/cache@v3
- name: Install Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- uses: actions/cache@v4
with:
path: |
./packages/**/dist
Expand All @@ -50,7 +62,7 @@ jobs:
fail-on-cache-miss: true
- name: Dry Run Publish
# omit npm-token token to perform dry run publish
uses: MetaMask/action-npm-publish@v4
uses: MetaMask/action-npm-publish@v5
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
subteam: S042S7RE4AE # @metamask-npm-publishers
Expand All @@ -62,18 +74,24 @@ jobs:
runs-on: ubuntu-latest
needs: publish-npm-dry-run
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- uses: actions/cache@v3
- name: Install Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install Yarn
run: corepack enable
- uses: actions/cache@v4
with:
path: |
./packages/**/dist
./node_modules/.yarn-state.yml
key: ${{ github.sha }}
fail-on-cache-miss: true
- name: Publish
uses: MetaMask/action-npm-publish@v4
uses: MetaMask/action-npm-publish@v5
with:
npm-token: ${{ secrets.NPM_TOKEN }}
env:
Expand Down
52 changes: 0 additions & 52 deletions .yarn/plugins/@yarnpkg/plugin-constraints.cjs

This file was deleted.

28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

807 changes: 0 additions & 807 deletions .yarn/releases/yarn-3.3.0.cjs

This file was deleted.

12 changes: 5 additions & 7 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
compressionLevel: mixed

enableGlobalCache: false

enableScripts: false

enableTelemetry: 0
enableTelemetry: false

logFilters:
- code: YN0004
Expand All @@ -11,9 +15,3 @@ nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
spec: "https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-constraints.cjs
spec: "@yarnpkg/plugin-constraints"

yarnPath: .yarn/releases/yarn-3.3.0.cjs
7 changes: 7 additions & 0 deletions constraints.pro
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,13 @@ gen_enforced_dependency(WorkspaceCwd, DependencyIdent, CorrectPeerDependencyRang
atom_concat('^', CurrentDependencyVersion, CorrectPeerDependencyRange)
).

% The root workspace (and only the root workspace) needs to specify the Yarn
% version required for development.
gen_enforced_field(WorkspaceCwd, 'packageManager', '[email protected]') :-
WorkspaceCwd == '.'.
gen_enforced_field(WorkspaceCwd, 'packageManager', null) :-
WorkspaceCwd \= '.'.

% All packages must specify a minimum Node version of 18.
gen_enforced_field(WorkspaceCwd, 'engines.node', '^18.18 || >=20').

Expand Down
3 changes: 2 additions & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

- Install the current LTS version of [Node.js](https://nodejs.org)
- If you are using [nvm](https://github.com/creationix/nvm#installation) (recommended) running `nvm install` will install the latest version and running `nvm use` will automatically choose the right node version for you.
- Install [Yarn v3](https://yarnpkg.com/getting-started/install).
- Install [Yarn](https://yarnpkg.com) via [Corepack](https://github.com/nodejs/corepack?tab=readme-ov-file#how-to-install)
- If you have Yarn installed globally via Homebrew or NPM, you'll need to uninstall it before enabling it via Corepack.
- Run `yarn install` to install dependencies and run any required post-install scripts.
- Run `yarn simple-git-hooks` to add a [Git hook](https://github.com/toplenboren/simple-git-hooks#what-is-a-git-hook) to your local development environment which will ensure that all files pass linting before you push a branch.

Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"scripts": {
"build": "yarn run build:source && yarn run build:types",
"build:clean": "rimraf dist '**/*.tsbuildinfo' && yarn build",
"build:docs": "yarn workspaces foreach --no-private --parallel --interlaced --verbose run build:docs",
"build:source": "yarn workspaces foreach --no-private --parallel --interlaced --verbose run build",
"build:docs": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run build:docs",
"build:source": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run build",
"build:types": "tsc --build tsconfig.build.json --verbose",
"build:watch": "yarn run build --watch",
"changelog:update": "yarn workspaces foreach --no-private --parallel --interlaced --verbose run changelog:update",
"changelog:validate": "yarn workspaces foreach --no-private --parallel --interlaced --verbose run changelog:validate",
"changelog:update": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run changelog:update",
"changelog:validate": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run changelog:validate",
"create-package": "ts-node scripts/create-package",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn constraints && yarn lint:dependencies",
"lint:dependencies": "depcheck && yarn dedupe --check",
Expand All @@ -29,13 +29,13 @@
"lint:misc": "prettier '**/*.json' '**/*.md' '!**/CHANGELOG.old.md' '**/*.yml' '!.yarnrc.yml' '!merged-packages/**' --ignore-path .gitignore",
"prepack": "./scripts/prepack.sh",
"prepare-preview-builds": "./scripts/prepare-preview-builds.sh",
"publish-previews": "yarn workspaces foreach --no-private --parallel --verbose run publish:preview",
"publish-previews": "yarn workspaces foreach --all --no-private --parallel --verbose run publish:preview",
"setup": "yarn install",
"test": "yarn test:scripts --silent --collectCoverage=false --reporters=jest-silent-reporter && yarn test:packages",
"test:clean": "yarn workspaces foreach --parallel --verbose run test:clean && yarn test",
"test:clean": "yarn workspaces foreach --all --parallel --verbose run test:clean && yarn test",
"test:packages": "yarn test:verbose --silent --collectCoverage=false --reporters=jest-silent-reporter",
"test:scripts": "yarn jest --config ./jest.config.scripts.js --silent",
"test:verbose": "yarn workspaces foreach --parallel --verbose run test:verbose",
"test:verbose": "yarn workspaces foreach --all --parallel --verbose run test:verbose",
"update-readme-content": "ts-node scripts/update-readme-content.ts",
"workspaces:list-versions": "./scripts/list-workspace-versions.sh"
},
Expand Down Expand Up @@ -88,7 +88,7 @@
"typescript": "~4.9.5",
"yargs": "^17.7.2"
},
"packageManager": "yarn@3.3.0",
"packageManager": "yarn@4.2.2",
"engines": {
"node": "^18.18 || >=20"
},
Expand Down
1 change: 0 additions & 1 deletion packages/eth-json-rpc-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"typedoc": "^0.24.8",
"typescript": "~4.9.5"
},
"packageManager": "[email protected]",
"engines": {
"node": "^18.18 || >=20"
},
Expand Down
1 change: 0 additions & 1 deletion packages/json-rpc-engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"typedoc": "^0.24.8",
"typescript": "~4.9.5"
},
"packageManager": "[email protected]",
"engines": {
"node": "^18.18 || >=20"
},
Expand Down
Loading

0 comments on commit 27dd62c

Please sign in to comment.