Skip to content

Commit

Permalink
chore: support for Yarn 4
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Jun 20, 2024
1 parent 05b70db commit 66f217a
Show file tree
Hide file tree
Showing 4 changed files with 2,630 additions and 2,632 deletions.
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
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"
}
Loading

0 comments on commit 66f217a

Please sign in to comment.