@qlover/fe-release 0.1.2 → 0.1.4
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 +62 -0
- package/bin/release.js +9 -1
- package/dist/cjs/index.d.ts +1 -4
- package/dist/cjs/index.js +1 -1
- package/dist/es/index.d.ts +1 -4
- package/dist/es/index.js +1 -1
- package/package.json +10 -7
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Fe-release
|
|
2
|
+
|
|
3
|
+
A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.
|
|
4
|
+
|
|
5
|
+
Currently, the release is based on the core functions of [release-it](https://github.com/release-it/release-it).
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @qlover/fe-release
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
fe-release [options]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Options
|
|
20
|
+
|
|
21
|
+
- `-V, --version`:output the version.
|
|
22
|
+
- `-d, --dry-run`:do not touch or write anything, but show the commands.
|
|
23
|
+
- `-V, --verbose`:show more information.
|
|
24
|
+
- `-P, --pull-request`:create a release PR.
|
|
25
|
+
- `-p, --publish-path <publishPath>`:specify the path of the package to release.
|
|
26
|
+
- `-h, --help`:show help information.
|
|
27
|
+
|
|
28
|
+
### Examples
|
|
29
|
+
|
|
30
|
+
1. show version:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
fe-release --version
|
|
34
|
+
# or
|
|
35
|
+
fe-release -V
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. dry run, show the commands:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
fe-release --dry-run
|
|
42
|
+
# or
|
|
43
|
+
fe-release -d
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
3. create a release PR:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
fe-release --pull-request
|
|
50
|
+
# or
|
|
51
|
+
fe-release -P
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
4. publish the package in the specified path:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
fe-release --publish-path ./path/to/package
|
|
58
|
+
# or
|
|
59
|
+
fe-release -p ./path/to/package
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Through the above instructions, users can better understand how to use the `fe-release` tool for project release. Hope this helps! If you have any other questions, please let me know.
|
package/bin/release.js
CHANGED
|
@@ -4,11 +4,19 @@ import { release } from '../dist/es/index.js';
|
|
|
4
4
|
import releaseIt from 'release-it';
|
|
5
5
|
import { readFileSync } from 'fs';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
|
-
import { join } from 'path';
|
|
7
|
+
import { join, dirname } from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const pkg = JSON.parse(
|
|
12
|
+
readFileSync(join(__dirname, '../package.json'), 'utf8')
|
|
13
|
+
);
|
|
8
14
|
|
|
9
15
|
function programArgs() {
|
|
10
16
|
const program = new Command();
|
|
11
17
|
program
|
|
18
|
+
.version(pkg.version, '-v, --version', 'Show version')
|
|
19
|
+
.description(pkg.description)
|
|
12
20
|
.option(
|
|
13
21
|
'-d, --dry-run',
|
|
14
22
|
'Do not touch or write anything, but show the commands'
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -22,10 +22,6 @@ interface PullRequestInterface {
|
|
|
22
22
|
number: number;
|
|
23
23
|
[key: string]: unknown;
|
|
24
24
|
}>;
|
|
25
|
-
getUserInfo(): Promise<{
|
|
26
|
-
repoName: string;
|
|
27
|
-
authorName: string;
|
|
28
|
-
}>;
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
interface ExecutorReleaseContext extends ExecutorContext<ReleaseContext> {
|
|
@@ -78,6 +74,7 @@ declare class ReleaseContext extends FeScriptContext<ReleaseConfig> {
|
|
|
78
74
|
getConfig(key: string | string[], defaultValue?: unknown): unknown;
|
|
79
75
|
getInitEnv(): Env;
|
|
80
76
|
getEnv(): Env;
|
|
77
|
+
getPkg(key: string): unknown;
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
type StepOption<T> = {
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t,e,r,n,i,o,u,a,s,c,f,l,h,g,p,v,b,d,y,m,w,_,R,P,O,j,E,N,k,x,C,B,A,T,I,S,$,q,z,F,U,L,M,V,G,D,H,K,W,J,Y,Q,X,Z,tt,et,rt,nt,it,ot,ut,at,st,ct,ft,lt,ht,gt,pt,vt,bt,dt,yt,mt,wt,_t,Rt,Pt,Ot,jt,Et,Nt,kt,xt,Ct,Bt,At,Tt,It,St,$t,qt,zt,Ft,Ut,Lt,Mt,Vt,Gt=require("@qlover/scripts-context"),Dt=require("@qlover/env-loader"),Ht=require("@qlover/fe-utils"),Kt=require("fs"),Wt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Jt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Yt(){if(e)return t;return e=1,t=function(){this.__data__=[],this.size=0}}function Qt(){if(n)return r;return n=1,r=function(t,e){return t===e||t!=t&&e!=e}}function Xt(){if(o)return i;o=1;var t=Qt();return i=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function Zt(){if(a)return u;a=1;var t=Xt(),e=Array.prototype.splice;return u=function(r){var n=this.__data__,i=t(n,r);return!(i<0)&&(i==n.length-1?n.pop():e.call(n,i,1),--this.size,!0)}}function te(){if(c)return s;c=1;var t=Xt();return s=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}function ee(){if(l)return f;l=1;var t=Xt();return f=function(e){return t(this.__data__,e)>-1}}function re(){if(g)return h;g=1;var t=Xt();return h=function(e,r){var n=this.__data__,i=t(n,e);return i<0?(++this.size,n.push([e,r])):n[i][1]=r,this}}function ne(){if(v)return p;v=1;var t=Yt(),e=Zt(),r=te(),n=ee(),i=re();function o(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 o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,p=o}function ie(){if(d)return b;d=1;var t=ne();return b=function(){this.__data__=new t,this.size=0}}function oe(){if(m)return y;return m=1,y=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}}function ue(){if(_)return w;return _=1,w=function(t){return this.__data__.get(t)}}function ae(){if(P)return R;return P=1,R=function(t){return this.__data__.has(t)}}function se(){if(j)return O;j=1;var t="object"==typeof Wt&&Wt&&Wt.Object===Object&&Wt;return O=t}function ce(){if(N)return E;N=1;var t=se(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return E=r}function fe(){if(x)return k;x=1;var t=ce().Symbol;return k=t}function le(){if(B)return C;B=1;var t=fe(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,i=t?t.toStringTag:void 0;return C=function(t){var e=r.call(t,i),o=t[i];try{t[i]=void 0;var u=!0}catch(t){}var a=n.call(t);return u&&(e?t[i]=o:delete t[i]),a}}function he(){if(T)return A;T=1;var t=Object.prototype.toString;return A=function(e){return t.call(e)}}function ge(){if(S)return I;S=1;var t=fe(),e=le(),r=he(),n=t?t.toStringTag:void 0;return I=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function pe(){if(q)return $;return q=1,$=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function ve(){if(F)return z;F=1;var t=ge(),e=pe();return z=function(r){if(!e(r))return!1;var n=t(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function be(){if(L)return U;L=1;var t=ce()["__core-js_shared__"];return U=t}function de(){if(V)return M;V=1;var t,e=be(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return M=function(t){return!!r&&r in t}}function ye(){if(D)return G;D=1;var t=Function.prototype.toString;return G=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function me(){if(K)return H;K=1;var t=ve(),e=de(),r=pe(),n=ye(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,u=Object.prototype,a=o.toString,s=u.hasOwnProperty,c=RegExp("^"+a.call(s).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return H=function(o){return!(!r(o)||e(o))&&(t(o)?c:i).test(n(o))}}function we(){if(J)return W;return J=1,W=function(t,e){return null==t?void 0:t[e]}}function _e(){if(Q)return Y;Q=1;var t=me(),e=we();return Y=function(r,n){var i=e(r,n);return t(i)?i:void 0}}function Re(){if(Z)return X;Z=1;var t=_e()(ce(),"Map");return X=t}function Pe(){if(et)return tt;et=1;var t=_e()(Object,"create");return tt=t}function Oe(){if(nt)return rt;nt=1;var t=Pe();return rt=function(){this.__data__=t?t(null):{},this.size=0}}function je(){if(ot)return it;return ot=1,it=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}}function Ee(){if(at)return ut;at=1;var t=Pe(),e=Object.prototype.hasOwnProperty;return ut=function(r){var n=this.__data__;if(t){var i=n[r];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(n,r)?n[r]:void 0}}function Ne(){if(ct)return st;ct=1;var t=Pe(),e=Object.prototype.hasOwnProperty;return st=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}function ke(){if(lt)return ft;lt=1;var t=Pe();return ft=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 xe(){if(gt)return ht;gt=1;var t=Oe(),e=je(),r=Ee(),n=Ne(),i=ke();function o(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 o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,ht=o}function Ce(){if(vt)return pt;vt=1;var t=xe(),e=ne(),r=Re();return pt=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function Be(){if(dt)return bt;return dt=1,bt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}}function Ae(){if(mt)return yt;mt=1;var t=Be();return yt=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Te(){if(_t)return wt;_t=1;var t=Ae();return wt=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}function Ie(){if(Pt)return Rt;Pt=1;var t=Ae();return Rt=function(e){return t(this,e).get(e)}}function Se(){if(jt)return Ot;jt=1;var t=Ae();return Ot=function(e){return t(this,e).has(e)}}function $e(){if(Nt)return Et;Nt=1;var t=Ae();return Et=function(e,r){var n=t(this,e),i=n.size;return n.set(e,r),this.size+=n.size==i?0:1,this}}function qe(){if(xt)return kt;xt=1;var t=Ce(),e=Te(),r=Ie(),n=Se(),i=$e();function o(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 o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,kt=o}function ze(){if(Bt)return Ct;Bt=1;var t=ne(),e=Re(),r=qe();return Ct=function(n,i){var o=this.__data__;if(o instanceof t){var u=o.__data__;if(!e||u.length<199)return u.push([n,i]),this.size=++o.size,this;o=this.__data__=new r(u)}return o.set(n,i),this.size=o.size,this}}function Fe(){if(Tt)return At;Tt=1;var t=ne(),e=ie(),r=oe(),n=ue(),i=ae(),o=ze();function u(e){var r=this.__data__=new t(e);this.size=r.size}return u.prototype.clear=e,u.prototype.delete=r,u.prototype.get=n,u.prototype.has=i,u.prototype.set=o,At=u}function Ue(){if(St)return It;St=1;var t=_e(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return It=e}function Le(){if(qt)return $t;qt=1;var t=Ue();return $t=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function Me(){if(Ft)return zt;Ft=1;var t=Le(),e=Qt();return zt=function(r,n,i){(void 0!==i&&!e(r[n],i)||void 0===i&&!(n in r))&&t(r,n,i)}}function Ve(){if(Lt)return Ut;return Lt=1,Ut=function(t){return function(e,r,n){for(var i=-1,o=Object(e),u=n(e),a=u.length;a--;){var s=u[t?a:++i];if(!1===r(o[s],s,o))break}return e}}}function Ge(){if(Vt)return Mt;Vt=1;var t=Ve()();return Mt=t}var De,He,Ke,We,Je,Ye,Qe,Xe,Ze,tr,er,rr,nr,ir,or,ur,ar,sr,cr,fr,lr,hr,gr,pr,vr,br,dr,yr,mr,wr,_r,Rr,Pr,Or={exports:{}};function jr(){return De||(De=1,function(t,e){var r=ce(),n=e&&!e.nodeType&&e,i=n&&t&&!t.nodeType&&t,o=i&&i.exports===n?r.Buffer:void 0,u=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=u?u(r):new t.constructor(r);return t.copy(n),n}}(Or,Or.exports)),Or.exports}function Er(){if(Ke)return He;Ke=1;var t=ce().Uint8Array;return He=t}function Nr(){if(Je)return We;Je=1;var t=Er();return We=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function kr(){if(Qe)return Ye;Qe=1;var t=Nr();return Ye=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function xr(){if(Ze)return Xe;return Ze=1,Xe=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}}function Cr(){if(er)return tr;er=1;var t=pe(),e=Object.create,r=function(){function r(){}return function(n){if(!t(n))return{};if(e)return e(n);r.prototype=n;var i=new r;return r.prototype=void 0,i}}();return tr=r}function Br(){if(nr)return rr;return nr=1,rr=function(t,e){return function(r){return t(e(r))}}}function Ar(){if(or)return ir;or=1;var t=Br()(Object.getPrototypeOf,Object);return ir=t}function Tr(){if(ar)return ur;ar=1;var t=Object.prototype;return ur=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function Ir(){if(cr)return sr;cr=1;var t=Cr(),e=Ar(),r=Tr();return sr=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function Sr(){if(lr)return fr;return lr=1,fr=function(t){return null!=t&&"object"==typeof t}}function $r(){if(gr)return hr;gr=1;var t=ge(),e=Sr();return hr=function(r){return e(r)&&"[object Arguments]"==t(r)}}function qr(){if(vr)return pr;vr=1;var t=$r(),e=Sr(),r=Object.prototype,n=r.hasOwnProperty,i=r.propertyIsEnumerable,o=t(function(){return arguments}())?t:function(t){return e(t)&&n.call(t,"callee")&&!i.call(t,"callee")};return pr=o}function zr(){if(dr)return br;dr=1;var t=Array.isArray;return br=t}function Fr(){if(mr)return yr;mr=1;return yr=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Ur(){if(_r)return wr;_r=1;var t=ve(),e=Fr();return wr=function(r){return null!=r&&e(r.length)&&!t(r)}}function Lr(){if(Pr)return Rr;Pr=1;var t=Ur(),e=Sr();return Rr=function(r){return e(r)&&t(r)}}var Mr,Vr,Gr,Dr,Hr,Kr,Wr,Jr,Yr,Qr={exports:{}};function Xr(){if(Vr)return Mr;return Vr=1,Mr=function(){return!1}}function Zr(){return Gr||(Gr=1,function(t,e){var r=ce(),n=Xr(),i=e&&!e.nodeType&&e,o=i&&t&&!t.nodeType&&t,u=o&&o.exports===i?r.Buffer:void 0,a=(u?u.isBuffer:void 0)||n;t.exports=a}(Qr,Qr.exports)),Qr.exports}function tn(){if(Hr)return Dr;Hr=1;var t=ge(),e=Ar(),r=Sr(),n=Function.prototype,i=Object.prototype,o=n.toString,u=i.hasOwnProperty,a=o.call(Object);return Dr=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var i=e(n);if(null===i)return!0;var s=u.call(i,"constructor")&&i.constructor;return"function"==typeof s&&s instanceof s&&o.call(s)==a}}function en(){if(Wr)return Kr;Wr=1;var t=ge(),e=Fr(),r=Sr(),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,Kr=function(i){return r(i)&&e(i.length)&&!!n[t(i)]}}function rn(){if(Yr)return Jr;return Yr=1,Jr=function(t){return function(e){return t(e)}}}var nn,on,un,an,sn,cn,fn,ln,hn,gn,pn,vn,bn,dn,yn,mn,wn,_n,Rn,Pn,On,jn,En,Nn,kn,xn,Cn,Bn,An,Tn,In,Sn,$n,qn,zn,Fn,Un,Ln,Mn,Vn,Gn,Dn,Hn,Kn,Wn,Jn,Yn,Qn,Xn,Zn={exports:{}};function ti(){return nn||(nn=1,function(t,e){var r=se(),n=e&&!e.nodeType&&e,i=n&&t&&!t.nodeType&&t,o=i&&i.exports===n&&r.process,u=function(){try{var t=i&&i.require&&i.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=u}(Zn,Zn.exports)),Zn.exports}function ei(){if(un)return on;un=1;var t=en(),e=rn(),r=ti(),n=r&&r.isTypedArray,i=n?e(n):t;return on=i}function ri(){if(sn)return an;return sn=1,an=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function ni(){if(fn)return cn;fn=1;var t=Le(),e=Qt(),r=Object.prototype.hasOwnProperty;return cn=function(n,i,o){var u=n[i];r.call(n,i)&&e(u,o)&&(void 0!==o||i in n)||t(n,i,o)}}function ii(){if(hn)return ln;hn=1;var t=ni(),e=Le();return ln=function(r,n,i,o){var u=!i;i||(i={});for(var a=-1,s=n.length;++a<s;){var c=n[a],f=o?o(i[c],r[c],c,i,r):void 0;void 0===f&&(f=r[c]),u?e(i,c,f):t(i,c,f)}return i}}function oi(){if(pn)return gn;return pn=1,gn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}}function ui(){if(bn)return vn;bn=1;var t=/^(?:0|[1-9]\d*)$/;return vn=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 ai(){if(yn)return dn;yn=1;var t=oi(),e=qr(),r=zr(),n=Zr(),i=ui(),o=ei(),u=Object.prototype.hasOwnProperty;return dn=function(a,s){var c=r(a),f=!c&&e(a),l=!c&&!f&&n(a),h=!c&&!f&&!l&&o(a),g=c||f||l||h,p=g?t(a.length,String):[],v=p.length;for(var b in a)!s&&!u.call(a,b)||g&&("length"==b||l&&("offset"==b||"parent"==b)||h&&("buffer"==b||"byteLength"==b||"byteOffset"==b)||i(b,v))||p.push(b);return p}}function si(){if(wn)return mn;return wn=1,mn=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}}function ci(){if(Rn)return _n;Rn=1;var t=pe(),e=Tr(),r=si(),n=Object.prototype.hasOwnProperty;return _n=function(i){if(!t(i))return r(i);var o=e(i),u=[];for(var a in i)("constructor"!=a||!o&&n.call(i,a))&&u.push(a);return u}}function fi(){if(On)return Pn;On=1;var t=ai(),e=ci(),r=Ur();return Pn=function(n){return r(n)?t(n,!0):e(n)}}function li(){if(En)return jn;En=1;var t=ii(),e=fi();return jn=function(r){return t(r,e(r))}}function hi(){if(kn)return Nn;kn=1;var t=Me(),e=jr(),r=kr(),n=xr(),i=Ir(),o=qr(),u=zr(),a=Lr(),s=Zr(),c=ve(),f=pe(),l=tn(),h=ei(),g=ri(),p=li();return Nn=function(v,b,d,y,m,w,_){var R=g(v,d),P=g(b,d),O=_.get(P);if(O)t(v,d,O);else{var j=w?w(R,P,d+"",v,b,_):void 0,E=void 0===j;if(E){var N=u(P),k=!N&&s(P),x=!N&&!k&&h(P);j=P,N||k||x?u(R)?j=R:a(R)?j=n(R):k?(E=!1,j=e(P,!0)):x?(E=!1,j=r(P,!0)):j=[]:l(P)||o(P)?(j=R,o(R)?j=p(R):f(R)&&!c(R)||(j=i(P))):E=!1}E&&(_.set(P,j),m(j,P,y,w,_),_.delete(P)),t(v,d,j)}}}function gi(){if(Cn)return xn;Cn=1;var t=Fe(),e=Me(),r=Ge(),n=hi(),i=pe(),o=fi(),u=ri();return xn=function a(s,c,f,l,h){s!==c&&r(c,(function(r,o){if(h||(h=new t),i(r))n(s,c,o,f,a,l,h);else{var g=l?l(u(s,o),r,o+"",s,c,h):void 0;void 0===g&&(g=r),e(s,o,g)}}),o)},xn}function pi(){if(An)return Bn;return An=1,Bn=function(t){return t}}function vi(){if(In)return Tn;return In=1,Tn=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 bi(){if($n)return Sn;$n=1;var t=vi(),e=Math.max;return Sn=function(r,n,i){return n=e(void 0===n?r.length-1:n,0),function(){for(var o=arguments,u=-1,a=e(o.length-n,0),s=Array(a);++u<a;)s[u]=o[n+u];u=-1;for(var c=Array(n+1);++u<n;)c[u]=o[u];return c[n]=i(s),t(r,this,c)}},Sn}function di(){if(zn)return qn;return zn=1,qn=function(t){return function(){return t}}}function yi(){if(Un)return Fn;Un=1;var t=di(),e=Ue();return Fn=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:pi()}function mi(){if(Mn)return Ln;Mn=1;var t=Date.now;return Ln=function(e){var r=0,n=0;return function(){var i=t(),o=16-(i-n);if(n=i,o>0){if(++r>=800)return arguments[0]}else r=0;return e.apply(void 0,arguments)}},Ln}function wi(){if(Gn)return Vn;Gn=1;var t=yi(),e=mi()(t);return Vn=e}function _i(){if(Hn)return Dn;Hn=1;var t=pi(),e=bi(),r=wi();return Dn=function(n,i){return r(e(n,i,t),n+"")}}function Ri(){if(Wn)return Kn;Wn=1;var t=Qt(),e=Ur(),r=ui(),n=pe();return Kn=function(i,o,u){if(!n(u))return!1;var a=typeof o;return!!("number"==a?e(u)&&r(o,u.length):"string"==a&&o in u)&&t(u[o],i)}}function Pi(){if(Yn)return Jn;Yn=1;var t=_i(),e=Ri();return Jn=function(r){return t((function(t,n){var i=-1,o=n.length,u=o>1?n[o-1]:void 0,a=o>2?n[2]:void 0;for(u=r.length>3&&"function"==typeof u?(o--,u):void 0,a&&e(n[0],n[1],a)&&(u=o<3?void 0:u,o=1),t=Object(t);++i<o;){var s=n[i];s&&r(t,s,i,u)}return t}))}}function Oi(){if(Xn)return Qn;Xn=1;var t=gi(),e=Pi()((function(e,r,n){t(e,r,n)}));return Qn=e}var ji,Ei,Ni,ki,xi,Ci,Bi,Ai,Ti,Ii,Si,$i,qi,zi,Fi,Ui,Li,Mi,Vi,Gi,Di,Hi,Ki,Wi,Ji=Jt(Oi());function Yi(){if(Ei)return ji;Ei=1;var t=ge(),e=Sr();return ji=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function Qi(){if(ki)return Ni;ki=1;var t=zr(),e=Yi(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Ni=function(i,o){if(t(i))return!1;var u=typeof i;return!("number"!=u&&"symbol"!=u&&"boolean"!=u&&null!=i&&!e(i))||(n.test(i)||!r.test(i)||null!=o&&i in Object(o))}}function Xi(){if(Ci)return xi;Ci=1;var t=qe();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=n?n.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var u=r.apply(this,t);return i.cache=o.set(e,u)||o,u};return i.cache=new(e.Cache||t),i}return e.Cache=t,xi=e}function Zi(){if(Ai)return Bi;Ai=1;var t=Xi();return Bi=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function to(){if(Ii)return Ti;Ii=1;var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,e=/\\(\\)?/g,r=Zi()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(t,(function(t,r,i,o){n.push(i?o.replace(e,"$1"):r||t)})),n}));return Ti=r}function eo(){if($i)return Si;return $i=1,Si=function(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}}function ro(){if(zi)return qi;zi=1;var t=fe(),e=eo(),r=zr(),n=Yi(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return qi=function t(i){if("string"==typeof i)return i;if(r(i))return e(i,t)+"";if(n(i))return o?o.call(i):"";var u=i+"";return"0"==u&&1/i==-1/0?"-0":u},qi}function no(){if(Ui)return Fi;Ui=1;var t=ro();return Fi=function(e){return null==e?"":t(e)}}function io(){if(Mi)return Li;Mi=1;var t=zr(),e=Qi(),r=to(),n=no();return Li=function(i,o){return t(i)?i:e(i,o)?[i]:r(n(i))}}function oo(){if(Gi)return Vi;Gi=1;var t=Yi();return Vi=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function uo(){if(Hi)return Di;Hi=1;var t=io(),e=oo();return Di=function(r,n){for(var i=0,o=(n=t(n,r)).length;null!=r&&i<o;)r=r[e(n[i++])];return i&&i==o?r:void 0}}function ao(){if(Wi)return Ki;Wi=1;var t=uo();return Ki=function(e,r,n){var i=null==e?void 0:t(e,r);return void 0===i?n:i}}var so,co,fo=Jt(ao());class lo extends Gt.FeScriptContext{env;config;constructor(t){super(t),this.config=Ji({},this.feConfig.release,this.options),this.env=this.getInitEnv()}setConfig(t){this.config=Ji(this.config,t)}getConfig(t,e){return fo(this.config,t,e)}getInitEnv(){return Dt.Env.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder})}getEnv(){return this.env}}class ho{context;onlyOne=!0;constructor(t){this.context=t}get logger(){return this.context.logger}get shell(){return this.context.shell}getEnv(t,e){return this.context.getEnv().get(t)??e}enabled(){return!0}getConfig(t,e){return this.context.getConfig(t,e)}setConfig(t){this.context.setConfig(t)}onBefore(t){}onSuccess(t){}onError(t){}async step({label:t,task:e}){this.logger.obtrusive(t);try{const r=await e();return this.logger.info(`${t} - success`),r}catch(t){throw this.logger.error(t),t}}}class go extends ho{pluginName="check-environment";constructor(t,e){if(super(t),!e)throw new Error("releaseIt is not required");this.hasReleaseIt(),this.hasGithubToken()}hasReleaseIt(){if("false"===this.getEnv("FE_RELEASE"))throw new Error("Skip Release");return!0}hasGithubToken(){const t=this.getEnv("GITHUB_TOKEN")||this.getEnv("PAT_TOKEN");if(!t)throw new Error("GITHUB_TOKEN or PAT_TOKEN environment variable is not set.");return this.setConfig({githubToken:t}),!0}onBefore(t){this.logger.verbose("CheckEnvironment onBefore")}}class po extends ho{releasePR;pluginName="create-release-pr";packageJson={};repoInfo;sourceBranch;get autoMergeReleasePR(){return this.getConfig("autoMergeReleasePR",!1)}dryRunPRNumber="999999";get releaseEnv(){return this.getConfig("releaseEnv")??this.getEnv("NODE_ENV")??"development"}constructor(t,e){super(t),this.releasePR=e,this.sourceBranch=this.getEnv("FE_RELEASE_BRANCH")??this.getEnv("FE_RELEASE_SOURCE_BRANCH")??"master"}async onBefore(){this.logger.verbose("CreateReleasePullRequest onBefore"),this.repoInfo=await this.releasePR.getUserInfo();const t=this.getConfig("githubToken");await this.releasePR.init({token:t}),this.packageJson=this.getConfig("packageJson")}async onSuccess(){const t=await this.step({label:"Create Changelog and Version",task:()=>this.createChangelogAndVersion()}),{tagName:e,releaseBranch:r}=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(t)}),n=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(e,r,t)});if(this.autoMergeReleasePR)return await this.step({label:`Merge Release PR(${n})`,task:()=>this.autoMergePR(n,r)}),void await this.step({label:`Checked Release PR(${n})`,task:()=>this.checkedPullRequest(n,r)});this.logger.info(`Please manually merge PR(#${n}) and complete the publishing process afterwards`)}async autoMergePR(t,e){if(!t)return void this.logger.error("Failed to create Pull Request.",t);const r=this.getConfig("autoMergeType","squash");if(this.context.dryRun){const{repoName:n,authorName:i}=this.getRepoInfo();this.logger.info(`[DRY RUN] Would merge PR #${t} with method '${r}' in repo ${i}/${n}, branch ${e}`)}else await this.releasePR.mergePullRequest({pull_number:Number(t),merge_method:r})}async checkedPullRequest(t,e){try{await this.releasePR.getPullRequest({pull_number:Number(t)}),await this.releasePR.deleteBranch({ref:`heads/${e}`}),this.logger.info(`Branch ${e} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${t} or branch ${e} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleaseBranch(t){const{tagName:e}=await this.checkTag(t),r=this.getReleaseBranch(e);return this.logger.verbose("PR SourceBranch is:",this.sourceBranch),this.logger.verbose("PR TargetBranch is:",r),await this.shell.exec(`git fetch origin ${this.sourceBranch}`),await this.shell.exec(`git merge origin/${this.sourceBranch}`),await this.shell.exec(`git checkout -b ${r}`),await this.shell.exec(`git push origin ${r}`),{tagName:e,releaseBranch:r}}getPkg(t){return fo(this.packageJson,t)}createChangelogAndVersion(){const t=this.getConfig("releaseIt");if(!t)throw new Error("releaseIt instance is not set");return t(this.getReleaseItChangelogOptions())}getReleaseItChangelogOptions(){return{ci:!0,increment:"patch",npm:{publish:!1},git:{requireCleanWorkingDir:!1,tag:!1,push:!1},github:{release:!1},verbose:!0,"dry-run":this.context.dryRun}}async checkTag(t){const e=fo(t,"version")||this.getPkg("version");if("string"!=typeof e)throw new Error("Tag name is not a string");return this.logger.verbose("Created Tag is:",e),{tagName:e}}getReleaseBranch(t){const e=this.getConfig("branchName","release-${tagName}");if("string"!=typeof e)throw new Error("Branch name template is not a string");return this.logger.verbose("Release Branch template is:",e),this.shell.format(e,{env:this.releaseEnv,branch:this.sourceBranch,tagName:t})}async createReleasePR(t,e,r){const n=this.getChangelogAndFeatures(r),i=await this.createReleasePRLabel();return this.getReleasePullRequest({tagName:t,releaseBranch:e,changelog:n,label:i})}async createReleasePRLabel(){const t=this.getConfig("label");if(!(t&&t.name&&t.description&&t.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",t),t;try{const e=await this.releasePR.createPullRequestLabel({name:t.name,description:t.description,color:t.color.replace("#","")});return this.logger.debug("Create PR label Success",e),t}catch(e){if(422===e.status)return this.logger.warn(`Label ${t.name} already exists, skipping!`),t;throw this.logger.error("Create PR label Failed",e),e}}getChangelogAndFeatures(t){return t||this.logger.warn("No release-it output found, changelog might be incomplete"),fo(t,"changelog","No changelog")}async getReleasePullRequest(t){const e=this.getCreateReleasePROptions(t.tagName,t.releaseBranch,t.changelog);if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...e,labels:[t.label?.name]}),this.dryRunPRNumber;try{const r=await this.releasePR.createPullRequest(e),n=r.number;if(!n)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",r),t.label?.name){const e=await this.releasePR.addPullRequestLabels({issue_number:n,labels:[t.label.name]});this.logger.debug("Add PR label Success",e)}return n.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}}getCreateReleasePROptions(t,e,r){return{title:this.getReleasePRTitle(t),body:this.getReleasePRBody({tagName:t,changelog:r}),base:this.sourceBranch,head:e}}getReleasePRTitle(t){const e=this.getConfig("PRTitle","Release ${env} ${pkgName} ${tagName}");return this.shell.format(e,{env:this.releaseEnv,branch:this.sourceBranch,tagName:t,pkgName:this.getPkg("name")})}getReleasePRBody({tagName:t,changelog:e}){const r=this.getConfig("PRBody","");return this.shell.format(r,{branch:this.sourceBranch,env:this.releaseEnv,tagName:t,changelog:e})}getRepoInfo(){if(!this.repoInfo)throw new Error("Repository information not initialized");return this.repoInfo}}function vo(){if(co)return so;co=1;var t=ge(),e=zr(),r=Sr();return so=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}var bo=Jt(vo());class yo{context;options;octokit;constructor(t,e={}){this.context=t,this.options=e}async init({token:t}){if(this.octokit)return this.octokit;if(!t)throw new Error("Github token is not set");const{repoName:e,authorName:r}=await this.getUserInfo();this.options.repoName=e,this.options.authorName=r;const{Octokit:n}=await import("@octokit/rest"),i=new n({auth:t});return this.octokit=i,i}getOctokit(){if(!this.octokit)throw new Error("Octokit is not initialized");return this.octokit}mergePullRequest(t){return this.getOctokit().rest.pulls.merge({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}getPullRequest(t){return this.getOctokit().rest.pulls.get({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}deleteBranch(t){return this.getOctokit().rest.git.deleteRef({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}addPullRequestLabels(t){return this.getOctokit().rest.issues.addLabels({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}async createPullRequestLabel(t){return await this.getOctokit().rest.issues.createLabel({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}async createPullRequest(t){const e=await this.getOctokit().rest.pulls.create({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""});return{...e.data,number:e.data.number}}async getUserInfo(){let t;try{t=(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}catch(t){throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!t)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.verbose("repoUrl: ",t);const e=t.match(/github\.com[:/]([^/]+)\/([^/.]+)(?:\.git)?$/);if(!e)throw new Error("Invalid GitHub repository URL format. Please ensure the remote URL is from GitHub.");const[,r,n]=e;if(!this.isValidString(r)||!this.isValidString(n))throw new Error("Failed to extract owner or repository name from GitHub URL");return{repoName:n,authorName:r}}isValidString(t){return!!t&&bo(t)}}var mo=Jt(pe());class wo extends ho{pluginName="publish-npm";_releaseItOutput;constructor(t){super(t),this.getIncrementVersion()}async onBefore(){this.logger.verbose("PublishNpm onBefore"),await this.checkNpmAuth()}async onSuccess(){const t=this.getPublishReleaseItOptions(this.context);await this.step({label:"Publish to NPM",task:()=>this.publish(t)})}async publish(t){this.logger.debug("Run release-it method",t);const e=this.getConfig("releaseIt");if(!e)throw new Error("releaseIt instance is not set");return this._releaseItOutput=await e(t),this._releaseItOutput}getPublishReleaseItOptions(t){return{ci:!0,npm:{publish:!0},git:{requireCleanWorkingDir:!1,requireUpstream:!1,changelog:!1},plugins:{"@release-it/conventional-changelog":{infile:!1}},"dry-run":t.dryRun,verbose:!0,increment:this.getIncrementVersion()}}getIncrementVersion(){const t=this.getConfig("packageJson");if(!mo(t))throw new Error("package.json is undefined");if(!("version"in t))throw new Error("package.json version is required");return t.version}async checkNpmAuth(){const t=this.getEnv("NPM_TOKEN");if(!t)throw new Error("NPM_TOKEN is not set.");this.setConfig({npmToken:t}),await this.shell.exec(`echo "//registry.npmjs.org/:_authToken=${t}" > .npmrc`)}}class _o extends ho{pluginName="publish-path";constructor(t){super(t),this.checkPublishPath()}async onBefore(){this.logger.verbose("PublishPath onBefore")}async checkPublishPath(){const t=this.getPublishPath();this.switchToPublishPath(t),this.logger.debug("Current path:",t)}switchToPublishPath(t){t&&Kt.existsSync(t)&&(this.logger.debug("Switching to publish path:",t),process.chdir(t))}getPublishPath(){const t=this.getConfig("publishPath");return"string"==typeof t?t:process.cwd()}}exports.Plugin=ho,exports.ReleaseContext=lo,exports.release=function(t){const e=new lo(t),r=new Ht.AsyncExecutor;return function(t){const e=[];return e.push(new go(t,t.options.releaseIt)),t.options.pullRequest?e.push(new po(t,new yo(t))):e.push(new wo(t)),e.push(new _o(t)),e}(e).forEach((t=>{r.use(t)})),r.exec(e,(({returnValue:t})=>Promise.resolve(t)))};
|
|
1
|
+
"use strict";var e,t,r,n,o,i,u,a,s,c,l,f,h,g,p,v,b,d,y,m,w,R,_,P,x,E,N,O,j,k,C,B,T,A,I,S,q,$,M,F,L,U,z,V,G,H,D,W,K,Y,J,Q,X,Z,ee,te,re,ne,oe,ie,ue,ae,se,ce,le,fe,he,ge,pe,ve,be,de,ye,me,we,Re,_e,Pe,xe,Ee,Ne,Oe,je,ke,Ce,Be,Te,Ae,Ie,Se,qe,$e,Me,Fe,Le,Ue,ze,Ve,Ge=require("@qlover/scripts-context"),He=require("@qlover/env-loader"),De=require("@qlover/fe-utils"),We=require("fs"),Ke="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ye(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Je(){if(t)return e;return t=1,e=function(){this.__data__=[],this.size=0}}function Qe(){if(n)return r;return n=1,r=function(e,t){return e===t||e!=e&&t!=t}}function Xe(){if(i)return o;i=1;var e=Qe();return o=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function Ze(){if(a)return u;a=1;var e=Xe(),t=Array.prototype.splice;return u=function(r){var n=this.__data__,o=e(n,r);return!(o<0)&&(o==n.length-1?n.pop():t.call(n,o,1),--this.size,!0)}}function et(){if(c)return s;c=1;var e=Xe();return s=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}function tt(){if(f)return l;f=1;var e=Xe();return l=function(t){return e(this.__data__,t)>-1}}function rt(){if(g)return h;g=1;var e=Xe();return h=function(t,r){var n=this.__data__,o=e(n,t);return o<0?(++this.size,n.push([t,r])):n[o][1]=r,this}}function nt(){if(v)return p;v=1;var e=Je(),t=Ze(),r=et(),n=tt(),o=rt();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,p=i}function ot(){if(d)return b;d=1;var e=nt();return b=function(){this.__data__=new e,this.size=0}}function it(){if(m)return y;return m=1,y=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}}function ut(){if(R)return w;return R=1,w=function(e){return this.__data__.get(e)}}function at(){if(P)return _;return P=1,_=function(e){return this.__data__.has(e)}}function st(){if(E)return x;E=1;var e="object"==typeof Ke&&Ke&&Ke.Object===Object&&Ke;return x=e}function ct(){if(O)return N;O=1;var e=st(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return N=r}function lt(){if(k)return j;k=1;var e=ct().Symbol;return j=e}function ft(){if(B)return C;B=1;var e=lt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,o=e?e.toStringTag:void 0;return C=function(e){var t=r.call(e,o),i=e[o];try{e[o]=void 0;var u=!0}catch(e){}var a=n.call(e);return u&&(t?e[o]=i:delete e[o]),a}}function ht(){if(A)return T;A=1;var e=Object.prototype.toString;return T=function(t){return e.call(t)}}function gt(){if(S)return I;S=1;var e=lt(),t=ft(),r=ht(),n=e?e.toStringTag:void 0;return I=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):r(e)}}function pt(){if($)return q;return $=1,q=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function vt(){if(F)return M;F=1;var e=gt(),t=pt();return M=function(r){if(!t(r))return!1;var n=e(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function bt(){if(U)return L;U=1;var e=ct()["__core-js_shared__"];return L=e}function dt(){if(V)return z;V=1;var e,t=bt(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return z=function(e){return!!r&&r in e}}function yt(){if(H)return G;H=1;var e=Function.prototype.toString;return G=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}function mt(){if(W)return D;W=1;var e=vt(),t=dt(),r=pt(),n=yt(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,u=Object.prototype,a=i.toString,s=u.hasOwnProperty,c=RegExp("^"+a.call(s).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return D=function(i){return!(!r(i)||t(i))&&(e(i)?c:o).test(n(i))}}function wt(){if(Y)return K;return Y=1,K=function(e,t){return null==e?void 0:e[t]}}function Rt(){if(Q)return J;Q=1;var e=mt(),t=wt();return J=function(r,n){var o=t(r,n);return e(o)?o:void 0}}function _t(){if(Z)return X;Z=1;var e=Rt()(ct(),"Map");return X=e}function Pt(){if(te)return ee;te=1;var e=Rt()(Object,"create");return ee=e}function xt(){if(ne)return re;ne=1;var e=Pt();return re=function(){this.__data__=e?e(null):{},this.size=0}}function Et(){if(ie)return oe;return ie=1,oe=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}}function Nt(){if(ae)return ue;ae=1;var e=Pt(),t=Object.prototype.hasOwnProperty;return ue=function(r){var n=this.__data__;if(e){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return t.call(n,r)?n[r]:void 0}}function Ot(){if(ce)return se;ce=1;var e=Pt(),t=Object.prototype.hasOwnProperty;return se=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}function jt(){if(fe)return le;fe=1;var e=Pt();return le=function(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===r?"__lodash_hash_undefined__":r,this}}function kt(){if(ge)return he;ge=1;var e=xt(),t=Et(),r=Nt(),n=Ot(),o=jt();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,he=i}function Ct(){if(ve)return pe;ve=1;var e=kt(),t=nt(),r=_t();return pe=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}function Bt(){if(de)return be;return de=1,be=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}}function Tt(){if(me)return ye;me=1;var e=Bt();return ye=function(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function At(){if(Re)return we;Re=1;var e=Tt();return we=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}function It(){if(Pe)return _e;Pe=1;var e=Tt();return _e=function(t){return e(this,t).get(t)}}function St(){if(Ee)return xe;Ee=1;var e=Tt();return xe=function(t){return e(this,t).has(t)}}function qt(){if(Oe)return Ne;Oe=1;var e=Tt();return Ne=function(t,r){var n=e(this,t),o=n.size;return n.set(t,r),this.size+=n.size==o?0:1,this}}function $t(){if(ke)return je;ke=1;var e=Ct(),t=At(),r=It(),n=St(),o=qt();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,je=i}function Mt(){if(Be)return Ce;Be=1;var e=nt(),t=_t(),r=$t();return Ce=function(n,o){var i=this.__data__;if(i instanceof e){var u=i.__data__;if(!t||u.length<199)return u.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(u)}return i.set(n,o),this.size=i.size,this}}function Ft(){if(Ae)return Te;Ae=1;var e=nt(),t=ot(),r=it(),n=ut(),o=at(),i=Mt();function u(t){var r=this.__data__=new e(t);this.size=r.size}return u.prototype.clear=t,u.prototype.delete=r,u.prototype.get=n,u.prototype.has=o,u.prototype.set=i,Te=u}function Lt(){if(Se)return Ie;Se=1;var e=Rt(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return Ie=t}function Ut(){if($e)return qe;$e=1;var e=Lt();return qe=function(t,r,n){"__proto__"==r&&e?e(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}}function zt(){if(Fe)return Me;Fe=1;var e=Ut(),t=Qe();return Me=function(r,n,o){(void 0!==o&&!t(r[n],o)||void 0===o&&!(n in r))&&e(r,n,o)}}function Vt(){if(Ue)return Le;return Ue=1,Le=function(e){return function(t,r,n){for(var o=-1,i=Object(t),u=n(t),a=u.length;a--;){var s=u[e?a:++o];if(!1===r(i[s],s,i))break}return t}}}function Gt(){if(Ve)return ze;Ve=1;var e=Vt()();return ze=e}var Ht,Dt,Wt,Kt,Yt,Jt,Qt,Xt,Zt,er,tr,rr,nr,or,ir,ur,ar,sr,cr,lr,fr,hr,gr,pr,vr,br,dr,yr,mr,wr,Rr,_r,Pr,xr={exports:{}};function Er(){return Ht||(Ht=1,function(e,t){var r=ct(),n=t&&!t.nodeType&&t,o=n&&e&&!e.nodeType&&e,i=o&&o.exports===n?r.Buffer:void 0,u=i?i.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=u?u(r):new e.constructor(r);return e.copy(n),n}}(xr,xr.exports)),xr.exports}function Nr(){if(Wt)return Dt;Wt=1;var e=ct().Uint8Array;return Dt=e}function Or(){if(Yt)return Kt;Yt=1;var e=Nr();return Kt=function(t){var r=new t.constructor(t.byteLength);return new e(r).set(new e(t)),r}}function jr(){if(Qt)return Jt;Qt=1;var e=Or();return Jt=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}function kr(){if(Zt)return Xt;return Zt=1,Xt=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}}function Cr(){if(tr)return er;tr=1;var e=pt(),t=Object.create,r=function(){function r(){}return function(n){if(!e(n))return{};if(t)return t(n);r.prototype=n;var o=new r;return r.prototype=void 0,o}}();return er=r}function Br(){if(nr)return rr;return nr=1,rr=function(e,t){return function(r){return e(t(r))}}}function Tr(){if(ir)return or;ir=1;var e=Br()(Object.getPrototypeOf,Object);return or=e}function Ar(){if(ar)return ur;ar=1;var e=Object.prototype;return ur=function(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}}function Ir(){if(cr)return sr;cr=1;var e=Cr(),t=Tr(),r=Ar();return sr=function(n){return"function"!=typeof n.constructor||r(n)?{}:e(t(n))}}function Sr(){if(fr)return lr;return fr=1,lr=function(e){return null!=e&&"object"==typeof e}}function qr(){if(gr)return hr;gr=1;var e=gt(),t=Sr();return hr=function(r){return t(r)&&"[object Arguments]"==e(r)}}function $r(){if(vr)return pr;vr=1;var e=qr(),t=Sr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=e(function(){return arguments}())?e:function(e){return t(e)&&n.call(e,"callee")&&!o.call(e,"callee")};return pr=i}function Mr(){if(dr)return br;dr=1;var e=Array.isArray;return br=e}function Fr(){if(mr)return yr;mr=1;return yr=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function Lr(){if(Rr)return wr;Rr=1;var e=vt(),t=Fr();return wr=function(r){return null!=r&&t(r.length)&&!e(r)}}function Ur(){if(Pr)return _r;Pr=1;var e=Lr(),t=Sr();return _r=function(r){return t(r)&&e(r)}}var zr,Vr,Gr,Hr,Dr,Wr,Kr,Yr,Jr,Qr={exports:{}};function Xr(){if(Vr)return zr;return Vr=1,zr=function(){return!1}}function Zr(){return Gr||(Gr=1,function(e,t){var r=ct(),n=Xr(),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,u=i&&i.exports===o?r.Buffer:void 0,a=(u?u.isBuffer:void 0)||n;e.exports=a}(Qr,Qr.exports)),Qr.exports}function en(){if(Dr)return Hr;Dr=1;var e=gt(),t=Tr(),r=Sr(),n=Function.prototype,o=Object.prototype,i=n.toString,u=o.hasOwnProperty,a=i.call(Object);return Hr=function(n){if(!r(n)||"[object Object]"!=e(n))return!1;var o=t(n);if(null===o)return!0;var s=u.call(o,"constructor")&&o.constructor;return"function"==typeof s&&s instanceof s&&i.call(s)==a}}function tn(){if(Kr)return Wr;Kr=1;var e=gt(),t=Fr(),r=Sr(),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,Wr=function(o){return r(o)&&t(o.length)&&!!n[e(o)]}}function rn(){if(Jr)return Yr;return Jr=1,Yr=function(e){return function(t){return e(t)}}}var nn,on,un,an,sn,cn,ln,fn,hn,gn,pn,vn,bn,dn,yn,mn,wn,Rn,_n,Pn,xn,En,Nn,On,jn,kn,Cn,Bn,Tn,An,In,Sn,qn,$n,Mn,Fn,Ln,Un,zn,Vn,Gn,Hn,Dn,Wn,Kn,Yn,Jn,Qn,Xn,Zn={exports:{}};function eo(){return nn||(nn=1,function(e,t){var r=st(),n=t&&!t.nodeType&&t,o=n&&e&&!e.nodeType&&e,i=o&&o.exports===n&&r.process,u=function(){try{var e=o&&o.require&&o.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=u}(Zn,Zn.exports)),Zn.exports}function to(){if(un)return on;un=1;var e=tn(),t=rn(),r=eo(),n=r&&r.isTypedArray,o=n?t(n):e;return on=o}function ro(){if(sn)return an;return sn=1,an=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function no(){if(ln)return cn;ln=1;var e=Ut(),t=Qe(),r=Object.prototype.hasOwnProperty;return cn=function(n,o,i){var u=n[o];r.call(n,o)&&t(u,i)&&(void 0!==i||o in n)||e(n,o,i)}}function oo(){if(hn)return fn;hn=1;var e=no(),t=Ut();return fn=function(r,n,o,i){var u=!o;o||(o={});for(var a=-1,s=n.length;++a<s;){var c=n[a],l=i?i(o[c],r[c],c,o,r):void 0;void 0===l&&(l=r[c]),u?t(o,c,l):e(o,c,l)}return o}}function io(){if(pn)return gn;return pn=1,gn=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}}function uo(){if(bn)return vn;bn=1;var e=/^(?:0|[1-9]\d*)$/;return vn=function(t,r){var n=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<r}}function ao(){if(yn)return dn;yn=1;var e=io(),t=$r(),r=Mr(),n=Zr(),o=uo(),i=to(),u=Object.prototype.hasOwnProperty;return dn=function(a,s){var c=r(a),l=!c&&t(a),f=!c&&!l&&n(a),h=!c&&!l&&!f&&i(a),g=c||l||f||h,p=g?e(a.length,String):[],v=p.length;for(var b in a)!s&&!u.call(a,b)||g&&("length"==b||f&&("offset"==b||"parent"==b)||h&&("buffer"==b||"byteLength"==b||"byteOffset"==b)||o(b,v))||p.push(b);return p}}function so(){if(wn)return mn;return wn=1,mn=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}}function co(){if(_n)return Rn;_n=1;var e=pt(),t=Ar(),r=so(),n=Object.prototype.hasOwnProperty;return Rn=function(o){if(!e(o))return r(o);var i=t(o),u=[];for(var a in o)("constructor"!=a||!i&&n.call(o,a))&&u.push(a);return u}}function lo(){if(xn)return Pn;xn=1;var e=ao(),t=co(),r=Lr();return Pn=function(n){return r(n)?e(n,!0):t(n)}}function fo(){if(Nn)return En;Nn=1;var e=oo(),t=lo();return En=function(r){return e(r,t(r))}}function ho(){if(jn)return On;jn=1;var e=zt(),t=Er(),r=jr(),n=kr(),o=Ir(),i=$r(),u=Mr(),a=Ur(),s=Zr(),c=vt(),l=pt(),f=en(),h=to(),g=ro(),p=fo();return On=function(v,b,d,y,m,w,R){var _=g(v,d),P=g(b,d),x=R.get(P);if(x)e(v,d,x);else{var E=w?w(_,P,d+"",v,b,R):void 0,N=void 0===E;if(N){var O=u(P),j=!O&&s(P),k=!O&&!j&&h(P);E=P,O||j||k?u(_)?E=_:a(_)?E=n(_):j?(N=!1,E=t(P,!0)):k?(N=!1,E=r(P,!0)):E=[]:f(P)||i(P)?(E=_,i(_)?E=p(_):l(_)&&!c(_)||(E=o(P))):N=!1}N&&(R.set(P,E),m(E,P,y,w,R),R.delete(P)),e(v,d,E)}}}function go(){if(Cn)return kn;Cn=1;var e=Ft(),t=zt(),r=Gt(),n=ho(),o=pt(),i=lo(),u=ro();return kn=function a(s,c,l,f,h){s!==c&&r(c,(function(r,i){if(h||(h=new e),o(r))n(s,c,i,l,a,f,h);else{var g=f?f(u(s,i),r,i+"",s,c,h):void 0;void 0===g&&(g=r),t(s,i,g)}}),i)},kn}function po(){if(Tn)return Bn;return Tn=1,Bn=function(e){return e}}function vo(){if(In)return An;return In=1,An=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}}function bo(){if(qn)return Sn;qn=1;var e=vo(),t=Math.max;return Sn=function(r,n,o){return n=t(void 0===n?r.length-1:n,0),function(){for(var i=arguments,u=-1,a=t(i.length-n,0),s=Array(a);++u<a;)s[u]=i[n+u];u=-1;for(var c=Array(n+1);++u<n;)c[u]=i[u];return c[n]=o(s),e(r,this,c)}},Sn}function yo(){if(Mn)return $n;return Mn=1,$n=function(e){return function(){return e}}}function mo(){if(Ln)return Fn;Ln=1;var e=yo(),t=Lt();return Fn=t?function(r,n){return t(r,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:po()}function wo(){if(zn)return Un;zn=1;var e=Date.now;return Un=function(t){var r=0,n=0;return function(){var o=e(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}},Un}function Ro(){if(Gn)return Vn;Gn=1;var e=mo(),t=wo()(e);return Vn=t}function _o(){if(Dn)return Hn;Dn=1;var e=po(),t=bo(),r=Ro();return Hn=function(n,o){return r(t(n,o,e),n+"")}}function Po(){if(Kn)return Wn;Kn=1;var e=Qe(),t=Lr(),r=uo(),n=pt();return Wn=function(o,i,u){if(!n(u))return!1;var a=typeof i;return!!("number"==a?t(u)&&r(i,u.length):"string"==a&&i in u)&&e(u[i],o)}}function xo(){if(Jn)return Yn;Jn=1;var e=_o(),t=Po();return Yn=function(r){return e((function(e,n){var o=-1,i=n.length,u=i>1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(u=r.length>3&&"function"==typeof u?(i--,u):void 0,a&&t(n[0],n[1],a)&&(u=i<3?void 0:u,i=1),e=Object(e);++o<i;){var s=n[o];s&&r(e,s,o,u)}return e}))}}function Eo(){if(Xn)return Qn;Xn=1;var e=go(),t=xo()((function(t,r,n){e(t,r,n)}));return Qn=t}var No,Oo,jo,ko,Co,Bo,To,Ao,Io,So,qo,$o,Mo,Fo,Lo,Uo,zo,Vo,Go,Ho,Do,Wo,Ko,Yo,Jo=Ye(Eo());function Qo(){if(Oo)return No;Oo=1;var e=gt(),t=Sr();return No=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function Xo(){if(ko)return jo;ko=1;var e=Mr(),t=Qo(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return jo=function(o,i){if(e(o))return!1;var u=typeof o;return!("number"!=u&&"symbol"!=u&&"boolean"!=u&&null!=o&&!t(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function Zo(){if(Bo)return Co;Bo=1;var e=$t();function t(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var e=arguments,t=n?n.apply(this,e):e[0],i=o.cache;if(i.has(t))return i.get(t);var u=r.apply(this,e);return o.cache=i.set(t,u)||i,u};return o.cache=new(t.Cache||e),o}return t.Cache=e,Co=t}function ei(){if(Ao)return To;Ao=1;var e=Zo();return To=function(t){var r=e(t,(function(e){return 500===n.size&&n.clear(),e})),n=r.cache;return r}}function ti(){if(So)return Io;So=1;var e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,r=ei()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(e,(function(e,r,o,i){n.push(o?i.replace(t,"$1"):r||e)})),n}));return Io=r}function ri(){if($o)return qo;return $o=1,qo=function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}}function ni(){if(Fo)return Mo;Fo=1;var e=lt(),t=ri(),r=Mr(),n=Qo(),o=e?e.prototype:void 0,i=o?o.toString:void 0;return Mo=function e(o){if("string"==typeof o)return o;if(r(o))return t(o,e)+"";if(n(o))return i?i.call(o):"";var u=o+"";return"0"==u&&1/o==-1/0?"-0":u},Mo}function oi(){if(Uo)return Lo;Uo=1;var e=ni();return Lo=function(t){return null==t?"":e(t)}}function ii(){if(Vo)return zo;Vo=1;var e=Mr(),t=Xo(),r=ti(),n=oi();return zo=function(o,i){return e(o)?o:t(o,i)?[o]:r(n(o))}}function ui(){if(Ho)return Go;Ho=1;var e=Qo();return Go=function(t){if("string"==typeof t||e(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}}function ai(){if(Wo)return Do;Wo=1;var e=ii(),t=ui();return Do=function(r,n){for(var o=0,i=(n=e(n,r)).length;null!=r&&o<i;)r=r[t(n[o++])];return o&&o==i?r:void 0}}function si(){if(Yo)return Ko;Yo=1;var e=ai();return Ko=function(t,r,n){var o=null==t?void 0:e(t,r);return void 0===o?n:o}}var ci,li,fi=Ye(si());class hi extends Ge.FeScriptContext{env;config;constructor(e){super(e),this.config=Jo({},this.feConfig.release,this.options),this.env=this.getInitEnv()}setConfig(e){this.config=Jo(this.config,e)}getConfig(e,t){return fi(this.config,e,t)}getInitEnv(){return He.Env.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder})}getEnv(){return this.env}getPkg(e){return this.getConfig(["packageJson",e])}}class gi{context;onlyOne=!0;constructor(e){this.context=e}get logger(){return this.context.logger}get shell(){return this.context.shell}getEnv(e,t){return this.context.getEnv().get(e)??t}enabled(){return!0}getConfig(e,t){return this.context.getConfig(e,t)}setConfig(e){this.context.setConfig(e)}onBefore(e){}onSuccess(e){}onError(e){}async step({label:e,task:t}){this.logger.obtrusive(e);try{const r=await t();return this.logger.info(`${e} - success`),r}catch(e){throw this.logger.error(e),e}}}class pi extends gi{pluginName="check-environment";constructor(e,t){if(super(e),!t)throw new Error("releaseIt is not required");this.hasReleaseIt(),this.hasGithubToken()}hasReleaseIt(){if("false"===this.getEnv("FE_RELEASE"))throw new Error("Skip Release");return!0}hasGithubToken(){const e=this.getEnv("GITHUB_TOKEN")||this.getEnv("PAT_TOKEN");if(!e)throw new Error("GITHUB_TOKEN or PAT_TOKEN environment variable is not set.");return this.setConfig({githubToken:e}),!0}onBefore(e){this.logger.verbose("CheckEnvironment onBefore")}}class vi{context;constructor(e){this.context=e;const t=this.context.getEnv().get("FE_RELEASE_BRANCH")??this.context.getEnv().get("FE_RELEASE_SOURCE_BRANCH")??"master";this.context.setConfig({sourceBranch:t})}getReleaseIt(){return this.context.getConfig("releaseIt")}getReleaseItChangelogOptions(){return{ci:!0,increment:"patch",npm:{publish:!1},git:{requireCleanWorkingDir:!1,tag:!1,push:!1},github:{release:!1},verbose:!0,"dry-run":this.context.dryRun}}getChangelogAndFeatures(e){return e||this.context.logger.warn("No release-it output found, changelog might be incomplete"),fi(e,"changelog","No changelog")}createChangelogAndVersion(){const e=this.getReleaseIt();if(!e)throw new Error("releaseIt instance is not set");return e(this.getReleaseItChangelogOptions())}}class bi{context;constructor(e){this.context=e;const t=this.context.getConfig("releaseEnv")??this.context.getEnv().get("NODE_ENV")??"development",r=this.context.getEnv().get("FE_RELEASE_BRANCH")??this.context.getEnv().get("FE_RELEASE_SOURCE_BRANCH")??"master";this.context.setConfig({releaseEnv:t,sourceBranch:r})}get sourceBranch(){return this.context.getConfig("sourceBranch")}get releaseEnv(){return this.context.getConfig("releaseEnv")}async checkTag(e){const t=fi(e,"version")||this.context.getPkg("version");if("string"!=typeof t)throw new Error("Tag name is not a string");return this.context.logger.verbose("Created Tag is:",t),{tagName:t}}getReleaseBranchName(e){const t=this.context.getConfig("branchName","release-${tagName}");if("string"!=typeof t)throw new Error("Branch name template is not a string");return this.context.logger.verbose("Release Branch template is:",t),this.context.shell.format(t,{env:this.releaseEnv,branch:this.sourceBranch,tagName:e})}async createReleaseBranch(e){const{tagName:t}=await this.checkTag(e),r=this.getReleaseBranchName(t),n=this.sourceBranch;this.context.logger.verbose("PR SourceBranch is:",n),this.context.logger.verbose("PR TargetBranch is:",r);try{await this.context.shell.exec(`git fetch origin ${n}`),await this.context.shell.exec(`git merge origin/${n}`),await this.context.shell.exec(`git checkout -b ${r}`),await this.context.shell.exec(`git push origin ${r}`)}catch(e){throw e.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),e}return{tagName:t,releaseBranch:r}}}class di{context;releaseBase;releasePR;constructor(e,t,r){this.context=e,this.releaseBase=t,this.releasePR=r}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.getConfig("autoMergeType","squash")}get dryRunPRNumber(){return this.context.getConfig("dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.getConfig("autoMergeReleasePR",!1)}async mergePR(e,t){if(!e)return void this.logger.error("Failed to create Pull Request.",e);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.releaseBase.repoInfo;this.logger.info(`[DRY RUN] Would merge PR #${e} with method '${r}' in repo ${o}/${n}, branch ${t}`)}else await this.releasePR.mergePullRequest({pull_number:Number(e),merge_method:r})}async checkedPR(e,t){try{await this.releasePR.getPullRequest({pull_number:Number(e)}),await this.releasePR.deleteBranch({ref:`heads/${t}`}),this.logger.info(`Branch ${t} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${e} or branch ${t} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const e=this.context.getConfig("label");if(!(e&&e.name&&e.description&&e.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",e),e;try{const t=await this.releasePR.createPullRequestLabel({name:e.name,description:e.description,color:e.color.replace("#","")});return this.logger.debug("Create PR label Success",t),e}catch(t){if(422===t.status)return this.logger.warn(`Label ${e.name} already exists, skipping!`),e;throw this.logger.error("Create PR label Failed",t),t}}async createReleasePR(e){const t=this.getCreateReleasePROptions(e);if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...t,labels:e.labels}),this.dryRunPRNumber;try{const r=await this.releasePR.createPullRequest(t),n=r.number;if(!n)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",r),e.labels&&e.labels.length){const t=await this.releasePR.addPullRequestLabels({issue_number:n,labels:e.labels});this.logger.debug("Add PR label Success",t)}return n.toString()}catch(e){if(422===e.status&&e.message.includes("already exists")){this.logger.warn("PR already exists");const t=e.message.match(/pull request #(\d+)/);return t?t[1]:""}throw this.logger.error("Failed to create PR",e),e}}getCreateReleasePROptions(e){return{title:this.getReleasePRTitle(e),body:this.getReleasePRBody(e),base:e.sourceBranch,head:e.releaseBranch}}getReleasePRTitle(e){const t=this.context.getConfig("PRTitle","Release ${env} ${pkgName} ${tagName}");return this.shell.format(t,{env:e.releaseEnv,branch:e.sourceBranch,tagName:e.tagName,pkgName:this.context.getPkg("name")})}getReleasePRBody(e){const t=this.context.getConfig("PRBody","");return this.shell.format(t,{branch:e.sourceBranch,env:e.releaseEnv,tagName:e.tagName,changelog:e.changelog})}}function yi(){if(li)return ci;li=1;var e=gt(),t=Mr(),r=Sr();return ci=function(n){return"string"==typeof n||!t(n)&&r(n)&&"[object String]"==e(n)}}var mi=Ye(yi());class wi{context;constructor(e){this.context=e}get repoInfo(){return this.context.getConfig("repoInfo")}async init(){const e=await this.getUserInfo();this.context.setConfig({repoInfo:e})}async getUserInfo(){let e;try{e=(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}catch(e){throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!e)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.verbose("repoUrl: ",e);const t=e.match(/github\.com[:/]([^/]+)\/([^/.]+)(?:\.git)?$/);if(!t)throw new Error("Invalid GitHub repository URL format. Please ensure the remote URL is from GitHub.");const[,r,n]=t;if(!this.isValidString(r)||!this.isValidString(n))throw new Error("Failed to extract owner or repository name from GitHub URL");return{repoName:n,authorName:r}}isValidString(e){return!!e&&mi(e)}}class Ri extends gi{context;releasePR;pluginName="create-release-pr";changelogManager;branchManager;pullRequestManager;releaseBase;constructor(e,t){super(e),this.context=e,this.releasePR=t,this.releaseBase=new wi(e),this.changelogManager=new vi(e),this.branchManager=new bi(e),this.pullRequestManager=new di(e,this.releaseBase,this.releasePR)}get githubToken(){return this.getConfig("githubToken")}async onBefore(){this.logger.verbose("CreateReleasePullRequest onBefore"),await this.releaseBase.init();const e=this.releaseBase.repoInfo;if(!e)throw new Error("repoInfo is not set");await this.releasePR.init({token:this.githubToken,repoName:e.repoName,authorName:e.authorName})}async onSuccess(){const e=await this.step({label:"Create Changelog and Version",task:()=>this.changelogManager.createChangelogAndVersion()}),{tagName:t,releaseBranch:r}=await this.step({label:"Create Release Branch",task:()=>this.branchManager.createReleaseBranch(e)}),n=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(t,r,e)});if(this.pullRequestManager.autoMergeReleasePR)return await this.step({label:`Merge Release PR(${n})`,task:()=>this.pullRequestManager.mergePR(n,r)}),void await this.step({label:`Checked Release PR(${n})`,task:()=>this.pullRequestManager.checkedPR(n,r)});this.logger.info(`Please manually merge PR(#${n}) and complete the publishing process afterwards`)}async createReleasePR(e,t,r){const n=this.changelogManager.getChangelogAndFeatures(r),o=[(await this.pullRequestManager.createReleasePRLabel()).name];return this.pullRequestManager.createReleasePR({tagName:e,releaseBranch:t,changelog:n,sourceBranch:this.branchManager.sourceBranch,releaseEnv:this.branchManager.releaseEnv,labels:o})}}class _i{options;octokit;constructor(e={}){this.options=e}async init({token:e,repoName:t,authorName:r}){if(this.octokit)return this.octokit;if(!e)throw new Error("Github token is not set");this.options.repoName=t,this.options.authorName=r;const{Octokit:n}=await import("@octokit/rest"),o=new n({auth:e});return this.octokit=o,o}getOctokit(){if(!this.octokit)throw new Error("Octokit is not initialized");return this.octokit}mergePullRequest(e){return this.getOctokit().rest.pulls.merge({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}getPullRequest(e){return this.getOctokit().rest.pulls.get({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}deleteBranch(e){return this.getOctokit().rest.git.deleteRef({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}addPullRequestLabels(e){return this.getOctokit().rest.issues.addLabels({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}async createPullRequestLabel(e){return await this.getOctokit().rest.issues.createLabel({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}async createPullRequest(e){const t=await this.getOctokit().rest.pulls.create({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""});return{...t.data,number:t.data.number}}}var Pi=Ye(pt());class xi extends gi{pluginName="publish-npm";_releaseItOutput;constructor(e){super(e),this.getIncrementVersion()}async onBefore(){this.logger.verbose("PublishNpm onBefore"),await this.checkNpmAuth()}async onSuccess(){const e=this.getPublishReleaseItOptions(this.context);await this.step({label:"Publish to NPM",task:()=>this.publish(e)})}async publish(e){this.logger.debug("Run release-it method",e);const t=this.getConfig("releaseIt");if(!t)throw new Error("releaseIt instance is not set");return this._releaseItOutput=await t(e),this._releaseItOutput}getPublishReleaseItOptions(e){return{ci:!0,npm:{publish:!0},git:{requireCleanWorkingDir:!1,requireUpstream:!1,changelog:!1},plugins:{"@release-it/conventional-changelog":{infile:!1}},"dry-run":e.dryRun,verbose:!0,increment:this.getIncrementVersion()}}getIncrementVersion(){const e=this.getConfig("packageJson");if(!Pi(e))throw new Error("package.json is undefined");if(!("version"in e))throw new Error("package.json version is required");return e.version}async checkNpmAuth(){const e=this.getEnv("NPM_TOKEN");if(!e)throw new Error("NPM_TOKEN is not set.");this.setConfig({npmToken:e}),await this.shell.exec(`echo //registry.npmjs.org/:_authToken=${e} > .npmrc`,{dryRun:!1})}}class Ei extends gi{pluginName="publish-path";constructor(e){super(e)}async onBefore(){this.logger.verbose("PublishPath onBefore"),this.checkPublishPath()}async checkPublishPath(){const e=this.getPublishPath();this.switchToPublishPath(e),this.logger.debug("Current path:",e)}switchToPublishPath(e){e&&We.existsSync(e)&&(this.logger.debug("Switching to publish path:",e),process.chdir(e))}getPublishPath(){const e=this.getConfig("publishPath");return"string"==typeof e?e:process.cwd()}}exports.Plugin=gi,exports.ReleaseContext=hi,exports.release=function(e){const t=new hi(e),r=new De.AsyncExecutor;return function(e){const t=[];return t.push(new pi(e,e.options.releaseIt)),e.options.pullRequest?t.push(new Ri(e,new _i)):t.push(new xi(e)),t.push(new Ei(e)),t}(t).forEach((e=>{r.use(e)})),r.exec(t,(({returnValue:e})=>Promise.resolve(e)))};
|
package/dist/es/index.d.ts
CHANGED
|
@@ -22,10 +22,6 @@ interface PullRequestInterface {
|
|
|
22
22
|
number: number;
|
|
23
23
|
[key: string]: unknown;
|
|
24
24
|
}>;
|
|
25
|
-
getUserInfo(): Promise<{
|
|
26
|
-
repoName: string;
|
|
27
|
-
authorName: string;
|
|
28
|
-
}>;
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
interface ExecutorReleaseContext extends ExecutorContext<ReleaseContext> {
|
|
@@ -78,6 +74,7 @@ declare class ReleaseContext extends FeScriptContext<ReleaseConfig> {
|
|
|
78
74
|
getConfig(key: string | string[], defaultValue?: unknown): unknown;
|
|
79
75
|
getInitEnv(): Env;
|
|
80
76
|
getEnv(): Env;
|
|
77
|
+
getPkg(key: string): unknown;
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
type StepOption<T> = {
|
package/dist/es/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-utils";import{existsSync as n}from"fs";var i,o,u,a,s,c,f,l,h,g,p,v,b,d,y,m,w,_,R,P,O,j,E,N,k,x,C,B,T,A,I,$,S,q,z,U,F,L,M,V,G,D,H,K,W,J,Y,Q,X,Z,tt,et,rt,nt,it,ot,ut,at,st,ct,ft,lt,ht,gt,pt,vt,bt,dt,yt,mt,wt,_t,Rt,Pt,Ot,jt,Et,Nt,kt,xt,Ct,Bt,Tt,At,It,$t,St,qt,zt,Ut,Ft,Lt,Mt,Vt,Gt,Dt,Ht,Kt,Wt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Jt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Yt(){if(o)return i;return o=1,i=function(){this.__data__=[],this.size=0}}function Qt(){if(a)return u;return a=1,u=function(t,e){return t===e||t!=t&&e!=e}}function Xt(){if(c)return s;c=1;var t=Qt();return s=function(e,r){for(var n=e.length;n--;)if(t(e[n][0],r))return n;return-1}}function Zt(){if(l)return f;l=1;var t=Xt(),e=Array.prototype.splice;return f=function(r){var n=this.__data__,i=t(n,r);return!(i<0)&&(i==n.length-1?n.pop():e.call(n,i,1),--this.size,!0)}}function te(){if(g)return h;g=1;var t=Xt();return h=function(e){var r=this.__data__,n=t(r,e);return n<0?void 0:r[n][1]}}function ee(){if(v)return p;v=1;var t=Xt();return p=function(e){return t(this.__data__,e)>-1}}function re(){if(d)return b;d=1;var t=Xt();return b=function(e,r){var n=this.__data__,i=t(n,e);return i<0?(++this.size,n.push([e,r])):n[i][1]=r,this}}function ne(){if(m)return y;m=1;var t=Yt(),e=Zt(),r=te(),n=ee(),i=re();function o(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 o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,y=o}function ie(){if(_)return w;_=1;var t=ne();return w=function(){this.__data__=new t,this.size=0}}function oe(){if(P)return R;return P=1,R=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}}function ue(){if(j)return O;return j=1,O=function(t){return this.__data__.get(t)}}function ae(){if(N)return E;return N=1,E=function(t){return this.__data__.has(t)}}function se(){if(x)return k;x=1;var t="object"==typeof Wt&&Wt&&Wt.Object===Object&&Wt;return k=t}function ce(){if(B)return C;B=1;var t=se(),e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return C=r}function fe(){if(A)return T;A=1;var t=ce().Symbol;return T=t}function le(){if($)return I;$=1;var t=fe(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,i=t?t.toStringTag:void 0;return I=function(t){var e=r.call(t,i),o=t[i];try{t[i]=void 0;var u=!0}catch(t){}var a=n.call(t);return u&&(e?t[i]=o:delete t[i]),a}}function he(){if(q)return S;q=1;var t=Object.prototype.toString;return S=function(e){return t.call(e)}}function ge(){if(U)return z;U=1;var t=fe(),e=le(),r=he(),n=t?t.toStringTag:void 0;return z=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):r(t)}}function pe(){if(L)return F;return L=1,F=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function ve(){if(V)return M;V=1;var t=ge(),e=pe();return M=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 be(){if(D)return G;D=1;var t=ce()["__core-js_shared__"];return G=t}function de(){if(K)return H;K=1;var t,e=be(),r=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return H=function(t){return!!r&&r in t}}function ye(){if(J)return W;J=1;var t=Function.prototype.toString;return W=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function me(){if(Q)return Y;Q=1;var t=ve(),e=de(),r=pe(),n=ye(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,u=Object.prototype,a=o.toString,s=u.hasOwnProperty,c=RegExp("^"+a.call(s).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return Y=function(o){return!(!r(o)||e(o))&&(t(o)?c:i).test(n(o))}}function we(){if(Z)return X;return Z=1,X=function(t,e){return null==t?void 0:t[e]}}function _e(){if(et)return tt;et=1;var t=me(),e=we();return tt=function(r,n){var i=e(r,n);return t(i)?i:void 0}}function Re(){if(nt)return rt;nt=1;var t=_e()(ce(),"Map");return rt=t}function Pe(){if(ot)return it;ot=1;var t=_e()(Object,"create");return it=t}function Oe(){if(at)return ut;at=1;var t=Pe();return ut=function(){this.__data__=t?t(null):{},this.size=0}}function je(){if(ct)return st;return ct=1,st=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}}function Ee(){if(lt)return ft;lt=1;var t=Pe(),e=Object.prototype.hasOwnProperty;return ft=function(r){var n=this.__data__;if(t){var i=n[r];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(n,r)?n[r]:void 0}}function Ne(){if(gt)return ht;gt=1;var t=Pe(),e=Object.prototype.hasOwnProperty;return ht=function(r){var n=this.__data__;return t?void 0!==n[r]:e.call(n,r)}}function ke(){if(vt)return pt;vt=1;var t=Pe();return pt=function(e,r){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===r?"__lodash_hash_undefined__":r,this}}function xe(){if(dt)return bt;dt=1;var t=Oe(),e=je(),r=Ee(),n=Ne(),i=ke();function o(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 o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,bt=o}function Ce(){if(mt)return yt;mt=1;var t=xe(),e=ne(),r=Re();return yt=function(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}}function Be(){if(_t)return wt;return _t=1,wt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}}function Te(){if(Pt)return Rt;Pt=1;var t=Be();return Rt=function(e,r){var n=e.__data__;return t(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Ae(){if(jt)return Ot;jt=1;var t=Te();return Ot=function(e){var r=t(this,e).delete(e);return this.size-=r?1:0,r}}function Ie(){if(Nt)return Et;Nt=1;var t=Te();return Et=function(e){return t(this,e).get(e)}}function $e(){if(xt)return kt;xt=1;var t=Te();return kt=function(e){return t(this,e).has(e)}}function Se(){if(Bt)return Ct;Bt=1;var t=Te();return Ct=function(e,r){var n=t(this,e),i=n.size;return n.set(e,r),this.size+=n.size==i?0:1,this}}function qe(){if(At)return Tt;At=1;var t=Ce(),e=Ae(),r=Ie(),n=$e(),i=Se();function o(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 o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=r,o.prototype.has=n,o.prototype.set=i,Tt=o}function ze(){if($t)return It;$t=1;var t=ne(),e=Re(),r=qe();return It=function(n,i){var o=this.__data__;if(o instanceof t){var u=o.__data__;if(!e||u.length<199)return u.push([n,i]),this.size=++o.size,this;o=this.__data__=new r(u)}return o.set(n,i),this.size=o.size,this}}function Ue(){if(qt)return St;qt=1;var t=ne(),e=ie(),r=oe(),n=ue(),i=ae(),o=ze();function u(e){var r=this.__data__=new t(e);this.size=r.size}return u.prototype.clear=e,u.prototype.delete=r,u.prototype.get=n,u.prototype.has=i,u.prototype.set=o,St=u}function Fe(){if(Ut)return zt;Ut=1;var t=_e(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return zt=e}function Le(){if(Lt)return Ft;Lt=1;var t=Fe();return Ft=function(e,r,n){"__proto__"==r&&t?t(e,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[r]=n}}function Me(){if(Vt)return Mt;Vt=1;var t=Le(),e=Qt();return Mt=function(r,n,i){(void 0!==i&&!e(r[n],i)||void 0===i&&!(n in r))&&t(r,n,i)}}function Ve(){if(Dt)return Gt;return Dt=1,Gt=function(t){return function(e,r,n){for(var i=-1,o=Object(e),u=n(e),a=u.length;a--;){var s=u[t?a:++i];if(!1===r(o[s],s,o))break}return e}}}function Ge(){if(Kt)return Ht;Kt=1;var t=Ve()();return Ht=t}var De,He,Ke,We,Je,Ye,Qe,Xe,Ze,tr,er,rr,nr,ir,or,ur,ar,sr,cr,fr,lr,hr,gr,pr,vr,br,dr,yr,mr,wr,_r,Rr,Pr,Or={exports:{}};function jr(){return De||(De=1,t=Or,e=Or.exports,r=ce(),n=e&&!e.nodeType&&e,i=n&&t&&!t.nodeType&&t,o=i&&i.exports===n?r.Buffer:void 0,u=o?o.allocUnsafe:void 0,t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=u?u(r):new t.constructor(r);return t.copy(n),n}),Or.exports;var t,e,r,n,i,o,u}function Er(){if(Ke)return He;Ke=1;var t=ce().Uint8Array;return He=t}function Nr(){if(Je)return We;Je=1;var t=Er();return We=function(e){var r=new e.constructor(e.byteLength);return new t(r).set(new t(e)),r}}function kr(){if(Qe)return Ye;Qe=1;var t=Nr();return Ye=function(e,r){var n=r?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}function xr(){if(Ze)return Xe;return Ze=1,Xe=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}}function Cr(){if(er)return tr;er=1;var t=pe(),e=Object.create,r=function(){function r(){}return function(n){if(!t(n))return{};if(e)return e(n);r.prototype=n;var i=new r;return r.prototype=void 0,i}}();return tr=r}function Br(){if(nr)return rr;return nr=1,rr=function(t,e){return function(r){return t(e(r))}}}function Tr(){if(or)return ir;or=1;var t=Br()(Object.getPrototypeOf,Object);return ir=t}function Ar(){if(ar)return ur;ar=1;var t=Object.prototype;return ur=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}}function Ir(){if(cr)return sr;cr=1;var t=Cr(),e=Tr(),r=Ar();return sr=function(n){return"function"!=typeof n.constructor||r(n)?{}:t(e(n))}}function $r(){if(lr)return fr;return lr=1,fr=function(t){return null!=t&&"object"==typeof t}}function Sr(){if(gr)return hr;gr=1;var t=ge(),e=$r();return hr=function(r){return e(r)&&"[object Arguments]"==t(r)}}function qr(){if(vr)return pr;vr=1;var t=Sr(),e=$r(),r=Object.prototype,n=r.hasOwnProperty,i=r.propertyIsEnumerable,o=t(function(){return arguments}())?t:function(t){return e(t)&&n.call(t,"callee")&&!i.call(t,"callee")};return pr=o}function zr(){if(dr)return br;dr=1;var t=Array.isArray;return br=t}function Ur(){if(mr)return yr;mr=1;return yr=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function Fr(){if(_r)return wr;_r=1;var t=ve(),e=Ur();return wr=function(r){return null!=r&&e(r.length)&&!t(r)}}function Lr(){if(Pr)return Rr;Pr=1;var t=Fr(),e=$r();return Rr=function(r){return e(r)&&t(r)}}var Mr,Vr,Gr,Dr,Hr,Kr,Wr,Jr,Yr,Qr={exports:{}};function Xr(){if(Vr)return Mr;return Vr=1,Mr=function(){return!1}}function Zr(){return Gr||(Gr=1,function(t,e){var r=ce(),n=Xr(),i=e&&!e.nodeType&&e,o=i&&t&&!t.nodeType&&t,u=o&&o.exports===i?r.Buffer:void 0,a=(u?u.isBuffer:void 0)||n;t.exports=a}(Qr,Qr.exports)),Qr.exports}function tn(){if(Hr)return Dr;Hr=1;var t=ge(),e=Tr(),r=$r(),n=Function.prototype,i=Object.prototype,o=n.toString,u=i.hasOwnProperty,a=o.call(Object);return Dr=function(n){if(!r(n)||"[object Object]"!=t(n))return!1;var i=e(n);if(null===i)return!0;var s=u.call(i,"constructor")&&i.constructor;return"function"==typeof s&&s instanceof s&&o.call(s)==a}}function en(){if(Wr)return Kr;Wr=1;var t=ge(),e=Ur(),r=$r(),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,Kr=function(i){return r(i)&&e(i.length)&&!!n[t(i)]}}function rn(){if(Yr)return Jr;return Yr=1,Jr=function(t){return function(e){return t(e)}}}var nn,on,un,an,sn,cn,fn,ln,hn,gn,pn,vn,bn,dn,yn,mn,wn,_n,Rn,Pn,On,jn,En,Nn,kn,xn,Cn,Bn,Tn,An,In,$n,Sn,qn,zn,Un,Fn,Ln,Mn,Vn,Gn,Dn,Hn,Kn,Wn,Jn,Yn,Qn,Xn,Zn={exports:{}};function ti(){return nn||(nn=1,t=Zn,e=Zn.exports,r=se(),n=e&&!e.nodeType&&e,i=n&&t&&!t.nodeType&&t,o=i&&i.exports===n&&r.process,u=function(){try{var t=i&&i.require&&i.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}(),t.exports=u),Zn.exports;var t,e,r,n,i,o,u}function ei(){if(un)return on;un=1;var t=en(),e=rn(),r=ti(),n=r&&r.isTypedArray,i=n?e(n):t;return on=i}function ri(){if(sn)return an;return sn=1,an=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function ni(){if(fn)return cn;fn=1;var t=Le(),e=Qt(),r=Object.prototype.hasOwnProperty;return cn=function(n,i,o){var u=n[i];r.call(n,i)&&e(u,o)&&(void 0!==o||i in n)||t(n,i,o)}}function ii(){if(hn)return ln;hn=1;var t=ni(),e=Le();return ln=function(r,n,i,o){var u=!i;i||(i={});for(var a=-1,s=n.length;++a<s;){var c=n[a],f=o?o(i[c],r[c],c,i,r):void 0;void 0===f&&(f=r[c]),u?e(i,c,f):t(i,c,f)}return i}}function oi(){if(pn)return gn;return pn=1,gn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}}function ui(){if(bn)return vn;bn=1;var t=/^(?:0|[1-9]\d*)$/;return vn=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 ai(){if(yn)return dn;yn=1;var t=oi(),e=qr(),r=zr(),n=Zr(),i=ui(),o=ei(),u=Object.prototype.hasOwnProperty;return dn=function(a,s){var c=r(a),f=!c&&e(a),l=!c&&!f&&n(a),h=!c&&!f&&!l&&o(a),g=c||f||l||h,p=g?t(a.length,String):[],v=p.length;for(var b in a)!s&&!u.call(a,b)||g&&("length"==b||l&&("offset"==b||"parent"==b)||h&&("buffer"==b||"byteLength"==b||"byteOffset"==b)||i(b,v))||p.push(b);return p}}function si(){if(wn)return mn;return wn=1,mn=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}}function ci(){if(Rn)return _n;Rn=1;var t=pe(),e=Ar(),r=si(),n=Object.prototype.hasOwnProperty;return _n=function(i){if(!t(i))return r(i);var o=e(i),u=[];for(var a in i)("constructor"!=a||!o&&n.call(i,a))&&u.push(a);return u}}function fi(){if(On)return Pn;On=1;var t=ai(),e=ci(),r=Fr();return Pn=function(n){return r(n)?t(n,!0):e(n)}}function li(){if(En)return jn;En=1;var t=ii(),e=fi();return jn=function(r){return t(r,e(r))}}function hi(){if(kn)return Nn;kn=1;var t=Me(),e=jr(),r=kr(),n=xr(),i=Ir(),o=qr(),u=zr(),a=Lr(),s=Zr(),c=ve(),f=pe(),l=tn(),h=ei(),g=ri(),p=li();return Nn=function(v,b,d,y,m,w,_){var R=g(v,d),P=g(b,d),O=_.get(P);if(O)t(v,d,O);else{var j=w?w(R,P,d+"",v,b,_):void 0,E=void 0===j;if(E){var N=u(P),k=!N&&s(P),x=!N&&!k&&h(P);j=P,N||k||x?u(R)?j=R:a(R)?j=n(R):k?(E=!1,j=e(P,!0)):x?(E=!1,j=r(P,!0)):j=[]:l(P)||o(P)?(j=R,o(R)?j=p(R):f(R)&&!c(R)||(j=i(P))):E=!1}E&&(_.set(P,j),m(j,P,y,w,_),_.delete(P)),t(v,d,j)}}}function gi(){if(Cn)return xn;Cn=1;var t=Ue(),e=Me(),r=Ge(),n=hi(),i=pe(),o=fi(),u=ri();return xn=function a(s,c,f,l,h){s!==c&&r(c,(function(r,o){if(h||(h=new t),i(r))n(s,c,o,f,a,l,h);else{var g=l?l(u(s,o),r,o+"",s,c,h):void 0;void 0===g&&(g=r),e(s,o,g)}}),o)},xn}function pi(){if(Tn)return Bn;return Tn=1,Bn=function(t){return t}}function vi(){if(In)return An;return In=1,An=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 bi(){if(Sn)return $n;Sn=1;var t=vi(),e=Math.max;return $n=function(r,n,i){return n=e(void 0===n?r.length-1:n,0),function(){for(var o=arguments,u=-1,a=e(o.length-n,0),s=Array(a);++u<a;)s[u]=o[n+u];u=-1;for(var c=Array(n+1);++u<n;)c[u]=o[u];return c[n]=i(s),t(r,this,c)}},$n}function di(){if(zn)return qn;return zn=1,qn=function(t){return function(){return t}}}function yi(){if(Fn)return Un;Fn=1;var t=di(),e=Fe();return Un=e?function(r,n){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:pi()}function mi(){if(Mn)return Ln;Mn=1;var t=Date.now;return Ln=function(e){var r=0,n=0;return function(){var i=t(),o=16-(i-n);if(n=i,o>0){if(++r>=800)return arguments[0]}else r=0;return e.apply(void 0,arguments)}},Ln}function wi(){if(Gn)return Vn;Gn=1;var t=yi(),e=mi()(t);return Vn=e}function _i(){if(Hn)return Dn;Hn=1;var t=pi(),e=bi(),r=wi();return Dn=function(n,i){return r(e(n,i,t),n+"")}}function Ri(){if(Wn)return Kn;Wn=1;var t=Qt(),e=Fr(),r=ui(),n=pe();return Kn=function(i,o,u){if(!n(u))return!1;var a=typeof o;return!!("number"==a?e(u)&&r(o,u.length):"string"==a&&o in u)&&t(u[o],i)}}function Pi(){if(Yn)return Jn;Yn=1;var t=_i(),e=Ri();return Jn=function(r){return t((function(t,n){var i=-1,o=n.length,u=o>1?n[o-1]:void 0,a=o>2?n[2]:void 0;for(u=r.length>3&&"function"==typeof u?(o--,u):void 0,a&&e(n[0],n[1],a)&&(u=o<3?void 0:u,o=1),t=Object(t);++i<o;){var s=n[i];s&&r(t,s,i,u)}return t}))}}function Oi(){if(Xn)return Qn;Xn=1;var t=gi(),e=Pi()((function(e,r,n){t(e,r,n)}));return Qn=e}var ji,Ei,Ni,ki,xi,Ci,Bi,Ti,Ai,Ii,$i,Si,qi,zi,Ui,Fi,Li,Mi,Vi,Gi,Di,Hi,Ki,Wi,Ji=Jt(Oi());function Yi(){if(Ei)return ji;Ei=1;var t=ge(),e=$r();return ji=function(r){return"symbol"==typeof r||e(r)&&"[object Symbol]"==t(r)}}function Qi(){if(ki)return Ni;ki=1;var t=zr(),e=Yi(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return Ni=function(i,o){if(t(i))return!1;var u=typeof i;return!("number"!=u&&"symbol"!=u&&"boolean"!=u&&null!=i&&!e(i))||(n.test(i)||!r.test(i)||null!=o&&i in Object(o))}}function Xi(){if(Ci)return xi;Ci=1;var t=qe();function e(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=n?n.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var u=r.apply(this,t);return i.cache=o.set(e,u)||o,u};return i.cache=new(e.Cache||t),i}return e.Cache=t,xi=e}function Zi(){if(Ti)return Bi;Ti=1;var t=Xi();return Bi=function(e){var r=t(e,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}}function to(){if(Ii)return Ai;Ii=1;var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,e=/\\(\\)?/g,r=Zi()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(t,(function(t,r,i,o){n.push(i?o.replace(e,"$1"):r||t)})),n}));return Ai=r}function eo(){if(Si)return $i;return Si=1,$i=function(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}}function ro(){if(zi)return qi;zi=1;var t=fe(),e=eo(),r=zr(),n=Yi(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return qi=function t(i){if("string"==typeof i)return i;if(r(i))return e(i,t)+"";if(n(i))return o?o.call(i):"";var u=i+"";return"0"==u&&1/i==-1/0?"-0":u},qi}function no(){if(Fi)return Ui;Fi=1;var t=ro();return Ui=function(e){return null==e?"":t(e)}}function io(){if(Mi)return Li;Mi=1;var t=zr(),e=Qi(),r=to(),n=no();return Li=function(i,o){return t(i)?i:e(i,o)?[i]:r(n(i))}}function oo(){if(Gi)return Vi;Gi=1;var t=Yi();return Vi=function(e){if("string"==typeof e||t(e))return e;var r=e+"";return"0"==r&&1/e==-1/0?"-0":r}}function uo(){if(Hi)return Di;Hi=1;var t=io(),e=oo();return Di=function(r,n){for(var i=0,o=(n=t(n,r)).length;null!=r&&i<o;)r=r[e(n[i++])];return i&&i==o?r:void 0}}function ao(){if(Wi)return Ki;Wi=1;var t=uo();return Ki=function(e,r,n){var i=null==e?void 0:t(e,r);return void 0===i?n:i}}var so,co,fo=Jt(ao());class lo extends t{env;config;constructor(t){super(t),this.config=Ji({},this.feConfig.release,this.options),this.env=this.getInitEnv()}setConfig(t){this.config=Ji(this.config,t)}getConfig(t,e){return fo(this.config,t,e)}getInitEnv(){return e.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder})}getEnv(){return this.env}}class ho{context;onlyOne=!0;constructor(t){this.context=t}get logger(){return this.context.logger}get shell(){return this.context.shell}getEnv(t,e){return this.context.getEnv().get(t)??e}enabled(){return!0}getConfig(t,e){return this.context.getConfig(t,e)}setConfig(t){this.context.setConfig(t)}onBefore(t){}onSuccess(t){}onError(t){}async step({label:t,task:e}){this.logger.obtrusive(t);try{const r=await e();return this.logger.info(`${t} - success`),r}catch(t){throw this.logger.error(t),t}}}class go extends ho{pluginName="check-environment";constructor(t,e){if(super(t),!e)throw new Error("releaseIt is not required");this.hasReleaseIt(),this.hasGithubToken()}hasReleaseIt(){if("false"===this.getEnv("FE_RELEASE"))throw new Error("Skip Release");return!0}hasGithubToken(){const t=this.getEnv("GITHUB_TOKEN")||this.getEnv("PAT_TOKEN");if(!t)throw new Error("GITHUB_TOKEN or PAT_TOKEN environment variable is not set.");return this.setConfig({githubToken:t}),!0}onBefore(t){this.logger.verbose("CheckEnvironment onBefore")}}class po extends ho{releasePR;pluginName="create-release-pr";packageJson={};repoInfo;sourceBranch;get autoMergeReleasePR(){return this.getConfig("autoMergeReleasePR",!1)}dryRunPRNumber="999999";get releaseEnv(){return this.getConfig("releaseEnv")??this.getEnv("NODE_ENV")??"development"}constructor(t,e){super(t),this.releasePR=e,this.sourceBranch=this.getEnv("FE_RELEASE_BRANCH")??this.getEnv("FE_RELEASE_SOURCE_BRANCH")??"master"}async onBefore(){this.logger.verbose("CreateReleasePullRequest onBefore"),this.repoInfo=await this.releasePR.getUserInfo();const t=this.getConfig("githubToken");await this.releasePR.init({token:t}),this.packageJson=this.getConfig("packageJson")}async onSuccess(){const t=await this.step({label:"Create Changelog and Version",task:()=>this.createChangelogAndVersion()}),{tagName:e,releaseBranch:r}=await this.step({label:"Create Release Branch",task:()=>this.createReleaseBranch(t)}),n=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(e,r,t)});if(this.autoMergeReleasePR)return await this.step({label:`Merge Release PR(${n})`,task:()=>this.autoMergePR(n,r)}),void await this.step({label:`Checked Release PR(${n})`,task:()=>this.checkedPullRequest(n,r)});this.logger.info(`Please manually merge PR(#${n}) and complete the publishing process afterwards`)}async autoMergePR(t,e){if(!t)return void this.logger.error("Failed to create Pull Request.",t);const r=this.getConfig("autoMergeType","squash");if(this.context.dryRun){const{repoName:n,authorName:i}=this.getRepoInfo();this.logger.info(`[DRY RUN] Would merge PR #${t} with method '${r}' in repo ${i}/${n}, branch ${e}`)}else await this.releasePR.mergePullRequest({pull_number:Number(t),merge_method:r})}async checkedPullRequest(t,e){try{await this.releasePR.getPullRequest({pull_number:Number(t)}),await this.releasePR.deleteBranch({ref:`heads/${e}`}),this.logger.info(`Branch ${e} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${t} or branch ${e} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleaseBranch(t){const{tagName:e}=await this.checkTag(t),r=this.getReleaseBranch(e);return this.logger.verbose("PR SourceBranch is:",this.sourceBranch),this.logger.verbose("PR TargetBranch is:",r),await this.shell.exec(`git fetch origin ${this.sourceBranch}`),await this.shell.exec(`git merge origin/${this.sourceBranch}`),await this.shell.exec(`git checkout -b ${r}`),await this.shell.exec(`git push origin ${r}`),{tagName:e,releaseBranch:r}}getPkg(t){return fo(this.packageJson,t)}createChangelogAndVersion(){const t=this.getConfig("releaseIt");if(!t)throw new Error("releaseIt instance is not set");return t(this.getReleaseItChangelogOptions())}getReleaseItChangelogOptions(){return{ci:!0,increment:"patch",npm:{publish:!1},git:{requireCleanWorkingDir:!1,tag:!1,push:!1},github:{release:!1},verbose:!0,"dry-run":this.context.dryRun}}async checkTag(t){const e=fo(t,"version")||this.getPkg("version");if("string"!=typeof e)throw new Error("Tag name is not a string");return this.logger.verbose("Created Tag is:",e),{tagName:e}}getReleaseBranch(t){const e=this.getConfig("branchName","release-${tagName}");if("string"!=typeof e)throw new Error("Branch name template is not a string");return this.logger.verbose("Release Branch template is:",e),this.shell.format(e,{env:this.releaseEnv,branch:this.sourceBranch,tagName:t})}async createReleasePR(t,e,r){const n=this.getChangelogAndFeatures(r),i=await this.createReleasePRLabel();return this.getReleasePullRequest({tagName:t,releaseBranch:e,changelog:n,label:i})}async createReleasePRLabel(){const t=this.getConfig("label");if(!(t&&t.name&&t.description&&t.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",t),t;try{const e=await this.releasePR.createPullRequestLabel({name:t.name,description:t.description,color:t.color.replace("#","")});return this.logger.debug("Create PR label Success",e),t}catch(e){if(422===e.status)return this.logger.warn(`Label ${t.name} already exists, skipping!`),t;throw this.logger.error("Create PR label Failed",e),e}}getChangelogAndFeatures(t){return t||this.logger.warn("No release-it output found, changelog might be incomplete"),fo(t,"changelog","No changelog")}async getReleasePullRequest(t){const e=this.getCreateReleasePROptions(t.tagName,t.releaseBranch,t.changelog);if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...e,labels:[t.label?.name]}),this.dryRunPRNumber;try{const r=await this.releasePR.createPullRequest(e),n=r.number;if(!n)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",r),t.label?.name){const e=await this.releasePR.addPullRequestLabels({issue_number:n,labels:[t.label.name]});this.logger.debug("Add PR label Success",e)}return n.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}}getCreateReleasePROptions(t,e,r){return{title:this.getReleasePRTitle(t),body:this.getReleasePRBody({tagName:t,changelog:r}),base:this.sourceBranch,head:e}}getReleasePRTitle(t){const e=this.getConfig("PRTitle","Release ${env} ${pkgName} ${tagName}");return this.shell.format(e,{env:this.releaseEnv,branch:this.sourceBranch,tagName:t,pkgName:this.getPkg("name")})}getReleasePRBody({tagName:t,changelog:e}){const r=this.getConfig("PRBody","");return this.shell.format(r,{branch:this.sourceBranch,env:this.releaseEnv,tagName:t,changelog:e})}getRepoInfo(){if(!this.repoInfo)throw new Error("Repository information not initialized");return this.repoInfo}}function vo(){if(co)return so;co=1;var t=ge(),e=zr(),r=$r();return so=function(n){return"string"==typeof n||!e(n)&&r(n)&&"[object String]"==t(n)}}var bo=Jt(vo());class yo{context;options;octokit;constructor(t,e={}){this.context=t,this.options=e}async init({token:t}){if(this.octokit)return this.octokit;if(!t)throw new Error("Github token is not set");const{repoName:e,authorName:r}=await this.getUserInfo();this.options.repoName=e,this.options.authorName=r;const{Octokit:n}=await import("@octokit/rest"),i=new n({auth:t});return this.octokit=i,i}getOctokit(){if(!this.octokit)throw new Error("Octokit is not initialized");return this.octokit}mergePullRequest(t){return this.getOctokit().rest.pulls.merge({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}getPullRequest(t){return this.getOctokit().rest.pulls.get({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}deleteBranch(t){return this.getOctokit().rest.git.deleteRef({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}addPullRequestLabels(t){return this.getOctokit().rest.issues.addLabels({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}async createPullRequestLabel(t){return await this.getOctokit().rest.issues.createLabel({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""})}async createPullRequest(t){const e=await this.getOctokit().rest.pulls.create({...t,owner:t.owner||this.options.authorName||"",repo:t.repo||this.options.repoName||""});return{...e.data,number:e.data.number}}async getUserInfo(){let t;try{t=(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}catch(t){throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!t)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.verbose("repoUrl: ",t);const e=t.match(/github\.com[:/]([^/]+)\/([^/.]+)(?:\.git)?$/);if(!e)throw new Error("Invalid GitHub repository URL format. Please ensure the remote URL is from GitHub.");const[,r,n]=e;if(!this.isValidString(r)||!this.isValidString(n))throw new Error("Failed to extract owner or repository name from GitHub URL");return{repoName:n,authorName:r}}isValidString(t){return!!t&&bo(t)}}var mo=Jt(pe());class wo extends ho{pluginName="publish-npm";_releaseItOutput;constructor(t){super(t),this.getIncrementVersion()}async onBefore(){this.logger.verbose("PublishNpm onBefore"),await this.checkNpmAuth()}async onSuccess(){const t=this.getPublishReleaseItOptions(this.context);await this.step({label:"Publish to NPM",task:()=>this.publish(t)})}async publish(t){this.logger.debug("Run release-it method",t);const e=this.getConfig("releaseIt");if(!e)throw new Error("releaseIt instance is not set");return this._releaseItOutput=await e(t),this._releaseItOutput}getPublishReleaseItOptions(t){return{ci:!0,npm:{publish:!0},git:{requireCleanWorkingDir:!1,requireUpstream:!1,changelog:!1},plugins:{"@release-it/conventional-changelog":{infile:!1}},"dry-run":t.dryRun,verbose:!0,increment:this.getIncrementVersion()}}getIncrementVersion(){const t=this.getConfig("packageJson");if(!mo(t))throw new Error("package.json is undefined");if(!("version"in t))throw new Error("package.json version is required");return t.version}async checkNpmAuth(){const t=this.getEnv("NPM_TOKEN");if(!t)throw new Error("NPM_TOKEN is not set.");this.setConfig({npmToken:t}),await this.shell.exec(`echo "//registry.npmjs.org/:_authToken=${t}" > .npmrc`)}}class _o extends ho{pluginName="publish-path";constructor(t){super(t),this.checkPublishPath()}async onBefore(){this.logger.verbose("PublishPath onBefore")}async checkPublishPath(){const t=this.getPublishPath();this.switchToPublishPath(t),this.logger.debug("Current path:",t)}switchToPublishPath(t){t&&n(t)&&(this.logger.debug("Switching to publish path:",t),process.chdir(t))}getPublishPath(){const t=this.getConfig("publishPath");return"string"==typeof t?t:process.cwd()}}function Ro(t){const e=new lo(t),n=new r;return function(t){const e=[];return e.push(new go(t,t.options.releaseIt)),t.options.pullRequest?e.push(new po(t,new yo(t))):e.push(new wo(t)),e.push(new _o(t)),e}(e).forEach((t=>{n.use(t)})),n.exec(e,(({returnValue:t})=>Promise.resolve(t)))}export{ho as Plugin,lo as ReleaseContext,Ro as release};
|
|
1
|
+
import{FeScriptContext as e}from"@qlover/scripts-context";import{Env as t}from"@qlover/env-loader";import{AsyncExecutor as r}from"@qlover/fe-utils";import{existsSync as n}from"fs";var o,i,u,a,s,c,f,l,h,g,p,v,b,d,y,m,w,R,_,P,x,E,N,O,j,k,C,B,T,A,I,S,$,q,M,F,L,U,z,V,G,H,D,W,K,Y,J,Q,X,Z,ee,te,re,ne,oe,ie,ue,ae,se,ce,fe,le,he,ge,pe,ve,be,de,ye,me,we,Re,_e,Pe,xe,Ee,Ne,Oe,je,ke,Ce,Be,Te,Ae,Ie,Se,$e,qe,Me,Fe,Le,Ue,ze,Ve,Ge,He,De,We,Ke="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ye(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Je(){if(i)return o;return i=1,o=function(){this.__data__=[],this.size=0}}function Qe(){if(a)return u;return a=1,u=function(e,t){return e===t||e!=e&&t!=t}}function Xe(){if(c)return s;c=1;var e=Qe();return s=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function Ze(){if(l)return f;l=1;var e=Xe(),t=Array.prototype.splice;return f=function(r){var n=this.__data__,o=e(n,r);return!(o<0)&&(o==n.length-1?n.pop():t.call(n,o,1),--this.size,!0)}}function et(){if(g)return h;g=1;var e=Xe();return h=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}function tt(){if(v)return p;v=1;var e=Xe();return p=function(t){return e(this.__data__,t)>-1}}function rt(){if(d)return b;d=1;var e=Xe();return b=function(t,r){var n=this.__data__,o=e(n,t);return o<0?(++this.size,n.push([t,r])):n[o][1]=r,this}}function nt(){if(m)return y;m=1;var e=Je(),t=Ze(),r=et(),n=tt(),o=rt();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,y=i}function ot(){if(R)return w;R=1;var e=nt();return w=function(){this.__data__=new e,this.size=0}}function it(){if(P)return _;return P=1,_=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}}function ut(){if(E)return x;return E=1,x=function(e){return this.__data__.get(e)}}function at(){if(O)return N;return O=1,N=function(e){return this.__data__.has(e)}}function st(){if(k)return j;k=1;var e="object"==typeof Ke&&Ke&&Ke.Object===Object&&Ke;return j=e}function ct(){if(B)return C;B=1;var e=st(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return C=r}function ft(){if(A)return T;A=1;var e=ct().Symbol;return T=e}function lt(){if(S)return I;S=1;var e=ft(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,o=e?e.toStringTag:void 0;return I=function(e){var t=r.call(e,o),i=e[o];try{e[o]=void 0;var u=!0}catch(e){}var a=n.call(e);return u&&(t?e[o]=i:delete e[o]),a}}function ht(){if(q)return $;q=1;var e=Object.prototype.toString;return $=function(t){return e.call(t)}}function gt(){if(F)return M;F=1;var e=ft(),t=lt(),r=ht(),n=e?e.toStringTag:void 0;return M=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):r(e)}}function pt(){if(U)return L;return U=1,L=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function vt(){if(V)return z;V=1;var e=gt(),t=pt();return z=function(r){if(!t(r))return!1;var n=e(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function bt(){if(H)return G;H=1;var e=ct()["__core-js_shared__"];return G=e}function dt(){if(W)return D;W=1;var e,t=bt(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return D=function(e){return!!r&&r in e}}function yt(){if(Y)return K;Y=1;var e=Function.prototype.toString;return K=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}function mt(){if(Q)return J;Q=1;var e=vt(),t=dt(),r=pt(),n=yt(),o=/^\[object .+?Constructor\]$/,i=Function.prototype,u=Object.prototype,a=i.toString,s=u.hasOwnProperty,c=RegExp("^"+a.call(s).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return J=function(i){return!(!r(i)||t(i))&&(e(i)?c:o).test(n(i))}}function wt(){if(Z)return X;return Z=1,X=function(e,t){return null==e?void 0:e[t]}}function Rt(){if(te)return ee;te=1;var e=mt(),t=wt();return ee=function(r,n){var o=t(r,n);return e(o)?o:void 0}}function _t(){if(ne)return re;ne=1;var e=Rt()(ct(),"Map");return re=e}function Pt(){if(ie)return oe;ie=1;var e=Rt()(Object,"create");return oe=e}function xt(){if(ae)return ue;ae=1;var e=Pt();return ue=function(){this.__data__=e?e(null):{},this.size=0}}function Et(){if(ce)return se;return ce=1,se=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}}function Nt(){if(le)return fe;le=1;var e=Pt(),t=Object.prototype.hasOwnProperty;return fe=function(r){var n=this.__data__;if(e){var o=n[r];return"__lodash_hash_undefined__"===o?void 0:o}return t.call(n,r)?n[r]:void 0}}function Ot(){if(ge)return he;ge=1;var e=Pt(),t=Object.prototype.hasOwnProperty;return he=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}function jt(){if(ve)return pe;ve=1;var e=Pt();return pe=function(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===r?"__lodash_hash_undefined__":r,this}}function kt(){if(de)return be;de=1;var e=xt(),t=Et(),r=Nt(),n=Ot(),o=jt();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,be=i}function Ct(){if(me)return ye;me=1;var e=kt(),t=nt(),r=_t();return ye=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}function Bt(){if(Re)return we;return Re=1,we=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}}function Tt(){if(Pe)return _e;Pe=1;var e=Bt();return _e=function(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function At(){if(Ee)return xe;Ee=1;var e=Tt();return xe=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}function It(){if(Oe)return Ne;Oe=1;var e=Tt();return Ne=function(t){return e(this,t).get(t)}}function St(){if(ke)return je;ke=1;var e=Tt();return je=function(t){return e(this,t).has(t)}}function $t(){if(Be)return Ce;Be=1;var e=Tt();return Ce=function(t,r){var n=e(this,t),o=n.size;return n.set(t,r),this.size+=n.size==o?0:1,this}}function qt(){if(Ae)return Te;Ae=1;var e=Ct(),t=At(),r=It(),n=St(),o=$t();function i(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Te=i}function Mt(){if(Se)return Ie;Se=1;var e=nt(),t=_t(),r=qt();return Ie=function(n,o){var i=this.__data__;if(i instanceof e){var u=i.__data__;if(!t||u.length<199)return u.push([n,o]),this.size=++i.size,this;i=this.__data__=new r(u)}return i.set(n,o),this.size=i.size,this}}function Ft(){if(qe)return $e;qe=1;var e=nt(),t=ot(),r=it(),n=ut(),o=at(),i=Mt();function u(t){var r=this.__data__=new e(t);this.size=r.size}return u.prototype.clear=t,u.prototype.delete=r,u.prototype.get=n,u.prototype.has=o,u.prototype.set=i,$e=u}function Lt(){if(Fe)return Me;Fe=1;var e=Rt(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return Me=t}function Ut(){if(Ue)return Le;Ue=1;var e=Lt();return Le=function(t,r,n){"__proto__"==r&&e?e(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}}function zt(){if(Ve)return ze;Ve=1;var e=Ut(),t=Qe();return ze=function(r,n,o){(void 0!==o&&!t(r[n],o)||void 0===o&&!(n in r))&&e(r,n,o)}}function Vt(){if(He)return Ge;return He=1,Ge=function(e){return function(t,r,n){for(var o=-1,i=Object(t),u=n(t),a=u.length;a--;){var s=u[e?a:++o];if(!1===r(i[s],s,i))break}return t}}}function Gt(){if(We)return De;We=1;var e=Vt()();return De=e}var Ht,Dt,Wt,Kt,Yt,Jt,Qt,Xt,Zt,er,tr,rr,nr,or,ir,ur,ar,sr,cr,fr,lr,hr,gr,pr,vr,br,dr,yr,mr,wr,Rr,_r,Pr,xr={exports:{}};function Er(){return Ht||(Ht=1,e=xr,t=xr.exports,r=ct(),n=t&&!t.nodeType&&t,o=n&&e&&!e.nodeType&&e,i=o&&o.exports===n?r.Buffer:void 0,u=i?i.allocUnsafe:void 0,e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=u?u(r):new e.constructor(r);return e.copy(n),n}),xr.exports;var e,t,r,n,o,i,u}function Nr(){if(Wt)return Dt;Wt=1;var e=ct().Uint8Array;return Dt=e}function Or(){if(Yt)return Kt;Yt=1;var e=Nr();return Kt=function(t){var r=new t.constructor(t.byteLength);return new e(r).set(new e(t)),r}}function jr(){if(Qt)return Jt;Qt=1;var e=Or();return Jt=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}function kr(){if(Zt)return Xt;return Zt=1,Xt=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}}function Cr(){if(tr)return er;tr=1;var e=pt(),t=Object.create,r=function(){function r(){}return function(n){if(!e(n))return{};if(t)return t(n);r.prototype=n;var o=new r;return r.prototype=void 0,o}}();return er=r}function Br(){if(nr)return rr;return nr=1,rr=function(e,t){return function(r){return e(t(r))}}}function Tr(){if(ir)return or;ir=1;var e=Br()(Object.getPrototypeOf,Object);return or=e}function Ar(){if(ar)return ur;ar=1;var e=Object.prototype;return ur=function(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}}function Ir(){if(cr)return sr;cr=1;var e=Cr(),t=Tr(),r=Ar();return sr=function(n){return"function"!=typeof n.constructor||r(n)?{}:e(t(n))}}function Sr(){if(lr)return fr;return lr=1,fr=function(e){return null!=e&&"object"==typeof e}}function $r(){if(gr)return hr;gr=1;var e=gt(),t=Sr();return hr=function(r){return t(r)&&"[object Arguments]"==e(r)}}function qr(){if(vr)return pr;vr=1;var e=$r(),t=Sr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=e(function(){return arguments}())?e:function(e){return t(e)&&n.call(e,"callee")&&!o.call(e,"callee")};return pr=i}function Mr(){if(dr)return br;dr=1;var e=Array.isArray;return br=e}function Fr(){if(mr)return yr;mr=1;return yr=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function Lr(){if(Rr)return wr;Rr=1;var e=vt(),t=Fr();return wr=function(r){return null!=r&&t(r.length)&&!e(r)}}function Ur(){if(Pr)return _r;Pr=1;var e=Lr(),t=Sr();return _r=function(r){return t(r)&&e(r)}}var zr,Vr,Gr,Hr,Dr,Wr,Kr,Yr,Jr,Qr={exports:{}};function Xr(){if(Vr)return zr;return Vr=1,zr=function(){return!1}}function Zr(){return Gr||(Gr=1,function(e,t){var r=ct(),n=Xr(),o=t&&!t.nodeType&&t,i=o&&e&&!e.nodeType&&e,u=i&&i.exports===o?r.Buffer:void 0,a=(u?u.isBuffer:void 0)||n;e.exports=a}(Qr,Qr.exports)),Qr.exports}function en(){if(Dr)return Hr;Dr=1;var e=gt(),t=Tr(),r=Sr(),n=Function.prototype,o=Object.prototype,i=n.toString,u=o.hasOwnProperty,a=i.call(Object);return Hr=function(n){if(!r(n)||"[object Object]"!=e(n))return!1;var o=t(n);if(null===o)return!0;var s=u.call(o,"constructor")&&o.constructor;return"function"==typeof s&&s instanceof s&&i.call(s)==a}}function tn(){if(Kr)return Wr;Kr=1;var e=gt(),t=Fr(),r=Sr(),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,Wr=function(o){return r(o)&&t(o.length)&&!!n[e(o)]}}function rn(){if(Jr)return Yr;return Jr=1,Yr=function(e){return function(t){return e(t)}}}var nn,on,un,an,sn,cn,fn,ln,hn,gn,pn,vn,bn,dn,yn,mn,wn,Rn,_n,Pn,xn,En,Nn,On,jn,kn,Cn,Bn,Tn,An,In,Sn,$n,qn,Mn,Fn,Ln,Un,zn,Vn,Gn,Hn,Dn,Wn,Kn,Yn,Jn,Qn,Xn,Zn={exports:{}};function eo(){return nn||(nn=1,e=Zn,t=Zn.exports,r=st(),n=t&&!t.nodeType&&t,o=n&&e&&!e.nodeType&&e,i=o&&o.exports===n&&r.process,u=function(){try{var e=o&&o.require&&o.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}(),e.exports=u),Zn.exports;var e,t,r,n,o,i,u}function to(){if(un)return on;un=1;var e=tn(),t=rn(),r=eo(),n=r&&r.isTypedArray,o=n?t(n):e;return on=o}function ro(){if(sn)return an;return sn=1,an=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function no(){if(fn)return cn;fn=1;var e=Ut(),t=Qe(),r=Object.prototype.hasOwnProperty;return cn=function(n,o,i){var u=n[o];r.call(n,o)&&t(u,i)&&(void 0!==i||o in n)||e(n,o,i)}}function oo(){if(hn)return ln;hn=1;var e=no(),t=Ut();return ln=function(r,n,o,i){var u=!o;o||(o={});for(var a=-1,s=n.length;++a<s;){var c=n[a],f=i?i(o[c],r[c],c,o,r):void 0;void 0===f&&(f=r[c]),u?t(o,c,f):e(o,c,f)}return o}}function io(){if(pn)return gn;return pn=1,gn=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}}function uo(){if(bn)return vn;bn=1;var e=/^(?:0|[1-9]\d*)$/;return vn=function(t,r){var n=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<r}}function ao(){if(yn)return dn;yn=1;var e=io(),t=qr(),r=Mr(),n=Zr(),o=uo(),i=to(),u=Object.prototype.hasOwnProperty;return dn=function(a,s){var c=r(a),f=!c&&t(a),l=!c&&!f&&n(a),h=!c&&!f&&!l&&i(a),g=c||f||l||h,p=g?e(a.length,String):[],v=p.length;for(var b in a)!s&&!u.call(a,b)||g&&("length"==b||l&&("offset"==b||"parent"==b)||h&&("buffer"==b||"byteLength"==b||"byteOffset"==b)||o(b,v))||p.push(b);return p}}function so(){if(wn)return mn;return wn=1,mn=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}}function co(){if(_n)return Rn;_n=1;var e=pt(),t=Ar(),r=so(),n=Object.prototype.hasOwnProperty;return Rn=function(o){if(!e(o))return r(o);var i=t(o),u=[];for(var a in o)("constructor"!=a||!i&&n.call(o,a))&&u.push(a);return u}}function fo(){if(xn)return Pn;xn=1;var e=ao(),t=co(),r=Lr();return Pn=function(n){return r(n)?e(n,!0):t(n)}}function lo(){if(Nn)return En;Nn=1;var e=oo(),t=fo();return En=function(r){return e(r,t(r))}}function ho(){if(jn)return On;jn=1;var e=zt(),t=Er(),r=jr(),n=kr(),o=Ir(),i=qr(),u=Mr(),a=Ur(),s=Zr(),c=vt(),f=pt(),l=en(),h=to(),g=ro(),p=lo();return On=function(v,b,d,y,m,w,R){var _=g(v,d),P=g(b,d),x=R.get(P);if(x)e(v,d,x);else{var E=w?w(_,P,d+"",v,b,R):void 0,N=void 0===E;if(N){var O=u(P),j=!O&&s(P),k=!O&&!j&&h(P);E=P,O||j||k?u(_)?E=_:a(_)?E=n(_):j?(N=!1,E=t(P,!0)):k?(N=!1,E=r(P,!0)):E=[]:l(P)||i(P)?(E=_,i(_)?E=p(_):f(_)&&!c(_)||(E=o(P))):N=!1}N&&(R.set(P,E),m(E,P,y,w,R),R.delete(P)),e(v,d,E)}}}function go(){if(Cn)return kn;Cn=1;var e=Ft(),t=zt(),r=Gt(),n=ho(),o=pt(),i=fo(),u=ro();return kn=function a(s,c,f,l,h){s!==c&&r(c,(function(r,i){if(h||(h=new e),o(r))n(s,c,i,f,a,l,h);else{var g=l?l(u(s,i),r,i+"",s,c,h):void 0;void 0===g&&(g=r),t(s,i,g)}}),i)},kn}function po(){if(Tn)return Bn;return Tn=1,Bn=function(e){return e}}function vo(){if(In)return An;return In=1,An=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}}function bo(){if($n)return Sn;$n=1;var e=vo(),t=Math.max;return Sn=function(r,n,o){return n=t(void 0===n?r.length-1:n,0),function(){for(var i=arguments,u=-1,a=t(i.length-n,0),s=Array(a);++u<a;)s[u]=i[n+u];u=-1;for(var c=Array(n+1);++u<n;)c[u]=i[u];return c[n]=o(s),e(r,this,c)}},Sn}function yo(){if(Mn)return qn;return Mn=1,qn=function(e){return function(){return e}}}function mo(){if(Ln)return Fn;Ln=1;var e=yo(),t=Lt();return Fn=t?function(r,n){return t(r,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:po()}function wo(){if(zn)return Un;zn=1;var e=Date.now;return Un=function(t){var r=0,n=0;return function(){var o=e(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}},Un}function Ro(){if(Gn)return Vn;Gn=1;var e=mo(),t=wo()(e);return Vn=t}function _o(){if(Dn)return Hn;Dn=1;var e=po(),t=bo(),r=Ro();return Hn=function(n,o){return r(t(n,o,e),n+"")}}function Po(){if(Kn)return Wn;Kn=1;var e=Qe(),t=Lr(),r=uo(),n=pt();return Wn=function(o,i,u){if(!n(u))return!1;var a=typeof i;return!!("number"==a?t(u)&&r(i,u.length):"string"==a&&i in u)&&e(u[i],o)}}function xo(){if(Jn)return Yn;Jn=1;var e=_o(),t=Po();return Yn=function(r){return e((function(e,n){var o=-1,i=n.length,u=i>1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(u=r.length>3&&"function"==typeof u?(i--,u):void 0,a&&t(n[0],n[1],a)&&(u=i<3?void 0:u,i=1),e=Object(e);++o<i;){var s=n[o];s&&r(e,s,o,u)}return e}))}}function Eo(){if(Xn)return Qn;Xn=1;var e=go(),t=xo()((function(t,r,n){e(t,r,n)}));return Qn=t}var No,Oo,jo,ko,Co,Bo,To,Ao,Io,So,$o,qo,Mo,Fo,Lo,Uo,zo,Vo,Go,Ho,Do,Wo,Ko,Yo,Jo=Ye(Eo());function Qo(){if(Oo)return No;Oo=1;var e=gt(),t=Sr();return No=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function Xo(){if(ko)return jo;ko=1;var e=Mr(),t=Qo(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return jo=function(o,i){if(e(o))return!1;var u=typeof o;return!("number"!=u&&"symbol"!=u&&"boolean"!=u&&null!=o&&!t(o))||(n.test(o)||!r.test(o)||null!=i&&o in Object(i))}}function Zo(){if(Bo)return Co;Bo=1;var e=qt();function t(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var o=function(){var e=arguments,t=n?n.apply(this,e):e[0],i=o.cache;if(i.has(t))return i.get(t);var u=r.apply(this,e);return o.cache=i.set(t,u)||i,u};return o.cache=new(t.Cache||e),o}return t.Cache=e,Co=t}function ei(){if(Ao)return To;Ao=1;var e=Zo();return To=function(t){var r=e(t,(function(e){return 500===n.size&&n.clear(),e})),n=r.cache;return r}}function ti(){if(So)return Io;So=1;var e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,r=ei()((function(r){var n=[];return 46===r.charCodeAt(0)&&n.push(""),r.replace(e,(function(e,r,o,i){n.push(o?i.replace(t,"$1"):r||e)})),n}));return Io=r}function ri(){if(qo)return $o;return qo=1,$o=function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}}function ni(){if(Fo)return Mo;Fo=1;var e=ft(),t=ri(),r=Mr(),n=Qo(),o=e?e.prototype:void 0,i=o?o.toString:void 0;return Mo=function e(o){if("string"==typeof o)return o;if(r(o))return t(o,e)+"";if(n(o))return i?i.call(o):"";var u=o+"";return"0"==u&&1/o==-1/0?"-0":u},Mo}function oi(){if(Uo)return Lo;Uo=1;var e=ni();return Lo=function(t){return null==t?"":e(t)}}function ii(){if(Vo)return zo;Vo=1;var e=Mr(),t=Xo(),r=ti(),n=oi();return zo=function(o,i){return e(o)?o:t(o,i)?[o]:r(n(o))}}function ui(){if(Ho)return Go;Ho=1;var e=Qo();return Go=function(t){if("string"==typeof t||e(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}}function ai(){if(Wo)return Do;Wo=1;var e=ii(),t=ui();return Do=function(r,n){for(var o=0,i=(n=e(n,r)).length;null!=r&&o<i;)r=r[t(n[o++])];return o&&o==i?r:void 0}}function si(){if(Yo)return Ko;Yo=1;var e=ai();return Ko=function(t,r,n){var o=null==t?void 0:e(t,r);return void 0===o?n:o}}var ci,fi,li=Ye(si());class hi extends e{env;config;constructor(e){super(e),this.config=Jo({},this.feConfig.release,this.options),this.env=this.getInitEnv()}setConfig(e){this.config=Jo(this.config,e)}getConfig(e,t){return li(this.config,e,t)}getInitEnv(){return t.searchEnv({logger:this.logger,preloadList:this.feConfig.envOrder})}getEnv(){return this.env}getPkg(e){return this.getConfig(["packageJson",e])}}class gi{context;onlyOne=!0;constructor(e){this.context=e}get logger(){return this.context.logger}get shell(){return this.context.shell}getEnv(e,t){return this.context.getEnv().get(e)??t}enabled(){return!0}getConfig(e,t){return this.context.getConfig(e,t)}setConfig(e){this.context.setConfig(e)}onBefore(e){}onSuccess(e){}onError(e){}async step({label:e,task:t}){this.logger.obtrusive(e);try{const r=await t();return this.logger.info(`${e} - success`),r}catch(e){throw this.logger.error(e),e}}}class pi extends gi{pluginName="check-environment";constructor(e,t){if(super(e),!t)throw new Error("releaseIt is not required");this.hasReleaseIt(),this.hasGithubToken()}hasReleaseIt(){if("false"===this.getEnv("FE_RELEASE"))throw new Error("Skip Release");return!0}hasGithubToken(){const e=this.getEnv("GITHUB_TOKEN")||this.getEnv("PAT_TOKEN");if(!e)throw new Error("GITHUB_TOKEN or PAT_TOKEN environment variable is not set.");return this.setConfig({githubToken:e}),!0}onBefore(e){this.logger.verbose("CheckEnvironment onBefore")}}class vi{context;constructor(e){this.context=e;const t=this.context.getEnv().get("FE_RELEASE_BRANCH")??this.context.getEnv().get("FE_RELEASE_SOURCE_BRANCH")??"master";this.context.setConfig({sourceBranch:t})}getReleaseIt(){return this.context.getConfig("releaseIt")}getReleaseItChangelogOptions(){return{ci:!0,increment:"patch",npm:{publish:!1},git:{requireCleanWorkingDir:!1,tag:!1,push:!1},github:{release:!1},verbose:!0,"dry-run":this.context.dryRun}}getChangelogAndFeatures(e){return e||this.context.logger.warn("No release-it output found, changelog might be incomplete"),li(e,"changelog","No changelog")}createChangelogAndVersion(){const e=this.getReleaseIt();if(!e)throw new Error("releaseIt instance is not set");return e(this.getReleaseItChangelogOptions())}}class bi{context;constructor(e){this.context=e;const t=this.context.getConfig("releaseEnv")??this.context.getEnv().get("NODE_ENV")??"development",r=this.context.getEnv().get("FE_RELEASE_BRANCH")??this.context.getEnv().get("FE_RELEASE_SOURCE_BRANCH")??"master";this.context.setConfig({releaseEnv:t,sourceBranch:r})}get sourceBranch(){return this.context.getConfig("sourceBranch")}get releaseEnv(){return this.context.getConfig("releaseEnv")}async checkTag(e){const t=li(e,"version")||this.context.getPkg("version");if("string"!=typeof t)throw new Error("Tag name is not a string");return this.context.logger.verbose("Created Tag is:",t),{tagName:t}}getReleaseBranchName(e){const t=this.context.getConfig("branchName","release-${tagName}");if("string"!=typeof t)throw new Error("Branch name template is not a string");return this.context.logger.verbose("Release Branch template is:",t),this.context.shell.format(t,{env:this.releaseEnv,branch:this.sourceBranch,tagName:e})}async createReleaseBranch(e){const{tagName:t}=await this.checkTag(e),r=this.getReleaseBranchName(t),n=this.sourceBranch;this.context.logger.verbose("PR SourceBranch is:",n),this.context.logger.verbose("PR TargetBranch is:",r);try{await this.context.shell.exec(`git fetch origin ${n}`),await this.context.shell.exec(`git merge origin/${n}`),await this.context.shell.exec(`git checkout -b ${r}`),await this.context.shell.exec(`git push origin ${r}`)}catch(e){throw e.message.includes("remote: Permission to ")&&this.context.logger.warn('Token maybe not allow Workflow permissions, can you try to open "Workflow permissions" -> "Read and write permissions" for this token?'),e}return{tagName:t,releaseBranch:r}}}class di{context;releaseBase;releasePR;constructor(e,t,r){this.context=e,this.releaseBase=t,this.releasePR=r}get logger(){return this.context.logger}get shell(){return this.context.shell}get autoMergeType(){return this.context.getConfig("autoMergeType","squash")}get dryRunPRNumber(){return this.context.getConfig("dryRunPRNumber","999999")}get autoMergeReleasePR(){return this.context.getConfig("autoMergeReleasePR",!1)}async mergePR(e,t){if(!e)return void this.logger.error("Failed to create Pull Request.",e);const r=this.autoMergeType;if(this.context.dryRun){const{repoName:n,authorName:o}=this.releaseBase.repoInfo;this.logger.info(`[DRY RUN] Would merge PR #${e} with method '${r}' in repo ${o}/${n}, branch ${t}`)}else await this.releasePR.mergePullRequest({pull_number:Number(e),merge_method:r})}async checkedPR(e,t){try{await this.releasePR.getPullRequest({pull_number:Number(e)}),await this.releasePR.deleteBranch({ref:`heads/${t}`}),this.logger.info(`Branch ${t} has been deleted`)}catch(r){if(404===r.status)return void this.logger.warn(`PR #${e} or branch ${t} not found`);throw this.logger.error("Failed to check PR or delete branch",r),r}}async createReleasePRLabel(){const e=this.context.getConfig("label");if(!(e&&e.name&&e.description&&e.color))throw new Error("Label is not valid, skipping creation");if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR label with:",e),e;try{const t=await this.releasePR.createPullRequestLabel({name:e.name,description:e.description,color:e.color.replace("#","")});return this.logger.debug("Create PR label Success",t),e}catch(t){if(422===t.status)return this.logger.warn(`Label ${e.name} already exists, skipping!`),e;throw this.logger.error("Create PR label Failed",t),t}}async createReleasePR(e){const t=this.getCreateReleasePROptions(e);if(this.context.dryRun)return this.logger.info("[DRY RUN] Would create PR with:",{...t,labels:e.labels}),this.dryRunPRNumber;try{const r=await this.releasePR.createPullRequest(t),n=r.number;if(!n)throw new Error("CreateReleasePR Failed, prNumber is empty");if(this.logger.debug("Create PR Success",r),e.labels&&e.labels.length){const t=await this.releasePR.addPullRequestLabels({issue_number:n,labels:e.labels});this.logger.debug("Add PR label Success",t)}return n.toString()}catch(e){if(422===e.status&&e.message.includes("already exists")){this.logger.warn("PR already exists");const t=e.message.match(/pull request #(\d+)/);return t?t[1]:""}throw this.logger.error("Failed to create PR",e),e}}getCreateReleasePROptions(e){return{title:this.getReleasePRTitle(e),body:this.getReleasePRBody(e),base:e.sourceBranch,head:e.releaseBranch}}getReleasePRTitle(e){const t=this.context.getConfig("PRTitle","Release ${env} ${pkgName} ${tagName}");return this.shell.format(t,{env:e.releaseEnv,branch:e.sourceBranch,tagName:e.tagName,pkgName:this.context.getPkg("name")})}getReleasePRBody(e){const t=this.context.getConfig("PRBody","");return this.shell.format(t,{branch:e.sourceBranch,env:e.releaseEnv,tagName:e.tagName,changelog:e.changelog})}}function yi(){if(fi)return ci;fi=1;var e=gt(),t=Mr(),r=Sr();return ci=function(n){return"string"==typeof n||!t(n)&&r(n)&&"[object String]"==e(n)}}var mi=Ye(yi());class wi{context;constructor(e){this.context=e}get repoInfo(){return this.context.getConfig("repoInfo")}async init(){const e=await this.getUserInfo();this.context.setConfig({repoInfo:e})}async getUserInfo(){let e;try{e=(await this.context.shell.exec("git config --get remote.origin.url",{dryRun:!1})).trim()}catch(e){throw new Error("Failed to get git remote url. Please ensure this is a git repository with a valid remote.")}if(!e)throw new Error("Git remote URL is empty. Please set a valid GitHub remote URL.");this.context.logger.verbose("repoUrl: ",e);const t=e.match(/github\.com[:/]([^/]+)\/([^/.]+)(?:\.git)?$/);if(!t)throw new Error("Invalid GitHub repository URL format. Please ensure the remote URL is from GitHub.");const[,r,n]=t;if(!this.isValidString(r)||!this.isValidString(n))throw new Error("Failed to extract owner or repository name from GitHub URL");return{repoName:n,authorName:r}}isValidString(e){return!!e&&mi(e)}}class Ri extends gi{context;releasePR;pluginName="create-release-pr";changelogManager;branchManager;pullRequestManager;releaseBase;constructor(e,t){super(e),this.context=e,this.releasePR=t,this.releaseBase=new wi(e),this.changelogManager=new vi(e),this.branchManager=new bi(e),this.pullRequestManager=new di(e,this.releaseBase,this.releasePR)}get githubToken(){return this.getConfig("githubToken")}async onBefore(){this.logger.verbose("CreateReleasePullRequest onBefore"),await this.releaseBase.init();const e=this.releaseBase.repoInfo;if(!e)throw new Error("repoInfo is not set");await this.releasePR.init({token:this.githubToken,repoName:e.repoName,authorName:e.authorName})}async onSuccess(){const e=await this.step({label:"Create Changelog and Version",task:()=>this.changelogManager.createChangelogAndVersion()}),{tagName:t,releaseBranch:r}=await this.step({label:"Create Release Branch",task:()=>this.branchManager.createReleaseBranch(e)}),n=await this.step({label:"Create Release PR",task:()=>this.createReleasePR(t,r,e)});if(this.pullRequestManager.autoMergeReleasePR)return await this.step({label:`Merge Release PR(${n})`,task:()=>this.pullRequestManager.mergePR(n,r)}),void await this.step({label:`Checked Release PR(${n})`,task:()=>this.pullRequestManager.checkedPR(n,r)});this.logger.info(`Please manually merge PR(#${n}) and complete the publishing process afterwards`)}async createReleasePR(e,t,r){const n=this.changelogManager.getChangelogAndFeatures(r),o=[(await this.pullRequestManager.createReleasePRLabel()).name];return this.pullRequestManager.createReleasePR({tagName:e,releaseBranch:t,changelog:n,sourceBranch:this.branchManager.sourceBranch,releaseEnv:this.branchManager.releaseEnv,labels:o})}}class _i{options;octokit;constructor(e={}){this.options=e}async init({token:e,repoName:t,authorName:r}){if(this.octokit)return this.octokit;if(!e)throw new Error("Github token is not set");this.options.repoName=t,this.options.authorName=r;const{Octokit:n}=await import("@octokit/rest"),o=new n({auth:e});return this.octokit=o,o}getOctokit(){if(!this.octokit)throw new Error("Octokit is not initialized");return this.octokit}mergePullRequest(e){return this.getOctokit().rest.pulls.merge({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}getPullRequest(e){return this.getOctokit().rest.pulls.get({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}deleteBranch(e){return this.getOctokit().rest.git.deleteRef({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}addPullRequestLabels(e){return this.getOctokit().rest.issues.addLabels({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}async createPullRequestLabel(e){return await this.getOctokit().rest.issues.createLabel({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""})}async createPullRequest(e){const t=await this.getOctokit().rest.pulls.create({...e,owner:e.owner||this.options.authorName||"",repo:e.repo||this.options.repoName||""});return{...t.data,number:t.data.number}}}var Pi=Ye(pt());class xi extends gi{pluginName="publish-npm";_releaseItOutput;constructor(e){super(e),this.getIncrementVersion()}async onBefore(){this.logger.verbose("PublishNpm onBefore"),await this.checkNpmAuth()}async onSuccess(){const e=this.getPublishReleaseItOptions(this.context);await this.step({label:"Publish to NPM",task:()=>this.publish(e)})}async publish(e){this.logger.debug("Run release-it method",e);const t=this.getConfig("releaseIt");if(!t)throw new Error("releaseIt instance is not set");return this._releaseItOutput=await t(e),this._releaseItOutput}getPublishReleaseItOptions(e){return{ci:!0,npm:{publish:!0},git:{requireCleanWorkingDir:!1,requireUpstream:!1,changelog:!1},plugins:{"@release-it/conventional-changelog":{infile:!1}},"dry-run":e.dryRun,verbose:!0,increment:this.getIncrementVersion()}}getIncrementVersion(){const e=this.getConfig("packageJson");if(!Pi(e))throw new Error("package.json is undefined");if(!("version"in e))throw new Error("package.json version is required");return e.version}async checkNpmAuth(){const e=this.getEnv("NPM_TOKEN");if(!e)throw new Error("NPM_TOKEN is not set.");this.setConfig({npmToken:e}),await this.shell.exec(`echo //registry.npmjs.org/:_authToken=${e} > .npmrc`,{dryRun:!1})}}class Ei extends gi{pluginName="publish-path";constructor(e){super(e)}async onBefore(){this.logger.verbose("PublishPath onBefore"),this.checkPublishPath()}async checkPublishPath(){const e=this.getPublishPath();this.switchToPublishPath(e),this.logger.debug("Current path:",e)}switchToPublishPath(e){e&&n(e)&&(this.logger.debug("Switching to publish path:",e),process.chdir(e))}getPublishPath(){const e=this.getConfig("publishPath");return"string"==typeof e?e:process.cwd()}}function Ni(e){const t=new hi(e),n=new r;return function(e){const t=[];return t.push(new pi(e,e.options.releaseIt)),e.options.pullRequest?t.push(new Ri(e,new _i)):t.push(new xi(e)),t.push(new Ei(e)),t}(t).forEach((e=>{n.use(e)})),n.exec(t,(({returnValue:e})=>Promise.resolve(e)))}export{gi as Plugin,hi as ReleaseContext,Ni as release};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlover/fe-release",
|
|
3
|
-
"description": "A
|
|
4
|
-
"version": "0.1.
|
|
3
|
+
"description": "A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.",
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
|
-
"homepage": "",
|
|
7
|
+
"homepage": "https://github.com/qlover/fe-base/tree/master/packages/fe-release",
|
|
8
8
|
"author": "qlover",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"main": "./dist/es/index.js",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"types": "./dist/es/index.d.ts",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
+
"types": "./dist/es/index.d.ts",
|
|
15
16
|
"import": "./dist/es/index.js",
|
|
16
|
-
"require": "./dist/cjs/index.js"
|
|
17
|
-
"types": "./dist/es/index.d.ts"
|
|
17
|
+
"require": "./dist/cjs/index.js"
|
|
18
18
|
},
|
|
19
19
|
"./cjs/*": "./dist/cjs/*",
|
|
20
20
|
"./es/*": "./dist/es/*",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
25
|
"url": "git+https://github.com/qlover/fe-base.git",
|
|
26
|
-
"directory": ""
|
|
26
|
+
"directory": "packages/fe-release"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"bin",
|
|
@@ -45,7 +45,10 @@
|
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "rollup -c",
|
|
47
47
|
"test": "jest",
|
|
48
|
-
"release": "node bin/release.js"
|
|
48
|
+
"release": "node bin/release.js",
|
|
49
|
+
"release-pr": "node bin/release.js -P",
|
|
50
|
+
"dryrun:release": "node bin/release.js --dry-run -V",
|
|
51
|
+
"dryrun:release-pr": "node bin/release.js -P --dry-run -V"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
54
|
"@qlover/fe-standard": "latest",
|