Skip to content

Commit

Permalink
Upgrade to Yarn v3 (#119)
Browse files Browse the repository at this point in the history
- Use Yarn 3.2.1 as designated by the module template
- Regenerate `yarn.lock` using Yarn v3
- Replace `prepublishOnly` package script with `prepack`, and add
  `scripts/prepack.sh` from the module template
- Run `yarn dedupe` when running `yarn lint`
- Remove `yarn setup` as `yarn install` automatically runs `yarn
  allow-scripts`
  • Loading branch information
mcmire authored Feb 6, 2024
1 parent bf5e598 commit 7956694
Show file tree
Hide file tree
Showing 11 changed files with 6,273 additions and 3,693 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install Yarn dependencies
run: yarn --frozen-lockfile && yarn allow-scripts
run: yarn --immutable

build:
name: Build
Expand All @@ -33,7 +33,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn --frozen-lockfile && yarn allow-scripts
- run: yarn --immutable --immutable-cache
- run: yarn build
- name: Require clean working directory
shell: bash
Expand All @@ -59,7 +59,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn --frozen-lockfile && yarn allow-scripts
- run: yarn --immutable --immutable-cache
- run: yarn lint
- name: Require clean working directory
shell: bash
Expand All @@ -85,7 +85,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn --frozen-lockfile && yarn allow-scripts
- run: yarn --immutable --immutable-cache
- run: yarn test
- name: Require clean working directory
shell: bash
Expand Down
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
package-lock.json
dist
node_modules/
bundle.js

# Output of 'npm pack'
*.tgz

# yarn v3 (w/o zero-install)
# See: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-allow-scripts",
factory: function (require) {
var plugin=(()=>{var a=Object.create,l=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var u=e=>l(e,"__esModule",{value:!0});var f=e=>{if(typeof require!="undefined")return require(e);throw new Error('Dynamic require of "'+e+'" is not supported')};var g=(e,o)=>{for(var r in o)l(e,r,{get:o[r],enumerable:!0})},m=(e,o,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of s(o))!c.call(e,t)&&t!=="default"&&l(e,t,{get:()=>o[t],enumerable:!(r=i(o,t))||r.enumerable});return e},x=e=>m(u(l(e!=null?a(p(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var k={};g(k,{default:()=>d});var n=x(f("@yarnpkg/shell")),y={hooks:{afterAllInstalled:async()=>{let e=await(0,n.execute)("yarn run allow-scripts");e!==0&&process.exit(e)}}},d=y;return k;})();
return plugin;
}
};
52 changes: 52 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-constraints.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.

17 changes: 17 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
enableScripts: false

enableTelemetry: 0

logFilters:
- code: YN0004
level: discard

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-constraints.cjs
spec: "@yarnpkg/plugin-constraints"

yarnPath: .yarn/releases/yarn-3.2.1.cjs
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A JS module for tracking Ethereum tokens and their values over time.

## Installation

`yarn install '@metamask/eth-token-tracker'`
`yarn add @metamask/eth-token-tracker`

## Usage

Expand Down Expand Up @@ -43,6 +43,6 @@ tokenTracker.stop()
## Running tests

```bash
yarn setup
yarn install
yarn test
```
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"node": "^16.20.1 || ^18.16.1 || >=20"
},
"scripts": {
"lint": "echo 'Skip'",
"prepublishOnly": "npm run build",
"lint": "yarn lint:dependencies",
"lint:dependencies": "yarn dedupe",
"build": "babel --presets @babel/preset-env --plugins @babel/plugin-transform-runtime -d dist/ lib/",
"test": "tape test/**/*.js",
"buildSample": "browserify example/index.js -o bundle.js",
"setup": "yarn install && yarn allow-scripts"
"prepack": "./scripts/prepack.sh"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -48,9 +48,9 @@
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/runtime": "^7.21.0",
"@babel/plugin-transform-runtime": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@babel/runtime": "^7.21.0",
"@lavamoat/allow-scripts": "^2.3.1",
"@lavamoat/preinstall-always-fail": "^2.0.0",
"ganache": "7.3.1",
Expand All @@ -60,6 +60,7 @@
"peerDependencies": {
"@babel/runtime": "^7.21.0"
},
"packageManager": "[email protected]",
"lavamoat": {
"allowScripts": {
"@lavamoat/preinstall-always-fail": false,
Expand Down
11 changes: 11 additions & 0 deletions scripts/prepack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -e
set -o pipefail

if [[ -n $SKIP_PREPACK ]]; then
echo "Notice: skipping prepack."
exit 0
fi

yarn build
Loading

0 comments on commit 7956694

Please sign in to comment.