Skip to content

Commit

Permalink
chore: support for Yarn 4 (#6949)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Jul 5, 2024
1 parent 44349e9 commit 406d5e9
Show file tree
Hide file tree
Showing 12 changed files with 2,736 additions and 2,693 deletions.
4 changes: 4 additions & 0 deletions .github/actions/prepare-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ inputs:
runs:
using: 'composite'
steps:
- name: Enable Corepack
shell: bash
run: corepack enable

- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows-disabled/approve-workflow-runs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Enable Corepack
shell: bash
run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
with:
fetch-depth: 0

- name: Enable Corepack
shell: bash
run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/nightly-config-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
with:
fetch-depth: 0 # Fetch the history, or this action won't work

- name: Enable Corepack
shell: bash
run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/zwave-js-bot_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ jobs:
- name: Switch to a branch
run: git switch -c temp

- name: Enable Corepack
shell: bash
run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -400,6 +404,10 @@ jobs:
return bot.checkAuthorized({github, context});
# These steps only run if the check was successful
- name: Enable Corepack
shell: bash
run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
if: steps.check-permissions.outputs.result == 'true'
uses: actions/setup-node@v4
Expand Down Expand Up @@ -508,6 +516,10 @@ jobs:
return bot.checkAuthorized({github, context});
# These steps only run if the check was successful
- name: Enable Corepack
shell: bash
run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
if: steps.check-permissions.outputs.result == 'true'
uses: actions/setup-node@v4
Expand Down Expand Up @@ -628,6 +640,10 @@ jobs:
return bot.checkAuthorized({github, context});
# These steps only run if the check was successful
- name: Enable Corepack
shell: bash
run: corepack enable

- name: Use Node.js ${{ matrix.node-version }}
if: steps.check-permissions.outputs.result == 'true'
uses: actions/setup-node@v4
Expand Down
9 changes: 7 additions & 2 deletions .yarn/plugins/@yarnpkg/plugin-changed.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-changed",
factory: function (require) {
var plugin;(()=>{"use strict";var e={d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>f});const o=require("@yarnpkg/cli"),n=require("clipanion"),r=require("@yarnpkg/core");function a(e){const{project:t}=e,o=new Set;return function e({manifest:n}){for(const a of r.Manifest.hardDependencies)for(const r of n.getForScope(a).values()){const n=t.tryWorkspaceByDescriptor(r);n&&!o.has(n)&&(o.add(n),e(n))}}(e),[...o]}function s(e){const t=new Set;for(const o of e.project.workspaces){a(o).some(t=>r.structUtils.areLocatorsEqual(t.locator,e.locator))&&t.add(o)}return[...t]}var i=function(e,t,o,n){var r,a=arguments.length,s=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,n);else for(var i=e.length-1;i>=0;i--)(r=e[i])&&(s=(a<3?r(s):a>3?r(t,o,s):r(t,o))||s);return a>3&&s&&Object.defineProperty(t,o,s),s};class c extends o.BaseCommand{async listWorkspaces(e){const{stdout:t}=await r.execUtils.execvp("git",["diff","--name-only",...this.gitRange?[this.gitRange]:[]],{cwd:e.cwd,strict:!0}),o=function(e,t){const o=new Set;for(const n of e.workspaces){if(t.some(e=>e.startsWith(n.relativeCwd))&&!o.has(n)){o.add(n);for(const e of s(n))o.add(e)}}return[...o]}(e,t.split(/\r?\n/)),n=this.include||[],a=this.exclude||[];return o.filter(e=>{const t=r.structUtils.stringifyIdent(e.locator);if(t){if(n.length&&!n.includes(t))return!1;if(a.length&&a.includes(t))return!1}return!0})}}i([n.Command.String("--git-range")],c.prototype,"gitRange",void 0),i([n.Command.Array("--include")],c.prototype,"include",void 0),i([n.Command.Array("--exclude")],c.prototype,"exclude",void 0);var d=function(e,t,o,n){var r,a=arguments.length,s=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,n);else for(var i=e.length-1;i>=0;i--)(r=e[i])&&(s=(a<3?r(s):a>3?r(t,o,s):r(t,o))||s);return a>3&&s&&Object.defineProperty(t,o,s),s};class l extends c{constructor(){super(...arguments),this.json=!1}async execute(){const e=await r.Configuration.find(this.context.cwd,this.context.plugins),{project:t,workspace:n}=await r.Project.find(e,this.context.cwd);if(!n)throw new o.WorkspaceRequiredError(t.cwd,this.context.cwd);return(await r.StreamReport.start({configuration:e,json:this.json,stdout:this.context.stdout},async e=>{const o=await this.listWorkspaces(t);for(const t of o)e.reportInfo(null,t.relativeCwd),e.reportJson({name:t.manifest.name?r.structUtils.stringifyIdent(t.manifest.name):null,location:t.relativeCwd})})).exitCode()}}l.usage=n.Command.Usage({description:"List changed workspaces and their dependents",details:"\n If the `--json` flag is set the output will follow a JSON-stream output also known as NDJSON (https://github.com/ndjson/ndjson-spec).\n ",examples:[["Find changed files within a Git range","yarn changed list --git-range 93a9ed8..4ef2c61"],["Include or exclude workspaces","yarn changed list --include @foo/a --exclude @foo/b"]]}),d([n.Command.Boolean("--json")],l.prototype,"json",void 0),d([n.Command.Path("changed","list")],l.prototype,"execute",null);var p=function(e,t,o,n){var r,a=arguments.length,s=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,n);else for(var i=e.length-1;i>=0;i--)(r=e[i])&&(s=(a<3?r(s):a>3?r(t,o,s):r(t,o))||s);return a>3&&s&&Object.defineProperty(t,o,s),s};class u extends c{constructor(){super(...arguments),this.args=[],this.verbose=!1,this.parallel=!1,this.interlaced=!1,this.topological=!1}async execute(){const e=await r.Configuration.find(this.context.cwd,this.context.plugins),{project:t,workspace:n}=await r.Project.find(e,this.context.cwd);if(!n)throw new o.WorkspaceRequiredError(t.cwd,this.context.cwd);const a=await this.listWorkspaces(t);if(!a.length){return(await r.StreamReport.start({configuration:e,stdout:this.context.stdout},async e=>{e.reportInfo(null,"No workspaces changed")})).exitCode()}return this.cli.run(["workspaces","foreach",...a.reduce((e,t)=>[...e,"--include",r.structUtils.stringifyIdent(t.locator)],[]),...this.verbose?["--verbose"]:[],...this.parallel?["--parallel"]:[],...this.interlaced?["--interlaced"]:[],...this.topological?["--topological"]:[],...this.jobs?["--jobs",""+this.jobs]:[],this.commandName,...this.args],{cwd:t.cwd})}}u.usage=n.Command.Usage({description:"Run a command on changed workspaces and their dependents",details:"\n This command will run a given sub-command on changed workspaces and workspaces depends on them.\n\n Check the documentation for `yarn workspace foreach` for more details.\n ",examples:[["Run build scripts on changed workspaces","yarn changed foreach run build"],["Find changed files within a Git range","yarn changed foreach --git-range 93a9ed8..4ef2c61 run build"]]}),p([n.Command.String()],u.prototype,"commandName",void 0),p([n.Command.Proxy()],u.prototype,"args",void 0),p([n.Command.Boolean("-v,--verbose")],u.prototype,"verbose",void 0),p([n.Command.Boolean("-p,--parallel")],u.prototype,"parallel",void 0),p([n.Command.Boolean("-i,--interlaced")],u.prototype,"interlaced",void 0),p([n.Command.Boolean("-t,--topological")],u.prototype,"topological",void 0),p([n.Command.String("-j,--jobs")],u.prototype,"jobs",void 0),p([n.Command.Path("changed","foreach")],u.prototype,"execute",null);const f={commands:[l,u]};plugin=t})();
"use strict";var plugin=(()=>{var b=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var i=(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 N=(t,o)=>{for(var e in o)b(t,e,{get:o[e],enumerable:!0})},O=(t,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of I(o))!U.call(t,s)&&s!==e&&b(t,s,{get:()=>o[s],enumerable:!(r=R(o,s))||r.enumerable});return t};var q=t=>O(b({},"__esModule",{value:!0}),t);var J={};N(J,{default:()=>E});var B=i("@yarnpkg/cli"),g=i("clipanion"),w=i("@yarnpkg/core");var P=i("@yarnpkg/core");var v=i("@yarnpkg/core");function W(t){let{project:o}=t,e=new Set;function r({manifest:s}){for(let c of v.Manifest.hardDependencies)for(let l of s.getForScope(c).values()){let n=o.tryWorkspaceByDescriptor(l);n&&!e.has(n)&&(e.add(n),r(n))}}return r(t),[...e]}function y(t){let o=new Set;for(let e of t.project.workspaces)W(e).some(s=>P.structUtils.areLocatorsEqual(s.anchoredLocator,t.anchoredLocator))&&o.add(e);return[...o]}function j(t,o){let e=new Set;for(let r of t.workspaces)if(o.some(c=>c.startsWith(r.relativeCwd))&&!e.has(r)){e.add(r);for(let c of y(r))e.add(c)}return[...e]}var m=class extends B.BaseCommand{constructor(){super(...arguments);this.gitRange=g.Option.String("--git-range");this.cached=g.Option.Boolean("--cached",!1);this.include=g.Option.Array("--include");this.exclude=g.Option.Array("--exclude")}async listWorkspaces(e){let{stdout:r}=await w.execUtils.execvp("git",["diff","--name-only",...this.cached?["--cached"]:[],...this.gitRange?[this.gitRange]:[]],{cwd:e.cwd,strict:!0}),s=r.split(/\r?\n/),c=j(e,s),l=this.include||[],n=this.exclude||[];return c.filter(h=>{let x=w.structUtils.stringifyIdent(h.anchoredLocator);return!(x&&(l.length&&!l.includes(x)||n.length&&n.includes(x)))})}};var k=i("clipanion"),d=i("@yarnpkg/core"),S=i("@yarnpkg/cli"),f=class extends m{constructor(){super(...arguments);this.json=k.Option.Boolean("--json",!1)}async execute(){let e=await d.Configuration.find(this.context.cwd,this.context.plugins),{project:r,workspace:s}=await d.Project.find(e,this.context.cwd);if(!s)throw new S.WorkspaceRequiredError(r.cwd,this.context.cwd);return(await d.StreamReport.start({configuration:e,json:this.json,stdout:this.context.stdout},async l=>{let n=await this.listWorkspaces(r);for(let h of n)l.reportInfo(null,h.relativeCwd),l.reportJson({name:h.manifest.name?d.structUtils.stringifyIdent(h.manifest.name):null,location:h.relativeCwd})})).exitCode()}};f.usage=k.Command.Usage({description:"List changed workspaces and their dependents",details:"\n If the `--json` flag is set the output will follow a JSON-stream output also known as NDJSON (https://github.com/ndjson/ndjson-spec).\n ",examples:[["Find changed files within a Git range","yarn changed list --git-range 93a9ed8..4ef2c61"],["Include or exclude workspaces","yarn changed list --include @foo/a --exclude @foo/b"]]}),f.paths=[["changed","list"]];var a=i("clipanion"),p=i("@yarnpkg/core"),D=i("@yarnpkg/cli"),u=class extends m{constructor(){super(...arguments);this.commandName=a.Option.String();this.args=a.Option.Proxy();this.verbose=a.Option.Boolean("-v,--verbose",!1);this.parallel=a.Option.Boolean("-p,--parallel",!1);this.interlaced=a.Option.Boolean("-i,--interlaced",!1);this.topological=a.Option.Boolean("-t,--topological",!1);this.all=a.Option.Boolean("-A,--all",!1);this.recursive=a.Option.Boolean("-R,--recursive",!1);this.worktree=a.Option.Boolean("-W,--worktree",!1);this.jobs=a.Option.String("-j,--jobs")}async execute(){let e=await p.Configuration.find(this.context.cwd,this.context.plugins),{project:r,workspace:s}=await p.Project.find(e,this.context.cwd);if(!s)throw new D.WorkspaceRequiredError(r.cwd,this.context.cwd);let c=await this.listWorkspaces(r);return c.length?this.cli.run(["workspaces","foreach",...c.reduce((l,n)=>[...l,"--include",p.structUtils.stringifyIdent(n.anchoredLocator)],[]),...this.verbose?["--verbose"]:[],...this.parallel?["--parallel"]:[],...this.interlaced?["--interlaced"]:[],...this.topological?["--topological"]:[],...this.all?["--all"]:[],...this.recursive?["--recursive"]:[],...this.worktree?["--worktree"]:[],...this.jobs?["--jobs",`${this.jobs}`]:[],this.commandName,...this.args],{cwd:r.cwd}):(await p.StreamReport.start({configuration:e,stdout:this.context.stdout},async n=>{n.reportInfo(null,"No workspaces changed")})).exitCode()}};u.usage=a.Command.Usage({description:"Run a command on changed workspaces and their dependents",details:`
This command will run a given sub-command on changed workspaces and workspaces depends on them.
Check the documentation for \`yarn workspace foreach\` for more details.
`,examples:[["Run build scripts on changed workspaces","yarn changed foreach run build"],["Find changed files within a Git range","yarn changed foreach --git-range 93a9ed8..4ef2c61 run build"]]}),u.paths=[["changed","foreach"]];var A={commands:[f,u]},E=A;return q(J);})();
return plugin;
}
};
};
17 changes: 5 additions & 12 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
compressionLevel: mixed

