@qlover/fe-release 1.0.5 → 1.0.9
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 +102 -103
- package/dist/index.js +1 -1
- package/package.json +19 -17
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
"use strict";var e=require("
|
|
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("node:fs"),require("node:module"),require("node:url"),require("p-limit"),require("conventional-changelog"),require("path"),require("fs");const n=["patch","minor","major"],t=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:i,...a}=function(){const i=new e.Command;return i.version("1.0.9","-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)&&!r.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("--packages-directories <packagesDirectories>","The packages that have been changed, multiple values use `,` to split, map to feConfig.release.packagesDirectories",t).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",t).option("--githubPR.command-prefix <commandPrefix>","The command prefix of the release, call @changeset/cli command","pnpm dlx"),i.parse(),o.reduceOptions(i.opts(),"shared")}(),{dryRun:s,verbose:c,...l}=i,h=Object.assign(a,{});await new o.ReleaseTask({dryRun:s,verbose:c,options:h,shared:l}).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
|
|
2
|
+
import{Command as e}from"commander";import o from"semver";import{ReleaseTask as r,reduceOptions as t}from"./index.js";import"@qlover/scripts-context";import"@qlover/env-loader";import"@qlover/fe-corekit";import"@octokit/rest";import"node:path";import"node:fs";import"node:module";import"node:url";import"p-limit";import"conventional-changelog";import"path";import"fs";const n=["patch","minor","major"],i=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:a,...s}=function(){const r=new e;return r.version("1.0.9","-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("--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).option("--githubPR.command-prefix <commandPrefix>","The command prefix of the release, call @changeset/cli command","pnpm dlx"),r.parse(),t(r.opts(),"shared")}(),{dryRun:p,verbose:c,...h}=a,l=Object.assign(s,{});await new r({dryRun:p,verbose:c,options:l,shared:h}).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,p,g,d,v,m,b,y,w,R,x,k,P,_,N,j,O,C,E,B,$,T,S,A,L,q,I,F,M,W,U,z,D,J,G,H,V,K,Y,Q,X,Z,ee,te,re,ne,oe,ie,se,ae,ue,ce,he,le,fe,pe,ge,de,ve,me,be,ye,we,Re,xe,ke,Pe,_e,Ne,je,Oe,Ce,Ee,Be,$e,Te,Se,Ae,Le,qe,Ie,Fe,Me,We,Ue,ze,De=require("@qlover/scripts-context"),Je=require("@qlover/env-loader"),Ge=require("@qlover/fe-corekit"),He=require("node:path"),Ve=require("node:fs"),Ke=require("node:module"),Ye=require("node:url"),Qe=require("p-limit"),Xe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ze(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function et(){if(t)return e;return t=1,e=function(){this.__data__=[],this.size=0}}function tt(){if(n)return r;return n=1,r=function(e,t){return e===t||e!=e&&t!=t}}function rt(){if(i)return o;i=1;var e=tt();return o=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function nt(){if(a)return s;a=1;var e=rt(),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 ot(){if(c)return u;c=1;var e=rt();return u=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}function it(){if(l)return h;l=1;var e=rt();return h=function(t){return e(this.__data__,t)>-1}}function st(){if(p)return f;p=1;var e=rt();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 at(){if(d)return g;d=1;var e=et(),t=nt(),r=ot(),n=it(),o=st();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,g=i}function ut(){if(m)return v;m=1;var e=at();return v=function(){this.__data__=new e,this.size=0}}function ct(){if(y)return b;return y=1,b=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}}function ht(){if(R)return w;return R=1,w=function(e){return this.__data__.get(e)}}function lt(){if(k)return x;return k=1,x=function(e){return this.__data__.has(e)}}function ft(){if(_)return P;_=1;var e="object"==typeof Xe&&Xe&&Xe.Object===Object&&Xe;return P=e}function pt(){if(j)return N;j=1;var e=ft(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return N=r}function gt(){if(C)return O;C=1;var e=pt().Symbol;return O=e}function dt(){if(B)return E;B=1;var e=gt(),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 vt(){if(T)return $;T=1;var e=Object.prototype.toString;return $=function(t){return e.call(t)}}function mt(){if(A)return S;A=1;var e=gt(),t=dt(),r=vt(),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 bt(){if(q)return L;return q=1,L=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function yt(){if(F)return I;F=1;var e=mt(),t=bt();return I=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 wt(){if(W)return M;W=1;var e=pt()["__core-js_shared__"];return M=e}function Rt(){if(z)return U;z=1;var e,t=wt(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return U=function(e){return!!r&&r in e}}function xt(){if(J)return D;J=1;var e=Function.prototype.toString;return D=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}function kt(){if(H)return G;H=1;var e=yt(),t=Rt(),r=bt(),n=xt(),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 G=function(i){return!(!r(i)||t(i))&&(e(i)?c:o).test(n(i))}}function Pt(){if(K)return V;return K=1,V=function(e,t){return null==e?void 0:e[t]}}function _t(){if(Q)return Y;Q=1;var e=kt(),t=Pt();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=_t()(pt(),"Map");return X=e}function jt(){if(te)return ee;te=1;var e=_t()(Object,"create");return ee=e}function Ot(){if(ne)return re;ne=1;var e=jt();return re=function(){this.__data__=e?e(null):{},this.size=0}}function Ct(){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 Et(){if(ae)return se;ae=1;var e=jt(),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 Bt(){if(ce)return ue;ce=1;var e=jt(),t=Object.prototype.hasOwnProperty;return ue=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}function $t(){if(le)return he;le=1;var e=jt();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 Tt(){if(pe)return fe;pe=1;var e=Ot(),t=Ct(),r=Et(),n=Bt(),o=$t();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 St(){if(de)return ge;de=1;var e=Tt(),t=at(),r=Nt();return ge=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}function At(){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 Lt(){if(ye)return be;ye=1;var e=At();return be=function(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function qt(){if(Re)return we;Re=1;var e=Lt();return we=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}function It(){if(ke)return xe;ke=1;var e=Lt();return xe=function(t){return e(this,t).get(t)}}function Ft(){if(_e)return Pe;_e=1;var e=Lt();return Pe=function(t){return e(this,t).has(t)}}function Mt(){if(je)return Ne;je=1;var e=Lt();return Ne=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 Wt(){if(Ce)return Oe;Ce=1;var e=St(),t=qt(),r=It(),n=Ft(),o=Mt();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,Oe=i}function Ut(){if(Be)return Ee;Be=1;var e=at(),t=Nt(),r=Wt();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 zt(){if(Te)return $e;Te=1;var e=at(),t=ut(),r=ct(),n=ht(),o=lt(),i=Ut();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,$e=s}function Dt(){if(Ae)return Se;Ae=1;var e=_t(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return Se=t}function Jt(){if(qe)return Le;qe=1;var e=Dt();return Le=function(t,r,n){"__proto__"==r&&e?e(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}}function Gt(){if(Fe)return Ie;Fe=1;var e=Jt(),t=tt();return Ie=function(r,n,o){(void 0!==o&&!t(r[n],o)||void 0===o&&!(n in r))&&e(r,n,o)}}function Ht(){if(We)return Me;return We=1,Me=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 Vt(){if(ze)return Ue;ze=1;var e=Ht()();return Ue=e}var Kt,Yt,Qt,Xt,Zt,er,tr,rr,nr,or,ir,sr,ar,ur,cr,hr,lr,fr,pr,gr,dr,vr,mr,br,yr,wr,Rr,xr,kr,Pr,_r,Nr,jr,Or={exports:{}};function Cr(){return Kt||(Kt=1,function(e,t){var r=pt(),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}}(Or,Or.exports)),Or.exports}function Er(){if(Qt)return Yt;Qt=1;var e=pt().Uint8Array;return Yt=e}function Br(){if(Zt)return Xt;Zt=1;var e=Er();return Xt=function(t){var r=new t.constructor(t.byteLength);return new e(r).set(new e(t)),r}}function $r(){if(tr)return er;tr=1;var e=Br();return er=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}function Tr(){if(nr)return rr;return nr=1,rr=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}}function Sr(){if(ir)return or;ir=1;var e=bt(),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 or=r}function Ar(){if(ar)return sr;return ar=1,sr=function(e,t){return function(r){return e(t(r))}}}function Lr(){if(cr)return ur;cr=1;var e=Ar()(Object.getPrototypeOf,Object);return ur=e}function qr(){if(lr)return hr;lr=1;var e=Object.prototype;return hr=function(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}}function Ir(){if(pr)return fr;pr=1;var e=Sr(),t=Lr(),r=qr();return fr=function(n){return"function"!=typeof n.constructor||r(n)?{}:e(t(n))}}function Fr(){if(dr)return gr;return dr=1,gr=function(e){return null!=e&&"object"==typeof e}}function Mr(){if(mr)return vr;mr=1;var e=mt(),t=Fr();return vr=function(r){return t(r)&&"[object Arguments]"==e(r)}}function Wr(){if(yr)return br;yr=1;var e=Mr(),t=Fr(),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 br=i}function Ur(){if(Rr)return wr;Rr=1;var e=Array.isArray;return wr=e}function zr(){if(kr)return xr;kr=1;return xr=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function Dr(){if(_r)return Pr;_r=1;var e=yt(),t=zr();return Pr=function(r){return null!=r&&t(r.length)&&!e(r)}}function Jr(){if(jr)return Nr;jr=1;var e=Dr(),t=Fr();return Nr=function(r){return t(r)&&e(r)}}var Gr,Hr,Vr,Kr,Yr,Qr,Xr,Zr,en,tn={exports:{}};function rn(){if(Hr)return Gr;return Hr=1,Gr=function(){return!1}}function nn(){return Vr||(Vr=1,function(e,t){var r=pt(),n=rn(),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}(tn,tn.exports)),tn.exports}function on(){if(Yr)return Kr;Yr=1;var e=mt(),t=Lr(),r=Fr(),n=Function.prototype,o=Object.prototype,i=n.toString,s=o.hasOwnProperty,a=i.call(Object);return Kr=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 sn(){if(Xr)return Qr;Xr=1;var e=mt(),t=zr(),r=Fr(),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,Qr=function(o){return r(o)&&t(o.length)&&!!n[e(o)]}}function an(){if(en)return Zr;return en=1,Zr=function(e){return function(t){return e(t)}}}var un,cn,hn,ln,fn,pn,gn,dn,vn,mn,bn,yn,wn,Rn,xn,kn,Pn,_n,Nn,jn,On,Cn,En,Bn,$n,Tn,Sn,An,Ln,qn,In,Fn,Mn,Wn,Un,zn,Dn,Jn,Gn,Hn,Vn,Kn,Yn,Qn,Xn,Zn,eo,to,ro,no={exports:{}};function oo(){return un||(un=1,function(e,t){var r=ft(),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}(no,no.exports)),no.exports}function io(){if(hn)return cn;hn=1;var e=sn(),t=an(),r=oo(),n=r&&r.isTypedArray,o=n?t(n):e;return cn=o}function so(){if(fn)return ln;return fn=1,ln=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function ao(){if(gn)return pn;gn=1;var e=Jt(),t=tt(),r=Object.prototype.hasOwnProperty;return pn=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 uo(){if(vn)return dn;vn=1;var e=ao(),t=Jt();return dn=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 co(){if(bn)return mn;return bn=1,mn=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}}function ho(){if(wn)return yn;wn=1;var e=/^(?:0|[1-9]\d*)$/;return yn=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 lo(){if(xn)return Rn;xn=1;var e=co(),t=Wr(),r=Ur(),n=nn(),o=ho(),i=io(),s=Object.prototype.hasOwnProperty;return Rn=function(a,u){var c=r(a),h=!c&&t(a),l=!c&&!h&&n(a),f=!c&&!h&&!l&&i(a),p=c||h||l||f,g=p?e(a.length,String):[],d=g.length;for(var v in a)!u&&!s.call(a,v)||p&&("length"==v||l&&("offset"==v||"parent"==v)||f&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||o(v,d))||g.push(v);return g}}function fo(){if(Pn)return kn;return Pn=1,kn=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}}function po(){if(Nn)return _n;Nn=1;var e=bt(),t=qr(),r=fo(),n=Object.prototype.hasOwnProperty;return _n=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 go(){if(On)return jn;On=1;var e=lo(),t=po(),r=Dr();return jn=function(n){return r(n)?e(n,!0):t(n)}}function vo(){if(En)return Cn;En=1;var e=uo(),t=go();return Cn=function(r){return e(r,t(r))}}function mo(){if($n)return Bn;$n=1;var e=Gt(),t=Cr(),r=$r(),n=Tr(),o=Ir(),i=Wr(),s=Ur(),a=Jr(),u=nn(),c=yt(),h=bt(),l=on(),f=io(),p=so(),g=vo();return Bn=function(d,v,m,b,y,w,R){var x=p(d,m),k=p(v,m),P=R.get(k);if(P)e(d,m,P);else{var _=w?w(x,k,m+"",d,v,R):void 0,N=void 0===_;if(N){var j=s(k),O=!j&&u(k),C=!j&&!O&&f(k);_=k,j||O||C?s(x)?_=x:a(x)?_=n(x):O?(N=!1,_=t(k,!0)):C?(N=!1,_=r(k,!0)):_=[]:l(k)||i(k)?(_=x,i(x)?_=g(x):h(x)&&!c(x)||(_=o(k))):N=!1}N&&(R.set(k,_),y(_,k,b,w,R),R.delete(k)),e(d,m,_)}}}function bo(){if(Sn)return Tn;Sn=1;var e=zt(),t=Gt(),r=Vt(),n=mo(),o=bt(),i=go(),s=so();return Tn=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 p=l?l(s(u,i),r,i+"",u,c,f):void 0;void 0===p&&(p=r),t(u,i,p)}}),i)},Tn}function yo(){if(Ln)return An;return Ln=1,An=function(e){return e}}function wo(){if(In)return qn;return In=1,qn=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 Ro(){if(Mn)return Fn;Mn=1;var e=wo(),t=Math.max;return Fn=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)}},Fn}function xo(){if(Un)return Wn;return Un=1,Wn=function(e){return function(){return e}}}function ko(){if(Dn)return zn;Dn=1;var e=xo(),t=Dt();return zn=t?function(r,n){return t(r,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:yo()}function Po(){if(Gn)return Jn;Gn=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 _o(){if(Vn)return Hn;Vn=1;var e=ko(),t=Po()(e);return Hn=t}function No(){if(Yn)return Kn;Yn=1;var e=yo(),t=Ro(),r=_o();return Kn=function(n,o){return r(t(n,o,e),n+"")}}function jo(){if(Xn)return Qn;Xn=1;var e=tt(),t=Dr(),r=ho(),n=bt();return Qn=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 Oo(){if(eo)return Zn;eo=1;var e=No(),t=jo();return Zn=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 Co(){if(ro)return to;ro=1;var e=bo(),t=Oo()((function(t,r,n){e(t,r,n)}));return to=t}var Eo,Bo,$o,To,So,Ao,Lo,qo,Io,Fo,Mo,Wo,Uo,zo,Do,Jo,Go,Ho,Vo,Ko,Yo,Qo,Xo,Zo,ei=Ze(Co());function ti(){if(Bo)return Eo;Bo=1;var e=mt(),t=Fr();return Eo=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function ri(){if(To)return $o;To=1;var e=Ur(),t=ti(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return $o=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 ni(){if(Ao)return So;Ao=1;var e=Wt();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,So=t}function oi(){if(qo)return Lo;qo=1;var e=ni();return Lo=function(t){var r=e(t,(function(e){return 500===n.size&&n.clear(),e})),n=r.cache;return r}}function ii(){if(Fo)return Io;Fo=1;var e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,r=oi()((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 Io=r}function si(){if(Wo)return Mo;return Wo=1,Mo=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 ai(){if(zo)return Uo;zo=1;var e=gt(),t=si(),r=Ur(),n=ti(),o=e?e.prototype:void 0,i=o?o.toString:void 0;return Uo=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},Uo}function ui(){if(Jo)return Do;Jo=1;var e=ai();return Do=function(t){return null==t?"":e(t)}}function ci(){if(Ho)return Go;Ho=1;var e=Ur(),t=ri(),r=ii(),n=ui();return Go=function(o,i){return e(o)?o:t(o,i)?[o]:r(n(o))}}function hi(){if(Ko)return Vo;Ko=1;var e=ti();return Vo=function(t){if("string"==typeof t||e(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}}function li(){if(Qo)return Yo;Qo=1;var e=ci(),t=hi();return Yo=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 fi(){if(Zo)return Xo;Zo=1;var e=li();return Xo=function(t,r,n){var o=null==t?void 0:e(t,r);return void 0===o?n:o}}var pi=Ze(fi());const gi="package.json";var di={git:{requireUpstream:!0,commit:!0,commitMessage:"chore(tag): {{packageJson.name}} v${version}",commitArgs:["--no-verify"],tag:!0,tagName:"{{packageJson.name}}-v${version}",tagMatch:"{{packageJson.name}}-v*",getLatestTagFromAllRefs:!0,tagAnnotation:"chore(tag): {{packageJson.name}} v${version}",push:!0,pushArgs:["--follow-tags"]},npm:{publish:!0,publishPath:"",versionArgs:["--allow-same-version","--workspaces-update=false"]},github:{release:!0,releaseName:"chore(tag): {{packageJson.name}} v${version}"},plugins:{"@release-it/conventional-changelog":{infile:"CHANGELOG.md",preset:{name:"conventionalcommits",types:[{type:"feat",section:"Features"},{type:"fix",section:"Bug Fixes"},{type:"revert",section:"Reverts"},{type:"build",hidden:!0,section:"Build System"},{type:"chore",hidden:!0},{type:"docs",section:"Documentation"},{type:"style",hidden:!0},{type:"refactor",hidden:!0},{type:"perf",hidden:!0},{type:"test",hidden:!0}]},gitRawCommitsOpts:{path:"{{publishPath}}"}}}};class vi{options;constructor(e){this.options=e,this.options={open:"{{",close:"}}",...e}}getNested(e,t){return t.split(".").reduce(((e,t)=>{if("object"==typeof e&&null!==e&&t in e)return e[t]}),e)}resolveString(e,t,r,n){const o=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(`${o}\\s*([\\w.]+)\\s*${i}`,"g");return e.replace(s,((e,r)=>{const n=this.getNested(t,r);return void 0===n?e:"string"!=typeof n?JSON.stringify(n):String(n)}))}format(e,t,r={}){const n=r.open??this.options.open,o=r.close??this.options.close;if("string"==typeof e)try{const n=JSON.parse(e),o=this.format(n,t,r);return JSON.stringify(o)}catch(r){return this.resolveString(e,t,n,o)}if(Array.isArray(e))return e.map((e=>this.format(e,t,r)));if(null!==e&&"object"==typeof e){const n={};for(const[o,i]of Object.entries(e))n[o]=this.format(i,t,r);return n}return e}static format(e,t,r={}){return new vi(r).format(e,t)}}class mi{context;releaseItInstance;templateOptions;templateJson;lastPath="";constructor(e,t){this.context=e;const{releaseIt:r,...n}=t||{};if(!r)throw new Error("releaseIt is not set");this.templateOptions=ei({},di,n),this.releaseItInstance=r,this.templateJson=new vi}async run(e){const t=this.context.workspace?.root;if(!t)throw new Error("publishPath is not set");try{return this.context.logger.debug("Switch to publish path to:",t),process.chdir(t),this.lastPath=t,await this.releaseItInstance(e)}finally{this.context.logger.debug("Switch back to:",this.lastPath),process.chdir(this.lastPath)}}getOptions(e,t){const r=ei({},this.templateOptions,t);return e&&Object.keys(e).length>0?this.templateJson.format(r,e):r}publishNpm(){return this.run(this.getOptions(this.context.getTemplateContext(),{ci:!0,npm:{publish:!0,publishPath:this.context.workspace?.name},git:{requireCleanWorkingDir:!1,requireUpstream:!1,changelog:!1},plugins:{"@release-it/conventional-changelog":{infile:!1}},"dry-run":this.context.dryRun,verbose:!0,increment:this.context.getPkg("version")}))}createChangelog(){return this.run(this.getOptions(this.context.getTemplateContext(),{ci:!0,increment:this.context.getConfig("githubPR.increment"),npm:{publish:!1},git:{requireCleanWorkingDir:!1,requireUpstream:!1,tag:!1,push:!1},github:{release:!1},verbose:!0,"dry-run":this.context.dryRun}))}}const bi=[".env.local",".env"];class yi extends De.FeScriptContext{_env;releaseIt;shared;constructor(e){super(e),this.releaseIt=new mi(this,e.options?.releaseIt),this._env=Je.Env.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||bi}),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 releasePR(){return!!this.shared.releasePR}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")}setConfig(e){this.options=ei(this.options,e)}getConfig(e,t){return pi(this.options,e,t)}setShared(e){this.shared=ei(this.shared,e)}getPkg(e,t){const r=this.workspace?.packageJson;if(!r)throw new Error("package.json is not found");return e?pi(r,e,t):r}getTemplateContext(){return{...this.shared,...this.workspace,publishPath:this.workspace?.path||"",env:this.releaseEnv,branch:this.sourceBranch}}}function wi(e,...t){return[e,...t]}function Ri(e,...t){return"function"==typeof e&&e.prototype&&e.prototype.constructor===e?new e(...t):e(...t)}const xi={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages"};class ki{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 Pi{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?ei({},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(){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 _i{context;constructor(e){this.context=e}getChangelogAndFeatures(e){return e||this.context.logger.warn("No release-it output found, changelog might be incomplete"),pi(e,"changelog","No changelog")}createChangelog(){return this.context.releaseIt.createChangelog()}async createChangeLogs(e){const t=[];for(const r of e){this.context.setConfig({workspaces:{workspace:r}});const e=await this.createChangelog();t.push({...r,...e})}return t}}class Ni{context;releasePR;constructor(e,t){this.context=e,this.releasePR=t}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.releasePR.mergePullRequest({pull_number:Number(e),merge_method:r})}async checkedPR(e,t){try{await this.releasePR.getPullRequest({pull_number:Number(e)}),await this.releasePR.deleteBranch({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.releasePR.createPullRequestLabel({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.releasePR.createPullRequest(e),r=t.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.releasePR.addPullRequestLabels({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}}}var ji,Oi;function Ci(){if(Oi)return ji;Oi=1;var e=mt(),t=Ur(),r=Fr();return ji=function(n){return"string"==typeof n||!t(n)&&r(n)&&"[object String]"==e(n)}}var Ei=Ze(Ci());class Bi{context;constructor(e){this.context=e}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 getUserInfo(){let e;try{e=(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}catch(e){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&&Ei(e)}}class $i extends Pi{context;gitBase;changelogManager;pullRequestManager;prImpl;releaseParams;constructor(e,t){super(e,"githubPR",t),this.context=e,this.prImpl=Ri(t.pullRequestInterface,e),this.gitBase=new Bi(e),this.changelogManager=new _i(e),this.releaseParams=new ki(e.shell,e.logger,{PRTitle:this.context.shared.PRTitle,PRBody:this.context.shared.PRBody,...this.props}),this.pullRequestManager=new Ni(e,this.prImpl)}enabled(){return this.context.releasePR}async onBefore(){this.logger.verbose("[before] GithubPR"),await this.gitBase.onBefore();const{repoName:e,authorName:t}=this.context.shared;await this.prImpl.init({repoName:e,authorName:t})}async onExec(){const e=await this.step({label:"Create Changelogs",task:()=>this.getComposeWorkspaces()}),t=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(this.releaseParams.getReleaseBranchParams(e,this.context.getTemplateContext()))}),r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(e,t)});this.pullRequestManager.autoMergeReleasePR?await this.mergePR(r,t.releaseBranch):this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async getComposeWorkspaces(){const e=this.context.workspaces;if(!e)throw new Error("No workspaces found");if(this.context.shared.mergePublish)return this.changelogManager.createChangeLogs(e);const t=await this.changelogManager.createChangelog();return[{...this.context.workspace,...t}]}async mergePR(e,t){await this.step({label:`Merge Release PR(${e})`,task:()=>this.pullRequestManager.mergePR(e,t)}),await this.step({label:`Checked Release PR(${e})`,task:()=>this.pullRequestManager.checkedPR(e,t)})}async createReleasePR(e,t){const r=[(await this.pullRequestManager.createReleasePRLabel()).name],n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(t,n),i=this.releaseParams.getPRBody(e,t,n);return this.pullRequestManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:t.releaseBranch,labels:r})}async createReleaseBranch(e){const{tagName:t,releaseBranch:r}=e;if("string"!=typeof t)throw new Error("Tag name is not a string");const{sourceBranch:n,currentBranch:o}=this.context.shared;this.context.logger.verbose("PR TagName is:",t),this.context.logger.verbose("PR CurrentBranch is:",o),this.context.logger.verbose("PR SourceBranch is:",n),this.context.logger.verbose("PR ReleaseBranch is:",r);try{await this.context.shell.exec(`git fetch origin ${n} ${o}`),await this.context.shell.exec(`git checkout -b ${r} ${o}`),await this.context.shell.exec(`git push origin ${r}`)}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:t,releaseBranch:r}}}class Ti extends Pi{constructor(e){super(e,"publishNpm")}enabled(){return!this.context.releasePR}async onBefore(){this.logger.verbose("PublishNpm onBefore"),await this.checkNpmAuth()}async onExec(){await this.step({label:"Publish to NPM",task:()=>this.publish()})}async publish(){return this.context.releaseIt.publishNpm()}async checkNpmAuth(){const e=this.getConfig("npmToken")||this.getEnv("NPM_TOKEN");if(!e)throw new Error("NPM_TOKEN is not set.");this.setConfig({npmToken:e}),this.getConfig("skipNpmrc")?this.logger.debug("skipNpmrc is true, skip set npmrc"):await this.shell.exec(`echo //registry.npmjs.org/:_authToken=${e} > .npmrc`,{dryRun:!1})}}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 extends Pi{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(){this.logger.debug("Merge publish:",!!this.context.shared.mergePublish);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 r=this.context.shared.publishPath;if(r){const e=t.find((e=>He.resolve(e.root)===He.resolve(r)));if(this.nextSkip(),!e)throw new Error(`No workspace found for: ${r}`);return this.logger.debug("publishPathWorkspace find!",He.join(e.root,gi)),void this.setCurrentWorkspace(e,t)}const[n,...o]=t;this.workspacesList=o,this.setCurrentWorkspace(n,t)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}async onExec(){if(this.nextSkip(),this.context.shared.mergePublish)this.logger.info("Merge publish, skip Workspaces");else for(const e of this.workspacesList)this.logger.obtrusive(`workspace: ${e.name} ${e.version}`),this.setCurrentWorkspace(e),await(this.releaseTask?.run())}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"):[]}readJson(e){const t=Ve.readFileSync(e,"utf-8");return JSON.parse(t)}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(),t=await this.getChangedPackages(e,this.getConfig("changeLabels"));this.logger.debug("changedPaths",t);return t.map((e=>this.toWorkspace({path:e})))}toWorkspace(e){let{root:t,packageJson:r}=e;const n=e.path;if(!n)throw new Error("path is not required!");return t=t||He.join(this.context.rootPath,n),r=r||this.readJson(He.join(t,gi)),{name:r.name,version:r.version,path:n,root:t,packageJson:r}}}function Li(e){return e.startsWith(".")?He.parse(e).name:e}async function qi(e){let t=null;try{t=(await import(e)).default}catch(r){try{t=(await import(He.join(process.cwd(),e))).default}catch(r){const n=Ke.createRequire(process.cwd());t=(await import(Ye.pathToFileURL(n.resolve(e,{paths:[process.cwd()]})))).default}}return[Li(e),t]}async function Ii(e,t,r=5){const n=Qe(r),o=t.map((([t,...r])=>n((()=>(async(t,...r)=>{if("string"==typeof t){const[,n]=await qi(t);return Ri(n,e,...r)}return Ri(t,e,...r)})(t,...r)))));return Promise.all(o)}const Fi=[wi($i,{increment:"patch",pullRequestInterface:class{octokit;options={};constructor(e){this.hasGithubToken(e)}hasGithubToken(e){const t=e.env.get("GITHUB_TOKEN")||e.env.get("PAT_TOKEN");if(!t)throw new Error("GITHUB_TOKEN or PAT_TOKEN environment variable is not set.");return this.options.token=t,!0}async init(e={}){if(this.octokit)return this.octokit;const{token:t,repoName:r,authorName:n}={...this.options,...e};if(!t)throw new Error("Github token is not set");this.options.repoName=r,this.options.authorName=n;const{Octokit:o}=await import("@octokit/rest");return this.octokit=new o({auth:t}),this.octokit}getOctokit(){if(!this.octokit)throw new Error("Octokit is not initialized");return this.octokit}mergePullRequest(e){return this.getOctokit().rest.pulls.merge({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}getPullRequest(e){return this.getOctokit().rest.pulls.get({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}deleteBranch(e){return this.getOctokit().rest.git.deleteRef({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}addPullRequestLabels(e){return this.getOctokit().rest.issues.addLabels({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}async createPullRequestLabel(e){return await this.getOctokit().rest.issues.createLabel({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}async createPullRequest(e){const t=await this.getOctokit().rest.pulls.create({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""});return{...t.data,number:t.data.number}}}}),wi(Ti),wi(Ai)];var Mi,Wi,Ui,zi;function Di(){if(Wi)return Mi;Wi=1;var e=ao(),t=ci(),r=ho(),n=bt(),o=hi();return Mi=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 p=o(s[c]),g=a;if("__proto__"===p||"constructor"===p||"prototype"===p)return i;if(c!=l){var d=f[p];void 0===(g=u?u(d,p,f):void 0)&&(g=n(d)?d:r(s[c+1])?[]:{})}e(f,p,g),f=f[p]}return i}}function Ji(){if(zi)return Ui;zi=1;var e=Di();return Ui=function(t,r,n){return null==t?t:e(t,r,n)}}var Gi=Ze(Ji());exports.Plugin=Pi,exports.ReleaseContext=yi,exports.ReleaseLabel=Si,exports.ReleaseTask=class{executor;defaultTuples;context;constructor(e={},t=new Ge.AsyncExecutor,r=Fi){this.executor=t,this.defaultTuples=r,this.context=new yi(e)}getContext(){return this.context}async usePlugins(e){e=e||this.context.shared.plugins||[];const t=await Ii(this.context,[...this.defaultTuples.filter((e=>!(!this.context.shared.releasePR&&e[0]===$i)&&(!this.context.shared.releasePR||e[0]!==Ti))),...e]);return t.forEach((e=>{e instanceof Ai&&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=Ri,exports.load=qi,exports.loaderPluginsFromPluginTuples=Ii,exports.reduceOptions=function(e,t){return Object.entries(e).reduce(((e,[r,n])=>(r.includes(".")?Gi(e,r,n):Gi(e,t?`${t}.${r}`:r,n),e)),{})},exports.tuple=wi;
|
|
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,F,U,W,q,M,I,z,G,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,Fe,Ue,We,qe,Me,Ie,ze,Ge=require("@qlover/scripts-context"),De=require("@qlover/env-loader"),He=require("@qlover/fe-corekit"),Ve=require("@octokit/rest"),Je=require("node:path"),Ke=require("node:fs"),Ye=require("node:module"),Qe=require("node:url"),Xe=require("p-limit"),Ze=require("conventional-changelog"),et=require("path"),tt=require("fs"),rt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function nt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ot(){if(t)return e;return t=1,e=function(){this.__data__=[],this.size=0}}function it(){if(n)return r;return n=1,r=function(e,t){return e===t||e!=e&&t!=t}}function st(){if(i)return o;i=1;var e=it();return o=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function at(){if(a)return s;a=1;var e=st(),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 ut(){if(c)return u;c=1;var e=st();return u=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=st();return h=function(t){return e(this.__data__,t)>-1}}function ht(){if(g)return f;g=1;var e=st();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 lt(){if(d)return p;d=1;var e=ot(),t=at(),r=ut(),n=ct(),o=ht();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 ft(){if(m)return v;m=1;var e=lt();return v=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 pt(){if(x)return w;return x=1,w=function(e){return this.__data__.get(e)}}function dt(){if(_)return R;return _=1,R=function(e){return this.__data__.has(e)}}function vt(){if(P)return k;P=1;var e="object"==typeof rt&&rt&&rt.Object===Object&&rt;return k=e}function mt(){if($)return C;$=1;var e=vt(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return C=r}function yt(){if(N)return j;N=1;var e=mt().Symbol;return j=e}function bt(){if(B)return E;B=1;var e=yt(),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 wt(){if(T)return O;T=1;var e=Object.prototype.toString;return O=function(t){return e.call(t)}}function xt(){if(A)return S;A=1;var e=yt(),t=bt(),r=wt(),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 Rt(){if(F)return L;return F=1,L=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function _t(){if(W)return U;W=1;var e=xt(),t=Rt();return U=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 kt(){if(M)return q;M=1;var e=mt()["__core-js_shared__"];return q=e}function Pt(){if(z)return I;z=1;var e,t=kt(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return I=function(e){return!!r&&r in e}}function Ct(){if(D)return G;D=1;var e=Function.prototype.toString;return G=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}function $t(){if(V)return H;V=1;var e=_t(),t=Pt(),r=Rt(),n=Ct(),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 jt(){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=$t(),t=jt();return Y=function(r,n){var o=t(r,n);return e(o)?o:void 0}}function Et(){if(Z)return X;Z=1;var e=Nt()(mt(),"Map");return X=e}function Bt(){if(te)return ee;te=1;var e=Nt()(Object,"create");return ee=e}function Ot(){if(ne)return re;ne=1;var e=Bt();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 St(){if(ae)return se;ae=1;var e=Bt(),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 At(){if(ce)return ue;ce=1;var e=Bt(),t=Object.prototype.hasOwnProperty;return ue=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}function Lt(){if(le)return he;le=1;var e=Bt();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 Ft(){if(ge)return fe;ge=1;var e=Ot(),t=Tt(),r=St(),n=At(),o=Lt();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=Ft(),t=lt(),r=Et();return pe=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}function Wt(){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 qt(){if(be)return ye;be=1;var e=Wt();return ye=function(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Mt(){if(xe)return we;xe=1;var e=qt();return we=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}function It(){if(_e)return Re;_e=1;var e=qt();return Re=function(t){return e(this,t).get(t)}}function zt(){if(Pe)return ke;Pe=1;var e=qt();return ke=function(t){return e(this,t).has(t)}}function Gt(){if($e)return Ce;$e=1;var e=qt();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 Dt(){if(Ne)return je;Ne=1;var e=Ut(),t=Mt(),r=It(),n=zt(),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,je=i}function Ht(){if(Be)return Ee;Be=1;var e=lt(),t=Et(),r=Dt();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 Vt(){if(Te)return Oe;Te=1;var e=lt(),t=ft(),r=gt(),n=pt(),o=dt(),i=Ht();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 Jt(){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 Kt(){if(Fe)return Le;Fe=1;var e=Jt();return Le=function(t,r,n){"__proto__"==r&&e?e(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}}function Yt(){if(We)return Ue;We=1;var e=Kt(),t=it();return Ue=function(r,n,o){(void 0!==o&&!t(r[n],o)||void 0===o&&!(n in r))&&e(r,n,o)}}function Qt(){if(Me)return qe;return Me=1,qe=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 Xt(){if(ze)return Ie;ze=1;var e=Qt()();return Ie=e}var 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,Or={exports:{}};function Tr(){return Zt||(Zt=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,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}}(Or,Or.exports)),Or.exports}function Sr(){if(tr)return er;tr=1;var e=mt().Uint8Array;return er=e}function Ar(){if(nr)return rr;nr=1;var e=Sr();return rr=function(t){var r=new t.constructor(t.byteLength);return new e(r).set(new e(t)),r}}function Lr(){if(ir)return or;ir=1;var e=Ar();return or=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}function Fr(){if(ar)return sr;return ar=1,sr=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 ur;cr=1;var e=Rt(),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 ur=r}function Wr(){if(lr)return hr;return lr=1,hr=function(e,t){return function(r){return e(t(r))}}}function qr(){if(gr)return fr;gr=1;var e=Wr()(Object.getPrototypeOf,Object);return fr=e}function Mr(){if(dr)return pr;dr=1;var e=Object.prototype;return pr=function(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}}function Ir(){if(mr)return vr;mr=1;var e=Ur(),t=qr(),r=Mr();return vr=function(n){return"function"!=typeof n.constructor||r(n)?{}:e(t(n))}}function zr(){if(br)return yr;return br=1,yr=function(e){return null!=e&&"object"==typeof e}}function Gr(){if(xr)return wr;xr=1;var e=xt(),t=zr();return wr=function(r){return t(r)&&"[object Arguments]"==e(r)}}function Dr(){if(_r)return Rr;_r=1;var e=Gr(),t=zr(),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 Rr=i}function Hr(){if(Pr)return kr;Pr=1;var e=Array.isArray;return kr=e}function Vr(){if($r)return Cr;$r=1;return Cr=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function Jr(){if(Nr)return jr;Nr=1;var e=_t(),t=Vr();return jr=function(r){return null!=r&&t(r.length)&&!e(r)}}function Kr(){if(Br)return Er;Br=1;var e=Jr(),t=zr();return Er=function(r){return t(r)&&e(r)}}var Yr,Qr,Xr,Zr,en,tn,rn,nn,on,sn={exports:{}};function an(){if(Qr)return Yr;return Qr=1,Yr=function(){return!1}}function un(){return Xr||(Xr=1,function(e,t){var r=mt(),n=an(),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}(sn,sn.exports)),sn.exports}function cn(){if(en)return Zr;en=1;var e=xt(),t=qr(),r=zr(),n=Function.prototype,o=Object.prototype,i=n.toString,s=o.hasOwnProperty,a=i.call(Object);return Zr=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 hn(){if(rn)return tn;rn=1;var e=xt(),t=Vr(),r=zr(),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,tn=function(o){return r(o)&&t(o.length)&&!!n[e(o)]}}function ln(){if(on)return nn;return on=1,nn=function(e){return function(t){return e(t)}}}var 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,Fn,Un,Wn,qn,Mn,In,zn,Gn,Dn,Hn,Vn,Jn,Kn,Yn,Qn,Xn,Zn,eo,to,ro,no,oo,io,so,ao={exports:{}};function uo(){return fn||(fn=1,function(e,t){var r=vt(),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}(ao,ao.exports)),ao.exports}function co(){if(pn)return gn;pn=1;var e=hn(),t=ln(),r=uo(),n=r&&r.isTypedArray,o=n?t(n):e;return gn=o}function ho(){if(vn)return dn;return vn=1,dn=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function lo(){if(yn)return mn;yn=1;var e=Kt(),t=it(),r=Object.prototype.hasOwnProperty;return mn=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 fo(){if(wn)return bn;wn=1;var e=lo(),t=Kt();return bn=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 go(){if(Rn)return xn;return Rn=1,xn=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}}function po(){if(kn)return _n;kn=1;var e=/^(?:0|[1-9]\d*)$/;return _n=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 vo(){if(Cn)return Pn;Cn=1;var e=go(),t=Dr(),r=Hr(),n=un(),o=po(),i=co(),s=Object.prototype.hasOwnProperty;return Pn=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 mo(){if(jn)return $n;return jn=1,$n=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}}function yo(){if(En)return Nn;En=1;var e=Rt(),t=Mr(),r=mo(),n=Object.prototype.hasOwnProperty;return Nn=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 bo(){if(On)return Bn;On=1;var e=vo(),t=yo(),r=Jr();return Bn=function(n){return r(n)?e(n,!0):t(n)}}function wo(){if(Sn)return Tn;Sn=1;var e=fo(),t=bo();return Tn=function(r){return e(r,t(r))}}function xo(){if(Ln)return An;Ln=1;var e=Yt(),t=Tr(),r=Lr(),n=Fr(),o=Ir(),i=Dr(),s=Hr(),a=Kr(),u=un(),c=_t(),h=Rt(),l=cn(),f=co(),g=ho(),p=wo();return An=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 Ro(){if(Un)return Fn;Un=1;var e=Vt(),t=Yt(),r=Xt(),n=xo(),o=Rt(),i=bo(),s=ho();return Fn=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)},Fn}function _o(){if(qn)return Wn;return qn=1,Wn=function(e){return e}}function ko(){if(In)return Mn;return In=1,Mn=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 Po(){if(Gn)return zn;Gn=1;var e=ko(),t=Math.max;return zn=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)}},zn}function Co(){if(Hn)return Dn;return Hn=1,Dn=function(e){return function(){return e}}}function $o(){if(Jn)return Vn;Jn=1;var e=Co(),t=Jt();return Vn=t?function(r,n){return t(r,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:_o()}function jo(){if(Yn)return Kn;Yn=1;var e=Date.now;return Kn=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)}},Kn}function No(){if(Xn)return Qn;Xn=1;var e=$o(),t=jo()(e);return Qn=t}function Eo(){if(eo)return Zn;eo=1;var e=_o(),t=Po(),r=No();return Zn=function(n,o){return r(t(n,o,e),n+"")}}function Bo(){if(ro)return to;ro=1;var e=it(),t=Jr(),r=po(),n=Rt();return to=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 Oo(){if(oo)return no;oo=1;var e=Eo(),t=Bo();return no=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 To(){if(so)return io;so=1;var e=Ro(),t=Oo()((function(t,r,n){e(t,r,n)}));return io=t}var So,Ao,Lo,Fo,Uo,Wo,qo,Mo,Io,zo,Go,Do,Ho,Vo,Jo,Ko,Yo,Qo,Xo,Zo,ei,ti,ri,ni,oi=nt(To());function ii(){if(Ao)return So;Ao=1;var e=xt(),t=zr();return So=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function si(){if(Fo)return Lo;Fo=1;var e=Hr(),t=ii(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Lo=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 ai(){if(Wo)return Uo;Wo=1;var e=Dt();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 ui(){if(Mo)return qo;Mo=1;var e=ai();return qo=function(t){var r=e(t,(function(e){return 500===n.size&&n.clear(),e})),n=r.cache;return r}}function ci(){if(zo)return Io;zo=1;var e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,r=ui()((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 Io=r}function hi(){if(Do)return Go;return Do=1,Go=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 li(){if(Vo)return Ho;Vo=1;var e=yt(),t=hi(),r=Hr(),n=ii(),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 s=o+"";return"0"==s&&1/o==-1/0?"-0":s},Ho}function fi(){if(Ko)return Jo;Ko=1;var e=li();return Jo=function(t){return null==t?"":e(t)}}function gi(){if(Qo)return Yo;Qo=1;var e=Hr(),t=si(),r=ci(),n=fi();return Yo=function(o,i){return e(o)?o:t(o,i)?[o]:r(n(o))}}function pi(){if(Zo)return Xo;Zo=1;var e=ii();return Xo=function(t){if("string"==typeof t||e(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}}function di(){if(ti)return ei;ti=1;var e=gi(),t=pi();return ei=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},ei}function vi(){if(ni)return ri;ni=1;var e=di();return ri=function(t,r,n){var o=null==t?void 0:e(t,r);return void 0===o?n:o},ri}var mi=nt(vi());const yi="package.json",bi=[".env.local",".env"];class wi extends Ge.FeScriptContext{_env;shared;constructor(e){super(e),this._env=De.Env.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||bi}),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=oi(this.options,e)}getConfig(e,t){return mi(this.options,e,t)}setShared(e){this.shared=oi(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}}}function xi(e,...t){return[e,...t]}const Ri={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages"};class _i{shell;logger;config;constructor(e,t,r={}){this.shell=e,this.logger=t,this.config={...Ri,...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 ki{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.context.dryRun)return void this.logger.exec(`octokit repos.createRelease "${t.name}" (${t.tag_name})`);const r=await this.octokit.repos.createRelease(t);this.logger.verbose(`octokit repos.createRelease: done (${r.headers.location})`)}}var Pi,Ci;function $i(){if(Ci)return Pi;Ci=1;var e=xt(),t=Hr(),r=zr();return Pi=function(n){return"string"==typeof n||!t(n)&&r(n)&&"[object String]"==e(n)}}var ji=nt($i());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?oi({},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 Ei 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 getUserInfo(){let e;try{e=(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}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&&ji(e)}}class Bi{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 extends Ni{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(e){super(e,"workspaces"),this.releaseLabel=new Bi({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,yi)),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"):[]}readJson(e){const t=Ke.readFileSync(e,"utf-8");return JSON.parse(t)}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(),t=await this.getChangedPackages(e,this.getConfig("changeLabels"));this.logger.debug("changedPaths",t);const r=t.map((e=>this.toWorkspace({path:e})));return r}toWorkspace(e){let{root:t,packageJson:r}=e;const n=e.path;if(!n)throw new Error("path is not required!");return t=t||Je.join(this.context.rootPath,n),r=r||this.readJson(Je.join(t,yi)),{name:r.name,version:r.version,path:n,root:t,packageJson: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=Ye.createRequire(process.cwd());t=(await import(Qe.pathToFileURL(r.resolve(e,{paths:[process.cwd()]})).href)).default}}return[Si(e),t]}async function Li(e,t,r=5){const n=Xe(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 Fi={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 Ui=[xi(Oi),xi(class extends Ni{constructor(e,t){super(e,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...t})}get changesetRoot(){return et.join(this.context.rootPath,this.getConfig("changesetRoot"))}enabled(){return!this.getConfig("skip")}async onBefore(){if(!tt.existsSync(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}async onExec(){const e=this.context.workspaces,t=await this.step({label:"Generate Changelogs",task:()=>Promise.all(e.map((e=>this.generate(e))))});this.logger.debug("changelogs",t),this.context.setWorkspaces(t),this.getConfig("skipChangeset")||await this.step({label:"Create Changeset Files",task:()=>Promise.all(t.map((e=>this.generateChangesetFile(e))))})}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:Fi.name},n={version:t.version},o={debug:this.logger.debug.bind(this.logger),from:e,reverse:!0},i={},s={};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="";Ze(r,n,o,i,s).on("data",(e=>{a+=e.toString()})).on("end",(()=>{e(this.tranformChangelog(a,Fi.types))})).on("error",t)}))}tranformChangelog(e,t){return e}async generate(e){const t=await this.getTagName(e);this.logger.verbose("tagName is:",t);const r=await this.createChangelog({workspace:e,lastTag:t});return{...e,tagName:t,changelog:r}}async 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=await 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 await 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=et.join(this.changesetRoot,`${n}.md`),i=this.shell.format("---\n'${name}': '${increment}'\n---\n${changelog}",{...e,increment:this.getIncrement()});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(i);tt.existsSync(o)?this.logger.info(`Changeset ${n} already exists`):tt.writeFileSync(o,i,"utf-8")}},{}),xi(class extends Ei{context;releaseParams;githubManager;constructor(e,t){super(e,"githubPR",{commandPrefix:"pnpm dlx",releaseName:"Release ${name} v${version}",...t}),this.context=e,this.githubManager=new ki(this.context),this.releaseParams=new _i(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"onExec"===e?!this.isPublish:"onSuccess"!==e||this.isPublish}get isPublish(){return!this.getConfig("releasePR")}async onBefore(){if(this.logger.verbose("GithubPR onBefore"),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.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;await this.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags"),await this.step({label:"Release Github",task:()=>Promise.all(e.map((e=>this.githubManager.createRelease(e))))})}async relesaeCommit(e){const t=this.getConfig("commitArgs",[]);if(await this.runChangesetsCli("version",["--no-changelog"]),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])}runChangesetsCli(e,t){return this.shell.exec([this.getConfig("commandPrefix","npx"),"@changesets/cli",e,...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,qi,Mi,Ii;function zi(){if(qi)return Wi;qi=1;var e=lo(),t=gi(),r=po(),n=Rt(),o=pi();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 Gi(){if(Ii)return Mi;Ii=1;var e=zi();return Mi=function(t,r,n){return null==t?t:e(t,r,n)},Mi}var Di=nt(Gi());exports.Plugin=Ni,exports.ReleaseContext=wi,exports.ReleaseLabel=Bi,exports.ReleaseTask=class{executor;defaultTuples;context;constructor(e={},t=new He.AsyncExecutor,r=Ui){this.executor=t,this.defaultTuples=r,this.context=new wi(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=xi;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,81 +3,6 @@ import { AsyncExecutor, ExecutorContext, ExecutorPlugin, Logger } from '@qlover/
|
|
|
3
3
|
import { Env } from '@qlover/env-loader';
|
|
4
4
|
import { OptionValues } from 'commander';
|
|
5
5
|
|
|
6
|
-
interface InitOptions {
|
|
7
|
-
token?: string;
|
|
8
|
-
repoName?: string;
|
|
9
|
-
authorName?: string;
|
|
10
|
-
}
|
|
11
|
-
interface PullRequestInterface {
|
|
12
|
-
init(params: InitOptions): Promise<unknown>;
|
|
13
|
-
mergePullRequest(params: unknown): Promise<unknown>;
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param params
|
|
17
|
-
*/
|
|
18
|
-
getPullRequest(params: {
|
|
19
|
-
pull_number: number;
|
|
20
|
-
}): Promise<unknown>;
|
|
21
|
-
deleteBranch(params: unknown): Promise<unknown>;
|
|
22
|
-
addPullRequestLabels(params: unknown): Promise<unknown>;
|
|
23
|
-
createPullRequestLabel(params: unknown): Promise<unknown>;
|
|
24
|
-
createPullRequest(params: unknown): Promise<{
|
|
25
|
-
/**
|
|
26
|
-
* pr number
|
|
27
|
-
*/
|
|
28
|
-
number: number;
|
|
29
|
-
[key: string]: unknown;
|
|
30
|
-
}>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface ReleaseItProps extends ReleaseItInstanceOptions {
|
|
34
|
-
/**
|
|
35
|
-
* Receive the `release-it` instance
|
|
36
|
-
*/
|
|
37
|
-
releaseIt: ReleaseItInstanceType;
|
|
38
|
-
}
|
|
39
|
-
type ReleaseItInstanceType = (options: ReleaseItInstanceOptions) => Promise<ReleaseItInstanceResult>;
|
|
40
|
-
type ReleaseItInstanceOptions = Record<string, unknown>;
|
|
41
|
-
type ReleaseItInstanceResult = {
|
|
42
|
-
changelog: string;
|
|
43
|
-
version: string;
|
|
44
|
-
};
|
|
45
|
-
declare class ReleaseIt {
|
|
46
|
-
private context;
|
|
47
|
-
private releaseItInstance;
|
|
48
|
-
private templateOptions;
|
|
49
|
-
private templateJson;
|
|
50
|
-
private lastPath;
|
|
51
|
-
constructor(context: ReleaseContext, props?: ReleaseItProps);
|
|
52
|
-
/**
|
|
53
|
-
* Run release-it in the publish path
|
|
54
|
-
*
|
|
55
|
-
* Because `release-it` only support signle publish path,
|
|
56
|
-
* so we need to change the current working directory to the publish path.
|
|
57
|
-
*
|
|
58
|
-
* @note This method will change the current working directory to the publish path.
|
|
59
|
-
* @param options - The options for the release-it process.
|
|
60
|
-
* @returns The output from the release-it process.
|
|
61
|
-
*/
|
|
62
|
-
run(options?: ReleaseItInstanceOptions): Promise<ReleaseItInstanceResult>;
|
|
63
|
-
getOptions(context?: SharedReleaseOptions, mergeOptions?: Partial<ReleaseItInstanceOptions>): ReleaseItInstanceOptions;
|
|
64
|
-
publishNpm(): Promise<ReleaseItInstanceResult>;
|
|
65
|
-
createChangelog(): Promise<ReleaseItInstanceResult>;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
interface PublishNpmProps {
|
|
69
|
-
npmToken?: string;
|
|
70
|
-
/**
|
|
71
|
-
* Whether to skip setting the npmrc file
|
|
72
|
-
*
|
|
73
|
-
* @default `false`
|
|
74
|
-
*/
|
|
75
|
-
skipNpmrc?: boolean;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
type ConstructorType<T, Args extends unknown[]> = (new (...args: Args) => T) | ((...args: Args) => T);
|
|
79
|
-
declare function factory<T, Args extends unknown[]>(Constructor: ConstructorType<T, Args>, ...args: Args): T;
|
|
80
|
-
|
|
81
6
|
declare class ReleaseTask {
|
|
82
7
|
private executor;
|
|
83
8
|
private defaultTuples;
|
|
@@ -133,6 +58,14 @@ interface WorkspaceValue {
|
|
|
133
58
|
* The package.json of the workspace
|
|
134
59
|
*/
|
|
135
60
|
packageJson: PackageJson;
|
|
61
|
+
/**
|
|
62
|
+
* The tag name of the workspace
|
|
63
|
+
*/
|
|
64
|
+
tagName?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The changelog of the workspace
|
|
67
|
+
*/
|
|
68
|
+
changelog?: string;
|
|
136
69
|
}
|
|
137
70
|
|
|
138
71
|
type ReleaseParamsConfig = {
|
|
@@ -176,23 +109,88 @@ type ReleaseParamsConfig = {
|
|
|
176
109
|
PRBody?: string;
|
|
177
110
|
};
|
|
178
111
|
|
|
179
|
-
interface
|
|
112
|
+
interface GitBaseProps {
|
|
180
113
|
/**
|
|
181
|
-
* The
|
|
114
|
+
* The token for the GitHub API
|
|
182
115
|
*
|
|
183
|
-
* @default `
|
|
116
|
+
* @default `GITHUB_TOKEN`
|
|
184
117
|
*/
|
|
185
|
-
|
|
118
|
+
tokenRef?: string;
|
|
186
119
|
/**
|
|
187
|
-
*
|
|
120
|
+
* The timeout for the GitHub API
|
|
121
|
+
*/
|
|
122
|
+
timeout?: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface GithubPRProps extends ReleaseParamsConfig, GitBaseProps {
|
|
126
|
+
/**
|
|
127
|
+
* The command to run before the release
|
|
128
|
+
*
|
|
129
|
+
* @default `pnpm dlx`
|
|
130
|
+
*/
|
|
131
|
+
commandPrefix?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Whether to publish a PR
|
|
188
134
|
*
|
|
189
135
|
* @default `false`
|
|
190
136
|
*/
|
|
191
|
-
|
|
137
|
+
releasePR?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* The commit message of the release
|
|
140
|
+
*
|
|
141
|
+
* support WorkspaceValue
|
|
142
|
+
*
|
|
143
|
+
* @default 'chore(tag): {{name}} v${version}'
|
|
144
|
+
*/
|
|
145
|
+
commitMessage?: string;
|
|
192
146
|
/**
|
|
193
|
-
* The
|
|
147
|
+
* The commit args of the release
|
|
148
|
+
*
|
|
149
|
+
* @default []
|
|
150
|
+
*/
|
|
151
|
+
commitArgs?: string[];
|
|
152
|
+
/**
|
|
153
|
+
* The release name of the release
|
|
154
|
+
*
|
|
155
|
+
* @default 'Release ${name} v${version}'
|
|
156
|
+
*/
|
|
157
|
+
releaseName?: string;
|
|
158
|
+
/**
|
|
159
|
+
* Whether to create a draft release
|
|
160
|
+
*
|
|
161
|
+
* @default false
|
|
162
|
+
*/
|
|
163
|
+
draft?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Whether to create a pre-release
|
|
166
|
+
*
|
|
167
|
+
* @default false
|
|
168
|
+
*/
|
|
169
|
+
preRelease?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Whether to auto-generate the release notes
|
|
172
|
+
*
|
|
173
|
+
* @default false
|
|
174
|
+
*/
|
|
175
|
+
autoGenerate?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Whether to make the latest release
|
|
178
|
+
*
|
|
179
|
+
* @default true
|
|
180
|
+
*/
|
|
181
|
+
makeLatest?: boolean | 'true' | 'false' | 'legacy';
|
|
182
|
+
/**
|
|
183
|
+
* The release notes of the release
|
|
184
|
+
*
|
|
185
|
+
* @default undefined
|
|
186
|
+
*/
|
|
187
|
+
releaseNotes?: string;
|
|
188
|
+
/**
|
|
189
|
+
* The discussion category name of the release
|
|
190
|
+
*
|
|
191
|
+
* @default undefined
|
|
194
192
|
*/
|
|
195
|
-
|
|
193
|
+
discussionCategoryName?: string;
|
|
196
194
|
}
|
|
197
195
|
|
|
198
196
|
interface ExecutorReleaseContext extends ExecutorContext<ReleaseContext> {
|
|
@@ -206,9 +204,7 @@ type DeepPartial<T> = {
|
|
|
206
204
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
207
205
|
};
|
|
208
206
|
interface ReleaseConfig {
|
|
209
|
-
|
|
210
|
-
githubPR?: ReleasePullRequestProps;
|
|
211
|
-
releaseIt: ReleaseItProps;
|
|
207
|
+
githubPR?: GithubPRProps;
|
|
212
208
|
workspaces?: WorkspacesProps;
|
|
213
209
|
}
|
|
214
210
|
interface ReleaseContextOptions<T extends ReleaseConfig = ReleaseConfig> extends Omit<FeScriptContextOptions<T>, 'constructor'> {
|
|
@@ -216,6 +212,7 @@ interface ReleaseContextOptions<T extends ReleaseConfig = ReleaseConfig> extends
|
|
|
216
212
|
}
|
|
217
213
|
type StepOption<T> = {
|
|
218
214
|
label: string;
|
|
215
|
+
enabled?: boolean;
|
|
219
216
|
task: () => Promise<T>;
|
|
220
217
|
};
|
|
221
218
|
type PackageJson = Record<string, unknown>;
|
|
@@ -242,7 +239,7 @@ declare abstract class Plugin<Props = unknown> implements ExecutorPlugin<Release
|
|
|
242
239
|
get shell(): Shell;
|
|
243
240
|
get options(): Props;
|
|
244
241
|
getEnv(key: string, defaultValue?: string): string | undefined;
|
|
245
|
-
enabled(): boolean;
|
|
242
|
+
enabled(_name: string, _context: ExecutorReleaseContext): boolean;
|
|
246
243
|
getConfig<T>(keys?: string | string[], defaultValue?: T): T;
|
|
247
244
|
setConfig(config: DeepPartial<Props>): void;
|
|
248
245
|
onBefore?(_context: ExecutorReleaseContext): void | Promise<void>;
|
|
@@ -276,6 +273,11 @@ type PluginTuple<T extends PluginClass> = [
|
|
|
276
273
|
];
|
|
277
274
|
declare function tuple<T extends PluginClass>(plugin: T | string, ...args: PluginConstructorParams<T>): PluginTuple<T>;
|
|
278
275
|
|
|
276
|
+
/**
|
|
277
|
+
* This is the shared options for the release.
|
|
278
|
+
*
|
|
279
|
+
* extends `FeReleaseConfig`
|
|
280
|
+
*/
|
|
279
281
|
interface SharedReleaseOptions extends FeReleaseConfig {
|
|
280
282
|
/**
|
|
281
283
|
* The source branch of the project
|
|
@@ -302,45 +304,39 @@ interface SharedReleaseOptions extends FeReleaseConfig {
|
|
|
302
304
|
* @default `process.cwd()`
|
|
303
305
|
*/
|
|
304
306
|
rootPath?: string;
|
|
305
|
-
/**
|
|
306
|
-
* Whether to publish a PR
|
|
307
|
-
*
|
|
308
|
-
* @default `false`
|
|
309
|
-
*/
|
|
310
|
-
releasePR?: boolean;
|
|
311
307
|
/**
|
|
312
308
|
* Plugins
|
|
313
309
|
*/
|
|
314
310
|
plugins?: PluginTuple<PluginClass<unknown[]>>[];
|
|
311
|
+
/**
|
|
312
|
+
* The name of the repository
|
|
313
|
+
*/
|
|
315
314
|
repoName?: string;
|
|
315
|
+
/**
|
|
316
|
+
* The name of the author
|
|
317
|
+
*/
|
|
316
318
|
authorName?: string;
|
|
317
|
-
currentBranch?: string;
|
|
318
319
|
/**
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* If true, the PR will be created for all workspaces, instead of creating one PR per workspace.
|
|
322
|
-
*
|
|
323
|
-
* @default `false`
|
|
320
|
+
* The current branch of the project
|
|
324
321
|
*/
|
|
325
|
-
|
|
322
|
+
currentBranch?: string;
|
|
326
323
|
}
|
|
327
324
|
|
|
328
325
|
declare class ReleaseContext<T extends ReleaseConfig = ReleaseConfig> extends FeScriptContext<T> {
|
|
329
326
|
protected readonly _env: Env;
|
|
330
|
-
readonly releaseIt: ReleaseIt;
|
|
331
327
|
/**
|
|
332
328
|
* Shared Config
|
|
333
329
|
*/
|
|
334
330
|
shared: SharedReleaseOptions;
|
|
335
331
|
constructor(context: ReleaseContextOptions<T>);
|
|
336
332
|
private getDefaultShreadOptions;
|
|
337
|
-
get releasePR(): boolean;
|
|
338
333
|
get rootPath(): string;
|
|
339
334
|
get sourceBranch(): string;
|
|
340
335
|
get releaseEnv(): string;
|
|
341
336
|
get env(): Env;
|
|
342
337
|
get workspaces(): WorkspaceValue[] | undefined;
|
|
343
338
|
get workspace(): WorkspaceValue | undefined;
|
|
339
|
+
setWorkspaces(workspaces: WorkspaceValue[]): void;
|
|
344
340
|
setConfig(config: DeepPartial<ReleaseConfig>): void;
|
|
345
341
|
getConfig<T = unknown>(key: string | string[], defaultValue?: T): T;
|
|
346
342
|
setShared(shared: Partial<SharedReleaseOptions>): void;
|
|
@@ -372,7 +368,10 @@ declare class ReleaseLabel {
|
|
|
372
368
|
declare function load<T>(pluginName: string): Promise<[string, T]>;
|
|
373
369
|
declare function loaderPluginsFromPluginTuples<T extends Plugin<unknown>>(context: ReleaseContext, pluginsTuples: PluginTuple<PluginClass>[], maxLimit?: number): Promise<T[]>;
|
|
374
370
|
|
|
371
|
+
type ConstructorType<T, Args extends unknown[]> = (new (...args: Args) => T) | ((...args: Args) => T);
|
|
372
|
+
declare function factory<T, Args extends unknown[]>(Constructor: ConstructorType<T, Args>, ...args: Args): T;
|
|
373
|
+
|
|
375
374
|
declare function reduceOptions(opts: OptionValues, commonKey?: string): OptionValues;
|
|
376
375
|
|
|
377
376
|
export { Plugin, ReleaseContext, ReleaseLabel, ReleaseTask, factory, load, loaderPluginsFromPluginTuples, reduceOptions, tuple };
|
|
378
|
-
export type { ConstructorType, DeepPartial, ExecutorReleaseContext,
|
|
377
|
+
export type { ConstructorType, DeepPartial, ExecutorReleaseContext, PackageJson, PluginClass, PluginConstructorParams, PluginTuple, ReleaseConfig, ReleaseContextOptions, ReleaseLabelCompare, ReleaseLabelOptions, ReleaseReturnValue, StepOption, TemplateContext };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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{resolve as n,join as o,parse as i}from"node:path";import{readFileSync as s}from"node:fs";import{createRequire as a}from"node:module";import{pathToFileURL as u}from"node:url";import c from"p-limit";var h,l,f,p,g,d,v,m,b,y,w,R,k,x,P,_,N,O,j,C,E,B,$,T,S,A,L,q,I,M,W,F,U,z,D,J,G,H,V,K,Y,Q,X,Z,tt,et,rt,nt,ot,it,st,at,ut,ct,ht,lt,ft,pt,gt,dt,vt,mt,bt,yt,wt,Rt,kt,xt,Pt,_t,Nt,Ot,jt,Ct,Et,Bt,$t,Tt,St,At,Lt,qt,It,Mt,Wt,Ft,Ut,zt,Dt,Jt,Gt,Ht,Vt,Kt,Yt,Qt,Xt,Zt,te="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ee(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function re(){if(l)return h;return l=1,h=function(){this.__data__=[],this.size=0}}function ne(){if(p)return f;return p=1,f=function(t,e){return t===e||t!=t&&e!=e}}function oe(){if(d)return g;d=1;var t=ne();return g=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function ie(){if(m)return v;m=1;var t=oe(),e=Array.prototype.splice;return v=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 se(){if(y)return b;y=1;var t=oe();return b=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}function ae(){if(R)return w;R=1;var t=oe();return w=function(e){return t(this.__data__,e)>-1}}function ue(){if(x)return k;x=1;var t=oe();return k=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 ce(){if(_)return P;_=1;var t=re(),e=ie(),r=se(),n=ae(),o=ue();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,P=i}function he(){if(O)return N;O=1;var t=ce();return N=function(){this.__data__=new t,this.size=0}}function le(){if(C)return j;return C=1,j=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}}function fe(){if(B)return E;return B=1,E=function(t){return this.__data__.get(t)}}function pe(){if(T)return $;return T=1,$=function(t){return this.__data__.has(t)}}function ge(){if(A)return S;A=1;var t="object"==typeof te&&te&&te.Object===Object&&te;return S=t}function de(){if(q)return L;q=1;var t=ge(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return L=r}function ve(){if(M)return I;M=1;var t=de().Symbol;return I=t}function me(){if(F)return W;F=1;var t=ve(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,o=t?t.toStringTag:void 0;return W=function(t){var e=r.call(t,o),i=t[o];try{t[o]=void 0;var s=!0}catch(t){}var a=n.call(t);return s&&(e?t[o]=i:delete t[o]),a}}function be(){if(z)return U;z=1;var t=Object.prototype.toString;return U=function(e){return t.call(e)}}function ye(){if(J)return D;J=1;var t=ve(),e=me(),r=be(),n=t?t.toStringTag:void 0;return D=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function we(){if(H)return G;return H=1,G=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Re(){if(K)return V;K=1;var t=ye(),e=we();return V=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 ke(){if(Q)return Y;Q=1;var t=de()["__core-js_shared__"];return Y=t}function xe(){if(Z)return X;Z=1;var t,e=ke(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return X=function(t){return!!r&&r in t}}function Pe(){if(et)return tt;et=1;var t=Function.prototype.toString;return tt=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function _e(){if(nt)return rt;nt=1;var t=Re(),e=xe(),r=we(),n=Pe(),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 rt=function(i){return!(!r(i)||e(i))&&(t(i)?c:o).test(n(i))}}function Ne(){if(it)return ot;return it=1,ot=function(t,e){return null==t?void 0:t[e]}}function Oe(){if(at)return st;at=1;var t=_e(),e=Ne();return st=function(r,n){var o=e(r,n);return t(o)?o:void 0}}function je(){if(ct)return ut;ct=1;var t=Oe()(de(),"Map");return ut=t}function Ce(){if(lt)return ht;lt=1;var t=Oe()(Object,"create");return ht=t}function Ee(){if(pt)return ft;pt=1;var t=Ce();return ft=function(){this.__data__=t?t(null):{},this.size=0}}function Be(){if(dt)return gt;return dt=1,gt=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}}function $e(){if(mt)return vt;mt=1;var t=Ce(),e=Object.prototype.hasOwnProperty;return vt=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 Te(){if(yt)return bt;yt=1;var t=Ce(),e=Object.prototype.hasOwnProperty;return bt=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}function Se(){if(Rt)return wt;Rt=1;var t=Ce();return wt=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 Ae(){if(xt)return kt;xt=1;var t=Ee(),e=Be(),r=$e(),n=Te(),o=Se();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,kt=i}function Le(){if(_t)return Pt;_t=1;var t=Ae(),e=ce(),r=je();return Pt=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function qe(){if(Ot)return Nt;return Ot=1,Nt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}}function Ie(){if(Ct)return jt;Ct=1;var t=qe();return jt=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Me(){if(Bt)return Et;Bt=1;var t=Ie();return Et=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}function We(){if(Tt)return $t;Tt=1;var t=Ie();return $t=function(e){return t(this,e).get(e)}}function Fe(){if(At)return St;At=1;var t=Ie();return St=function(e){return t(this,e).has(e)}}function Ue(){if(qt)return Lt;qt=1;var t=Ie();return Lt=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 ze(){if(Mt)return It;Mt=1;var t=Le(),e=Me(),r=We(),n=Fe(),o=Ue();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,It=i}function De(){if(Ft)return Wt;Ft=1;var t=ce(),e=je(),r=ze();return Wt=function(n,o){var i=this.__data__;if(i instanceof t){var s=i.__data__;if(!e||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 Je(){if(zt)return Ut;zt=1;var t=ce(),e=he(),r=le(),n=fe(),o=pe(),i=De();function s(e){var r=this.__data__=new t(e);this.size=r.size}return s.prototype.clear=e,s.prototype.delete=r,s.prototype.get=n,s.prototype.has=o,s.prototype.set=i,Ut=s}function Ge(){if(Jt)return Dt;Jt=1;var t=Oe(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Dt=e}function He(){if(Ht)return Gt;Ht=1;var t=Ge();return Gt=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function Ve(){if(Kt)return Vt;Kt=1;var t=He(),e=ne();return Vt=function(r,n,o){(void 0!==o&&!e(r[n],o)||void 0===o&&!(n in r))&&t(r,n,o)}}function Ke(){if(Qt)return Yt;return Qt=1,Yt=function(t){return function(e,r,n){for(var o=-1,i=Object(e),s=n(e),a=s.length;a--;){var u=s[t?a:++o];if(!1===r(i[u],u,i))break}return e}}}function Ye(){if(Zt)return Xt;Zt=1;var t=Ke()();return Xt=t}var Qe,Xe,Ze,tr,er,rr,nr,or,ir,sr,ar,ur,cr,hr,lr,fr,pr,gr,dr,vr,mr,br,yr,wr,Rr,kr,xr,Pr,_r,Nr,Or,jr,Cr,Er={exports:{}};function Br(){return Qe||(Qe=1,t=Er,e=Er.exports,r=de(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n?r.Buffer:void 0,s=i?i.allocUnsafe:void 0,t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=s?s(r):new t.constructor(r);return t.copy(n),n}),Er.exports;var t,e,r,n,o,i,s}function $r(){if(Ze)return Xe;Ze=1;var t=de().Uint8Array;return Xe=t}function Tr(){if(er)return tr;er=1;var t=$r();return tr=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function Sr(){if(nr)return rr;nr=1;var t=Tr();return rr=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function Ar(){if(ir)return or;return ir=1,or=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}}function Lr(){if(ar)return sr;ar=1;var t=we(),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 sr=r}function qr(){if(cr)return ur;return cr=1,ur=function(t,e){return function(r){return t(e(r))}}}function Ir(){if(lr)return hr;lr=1;var t=qr()(Object.getPrototypeOf,Object);return hr=t}function Mr(){if(pr)return fr;pr=1;var t=Object.prototype;return fr=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function Wr(){if(dr)return gr;dr=1;var t=Lr(),e=Ir(),r=Mr();return gr=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function Fr(){if(mr)return vr;return mr=1,vr=function(t){return null!=t&&"object"==typeof t}}function Ur(){if(yr)return br;yr=1;var t=ye(),e=Fr();return br=function(r){return e(r)&&"[object Arguments]"==t(r)}}function zr(){if(Rr)return wr;Rr=1;var t=Ur(),e=Fr(),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 wr=i}function Dr(){if(xr)return kr;xr=1;var t=Array.isArray;return kr=t}function Jr(){if(_r)return Pr;_r=1;return Pr=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Gr(){if(Or)return Nr;Or=1;var t=Re(),e=Jr();return Nr=function(r){return null!=r&&e(r.length)&&!t(r)}}function Hr(){if(Cr)return jr;Cr=1;var t=Gr(),e=Fr();return jr=function(r){return e(r)&&t(r)}}var Vr,Kr,Yr,Qr,Xr,Zr,tn,en,rn,nn={exports:{}};function on(){if(Kr)return Vr;return Kr=1,Vr=function(){return!1}}function sn(){return Yr||(Yr=1,function(t,e){var r=de(),n=on(),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o?r.Buffer:void 0,a=(s?s.isBuffer:void 0)||n;t.exports=a}(nn,nn.exports)),nn.exports}function an(){if(Xr)return Qr;Xr=1;var t=ye(),e=Ir(),r=Fr(),n=Function.prototype,o=Object.prototype,i=n.toString,s=o.hasOwnProperty,a=i.call(Object);return Qr=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var o=e(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 un(){if(tn)return Zr;tn=1;var t=ye(),e=Jr(),r=Fr(),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,Zr=function(o){return r(o)&&e(o.length)&&!!n[t(o)]}}function cn(){if(rn)return en;return rn=1,en=function(t){return function(e){return t(e)}}}var hn,ln,fn,pn,gn,dn,vn,mn,bn,yn,wn,Rn,kn,xn,Pn,_n,Nn,On,jn,Cn,En,Bn,$n,Tn,Sn,An,Ln,qn,In,Mn,Wn,Fn,Un,zn,Dn,Jn,Gn,Hn,Vn,Kn,Yn,Qn,Xn,Zn,to,eo,ro,no,oo,io={exports:{}};function so(){return hn||(hn=1,t=io,e=io.exports,r=ge(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n&&r.process,s=function(){try{var t=o&&o.require&&o.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}(),t.exports=s),io.exports;var t,e,r,n,o,i,s}function ao(){if(fn)return ln;fn=1;var t=un(),e=cn(),r=so(),n=r&&r.isTypedArray,o=n?e(n):t;return ln=o}function uo(){if(gn)return pn;return gn=1,pn=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function co(){if(vn)return dn;vn=1;var t=He(),e=ne(),r=Object.prototype.hasOwnProperty;return dn=function(n,o,i){var s=n[o];r.call(n,o)&&e(s,i)&&(void 0!==i||o in n)||t(n,o,i)}}function ho(){if(bn)return mn;bn=1;var t=co(),e=He();return mn=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?e(o,c,h):t(o,c,h)}return o}}function lo(){if(wn)return yn;return wn=1,yn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}}function fo(){if(kn)return Rn;kn=1;var t=/^(?:0|[1-9]\d*)$/;return Rn=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 po(){if(Pn)return xn;Pn=1;var t=lo(),e=zr(),r=Dr(),n=sn(),o=fo(),i=ao(),s=Object.prototype.hasOwnProperty;return xn=function(a,u){var c=r(a),h=!c&&e(a),l=!c&&!h&&n(a),f=!c&&!h&&!l&&i(a),p=c||h||l||f,g=p?t(a.length,String):[],d=g.length;for(var v in a)!u&&!s.call(a,v)||p&&("length"==v||l&&("offset"==v||"parent"==v)||f&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||o(v,d))||g.push(v);return g}}function go(){if(Nn)return _n;return Nn=1,_n=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}}function vo(){if(jn)return On;jn=1;var t=we(),e=Mr(),r=go(),n=Object.prototype.hasOwnProperty;return On=function(o){if(!t(o))return r(o);var i=e(o),s=[];for(var a in o)("constructor"!=a||!i&&n.call(o,a))&&s.push(a);return s}}function mo(){if(En)return Cn;En=1;var t=po(),e=vo(),r=Gr();return Cn=function(n){return r(n)?t(n,!0):e(n)}}function bo(){if($n)return Bn;$n=1;var t=ho(),e=mo();return Bn=function(r){return t(r,e(r))}}function yo(){if(Sn)return Tn;Sn=1;var t=Ve(),e=Br(),r=Sr(),n=Ar(),o=Wr(),i=zr(),s=Dr(),a=Hr(),u=sn(),c=Re(),h=we(),l=an(),f=ao(),p=uo(),g=bo();return Tn=function(d,v,m,b,y,w,R){var k=p(d,m),x=p(v,m),P=R.get(x);if(P)t(d,m,P);else{var _=w?w(k,x,m+"",d,v,R):void 0,N=void 0===_;if(N){var O=s(x),j=!O&&u(x),C=!O&&!j&&f(x);_=x,O||j||C?s(k)?_=k:a(k)?_=n(k):j?(N=!1,_=e(x,!0)):C?(N=!1,_=r(x,!0)):_=[]:l(x)||i(x)?(_=k,i(k)?_=g(k):h(k)&&!c(k)||(_=o(x))):N=!1}N&&(R.set(x,_),y(_,x,b,w,R),R.delete(x)),t(d,m,_)}}}function wo(){if(Ln)return An;Ln=1;var t=Je(),e=Ve(),r=Ye(),n=yo(),o=we(),i=mo(),s=uo();return An=function a(u,c,h,l,f){u!==c&&r(c,(function(r,i){if(f||(f=new t),o(r))n(u,c,i,h,a,l,f);else{var p=l?l(s(u,i),r,i+"",u,c,f):void 0;void 0===p&&(p=r),e(u,i,p)}}),i)},An}function Ro(){if(In)return qn;return In=1,qn=function(t){return t}}function ko(){if(Wn)return Mn;return Wn=1,Mn=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 xo(){if(Un)return Fn;Un=1;var t=ko(),e=Math.max;return Fn=function(r,n,o){return n=e(void 0===n?r.length-1:n,0),function(){for(var i=arguments,s=-1,a=e(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),t(r,this,c)}},Fn}function Po(){if(Dn)return zn;return Dn=1,zn=function(t){return function(){return t}}}function _o(){if(Gn)return Jn;Gn=1;var t=Po(),e=Ge();return Jn=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:Ro()}function No(){if(Vn)return Hn;Vn=1;var t=Date.now;return Hn=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)}},Hn}function Oo(){if(Yn)return Kn;Yn=1;var t=_o(),e=No()(t);return Kn=e}function jo(){if(Xn)return Qn;Xn=1;var t=Ro(),e=xo(),r=Oo();return Qn=function(n,o){return r(e(n,o,t),n+"")}}function Co(){if(to)return Zn;to=1;var t=ne(),e=Gr(),r=fo(),n=we();return Zn=function(o,i,s){if(!n(s))return!1;var a=typeof i;return!!("number"==a?e(s)&&r(i,s.length):"string"==a&&i in s)&&t(s[i],o)}}function Eo(){if(ro)return eo;ro=1;var t=jo(),e=Co();return eo=function(r){return t((function(t,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&&e(n[0],n[1],a)&&(s=i<3?void 0:s,i=1),t=Object(t);++o<i;){var u=n[o];u&&r(t,u,o,s)}return t}))}}function Bo(){if(oo)return no;oo=1;var t=wo(),e=Eo()((function(e,r,n){t(e,r,n)}));return no=e}var $o,To,So,Ao,Lo,qo,Io,Mo,Wo,Fo,Uo,zo,Do,Jo,Go,Ho,Vo,Ko,Yo,Qo,Xo,Zo,ti,ei,ri=ee(Bo());function ni(){if(To)return $o;To=1;var t=ye(),e=Fr();return $o=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function oi(){if(Ao)return So;Ao=1;var t=Dr(),e=ni(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return So=function(o,i){if(t(o))return!1;var s=typeof o;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=o&&!e(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function ii(){if(qo)return Lo;qo=1;var t=ze();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 s=r.apply(this,t);return o.cache=i.set(e,s)||i,s};return o.cache=new(e.Cache||t),o}return e.Cache=t,Lo=e}function si(){if(Mo)return Io;Mo=1;var t=ii();return Io=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function ai(){if(Fo)return Wo;Fo=1;var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,e=/\\(\\)?/g,r=si()((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 Wo=r}function ui(){if(zo)return Uo;return zo=1,Uo=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 ci(){if(Jo)return Do;Jo=1;var t=ve(),e=ui(),r=Dr(),n=ni(),o=t?t.prototype:void 0,i=o?o.toString:void 0;return Do=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 s=o+"";return"0"==s&&1/o==-1/0?"-0":s},Do}function hi(){if(Ho)return Go;Ho=1;var t=ci();return Go=function(e){return null==e?"":t(e)}}function li(){if(Ko)return Vo;Ko=1;var t=Dr(),e=oi(),r=ai(),n=hi();return Vo=function(o,i){return t(o)?o:e(o,i)?[o]:r(n(o))}}function fi(){if(Qo)return Yo;Qo=1;var t=ni();return Yo=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function pi(){if(Zo)return Xo;Zo=1;var t=li(),e=fi();return Xo=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 gi(){if(ei)return ti;ei=1;var t=pi();return ti=function(e,r,n){var o=null==e?void 0:t(e,r);return void 0===o?n:o}}var di=ee(gi());const vi="package.json";var mi={git:{requireUpstream:!0,commit:!0,commitMessage:"chore(tag): {{packageJson.name}} v${version}",commitArgs:["--no-verify"],tag:!0,tagName:"{{packageJson.name}}-v${version}",tagMatch:"{{packageJson.name}}-v*",getLatestTagFromAllRefs:!0,tagAnnotation:"chore(tag): {{packageJson.name}} v${version}",push:!0,pushArgs:["--follow-tags"]},npm:{publish:!0,publishPath:"",versionArgs:["--allow-same-version","--workspaces-update=false"]},github:{release:!0,releaseName:"chore(tag): {{packageJson.name}} v${version}"},plugins:{"@release-it/conventional-changelog":{infile:"CHANGELOG.md",preset:{name:"conventionalcommits",types:[{type:"feat",section:"Features"},{type:"fix",section:"Bug Fixes"},{type:"revert",section:"Reverts"},{type:"build",hidden:!0,section:"Build System"},{type:"chore",hidden:!0},{type:"docs",section:"Documentation"},{type:"style",hidden:!0},{type:"refactor",hidden:!0},{type:"perf",hidden:!0},{type:"test",hidden:!0}]},gitRawCommitsOpts:{path:"{{publishPath}}"}}}};class bi{options;constructor(t){this.options=t,this.options={open:"{{",close:"}}",...t}}getNested(t,e){return e.split(".").reduce(((t,e)=>{if("object"==typeof t&&null!==t&&e in t)return t[e]}),t)}resolveString(t,e,r,n){const o=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(`${o}\\s*([\\w.]+)\\s*${i}`,"g");return t.replace(s,((t,r)=>{const n=this.getNested(e,r);return void 0===n?t:"string"!=typeof n?JSON.stringify(n):String(n)}))}format(t,e,r={}){const n=r.open??this.options.open,o=r.close??this.options.close;if("string"==typeof t)try{const n=JSON.parse(t),o=this.format(n,e,r);return JSON.stringify(o)}catch(r){return this.resolveString(t,e,n,o)}if(Array.isArray(t))return t.map((t=>this.format(t,e,r)));if(null!==t&&"object"==typeof t){const n={};for(const[o,i]of Object.entries(t))n[o]=this.format(i,e,r);return n}return t}static format(t,e,r={}){return new bi(r).format(t,e)}}class yi{context;releaseItInstance;templateOptions;templateJson;lastPath="";constructor(t,e){this.context=t;const{releaseIt:r,...n}=e||{};if(!r)throw new Error("releaseIt is not set");this.templateOptions=ri({},mi,n),this.releaseItInstance=r,this.templateJson=new bi}async run(t){const e=this.context.workspace?.root;if(!e)throw new Error("publishPath is not set");try{return this.context.logger.debug("Switch to publish path to:",e),process.chdir(e),this.lastPath=e,await this.releaseItInstance(t)}finally{this.context.logger.debug("Switch back to:",this.lastPath),process.chdir(this.lastPath)}}getOptions(t,e){const r=ri({},this.templateOptions,e);return t&&Object.keys(t).length>0?this.templateJson.format(r,t):r}publishNpm(){return this.run(this.getOptions(this.context.getTemplateContext(),{ci:!0,npm:{publish:!0,publishPath:this.context.workspace?.name},git:{requireCleanWorkingDir:!1,requireUpstream:!1,changelog:!1},plugins:{"@release-it/conventional-changelog":{infile:!1}},"dry-run":this.context.dryRun,verbose:!0,increment:this.context.getPkg("version")}))}createChangelog(){return this.run(this.getOptions(this.context.getTemplateContext(),{ci:!0,increment:this.context.getConfig("githubPR.increment"),npm:{publish:!1},git:{requireCleanWorkingDir:!1,requireUpstream:!1,tag:!1,push:!1},github:{release:!1},verbose:!0,"dry-run":this.context.dryRun}))}}const wi=[".env.local",".env"];class Ri extends t{_env;releaseIt;shared;constructor(t){super(t),this.releaseIt=new yi(this,t.options?.releaseIt),this._env=e.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||wi}),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 releasePR(){return!!this.shared.releasePR}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")}setConfig(t){this.options=ri(this.options,t)}getConfig(t,e){return di(this.options,t,e)}setShared(t){this.shared=ri(this.shared,t)}getPkg(t,e){const r=this.workspace?.packageJson;if(!r)throw new Error("package.json is not found");return t?di(r,t,e):r}getTemplateContext(){return{...this.shared,...this.workspace,publishPath:this.workspace?.path||"",env:this.releaseEnv,branch:this.sourceBranch}}}function ki(t,...e){return[t,...e]}function xi(t,...e){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t?new t(...e):t(...e)}const Pi={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages"};class _i{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})}getReleaseName(t){if(1===t.length)return t[0].name;const{maxWorkspace:e,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return t.slice(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,s=1===t.length?e.tagName:t.map((t=>`${t.name}${i}${t.version}`)).join(" ");return this.shell.format(n,{...r,tagName:s,changelog:o})}}class Ni{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?ri({},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(){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 Oi{context;constructor(t){this.context=t}getChangelogAndFeatures(t){return t||this.context.logger.warn("No release-it output found, changelog might be incomplete"),di(t,"changelog","No changelog")}createChangelog(){return this.context.releaseIt.createChangelog()}async createChangeLogs(t){const e=[];for(const r of t){this.context.setConfig({workspaces:{workspace:r}});const t=await this.createChangelog();e.push({...r,...t})}return e}}class ji{context;releasePR;constructor(t,e){this.context=t,this.releasePR=e}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.releasePR.mergePullRequest({pull_number:Number(t),merge_method:r})}async checkedPR(t,e){try{await this.releasePR.getPullRequest({pull_number:Number(t)}),await this.releasePR.deleteBranch({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.releasePR.createPullRequestLabel({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.releasePR.createPullRequest(t),r=e.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.releasePR.addPullRequestLabels({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}}}var Ci,Ei;function Bi(){if(Ei)return Ci;Ei=1;var t=ye(),e=Dr(),r=Fr();return Ci=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}var $i=ee(Bi());class Ti{context;constructor(t){this.context=t}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 getUserInfo(){let t;try{t=(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}catch(t){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&&$i(t)}}class Si extends Ni{context;gitBase;changelogManager;pullRequestManager;prImpl;releaseParams;constructor(t,e){super(t,"githubPR",e),this.context=t,this.prImpl=xi(e.pullRequestInterface,t),this.gitBase=new Ti(t),this.changelogManager=new Oi(t),this.releaseParams=new _i(t.shell,t.logger,{PRTitle:this.context.shared.PRTitle,PRBody:this.context.shared.PRBody,...this.props}),this.pullRequestManager=new ji(t,this.prImpl)}enabled(){return this.context.releasePR}async onBefore(){this.logger.verbose("[before] GithubPR"),await this.gitBase.onBefore();const{repoName:t,authorName:e}=this.context.shared;await this.prImpl.init({repoName:t,authorName:e})}async onExec(){const t=await this.step({label:"Create Changelogs",task:()=>this.getComposeWorkspaces()}),e=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(this.releaseParams.getReleaseBranchParams(t,this.context.getTemplateContext()))}),r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(t,e)});this.pullRequestManager.autoMergeReleasePR?await this.mergePR(r,e.releaseBranch):this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async getComposeWorkspaces(){const t=this.context.workspaces;if(!t)throw new Error("No workspaces found");if(this.context.shared.mergePublish)return this.changelogManager.createChangeLogs(t);const e=await this.changelogManager.createChangelog();return[{...this.context.workspace,...e}]}async mergePR(t,e){await this.step({label:`Merge Release PR(${t})`,task:()=>this.pullRequestManager.mergePR(t,e)}),await this.step({label:`Checked Release PR(${t})`,task:()=>this.pullRequestManager.checkedPR(t,e)})}async createReleasePR(t,e){const r=[(await this.pullRequestManager.createReleasePRLabel()).name],n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(e,n),i=this.releaseParams.getPRBody(t,e,n);return this.pullRequestManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:e.releaseBranch,labels:r})}async createReleaseBranch(t){const{tagName:e,releaseBranch:r}=t;if("string"!=typeof e)throw new Error("Tag name is not a string");const{sourceBranch:n,currentBranch:o}=this.context.shared;this.context.logger.verbose("PR TagName is:",e),this.context.logger.verbose("PR CurrentBranch is:",o),this.context.logger.verbose("PR SourceBranch is:",n),this.context.logger.verbose("PR ReleaseBranch is:",r);try{await this.context.shell.exec(`git fetch origin ${n} ${o}`),await this.context.shell.exec(`git checkout -b ${r} ${o}`),await this.context.shell.exec(`git push origin ${r}`)}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:e,releaseBranch:r}}}class Ai extends Ni{constructor(t){super(t,"publishNpm")}enabled(){return!this.context.releasePR}async onBefore(){this.logger.verbose("PublishNpm onBefore"),await this.checkNpmAuth()}async onExec(){await this.step({label:"Publish to NPM",task:()=>this.publish()})}async publish(){return this.context.releaseIt.publishNpm()}async checkNpmAuth(){const t=this.getConfig("npmToken")||this.getEnv("NPM_TOKEN");if(!t)throw new Error("NPM_TOKEN is not set.");this.setConfig({npmToken:t}),this.getConfig("skipNpmrc")?this.logger.debug("skipNpmrc is true, skip set npmrc"):await this.shell.exec(`echo //registry.npmjs.org/:_authToken=${t} > .npmrc`,{dryRun:!1})}}class Li{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 qi extends Ni{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(t){super(t,"workspaces"),this.releaseLabel=new Li({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[]})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){this.logger.debug("Merge publish:",!!this.context.shared.mergePublish);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 r=this.context.shared.publishPath;if(r){const t=e.find((t=>n(t.root)===n(r)));if(this.nextSkip(),!t)throw new Error(`No workspace found for: ${r}`);return this.logger.debug("publishPathWorkspace find!",o(t.root,vi)),void this.setCurrentWorkspace(t,e)}const[i,...s]=e;this.workspacesList=s,this.setCurrentWorkspace(i,e)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}async onExec(){if(this.nextSkip(),this.context.shared.mergePublish)this.logger.info("Merge publish, skip Workspaces");else for(const t of this.workspacesList)this.logger.obtrusive(`workspace: ${t.name} ${t.version}`),this.setCurrentWorkspace(t),await(this.releaseTask?.run())}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"):[]}readJson(t){const e=s(t,"utf-8");return JSON.parse(e)}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(),e=await this.getChangedPackages(t,this.getConfig("changeLabels"));this.logger.debug("changedPaths",e);return e.map((t=>this.toWorkspace({path:t})))}toWorkspace(t){let{root:e,packageJson:r}=t;const n=t.path;if(!n)throw new Error("path is not required!");return e=e||o(this.context.rootPath,n),r=r||this.readJson(o(e,vi)),{name:r.name,version:r.version,path:n,root:e,packageJson:r}}}function Ii(t){return t.startsWith(".")?i(t).name:t}async function Mi(t){let e=null;try{e=(await import(t)).default}catch(r){try{e=(await import(o(process.cwd(),t))).default}catch(r){const n=a(process.cwd());e=(await import(u(n.resolve(t,{paths:[process.cwd()]})))).default}}return[Ii(t),e]}async function Wi(t,e,r=5){const n=c(r),o=e.map((([e,...r])=>n((()=>(async(e,...r)=>{if("string"==typeof e){const[,n]=await Mi(e);return xi(n,t,...r)}return xi(e,t,...r)})(e,...r)))));return Promise.all(o)}const Fi=[ki(Si,{increment:"patch",pullRequestInterface:class{octokit;options={};constructor(t){this.hasGithubToken(t)}hasGithubToken(t){const e=t.env.get("GITHUB_TOKEN")||t.env.get("PAT_TOKEN");if(!e)throw new Error("GITHUB_TOKEN or PAT_TOKEN environment variable is not set.");return this.options.token=e,!0}async init(t={}){if(this.octokit)return this.octokit;const{token:e,repoName:r,authorName:n}={...this.options,...t};if(!e)throw new Error("Github token is not set");this.options.repoName=r,this.options.authorName=n;const{Octokit:o}=await import("@octokit/rest");return this.octokit=new o({auth:e}),this.octokit}getOctokit(){if(!this.octokit)throw new Error("Octokit is not initialized");return this.octokit}mergePullRequest(t){return this.getOctokit().rest.pulls.merge({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}getPullRequest(t){return this.getOctokit().rest.pulls.get({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}deleteBranch(t){return this.getOctokit().rest.git.deleteRef({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}addPullRequestLabels(t){return this.getOctokit().rest.issues.addLabels({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}async createPullRequestLabel(t){return await this.getOctokit().rest.issues.createLabel({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}async createPullRequest(t){const e=await this.getOctokit().rest.pulls.create({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""});return{...e.data,number:e.data.number}}}}),ki(Ai),ki(qi)];class Ui{executor;defaultTuples;context;constructor(t={},e=new r,n=Fi){this.executor=e,this.defaultTuples=n,this.context=new Ri(t)}getContext(){return this.context}async usePlugins(t){t=t||this.context.shared.plugins||[];const e=await Wi(this.context,[...this.defaultTuples.filter((t=>!(!this.context.shared.releasePR&&t[0]===Si)&&(!this.context.shared.releasePR||t[0]!==Ai))),...t]);return e.forEach((t=>{t instanceof qi&&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 zi,Di,Ji,Gi;function Hi(){if(Di)return zi;Di=1;var t=co(),e=li(),r=fo(),n=we(),o=fi();return zi=function(i,s,a,u){if(!n(i))return i;for(var c=-1,h=(s=e(s,i)).length,l=h-1,f=i;null!=f&&++c<h;){var p=o(s[c]),g=a;if("__proto__"===p||"constructor"===p||"prototype"===p)return i;if(c!=l){var d=f[p];void 0===(g=u?u(d,p,f):void 0)&&(g=n(d)?d:r(s[c+1])?[]:{})}t(f,p,g),f=f[p]}return i}}function Vi(){if(Gi)return Ji;Gi=1;var t=Hi();return Ji=function(e,r,n){return null==e?e:t(e,r,n)}}var Ki=ee(Vi());function Yi(t,e){return Object.entries(t).reduce(((t,[r,n])=>(r.includes(".")?Ki(t,r,n):Ki(t,e?`${e}.${r}`:r,n),t)),{})}export{Ni as Plugin,Ri as ReleaseContext,Li as ReleaseLabel,Ui as ReleaseTask,xi as factory,Mi as load,Wi as loaderPluginsFromPluginTuples,Yi as reduceOptions,ki as tuple};
|
|
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}from"node:fs";import{createRequire as c}from"node:module";import{pathToFileURL as u}from"node:url";import h from"p-limit";import l from"conventional-changelog";import{join as f}from"path";import{existsSync as g,writeFileSync as p}from"fs";var d,m,v,y,b,w,_,x,R,k,P,C,$,N,j,B,E,O,T,S,A,L,U,F,W,M,I,z,G,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,_e,xe,Re,ke,Pe,Ce,$e,Ne,je,Be,Ee,Oe,Te,Se,Ae,Le,Ue,Fe,We,Me,Ie,ze,Ge,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(x)return _;x=1;var e=ut(),t=Array.prototype.splice;return _=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 R;k=1;var e=ut();return R=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(B)return j;B=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 E;O=1;var e=pt();return E=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(F)return U;return F=1,U=function(e){return this.__data__.has(e)}}function bt(){if(M)return W;M=1;var e="object"==typeof it&&it&&it.Object===Object&⁢return W=e}function wt(){if(z)return I;z=1;var e=bt(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return I=r}function _t(){if(D)return G;D=1;var e=wt().Symbol;return G=e}function xt(){if(q)return H;q=1;var e=_t(),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 Rt(){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=_t(),t=xt(),r=Rt(),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 Bt(){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 Et(){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=Bt(),t=Et();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(xe)return _e;xe=1;var e=St(),t=Object.prototype.hasOwnProperty;return _e=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 Ft(){if(ke)return Re;ke=1;var e=St(),t=Object.prototype.hasOwnProperty;return Re=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}function Wt(){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 Mt(){if(Ne)return $e;Ne=1;var e=At(),t=Lt(),r=Ut(),n=Ft(),o=Wt();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 It(){if(Be)return je;Be=1;var e=Mt(),t=pt(),r=Tt();return je=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}function zt(){if(Oe)return Ee;return Oe=1,Ee=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}}function Gt(){if(Se)return Te;Se=1;var e=zt();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=Gt();return Ae=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}function Ht(){if(Fe)return Ue;Fe=1;var e=Gt();return Ue=function(t){return e(this,t).get(t)}}function qt(){if(Me)return We;Me=1;var e=Gt();return We=function(t){return e(this,t).has(t)}}function Vt(){if(ze)return Ie;ze=1;var e=Gt();return Ie=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 Ge;De=1;var e=It(),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,Ge=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,_r,xr,Rr,kr,Pr,Cr,$r,Nr,jr,Br,Er,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 Fr(){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 Wr(){if(cr)return sr;cr=1;var e=Fr();return sr=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}function Mr(){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 Ir(){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 zr(){if(pr)return gr;return pr=1,gr=function(e,t){return function(r){return e(t(r))}}}function Gr(){if(mr)return dr;mr=1;var e=zr()(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=Ir(),t=Gr(),r=Dr();return br=function(n){return"function"!=typeof n.constructor||r(n)?{}:e(t(n))}}function qr(){if(xr)return _r;return xr=1,_r=function(e){return null!=e&&"object"==typeof e}}function Vr(){if(kr)return Rr;kr=1;var e=kt(),t=qr();return Rr=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(Br)return jr;Br=1;return jr=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function Qr(){if(Or)return Er;Or=1;var e=Ct(),t=Yr();return Er=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=Gr(),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,_n,xn,Rn,kn,Pn,Cn,$n,Nn,jn,Bn,En,On,Tn,Sn,An,Ln,Un,Fn,Wn,Mn,In,zn,Gn,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(_n)return wn;_n=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(Rn)return xn;Rn=1;var e=po(),t=Xt();return xn=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(En)return Bn;return En=1,Bn=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}}function _o(){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 xo(){if(An)return Sn;An=1;var e=bo(),t=_o(),r=Qr();return Sn=function(n){return r(n)?e(n,!0):t(n)}}function Ro(){if(Un)return Ln;Un=1;var e=mo(),t=xo();return Ln=function(r){return e(r,t(r))}}function ko(){if(Wn)return Fn;Wn=1;var e=Zt(),t=Lr(),r=Wr(),n=Mr(),o=Hr(),i=Jr(),a=Kr(),s=Xr(),c=ln(),u=Ct(),h=Pt(),l=fn(),f=fo(),g=go(),p=Ro();return Fn=function(d,m,v,y,b,w,_){var x=g(d,v),R=g(m,v),k=_.get(R);if(k)e(d,v,k);else{var P=w?w(x,R,v+"",d,m,_):void 0,C=void 0===P;if(C){var $=a(R),N=!$&&c(R),j=!$&&!N&&f(R);P=R,$||N||j?a(x)?P=x:s(x)?P=n(x):N?(C=!1,P=t(R,!0)):j?(C=!1,P=r(R,!0)):P=[]:l(R)||i(R)?(P=x,i(x)?P=p(x):h(x)&&!u(x)||(P=o(R))):C=!1}C&&(_.set(R,P),b(P,R,y,w,_),_.delete(R)),e(d,v,P)}}}function Po(){if(In)return Mn;In=1;var e=Yt(),t=Zt(),r=tr(),n=ko(),o=Pt(),i=xo(),a=go();return Mn=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)},Mn}function Co(){if(Gn)return zn;return Gn=1,zn=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 Bo(){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 Eo(){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=Bo(),t=Eo()(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,Fo,Wo,Mo,Io,zo,Go,Do,Ho,qo,Vo,Jo,Ko,Yo,Qo,Xo,Zo,ei,ti,ri,ni,oi,ii,ai,si=at(Lo());function ci(){if(Fo)return Uo;Fo=1;var e=kt(),t=qr();return Uo=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function ui(){if(Mo)return Wo;Mo=1;var e=Kr(),t=ci(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Wo=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(zo)return Io;zo=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,Io=t}function li(){if(Do)return Go;Do=1;var e=hi();return Go=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=_t(),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 _i="package.json",xi=[".env.local",".env"];class Ri extends e{_env;shared;constructor(e){super(e),this._env=t.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||xi}),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}}}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.context.dryRun)return void this.logger.exec(`octokit repos.createRelease "${t.name}" (${t.tag_name})`);const r=await this.octokit.repos.createRelease(t);this.logger.verbose(`octokit repos.createRelease: done (${r.headers.location})`)}}var Ni,ji;function Bi(){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 Ei=at(Bi());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 getUserInfo(){let e;try{e=(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}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&&Ei(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 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,_i)),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"):[]}readJson(e){const t=s(e,"utf-8");return JSON.parse(t)}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(),t=await this.getChangedPackages(e,this.getConfig("changeLabels"));this.logger.debug("changedPaths",t);return t.map((e=>this.toWorkspace({path:e})))}toWorkspace(e){let{root:t,packageJson:r}=e;const n=e.path;if(!n)throw new Error("path is not required!");return t=t||i(this.context.rootPath,n),r=r||this.readJson(i(t,_i)),{name:r.name,version:r.version,path:n,root:t,packageJson:r}}}function Li(e,...t){return"function"==typeof e&&e.prototype&&e.prototype.constructor===e?new e(...t):e(...t)}function Ui(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=c(process.cwd());t=(await import(u(r.resolve(e,{paths:[process.cwd()]})).href)).default}}return[Ui(e),t]}async function Wi(e,t,r=5){const n=h(r),o=t.map((([t,...r])=>n((()=>(async(t,...r)=>{if("string"==typeof t){const[,n]=await Fi(t);return Li(n,e,...r)}return Li(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(Ai),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 f(this.context.rootPath,this.getConfig("changesetRoot"))}enabled(){return!this.getConfig("skip")}async onBefore(){if(!g(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}async onExec(){const e=this.context.workspaces,t=await this.step({label:"Generate Changelogs",task:()=>Promise.all(e.map((e=>this.generate(e))))});this.logger.debug("changelogs",t),this.context.setWorkspaces(t),this.getConfig("skipChangeset")||await this.step({label:"Create Changeset Files",task:()=>Promise.all(t.map((e=>this.generateChangesetFile(e))))})}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={};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="";l(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 generate(e){const t=await this.getTagName(e);this.logger.verbose("tagName is:",t);const r=await this.createChangelog({workspace:e,lastTag:t});return{...e,tagName:t,changelog:r}}async 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=await 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 await 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=f(this.changesetRoot,`${n}.md`),i=this.shell.format("---\n'${name}': '${increment}'\n---\n${changelog}",{...e,increment:this.getIncrement()});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(i);g(o)?this.logger.info(`Changeset ${n} already exists`):p(o,i,"utf-8")}},{}),ki(class extends Ti{context;releaseParams;githubManager;constructor(e,t){super(e,"githubPR",{commandPrefix:"pnpm dlx",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"onExec"===e?!this.isPublish:"onSuccess"!==e||this.isPublish}get isPublish(){return!this.getConfig("releasePR")}async onBefore(){if(this.logger.verbose("GithubPR onBefore"),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.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;await this.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags"),await this.step({label:"Release Github",task:()=>Promise.all(e.map((e=>this.githubManager.createRelease(e))))})}async relesaeCommit(e){const t=this.getConfig("commitArgs",[]);if(await this.runChangesetsCli("version",["--no-changelog"]),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])}runChangesetsCli(e,t){return this.shell.exec([this.getConfig("commandPrefix","npx"),"@changesets/cli",e,...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 Ri(e)}getContext(){return this.context}async usePlugins(e){e=e||this.context.shared.plugins||[];const t=await Wi(this.context,[...this.defaultTuples,...e]);return t.forEach((e=>{e instanceof Ai&&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 Gi,Di,Hi,qi;function Vi(){if(Di)return Gi;Di=1;var e=po(),t=mi(),r=yo(),n=Pt(),o=vi();return Gi=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 Ji(){if(qi)return Hi;qi=1;var e=Vi();return Hi=function(t,r,n){return null==t?t:e(t,r,n)}}var Ki=at(Ji());function Yi(e,t){return Object.entries(e).reduce(((e,[r,n])=>(r.includes(".")?Ki(e,r,n):Ki(e,t?`${t}.${r}`:r,n),e)),{})}export{Oi as Plugin,Ri as ReleaseContext,Si as ReleaseLabel,zi as ReleaseTask,Li as factory,Fi as load,Wi as loaderPluginsFromPluginTuples,Yi 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": "1.0.
|
|
4
|
+
"version": "1.0.9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"homepage": "https://github.com/qlover/fe-base/tree/master/packages/fe-release",
|
|
@@ -42,7 +42,23 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"bin": {
|
|
45
|
-
"fe-release": "
|
|
45
|
+
"fe-release": "dist/cli.js"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@octokit/rest": "^21.0.2",
|
|
49
|
+
"@types/conventional-changelog": "^6.0.0",
|
|
50
|
+
"@types/semver": "^7.7.0",
|
|
51
|
+
"commander": "^11.0.0",
|
|
52
|
+
"p-limit": "^6.2.0",
|
|
53
|
+
"semver": "^7.5.4"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@octokit/rest": "^21.0.2",
|
|
57
|
+
"@qlover/env-loader": "^0.0.1",
|
|
58
|
+
"@qlover/fe-corekit": "^1.2.2",
|
|
59
|
+
"@qlover/scripts-context": "^0.0.8",
|
|
60
|
+
"conventional-changelog": "^6.0.0",
|
|
61
|
+
"lodash": "^4.17.21"
|
|
46
62
|
},
|
|
47
63
|
"scripts": {
|
|
48
64
|
"build": "rollup -c",
|
|
@@ -50,19 +66,5 @@
|
|
|
50
66
|
"release-pr": "node dist/cli.js -P",
|
|
51
67
|
"dryrun:release": "node dist/cli.js --dry-run -V",
|
|
52
68
|
"dryrun:release-pr": "node dist/cli.js -P --dry-run -V"
|
|
53
|
-
},
|
|
54
|
-
"devDependencies": {
|
|
55
|
-
"@qlover/fe-standard": "latest",
|
|
56
|
-
"@qlover/env-loader": "latest",
|
|
57
|
-
"commander": "^11.0.0",
|
|
58
|
-
"release-it": "^17.10.0",
|
|
59
|
-
"@release-it/conventional-changelog": "^8.0.1",
|
|
60
|
-
"@octokit/rest": "^21.0.2",
|
|
61
|
-
"semver": "^7.5.4",
|
|
62
|
-
"p-limit": "^6.2.0"
|
|
63
|
-
},
|
|
64
|
-
"dependencies": {
|
|
65
|
-
"@qlover/fe-corekit": "latest",
|
|
66
|
-
"@qlover/scripts-context": "latest"
|
|
67
69
|
}
|
|
68
|
-
}
|
|
70
|
+
}
|