@qlover/fe-release 2.1.6 → 2.3.0
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/README.md +22 -24
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +131 -2
- package/dist/index.js +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -164,30 +164,28 @@ fe-release [options]
|
|
|
164
164
|
"commitMessage": "chore(tag): ${name} v${version}"
|
|
165
165
|
},
|
|
166
166
|
"changelog": {
|
|
167
|
-
"
|
|
168
|
-
"
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
]
|
|
190
|
-
}
|
|
167
|
+
"types": [
|
|
168
|
+
{ "type": "feat", "section": "#### ✨ Features", "hidden": false },
|
|
169
|
+
{ "type": "fix", "section": "#### 🐞 Bug Fixes", "hidden": false },
|
|
170
|
+
{ "type": "chore", "section": "#### 🔧 Chores", "hidden": true },
|
|
171
|
+
{
|
|
172
|
+
"type": "docs",
|
|
173
|
+
"section": "#### 📝 Documentation",
|
|
174
|
+
"hidden": false
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"type": "refactor",
|
|
178
|
+
"section": "#### ♻️ Refactors",
|
|
179
|
+
"hidden": false
|
|
180
|
+
},
|
|
181
|
+
{ "type": "perf", "section": "#### 🚀 Performance", "hidden": false },
|
|
182
|
+
{ "type": "test", "section": "#### 🚨 Tests", "hidden": true },
|
|
183
|
+
{ "type": "style", "section": "#### 🎨 Styles", "hidden": true },
|
|
184
|
+
{ "type": "ci", "section": "#### 🔄 CI", "hidden": true },
|
|
185
|
+
{ "type": "build", "section": "#### 🚧 Build", "hidden": false },
|
|
186
|
+
{ "type": "revert", "section": "#### ⏪ Reverts", "hidden": true },
|
|
187
|
+
{ "type": "release", "section": "#### 🔖 Releases", "hidden": true }
|
|
188
|
+
]
|
|
191
189
|
}
|
|
192
190
|
}
|
|
193
191
|
}
|
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
"use strict";var e=require("commander"),r=require("semver"),o=require("./index.cjs");require("@qlover/scripts-context"),require("@qlover/env-loader"),require("@qlover/fe-corekit"),require("@octokit/rest"),require("node:path"),require("find-workspaces"),require("fs"),require("path"),require("node:module"),require("node:url"),require("p-limit");const t=["patch","minor","major"],n=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:i,...a}=function(){const i=new e.Command;return i.version("2.
|
|
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("gitlog"),require("node:path"),require("find-workspaces"),require("fs"),require("path"),require("node:module"),require("node:url"),require("p-limit");const t=["patch","minor","major"],n=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:i,...a}=function(){const i=new e.Command;return i.version("2.3.0","-v, --version","Show version").description("A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.").option("-d, --dry-run","Do not touch or write anything, but show the commands").option("-V, --verbose","Show more information").option("-p, --publish-path <publishPath>","The path of the package to release, map to feConfig.release.publishPath").option("-b, --branch-name <branchName>","The branch name of the release, map to feConfig.release.branchName, default(release-${pkgName}-${tagName})").option("-s, --source-branch <sourceBranch>","The source branch of the release").option("-i, --changelog.increment <increment>","The increment of the release",(e=>{if(!t.includes(e)&&!r.valid(e))throw new Error(`Invalid increment(-i) Must be one of [${t.join(", ")}] or valid version string(semver)`);return e}),"patch").option("--changelog.skip","Whether to skip the changelog").option("--changelog.ignore-non-updated-packages","Whether to ignore non updated packages").option("--changelog.skip-changeset","Whether to skip the changeset").option("--githubPR.skip","Whether to skip the githubPR").option("--packages-directories <packagesDirectories>","The packages that have been changed, multiple values use `,` to split, map to feConfig.release.packagesDirectories",n).option("--githubPR.dry-run-create-PR","Whether to dry run the creation of the pull request").option("--githubPR.push-change-labels","Whether to push the changed labels to the release PR").option("-P, --githubPR.release-PR","Create a release PR").option("-l, --workspaces.change-labels <changeLabels>","The change labels of the release, multiple values use `,` to split",n),i.parse(),o.reduceOptions(i.opts(),"shared")}(),{dryRun:s,verbose:h,...c}=i,p=Object.assign(a,{});await new o.ReleaseTask({dryRun:s,verbose:h,options:p,shared:c}).exec()})().catch((e=>{console.error(e.message),process.exit(1)}));
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
import{Command as e}from"commander";import o from"semver";import{ReleaseTask as t,reduceOptions as r}from"./index.js";import"@qlover/scripts-context";import"@qlover/env-loader";import"@qlover/fe-corekit";import"@octokit/rest";import"node:path";import"find-workspaces";import"fs";import"path";import"node:module";import"node:url";import"p-limit";const n=["patch","minor","major"],i=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:a,...s}=function(){const t=new e;return t.version("2.
|
|
2
|
+
import{Command as e}from"commander";import o from"semver";import{ReleaseTask as t,reduceOptions as r}from"./index.js";import"@qlover/scripts-context";import"@qlover/env-loader";import"@qlover/fe-corekit";import"@octokit/rest";import"gitlog";import"node:path";import"find-workspaces";import"fs";import"path";import"node:module";import"node:url";import"p-limit";const n=["patch","minor","major"],i=e=>e.split(",").filter((e=>null!=e&&""!=e));(async function(){const{shared:a,...s}=function(){const t=new e;return t.version("2.3.0","-v, --version","Show version").description("A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.").option("-d, --dry-run","Do not touch or write anything, but show the commands").option("-V, --verbose","Show more information").option("-p, --publish-path <publishPath>","The path of the package to release, map to feConfig.release.publishPath").option("-b, --branch-name <branchName>","The branch name of the release, map to feConfig.release.branchName, default(release-${pkgName}-${tagName})").option("-s, --source-branch <sourceBranch>","The source branch of the release").option("-i, --changelog.increment <increment>","The increment of the release",(e=>{if(!n.includes(e)&&!o.valid(e))throw new Error(`Invalid increment(-i) Must be one of [${n.join(", ")}] or valid version string(semver)`);return e}),"patch").option("--changelog.skip","Whether to skip the changelog").option("--changelog.ignore-non-updated-packages","Whether to ignore non updated packages").option("--changelog.skip-changeset","Whether to skip the changeset").option("--githubPR.skip","Whether to skip the githubPR").option("--packages-directories <packagesDirectories>","The packages that have been changed, multiple values use `,` to split, map to feConfig.release.packagesDirectories",i).option("--githubPR.dry-run-create-PR","Whether to dry run the creation of the pull request").option("--githubPR.push-change-labels","Whether to push the changed labels to the release PR").option("-P, --githubPR.release-PR","Create a release PR").option("-l, --workspaces.change-labels <changeLabels>","The change labels of the release, multiple values use `,` to split",i),t.parse(),r(t.opts(),"shared")}(),{dryRun:p,verbose:h,...c}=a,l=Object.assign(s,{});await new t({dryRun:p,verbose:h,options:l,shared:c}).exec()})().catch((e=>{console.error(e.message),process.exit(1)}));
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t,e,r,n,o,i,s,a,c,u,h,l,g,f,p,m,d,y,v,b,w,R,x,k,_,P,C,$,N,j,E,T,B,O,S,A,L,W,U,F,M,G,H,I,q,D,z,V,J,Y,K,Q,X,Z,tt,et,rt,nt,ot,it,st,at,ct,ut,ht,lt,gt,ft,pt,mt,dt,yt,vt,bt,wt,Rt,xt,kt,_t,Pt,Ct,$t,Nt,jt,Et,Tt,Bt,Ot,St,At,Lt,Wt,Ut,Ft,Mt,Gt,Ht,It,qt=require("@qlover/scripts-context"),Dt=require("@qlover/env-loader"),zt=require("@qlover/fe-corekit"),Vt=require("@octokit/rest"),Jt=require("node:path"),Yt=require("find-workspaces"),Kt=require("fs"),Qt=require("path"),Xt=require("node:module"),Zt=require("node:url"),te=require("p-limit"),ee="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function re(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ne(){if(e)return t;return e=1,t=function(){this.__data__=[],this.size=0}}function oe(){if(n)return r;return n=1,r=function(t,e){return t===e||t!=t&&e!=e}}function ie(){if(i)return o;i=1;var t=oe();return o=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function se(){if(a)return s;a=1;var t=ie(),e=Array.prototype.splice;return s=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 ae(){if(u)return c;u=1;var t=ie();return c=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}function ce(){if(l)return h;l=1;var t=ie();return h=function(e){return t(this.__data__,e)>-1}}function ue(){if(f)return g;f=1;var t=ie();return g=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 he(){if(m)return p;m=1;var t=ne(),e=se(),r=ae(),n=ce(),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 le(){if(y)return d;y=1;var t=he();return d=function(){this.__data__=new t,this.size=0}}function ge(){if(b)return v;return b=1,v=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}}function fe(){if(R)return w;return R=1,w=function(t){return this.__data__.get(t)}}function pe(){if(k)return x;return k=1,x=function(t){return this.__data__.has(t)}}function me(){if(P)return _;P=1;var t="object"==typeof ee&&ee&&ee.Object===Object&ⅇreturn _=t}function de(){if($)return C;$=1;var t=me(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return C=r}function ye(){if(j)return N;j=1;var t=de().Symbol;return N=t}function ve(){if(T)return E;T=1;var t=ye(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,o=t?t.toStringTag:void 0;return E=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(O)return B;O=1;var t=Object.prototype.toString;return B=function(e){return t.call(e)}}function we(){if(A)return S;A=1;var t=ye(),e=ve(),r=be(),n=t?t.toStringTag:void 0;return S=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function Re(){if(W)return L;return W=1,L=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function xe(){if(F)return U;F=1;var t=we(),e=Re();return U=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(G)return M;G=1;var t=de()["__core-js_shared__"];return M=t}function _e(){if(I)return H;I=1;var t,e=ke(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return H=function(t){return!!r&&r in t}}function Pe(){if(D)return q;D=1;var t=Function.prototype.toString;return q=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function Ce(){if(V)return z;V=1;var t=xe(),e=_e(),r=Re(),n=Pe(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,s=Object.prototype,a=i.toString,c=s.hasOwnProperty,u=RegExp("^"+a.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return z=function(i){return!(!r(i)||e(i))&&(t(i)?u:o).test(n(i))}}function $e(){if(Y)return J;return Y=1,J=function(t,e){return null==t?void 0:t[e]}}function Ne(){if(Q)return K;Q=1;var t=Ce(),e=$e();return K=function(r,n){var o=e(r,n);return t(o)?o:void 0}}function je(){if(Z)return X;Z=1;var t=Ne()(de(),"Map");return X=t}function Ee(){if(et)return tt;et=1;var t=Ne()(Object,"create");return tt=t}function Te(){if(nt)return rt;nt=1;var t=Ee();return rt=function(){this.__data__=t?t(null):{},this.size=0}}function Be(){if(it)return ot;return it=1,ot=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}}function Oe(){if(at)return st;at=1;var t=Ee(),e=Object.prototype.hasOwnProperty;return st=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 Se(){if(ut)return ct;ut=1;var t=Ee(),e=Object.prototype.hasOwnProperty;return ct=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}function Ae(){if(lt)return ht;lt=1;var t=Ee();return ht=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 Le(){if(ft)return gt;ft=1;var t=Te(),e=Be(),r=Oe(),n=Se(),o=Ae();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,gt=i}function We(){if(mt)return pt;mt=1;var t=Le(),e=he(),r=je();return pt=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function Ue(){if(yt)return dt;return yt=1,dt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}}function Fe(){if(bt)return vt;bt=1;var t=Ue();return vt=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Me(){if(Rt)return wt;Rt=1;var t=Fe();return wt=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}function Ge(){if(kt)return xt;kt=1;var t=Fe();return xt=function(e){return t(this,e).get(e)}}function He(){if(Pt)return _t;Pt=1;var t=Fe();return _t=function(e){return t(this,e).has(e)}}function Ie(){if($t)return Ct;$t=1;var t=Fe();return Ct=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 qe(){if(jt)return Nt;jt=1;var t=We(),e=Me(),r=Ge(),n=He(),o=Ie();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,Nt=i}function De(){if(Tt)return Et;Tt=1;var t=he(),e=je(),r=qe();return Et=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 ze(){if(Ot)return Bt;Ot=1;var t=he(),e=le(),r=ge(),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,Bt=s}function Ve(){if(At)return St;At=1;var t=Ne(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return St=e}function Je(){if(Wt)return Lt;Wt=1;var t=Ve();return Lt=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function Ye(){if(Ft)return Ut;Ft=1;var t=Je(),e=oe();return Ut=function(r,n,o){(void 0!==o&&!e(r[n],o)||void 0===o&&!(n in r))&&t(r,n,o)}}function Ke(){if(Gt)return Mt;return Gt=1,Mt=function(t){return function(e,r,n){for(var o=-1,i=Object(e),s=n(e),a=s.length;a--;){var c=s[t?a:++o];if(!1===r(i[c],c,i))break}return e}}}function Qe(){if(It)return Ht;It=1;var t=Ke()();return Ht=t}var Xe,Ze,tr,er,rr,nr,or,ir,sr,ar,cr,ur,hr,lr,gr,fr,pr,mr,dr,yr,vr,br,wr,Rr,xr,kr,_r,Pr,Cr,$r,Nr,jr,Er,Tr={exports:{}};function Br(){return Xe||(Xe=1,function(t,e){var 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}}(Tr,Tr.exports)),Tr.exports}function Or(){if(tr)return Ze;tr=1;var t=de().Uint8Array;return Ze=t}function Sr(){if(rr)return er;rr=1;var t=Or();return er=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function Ar(){if(or)return nr;or=1;var t=Sr();return nr=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function Lr(){if(sr)return ir;return sr=1,ir=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}}function Wr(){if(cr)return ar;cr=1;var t=Re(),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 ar=r}function Ur(){if(hr)return ur;return hr=1,ur=function(t,e){return function(r){return t(e(r))}}}function Fr(){if(gr)return lr;gr=1;var t=Ur()(Object.getPrototypeOf,Object);return lr=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 Gr(){if(dr)return mr;dr=1;var t=Wr(),e=Fr(),r=Mr();return mr=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function Hr(){if(vr)return yr;return vr=1,yr=function(t){return null!=t&&"object"==typeof t}}function Ir(){if(wr)return br;wr=1;var t=we(),e=Hr();return br=function(r){return e(r)&&"[object Arguments]"==t(r)}}function qr(){if(xr)return Rr;xr=1;var t=Ir(),e=Hr(),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 Rr=i}function Dr(){if(_r)return kr;_r=1;var t=Array.isArray;return kr=t}function zr(){if(Cr)return Pr;Cr=1;return Pr=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Vr(){if(Nr)return $r;Nr=1;var t=xe(),e=zr();return $r=function(r){return null!=r&&e(r.length)&&!t(r)}}function Jr(){if(Er)return jr;Er=1;var t=Vr(),e=Hr();return jr=function(r){return e(r)&&t(r)}}var Yr,Kr,Qr,Xr,Zr,tn,en,rn,nn,on={exports:{}};function sn(){if(Kr)return Yr;return Kr=1,Yr=function(){return!1}}function an(){return Qr||(Qr=1,function(t,e){var r=de(),n=sn(),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}(on,on.exports)),on.exports}function cn(){if(Zr)return Xr;Zr=1;var t=we(),e=Fr(),r=Hr(),n=Function.prototype,o=Object.prototype,i=n.toString,s=o.hasOwnProperty,a=i.call(Object);return Xr=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var o=e(n);if(null===o)return!0;var c=s.call(o,"constructor")&&o.constructor;return"function"==typeof c&&c instanceof c&&i.call(c)==a}}function un(){if(en)return tn;en=1;var t=we(),e=zr(),r=Hr(),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)&&e(o.length)&&!!n[t(o)]}}function hn(){if(nn)return rn;return nn=1,rn=function(t){return function(e){return t(e)}}}var ln,gn,fn,pn,mn,dn,yn,vn,bn,wn,Rn,xn,kn,_n,Pn,Cn,$n,Nn,jn,En,Tn,Bn,On,Sn,An,Ln,Wn,Un,Fn,Mn,Gn,Hn,In,qn,Dn,zn,Vn,Jn,Yn,Kn,Qn,Xn,Zn,to,eo,ro,no,oo,io,so={exports:{}};function ao(){return ln||(ln=1,function(t,e){var r=me(),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}(so,so.exports)),so.exports}function co(){if(fn)return gn;fn=1;var t=un(),e=hn(),r=ao(),n=r&&r.isTypedArray,o=n?e(n):t;return gn=o}function uo(){if(mn)return pn;return mn=1,pn=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function ho(){if(yn)return dn;yn=1;var t=Je(),e=oe(),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 lo(){if(bn)return vn;bn=1;var t=ho(),e=Je();return vn=function(r,n,o,i){var s=!o;o||(o={});for(var a=-1,c=n.length;++a<c;){var u=n[a],h=i?i(o[u],r[u],u,o,r):void 0;void 0===h&&(h=r[u]),s?e(o,u,h):t(o,u,h)}return o}}function go(){if(Rn)return wn;return Rn=1,wn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}}function fo(){if(kn)return xn;kn=1;var t=/^(?:0|[1-9]\d*)$/;return xn=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 _n;Pn=1;var t=go(),e=qr(),r=Dr(),n=an(),o=fo(),i=co(),s=Object.prototype.hasOwnProperty;return _n=function(a,c){var u=r(a),h=!u&&e(a),l=!u&&!h&&n(a),g=!u&&!h&&!l&&i(a),f=u||h||l||g,p=f?t(a.length,String):[],m=p.length;for(var d in a)!c&&!s.call(a,d)||f&&("length"==d||l&&("offset"==d||"parent"==d)||g&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||o(d,m))||p.push(d);return p}}function mo(){if($n)return Cn;return $n=1,Cn=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}}function yo(){if(jn)return Nn;jn=1;var t=Re(),e=Mr(),r=mo(),n=Object.prototype.hasOwnProperty;return Nn=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 vo(){if(Tn)return En;Tn=1;var t=po(),e=yo(),r=Vr();return En=function(n){return r(n)?t(n,!0):e(n)}}function bo(){if(On)return Bn;On=1;var t=lo(),e=vo();return Bn=function(r){return t(r,e(r))}}function wo(){if(An)return Sn;An=1;var t=Ye(),e=Br(),r=Ar(),n=Lr(),o=Gr(),i=qr(),s=Dr(),a=Jr(),c=an(),u=xe(),h=Re(),l=cn(),g=co(),f=uo(),p=bo();return Sn=function(m,d,y,v,b,w,R){var x=f(m,y),k=f(d,y),_=R.get(k);if(_)t(m,y,_);else{var P=w?w(x,k,y+"",m,d,R):void 0,C=void 0===P;if(C){var $=s(k),N=!$&&c(k),j=!$&&!N&&g(k);P=k,$||N||j?s(x)?P=x:a(x)?P=n(x):N?(C=!1,P=e(k,!0)):j?(C=!1,P=r(k,!0)):P=[]:l(k)||i(k)?(P=x,i(x)?P=p(x):h(x)&&!u(x)||(P=o(k))):C=!1}C&&(R.set(k,P),b(P,k,v,w,R),R.delete(k)),t(m,y,P)}}}function Ro(){if(Wn)return Ln;Wn=1;var t=ze(),e=Ye(),r=Qe(),n=wo(),o=Re(),i=vo(),s=uo();return Ln=function a(c,u,h,l,g){c!==u&&r(u,(function(r,i){if(g||(g=new t),o(r))n(c,u,i,h,a,l,g);else{var f=l?l(s(c,i),r,i+"",c,u,g):void 0;void 0===f&&(f=r),e(c,i,f)}}),i)},Ln}function xo(){if(Fn)return Un;return Fn=1,Un=function(t){return t}}function ko(){if(Gn)return Mn;return Gn=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 _o(){if(In)return Hn;In=1;var t=ko(),e=Math.max;return Hn=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),c=Array(a);++s<a;)c[s]=i[n+s];s=-1;for(var u=Array(n+1);++s<n;)u[s]=i[s];return u[n]=o(c),t(r,this,u)}},Hn}function Po(){if(Dn)return qn;return Dn=1,qn=function(t){return function(){return t}}}function Co(){if(Vn)return zn;Vn=1;var t=Po(),e=Ve();return zn=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:xo()}function $o(){if(Yn)return Jn;Yn=1;var t=Date.now;return Jn=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)}},Jn}function No(){if(Qn)return Kn;Qn=1;var t=Co(),e=$o()(t);return Kn=e}function jo(){if(Zn)return Xn;Zn=1;var t=xo(),e=_o(),r=No();return Xn=function(n,o){return r(e(n,o,t),n+"")}}function Eo(){if(eo)return to;eo=1;var t=oe(),e=Vr(),r=fo(),n=Re();return to=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 To(){if(no)return ro;no=1;var t=jo(),e=Eo();return ro=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 c=n[o];c&&r(t,c,o,s)}return t}))}}function Bo(){if(io)return oo;io=1;var t=Ro(),e=To()((function(e,r,n){t(e,r,n)}));return oo=e}var Oo,So,Ao,Lo,Wo,Uo,Fo,Mo,Go,Ho,Io,qo,Do,zo,Vo,Jo,Yo,Ko,Qo,Xo,Zo,ti,ei,ri,ni=re(Bo());function oi(){if(So)return Oo;So=1;var t=we(),e=Hr();return Oo=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function ii(){if(Lo)return Ao;Lo=1;var t=Dr(),e=oi(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Ao=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 si(){if(Uo)return Wo;Uo=1;var t=qe();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,Wo=e}function ai(){if(Mo)return Fo;Mo=1;var t=si();return Fo=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function ci(){if(Ho)return Go;Ho=1;var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,e=/\\(\\)?/g,r=ai()((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 Go=r}function ui(){if(qo)return Io;return qo=1,Io=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 hi(){if(zo)return Do;zo=1;var t=ye(),e=ui(),r=Dr(),n=oi(),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 li(){if(Jo)return Vo;Jo=1;var t=hi();return Vo=function(e){return null==e?"":t(e)}}function gi(){if(Ko)return Yo;Ko=1;var t=Dr(),e=ii(),r=ci(),n=li();return Yo=function(o,i){return t(o)?o:e(o,i)?[o]:r(n(o))}}function fi(){if(Xo)return Qo;Xo=1;var t=oi();return Qo=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(ti)return Zo;ti=1;var t=gi(),e=fi();return Zo=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},Zo}function mi(){if(ri)return ei;ri=1;var t=pi();return ei=function(e,r,n){var o=null==e?void 0:t(e,r);return void 0===o?n:o},ei}var di=re(mi());const yi="package.json",vi=[".env.local",".env"];class bi extends qt.FeScriptContext{_env;shared;constructor(t){super(t),this._env=Dt.Env.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||vi}),this.shared=Object.assign({},this.feConfig.release,this.getDefaultShreadOptions(t.shared))}getDefaultShreadOptions(t){return{rootPath:process.cwd(),sourceBranch:this._env.get("FE_RELEASE_BRANCH")||this._env.get("FE_RELEASE_SOURCE_BRANCH")||"master",releaseEnv:this._env.get("FE_RELEASE_ENV")||this._env.get("NODE_ENV")||"development",...t}}get rootPath(){return this.shared.rootPath}get sourceBranch(){return this.shared.sourceBranch}get releaseEnv(){return this.shared.releaseEnv}get env(){return this._env}get workspaces(){return this.getConfig("workspaces.workspaces")}get workspace(){return this.getConfig("workspaces.workspace")}setWorkspaces(t){this.options.workspaces={...this.options.workspaces,workspaces:t}}setConfig(t){this.options=ni(this.options,t)}getConfig(t,e){return di(this.options,t,e)}setShared(t){this.shared=ni(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}}async runChangesetsCli(t,e){let r="pnpm";try{await this.shell.exec("pnpm -v",{dryRun:!1})}catch{r="npx"}return await this.shell.exec([r,"changeset",t,...e??[]])}}function wi(t,...e){return[t,...e]}const Ri={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages-${timestamp}",batchTagName:"batch-${length}-packages-${timestamp}"};class xi{shell;logger;config;constructor(t,e,r={}){this.shell=t,this.logger=e,this.config={...Ri,...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.debug("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.debug("Release Batch Branch template is:",o),this.shell.format(o,{pkgName:t,releaseName:t,tagName:e,...r,length:n,timestamp:Date.now()})}getReleaseName(t){if(1===t.length)return t[0].name;const{maxWorkspace:e,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return t.slice(0,e).map((({name:t,version:e})=>`${t}${n}${e}`)).join(r)}getReleaseTagName(t){if(1===t.length)return t[0].version;const{batchTagName:e}=this.config;return this.shell.format(e,{length:t.length,timestamp:Date.now()})}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))).join("\n"):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 ki{context;_octokit=null;constructor(t){this.context=t}getGitHubUserInfo(){const{authorName:t,repoName:e}=this.context.shared;if(!t||!e)throw new Error("Author name or repo name is not set");return{owner:t,repo:e}}getToken(){const{tokenRef:t="GITHUB_TOKEN"}=this.context.getConfig("githubPR"),e=this.context.env.get(t);if(!e)throw new Error(`Token is not set. Please set ${t} environment variable.`);return e}get octokit(){if(this._octokit)return this._octokit;const{timeout:t}=this.context.getConfig("githubPR"),e={auth:this.getToken(),request:{timeout:t}};return this._octokit=new Vt.Octokit(e),this._octokit}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.shared.autoMergeType||"squash"}get dryRunPRNumber(){return this.context.getConfig("githubPR.dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.shared.autoMergeReleasePR||false}async mergePR(t,e){if(!t)return void this.logger.error("Failed to create Pull Request.",t);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.context.shared;this.logger.info(`[DRY RUN] Would merge PR #${t} with method '${r}' in repo ${o}/${n}, branch ${e}`)}else await this.octokit.rest.pulls.merge({...this.getGitHubUserInfo(),pull_number:Number(t),merge_method:r})}async checkedPR(t,e){try{await this.octokit.rest.pulls.get({...this.getGitHubUserInfo(),pull_number:Number(t)}),await this.octokit.rest.git.deleteRef({...this.getGitHubUserInfo(),ref:`heads/${e}`}),this.logger.info(`Branch ${e} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${t} or branch ${e} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const t=this.context.shared.label;if(!(t&&t.name&&t.description&&t.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",t),t;try{const e=await this.octokit.rest.issues.createLabel({...this.getGitHubUserInfo(),name:t.name,description:t.description,color:t.color.replace("#","")});return this.logger.debug("Create PR label Success",e),t}catch(e){if(422===e.status)return this.logger.warn(`Label ${t.name} already exists, skipping!`),t;throw this.logger.error("Create PR label Failed",e),e}}async createReleasePR(t){if(this.context.getConfig("githubPR.dryRunCreatePR")||this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...t,labels:t.labels}),this.dryRunPRNumber;try{const e=await this.octokit.rest.pulls.create({...this.getGitHubUserInfo(),...t}),r=e.data.number;if(!r)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",[e?.url]),t.labels&&t.labels.length){const e=await this.octokit.rest.issues.addLabels({...this.getGitHubUserInfo(),issue_number:r,labels:t.labels});this.logger.debug("Add PR label Success",[e.url])}return r.toString()}catch(t){if(422===t.status&&t.message.includes("already exists")){this.logger.warn("PR already exists");const e=t.message.match(/pull request #(\d+)/);return e?e[1]:""}throw this.logger.error("Failed to create PR",t),t}}truncateBody(t){return t&&t.length>=124e3?t.substring(0,124e3)+"...":t}getOctokitReleaseOptions(t){const{releaseName:e,draft:r=!1,preRelease:n=!1,autoGenerate:o=!1,makeLatest:i=!0,releaseNotes:s,discussionCategoryName:a}=this.context.getConfig("githubPR"),c=e,u=o?"":this.truncateBody(String(s));return{name:c,make_latest:i.toString(),body:u,draft:r,prerelease:n,generate_release_notes:o,discussion_category_name:a,tag_name:"",...t,...this.getGitHubUserInfo()}}async createRelease(t){const e=this.getOctokitReleaseOptions({tag_name:t.tagName,body:t.changelog});if(e.name=this.shell.format(e.name,t),this.logger.log(`[DRY RUN] octokit repos.createRelease "${e.name}" (${e.tag_name})`,{isDryRun:this.context.dryRun}),!e.tag_name)throw new Error("TagName is undefined");if(!this.context.dryRun)try{const t=await this.octokit.repos.createRelease(e);this.logger.debug(`[DONE] octokit repos.createRelease "${e.name}" (${e.tag_name}) (${t.headers.location})`)}catch(t){this.logger.error(`[FAILED] octokit repos.createRelease "${e.name}" (${e.tag_name})`,t)}}}var _i,Pi;function Ci(){if(Pi)return _i;Pi=1;var t=we(),e=Dr(),r=Hr();return _i=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}var $i=re(Ci());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],r=di(this.context.shared,this.pluginName);return e||t?ni({},r,t,e):{}}get logger(){return this.context.logger}get shell(){return this.context.shell}get options(){return this.context.getConfig(this.pluginName,{})}getEnv(t,e){return this.context.env.get(t)??e}enabled(t,e){return!0}getConfig(t,e){return t?this.context.getConfig([this.pluginName,...Array.isArray(t)?t:[t]],e):this.context.getConfig(this.pluginName,e)}setConfig(t){this.context.setConfig({[this.pluginName]:t})}onBefore(t){}onExec(t){}onSuccess(t){}onError(t){}async step({label:t,task:e}){this.logger.log(),this.logger.info(t),this.logger.log();try{const r=await e();return this.logger.info(`${t} - success`),r}catch(t){throw this.logger.error(t),t}}}class ji extends Ni{async onBefore(){const t=await this.getUserInfo();if(!t)throw new Error("Failed to get repoInfo");let e=this.context.shared.currentBranch;e||(e=await this.getCurrentBranch()),e&&await this.context.shell.exec(`git checkout ${e}`,{dryRun:!1}),this.context.setShared({repoName:t.repoName,authorName:t.authorName,currentBranch:e})}async getCurrentBranch(){return await new Promise((t=>setTimeout(t,100))),this.context.shell.exec("git rev-parse --abbrev-ref HEAD",{dryRun:!1})}async getRemoteUrl(){return(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}async getUserInfo(){let t;try{t=await this.getRemoteUrl()}catch{throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!t)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.debug("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)}commit(t,e=[]){return this.context.shell.exec(["git","commit","--message",JSON.stringify(t),...e])}}class Ei{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 Ti{static readJson(t){const e=Kt.readFileSync(t,"utf-8");return JSON.parse(e)}static toWorkspace(t,e){let{root:r,packageJson:n}=t;const o=t.path;if(!o)throw new Error("path is not required!");return r=r||Qt.join(e,o),n=n||Ti.readJson(Qt.join(r,yi)),{name:n.name,version:n.version,path:o,root:r,packageJson:n}}}class Bi extends Ni{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(t){super(t,"workspaces"),this.releaseLabel=new Ei({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[],compare:(t,e)=>Jt.resolve(t).startsWith(Jt.resolve(e))})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){const t=this.getConfig("workspace");if(t)return this.logger.debug("Use the specified workspace",t),void this.setCurrentWorkspace(t,[]);const e=await this.getWorkspaces();if(this.getConfig("skipCheckPackage")||0===e.length)throw new Error("No changes to publish packages");const{publishPath:r}=this.context.shared;if(r){const t=e.find((t=>Jt.resolve(t.root)===Jt.resolve(r)));if(this.nextSkip(),!t)throw new Error(`No workspace found for: ${r}`);return this.logger.debug(`Workspace of ${r} find!`,Jt.join(t.root,yi)),void this.setCurrentWorkspace(t,[t])}const[n,...o]=e;this.workspacesList=o,this.setCurrentWorkspace(n,e)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}setReleaseTask(t){this.releaseTask=t}setCurrentWorkspace(t,e){this.context.setShared({publishPath:t.path}),this.setConfig({workspace:t,workspaces:e})}async getGitWorkspaces(){const t=this.context.sourceBranch,e=await this.shell.exec(`git diff --name-only origin/${t}...HEAD`,{dryRun:!1});return"string"==typeof e?e.split("\n"):[]}async getChangedPackages(t,e){if(this.logger.debug("changeLabels",e),Array.isArray(e)&&e.length>0){const r=t.filter((t=>{const r=this.releaseLabel.toChangeLabel(t);return e.includes(r)}));return this.logger.debug("changed by labels",r),r}const r=await this.getGitWorkspaces();return this.logger.debug("changed by git",r),this.releaseLabel.pick(r,t)}getProjectWorkspaces(){const t=this.context.rootPath,e=this.context.shared.packagesDirectories;if(Array.isArray(e)&&e.length>0)return e.map((e=>Ti.toWorkspace({path:e},t)));return(Yt.findWorkspaces(t)||[]).map((e=>({name:e.package.name,version:e.package.version,path:Jt.relative(t,e.location),root:Jt.resolve(t,e.location),packageJson:e.package})))}async getWorkspaces(){const t=this.getProjectWorkspaces(),e=t.map((({path:t})=>t));this.logger.debug("packages",e);const r=this.getConfig("changeLabels"),n=await this.getChangedPackages(e,r);return this.setConfig({packages:e,changedPaths:n,projectWorkspaces:t}),this.logger.debug("changedPaths",n),t.filter((t=>n.includes(t.path)))}}function Oi(t,...e){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t?new t(...e):t(...e)}function Si(t){return t.startsWith(".")?Jt.parse(t).name:t}async function Ai(t){let e=null;try{e=(await import(t)).default}catch{try{e=(await import(Jt.join(process.cwd(),t))).default}catch{const r=Xt.createRequire(process.cwd());e=(await import(Zt.pathToFileURL(r.resolve(t,{paths:[process.cwd()]})).href)).default}}return[Si(t),e]}async function Li(t,e,r=5){const n=te(r),o=e.map((([e,...r])=>n((()=>(async(e,...r)=>{if("string"==typeof e){const[,n]=await Ai(e);return Oi(n,t,...r)}return Oi(e,t,...r)})(e,...r)))));return Promise.all(o)}const Wi="- ${message}${prRef}\n",Ui="%H%n%s%n%b%n----------------------";class Fi{formatFlatCommits(t,e,r){const{types:n=[],formatTemplate:o=Wi}=e,i=new Map;for(const e of t){const t=e.type||"other";i.has(t)||i.set(t,[]),i.get(t).push(e)}const s=[];for(const{type:t,section:e,hidden:a}of n){if(a)continue;const n=i.get(t);if(n?.length){s.push(`${e||t}`);for(const t of n){const e=t.prNumber?` (#${t.prNumber})`:"";if(s.push(r.format(o,{...t,prRef:e})),t.body){const e=t.body.split("\n").map((t=>` ${t}`));s.push(e.join("\n"))}}}}return s}}class Mi{shell;options;constructor(t,e){this.shell=t,this.options=e}parseCommitBody(t){const e=t.split("\n").filter(Boolean),r=[];let n=null;for(let t=0;t<e.length;t++){const o=e[t].trim();if(o.startsWith("Co-authored-by:")||"---------"===o||0===o.length)continue;const i=o.match(/^\*?\s*(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);if(i&&o.startsWith("*")){n&&r.push({...n,body:n.bodyLines?.join("\n").trim()});const[t,e,s,a]=i;n={matchRaw:t,raw:o,type:e?.toLowerCase(),scope:s?.trim(),message:a.trim(),bodyLines:[]}}else n&&o.startsWith("-")&&n.bodyLines?.push(o)}return n&&r.push({...n,body:n.bodyLines?.join("\n").trim()}),r}async getPRCommits(t){const{from:e,to:r,directory:n,format:o}={...this.options,...t};return(await this.getLog({from:e,to:r,directory:n,format:o,noMerges:!1})).split("\n----------------------\n").filter(Boolean).map((t=>{const[e,r,...n]=t.trim().split("\n"),o=n.join("\n"),i=r.match(/\(#(\d+)\)/),s=r.replace(/\s*\(#\d+\)\s*$/,"").match(/^(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);return{hash:e,raw:{title:r,body:o},title:s?{type:s[1]?.toLowerCase(),scope:s[2]?.trim(),message:s[3].trim()}:{message:r.replace(/\s*\(#\d+\)\s*$/,"").trim()},commits:this.parseCommitBody(o),prNumber:i?.[1]}}))}async hasTag(t){return this.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((()=>!0)).catch((()=>!1))}async resolveTag(t,e){if(t)try{if(await this.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((t=>!!t.trim())))return t}catch{}return"root"===e?this.shell.exec("git rev-list --max-parents=0 HEAD",{dryRun:!1}).then((t=>t.trim())):"HEAD"}async getLog(t){const{directory:e,format:r=Ui,noMerges:n=!0}=t;if(t.logCommand)return this.shell.exec(t.logCommand,{dryRun:!1});const o=await this.resolveTag(t.from,"root"),i=await this.resolveTag(t.to,"HEAD"),s=`git log --pretty=format:"${r}" ${n?"--no-merges":""} ${o===i?i:`${o}..${i}`} ${e?`-- "${e}"`:""}`;return this.shell.exec(s.trim(),{dryRun:!1})}flatCommits(t){const e=[];for(const r of t){const t={title:r.title,raw:r.raw,hash:r.hash,prNumber:r.prNumber};if(Array.isArray(r.commits)&&r.commits.length>0){const n=r.commits.map((e=>({...e,prNumber:r.prNumber,hash:r.hash,parentHash:r.hash,parentCommit:t})));e.push(...n)}else e.push({raw:r.raw.title,type:r.title.type,scope:r.title.scope,message:r.title.message,body:r.raw.body,prNumber:r.prNumber,hash:r.hash,parentHash:r.hash,parentCommit:t})}return e}formatFlatCommits(t,e){const{types:r=[],formatter:n}={...this.options,...e};return(n||new Fi).formatFlatCommits(t,{types:r},this.shell)}}const Gi=[wi(Bi),wi(class extends Ni{constructor(t,e){super(t,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...e})}get changesetRoot(){return Qt.join(this.context.rootPath,this.getConfig("changesetRoot"))}get changesetConfigPath(){return Qt.join(this.changesetRoot,"config.json")}enabled(){return!this.getConfig("skip")}async onBefore(){if(!Kt.existsSync(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}mergeWorkspaces(t){return t.map((t=>{const e=Ti.toWorkspace({path:t.path},this.context.rootPath),r={...t,version:e.version};return r.tagName=this.generateTagName(r),r}))}async onExec(){const t=await this.step({label:"Generate Changelogs",task:()=>Promise.all(this.context.workspaces.map((t=>this.generateChangelog(t))))});this.getConfig("skipChangeset")?this.logger.debug("Skip generate changeset files"):(await this.step({label:"Changeset Version",task:()=>Promise.all(t.map((t=>this.generateChangesetFile(t))))}),await this.context.runChangesetsCli("version",["--no-changelog","--update-dependencies"]),this.getConfig("ignoreNonUpdatedPackages")&&await this.restoreIgnorePackages());const e=this.mergeWorkspaces(t);this.logger.debug("new workspaces",e),this.context.setWorkspaces(e)}async restoreIgnorePackages(){const{changedPaths:t=[],packages:e=[]}=this.context.getConfig("workspaces"),r=e.filter((e=>!t.includes(e))).map((t=>Ti.toWorkspace({path:t},this.context.rootPath).path));this.logger.debug("noChangedPackages",r),await this.shell.exec(["git","restore",...r])}getTagPrefix(t){return this.shell.format(this.getConfig("tagPrefix"),t)}async createChangelog({lastTag:t,workspace:e}){const r=new Mi(this.context.shell,{...this.getConfig("gitChangelogOptions"),from:t,directory:e.path});return r.getPRCommits().then((t=>{const e=r.flatCommits(t);return r.formatFlatCommits(e).join("\n")}))}async generateChangelog(t){const e=await this.getTagName(t);this.logger.debug("tagName is:",e);const r=await this.createChangelog({workspace:t,lastTag:e});return{...t,lastTag:e,changelog:r}}generateTagName(t){try{const e=this.getConfig("tagTemplate");return this.shell.format(e,t)}catch(e){return console.error(`Error generating tag name for ${t.name}:`,e),`${t.name}-v0.0.0`}}async getTagName(t){try{const e=this.generateTagName(t),r=this.shell.format(this.getConfig("tagMatch"),t),n=await this.shell.exec(`git for-each-ref --sort=-creatordate --format "%(refname:short)|%(creatordate:iso8601)" "refs/tags/${r}"`,{dryRun:!1});if(!n)return e;const o=n.split("\n").filter(Boolean);if(0===o.length)return e;return o[0].split("|")[0]}catch(e){console.error(`Error getting tag for ${t.name}:`,e);return this.generateTagName(t)}}getIncrement(){const t=this.context.getConfig("workspaces.changeLabels");if(Array.isArray(t)&&t.length>0){if(t.includes("increment:major"))return"major";if(t.includes("increment:minor"))return"minor"}return this.getConfig("increment","patch")}async generateChangesetFile(t){const{name:e,version:r}=t,n=`${e}-${r}`.replace(/[\/\\]/g,"_"),o=Qt.join(this.changesetRoot,`${n}.md`),i=this.getIncrement();this.logger.debug("increment is:",[i]);const s=this.shell.format("---\n'${name}': '${increment}'\n---\n\n${changelog}",{...t,increment:i});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(s);Kt.existsSync(o)?this.logger.info(`Changeset ${n} already exists`):Kt.writeFileSync(o,s,"utf-8")}},{}),wi(class extends ji{context;releaseParams;githubManager;constructor(t,e){super(t,"githubPR",{releaseName:"Release ${name} v${version}",...e}),this.context=t,this.githubManager=new ki(this.context),this.releaseParams=new xi(t.shell,t.logger,{PRTitle:this.getConfig("PRTitle",this.context.shared.PRTitle),PRBody:this.getConfig("PRBody",this.context.shared.PRBody),...this.props})}enabled(t){return!this.getConfig("skip")&&("onExec"===t?!this.isPublish:"onSuccess"!==t||this.isPublish)}get isPublish(){return!this.getConfig("releasePR")}async isGithubRepository(){try{return(await this.getRemoteUrl()).includes("github.com")}catch{return!1}}async onBefore(){this.logger.debug("GithubPR onBefore");if(!await this.isGithubRepository())throw new Error("Current repository is not a GitHub repository. GitHub PR workflow is only available for GitHub repositories.");if(await super.onBefore(),this.isPublish){const t=this.getEnv("NPM_TOKEN");if(!t)throw new Error("NPM_TOKEN is not set");await this.shell.exec(`npm config set //registry.npmjs.org/:_authToken=${t}`)}}async onExec(){const t=this.context.workspaces;await this.step({label:"Release Commit",task:()=>this.relesaeCommit(t)});const e=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(t)});await this.releasePullRequest(t,e)}async onSuccess(){const t=this.context.workspaces;this.getConfig("dryRunCreatePR")||(await this.context.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags")),await this.step({label:"Release Github",task:()=>Promise.all(t.map((t=>(this.logger.debug(t),this.githubManager.createRelease(t)))))})}async relesaeCommit(t){const e=this.getConfig("commitArgs",[]);if(1===t.length)return await this.shell.exec("git add ."),void await this.commitWorkspace(t[0],e);await this.shell.exec("git add .");const r=`chore(tag): ${t.map((t=>`${t.name} v${t.version}`)).join(",")}`;await this.commit(r,e)}async releasePullRequest(t,e){const r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(t,e)});if(this.githubManager.autoMergeReleasePR){const{releaseBranch:t}=e;return await this.step({label:`Merge Release PR(${r})`,task:()=>this.githubManager.mergePR(r,t)}),void await this.step({label:`Checked Release PR(${r})`,task:()=>this.githubManager.checkedPR(r,t)})}this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async commitWorkspace(t,e=[]){const r=this.shell.format(this.getConfig("commitMessage","chore(tag): ${name} v${version}"),t);return await this.commit(r,e)}async createReleaseBranch(t){const e=this.releaseParams.getReleaseBranchParams(t,this.context.getTemplateContext()),{tagName:r,releaseBranch:n}=e;if("string"!=typeof r)throw new Error("Tag name is not a string");const{sourceBranch:o,currentBranch:i}=this.context.shared;this.context.logger.debug("PR TagName is:",r),this.context.logger.debug("PR CurrentBranch is:",i),this.context.logger.debug("PR SourceBranch is:",o),this.context.logger.debug("PR ReleaseBranch is:",n);try{await this.context.shell.exec(`git fetch origin ${o} ${i}`),await this.context.shell.exec(`git checkout -b ${n} ${i}`),await this.context.shell.exec(`git push origin ${n}`)}catch(t){throw t.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),t}return{tagName:r,releaseBranch:n}}async createReleasePR(t,e){let r=[(await this.githubManager.createReleasePRLabel()).name];if(this.getConfig("pushChangeLabels")){const t=this.context.getConfig("workspaces.changeLabels");Array.isArray(t)&&t.length>0&&r.push(...t)}r=Array.from(new Set(r)),this.logger.debug("Release PR labels:",r);const n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(e,n),i=this.releaseParams.getPRBody(t,e,n);return this.githubManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:e.releaseBranch,labels:r})}},{})];var Hi,Ii,qi,Di;function zi(){if(Ii)return Hi;Ii=1;var t=ho(),e=gi(),r=fo(),n=Re(),o=fi();return Hi=function(i,s,a,c){if(!n(i))return i;for(var u=-1,h=(s=e(s,i)).length,l=h-1,g=i;null!=g&&++u<h;){var f=o(s[u]),p=a;if("__proto__"===f||"constructor"===f||"prototype"===f)return i;if(u!=l){var m=g[f];void 0===(p=c?c(m,f,g):void 0)&&(p=n(m)?m:r(s[u+1])?[]:{})}t(g,f,p),g=g[f]}return i},Hi}function Vi(){if(Di)return qi;Di=1;var t=zi();return qi=function(e,r,n){return null==e?e:t(e,r,n)},qi}var Ji=re(Vi());exports.Plugin=Ni,exports.ReleaseContext=bi,exports.ReleaseLabel=Ei,exports.ReleaseTask=class{executor;defaultTuples;context;constructor(t={},e=new zt.AsyncExecutor,r=Gi){this.executor=e,this.defaultTuples=r,this.context=new bi(t)}getContext(){return this.context}async usePlugins(t){t=t||this.context.shared.plugins||[];const e=await Li(this.context,[...this.defaultTuples,...t]);return e.forEach((t=>{t instanceof Bi&&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()}},exports.factory=Oi,exports.load=Ai,exports.loaderPluginsFromPluginTuples=Li,exports.reduceOptions=function(t,e){return Object.entries(t).reduce(((t,[r,n])=>(r.includes(".")?Ji(t,r,n):Ji(t,e?`${e}.${r}`:r,n),t)),{})},exports.tuple=wi;
|
|
1
|
+
"use strict";var t,e,r,n,o,i,a,s,u,c,h,f,l,g,p,m,v,d,b,y,w,k,_,R,x,P,j,C,$,N,O,E,B,T,S,A,L,W,U,M,F,G,D,H,q,I,z,V,J,Y,K,Q,X,Z,tt,et,rt,nt,ot,it,at,st,ut,ct,ht,ft,lt,gt,pt,mt,vt,dt,bt,yt,wt,kt,_t,Rt,xt,Pt,jt,Ct,$t,Nt,Ot,Et,Bt,Tt,St,At,Lt,Wt,Ut,Mt,Ft,Gt,Dt,Ht,qt=require("@qlover/scripts-context"),It=require("@qlover/env-loader"),zt=require("@qlover/fe-corekit"),Vt=require("@octokit/rest"),Jt=require("gitlog"),Yt=require("node:path"),Kt=require("find-workspaces"),Qt=require("fs"),Xt=require("path"),Zt=require("node:module"),te=require("node:url"),ee=require("p-limit"),re="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ne(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function oe(){if(e)return t;return e=1,t=function(){this.__data__=[],this.size=0}}function ie(){if(n)return r;return n=1,r=function(t,e){return t===e||t!=t&&e!=e}}function ae(){if(i)return o;i=1;var t=ie();return o=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function se(){if(s)return a;s=1;var t=ae(),e=Array.prototype.splice;return a=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 ue(){if(c)return u;c=1;var t=ae();return u=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}function ce(){if(f)return h;f=1;var t=ae();return h=function(e){return t(this.__data__,e)>-1}}function he(){if(g)return l;g=1;var t=ae();return l=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 fe(){if(m)return p;m=1;var t=oe(),e=se(),r=ue(),n=ce(),o=he();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 le(){if(d)return v;d=1;var t=fe();return v=function(){this.__data__=new t,this.size=0}}function ge(){if(y)return b;return y=1,b=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}}function pe(){if(k)return w;return k=1,w=function(t){return this.__data__.get(t)}}function me(){if(R)return _;return R=1,_=function(t){return this.__data__.has(t)}}function ve(){if(P)return x;P=1;var t="object"==typeof re&&re&&re.Object===Object&&re;return x=t}function de(){if(C)return j;C=1;var t=ve(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return j=r}function be(){if(N)return $;N=1;var t=de().Symbol;return $=t}function ye(){if(E)return O;E=1;var t=be(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,o=t?t.toStringTag:void 0;return O=function(t){var e=r.call(t,o),i=t[o];try{t[o]=void 0;var a=!0}catch(t){}var s=n.call(t);return a&&(e?t[o]=i:delete t[o]),s}}function we(){if(T)return B;T=1;var t=Object.prototype.toString;return B=function(e){return t.call(e)}}function ke(){if(A)return S;A=1;var t=be(),e=ye(),r=we(),n=t?t.toStringTag:void 0;return S=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function _e(){if(W)return L;return W=1,L=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Re(){if(M)return U;M=1;var t=ke(),e=_e();return U=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 xe(){if(G)return F;G=1;var t=de()["__core-js_shared__"];return F=t}function Pe(){if(H)return D;H=1;var t,e=xe(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return D=function(t){return!!r&&r in t}}function je(){if(I)return q;I=1;var t=Function.prototype.toString;return q=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function Ce(){if(V)return z;V=1;var t=Re(),e=Pe(),r=_e(),n=je(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,a=Object.prototype,s=i.toString,u=a.hasOwnProperty,c=RegExp("^"+s.call(u).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return z=function(i){return!(!r(i)||e(i))&&(t(i)?c:o).test(n(i))}}function $e(){if(Y)return J;return Y=1,J=function(t,e){return null==t?void 0:t[e]}}function Ne(){if(Q)return K;Q=1;var t=Ce(),e=$e();return K=function(r,n){var o=e(r,n);return t(o)?o:void 0}}function Oe(){if(Z)return X;Z=1;var t=Ne()(de(),"Map");return X=t}function Ee(){if(et)return tt;et=1;var t=Ne()(Object,"create");return tt=t}function Be(){if(nt)return rt;nt=1;var t=Ee();return rt=function(){this.__data__=t?t(null):{},this.size=0}}function Te(){if(it)return ot;return it=1,ot=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}}function Se(){if(st)return at;st=1;var t=Ee(),e=Object.prototype.hasOwnProperty;return at=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 Ae(){if(ct)return ut;ct=1;var t=Ee(),e=Object.prototype.hasOwnProperty;return ut=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}function Le(){if(ft)return ht;ft=1;var t=Ee();return ht=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 We(){if(gt)return lt;gt=1;var t=Be(),e=Te(),r=Se(),n=Ae(),o=Le();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,lt=i}function Ue(){if(mt)return pt;mt=1;var t=We(),e=fe(),r=Oe();return pt=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function Me(){if(dt)return vt;return dt=1,vt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}}function Fe(){if(yt)return bt;yt=1;var t=Me();return bt=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Ge(){if(kt)return wt;kt=1;var t=Fe();return wt=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}function De(){if(Rt)return _t;Rt=1;var t=Fe();return _t=function(e){return t(this,e).get(e)}}function He(){if(Pt)return xt;Pt=1;var t=Fe();return xt=function(e){return t(this,e).has(e)}}function qe(){if(Ct)return jt;Ct=1;var t=Fe();return jt=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 Ie(){if(Nt)return $t;Nt=1;var t=Ue(),e=Ge(),r=De(),n=He(),o=qe();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,$t=i}function ze(){if(Et)return Ot;Et=1;var t=fe(),e=Oe(),r=Ie();return Ot=function(n,o){var i=this.__data__;if(i instanceof t){var a=i.__data__;if(!e||a.length<199)return a.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(a)}return i.set(n,o),this.size=i.size,this}}function Ve(){if(Tt)return Bt;Tt=1;var t=fe(),e=le(),r=ge(),n=pe(),o=me(),i=ze();function a(e){var r=this.__data__=new t(e);this.size=r.size}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=n,a.prototype.has=o,a.prototype.set=i,Bt=a}function Je(){if(At)return St;At=1;var t=Ne(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return St=e}function Ye(){if(Wt)return Lt;Wt=1;var t=Je();return Lt=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function Ke(){if(Mt)return Ut;Mt=1;var t=Ye(),e=ie();return Ut=function(r,n,o){(void 0!==o&&!e(r[n],o)||void 0===o&&!(n in r))&&t(r,n,o)}}function Qe(){if(Gt)return Ft;return Gt=1,Ft=function(t){return function(e,r,n){for(var o=-1,i=Object(e),a=n(e),s=a.length;s--;){var u=a[t?s:++o];if(!1===r(i[u],u,i))break}return e}}}function Xe(){if(Ht)return Dt;Ht=1;var t=Qe()();return Dt=t}var Ze,tr,er,rr,nr,or,ir,ar,sr,ur,cr,hr,fr,lr,gr,pr,mr,vr,dr,br,yr,wr,kr,_r,Rr,xr,Pr,jr,Cr,$r,Nr,Or,Er,Br={exports:{}};function Tr(){return Ze||(Ze=1,function(t,e){var r=de(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n?r.Buffer:void 0,a=i?i.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=a?a(r):new t.constructor(r);return t.copy(n),n}}(Br,Br.exports)),Br.exports}function Sr(){if(er)return tr;er=1;var t=de().Uint8Array;return tr=t}function Ar(){if(nr)return rr;nr=1;var t=Sr();return rr=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function Lr(){if(ir)return or;ir=1;var t=Ar();return or=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function Wr(){if(sr)return ar;return sr=1,ar=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}}function Ur(){if(cr)return ur;cr=1;var t=_e(),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 ur=r}function Mr(){if(fr)return hr;return fr=1,hr=function(t,e){return function(r){return t(e(r))}}}function Fr(){if(gr)return lr;gr=1;var t=Mr()(Object.getPrototypeOf,Object);return lr=t}function Gr(){if(mr)return pr;mr=1;var t=Object.prototype;return pr=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function Dr(){if(dr)return vr;dr=1;var t=Ur(),e=Fr(),r=Gr();return vr=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function Hr(){if(yr)return br;return yr=1,br=function(t){return null!=t&&"object"==typeof t}}function qr(){if(kr)return wr;kr=1;var t=ke(),e=Hr();return wr=function(r){return e(r)&&"[object Arguments]"==t(r)}}function Ir(){if(Rr)return _r;Rr=1;var t=qr(),e=Hr(),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 _r=i}function zr(){if(Pr)return xr;Pr=1;var t=Array.isArray;return xr=t}function Vr(){if(Cr)return jr;Cr=1;return jr=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Jr(){if(Nr)return $r;Nr=1;var t=Re(),e=Vr();return $r=function(r){return null!=r&&e(r.length)&&!t(r)}}function Yr(){if(Er)return Or;Er=1;var t=Jr(),e=Hr();return Or=function(r){return e(r)&&t(r)}}var Kr,Qr,Xr,Zr,tn,en,rn,nn,on,an={exports:{}};function sn(){if(Qr)return Kr;return Qr=1,Kr=function(){return!1}}function un(){return Xr||(Xr=1,function(t,e){var r=de(),n=sn(),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,a=i&&i.exports===o?r.Buffer:void 0,s=(a?a.isBuffer:void 0)||n;t.exports=s}(an,an.exports)),an.exports}function cn(){if(tn)return Zr;tn=1;var t=ke(),e=Fr(),r=Hr(),n=Function.prototype,o=Object.prototype,i=n.toString,a=o.hasOwnProperty,s=i.call(Object);return Zr=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var o=e(n);if(null===o)return!0;var u=a.call(o,"constructor")&&o.constructor;return"function"==typeof u&&u instanceof u&&i.call(u)==s}}function hn(){if(rn)return en;rn=1;var t=ke(),e=Vr(),r=Hr(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,en=function(o){return r(o)&&e(o.length)&&!!n[t(o)]}}function fn(){if(on)return nn;return on=1,nn=function(t){return function(e){return t(e)}}}var ln,gn,pn,mn,vn,dn,bn,yn,wn,kn,_n,Rn,xn,Pn,jn,Cn,$n,Nn,On,En,Bn,Tn,Sn,An,Ln,Wn,Un,Mn,Fn,Gn,Dn,Hn,qn,In,zn,Vn,Jn,Yn,Kn,Qn,Xn,Zn,to,eo,ro,no,oo,io,ao,so={exports:{}};function uo(){return ln||(ln=1,function(t,e){var r=ve(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n&&r.process,a=function(){try{var t=o&&o.require&&o.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}();t.exports=a}(so,so.exports)),so.exports}function co(){if(pn)return gn;pn=1;var t=hn(),e=fn(),r=uo(),n=r&&r.isTypedArray,o=n?e(n):t;return gn=o}function ho(){if(vn)return mn;return vn=1,mn=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function fo(){if(bn)return dn;bn=1;var t=Ye(),e=ie(),r=Object.prototype.hasOwnProperty;return dn=function(n,o,i){var a=n[o];r.call(n,o)&&e(a,i)&&(void 0!==i||o in n)||t(n,o,i)}}function lo(){if(wn)return yn;wn=1;var t=fo(),e=Ye();return yn=function(r,n,o,i){var a=!o;o||(o={});for(var s=-1,u=n.length;++s<u;){var c=n[s],h=i?i(o[c],r[c],c,o,r):void 0;void 0===h&&(h=r[c]),a?e(o,c,h):t(o,c,h)}return o}}function go(){if(_n)return kn;return _n=1,kn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}}function po(){if(xn)return Rn;xn=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 mo(){if(jn)return Pn;jn=1;var t=go(),e=Ir(),r=zr(),n=un(),o=po(),i=co(),a=Object.prototype.hasOwnProperty;return Pn=function(s,u){var c=r(s),h=!c&&e(s),f=!c&&!h&&n(s),l=!c&&!h&&!f&&i(s),g=c||h||f||l,p=g?t(s.length,String):[],m=p.length;for(var v in s)!u&&!a.call(s,v)||g&&("length"==v||f&&("offset"==v||"parent"==v)||l&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||o(v,m))||p.push(v);return p}}function vo(){if($n)return Cn;return $n=1,Cn=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}}function bo(){if(On)return Nn;On=1;var t=_e(),e=Gr(),r=vo(),n=Object.prototype.hasOwnProperty;return Nn=function(o){if(!t(o))return r(o);var i=e(o),a=[];for(var s in o)("constructor"!=s||!i&&n.call(o,s))&&a.push(s);return a}}function yo(){if(Bn)return En;Bn=1;var t=mo(),e=bo(),r=Jr();return En=function(n){return r(n)?t(n,!0):e(n)}}function wo(){if(Sn)return Tn;Sn=1;var t=lo(),e=yo();return Tn=function(r){return t(r,e(r))}}function ko(){if(Ln)return An;Ln=1;var t=Ke(),e=Tr(),r=Lr(),n=Wr(),o=Dr(),i=Ir(),a=zr(),s=Yr(),u=un(),c=Re(),h=_e(),f=cn(),l=co(),g=ho(),p=wo();return An=function(m,v,d,b,y,w,k){var _=g(m,d),R=g(v,d),x=k.get(R);if(x)t(m,d,x);else{var P=w?w(_,R,d+"",m,v,k):void 0,j=void 0===P;if(j){var C=a(R),$=!C&&u(R),N=!C&&!$&&l(R);P=R,C||$||N?a(_)?P=_:s(_)?P=n(_):$?(j=!1,P=e(R,!0)):N?(j=!1,P=r(R,!0)):P=[]:f(R)||i(R)?(P=_,i(_)?P=p(_):h(_)&&!c(_)||(P=o(R))):j=!1}j&&(k.set(R,P),y(P,R,b,w,k),k.delete(R)),t(m,d,P)}}}function _o(){if(Un)return Wn;Un=1;var t=Ve(),e=Ke(),r=Xe(),n=ko(),o=_e(),i=yo(),a=ho();return Wn=function s(u,c,h,f,l){u!==c&&r(c,(function(r,i){if(l||(l=new t),o(r))n(u,c,i,h,s,f,l);else{var g=f?f(a(u,i),r,i+"",u,c,l):void 0;void 0===g&&(g=r),e(u,i,g)}}),i)},Wn}function Ro(){if(Fn)return Mn;return Fn=1,Mn=function(t){return t}}function xo(){if(Dn)return Gn;return Dn=1,Gn=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 Po(){if(qn)return Hn;qn=1;var t=xo(),e=Math.max;return Hn=function(r,n,o){return n=e(void 0===n?r.length-1:n,0),function(){for(var i=arguments,a=-1,s=e(i.length-n,0),u=Array(s);++a<s;)u[a]=i[n+a];a=-1;for(var c=Array(n+1);++a<n;)c[a]=i[a];return c[n]=o(u),t(r,this,c)}},Hn}function jo(){if(zn)return In;return zn=1,In=function(t){return function(){return t}}}function Co(){if(Jn)return Vn;Jn=1;var t=jo(),e=Je();return Vn=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:Ro()}function $o(){if(Kn)return Yn;Kn=1;var t=Date.now;return Yn=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)}},Yn}function No(){if(Xn)return Qn;Xn=1;var t=Co(),e=$o()(t);return Qn=e}function Oo(){if(to)return Zn;to=1;var t=Ro(),e=Po(),r=No();return Zn=function(n,o){return r(e(n,o,t),n+"")}}function Eo(){if(ro)return eo;ro=1;var t=ie(),e=Jr(),r=po(),n=_e();return eo=function(o,i,a){if(!n(a))return!1;var s=typeof i;return!!("number"==s?e(a)&&r(i,a.length):"string"==s&&i in a)&&t(a[i],o)}}function Bo(){if(oo)return no;oo=1;var t=Oo(),e=Eo();return no=function(r){return t((function(t,n){var o=-1,i=n.length,a=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(a=r.length>3&&"function"==typeof a?(i--,a):void 0,s&&e(n[0],n[1],s)&&(a=i<3?void 0:a,i=1),t=Object(t);++o<i;){var u=n[o];u&&r(t,u,o,a)}return t}))}}function To(){if(ao)return io;ao=1;var t=_o(),e=Bo()((function(e,r,n){t(e,r,n)}));return io=e}var So,Ao,Lo,Wo,Uo,Mo,Fo,Go,Do,Ho,qo,Io,zo,Vo,Jo,Yo,Ko,Qo,Xo,Zo,ti,ei,ri,ni,oi=ne(To());function ii(){if(Ao)return So;Ao=1;var t=ke(),e=Hr();return So=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function ai(){if(Wo)return Lo;Wo=1;var t=zr(),e=ii(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Lo=function(o,i){if(t(o))return!1;var a=typeof o;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=o&&!e(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function si(){if(Mo)return Uo;Mo=1;var t=Ie();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var t=arguments,e=n?n.apply(this,t):t[0],i=o.cache;if(i.has(e))return i.get(e);var a=r.apply(this,t);return o.cache=i.set(e,a)||i,a};return o.cache=new(e.Cache||t),o}return e.Cache=t,Uo=e}function ui(){if(Go)return Fo;Go=1;var t=si();return Fo=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function ci(){if(Ho)return Do;Ho=1;var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,e=/\\(\\)?/g,r=ui()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(t,(function(t,r,o,i){n.push(o?i.replace(e,"$1"):r||t)})),n}));return Do=r}function hi(){if(Io)return qo;return Io=1,qo=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 fi(){if(Vo)return zo;Vo=1;var t=be(),e=hi(),r=zr(),n=ii(),o=t?t.prototype:void 0,i=o?o.toString:void 0;return zo=function t(o){if("string"==typeof o)return o;if(r(o))return e(o,t)+"";if(n(o))return i?i.call(o):"";var a=o+"";return"0"==a&&1/o==-1/0?"-0":a},zo}function li(){if(Yo)return Jo;Yo=1;var t=fi();return Jo=function(e){return null==e?"":t(e)}}function gi(){if(Qo)return Ko;Qo=1;var t=zr(),e=ai(),r=ci(),n=li();return Ko=function(o,i){return t(o)?o:e(o,i)?[o]:r(n(o))}}function pi(){if(Zo)return Xo;Zo=1;var t=ii();return Xo=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function mi(){if(ei)return ti;ei=1;var t=gi(),e=pi();return ti=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},ti}function vi(){if(ni)return ri;ni=1;var t=mi();return ri=function(e,r,n){var o=null==e?void 0:t(e,r);return void 0===o?n:o},ri}var di=ne(vi());const bi="package.json",yi=[".env.local",".env"];class wi extends qt.FeScriptContext{_env;shared;constructor(t){super(t),this._env=It.Env.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||yi}),this.shared=Object.assign({},this.feConfig.release,this.getDefaultShreadOptions(t.shared))}getDefaultShreadOptions(t){return{rootPath:process.cwd(),sourceBranch:this._env.get("FE_RELEASE_BRANCH")||this._env.get("FE_RELEASE_SOURCE_BRANCH")||"master",releaseEnv:this._env.get("FE_RELEASE_ENV")||this._env.get("NODE_ENV")||"development",...t}}get rootPath(){return this.shared.rootPath}get sourceBranch(){return this.shared.sourceBranch}get releaseEnv(){return this.shared.releaseEnv}get env(){return this._env}get workspaces(){return this.getConfig("workspaces.workspaces")}get workspace(){return this.getConfig("workspaces.workspace")}setWorkspaces(t){this.options.workspaces={...this.options.workspaces,workspaces:t}}setConfig(t){this.options=oi(this.options,t)}getConfig(t,e){return di(this.options,t,e)}setShared(t){this.shared=oi(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}}async runChangesetsCli(t,e){let r="pnpm";try{await this.shell.exec("pnpm -v",{dryRun:!1})}catch{r="npx"}return await this.shell.exec([r,"changeset",t,...e??[]])}}function ki(t,...e){return[t,...e]}const _i={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages-${timestamp}",batchTagName:"batch-${length}-packages-${timestamp}"};class Ri{shell;logger;config;constructor(t,e,r={}){this.shell=t,this.logger=e,this.config={..._i,...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.debug("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.debug("Release Batch Branch template is:",o),this.shell.format(o,{pkgName:t,releaseName:t,tagName:e,...r,length:n,timestamp:Date.now()})}getReleaseName(t){if(1===t.length)return t[0].name;const{maxWorkspace:e,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return t.slice(0,e).map((({name:t,version:e})=>`${t}${n}${e}`)).join(r)}getReleaseTagName(t){if(1===t.length)return t[0].version;const{batchTagName:e}=this.config;return this.shell.format(e,{length:t.length,timestamp:Date.now()})}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))).join("\n"):t[0].changelog,{workspaceVersionSeparator:i}=this.config,a=1===t.length?e.tagName:t.map((t=>`${t.name}${i}${t.version}`)).join(" ");return this.shell.format(n,{...r,tagName:a,changelog:o})}}class xi{context;_octokit=null;constructor(t){this.context=t}getGitHubUserInfo(){const{authorName:t,repoName:e}=this.context.shared;if(!t||!e)throw new Error("Author name or repo name is not set");return{owner:t,repo:e}}getToken(){const{tokenRef:t="GITHUB_TOKEN"}=this.context.getConfig("githubPR"),e=this.context.env.get(t);if(!e)throw new Error(`Token is not set. Please set ${t} environment variable.`);return e}get octokit(){if(this._octokit)return this._octokit;const{timeout:t}=this.context.getConfig("githubPR"),e={auth:this.getToken(),request:{timeout:t}};return this._octokit=new Vt.Octokit(e),this._octokit}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.shared.autoMergeType||"squash"}get dryRunPRNumber(){return this.context.getConfig("githubPR.dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.shared.autoMergeReleasePR||false}async mergePR(t,e){if(!t)return void this.logger.error("Failed to create Pull Request.",t);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.context.shared;this.logger.info(`[DRY RUN] Would merge PR #${t} with method '${r}' in repo ${o}/${n}, branch ${e}`)}else await this.octokit.rest.pulls.merge({...this.getGitHubUserInfo(),pull_number:Number(t),merge_method:r})}async getPullRequestCommits(t){return(await this.octokit.rest.pulls.listCommits({...this.getGitHubUserInfo(),pull_number:t})).data}async getPullRequest(t){return(await this.octokit.rest.pulls.get({...this.getGitHubUserInfo(),pull_number:t})).data}async checkedPR(t,e){try{await this.getPullRequest(Number(t)),await this.octokit.rest.git.deleteRef({...this.getGitHubUserInfo(),ref:`heads/${e}`}),this.logger.info(`Branch ${e} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${t} or branch ${e} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const t=this.context.shared.label;if(!(t&&t.name&&t.description&&t.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",t),t;try{const e=await this.octokit.rest.issues.createLabel({...this.getGitHubUserInfo(),name:t.name,description:t.description,color:t.color.replace("#","")});return this.logger.debug("Create PR label Success",e),t}catch(e){if(422===e.status)return this.logger.warn(`Label ${t.name} already exists, skipping!`),t;throw this.logger.error("Create PR label Failed",e),e}}async createReleasePR(t){if(this.context.getConfig("githubPR.dryRunCreatePR")||this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...t,labels:t.labels}),this.dryRunPRNumber;try{const e=await this.octokit.rest.pulls.create({...this.getGitHubUserInfo(),...t}),r=e.data.number;if(!r)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",[e?.url]),t.labels&&t.labels.length){const e=await this.octokit.rest.issues.addLabels({...this.getGitHubUserInfo(),issue_number:r,labels:t.labels});this.logger.debug("Add PR label Success",[e.url])}return r.toString()}catch(t){if(422===t.status&&t.message.includes("already exists")){this.logger.warn("PR already exists");const e=t.message.match(/pull request #(\d+)/);return e?e[1]:""}throw this.logger.error("Failed to create PR",t),t}}truncateBody(t){return t&&t.length>=124e3?t.substring(0,124e3)+"...":t}getOctokitReleaseOptions(t){const{releaseName:e,draft:r=!1,preRelease:n=!1,autoGenerate:o=!1,makeLatest:i=!0,releaseNotes:a,discussionCategoryName:s}=this.context.getConfig("githubPR"),u=e,c=o?"":this.truncateBody(String(a));return{name:u,make_latest:i.toString(),body:c,draft:r,prerelease:n,generate_release_notes:o,discussion_category_name:s,tag_name:"",...t,...this.getGitHubUserInfo()}}async createRelease(t){const e=this.getOctokitReleaseOptions({tag_name:t.tagName,body:t.changelog});if(e.name=this.shell.format(e.name,t),this.logger.log(`[DRY RUN] octokit repos.createRelease "${e.name}" (${e.tag_name})`,{isDryRun:this.context.dryRun}),!e.tag_name)throw new Error("TagName is undefined");if(!this.context.dryRun)try{const t=await this.octokit.repos.createRelease(e);this.logger.debug(`[DONE] octokit repos.createRelease "${e.name}" (${e.tag_name}) (${t.headers.location})`)}catch(t){this.logger.error(`[FAILED] octokit repos.createRelease "${e.name}" (${e.tag_name})`,t)}}}var Pi,ji;function Ci(){if(ji)return Pi;ji=1;var t=ke(),e=zr(),r=Hr();return Pi=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}var $i=ne(Ci());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],r=di(this.context.shared,this.pluginName);return e||t?oi({},r,t,e):{}}get logger(){return this.context.logger}get shell(){return this.context.shell}get options(){return this.context.getConfig(this.pluginName,{})}getEnv(t,e){return this.context.env.get(t)??e}enabled(t,e){return!0}getConfig(t,e){return t?this.context.getConfig([this.pluginName,...Array.isArray(t)?t:[t]],e):this.context.getConfig(this.pluginName,e)}setConfig(t){this.context.setConfig({[this.pluginName]:t})}onBefore(t){}onExec(t){}onSuccess(t){}onError(t){}async step({label:t,task:e}){this.logger.log(),this.logger.info(t),this.logger.log();try{const r=await e();return this.logger.info(`${t} - success`),r}catch(t){throw this.logger.error(t),t}}}class Oi extends Ni{async onBefore(){const t=await this.getUserInfo();if(!t)throw new Error("Failed to get repoInfo");let e=this.context.shared.currentBranch;e||(e=await this.getCurrentBranch()),e&&await this.context.shell.exec(`git checkout ${e}`,{dryRun:!1}),this.context.setShared({repoName:t.repoName,authorName:t.authorName,currentBranch:e})}async getCurrentBranch(){return await new Promise((t=>setTimeout(t,100))),this.context.shell.exec("git rev-parse --abbrev-ref HEAD",{dryRun:!1})}async getRemoteUrl(){return(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}async getUserInfo(){let t;try{t=await this.getRemoteUrl()}catch{throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!t)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.debug("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)}commit(t,e=[]){return this.context.shell.exec(["git","commit","--message",JSON.stringify(t),...e])}}const Ei=["hash","abbrevHash","treeHash","abbrevTreeHash","parentHashes","abbrevParentHashes","authorName","authorEmail","authorDate","authorDateRel","committerName","committerEmail","committerDate","committerDateRel","subject","body","rawBody","tag"];class Bi{options;constructor(t){this.options=t}async getGitLog(t={}){const{directory:e,noMerges:r=!0,fileds:n}=t,o=await this.resolveTag(t.from,"root"),i=await this.resolveTag(t.to,"HEAD"),a=o===i?i:`${o}..${i}`;return await Jt({repo:".",number:1e3,fields:n,branch:a,file:e,nameStatus:!1,includeMergeCommitFiles:!r})}async getCommits(t){return(await this.getGitLog(t)).map((t=>{const{subject:e,rawBody:r}=t;return{base:t,commitlint:this.parseCommitlint(e||"",r),commits:[]}}))}createBaseCommit(t,e){return{subject:t,rawBody:t,body:t,...e}}parseCommitlint(t,e=""){const[r]=t.trim().split("\n"),n=e.startsWith(r)?e.replace(r,""):e,o=r.replace(/\s*\(#\d+\)\s*$/,"").match(/^(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);return o?{type:o[1]?.toLowerCase(),scope:o[2]?.trim(),message:o[3].trim(),body:n||void 0}:{message:r,body:n||void 0}}toCommitValue(t,e){const[r]=e.trim().split("\n"),n=r.match(/\(#(\d+)\)/),o=this.parseCommitlint(r,e);return{base:this.createBaseCommit(r,{hash:t,abbrevHash:t.substring(0,7),rawBody:e}),commitlint:o,commits:[],prNumber:n?.[1]}}async resolveTag(t,e){if(t)try{if(await this.options.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((t=>!!t.trim())))return t}catch{}return"root"===e?this.options.shell.exec("git rev-list --max-parents=0 HEAD",{dryRun:!1}).then((t=>t.trim())):"HEAD"}}var Ti,Si,Ai,Li,Wi,Ui,Mi,Fi,Gi,Di,Hi,qi,Ii,zi,Vi,Ji,Yi,Ki,Qi,Xi,Zi,ta,ea,ra,na,oa,ia,aa,sa,ua,ca,ha,fa,la,ga,pa,ma,va,da,ba,ya,wa,ka,_a,Ra,xa,Pa,ja,Ca,$a,Na,Oa,Ea,Ba,Ta,Sa,Aa,La,Wa,Ua,Ma,Fa,Ga,Da,Ha,qa,Ia,za,Va,Ja,Ya,Ka,Qa,Xa,Za,ts,es,rs,ns,os,is,as,ss,us,cs,hs,fs,ls,gs,ps,ms,vs;function ds(){if(Si)return Ti;return Si=1,Ti=function(t,e,r,n){for(var o=-1,i=null==t?0:t.length;++o<i;){var a=t[o];e(n,a,r(a),t)}return n}}function bs(){if(Li)return Ai;Li=1;var t=Mr()(Object.keys,Object);return Ai=t}function ys(){if(Ui)return Wi;Ui=1;var t=Gr(),e=bs(),r=Object.prototype.hasOwnProperty;return Wi=function(n){if(!t(n))return e(n);var o=[];for(var i in Object(n))r.call(n,i)&&"constructor"!=i&&o.push(i);return o}}function ws(){if(Fi)return Mi;Fi=1;var t=mo(),e=ys(),r=Jr();return Mi=function(n){return r(n)?t(n):e(n)}}function ks(){if(Di)return Gi;Di=1;var t=Xe(),e=ws();return Gi=function(r,n){return r&&t(r,n,e)}}function _s(){if(qi)return Hi;qi=1;var t=Jr();return Hi=function(e,r){return function(n,o){if(null==n)return n;if(!t(n))return e(n,o);for(var i=n.length,a=r?i:-1,s=Object(n);(r?a--:++a<i)&&!1!==o(s[a],a,s););return n}}}function Rs(){if(zi)return Ii;zi=1;var t=ks(),e=_s()(t);return Ii=e}function xs(){if(Ji)return Vi;Ji=1;var t=Rs();return Vi=function(e,r,n,o){return t(e,(function(t,e,i){r(o,t,n(t),i)})),o}}function Ps(){if(Ki)return Yi;Ki=1;return Yi=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}}function js(){if(Xi)return Qi;return Xi=1,Qi=function(t){return this.__data__.has(t)}}function Cs(){if(ta)return Zi;ta=1;var t=Ie(),e=Ps(),r=js();function n(e){var r=-1,n=null==e?0:e.length;for(this.__data__=new t;++r<n;)this.add(e[r])}return n.prototype.add=n.prototype.push=e,n.prototype.has=r,Zi=n}function $s(){if(ra)return ea;return ra=1,ea=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}}function Ns(){if(oa)return na;return oa=1,na=function(t,e){return t.has(e)}}function Os(){if(aa)return ia;aa=1;var t=Cs(),e=$s(),r=Ns();return ia=function(n,o,i,a,s,u){var c=1&i,h=n.length,f=o.length;if(h!=f&&!(c&&f>h))return!1;var l=u.get(n),g=u.get(o);if(l&&g)return l==o&&g==n;var p=-1,m=!0,v=2&i?new t:void 0;for(u.set(n,o),u.set(o,n);++p<h;){var d=n[p],b=o[p];if(a)var y=c?a(b,d,p,o,n,u):a(d,b,p,n,o,u);if(void 0!==y){if(y)continue;m=!1;break}if(v){if(!e(o,(function(t,e){if(!r(v,e)&&(d===t||s(d,t,i,a,u)))return v.push(e)}))){m=!1;break}}else if(d!==b&&!s(d,b,i,a,u)){m=!1;break}}return u.delete(n),u.delete(o),m}}function Es(){if(ua)return sa;return ua=1,sa=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}}function Bs(){if(ha)return ca;return ha=1,ca=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r},ca}function Ts(){if(la)return fa;la=1;var t=be(),e=Sr(),r=ie(),n=Os(),o=Es(),i=Bs(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return fa=function(t,a,u,c,h,f,l){switch(u){case"[object DataView]":if(t.byteLength!=a.byteLength||t.byteOffset!=a.byteOffset)return!1;t=t.buffer,a=a.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=a.byteLength||!f(new e(t),new e(a)));case"[object Boolean]":case"[object Date]":case"[object Number]":return r(+t,+a);case"[object Error]":return t.name==a.name&&t.message==a.message;case"[object RegExp]":case"[object String]":return t==a+"";case"[object Map]":var g=o;case"[object Set]":var p=1&c;if(g||(g=i),t.size!=a.size&&!p)return!1;var m=l.get(t);if(m)return m==a;c|=2,l.set(t,a);var v=n(g(t),g(a),c,h,f,l);return l.delete(t),v;case"[object Symbol]":if(s)return s.call(t)==s.call(a)}return!1}}function Ss(){if(pa)return ga;return pa=1,ga=function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}}function As(){if(va)return ma;va=1;var t=Ss(),e=zr();return ma=function(r,n,o){var i=n(r);return e(r)?i:t(i,o(r))}}function Ls(){if(ba)return da;return ba=1,da=function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var a=t[r];e(a,r,t)&&(i[o++]=a)}return i}}function Ws(){if(wa)return ya;return wa=1,ya=function(){return[]}}function Us(){if(_a)return ka;_a=1;var t=Ls(),e=Ws(),r=Object.prototype.propertyIsEnumerable,n=Object.getOwnPropertySymbols;return ka=n?function(e){return null==e?[]:(e=Object(e),t(n(e),(function(t){return r.call(e,t)})))}:e}function Ms(){if(xa)return Ra;xa=1;var t=As(),e=Us(),r=ws();return Ra=function(n){return t(n,r,e)}}function Fs(){if(ja)return Pa;ja=1;var t=Ms(),e=Object.prototype.hasOwnProperty;return Pa=function(r,n,o,i,a,s){var u=1&o,c=t(r),h=c.length;if(h!=t(n).length&&!u)return!1;for(var f=h;f--;){var l=c[f];if(!(u?l in n:e.call(n,l)))return!1}var g=s.get(r),p=s.get(n);if(g&&p)return g==n&&p==r;var m=!0;s.set(r,n),s.set(n,r);for(var v=u;++f<h;){var d=r[l=c[f]],b=n[l];if(i)var y=u?i(b,d,l,n,r,s):i(d,b,l,r,n,s);if(!(void 0===y?d===b||a(d,b,o,i,s):y)){m=!1;break}v||(v="constructor"==l)}if(m&&!v){var w=r.constructor,k=n.constructor;w==k||!("constructor"in r)||!("constructor"in n)||"function"==typeof w&&w instanceof w&&"function"==typeof k&&k instanceof k||(m=!1)}return s.delete(r),s.delete(n),m}}function Gs(){if($a)return Ca;$a=1;var t=Ne()(de(),"DataView");return Ca=t}function Ds(){if(Oa)return Na;Oa=1;var t=Ne()(de(),"Promise");return Na=t}function Hs(){if(Ba)return Ea;Ba=1;var t=Ne()(de(),"Set");return Ea=t}function qs(){if(Sa)return Ta;Sa=1;var t=Ne()(de(),"WeakMap");return Ta=t}function Is(){if(La)return Aa;La=1;var t=Gs(),e=Oe(),r=Ds(),n=Hs(),o=qs(),i=ke(),a=je(),s="[object Map]",u="[object Promise]",c="[object Set]",h="[object WeakMap]",f="[object DataView]",l=a(t),g=a(e),p=a(r),m=a(n),v=a(o),d=i;return(t&&d(new t(new ArrayBuffer(1)))!=f||e&&d(new e)!=s||r&&d(r.resolve())!=u||n&&d(new n)!=c||o&&d(new o)!=h)&&(d=function(t){var e=i(t),r="[object Object]"==e?t.constructor:void 0,n=r?a(r):"";if(n)switch(n){case l:return f;case g:return s;case p:return u;case m:return c;case v:return h}return e}),Aa=d}function zs(){if(Ua)return Wa;Ua=1;var t=Ve(),e=Os(),r=Ts(),n=Fs(),o=Is(),i=zr(),a=un(),s=co(),u="[object Arguments]",c="[object Array]",h="[object Object]",f=Object.prototype.hasOwnProperty;return Wa=function(l,g,p,m,v,d){var b=i(l),y=i(g),w=b?c:o(l),k=y?c:o(g),_=(w=w==u?h:w)==h,R=(k=k==u?h:k)==h,x=w==k;if(x&&a(l)){if(!a(g))return!1;b=!0,_=!1}if(x&&!_)return d||(d=new t),b||s(l)?e(l,g,p,m,v,d):r(l,g,w,p,m,v,d);if(!(1&p)){var P=_&&f.call(l,"__wrapped__"),j=R&&f.call(g,"__wrapped__");if(P||j){var C=P?l.value():l,$=j?g.value():g;return d||(d=new t),v(C,$,p,m,d)}}return!!x&&(d||(d=new t),n(l,g,p,m,v,d))}}function Vs(){if(Fa)return Ma;Fa=1;var t=zs(),e=Hr();return Ma=function r(n,o,i,a,s){return n===o||(null==n||null==o||!e(n)&&!e(o)?n!=n&&o!=o:t(n,o,i,a,r,s))},Ma}function Js(){if(Da)return Ga;Da=1;var t=Ve(),e=Vs();return Ga=function(r,n,o,i){var a=o.length,s=a,u=!i;if(null==r)return!s;for(r=Object(r);a--;){var c=o[a];if(u&&c[2]?c[1]!==r[c[0]]:!(c[0]in r))return!1}for(;++a<s;){var h=(c=o[a])[0],f=r[h],l=c[1];if(u&&c[2]){if(void 0===f&&!(h in r))return!1}else{var g=new t;if(i)var p=i(f,l,h,r,n,g);if(!(void 0===p?e(l,f,3,i,g):p))return!1}}return!0}}function Ys(){if(qa)return Ha;qa=1;var t=_e();return Ha=function(e){return e==e&&!t(e)}}function Ks(){if(za)return Ia;za=1;var t=Ys(),e=ws();return Ia=function(r){for(var n=e(r),o=n.length;o--;){var i=n[o],a=r[i];n[o]=[i,a,t(a)]}return n}}function Qs(){if(Ja)return Va;return Ja=1,Va=function(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}}function Xs(){if(Ka)return Ya;Ka=1;var t=Js(),e=Ks(),r=Qs();return Ya=function(n){var o=e(n);return 1==o.length&&o[0][2]?r(o[0][0],o[0][1]):function(e){return e===n||t(e,n,o)}}}function Zs(){if(Xa)return Qa;return Xa=1,Qa=function(t,e){return null!=t&&e in Object(t)}}function tu(){if(ts)return Za;ts=1;var t=gi(),e=Ir(),r=zr(),n=po(),o=Vr(),i=pi();return Za=function(a,s,u){for(var c=-1,h=(s=t(s,a)).length,f=!1;++c<h;){var l=i(s[c]);if(!(f=null!=a&&u(a,l)))break;a=a[l]}return f||++c!=h?f:!!(h=null==a?0:a.length)&&o(h)&&n(l,h)&&(r(a)||e(a))},Za}function eu(){if(rs)return es;rs=1;var t=Zs(),e=tu();return es=function(r,n){return null!=r&&e(r,n,t)},es}function ru(){if(os)return ns;os=1;var t=Vs(),e=vi(),r=eu(),n=ai(),o=Ys(),i=Qs(),a=pi();return ns=function(s,u){return n(s)&&o(u)?i(a(s),u):function(n){var o=e(n,s);return void 0===o&&o===u?r(n,s):t(u,o,3)}},ns}function nu(){if(as)return is;return as=1,is=function(t){return function(e){return null==e?void 0:e[t]}}}function ou(){if(us)return ss;us=1;var t=mi();return ss=function(e){return function(r){return t(r,e)}},ss}function iu(){if(hs)return cs;hs=1;var t=nu(),e=ou(),r=ai(),n=pi();return cs=function(o){return r(o)?t(n(o)):e(o)},cs}function au(){if(ls)return fs;ls=1;var t=Xs(),e=ru(),r=Ro(),n=zr(),o=iu();return fs=function(i){return"function"==typeof i?i:null==i?r:"object"==typeof i?n(i)?e(i[0],i[1]):t(i):o(i)}}function su(){if(ps)return gs;ps=1;var t=ds(),e=xs(),r=au(),n=zr();return gs=function(o,i){return function(a,s){var u=n(a)?t:e,c=i?i():{};return u(a,o,r(s,2),c)}}}function uu(){if(vs)return ms;vs=1;var t=Ye(),e=su(),r=Object.prototype.hasOwnProperty,n=e((function(e,n,o){r.call(e,o)?e[o].push(n):t(e,o,[n])}));return ms=n}var cu=ne(uu());const hu="\n- ${scopeHeader} ${commitlint.message} ${commitLink} ${prLink}";class fu{options;constructor(t){this.options=t}format(t,e){const{types:r=[],commitBody:n=!1}={...this.options,...e},o=[],i=cu(t,(t=>t.commitlint.type?t.commitlint.type:t.commitlint.message));return r.forEach((t=>{const{type:r,section:a,hidden:s}=t;if(s)return;const u=i[r]||[];u.length>0&&(o.push(a||""),u.forEach((t=>{if(o.push(this.formatCommit(t,e)),n&&t.commitlint.body){const e=t.commitlint.body.split("\n").map((t=>` ${t}`));o.push(...e)}})))})),o}formatCommit(t,e){const{commitlint:r,base:{hash:n},prNumber:o}=t,{repoUrl:i,formatTemplate:a=hu}={...this.options,...e},s=r.scope?this.formatScope(r.scope):"",u=o?this.foramtLink("#"+o,i?`${i}/pull/${o}`:""):"",c=n?this.foramtLink(n.slice(0,7),i?`${i}/commit/${n}`:""):"";return this.options.shell.format(a,{...t,scopeHeader:s,commitLink:c,prLink:u})}foramtLink(t,e){return e?`([${t}](${e}))`:`(${t})`}formatCommitLink(t,e){return e?`([${t}](${e}))`:`(${t})`}formatScope(t){return`**${t}:**`}}const lu="https://github.com";class gu extends Bi{options;githubManager;constructor(t,e){super(t),this.options=t,this.githubManager=e}async getFullCommit(t){const e={...this.options,...t},r=await this.getCommits(e);return(await Promise.all(r.map((async t=>{let{prNumber:e}=t;if(!e&&t.base.subject){const r=t.base.subject.match(/\(#(\d+)\)/);r&&(e=r[1],t.prNumber=e)}if(!e)return t;return(await this.githubManager.getPullRequestCommits(+e)).map((({sha:t,commit:{message:r}})=>Object.assign(this.toCommitValue(t,r),{prNumber:e})))})))).flat()}async transformWorkspace(t,e){const r=[lu,e.shared.authorName,e.shared.repoName].join("/"),n={...e.getConfig("changelog"),githubRootPath:r,mergePRcommit:!0,shell:e.shell},o=new gu(n,this.githubManager),i=new fu(n);return await Promise.all(t.map((async t=>{const e=await o.getFullCommit({from:t.lastTag??"",directory:t.path,fileds:Ei});if("string"==typeof e)return{...t,changelog:e};const a=i.format(e,{...n,repoUrl:r});return{...t,changelog:a.join("\n")}})))}}class pu{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 mu{static readJson(t){const e=Qt.readFileSync(t,"utf-8");return JSON.parse(e)}static toWorkspace(t,e){let{root:r,packageJson:n}=t;const o=t.path;if(!o)throw new Error("path is not required!");return r=r||Xt.join(e,o),n=n||mu.readJson(Xt.join(r,bi)),{name:n.name,version:n.version,path:o,root:r,packageJson:n}}}class vu extends Ni{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(t){super(t,"workspaces"),this.releaseLabel=new pu({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[],compare:(t,e)=>Yt.resolve(t).startsWith(Yt.resolve(e))})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){const t=this.getConfig("workspace");if(t)return this.logger.debug("Use the specified workspace",t),void this.setCurrentWorkspace(t,[]);const e=await this.getWorkspaces();if(this.getConfig("skipCheckPackage")||0===e.length)throw new Error("No changes to publish packages");const{publishPath:r}=this.context.shared;if(r){const t=e.find((t=>Yt.resolve(t.root)===Yt.resolve(r)));if(this.nextSkip(),!t)throw new Error(`No workspace found for: ${r}`);return this.logger.debug(`Workspace of ${r} find!`,Yt.join(t.root,bi)),void this.setCurrentWorkspace(t,[t])}const[n,...o]=e;this.workspacesList=o,this.setCurrentWorkspace(n,e)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}setReleaseTask(t){this.releaseTask=t}setCurrentWorkspace(t,e){this.context.setShared({publishPath:t.path}),this.setConfig({workspace:t,workspaces:e})}async getGitWorkspaces(){const t=this.context.sourceBranch,e=await this.shell.exec(`git diff --name-only origin/${t}...HEAD`,{dryRun:!1});return"string"==typeof e?e.split("\n"):[]}async getChangedPackages(t,e){if(this.logger.debug("changeLabels",e),Array.isArray(e)&&e.length>0){const r=t.filter((t=>{const r=this.releaseLabel.toChangeLabel(t);return e.includes(r)}));return this.logger.debug("changed by labels",r),r}const r=await this.getGitWorkspaces();return this.logger.debug("changed by git",r),this.releaseLabel.pick(r,t)}getProjectWorkspaces(){const t=this.context.rootPath,e=this.context.shared.packagesDirectories;if(Array.isArray(e)&&e.length>0)return e.map((e=>mu.toWorkspace({path:e},t)));return(Kt.findWorkspaces(t)||[]).map((e=>({name:e.package.name,version:e.package.version,path:Yt.relative(t,e.location),root:Yt.resolve(t,e.location),packageJson:e.package})))}async getWorkspaces(){const t=this.getProjectWorkspaces(),e=t.map((({path:t})=>t));this.logger.debug("packages",e);const r=this.getConfig("changeLabels"),n=await this.getChangedPackages(e,r);return this.setConfig({packages:e,changedPaths:n,projectWorkspaces:t}),this.logger.debug("changedPaths",n),t.filter((t=>n.includes(t.path)))}}function du(t,...e){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t?new t(...e):t(...e)}function bu(t){return t.startsWith(".")?Yt.parse(t).name:t}async function yu(t){let e=null;try{e=(await import(t)).default}catch{try{e=(await import(Yt.join(process.cwd(),t))).default}catch{const r=Zt.createRequire(process.cwd());e=(await import(te.pathToFileURL(r.resolve(t,{paths:[process.cwd()]})).href)).default}}return[bu(t),e]}async function wu(t,e,r=5){const n=ee(r),o=e.map((([e,...r])=>n((()=>(async(e,...r)=>{if("string"==typeof e){const[,n]=await yu(e);return du(n,t,...r)}return du(e,t,...r)})(e,...r)))));return Promise.all(o)}const ku=[ki(vu),ki(class extends Ni{constructor(t,e){super(t,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...e})}get changesetRoot(){return Xt.join(this.context.rootPath,this.getConfig("changesetRoot"))}get changesetConfigPath(){return Xt.join(this.changesetRoot,"config.json")}enabled(){return!this.getConfig("skip")}async onBefore(){if(!Qt.existsSync(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}mergeWorkspaces(t){return t.map((t=>{const e=mu.toWorkspace({path:t.path},this.context.rootPath),r={...t,version:e.version};return r.tagName=this.generateTagName(r),r}))}async onExec(t){const e=await this.step({label:"Generate Changelogs",task:()=>Promise.all(this.context.workspaces.map((t=>this.generateChangelog(t))))});this.context.setWorkspaces(e)}async onSuccess(){const t=this.context.workspaces;this.getConfig("skipChangeset")?this.logger.debug("Skip generate changeset files"):(await this.step({label:"Changeset Version",task:()=>Promise.all(t.map((t=>this.generateChangesetFile(t))))}),await this.context.runChangesetsCli("version",["--no-changelog","--update-dependencies"]),this.getConfig("ignoreNonUpdatedPackages")&&await this.restoreIgnorePackages());const e=this.mergeWorkspaces(t);this.logger.debug("new workspaces",e),this.context.setWorkspaces(e)}async restoreIgnorePackages(){const{changedPaths:t=[],packages:e=[]}=this.context.getConfig("workspaces"),r=e.filter((e=>!t.includes(e))).map((t=>mu.toWorkspace({path:t},this.context.rootPath).path));this.logger.debug("noChangedPackages",r),await this.shell.exec(["git","restore",...r])}getTagPrefix(t){return this.shell.format(this.getConfig("tagPrefix"),t)}async generateChangelog(t){const e=await this.getTagName(t);this.logger.debug("tagName is:",e);const r={...this.getConfig(),from:e,directory:t.path,shell:this.shell,fileds:Ei},n=new Bi(r),o=await n.getCommits(r),i=new fu(r).format(o);return{...t,lastTag:e,changelog:i.join("\n")}}generateTagName(t){try{const e=this.getConfig("tagTemplate");return this.shell.format(e,t)}catch(e){return console.error(`Error generating tag name for ${t.name}:`,e),`${t.name}-v0.0.0`}}async getTagName(t){try{const e=this.generateTagName(t),r=this.shell.format(this.getConfig("tagMatch"),t),n=await this.shell.exec(`git for-each-ref --sort=-creatordate --format "%(refname:short)|%(creatordate:iso8601)" "refs/tags/${r}"`,{dryRun:!1});if(!n)return e;const o=n.split("\n").filter(Boolean);if(0===o.length)return e;return o[0].split("|")[0]}catch(e){console.error(`Error getting tag for ${t.name}:`,e);return this.generateTagName(t)}}getIncrement(){const t=this.context.getConfig("workspaces.changeLabels");if(Array.isArray(t)&&t.length>0){if(t.includes("increment:major"))return"major";if(t.includes("increment:minor"))return"minor"}return this.getConfig("increment","patch")}async generateChangesetFile(t){const{name:e,version:r}=t,n=`${e}-${r}`.replace(/[\/\\]/g,"_"),o=Xt.join(this.changesetRoot,`${n}.md`),i=this.getIncrement();this.logger.debug("increment is:",[i]);const a=this.shell.format("---\n'${name}': '${increment}'\n---\n\n${changelog}",{...t,increment:i});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(a);Qt.existsSync(o)?this.logger.info(`Changeset ${n} already exists`):Qt.writeFileSync(o,a,"utf-8")}},{}),ki(class extends Oi{context;releaseParams;githubManager;constructor(t,e){super(t,"githubPR",{releaseName:"Release ${name} v${version}",...e}),this.context=t,this.githubManager=new xi(this.context),this.releaseParams=new Ri(t.shell,t.logger,{PRTitle:this.getConfig("PRTitle",this.context.shared.PRTitle),PRBody:this.getConfig("PRBody",this.context.shared.PRBody),...this.props})}enabled(t){return!this.getConfig("skip")}get isPublish(){return!this.getConfig("releasePR")}async isGithubRepository(){try{return(await this.getRemoteUrl()).includes("github.com")}catch{return!1}}async onBefore(){this.logger.debug("GithubPR onBefore");if(!await this.isGithubRepository())throw new Error("Current repository is not a GitHub repository. GitHub PR workflow is only available for GitHub repositories.");if(await super.onBefore(),this.isPublish){const t=this.getEnv("NPM_TOKEN");if(!t)throw new Error("NPM_TOKEN is not set");await this.shell.exec(`npm config set //registry.npmjs.org/:_authToken=${t}`)}}async onExec(){const t=this.context.workspaces,e=new gu(this.context.getConfig("changelog"),this.githubManager),r=await this.step({label:"GithubPR Changelogs",task:()=>e.transformWorkspace(t,this.context)});this.context.setWorkspaces(r),this.logger.debug("github changelog",this.context.workspaces)}async onSuccess(){this.isPublish?await this.publishPR(this.context.workspaces):await this.releasePR(this.context.workspaces)}async releasePR(t){await this.step({label:"Release Commit",task:()=>this.relesaeCommit(t)});const e=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(t)});await this.releasePullRequest(t,e)}async publishPR(t){this.getConfig("dryRunCreatePR")||(await this.context.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags")),await this.step({label:"Release Github",task:()=>Promise.all(t.map((t=>(this.logger.debug(t),this.githubManager.createRelease(t)))))})}async relesaeCommit(t){const e=this.getConfig("commitArgs",[]);if(1===t.length)return await this.shell.exec("git add ."),void await this.commitWorkspace(t[0],e);await this.shell.exec("git add .");const r=`chore(tag): ${t.map((t=>`${t.name} v${t.version}`)).join(",")}`;await this.commit(r,e)}async releasePullRequest(t,e){const r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(t,e)});if(this.githubManager.autoMergeReleasePR){const{releaseBranch:t}=e;return await this.step({label:`Merge Release PR(${r})`,task:()=>this.githubManager.mergePR(r,t)}),void await this.step({label:`Checked Release PR(${r})`,task:()=>this.githubManager.checkedPR(r,t)})}this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async commitWorkspace(t,e=[]){const r=this.shell.format(this.getConfig("commitMessage","chore(tag): ${name} v${version}"),t);return await this.commit(r,e)}async createReleaseBranch(t){const e=this.releaseParams.getReleaseBranchParams(t,this.context.getTemplateContext()),{tagName:r,releaseBranch:n}=e;if("string"!=typeof r)throw new Error("Tag name is not a string");const{sourceBranch:o,currentBranch:i}=this.context.shared;this.context.logger.debug("PR TagName is:",r),this.context.logger.debug("PR CurrentBranch is:",i),this.context.logger.debug("PR SourceBranch is:",o),this.context.logger.debug("PR ReleaseBranch is:",n);try{await this.context.shell.exec(`git fetch origin ${o} ${i}`),await this.context.shell.exec(`git checkout -b ${n} ${i}`),await this.context.shell.exec(`git push origin ${n}`)}catch(t){throw t.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),t}return{tagName:r,releaseBranch:n}}async createReleasePR(t,e){let r=[(await this.githubManager.createReleasePRLabel()).name];if(this.getConfig("pushChangeLabels")){const t=this.context.getConfig("workspaces.changeLabels");Array.isArray(t)&&t.length>0&&r.push(...t)}r=Array.from(new Set(r)),this.logger.debug("Release PR labels:",r);const n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(e,n),i=this.releaseParams.getPRBody(t,e,n);return this.githubManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:e.releaseBranch,labels:r})}},{})];var _u,Ru,xu,Pu;function ju(){if(Ru)return _u;Ru=1;var t=fo(),e=gi(),r=po(),n=_e(),o=pi();return _u=function(i,a,s,u){if(!n(i))return i;for(var c=-1,h=(a=e(a,i)).length,f=h-1,l=i;null!=l&&++c<h;){var g=o(a[c]),p=s;if("__proto__"===g||"constructor"===g||"prototype"===g)return i;if(c!=f){var m=l[g];void 0===(p=u?u(m,g,l):void 0)&&(p=n(m)?m:r(a[c+1])?[]:{})}t(l,g,p),l=l[g]}return i},_u}function Cu(){if(Pu)return xu;Pu=1;var t=ju();return xu=function(e,r,n){return null==e?e:t(e,r,n)},xu}var $u=ne(Cu());exports.CHANGELOG_ALL_FIELDS=Ei,exports.GitChangelog=Bi,exports.GitChangelogFormatter=fu,exports.Plugin=Ni,exports.ReleaseContext=wi,exports.ReleaseLabel=pu,exports.ReleaseTask=class{executor;defaultTuples;context;constructor(t={},e=new zt.AsyncExecutor,r=ku){this.executor=e,this.defaultTuples=r,this.context=new wi(t)}getContext(){return this.context}async usePlugins(t){t=t||this.context.shared.plugins||[];const e=await wu(this.context,[...this.defaultTuples,...t]);return e.forEach((t=>{t instanceof vu&&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()}},exports.factory=du,exports.load=yu,exports.loaderPluginsFromPluginTuples=wu,exports.reduceOptions=function(t,e){return Object.entries(t).reduce(((t,[r,n])=>(r.includes(".")?$u(t,r,n):$u(t,e?`${e}.${r}`:r,n),t)),{})},exports.tuple=ki;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { FeScriptContextOptions, Shell, FeReleaseConfig, FeScriptContext } from
|
|
|
2
2
|
import { AsyncExecutor, ExecutorContext, ExecutorPlugin } from '@qlover/fe-corekit';
|
|
3
3
|
import { LoggerInterface } from '@qlover/logger';
|
|
4
4
|
import { Env } from '@qlover/env-loader';
|
|
5
|
+
import { CommitField } from 'gitlog';
|
|
5
6
|
import { OptionValues } from 'commander';
|
|
6
7
|
|
|
7
8
|
declare class ReleaseTask {
|
|
@@ -410,6 +411,134 @@ declare class ReleaseLabel {
|
|
|
410
411
|
pick(changedFiles: Array<string> | Set<string>, packages?: string[]): string[];
|
|
411
412
|
}
|
|
412
413
|
|
|
414
|
+
type BaseCommit = {
|
|
415
|
+
[key in CommitField]: string | undefined;
|
|
416
|
+
};
|
|
417
|
+
interface GitChangelogOptions {
|
|
418
|
+
/**
|
|
419
|
+
* start tag
|
|
420
|
+
*/
|
|
421
|
+
from?: string;
|
|
422
|
+
/**
|
|
423
|
+
* end tag
|
|
424
|
+
*/
|
|
425
|
+
to?: string;
|
|
426
|
+
/**
|
|
427
|
+
* log directory
|
|
428
|
+
*/
|
|
429
|
+
directory?: string;
|
|
430
|
+
/**
|
|
431
|
+
* gitlog default fields
|
|
432
|
+
* @default ["abbrevHash", "hash", "subject", "authorName", "authorDate"]
|
|
433
|
+
*/
|
|
434
|
+
fileds?: CommitField[];
|
|
435
|
+
/**
|
|
436
|
+
* not include merge commit
|
|
437
|
+
* @default true
|
|
438
|
+
*/
|
|
439
|
+
noMerges?: boolean;
|
|
440
|
+
/**
|
|
441
|
+
* custom commit type
|
|
442
|
+
*/
|
|
443
|
+
types?: {
|
|
444
|
+
type: string;
|
|
445
|
+
section?: string;
|
|
446
|
+
hidden?: boolean;
|
|
447
|
+
}[];
|
|
448
|
+
/**
|
|
449
|
+
* custom commit format
|
|
450
|
+
*
|
|
451
|
+
* - support `CommitValue` properties
|
|
452
|
+
* - add scopeHeader, commitLink, prLink
|
|
453
|
+
*
|
|
454
|
+
* @default '\n- ${scopeHeader} ${commitlint.message} ${commitLink} ${prLink}'
|
|
455
|
+
*/
|
|
456
|
+
formatTemplate?: string;
|
|
457
|
+
/**
|
|
458
|
+
* whether to include commit body
|
|
459
|
+
* @since 2.3.0
|
|
460
|
+
* @default false
|
|
461
|
+
*/
|
|
462
|
+
commitBody?: boolean;
|
|
463
|
+
}
|
|
464
|
+
interface Commitlint {
|
|
465
|
+
type?: string;
|
|
466
|
+
scope?: string;
|
|
467
|
+
message: string;
|
|
468
|
+
/**
|
|
469
|
+
* commit body, remove repeat title
|
|
470
|
+
* @since 2.3.0
|
|
471
|
+
*/
|
|
472
|
+
body?: string;
|
|
473
|
+
}
|
|
474
|
+
interface CommitValue {
|
|
475
|
+
/**
|
|
476
|
+
* git log base info
|
|
477
|
+
*/
|
|
478
|
+
base: BaseCommit;
|
|
479
|
+
/**
|
|
480
|
+
* parsed commitlint info
|
|
481
|
+
*/
|
|
482
|
+
commitlint: Commitlint;
|
|
483
|
+
/**
|
|
484
|
+
* parsed commitlint info
|
|
485
|
+
*/
|
|
486
|
+
commits: CommitValue[];
|
|
487
|
+
/**
|
|
488
|
+
* pr number
|
|
489
|
+
*/
|
|
490
|
+
prNumber?: string;
|
|
491
|
+
}
|
|
492
|
+
interface ChangelogFormatter {
|
|
493
|
+
format<Opt extends GitChangelogOptions>(commits: unknown[], options?: Opt): string[];
|
|
494
|
+
}
|
|
495
|
+
interface ChangeLogInterface {
|
|
496
|
+
getCommits(options?: GitChangelogOptions): Promise<CommitValue[]>;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
declare const CHANGELOG_ALL_FIELDS: CommitField[];
|
|
500
|
+
interface GitChangelogProps extends GitChangelogOptions {
|
|
501
|
+
shell: Shell;
|
|
502
|
+
}
|
|
503
|
+
declare class GitChangelog implements ChangeLogInterface {
|
|
504
|
+
protected options: GitChangelogProps;
|
|
505
|
+
constructor(options: GitChangelogProps);
|
|
506
|
+
/**
|
|
507
|
+
* Get the git log
|
|
508
|
+
*
|
|
509
|
+
* @param options
|
|
510
|
+
* @returns
|
|
511
|
+
*/
|
|
512
|
+
getGitLog(options?: GitChangelogOptions): Promise<BaseCommit[]>;
|
|
513
|
+
getCommits(options?: GitChangelogOptions): Promise<CommitValue[]>;
|
|
514
|
+
protected createBaseCommit(message: string, target?: Partial<BaseCommit>): BaseCommit;
|
|
515
|
+
parseCommitlint(subject: string, rawBody?: string): Commitlint;
|
|
516
|
+
toCommitValue(hash: string, message: string): CommitValue;
|
|
517
|
+
protected resolveTag(tag?: string, fallback?: string): Promise<string>;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
interface Options extends GitChangelogOptions {
|
|
521
|
+
repoUrl?: string;
|
|
522
|
+
}
|
|
523
|
+
declare class GitChangelogFormatter implements ChangelogFormatter {
|
|
524
|
+
protected options: Options & {
|
|
525
|
+
shell: Shell;
|
|
526
|
+
};
|
|
527
|
+
constructor(options: Options & {
|
|
528
|
+
shell: Shell;
|
|
529
|
+
});
|
|
530
|
+
format(commits: CommitValue[], options?: Options): string[];
|
|
531
|
+
formatCommit(commit: CommitValue, options?: Options): string;
|
|
532
|
+
foramtLink(target: string, url?: string): string;
|
|
533
|
+
formatCommitLink(target: string, url?: string): string;
|
|
534
|
+
formatScope(scope: string): string;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
interface GithubChangelogProps extends GitChangelogProps {
|
|
538
|
+
mergePRcommit?: boolean;
|
|
539
|
+
githubRootPath?: string;
|
|
540
|
+
}
|
|
541
|
+
|
|
413
542
|
declare function load<T>(pluginName: string): Promise<[string, T]>;
|
|
414
543
|
declare function loaderPluginsFromPluginTuples<T extends Plugin<unknown>>(context: ReleaseContext, pluginsTuples: PluginTuple<PluginClass>[], maxLimit?: number): Promise<T[]>;
|
|
415
544
|
|
|
@@ -418,5 +547,5 @@ declare function factory<T, Args extends unknown[]>(Constructor: ConstructorType
|
|
|
418
547
|
|
|
419
548
|
declare function reduceOptions(opts: OptionValues, commonKey?: string): OptionValues;
|
|
420
549
|
|
|
421
|
-
export { Plugin, ReleaseContext, ReleaseLabel, ReleaseTask, factory, load, loaderPluginsFromPluginTuples, reduceOptions, tuple };
|
|
422
|
-
export type { ConstructorType, DeepPartial, ExecutorReleaseContext, PackageJson, PluginClass, PluginConstructorParams, PluginTuple, ReleaseConfig, ReleaseContextOptions, ReleaseLabelCompare, ReleaseLabelOptions, ReleaseReturnValue, StepOption, TemplateContext };
|
|
550
|
+
export { CHANGELOG_ALL_FIELDS, GitChangelog, GitChangelogFormatter, Plugin, ReleaseContext, ReleaseLabel, ReleaseTask, factory, load, loaderPluginsFromPluginTuples, reduceOptions, tuple };
|
|
551
|
+
export type { ConstructorType, DeepPartial, ExecutorReleaseContext, GitChangelogProps, GithubChangelogProps, Options, 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{Octokit as n}from"@octokit/rest";import{resolve as o,join as i,relative as s,parse as a}from"node:path";import{findWorkspaces as c}from"find-workspaces";import{readFileSync as u,existsSync as h,writeFileSync as l}from"fs";import{join as g}from"path";import{createRequire as f}from"node:module";import{pathToFileURL as p}from"node:url";import m from"p-limit";var d,y,b,v,w,R,k,x,_,P,C,$,N,j,E,B,T,O,A,S,L,W,U,F,M,G,H,I,D,z,q,V,J,Y,K,Q,X,Z,tt,et,rt,nt,ot,it,st,at,ct,ut,ht,lt,gt,ft,pt,mt,dt,yt,bt,vt,wt,Rt,kt,xt,_t,Pt,Ct,$t,Nt,jt,Et,Bt,Tt,Ot,At,St,Lt,Wt,Ut,Ft,Mt,Gt,Ht,It,Dt,zt,qt,Vt,Jt,Yt,Kt,Qt,Xt,Zt,te,ee,re,ne,oe,ie,se="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ae(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ce(){if(y)return d;return y=1,d=function(){this.__data__=[],this.size=0}}function ue(){if(v)return b;return v=1,b=function(t,e){return t===e||t!=t&&e!=e}}function he(){if(R)return w;R=1;var t=ue();return w=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function le(){if(x)return k;x=1;var t=he(),e=Array.prototype.splice;return k=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 ge(){if(P)return _;P=1;var t=he();return _=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}function fe(){if($)return C;$=1;var t=he();return C=function(e){return t(this.__data__,e)>-1}}function pe(){if(j)return N;j=1;var t=he();return N=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 me(){if(B)return E;B=1;var t=ce(),e=le(),r=ge(),n=fe(),o=pe();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,E=i}function de(){if(O)return T;O=1;var t=me();return T=function(){this.__data__=new t,this.size=0}}function ye(){if(S)return A;return S=1,A=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}}function be(){if(W)return L;return W=1,L=function(t){return this.__data__.get(t)}}function ve(){if(F)return U;return F=1,U=function(t){return this.__data__.has(t)}}function we(){if(G)return M;G=1;var t="object"==typeof se&&se&&se.Object===Object&&se;return M=t}function Re(){if(I)return H;I=1;var t=we(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return H=r}function ke(){if(z)return D;z=1;var t=Re().Symbol;return D=t}function xe(){if(V)return q;V=1;var t=ke(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,o=t?t.toStringTag:void 0;return q=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 _e(){if(Y)return J;Y=1;var t=Object.prototype.toString;return J=function(e){return t.call(e)}}function Pe(){if(Q)return K;Q=1;var t=ke(),e=xe(),r=_e(),n=t?t.toStringTag:void 0;return K=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function Ce(){if(Z)return X;return Z=1,X=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function $e(){if(et)return tt;et=1;var t=Pe(),e=Ce();return tt=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 Ne(){if(nt)return rt;nt=1;var t=Re()["__core-js_shared__"];return rt=t}function je(){if(it)return ot;it=1;var t,e=Ne(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return ot=function(t){return!!r&&r in t}}function Ee(){if(at)return st;at=1;var t=Function.prototype.toString;return st=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function Be(){if(ut)return ct;ut=1;var t=$e(),e=je(),r=Ce(),n=Ee(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,s=Object.prototype,a=i.toString,c=s.hasOwnProperty,u=RegExp("^"+a.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return ct=function(i){return!(!r(i)||e(i))&&(t(i)?u:o).test(n(i))}}function Te(){if(lt)return ht;return lt=1,ht=function(t,e){return null==t?void 0:t[e]}}function Oe(){if(ft)return gt;ft=1;var t=Be(),e=Te();return gt=function(r,n){var o=e(r,n);return t(o)?o:void 0}}function Ae(){if(mt)return pt;mt=1;var t=Oe()(Re(),"Map");return pt=t}function Se(){if(yt)return dt;yt=1;var t=Oe()(Object,"create");return dt=t}function Le(){if(vt)return bt;vt=1;var t=Se();return bt=function(){this.__data__=t?t(null):{},this.size=0}}function We(){if(Rt)return wt;return Rt=1,wt=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}}function Ue(){if(xt)return kt;xt=1;var t=Se(),e=Object.prototype.hasOwnProperty;return kt=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 Fe(){if(Pt)return _t;Pt=1;var t=Se(),e=Object.prototype.hasOwnProperty;return _t=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}function Me(){if($t)return Ct;$t=1;var t=Se();return Ct=function(e,r){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===r?"__lodash_hash_undefined__":r,this}}function Ge(){if(jt)return Nt;jt=1;var t=Le(),e=We(),r=Ue(),n=Fe(),o=Me();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,Nt=i}function He(){if(Bt)return Et;Bt=1;var t=Ge(),e=me(),r=Ae();return Et=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function Ie(){if(Ot)return Tt;return Ot=1,Tt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}}function De(){if(St)return At;St=1;var t=Ie();return At=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function ze(){if(Wt)return Lt;Wt=1;var t=De();return Lt=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}function qe(){if(Ft)return Ut;Ft=1;var t=De();return Ut=function(e){return t(this,e).get(e)}}function Ve(){if(Gt)return Mt;Gt=1;var t=De();return Mt=function(e){return t(this,e).has(e)}}function Je(){if(It)return Ht;It=1;var t=De();return Ht=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 Ye(){if(zt)return Dt;zt=1;var t=He(),e=ze(),r=qe(),n=Ve(),o=Je();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,Dt=i}function Ke(){if(Vt)return qt;Vt=1;var t=me(),e=Ae(),r=Ye();return qt=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 Qe(){if(Yt)return Jt;Yt=1;var t=me(),e=de(),r=ye(),n=be(),o=ve(),i=Ke();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,Jt=s}function Xe(){if(Qt)return Kt;Qt=1;var t=Oe(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Kt=e}function Ze(){if(Zt)return Xt;Zt=1;var t=Xe();return Xt=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function tr(){if(ee)return te;ee=1;var t=Ze(),e=ue();return te=function(r,n,o){(void 0!==o&&!e(r[n],o)||void 0===o&&!(n in r))&&t(r,n,o)}}function er(){if(ne)return re;return ne=1,re=function(t){return function(e,r,n){for(var o=-1,i=Object(e),s=n(e),a=s.length;a--;){var c=s[t?a:++o];if(!1===r(i[c],c,i))break}return e}}}function rr(){if(ie)return oe;ie=1;var t=er()();return oe=t}var nr,or,ir,sr,ar,cr,ur,hr,lr,gr,fr,pr,mr,dr,yr,br,vr,wr,Rr,kr,xr,_r,Pr,Cr,$r,Nr,jr,Er,Br,Tr,Or,Ar,Sr,Lr={exports:{}};function Wr(){return nr||(nr=1,t=Lr,e=Lr.exports,r=Re(),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}),Lr.exports;var t,e,r,n,o,i,s}function Ur(){if(ir)return or;ir=1;var t=Re().Uint8Array;return or=t}function Fr(){if(ar)return sr;ar=1;var t=Ur();return sr=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function Mr(){if(ur)return cr;ur=1;var t=Fr();return cr=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function Gr(){if(lr)return hr;return lr=1,hr=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}}function Hr(){if(fr)return gr;fr=1;var t=Ce(),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 gr=r}function Ir(){if(mr)return pr;return mr=1,pr=function(t,e){return function(r){return t(e(r))}}}function Dr(){if(yr)return dr;yr=1;var t=Ir()(Object.getPrototypeOf,Object);return dr=t}function zr(){if(vr)return br;vr=1;var t=Object.prototype;return br=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function qr(){if(Rr)return wr;Rr=1;var t=Hr(),e=Dr(),r=zr();return wr=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function Vr(){if(xr)return kr;return xr=1,kr=function(t){return null!=t&&"object"==typeof t}}function Jr(){if(Pr)return _r;Pr=1;var t=Pe(),e=Vr();return _r=function(r){return e(r)&&"[object Arguments]"==t(r)}}function Yr(){if($r)return Cr;$r=1;var t=Jr(),e=Vr(),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 Cr=i}function Kr(){if(jr)return Nr;jr=1;var t=Array.isArray;return Nr=t}function Qr(){if(Br)return Er;Br=1;return Er=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Xr(){if(Or)return Tr;Or=1;var t=$e(),e=Qr();return Tr=function(r){return null!=r&&e(r.length)&&!t(r)}}function Zr(){if(Sr)return Ar;Sr=1;var t=Xr(),e=Vr();return Ar=function(r){return e(r)&&t(r)}}var tn,en,rn,nn,on,sn,an,cn,un,hn={exports:{}};function ln(){if(en)return tn;return en=1,tn=function(){return!1}}function gn(){return rn||(rn=1,function(t,e){var r=Re(),n=ln(),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}(hn,hn.exports)),hn.exports}function fn(){if(on)return nn;on=1;var t=Pe(),e=Dr(),r=Vr(),n=Function.prototype,o=Object.prototype,i=n.toString,s=o.hasOwnProperty,a=i.call(Object);return nn=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var o=e(n);if(null===o)return!0;var c=s.call(o,"constructor")&&o.constructor;return"function"==typeof c&&c instanceof c&&i.call(c)==a}}function pn(){if(an)return sn;an=1;var t=Pe(),e=Qr(),r=Vr(),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,sn=function(o){return r(o)&&e(o.length)&&!!n[t(o)]}}function mn(){if(un)return cn;return un=1,cn=function(t){return function(e){return t(e)}}}var dn,yn,bn,vn,wn,Rn,kn,xn,_n,Pn,Cn,$n,Nn,jn,En,Bn,Tn,On,An,Sn,Ln,Wn,Un,Fn,Mn,Gn,Hn,In,Dn,zn,qn,Vn,Jn,Yn,Kn,Qn,Xn,Zn,to,eo,ro,no,oo,io,so,ao,co,uo,ho,lo={exports:{}};function go(){return dn||(dn=1,t=lo,e=lo.exports,r=we(),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),lo.exports;var t,e,r,n,o,i,s}function fo(){if(bn)return yn;bn=1;var t=pn(),e=mn(),r=go(),n=r&&r.isTypedArray,o=n?e(n):t;return yn=o}function po(){if(wn)return vn;return wn=1,vn=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function mo(){if(kn)return Rn;kn=1;var t=Ze(),e=ue(),r=Object.prototype.hasOwnProperty;return Rn=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 yo(){if(_n)return xn;_n=1;var t=mo(),e=Ze();return xn=function(r,n,o,i){var s=!o;o||(o={});for(var a=-1,c=n.length;++a<c;){var u=n[a],h=i?i(o[u],r[u],u,o,r):void 0;void 0===h&&(h=r[u]),s?e(o,u,h):t(o,u,h)}return o}}function bo(){if(Cn)return Pn;return Cn=1,Pn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}}function vo(){if(Nn)return $n;Nn=1;var t=/^(?:0|[1-9]\d*)$/;return $n=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 wo(){if(En)return jn;En=1;var t=bo(),e=Yr(),r=Kr(),n=gn(),o=vo(),i=fo(),s=Object.prototype.hasOwnProperty;return jn=function(a,c){var u=r(a),h=!u&&e(a),l=!u&&!h&&n(a),g=!u&&!h&&!l&&i(a),f=u||h||l||g,p=f?t(a.length,String):[],m=p.length;for(var d in a)!c&&!s.call(a,d)||f&&("length"==d||l&&("offset"==d||"parent"==d)||g&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||o(d,m))||p.push(d);return p}}function Ro(){if(Tn)return Bn;return Tn=1,Bn=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}}function ko(){if(An)return On;An=1;var t=Ce(),e=zr(),r=Ro(),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 xo(){if(Ln)return Sn;Ln=1;var t=wo(),e=ko(),r=Xr();return Sn=function(n){return r(n)?t(n,!0):e(n)}}function _o(){if(Un)return Wn;Un=1;var t=yo(),e=xo();return Wn=function(r){return t(r,e(r))}}function Po(){if(Mn)return Fn;Mn=1;var t=tr(),e=Wr(),r=Mr(),n=Gr(),o=qr(),i=Yr(),s=Kr(),a=Zr(),c=gn(),u=$e(),h=Ce(),l=fn(),g=fo(),f=po(),p=_o();return Fn=function(m,d,y,b,v,w,R){var k=f(m,y),x=f(d,y),_=R.get(x);if(_)t(m,y,_);else{var P=w?w(k,x,y+"",m,d,R):void 0,C=void 0===P;if(C){var $=s(x),N=!$&&c(x),j=!$&&!N&&g(x);P=x,$||N||j?s(k)?P=k:a(k)?P=n(k):N?(C=!1,P=e(x,!0)):j?(C=!1,P=r(x,!0)):P=[]:l(x)||i(x)?(P=k,i(k)?P=p(k):h(k)&&!u(k)||(P=o(x))):C=!1}C&&(R.set(x,P),v(P,x,b,w,R),R.delete(x)),t(m,y,P)}}}function Co(){if(Hn)return Gn;Hn=1;var t=Qe(),e=tr(),r=rr(),n=Po(),o=Ce(),i=xo(),s=po();return Gn=function a(c,u,h,l,g){c!==u&&r(u,(function(r,i){if(g||(g=new t),o(r))n(c,u,i,h,a,l,g);else{var f=l?l(s(c,i),r,i+"",c,u,g):void 0;void 0===f&&(f=r),e(c,i,f)}}),i)},Gn}function $o(){if(Dn)return In;return Dn=1,In=function(t){return t}}function No(){if(qn)return zn;return qn=1,zn=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 jo(){if(Jn)return Vn;Jn=1;var t=No(),e=Math.max;return Vn=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),c=Array(a);++s<a;)c[s]=i[n+s];s=-1;for(var u=Array(n+1);++s<n;)u[s]=i[s];return u[n]=o(c),t(r,this,u)}},Vn}function Eo(){if(Kn)return Yn;return Kn=1,Yn=function(t){return function(){return t}}}function Bo(){if(Xn)return Qn;Xn=1;var t=Eo(),e=Xe();return Qn=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:$o()}function To(){if(to)return Zn;to=1;var t=Date.now;return Zn=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)}},Zn}function Oo(){if(ro)return eo;ro=1;var t=Bo(),e=To()(t);return eo=e}function Ao(){if(oo)return no;oo=1;var t=$o(),e=jo(),r=Oo();return no=function(n,o){return r(e(n,o,t),n+"")}}function So(){if(so)return io;so=1;var t=ue(),e=Xr(),r=vo(),n=Ce();return io=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 Lo(){if(co)return ao;co=1;var t=Ao(),e=So();return ao=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 c=n[o];c&&r(t,c,o,s)}return t}))}}function Wo(){if(ho)return uo;ho=1;var t=Co(),e=Lo()((function(e,r,n){t(e,r,n)}));return uo=e}var Uo,Fo,Mo,Go,Ho,Io,Do,zo,qo,Vo,Jo,Yo,Ko,Qo,Xo,Zo,ti,ei,ri,ni,oi,ii,si,ai,ci=ae(Wo());function ui(){if(Fo)return Uo;Fo=1;var t=Pe(),e=Vr();return Uo=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function hi(){if(Go)return Mo;Go=1;var t=Kr(),e=ui(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Mo=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 li(){if(Io)return Ho;Io=1;var t=Ye();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,Ho=e}function gi(){if(zo)return Do;zo=1;var t=li();return Do=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function fi(){if(Vo)return qo;Vo=1;var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,e=/\\(\\)?/g,r=gi()((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 qo=r}function pi(){if(Yo)return Jo;return Yo=1,Jo=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 mi(){if(Qo)return Ko;Qo=1;var t=ke(),e=pi(),r=Kr(),n=ui(),o=t?t.prototype:void 0,i=o?o.toString:void 0;return Ko=function t(o){if("string"==typeof o)return o;if(r(o))return e(o,t)+"";if(n(o))return i?i.call(o):"";var s=o+"";return"0"==s&&1/o==-1/0?"-0":s},Ko}function di(){if(Zo)return Xo;Zo=1;var t=mi();return Xo=function(e){return null==e?"":t(e)}}function yi(){if(ei)return ti;ei=1;var t=Kr(),e=hi(),r=fi(),n=di();return ti=function(o,i){return t(o)?o:e(o,i)?[o]:r(n(o))}}function bi(){if(ni)return ri;ni=1;var t=ui();return ri=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function vi(){if(ii)return oi;ii=1;var t=yi(),e=bi();return oi=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 wi(){if(ai)return si;ai=1;var t=vi();return si=function(e,r,n){var o=null==e?void 0:t(e,r);return void 0===o?n:o}}var Ri=ae(wi());const ki="package.json",xi=[".env.local",".env"];class _i extends t{_env;shared;constructor(t){super(t),this._env=e.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||xi}),this.shared=Object.assign({},this.feConfig.release,this.getDefaultShreadOptions(t.shared))}getDefaultShreadOptions(t){return{rootPath:process.cwd(),sourceBranch:this._env.get("FE_RELEASE_BRANCH")||this._env.get("FE_RELEASE_SOURCE_BRANCH")||"master",releaseEnv:this._env.get("FE_RELEASE_ENV")||this._env.get("NODE_ENV")||"development",...t}}get rootPath(){return this.shared.rootPath}get sourceBranch(){return this.shared.sourceBranch}get releaseEnv(){return this.shared.releaseEnv}get env(){return this._env}get workspaces(){return this.getConfig("workspaces.workspaces")}get workspace(){return this.getConfig("workspaces.workspace")}setWorkspaces(t){this.options.workspaces={...this.options.workspaces,workspaces:t}}setConfig(t){this.options=ci(this.options,t)}getConfig(t,e){return Ri(this.options,t,e)}setShared(t){this.shared=ci(this.shared,t)}getPkg(t,e){const r=this.workspace?.packageJson;if(!r)throw new Error("package.json is not found");return t?Ri(r,t,e):r}getTemplateContext(){return{...this.shared,...this.workspace,publishPath:this.workspace?.path||"",env:this.releaseEnv,branch:this.sourceBranch}}async runChangesetsCli(t,e){let r="pnpm";try{await this.shell.exec("pnpm -v",{dryRun:!1})}catch{r="npx"}return await this.shell.exec([r,"changeset",t,...e??[]])}}function Pi(t,...e){return[t,...e]}const Ci={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages-${timestamp}",batchTagName:"batch-${length}-packages-${timestamp}"};class $i{shell;logger;config;constructor(t,e,r={}){this.shell=t,this.logger=e,this.config={...Ci,...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.debug("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.debug("Release Batch Branch template is:",o),this.shell.format(o,{pkgName:t,releaseName:t,tagName:e,...r,length:n,timestamp:Date.now()})}getReleaseName(t){if(1===t.length)return t[0].name;const{maxWorkspace:e,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return t.slice(0,e).map((({name:t,version:e})=>`${t}${n}${e}`)).join(r)}getReleaseTagName(t){if(1===t.length)return t[0].version;const{batchTagName:e}=this.config;return this.shell.format(e,{length:t.length,timestamp:Date.now()})}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))).join("\n"):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;_octokit=null;constructor(t){this.context=t}getGitHubUserInfo(){const{authorName:t,repoName:e}=this.context.shared;if(!t||!e)throw new Error("Author name or repo name is not set");return{owner:t,repo:e}}getToken(){const{tokenRef:t="GITHUB_TOKEN"}=this.context.getConfig("githubPR"),e=this.context.env.get(t);if(!e)throw new Error(`Token is not set. Please set ${t} environment variable.`);return e}get octokit(){if(this._octokit)return this._octokit;const{timeout:t}=this.context.getConfig("githubPR"),e={auth:this.getToken(),request:{timeout:t}};return this._octokit=new n(e),this._octokit}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.shared.autoMergeType||"squash"}get dryRunPRNumber(){return this.context.getConfig("githubPR.dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.shared.autoMergeReleasePR||false}async mergePR(t,e){if(!t)return void this.logger.error("Failed to create Pull Request.",t);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.context.shared;this.logger.info(`[DRY RUN] Would merge PR #${t} with method '${r}' in repo ${o}/${n}, branch ${e}`)}else await this.octokit.rest.pulls.merge({...this.getGitHubUserInfo(),pull_number:Number(t),merge_method:r})}async checkedPR(t,e){try{await this.octokit.rest.pulls.get({...this.getGitHubUserInfo(),pull_number:Number(t)}),await this.octokit.rest.git.deleteRef({...this.getGitHubUserInfo(),ref:`heads/${e}`}),this.logger.info(`Branch ${e} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${t} or branch ${e} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const t=this.context.shared.label;if(!(t&&t.name&&t.description&&t.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",t),t;try{const e=await this.octokit.rest.issues.createLabel({...this.getGitHubUserInfo(),name:t.name,description:t.description,color:t.color.replace("#","")});return this.logger.debug("Create PR label Success",e),t}catch(e){if(422===e.status)return this.logger.warn(`Label ${t.name} already exists, skipping!`),t;throw this.logger.error("Create PR label Failed",e),e}}async createReleasePR(t){if(this.context.getConfig("githubPR.dryRunCreatePR")||this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...t,labels:t.labels}),this.dryRunPRNumber;try{const e=await this.octokit.rest.pulls.create({...this.getGitHubUserInfo(),...t}),r=e.data.number;if(!r)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",[e?.url]),t.labels&&t.labels.length){const e=await this.octokit.rest.issues.addLabels({...this.getGitHubUserInfo(),issue_number:r,labels:t.labels});this.logger.debug("Add PR label Success",[e.url])}return r.toString()}catch(t){if(422===t.status&&t.message.includes("already exists")){this.logger.warn("PR already exists");const e=t.message.match(/pull request #(\d+)/);return e?e[1]:""}throw this.logger.error("Failed to create PR",t),t}}truncateBody(t){return t&&t.length>=124e3?t.substring(0,124e3)+"...":t}getOctokitReleaseOptions(t){const{releaseName:e,draft:r=!1,preRelease:n=!1,autoGenerate:o=!1,makeLatest:i=!0,releaseNotes:s,discussionCategoryName:a}=this.context.getConfig("githubPR"),c=e,u=o?"":this.truncateBody(String(s));return{name:c,make_latest:i.toString(),body:u,draft:r,prerelease:n,generate_release_notes:o,discussion_category_name:a,tag_name:"",...t,...this.getGitHubUserInfo()}}async createRelease(t){const e=this.getOctokitReleaseOptions({tag_name:t.tagName,body:t.changelog});if(e.name=this.shell.format(e.name,t),this.logger.log(`[DRY RUN] octokit repos.createRelease "${e.name}" (${e.tag_name})`,{isDryRun:this.context.dryRun}),!e.tag_name)throw new Error("TagName is undefined");if(!this.context.dryRun)try{const t=await this.octokit.repos.createRelease(e);this.logger.debug(`[DONE] octokit repos.createRelease "${e.name}" (${e.tag_name}) (${t.headers.location})`)}catch(t){this.logger.error(`[FAILED] octokit repos.createRelease "${e.name}" (${e.tag_name})`,t)}}}var ji,Ei;function Bi(){if(Ei)return ji;Ei=1;var t=Pe(),e=Kr(),r=Vr();return ji=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}var Ti=ae(Bi());class Oi{context;pluginName;props;onlyOne=!0;constructor(t,e,r={}){this.context=t,this.pluginName=e,this.props=r,this.setConfig(this.getInitialProps(r))}getInitialProps(t){const e=this.context.options[this.pluginName],r=Ri(this.context.shared,this.pluginName);return e||t?ci({},r,t,e):{}}get logger(){return this.context.logger}get shell(){return this.context.shell}get options(){return this.context.getConfig(this.pluginName,{})}getEnv(t,e){return this.context.env.get(t)??e}enabled(t,e){return!0}getConfig(t,e){return t?this.context.getConfig([this.pluginName,...Array.isArray(t)?t:[t]],e):this.context.getConfig(this.pluginName,e)}setConfig(t){this.context.setConfig({[this.pluginName]:t})}onBefore(t){}onExec(t){}onSuccess(t){}onError(t){}async step({label:t,task:e}){this.logger.log(),this.logger.info(t),this.logger.log();try{const r=await e();return this.logger.info(`${t} - success`),r}catch(t){throw this.logger.error(t),t}}}class Ai extends Oi{async onBefore(){const t=await this.getUserInfo();if(!t)throw new Error("Failed to get repoInfo");let e=this.context.shared.currentBranch;e||(e=await this.getCurrentBranch()),e&&await this.context.shell.exec(`git checkout ${e}`,{dryRun:!1}),this.context.setShared({repoName:t.repoName,authorName:t.authorName,currentBranch:e})}async getCurrentBranch(){return await new Promise((t=>setTimeout(t,100))),this.context.shell.exec("git rev-parse --abbrev-ref HEAD",{dryRun:!1})}async getRemoteUrl(){return(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}async getUserInfo(){let t;try{t=await this.getRemoteUrl()}catch{throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!t)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.debug("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&&Ti(t)}commit(t,e=[]){return this.context.shell.exec(["git","commit","--message",JSON.stringify(t),...e])}}class Si{options;constructor(t){this.options=t}compare(t,e){return"function"==typeof this.options.compare?this.options.compare(t,e):t.startsWith(e)}toChangeLabel(t,e=this.options.changePackagesLabel){return e.replace("${name}",t)}toChangeLabels(t,e=this.options.changePackagesLabel){return t.map((t=>this.toChangeLabel(t,e)))}pick(t,e=this.options.packagesDirectories){const r=[];for(const n of e)for(const e of t)if(this.compare(e,n)){r.push(n);break}return r}}class Li{static readJson(t){const e=u(t,"utf-8");return JSON.parse(e)}static toWorkspace(t,e){let{root:r,packageJson:n}=t;const o=t.path;if(!o)throw new Error("path is not required!");return r=r||g(e,o),n=n||Li.readJson(g(r,ki)),{name:n.name,version:n.version,path:o,root:r,packageJson:n}}}class Wi extends Oi{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(t){super(t,"workspaces"),this.releaseLabel=new Si({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[],compare:(t,e)=>o(t).startsWith(o(e))})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){const t=this.getConfig("workspace");if(t)return this.logger.debug("Use the specified workspace",t),void this.setCurrentWorkspace(t,[]);const e=await this.getWorkspaces();if(this.getConfig("skipCheckPackage")||0===e.length)throw new Error("No changes to publish packages");const{publishPath:r}=this.context.shared;if(r){const t=e.find((t=>o(t.root)===o(r)));if(this.nextSkip(),!t)throw new Error(`No workspace found for: ${r}`);return this.logger.debug(`Workspace of ${r} find!`,i(t.root,ki)),void this.setCurrentWorkspace(t,[t])}const[n,...s]=e;this.workspacesList=s,this.setCurrentWorkspace(n,e)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}setReleaseTask(t){this.releaseTask=t}setCurrentWorkspace(t,e){this.context.setShared({publishPath:t.path}),this.setConfig({workspace:t,workspaces:e})}async getGitWorkspaces(){const t=this.context.sourceBranch,e=await this.shell.exec(`git diff --name-only origin/${t}...HEAD`,{dryRun:!1});return"string"==typeof e?e.split("\n"):[]}async getChangedPackages(t,e){if(this.logger.debug("changeLabels",e),Array.isArray(e)&&e.length>0){const r=t.filter((t=>{const r=this.releaseLabel.toChangeLabel(t);return e.includes(r)}));return this.logger.debug("changed by labels",r),r}const r=await this.getGitWorkspaces();return this.logger.debug("changed by git",r),this.releaseLabel.pick(r,t)}getProjectWorkspaces(){const t=this.context.rootPath,e=this.context.shared.packagesDirectories;if(Array.isArray(e)&&e.length>0)return e.map((e=>Li.toWorkspace({path:e},t)));return(c(t)||[]).map((e=>({name:e.package.name,version:e.package.version,path:s(t,e.location),root:o(t,e.location),packageJson:e.package})))}async getWorkspaces(){const t=this.getProjectWorkspaces(),e=t.map((({path:t})=>t));this.logger.debug("packages",e);const r=this.getConfig("changeLabels"),n=await this.getChangedPackages(e,r);return this.setConfig({packages:e,changedPaths:n,projectWorkspaces:t}),this.logger.debug("changedPaths",n),t.filter((t=>n.includes(t.path)))}}function Ui(t,...e){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t?new t(...e):t(...e)}function Fi(t){return t.startsWith(".")?a(t).name:t}async function Mi(t){let e=null;try{e=(await import(t)).default}catch{try{e=(await import(i(process.cwd(),t))).default}catch{const r=f(process.cwd());e=(await import(p(r.resolve(t,{paths:[process.cwd()]})).href)).default}}return[Fi(t),e]}async function Gi(t,e,r=5){const n=m(r),o=e.map((([e,...r])=>n((()=>(async(e,...r)=>{if("string"==typeof e){const[,n]=await Mi(e);return Ui(n,t,...r)}return Ui(e,t,...r)})(e,...r)))));return Promise.all(o)}const Hi="- ${message}${prRef}\n",Ii="%H%n%s%n%b%n----------------------";class Di{formatFlatCommits(t,e,r){const{types:n=[],formatTemplate:o=Hi}=e,i=new Map;for(const e of t){const t=e.type||"other";i.has(t)||i.set(t,[]),i.get(t).push(e)}const s=[];for(const{type:t,section:e,hidden:a}of n){if(a)continue;const n=i.get(t);if(n?.length){s.push(`${e||t}`);for(const t of n){const e=t.prNumber?` (#${t.prNumber})`:"";if(s.push(r.format(o,{...t,prRef:e})),t.body){const e=t.body.split("\n").map((t=>` ${t}`));s.push(e.join("\n"))}}}}return s}}class zi{shell;options;constructor(t,e){this.shell=t,this.options=e}parseCommitBody(t){const e=t.split("\n").filter(Boolean),r=[];let n=null;for(let t=0;t<e.length;t++){const o=e[t].trim();if(o.startsWith("Co-authored-by:")||"---------"===o||0===o.length)continue;const i=o.match(/^\*?\s*(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);if(i&&o.startsWith("*")){n&&r.push({...n,body:n.bodyLines?.join("\n").trim()});const[t,e,s,a]=i;n={matchRaw:t,raw:o,type:e?.toLowerCase(),scope:s?.trim(),message:a.trim(),bodyLines:[]}}else n&&o.startsWith("-")&&n.bodyLines?.push(o)}return n&&r.push({...n,body:n.bodyLines?.join("\n").trim()}),r}async getPRCommits(t){const{from:e,to:r,directory:n,format:o}={...this.options,...t};return(await this.getLog({from:e,to:r,directory:n,format:o,noMerges:!1})).split("\n----------------------\n").filter(Boolean).map((t=>{const[e,r,...n]=t.trim().split("\n"),o=n.join("\n"),i=r.match(/\(#(\d+)\)/),s=r.replace(/\s*\(#\d+\)\s*$/,"").match(/^(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);return{hash:e,raw:{title:r,body:o},title:s?{type:s[1]?.toLowerCase(),scope:s[2]?.trim(),message:s[3].trim()}:{message:r.replace(/\s*\(#\d+\)\s*$/,"").trim()},commits:this.parseCommitBody(o),prNumber:i?.[1]}}))}async hasTag(t){return this.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((()=>!0)).catch((()=>!1))}async resolveTag(t,e){if(t)try{if(await this.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((t=>!!t.trim())))return t}catch{}return"root"===e?this.shell.exec("git rev-list --max-parents=0 HEAD",{dryRun:!1}).then((t=>t.trim())):"HEAD"}async getLog(t){const{directory:e,format:r=Ii,noMerges:n=!0}=t;if(t.logCommand)return this.shell.exec(t.logCommand,{dryRun:!1});const o=await this.resolveTag(t.from,"root"),i=await this.resolveTag(t.to,"HEAD"),s=`git log --pretty=format:"${r}" ${n?"--no-merges":""} ${o===i?i:`${o}..${i}`} ${e?`-- "${e}"`:""}`;return this.shell.exec(s.trim(),{dryRun:!1})}flatCommits(t){const e=[];for(const r of t){const t={title:r.title,raw:r.raw,hash:r.hash,prNumber:r.prNumber};if(Array.isArray(r.commits)&&r.commits.length>0){const n=r.commits.map((e=>({...e,prNumber:r.prNumber,hash:r.hash,parentHash:r.hash,parentCommit:t})));e.push(...n)}else e.push({raw:r.raw.title,type:r.title.type,scope:r.title.scope,message:r.title.message,body:r.raw.body,prNumber:r.prNumber,hash:r.hash,parentHash:r.hash,parentCommit:t})}return e}formatFlatCommits(t,e){const{types:r=[],formatter:n}={...this.options,...e};return(n||new Di).formatFlatCommits(t,{types:r},this.shell)}}const qi=[Pi(Wi),Pi(class extends Oi{constructor(t,e){super(t,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...e})}get changesetRoot(){return g(this.context.rootPath,this.getConfig("changesetRoot"))}get changesetConfigPath(){return g(this.changesetRoot,"config.json")}enabled(){return!this.getConfig("skip")}async onBefore(){if(!h(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}mergeWorkspaces(t){return t.map((t=>{const e=Li.toWorkspace({path:t.path},this.context.rootPath),r={...t,version:e.version};return r.tagName=this.generateTagName(r),r}))}async onExec(){const t=await this.step({label:"Generate Changelogs",task:()=>Promise.all(this.context.workspaces.map((t=>this.generateChangelog(t))))});this.getConfig("skipChangeset")?this.logger.debug("Skip generate changeset files"):(await this.step({label:"Changeset Version",task:()=>Promise.all(t.map((t=>this.generateChangesetFile(t))))}),await this.context.runChangesetsCli("version",["--no-changelog","--update-dependencies"]),this.getConfig("ignoreNonUpdatedPackages")&&await this.restoreIgnorePackages());const e=this.mergeWorkspaces(t);this.logger.debug("new workspaces",e),this.context.setWorkspaces(e)}async restoreIgnorePackages(){const{changedPaths:t=[],packages:e=[]}=this.context.getConfig("workspaces"),r=e.filter((e=>!t.includes(e))).map((t=>Li.toWorkspace({path:t},this.context.rootPath).path));this.logger.debug("noChangedPackages",r),await this.shell.exec(["git","restore",...r])}getTagPrefix(t){return this.shell.format(this.getConfig("tagPrefix"),t)}async createChangelog({lastTag:t,workspace:e}){const r=new zi(this.context.shell,{...this.getConfig("gitChangelogOptions"),from:t,directory:e.path});return r.getPRCommits().then((t=>{const e=r.flatCommits(t);return r.formatFlatCommits(e).join("\n")}))}async generateChangelog(t){const e=await this.getTagName(t);this.logger.debug("tagName is:",e);const r=await this.createChangelog({workspace:t,lastTag:e});return{...t,lastTag:e,changelog:r}}generateTagName(t){try{const e=this.getConfig("tagTemplate");return this.shell.format(e,t)}catch(e){return console.error(`Error generating tag name for ${t.name}:`,e),`${t.name}-v0.0.0`}}async getTagName(t){try{const e=this.generateTagName(t),r=this.shell.format(this.getConfig("tagMatch"),t),n=await this.shell.exec(`git for-each-ref --sort=-creatordate --format "%(refname:short)|%(creatordate:iso8601)" "refs/tags/${r}"`,{dryRun:!1});if(!n)return e;const o=n.split("\n").filter(Boolean);if(0===o.length)return e;return o[0].split("|")[0]}catch(e){console.error(`Error getting tag for ${t.name}:`,e);return this.generateTagName(t)}}getIncrement(){const t=this.context.getConfig("workspaces.changeLabels");if(Array.isArray(t)&&t.length>0){if(t.includes("increment:major"))return"major";if(t.includes("increment:minor"))return"minor"}return this.getConfig("increment","patch")}async generateChangesetFile(t){const{name:e,version:r}=t,n=`${e}-${r}`.replace(/[\/\\]/g,"_"),o=g(this.changesetRoot,`${n}.md`),i=this.getIncrement();this.logger.debug("increment is:",[i]);const s=this.shell.format("---\n'${name}': '${increment}'\n---\n\n${changelog}",{...t,increment:i});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(s);h(o)?this.logger.info(`Changeset ${n} already exists`):l(o,s,"utf-8")}},{}),Pi(class extends Ai{context;releaseParams;githubManager;constructor(t,e){super(t,"githubPR",{releaseName:"Release ${name} v${version}",...e}),this.context=t,this.githubManager=new Ni(this.context),this.releaseParams=new $i(t.shell,t.logger,{PRTitle:this.getConfig("PRTitle",this.context.shared.PRTitle),PRBody:this.getConfig("PRBody",this.context.shared.PRBody),...this.props})}enabled(t){return!this.getConfig("skip")&&("onExec"===t?!this.isPublish:"onSuccess"!==t||this.isPublish)}get isPublish(){return!this.getConfig("releasePR")}async isGithubRepository(){try{return(await this.getRemoteUrl()).includes("github.com")}catch{return!1}}async onBefore(){this.logger.debug("GithubPR onBefore");if(!await this.isGithubRepository())throw new Error("Current repository is not a GitHub repository. GitHub PR workflow is only available for GitHub repositories.");if(await super.onBefore(),this.isPublish){const t=this.getEnv("NPM_TOKEN");if(!t)throw new Error("NPM_TOKEN is not set");await this.shell.exec(`npm config set //registry.npmjs.org/:_authToken=${t}`)}}async onExec(){const t=this.context.workspaces;await this.step({label:"Release Commit",task:()=>this.relesaeCommit(t)});const e=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(t)});await this.releasePullRequest(t,e)}async onSuccess(){const t=this.context.workspaces;this.getConfig("dryRunCreatePR")||(await this.context.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags")),await this.step({label:"Release Github",task:()=>Promise.all(t.map((t=>(this.logger.debug(t),this.githubManager.createRelease(t)))))})}async relesaeCommit(t){const e=this.getConfig("commitArgs",[]);if(1===t.length)return await this.shell.exec("git add ."),void await this.commitWorkspace(t[0],e);await this.shell.exec("git add .");const r=`chore(tag): ${t.map((t=>`${t.name} v${t.version}`)).join(",")}`;await this.commit(r,e)}async releasePullRequest(t,e){const r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(t,e)});if(this.githubManager.autoMergeReleasePR){const{releaseBranch:t}=e;return await this.step({label:`Merge Release PR(${r})`,task:()=>this.githubManager.mergePR(r,t)}),void await this.step({label:`Checked Release PR(${r})`,task:()=>this.githubManager.checkedPR(r,t)})}this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async commitWorkspace(t,e=[]){const r=this.shell.format(this.getConfig("commitMessage","chore(tag): ${name} v${version}"),t);return await this.commit(r,e)}async createReleaseBranch(t){const e=this.releaseParams.getReleaseBranchParams(t,this.context.getTemplateContext()),{tagName:r,releaseBranch:n}=e;if("string"!=typeof r)throw new Error("Tag name is not a string");const{sourceBranch:o,currentBranch:i}=this.context.shared;this.context.logger.debug("PR TagName is:",r),this.context.logger.debug("PR CurrentBranch is:",i),this.context.logger.debug("PR SourceBranch is:",o),this.context.logger.debug("PR ReleaseBranch is:",n);try{await this.context.shell.exec(`git fetch origin ${o} ${i}`),await this.context.shell.exec(`git checkout -b ${n} ${i}`),await this.context.shell.exec(`git push origin ${n}`)}catch(t){throw t.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),t}return{tagName:r,releaseBranch:n}}async createReleasePR(t,e){let r=[(await this.githubManager.createReleasePRLabel()).name];if(this.getConfig("pushChangeLabels")){const t=this.context.getConfig("workspaces.changeLabels");Array.isArray(t)&&t.length>0&&r.push(...t)}r=Array.from(new Set(r)),this.logger.debug("Release PR labels:",r);const n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(e,n),i=this.releaseParams.getPRBody(t,e,n);return this.githubManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:e.releaseBranch,labels:r})}},{})];class Vi{executor;defaultTuples;context;constructor(t={},e=new r,n=qi){this.executor=e,this.defaultTuples=n,this.context=new _i(t)}getContext(){return this.context}async usePlugins(t){t=t||this.context.shared.plugins||[];const e=await Gi(this.context,[...this.defaultTuples,...t]);return e.forEach((t=>{t instanceof Wi&&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 Ji,Yi,Ki,Qi;function Xi(){if(Yi)return Ji;Yi=1;var t=mo(),e=yi(),r=vo(),n=Ce(),o=bi();return Ji=function(i,s,a,c){if(!n(i))return i;for(var u=-1,h=(s=e(s,i)).length,l=h-1,g=i;null!=g&&++u<h;){var f=o(s[u]),p=a;if("__proto__"===f||"constructor"===f||"prototype"===f)return i;if(u!=l){var m=g[f];void 0===(p=c?c(m,f,g):void 0)&&(p=n(m)?m:r(s[u+1])?[]:{})}t(g,f,p),g=g[f]}return i}}function Zi(){if(Qi)return Ki;Qi=1;var t=Xi();return Ki=function(e,r,n){return null==e?e:t(e,r,n)}}var ts=ae(Zi());function es(t,e){return Object.entries(t).reduce(((t,[r,n])=>(r.includes(".")?ts(t,r,n):ts(t,e?`${e}.${r}`:r,n),t)),{})}export{Oi as Plugin,_i as ReleaseContext,Si as ReleaseLabel,Vi as ReleaseTask,Ui as factory,Mi as load,Gi as loaderPluginsFromPluginTuples,es as reduceOptions,Pi as tuple};
|
|
1
|
+
import{FeScriptContext as t}from"@qlover/scripts-context";import{Env as e}from"@qlover/env-loader";import{AsyncExecutor as r}from"@qlover/fe-corekit";import{Octokit as n}from"@octokit/rest";import o from"gitlog";import{resolve as i,join as a,relative as s,parse as u}from"node:path";import{findWorkspaces as c}from"find-workspaces";import{readFileSync as f,existsSync as h,writeFileSync as l}from"fs";import{join as g}from"path";import{createRequire as p}from"node:module";import{pathToFileURL as m}from"node:url";import v from"p-limit";var d,b,y,w,k,_,R,x,P,j,C,$,N,O,E,B,T,S,A,L,W,U,M,D,H,G,F,I,z,q,V,J,Y,K,Q,X,Z,tt,et,rt,nt,ot,it,at,st,ut,ct,ft,ht,lt,gt,pt,mt,vt,dt,bt,yt,wt,kt,_t,Rt,xt,Pt,jt,Ct,$t,Nt,Ot,Et,Bt,Tt,St,At,Lt,Wt,Ut,Mt,Dt,Ht,Gt,Ft,It,zt,qt,Vt,Jt,Yt,Kt,Qt,Xt,Zt,te,ee,re,ne,oe,ie,ae,se="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ue(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ce(){if(b)return d;return b=1,d=function(){this.__data__=[],this.size=0}}function fe(){if(w)return y;return w=1,y=function(t,e){return t===e||t!=t&&e!=e}}function he(){if(_)return k;_=1;var t=fe();return k=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function le(){if(x)return R;x=1;var t=he(),e=Array.prototype.splice;return R=function(r){var n=this.__data__,o=t(n,r);return!(o<0)&&(o==n.length-1?n.pop():e.call(n,o,1),--this.size,!0)}}function ge(){if(j)return P;j=1;var t=he();return P=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}function pe(){if($)return C;$=1;var t=he();return C=function(e){return t(this.__data__,e)>-1}}function me(){if(O)return N;O=1;var t=he();return N=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 ve(){if(B)return E;B=1;var t=ce(),e=le(),r=ge(),n=pe(),o=me();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,E=i}function de(){if(S)return T;S=1;var t=ve();return T=function(){this.__data__=new t,this.size=0}}function be(){if(L)return A;return L=1,A=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}}function ye(){if(U)return W;return U=1,W=function(t){return this.__data__.get(t)}}function we(){if(D)return M;return D=1,M=function(t){return this.__data__.has(t)}}function ke(){if(G)return H;G=1;var t="object"==typeof se&&se&&se.Object===Object&&se;return H=t}function _e(){if(I)return F;I=1;var t=ke(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return F=r}function Re(){if(q)return z;q=1;var t=_e().Symbol;return z=t}function xe(){if(J)return V;J=1;var t=Re(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,o=t?t.toStringTag:void 0;return V=function(t){var e=r.call(t,o),i=t[o];try{t[o]=void 0;var a=!0}catch(t){}var s=n.call(t);return a&&(e?t[o]=i:delete t[o]),s}}function Pe(){if(K)return Y;K=1;var t=Object.prototype.toString;return Y=function(e){return t.call(e)}}function je(){if(X)return Q;X=1;var t=Re(),e=xe(),r=Pe(),n=t?t.toStringTag:void 0;return Q=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function Ce(){if(tt)return Z;return tt=1,Z=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function $e(){if(rt)return et;rt=1;var t=je(),e=Ce();return et=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 Ne(){if(ot)return nt;ot=1;var t=_e()["__core-js_shared__"];return nt=t}function Oe(){if(at)return it;at=1;var t,e=Ne(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return it=function(t){return!!r&&r in t}}function Ee(){if(ut)return st;ut=1;var t=Function.prototype.toString;return st=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function Be(){if(ft)return ct;ft=1;var t=$e(),e=Oe(),r=Ce(),n=Ee(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,a=Object.prototype,s=i.toString,u=a.hasOwnProperty,c=RegExp("^"+s.call(u).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return ct=function(i){return!(!r(i)||e(i))&&(t(i)?c:o).test(n(i))}}function Te(){if(lt)return ht;return lt=1,ht=function(t,e){return null==t?void 0:t[e]}}function Se(){if(pt)return gt;pt=1;var t=Be(),e=Te();return gt=function(r,n){var o=e(r,n);return t(o)?o:void 0}}function Ae(){if(vt)return mt;vt=1;var t=Se()(_e(),"Map");return mt=t}function Le(){if(bt)return dt;bt=1;var t=Se()(Object,"create");return dt=t}function We(){if(wt)return yt;wt=1;var t=Le();return yt=function(){this.__data__=t?t(null):{},this.size=0}}function Ue(){if(_t)return kt;return _t=1,kt=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}}function Me(){if(xt)return Rt;xt=1;var t=Le(),e=Object.prototype.hasOwnProperty;return Rt=function(r){var n=this.__data__;if(t){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return e.call(n,r)?n[r]:void 0}}function De(){if(jt)return Pt;jt=1;var t=Le(),e=Object.prototype.hasOwnProperty;return Pt=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}function He(){if($t)return Ct;$t=1;var t=Le();return Ct=function(e,r){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===r?"__lodash_hash_undefined__":r,this}}function Ge(){if(Ot)return Nt;Ot=1;var t=We(),e=Ue(),r=Me(),n=De(),o=He();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,Nt=i}function Fe(){if(Bt)return Et;Bt=1;var t=Ge(),e=ve(),r=Ae();return Et=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function Ie(){if(St)return Tt;return St=1,Tt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}}function ze(){if(Lt)return At;Lt=1;var t=Ie();return At=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function qe(){if(Ut)return Wt;Ut=1;var t=ze();return Wt=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}function Ve(){if(Dt)return Mt;Dt=1;var t=ze();return Mt=function(e){return t(this,e).get(e)}}function Je(){if(Gt)return Ht;Gt=1;var t=ze();return Ht=function(e){return t(this,e).has(e)}}function Ye(){if(It)return Ft;It=1;var t=ze();return Ft=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 Ke(){if(qt)return zt;qt=1;var t=Fe(),e=qe(),r=Ve(),n=Je(),o=Ye();function i(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}return i.prototype.clear=t,i.prototype.delete=e,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,zt=i}function Qe(){if(Jt)return Vt;Jt=1;var t=ve(),e=Ae(),r=Ke();return Vt=function(n,o){var i=this.__data__;if(i instanceof t){var a=i.__data__;if(!e||a.length<199)return a.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(a)}return i.set(n,o),this.size=i.size,this}}function Xe(){if(Kt)return Yt;Kt=1;var t=ve(),e=de(),r=be(),n=ye(),o=we(),i=Qe();function a(e){var r=this.__data__=new t(e);this.size=r.size}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=n,a.prototype.has=o,a.prototype.set=i,Yt=a}function Ze(){if(Xt)return Qt;Xt=1;var t=Se(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Qt=e}function tr(){if(te)return Zt;te=1;var t=Ze();return Zt=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function er(){if(re)return ee;re=1;var t=tr(),e=fe();return ee=function(r,n,o){(void 0!==o&&!e(r[n],o)||void 0===o&&!(n in r))&&t(r,n,o)}}function rr(){if(oe)return ne;return oe=1,ne=function(t){return function(e,r,n){for(var o=-1,i=Object(e),a=n(e),s=a.length;s--;){var u=a[t?s:++o];if(!1===r(i[u],u,i))break}return e}}}function nr(){if(ae)return ie;ae=1;var t=rr()();return ie=t}var or,ir,ar,sr,ur,cr,fr,hr,lr,gr,pr,mr,vr,dr,br,yr,wr,kr,_r,Rr,xr,Pr,jr,Cr,$r,Nr,Or,Er,Br,Tr,Sr,Ar,Lr,Wr={exports:{}};function Ur(){return or||(or=1,t=Wr,e=Wr.exports,r=_e(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n?r.Buffer:void 0,a=i?i.allocUnsafe:void 0,t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=a?a(r):new t.constructor(r);return t.copy(n),n}),Wr.exports;var t,e,r,n,o,i,a}function Mr(){if(ar)return ir;ar=1;var t=_e().Uint8Array;return ir=t}function Dr(){if(ur)return sr;ur=1;var t=Mr();return sr=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function Hr(){if(fr)return cr;fr=1;var t=Dr();return cr=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function Gr(){if(lr)return hr;return lr=1,hr=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}}function Fr(){if(pr)return gr;pr=1;var t=Ce(),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 gr=r}function Ir(){if(vr)return mr;return vr=1,mr=function(t,e){return function(r){return t(e(r))}}}function zr(){if(br)return dr;br=1;var t=Ir()(Object.getPrototypeOf,Object);return dr=t}function qr(){if(wr)return yr;wr=1;var t=Object.prototype;return yr=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function Vr(){if(_r)return kr;_r=1;var t=Fr(),e=zr(),r=qr();return kr=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function Jr(){if(xr)return Rr;return xr=1,Rr=function(t){return null!=t&&"object"==typeof t}}function Yr(){if(jr)return Pr;jr=1;var t=je(),e=Jr();return Pr=function(r){return e(r)&&"[object Arguments]"==t(r)}}function Kr(){if($r)return Cr;$r=1;var t=Yr(),e=Jr(),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 Cr=i}function Qr(){if(Or)return Nr;Or=1;var t=Array.isArray;return Nr=t}function Xr(){if(Br)return Er;Br=1;return Er=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Zr(){if(Sr)return Tr;Sr=1;var t=$e(),e=Xr();return Tr=function(r){return null!=r&&e(r.length)&&!t(r)}}function tn(){if(Lr)return Ar;Lr=1;var t=Zr(),e=Jr();return Ar=function(r){return e(r)&&t(r)}}var en,rn,nn,on,an,sn,un,cn,fn,hn={exports:{}};function ln(){if(rn)return en;return rn=1,en=function(){return!1}}function gn(){return nn||(nn=1,function(t,e){var r=_e(),n=ln(),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,a=i&&i.exports===o?r.Buffer:void 0,s=(a?a.isBuffer:void 0)||n;t.exports=s}(hn,hn.exports)),hn.exports}function pn(){if(an)return on;an=1;var t=je(),e=zr(),r=Jr(),n=Function.prototype,o=Object.prototype,i=n.toString,a=o.hasOwnProperty,s=i.call(Object);return on=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var o=e(n);if(null===o)return!0;var u=a.call(o,"constructor")&&o.constructor;return"function"==typeof u&&u instanceof u&&i.call(u)==s}}function mn(){if(un)return sn;un=1;var t=je(),e=Xr(),r=Jr(),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,sn=function(o){return r(o)&&e(o.length)&&!!n[t(o)]}}function vn(){if(fn)return cn;return fn=1,cn=function(t){return function(e){return t(e)}}}var dn,bn,yn,wn,kn,_n,Rn,xn,Pn,jn,Cn,$n,Nn,On,En,Bn,Tn,Sn,An,Ln,Wn,Un,Mn,Dn,Hn,Gn,Fn,In,zn,qn,Vn,Jn,Yn,Kn,Qn,Xn,Zn,to,eo,ro,no,oo,io,ao,so,uo,co,fo,ho,lo={exports:{}};function go(){return dn||(dn=1,t=lo,e=lo.exports,r=ke(),n=e&&!e.nodeType&&e,o=n&&t&&!t.nodeType&&t,i=o&&o.exports===n&&r.process,a=function(){try{var t=o&&o.require&&o.require("util").types;return t||i&&i.binding&&i.binding("util")}catch(t){}}(),t.exports=a),lo.exports;var t,e,r,n,o,i,a}function po(){if(yn)return bn;yn=1;var t=mn(),e=vn(),r=go(),n=r&&r.isTypedArray,o=n?e(n):t;return bn=o}function mo(){if(kn)return wn;return kn=1,wn=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function vo(){if(Rn)return _n;Rn=1;var t=tr(),e=fe(),r=Object.prototype.hasOwnProperty;return _n=function(n,o,i){var a=n[o];r.call(n,o)&&e(a,i)&&(void 0!==i||o in n)||t(n,o,i)}}function bo(){if(Pn)return xn;Pn=1;var t=vo(),e=tr();return xn=function(r,n,o,i){var a=!o;o||(o={});for(var s=-1,u=n.length;++s<u;){var c=n[s],f=i?i(o[c],r[c],c,o,r):void 0;void 0===f&&(f=r[c]),a?e(o,c,f):t(o,c,f)}return o}}function yo(){if(Cn)return jn;return Cn=1,jn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}}function wo(){if(Nn)return $n;Nn=1;var t=/^(?:0|[1-9]\d*)$/;return $n=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 ko(){if(En)return On;En=1;var t=yo(),e=Kr(),r=Qr(),n=gn(),o=wo(),i=po(),a=Object.prototype.hasOwnProperty;return On=function(s,u){var c=r(s),f=!c&&e(s),h=!c&&!f&&n(s),l=!c&&!f&&!h&&i(s),g=c||f||h||l,p=g?t(s.length,String):[],m=p.length;for(var v in s)!u&&!a.call(s,v)||g&&("length"==v||h&&("offset"==v||"parent"==v)||l&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||o(v,m))||p.push(v);return p}}function _o(){if(Tn)return Bn;return Tn=1,Bn=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}}function Ro(){if(An)return Sn;An=1;var t=Ce(),e=qr(),r=_o(),n=Object.prototype.hasOwnProperty;return Sn=function(o){if(!t(o))return r(o);var i=e(o),a=[];for(var s in o)("constructor"!=s||!i&&n.call(o,s))&&a.push(s);return a}}function xo(){if(Wn)return Ln;Wn=1;var t=ko(),e=Ro(),r=Zr();return Ln=function(n){return r(n)?t(n,!0):e(n)}}function Po(){if(Mn)return Un;Mn=1;var t=bo(),e=xo();return Un=function(r){return t(r,e(r))}}function jo(){if(Hn)return Dn;Hn=1;var t=er(),e=Ur(),r=Hr(),n=Gr(),o=Vr(),i=Kr(),a=Qr(),s=tn(),u=gn(),c=$e(),f=Ce(),h=pn(),l=po(),g=mo(),p=Po();return Dn=function(m,v,d,b,y,w,k){var _=g(m,d),R=g(v,d),x=k.get(R);if(x)t(m,d,x);else{var P=w?w(_,R,d+"",m,v,k):void 0,j=void 0===P;if(j){var C=a(R),$=!C&&u(R),N=!C&&!$&&l(R);P=R,C||$||N?a(_)?P=_:s(_)?P=n(_):$?(j=!1,P=e(R,!0)):N?(j=!1,P=r(R,!0)):P=[]:h(R)||i(R)?(P=_,i(_)?P=p(_):f(_)&&!c(_)||(P=o(R))):j=!1}j&&(k.set(R,P),y(P,R,b,w,k),k.delete(R)),t(m,d,P)}}}function Co(){if(Fn)return Gn;Fn=1;var t=Xe(),e=er(),r=nr(),n=jo(),o=Ce(),i=xo(),a=mo();return Gn=function s(u,c,f,h,l){u!==c&&r(c,(function(r,i){if(l||(l=new t),o(r))n(u,c,i,f,s,h,l);else{var g=h?h(a(u,i),r,i+"",u,c,l):void 0;void 0===g&&(g=r),e(u,i,g)}}),i)},Gn}function $o(){if(zn)return In;return zn=1,In=function(t){return t}}function No(){if(Vn)return qn;return Vn=1,qn=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 Oo(){if(Yn)return Jn;Yn=1;var t=No(),e=Math.max;return Jn=function(r,n,o){return n=e(void 0===n?r.length-1:n,0),function(){for(var i=arguments,a=-1,s=e(i.length-n,0),u=Array(s);++a<s;)u[a]=i[n+a];a=-1;for(var c=Array(n+1);++a<n;)c[a]=i[a];return c[n]=o(u),t(r,this,c)}},Jn}function Eo(){if(Qn)return Kn;return Qn=1,Kn=function(t){return function(){return t}}}function Bo(){if(Zn)return Xn;Zn=1;var t=Eo(),e=Ze();return Xn=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:$o()}function To(){if(eo)return to;eo=1;var t=Date.now;return to=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)}},to}function So(){if(no)return ro;no=1;var t=Bo(),e=To()(t);return ro=e}function Ao(){if(io)return oo;io=1;var t=$o(),e=Oo(),r=So();return oo=function(n,o){return r(e(n,o,t),n+"")}}function Lo(){if(so)return ao;so=1;var t=fe(),e=Zr(),r=wo(),n=Ce();return ao=function(o,i,a){if(!n(a))return!1;var s=typeof i;return!!("number"==s?e(a)&&r(i,a.length):"string"==s&&i in a)&&t(a[i],o)}}function Wo(){if(co)return uo;co=1;var t=Ao(),e=Lo();return uo=function(r){return t((function(t,n){var o=-1,i=n.length,a=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(a=r.length>3&&"function"==typeof a?(i--,a):void 0,s&&e(n[0],n[1],s)&&(a=i<3?void 0:a,i=1),t=Object(t);++o<i;){var u=n[o];u&&r(t,u,o,a)}return t}))}}function Uo(){if(ho)return fo;ho=1;var t=Co(),e=Wo()((function(e,r,n){t(e,r,n)}));return fo=e}var Mo,Do,Ho,Go,Fo,Io,zo,qo,Vo,Jo,Yo,Ko,Qo,Xo,Zo,ti,ei,ri,ni,oi,ii,ai,si,ui,ci=ue(Uo());function fi(){if(Do)return Mo;Do=1;var t=je(),e=Jr();return Mo=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function hi(){if(Go)return Ho;Go=1;var t=Qr(),e=fi(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Ho=function(o,i){if(t(o))return!1;var a=typeof o;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=o&&!e(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function li(){if(Io)return Fo;Io=1;var t=Ke();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var t=arguments,e=n?n.apply(this,t):t[0],i=o.cache;if(i.has(e))return i.get(e);var a=r.apply(this,t);return o.cache=i.set(e,a)||i,a};return o.cache=new(e.Cache||t),o}return e.Cache=t,Fo=e}function gi(){if(qo)return zo;qo=1;var t=li();return zo=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function pi(){if(Jo)return Vo;Jo=1;var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,e=/\\(\\)?/g,r=gi()((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 Vo=r}function mi(){if(Ko)return Yo;return Ko=1,Yo=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 vi(){if(Xo)return Qo;Xo=1;var t=Re(),e=mi(),r=Qr(),n=fi(),o=t?t.prototype:void 0,i=o?o.toString:void 0;return Qo=function t(o){if("string"==typeof o)return o;if(r(o))return e(o,t)+"";if(n(o))return i?i.call(o):"";var a=o+"";return"0"==a&&1/o==-1/0?"-0":a},Qo}function di(){if(ti)return Zo;ti=1;var t=vi();return Zo=function(e){return null==e?"":t(e)}}function bi(){if(ri)return ei;ri=1;var t=Qr(),e=hi(),r=pi(),n=di();return ei=function(o,i){return t(o)?o:e(o,i)?[o]:r(n(o))}}function yi(){if(oi)return ni;oi=1;var t=fi();return ni=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function wi(){if(ai)return ii;ai=1;var t=bi(),e=yi();return ii=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 ki(){if(ui)return si;ui=1;var t=wi();return si=function(e,r,n){var o=null==e?void 0:t(e,r);return void 0===o?n:o}}var _i=ue(ki());const Ri="package.json",xi=[".env.local",".env"];class Pi extends t{_env;shared;constructor(t){super(t),this._env=e.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder||xi}),this.shared=Object.assign({},this.feConfig.release,this.getDefaultShreadOptions(t.shared))}getDefaultShreadOptions(t){return{rootPath:process.cwd(),sourceBranch:this._env.get("FE_RELEASE_BRANCH")||this._env.get("FE_RELEASE_SOURCE_BRANCH")||"master",releaseEnv:this._env.get("FE_RELEASE_ENV")||this._env.get("NODE_ENV")||"development",...t}}get rootPath(){return this.shared.rootPath}get sourceBranch(){return this.shared.sourceBranch}get releaseEnv(){return this.shared.releaseEnv}get env(){return this._env}get workspaces(){return this.getConfig("workspaces.workspaces")}get workspace(){return this.getConfig("workspaces.workspace")}setWorkspaces(t){this.options.workspaces={...this.options.workspaces,workspaces:t}}setConfig(t){this.options=ci(this.options,t)}getConfig(t,e){return _i(this.options,t,e)}setShared(t){this.shared=ci(this.shared,t)}getPkg(t,e){const r=this.workspace?.packageJson;if(!r)throw new Error("package.json is not found");return t?_i(r,t,e):r}getTemplateContext(){return{...this.shared,...this.workspace,publishPath:this.workspace?.path||"",env:this.releaseEnv,branch:this.sourceBranch}}async runChangesetsCli(t,e){let r="pnpm";try{await this.shell.exec("pnpm -v",{dryRun:!1})}catch{r="npx"}return await this.shell.exec([r,"changeset",t,...e??[]])}}function ji(t,...e){return[t,...e]}const Ci={maxWorkspace:3,multiWorkspaceSeparator:"_",workspaceVersionSeparator:"@",batchBranchName:"batch-${releaseName}-${length}-packages-${timestamp}",batchTagName:"batch-${length}-packages-${timestamp}"};class $i{shell;logger;config;constructor(t,e,r={}){this.shell=t,this.logger=e,this.config={...Ci,...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.debug("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.debug("Release Batch Branch template is:",o),this.shell.format(o,{pkgName:t,releaseName:t,tagName:e,...r,length:n,timestamp:Date.now()})}getReleaseName(t){if(1===t.length)return t[0].name;const{maxWorkspace:e,multiWorkspaceSeparator:r,workspaceVersionSeparator:n}=this.config;return t.slice(0,e).map((({name:t,version:e})=>`${t}${n}${e}`)).join(r)}getReleaseTagName(t){if(1===t.length)return t[0].version;const{batchTagName:e}=this.config;return this.shell.format(e,{length:t.length,timestamp:Date.now()})}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))).join("\n"):t[0].changelog,{workspaceVersionSeparator:i}=this.config,a=1===t.length?e.tagName:t.map((t=>`${t.name}${i}${t.version}`)).join(" ");return this.shell.format(n,{...r,tagName:a,changelog:o})}}class Ni{context;_octokit=null;constructor(t){this.context=t}getGitHubUserInfo(){const{authorName:t,repoName:e}=this.context.shared;if(!t||!e)throw new Error("Author name or repo name is not set");return{owner:t,repo:e}}getToken(){const{tokenRef:t="GITHUB_TOKEN"}=this.context.getConfig("githubPR"),e=this.context.env.get(t);if(!e)throw new Error(`Token is not set. Please set ${t} environment variable.`);return e}get octokit(){if(this._octokit)return this._octokit;const{timeout:t}=this.context.getConfig("githubPR"),e={auth:this.getToken(),request:{timeout:t}};return this._octokit=new n(e),this._octokit}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.shared.autoMergeType||"squash"}get dryRunPRNumber(){return this.context.getConfig("githubPR.dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.shared.autoMergeReleasePR||false}async mergePR(t,e){if(!t)return void this.logger.error("Failed to create Pull Request.",t);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.context.shared;this.logger.info(`[DRY RUN] Would merge PR #${t} with method '${r}' in repo ${o}/${n}, branch ${e}`)}else await this.octokit.rest.pulls.merge({...this.getGitHubUserInfo(),pull_number:Number(t),merge_method:r})}async getPullRequestCommits(t){return(await this.octokit.rest.pulls.listCommits({...this.getGitHubUserInfo(),pull_number:t})).data}async getPullRequest(t){return(await this.octokit.rest.pulls.get({...this.getGitHubUserInfo(),pull_number:t})).data}async checkedPR(t,e){try{await this.getPullRequest(Number(t)),await this.octokit.rest.git.deleteRef({...this.getGitHubUserInfo(),ref:`heads/${e}`}),this.logger.info(`Branch ${e} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${t} or branch ${e} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const t=this.context.shared.label;if(!(t&&t.name&&t.description&&t.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",t),t;try{const e=await this.octokit.rest.issues.createLabel({...this.getGitHubUserInfo(),name:t.name,description:t.description,color:t.color.replace("#","")});return this.logger.debug("Create PR label Success",e),t}catch(e){if(422===e.status)return this.logger.warn(`Label ${t.name} already exists, skipping!`),t;throw this.logger.error("Create PR label Failed",e),e}}async createReleasePR(t){if(this.context.getConfig("githubPR.dryRunCreatePR")||this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...t,labels:t.labels}),this.dryRunPRNumber;try{const e=await this.octokit.rest.pulls.create({...this.getGitHubUserInfo(),...t}),r=e.data.number;if(!r)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",[e?.url]),t.labels&&t.labels.length){const e=await this.octokit.rest.issues.addLabels({...this.getGitHubUserInfo(),issue_number:r,labels:t.labels});this.logger.debug("Add PR label Success",[e.url])}return r.toString()}catch(t){if(422===t.status&&t.message.includes("already exists")){this.logger.warn("PR already exists");const e=t.message.match(/pull request #(\d+)/);return e?e[1]:""}throw this.logger.error("Failed to create PR",t),t}}truncateBody(t){return t&&t.length>=124e3?t.substring(0,124e3)+"...":t}getOctokitReleaseOptions(t){const{releaseName:e,draft:r=!1,preRelease:n=!1,autoGenerate:o=!1,makeLatest:i=!0,releaseNotes:a,discussionCategoryName:s}=this.context.getConfig("githubPR"),u=e,c=o?"":this.truncateBody(String(a));return{name:u,make_latest:i.toString(),body:c,draft:r,prerelease:n,generate_release_notes:o,discussion_category_name:s,tag_name:"",...t,...this.getGitHubUserInfo()}}async createRelease(t){const e=this.getOctokitReleaseOptions({tag_name:t.tagName,body:t.changelog});if(e.name=this.shell.format(e.name,t),this.logger.log(`[DRY RUN] octokit repos.createRelease "${e.name}" (${e.tag_name})`,{isDryRun:this.context.dryRun}),!e.tag_name)throw new Error("TagName is undefined");if(!this.context.dryRun)try{const t=await this.octokit.repos.createRelease(e);this.logger.debug(`[DONE] octokit repos.createRelease "${e.name}" (${e.tag_name}) (${t.headers.location})`)}catch(t){this.logger.error(`[FAILED] octokit repos.createRelease "${e.name}" (${e.tag_name})`,t)}}}var Oi,Ei;function Bi(){if(Ei)return Oi;Ei=1;var t=je(),e=Qr(),r=Jr();return Oi=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}var Ti=ue(Bi());class Si{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],r=_i(this.context.shared,this.pluginName);return e||t?ci({},r,t,e):{}}get logger(){return this.context.logger}get shell(){return this.context.shell}get options(){return this.context.getConfig(this.pluginName,{})}getEnv(t,e){return this.context.env.get(t)??e}enabled(t,e){return!0}getConfig(t,e){return t?this.context.getConfig([this.pluginName,...Array.isArray(t)?t:[t]],e):this.context.getConfig(this.pluginName,e)}setConfig(t){this.context.setConfig({[this.pluginName]:t})}onBefore(t){}onExec(t){}onSuccess(t){}onError(t){}async step({label:t,task:e}){this.logger.log(),this.logger.info(t),this.logger.log();try{const r=await e();return this.logger.info(`${t} - success`),r}catch(t){throw this.logger.error(t),t}}}class Ai extends Si{async onBefore(){const t=await this.getUserInfo();if(!t)throw new Error("Failed to get repoInfo");let e=this.context.shared.currentBranch;e||(e=await this.getCurrentBranch()),e&&await this.context.shell.exec(`git checkout ${e}`,{dryRun:!1}),this.context.setShared({repoName:t.repoName,authorName:t.authorName,currentBranch:e})}async getCurrentBranch(){return await new Promise((t=>setTimeout(t,100))),this.context.shell.exec("git rev-parse --abbrev-ref HEAD",{dryRun:!1})}async getRemoteUrl(){return(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}async getUserInfo(){let t;try{t=await this.getRemoteUrl()}catch{throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!t)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.debug("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&&Ti(t)}commit(t,e=[]){return this.context.shell.exec(["git","commit","--message",JSON.stringify(t),...e])}}const Li=["hash","abbrevHash","treeHash","abbrevTreeHash","parentHashes","abbrevParentHashes","authorName","authorEmail","authorDate","authorDateRel","committerName","committerEmail","committerDate","committerDateRel","subject","body","rawBody","tag"];class Wi{options;constructor(t){this.options=t}async getGitLog(t={}){const{directory:e,noMerges:r=!0,fileds:n}=t,i=await this.resolveTag(t.from,"root"),a=await this.resolveTag(t.to,"HEAD"),s=i===a?a:`${i}..${a}`;return await o({repo:".",number:1e3,fields:n,branch:s,file:e,nameStatus:!1,includeMergeCommitFiles:!r})}async getCommits(t){return(await this.getGitLog(t)).map((t=>{const{subject:e,rawBody:r}=t;return{base:t,commitlint:this.parseCommitlint(e||"",r),commits:[]}}))}createBaseCommit(t,e){return{subject:t,rawBody:t,body:t,...e}}parseCommitlint(t,e=""){const[r]=t.trim().split("\n"),n=e.startsWith(r)?e.replace(r,""):e,o=r.replace(/\s*\(#\d+\)\s*$/,"").match(/^(?:([a-z]+)(?:\((.*?)\))?: )?(.+)$/i);return o?{type:o[1]?.toLowerCase(),scope:o[2]?.trim(),message:o[3].trim(),body:n||void 0}:{message:r,body:n||void 0}}toCommitValue(t,e){const[r]=e.trim().split("\n"),n=r.match(/\(#(\d+)\)/),o=this.parseCommitlint(r,e);return{base:this.createBaseCommit(r,{hash:t,abbrevHash:t.substring(0,7),rawBody:e}),commitlint:o,commits:[],prNumber:n?.[1]}}async resolveTag(t,e){if(t)try{if(await this.options.shell.exec(`git tag --list "${t}"`,{dryRun:!1}).then((t=>!!t.trim())))return t}catch{}return"root"===e?this.options.shell.exec("git rev-list --max-parents=0 HEAD",{dryRun:!1}).then((t=>t.trim())):"HEAD"}}var Ui,Mi,Di,Hi,Gi,Fi,Ii,zi,qi,Vi,Ji,Yi,Ki,Qi,Xi,Zi,ta,ea,ra,na,oa,ia,aa,sa,ua,ca,fa,ha,la,ga,pa,ma,va,da,ba,ya,wa,ka,_a,Ra,xa,Pa,ja,Ca,$a,Na,Oa,Ea,Ba,Ta,Sa,Aa,La,Wa,Ua,Ma,Da,Ha,Ga,Fa,Ia,za,qa,Va,Ja,Ya,Ka,Qa,Xa,Za,ts,es,rs,ns,os,is,as,ss,us,cs,fs,hs,ls,gs,ps,ms,vs,ds,bs,ys,ws,ks;function _s(){if(Mi)return Ui;return Mi=1,Ui=function(t,e,r,n){for(var o=-1,i=null==t?0:t.length;++o<i;){var a=t[o];e(n,a,r(a),t)}return n}}function Rs(){if(Hi)return Di;Hi=1;var t=Ir()(Object.keys,Object);return Di=t}function xs(){if(Fi)return Gi;Fi=1;var t=qr(),e=Rs(),r=Object.prototype.hasOwnProperty;return Gi=function(n){if(!t(n))return e(n);var o=[];for(var i in Object(n))r.call(n,i)&&"constructor"!=i&&o.push(i);return o}}function Ps(){if(zi)return Ii;zi=1;var t=ko(),e=xs(),r=Zr();return Ii=function(n){return r(n)?t(n):e(n)}}function js(){if(Vi)return qi;Vi=1;var t=nr(),e=Ps();return qi=function(r,n){return r&&t(r,n,e)}}function Cs(){if(Yi)return Ji;Yi=1;var t=Zr();return Ji=function(e,r){return function(n,o){if(null==n)return n;if(!t(n))return e(n,o);for(var i=n.length,a=r?i:-1,s=Object(n);(r?a--:++a<i)&&!1!==o(s[a],a,s););return n}}}function $s(){if(Qi)return Ki;Qi=1;var t=js(),e=Cs()(t);return Ki=e}function Ns(){if(Zi)return Xi;Zi=1;var t=$s();return Xi=function(e,r,n,o){return t(e,(function(t,e,i){r(o,t,n(t),i)})),o}}function Os(){if(ea)return ta;ea=1;return ta=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}}function Es(){if(na)return ra;return na=1,ra=function(t){return this.__data__.has(t)}}function Bs(){if(ia)return oa;ia=1;var t=Ke(),e=Os(),r=Es();function n(e){var r=-1,n=null==e?0:e.length;for(this.__data__=new t;++r<n;)this.add(e[r])}return n.prototype.add=n.prototype.push=e,n.prototype.has=r,oa=n}function Ts(){if(sa)return aa;return sa=1,aa=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}}function Ss(){if(ca)return ua;return ca=1,ua=function(t,e){return t.has(e)}}function As(){if(ha)return fa;ha=1;var t=Bs(),e=Ts(),r=Ss();return fa=function(n,o,i,a,s,u){var c=1&i,f=n.length,h=o.length;if(f!=h&&!(c&&h>f))return!1;var l=u.get(n),g=u.get(o);if(l&&g)return l==o&&g==n;var p=-1,m=!0,v=2&i?new t:void 0;for(u.set(n,o),u.set(o,n);++p<f;){var d=n[p],b=o[p];if(a)var y=c?a(b,d,p,o,n,u):a(d,b,p,n,o,u);if(void 0!==y){if(y)continue;m=!1;break}if(v){if(!e(o,(function(t,e){if(!r(v,e)&&(d===t||s(d,t,i,a,u)))return v.push(e)}))){m=!1;break}}else if(d!==b&&!s(d,b,i,a,u)){m=!1;break}}return u.delete(n),u.delete(o),m}}function Ls(){if(ga)return la;return ga=1,la=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}}function Ws(){if(ma)return pa;return ma=1,pa=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r},pa}function Us(){if(da)return va;da=1;var t=Re(),e=Mr(),r=fe(),n=As(),o=Ls(),i=Ws(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return va=function(t,a,u,c,f,h,l){switch(u){case"[object DataView]":if(t.byteLength!=a.byteLength||t.byteOffset!=a.byteOffset)return!1;t=t.buffer,a=a.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=a.byteLength||!h(new e(t),new e(a)));case"[object Boolean]":case"[object Date]":case"[object Number]":return r(+t,+a);case"[object Error]":return t.name==a.name&&t.message==a.message;case"[object RegExp]":case"[object String]":return t==a+"";case"[object Map]":var g=o;case"[object Set]":var p=1&c;if(g||(g=i),t.size!=a.size&&!p)return!1;var m=l.get(t);if(m)return m==a;c|=2,l.set(t,a);var v=n(g(t),g(a),c,f,h,l);return l.delete(t),v;case"[object Symbol]":if(s)return s.call(t)==s.call(a)}return!1}}function Ms(){if(ya)return ba;return ya=1,ba=function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}}function Ds(){if(ka)return wa;ka=1;var t=Ms(),e=Qr();return wa=function(r,n,o){var i=n(r);return e(r)?i:t(i,o(r))}}function Hs(){if(Ra)return _a;return Ra=1,_a=function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var a=t[r];e(a,r,t)&&(i[o++]=a)}return i}}function Gs(){if(Pa)return xa;return Pa=1,xa=function(){return[]}}function Fs(){if(Ca)return ja;Ca=1;var t=Hs(),e=Gs(),r=Object.prototype.propertyIsEnumerable,n=Object.getOwnPropertySymbols;return ja=n?function(e){return null==e?[]:(e=Object(e),t(n(e),(function(t){return r.call(e,t)})))}:e}function Is(){if(Na)return $a;Na=1;var t=Ds(),e=Fs(),r=Ps();return $a=function(n){return t(n,r,e)}}function zs(){if(Ea)return Oa;Ea=1;var t=Is(),e=Object.prototype.hasOwnProperty;return Oa=function(r,n,o,i,a,s){var u=1&o,c=t(r),f=c.length;if(f!=t(n).length&&!u)return!1;for(var h=f;h--;){var l=c[h];if(!(u?l in n:e.call(n,l)))return!1}var g=s.get(r),p=s.get(n);if(g&&p)return g==n&&p==r;var m=!0;s.set(r,n),s.set(n,r);for(var v=u;++h<f;){var d=r[l=c[h]],b=n[l];if(i)var y=u?i(b,d,l,n,r,s):i(d,b,l,r,n,s);if(!(void 0===y?d===b||a(d,b,o,i,s):y)){m=!1;break}v||(v="constructor"==l)}if(m&&!v){var w=r.constructor,k=n.constructor;w==k||!("constructor"in r)||!("constructor"in n)||"function"==typeof w&&w instanceof w&&"function"==typeof k&&k instanceof k||(m=!1)}return s.delete(r),s.delete(n),m}}function qs(){if(Ta)return Ba;Ta=1;var t=Se()(_e(),"DataView");return Ba=t}function Vs(){if(Aa)return Sa;Aa=1;var t=Se()(_e(),"Promise");return Sa=t}function Js(){if(Wa)return La;Wa=1;var t=Se()(_e(),"Set");return La=t}function Ys(){if(Ma)return Ua;Ma=1;var t=Se()(_e(),"WeakMap");return Ua=t}function Ks(){if(Ha)return Da;Ha=1;var t=qs(),e=Ae(),r=Vs(),n=Js(),o=Ys(),i=je(),a=Ee(),s="[object Map]",u="[object Promise]",c="[object Set]",f="[object WeakMap]",h="[object DataView]",l=a(t),g=a(e),p=a(r),m=a(n),v=a(o),d=i;return(t&&d(new t(new ArrayBuffer(1)))!=h||e&&d(new e)!=s||r&&d(r.resolve())!=u||n&&d(new n)!=c||o&&d(new o)!=f)&&(d=function(t){var e=i(t),r="[object Object]"==e?t.constructor:void 0,n=r?a(r):"";if(n)switch(n){case l:return h;case g:return s;case p:return u;case m:return c;case v:return f}return e}),Da=d}function Qs(){if(Fa)return Ga;Fa=1;var t=Xe(),e=As(),r=Us(),n=zs(),o=Ks(),i=Qr(),a=gn(),s=po(),u="[object Arguments]",c="[object Array]",f="[object Object]",h=Object.prototype.hasOwnProperty;return Ga=function(l,g,p,m,v,d){var b=i(l),y=i(g),w=b?c:o(l),k=y?c:o(g),_=(w=w==u?f:w)==f,R=(k=k==u?f:k)==f,x=w==k;if(x&&a(l)){if(!a(g))return!1;b=!0,_=!1}if(x&&!_)return d||(d=new t),b||s(l)?e(l,g,p,m,v,d):r(l,g,w,p,m,v,d);if(!(1&p)){var P=_&&h.call(l,"__wrapped__"),j=R&&h.call(g,"__wrapped__");if(P||j){var C=P?l.value():l,$=j?g.value():g;return d||(d=new t),v(C,$,p,m,d)}}return!!x&&(d||(d=new t),n(l,g,p,m,v,d))}}function Xs(){if(za)return Ia;za=1;var t=Qs(),e=Jr();return Ia=function r(n,o,i,a,s){return n===o||(null==n||null==o||!e(n)&&!e(o)?n!=n&&o!=o:t(n,o,i,a,r,s))},Ia}function Zs(){if(Va)return qa;Va=1;var t=Xe(),e=Xs();return qa=function(r,n,o,i){var a=o.length,s=a,u=!i;if(null==r)return!s;for(r=Object(r);a--;){var c=o[a];if(u&&c[2]?c[1]!==r[c[0]]:!(c[0]in r))return!1}for(;++a<s;){var f=(c=o[a])[0],h=r[f],l=c[1];if(u&&c[2]){if(void 0===h&&!(f in r))return!1}else{var g=new t;if(i)var p=i(h,l,f,r,n,g);if(!(void 0===p?e(l,h,3,i,g):p))return!1}}return!0}}function tu(){if(Ya)return Ja;Ya=1;var t=Ce();return Ja=function(e){return e==e&&!t(e)}}function eu(){if(Qa)return Ka;Qa=1;var t=tu(),e=Ps();return Ka=function(r){for(var n=e(r),o=n.length;o--;){var i=n[o],a=r[i];n[o]=[i,a,t(a)]}return n}}function ru(){if(Za)return Xa;return Za=1,Xa=function(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}}function nu(){if(es)return ts;es=1;var t=Zs(),e=eu(),r=ru();return ts=function(n){var o=e(n);return 1==o.length&&o[0][2]?r(o[0][0],o[0][1]):function(e){return e===n||t(e,n,o)}}}function ou(){if(ns)return rs;return ns=1,rs=function(t,e){return null!=t&&e in Object(t)}}function iu(){if(is)return os;is=1;var t=bi(),e=Kr(),r=Qr(),n=wo(),o=Xr(),i=yi();return os=function(a,s,u){for(var c=-1,f=(s=t(s,a)).length,h=!1;++c<f;){var l=i(s[c]);if(!(h=null!=a&&u(a,l)))break;a=a[l]}return h||++c!=f?h:!!(f=null==a?0:a.length)&&o(f)&&n(l,f)&&(r(a)||e(a))}}function au(){if(ss)return as;ss=1;var t=ou(),e=iu();return as=function(r,n){return null!=r&&e(r,n,t)}}function su(){if(cs)return us;cs=1;var t=Xs(),e=ki(),r=au(),n=hi(),o=tu(),i=ru(),a=yi();return us=function(s,u){return n(s)&&o(u)?i(a(s),u):function(n){var o=e(n,s);return void 0===o&&o===u?r(n,s):t(u,o,3)}}}function uu(){if(hs)return fs;return hs=1,fs=function(t){return function(e){return null==e?void 0:e[t]}}}function cu(){if(gs)return ls;gs=1;var t=wi();return ls=function(e){return function(r){return t(r,e)}}}function fu(){if(ms)return ps;ms=1;var t=uu(),e=cu(),r=hi(),n=yi();return ps=function(o){return r(o)?t(n(o)):e(o)}}function hu(){if(ds)return vs;ds=1;var t=nu(),e=su(),r=$o(),n=Qr(),o=fu();return vs=function(i){return"function"==typeof i?i:null==i?r:"object"==typeof i?n(i)?e(i[0],i[1]):t(i):o(i)}}function lu(){if(ys)return bs;ys=1;var t=_s(),e=Ns(),r=hu(),n=Qr();return bs=function(o,i){return function(a,s){var u=n(a)?t:e,c=i?i():{};return u(a,o,r(s,2),c)}}}function gu(){if(ks)return ws;ks=1;var t=tr(),e=lu(),r=Object.prototype.hasOwnProperty,n=e((function(e,n,o){r.call(e,o)?e[o].push(n):t(e,o,[n])}));return ws=n}var pu=ue(gu());const mu="\n- ${scopeHeader} ${commitlint.message} ${commitLink} ${prLink}";class vu{options;constructor(t){this.options=t}format(t,e){const{types:r=[],commitBody:n=!1}={...this.options,...e},o=[],i=pu(t,(t=>t.commitlint.type?t.commitlint.type:t.commitlint.message));return r.forEach((t=>{const{type:r,section:a,hidden:s}=t;if(s)return;const u=i[r]||[];u.length>0&&(o.push(a||""),u.forEach((t=>{if(o.push(this.formatCommit(t,e)),n&&t.commitlint.body){const e=t.commitlint.body.split("\n").map((t=>` ${t}`));o.push(...e)}})))})),o}formatCommit(t,e){const{commitlint:r,base:{hash:n},prNumber:o}=t,{repoUrl:i,formatTemplate:a=mu}={...this.options,...e},s=r.scope?this.formatScope(r.scope):"",u=o?this.foramtLink("#"+o,i?`${i}/pull/${o}`:""):"",c=n?this.foramtLink(n.slice(0,7),i?`${i}/commit/${n}`:""):"";return this.options.shell.format(a,{...t,scopeHeader:s,commitLink:c,prLink:u})}foramtLink(t,e){return e?`([${t}](${e}))`:`(${t})`}formatCommitLink(t,e){return e?`([${t}](${e}))`:`(${t})`}formatScope(t){return`**${t}:**`}}const du="https://github.com";class bu extends Wi{options;githubManager;constructor(t,e){super(t),this.options=t,this.githubManager=e}async getFullCommit(t){const e={...this.options,...t},r=await this.getCommits(e);return(await Promise.all(r.map((async t=>{let{prNumber:e}=t;if(!e&&t.base.subject){const r=t.base.subject.match(/\(#(\d+)\)/);r&&(e=r[1],t.prNumber=e)}if(!e)return t;return(await this.githubManager.getPullRequestCommits(+e)).map((({sha:t,commit:{message:r}})=>Object.assign(this.toCommitValue(t,r),{prNumber:e})))})))).flat()}async transformWorkspace(t,e){const r=[du,e.shared.authorName,e.shared.repoName].join("/"),n={...e.getConfig("changelog"),githubRootPath:r,mergePRcommit:!0,shell:e.shell},o=new bu(n,this.githubManager),i=new vu(n);return await Promise.all(t.map((async t=>{const e=await o.getFullCommit({from:t.lastTag??"",directory:t.path,fileds:Li});if("string"==typeof e)return{...t,changelog:e};const a=i.format(e,{...n,repoUrl:r});return{...t,changelog:a.join("\n")}})))}}class yu{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 wu{static readJson(t){const e=f(t,"utf-8");return JSON.parse(e)}static toWorkspace(t,e){let{root:r,packageJson:n}=t;const o=t.path;if(!o)throw new Error("path is not required!");return r=r||g(e,o),n=n||wu.readJson(g(r,Ri)),{name:n.name,version:n.version,path:o,root:r,packageJson:n}}}class ku extends Si{releaseTask=null;workspacesList=[];_skip=!1;releaseLabel;constructor(t){super(t,"workspaces"),this.releaseLabel=new yu({changePackagesLabel:this.context.shared.changePackagesLabel||"change:${name}",packagesDirectories:this.context.shared.packagesDirectories||[],compare:(t,e)=>i(t).startsWith(i(e))})}enabled(){return!this._skip&&!this.getConfig("skip")}async onBefore(){const t=this.getConfig("workspace");if(t)return this.logger.debug("Use the specified workspace",t),void this.setCurrentWorkspace(t,[]);const e=await this.getWorkspaces();if(this.getConfig("skipCheckPackage")||0===e.length)throw new Error("No changes to publish packages");const{publishPath:r}=this.context.shared;if(r){const t=e.find((t=>i(t.root)===i(r)));if(this.nextSkip(),!t)throw new Error(`No workspace found for: ${r}`);return this.logger.debug(`Workspace of ${r} find!`,a(t.root,Ri)),void this.setCurrentWorkspace(t,[t])}const[n,...o]=e;this.workspacesList=o,this.setCurrentWorkspace(n,e)}nextSkip(){this._skip=!0,this.logger.debug("skip next workspace")}setReleaseTask(t){this.releaseTask=t}setCurrentWorkspace(t,e){this.context.setShared({publishPath:t.path}),this.setConfig({workspace:t,workspaces:e})}async getGitWorkspaces(){const t=this.context.sourceBranch,e=await this.shell.exec(`git diff --name-only origin/${t}...HEAD`,{dryRun:!1});return"string"==typeof e?e.split("\n"):[]}async getChangedPackages(t,e){if(this.logger.debug("changeLabels",e),Array.isArray(e)&&e.length>0){const r=t.filter((t=>{const r=this.releaseLabel.toChangeLabel(t);return e.includes(r)}));return this.logger.debug("changed by labels",r),r}const r=await this.getGitWorkspaces();return this.logger.debug("changed by git",r),this.releaseLabel.pick(r,t)}getProjectWorkspaces(){const t=this.context.rootPath,e=this.context.shared.packagesDirectories;if(Array.isArray(e)&&e.length>0)return e.map((e=>wu.toWorkspace({path:e},t)));return(c(t)||[]).map((e=>({name:e.package.name,version:e.package.version,path:s(t,e.location),root:i(t,e.location),packageJson:e.package})))}async getWorkspaces(){const t=this.getProjectWorkspaces(),e=t.map((({path:t})=>t));this.logger.debug("packages",e);const r=this.getConfig("changeLabels"),n=await this.getChangedPackages(e,r);return this.setConfig({packages:e,changedPaths:n,projectWorkspaces:t}),this.logger.debug("changedPaths",n),t.filter((t=>n.includes(t.path)))}}function _u(t,...e){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t?new t(...e):t(...e)}function Ru(t){return t.startsWith(".")?u(t).name:t}async function xu(t){let e=null;try{e=(await import(t)).default}catch{try{e=(await import(a(process.cwd(),t))).default}catch{const r=p(process.cwd());e=(await import(m(r.resolve(t,{paths:[process.cwd()]})).href)).default}}return[Ru(t),e]}async function Pu(t,e,r=5){const n=v(r),o=e.map((([e,...r])=>n((()=>(async(e,...r)=>{if("string"==typeof e){const[,n]=await xu(e);return _u(n,t,...r)}return _u(e,t,...r)})(e,...r)))));return Promise.all(o)}const ju=[ji(ku),ji(class extends Si{constructor(t,e){super(t,"changelog",{increment:"patch",changesetRoot:".changeset",tagTemplate:"${name}@${version}",tagPrefix:"${name}",tagMatch:"${name}@*",...e})}get changesetRoot(){return g(this.context.rootPath,this.getConfig("changesetRoot"))}get changesetConfigPath(){return g(this.changesetRoot,"config.json")}enabled(){return!this.getConfig("skip")}async onBefore(){if(!h(this.changesetRoot))throw new Error(`Changeset directory ${this.changesetRoot} does not exist`);this.logger.debug(`${this.changesetRoot} exists`)}mergeWorkspaces(t){return t.map((t=>{const e=wu.toWorkspace({path:t.path},this.context.rootPath),r={...t,version:e.version};return r.tagName=this.generateTagName(r),r}))}async onExec(t){const e=await this.step({label:"Generate Changelogs",task:()=>Promise.all(this.context.workspaces.map((t=>this.generateChangelog(t))))});this.context.setWorkspaces(e)}async onSuccess(){const t=this.context.workspaces;this.getConfig("skipChangeset")?this.logger.debug("Skip generate changeset files"):(await this.step({label:"Changeset Version",task:()=>Promise.all(t.map((t=>this.generateChangesetFile(t))))}),await this.context.runChangesetsCli("version",["--no-changelog","--update-dependencies"]),this.getConfig("ignoreNonUpdatedPackages")&&await this.restoreIgnorePackages());const e=this.mergeWorkspaces(t);this.logger.debug("new workspaces",e),this.context.setWorkspaces(e)}async restoreIgnorePackages(){const{changedPaths:t=[],packages:e=[]}=this.context.getConfig("workspaces"),r=e.filter((e=>!t.includes(e))).map((t=>wu.toWorkspace({path:t},this.context.rootPath).path));this.logger.debug("noChangedPackages",r),await this.shell.exec(["git","restore",...r])}getTagPrefix(t){return this.shell.format(this.getConfig("tagPrefix"),t)}async generateChangelog(t){const e=await this.getTagName(t);this.logger.debug("tagName is:",e);const r={...this.getConfig(),from:e,directory:t.path,shell:this.shell,fileds:Li},n=new Wi(r),o=await n.getCommits(r),i=new vu(r).format(o);return{...t,lastTag:e,changelog:i.join("\n")}}generateTagName(t){try{const e=this.getConfig("tagTemplate");return this.shell.format(e,t)}catch(e){return console.error(`Error generating tag name for ${t.name}:`,e),`${t.name}-v0.0.0`}}async getTagName(t){try{const e=this.generateTagName(t),r=this.shell.format(this.getConfig("tagMatch"),t),n=await this.shell.exec(`git for-each-ref --sort=-creatordate --format "%(refname:short)|%(creatordate:iso8601)" "refs/tags/${r}"`,{dryRun:!1});if(!n)return e;const o=n.split("\n").filter(Boolean);if(0===o.length)return e;return o[0].split("|")[0]}catch(e){console.error(`Error getting tag for ${t.name}:`,e);return this.generateTagName(t)}}getIncrement(){const t=this.context.getConfig("workspaces.changeLabels");if(Array.isArray(t)&&t.length>0){if(t.includes("increment:major"))return"major";if(t.includes("increment:minor"))return"minor"}return this.getConfig("increment","patch")}async generateChangesetFile(t){const{name:e,version:r}=t,n=`${e}-${r}`.replace(/[\/\\]/g,"_"),o=g(this.changesetRoot,`${n}.md`),i=this.getIncrement();this.logger.debug("increment is:",[i]);const a=this.shell.format("---\n'${name}': '${increment}'\n---\n\n${changelog}",{...t,increment:i});if(this.context.dryRun)return this.logger.info(`Changeset [${o}] will be created, content is:`),void this.logger.log(a);h(o)?this.logger.info(`Changeset ${n} already exists`):l(o,a,"utf-8")}},{}),ji(class extends Ai{context;releaseParams;githubManager;constructor(t,e){super(t,"githubPR",{releaseName:"Release ${name} v${version}",...e}),this.context=t,this.githubManager=new Ni(this.context),this.releaseParams=new $i(t.shell,t.logger,{PRTitle:this.getConfig("PRTitle",this.context.shared.PRTitle),PRBody:this.getConfig("PRBody",this.context.shared.PRBody),...this.props})}enabled(t){return!this.getConfig("skip")}get isPublish(){return!this.getConfig("releasePR")}async isGithubRepository(){try{return(await this.getRemoteUrl()).includes("github.com")}catch{return!1}}async onBefore(){this.logger.debug("GithubPR onBefore");if(!await this.isGithubRepository())throw new Error("Current repository is not a GitHub repository. GitHub PR workflow is only available for GitHub repositories.");if(await super.onBefore(),this.isPublish){const t=this.getEnv("NPM_TOKEN");if(!t)throw new Error("NPM_TOKEN is not set");await this.shell.exec(`npm config set //registry.npmjs.org/:_authToken=${t}`)}}async onExec(){const t=this.context.workspaces,e=new bu(this.context.getConfig("changelog"),this.githubManager),r=await this.step({label:"GithubPR Changelogs",task:()=>e.transformWorkspace(t,this.context)});this.context.setWorkspaces(r),this.logger.debug("github changelog",this.context.workspaces)}async onSuccess(){this.isPublish?await this.publishPR(this.context.workspaces):await this.releasePR(this.context.workspaces)}async releasePR(t){await this.step({label:"Release Commit",task:()=>this.relesaeCommit(t)});const e=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(t)});await this.releasePullRequest(t,e)}async publishPR(t){this.getConfig("dryRunCreatePR")||(await this.context.runChangesetsCli("publish"),await this.shell.exec("git push origin --tags")),await this.step({label:"Release Github",task:()=>Promise.all(t.map((t=>(this.logger.debug(t),this.githubManager.createRelease(t)))))})}async relesaeCommit(t){const e=this.getConfig("commitArgs",[]);if(1===t.length)return await this.shell.exec("git add ."),void await this.commitWorkspace(t[0],e);await this.shell.exec("git add .");const r=`chore(tag): ${t.map((t=>`${t.name} v${t.version}`)).join(",")}`;await this.commit(r,e)}async releasePullRequest(t,e){const r=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(t,e)});if(this.githubManager.autoMergeReleasePR){const{releaseBranch:t}=e;return await this.step({label:`Merge Release PR(${r})`,task:()=>this.githubManager.mergePR(r,t)}),void await this.step({label:`Checked Release PR(${r})`,task:()=>this.githubManager.checkedPR(r,t)})}this.logger.info(`Please manually merge PR(#${r}) and complete the publishing process afterwards`)}async commitWorkspace(t,e=[]){const r=this.shell.format(this.getConfig("commitMessage","chore(tag): ${name} v${version}"),t);return await this.commit(r,e)}async createReleaseBranch(t){const e=this.releaseParams.getReleaseBranchParams(t,this.context.getTemplateContext()),{tagName:r,releaseBranch:n}=e;if("string"!=typeof r)throw new Error("Tag name is not a string");const{sourceBranch:o,currentBranch:i}=this.context.shared;this.context.logger.debug("PR TagName is:",r),this.context.logger.debug("PR CurrentBranch is:",i),this.context.logger.debug("PR SourceBranch is:",o),this.context.logger.debug("PR ReleaseBranch is:",n);try{await this.context.shell.exec(`git fetch origin ${o} ${i}`),await this.context.shell.exec(`git checkout -b ${n} ${i}`),await this.context.shell.exec(`git push origin ${n}`)}catch(t){throw t.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),t}return{tagName:r,releaseBranch:n}}async createReleasePR(t,e){let r=[(await this.githubManager.createReleasePRLabel()).name];if(this.getConfig("pushChangeLabels")){const t=this.context.getConfig("workspaces.changeLabels");Array.isArray(t)&&t.length>0&&r.push(...t)}r=Array.from(new Set(r)),this.logger.debug("Release PR labels:",r);const n=this.context.getTemplateContext(),o=this.releaseParams.getPRTitle(e,n),i=this.releaseParams.getPRBody(t,e,n);return this.githubManager.createReleasePR({title:o,body:i,base:this.context.sourceBranch,head:e.releaseBranch,labels:r})}},{})];class Cu{executor;defaultTuples;context;constructor(t={},e=new r,n=ju){this.executor=e,this.defaultTuples=n,this.context=new Pi(t)}getContext(){return this.context}async usePlugins(t){t=t||this.context.shared.plugins||[];const e=await Pu(this.context,[...this.defaultTuples,...t]);return e.forEach((t=>{t instanceof ku&&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 $u,Nu,Ou,Eu;function Bu(){if(Nu)return $u;Nu=1;var t=vo(),e=bi(),r=wo(),n=Ce(),o=yi();return $u=function(i,a,s,u){if(!n(i))return i;for(var c=-1,f=(a=e(a,i)).length,h=f-1,l=i;null!=l&&++c<f;){var g=o(a[c]),p=s;if("__proto__"===g||"constructor"===g||"prototype"===g)return i;if(c!=h){var m=l[g];void 0===(p=u?u(m,g,l):void 0)&&(p=n(m)?m:r(a[c+1])?[]:{})}t(l,g,p),l=l[g]}return i}}function Tu(){if(Eu)return Ou;Eu=1;var t=Bu();return Ou=function(e,r,n){return null==e?e:t(e,r,n)}}var Su=ue(Tu());function Au(t,e){return Object.entries(t).reduce(((t,[r,n])=>(r.includes(".")?Su(t,r,n):Su(t,e?`${e}.${r}`:r,n),t)),{})}export{Li as CHANGELOG_ALL_FIELDS,Wi as GitChangelog,vu as GitChangelogFormatter,Si as Plugin,Pi as ReleaseContext,yu as ReleaseLabel,Cu as ReleaseTask,_u as factory,xu as load,Pu as loaderPluginsFromPluginTuples,Au as reduceOptions,ji as tuple};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlover/fe-release",
|
|
3
3
|
"description": "A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"homepage": "https://github.com/qlover/fe-base/tree/master/packages/fe-release",
|
|
@@ -54,11 +54,12 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@octokit/rest": "^21.0.2",
|
|
56
56
|
"find-workspaces": "^0.3.1",
|
|
57
|
+
"gitlog": "^5.1.0",
|
|
57
58
|
"lodash": "^4.17.21",
|
|
58
|
-
"@qlover/env-loader": "0.3.0",
|
|
59
59
|
"@qlover/fe-corekit": "1.3.1",
|
|
60
|
+
"@qlover/logger": "0.1.1",
|
|
60
61
|
"@qlover/scripts-context": "0.2.1",
|
|
61
|
-
"@qlover/
|
|
62
|
+
"@qlover/env-loader": "0.3.0"
|
|
62
63
|
},
|
|
63
64
|
"scripts": {
|
|
64
65
|
"build": "rollup -c",
|