@jujulego/jill 2.2.0-alpha.7 → 2.2.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/828.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";exports.id=828,exports.ids=[828],exports.modules={90236:(e,t,r)=>{r.d(t,{F:()=>f});var s=r(18703),n=r(69076),o=r(29724),i=r(62429),a=r(85099),c=r(95960),l=r(29921),h=function(e,t){return function(r,s){t(r,s,e)}};let f=class{constructor(e,t){this.manager=e,this.logger=t}command(e,t,r={}){const s={logger:this.logger,...r},o=new n.m("git",[e,...t],{command:e},s);return o.on("stream",(({data:e})=>s.logger.debug(e.toString("utf-8")))),this.manager.add(o),o}branch(e,t){return this.command("branch",e,t)}diff(e,t){return this.command("diff",e,t)}tag(e,t){return this.command("tag",e,t)}isAffected(e,t=[],r){return new Promise(((n,o)=>{const i=this.diff(["--quiet",e,"--",...t],r);(0,s.I)(i,"status.done",(()=>n(!1))),(0,s.I)(i,"status.failed",(()=>{i.exitCode?n(!0):o(new Error(`Task ${i.name} failed`))}))}))}async listBranches(e=[],t){const r=this.branch(["-l",...e],t),s=[];for await(const e of(0,c.F)(r,"stdout"))s.push(e.replace(/^[ *] /,""));return s}async listTags(e=[],t){const r=this.tag(["-l",...e],t),s=[];for await(const e of(0,c.F)(r,"stdout"))s.push(e);return s}};f=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}([(0,l.t)(),h(0,(0,o.f)(a.N)),h(1,(0,o.f)(i.Y))],f)},48652:(e,t,r)=>{r.d(t,{L:()=>a});var s=r(90236),n=r(10466),o=r(62429),i=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i};class a{constructor(e,t,r){this.format=e,this.fallback=t,this.sort=r}async _formatRevision(e){const t=this._logger.child({label:e.name});let r=this.format;r=r.replace(/(?<!\\)((?:\\\\)*)%name/g,`$1${e.name}`),r=r.replace(/\\(.)/g,"$1");const s=this.sort?["--sort",this.sort]:[];if(r.includes("*")){const n=await this._git.listBranches([...s,r],{cwd:e.cwd,logger:t});n.length>0&&(r=n[n.length-1])}if(r.includes("*")){const n=await this._git.listTags([...s,r],{cwd:e.cwd,logger:t});n.length>0&&(r=n[n.length-1])}return r!==this.format&&t.verbose`Resolved ${this.format} into ${r}`,r.includes("*")?(t.warn`No revision found matching ${r}, using fallback ${this.fallback}`,this.fallback):r}async test(e){const t=await this._formatRevision(e);return await e.isAffected(t)}}i([(0,n.yT)(o.Y)],a.prototype,"_logger",void 0),i([(0,n.yT)(s.F)],a.prototype,"_git",void 0)},72999:(e,t,r)=>{r.d(t,{B:()=>s});class s{_filters=[];add(e){this._filters.push(e)}async _test(e){for(const t of this._filters)if(!await t.test(e))return!1;return!0}async*filter(e){for await(const t of e)await this._test(t)&&(yield t)}}},40307:(e,t,r)=>{r.d(t,{N:()=>s});class s{constructor(e){this.value=e}test(e){return(e.manifest.private??!1)===this.value}}},84203:(e,t,r)=>{r.d(t,{f:()=>s});class s{constructor(e){this.scripts=e}test(e){const t=Object.keys(e.manifest.scripts||{});return this.scripts.some((e=>t.includes(e)))}}},8754:(e,t,r)=>{r.d(t,{_:()=>p,r:()=>d});var s=r(29724),n=r(96156),o=r(53565),i=r(9300),a=r(10466),c=r(81632),l=r(97672),h=r(29808),f=function(e,t){return function(r,s){t(r,s,e)}};let d=class{constructor(e,t,r){this.spinner=e,this.projects=t,this.context=r}builder(e){return e.option("project",{alias:"p",type:"string",description:"Project root directory"}).option("package-manager",{choices:["yarn","npm"],type:"string",description:"Force package manager"})}async handler(e){if(!this.context.project||e.project)try{this.spinner.spin("Loading project ..."),e.project=await this.projects.searchProjectRoot(e.project??process.cwd()),this.context.project=this.projects.getProject(e.project,{packageManager:e.packageManager})}finally{this.spinner.stop()}else e.project=this.context.project.root}};function p(){return(0,a.oV)(l.I,i.W)}d=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}([(0,c.d)(),f(0,(0,s.f)(o.V)),f(1,(0,s.f)(h.Z)),f(2,(0,s.f)(n.O))],d),a.nC.bind(l.I).toDynamicValue((({container:e})=>{const t=e.get(n.O).project;if(!t)throw new Error("Cannot inject current project, it not yet defined");return t})).whenTargetNamed(i.W)},72419:(e,t,r)=>{r.d(t,{I:()=>g,S:()=>u});var s=r(29724),n=r(96156),o=r(53565),i=r(9300),a=r(10466),c=r(81632),l=r(28410),h=r(16505),f=r(8754),d=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i},p=function(e,t){return function(r,s){t(r,s,e)}};let u=class{constructor(e,t){this.spinner=e,this.context=t}builder(e){return e.option("workspace",{alias:"w",type:"string",desc:"Workspace to use"})}async handler(e){try{this.spinner.spin(`Loading "${e.workspace||"."}" workspace ...`);let t=this.context.workspace??null;if(t&&!e.workspace||(t=await this.project.workspace(e.workspace)),!t)throw this.spinner.failed(`Workspace "${e.workspace||"."}" not found`),new h.T(1,"Workspace not found");this.context.workspace=t}finally{this.spinner.stop()}}};function g(){return(0,a.oV)(l.j,i.W)}d([(0,f._)()],u.prototype,"project",void 0),u=d([(0,c.d)(),p(0,(0,s.f)(o.V)),p(1,(0,s.f)(n.O))],u),a.nC.bind(l.j).toDynamicValue((({container:e})=>{const t=e.get(n.O).workspace;if(!t)throw new Error("Cannot inject current workspace, it not yet defined");return t})).whenTargetNamed(i.W)},75756:(e,t,r)=>{r.d(t,{S:()=>a,p:()=>i});var s=r(20328),n=r(66150),o=r(23617);class i extends s.n{constructor(e,t){super(((...e)=>{for(const t of this.commands)(0,o.JH)(t)(...e)})),this.name=e,this.commands=t,this.id=(0,n.id)()}}function a(e){return t=>{const r=e.name??t.name,s=new i(r,e.commands);(0,o.IY)(t,s)}}},29808:(e,t,r)=>{r.d(t,{Z:()=>d});var s=r(93977),n=r.n(s),o=r(49411),i=r.n(o),a=r(29724),c=r(62429),l=r(29921),h=r(97672);const f=["package-lock.json","yarn.lock"];let d=class{_cache=new Map;_roots=new Map;constructor(e){this._logger=e.child({label:"projects"})}async isProjectRoot(e){const t=await n().readdir(e);return{hasManifest:t.includes("package.json"),hasLockFile:f.some((e=>t.includes(e)))}}async searchProjectRoot(e){const t=[];let r=!1,s=e=i().resolve(e),n=e,o=n;do{const e=this._roots.get(n);if(e){s=e,r=!0;break}const{hasManifest:a,hasLockFile:c}=await this.isProjectRoot(n);if(t.push(n),a&&(s=n,r=!0),c)break;o=n,n=i().dirname(n)}while(o!==n);for(const e of t)e.startsWith(s)&&this._roots.set(e,s);return r?this._logger.debug`Project root found at #cwd:${s}`:this._logger.debug`Project root not found, keeping #cwd:${s}`,s}getProject(e,t){let r=this._cache.get(e);return r||(r=new h.I(e,this._logger,t),this._cache.set(e,r)),r}};var p,u;d=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}([(0,l.t)(),(p=0,u=(0,a.f)(c.Y),function(e,t){u(e,t,p)})],d)},97672:(e,t,r)=>{r.d(t,{I:()=>u});var s=r(90410),n=r(19694),o=r(93977),i=r.n(o),a=r(49411),c=r.n(a),l=r(74782),h=r.n(l),f=r(18799),d=r.n(f),p=r(28410);let u=class{constructor(e,t,r={}){this._root=e,this._logger=t,this._names=new Map,this._workspaces=new Map,this._isFullyLoaded=!1,this._lock=new s.H,r.packageManager&&(this._logger.debug`Forced use of ${r.packageManager} in #cwd:${this.root}`,this._packageManager=r.packageManager)}async _loadManifest(e){const t=c().resolve(this.root,e,"package.json"),r=c().relative(this.root,c().dirname(t)),s=this._logger.child({label:r?`project@${r}`:"project"});s.verbose("Loading package.json ...");const n=await i().readFile(t,"utf-8"),o=JSON.parse(n);return h()(o,(e=>s.verbose(e))),o}async _loadWorkspace(e){return await this._lock.with((async()=>{let t=this._workspaces.get(e);if(!t){const r=await this._loadManifest(e);t=new p.j(e,r,this),this._workspaces.set(e,t),this._names.set(t.name,t)}return t}))}async packageManager(){if(!this._packageManager){const e=await i().readdir(this.root);e.includes("yarn.lock")?(this._logger.debug`Detected yarn in #cwd:${this.root}`,this._packageManager="yarn"):e.includes("package-lock.json")?(this._logger.debug`Detected npm in #cwd:${this.root}`,this._packageManager="npm"):(this._logger.debug`No package manager recognized in #cwd:${this.root}, defaults to npm`,this._packageManager="npm")}return this._packageManager}async mainWorkspace(){if(!this._mainWorkspace){const e=await this._loadManifest(".");this._mainWorkspace=new p.j(".",e,this),this._names.set(this._mainWorkspace.name,this._mainWorkspace)}return this._mainWorkspace}async currentWorkspace(e=process.cwd()){let t=null;e=c().resolve(e);for await(const r of this.workspaces())if(e.startsWith(r.cwd)&&(t=r,r.cwd!==this.root))return r;return t}async*workspaces(){const e=await this.mainWorkspace();if(yield e,this._isFullyLoaded)for(const t of this._names.values())t.name!==e.name&&(yield t);else{const{workspaces:t=[]}=e.manifest;for(const e of t)for(const t of await d()(e,{cwd:this.root}))try{const e=c().resolve(this.root,t);(await i().stat(e)).isDirectory()&&(yield await this._loadWorkspace(t))}catch(e){if("ENOENT"===e.code)continue;throw e}this._isFullyLoaded=!0}}async workspace(e){if(!e){const e=c().relative(this.root,process.cwd());return this._loadWorkspace(e)}const t=this._names.get(e);if(t)return t;if(this._isFullyLoaded)return null;for await(const t of this.workspaces())if(t.name===e)return t;return this._isFullyLoaded=!0,null}get root(){return c().resolve(this._root)}};u=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}([(0,n.b)()],u)},28410:(e,t,r)=>{r.d(t,{j:()=>u});var s=r(19694),n=r(49411),o=r.n(n),i=r(67329),a=r(90236),c=r(10466),l=r(62429),h=r(24244),f=r(26839),d=r(95960),p=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i};let u=class{constructor(e,t,r){this._cwd=e,this.manifest=t,this.project=r,this._affectedCache=new Map,this._tasks=new Map;const s=c.nC.get(l.Y);this._logger=s.child({label:this.manifest.name})}_satisfies(e,t){return t.startsWith("file:")?o().resolve(e.cwd,t.substring(5))===this.cwd:(t.startsWith("workspace:")&&(t=t.substring(10)),!this.version||(0,i.satisfies)(this.version,t))}async _buildDependencies(e,t="all"){const r=[];switch(t){case"all":r.unshift(this.devDependencies());case"prod":r.unshift(this.dependencies())}for await(const t of(0,d.$)(...r)){const r=await t.build();r&&e.dependsOn(r)}}async _isAffected(e){if(await this._git.isAffected(e,[this.cwd],{cwd:this.project.root,logger:this._logger}))return!0;const t=[];for await(const r of(0,d.$)(this.dependencies(),this.devDependencies()))t.push(r.isAffected(e));return(await Promise.all(t)).some((e=>e))}async isAffected(e){let t=this._affectedCache.get(e);return t||(t=this._isAffected(e),this._affectedCache.set(e,t)),await t}async*_loadDependencies(e,t){for(const[r,s]of Object.entries(e)){const e=await this.project.workspace(r);e&&(e._satisfies(this,s)?yield e:this._logger.verbose`Ignoring ${t} ${e.reference} as it does not match requirement ${s}`)}}async*dependencies(){if(this.manifest.dependencies)for await(const e of this._loadDependencies(this.manifest.dependencies,"dependency"))yield e}async*devDependencies(){if(this.manifest.devDependencies)for await(const e of this._loadDependencies(this.manifest.devDependencies,"devDependency"))yield e}async exec(e,t=[],r={}){const s=await this.project.packageManager(),n=new h.F(this,e,t,{...r,logger:this._logger.child({label:`${this.name}$${e}`}),superCommand:"yarn"===s?"yarn":void 0});return await this._buildDependencies(n,r.buildDeps),n}async run(e,t=[],r={}){if(!this.getScript(e))return null;let s=this._tasks.get(e);return s||(s=new f.s(this,e,t,{...r,logger:this._logger.child({label:`${this.name}#${e}`})}),await s.prepare(),await this._buildDependencies(s,r.buildDeps),this._tasks.set(e,s)),s}async build(e){const t=await this.run("build",[],e);return t||this._logger.warn("Will not be built (no build script)"),t}getScript(e){const{scripts:t={}}=this.manifest;return t[e]||null}toJSON(){return{name:this.name,version:this.version,cwd:this.cwd}}get name(){return this.manifest.name}get version(){return this.manifest.version}get reference(){return this.version?`${this.name}@${this.version}`:this.name}get cwd(){return o().resolve(this.project.root,this._cwd)}};p([(0,c.yT)(a.F)],u.prototype,"_git",void 0),u=p([(0,s.b)()],u)},3678:(e,t,r)=>{r.d(t,{P:()=>h});var s=r(88220),n=r(727),o=r(73480),i=r.n(o),a=r(62429),c=r(29724),l=r(29921);let h=class{static isTaskNode(e){return"script"in e}constructor(e){this._logger=e}_lexer(){return i().states({task:{lparen:"(",whitespace:/[ \t]+/,string:[{match:/[:a-zA-Z0-9]+/,push:"operator"},{match:/'(?:\\['\\]|[^\n'\\])+'/,push:"operator",value:e=>e.slice(1,-1).replace(/\\(['\\])/g,"$1")},{match:/"(?:\\["\\]|[^\n"\\])+"/,push:"operator",value:e=>e.slice(1,-1).replace(/\\(["\\])/g,"$1")}]},operator:{whitespace:/[ \t]+/,rparen:")",operator:{match:["->","//"],pop:1}}})}_nextNode(e,t=0){let r=null;for(const s of e){if("whitespace"===s.type)continue;if("rparen"===s.type)break;if("operator"===s.type){const t=s.value;if(r){if(h.isTaskNode(r)){r={operator:t,tasks:[r]};continue}r.operator!==t&&(r={operator:t,tasks:[r]});continue}throw new Error(e.formatError(s,"Unexpected operator"))}let n;if("string"===s.type)n={script:s.value};else{if("lparen"!==s.type)throw new Error(e.formatError(s,"Unexpected token"));{const r=this._nextNode(e,t+1);if(!r)throw new Error(e.formatError(s,"Empty group found"));n=r}}if(r){if(h.isTaskNode(r))throw new Error(e.formatError(s,"Unexpected token, expected an operator"));r.tasks.push(n)}else r=n}return r}parse(e){const t=this._lexer().reset(e),r={roots:[]};for(;;){const e=this._nextNode(t);if(!e)break;r.roots.push(e)}return r}async buildTask(e,t,r){if(h.isTaskNode(e)){const s=await t.run(e.script,[],r);if(!s)throw new Error(`Workspace ${t.name} have no ${e.script} script`);return s}{let o;o="//"===e.operator?new s.W("In parallel",{},{logger:this._logger}):new n.h("In sequence",{},{logger:this._logger});for(const s of e.tasks)o.add(await this.buildTask(s,t,r));return o}}};var f,d;h=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}([(0,l.t)(),(f=0,d=(0,c.f)(a.Y),function(e,t){d(e,t,f)})],h)},66238:(e,t,r)=>{r.d(t,{Z:()=>a});var s=r(52010),n=r(81119),o=r(76687);const i=e=>({color:e?"blue":""});function a(e){const{workspace:t,dev:r=!1,level:c=""}=e,[l,h]=(0,o.useState)([]);return(0,o.useEffect)((()=>{(async()=>{const e=[];for await(const r of t.dependencies())e.push([r,null]);for await(const r of t.devDependencies())e.push([r,!0]);h(e)})()}),[t]),(0,s.jsxs)(n.Text,{children:[(0,s.jsx)(n.Text,{...i(r),children:t.name}),t.version&&(0,s.jsxs)(n.Text,{color:"grey",children:["@",t.version]}),l.length>0&&(0,s.jsx)(n.Newline,{}),l.map((([e,t],o)=>(0,s.jsxs)(n.Text,{children:[c,(0,s.jsxs)(n.Text,{...i(r),children:[o===l.length-1?"└":"├","─"," "]}),(0,s.jsx)(a,{workspace:e,dev:t??r,level:(0,s.jsxs)(s.Fragment,{children:[c,(0,s.jsxs)(n.Text,{...i(r),children:[o===l.length-1?" ":"│"," "]})]})}),o<l.length-1&&(0,s.jsx)(n.Newline,{})]},e.name)))]})}},95960:(e,t,r)=>{r.d(t,{$:()=>o,F:()=>i});var s=r(18703),n=r(62506);async function*o(...e){for(const t of e)yield*t}async function*i(e,t){const r=new AbortController,o=new Error("aborted");(0,s.I)(e,"completed",(()=>r.abort(o)));let i="";try{for await(const s of(0,n.U)(e,`stream.${t}`,{signal:r.signal})){const e=(i+s.data.toString("utf-8")).split(/\r?\n/);i=e.pop()??"";for(const t of e)yield t}}catch(e){if(e!==o)throw e;i&&(yield i)}}}};
1
+ "use strict";exports.id=828,exports.ids=[828],exports.modules={90236:(e,t,r)=>{r.d(t,{F:()=>f});var s=r(18703),n=r(69076),o=r(29724),i=r(62429),a=r(85099),c=r(95960),l=r(29921),h=function(e,t){return function(r,s){t(r,s,e)}};let f=class{constructor(e,t){this.manager=e,this.logger=t}command(e,t,r={}){const s={logger:this.logger,...r},o=new n.m("git",[e,...t],{command:e},s);return o.on("stream",(({data:e})=>s.logger.debug(e.toString("utf-8")))),this.manager.add(o),o}branch(e,t){return this.command("branch",e,t)}diff(e,t){return this.command("diff",e,t)}tag(e,t){return this.command("tag",e,t)}isAffected(e,t=[],r){return new Promise(((n,o)=>{const i=this.diff(["--quiet",e,"--",...t],r);(0,s.I)(i,"status.done",(()=>n(!1))),(0,s.I)(i,"status.failed",(()=>{i.exitCode?n(!0):o(new Error(`Task ${i.name} failed`))}))}))}async listBranches(e=[],t){const r=this.branch(["-l",...e],t),s=[];for await(const e of(0,c.F)(r,"stdout"))s.push(e.replace(/^[ *] /,""));return s}async listTags(e=[],t){const r=this.tag(["-l",...e],t),s=[];for await(const e of(0,c.F)(r,"stdout"))s.push(e);return s}};f=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}([(0,l.t)(),h(0,(0,o.f)(a.N)),h(1,(0,o.f)(i.Y))],f)},48652:(e,t,r)=>{r.d(t,{L:()=>a});var s=r(90236),n=r(10466),o=r(62429),i=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i};class a{constructor(e,t,r){this.format=e,this.fallback=t,this.sort=r}async _formatRevision(e){const t=this._logger.child({label:e.name});let r=this.format;r=r.replace(/(?<!\\)((?:\\\\)*)%name/g,`$1${e.name}`),r=r.replace(/\\(.)/g,"$1");const s=this.sort?["--sort",this.sort]:[];if(r.includes("*")){const n=await this._git.listBranches([...s,r],{cwd:e.cwd,logger:t});n.length>0&&(r=n[n.length-1])}if(r.includes("*")){const n=await this._git.listTags([...s,r],{cwd:e.cwd,logger:t});n.length>0&&(r=n[n.length-1])}return r!==this.format&&t.verbose`Resolved ${this.format} into ${r}`,r.includes("*")?(t.warn`No revision found matching ${r}, using fallback ${this.fallback}`,this.fallback):r}async test(e){const t=await this._formatRevision(e);return await e.isAffected(t)}}i([(0,n.yT)(o.Y)],a.prototype,"_logger",void 0),i([(0,n.yT)(s.F)],a.prototype,"_git",void 0)},72999:(e,t,r)=>{r.d(t,{B:()=>s});class s{_filters=[];add(e){this._filters.push(e)}async _test(e){for(const t of this._filters)if(!await t.test(e))return!1;return!0}async*filter(e){for await(const t of e)await this._test(t)&&(yield t)}}},40307:(e,t,r)=>{r.d(t,{N:()=>s});class s{constructor(e){this.value=e}test(e){return(e.manifest.private??!1)===this.value}}},84203:(e,t,r)=>{r.d(t,{f:()=>s});class s{constructor(e){this.scripts=e}test(e){const t=Object.keys(e.manifest.scripts||{});return this.scripts.some((e=>t.includes(e)))}}},8754:(e,t,r)=>{r.d(t,{_:()=>p,r:()=>d});var s=r(29724),n=r(96156),o=r(53565),i=r(9300),a=r(10466),c=r(81632),l=r(97672),h=r(29808),f=function(e,t){return function(r,s){t(r,s,e)}};let d=class{constructor(e,t,r){this.spinner=e,this.projects=t,this.context=r}builder(e){return e.option("project",{alias:"p",type:"string",description:"Project root directory"}).option("package-manager",{choices:["yarn","npm"],type:"string",description:"Force package manager"})}async handler(e){if(!this.context.project||e.project)try{this.spinner.spin("Loading project ..."),e.project=await this.projects.searchProjectRoot(e.project??process.cwd()),this.context.project=this.projects.getProject(e.project,{packageManager:e.packageManager})}finally{this.spinner.stop()}else e.project=this.context.project.root}};function p(){return(0,a.oV)(l.I,i.W)}d=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}([(0,c.d)(),f(0,(0,s.f)(o.V)),f(1,(0,s.f)(h.Z)),f(2,(0,s.f)(n.O))],d),a.nC.bind(l.I).toDynamicValue((({container:e})=>{const t=e.get(n.O).project;if(!t)throw new Error("Cannot inject current project, it not yet defined");return t})).whenTargetNamed(i.W)},72419:(e,t,r)=>{r.d(t,{I:()=>g,S:()=>u});var s=r(29724),n=r(96156),o=r(53565),i=r(9300),a=r(10466),c=r(81632),l=r(28410),h=r(16505),f=r(8754),d=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i},p=function(e,t){return function(r,s){t(r,s,e)}};let u=class{constructor(e,t){this.spinner=e,this.context=t}builder(e){return e.option("workspace",{alias:"w",type:"string",desc:"Workspace to use"})}async handler(e){try{this.spinner.spin(`Loading "${e.workspace||"."}" workspace ...`);let t=this.context.workspace??null;if(t&&!e.workspace||(t=await this.project.workspace(e.workspace)),!t)throw this.spinner.failed(`Workspace "${e.workspace||"."}" not found`),new h.T(1,"Workspace not found");this.context.workspace=t}finally{this.spinner.stop()}}};function g(){return(0,a.oV)(l.j,i.W)}d([(0,f._)()],u.prototype,"project",void 0),u=d([(0,c.d)(),p(0,(0,s.f)(o.V)),p(1,(0,s.f)(n.O))],u),a.nC.bind(l.j).toDynamicValue((({container:e})=>{const t=e.get(n.O).workspace;if(!t)throw new Error("Cannot inject current workspace, it not yet defined");return t})).whenTargetNamed(i.W)},75756:(e,t,r)=>{r.d(t,{S:()=>a,p:()=>i});var s=r(20328),n=r(66150),o=r(23617);class i extends s.n{constructor(e,t){super(((...e)=>{for(const t of this.commands)(0,o.JH)(t)(...e)})),this.name=e,this.commands=t,this.id=(0,n.id)()}}function a(e){return t=>{const r=e.name??t.name,s=new i(r,e.commands);(0,o.IY)(t,s)}}},29808:(e,t,r)=>{r.d(t,{Z:()=>d});var s=r(93977),n=r.n(s),o=r(49411),i=r.n(o),a=r(29724),c=r(62429),l=r(29921),h=r(97672);const f=["package-lock.json","yarn.lock"];let d=class{_cache=new Map;_roots=new Map;constructor(e){this._logger=e.child({label:"projects"})}async isProjectRoot(e){const t=await n().readdir(e);return{hasManifest:t.includes("package.json"),hasLockFile:f.some((e=>t.includes(e)))}}async searchProjectRoot(e){const t=[];let r=!1,s=e=i().resolve(e),n=e,o=n;do{const e=this._roots.get(n);if(e){s=e,r=!0;break}const{hasManifest:a,hasLockFile:c}=await this.isProjectRoot(n);if(t.push(n),a&&(s=n,r=!0),c)break;o=n,n=i().dirname(n)}while(o!==n);for(const e of t)e.startsWith(s)&&this._roots.set(e,s);return r?this._logger.debug`Project root found at #cwd:${s}`:this._logger.debug`Project root not found, keeping #cwd:${s}`,s}getProject(e,t){let r=this._cache.get(e);return r||(r=new h.I(e,this._logger,t),this._cache.set(e,r)),r}};var p,u;d=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}([(0,l.t)(),(p=0,u=(0,a.f)(c.Y),function(e,t){u(e,t,p)})],d)},97672:(e,t,r)=>{r.d(t,{I:()=>u});var s=r(22432),n=r(19694),o=r(93977),i=r.n(o),a=r(49411),c=r.n(a),l=r(74782),h=r.n(l),f=r(18799),d=r.n(f),p=r(28410);let u=class{constructor(e,t,r={}){this._root=e,this._logger=t,this._names=new Map,this._workspaces=new Map,this._isFullyLoaded=!1,this._lock=new s.H,r.packageManager&&(this._logger.debug`Forced use of ${r.packageManager} in #cwd:${this.root}`,this._packageManager=r.packageManager)}async _loadManifest(e){const t=c().resolve(this.root,e,"package.json"),r=c().relative(this.root,c().dirname(t)),s=this._logger.child({label:r?`project@${r}`:"project"});s.verbose("Loading package.json ...");const n=await i().readFile(t,"utf-8"),o=JSON.parse(n);return h()(o,(e=>s.verbose(e))),o}async _loadWorkspace(e){return await this._lock.with((async()=>{let t=this._workspaces.get(e);if(!t){const r=await this._loadManifest(e);t=new p.j(e,r,this),this._workspaces.set(e,t),this._names.set(t.name,t)}return t}))}async packageManager(){if(!this._packageManager){const e=await i().readdir(this.root);e.includes("yarn.lock")?(this._logger.debug`Detected yarn in #cwd:${this.root}`,this._packageManager="yarn"):e.includes("package-lock.json")?(this._logger.debug`Detected npm in #cwd:${this.root}`,this._packageManager="npm"):(this._logger.debug`No package manager recognized in #cwd:${this.root}, defaults to npm`,this._packageManager="npm")}return this._packageManager}async mainWorkspace(){if(!this._mainWorkspace){const e=await this._loadManifest(".");this._mainWorkspace=new p.j(".",e,this),this._names.set(this._mainWorkspace.name,this._mainWorkspace)}return this._mainWorkspace}async currentWorkspace(e=process.cwd()){let t=null;e=c().resolve(e);for await(const r of this.workspaces())if(e.startsWith(r.cwd)&&(t=r,r.cwd!==this.root))return r;return t}async*workspaces(){const e=await this.mainWorkspace();if(yield e,this._isFullyLoaded)for(const t of this._names.values())t.name!==e.name&&(yield t);else{const{workspaces:t=[]}=e.manifest;for(const e of t)for(const t of await d()(e,{cwd:this.root}))try{const e=c().resolve(this.root,t);(await i().stat(e)).isDirectory()&&(yield await this._loadWorkspace(t))}catch(e){if("ENOENT"===e.code)continue;throw e}this._isFullyLoaded=!0}}async workspace(e){if(!e){const e=c().relative(this.root,process.cwd());return this._loadWorkspace(e)}const t=this._names.get(e);if(t)return t;if(this._isFullyLoaded)return null;for await(const t of this.workspaces())if(t.name===e)return t;return this._isFullyLoaded=!0,null}get root(){return c().resolve(this._root)}};u=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}([(0,n.b)()],u)},28410:(e,t,r)=>{r.d(t,{j:()=>u});var s=r(19694),n=r(49411),o=r.n(n),i=r(67329),a=r(90236),c=r(10466),l=r(62429),h=r(24244),f=r(26839),d=r(95960),p=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i};let u=class{constructor(e,t,r){this._cwd=e,this.manifest=t,this.project=r,this._affectedCache=new Map,this._tasks=new Map;const s=c.nC.get(l.Y);this._logger=s.child({label:this.manifest.name})}_satisfies(e,t){return t.startsWith("file:")?o().resolve(e.cwd,t.substring(5))===this.cwd:(t.startsWith("workspace:")&&(t=t.substring(10)),!this.version||(0,i.satisfies)(this.version,t))}async _buildDependencies(e,t="all"){const r=[];switch(t){case"all":r.unshift(this.devDependencies());case"prod":r.unshift(this.dependencies())}for await(const t of(0,d.$)(...r)){const r=await t.build();r&&e.dependsOn(r)}}async _isAffected(e){if(await this._git.isAffected(e,[this.cwd],{cwd:this.project.root,logger:this._logger}))return!0;const t=[];for await(const r of(0,d.$)(this.dependencies(),this.devDependencies()))t.push(r.isAffected(e));return(await Promise.all(t)).some((e=>e))}async isAffected(e){let t=this._affectedCache.get(e);return t||(t=this._isAffected(e),this._affectedCache.set(e,t)),await t}async*_loadDependencies(e,t){for(const[r,s]of Object.entries(e)){const e=await this.project.workspace(r);e&&(e._satisfies(this,s)?yield e:this._logger.verbose`Ignoring ${t} ${e.reference} as it does not match requirement ${s}`)}}async*dependencies(){if(this.manifest.dependencies)for await(const e of this._loadDependencies(this.manifest.dependencies,"dependency"))yield e}async*devDependencies(){if(this.manifest.devDependencies)for await(const e of this._loadDependencies(this.manifest.devDependencies,"devDependency"))yield e}async exec(e,t=[],r={}){const s=await this.project.packageManager(),n=new h.F(this,e,t,{...r,logger:this._logger.child({label:`${this.name}$${e}`}),superCommand:"yarn"===s?"yarn":void 0});return await this._buildDependencies(n,r.buildDeps),n}async run(e,t=[],r={}){if(!this.getScript(e))return null;let s=this._tasks.get(e);return s||(s=new f.s(this,e,t,{...r,logger:this._logger.child({label:`${this.name}#${e}`})}),await s.prepare(),await this._buildDependencies(s,r.buildDeps),this._tasks.set(e,s)),s}async build(e){const t=await this.run("build",[],e);return t||this._logger.warn("Will not be built (no build script)"),t}getScript(e){const{scripts:t={}}=this.manifest;return t[e]||null}toJSON(){return{name:this.name,version:this.version,cwd:this.cwd}}get name(){return this.manifest.name}get version(){return this.manifest.version}get reference(){return this.version?`${this.name}@${this.version}`:this.name}get cwd(){return o().resolve(this.project.root,this._cwd)}};p([(0,c.yT)(a.F)],u.prototype,"_git",void 0),u=p([(0,s.b)()],u)},3678:(e,t,r)=>{r.d(t,{P:()=>h});var s=r(88220),n=r(727),o=r(73480),i=r.n(o),a=r(62429),c=r(29724),l=r(29921);let h=class{static isTaskNode(e){return"script"in e}constructor(e){this._logger=e}_lexer(){return i().states({task:{lparen:"(",whitespace:/[ \t]+/,string:[{match:/[:a-zA-Z0-9]+/,push:"operator"},{match:/'(?:\\['\\]|[^\n'\\])+'/,push:"operator",value:e=>e.slice(1,-1).replace(/\\(['\\])/g,"$1")},{match:/"(?:\\["\\]|[^\n"\\])+"/,push:"operator",value:e=>e.slice(1,-1).replace(/\\(["\\])/g,"$1")}]},operator:{whitespace:/[ \t]+/,rparen:")",operator:{match:["->","//"],pop:1}}})}_nextNode(e,t=0){let r=null;for(const s of e){if("whitespace"===s.type)continue;if("rparen"===s.type)break;if("operator"===s.type){const t=s.value;if(r){if(h.isTaskNode(r)){r={operator:t,tasks:[r]};continue}r.operator!==t&&(r={operator:t,tasks:[r]});continue}throw new Error(e.formatError(s,"Unexpected operator"))}let n;if("string"===s.type)n={script:s.value};else{if("lparen"!==s.type)throw new Error(e.formatError(s,"Unexpected token"));{const r=this._nextNode(e,t+1);if(!r)throw new Error(e.formatError(s,"Empty group found"));n=r}}if(r){if(h.isTaskNode(r))throw new Error(e.formatError(s,"Unexpected token, expected an operator"));r.tasks.push(n)}else r=n}return r}parse(e){const t=this._lexer().reset(e),r={roots:[]};for(;;){const e=this._nextNode(t);if(!e)break;r.roots.push(e)}return r}async buildTask(e,t,r){if(h.isTaskNode(e)){const s=await t.run(e.script,[],r);if(!s)throw new Error(`Workspace ${t.name} have no ${e.script} script`);return s}{let o;o="//"===e.operator?new s.W("In parallel",{},{logger:this._logger}):new n.h("In sequence",{},{logger:this._logger});for(const s of e.tasks)o.add(await this.buildTask(s,t,r));return o}}};var f,d;h=function(e,t,r,s){var n,o=arguments.length,i=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}([(0,l.t)(),(f=0,d=(0,c.f)(a.Y),function(e,t){d(e,t,f)})],h)},66238:(e,t,r)=>{r.d(t,{Z:()=>a});var s=r(52010),n=r(81119),o=r(76687);const i=e=>({color:e?"blue":""});function a(e){const{workspace:t,dev:r=!1,level:c=""}=e,[l,h]=(0,o.useState)([]);return(0,o.useEffect)((()=>{(async()=>{const e=[];for await(const r of t.dependencies())e.push([r,null]);for await(const r of t.devDependencies())e.push([r,!0]);h(e)})()}),[t]),(0,s.jsxs)(n.Text,{children:[(0,s.jsx)(n.Text,{...i(r),children:t.name}),t.version&&(0,s.jsxs)(n.Text,{color:"grey",children:["@",t.version]}),l.length>0&&(0,s.jsx)(n.Newline,{}),l.map((([e,t],o)=>(0,s.jsxs)(n.Text,{children:[c,(0,s.jsxs)(n.Text,{...i(r),children:[o===l.length-1?"└":"├","─"," "]}),(0,s.jsx)(a,{workspace:e,dev:t??r,level:(0,s.jsxs)(s.Fragment,{children:[c,(0,s.jsxs)(n.Text,{...i(r),children:[o===l.length-1?" ":"│"," "]})]})}),o<l.length-1&&(0,s.jsx)(n.Newline,{})]},e.name)))]})}},95960:(e,t,r)=>{r.d(t,{$:()=>o,F:()=>i});var s=r(18703),n=r(62506);async function*o(...e){for(const t of e)yield*t}async function*i(e,t){const r=new AbortController,o=new Error("aborted");(0,s.I)(e,"completed",(()=>r.abort(o)));let i="";try{for await(const s of(0,n.U)(e,`stream.${t}`,{signal:r.signal})){const e=(i+s.data.toString("utf-8")).split(/\r?\n/);i=e.pop()??"";for(const t of e)yield t}}catch(e){if(e!==o)throw e;i&&(yield i)}}}};
2
2
  //# sourceMappingURL=828.js.map