@qlover/fe-release 2.0.4 → 2.0.5
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/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
"use strict";var e=require("commander"),r=require("semver"),o=require("./index.cjs");require("@qlover/scripts-context"),require("@qlover/env-loader"),require("@qlover/fe-corekit"),require("@octokit/rest"),require("node:path"),require("fs"),require("path"),require("node:module"),require("node:url"),require("p-limit"),require("conventional-changelog");const t=["patch","minor","major"],n=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:i,...a}=function(){const i=new e.Command;return i.version("2.0.
|
|
2
|
+
"use strict";var e=require("commander"),r=require("semver"),o=require("./index.cjs");require("@qlover/scripts-context"),require("@qlover/env-loader"),require("@qlover/fe-corekit"),require("@octokit/rest"),require("node:path"),require("fs"),require("path"),require("node:module"),require("node:url"),require("p-limit"),require("conventional-changelog");const t=["patch","minor","major"],n=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:i,...a}=function(){const i=new e.Command;return i.version("2.0.5","-v, --version","Show version").description("A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.").option("-d, --dry-run","Do not touch or write anything, but show the commands").option("-V, --verbose","Show more information").option("-p, --publish-path <publishPath>","The path of the package to release, map to feConfig.release.publishPath").option("-b, --branch-name <branchName>","The branch name of the release, map to feConfig.release.branchName, default(release-${pkgName}-${tagName})").option("-s, --source-branch <sourceBranch>","The source branch of the release").option("-i, --changelog.increment <increment>","The increment of the release",(e=>{if(!t.includes(e)&&!r.valid(e))throw new Error(`Invalid increment(-i) Must be one of [${t.join(", ")}] or valid version string(semver)`);return e}),"patch").option("--changelog.skip","Whether to skip the changelog").option("--changelog.skip-changeset","Whether to skip the changeset").option("--githubPR.skip","Whether to skip the githubPR").option("--packages-directories <packagesDirectories>","The packages that have been changed, multiple values use `,` to split, map to feConfig.release.packagesDirectories",n).option("--githubPR.dry-run-create-PR","Whether to dry run the creation of the pull request").option("-P, --githubPR.release-PR","Create a release PR").option("-l, --workspaces.change-labels <changeLabels>","The change labels of the release, multiple values use `,` to split",n),i.parse(),o.reduceOptions(i.opts(),"shared")}(),{dryRun:s,verbose:h,...c}=i,l=Object.assign(a,{});await new o.ReleaseTask({dryRun:s,verbose:h,options:l,shared:c}).exec()})().catch((e=>{console.error(e.message),process.exit(1)}));
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
import{Command as e}from"commander";import o from"semver";import{ReleaseTask as t,reduceOptions as r}from"./index.js";import"@qlover/scripts-context";import"@qlover/env-loader";import"@qlover/fe-corekit";import"@octokit/rest";import"node:path";import"fs";import"path";import"node:module";import"node:url";import"p-limit";import"conventional-changelog";const n=["patch","minor","major"],i=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:a,...s}=function(){const t=new e;return t.version("2.0.
|
|
2
|
+
import{Command as e}from"commander";import o from"semver";import{ReleaseTask as t,reduceOptions as r}from"./index.js";import"@qlover/scripts-context";import"@qlover/env-loader";import"@qlover/fe-corekit";import"@octokit/rest";import"node:path";import"fs";import"path";import"node:module";import"node:url";import"p-limit";import"conventional-changelog";const n=["patch","minor","major"],i=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:a,...s}=function(){const t=new e;return t.version("2.0.5","-v, --version","Show version").description("A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.").option("-d, --dry-run","Do not touch or write anything, but show the commands").option("-V, --verbose","Show more information").option("-p, --publish-path <publishPath>","The path of the package to release, map to feConfig.release.publishPath").option("-b, --branch-name <branchName>","The branch name of the release, map to feConfig.release.branchName, default(release-${pkgName}-${tagName})").option("-s, --source-branch <sourceBranch>","The source branch of the release").option("-i, --changelog.increment <increment>","The increment of the release",(e=>{if(!n.includes(e)&&!o.valid(e))throw new Error(`Invalid increment(-i) Must be one of [${n.join(", ")}] or valid version string(semver)`);return e}),"patch").option("--changelog.skip","Whether to skip the changelog").option("--changelog.skip-changeset","Whether to skip the changeset").option("--githubPR.skip","Whether to skip the githubPR").option("--packages-directories <packagesDirectories>","The packages that have been changed, multiple values use `,` to split, map to feConfig.release.packagesDirectories",i).option("--githubPR.dry-run-create-PR","Whether to dry run the creation of the pull request").option("-P, --githubPR.release-PR","Create a release PR").option("-l, --workspaces.change-labels <changeLabels>","The change labels of the release, multiple values use `,` to split",i),t.parse(),r(t.opts(),"shared")}(),{dryRun:p,verbose:h,...c}=a,l=Object.assign(s,{});await new t({dryRun:p,verbose:h,options:l,shared:c}).exec()})().catch((e=>{console.error(e.message),process.exit(1)}));
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t,r,n,o,i,s,a,u,c,h,l,f,g,p,d,v,m,y,b,w,x,R,_,k,P,C,$,j,N,E,B,O,T,S,A,L,U,F,W,G,M,q,I,z,D,H,V,J,K,Y,Q,X,Z,ee,te,re,ne,oe,ie,se,ae,ue,ce,he,le,fe,ge,pe,de,ve,me,ye,be,we,xe,Re,_e,ke,Pe,Ce,$e,je,Ne,Ee,Be,Oe,Te,Se,Ae,Le,Ue,Fe,We,Ge,Me,qe,Ie,ze=require("@qlover/scripts-context"),De=require("@qlover/env-loader"),He=require("@qlover/fe-corekit"),Ve=require("@octokit/rest"),Je=require("node:path"),Ke=require("fs"),Ye=require("path"),Qe=require("node:module"),Xe=require("node:url"),Ze=require("p-limit"),et=require("conventional-changelog"),tt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function rt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function nt(){if(t)return e;return t=1,e=function(){this.__data__=[],this.size=0}}function ot(){if(n)return r;return n=1,r=function(e,t){return e===t||e!=e&&t!=t}}function it(){if(i)return o;i=1;var e=ot();return o=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function st(){if(a)return s;a=1;var e=it(),t=Array.prototype.splice;return s=function(r){var n=this.__data__,o=e(n,r);return!(o<0)&&(o==n.length-1?n.pop():t.call(n,o,1),--this.size,!0)}}function at(){if(c)return u;c=1;var e=it();return u=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}function ut(){if(l)return h;l=1;var e=it();return h=function(t){return e(this.__data__,t)>-1}}function ct(){if(g)return f;g=1;var e=it();return f=function(t,r){var n=this.__data__,o=e(n,t);return o<0?(++this.size,n.push([t,r])):n[o][1]=r,this}}function ht(){if(d)return p;d=1;var e=nt(),t=st(),r=at(),n=ut(),o=ct();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,p=i}function lt(){if(m)return v;m=1;var e=ht();return v=function(){this.__data__=new e,this.size=0}}function ft(){if(b)return y;return b=1,y=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}}function gt(){if(x)return w;return x=1,w=function(e){return this.__data__.get(e)}}function pt(){if(_)return R;return _=1,R=function(e){return this.__data__.has(e)}}function dt(){if(P)return k;P=1;var e="object"==typeof tt&&tt&&tt.Object===Object&&tt;return k=e}function vt(){if($)return C;$=1;var e=dt(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return C=r}function mt(){if(N)return j;N=1;var e=vt().Symbol;return j=e}function yt(){if(B)return E;B=1;var e=mt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,o=e?e.toStringTag:void 0;return E=function(e){var t=r.call(e,o),i=e[o];try{e[o]=void 0;var s=!0}catch(e){}var a=n.call(e);return s&&(t?e[o]=i:delete e[o]),a}}function bt(){if(T)return O;T=1;var e=Object.prototype.toString;return O=function(t){return e.call(t)}}function wt(){if(A)return S;A=1;var e=mt(),t=yt(),r=bt(),n=e?e.toStringTag:void 0;return S=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):r(e)}}function xt(){if(U)return L;return U=1,L=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function Rt(){if(W)return F;W=1;var e=wt(),t=xt();return F=function(r){if(!t(r))return!1;var n=e(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function _t(){if(M)return G;M=1;var e=vt()["__core-js_shared__"];return G=e}function kt(){if(I)return q;I=1;var e,t=_t(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return q=function(e){return!!r&&r in e}}function Pt(){if(D)return z;D=1;var e=Function.prototype.toString;return z=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}function Ct(){if(V)return H;V=1;var e=Rt(),t=kt(),r=xt(),n=Pt(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,s=Object.prototype,a=i.toString,u=s.hasOwnProperty,c=RegExp("^"+a.call(u).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return H=function(i){return!(!r(i)||t(i))&&(e(i)?c:o).test(n(i))}}function $t(){if(K)return J;return K=1,J=function(e,t){return null==e?void 0:e[t]}}function jt(){if(Q)return Y;Q=1;var e=Ct(),t=$t();return Y=function(r,n){var o=t(r,n);return e(o)?o:void 0}}function Nt(){if(Z)return X;Z=1;var e=jt()(vt(),"Map");return X=e}function Et(){if(te)return ee;te=1;var e=jt()(Object,"create");return ee=e}function Bt(){if(ne)return re;ne=1;var e=Et();return re=function(){this.__data__=e?e(null):{},this.size=0}}function Ot(){if(ie)return oe;return ie=1,oe=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}}function Tt(){if(ae)return se;ae=1;var e=Et(),t=Object.prototype.hasOwnProperty;return se=function(r){var n=this.__data__;if(e){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return t.call(n,r)?n[r]:void 0}}function St(){if(ce)return ue;ce=1;var e=Et(),t=Object.prototype.hasOwnProperty;return ue=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}function At(){if(le)return he;le=1;var e=Et();return he=function(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===r?"__lodash_hash_undefined__":r,this}}function Lt(){if(ge)return fe;ge=1;var e=Bt(),t=Ot(),r=Tt(),n=St(),o=At();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,fe=i}function Ut(){if(de)return pe;de=1;var e=Lt(),t=ht(),r=Nt();return pe=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}function Ft(){if(me)return ve;return me=1,ve=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}}function Wt(){if(be)return ye;be=1;var e=Ft();return ye=function(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Gt(){if(xe)return we;xe=1;var e=Wt();return we=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}function Mt(){if(_e)return Re;_e=1;var e=Wt();return Re=function(t){return e(this,t).get(t)}}function qt(){if(Pe)return ke;Pe=1;var e=Wt();return ke=function(t){return e(this,t).has(t)}}function It(){if($e)return Ce;$e=1;var e=Wt();return Ce=function(t,r){var n=e(this,t),o=n.size;return n.set(t,r),this.size+=n.size==o?0:1,this}}function zt(){if(Ne)return je;Ne=1;var e=Ut(),t=Gt(),r=Mt(),n=qt(),o=It();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,je=i}function Dt(){if(Be)return Ee;Be=1;var e=ht(),t=Nt(),r=zt();return Ee=function(n,o){var i=this.__data__;if(i instanceof e){var s=i.__data__;if(!t||s.length<199)return s.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(s)}return i.set(n,o),this.size=i.size,this}}function Ht(){if(Te)return Oe;Te=1;var e=ht(),t=lt(),r=ft(),n=gt(),o=pt(),i=Dt();function s(t){var r=this.__data__=new e(t);this.size=r.size}return s.prototype.clear=t,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,Oe=s}function Vt(){if(Ae)return Se;Ae=1;var e=jt(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return Se=t}function Jt(){if(Ue)return Le;Ue=1;var e=Vt();return Le=function(t,r,n){"__proto__"==r&&e?e(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}}function Kt(){if(We)return Fe;We=1;var e=Jt(),t=ot();return Fe=function(r,n,o){(void 0!==o&&!t(r[n],o)||void 0===o&&!(n in r))&&e(r,n,o)}}function Yt(){if(Me)return Ge;return Me=1,Ge=function(e){return function(t,r,n){for(var o=-1,i=Object(t),s=n(t),a=s.length;a--;){var u=s[e?a:++o];if(!1===r(i[u],u,i))break}return t}}}function Qt(){if(Ie)return qe;Ie=1;var e=Yt()();return qe=e}var Xt,Zt,er,tr,rr,nr,or,ir,sr,ar,ur,cr,hr,lr,fr,gr,pr,dr,vr,mr,yr,br,wr,xr,Rr,_r,kr,Pr,Cr,$r,jr,Nr,Er,Br={exports:{}};function Or(){return Xt||(Xt=1,function(e,t){var r=vt(),n=t&&!t.nodeType&&t,o=n&&e&&!e.nodeType&&e,i=o&&o.exports===n?r.Buffer:void 0,s=i?i.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=s?s(r):new e.constructor(r);return e.copy(n),n}}(Br,Br.exports)),Br.exports}function Tr(){if(er)return Zt;er=1;var e=vt().Uint8Array;return Zt=e}function Sr(){if(rr)return tr;rr=1;var e=Tr();return tr=function(t){var r=new t.constructor(t.byteLength);return new e(r).set(new e(t)),r}}function Ar(){if(or)return nr;or=1;var e=Sr();return nr=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}function Lr(){if(sr)return ir;return sr=1,ir=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}}function Ur(){if(ur)return ar;ur=1;var e=xt(),t=Object.create,r=function(){function r(){}return function(n){if(!e(n))return{};if(t)return t(n);r.prototype=n;var o=new r;return r.prototype=void 0,o}}();return ar=r}function Fr(){if(hr)return cr;return hr=1,cr=function(e,t){return function(r){return e(t(r))}}}function Wr(){if(fr)return lr;fr=1;var e=Fr()(Object.getPrototypeOf,Object);return lr=e}function Gr(){if(pr)return gr;pr=1;var e=Object.prototype;return gr=function(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}}function Mr(){if(vr)return dr;vr=1;var e=Ur(),t=Wr(),r=Gr();return dr=function(n){return"function"!=typeof n.constructor||r(n)?{}:e(t(n))}}function qr(){if(yr)return mr;return yr=1,mr=function(e){return null!=e&&"object"==typeof e}}function Ir(){if(wr)return br;wr=1;var e=wt(),t=qr();return br=function(r){return t(r)&&"[object Arguments]"==e(r)}}function zr(){if(Rr)return xr;Rr=1;var e=Ir(),t=qr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=e(function(){return arguments}())?e:function(e){return t(e)&&n.call(e,"callee")&&!o.call(e,"callee")};return xr=i}function Dr(){if(kr)return _r;kr=1;var e=Array.isArray;return _r=e}function Hr(){if(Cr)return Pr;Cr=1;return Pr=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function Vr(){if(jr)return $r;jr=1;var e=Rt(),t=Hr();return $r=function(r){return null!=r&&t(r.length)&&!e(r)}}function Jr(){if(Er)return Nr;Er=1;var e=Vr(),t=qr();return Nr=function(r){return t(r)&&e(r)}}var Kr,Yr,Qr,Xr,Zr,en,tn,rn,nn,on={exports:{}};function sn(){if(Yr)return Kr;return Yr=1,Kr=function(){return!1}}function an(){return Qr||(Qr=1,function(e,t){var r=vt(),n=sn(),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,s=i&&i.exports===o?r.Buffer:void 0,a=(s?s.isBuffer:void 0)||n;e.exports=a}(on,on.exports)),on.exports}function un(){if(Zr)return Xr;Zr=1;var e=wt(),t=Wr(),r=qr(),n=Function.prototype,o=Object.prototype,i=n.toString,s=o.hasOwnProperty,a=i.call(Object);return Xr=function(n){if(!r(n)||"[object Object]"!=e(n))return!1;var o=t(n);if(null===o)return!0;var u=s.call(o,"constructor")&&o.constructor;return"function"==typeof u&&u instanceof u&&i.call(u)==a}}function cn(){if(tn)return en;tn=1;var e=wt(),t=Hr(),r=qr(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,en=function(o){return r(o)&&t(o.length)&&!!n[e(o)]}}function hn(){if(nn)return rn;return nn=1,rn=function(e){return function(t){return e(t)}}}var ln,fn,gn,pn,dn,vn,mn,yn,bn,wn,xn,Rn,_n,kn,Pn,Cn,$n,jn,Nn,En,Bn,On,Tn,Sn,An,Ln,Un,Fn,Wn,Gn,Mn,qn,In,zn,Dn,Hn,Vn,Jn,Kn,Yn,Qn,Xn,Zn,eo,to,ro,no,oo,io,so={exports:{}};function ao(){return ln||(ln=1,function(e,t){var r=dt(),n=t&&!t.nodeType&&t,o=n&&e&&!e.nodeType&&e,i=o&&o.exports===n&&r.process,s=function(){try{var e=o&&o.require&&o.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=s}(so,so.exports)),so.exports}function uo(){if(gn)return fn;gn=1;var e=cn(),t=hn(),r=ao(),n=r&&r.isTypedArray,o=n?t(n):e;return fn=o}function co(){if(dn)return pn;return dn=1,pn=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function ho(){if(mn)return vn;mn=1;var e=Jt(),t=ot(),r=Object.prototype.hasOwnProperty;return vn=function(n,o,i){var s=n[o];r.call(n,o)&&t(s,i)&&(void 0!==i||o in n)||e(n,o,i)}}function lo(){if(bn)return yn;bn=1;var e=ho(),t=Jt();return yn=function(r,n,o,i){var s=!o;o||(o={});for(var a=-1,u=n.length;++a<u;){var c=n[a],h=i?i(o[c],r[c],c,o,r):void 0;void 0===h&&(h=r[c]),s?t(o,c,h):e(o,c,h)}return o}}function fo(){if(xn)return wn;return xn=1,wn=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}}function go(){if(_n)return Rn;_n=1;var e=/^(?:0|[1-9]\d*)$/;return Rn=function(t,r){var n=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<r}}function po(){if(Pn)return kn;Pn=1;var e=fo(),t=zr(),r=Dr(),n=an(),o=go(),i=uo(),s=Object.prototype.hasOwnProperty;return kn=function(a,u){var c=r(a),h=!c&&t(a),l=!c&&!h&&n(a),f=!c&&!h&&!l&&i(a),g=c||h||l||f,p=g?e(a.length,String):[],d=p.length;for(var v in a)!u&&!s.call(a,v)||g&&("length"==v||l&&("offset"==v||"parent"==v)||f&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||o(v,d))||p.push(v);return p}}function vo(){if($n)return Cn;return $n=1,Cn=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}}function mo(){if(Nn)return jn;Nn=1;var e=xt(),t=Gr(),r=vo(),n=Object.prototype.hasOwnProperty;return jn=function(o){if(!e(o))return r(o);var i=t(o),s=[];for(var a in o)("constructor"!=a||!i&&n.call(o,a))&&s.push(a);return s}}function yo(){if(Bn)return En;Bn=1;var e=po(),t=mo(),r=Vr();return En=function(n){return r(n)?e(n,!0):t(n)}}function bo(){if(Tn)return On;Tn=1;var e=lo(),t=yo();return On=function(r){return e(r,t(r))}}function wo(){if(An)return Sn;An=1;var e=Kt(),t=Or(),r=Ar(),n=Lr(),o=Mr(),i=zr(),s=Dr(),a=Jr(),u=an(),c=Rt(),h=xt(),l=un(),f=uo(),g=co(),p=bo();return Sn=function(d,v,m,y,b,w,x){var R=g(d,m),_=g(v,m),k=x.get(_);if(k)e(d,m,k);else{var P=w?w(R,_,m+"",d,v,x):void 0,C=void 0===P;if(C){var $=s(_),j=!$&&u(_),N=!$&&!j&&f(_);P=_,$||j||N?s(R)?P=R:a(R)?P=n(R):j?(C=!1,P=t(_,!0)):N?(C=!1,P=r(_,!0)):P=[]:l(_)||i(_)?(P=R,i(R)?P=p(R):h(R)&&!c(R)||(P=o(_))):C=!1}C&&(x.set(_,P),b(P,_,y,w,x),x.delete(_)),e(d,m,P)}}}function xo(){if(Un)return Ln;Un=1;var e=Ht(),t=Kt(),r=Qt(),n=wo(),o=xt(),i=yo(),s=co();return Ln=function a(u,c,h,l,f){u!==c&&r(c,(function(r,i){if(f||(f=new e),o(r))n(u,c,i,h,a,l,f);else{var g=l?l(s(u,i),r,i+"",u,c,f):void 0;void 0===g&&(g=r),t(u,i,g)}}),i)},Ln}function Ro(){if(Wn)return Fn;return Wn=1,Fn=function(e){return e}}function _o(){if(Mn)return Gn;return Mn=1,Gn=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}}function ko(){if(In)return qn;In=1;var e=_o(),t=Math.max;return qn=function(r,n,o){return n=t(void 0===n?r.length-1:n,0),function(){for(var i=arguments,s=-1,a=t(i.length-n,0),u=Array(a);++s<a;)u[s]=i[n+s];s=-1;for(var c=Array(n+1);++s<n;)c[s]=i[s];return c[n]=o(u),e(r,this,c)}},qn}function Po(){if(Dn)return zn;return Dn=1,zn=function(e){return function(){return e}}}function Co(){if(Vn)return Hn;Vn=1;var e=Po(),t=Vt();return Hn=t?function(r,n){return t(r,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:Ro()}function $o(){if(Kn)return Jn;Kn=1;var e=Date.now;return Jn=function(t){var r=0,n=0;return function(){var o=e(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}},Jn}function jo(){if(Qn)return Yn;Qn=1;var e=Co(),t=$o()(e);return Yn=t}function No(){if(Zn)return Xn;Zn=1;var e=Ro(),t=ko(),r=jo();return Xn=function(n,o){return r(t(n,o,e),n+"")}}function Eo(){if(to)return eo;to=1;var e=ot(),t=Vr(),r=go(),n=xt();return eo=function(o,i,s){if(!n(s))return!1;var a=typeof i;return!!("number"==a?t(s)&&r(i,s.length):"string"==a&&i in s)&&e(s[i],o)}}function Bo(){if(no)return ro;no=1;var e=No(),t=Eo();return ro=function(r){return e((function(e,n){var o=-1,i=n.length,s=i>1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(s=r.length>3&&"function"==typeof s?(i--,s):void 0,a&&t(n[0],n[1],a)&&(s=i<3?void 0:s,i=1),e=Object(e);++o<i;){var u=n[o];u&&r(e,u,o,s)}return e}))}}function Oo(){if(io)return oo;io=1;var e=xo(),t=Bo()((function(t,r,n){e(t,r,n)}));return oo=t}var To,So,Ao,Lo,Uo,Fo,Wo,Go,Mo,qo,Io,zo,Do,Ho,Vo,Jo,Ko,Yo,Qo,Xo,Zo,ei,ti,ri,ni=rt(Oo());function oi(){if(So)return To;So=1;var e=wt(),t=qr();return To=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function ii(){if(Lo)return Ao;Lo=1;var e=Dr(),t=oi(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Ao=function(o,i){if(e(o))return!1;var s=typeof o;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=o&&!t(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function si(){if(Fo)return Uo;Fo=1;var e=zt();function t(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var e=arguments,t=n?n.apply(this,e):e[0],i=o.cache;if(i.has(t))return i.get(t);var s=r.apply(this,e);return o.cache=i.set(t,s)||i,s};return o.cache=new(t.Cache||e),o}return t.Cache=e,Uo=t}function ai(){if(Go)return Wo;Go=1;var e=si();return Wo=function(t){var r=e(t,(function(e){return 500===n.size&&n.clear(),e})),n=r.cache;return r}}function ui(){if(qo)return Mo;qo=1;var e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,r=ai()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(e,(function(e,r,o,i){n.push(o?i.replace(t,"$1"):r||e)})),n}));return Mo=r}function ci(){if(zo)return Io;return zo=1,Io=function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}}function hi(){if(Ho)return Do;Ho=1;var e=mt(),t=ci(),r=Dr(),n=oi(),o=e?e.prototype:void 0,i=o?o.toString:void 0;return Do=function e(o){if("string"==typeof o)return o;if(r(o))return t(o,e)+"";if(n(o))return i?i.call(o):"";var s=o+"";return"0"==s&&1/o==-1/0?"-0":s},Do}function li(){if(Jo)return Vo;Jo=1;var e=hi();return Vo=function(t){return null==t?"":e(t)}}function fi(){if(Yo)return Ko;Yo=1;var e=Dr(),t=ii(),r=ui(),n=li();return Ko=function(o,i){return e(o)?o:t(o,i)?[o]:r(n(o))}}function gi(){if(Xo)return Qo;Xo=1;var e=oi();return Qo=function(t){if("string"==typeof t||e(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}}function pi(){if(ei)return Zo;ei=1;var e=fi(),t=gi();return Zo=function(r,n){for(var o=0,i=(n=e(n,r)).length;null!=r&&o<i;)r=r[t(n[o++])];return o&&o==i?r:void 0},Zo}function di(){if(ri)return ti;ri=1;var e=pi();return ti=function(t,r,n){var o=null==t?void 0:e(t,r);return void 0===o?n:o},ti}var vi=rt(di());const mi="package.json",yi=[".env.local",".env"];class bi extends ze.FeScriptContext{_env;shared;constructor(e){super(e),this._env=De.Env.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||yi}),this.shared=Object.assign({},this.feConfig.release,this.getDefaultShreadOptions(e.shared))}getDefaultShreadOptions(e){return{rootPath:process.cwd(),sourceBranch:this._env.get("FE_RELEASE_BRANCH")||this._env.get("FE_RELEASE_SOURCE_BRANCH")||"master",releaseEnv:this._env.get("FE_RELEASE_ENV")||this._env.get("NODE_ENV")||"development",...e}}get rootPath(){return this.shared.rootPath}get sourceBranch(){return this.shared.sourceBranch}get releaseEnv(){return this.shared.releaseEnv}get env(){return this._env}get workspaces(){return this.getConfig("workspaces.workspaces")}get workspace(){return this.getConfig("workspaces.workspace")}setWorkspaces(e){this.options.workspaces={...this.options.workspaces,workspaces:e}}setConfig(e){this.options=ni(this.options,e)}getConfig(e,t){return vi(this.options,e,t)}setShared(e){this.shared=ni(this.shared,e)}getPkg(e,t){const r=this.workspace?.packageJson;if(!r)throw new Error("package.json is not found");return e?vi(r,e,t):r}getTemplateContext(){return{...this.shared,...this.workspace,publishPath:this.workspace?.path||"",env:this.releaseEnv,branch:this.sourceBranch}}async runChangesetsCli(e,t){let r="pnpm";try{await this.shell.exec("pnpm -v",{dryRun:!1})}catch{r="npm"}return await this.shell.exec(["pnpm"===r?"pnpm dlx":"npx","@changesets/cli",e,...t??[]])}}function wi(e,...t){return[e,...t]}const xi={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages"};class Ri{shell;logger;config;constructor(e,t,r={}){this.shell=e,this.logger=t,this.config={...xi,...r}}getReleaseBranchName(e,t,r){const n=r.branchName||"release-${tagName}";if("string"!=typeof n)throw new Error("Branch name template is not a string");return this.logger.verbose("Release Branch template is:",n),this.shell.format(n,{pkgName:e,releaseName:e,tagName:t,...r})}getBatchReleaseBranchName(e,t,r,n){const o=this.config.batchBranchName;if("string"!=typeof o)throw new Error("Branch name template is not a string");return this.logger.verbose("Release Batch Branch template is:",o),this.shell.format(o,{pkgName:e,releaseName:e,tagName:t,...r,length:n})}getReleaseName(e){if(1===e.length)return e[0].name;const{maxWorkspace:t,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return e.slice(t).map((({name:e,version:t})=>`${e}${n}${t}`)).join(r)}getReleaseTagName(e){return 1===e.length?e[0].version:`batch-${e.length}-${(new Date).toISOString().split("T")[0]}`}getReleaseBranchParams(e,t){const r=this.getReleaseTagName(e),n=this.getReleaseName(e);return{tagName:r,releaseBranch:e.length>1?this.getBatchReleaseBranchName(n,r,t,e.length):this.getReleaseBranchName(n,r,t)}}getPRTitle(e,t){const r=this.config.PRTitle||"Release ${env} ${pkgName} ${tagName}";return this.shell.format(r,{...t,tagName:e.tagName,pkgName:e.releaseBranch})}getPRBody(e,t,r){const n=this.config.PRBody,o=e.length>1?e.map((e=>this.shell.format("\n## ${name} ${version}\n${changelog}\n",e))):e[0].changelog,{workspaceVersionSeparator:i}=this.config,s=1===e.length?t.tagName:e.map((e=>`${e.name}${i}${e.version}`)).join(" ");return this.shell.format(n,{...r,tagName:s,changelog:o})}}class _i{context;_octokit=null;constructor(e){this.context=e}getGitHubUserInfo(){const{authorName:e,repoName:t}=this.context.shared;if(!e||!t)throw new Error("Author name or repo name is not set");return{owner:e,repo:t}}getToken(){const{tokenRef:e="GITHUB_TOKEN"}=this.context.getConfig("githubPR"),t=this.context.env.get(e);if(!t)throw new Error(`Token is not set. Please set ${e} environment variable.`);return t}get octokit(){if(this._octokit)return this._octokit;const{timeout:e}=this.context.getConfig("githubPR"),t={auth:this.getToken(),request:{timeout:e}};return this._octokit=new Ve.Octokit(t),this._octokit}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.shared.autoMergeType||"squash"}get dryRunPRNumber(){return this.context.getConfig("githubPR.dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.shared.autoMergeReleasePR||false}async mergePR(e,t){if(!e)return void this.logger.error("Failed to create Pull Request.",e);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.context.shared;this.logger.info(`[DRY RUN] Would merge PR #${e} with method '${r}' in repo ${o}/${n}, branch ${t}`)}else await this.octokit.rest.pulls.merge({...this.getGitHubUserInfo(),pull_number:Number(e),merge_method:r})}async checkedPR(e,t){try{await this.octokit.rest.pulls.get({...this.getGitHubUserInfo(),pull_number:Number(e)}),await this.octokit.rest.git.deleteRef({...this.getGitHubUserInfo(),ref:`heads/${t}`}),this.logger.info(`Branch ${t} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${e} or branch ${t} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const e=this.context.shared.label;if(!(e&&e.name&&e.description&&e.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",e),e;try{const t=await this.octokit.rest.issues.createLabel({...this.getGitHubUserInfo(),name:e.name,description:e.description,color:e.color.replace("#","")});return this.logger.debug("Create PR label Success",t),e}catch(t){if(422===t.status)return this.logger.warn(`Label ${e.name} already exists, skipping!`),e;throw this.logger.error("Create PR label Failed",t),t}}async createReleasePR(e){if(this.context.getConfig("githubPR.dryRunCreatePR")||this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...e,labels:e.labels}),this.dryRunPRNumber;try{const t=await this.octokit.rest.pulls.create({...this.getGitHubUserInfo(),...e}),r=t.data.number;if(!r)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",[t?.url]),e.labels&&e.labels.length){const t=await this.octokit.rest.issues.addLabels({...this.getGitHubUserInfo(),issue_number:r,labels:e.labels});this.logger.debug("Add PR label Success",[t.url])}return r.toString()}catch(e){if(422===e.status&&e.message.includes("already exists")){this.logger.warn("PR already exists");const t=e.message.match(/pull request #(\d+)/);return t?t[1]:""}throw this.logger.error("Failed to create PR",e),e}}truncateBody(e){return e&&e.length>=124e3?e.substring(0,124e3)+"...":e}getOctokitReleaseOptions(e){const{releaseName:t,draft:r=!1,preRelease:n=!1,autoGenerate:o=!1,makeLatest:i=!0,releaseNotes:s,discussionCategoryName:a}=this.context.getConfig("githubPR"),u=t,c=o?"":this.truncateBody(String(s));return{name:u,make_latest:i.toString(),body:c,draft:r,prerelease:n,generate_release_notes:o,discussion_category_name:a,tag_name:"",...e,...this.getGitHubUserInfo()}}async createRelease(e){const t=this.getOctokitReleaseOptions({tag_name:e.tagName,body:e.changelog});if(t.name=this.shell.format(t.name,e),this.logger.exec(`octokit repos.createRelease "${t.name}" (${t.tag_name})`,{isDryRun:this.context.dryRun}),!t.tag_name)throw new Error("TagName is undefined");if(this.context.dryRun)return;const r=await this.octokit.repos.createRelease(t);this.logger.verbose(`octokit repos.createRelease: done (${r.headers.location})`)}}var ki,Pi;function Ci(){if(Pi)return ki;Pi=1;var e=wt(),t=Dr(),r=qr();return ki=function(n){return"string"==typeof n||!t(n)&&r(n)&&"[object String]"==e(n)}}var $i=rt(Ci());class ji{context;pluginName;props;onlyOne=!0;constructor(e,t,r={}){this.context=e,this.pluginName=t,this.props=r,this.setConfig(this.getInitialProps(r))}getInitialProps(e){const t=this.context.options[this.pluginName];return t||e?ni({},e,t):{}}get logger(){return this.context.logger}get shell(){return this.context.shell}get options(){return this.context.getConfig(this.pluginName,{})}getEnv(e,t){return this.context.env.get(e)??t}enabled(e,t){return!0}getConfig(e,t){return e?this.context.getConfig([this.pluginName,...Array.isArray(e)?e:[e]],t):this.context.getConfig(this.pluginName,t)}setConfig(e){this.context.setConfig({[this.pluginName]:e})}onBefore(e){}onExec(e){}onSuccess(e){}onError(e){}async step({label:e,task:t}){this.logger.obtrusive(e);try{const r=await t();return this.logger.info(`${e} - success`),r}catch(e){throw this.logger.error(e),e}}}class Ni extends ji{async onBefore(){const e=await this.getUserInfo();if(!e)throw new Error("Failed to get repoInfo");let t=this.context.shared.currentBranch;t||(t=await this.getCurrentBranch()),t&&await this.context.shell.exec(`git checkout ${t}`,{dryRun:!1}),this.context.setShared({repoName:e.repoName,authorName:e.authorName,currentBranch:t})}async getCurrentBranch(){return await new Promise((e=>setTimeout(e,100))),this.context.shell.exec("git rev-parse --abbrev-ref HEAD",{dryRun:!1})}async getRemoteUrl(){return(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}async getUserInfo(){let e;try{e=await this.getRemoteUrl()}catch{throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!e)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.verbose("repoUrl: ",e);const t=e.match(/github\.com[:/]([^/]+)\/([^/.]+)(?:\.git)?$/);if(!t)throw new Error("Invalid GitHub repository URL format. Please ensure the remote URL is from GitHub.");const[,r,n]=t;if(!this.isValidString(r)||!this.isValidString(n))throw new Error("Failed to extract owner or repository name from GitHub URL");return{repoName:n,authorName:r}}isValidString(e){return!!e&&$i(e)}}class Ei{options;constructor(e){this.options=e}compare(e,t){return"function"==typeof this.options.compare?this.options.compare(e,t):e.startsWith(t)}toChangeLabel(e,t=this.options.changePackagesLabel){return t.replace("${name}",e)}toChangeLabels(e,t=this.options.changePackagesLabel){return e.map((e=>this.toChangeLabel(e,t)))}pick(e,t=this.options.packagesDirectories){const r=[];for(const n of t)for(const t of e)if(this.compare(t,n)){r.push(n);break}return r}}class Bi{static readJson(e){const t=Ke.readFileSync(e,"utf-8");return JSON.parse(t)}static toWorkspace(e,t){let{root:r,packageJson:n}=e;const o=e.path;if(!o)throw new Error("path is not required!");return r=r||Ye.join(t,o),n=n||Bi.readJson(Ye.join(r,mi)),{name:n.name,version:n.version,path:o,root:r,packageJson:n}}}class Oi extends ji{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(e){super(e,"workspaces"),this.releaseLabel=new Ei({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[]})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){const e=this.getConfig("workspace");if(e)return this.logger.debug("Use the specified workspace",e),void this.setCurrentWorkspace(e,[]);const t=await this.getWorkspaces();if(this.getConfig("skipCheckPackage")||0===t.length)throw new Error("No changes to publish packages");const{publishPath:r}=this.context.shared;if(r){const e=t.find((e=>Je.resolve(e.root)===Je.resolve(r)));if(this.nextSkip(),!e)throw new Error(`No workspace found for: ${r}`);return this.logger.debug(`Workspace of ${r} find!`,Je.join(e.root,mi)),void this.setCurrentWorkspace(e,[e])}const[n,...o]=t;this.workspacesList=o,this.setCurrentWorkspace(n,t)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}setReleaseTask(e){this.releaseTask=e}setCurrentWorkspace(e,t){this.context.setShared({publishPath:e.path}),this.setConfig({workspace:e,workspaces:t})}getPackages(){const e=this.context.shared.packagesDirectories;return Array.isArray(e)?e:[]}async getGitWorkspaces(){const e=this.context.sourceBranch,t=await this.shell.exec(`git diff --name-only origin/${e}...HEAD`,{dryRun:!1});return"string"==typeof t?t.split("\n"):[]}async getChangedPackages(e,t){if(this.logger.debug("changeLabels",t),Array.isArray(t)&&t.length>0){const r=e.filter((e=>{const r=this.releaseLabel.toChangeLabel(e);return t.includes(r)}));return this.logger.debug("changed by labels",r),r}const r=await this.getGitWorkspaces();return this.logger.debug("changed by git",r),this.releaseLabel.pick(r,e)}async getWorkspaces(){const e=this.getPackages();this.logger.debug("packages",e);const t=await this.getChangedPackages(e,this.getConfig("changeLabels"));this.logger.debug("changedPaths",t);const r=t.map((e=>Bi.toWorkspace({path:e},this.context.rootPath)));return r}}function Ti(e,...t){return"function"==typeof e&&e.prototype&&e.prototype.constructor===e?new e(...t):e(...t)}function Si(e){return e.startsWith(".")?Je.parse(e).name:e}async function Ai(e){let t=null;try{t=(await import(e)).default}catch{try{t=(await import(Je.join(process.cwd(),e))).default}catch{const r=Qe.createRequire(process.cwd());t=(await import(Xe.pathToFileURL(r.resolve(e,{paths:[process.cwd()]})).href)).default}}return[Si(e),t]}async function Li(e,t,r=5){const n=Ze(r),o=t.map((([t,...r])=>n((()=>(async(t,...r)=>{if("string"==typeof t){const[,n]=await Ai(t);return Ti(n,e,...r)}return Ti(t,e,...r)})(t,...r)))));return Promise.all(o)}const Ui={name:"angular",types:[{type:"feat",section:"✨ Features",hidden:!1},{type:"fix",section:"🐞 Bug Fixes",hidden:!1},{type:"chore",section:"🔧 Chores",hidden:!1},{type:"docs",section:"📝 Documentation",hidden:!1},{type:"refactor",section:"♻️ Refactors",hidden:!1},{type:"perf",section:"🚀 Performance",hidden:!1},{type:"test",section:"🚨 Tests",hidden:!1},{type:"style",section:"🎨 Styles",hidden:!1},{type:"ci",section:"🔄 CI",hidden:!1},{type:"build",section:"🚧 Build",hidden:!1},{type:"revert",section:"⏪ Reverts",hidden:!1},{type:"release",section:"🔖 Releases",hidden:!1}]};const Fi=[wi(Oi),wi(class extends ji{constructor(e,t){super(e,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...t})}get changesetRoot(){return Ye.join(this.context.rootPath,this.getConfig("changesetRoot"))}enabled(){return!this.getConfig("skip")}async onBefore(){if(!Ke.existsSync(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}mergeWorkspaces(e){return e.map((e=>{const t=Bi.toWorkspace({path:e.path},this.context.rootPath),r={...e,version:t.version};return r.tagName=this.generateTagName(r),r}))}async onExec(){const e=await this.step({label:"Generate Changelogs",task:()=>Promise.all(this.context.workspaces.map((e=>this.generateChangelog(e))))});this.getConfig("skipChangeset")?this.logger.debug("Skip generate changeset files"):(await this.step({label:"Changeset Version",task:()=>Promise.all(e.map((e=>this.generateChangesetFile(e))))}),await this.context.runChangesetsCli("version",["--no-changelog"]));const t=this.mergeWorkspaces(e);this.logger.debug("new workspaces",t),this.context.setWorkspaces(t)}getTagPrefix(e){return this.shell.format(this.getConfig("tagPrefix"),e)}async createChangelog({lastTag:e,workspace:t}){const r={releaseCount:1,tagPrefix:this.getTagPrefix(t),warn:this.logger.warn.bind(this.logger),preset:Ui.name},n={version:t.version},o={debug:this.logger.debug.bind(this.logger),from:e,reverse:!0},i={},s={headerPartial:""};return this.context.dryRun?(this.logger.info("[Dry Run] Changelog is dry run"),new Promise((e=>{e("## Dry Run Changelog")}))):new Promise(((e,t)=>{let a="";et(r,n,o,i,s).on("data",(e=>{a+=e.toString()})).on("end",(()=>{e(this.tranformChangelog(a,Ui.types))})).on("error",t)}))}tranformChangelog(e,t){return e}async generateChangelog(e){const t=await this.getTagName(e);this.logger.verbose("tagName is:",t);const r=await this.createChangelog({workspace:e,lastTag:t});return{...e,lastTag:t,changelog:r}}generateTagName(e){try{const t=this.getConfig("tagTemplate");return this.shell.format(t,e)}catch(t){return console.error(`Error generating tag name for ${e.name}:`,t),`${e.name}-v0.0.0`}}async getTagName(e){try{const t=this.generateTagName(e),r=this.shell.format(this.getConfig("tagMatch"),e),n=await this.shell.exec(`git for-each-ref --sort=-creatordate --format "%(refname:short)|%(creatordate:iso8601)" "refs/tags/${r}"`,{dryRun:!1});if(this.logger.debug("tagsOutput",n),!n)return t;const o=n.split("\n").filter(Boolean);if(0===o.length)return t;return o[0].split("|")[0]}catch(t){console.error(`Error getting tag for ${e.name}:`,t);return this.generateTagName(e)}}getIncrement(){const e=this.context.getConfig("workspaces.changeLabels");if(Array.isArray(e)&&e.length>0){if(e.includes("increment:major"))return"major";if(e.includes("increment:minor"))return"minor"}return this.getConfig("increment","patch")}async generateChangesetFile(e){const{name:t,version:r}=e,n=`${t}-${r}`.replace(/[\/\\]/g,"_"),o=Ye.join(this.changesetRoot,`${n}.md`),i=this.getIncrement();this.logger.verbose("increment is:",[i]);const s=this.shell.format("---\n'${name}': '${increment}'\n---\n${changelog}",{...e,increment:i});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(s);Ke.existsSync(o)?this.logger.info(`Changeset ${n} already exists`):Ke.writeFileSync(o,s,"utf-8")}},{}),wi(class extends Ni{context;releaseParams;githubManager;constructor(e,t){super(e,"githubPR",{releaseName:"Release ${name} v${version}",...t}),this.context=e,this.githubManager=new _i(this.context),this.releaseParams=new Ri(e.shell,e.logger,{PRTitle:this.getConfig("PRTitle",this.context.shared.PRTitle),PRBody:this.getConfig("PRBody",this.context.shared.PRBody),...this.props})}enabled(e){return!this.getConfig("skip")&&("onExec"===e?!this.isPublish:"onSuccess"!==e||this.isPublish)}get isPublish(){return!this.getConfig("releasePR")}async isGithubRepository(){try{return(await this.getRemoteUrl()).includes("github.com")}catch{return!1}}async onBefore(){this.logger.verbose("GithubPR onBefore");if(!await this.isGithubRepository())throw new Error("Current repository is not a GitHub repository. GitHub PR workflow is only available for GitHub repositories.");if(await super.onBefore(),this.isPublish){const e=this.getEnv("NPM_TOKEN");if(!e)throw new Error("NPM_TOKEN is not set");await this.shell.exec(`npm config set //registry.npmjs.org/:_authToken=${e}`)}}async onExec(){const e=this.context.workspaces;await this.step({label:"Release Commit",task:()=>this.relesaeCommit(e)});const t=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(e)});await this.releasePullRequest(e,t)}async onSuccess(){const e=this.context.workspaces;this.getConfig("dryRunCreatePR")||(await this.context.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags")),await this.step({label:"Release Github",task:()=>Promise.all(e.map((e=>(this.logger.debug(e),this.githubManager.createRelease(e)))))})}async relesaeCommit(e){const t=this.getConfig("commitArgs",[]);if(1===e.length)return await this.shell.exec("git add ."),void await this.commitWorkspace(e[0],t);await this.shell.exec("git add .");const r=`chore(tag): ${e.map((e=>`${e.name} v${e.version}`)).join(",")}`;await this.shell.exec(["git","commit","--message",r,...t])}async releasePullRequest(e,t){const r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(e,t)});if(this.githubManager.autoMergeReleasePR){const{releaseBranch:e}=t;return await this.step({label:`Merge Release PR(${r})`,task:()=>this.githubManager.mergePR(r,e)}),void await this.step({label:`Checked Release PR(${r})`,task:()=>this.githubManager.checkedPR(r,e)})}this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async commitWorkspace(e,t=[]){const r=this.shell.format(this.getConfig("commitMessage","chore(tag): ${name} v${version}"),e);return await this.shell.exec(["git","commit","--message",`"${r}"`,...t])}async createReleaseBranch(e){const t=this.releaseParams.getReleaseBranchParams(e,this.context.getTemplateContext()),{tagName:r,releaseBranch:n}=t;if("string"!=typeof r)throw new Error("Tag name is not a string");const{sourceBranch:o,currentBranch:i}=this.context.shared;this.context.logger.verbose("PR TagName is:",r),this.context.logger.verbose("PR CurrentBranch is:",i),this.context.logger.verbose("PR SourceBranch is:",o),this.context.logger.verbose("PR ReleaseBranch is:",n);try{await this.context.shell.exec(`git fetch origin ${o} ${i}`),await this.context.shell.exec(`git checkout -b ${n} ${i}`),await this.context.shell.exec(`git push origin ${n}`)}catch(e){throw e.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),e}return{tagName:r,releaseBranch:n}}async createReleasePR(e,t){const r=[(await this.githubManager.createReleasePRLabel()).name],n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(t,n),i=this.releaseParams.getPRBody(e,t,n);return this.githubManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:t.releaseBranch,labels:r})}},{})];var Wi,Gi,Mi,qi;function Ii(){if(Gi)return Wi;Gi=1;var e=ho(),t=fi(),r=go(),n=xt(),o=gi();return Wi=function(i,s,a,u){if(!n(i))return i;for(var c=-1,h=(s=t(s,i)).length,l=h-1,f=i;null!=f&&++c<h;){var g=o(s[c]),p=a;if("__proto__"===g||"constructor"===g||"prototype"===g)return i;if(c!=l){var d=f[g];void 0===(p=u?u(d,g,f):void 0)&&(p=n(d)?d:r(s[c+1])?[]:{})}e(f,g,p),f=f[g]}return i},Wi}function zi(){if(qi)return Mi;qi=1;var e=Ii();return Mi=function(t,r,n){return null==t?t:e(t,r,n)},Mi}var Di=rt(zi());exports.Plugin=ji,exports.ReleaseContext=bi,exports.ReleaseLabel=Ei,exports.ReleaseTask=class{executor;defaultTuples;context;constructor(e={},t=new He.AsyncExecutor,r=Fi){this.executor=t,this.defaultTuples=r,this.context=new bi(e)}getContext(){return this.context}async usePlugins(e){e=e||this.context.shared.plugins||[];const t=await Li(this.context,[...this.defaultTuples,...e]);return t.forEach((e=>{e instanceof Oi&&e.setReleaseTask(this),this.executor.use(e)})),t}async run(){return this.executor.exec(this.context,(e=>Promise.resolve(e)))}async exec(e){if("false"===this.context.env.get("FE_RELEASE"))throw new Error("Skip Release");return await this.usePlugins(e),this.run()}},exports.factory=Ti,exports.load=Ai,exports.loaderPluginsFromPluginTuples=Li,exports.reduceOptions=function(e,t){return Object.entries(e).reduce(((e,[r,n])=>(r.includes(".")?Di(e,r,n):Di(e,t?`${t}.${r}`:r,n),e)),{})},exports.tuple=wi;
|
|
1
|
+
"use strict";var e,t,r,n,o,i,a,s,c,u,h,l,g,f,p,d,m,v,y,b,w,x,R,_,k,P,C,$,N,j,E,O,T,B,S,A,L,U,F,W,G,q,M,I,z,H,D,V,J,K,Y,Q,X,Z,ee,te,re,ne,oe,ie,ae,se,ce,ue,he,le,ge,fe,pe,de,me,ve,ye,be,we,xe,Re,_e,ke,Pe,Ce,$e,Ne,je,Ee,Oe,Te,Be,Se,Ae,Le,Ue,Fe,We,Ge,qe,Me,Ie,ze=require("@qlover/scripts-context"),He=require("@qlover/env-loader"),De=require("@qlover/fe-corekit"),Ve=require("@octokit/rest"),Je=require("node:path"),Ke=require("fs"),Ye=require("path"),Qe=require("node:module"),Xe=require("node:url"),Ze=require("p-limit"),et=require("conventional-changelog"),tt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function rt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function nt(){if(t)return e;return t=1,e=function(){this.__data__=[],this.size=0}}function ot(){if(n)return r;return n=1,r=function(e,t){return e===t||e!=e&&t!=t}}function it(){if(i)return o;i=1;var e=ot();return o=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function at(){if(s)return a;s=1;var e=it(),t=Array.prototype.splice;return a=function(r){var n=this.__data__,o=e(n,r);return!(o<0)&&(o==n.length-1?n.pop():t.call(n,o,1),--this.size,!0)}}function st(){if(u)return c;u=1;var e=it();return c=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}function ct(){if(l)return h;l=1;var e=it();return h=function(t){return e(this.__data__,t)>-1}}function ut(){if(f)return g;f=1;var e=it();return g=function(t,r){var n=this.__data__,o=e(n,t);return o<0?(++this.size,n.push([t,r])):n[o][1]=r,this}}function ht(){if(d)return p;d=1;var e=nt(),t=at(),r=st(),n=ct(),o=ut();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,p=i}function lt(){if(v)return m;v=1;var e=ht();return m=function(){this.__data__=new e,this.size=0}}function gt(){if(b)return y;return b=1,y=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}}function ft(){if(x)return w;return x=1,w=function(e){return this.__data__.get(e)}}function pt(){if(_)return R;return _=1,R=function(e){return this.__data__.has(e)}}function dt(){if(P)return k;P=1;var e="object"==typeof tt&&tt&&tt.Object===Object&&tt;return k=e}function mt(){if($)return C;$=1;var e=dt(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return C=r}function vt(){if(j)return N;j=1;var e=mt().Symbol;return N=e}function yt(){if(O)return E;O=1;var e=vt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,o=e?e.toStringTag:void 0;return E=function(e){var t=r.call(e,o),i=e[o];try{e[o]=void 0;var a=!0}catch(e){}var s=n.call(e);return a&&(t?e[o]=i:delete e[o]),s}}function bt(){if(B)return T;B=1;var e=Object.prototype.toString;return T=function(t){return e.call(t)}}function wt(){if(A)return S;A=1;var e=vt(),t=yt(),r=bt(),n=e?e.toStringTag:void 0;return S=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):r(e)}}function xt(){if(U)return L;return U=1,L=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function Rt(){if(W)return F;W=1;var e=wt(),t=xt();return F=function(r){if(!t(r))return!1;var n=e(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function _t(){if(q)return G;q=1;var e=mt()["__core-js_shared__"];return G=e}function kt(){if(I)return M;I=1;var e,t=_t(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return M=function(e){return!!r&&r in e}}function Pt(){if(H)return z;H=1;var e=Function.prototype.toString;return z=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}function Ct(){if(V)return D;V=1;var e=Rt(),t=kt(),r=xt(),n=Pt(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,a=Object.prototype,s=i.toString,c=a.hasOwnProperty,u=RegExp("^"+s.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return D=function(i){return!(!r(i)||t(i))&&(e(i)?u:o).test(n(i))}}function $t(){if(K)return J;return K=1,J=function(e,t){return null==e?void 0:e[t]}}function Nt(){if(Q)return Y;Q=1;var e=Ct(),t=$t();return Y=function(r,n){var o=t(r,n);return e(o)?o:void 0}}function jt(){if(Z)return X;Z=1;var e=Nt()(mt(),"Map");return X=e}function Et(){if(te)return ee;te=1;var e=Nt()(Object,"create");return ee=e}function Ot(){if(ne)return re;ne=1;var e=Et();return re=function(){this.__data__=e?e(null):{},this.size=0}}function Tt(){if(ie)return oe;return ie=1,oe=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}}function Bt(){if(se)return ae;se=1;var e=Et(),t=Object.prototype.hasOwnProperty;return ae=function(r){var n=this.__data__;if(e){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return t.call(n,r)?n[r]:void 0}}function St(){if(ue)return ce;ue=1;var e=Et(),t=Object.prototype.hasOwnProperty;return ce=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}function At(){if(le)return he;le=1;var e=Et();return he=function(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===r?"__lodash_hash_undefined__":r,this}}function Lt(){if(fe)return ge;fe=1;var e=Ot(),t=Tt(),r=Bt(),n=St(),o=At();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,ge=i}function Ut(){if(de)return pe;de=1;var e=Lt(),t=ht(),r=jt();return pe=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}function Ft(){if(ve)return me;return ve=1,me=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}}function Wt(){if(be)return ye;be=1;var e=Ft();return ye=function(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Gt(){if(xe)return we;xe=1;var e=Wt();return we=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}function qt(){if(_e)return Re;_e=1;var e=Wt();return Re=function(t){return e(this,t).get(t)}}function Mt(){if(Pe)return ke;Pe=1;var e=Wt();return ke=function(t){return e(this,t).has(t)}}function It(){if($e)return Ce;$e=1;var e=Wt();return Ce=function(t,r){var n=e(this,t),o=n.size;return n.set(t,r),this.size+=n.size==o?0:1,this}}function zt(){if(je)return Ne;je=1;var e=Ut(),t=Gt(),r=qt(),n=Mt(),o=It();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Ne=i}function Ht(){if(Oe)return Ee;Oe=1;var e=ht(),t=jt(),r=zt();return Ee=function(n,o){var i=this.__data__;if(i instanceof e){var a=i.__data__;if(!t||a.length<199)return a.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(a)}return i.set(n,o),this.size=i.size,this}}function Dt(){if(Be)return Te;Be=1;var e=ht(),t=lt(),r=gt(),n=ft(),o=pt(),i=Ht();function a(t){var r=this.__data__=new e(t);this.size=r.size}return a.prototype.clear=t,a.prototype.delete=r,a.prototype.get=n,a.prototype.has=o,a.prototype.set=i,Te=a}function Vt(){if(Ae)return Se;Ae=1;var e=Nt(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return Se=t}function Jt(){if(Ue)return Le;Ue=1;var e=Vt();return Le=function(t,r,n){"__proto__"==r&&e?e(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}}function Kt(){if(We)return Fe;We=1;var e=Jt(),t=ot();return Fe=function(r,n,o){(void 0!==o&&!t(r[n],o)||void 0===o&&!(n in r))&&e(r,n,o)}}function Yt(){if(qe)return Ge;return qe=1,Ge=function(e){return function(t,r,n){for(var o=-1,i=Object(t),a=n(t),s=a.length;s--;){var c=a[e?s:++o];if(!1===r(i[c],c,i))break}return t}}}function Qt(){if(Ie)return Me;Ie=1;var e=Yt()();return Me=e}var Xt,Zt,er,tr,rr,nr,or,ir,ar,sr,cr,ur,hr,lr,gr,fr,pr,dr,mr,vr,yr,br,wr,xr,Rr,_r,kr,Pr,Cr,$r,Nr,jr,Er,Or={exports:{}};function Tr(){return Xt||(Xt=1,function(e,t){var r=mt(),n=t&&!t.nodeType&&t,o=n&&e&&!e.nodeType&&e,i=o&&o.exports===n?r.Buffer:void 0,a=i?i.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=a?a(r):new e.constructor(r);return e.copy(n),n}}(Or,Or.exports)),Or.exports}function Br(){if(er)return Zt;er=1;var e=mt().Uint8Array;return Zt=e}function Sr(){if(rr)return tr;rr=1;var e=Br();return tr=function(t){var r=new t.constructor(t.byteLength);return new e(r).set(new e(t)),r}}function Ar(){if(or)return nr;or=1;var e=Sr();return nr=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}function Lr(){if(ar)return ir;return ar=1,ir=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}}function Ur(){if(cr)return sr;cr=1;var e=xt(),t=Object.create,r=function(){function r(){}return function(n){if(!e(n))return{};if(t)return t(n);r.prototype=n;var o=new r;return r.prototype=void 0,o}}();return sr=r}function Fr(){if(hr)return ur;return hr=1,ur=function(e,t){return function(r){return e(t(r))}}}function Wr(){if(gr)return lr;gr=1;var e=Fr()(Object.getPrototypeOf,Object);return lr=e}function Gr(){if(pr)return fr;pr=1;var e=Object.prototype;return fr=function(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}}function qr(){if(mr)return dr;mr=1;var e=Ur(),t=Wr(),r=Gr();return dr=function(n){return"function"!=typeof n.constructor||r(n)?{}:e(t(n))}}function Mr(){if(yr)return vr;return yr=1,vr=function(e){return null!=e&&"object"==typeof e}}function Ir(){if(wr)return br;wr=1;var e=wt(),t=Mr();return br=function(r){return t(r)&&"[object Arguments]"==e(r)}}function zr(){if(Rr)return xr;Rr=1;var e=Ir(),t=Mr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=e(function(){return arguments}())?e:function(e){return t(e)&&n.call(e,"callee")&&!o.call(e,"callee")};return xr=i}function Hr(){if(kr)return _r;kr=1;var e=Array.isArray;return _r=e}function Dr(){if(Cr)return Pr;Cr=1;return Pr=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function Vr(){if(Nr)return $r;Nr=1;var e=Rt(),t=Dr();return $r=function(r){return null!=r&&t(r.length)&&!e(r)}}function Jr(){if(Er)return jr;Er=1;var e=Vr(),t=Mr();return jr=function(r){return t(r)&&e(r)}}var Kr,Yr,Qr,Xr,Zr,en,tn,rn,nn,on={exports:{}};function an(){if(Yr)return Kr;return Yr=1,Kr=function(){return!1}}function sn(){return Qr||(Qr=1,function(e,t){var r=mt(),n=an(),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,a=i&&i.exports===o?r.Buffer:void 0,s=(a?a.isBuffer:void 0)||n;e.exports=s}(on,on.exports)),on.exports}function cn(){if(Zr)return Xr;Zr=1;var e=wt(),t=Wr(),r=Mr(),n=Function.prototype,o=Object.prototype,i=n.toString,a=o.hasOwnProperty,s=i.call(Object);return Xr=function(n){if(!r(n)||"[object Object]"!=e(n))return!1;var o=t(n);if(null===o)return!0;var c=a.call(o,"constructor")&&o.constructor;return"function"==typeof c&&c instanceof c&&i.call(c)==s}}function un(){if(tn)return en;tn=1;var e=wt(),t=Dr(),r=Mr(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,en=function(o){return r(o)&&t(o.length)&&!!n[e(o)]}}function hn(){if(nn)return rn;return nn=1,rn=function(e){return function(t){return e(t)}}}var ln,gn,fn,pn,dn,mn,vn,yn,bn,wn,xn,Rn,_n,kn,Pn,Cn,$n,Nn,jn,En,On,Tn,Bn,Sn,An,Ln,Un,Fn,Wn,Gn,qn,Mn,In,zn,Hn,Dn,Vn,Jn,Kn,Yn,Qn,Xn,Zn,eo,to,ro,no,oo,io,ao={exports:{}};function so(){return ln||(ln=1,function(e,t){var r=dt(),n=t&&!t.nodeType&&t,o=n&&e&&!e.nodeType&&e,i=o&&o.exports===n&&r.process,a=function(){try{var e=o&&o.require&&o.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=a}(ao,ao.exports)),ao.exports}function co(){if(fn)return gn;fn=1;var e=un(),t=hn(),r=so(),n=r&&r.isTypedArray,o=n?t(n):e;return gn=o}function uo(){if(dn)return pn;return dn=1,pn=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function ho(){if(vn)return mn;vn=1;var e=Jt(),t=ot(),r=Object.prototype.hasOwnProperty;return mn=function(n,o,i){var a=n[o];r.call(n,o)&&t(a,i)&&(void 0!==i||o in n)||e(n,o,i)}}function lo(){if(bn)return yn;bn=1;var e=ho(),t=Jt();return yn=function(r,n,o,i){var a=!o;o||(o={});for(var s=-1,c=n.length;++s<c;){var u=n[s],h=i?i(o[u],r[u],u,o,r):void 0;void 0===h&&(h=r[u]),a?t(o,u,h):e(o,u,h)}return o}}function go(){if(xn)return wn;return xn=1,wn=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}}function fo(){if(_n)return Rn;_n=1;var e=/^(?:0|[1-9]\d*)$/;return Rn=function(t,r){var n=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<r}}function po(){if(Pn)return kn;Pn=1;var e=go(),t=zr(),r=Hr(),n=sn(),o=fo(),i=co(),a=Object.prototype.hasOwnProperty;return kn=function(s,c){var u=r(s),h=!u&&t(s),l=!u&&!h&&n(s),g=!u&&!h&&!l&&i(s),f=u||h||l||g,p=f?e(s.length,String):[],d=p.length;for(var m in s)!c&&!a.call(s,m)||f&&("length"==m||l&&("offset"==m||"parent"==m)||g&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||o(m,d))||p.push(m);return p}}function mo(){if($n)return Cn;return $n=1,Cn=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}}function vo(){if(jn)return Nn;jn=1;var e=xt(),t=Gr(),r=mo(),n=Object.prototype.hasOwnProperty;return Nn=function(o){if(!e(o))return r(o);var i=t(o),a=[];for(var s in o)("constructor"!=s||!i&&n.call(o,s))&&a.push(s);return a}}function yo(){if(On)return En;On=1;var e=po(),t=vo(),r=Vr();return En=function(n){return r(n)?e(n,!0):t(n)}}function bo(){if(Bn)return Tn;Bn=1;var e=lo(),t=yo();return Tn=function(r){return e(r,t(r))}}function wo(){if(An)return Sn;An=1;var e=Kt(),t=Tr(),r=Ar(),n=Lr(),o=qr(),i=zr(),a=Hr(),s=Jr(),c=sn(),u=Rt(),h=xt(),l=cn(),g=co(),f=uo(),p=bo();return Sn=function(d,m,v,y,b,w,x){var R=f(d,v),_=f(m,v),k=x.get(_);if(k)e(d,v,k);else{var P=w?w(R,_,v+"",d,m,x):void 0,C=void 0===P;if(C){var $=a(_),N=!$&&c(_),j=!$&&!N&&g(_);P=_,$||N||j?a(R)?P=R:s(R)?P=n(R):N?(C=!1,P=t(_,!0)):j?(C=!1,P=r(_,!0)):P=[]:l(_)||i(_)?(P=R,i(R)?P=p(R):h(R)&&!u(R)||(P=o(_))):C=!1}C&&(x.set(_,P),b(P,_,y,w,x),x.delete(_)),e(d,v,P)}}}function xo(){if(Un)return Ln;Un=1;var e=Dt(),t=Kt(),r=Qt(),n=wo(),o=xt(),i=yo(),a=uo();return Ln=function s(c,u,h,l,g){c!==u&&r(u,(function(r,i){if(g||(g=new e),o(r))n(c,u,i,h,s,l,g);else{var f=l?l(a(c,i),r,i+"",c,u,g):void 0;void 0===f&&(f=r),t(c,i,f)}}),i)},Ln}function Ro(){if(Wn)return Fn;return Wn=1,Fn=function(e){return e}}function _o(){if(qn)return Gn;return qn=1,Gn=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}}function ko(){if(In)return Mn;In=1;var e=_o(),t=Math.max;return Mn=function(r,n,o){return n=t(void 0===n?r.length-1:n,0),function(){for(var i=arguments,a=-1,s=t(i.length-n,0),c=Array(s);++a<s;)c[a]=i[n+a];a=-1;for(var u=Array(n+1);++a<n;)u[a]=i[a];return u[n]=o(c),e(r,this,u)}},Mn}function Po(){if(Hn)return zn;return Hn=1,zn=function(e){return function(){return e}}}function Co(){if(Vn)return Dn;Vn=1;var e=Po(),t=Vt();return Dn=t?function(r,n){return t(r,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:Ro()}function $o(){if(Kn)return Jn;Kn=1;var e=Date.now;return Jn=function(t){var r=0,n=0;return function(){var o=e(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}},Jn}function No(){if(Qn)return Yn;Qn=1;var e=Co(),t=$o()(e);return Yn=t}function jo(){if(Zn)return Xn;Zn=1;var e=Ro(),t=ko(),r=No();return Xn=function(n,o){return r(t(n,o,e),n+"")}}function Eo(){if(to)return eo;to=1;var e=ot(),t=Vr(),r=fo(),n=xt();return eo=function(o,i,a){if(!n(a))return!1;var s=typeof i;return!!("number"==s?t(a)&&r(i,a.length):"string"==s&&i in a)&&e(a[i],o)}}function Oo(){if(no)return ro;no=1;var e=jo(),t=Eo();return ro=function(r){return e((function(e,n){var o=-1,i=n.length,a=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(a=r.length>3&&"function"==typeof a?(i--,a):void 0,s&&t(n[0],n[1],s)&&(a=i<3?void 0:a,i=1),e=Object(e);++o<i;){var c=n[o];c&&r(e,c,o,a)}return e}))}}function To(){if(io)return oo;io=1;var e=xo(),t=Oo()((function(t,r,n){e(t,r,n)}));return oo=t}var Bo,So,Ao,Lo,Uo,Fo,Wo,Go,qo,Mo,Io,zo,Ho,Do,Vo,Jo,Ko,Yo,Qo,Xo,Zo,ei,ti,ri,ni=rt(To());function oi(){if(So)return Bo;So=1;var e=wt(),t=Mr();return Bo=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function ii(){if(Lo)return Ao;Lo=1;var e=Hr(),t=oi(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Ao=function(o,i){if(e(o))return!1;var a=typeof o;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=o&&!t(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function ai(){if(Fo)return Uo;Fo=1;var e=zt();function t(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var e=arguments,t=n?n.apply(this,e):e[0],i=o.cache;if(i.has(t))return i.get(t);var a=r.apply(this,e);return o.cache=i.set(t,a)||i,a};return o.cache=new(t.Cache||e),o}return t.Cache=e,Uo=t}function si(){if(Go)return Wo;Go=1;var e=ai();return Wo=function(t){var r=e(t,(function(e){return 500===n.size&&n.clear(),e})),n=r.cache;return r}}function ci(){if(Mo)return qo;Mo=1;var e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,r=si()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(e,(function(e,r,o,i){n.push(o?i.replace(t,"$1"):r||e)})),n}));return qo=r}function ui(){if(zo)return Io;return zo=1,Io=function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}}function hi(){if(Do)return Ho;Do=1;var e=vt(),t=ui(),r=Hr(),n=oi(),o=e?e.prototype:void 0,i=o?o.toString:void 0;return Ho=function e(o){if("string"==typeof o)return o;if(r(o))return t(o,e)+"";if(n(o))return i?i.call(o):"";var a=o+"";return"0"==a&&1/o==-1/0?"-0":a},Ho}function li(){if(Jo)return Vo;Jo=1;var e=hi();return Vo=function(t){return null==t?"":e(t)}}function gi(){if(Yo)return Ko;Yo=1;var e=Hr(),t=ii(),r=ci(),n=li();return Ko=function(o,i){return e(o)?o:t(o,i)?[o]:r(n(o))}}function fi(){if(Xo)return Qo;Xo=1;var e=oi();return Qo=function(t){if("string"==typeof t||e(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}}function pi(){if(ei)return Zo;ei=1;var e=gi(),t=fi();return Zo=function(r,n){for(var o=0,i=(n=e(n,r)).length;null!=r&&o<i;)r=r[t(n[o++])];return o&&o==i?r:void 0},Zo}function di(){if(ri)return ti;ri=1;var e=pi();return ti=function(t,r,n){var o=null==t?void 0:e(t,r);return void 0===o?n:o},ti}var mi=rt(di());const vi="package.json",yi=[".env.local",".env"];class bi extends ze.FeScriptContext{_env;shared;constructor(e){super(e),this._env=He.Env.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||yi}),this.shared=Object.assign({},this.feConfig.release,this.getDefaultShreadOptions(e.shared))}getDefaultShreadOptions(e){return{rootPath:process.cwd(),sourceBranch:this._env.get("FE_RELEASE_BRANCH")||this._env.get("FE_RELEASE_SOURCE_BRANCH")||"master",releaseEnv:this._env.get("FE_RELEASE_ENV")||this._env.get("NODE_ENV")||"development",...e}}get rootPath(){return this.shared.rootPath}get sourceBranch(){return this.shared.sourceBranch}get releaseEnv(){return this.shared.releaseEnv}get env(){return this._env}get workspaces(){return this.getConfig("workspaces.workspaces")}get workspace(){return this.getConfig("workspaces.workspace")}setWorkspaces(e){this.options.workspaces={...this.options.workspaces,workspaces:e}}setConfig(e){this.options=ni(this.options,e)}getConfig(e,t){return mi(this.options,e,t)}setShared(e){this.shared=ni(this.shared,e)}getPkg(e,t){const r=this.workspace?.packageJson;if(!r)throw new Error("package.json is not found");return e?mi(r,e,t):r}getTemplateContext(){return{...this.shared,...this.workspace,publishPath:this.workspace?.path||"",env:this.releaseEnv,branch:this.sourceBranch}}async runChangesetsCli(e,t){let r="pnpm";try{await this.shell.exec("pnpm -v",{dryRun:!1})}catch{r="npm"}return await this.shell.exec(["pnpm"===r?"pnpm dlx":"npx","@changesets/cli",e,...t??[]])}}function wi(e,...t){return[e,...t]}const xi={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${timestamp}-${releaseName}-${length}-packages"};class Ri{shell;logger;config;constructor(e,t,r={}){this.shell=e,this.logger=t,this.config={...xi,...r}}getReleaseBranchName(e,t,r){const n=r.branchName||"release-${tagName}";if("string"!=typeof n)throw new Error("Branch name template is not a string");return this.logger.verbose("Release Branch template is:",n),this.shell.format(n,{pkgName:e,releaseName:e,tagName:t,...r})}getBatchReleaseBranchName(e,t,r,n){const o=this.config.batchBranchName;if("string"!=typeof o)throw new Error("Branch name template is not a string");return this.logger.verbose("Release Batch Branch template is:",o),this.shell.format(o,{pkgName:e,releaseName:e,tagName:t,...r,length:n,timestamp:Date.now()})}getReleaseName(e){if(1===e.length)return e[0].name;const{maxWorkspace:t,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return e.slice(0,t).map((({name:e,version:t})=>`${e}${n}${t}`)).join(r)}getReleaseTagName(e){return 1===e.length?e[0].version:`batch-${e.length}-${(new Date).toISOString().split("T")[0]}`}getReleaseBranchParams(e,t){const r=this.getReleaseTagName(e),n=this.getReleaseName(e);return{tagName:r,releaseBranch:e.length>1?this.getBatchReleaseBranchName(n,r,t,e.length):this.getReleaseBranchName(n,r,t)}}getPRTitle(e,t){const r=this.config.PRTitle||"Release ${env} ${pkgName} ${tagName}";return this.shell.format(r,{...t,tagName:e.tagName,pkgName:e.releaseBranch})}getPRBody(e,t,r){const n=this.config.PRBody,o=e.length>1?e.map((e=>this.shell.format("\n## ${name} ${version}\n${changelog}\n",e))):e[0].changelog,{workspaceVersionSeparator:i}=this.config,a=1===e.length?t.tagName:e.map((e=>`${e.name}${i}${e.version}`)).join(" ");return this.shell.format(n,{...r,tagName:a,changelog:o})}}class _i{context;_octokit=null;constructor(e){this.context=e}getGitHubUserInfo(){const{authorName:e,repoName:t}=this.context.shared;if(!e||!t)throw new Error("Author name or repo name is not set");return{owner:e,repo:t}}getToken(){const{tokenRef:e="GITHUB_TOKEN"}=this.context.getConfig("githubPR"),t=this.context.env.get(e);if(!t)throw new Error(`Token is not set. Please set ${e} environment variable.`);return t}get octokit(){if(this._octokit)return this._octokit;const{timeout:e}=this.context.getConfig("githubPR"),t={auth:this.getToken(),request:{timeout:e}};return this._octokit=new Ve.Octokit(t),this._octokit}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.shared.autoMergeType||"squash"}get dryRunPRNumber(){return this.context.getConfig("githubPR.dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.shared.autoMergeReleasePR||false}async mergePR(e,t){if(!e)return void this.logger.error("Failed to create Pull Request.",e);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.context.shared;this.logger.info(`[DRY RUN] Would merge PR #${e} with method '${r}' in repo ${o}/${n}, branch ${t}`)}else await this.octokit.rest.pulls.merge({...this.getGitHubUserInfo(),pull_number:Number(e),merge_method:r})}async checkedPR(e,t){try{await this.octokit.rest.pulls.get({...this.getGitHubUserInfo(),pull_number:Number(e)}),await this.octokit.rest.git.deleteRef({...this.getGitHubUserInfo(),ref:`heads/${t}`}),this.logger.info(`Branch ${t} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${e} or branch ${t} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const e=this.context.shared.label;if(!(e&&e.name&&e.description&&e.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",e),e;try{const t=await this.octokit.rest.issues.createLabel({...this.getGitHubUserInfo(),name:e.name,description:e.description,color:e.color.replace("#","")});return this.logger.debug("Create PR label Success",t),e}catch(t){if(422===t.status)return this.logger.warn(`Label ${e.name} already exists, skipping!`),e;throw this.logger.error("Create PR label Failed",t),t}}async createReleasePR(e){if(this.context.getConfig("githubPR.dryRunCreatePR")||this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...e,labels:e.labels}),this.dryRunPRNumber;try{const t=await this.octokit.rest.pulls.create({...this.getGitHubUserInfo(),...e}),r=t.data.number;if(!r)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",[t?.url]),e.labels&&e.labels.length){const t=await this.octokit.rest.issues.addLabels({...this.getGitHubUserInfo(),issue_number:r,labels:e.labels});this.logger.debug("Add PR label Success",[t.url])}return r.toString()}catch(e){if(422===e.status&&e.message.includes("already exists")){this.logger.warn("PR already exists");const t=e.message.match(/pull request #(\d+)/);return t?t[1]:""}throw this.logger.error("Failed to create PR",e),e}}truncateBody(e){return e&&e.length>=124e3?e.substring(0,124e3)+"...":e}getOctokitReleaseOptions(e){const{releaseName:t,draft:r=!1,preRelease:n=!1,autoGenerate:o=!1,makeLatest:i=!0,releaseNotes:a,discussionCategoryName:s}=this.context.getConfig("githubPR"),c=t,u=o?"":this.truncateBody(String(a));return{name:c,make_latest:i.toString(),body:u,draft:r,prerelease:n,generate_release_notes:o,discussion_category_name:s,tag_name:"",...e,...this.getGitHubUserInfo()}}async createRelease(e){const t=this.getOctokitReleaseOptions({tag_name:e.tagName,body:e.changelog});if(t.name=this.shell.format(t.name,e),this.logger.exec(`octokit repos.createRelease "${t.name}" (${t.tag_name})`,{isDryRun:this.context.dryRun}),!t.tag_name)throw new Error("TagName is undefined");if(this.context.dryRun)return;const r=await this.octokit.repos.createRelease(t);this.logger.verbose(`octokit repos.createRelease: done (${r.headers.location})`)}}var ki,Pi;function Ci(){if(Pi)return ki;Pi=1;var e=wt(),t=Hr(),r=Mr();return ki=function(n){return"string"==typeof n||!t(n)&&r(n)&&"[object String]"==e(n)}}var $i=rt(Ci());class Ni{context;pluginName;props;onlyOne=!0;constructor(e,t,r={}){this.context=e,this.pluginName=t,this.props=r,this.setConfig(this.getInitialProps(r))}getInitialProps(e){const t=this.context.options[this.pluginName];return t||e?ni({},e,t):{}}get logger(){return this.context.logger}get shell(){return this.context.shell}get options(){return this.context.getConfig(this.pluginName,{})}getEnv(e,t){return this.context.env.get(e)??t}enabled(e,t){return!0}getConfig(e,t){return e?this.context.getConfig([this.pluginName,...Array.isArray(e)?e:[e]],t):this.context.getConfig(this.pluginName,t)}setConfig(e){this.context.setConfig({[this.pluginName]:e})}onBefore(e){}onExec(e){}onSuccess(e){}onError(e){}async step({label:e,task:t}){this.logger.obtrusive(e);try{const r=await t();return this.logger.info(`${e} - success`),r}catch(e){throw this.logger.error(e),e}}}class ji extends Ni{async onBefore(){const e=await this.getUserInfo();if(!e)throw new Error("Failed to get repoInfo");let t=this.context.shared.currentBranch;t||(t=await this.getCurrentBranch()),t&&await this.context.shell.exec(`git checkout ${t}`,{dryRun:!1}),this.context.setShared({repoName:e.repoName,authorName:e.authorName,currentBranch:t})}async getCurrentBranch(){return await new Promise((e=>setTimeout(e,100))),this.context.shell.exec("git rev-parse --abbrev-ref HEAD",{dryRun:!1})}async getRemoteUrl(){return(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}async getUserInfo(){let e;try{e=await this.getRemoteUrl()}catch{throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!e)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.verbose("repoUrl: ",e);const t=e.match(/github\.com[:/]([^/]+)\/([^/.]+)(?:\.git)?$/);if(!t)throw new Error("Invalid GitHub repository URL format. Please ensure the remote URL is from GitHub.");const[,r,n]=t;if(!this.isValidString(r)||!this.isValidString(n))throw new Error("Failed to extract owner or repository name from GitHub URL");return{repoName:n,authorName:r}}isValidString(e){return!!e&&$i(e)}commit(e,t=[]){return this.context.shell.exec(["git","commit","--message",JSON.stringify(e),...t])}}class Ei{options;constructor(e){this.options=e}compare(e,t){return"function"==typeof this.options.compare?this.options.compare(e,t):e.startsWith(t)}toChangeLabel(e,t=this.options.changePackagesLabel){return t.replace("${name}",e)}toChangeLabels(e,t=this.options.changePackagesLabel){return e.map((e=>this.toChangeLabel(e,t)))}pick(e,t=this.options.packagesDirectories){const r=[];for(const n of t)for(const t of e)if(this.compare(t,n)){r.push(n);break}return r}}class Oi{static readJson(e){const t=Ke.readFileSync(e,"utf-8");return JSON.parse(t)}static toWorkspace(e,t){let{root:r,packageJson:n}=e;const o=e.path;if(!o)throw new Error("path is not required!");return r=r||Ye.join(t,o),n=n||Oi.readJson(Ye.join(r,vi)),{name:n.name,version:n.version,path:o,root:r,packageJson:n}}}class Ti extends Ni{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(e){super(e,"workspaces"),this.releaseLabel=new Ei({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[]})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){const e=this.getConfig("workspace");if(e)return this.logger.debug("Use the specified workspace",e),void this.setCurrentWorkspace(e,[]);const t=await this.getWorkspaces();if(this.getConfig("skipCheckPackage")||0===t.length)throw new Error("No changes to publish packages");const{publishPath:r}=this.context.shared;if(r){const e=t.find((e=>Je.resolve(e.root)===Je.resolve(r)));if(this.nextSkip(),!e)throw new Error(`No workspace found for: ${r}`);return this.logger.debug(`Workspace of ${r} find!`,Je.join(e.root,vi)),void this.setCurrentWorkspace(e,[e])}const[n,...o]=t;this.workspacesList=o,this.setCurrentWorkspace(n,t)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}setReleaseTask(e){this.releaseTask=e}setCurrentWorkspace(e,t){this.context.setShared({publishPath:e.path}),this.setConfig({workspace:e,workspaces:t})}getPackages(){const e=this.context.shared.packagesDirectories;return Array.isArray(e)?e:[]}async getGitWorkspaces(){const e=this.context.sourceBranch,t=await this.shell.exec(`git diff --name-only origin/${e}...HEAD`,{dryRun:!1});return"string"==typeof t?t.split("\n"):[]}async getChangedPackages(e,t){if(this.logger.debug("changeLabels",t),Array.isArray(t)&&t.length>0){const r=e.filter((e=>{const r=this.releaseLabel.toChangeLabel(e);return t.includes(r)}));return this.logger.debug("changed by labels",r),r}const r=await this.getGitWorkspaces();return this.logger.debug("changed by git",r),this.releaseLabel.pick(r,e)}async getWorkspaces(){const e=this.getPackages();this.logger.debug("packages",e);const t=await this.getChangedPackages(e,this.getConfig("changeLabels"));this.logger.debug("changedPaths",t);const r=t.map((e=>Oi.toWorkspace({path:e},this.context.rootPath)));return r}}function Bi(e,...t){return"function"==typeof e&&e.prototype&&e.prototype.constructor===e?new e(...t):e(...t)}function Si(e){return e.startsWith(".")?Je.parse(e).name:e}async function Ai(e){let t=null;try{t=(await import(e)).default}catch{try{t=(await import(Je.join(process.cwd(),e))).default}catch{const r=Qe.createRequire(process.cwd());t=(await import(Xe.pathToFileURL(r.resolve(e,{paths:[process.cwd()]})).href)).default}}return[Si(e),t]}async function Li(e,t,r=5){const n=Ze(r),o=t.map((([t,...r])=>n((()=>(async(t,...r)=>{if("string"==typeof t){const[,n]=await Ai(t);return Bi(n,e,...r)}return Bi(t,e,...r)})(t,...r)))));return Promise.all(o)}const Ui={name:"angular",types:[{type:"feat",section:"✨ Features",hidden:!1},{type:"fix",section:"🐞 Bug Fixes",hidden:!1},{type:"chore",section:"🔧 Chores",hidden:!1},{type:"docs",section:"📝 Documentation",hidden:!1},{type:"refactor",section:"♻️ Refactors",hidden:!1},{type:"perf",section:"🚀 Performance",hidden:!1},{type:"test",section:"🚨 Tests",hidden:!1},{type:"style",section:"🎨 Styles",hidden:!1},{type:"ci",section:"🔄 CI",hidden:!1},{type:"build",section:"🚧 Build",hidden:!1},{type:"revert",section:"⏪ Reverts",hidden:!1},{type:"release",section:"🔖 Releases",hidden:!1}]};const Fi=[wi(Ti),wi(class extends Ni{constructor(e,t){super(e,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...t})}get changesetRoot(){return Ye.join(this.context.rootPath,this.getConfig("changesetRoot"))}enabled(){return!this.getConfig("skip")}async onBefore(){if(!Ke.existsSync(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}mergeWorkspaces(e){return e.map((e=>{const t=Oi.toWorkspace({path:e.path},this.context.rootPath),r={...e,version:t.version};return r.tagName=this.generateTagName(r),r}))}async onExec(){const e=await this.step({label:"Generate Changelogs",task:()=>Promise.all(this.context.workspaces.map((e=>this.generateChangelog(e))))});this.getConfig("skipChangeset")?this.logger.debug("Skip generate changeset files"):(await this.step({label:"Changeset Version",task:()=>Promise.all(e.map((e=>this.generateChangesetFile(e))))}),await this.context.runChangesetsCli("version",["--no-changelog"]));const t=this.mergeWorkspaces(e);this.logger.debug("new workspaces",t),this.context.setWorkspaces(t)}getTagPrefix(e){return this.shell.format(this.getConfig("tagPrefix"),e)}async createChangelog({lastTag:e,workspace:t}){const r={releaseCount:1,tagPrefix:this.getTagPrefix(t),warn:this.logger.warn.bind(this.logger),preset:Ui.name},n={version:t.version};let o=e;try{await this.shell.exec(`git rev-parse --verify --quiet "refs/tags/${e}"`,{dryRun:!1}),this.logger.verbose(`Tag '${e}' found for workspace '${t.name}'. Using it as the starting point.`)}catch{this.logger.warn(`Tag '${e}' not found for workspace '${t.name}'. Will generate changelog using commits within path '${t.path}' from the beginning of history or latest available tag.`),o=void 0}const i={debug:this.logger.debug.bind(this.logger),from:o,reverse:!0,path:t.path},a={},s={headerPartial:""};return this.logger.debug("options",r),this.logger.debug("context",n),this.logger.debug("gitRawCommitsOpts",i),new Promise(((e,c)=>{let u="";const h=et(r,n,i,a,s);h.on("data",(e=>{u+=e.toString()})),h.on("error",(e=>{this.logger.error(`Error during conventional-changelog stream for workspace '${t.name}':`,e),c(new Error(`Failed to generate changelog for ${t.name}: ${e.message}`))})),h.on("end",(()=>{!u&&o?this.logger.warn(`No commits found for workspace '${t.name}' since tag '${o}' within path '${t.path}'. Changelog will be empty.`):u||this.logger.info(`No commits found for workspace '${t.name}' within path '${t.path}'. Changelog will be empty.`),e(this.tranformChangelog(u,Ui.types))}))}))}tranformChangelog(e,t){return e}async generateChangelog(e){const t=await this.getTagName(e);this.logger.verbose("tagName is:",t);const r=await this.createChangelog({workspace:e,lastTag:t});return{...e,lastTag:t,changelog:r}}generateTagName(e){try{const t=this.getConfig("tagTemplate");return this.shell.format(t,e)}catch(t){return console.error(`Error generating tag name for ${e.name}:`,t),`${e.name}-v0.0.0`}}async getTagName(e){try{const t=this.generateTagName(e),r=this.shell.format(this.getConfig("tagMatch"),e),n=await this.shell.exec(`git for-each-ref --sort=-creatordate --format "%(refname:short)|%(creatordate:iso8601)" "refs/tags/${r}"`,{dryRun:!1});if(this.logger.debug("tagsOutput",n),!n)return t;const o=n.split("\n").filter(Boolean);if(0===o.length)return t;return o[0].split("|")[0]}catch(t){console.error(`Error getting tag for ${e.name}:`,t);return this.generateTagName(e)}}getIncrement(){const e=this.context.getConfig("workspaces.changeLabels");if(Array.isArray(e)&&e.length>0){if(e.includes("increment:major"))return"major";if(e.includes("increment:minor"))return"minor"}return this.getConfig("increment","patch")}async generateChangesetFile(e){const{name:t,version:r}=e,n=`${t}-${r}`.replace(/[\/\\]/g,"_"),o=Ye.join(this.changesetRoot,`${n}.md`),i=this.getIncrement();this.logger.verbose("increment is:",[i]);const a=this.shell.format("---\n'${name}': '${increment}'\n---\n${changelog}",{...e,increment:i});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(a);Ke.existsSync(o)?this.logger.info(`Changeset ${n} already exists`):Ke.writeFileSync(o,a,"utf-8")}},{}),wi(class extends ji{context;releaseParams;githubManager;constructor(e,t){super(e,"githubPR",{releaseName:"Release ${name} v${version}",...t}),this.context=e,this.githubManager=new _i(this.context),this.releaseParams=new Ri(e.shell,e.logger,{PRTitle:this.getConfig("PRTitle",this.context.shared.PRTitle),PRBody:this.getConfig("PRBody",this.context.shared.PRBody),...this.props})}enabled(e){return!this.getConfig("skip")&&("onExec"===e?!this.isPublish:"onSuccess"!==e||this.isPublish)}get isPublish(){return!this.getConfig("releasePR")}async isGithubRepository(){try{return(await this.getRemoteUrl()).includes("github.com")}catch{return!1}}async onBefore(){this.logger.verbose("GithubPR onBefore");if(!await this.isGithubRepository())throw new Error("Current repository is not a GitHub repository. GitHub PR workflow is only available for GitHub repositories.");if(await super.onBefore(),this.isPublish){const e=this.getEnv("NPM_TOKEN");if(!e)throw new Error("NPM_TOKEN is not set");await this.shell.exec(`npm config set //registry.npmjs.org/:_authToken=${e}`)}}async onExec(){const e=this.context.workspaces;await this.step({label:"Release Commit",task:()=>this.relesaeCommit(e)});const t=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(e)});await this.releasePullRequest(e,t)}async onSuccess(){const e=this.context.workspaces;this.getConfig("dryRunCreatePR")||(await this.context.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags")),await this.step({label:"Release Github",task:()=>Promise.all(e.map((e=>(this.logger.debug(e),this.githubManager.createRelease(e)))))})}async relesaeCommit(e){const t=this.getConfig("commitArgs",[]);if(1===e.length)return await this.shell.exec("git add ."),void await this.commitWorkspace(e[0],t);await this.shell.exec("git add .");const r=`chore(tag): ${e.map((e=>`${e.name} v${e.version}`)).join(",")}`;await this.commit(r,t)}async releasePullRequest(e,t){const r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(e,t)});if(this.githubManager.autoMergeReleasePR){const{releaseBranch:e}=t;return await this.step({label:`Merge Release PR(${r})`,task:()=>this.githubManager.mergePR(r,e)}),void await this.step({label:`Checked Release PR(${r})`,task:()=>this.githubManager.checkedPR(r,e)})}this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async commitWorkspace(e,t=[]){const r=this.shell.format(this.getConfig("commitMessage","chore(tag): ${name} v${version}"),e);return await this.commit(r,t)}async createReleaseBranch(e){const t=this.releaseParams.getReleaseBranchParams(e,this.context.getTemplateContext()),{tagName:r,releaseBranch:n}=t;if("string"!=typeof r)throw new Error("Tag name is not a string");const{sourceBranch:o,currentBranch:i}=this.context.shared;this.context.logger.verbose("PR TagName is:",r),this.context.logger.verbose("PR CurrentBranch is:",i),this.context.logger.verbose("PR SourceBranch is:",o),this.context.logger.verbose("PR ReleaseBranch is:",n);try{await this.context.shell.exec(`git fetch origin ${o} ${i}`),await this.context.shell.exec(`git checkout -b ${n} ${i}`),await this.context.shell.exec(`git push origin ${n}`)}catch(e){throw e.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),e}return{tagName:r,releaseBranch:n}}async createReleasePR(e,t){const r=[(await this.githubManager.createReleasePRLabel()).name],n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(t,n),i=this.releaseParams.getPRBody(e,t,n);return this.githubManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:t.releaseBranch,labels:r})}},{})];var Wi,Gi,qi,Mi;function Ii(){if(Gi)return Wi;Gi=1;var e=ho(),t=gi(),r=fo(),n=xt(),o=fi();return Wi=function(i,a,s,c){if(!n(i))return i;for(var u=-1,h=(a=t(a,i)).length,l=h-1,g=i;null!=g&&++u<h;){var f=o(a[u]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)return i;if(u!=l){var d=g[f];void 0===(p=c?c(d,f,g):void 0)&&(p=n(d)?d:r(a[u+1])?[]:{})}e(g,f,p),g=g[f]}return i},Wi}function zi(){if(Mi)return qi;Mi=1;var e=Ii();return qi=function(t,r,n){return null==t?t:e(t,r,n)},qi}var Hi=rt(zi());exports.Plugin=Ni,exports.ReleaseContext=bi,exports.ReleaseLabel=Ei,exports.ReleaseTask=class{executor;defaultTuples;context;constructor(e={},t=new De.AsyncExecutor,r=Fi){this.executor=t,this.defaultTuples=r,this.context=new bi(e)}getContext(){return this.context}async usePlugins(e){e=e||this.context.shared.plugins||[];const t=await Li(this.context,[...this.defaultTuples,...e]);return t.forEach((e=>{e instanceof Ti&&e.setReleaseTask(this),this.executor.use(e)})),t}async run(){return this.executor.exec(this.context,(e=>Promise.resolve(e)))}async exec(e){if("false"===this.context.env.get("FE_RELEASE"))throw new Error("Skip Release");return await this.usePlugins(e),this.run()}},exports.factory=Bi,exports.load=Ai,exports.loaderPluginsFromPluginTuples=Li,exports.reduceOptions=function(e,t){return Object.entries(e).reduce(((e,[r,n])=>(r.includes(".")?Hi(e,r,n):Hi(e,t?`${t}.${r}`:r,n),e)),{})},exports.tuple=wi;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FeScriptContext as e}from"@qlover/scripts-context";import{Env as t}from"@qlover/env-loader";import{AsyncExecutor as r}from"@qlover/fe-corekit";import{Octokit as n}from"@octokit/rest";import{resolve as o,join as i,parse as a}from"node:path";import{readFileSync as s,existsSync as c,writeFileSync as u}from"fs";import{join as h}from"path";import{createRequire as l}from"node:module";import{pathToFileURL as f}from"node:url";import g from"p-limit";import p from"conventional-changelog";var d,m,v,y,b,w,R,_,x,k,P,C,$,N,j,E,B,O,T,S,A,L,U,W,F,G,M,I,z,D,H,q,V,J,K,Y,Q,X,Z,ee,te,re,ne,oe,ie,ae,se,ce,ue,he,le,fe,ge,pe,de,me,ve,ye,be,we,Re,_e,xe,ke,Pe,Ce,$e,Ne,je,Ee,Be,Oe,Te,Se,Ae,Le,Ue,We,Fe,Ge,Me,Ie,ze,De,He,qe,Ve,Je,Ke,Ye,Qe,Xe,Ze,et,tt,rt,nt,ot,it="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function at(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function st(){if(m)return d;return m=1,d=function(){this.__data__=[],this.size=0}}function ct(){if(y)return v;return y=1,v=function(e,t){return e===t||e!=e&&t!=t}}function ut(){if(w)return b;w=1;var e=ct();return b=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function ht(){if(_)return R;_=1;var e=ut(),t=Array.prototype.splice;return R=function(r){var n=this.__data__,o=e(n,r);return!(o<0)&&(o==n.length-1?n.pop():t.call(n,o,1),--this.size,!0)}}function lt(){if(k)return x;k=1;var e=ut();return x=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}function ft(){if(C)return P;C=1;var e=ut();return P=function(t){return e(this.__data__,t)>-1}}function gt(){if(N)return $;N=1;var e=ut();return $=function(t,r){var n=this.__data__,o=e(n,t);return o<0?(++this.size,n.push([t,r])):n[o][1]=r,this}}function pt(){if(E)return j;E=1;var e=st(),t=ht(),r=lt(),n=ft(),o=gt();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,j=i}function dt(){if(O)return B;O=1;var e=pt();return B=function(){this.__data__=new e,this.size=0}}function mt(){if(S)return T;return S=1,T=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}}function vt(){if(L)return A;return L=1,A=function(e){return this.__data__.get(e)}}function yt(){if(W)return U;return W=1,U=function(e){return this.__data__.has(e)}}function bt(){if(G)return F;G=1;var e="object"==typeof it&&it&&it.Object===Object&⁢return F=e}function wt(){if(I)return M;I=1;var e=bt(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return M=r}function Rt(){if(D)return z;D=1;var e=wt().Symbol;return z=e}function _t(){if(q)return H;q=1;var e=Rt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,o=e?e.toStringTag:void 0;return H=function(e){var t=r.call(e,o),i=e[o];try{e[o]=void 0;var a=!0}catch(e){}var s=n.call(e);return a&&(t?e[o]=i:delete e[o]),s}}function xt(){if(J)return V;J=1;var e=Object.prototype.toString;return V=function(t){return e.call(t)}}function kt(){if(Y)return K;Y=1;var e=Rt(),t=_t(),r=xt(),n=e?e.toStringTag:void 0;return K=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):r(e)}}function Pt(){if(X)return Q;return X=1,Q=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function Ct(){if(ee)return Z;ee=1;var e=kt(),t=Pt();return Z=function(r){if(!t(r))return!1;var n=e(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function $t(){if(re)return te;re=1;var e=wt()["__core-js_shared__"];return te=e}function Nt(){if(oe)return ne;oe=1;var e,t=$t(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return ne=function(e){return!!r&&r in e}}function jt(){if(ae)return ie;ae=1;var e=Function.prototype.toString;return ie=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}function Et(){if(ce)return se;ce=1;var e=Ct(),t=Nt(),r=Pt(),n=jt(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,a=Object.prototype,s=i.toString,c=a.hasOwnProperty,u=RegExp("^"+s.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return se=function(i){return!(!r(i)||t(i))&&(e(i)?u:o).test(n(i))}}function Bt(){if(he)return ue;return he=1,ue=function(e,t){return null==e?void 0:e[t]}}function Ot(){if(fe)return le;fe=1;var e=Et(),t=Bt();return le=function(r,n){var o=t(r,n);return e(o)?o:void 0}}function Tt(){if(pe)return ge;pe=1;var e=Ot()(wt(),"Map");return ge=e}function St(){if(me)return de;me=1;var e=Ot()(Object,"create");return de=e}function At(){if(ye)return ve;ye=1;var e=St();return ve=function(){this.__data__=e?e(null):{},this.size=0}}function Lt(){if(we)return be;return we=1,be=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}}function Ut(){if(_e)return Re;_e=1;var e=St(),t=Object.prototype.hasOwnProperty;return Re=function(r){var n=this.__data__;if(e){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return t.call(n,r)?n[r]:void 0}}function Wt(){if(ke)return xe;ke=1;var e=St(),t=Object.prototype.hasOwnProperty;return xe=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}function Ft(){if(Ce)return Pe;Ce=1;var e=St();return Pe=function(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===r?"__lodash_hash_undefined__":r,this}}function Gt(){if(Ne)return $e;Ne=1;var e=At(),t=Lt(),r=Ut(),n=Wt(),o=Ft();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,$e=i}function Mt(){if(Ee)return je;Ee=1;var e=Gt(),t=pt(),r=Tt();return je=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}function It(){if(Oe)return Be;return Oe=1,Be=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}}function zt(){if(Se)return Te;Se=1;var e=It();return Te=function(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Dt(){if(Le)return Ae;Le=1;var e=zt();return Ae=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}function Ht(){if(We)return Ue;We=1;var e=zt();return Ue=function(t){return e(this,t).get(t)}}function qt(){if(Ge)return Fe;Ge=1;var e=zt();return Fe=function(t){return e(this,t).has(t)}}function Vt(){if(Ie)return Me;Ie=1;var e=zt();return Me=function(t,r){var n=e(this,t),o=n.size;return n.set(t,r),this.size+=n.size==o?0:1,this}}function Jt(){if(De)return ze;De=1;var e=Mt(),t=Dt(),r=Ht(),n=qt(),o=Vt();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,ze=i}function Kt(){if(qe)return He;qe=1;var e=pt(),t=Tt(),r=Jt();return He=function(n,o){var i=this.__data__;if(i instanceof e){var a=i.__data__;if(!t||a.length<199)return a.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(a)}return i.set(n,o),this.size=i.size,this}}function Yt(){if(Je)return Ve;Je=1;var e=pt(),t=dt(),r=mt(),n=vt(),o=yt(),i=Kt();function a(t){var r=this.__data__=new e(t);this.size=r.size}return a.prototype.clear=t,a.prototype.delete=r,a.prototype.get=n,a.prototype.has=o,a.prototype.set=i,Ve=a}function Qt(){if(Ye)return Ke;Ye=1;var e=Ot(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return Ke=t}function Xt(){if(Xe)return Qe;Xe=1;var e=Qt();return Qe=function(t,r,n){"__proto__"==r&&e?e(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}}function Zt(){if(et)return Ze;et=1;var e=Xt(),t=ct();return Ze=function(r,n,o){(void 0!==o&&!t(r[n],o)||void 0===o&&!(n in r))&&e(r,n,o)}}function er(){if(rt)return tt;return rt=1,tt=function(e){return function(t,r,n){for(var o=-1,i=Object(t),a=n(t),s=a.length;s--;){var c=a[e?s:++o];if(!1===r(i[c],c,i))break}return t}}}function tr(){if(ot)return nt;ot=1;var e=er()();return nt=e}var rr,nr,or,ir,ar,sr,cr,ur,hr,lr,fr,gr,pr,dr,mr,vr,yr,br,wr,Rr,_r,xr,kr,Pr,Cr,$r,Nr,jr,Er,Br,Or,Tr,Sr,Ar={exports:{}};function Lr(){return rr||(rr=1,e=Ar,t=Ar.exports,r=wt(),n=t&&!t.nodeType&&t,o=n&&e&&!e.nodeType&&e,i=o&&o.exports===n?r.Buffer:void 0,a=i?i.allocUnsafe:void 0,e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=a?a(r):new e.constructor(r);return e.copy(n),n}),Ar.exports;var e,t,r,n,o,i,a}function Ur(){if(or)return nr;or=1;var e=wt().Uint8Array;return nr=e}function Wr(){if(ar)return ir;ar=1;var e=Ur();return ir=function(t){var r=new t.constructor(t.byteLength);return new e(r).set(new e(t)),r}}function Fr(){if(cr)return sr;cr=1;var e=Wr();return sr=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}function Gr(){if(hr)return ur;return hr=1,ur=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}}function Mr(){if(fr)return lr;fr=1;var e=Pt(),t=Object.create,r=function(){function r(){}return function(n){if(!e(n))return{};if(t)return t(n);r.prototype=n;var o=new r;return r.prototype=void 0,o}}();return lr=r}function Ir(){if(pr)return gr;return pr=1,gr=function(e,t){return function(r){return e(t(r))}}}function zr(){if(mr)return dr;mr=1;var e=Ir()(Object.getPrototypeOf,Object);return dr=e}function Dr(){if(yr)return vr;yr=1;var e=Object.prototype;return vr=function(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}}function Hr(){if(wr)return br;wr=1;var e=Mr(),t=zr(),r=Dr();return br=function(n){return"function"!=typeof n.constructor||r(n)?{}:e(t(n))}}function qr(){if(_r)return Rr;return _r=1,Rr=function(e){return null!=e&&"object"==typeof e}}function Vr(){if(kr)return xr;kr=1;var e=kt(),t=qr();return xr=function(r){return t(r)&&"[object Arguments]"==e(r)}}function Jr(){if(Cr)return Pr;Cr=1;var e=Vr(),t=qr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=e(function(){return arguments}())?e:function(e){return t(e)&&n.call(e,"callee")&&!o.call(e,"callee")};return Pr=i}function Kr(){if(Nr)return $r;Nr=1;var e=Array.isArray;return $r=e}function Yr(){if(Er)return jr;Er=1;return jr=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function Qr(){if(Or)return Br;Or=1;var e=Ct(),t=Yr();return Br=function(r){return null!=r&&t(r.length)&&!e(r)}}function Xr(){if(Sr)return Tr;Sr=1;var e=Qr(),t=qr();return Tr=function(r){return t(r)&&e(r)}}var Zr,en,tn,rn,nn,on,an,sn,cn,un={exports:{}};function hn(){if(en)return Zr;return en=1,Zr=function(){return!1}}function ln(){return tn||(tn=1,function(e,t){var r=wt(),n=hn(),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,a=i&&i.exports===o?r.Buffer:void 0,s=(a?a.isBuffer:void 0)||n;e.exports=s}(un,un.exports)),un.exports}function fn(){if(nn)return rn;nn=1;var e=kt(),t=zr(),r=qr(),n=Function.prototype,o=Object.prototype,i=n.toString,a=o.hasOwnProperty,s=i.call(Object);return rn=function(n){if(!r(n)||"[object Object]"!=e(n))return!1;var o=t(n);if(null===o)return!0;var c=a.call(o,"constructor")&&o.constructor;return"function"==typeof c&&c instanceof c&&i.call(c)==s}}function gn(){if(an)return on;an=1;var e=kt(),t=Yr(),r=qr(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,on=function(o){return r(o)&&t(o.length)&&!!n[e(o)]}}function pn(){if(cn)return sn;return cn=1,sn=function(e){return function(t){return e(t)}}}var dn,mn,vn,yn,bn,wn,Rn,_n,xn,kn,Pn,Cn,$n,Nn,jn,En,Bn,On,Tn,Sn,An,Ln,Un,Wn,Fn,Gn,Mn,In,zn,Dn,Hn,qn,Vn,Jn,Kn,Yn,Qn,Xn,Zn,eo,to,ro,no,oo,io,ao,so,co,uo,ho={exports:{}};function lo(){return dn||(dn=1,e=ho,t=ho.exports,r=bt(),n=t&&!t.nodeType&&t,o=n&&e&&!e.nodeType&&e,i=o&&o.exports===n&&r.process,a=function(){try{var e=o&&o.require&&o.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}(),e.exports=a),ho.exports;var e,t,r,n,o,i,a}function fo(){if(vn)return mn;vn=1;var e=gn(),t=pn(),r=lo(),n=r&&r.isTypedArray,o=n?t(n):e;return mn=o}function go(){if(bn)return yn;return bn=1,yn=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function po(){if(Rn)return wn;Rn=1;var e=Xt(),t=ct(),r=Object.prototype.hasOwnProperty;return wn=function(n,o,i){var a=n[o];r.call(n,o)&&t(a,i)&&(void 0!==i||o in n)||e(n,o,i)}}function mo(){if(xn)return _n;xn=1;var e=po(),t=Xt();return _n=function(r,n,o,i){var a=!o;o||(o={});for(var s=-1,c=n.length;++s<c;){var u=n[s],h=i?i(o[u],r[u],u,o,r):void 0;void 0===h&&(h=r[u]),a?t(o,u,h):e(o,u,h)}return o}}function vo(){if(Pn)return kn;return Pn=1,kn=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}}function yo(){if($n)return Cn;$n=1;var e=/^(?:0|[1-9]\d*)$/;return Cn=function(t,r){var n=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<r}}function bo(){if(jn)return Nn;jn=1;var e=vo(),t=Jr(),r=Kr(),n=ln(),o=yo(),i=fo(),a=Object.prototype.hasOwnProperty;return Nn=function(s,c){var u=r(s),h=!u&&t(s),l=!u&&!h&&n(s),f=!u&&!h&&!l&&i(s),g=u||h||l||f,p=g?e(s.length,String):[],d=p.length;for(var m in s)!c&&!a.call(s,m)||g&&("length"==m||l&&("offset"==m||"parent"==m)||f&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||o(m,d))||p.push(m);return p}}function wo(){if(Bn)return En;return Bn=1,En=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}}function Ro(){if(Tn)return On;Tn=1;var e=Pt(),t=Dr(),r=wo(),n=Object.prototype.hasOwnProperty;return On=function(o){if(!e(o))return r(o);var i=t(o),a=[];for(var s in o)("constructor"!=s||!i&&n.call(o,s))&&a.push(s);return a}}function _o(){if(An)return Sn;An=1;var e=bo(),t=Ro(),r=Qr();return Sn=function(n){return r(n)?e(n,!0):t(n)}}function xo(){if(Un)return Ln;Un=1;var e=mo(),t=_o();return Ln=function(r){return e(r,t(r))}}function ko(){if(Fn)return Wn;Fn=1;var e=Zt(),t=Lr(),r=Fr(),n=Gr(),o=Hr(),i=Jr(),a=Kr(),s=Xr(),c=ln(),u=Ct(),h=Pt(),l=fn(),f=fo(),g=go(),p=xo();return Wn=function(d,m,v,y,b,w,R){var _=g(d,v),x=g(m,v),k=R.get(x);if(k)e(d,v,k);else{var P=w?w(_,x,v+"",d,m,R):void 0,C=void 0===P;if(C){var $=a(x),N=!$&&c(x),j=!$&&!N&&f(x);P=x,$||N||j?a(_)?P=_:s(_)?P=n(_):N?(C=!1,P=t(x,!0)):j?(C=!1,P=r(x,!0)):P=[]:l(x)||i(x)?(P=_,i(_)?P=p(_):h(_)&&!u(_)||(P=o(x))):C=!1}C&&(R.set(x,P),b(P,x,y,w,R),R.delete(x)),e(d,v,P)}}}function Po(){if(Mn)return Gn;Mn=1;var e=Yt(),t=Zt(),r=tr(),n=ko(),o=Pt(),i=_o(),a=go();return Gn=function s(c,u,h,l,f){c!==u&&r(u,(function(r,i){if(f||(f=new e),o(r))n(c,u,i,h,s,l,f);else{var g=l?l(a(c,i),r,i+"",c,u,f):void 0;void 0===g&&(g=r),t(c,i,g)}}),i)},Gn}function Co(){if(zn)return In;return zn=1,In=function(e){return e}}function $o(){if(Hn)return Dn;return Hn=1,Dn=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}}function No(){if(Vn)return qn;Vn=1;var e=$o(),t=Math.max;return qn=function(r,n,o){return n=t(void 0===n?r.length-1:n,0),function(){for(var i=arguments,a=-1,s=t(i.length-n,0),c=Array(s);++a<s;)c[a]=i[n+a];a=-1;for(var u=Array(n+1);++a<n;)u[a]=i[a];return u[n]=o(c),e(r,this,u)}},qn}function jo(){if(Kn)return Jn;return Kn=1,Jn=function(e){return function(){return e}}}function Eo(){if(Qn)return Yn;Qn=1;var e=jo(),t=Qt();return Yn=t?function(r,n){return t(r,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:Co()}function Bo(){if(Zn)return Xn;Zn=1;var e=Date.now;return Xn=function(t){var r=0,n=0;return function(){var o=e(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}},Xn}function Oo(){if(to)return eo;to=1;var e=Eo(),t=Bo()(e);return eo=t}function To(){if(no)return ro;no=1;var e=Co(),t=No(),r=Oo();return ro=function(n,o){return r(t(n,o,e),n+"")}}function So(){if(io)return oo;io=1;var e=ct(),t=Qr(),r=yo(),n=Pt();return oo=function(o,i,a){if(!n(a))return!1;var s=typeof i;return!!("number"==s?t(a)&&r(i,a.length):"string"==s&&i in a)&&e(a[i],o)}}function Ao(){if(so)return ao;so=1;var e=To(),t=So();return ao=function(r){return e((function(e,n){var o=-1,i=n.length,a=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(a=r.length>3&&"function"==typeof a?(i--,a):void 0,s&&t(n[0],n[1],s)&&(a=i<3?void 0:a,i=1),e=Object(e);++o<i;){var c=n[o];c&&r(e,c,o,a)}return e}))}}function Lo(){if(uo)return co;uo=1;var e=Po(),t=Ao()((function(t,r,n){e(t,r,n)}));return co=t}var Uo,Wo,Fo,Go,Mo,Io,zo,Do,Ho,qo,Vo,Jo,Ko,Yo,Qo,Xo,Zo,ei,ti,ri,ni,oi,ii,ai,si=at(Lo());function ci(){if(Wo)return Uo;Wo=1;var e=kt(),t=qr();return Uo=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function ui(){if(Go)return Fo;Go=1;var e=Kr(),t=ci(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Fo=function(o,i){if(e(o))return!1;var a=typeof o;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=o&&!t(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function hi(){if(Io)return Mo;Io=1;var e=Jt();function t(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var e=arguments,t=n?n.apply(this,e):e[0],i=o.cache;if(i.has(t))return i.get(t);var a=r.apply(this,e);return o.cache=i.set(t,a)||i,a};return o.cache=new(t.Cache||e),o}return t.Cache=e,Mo=t}function li(){if(Do)return zo;Do=1;var e=hi();return zo=function(t){var r=e(t,(function(e){return 500===n.size&&n.clear(),e})),n=r.cache;return r}}function fi(){if(qo)return Ho;qo=1;var e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,r=li()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(e,(function(e,r,o,i){n.push(o?i.replace(t,"$1"):r||e)})),n}));return Ho=r}function gi(){if(Jo)return Vo;return Jo=1,Vo=function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}}function pi(){if(Yo)return Ko;Yo=1;var e=Rt(),t=gi(),r=Kr(),n=ci(),o=e?e.prototype:void 0,i=o?o.toString:void 0;return Ko=function e(o){if("string"==typeof o)return o;if(r(o))return t(o,e)+"";if(n(o))return i?i.call(o):"";var a=o+"";return"0"==a&&1/o==-1/0?"-0":a},Ko}function di(){if(Xo)return Qo;Xo=1;var e=pi();return Qo=function(t){return null==t?"":e(t)}}function mi(){if(ei)return Zo;ei=1;var e=Kr(),t=ui(),r=fi(),n=di();return Zo=function(o,i){return e(o)?o:t(o,i)?[o]:r(n(o))}}function vi(){if(ri)return ti;ri=1;var e=ci();return ti=function(t){if("string"==typeof t||e(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}}function yi(){if(oi)return ni;oi=1;var e=mi(),t=vi();return ni=function(r,n){for(var o=0,i=(n=e(n,r)).length;null!=r&&o<i;)r=r[t(n[o++])];return o&&o==i?r:void 0}}function bi(){if(ai)return ii;ai=1;var e=yi();return ii=function(t,r,n){var o=null==t?void 0:e(t,r);return void 0===o?n:o}}var wi=at(bi());const Ri="package.json",_i=[".env.local",".env"];class xi extends e{_env;shared;constructor(e){super(e),this._env=t.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||_i}),this.shared=Object.assign({},this.feConfig.release,this.getDefaultShreadOptions(e.shared))}getDefaultShreadOptions(e){return{rootPath:process.cwd(),sourceBranch:this._env.get("FE_RELEASE_BRANCH")||this._env.get("FE_RELEASE_SOURCE_BRANCH")||"master",releaseEnv:this._env.get("FE_RELEASE_ENV")||this._env.get("NODE_ENV")||"development",...e}}get rootPath(){return this.shared.rootPath}get sourceBranch(){return this.shared.sourceBranch}get releaseEnv(){return this.shared.releaseEnv}get env(){return this._env}get workspaces(){return this.getConfig("workspaces.workspaces")}get workspace(){return this.getConfig("workspaces.workspace")}setWorkspaces(e){this.options.workspaces={...this.options.workspaces,workspaces:e}}setConfig(e){this.options=si(this.options,e)}getConfig(e,t){return wi(this.options,e,t)}setShared(e){this.shared=si(this.shared,e)}getPkg(e,t){const r=this.workspace?.packageJson;if(!r)throw new Error("package.json is not found");return e?wi(r,e,t):r}getTemplateContext(){return{...this.shared,...this.workspace,publishPath:this.workspace?.path||"",env:this.releaseEnv,branch:this.sourceBranch}}async runChangesetsCli(e,t){let r="pnpm";try{await this.shell.exec("pnpm -v",{dryRun:!1})}catch{r="npm"}return await this.shell.exec(["pnpm"===r?"pnpm dlx":"npx","@changesets/cli",e,...t??[]])}}function ki(e,...t){return[e,...t]}const Pi={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages"};class Ci{shell;logger;config;constructor(e,t,r={}){this.shell=e,this.logger=t,this.config={...Pi,...r}}getReleaseBranchName(e,t,r){const n=r.branchName||"release-${tagName}";if("string"!=typeof n)throw new Error("Branch name template is not a string");return this.logger.verbose("Release Branch template is:",n),this.shell.format(n,{pkgName:e,releaseName:e,tagName:t,...r})}getBatchReleaseBranchName(e,t,r,n){const o=this.config.batchBranchName;if("string"!=typeof o)throw new Error("Branch name template is not a string");return this.logger.verbose("Release Batch Branch template is:",o),this.shell.format(o,{pkgName:e,releaseName:e,tagName:t,...r,length:n})}getReleaseName(e){if(1===e.length)return e[0].name;const{maxWorkspace:t,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return e.slice(t).map((({name:e,version:t})=>`${e}${n}${t}`)).join(r)}getReleaseTagName(e){return 1===e.length?e[0].version:`batch-${e.length}-${(new Date).toISOString().split("T")[0]}`}getReleaseBranchParams(e,t){const r=this.getReleaseTagName(e),n=this.getReleaseName(e);return{tagName:r,releaseBranch:e.length>1?this.getBatchReleaseBranchName(n,r,t,e.length):this.getReleaseBranchName(n,r,t)}}getPRTitle(e,t){const r=this.config.PRTitle||"Release ${env} ${pkgName} ${tagName}";return this.shell.format(r,{...t,tagName:e.tagName,pkgName:e.releaseBranch})}getPRBody(e,t,r){const n=this.config.PRBody,o=e.length>1?e.map((e=>this.shell.format("\n## ${name} ${version}\n${changelog}\n",e))):e[0].changelog,{workspaceVersionSeparator:i}=this.config,a=1===e.length?t.tagName:e.map((e=>`${e.name}${i}${e.version}`)).join(" ");return this.shell.format(n,{...r,tagName:a,changelog:o})}}class $i{context;_octokit=null;constructor(e){this.context=e}getGitHubUserInfo(){const{authorName:e,repoName:t}=this.context.shared;if(!e||!t)throw new Error("Author name or repo name is not set");return{owner:e,repo:t}}getToken(){const{tokenRef:e="GITHUB_TOKEN"}=this.context.getConfig("githubPR"),t=this.context.env.get(e);if(!t)throw new Error(`Token is not set. Please set ${e} environment variable.`);return t}get octokit(){if(this._octokit)return this._octokit;const{timeout:e}=this.context.getConfig("githubPR"),t={auth:this.getToken(),request:{timeout:e}};return this._octokit=new n(t),this._octokit}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.shared.autoMergeType||"squash"}get dryRunPRNumber(){return this.context.getConfig("githubPR.dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.shared.autoMergeReleasePR||false}async mergePR(e,t){if(!e)return void this.logger.error("Failed to create Pull Request.",e);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.context.shared;this.logger.info(`[DRY RUN] Would merge PR #${e} with method '${r}' in repo ${o}/${n}, branch ${t}`)}else await this.octokit.rest.pulls.merge({...this.getGitHubUserInfo(),pull_number:Number(e),merge_method:r})}async checkedPR(e,t){try{await this.octokit.rest.pulls.get({...this.getGitHubUserInfo(),pull_number:Number(e)}),await this.octokit.rest.git.deleteRef({...this.getGitHubUserInfo(),ref:`heads/${t}`}),this.logger.info(`Branch ${t} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${e} or branch ${t} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const e=this.context.shared.label;if(!(e&&e.name&&e.description&&e.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",e),e;try{const t=await this.octokit.rest.issues.createLabel({...this.getGitHubUserInfo(),name:e.name,description:e.description,color:e.color.replace("#","")});return this.logger.debug("Create PR label Success",t),e}catch(t){if(422===t.status)return this.logger.warn(`Label ${e.name} already exists, skipping!`),e;throw this.logger.error("Create PR label Failed",t),t}}async createReleasePR(e){if(this.context.getConfig("githubPR.dryRunCreatePR")||this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...e,labels:e.labels}),this.dryRunPRNumber;try{const t=await this.octokit.rest.pulls.create({...this.getGitHubUserInfo(),...e}),r=t.data.number;if(!r)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",[t?.url]),e.labels&&e.labels.length){const t=await this.octokit.rest.issues.addLabels({...this.getGitHubUserInfo(),issue_number:r,labels:e.labels});this.logger.debug("Add PR label Success",[t.url])}return r.toString()}catch(e){if(422===e.status&&e.message.includes("already exists")){this.logger.warn("PR already exists");const t=e.message.match(/pull request #(\d+)/);return t?t[1]:""}throw this.logger.error("Failed to create PR",e),e}}truncateBody(e){return e&&e.length>=124e3?e.substring(0,124e3)+"...":e}getOctokitReleaseOptions(e){const{releaseName:t,draft:r=!1,preRelease:n=!1,autoGenerate:o=!1,makeLatest:i=!0,releaseNotes:a,discussionCategoryName:s}=this.context.getConfig("githubPR"),c=t,u=o?"":this.truncateBody(String(a));return{name:c,make_latest:i.toString(),body:u,draft:r,prerelease:n,generate_release_notes:o,discussion_category_name:s,tag_name:"",...e,...this.getGitHubUserInfo()}}async createRelease(e){const t=this.getOctokitReleaseOptions({tag_name:e.tagName,body:e.changelog});if(t.name=this.shell.format(t.name,e),this.logger.exec(`octokit repos.createRelease "${t.name}" (${t.tag_name})`,{isDryRun:this.context.dryRun}),!t.tag_name)throw new Error("TagName is undefined");if(this.context.dryRun)return;const r=await this.octokit.repos.createRelease(t);this.logger.verbose(`octokit repos.createRelease: done (${r.headers.location})`)}}var Ni,ji;function Ei(){if(ji)return Ni;ji=1;var e=kt(),t=Kr(),r=qr();return Ni=function(n){return"string"==typeof n||!t(n)&&r(n)&&"[object String]"==e(n)}}var Bi=at(Ei());class Oi{context;pluginName;props;onlyOne=!0;constructor(e,t,r={}){this.context=e,this.pluginName=t,this.props=r,this.setConfig(this.getInitialProps(r))}getInitialProps(e){const t=this.context.options[this.pluginName];return t||e?si({},e,t):{}}get logger(){return this.context.logger}get shell(){return this.context.shell}get options(){return this.context.getConfig(this.pluginName,{})}getEnv(e,t){return this.context.env.get(e)??t}enabled(e,t){return!0}getConfig(e,t){return e?this.context.getConfig([this.pluginName,...Array.isArray(e)?e:[e]],t):this.context.getConfig(this.pluginName,t)}setConfig(e){this.context.setConfig({[this.pluginName]:e})}onBefore(e){}onExec(e){}onSuccess(e){}onError(e){}async step({label:e,task:t}){this.logger.obtrusive(e);try{const r=await t();return this.logger.info(`${e} - success`),r}catch(e){throw this.logger.error(e),e}}}class Ti extends Oi{async onBefore(){const e=await this.getUserInfo();if(!e)throw new Error("Failed to get repoInfo");let t=this.context.shared.currentBranch;t||(t=await this.getCurrentBranch()),t&&await this.context.shell.exec(`git checkout ${t}`,{dryRun:!1}),this.context.setShared({repoName:e.repoName,authorName:e.authorName,currentBranch:t})}async getCurrentBranch(){return await new Promise((e=>setTimeout(e,100))),this.context.shell.exec("git rev-parse --abbrev-ref HEAD",{dryRun:!1})}async getRemoteUrl(){return(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}async getUserInfo(){let e;try{e=await this.getRemoteUrl()}catch{throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!e)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.verbose("repoUrl: ",e);const t=e.match(/github\.com[:/]([^/]+)\/([^/.]+)(?:\.git)?$/);if(!t)throw new Error("Invalid GitHub repository URL format. Please ensure the remote URL is from GitHub.");const[,r,n]=t;if(!this.isValidString(r)||!this.isValidString(n))throw new Error("Failed to extract owner or repository name from GitHub URL");return{repoName:n,authorName:r}}isValidString(e){return!!e&&Bi(e)}}class Si{options;constructor(e){this.options=e}compare(e,t){return"function"==typeof this.options.compare?this.options.compare(e,t):e.startsWith(t)}toChangeLabel(e,t=this.options.changePackagesLabel){return t.replace("${name}",e)}toChangeLabels(e,t=this.options.changePackagesLabel){return e.map((e=>this.toChangeLabel(e,t)))}pick(e,t=this.options.packagesDirectories){const r=[];for(const n of t)for(const t of e)if(this.compare(t,n)){r.push(n);break}return r}}class Ai{static readJson(e){const t=s(e,"utf-8");return JSON.parse(t)}static toWorkspace(e,t){let{root:r,packageJson:n}=e;const o=e.path;if(!o)throw new Error("path is not required!");return r=r||h(t,o),n=n||Ai.readJson(h(r,Ri)),{name:n.name,version:n.version,path:o,root:r,packageJson:n}}}class Li extends Oi{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(e){super(e,"workspaces"),this.releaseLabel=new Si({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[]})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){const e=this.getConfig("workspace");if(e)return this.logger.debug("Use the specified workspace",e),void this.setCurrentWorkspace(e,[]);const t=await this.getWorkspaces();if(this.getConfig("skipCheckPackage")||0===t.length)throw new Error("No changes to publish packages");const{publishPath:r}=this.context.shared;if(r){const e=t.find((e=>o(e.root)===o(r)));if(this.nextSkip(),!e)throw new Error(`No workspace found for: ${r}`);return this.logger.debug(`Workspace of ${r} find!`,i(e.root,Ri)),void this.setCurrentWorkspace(e,[e])}const[n,...a]=t;this.workspacesList=a,this.setCurrentWorkspace(n,t)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}setReleaseTask(e){this.releaseTask=e}setCurrentWorkspace(e,t){this.context.setShared({publishPath:e.path}),this.setConfig({workspace:e,workspaces:t})}getPackages(){const e=this.context.shared.packagesDirectories;return Array.isArray(e)?e:[]}async getGitWorkspaces(){const e=this.context.sourceBranch,t=await this.shell.exec(`git diff --name-only origin/${e}...HEAD`,{dryRun:!1});return"string"==typeof t?t.split("\n"):[]}async getChangedPackages(e,t){if(this.logger.debug("changeLabels",t),Array.isArray(t)&&t.length>0){const r=e.filter((e=>{const r=this.releaseLabel.toChangeLabel(e);return t.includes(r)}));return this.logger.debug("changed by labels",r),r}const r=await this.getGitWorkspaces();return this.logger.debug("changed by git",r),this.releaseLabel.pick(r,e)}async getWorkspaces(){const e=this.getPackages();this.logger.debug("packages",e);const t=await this.getChangedPackages(e,this.getConfig("changeLabels"));this.logger.debug("changedPaths",t);return t.map((e=>Ai.toWorkspace({path:e},this.context.rootPath)))}}function Ui(e,...t){return"function"==typeof e&&e.prototype&&e.prototype.constructor===e?new e(...t):e(...t)}function Wi(e){return e.startsWith(".")?a(e).name:e}async function Fi(e){let t=null;try{t=(await import(e)).default}catch{try{t=(await import(i(process.cwd(),e))).default}catch{const r=l(process.cwd());t=(await import(f(r.resolve(e,{paths:[process.cwd()]})).href)).default}}return[Wi(e),t]}async function Gi(e,t,r=5){const n=g(r),o=t.map((([t,...r])=>n((()=>(async(t,...r)=>{if("string"==typeof t){const[,n]=await Fi(t);return Ui(n,e,...r)}return Ui(t,e,...r)})(t,...r)))));return Promise.all(o)}const Mi={name:"angular",types:[{type:"feat",section:"✨ Features",hidden:!1},{type:"fix",section:"🐞 Bug Fixes",hidden:!1},{type:"chore",section:"🔧 Chores",hidden:!1},{type:"docs",section:"📝 Documentation",hidden:!1},{type:"refactor",section:"♻️ Refactors",hidden:!1},{type:"perf",section:"🚀 Performance",hidden:!1},{type:"test",section:"🚨 Tests",hidden:!1},{type:"style",section:"🎨 Styles",hidden:!1},{type:"ci",section:"🔄 CI",hidden:!1},{type:"build",section:"🚧 Build",hidden:!1},{type:"revert",section:"⏪ Reverts",hidden:!1},{type:"release",section:"🔖 Releases",hidden:!1}]};const Ii=[ki(Li),ki(class extends Oi{constructor(e,t){super(e,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...t})}get changesetRoot(){return h(this.context.rootPath,this.getConfig("changesetRoot"))}enabled(){return!this.getConfig("skip")}async onBefore(){if(!c(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}mergeWorkspaces(e){return e.map((e=>{const t=Ai.toWorkspace({path:e.path},this.context.rootPath),r={...e,version:t.version};return r.tagName=this.generateTagName(r),r}))}async onExec(){const e=await this.step({label:"Generate Changelogs",task:()=>Promise.all(this.context.workspaces.map((e=>this.generateChangelog(e))))});this.getConfig("skipChangeset")?this.logger.debug("Skip generate changeset files"):(await this.step({label:"Changeset Version",task:()=>Promise.all(e.map((e=>this.generateChangesetFile(e))))}),await this.context.runChangesetsCli("version",["--no-changelog"]));const t=this.mergeWorkspaces(e);this.logger.debug("new workspaces",t),this.context.setWorkspaces(t)}getTagPrefix(e){return this.shell.format(this.getConfig("tagPrefix"),e)}async createChangelog({lastTag:e,workspace:t}){const r={releaseCount:1,tagPrefix:this.getTagPrefix(t),warn:this.logger.warn.bind(this.logger),preset:Mi.name},n={version:t.version},o={debug:this.logger.debug.bind(this.logger),from:e,reverse:!0},i={},a={headerPartial:""};return this.context.dryRun?(this.logger.info("[Dry Run] Changelog is dry run"),new Promise((e=>{e("## Dry Run Changelog")}))):new Promise(((e,t)=>{let s="";p(r,n,o,i,a).on("data",(e=>{s+=e.toString()})).on("end",(()=>{e(this.tranformChangelog(s,Mi.types))})).on("error",t)}))}tranformChangelog(e,t){return e}async generateChangelog(e){const t=await this.getTagName(e);this.logger.verbose("tagName is:",t);const r=await this.createChangelog({workspace:e,lastTag:t});return{...e,lastTag:t,changelog:r}}generateTagName(e){try{const t=this.getConfig("tagTemplate");return this.shell.format(t,e)}catch(t){return console.error(`Error generating tag name for ${e.name}:`,t),`${e.name}-v0.0.0`}}async getTagName(e){try{const t=this.generateTagName(e),r=this.shell.format(this.getConfig("tagMatch"),e),n=await this.shell.exec(`git for-each-ref --sort=-creatordate --format "%(refname:short)|%(creatordate:iso8601)" "refs/tags/${r}"`,{dryRun:!1});if(this.logger.debug("tagsOutput",n),!n)return t;const o=n.split("\n").filter(Boolean);if(0===o.length)return t;return o[0].split("|")[0]}catch(t){console.error(`Error getting tag for ${e.name}:`,t);return this.generateTagName(e)}}getIncrement(){const e=this.context.getConfig("workspaces.changeLabels");if(Array.isArray(e)&&e.length>0){if(e.includes("increment:major"))return"major";if(e.includes("increment:minor"))return"minor"}return this.getConfig("increment","patch")}async generateChangesetFile(e){const{name:t,version:r}=e,n=`${t}-${r}`.replace(/[\/\\]/g,"_"),o=h(this.changesetRoot,`${n}.md`),i=this.getIncrement();this.logger.verbose("increment is:",[i]);const a=this.shell.format("---\n'${name}': '${increment}'\n---\n${changelog}",{...e,increment:i});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(a);c(o)?this.logger.info(`Changeset ${n} already exists`):u(o,a,"utf-8")}},{}),ki(class extends Ti{context;releaseParams;githubManager;constructor(e,t){super(e,"githubPR",{releaseName:"Release ${name} v${version}",...t}),this.context=e,this.githubManager=new $i(this.context),this.releaseParams=new Ci(e.shell,e.logger,{PRTitle:this.getConfig("PRTitle",this.context.shared.PRTitle),PRBody:this.getConfig("PRBody",this.context.shared.PRBody),...this.props})}enabled(e){return!this.getConfig("skip")&&("onExec"===e?!this.isPublish:"onSuccess"!==e||this.isPublish)}get isPublish(){return!this.getConfig("releasePR")}async isGithubRepository(){try{return(await this.getRemoteUrl()).includes("github.com")}catch{return!1}}async onBefore(){this.logger.verbose("GithubPR onBefore");if(!await this.isGithubRepository())throw new Error("Current repository is not a GitHub repository. GitHub PR workflow is only available for GitHub repositories.");if(await super.onBefore(),this.isPublish){const e=this.getEnv("NPM_TOKEN");if(!e)throw new Error("NPM_TOKEN is not set");await this.shell.exec(`npm config set //registry.npmjs.org/:_authToken=${e}`)}}async onExec(){const e=this.context.workspaces;await this.step({label:"Release Commit",task:()=>this.relesaeCommit(e)});const t=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(e)});await this.releasePullRequest(e,t)}async onSuccess(){const e=this.context.workspaces;this.getConfig("dryRunCreatePR")||(await this.context.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags")),await this.step({label:"Release Github",task:()=>Promise.all(e.map((e=>(this.logger.debug(e),this.githubManager.createRelease(e)))))})}async relesaeCommit(e){const t=this.getConfig("commitArgs",[]);if(1===e.length)return await this.shell.exec("git add ."),void await this.commitWorkspace(e[0],t);await this.shell.exec("git add .");const r=`chore(tag): ${e.map((e=>`${e.name} v${e.version}`)).join(",")}`;await this.shell.exec(["git","commit","--message",r,...t])}async releasePullRequest(e,t){const r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(e,t)});if(this.githubManager.autoMergeReleasePR){const{releaseBranch:e}=t;return await this.step({label:`Merge Release PR(${r})`,task:()=>this.githubManager.mergePR(r,e)}),void await this.step({label:`Checked Release PR(${r})`,task:()=>this.githubManager.checkedPR(r,e)})}this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async commitWorkspace(e,t=[]){const r=this.shell.format(this.getConfig("commitMessage","chore(tag): ${name} v${version}"),e);return await this.shell.exec(["git","commit","--message",`"${r}"`,...t])}async createReleaseBranch(e){const t=this.releaseParams.getReleaseBranchParams(e,this.context.getTemplateContext()),{tagName:r,releaseBranch:n}=t;if("string"!=typeof r)throw new Error("Tag name is not a string");const{sourceBranch:o,currentBranch:i}=this.context.shared;this.context.logger.verbose("PR TagName is:",r),this.context.logger.verbose("PR CurrentBranch is:",i),this.context.logger.verbose("PR SourceBranch is:",o),this.context.logger.verbose("PR ReleaseBranch is:",n);try{await this.context.shell.exec(`git fetch origin ${o} ${i}`),await this.context.shell.exec(`git checkout -b ${n} ${i}`),await this.context.shell.exec(`git push origin ${n}`)}catch(e){throw e.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),e}return{tagName:r,releaseBranch:n}}async createReleasePR(e,t){const r=[(await this.githubManager.createReleasePRLabel()).name],n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(t,n),i=this.releaseParams.getPRBody(e,t,n);return this.githubManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:t.releaseBranch,labels:r})}},{})];class zi{executor;defaultTuples;context;constructor(e={},t=new r,n=Ii){this.executor=t,this.defaultTuples=n,this.context=new xi(e)}getContext(){return this.context}async usePlugins(e){e=e||this.context.shared.plugins||[];const t=await Gi(this.context,[...this.defaultTuples,...e]);return t.forEach((e=>{e instanceof Li&&e.setReleaseTask(this),this.executor.use(e)})),t}async run(){return this.executor.exec(this.context,(e=>Promise.resolve(e)))}async exec(e){if("false"===this.context.env.get("FE_RELEASE"))throw new Error("Skip Release");return await this.usePlugins(e),this.run()}}var Di,Hi,qi,Vi;function Ji(){if(Hi)return Di;Hi=1;var e=po(),t=mi(),r=yo(),n=Pt(),o=vi();return Di=function(i,a,s,c){if(!n(i))return i;for(var u=-1,h=(a=t(a,i)).length,l=h-1,f=i;null!=f&&++u<h;){var g=o(a[u]),p=s;if("__proto__"===g||"constructor"===g||"prototype"===g)return i;if(u!=l){var d=f[g];void 0===(p=c?c(d,g,f):void 0)&&(p=n(d)?d:r(a[u+1])?[]:{})}e(f,g,p),f=f[g]}return i}}function Ki(){if(Vi)return qi;Vi=1;var e=Ji();return qi=function(t,r,n){return null==t?t:e(t,r,n)}}var Yi=at(Ki());function Qi(e,t){return Object.entries(e).reduce(((e,[r,n])=>(r.includes(".")?Yi(e,r,n):Yi(e,t?`${t}.${r}`:r,n),e)),{})}export{Oi as Plugin,xi as ReleaseContext,Si as ReleaseLabel,zi as ReleaseTask,Ui as factory,Fi as load,Gi as loaderPluginsFromPluginTuples,Qi as reduceOptions,ki as tuple};
|
|
1
|
+
import{FeScriptContext as t}from"@qlover/scripts-context";import{Env as e}from"@qlover/env-loader";import{AsyncExecutor as r}from"@qlover/fe-corekit";import{Octokit as n}from"@octokit/rest";import{resolve as o,join as i,parse as a}from"node:path";import{readFileSync as s,existsSync as c,writeFileSync as u}from"fs";import{join as h}from"path";import{createRequire as l}from"node:module";import{pathToFileURL as f}from"node:url";import g from"p-limit";import p from"conventional-changelog";var d,m,v,y,b,w,R,_,x,k,P,C,$,N,j,E,B,O,T,S,A,L,U,W,F,G,M,I,z,H,D,q,V,J,K,Y,Q,X,Z,tt,et,rt,nt,ot,it,at,st,ct,ut,ht,lt,ft,gt,pt,dt,mt,vt,yt,bt,wt,Rt,_t,xt,kt,Pt,Ct,$t,Nt,jt,Et,Bt,Ot,Tt,St,At,Lt,Ut,Wt,Ft,Gt,Mt,It,zt,Ht,Dt,qt,Vt,Jt,Kt,Yt,Qt,Xt,Zt,te,ee,re,ne,oe,ie="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ae(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function se(){if(m)return d;return m=1,d=function(){this.__data__=[],this.size=0}}function ce(){if(y)return v;return y=1,v=function(t,e){return t===e||t!=t&&e!=e}}function ue(){if(w)return b;w=1;var t=ce();return b=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function he(){if(_)return R;_=1;var t=ue(),e=Array.prototype.splice;return R=function(r){var n=this.__data__,o=t(n,r);return!(o<0)&&(o==n.length-1?n.pop():e.call(n,o,1),--this.size,!0)}}function le(){if(k)return x;k=1;var t=ue();return x=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}function fe(){if(C)return P;C=1;var t=ue();return P=function(e){return t(this.__data__,e)>-1}}function ge(){if(N)return $;N=1;var t=ue();return $=function(e,r){var n=this.__data__,o=t(n,e);return o<0?(++this.size,n.push([e,r])):n[o][1]=r,this}}function pe(){if(E)return j;E=1;var t=se(),e=he(),r=le(),n=fe(),o=ge();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,j=i}function de(){if(O)return B;O=1;var t=pe();return B=function(){this.__data__=new t,this.size=0}}function me(){if(S)return T;return S=1,T=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}}function ve(){if(L)return A;return L=1,A=function(t){return this.__data__.get(t)}}function ye(){if(W)return U;return W=1,U=function(t){return this.__data__.has(t)}}function be(){if(G)return F;G=1;var t="object"==typeof ie&&ie&&ie.Object===Object&&ie;return F=t}function we(){if(I)return M;I=1;var t=be(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return M=r}function Re(){if(H)return z;H=1;var t=we().Symbol;return z=t}function _e(){if(q)return D;q=1;var t=Re(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,o=t?t.toStringTag:void 0;return D=function(t){var e=r.call(t,o),i=t[o];try{t[o]=void 0;var a=!0}catch(t){}var s=n.call(t);return a&&(e?t[o]=i:delete t[o]),s}}function xe(){if(J)return V;J=1;var t=Object.prototype.toString;return V=function(e){return t.call(e)}}function ke(){if(Y)return K;Y=1;var t=Re(),e=_e(),r=xe(),n=t?t.toStringTag:void 0;return K=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function Pe(){if(X)return Q;return X=1,Q=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Ce(){if(tt)return Z;tt=1;var t=ke(),e=Pe();return Z=function(r){if(!e(r))return!1;var n=t(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function $e(){if(rt)return et;rt=1;var t=we()["__core-js_shared__"];return et=t}function Ne(){if(ot)return nt;ot=1;var t,e=$e(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return nt=function(t){return!!r&&r in t}}function je(){if(at)return it;at=1;var t=Function.prototype.toString;return it=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function Ee(){if(ct)return st;ct=1;var t=Ce(),e=Ne(),r=Pe(),n=je(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,a=Object.prototype,s=i.toString,c=a.hasOwnProperty,u=RegExp("^"+s.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return st=function(i){return!(!r(i)||e(i))&&(t(i)?u:o).test(n(i))}}function Be(){if(ht)return ut;return ht=1,ut=function(t,e){return null==t?void 0:t[e]}}function Oe(){if(ft)return lt;ft=1;var t=Ee(),e=Be();return lt=function(r,n){var o=e(r,n);return t(o)?o:void 0}}function Te(){if(pt)return gt;pt=1;var t=Oe()(we(),"Map");return gt=t}function Se(){if(mt)return dt;mt=1;var t=Oe()(Object,"create");return dt=t}function Ae(){if(yt)return vt;yt=1;var t=Se();return vt=function(){this.__data__=t?t(null):{},this.size=0}}function Le(){if(wt)return bt;return wt=1,bt=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}}function Ue(){if(_t)return Rt;_t=1;var t=Se(),e=Object.prototype.hasOwnProperty;return Rt=function(r){var n=this.__data__;if(t){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return e.call(n,r)?n[r]:void 0}}function We(){if(kt)return xt;kt=1;var t=Se(),e=Object.prototype.hasOwnProperty;return xt=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}function Fe(){if(Ct)return Pt;Ct=1;var t=Se();return Pt=function(e,r){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===r?"__lodash_hash_undefined__":r,this}}function Ge(){if(Nt)return $t;Nt=1;var t=Ae(),e=Le(),r=Ue(),n=We(),o=Fe();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,$t=i}function Me(){if(Et)return jt;Et=1;var t=Ge(),e=pe(),r=Te();return jt=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function Ie(){if(Ot)return Bt;return Ot=1,Bt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}}function ze(){if(St)return Tt;St=1;var t=Ie();return Tt=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function He(){if(Lt)return At;Lt=1;var t=ze();return At=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}function De(){if(Wt)return Ut;Wt=1;var t=ze();return Ut=function(e){return t(this,e).get(e)}}function qe(){if(Gt)return Ft;Gt=1;var t=ze();return Ft=function(e){return t(this,e).has(e)}}function Ve(){if(It)return Mt;It=1;var t=ze();return Mt=function(e,r){var n=t(this,e),o=n.size;return n.set(e,r),this.size+=n.size==o?0:1,this}}function Je(){if(Ht)return zt;Ht=1;var t=Me(),e=He(),r=De(),n=qe(),o=Ve();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,zt=i}function Ke(){if(qt)return Dt;qt=1;var t=pe(),e=Te(),r=Je();return Dt=function(n,o){var i=this.__data__;if(i instanceof t){var a=i.__data__;if(!e||a.length<199)return a.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(a)}return i.set(n,o),this.size=i.size,this}}function Ye(){if(Jt)return Vt;Jt=1;var t=pe(),e=de(),r=me(),n=ve(),o=ye(),i=Ke();function a(e){var r=this.__data__=new t(e);this.size=r.size}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=n,a.prototype.has=o,a.prototype.set=i,Vt=a}function Qe(){if(Yt)return Kt;Yt=1;var t=Oe(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Kt=e}function Xe(){if(Xt)return Qt;Xt=1;var t=Qe();return Qt=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function Ze(){if(te)return Zt;te=1;var t=Xe(),e=ce();return Zt=function(r,n,o){(void 0!==o&&!e(r[n],o)||void 0===o&&!(n in r))&&t(r,n,o)}}function tr(){if(re)return ee;return re=1,ee=function(t){return function(e,r,n){for(var o=-1,i=Object(e),a=n(e),s=a.length;s--;){var c=a[t?s:++o];if(!1===r(i[c],c,i))break}return e}}}function er(){if(oe)return ne;oe=1;var t=tr()();return ne=t}var rr,nr,or,ir,ar,sr,cr,ur,hr,lr,fr,gr,pr,dr,mr,vr,yr,br,wr,Rr,_r,xr,kr,Pr,Cr,$r,Nr,jr,Er,Br,Or,Tr,Sr,Ar={exports:{}};function Lr(){return rr||(rr=1,t=Ar,e=Ar.exports,r=we(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n?r.Buffer:void 0,a=i?i.allocUnsafe:void 0,t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=a?a(r):new t.constructor(r);return t.copy(n),n}),Ar.exports;var t,e,r,n,o,i,a}function Ur(){if(or)return nr;or=1;var t=we().Uint8Array;return nr=t}function Wr(){if(ar)return ir;ar=1;var t=Ur();return ir=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function Fr(){if(cr)return sr;cr=1;var t=Wr();return sr=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function Gr(){if(hr)return ur;return hr=1,ur=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}}function Mr(){if(fr)return lr;fr=1;var t=Pe(),e=Object.create,r=function(){function r(){}return function(n){if(!t(n))return{};if(e)return e(n);r.prototype=n;var o=new r;return r.prototype=void 0,o}}();return lr=r}function Ir(){if(pr)return gr;return pr=1,gr=function(t,e){return function(r){return t(e(r))}}}function zr(){if(mr)return dr;mr=1;var t=Ir()(Object.getPrototypeOf,Object);return dr=t}function Hr(){if(yr)return vr;yr=1;var t=Object.prototype;return vr=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function Dr(){if(wr)return br;wr=1;var t=Mr(),e=zr(),r=Hr();return br=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function qr(){if(_r)return Rr;return _r=1,Rr=function(t){return null!=t&&"object"==typeof t}}function Vr(){if(kr)return xr;kr=1;var t=ke(),e=qr();return xr=function(r){return e(r)&&"[object Arguments]"==t(r)}}function Jr(){if(Cr)return Pr;Cr=1;var t=Vr(),e=qr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=t(function(){return arguments}())?t:function(t){return e(t)&&n.call(t,"callee")&&!o.call(t,"callee")};return Pr=i}function Kr(){if(Nr)return $r;Nr=1;var t=Array.isArray;return $r=t}function Yr(){if(Er)return jr;Er=1;return jr=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Qr(){if(Or)return Br;Or=1;var t=Ce(),e=Yr();return Br=function(r){return null!=r&&e(r.length)&&!t(r)}}function Xr(){if(Sr)return Tr;Sr=1;var t=Qr(),e=qr();return Tr=function(r){return e(r)&&t(r)}}var Zr,tn,en,rn,nn,on,an,sn,cn,un={exports:{}};function hn(){if(tn)return Zr;return tn=1,Zr=function(){return!1}}function ln(){return en||(en=1,function(t,e){var r=we(),n=hn(),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,a=i&&i.exports===o?r.Buffer:void 0,s=(a?a.isBuffer:void 0)||n;t.exports=s}(un,un.exports)),un.exports}function fn(){if(nn)return rn;nn=1;var t=ke(),e=zr(),r=qr(),n=Function.prototype,o=Object.prototype,i=n.toString,a=o.hasOwnProperty,s=i.call(Object);return rn=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var o=e(n);if(null===o)return!0;var c=a.call(o,"constructor")&&o.constructor;return"function"==typeof c&&c instanceof c&&i.call(c)==s}}function gn(){if(an)return on;an=1;var t=ke(),e=Yr(),r=qr(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,on=function(o){return r(o)&&e(o.length)&&!!n[t(o)]}}function pn(){if(cn)return sn;return cn=1,sn=function(t){return function(e){return t(e)}}}var dn,mn,vn,yn,bn,wn,Rn,_n,xn,kn,Pn,Cn,$n,Nn,jn,En,Bn,On,Tn,Sn,An,Ln,Un,Wn,Fn,Gn,Mn,In,zn,Hn,Dn,qn,Vn,Jn,Kn,Yn,Qn,Xn,Zn,to,eo,ro,no,oo,io,ao,so,co,uo,ho={exports:{}};function lo(){return dn||(dn=1,t=ho,e=ho.exports,r=be(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n&&r.process,a=function(){try{var t=o&&o.require&&o.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}(),t.exports=a),ho.exports;var t,e,r,n,o,i,a}function fo(){if(vn)return mn;vn=1;var t=gn(),e=pn(),r=lo(),n=r&&r.isTypedArray,o=n?e(n):t;return mn=o}function go(){if(bn)return yn;return bn=1,yn=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function po(){if(Rn)return wn;Rn=1;var t=Xe(),e=ce(),r=Object.prototype.hasOwnProperty;return wn=function(n,o,i){var a=n[o];r.call(n,o)&&e(a,i)&&(void 0!==i||o in n)||t(n,o,i)}}function mo(){if(xn)return _n;xn=1;var t=po(),e=Xe();return _n=function(r,n,o,i){var a=!o;o||(o={});for(var s=-1,c=n.length;++s<c;){var u=n[s],h=i?i(o[u],r[u],u,o,r):void 0;void 0===h&&(h=r[u]),a?e(o,u,h):t(o,u,h)}return o}}function vo(){if(Pn)return kn;return Pn=1,kn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}}function yo(){if($n)return Cn;$n=1;var t=/^(?:0|[1-9]\d*)$/;return Cn=function(e,r){var n=typeof e;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<r}}function bo(){if(jn)return Nn;jn=1;var t=vo(),e=Jr(),r=Kr(),n=ln(),o=yo(),i=fo(),a=Object.prototype.hasOwnProperty;return Nn=function(s,c){var u=r(s),h=!u&&e(s),l=!u&&!h&&n(s),f=!u&&!h&&!l&&i(s),g=u||h||l||f,p=g?t(s.length,String):[],d=p.length;for(var m in s)!c&&!a.call(s,m)||g&&("length"==m||l&&("offset"==m||"parent"==m)||f&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||o(m,d))||p.push(m);return p}}function wo(){if(Bn)return En;return Bn=1,En=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}}function Ro(){if(Tn)return On;Tn=1;var t=Pe(),e=Hr(),r=wo(),n=Object.prototype.hasOwnProperty;return On=function(o){if(!t(o))return r(o);var i=e(o),a=[];for(var s in o)("constructor"!=s||!i&&n.call(o,s))&&a.push(s);return a}}function _o(){if(An)return Sn;An=1;var t=bo(),e=Ro(),r=Qr();return Sn=function(n){return r(n)?t(n,!0):e(n)}}function xo(){if(Un)return Ln;Un=1;var t=mo(),e=_o();return Ln=function(r){return t(r,e(r))}}function ko(){if(Fn)return Wn;Fn=1;var t=Ze(),e=Lr(),r=Fr(),n=Gr(),o=Dr(),i=Jr(),a=Kr(),s=Xr(),c=ln(),u=Ce(),h=Pe(),l=fn(),f=fo(),g=go(),p=xo();return Wn=function(d,m,v,y,b,w,R){var _=g(d,v),x=g(m,v),k=R.get(x);if(k)t(d,v,k);else{var P=w?w(_,x,v+"",d,m,R):void 0,C=void 0===P;if(C){var $=a(x),N=!$&&c(x),j=!$&&!N&&f(x);P=x,$||N||j?a(_)?P=_:s(_)?P=n(_):N?(C=!1,P=e(x,!0)):j?(C=!1,P=r(x,!0)):P=[]:l(x)||i(x)?(P=_,i(_)?P=p(_):h(_)&&!u(_)||(P=o(x))):C=!1}C&&(R.set(x,P),b(P,x,y,w,R),R.delete(x)),t(d,v,P)}}}function Po(){if(Mn)return Gn;Mn=1;var t=Ye(),e=Ze(),r=er(),n=ko(),o=Pe(),i=_o(),a=go();return Gn=function s(c,u,h,l,f){c!==u&&r(u,(function(r,i){if(f||(f=new t),o(r))n(c,u,i,h,s,l,f);else{var g=l?l(a(c,i),r,i+"",c,u,f):void 0;void 0===g&&(g=r),e(c,i,g)}}),i)},Gn}function Co(){if(zn)return In;return zn=1,In=function(t){return t}}function $o(){if(Dn)return Hn;return Dn=1,Hn=function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}}function No(){if(Vn)return qn;Vn=1;var t=$o(),e=Math.max;return qn=function(r,n,o){return n=e(void 0===n?r.length-1:n,0),function(){for(var i=arguments,a=-1,s=e(i.length-n,0),c=Array(s);++a<s;)c[a]=i[n+a];a=-1;for(var u=Array(n+1);++a<n;)u[a]=i[a];return u[n]=o(c),t(r,this,u)}},qn}function jo(){if(Kn)return Jn;return Kn=1,Jn=function(t){return function(){return t}}}function Eo(){if(Qn)return Yn;Qn=1;var t=jo(),e=Qe();return Yn=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:Co()}function Bo(){if(Zn)return Xn;Zn=1;var t=Date.now;return Xn=function(e){var r=0,n=0;return function(){var o=t(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return e.apply(void 0,arguments)}},Xn}function Oo(){if(eo)return to;eo=1;var t=Eo(),e=Bo()(t);return to=e}function To(){if(no)return ro;no=1;var t=Co(),e=No(),r=Oo();return ro=function(n,o){return r(e(n,o,t),n+"")}}function So(){if(io)return oo;io=1;var t=ce(),e=Qr(),r=yo(),n=Pe();return oo=function(o,i,a){if(!n(a))return!1;var s=typeof i;return!!("number"==s?e(a)&&r(i,a.length):"string"==s&&i in a)&&t(a[i],o)}}function Ao(){if(so)return ao;so=1;var t=To(),e=So();return ao=function(r){return t((function(t,n){var o=-1,i=n.length,a=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(a=r.length>3&&"function"==typeof a?(i--,a):void 0,s&&e(n[0],n[1],s)&&(a=i<3?void 0:a,i=1),t=Object(t);++o<i;){var c=n[o];c&&r(t,c,o,a)}return t}))}}function Lo(){if(uo)return co;uo=1;var t=Po(),e=Ao()((function(e,r,n){t(e,r,n)}));return co=e}var Uo,Wo,Fo,Go,Mo,Io,zo,Ho,Do,qo,Vo,Jo,Ko,Yo,Qo,Xo,Zo,ti,ei,ri,ni,oi,ii,ai,si=ae(Lo());function ci(){if(Wo)return Uo;Wo=1;var t=ke(),e=qr();return Uo=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function ui(){if(Go)return Fo;Go=1;var t=Kr(),e=ci(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Fo=function(o,i){if(t(o))return!1;var a=typeof o;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=o&&!e(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function hi(){if(Io)return Mo;Io=1;var t=Je();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var t=arguments,e=n?n.apply(this,t):t[0],i=o.cache;if(i.has(e))return i.get(e);var a=r.apply(this,t);return o.cache=i.set(e,a)||i,a};return o.cache=new(e.Cache||t),o}return e.Cache=t,Mo=e}function li(){if(Ho)return zo;Ho=1;var t=hi();return zo=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function fi(){if(qo)return Do;qo=1;var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,e=/\\(\\)?/g,r=li()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(t,(function(t,r,o,i){n.push(o?i.replace(e,"$1"):r||t)})),n}));return Do=r}function gi(){if(Jo)return Vo;return Jo=1,Vo=function(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}}function pi(){if(Yo)return Ko;Yo=1;var t=Re(),e=gi(),r=Kr(),n=ci(),o=t?t.prototype:void 0,i=o?o.toString:void 0;return Ko=function t(o){if("string"==typeof o)return o;if(r(o))return e(o,t)+"";if(n(o))return i?i.call(o):"";var a=o+"";return"0"==a&&1/o==-1/0?"-0":a},Ko}function di(){if(Xo)return Qo;Xo=1;var t=pi();return Qo=function(e){return null==e?"":t(e)}}function mi(){if(ti)return Zo;ti=1;var t=Kr(),e=ui(),r=fi(),n=di();return Zo=function(o,i){return t(o)?o:e(o,i)?[o]:r(n(o))}}function vi(){if(ri)return ei;ri=1;var t=ci();return ei=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function yi(){if(oi)return ni;oi=1;var t=mi(),e=vi();return ni=function(r,n){for(var o=0,i=(n=t(n,r)).length;null!=r&&o<i;)r=r[e(n[o++])];return o&&o==i?r:void 0}}function bi(){if(ai)return ii;ai=1;var t=yi();return ii=function(e,r,n){var o=null==e?void 0:t(e,r);return void 0===o?n:o}}var wi=ae(bi());const Ri="package.json",_i=[".env.local",".env"];class xi extends t{_env;shared;constructor(t){super(t),this._env=e.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||_i}),this.shared=Object.assign({},this.feConfig.release,this.getDefaultShreadOptions(t.shared))}getDefaultShreadOptions(t){return{rootPath:process.cwd(),sourceBranch:this._env.get("FE_RELEASE_BRANCH")||this._env.get("FE_RELEASE_SOURCE_BRANCH")||"master",releaseEnv:this._env.get("FE_RELEASE_ENV")||this._env.get("NODE_ENV")||"development",...t}}get rootPath(){return this.shared.rootPath}get sourceBranch(){return this.shared.sourceBranch}get releaseEnv(){return this.shared.releaseEnv}get env(){return this._env}get workspaces(){return this.getConfig("workspaces.workspaces")}get workspace(){return this.getConfig("workspaces.workspace")}setWorkspaces(t){this.options.workspaces={...this.options.workspaces,workspaces:t}}setConfig(t){this.options=si(this.options,t)}getConfig(t,e){return wi(this.options,t,e)}setShared(t){this.shared=si(this.shared,t)}getPkg(t,e){const r=this.workspace?.packageJson;if(!r)throw new Error("package.json is not found");return t?wi(r,t,e):r}getTemplateContext(){return{...this.shared,...this.workspace,publishPath:this.workspace?.path||"",env:this.releaseEnv,branch:this.sourceBranch}}async runChangesetsCli(t,e){let r="pnpm";try{await this.shell.exec("pnpm -v",{dryRun:!1})}catch{r="npm"}return await this.shell.exec(["pnpm"===r?"pnpm dlx":"npx","@changesets/cli",t,...e??[]])}}function ki(t,...e){return[t,...e]}const Pi={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${timestamp}-${releaseName}-${length}-packages"};class Ci{shell;logger;config;constructor(t,e,r={}){this.shell=t,this.logger=e,this.config={...Pi,...r}}getReleaseBranchName(t,e,r){const n=r.branchName||"release-${tagName}";if("string"!=typeof n)throw new Error("Branch name template is not a string");return this.logger.verbose("Release Branch template is:",n),this.shell.format(n,{pkgName:t,releaseName:t,tagName:e,...r})}getBatchReleaseBranchName(t,e,r,n){const o=this.config.batchBranchName;if("string"!=typeof o)throw new Error("Branch name template is not a string");return this.logger.verbose("Release Batch Branch template is:",o),this.shell.format(o,{pkgName:t,releaseName:t,tagName:e,...r,length:n,timestamp:Date.now()})}getReleaseName(t){if(1===t.length)return t[0].name;const{maxWorkspace:e,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return t.slice(0,e).map((({name:t,version:e})=>`${t}${n}${e}`)).join(r)}getReleaseTagName(t){return 1===t.length?t[0].version:`batch-${t.length}-${(new Date).toISOString().split("T")[0]}`}getReleaseBranchParams(t,e){const r=this.getReleaseTagName(t),n=this.getReleaseName(t);return{tagName:r,releaseBranch:t.length>1?this.getBatchReleaseBranchName(n,r,e,t.length):this.getReleaseBranchName(n,r,e)}}getPRTitle(t,e){const r=this.config.PRTitle||"Release ${env} ${pkgName} ${tagName}";return this.shell.format(r,{...e,tagName:t.tagName,pkgName:t.releaseBranch})}getPRBody(t,e,r){const n=this.config.PRBody,o=t.length>1?t.map((t=>this.shell.format("\n## ${name} ${version}\n${changelog}\n",t))):t[0].changelog,{workspaceVersionSeparator:i}=this.config,a=1===t.length?e.tagName:t.map((t=>`${t.name}${i}${t.version}`)).join(" ");return this.shell.format(n,{...r,tagName:a,changelog:o})}}class $i{context;_octokit=null;constructor(t){this.context=t}getGitHubUserInfo(){const{authorName:t,repoName:e}=this.context.shared;if(!t||!e)throw new Error("Author name or repo name is not set");return{owner:t,repo:e}}getToken(){const{tokenRef:t="GITHUB_TOKEN"}=this.context.getConfig("githubPR"),e=this.context.env.get(t);if(!e)throw new Error(`Token is not set. Please set ${t} environment variable.`);return e}get octokit(){if(this._octokit)return this._octokit;const{timeout:t}=this.context.getConfig("githubPR"),e={auth:this.getToken(),request:{timeout:t}};return this._octokit=new n(e),this._octokit}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.shared.autoMergeType||"squash"}get dryRunPRNumber(){return this.context.getConfig("githubPR.dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.shared.autoMergeReleasePR||false}async mergePR(t,e){if(!t)return void this.logger.error("Failed to create Pull Request.",t);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.context.shared;this.logger.info(`[DRY RUN] Would merge PR #${t} with method '${r}' in repo ${o}/${n}, branch ${e}`)}else await this.octokit.rest.pulls.merge({...this.getGitHubUserInfo(),pull_number:Number(t),merge_method:r})}async checkedPR(t,e){try{await this.octokit.rest.pulls.get({...this.getGitHubUserInfo(),pull_number:Number(t)}),await this.octokit.rest.git.deleteRef({...this.getGitHubUserInfo(),ref:`heads/${e}`}),this.logger.info(`Branch ${e} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${t} or branch ${e} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const t=this.context.shared.label;if(!(t&&t.name&&t.description&&t.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",t),t;try{const e=await this.octokit.rest.issues.createLabel({...this.getGitHubUserInfo(),name:t.name,description:t.description,color:t.color.replace("#","")});return this.logger.debug("Create PR label Success",e),t}catch(e){if(422===e.status)return this.logger.warn(`Label ${t.name} already exists, skipping!`),t;throw this.logger.error("Create PR label Failed",e),e}}async createReleasePR(t){if(this.context.getConfig("githubPR.dryRunCreatePR")||this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...t,labels:t.labels}),this.dryRunPRNumber;try{const e=await this.octokit.rest.pulls.create({...this.getGitHubUserInfo(),...t}),r=e.data.number;if(!r)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",[e?.url]),t.labels&&t.labels.length){const e=await this.octokit.rest.issues.addLabels({...this.getGitHubUserInfo(),issue_number:r,labels:t.labels});this.logger.debug("Add PR label Success",[e.url])}return r.toString()}catch(t){if(422===t.status&&t.message.includes("already exists")){this.logger.warn("PR already exists");const e=t.message.match(/pull request #(\d+)/);return e?e[1]:""}throw this.logger.error("Failed to create PR",t),t}}truncateBody(t){return t&&t.length>=124e3?t.substring(0,124e3)+"...":t}getOctokitReleaseOptions(t){const{releaseName:e,draft:r=!1,preRelease:n=!1,autoGenerate:o=!1,makeLatest:i=!0,releaseNotes:a,discussionCategoryName:s}=this.context.getConfig("githubPR"),c=e,u=o?"":this.truncateBody(String(a));return{name:c,make_latest:i.toString(),body:u,draft:r,prerelease:n,generate_release_notes:o,discussion_category_name:s,tag_name:"",...t,...this.getGitHubUserInfo()}}async createRelease(t){const e=this.getOctokitReleaseOptions({tag_name:t.tagName,body:t.changelog});if(e.name=this.shell.format(e.name,t),this.logger.exec(`octokit repos.createRelease "${e.name}" (${e.tag_name})`,{isDryRun:this.context.dryRun}),!e.tag_name)throw new Error("TagName is undefined");if(this.context.dryRun)return;const r=await this.octokit.repos.createRelease(e);this.logger.verbose(`octokit repos.createRelease: done (${r.headers.location})`)}}var Ni,ji;function Ei(){if(ji)return Ni;ji=1;var t=ke(),e=Kr(),r=qr();return Ni=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}var Bi=ae(Ei());class Oi{context;pluginName;props;onlyOne=!0;constructor(t,e,r={}){this.context=t,this.pluginName=e,this.props=r,this.setConfig(this.getInitialProps(r))}getInitialProps(t){const e=this.context.options[this.pluginName];return e||t?si({},t,e):{}}get logger(){return this.context.logger}get shell(){return this.context.shell}get options(){return this.context.getConfig(this.pluginName,{})}getEnv(t,e){return this.context.env.get(t)??e}enabled(t,e){return!0}getConfig(t,e){return t?this.context.getConfig([this.pluginName,...Array.isArray(t)?t:[t]],e):this.context.getConfig(this.pluginName,e)}setConfig(t){this.context.setConfig({[this.pluginName]:t})}onBefore(t){}onExec(t){}onSuccess(t){}onError(t){}async step({label:t,task:e}){this.logger.obtrusive(t);try{const r=await e();return this.logger.info(`${t} - success`),r}catch(t){throw this.logger.error(t),t}}}class Ti extends Oi{async onBefore(){const t=await this.getUserInfo();if(!t)throw new Error("Failed to get repoInfo");let e=this.context.shared.currentBranch;e||(e=await this.getCurrentBranch()),e&&await this.context.shell.exec(`git checkout ${e}`,{dryRun:!1}),this.context.setShared({repoName:t.repoName,authorName:t.authorName,currentBranch:e})}async getCurrentBranch(){return await new Promise((t=>setTimeout(t,100))),this.context.shell.exec("git rev-parse --abbrev-ref HEAD",{dryRun:!1})}async getRemoteUrl(){return(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}async getUserInfo(){let t;try{t=await this.getRemoteUrl()}catch{throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!t)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.verbose("repoUrl: ",t);const e=t.match(/github\.com[:/]([^/]+)\/([^/.]+)(?:\.git)?$/);if(!e)throw new Error("Invalid GitHub repository URL format. Please ensure the remote URL is from GitHub.");const[,r,n]=e;if(!this.isValidString(r)||!this.isValidString(n))throw new Error("Failed to extract owner or repository name from GitHub URL");return{repoName:n,authorName:r}}isValidString(t){return!!t&&Bi(t)}commit(t,e=[]){return this.context.shell.exec(["git","commit","--message",JSON.stringify(t),...e])}}class Si{options;constructor(t){this.options=t}compare(t,e){return"function"==typeof this.options.compare?this.options.compare(t,e):t.startsWith(e)}toChangeLabel(t,e=this.options.changePackagesLabel){return e.replace("${name}",t)}toChangeLabels(t,e=this.options.changePackagesLabel){return t.map((t=>this.toChangeLabel(t,e)))}pick(t,e=this.options.packagesDirectories){const r=[];for(const n of e)for(const e of t)if(this.compare(e,n)){r.push(n);break}return r}}class Ai{static readJson(t){const e=s(t,"utf-8");return JSON.parse(e)}static toWorkspace(t,e){let{root:r,packageJson:n}=t;const o=t.path;if(!o)throw new Error("path is not required!");return r=r||h(e,o),n=n||Ai.readJson(h(r,Ri)),{name:n.name,version:n.version,path:o,root:r,packageJson:n}}}class Li extends Oi{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(t){super(t,"workspaces"),this.releaseLabel=new Si({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[]})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){const t=this.getConfig("workspace");if(t)return this.logger.debug("Use the specified workspace",t),void this.setCurrentWorkspace(t,[]);const e=await this.getWorkspaces();if(this.getConfig("skipCheckPackage")||0===e.length)throw new Error("No changes to publish packages");const{publishPath:r}=this.context.shared;if(r){const t=e.find((t=>o(t.root)===o(r)));if(this.nextSkip(),!t)throw new Error(`No workspace found for: ${r}`);return this.logger.debug(`Workspace of ${r} find!`,i(t.root,Ri)),void this.setCurrentWorkspace(t,[t])}const[n,...a]=e;this.workspacesList=a,this.setCurrentWorkspace(n,e)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}setReleaseTask(t){this.releaseTask=t}setCurrentWorkspace(t,e){this.context.setShared({publishPath:t.path}),this.setConfig({workspace:t,workspaces:e})}getPackages(){const t=this.context.shared.packagesDirectories;return Array.isArray(t)?t:[]}async getGitWorkspaces(){const t=this.context.sourceBranch,e=await this.shell.exec(`git diff --name-only origin/${t}...HEAD`,{dryRun:!1});return"string"==typeof e?e.split("\n"):[]}async getChangedPackages(t,e){if(this.logger.debug("changeLabels",e),Array.isArray(e)&&e.length>0){const r=t.filter((t=>{const r=this.releaseLabel.toChangeLabel(t);return e.includes(r)}));return this.logger.debug("changed by labels",r),r}const r=await this.getGitWorkspaces();return this.logger.debug("changed by git",r),this.releaseLabel.pick(r,t)}async getWorkspaces(){const t=this.getPackages();this.logger.debug("packages",t);const e=await this.getChangedPackages(t,this.getConfig("changeLabels"));this.logger.debug("changedPaths",e);return e.map((t=>Ai.toWorkspace({path:t},this.context.rootPath)))}}function Ui(t,...e){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t?new t(...e):t(...e)}function Wi(t){return t.startsWith(".")?a(t).name:t}async function Fi(t){let e=null;try{e=(await import(t)).default}catch{try{e=(await import(i(process.cwd(),t))).default}catch{const r=l(process.cwd());e=(await import(f(r.resolve(t,{paths:[process.cwd()]})).href)).default}}return[Wi(t),e]}async function Gi(t,e,r=5){const n=g(r),o=e.map((([e,...r])=>n((()=>(async(e,...r)=>{if("string"==typeof e){const[,n]=await Fi(e);return Ui(n,t,...r)}return Ui(e,t,...r)})(e,...r)))));return Promise.all(o)}const Mi={name:"angular",types:[{type:"feat",section:"✨ Features",hidden:!1},{type:"fix",section:"🐞 Bug Fixes",hidden:!1},{type:"chore",section:"🔧 Chores",hidden:!1},{type:"docs",section:"📝 Documentation",hidden:!1},{type:"refactor",section:"♻️ Refactors",hidden:!1},{type:"perf",section:"🚀 Performance",hidden:!1},{type:"test",section:"🚨 Tests",hidden:!1},{type:"style",section:"🎨 Styles",hidden:!1},{type:"ci",section:"🔄 CI",hidden:!1},{type:"build",section:"🚧 Build",hidden:!1},{type:"revert",section:"⏪ Reverts",hidden:!1},{type:"release",section:"🔖 Releases",hidden:!1}]};const Ii=[ki(Li),ki(class extends Oi{constructor(t,e){super(t,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...e})}get changesetRoot(){return h(this.context.rootPath,this.getConfig("changesetRoot"))}enabled(){return!this.getConfig("skip")}async onBefore(){if(!c(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}mergeWorkspaces(t){return t.map((t=>{const e=Ai.toWorkspace({path:t.path},this.context.rootPath),r={...t,version:e.version};return r.tagName=this.generateTagName(r),r}))}async onExec(){const t=await this.step({label:"Generate Changelogs",task:()=>Promise.all(this.context.workspaces.map((t=>this.generateChangelog(t))))});this.getConfig("skipChangeset")?this.logger.debug("Skip generate changeset files"):(await this.step({label:"Changeset Version",task:()=>Promise.all(t.map((t=>this.generateChangesetFile(t))))}),await this.context.runChangesetsCli("version",["--no-changelog"]));const e=this.mergeWorkspaces(t);this.logger.debug("new workspaces",e),this.context.setWorkspaces(e)}getTagPrefix(t){return this.shell.format(this.getConfig("tagPrefix"),t)}async createChangelog({lastTag:t,workspace:e}){const r={releaseCount:1,tagPrefix:this.getTagPrefix(e),warn:this.logger.warn.bind(this.logger),preset:Mi.name},n={version:e.version};let o=t;try{await this.shell.exec(`git rev-parse --verify --quiet "refs/tags/${t}"`,{dryRun:!1}),this.logger.verbose(`Tag '${t}' found for workspace '${e.name}'. Using it as the starting point.`)}catch{this.logger.warn(`Tag '${t}' not found for workspace '${e.name}'. Will generate changelog using commits within path '${e.path}' from the beginning of history or latest available tag.`),o=void 0}const i={debug:this.logger.debug.bind(this.logger),from:o,reverse:!0,path:e.path},a={},s={headerPartial:""};return this.logger.debug("options",r),this.logger.debug("context",n),this.logger.debug("gitRawCommitsOpts",i),new Promise(((t,c)=>{let u="";const h=p(r,n,i,a,s);h.on("data",(t=>{u+=t.toString()})),h.on("error",(t=>{this.logger.error(`Error during conventional-changelog stream for workspace '${e.name}':`,t),c(new Error(`Failed to generate changelog for ${e.name}: ${t.message}`))})),h.on("end",(()=>{!u&&o?this.logger.warn(`No commits found for workspace '${e.name}' since tag '${o}' within path '${e.path}'. Changelog will be empty.`):u||this.logger.info(`No commits found for workspace '${e.name}' within path '${e.path}'. Changelog will be empty.`),t(this.tranformChangelog(u,Mi.types))}))}))}tranformChangelog(t,e){return t}async generateChangelog(t){const e=await this.getTagName(t);this.logger.verbose("tagName is:",e);const r=await this.createChangelog({workspace:t,lastTag:e});return{...t,lastTag:e,changelog:r}}generateTagName(t){try{const e=this.getConfig("tagTemplate");return this.shell.format(e,t)}catch(e){return console.error(`Error generating tag name for ${t.name}:`,e),`${t.name}-v0.0.0`}}async getTagName(t){try{const e=this.generateTagName(t),r=this.shell.format(this.getConfig("tagMatch"),t),n=await this.shell.exec(`git for-each-ref --sort=-creatordate --format "%(refname:short)|%(creatordate:iso8601)" "refs/tags/${r}"`,{dryRun:!1});if(this.logger.debug("tagsOutput",n),!n)return e;const o=n.split("\n").filter(Boolean);if(0===o.length)return e;return o[0].split("|")[0]}catch(e){console.error(`Error getting tag for ${t.name}:`,e);return this.generateTagName(t)}}getIncrement(){const t=this.context.getConfig("workspaces.changeLabels");if(Array.isArray(t)&&t.length>0){if(t.includes("increment:major"))return"major";if(t.includes("increment:minor"))return"minor"}return this.getConfig("increment","patch")}async generateChangesetFile(t){const{name:e,version:r}=t,n=`${e}-${r}`.replace(/[\/\\]/g,"_"),o=h(this.changesetRoot,`${n}.md`),i=this.getIncrement();this.logger.verbose("increment is:",[i]);const a=this.shell.format("---\n'${name}': '${increment}'\n---\n${changelog}",{...t,increment:i});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(a);c(o)?this.logger.info(`Changeset ${n} already exists`):u(o,a,"utf-8")}},{}),ki(class extends Ti{context;releaseParams;githubManager;constructor(t,e){super(t,"githubPR",{releaseName:"Release ${name} v${version}",...e}),this.context=t,this.githubManager=new $i(this.context),this.releaseParams=new Ci(t.shell,t.logger,{PRTitle:this.getConfig("PRTitle",this.context.shared.PRTitle),PRBody:this.getConfig("PRBody",this.context.shared.PRBody),...this.props})}enabled(t){return!this.getConfig("skip")&&("onExec"===t?!this.isPublish:"onSuccess"!==t||this.isPublish)}get isPublish(){return!this.getConfig("releasePR")}async isGithubRepository(){try{return(await this.getRemoteUrl()).includes("github.com")}catch{return!1}}async onBefore(){this.logger.verbose("GithubPR onBefore");if(!await this.isGithubRepository())throw new Error("Current repository is not a GitHub repository. GitHub PR workflow is only available for GitHub repositories.");if(await super.onBefore(),this.isPublish){const t=this.getEnv("NPM_TOKEN");if(!t)throw new Error("NPM_TOKEN is not set");await this.shell.exec(`npm config set //registry.npmjs.org/:_authToken=${t}`)}}async onExec(){const t=this.context.workspaces;await this.step({label:"Release Commit",task:()=>this.relesaeCommit(t)});const e=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(t)});await this.releasePullRequest(t,e)}async onSuccess(){const t=this.context.workspaces;this.getConfig("dryRunCreatePR")||(await this.context.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags")),await this.step({label:"Release Github",task:()=>Promise.all(t.map((t=>(this.logger.debug(t),this.githubManager.createRelease(t)))))})}async relesaeCommit(t){const e=this.getConfig("commitArgs",[]);if(1===t.length)return await this.shell.exec("git add ."),void await this.commitWorkspace(t[0],e);await this.shell.exec("git add .");const r=`chore(tag): ${t.map((t=>`${t.name} v${t.version}`)).join(",")}`;await this.commit(r,e)}async releasePullRequest(t,e){const r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(t,e)});if(this.githubManager.autoMergeReleasePR){const{releaseBranch:t}=e;return await this.step({label:`Merge Release PR(${r})`,task:()=>this.githubManager.mergePR(r,t)}),void await this.step({label:`Checked Release PR(${r})`,task:()=>this.githubManager.checkedPR(r,t)})}this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async commitWorkspace(t,e=[]){const r=this.shell.format(this.getConfig("commitMessage","chore(tag): ${name} v${version}"),t);return await this.commit(r,e)}async createReleaseBranch(t){const e=this.releaseParams.getReleaseBranchParams(t,this.context.getTemplateContext()),{tagName:r,releaseBranch:n}=e;if("string"!=typeof r)throw new Error("Tag name is not a string");const{sourceBranch:o,currentBranch:i}=this.context.shared;this.context.logger.verbose("PR TagName is:",r),this.context.logger.verbose("PR CurrentBranch is:",i),this.context.logger.verbose("PR SourceBranch is:",o),this.context.logger.verbose("PR ReleaseBranch is:",n);try{await this.context.shell.exec(`git fetch origin ${o} ${i}`),await this.context.shell.exec(`git checkout -b ${n} ${i}`),await this.context.shell.exec(`git push origin ${n}`)}catch(t){throw t.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),t}return{tagName:r,releaseBranch:n}}async createReleasePR(t,e){const r=[(await this.githubManager.createReleasePRLabel()).name],n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(e,n),i=this.releaseParams.getPRBody(t,e,n);return this.githubManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:e.releaseBranch,labels:r})}},{})];class zi{executor;defaultTuples;context;constructor(t={},e=new r,n=Ii){this.executor=e,this.defaultTuples=n,this.context=new xi(t)}getContext(){return this.context}async usePlugins(t){t=t||this.context.shared.plugins||[];const e=await Gi(this.context,[...this.defaultTuples,...t]);return e.forEach((t=>{t instanceof Li&&t.setReleaseTask(this),this.executor.use(t)})),e}async run(){return this.executor.exec(this.context,(t=>Promise.resolve(t)))}async exec(t){if("false"===this.context.env.get("FE_RELEASE"))throw new Error("Skip Release");return await this.usePlugins(t),this.run()}}var Hi,Di,qi,Vi;function Ji(){if(Di)return Hi;Di=1;var t=po(),e=mi(),r=yo(),n=Pe(),o=vi();return Hi=function(i,a,s,c){if(!n(i))return i;for(var u=-1,h=(a=e(a,i)).length,l=h-1,f=i;null!=f&&++u<h;){var g=o(a[u]),p=s;if("__proto__"===g||"constructor"===g||"prototype"===g)return i;if(u!=l){var d=f[g];void 0===(p=c?c(d,g,f):void 0)&&(p=n(d)?d:r(a[u+1])?[]:{})}t(f,g,p),f=f[g]}return i}}function Ki(){if(Vi)return qi;Vi=1;var t=Ji();return qi=function(e,r,n){return null==e?e:t(e,r,n)}}var Yi=ae(Ki());function Qi(t,e){return Object.entries(t).reduce(((t,[r,n])=>(r.includes(".")?Yi(t,r,n):Yi(t,e?`${e}.${r}`:r,n),t)),{})}export{Oi as Plugin,xi as ReleaseContext,Si as ReleaseLabel,zi as ReleaseTask,Ui as factory,Fi as load,Gi as loaderPluginsFromPluginTuples,Qi as reduceOptions,ki as tuple};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlover/fe-release",
|
|
3
3
|
"description": "A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"homepage": "https://github.com/qlover/fe-base/tree/master/packages/fe-release",
|