Skip to content

Commit

Permalink
Add Yarn 3 allow-scripts plugin (#545)
Browse files Browse the repository at this point in the history
* Add Yarn 3 allow-scripts plugin

* Remove usage of yarn setup

* Remove manual instances of calling allow-scripts

* Re-add setup command for backwards compatability
  • Loading branch information
FrederikBolding committed Jun 16, 2022
1 parent e9dbe49 commit 07651ad
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 11 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
path: .yarn/cache
key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}
- run: yarn install --immutable
- run: yarn allow-scripts
- run: yarn build
- name: Require clean working directory
shell: bash
Expand Down Expand Up @@ -76,7 +75,6 @@ jobs:
# To use the --immutable flag, we have to install all dependencies, not
# just the ones we need.
- run: yarn install --immutable
- run: yarn allow-scripts
- name: Build @metamask/snaps-cli and its dependents only
shell: bash
run: |
Expand Down
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;
}
};
6 changes: 4 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
nodeLinker: node-modules

enableScripts: false

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'
- 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'

yarnPath: .yarn/releases/yarn-3.2.1.cjs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Monorepo for experimental snaps dependencies.

### Installing

Run `yarn setup` in the project root directory.
Run `yarn install` in the project root directory.
Do **not** run any installation commands in individual workspaces.

If you add a dependency with a lifecycle script, said dependency must be added to the `devDependencies` and `lavamoat.allow-scripts` config of the root `package.json` file.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"packages/*"
],
"scripts": {
"setup": "yarn install && yarn allow-scripts && yarn postinstall && yarn simple-git-hooks",
"postinstall": "patch-package",
"setup": "yarn install",
"postinstall": "patch-package && simple-git-hooks",
"publish:all": "./scripts/publish-all.sh",
"link-packages": "./scripts/link-packages.sh",
"lint:eslint": "eslint . --cache --ext js,ts",
Expand Down
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"dist/"
],
"scripts": {
"setup": "yarn install && yarn allow-scripts",
"shasum": "node ./scripts/computeSnapShasum.js",
"build:init-template": "node ./scripts/createInitTemplate.js && yarn prettier --check src/cmds/init/init-template.json",
"build:guards": "ts-auto-guard --guard-file-name=__GENERATED__ ./src/utils/snap-config.ts",
Expand Down
1 change: 0 additions & 1 deletion packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"examples/*"
],
"scripts": {
"setup": "yarn install && yarn allow-scripts",
"lint:changelog": "yarn auto-changelog validate",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore",
Expand Down
1 change: 0 additions & 1 deletion packages/execution-environments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"posttest": "jest-it-up",
"test:ci": "yarn test",
"test:watch": "jest --watch",
"setup": "yarn install && yarn allow-scripts",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path .gitignore",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
Expand Down
2 changes: 1 addition & 1 deletion scripts/publish-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -o pipefail
# git working tree remains cleans, then asks for an npm 2FA code and publishes
# all packages.

yarn setup
yarn install
yarn build:clean
yarn lint

Expand Down

0 comments on commit 07651ad

Please sign in to comment.