enableGlobalCache: true

nodeLinker: pnpm

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-changed.cjs
spec: "https://github.com/Dcard/yarn-plugins/releases/download/v0.7.2/plugin-changed.js"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
- checksum: e09b9d94c3e4f271d75c0aa5364f424f9d654a086b7f6c8a16c7dd46ee6b0face259054cb4ac916080a1ec49a6519e04858b3f340fd3a9f325b6b344c34839c6
path: .yarn/plugins/@yarnpkg/plugin-changed.cjs
spec: "https://raw.githubusercontent.com/zwave-js/yarn-plugins/master/packages/changed/bundles/%40yarnpkg/plugin-changed.js"

preferInteractive: true

yarnPath: .yarn/releases/yarn-3.5.0.cjs
2 changes: 1 addition & 1 deletion docs/development/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ _Alright, here's a short introduction if you're new to this stuff. If you know t
`npm` and `yarn` are both package managers for `Node.js` projects. `npm` comes with `Node.js` by default, but especially new major releases are often buggy, so we've decided to use `yarn` instead.

> [!WARNING]
> When working with Linux, you might already have a `yarn` executable on your system, but that is [not the correct one](https://stackoverflow.com/a/45551189/10179833). To install the correct one, run `npm i -g yarn`, which installs `yarn` the package manager globally on your system. If you're on Windows, **DO NOT** install `yarn` with an installer, as this version can mess things up.
> When working with Linux, you might already have a `yarn` executable on your system, but that is [not the correct one](https://stackoverflow.com/a/45551189/10179833). To install the correct one, we rely on [corepack](https://github.com/nodejs/corepack), which automatically installs the correct version of `yarn` for you. If you're on Windows, **DO NOT** install `yarn` with an installer, as this version can mess things up.
`yarn` has a [bunch of commands](https://classic.yarnpkg.com/en/docs/usage) but you'll likely only need to use `yarn` (short for `yarn install`) to install all dependencies. **Don't** install missing dependencies one by one, **don't** install them globally.\
`yarn` can also run package scripts for you, which we use extensively, e.g. `yarn run build` to compile TypeScript into JavaScript. You'll find most of the scripts in `package.json` under `"scripts"`.
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
"@actions/exec": "^1.1.1",
"@actions/github": "^6.0.0",
"@alcalzone/jsonl-db": "^3.1.1",
"@alcalzone/monopack": "^1.2.2",
"@alcalzone/monopack": "^1.3.0",
"@alcalzone/release-script": "~3.7.0",
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@dprint/formatter": "^0.2.1",
"@dprint/json": "^0.19.2",
"@dprint/markdown": "^0.16.4",
"@dprint/typescript": "^0.90.0",
"@dprint/formatter": "^0.3.0",
"@dprint/json": "^0.19.3",
"@dprint/markdown": "^0.17.1",
"@dprint/typescript": "^0.91.1",
"@microsoft/api-extractor": "^7.43.0",
"@monorepo-utils/workspaces-to-typescript-project-references": "^2.10.4",
"@tsconfig/node18": "^18.2.4",
Expand All @@ -54,7 +54,7 @@
"@zwave-js/core": "workspace:*",
"@zwave-js/eslint-plugin": "workspace:*",
"@zwave-js/flash": "workspace:*",
"@zwave-js/fmt": "^1.0.0",
"@zwave-js/fmt": "^1.0.1",
"@zwave-js/host": "workspace:*",
"@zwave-js/maintenance": "workspace:*",
"@zwave-js/nvmedit": "workspace:*",
Expand All @@ -68,7 +68,7 @@
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"del-cli": "^5.1.0",
"dprint": "^0.45.0",
"dprint": "^0.46.3",
"esbuild": "0.20.2",
"esbuild-register": "^3.5.0",
"eslint": "^8.57.0",
Expand Down Expand Up @@ -131,7 +131,7 @@
"test:firmware": "yarn ts test/firmware-extraction.ts",
"nvmedit": "yarn ts packages/nvmedit/src/cli.ts",
"ls-changed": "yarn changed list --exclude \"@zwave-js/repo\" --git-range=$(git describe --abbrev=0) --json | cut -d'\"' -f4",
"for-changed": "yarn changed foreach --exclude \"@zwave-js/repo\" --git-range=$(git describe --abbrev=0)",
"for-changed": "yarn changed foreach --all --exclude \"@zwave-js/repo\" --git-range=$(git describe --abbrev=0)",
"codefind": "yarn ts packages/maintenance/src/codefind.ts",
"configfind": "yarn ts packages/config/maintenance/find.ts",
"extract-api": "FORCE_COLOR=1 yarn turbo run extract-api",
Expand All @@ -146,5 +146,5 @@
"path": "./node_modules/cz-conventional-changelog"
}
},
"packageManager": "yarn@3.5.0"
"packageManager": "yarn@4.3.0"
}
12 changes: 6 additions & 6 deletions packages/maintenance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@
"lint:ts:fix": "yarn run lint:ts --fix"
},
"devDependencies": {
"@dprint/formatter": "^0.2.1",
"@dprint/json": "^0.19.2",
"@dprint/markdown": "^0.16.4",
"@dprint/typescript": "^0.90.0",
"@dprint/formatter": "^0.3.0",
"@dprint/json": "^0.19.3",
"@dprint/markdown": "^0.17.1",
"@dprint/typescript": "^0.91.1",
"@types/fs-extra": "^11.0.4",
"@types/globrex": "^0.1.4",
"@types/node": "^18.19.31",
"@types/yargs": "^17.0.32",
"@zwave-js/core": "workspace:*",
"@zwave-js/fmt": "^1.0.0",
"@zwave-js/fmt": "^1.0.1",
"@zwave-js/shared": "workspace:*",
"ansi-colors": "^4.1.3",
"cli-highlight": "^2.1.11",
"del-cli": "^5.1.0",
"dprint": "^0.45.0",
"dprint": "^0.46.3",
"esbuild": "0.20.2",
"esbuild-register": "^3.5.0",
"execa": "^5.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/zwave-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
},
"dependencies": {
"@alcalzone/jsonl-db": "^3.1.1",
"@alcalzone/pak": "^0.10.1",
"@alcalzone/pak": "^0.11.0",
"@homebridge/ciao": "^1.2.0",
"@zwave-js/cc": "workspace:*",
"@zwave-js/config": "workspace:*",
Expand Down
Loading

0 comments on commit 406d5e9

Please sign in to comment.