Skip to content

Commit

Permalink
Upgrade Yarn to v3 (#463)
Browse files Browse the repository at this point in the history
Closes #458.

This upgrades Yarn to the latest version, v3, and uses the Yarn v3 workspaces plugin to manage the workspace. The examples package is now a sub-workspace (meaning it can't be published to npm anymore), which removes the need for the build script and solves some issues regarding dependency management as well.

Co-authored-by: Erik Marks <rekmarks@protonmail.com>
  • Loading branch information
Mrtenz and rekmarks committed May 16, 2022
1 parent 9f7d90d commit 1ef459c
Show file tree
Hide file tree
Showing 37 changed files with 23,900 additions and 19,847 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Get Yarn cache directory
run: echo "::set-output name=YARN_CACHE_DIR::$(yarn cache dir)"
id: yarn-cache-dir
- name: Get Yarn version
run: echo "::set-output name=YARN_VERSION::$(yarn --version)"
id: yarn-version
- name: Cache yarn dependencies
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }}
path: .yarn/cache
key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}
- run: yarn install --frozen-lockfile
- run: yarn install --immutable
- run: yarn allow-scripts
- run: yarn build
- name: Require clean working directory
Expand Down Expand Up @@ -68,18 +65,15 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Get Yarn cache directory
run: echo "::set-output name=YARN_CACHE_DIR::$(yarn cache dir)"
id: yarn-cache-dir
- name: Get Yarn version
run: echo "::set-output name=YARN_VERSION::$(yarn --version)"
id: yarn-version
- name: Cache yarn dependencies
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }}
path: .yarn/cache
key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}
- run: yarn install --frozen-lockfile
- run: yarn install --immutable
- run: yarn allow-scripts
- run: yarn build
- name: Require clean working directory
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ build/Release
# Dependency directories
node_modules/

# Yarn directories
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# TypeScript v1 declaration files
typings/

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

Large diffs are not rendered by default.

786 changes: 786 additions & 0 deletions .yarn/releases/yarn-3.2.1.cjs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion .yarnrc

This file was deleted.

9 changes: 9 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
nodeLinker: node-modules

enableScripts: false

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'

yarnPath: .yarn/releases/yarn-3.2.1.cjs
23 changes: 13 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
"link-packages": "./scripts/link-packages.sh",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:misc": "prettier '**/*.json' '**/*.md' '!**/CHANGELOG.md' '**/*.yml' --ignore-path .gitignore",
"lint:changelogs": "yarn workspaces run lint:changelog",
"lint:changelogs": "cross-env npm_package_repository_url=https://github.com/MetaMask/snaps-skunkworks.git yarn workspaces foreach --parallel --topological run lint:changelog",
"lint:tsconfig": "node scripts/verify-tsconfig.mjs",
"lint": "yarn lint:tsconfig && yarn lint:eslint && yarn lint:misc --check",
"lint:fix": "yarn lint:tsconfig && yarn lint:eslint --fix && yarn lint:misc --write",
"build": "yarn build:pre-tsc && yarn build:tsc && yarn build:post-tsc",
"build:clean": "yarn clean && yarn build",
"build:tsc": "tsc --build",
"build:pre-tsc": "yarn workspaces run build:pre-tsc ",
"build:post-tsc": "yarn workspaces run build:post-tsc",
"clean": "yarn workspaces run clean",
"test": "yarn workspaces run test",
"test:ci": "yarn workspaces run test:ci"
"build:pre-tsc": "yarn workspaces foreach --parallel --topological run build:pre-tsc",
"build:post-tsc": "yarn workspaces foreach --parallel --topological run build:post-tsc",
"clean": "yarn workspaces foreach --parallel run clean",
"test": "yarn workspaces foreach --parallel run test",
"test:ci": "yarn workspaces foreach --parallel run test:ci"
},
"simple-git-hooks": {
"pre-commit": "yarn lint-staged"
Expand All @@ -42,7 +42,7 @@
},
"devDependencies": {
"@jest-runner/electron": "^3.0.1",
"@lavamoat/allow-scripts": "^1.0.6",
"@lavamoat/allow-scripts": "^2.0.3",
"@metamask/auto-changelog": "^2.5.0",
"@metamask/eslint-config": "^8.0.0",
"@metamask/eslint-config-jest": "^8.0.0",
Expand All @@ -52,6 +52,7 @@
"@types/node": "^14.14.25",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"cross-env": "^7.0.3",
"electron": "^13.6.6",
"eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0",
Expand All @@ -73,9 +74,11 @@
"allowScripts": {
"@jest-runner/electron": true,
"@lavamoat/preinstall-always-fail": false,
"core-js": true,
"electron": true,
"simple-git-hooks": false
"simple-git-hooks": false,
"$root$": false,
"electron>@electron/get>global-agent>core-js": false
}
}
},
"packageManager": "yarn@3.2.1"
}
2 changes: 1 addition & 1 deletion packages/controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"posttest": "jest-it-up",
"test:ci": "yarn test:prepare && ./scripts/test-ci.sh",
"build:pre-tsc": "yarn build:ajv && node scripts/transpileSchemaTypes.js",
"build:post-tsc": "echo 'N/A'",
"build:tsc": "tsc --project tsconfig.local.json",
"ajv-compile": "ajv compile --strict=true --all-errors",
"build:ajv": "./scripts/build-ajv.sh",
Expand Down Expand Up @@ -58,6 +57,7 @@
"devDependencies": {
"@jest-runner/electron": "^3.0.1",
"@json-schema-tools/transpiler": "^1.10.2",
"@metamask/auto-changelog": "^2.5.0",
"@metamask/snap-types": "^0.14.0",
"@metamask/template-snap": "^0.7.0",
"@types/concat-stream": "^1.6.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/controllers/scripts/test-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ set -o pipefail

# We have to use xvfb due to electron
# Ref: https://github.com/facebook-atom/jest-electron-runner/issues/47#issuecomment-508556407
xvfb-run -e /dev/stdout yarn test
xvfb-run yarn test 2>&1
1 change: 0 additions & 1 deletion packages/examples/examples/bls-signer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"snap.manifest.json"
],
"scripts": {
"test": "echo 'Error: no test specified' && exit 1",
"build": "mm-snap build"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/examples/bls-signer/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps-skunkworks.git"
},
"source": {
"shasum": "n5/s5K66duQVo/8Rz+ajmeqx8+y9pRKezjZXG9K4xd4=",
"shasum": "cWQwCSudKr+KUCgLIwnCtaes7GZjBq3pTOyFmKwjXCE=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
20 changes: 0 additions & 20 deletions packages/examples/examples/bls-signer/yarn.lock

This file was deleted.

1 change: 0 additions & 1 deletion packages/examples/examples/ethers-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"snap.manifest.json"
],
"scripts": {
"test": "echo 'Error: no test specified' && exit 1",
"build": "mm-snap build"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/examples/ethers-js/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps-skunkworks.git"
},
"source": {
"shasum": "h3V7LGvxmyPPdbQDoB4JA2aEqejW9B0saUNwIsGAr4w=",
"shasum": "y27GfCXkuPncK3zao081xoIfu8k/Ji8U6XmLfmexZyo=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Loading

0 comments on commit 1ef459c

Please sign in to comment.