Skip to content

Commit 56445a7

Browse files
authored
chore: Upgrade to Yarn v4 (#128)
Update from Yarn v1 to v4, following the `metamask-module-template` as a guide.
1 parent f2031cd commit 56445a7

File tree

8 files changed

+7565
-5413
lines changed

8 files changed

+7565
-5413
lines changed

.github/workflows/create-release-pr.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ jobs:
2121
contents: write
2222
pull-requests: write
2323
steps:
24-
- uses: actions/checkout@v4
24+
- name: Checkout and setup environment
25+
uses: MetaMask/action-checkout-and-setup@v1
2526
with:
26-
# This is to guarantee that the most recent tag is fetched.
27-
# This can be configured to a more reasonable value by consumers.
27+
is-high-risk-environment: true
28+
29+
# This is to guarantee that the most recent tag is fetched. This can
30+
# be configured to a more reasonable value by consumers.
2831
fetch-depth: 0
32+
2933
# We check out the specified branch, which will be used as the base
3034
# branch for all git operations and the release PR.
3135
ref: ${{ github.event.inputs.base-branch }}
32-
- uses: actions/setup-node@v4
33-
with:
34-
node-version-file: .nvmrc
35-
cache: yarn
3636
- uses: MetaMask/action-create-release-pr@v1
3737
env:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/lint-test.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ jobs:
1616
- 20.x
1717
- 22.x
1818
steps:
19-
- uses: actions/checkout@v4
20-
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v4
19+
- name: Checkout and setup environment
20+
uses: MetaMask/action-checkout-and-setup@v1
2221
with:
22+
is-high-risk-environment: false
2323
node-version: ${{ matrix.node-version }}
24-
cache: yarn
25-
- run: yarn --frozen-lockfile --ignore-engines
26-
- run: yarn allow-scripts
2724
- run: yarn build
2825
- run: yarn lint
2926
- run: yarn test

.gitignore

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ node_modules/
6666
# Stores VSCode versions used for testing VSCode extensions
6767
.vscode-test
6868

69-
# yarn v2
70-
.yarn/cache
71-
.yarn/unplugged
72-
.yarn/build-state.yml
73-
.yarn/install-state.gz
69+
# yarn v3 (w/o zero-install)
70+
# See: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
7471
.pnp.*
72+
.yarn/*
73+
!.yarn/patches
74+
!.yarn/plugins
75+
!.yarn/releases
76+
!.yarn/sdks
77+
!.yarn/versions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* eslint-disable */
2+
//prettier-ignore
3+
module.exports = {
4+
name: "@yarnpkg/plugin-allow-scripts",
5+
factory: function (require) {
6+
var plugin=(()=>{var l=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var u=(t,o)=>{for(var e in o)l(t,e,{get:o[e],enumerable:!0})},f=(t,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of a(o))!c.call(t,i)&&i!==e&&l(t,i,{get:()=>o[i],enumerable:!(r=s(o,i))||r.enumerable});return t};var m=t=>f(l({},"__esModule",{value:!0}),t);var g={};u(g,{default:()=>d});var n=p("@yarnpkg/shell"),x={hooks:{afterAllInstalled:async()=>{let t=await(0,n.execute)("yarn run allow-scripts");t!==0&&process.exit(t)}}},d=x;return m(g);})();
7+
return plugin;
8+
}
9+
};

.yarnrc.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
compressionLevel: mixed
2+
3+
enableGlobalCache: false
4+
5+
enableScripts: false
6+
7+
enableTelemetry: 0
8+
logFilters:
9+
- code: YN0004
10+
level: discard
11+
12+
nodeLinker: node-modules
13+
14+
plugins:
15+
- path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
16+
spec: "https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js"

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ const result = await engine.handle({
6060

6161
- Install [Node.js](https://nodejs.org) version 18
6262
- If you are using [nvm](https://github.com/creationix/nvm#installation) (recommended) running `nvm use` will automatically choose the right node version for you.
63-
- Install [Yarn v1](https://yarnpkg.com/en/docs/install)
64-
- Run `yarn setup` to install dependencies and run any requried post-install scripts
65-
- **Warning:** Do not use the `yarn` / `yarn install` command directly. Use `yarn setup` instead. The normal install command will skip required post-install scripts, leaving your development environment in an invalid state.
63+
- Install [Yarn](https://yarnpkg.com) v4 via [Corepack](https://github.com/nodejs/corepack?tab=readme-ov-file#how-to-install)
64+
- Run `yarn install` to install dependencies and run any required post-install scripts
6665

6766
### Testing and Linting
6867

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
"lint": "yarn lint:eslint && yarn lint:misc --check",
1919
"lint:eslint": "eslint . --cache --ext js,ts",
2020
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
21-
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern",
21+
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore --no-error-on-unmatched-pattern",
2222
"prepublishOnly": "yarn build:clean && yarn lint && yarn test",
23-
"setup": "yarn install && yarn allow-scripts",
2423
"test": "jest && yarn build:clean && yarn test:types",
2524
"test:types": "tsd --files 'src/**/*.test-d.ts'",
2625
"test:watch": "jest --watch"
@@ -33,7 +32,7 @@
3332
},
3433
"devDependencies": {
3534
"@lavamoat/allow-scripts": "^2.3.1",
36-
"@metamask/auto-changelog": "^2.5.0",
35+
"@metamask/auto-changelog": "^2.6.0",
3736
"@metamask/error-reporting-service": "^2.1.0",
3837
"@metamask/eslint-config": "^12.2.0",
3938
"@metamask/eslint-config-jest": "^12.1.0",
@@ -62,6 +61,7 @@
6261
"tsd": "^0.31.2",
6362
"typescript": "~4.8.4"
6463
},
64+
"packageManager": "[email protected]",
6565
"engines": {
6666
"node": "^18.18 || ^20.14 || >=22"
6767
},

0 commit comments

Comments
 (0)