@zjex/git-workflow 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1584 -38
- package/package.json +1 -1
- package/src/update-notifier.ts +18 -25
- package/src/utils.ts +6 -0
- package/test-update-flow.mjs +98 -0
- package/tsup.config.ts +13 -3
package/dist/index.js
CHANGED
|
@@ -1,35 +1,1287 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var zt=Object.create;var Je=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var Zt=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty;var T=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,u)=>(typeof require<"u"?require:t)[u]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Xt=(e,t)=>()=>(e&&(t=e(e=0)),t);var _=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var en=(e,t,u,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Jt(t))!Qt.call(e,o)&&o!==u&&Je(e,o,{get:()=>t[o],enumerable:!(n=Yt(t,o))||n.enumerable});return e};var oe=(e,t,u)=>(u=e!=null?zt(Zt(e)):{},en(t||!e||!e.__esModule?Je(u,"default",{value:e,enumerable:!0}):u,e));import _u from"path";import{fileURLToPath as Ru}from"url";var l=Xt(()=>{"use strict"});var Xe=_((no,Qe)=>{"use strict";l();var un=T("tty"),on=un?.WriteStream?.prototype?.hasColors?.()??!1,C=(e,t)=>{if(!on)return o=>o;let u=`\x1B[${e}m`,n=`\x1B[${t}m`;return o=>{let r=o+"",s=r.indexOf(n);if(s===-1)return u+r+n;let i=u,a=0,m=(t===22?n:"")+u;for(;s!==-1;)i+=r.slice(a,s)+m,a=s+n.length,s=r.indexOf(n,a);return i+=r.slice(a)+n,i}},F={};F.reset=C(0,0);F.bold=C(1,22);F.dim=C(2,22);F.italic=C(3,23);F.underline=C(4,24);F.overline=C(53,55);F.inverse=C(7,27);F.hidden=C(8,28);F.strikethrough=C(9,29);F.black=C(30,39);F.red=C(31,39);F.green=C(32,39);F.yellow=C(33,39);F.blue=C(34,39);F.magenta=C(35,39);F.cyan=C(36,39);F.white=C(37,39);F.gray=C(90,39);F.bgBlack=C(40,49);F.bgRed=C(41,49);F.bgGreen=C(42,49);F.bgYellow=C(43,49);F.bgBlue=C(44,49);F.bgMagenta=C(45,49);F.bgCyan=C(46,49);F.bgWhite=C(47,49);F.bgGray=C(100,49);F.redBright=C(91,39);F.greenBright=C(92,39);F.yellowBright=C(93,39);F.blueBright=C(94,39);F.magentaBright=C(95,39);F.cyanBright=C(96,39);F.whiteBright=C(97,39);F.bgRedBright=C(101,49);F.bgGreenBright=C(102,49);F.bgYellowBright=C(103,49);F.bgBlueBright=C(104,49);F.bgMagentaBright=C(105,49);F.bgCyanBright=C(106,49);F.bgWhiteBright=C(107,49);Qe.exports=F});var st=_((Lo,rt)=>{"use strict";l();rt.exports=mn;function gn(e){let t={defaultWidth:0,output:process.stdout,tty:T("tty")};return e?(Object.keys(t).forEach(function(u){e[u]||(e[u]=t[u])}),e):t}function mn(e){let t=gn(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let u=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(u)&&u!==0)return u}return t.defaultWidth}});var at=_((jo,it)=>{"use strict";l();it.exports=({onlyFirst:e=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}});var pe=_((Uo,Dt)=>{"use strict";l();var pn=at();Dt.exports=e=>typeof e=="string"?e.replace(pn(),""):e});var ct=_((Io,de)=>{"use strict";l();var lt=e=>Number.isNaN(e)?!1:e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141);de.exports=lt;de.exports.default=lt});var ht=_((Oo,ft)=>{"use strict";l();ft.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var mt=_((qo,Fe)=>{"use strict";l();var dn=pe(),Fn=ct(),Cn=ht(),gt=e=>{if(typeof e!="string"||e.length===0||(e=dn(e),e.length===0))return 0;e=e.replace(Cn()," ");let t=0;for(let u=0;u<e.length;u++){let n=e.codePointAt(u);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&u++,t+=Fn(n)?2:1)}return t};Fe.exports=gt;Fe.exports.default=gt});var dt=_((Wo,pt)=>{"use strict";l();pt.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var Ce=_((Ho,Ct)=>{"use strict";l();var J=dt(),Ft={};for(let e of Object.keys(J))Ft[J[e]]=e;var c={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};Ct.exports=c;for(let e of Object.keys(c)){if(!("channels"in c[e]))throw new Error("missing channels property: "+e);if(!("labels"in c[e]))throw new Error("missing channel labels property: "+e);if(c[e].labels.length!==c[e].channels)throw new Error("channel and label counts mismatch: "+e);let{channels:t,labels:u}=c[e];delete c[e].channels,delete c[e].labels,Object.defineProperty(c[e],"channels",{value:t}),Object.defineProperty(c[e],"labels",{value:u})}c.rgb.hsl=function(e){let t=e[0]/255,u=e[1]/255,n=e[2]/255,o=Math.min(t,u,n),r=Math.max(t,u,n),s=r-o,i,a;r===o?i=0:t===r?i=(u-n)/s:u===r?i=2+(n-t)/s:n===r&&(i=4+(t-u)/s),i=Math.min(i*60,360),i<0&&(i+=360);let f=(o+r)/2;return r===o?a=0:f<=.5?a=s/(r+o):a=s/(2-r-o),[i,a*100,f*100]};c.rgb.hsv=function(e){let t,u,n,o,r,s=e[0]/255,i=e[1]/255,a=e[2]/255,f=Math.max(s,i,a),m=f-Math.min(s,i,a),g=function(b){return(f-b)/6/m+1/2};return m===0?(o=0,r=0):(r=m/f,t=g(s),u=g(i),n=g(a),s===f?o=n-u:i===f?o=1/3+t-n:a===f&&(o=2/3+u-t),o<0?o+=1:o>1&&(o-=1)),[o*360,r*100,f*100]};c.rgb.hwb=function(e){let t=e[0],u=e[1],n=e[2],o=c.rgb.hsl(e)[0],r=1/255*Math.min(t,Math.min(u,n));return n=1-1/255*Math.max(t,Math.max(u,n)),[o,r*100,n*100]};c.rgb.cmyk=function(e){let t=e[0]/255,u=e[1]/255,n=e[2]/255,o=Math.min(1-t,1-u,1-n),r=(1-t-o)/(1-o)||0,s=(1-u-o)/(1-o)||0,i=(1-n-o)/(1-o)||0;return[r*100,s*100,i*100,o*100]};function En(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}c.rgb.keyword=function(e){let t=Ft[e];if(t)return t;let u=1/0,n;for(let o of Object.keys(J)){let r=J[o],s=En(e,r);s<u&&(u=s,n=o)}return n};c.keyword.rgb=function(e){return J[e]};c.rgb.xyz=function(e){let t=e[0]/255,u=e[1]/255,n=e[2]/255;t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,u=u>.04045?((u+.055)/1.055)**2.4:u/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92;let o=t*.4124+u*.3576+n*.1805,r=t*.2126+u*.7152+n*.0722,s=t*.0193+u*.1192+n*.9505;return[o*100,r*100,s*100]};c.rgb.lab=function(e){let t=c.rgb.xyz(e),u=t[0],n=t[1],o=t[2];u/=95.047,n/=100,o/=108.883,u=u>.008856?u**(1/3):7.787*u+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,o=o>.008856?o**(1/3):7.787*o+16/116;let r=116*n-16,s=500*(u-n),i=200*(n-o);return[r,s,i]};c.hsl.rgb=function(e){let t=e[0]/360,u=e[1]/100,n=e[2]/100,o,r,s;if(u===0)return s=n*255,[s,s,s];n<.5?o=n*(1+u):o=n+u-n*u;let i=2*n-o,a=[0,0,0];for(let f=0;f<3;f++)r=t+1/3*-(f-1),r<0&&r++,r>1&&r--,6*r<1?s=i+(o-i)*6*r:2*r<1?s=o:3*r<2?s=i+(o-i)*(2/3-r)*6:s=i,a[f]=s*255;return a};c.hsl.hsv=function(e){let t=e[0],u=e[1]/100,n=e[2]/100,o=u,r=Math.max(n,.01);n*=2,u*=n<=1?n:2-n,o*=r<=1?r:2-r;let s=(n+u)/2,i=n===0?2*o/(r+o):2*u/(n+u);return[t,i*100,s*100]};c.hsv.rgb=function(e){let t=e[0]/60,u=e[1]/100,n=e[2]/100,o=Math.floor(t)%6,r=t-Math.floor(t),s=255*n*(1-u),i=255*n*(1-u*r),a=255*n*(1-u*(1-r));switch(n*=255,o){case 0:return[n,a,s];case 1:return[i,n,s];case 2:return[s,n,a];case 3:return[s,i,n];case 4:return[a,s,n];case 5:return[n,s,i]}};c.hsv.hsl=function(e){let t=e[0],u=e[1]/100,n=e[2]/100,o=Math.max(n,.01),r,s;s=(2-u)*n;let i=(2-u)*o;return r=u*o,r/=i<=1?i:2-i,r=r||0,s/=2,[t,r*100,s*100]};c.hwb.rgb=function(e){let t=e[0]/360,u=e[1]/100,n=e[2]/100,o=u+n,r;o>1&&(u/=o,n/=o);let s=Math.floor(6*t),i=1-n;r=6*t-s,(s&1)!==0&&(r=1-r);let a=u+r*(i-u),f,m,g;switch(s){default:case 6:case 0:f=i,m=a,g=u;break;case 1:f=a,m=i,g=u;break;case 2:f=u,m=i,g=a;break;case 3:f=u,m=a,g=i;break;case 4:f=a,m=u,g=i;break;case 5:f=i,m=u,g=a;break}return[f*255,m*255,g*255]};c.cmyk.rgb=function(e){let t=e[0]/100,u=e[1]/100,n=e[2]/100,o=e[3]/100,r=1-Math.min(1,t*(1-o)+o),s=1-Math.min(1,u*(1-o)+o),i=1-Math.min(1,n*(1-o)+o);return[r*255,s*255,i*255]};c.xyz.rgb=function(e){let t=e[0]/100,u=e[1]/100,n=e[2]/100,o,r,s;return o=t*3.2406+u*-1.5372+n*-.4986,r=t*-.9689+u*1.8758+n*.0415,s=t*.0557+u*-.204+n*1.057,o=o>.0031308?1.055*o**(1/2.4)-.055:o*12.92,r=r>.0031308?1.055*r**(1/2.4)-.055:r*12.92,s=s>.0031308?1.055*s**(1/2.4)-.055:s*12.92,o=Math.min(Math.max(0,o),1),r=Math.min(Math.max(0,r),1),s=Math.min(Math.max(0,s),1),[o*255,r*255,s*255]};c.xyz.lab=function(e){let t=e[0],u=e[1],n=e[2];t/=95.047,u/=100,n/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,u=u>.008856?u**(1/3):7.787*u+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;let o=116*u-16,r=500*(t-u),s=200*(u-n);return[o,r,s]};c.lab.xyz=function(e){let t=e[0],u=e[1],n=e[2],o,r,s;r=(t+16)/116,o=u/500+r,s=r-n/200;let i=r**3,a=o**3,f=s**3;return r=i>.008856?i:(r-16/116)/7.787,o=a>.008856?a:(o-16/116)/7.787,s=f>.008856?f:(s-16/116)/7.787,o*=95.047,r*=100,s*=108.883,[o,r,s]};c.lab.lch=function(e){let t=e[0],u=e[1],n=e[2],o;o=Math.atan2(n,u)*360/2/Math.PI,o<0&&(o+=360);let s=Math.sqrt(u*u+n*n);return[t,s,o]};c.lch.lab=function(e){let t=e[0],u=e[1],o=e[2]/360*2*Math.PI,r=u*Math.cos(o),s=u*Math.sin(o);return[t,r,s]};c.rgb.ansi16=function(e,t=null){let[u,n,o]=e,r=t===null?c.rgb.hsv(e)[2]:t;if(r=Math.round(r/50),r===0)return 30;let s=30+(Math.round(o/255)<<2|Math.round(n/255)<<1|Math.round(u/255));return r===2&&(s+=60),s};c.hsv.ansi16=function(e){return c.rgb.ansi16(c.hsv.rgb(e),e[2])};c.rgb.ansi256=function(e){let t=e[0],u=e[1],n=e[2];return t===u&&u===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(u/255*5)+Math.round(n/255*5)};c.ansi16.rgb=function(e){let t=e%10;if(t===0||t===7)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];let u=(~~(e>50)+1)*.5,n=(t&1)*u*255,o=(t>>1&1)*u*255,r=(t>>2&1)*u*255;return[n,o,r]};c.ansi256.rgb=function(e){if(e>=232){let r=(e-232)*10+8;return[r,r,r]}e-=16;let t,u=Math.floor(e/36)/5*255,n=Math.floor((t=e%36)/6)/5*255,o=t%6/5*255;return[u,n,o]};c.rgb.hex=function(e){let u=(((Math.round(e[0])&255)<<16)+((Math.round(e[1])&255)<<8)+(Math.round(e[2])&255)).toString(16).toUpperCase();return"000000".substring(u.length)+u};c.hex.rgb=function(e){let t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let u=t[0];t[0].length===3&&(u=u.split("").map(i=>i+i).join(""));let n=parseInt(u,16),o=n>>16&255,r=n>>8&255,s=n&255;return[o,r,s]};c.rgb.hcg=function(e){let t=e[0]/255,u=e[1]/255,n=e[2]/255,o=Math.max(Math.max(t,u),n),r=Math.min(Math.min(t,u),n),s=o-r,i,a;return s<1?i=r/(1-s):i=0,s<=0?a=0:o===t?a=(u-n)/s%6:o===u?a=2+(n-t)/s:a=4+(t-u)/s,a/=6,a%=1,[a*360,s*100,i*100]};c.hsl.hcg=function(e){let t=e[1]/100,u=e[2]/100,n=u<.5?2*t*u:2*t*(1-u),o=0;return n<1&&(o=(u-.5*n)/(1-n)),[e[0],n*100,o*100]};c.hsv.hcg=function(e){let t=e[1]/100,u=e[2]/100,n=t*u,o=0;return n<1&&(o=(u-n)/(1-n)),[e[0],n*100,o*100]};c.hcg.rgb=function(e){let t=e[0]/360,u=e[1]/100,n=e[2]/100;if(u===0)return[n*255,n*255,n*255];let o=[0,0,0],r=t%1*6,s=r%1,i=1-s,a=0;switch(Math.floor(r)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=i,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=i,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=i}return a=(1-u)*n,[(u*o[0]+a)*255,(u*o[1]+a)*255,(u*o[2]+a)*255]};c.hcg.hsv=function(e){let t=e[1]/100,u=e[2]/100,n=t+u*(1-t),o=0;return n>0&&(o=t/n),[e[0],o*100,n*100]};c.hcg.hsl=function(e){let t=e[1]/100,n=e[2]/100*(1-t)+.5*t,o=0;return n>0&&n<.5?o=t/(2*n):n>=.5&&n<1&&(o=t/(2*(1-n))),[e[0],o*100,n*100]};c.hcg.hwb=function(e){let t=e[1]/100,u=e[2]/100,n=t+u*(1-t);return[e[0],(n-t)*100,(1-n)*100]};c.hwb.hcg=function(e){let t=e[1]/100,n=1-e[2]/100,o=n-t,r=0;return o<1&&(r=(n-o)/(1-o)),[e[0],o*100,r*100]};c.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]};c.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]};c.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]};c.gray.hsl=function(e){return[0,0,e[0]]};c.gray.hsv=c.gray.hsl;c.gray.hwb=function(e){return[0,100,e[0]]};c.gray.cmyk=function(e){return[0,0,0,e[0]]};c.gray.lab=function(e){return[e[0],0,0]};c.gray.hex=function(e){let t=Math.round(e[0]/100*255)&255,n=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(n.length)+n};c.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}});var bt=_((zo,Et)=>{"use strict";l();var re=Ce();function bn(){let e={},t=Object.keys(re);for(let u=t.length,n=0;n<u;n++)e[t[n]]={distance:-1,parent:null};return e}function wn(e){let t=bn(),u=[e];for(t[e].distance=0;u.length;){let n=u.pop(),o=Object.keys(re[n]);for(let r=o.length,s=0;s<r;s++){let i=o[s],a=t[i];a.distance===-1&&(a.distance=t[n].distance+1,a.parent=n,u.unshift(i))}}return t}function Bn(e,t){return function(u){return t(e(u))}}function xn(e,t){let u=[t[e].parent,e],n=re[t[e].parent][e],o=t[e].parent;for(;t[o].parent;)u.unshift(t[o].parent),n=Bn(re[t[o].parent][o],n),o=t[o].parent;return n.conversion=u,n}Et.exports=function(e){let t=wn(e),u={},n=Object.keys(t);for(let o=n.length,r=0;r<o;r++){let s=n[r];t[s].parent!==null&&(u[s]=xn(s,t))}return u}});var Bt=_((Jo,wt)=>{"use strict";l();var Ee=Ce(),yn=bt(),q={},$n=Object.keys(Ee);function vn(e){let t=function(...u){let n=u[0];return n==null?n:(n.length>1&&(u=n),e(u))};return"conversion"in e&&(t.conversion=e.conversion),t}function Sn(e){let t=function(...u){let n=u[0];if(n==null)return n;n.length>1&&(u=n);let o=e(u);if(typeof o=="object")for(let r=o.length,s=0;s<r;s++)o[s]=Math.round(o[s]);return o};return"conversion"in e&&(t.conversion=e.conversion),t}$n.forEach(e=>{q[e]={},Object.defineProperty(q[e],"channels",{value:Ee[e].channels}),Object.defineProperty(q[e],"labels",{value:Ee[e].labels});let t=yn(e);Object.keys(t).forEach(n=>{let o=t[n];q[e][n]=Sn(o),q[e][n].raw=vn(o)})});wt.exports=q});var At=_((Qo,St)=>{"use strict";l();var xt=(e,t)=>(...u)=>`\x1B[${e(...u)+t}m`,yt=(e,t)=>(...u)=>{let n=e(...u);return`\x1B[${38+t};5;${n}m`},$t=(e,t)=>(...u)=>{let n=e(...u);return`\x1B[${38+t};2;${n[0]};${n[1]};${n[2]}m`},se=e=>e,vt=(e,t,u)=>[e,t,u],G=(e,t,u)=>{Object.defineProperty(e,t,{get:()=>{let n=u();return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0}),n},enumerable:!0,configurable:!0})},be,W=(e,t,u,n)=>{be===void 0&&(be=Bt());let o=n?10:0,r={};for(let[s,i]of Object.entries(be)){let a=s==="ansi16"?"ansi":s;s===t?r[a]=e(u,o):typeof i=="object"&&(r[a]=e(i[t],o))}return r};function An(){let e=new Map,t={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[u,n]of Object.entries(t)){for(let[o,r]of Object.entries(n))t[o]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[o]=t[o],e.set(r[0],r[1]);Object.defineProperty(t,u,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",G(t.color,"ansi",()=>W(xt,"ansi16",se,!1)),G(t.color,"ansi256",()=>W(yt,"ansi256",se,!1)),G(t.color,"ansi16m",()=>W($t,"rgb",vt,!1)),G(t.bgColor,"ansi",()=>W(xt,"ansi16",se,!0)),G(t.bgColor,"ansi256",()=>W(yt,"ansi256",se,!0)),G(t.bgColor,"ansi16m",()=>W($t,"rgb",vt,!0)),t}Object.defineProperty(St,"exports",{enumerable:!0,get:An})});var Lt=_((er,_t)=>{"use strict";l();var Z=mt(),kn=pe(),_n=At(),Be=new Set(["\x1B","\x9B"]),Ln=39,kt=e=>`${Be.values().next().value}[${e}m`,Rn=e=>e.split(" ").map(t=>Z(t)),we=(e,t,u)=>{let n=[...t],o=!1,r=Z(kn(e[e.length-1]));for(let[s,i]of n.entries()){let a=Z(i);if(r+a<=u?e[e.length-1]+=i:(e.push(i),r=0),Be.has(i))o=!0;else if(o&&i==="m"){o=!1;continue}o||(r+=a,r===u&&s<n.length-1&&(e.push(""),r=0))}!r&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},jn=e=>{let t=e.split(" "),u=t.length;for(;u>0&&!(Z(t[u-1])>0);)u--;return u===t.length?e:t.slice(0,u).join(" ")+t.slice(u).join("")},Tn=(e,t,u={})=>{if(u.trim!==!1&&e.trim()==="")return"";let n="",o="",r,s=Rn(e),i=[""];for(let[a,f]of e.split(" ").entries()){u.trim!==!1&&(i[i.length-1]=i[i.length-1].trimLeft());let m=Z(i[i.length-1]);if(a!==0&&(m>=t&&(u.wordWrap===!1||u.trim===!1)&&(i.push(""),m=0),(m>0||u.trim===!1)&&(i[i.length-1]+=" ",m++)),u.hard&&s[a]>t){let g=t-m,b=1+Math.floor((s[a]-g-1)/t);Math.floor((s[a]-1)/t)<b&&i.push(""),we(i,f,t);continue}if(m+s[a]>t&&m>0&&s[a]>0){if(u.wordWrap===!1&&m<t){we(i,f,t);continue}i.push("")}if(m+s[a]>t&&u.wordWrap===!1){we(i,f,t);continue}i[i.length-1]+=f}u.trim!==!1&&(i=i.map(jn)),n=i.join(`
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
`)});var jt=_((lr,Rt)=>{"use strict";l();var On=T("stream"),xe=class extends On{#n=null;constructor(t={}){super(t),this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=t.replace,this._prompt=t.prompt||null,this._hadControl=!1}#t(t,u){return this._dest?this._dest[t]:this._src?this._src[t]:u}#e(t,...u){typeof this._dest?.[t]=="function"&&this._dest[t](...u),typeof this._src?.[t]=="function"&&this._src[t](...u)}get isTTY(){return this.#n!==null?this.#n:this.#t("isTTY",!1)}set isTTY(t){this.#n=t}get rows(){return this.#t("rows")}get columns(){return this.#t("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(t){this._src=t}pipe(t,u){return this._dest=t,super.pipe(t,u)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(t){if(this.muted){if(!this.replace)return!0;if(t.match(/^\u001b/))return t.indexOf(this._prompt)===0&&(t=t.slice(this._prompt.length),t=t.replace(/./g,this.replace),t=this._prompt+t),this._hadControl=!0,this.emit("data",t);this._prompt&&this._hadControl&&t.indexOf(this._prompt)===0&&(this._hadControl=!1,this.emit("data",this._prompt),t=t.slice(this._prompt.length)),t=t.toString().replace(/./g,this.replace)}this.emit("data",t)}end(t){this.muted&&(t&&this.replace?t=t.toString().replace(/./g,this.replace):t=null),t&&this.emit("data",t),this.emit("end")}destroy(...t){return this.#e("destroy",...t)}destroySoon(...t){return this.#e("destroySoon",...t)}close(...t){return this.#e("close",...t)}};Rt.exports=xe});l();import{cac as $u}from"cac";import{select as vu}from"@inquirer/prompts";l();l();l();var Y=class extends Error{name="ExitPromptError"};l();l();import{AsyncResource as Yu}from"async_hooks";l();import{AsyncLocalStorage as tn,AsyncResource as qu}from"async_hooks";var Wu=new tn;l();l();l();var R=oe(Xe(),1);l();import j from"process";function rn(){return j.platform!=="win32"?j.env.TERM!=="linux":!!j.env.WT_SESSION||!!j.env.TERMINUS_SUBLIME||j.env.ConEmuTask==="{cmd::Cmder}"||j.env.TERM_PROGRAM==="Terminus-Sublime"||j.env.TERM_PROGRAM==="vscode"||j.env.TERM==="xterm-256color"||j.env.TERM==="alacritty"||j.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var et={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},tt={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},sn={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},an={...et,...tt},Dn={...et,...sn},ln=rn(),cn=ln?an:Dn,me=cn,ro=Object.entries(tt);var fn={prefix:{idle:R.default.blue("?"),done:R.default.green(me.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map(e=>R.default.yellow(e))},style:{answer:R.default.cyan,message:R.default.bold,error:e=>R.default.red(`> ${e}`),defaultAnswer:e=>R.default.dim(`(${e})`),help:R.default.dim,highlight:R.default.cyan,key:e=>R.default.cyan(R.default.bold(`<${e}>`))}};l();l();l();l();l();var Un=oe(st(),1),Pn=oe(Lt(),1);l();var Vn=oe(jt(),1);import*as Wn from"readline";import{AsyncResource as Or}from"async_hooks";l();l();var M=[];M.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&M.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&M.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ie=e=>!!e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",ye=Symbol.for("signal-exit emitter"),$e=globalThis,Nn=Object.defineProperty.bind(Object),ve=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if($e[ye])return $e[ye];Nn($e,ye,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,u){this.listeners[t].push(u)}removeListener(t,u){let n=this.listeners[t],o=n.indexOf(u);o!==-1&&(o===0&&n.length===1?n.length=0:n.splice(o,1))}emit(t,u,n){if(this.emitted[t])return!1;this.emitted[t]=!0;let o=!1;for(let r of this.listeners[t])o=r(u,n)===!0||o;return t==="exit"&&(o=this.emit("afterExit",u,n)||o),o}},ae=class{},qn=e=>({onExit(t,u){return e.onExit(t,u)},load(){return e.load()},unload(){return e.unload()}}),Se=class extends ae{onExit(){return()=>{}}load(){}unload(){}},Ae=class extends ae{#n=ke.platform==="win32"?"SIGINT":"SIGHUP";#t=new ve;#e;#r;#s;#o={};#u=!1;constructor(t){super(),this.#e=t,this.#o={};for(let u of M)this.#o[u]=()=>{let n=this.#e.listeners(u),{count:o}=this.#t,r=t;if(typeof r.__signal_exit_emitter__=="object"&&typeof r.__signal_exit_emitter__.count=="number"&&(o+=r.__signal_exit_emitter__.count),n.length===o){this.unload();let s=this.#t.emit("exit",null,u),i=u==="SIGHUP"?this.#n:u;s||t.kill(t.pid,i)}};this.#s=t.reallyExit,this.#r=t.emit}onExit(t,u){if(!ie(this.#e))return()=>{};this.#u===!1&&this.load();let n=u?.alwaysLast?"afterExit":"exit";return this.#t.on(n,t),()=>{this.#t.removeListener(n,t),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#u){this.#u=!0,this.#t.count+=1;for(let t of M)try{let u=this.#o[t];u&&this.#e.on(t,u)}catch{}this.#e.emit=(t,...u)=>this.#a(t,...u),this.#e.reallyExit=t=>this.#i(t)}}unload(){this.#u&&(this.#u=!1,M.forEach(t=>{let u=this.#o[t];if(!u)throw new Error("Listener not defined for signal: "+t);try{this.#e.removeListener(t,u)}catch{}}),this.#e.emit=this.#r,this.#e.reallyExit=this.#s,this.#t.count-=1)}#i(t){return ie(this.#e)?(this.#e.exitCode=t||0,this.#t.emit("exit",this.#e.exitCode,null),this.#s.call(this.#e,this.#e.exitCode)):0}#a(t,...u){let n=this.#r;if(t==="exit"&&ie(this.#e)){typeof u[0]=="number"&&(this.#e.exitCode=u[0]);let o=n.call(this.#e,t,...u);return this.#t.emit("exit",this.#e.exitCode,null),o}else return n.call(this.#e,t,...u)}},ke=globalThis.process,{onExit:Gn,load:mr,unload:pr}=qn(ie(ke)?new Ae(ke):new Se);l();import{stripVTControlCharacters as vr}from"util";l();l();l();l();import{execSync as _e}from"child_process";var D={red:e=>`\x1B[31m${e}\x1B[0m`,green:e=>`\x1B[32m${e}\x1B[0m`,yellow:e=>`\x1B[33m${e}\x1B[0m`,dim:e=>`\x1B[2m${e}\x1B[0m`},V=new Date().toISOString().slice(0,10).replace(/-/g,""),h={helpMode:"always",style:{keysHelpTip:e=>`\x1B[2m${e.map(([u,n])=>`${u} ${n}`).join(" \u2022 ")} \u2022 Ctrl+C quit\x1B[0m`}};function P(e,t=!1){try{return _e(e,{encoding:"utf-8",stdio:t?"pipe":"inherit"})}catch(u){if(t)return"";throw u}}function x(e){try{return _e(e,{encoding:"utf-8"}).trim()}catch{return""}}function k(){try{_e("git rev-parse --is-inside-work-tree",{stdio:"pipe"})}catch{console.log(D.red("\u9519\u8BEF: \u5F53\u524D\u76EE\u5F55\u4E0D\u662F git \u4ED3\u5E93")),process.exit(1)}}function Tt(){let e=x("git branch -r").split(`
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { cac } from "cac";
|
|
5
|
+
import { select as select8 } from "@inquirer/prompts";
|
|
6
|
+
import { ExitPromptError } from "@inquirer/core";
|
|
7
|
+
|
|
8
|
+
// src/utils.ts
|
|
9
|
+
import { execSync } from "child_process";
|
|
10
|
+
var colors = {
|
|
11
|
+
red: (s) => `\x1B[31m${s}\x1B[0m`,
|
|
12
|
+
green: (s) => `\x1B[32m${s}\x1B[0m`,
|
|
13
|
+
yellow: (s) => `\x1B[33m${s}\x1B[0m`,
|
|
14
|
+
cyan: (s) => `\x1B[36m${s}\x1B[0m`,
|
|
15
|
+
dim: (s) => `\x1B[2m${s}\x1B[0m`,
|
|
16
|
+
bold: (s) => `\x1B[1m${s}\x1B[0m`,
|
|
17
|
+
reset: "\x1B[0m"
|
|
18
|
+
};
|
|
19
|
+
var TODAY = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, "");
|
|
20
|
+
var theme = {
|
|
21
|
+
helpMode: "always",
|
|
22
|
+
style: {
|
|
23
|
+
keysHelpTip: (keys) => {
|
|
24
|
+
const tips = keys.map(([key, label]) => `${key} ${label}`).join(" \u2022 ");
|
|
25
|
+
return `\x1B[2m${tips} \u2022 Ctrl+C quit\x1B[0m`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function exec(cmd, silent = false) {
|
|
30
|
+
try {
|
|
31
|
+
const options = {
|
|
32
|
+
encoding: "utf-8",
|
|
33
|
+
stdio: silent ? "pipe" : "inherit"
|
|
34
|
+
};
|
|
35
|
+
return execSync(cmd, options);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
if (silent) return "";
|
|
38
|
+
throw e;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function execOutput(cmd) {
|
|
42
|
+
try {
|
|
43
|
+
return execSync(cmd, { encoding: "utf-8" }).trim();
|
|
44
|
+
} catch {
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function checkGitRepo() {
|
|
49
|
+
try {
|
|
50
|
+
execSync("git rev-parse --is-inside-work-tree", { stdio: "pipe" });
|
|
51
|
+
} catch {
|
|
52
|
+
console.log(colors.red("\u9519\u8BEF: \u5F53\u524D\u76EE\u5F55\u4E0D\u662F git \u4ED3\u5E93"));
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function getMainBranch() {
|
|
57
|
+
const branches = execOutput("git branch -r").split("\n").map((b) => b.trim());
|
|
58
|
+
if (branches.includes("origin/main")) {
|
|
59
|
+
return "origin/main";
|
|
60
|
+
}
|
|
61
|
+
if (branches.includes("origin/master")) {
|
|
62
|
+
return "origin/master";
|
|
63
|
+
}
|
|
64
|
+
return "origin/main";
|
|
65
|
+
}
|
|
66
|
+
function divider() {
|
|
67
|
+
console.log(colors.dim("\u2500".repeat(40)));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/commands/branch.ts
|
|
71
|
+
import { execSync as execSync2 } from "child_process";
|
|
72
|
+
import { select, input } from "@inquirer/prompts";
|
|
73
|
+
import ora from "ora";
|
|
74
|
+
|
|
75
|
+
// src/config.ts
|
|
76
|
+
import { existsSync, readFileSync } from "fs";
|
|
77
|
+
import { join } from "path";
|
|
78
|
+
var defaultConfig = {
|
|
79
|
+
featurePrefix: "feature",
|
|
80
|
+
hotfixPrefix: "hotfix",
|
|
81
|
+
requireId: false,
|
|
82
|
+
featureIdLabel: "Story ID",
|
|
83
|
+
hotfixIdLabel: "Issue ID",
|
|
84
|
+
autoStage: true,
|
|
85
|
+
useEmoji: true
|
|
86
|
+
};
|
|
87
|
+
function getGitRoot() {
|
|
88
|
+
return execOutput("git rev-parse --show-toplevel");
|
|
89
|
+
}
|
|
90
|
+
function findConfigFile() {
|
|
91
|
+
const configNames = [".gwrc.json", ".gwrc", "gw.config.json"];
|
|
92
|
+
for (const name of configNames) {
|
|
93
|
+
if (existsSync(name)) {
|
|
94
|
+
return name;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const gitRoot = getGitRoot();
|
|
99
|
+
if (gitRoot) {
|
|
100
|
+
for (const name of configNames) {
|
|
101
|
+
const configPath = join(gitRoot, name);
|
|
102
|
+
if (existsSync(configPath)) {
|
|
103
|
+
return configPath;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
} catch {
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
function loadConfig() {
|
|
112
|
+
const configPath = findConfigFile();
|
|
113
|
+
if (!configPath) {
|
|
114
|
+
return defaultConfig;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const content = readFileSync(configPath, "utf-8");
|
|
118
|
+
const userConfig = JSON.parse(content);
|
|
119
|
+
return { ...defaultConfig, ...userConfig };
|
|
120
|
+
} catch (e) {
|
|
121
|
+
console.warn(`\u914D\u7F6E\u6587\u4EF6\u89E3\u6790\u5931\u8D25: ${configPath}`);
|
|
122
|
+
return defaultConfig;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
var config = null;
|
|
126
|
+
function getConfig() {
|
|
127
|
+
if (!config) {
|
|
128
|
+
config = loadConfig();
|
|
129
|
+
}
|
|
130
|
+
return config;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/commands/branch.ts
|
|
134
|
+
async function getBranchName(type) {
|
|
135
|
+
const config2 = getConfig();
|
|
136
|
+
const idLabel = type === "feature" ? config2.featureIdLabel : config2.hotfixIdLabel;
|
|
137
|
+
const branchPrefix = type === "feature" ? config2.featurePrefix : config2.hotfixPrefix;
|
|
138
|
+
const idMessage = config2.requireId ? `\u8BF7\u8F93\u5165${idLabel}:` : `\u8BF7\u8F93\u5165${idLabel} (\u53EF\u8DF3\u8FC7):`;
|
|
139
|
+
const id = await input({ message: idMessage, theme });
|
|
140
|
+
if (config2.requireId && !id) {
|
|
141
|
+
console.log(colors.red(`${idLabel}\u4E0D\u80FD\u4E3A\u7A7A`));
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const description = await input({ message: "\u8BF7\u8F93\u5165\u63CF\u8FF0:", theme });
|
|
145
|
+
if (!description) {
|
|
146
|
+
console.log(colors.red("\u63CF\u8FF0\u4E0D\u80FD\u4E3A\u7A7A"));
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
return id ? `${branchPrefix}/${TODAY}-${id}-${description}` : `${branchPrefix}/${TODAY}-${description}`;
|
|
150
|
+
}
|
|
151
|
+
async function createBranch(type, baseBranchArg) {
|
|
152
|
+
const config2 = getConfig();
|
|
153
|
+
const hasChanges = execOutput("git status --porcelain");
|
|
154
|
+
if (hasChanges) {
|
|
155
|
+
console.log(colors.yellow("\u68C0\u6D4B\u5230\u672A\u63D0\u4EA4\u7684\u66F4\u6539:"));
|
|
156
|
+
console.log(colors.dim(hasChanges));
|
|
157
|
+
divider();
|
|
158
|
+
const shouldStash = await select({
|
|
159
|
+
message: "\u662F\u5426\u6682\u5B58 (stash) \u8FD9\u4E9B\u66F4\u6539\u540E\u7EE7\u7EED?",
|
|
160
|
+
choices: [
|
|
161
|
+
{ name: "\u662F", value: true },
|
|
162
|
+
{ name: "\u5426\uFF0C\u53D6\u6D88\u64CD\u4F5C", value: false }
|
|
163
|
+
],
|
|
164
|
+
theme
|
|
165
|
+
});
|
|
166
|
+
if (!shouldStash) {
|
|
167
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const stashSpinner = ora("\u6B63\u5728\u6682\u5B58\u66F4\u6539...").start();
|
|
171
|
+
try {
|
|
172
|
+
exec('git stash push -m "auto stash before branch switch"', true);
|
|
173
|
+
stashSpinner.succeed("\u66F4\u6539\u5DF2\u6682\u5B58\uFF0C\u5207\u6362\u5206\u652F\u540E\u53EF\u7528 gw s \u6062\u590D");
|
|
174
|
+
} catch {
|
|
175
|
+
stashSpinner.fail("\u6682\u5B58\u5931\u8D25");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
divider();
|
|
179
|
+
}
|
|
180
|
+
const branchName = await getBranchName(type);
|
|
181
|
+
if (!branchName) return;
|
|
182
|
+
divider();
|
|
183
|
+
let baseBranch;
|
|
184
|
+
if (baseBranchArg) {
|
|
185
|
+
baseBranch = `origin/${baseBranchArg}`;
|
|
186
|
+
} else if (config2.baseBranch) {
|
|
187
|
+
baseBranch = `origin/${config2.baseBranch}`;
|
|
188
|
+
} else {
|
|
189
|
+
baseBranch = getMainBranch();
|
|
190
|
+
}
|
|
191
|
+
const spinner = ora(`\u6B63\u5728\u4ECE ${baseBranch} \u521B\u5EFA\u5206\u652F...`).start();
|
|
192
|
+
try {
|
|
193
|
+
exec(`git fetch origin ${baseBranch.replace("origin/", "")}`, true);
|
|
194
|
+
exec(`git checkout -b "${branchName}" ${baseBranch}`);
|
|
195
|
+
spinner.succeed(`\u5206\u652F\u521B\u5EFA\u6210\u529F: ${branchName}`);
|
|
196
|
+
divider();
|
|
197
|
+
let shouldPush;
|
|
198
|
+
if (config2.autoPush !== void 0) {
|
|
199
|
+
shouldPush = config2.autoPush;
|
|
200
|
+
if (shouldPush) {
|
|
201
|
+
console.log(colors.dim("(\u81EA\u52A8\u63A8\u9001\u5DF2\u542F\u7528)"));
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
shouldPush = await select({
|
|
205
|
+
message: "\u662F\u5426\u63A8\u9001\u5230\u8FDC\u7A0B?",
|
|
206
|
+
choices: [
|
|
207
|
+
{ name: "\u662F", value: true },
|
|
208
|
+
{ name: "\u5426", value: false }
|
|
209
|
+
],
|
|
210
|
+
theme
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (shouldPush) {
|
|
214
|
+
const pushSpinner = ora("\u6B63\u5728\u63A8\u9001\u5230\u8FDC\u7A0B...").start();
|
|
215
|
+
try {
|
|
216
|
+
execSync2(`git push -u origin "${branchName}"`, { stdio: "pipe" });
|
|
217
|
+
pushSpinner.succeed(`\u5DF2\u63A8\u9001\u5230\u8FDC\u7A0B: origin/${branchName}`);
|
|
218
|
+
} catch {
|
|
219
|
+
pushSpinner.warn(
|
|
220
|
+
"\u8FDC\u7A0B\u63A8\u9001\u5931\u8D25\uFF0C\u53EF\u7A0D\u540E\u624B\u52A8\u6267\u884C: git push -u origin " + branchName
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
} catch {
|
|
225
|
+
spinner.fail("\u5206\u652F\u521B\u5EFA\u5931\u8D25");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
async function deleteBranch(branchArg) {
|
|
229
|
+
const fetchSpinner = ora("\u6B63\u5728\u83B7\u53D6\u5206\u652F\u4FE1\u606F...").start();
|
|
230
|
+
exec("git fetch --all --prune", true);
|
|
231
|
+
fetchSpinner.succeed("\u5206\u652F\u4FE1\u606F\u5DF2\u66F4\u65B0");
|
|
232
|
+
divider();
|
|
233
|
+
const currentBranch = execOutput("git branch --show-current");
|
|
234
|
+
let branch = branchArg;
|
|
235
|
+
if (branch?.startsWith("origin/")) {
|
|
236
|
+
branch = branch.replace("origin/", "");
|
|
237
|
+
}
|
|
238
|
+
if (!branch) {
|
|
239
|
+
const localBranches = execOutput(
|
|
240
|
+
"git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short)'"
|
|
241
|
+
).split("\n").filter((b) => b && b !== currentBranch);
|
|
242
|
+
const remoteBranches = execOutput(
|
|
243
|
+
"git for-each-ref --sort=-committerdate refs/remotes/origin/ --format='%(refname:short)'"
|
|
244
|
+
).split("\n").map((b) => b.replace("origin/", "")).filter(
|
|
245
|
+
(b) => b && b !== "HEAD" && b !== currentBranch && !localBranches.includes(b)
|
|
246
|
+
);
|
|
247
|
+
if (localBranches.length === 0 && remoteBranches.length === 0) {
|
|
248
|
+
console.log(colors.yellow("\u6CA1\u6709\u53EF\u5220\u9664\u7684\u5206\u652F"));
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const choices = [];
|
|
252
|
+
localBranches.forEach((b) => {
|
|
253
|
+
const hasRemote2 = execOutput(`git branch -r --list "origin/${b}"`);
|
|
254
|
+
choices.push({
|
|
255
|
+
name: hasRemote2 ? `${b} (\u672C\u5730+\u8FDC\u7A0B)` : `${b} (\u4EC5\u672C\u5730)`,
|
|
256
|
+
value: b
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
remoteBranches.forEach((b) => {
|
|
260
|
+
choices.push({
|
|
261
|
+
name: `${b} (\u4EC5\u8FDC\u7A0B)`,
|
|
262
|
+
value: `__remote__${b}`
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
choices.push({ name: "\u53D6\u6D88", value: "__cancel__" });
|
|
266
|
+
branch = await select({
|
|
267
|
+
message: "\u9009\u62E9\u8981\u5220\u9664\u7684\u5206\u652F (\u6309\u6700\u8FD1\u4F7F\u7528\u6392\u5E8F):",
|
|
268
|
+
choices,
|
|
269
|
+
theme
|
|
270
|
+
});
|
|
271
|
+
if (branch === "__cancel__") {
|
|
272
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (branch.startsWith("__remote__")) {
|
|
276
|
+
const remoteBranch = branch.replace("__remote__", "");
|
|
277
|
+
const confirm3 = await select({
|
|
278
|
+
message: `\u786E\u8BA4\u5220\u9664\u8FDC\u7A0B\u5206\u652F origin/${remoteBranch}?`,
|
|
279
|
+
choices: [
|
|
280
|
+
{ name: "\u662F", value: true },
|
|
281
|
+
{ name: "\u5426", value: false }
|
|
282
|
+
],
|
|
283
|
+
theme
|
|
284
|
+
});
|
|
285
|
+
if (!confirm3) {
|
|
286
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const spinner = ora(`\u6B63\u5728\u5220\u9664\u8FDC\u7A0B\u5206\u652F: origin/${remoteBranch}`).start();
|
|
290
|
+
try {
|
|
291
|
+
execSync2(`git push origin --delete "${remoteBranch}"`, {
|
|
292
|
+
stdio: "pipe"
|
|
293
|
+
});
|
|
294
|
+
spinner.succeed(`\u8FDC\u7A0B\u5206\u652F\u5DF2\u5220\u9664: origin/${remoteBranch}`);
|
|
295
|
+
} catch {
|
|
296
|
+
spinner.fail("\u8FDC\u7A0B\u5206\u652F\u5220\u9664\u5931\u8D25");
|
|
297
|
+
}
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (branch === currentBranch) {
|
|
302
|
+
console.log(colors.red("\u4E0D\u80FD\u5220\u9664\u5F53\u524D\u6240\u5728\u5206\u652F"));
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const localExists = execOutput(`git branch --list "${branch}"`);
|
|
306
|
+
const hasRemote = execOutput(`git branch -r --list "origin/${branch}"`);
|
|
307
|
+
if (!localExists) {
|
|
308
|
+
if (hasRemote) {
|
|
309
|
+
console.log(
|
|
310
|
+
colors.yellow(`\u672C\u5730\u5206\u652F\u4E0D\u5B58\u5728\uFF0C\u4F46\u8FDC\u7A0B\u5206\u652F\u5B58\u5728: origin/${branch}`)
|
|
311
|
+
);
|
|
312
|
+
const deleteRemote = await select({
|
|
313
|
+
message: `\u786E\u8BA4\u5220\u9664\u8FDC\u7A0B\u5206\u652F origin/${branch}?`,
|
|
314
|
+
choices: [
|
|
315
|
+
{ name: "\u662F", value: true },
|
|
316
|
+
{ name: "\u5426", value: false }
|
|
317
|
+
],
|
|
318
|
+
theme
|
|
319
|
+
});
|
|
320
|
+
if (deleteRemote) {
|
|
321
|
+
const spinner = ora(`\u6B63\u5728\u5220\u9664\u8FDC\u7A0B\u5206\u652F: origin/${branch}`).start();
|
|
322
|
+
try {
|
|
323
|
+
execSync2(`git push origin --delete "${branch}"`, { stdio: "pipe" });
|
|
324
|
+
spinner.succeed(`\u8FDC\u7A0B\u5206\u652F\u5DF2\u5220\u9664: origin/${branch}`);
|
|
325
|
+
} catch {
|
|
326
|
+
spinner.fail("\u8FDC\u7A0B\u5206\u652F\u5220\u9664\u5931\u8D25");
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
} else {
|
|
330
|
+
console.log(colors.red(`\u5206\u652F\u4E0D\u5B58\u5728: ${branch}`));
|
|
331
|
+
}
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const confirmDelete = await select({
|
|
335
|
+
message: `\u786E\u8BA4\u5220\u9664\u5206\u652F ${branch}?${hasRemote ? " (\u672C\u5730+\u8FDC\u7A0B)" : " (\u4EC5\u672C\u5730)"}`,
|
|
336
|
+
choices: [
|
|
337
|
+
{ name: "\u662F", value: true },
|
|
338
|
+
{ name: "\u5426", value: false }
|
|
339
|
+
],
|
|
340
|
+
theme
|
|
341
|
+
});
|
|
342
|
+
if (!confirmDelete) {
|
|
343
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
const localSpinner = ora(`\u6B63\u5728\u5220\u9664\u672C\u5730\u5206\u652F: ${branch}`).start();
|
|
347
|
+
try {
|
|
348
|
+
execSync2(`git branch -D "${branch}"`, { stdio: "pipe" });
|
|
349
|
+
localSpinner.succeed(`\u672C\u5730\u5206\u652F\u5DF2\u5220\u9664: ${branch}`);
|
|
350
|
+
} catch {
|
|
351
|
+
localSpinner.fail("\u672C\u5730\u5206\u652F\u5220\u9664\u5931\u8D25");
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (hasRemote) {
|
|
355
|
+
const remoteSpinner = ora(`\u6B63\u5728\u5220\u9664\u8FDC\u7A0B\u5206\u652F: origin/${branch}`).start();
|
|
356
|
+
try {
|
|
357
|
+
execSync2(`git push origin --delete "${branch}"`, { stdio: "pipe" });
|
|
358
|
+
remoteSpinner.succeed(`\u8FDC\u7A0B\u5206\u652F\u5DF2\u5220\u9664: origin/${branch}`);
|
|
359
|
+
} catch {
|
|
360
|
+
remoteSpinner.fail("\u8FDC\u7A0B\u5206\u652F\u5220\u9664\u5931\u8D25");
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// src/commands/tag.ts
|
|
366
|
+
import { execSync as execSync3 } from "child_process";
|
|
367
|
+
import { select as select2, input as input2 } from "@inquirer/prompts";
|
|
368
|
+
import ora2 from "ora";
|
|
369
|
+
async function listTags(prefix) {
|
|
370
|
+
const spinner = ora2("\u6B63\u5728\u83B7\u53D6 tags...").start();
|
|
371
|
+
exec("git fetch --tags", true);
|
|
372
|
+
spinner.stop();
|
|
373
|
+
const pattern = prefix ? `${prefix}*` : "";
|
|
374
|
+
const tags = execOutput(`git tag -l ${pattern} --sort=-v:refname`).split("\n").filter(Boolean);
|
|
375
|
+
if (tags.length === 0) {
|
|
376
|
+
console.log(
|
|
377
|
+
colors.yellow(prefix ? `\u6CA1\u6709 '${prefix}' \u5F00\u5934\u7684 tag` : "\u6CA1\u6709 tag")
|
|
378
|
+
);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
console.log(
|
|
382
|
+
colors.green(prefix ? `\u4EE5 '${prefix}' \u5F00\u5934\u7684 tags:` : "\u6240\u6709 tags:")
|
|
383
|
+
);
|
|
384
|
+
tags.slice(0, 20).forEach((tag) => console.log(` ${tag}`));
|
|
385
|
+
if (tags.length > 20) {
|
|
386
|
+
console.log(colors.yellow(`
|
|
387
|
+
\u5171 ${tags.length} \u4E2A\uFF0C\u4EC5\u663E\u793A\u524D 20 \u4E2A`));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function getLatestTag(prefix) {
|
|
391
|
+
const tags = execOutput(`git tag -l "${prefix}*" --sort=-v:refname`).split("\n").filter(Boolean);
|
|
392
|
+
return tags[0] || "";
|
|
393
|
+
}
|
|
394
|
+
async function createTag(inputPrefix) {
|
|
395
|
+
const config2 = getConfig();
|
|
396
|
+
const fetchSpinner = ora2("\u6B63\u5728\u83B7\u53D6 tags...").start();
|
|
397
|
+
exec("git fetch --tags", true);
|
|
398
|
+
fetchSpinner.stop();
|
|
399
|
+
divider();
|
|
400
|
+
let prefix = inputPrefix;
|
|
401
|
+
if (!prefix && config2.defaultTagPrefix) {
|
|
402
|
+
prefix = config2.defaultTagPrefix;
|
|
403
|
+
console.log(colors.dim(`(\u4F7F\u7528\u914D\u7F6E\u7684\u9ED8\u8BA4\u524D\u7F00: ${prefix})`));
|
|
404
|
+
}
|
|
405
|
+
if (!prefix) {
|
|
406
|
+
const allTags = execOutput("git tag -l").split("\n").filter(Boolean);
|
|
407
|
+
if (allTags.length === 0) {
|
|
408
|
+
prefix = await input2({
|
|
409
|
+
message: "\u5F53\u524D\u4ED3\u5E93\u6CA1\u6709 tag\uFF0C\u8BF7\u8F93\u5165\u524D\u7F00 (\u5982 v):",
|
|
410
|
+
default: "v",
|
|
411
|
+
theme
|
|
412
|
+
});
|
|
413
|
+
if (!prefix) {
|
|
414
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const initialVersion = await select2({
|
|
418
|
+
message: "\u9009\u62E9\u521D\u59CB\u7248\u672C\u53F7:",
|
|
419
|
+
choices: [
|
|
420
|
+
{ name: `${prefix}0.0.1`, value: "0.0.1" },
|
|
421
|
+
{ name: `${prefix}0.1.0`, value: "0.1.0" },
|
|
422
|
+
{ name: `${prefix}1.0.0`, value: "1.0.0" },
|
|
423
|
+
{ name: "\u81EA\u5B9A\u4E49...", value: "__custom__" }
|
|
424
|
+
],
|
|
425
|
+
theme
|
|
426
|
+
});
|
|
427
|
+
let version3 = initialVersion;
|
|
428
|
+
if (initialVersion === "__custom__") {
|
|
429
|
+
version3 = await input2({
|
|
430
|
+
message: "\u8BF7\u8F93\u5165\u7248\u672C\u53F7 (\u5982 0.0.1):",
|
|
431
|
+
theme
|
|
432
|
+
});
|
|
433
|
+
if (!version3) {
|
|
434
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
const newTag = `${prefix}${version3}`;
|
|
439
|
+
const ok = await select2({
|
|
440
|
+
message: `\u786E\u8BA4\u521B\u5EFA ${newTag}?`,
|
|
441
|
+
choices: [
|
|
442
|
+
{ name: "\u662F", value: true },
|
|
443
|
+
{ name: "\u5426", value: false }
|
|
444
|
+
],
|
|
445
|
+
theme
|
|
446
|
+
});
|
|
447
|
+
if (ok) {
|
|
448
|
+
doCreateTag(newTag);
|
|
449
|
+
}
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const prefixes = [
|
|
453
|
+
...new Set(allTags.map((t) => t.replace(/[0-9].*/, "")).filter(Boolean))
|
|
454
|
+
];
|
|
455
|
+
if (prefixes.length === 0) {
|
|
456
|
+
prefix = await input2({
|
|
457
|
+
message: "\u8BF7\u8F93\u5165 tag \u524D\u7F00 (\u5982 v):",
|
|
458
|
+
default: "v",
|
|
459
|
+
theme
|
|
460
|
+
});
|
|
461
|
+
if (!prefix) {
|
|
462
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
} else {
|
|
466
|
+
const prefixWithDate = prefixes.map((p) => {
|
|
467
|
+
const latest = getLatestTag(p);
|
|
468
|
+
const date = latest ? execOutput(`git log -1 --format=%ct "${latest}" 2>/dev/null`) : "0";
|
|
469
|
+
return { prefix: p, latest, date: parseInt(date) || 0 };
|
|
470
|
+
});
|
|
471
|
+
prefixWithDate.sort((a, b) => b.date - a.date);
|
|
472
|
+
const choices2 = prefixWithDate.map(
|
|
473
|
+
({ prefix: p, latest }) => {
|
|
474
|
+
return { name: `${p} (\u6700\u65B0: ${latest})`, value: p };
|
|
475
|
+
}
|
|
476
|
+
);
|
|
477
|
+
choices2.push({ name: "\u8F93\u5165\u65B0\u524D\u7F00...", value: "__new__" });
|
|
478
|
+
prefix = await select2({
|
|
479
|
+
message: "\u9009\u62E9 tag \u524D\u7F00:",
|
|
480
|
+
choices: choices2,
|
|
481
|
+
theme
|
|
482
|
+
});
|
|
483
|
+
if (prefix === "__new__") {
|
|
484
|
+
prefix = await input2({ message: "\u8BF7\u8F93\u5165\u65B0\u524D\u7F00:", theme });
|
|
485
|
+
if (!prefix) {
|
|
486
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
const latestTag = getLatestTag(prefix);
|
|
493
|
+
if (!latestTag) {
|
|
494
|
+
const newTag = `${prefix}1.0.0`;
|
|
495
|
+
console.log(
|
|
496
|
+
colors.yellow(`\u672A\u627E\u5230 '${prefix}' \u5F00\u5934\u7684 tag\uFF0C\u5C06\u521B\u5EFA ${newTag}`)
|
|
497
|
+
);
|
|
498
|
+
const ok = await select2({
|
|
499
|
+
message: `\u786E\u8BA4\u521B\u5EFA ${newTag}?`,
|
|
500
|
+
choices: [
|
|
501
|
+
{ name: "\u662F", value: true },
|
|
502
|
+
{ name: "\u5426", value: false }
|
|
503
|
+
],
|
|
504
|
+
theme
|
|
505
|
+
});
|
|
506
|
+
if (ok) {
|
|
507
|
+
doCreateTag(newTag);
|
|
508
|
+
}
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
console.log(colors.yellow(`\u5F53\u524D\u6700\u65B0 tag: ${latestTag}`));
|
|
512
|
+
divider();
|
|
513
|
+
const version2 = latestTag.slice(prefix.length);
|
|
514
|
+
const preReleaseMatch = version2.match(
|
|
515
|
+
/^(\d+)\.(\d+)\.(\d+)-([a-zA-Z]+)\.(\d+)$/
|
|
516
|
+
);
|
|
517
|
+
const match3 = version2.match(/^(\d+)\.(\d+)\.(\d+)$/);
|
|
518
|
+
const match2 = version2.match(/^(\d+)\.(\d+)$/);
|
|
519
|
+
const match1 = version2.match(/^(\d+)$/);
|
|
520
|
+
let choices = [];
|
|
521
|
+
if (preReleaseMatch) {
|
|
522
|
+
const [, majorStr, minorStr, patchStr, preTag, preNumStr] = preReleaseMatch;
|
|
523
|
+
const major = Number(majorStr);
|
|
524
|
+
const minor = Number(minorStr);
|
|
525
|
+
const patch = Number(patchStr);
|
|
526
|
+
const preNum = Number(preNumStr);
|
|
527
|
+
const baseVersion = `${major}.${minor}.${patch}`;
|
|
528
|
+
choices = [
|
|
529
|
+
{
|
|
530
|
+
name: `pre \u2192 ${prefix}${baseVersion}-${preTag}.${preNum + 1}`,
|
|
531
|
+
value: `${prefix}${baseVersion}-${preTag}.${preNum + 1}`
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
name: `release\u2192 ${prefix}${baseVersion}`,
|
|
535
|
+
value: `${prefix}${baseVersion}`
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
name: `patch \u2192 ${prefix}${major}.${minor}.${patch + 1}`,
|
|
539
|
+
value: `${prefix}${major}.${minor}.${patch + 1}`
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
name: `minor \u2192 ${prefix}${major}.${minor + 1}.0`,
|
|
543
|
+
value: `${prefix}${major}.${minor + 1}.0`
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
name: `major \u2192 ${prefix}${major + 1}.0.0`,
|
|
547
|
+
value: `${prefix}${major + 1}.0.0`
|
|
548
|
+
}
|
|
549
|
+
];
|
|
550
|
+
} else if (match3) {
|
|
551
|
+
const [, majorStr, minorStr, patchStr] = match3;
|
|
552
|
+
const major = Number(majorStr);
|
|
553
|
+
const minor = Number(minorStr);
|
|
554
|
+
const patch = Number(patchStr);
|
|
555
|
+
choices = [
|
|
556
|
+
{
|
|
557
|
+
name: `patch \u2192 ${prefix}${major}.${minor}.${patch + 1}`,
|
|
558
|
+
value: `${prefix}${major}.${minor}.${patch + 1}`
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
name: `minor \u2192 ${prefix}${major}.${minor + 1}.0`,
|
|
562
|
+
value: `${prefix}${major}.${minor + 1}.0`
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
name: `major \u2192 ${prefix}${major + 1}.0.0`,
|
|
566
|
+
value: `${prefix}${major + 1}.0.0`
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
name: `alpha \u2192 ${prefix}${major}.${minor}.${patch + 1}-alpha.1`,
|
|
570
|
+
value: `${prefix}${major}.${minor}.${patch + 1}-alpha.1`
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
name: `beta \u2192 ${prefix}${major}.${minor}.${patch + 1}-beta.1`,
|
|
574
|
+
value: `${prefix}${major}.${minor}.${patch + 1}-beta.1`
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
name: `rc \u2192 ${prefix}${major}.${minor}.${patch + 1}-rc.1`,
|
|
578
|
+
value: `${prefix}${major}.${minor}.${patch + 1}-rc.1`
|
|
579
|
+
}
|
|
580
|
+
];
|
|
581
|
+
} else if (match2) {
|
|
582
|
+
const [, majorStr, minorStr] = match2;
|
|
583
|
+
const major = Number(majorStr);
|
|
584
|
+
const minor = Number(minorStr);
|
|
585
|
+
choices = [
|
|
586
|
+
{
|
|
587
|
+
name: `minor \u2192 ${prefix}${major}.${minor + 1}`,
|
|
588
|
+
value: `${prefix}${major}.${minor + 1}`
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
name: `major \u2192 ${prefix}${major + 1}.0`,
|
|
592
|
+
value: `${prefix}${major + 1}.0`
|
|
593
|
+
}
|
|
594
|
+
];
|
|
595
|
+
} else if (match1) {
|
|
596
|
+
const num = Number(match1[1]);
|
|
597
|
+
choices = [
|
|
598
|
+
{ name: `next \u2192 ${prefix}${num + 1}`, value: `${prefix}${num + 1}` }
|
|
599
|
+
];
|
|
600
|
+
} else {
|
|
601
|
+
console.log(colors.red(`\u65E0\u6CD5\u89E3\u6790\u7248\u672C\u53F7: ${version2}`));
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
choices.push({ name: "\u53D6\u6D88", value: "__cancel__" });
|
|
605
|
+
const nextTag = await select2({
|
|
606
|
+
message: "\u9009\u62E9\u7248\u672C\u7C7B\u578B:",
|
|
607
|
+
choices,
|
|
608
|
+
theme
|
|
609
|
+
});
|
|
610
|
+
if (nextTag === "__cancel__") {
|
|
611
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
doCreateTag(nextTag);
|
|
615
|
+
}
|
|
616
|
+
function doCreateTag(tagName) {
|
|
617
|
+
divider();
|
|
618
|
+
const spinner = ora2(`\u6B63\u5728\u521B\u5EFA tag: ${tagName}`).start();
|
|
619
|
+
try {
|
|
620
|
+
execSync3(`git tag -a "${tagName}" -m "Release ${tagName}"`, {
|
|
621
|
+
stdio: "pipe"
|
|
622
|
+
});
|
|
623
|
+
spinner.succeed(`Tag \u521B\u5EFA\u6210\u529F: ${tagName}`);
|
|
624
|
+
} catch {
|
|
625
|
+
spinner.fail("tag \u521B\u5EFA\u5931\u8D25");
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
const pushSpinner = ora2("\u6B63\u5728\u63A8\u9001\u5230\u8FDC\u7A0B...").start();
|
|
629
|
+
try {
|
|
630
|
+
execSync3(`git push origin "${tagName}"`, { stdio: "pipe" });
|
|
631
|
+
pushSpinner.succeed(`Tag \u5DF2\u63A8\u9001: ${tagName}`);
|
|
632
|
+
} catch {
|
|
633
|
+
pushSpinner.warn(
|
|
634
|
+
`\u8FDC\u7A0B\u63A8\u9001\u5931\u8D25\uFF0C\u53EF\u7A0D\u540E\u624B\u52A8\u6267\u884C: git push origin ${tagName}`
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// src/commands/release.ts
|
|
640
|
+
import { readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
641
|
+
import { select as select3 } from "@inquirer/prompts";
|
|
642
|
+
function getPackageVersion() {
|
|
643
|
+
const pkg = JSON.parse(readFileSync2("package.json", "utf-8"));
|
|
644
|
+
return pkg.version || "0.0.0";
|
|
645
|
+
}
|
|
646
|
+
function setPackageVersion(version2) {
|
|
647
|
+
const pkg = JSON.parse(readFileSync2("package.json", "utf-8"));
|
|
648
|
+
pkg.version = version2;
|
|
649
|
+
writeFileSync("package.json", JSON.stringify(pkg, null, " ") + "\n");
|
|
650
|
+
}
|
|
651
|
+
function generateChoices(current) {
|
|
652
|
+
const preReleaseMatch = current.match(
|
|
653
|
+
/^(\d+)\.(\d+)\.(\d+)-([a-zA-Z]+)\.(\d+)$/
|
|
654
|
+
);
|
|
655
|
+
const match = current.match(/^(\d+)\.(\d+)\.(\d+)$/);
|
|
656
|
+
if (preReleaseMatch) {
|
|
657
|
+
const [, majorStr, minorStr, patchStr, preTag, preNumStr] = preReleaseMatch;
|
|
658
|
+
const major = Number(majorStr);
|
|
659
|
+
const minor = Number(minorStr);
|
|
660
|
+
const patch = Number(patchStr);
|
|
661
|
+
const preNum = Number(preNumStr);
|
|
662
|
+
const baseVersion = `${major}.${minor}.${patch}`;
|
|
663
|
+
return [
|
|
664
|
+
{
|
|
665
|
+
name: `pre \u2192 ${baseVersion}-${preTag}.${preNum + 1}`,
|
|
666
|
+
value: `${baseVersion}-${preTag}.${preNum + 1}`
|
|
667
|
+
},
|
|
668
|
+
{ name: `release \u2192 ${baseVersion}`, value: baseVersion },
|
|
669
|
+
{
|
|
670
|
+
name: `patch \u2192 ${major}.${minor}.${patch + 1}`,
|
|
671
|
+
value: `${major}.${minor}.${patch + 1}`
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
name: `minor \u2192 ${major}.${minor + 1}.0`,
|
|
675
|
+
value: `${major}.${minor + 1}.0`
|
|
676
|
+
},
|
|
677
|
+
{ name: `major \u2192 ${major + 1}.0.0`, value: `${major + 1}.0.0` }
|
|
678
|
+
];
|
|
679
|
+
}
|
|
680
|
+
if (match) {
|
|
681
|
+
const [, majorStr, minorStr, patchStr] = match;
|
|
682
|
+
const major = Number(majorStr);
|
|
683
|
+
const minor = Number(minorStr);
|
|
684
|
+
const patch = Number(patchStr);
|
|
685
|
+
return [
|
|
686
|
+
{
|
|
687
|
+
name: `patch \u2192 ${major}.${minor}.${patch + 1}`,
|
|
688
|
+
value: `${major}.${minor}.${patch + 1}`
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
name: `minor \u2192 ${major}.${minor + 1}.0`,
|
|
692
|
+
value: `${major}.${minor + 1}.0`
|
|
693
|
+
},
|
|
694
|
+
{ name: `major \u2192 ${major + 1}.0.0`, value: `${major + 1}.0.0` },
|
|
695
|
+
{
|
|
696
|
+
name: `alpha \u2192 ${major}.${minor}.${patch + 1}-alpha.1`,
|
|
697
|
+
value: `${major}.${minor}.${patch + 1}-alpha.1`
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
name: `beta \u2192 ${major}.${minor}.${patch + 1}-beta.1`,
|
|
701
|
+
value: `${major}.${minor}.${patch + 1}-beta.1`
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
name: `rc \u2192 ${major}.${minor}.${patch + 1}-rc.1`,
|
|
705
|
+
value: `${major}.${minor}.${patch + 1}-rc.1`
|
|
706
|
+
}
|
|
707
|
+
];
|
|
708
|
+
}
|
|
709
|
+
return [
|
|
710
|
+
{ name: `patch \u2192 0.0.1`, value: "0.0.1" },
|
|
711
|
+
{ name: `minor \u2192 0.1.0`, value: "0.1.0" },
|
|
712
|
+
{ name: `major \u2192 1.0.0`, value: "1.0.0" }
|
|
713
|
+
];
|
|
714
|
+
}
|
|
715
|
+
async function release() {
|
|
716
|
+
const currentVersion = getPackageVersion();
|
|
717
|
+
console.log(colors.yellow(`\u5F53\u524D\u7248\u672C: ${currentVersion}`));
|
|
718
|
+
divider();
|
|
719
|
+
const choices = generateChoices(currentVersion);
|
|
720
|
+
choices.push({ name: "\u53D6\u6D88", value: "__cancel__" });
|
|
721
|
+
const nextVersion = await select3({
|
|
722
|
+
message: "\u9009\u62E9\u65B0\u7248\u672C:",
|
|
723
|
+
choices,
|
|
724
|
+
theme
|
|
725
|
+
});
|
|
726
|
+
if (nextVersion === "__cancel__") {
|
|
727
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
setPackageVersion(nextVersion);
|
|
731
|
+
divider();
|
|
732
|
+
console.log(
|
|
733
|
+
colors.green(`\u2713 \u7248\u672C\u53F7\u5DF2\u66F4\u65B0: ${currentVersion} \u2192 ${nextVersion}`)
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// src/commands/init.ts
|
|
738
|
+
import { existsSync as existsSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
739
|
+
import { select as select4, input as input3, confirm } from "@inquirer/prompts";
|
|
740
|
+
var CONFIG_FILE = ".gwrc.json";
|
|
741
|
+
var DEFAULT_COMMIT_EMOJIS = {
|
|
742
|
+
feat: "\u2728",
|
|
743
|
+
fix: "\u{1F41B}",
|
|
744
|
+
docs: "\u{1F4DD}",
|
|
745
|
+
style: "\u{1F484}",
|
|
746
|
+
refactor: "\u267B\uFE0F",
|
|
747
|
+
perf: "\u26A1\uFE0F",
|
|
748
|
+
test: "\u2705",
|
|
749
|
+
build: "\u{1F4E6}",
|
|
750
|
+
ci: "\u{1F477}",
|
|
751
|
+
chore: "\u{1F527}",
|
|
752
|
+
revert: "\u23EA"
|
|
753
|
+
};
|
|
754
|
+
async function init() {
|
|
755
|
+
if (existsSync2(CONFIG_FILE)) {
|
|
756
|
+
const overwrite = await confirm({
|
|
757
|
+
message: `${CONFIG_FILE} \u5DF2\u5B58\u5728\uFF0C\u662F\u5426\u8986\u76D6?`,
|
|
758
|
+
default: false,
|
|
759
|
+
theme
|
|
760
|
+
});
|
|
761
|
+
if (!overwrite) {
|
|
762
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
console.log(colors.dim("\u914D\u7F6E git-workflow\uFF0C\u76F4\u63A5\u56DE\u8F66\u4F7F\u7528\u9ED8\u8BA4\u503C\n"));
|
|
767
|
+
const config2 = {};
|
|
768
|
+
const baseBranch = await input3({
|
|
769
|
+
message: "\u9ED8\u8BA4\u57FA\u7840\u5206\u652F (\u7559\u7A7A\u81EA\u52A8\u68C0\u6D4B main/master):",
|
|
770
|
+
theme
|
|
771
|
+
});
|
|
772
|
+
if (baseBranch) config2.baseBranch = baseBranch;
|
|
773
|
+
divider();
|
|
774
|
+
const featurePrefix = await input3({
|
|
775
|
+
message: "Feature \u5206\u652F\u524D\u7F00:",
|
|
776
|
+
default: "feature",
|
|
777
|
+
theme
|
|
778
|
+
});
|
|
779
|
+
if (featurePrefix !== "feature") config2.featurePrefix = featurePrefix;
|
|
780
|
+
const hotfixPrefix = await input3({
|
|
781
|
+
message: "Hotfix \u5206\u652F\u524D\u7F00:",
|
|
782
|
+
default: "hotfix",
|
|
783
|
+
theme
|
|
784
|
+
});
|
|
785
|
+
if (hotfixPrefix !== "hotfix") config2.hotfixPrefix = hotfixPrefix;
|
|
786
|
+
divider();
|
|
787
|
+
const requireId = await confirm({
|
|
788
|
+
message: "\u662F\u5426\u8981\u6C42\u5FC5\u586B ID (Story ID / Issue ID)?",
|
|
789
|
+
default: false,
|
|
790
|
+
theme
|
|
791
|
+
});
|
|
792
|
+
if (requireId) config2.requireId = true;
|
|
793
|
+
const featureIdLabel = await input3({
|
|
794
|
+
message: "Feature \u5206\u652F ID \u6807\u7B7E:",
|
|
795
|
+
default: "Story ID",
|
|
796
|
+
theme
|
|
797
|
+
});
|
|
798
|
+
if (featureIdLabel !== "Story ID") config2.featureIdLabel = featureIdLabel;
|
|
799
|
+
const hotfixIdLabel = await input3({
|
|
800
|
+
message: "Hotfix \u5206\u652F ID \u6807\u7B7E:",
|
|
801
|
+
default: "Issue ID",
|
|
802
|
+
theme
|
|
803
|
+
});
|
|
804
|
+
if (hotfixIdLabel !== "Issue ID") config2.hotfixIdLabel = hotfixIdLabel;
|
|
805
|
+
divider();
|
|
806
|
+
const defaultTagPrefix = await input3({
|
|
807
|
+
message: "\u9ED8\u8BA4 Tag \u524D\u7F00 (\u7559\u7A7A\u5219\u6BCF\u6B21\u9009\u62E9):",
|
|
808
|
+
theme
|
|
809
|
+
});
|
|
810
|
+
if (defaultTagPrefix) config2.defaultTagPrefix = defaultTagPrefix;
|
|
811
|
+
const autoPushChoice = await select4({
|
|
812
|
+
message: "\u521B\u5EFA\u5206\u652F\u540E\u662F\u5426\u81EA\u52A8\u63A8\u9001?",
|
|
813
|
+
choices: [
|
|
814
|
+
{ name: "\u6BCF\u6B21\u8BE2\u95EE", value: "ask" },
|
|
815
|
+
{ name: "\u81EA\u52A8\u63A8\u9001", value: "yes" },
|
|
816
|
+
{ name: "\u4E0D\u63A8\u9001", value: "no" }
|
|
817
|
+
],
|
|
818
|
+
theme
|
|
819
|
+
});
|
|
820
|
+
if (autoPushChoice === "yes") config2.autoPush = true;
|
|
821
|
+
if (autoPushChoice === "no") config2.autoPush = false;
|
|
822
|
+
divider();
|
|
823
|
+
const autoStage = await confirm({
|
|
824
|
+
message: "Commit \u65F6\u662F\u5426\u81EA\u52A8\u6682\u5B58\u6240\u6709\u66F4\u6539?",
|
|
825
|
+
default: true,
|
|
826
|
+
theme
|
|
827
|
+
});
|
|
828
|
+
if (!autoStage) config2.autoStage = false;
|
|
829
|
+
const useEmoji = await confirm({
|
|
830
|
+
message: "Commit \u65F6\u662F\u5426\u4F7F\u7528 emoji?",
|
|
831
|
+
default: true,
|
|
832
|
+
theme
|
|
833
|
+
});
|
|
834
|
+
if (!useEmoji) config2.useEmoji = false;
|
|
835
|
+
config2.commitEmojis = DEFAULT_COMMIT_EMOJIS;
|
|
836
|
+
divider();
|
|
837
|
+
const content = JSON.stringify(config2, null, 2);
|
|
838
|
+
writeFileSync2(CONFIG_FILE, content + "\n");
|
|
839
|
+
console.log(colors.green(`\u2713 \u914D\u7F6E\u5DF2\u4FDD\u5B58\u5230 ${CONFIG_FILE}`));
|
|
840
|
+
console.log(
|
|
841
|
+
colors.dim(
|
|
842
|
+
"\n\u63D0\u793A: \u53EF\u4EE5\u5728\u914D\u7F6E\u6587\u4EF6\u4E2D\u4FEE\u6539 commitEmojis \u6765\u81EA\u5B9A\u4E49\u5404\u7C7B\u578B\u7684 emoji"
|
|
843
|
+
)
|
|
844
|
+
);
|
|
845
|
+
console.log(colors.dim("\n" + content));
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
// src/commands/stash.ts
|
|
849
|
+
import { execSync as execSync4 } from "child_process";
|
|
850
|
+
import { select as select5, input as input4 } from "@inquirer/prompts";
|
|
851
|
+
import ora3 from "ora";
|
|
852
|
+
function parseStashList() {
|
|
853
|
+
const raw = execOutput('git stash list --format="%gd|%s|%ar"');
|
|
854
|
+
if (!raw) return [];
|
|
855
|
+
return raw.split("\n").filter(Boolean).map((line) => {
|
|
856
|
+
const [ref, subject, date] = line.split("|");
|
|
857
|
+
const index = parseInt(ref.match(/stash@\{(\d+)\}/)?.[1] || "0");
|
|
858
|
+
const branchMatch = subject.match(/(?:WIP on|On) ([^:]+):/);
|
|
859
|
+
const branch = branchMatch?.[1] || "unknown";
|
|
860
|
+
let message = subject.replace(/(?:WIP on|On) [^:]+:\s*/, "");
|
|
861
|
+
if (subject.startsWith("WIP")) {
|
|
862
|
+
message = message.replace(/^[a-f0-9]+ /, "");
|
|
863
|
+
}
|
|
864
|
+
message = message || "(no message)";
|
|
865
|
+
const filesRaw = execOutput(
|
|
866
|
+
`git stash show stash@{${index}} --name-only 2>/dev/null`
|
|
867
|
+
);
|
|
868
|
+
const files = filesRaw ? filesRaw.split("\n").filter(Boolean) : [];
|
|
869
|
+
return { index, branch, message, date, files };
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
function formatStashChoice(entry) {
|
|
873
|
+
const fileCount = entry.files.length;
|
|
874
|
+
const filesInfo = fileCount > 0 ? colors.dim(` (${fileCount} \u6587\u4EF6)`) : "";
|
|
875
|
+
return `${colors.yellow(`[${entry.index}]`)} ${colors.green(entry.branch)} ${entry.message}${filesInfo} ${colors.dim(entry.date)}`;
|
|
876
|
+
}
|
|
877
|
+
function showStashDetail(entry) {
|
|
878
|
+
console.log();
|
|
879
|
+
console.log(colors.yellow(`Stash #${entry.index}`));
|
|
880
|
+
console.log(`\u5206\u652F: ${colors.green(entry.branch)}`);
|
|
881
|
+
console.log(`\u6D88\u606F: ${entry.message}`);
|
|
882
|
+
console.log(`\u65F6\u95F4: ${colors.dim(entry.date)}`);
|
|
883
|
+
if (entry.files.length > 0) {
|
|
884
|
+
console.log(`\u6587\u4EF6 (${entry.files.length}):`);
|
|
885
|
+
entry.files.slice(0, 10).forEach((f) => console.log(` ${colors.dim("\u2022")} ${f}`));
|
|
886
|
+
if (entry.files.length > 10) {
|
|
887
|
+
console.log(colors.dim(` ... \u8FD8\u6709 ${entry.files.length - 10} \u4E2A\u6587\u4EF6`));
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
async function stash() {
|
|
892
|
+
const entries = parseStashList();
|
|
893
|
+
if (entries.length === 0) {
|
|
894
|
+
console.log(colors.yellow("\u6CA1\u6709 stash \u8BB0\u5F55"));
|
|
895
|
+
const status = execOutput("git status --porcelain");
|
|
896
|
+
if (status) {
|
|
897
|
+
const doStash = await select5({
|
|
898
|
+
message: "\u68C0\u6D4B\u5230\u672A\u63D0\u4EA4\u7684\u53D8\u66F4\uFF0C\u662F\u5426\u521B\u5EFA stash?",
|
|
899
|
+
choices: [
|
|
900
|
+
{ name: "\u662F", value: true },
|
|
901
|
+
{ name: "\u5426", value: false }
|
|
902
|
+
],
|
|
903
|
+
theme
|
|
904
|
+
});
|
|
905
|
+
if (doStash) {
|
|
906
|
+
await createStash();
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
console.log(colors.green(`\u5171 ${entries.length} \u4E2A stash:
|
|
912
|
+
`));
|
|
913
|
+
const choices = entries.map((entry2) => ({
|
|
914
|
+
name: formatStashChoice(entry2),
|
|
915
|
+
value: entry2.index.toString()
|
|
916
|
+
}));
|
|
917
|
+
choices.push({ name: colors.dim("+ \u521B\u5EFA\u65B0 stash"), value: "__new__" });
|
|
918
|
+
choices.push({ name: colors.dim("\u53D6\u6D88"), value: "__cancel__" });
|
|
919
|
+
const selected = await select5({
|
|
920
|
+
message: "\u9009\u62E9 stash:",
|
|
921
|
+
choices,
|
|
922
|
+
theme
|
|
923
|
+
});
|
|
924
|
+
if (selected === "__cancel__") {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
if (selected === "__new__") {
|
|
928
|
+
await createStash();
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
const entry = entries.find((e) => e.index.toString() === selected);
|
|
932
|
+
await showStashActions(entry);
|
|
933
|
+
}
|
|
934
|
+
async function showStashActions(entry) {
|
|
935
|
+
showStashDetail(entry);
|
|
936
|
+
divider();
|
|
937
|
+
const action = await select5({
|
|
938
|
+
message: "\u64CD\u4F5C:",
|
|
939
|
+
choices: [
|
|
940
|
+
{ name: "\u5E94\u7528 (\u4FDD\u7559 stash)", value: "apply" },
|
|
941
|
+
{ name: "\u5F39\u51FA (\u5E94\u7528\u5E76\u5220\u9664)", value: "pop" },
|
|
942
|
+
{ name: "\u521B\u5EFA\u5206\u652F", value: "branch" },
|
|
943
|
+
{ name: "\u67E5\u770B\u5DEE\u5F02", value: "diff" },
|
|
944
|
+
{ name: "\u5220\u9664", value: "drop" },
|
|
945
|
+
{ name: "\u8FD4\u56DE\u5217\u8868", value: "back" },
|
|
946
|
+
{ name: "\u53D6\u6D88", value: "cancel" }
|
|
947
|
+
],
|
|
948
|
+
theme
|
|
949
|
+
});
|
|
950
|
+
switch (action) {
|
|
951
|
+
case "apply":
|
|
952
|
+
applyStash(entry.index, false);
|
|
953
|
+
break;
|
|
954
|
+
case "pop":
|
|
955
|
+
applyStash(entry.index, true);
|
|
956
|
+
break;
|
|
957
|
+
case "branch":
|
|
958
|
+
await createBranchFromStash(entry.index);
|
|
959
|
+
break;
|
|
960
|
+
case "diff":
|
|
961
|
+
await showDiff(entry.index);
|
|
962
|
+
await showStashActions(entry);
|
|
963
|
+
break;
|
|
964
|
+
case "drop":
|
|
965
|
+
await dropStash(entry.index);
|
|
966
|
+
break;
|
|
967
|
+
case "back":
|
|
968
|
+
await stash();
|
|
969
|
+
break;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
async function createStash() {
|
|
973
|
+
const status = execOutput("git status --porcelain");
|
|
974
|
+
if (!status) {
|
|
975
|
+
console.log(colors.yellow("\u6CA1\u6709\u9700\u8981 stash \u7684\u53D8\u66F4"));
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
const hasUntracked = status.split("\n").some((line) => line.startsWith("??"));
|
|
979
|
+
let includeUntracked = false;
|
|
980
|
+
if (hasUntracked) {
|
|
981
|
+
includeUntracked = await select5({
|
|
982
|
+
message: "\u68C0\u6D4B\u5230\u672A\u8DDF\u8E2A\u7684\u6587\u4EF6\uFF0C\u662F\u5426\u4E00\u5E76 stash?",
|
|
983
|
+
choices: [
|
|
984
|
+
{ name: "\u662F (\u5305\u542B\u672A\u8DDF\u8E2A\u6587\u4EF6)", value: true },
|
|
985
|
+
{ name: "\u5426 (\u4EC5\u5DF2\u8DDF\u8E2A\u6587\u4EF6)", value: false }
|
|
986
|
+
],
|
|
987
|
+
theme
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
const message = await input4({
|
|
991
|
+
message: "Stash \u6D88\u606F (\u53EF\u9009):",
|
|
992
|
+
theme
|
|
993
|
+
});
|
|
994
|
+
const spinner = ora3("\u521B\u5EFA stash...").start();
|
|
995
|
+
try {
|
|
996
|
+
let cmd = "git stash push";
|
|
997
|
+
if (includeUntracked) cmd += " -u";
|
|
998
|
+
if (message) cmd += ` -m "${message.replace(/"/g, '\\"')}"`;
|
|
999
|
+
execSync4(cmd, { stdio: "pipe" });
|
|
1000
|
+
spinner.succeed("Stash \u521B\u5EFA\u6210\u529F");
|
|
1001
|
+
await stash();
|
|
1002
|
+
} catch {
|
|
1003
|
+
spinner.fail("Stash \u521B\u5EFA\u5931\u8D25");
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
function applyStash(index, pop) {
|
|
1007
|
+
const action = pop ? "pop" : "apply";
|
|
1008
|
+
const spinner = ora3(`${pop ? "\u5F39\u51FA" : "\u5E94\u7528"} stash...`).start();
|
|
1009
|
+
try {
|
|
1010
|
+
execSync4(`git stash ${action} stash@{${index}}`, { stdio: "pipe" });
|
|
1011
|
+
spinner.succeed(`Stash ${pop ? "\u5DF2\u5F39\u51FA" : "\u5DF2\u5E94\u7528"}`);
|
|
1012
|
+
} catch {
|
|
1013
|
+
spinner.fail("\u64CD\u4F5C\u5931\u8D25\uFF0C\u53EF\u80FD\u5B58\u5728\u51B2\u7A81");
|
|
1014
|
+
const status = execOutput("git status --porcelain");
|
|
1015
|
+
if (status.includes("UU") || status.includes("AA")) {
|
|
1016
|
+
console.log(colors.yellow("\n\u5B58\u5728\u51B2\u7A81\uFF0C\u8BF7\u624B\u52A8\u89E3\u51B3\u540E\u63D0\u4EA4"));
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
async function showDiff(index) {
|
|
1021
|
+
try {
|
|
1022
|
+
execSync4(`git stash show -p --color=always stash@{${index}}`, {
|
|
1023
|
+
stdio: "inherit"
|
|
1024
|
+
});
|
|
1025
|
+
console.log();
|
|
1026
|
+
await input4({
|
|
1027
|
+
message: colors.dim("\u6309 Enter \u8FD4\u56DE\u83DC\u5355..."),
|
|
1028
|
+
theme
|
|
1029
|
+
});
|
|
1030
|
+
} catch {
|
|
1031
|
+
console.log(colors.red("\u65E0\u6CD5\u663E\u793A\u5DEE\u5F02"));
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
async function createBranchFromStash(index) {
|
|
1035
|
+
const type = await select5({
|
|
1036
|
+
message: "\u9009\u62E9\u5206\u652F\u7C7B\u578B:",
|
|
1037
|
+
choices: [
|
|
1038
|
+
{ name: "feature", value: "feature" },
|
|
1039
|
+
{ name: "hotfix", value: "hotfix" },
|
|
1040
|
+
{ name: "\u53D6\u6D88", value: "__cancel__" }
|
|
1041
|
+
],
|
|
1042
|
+
theme
|
|
1043
|
+
});
|
|
1044
|
+
if (type === "__cancel__") {
|
|
1045
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
const branchName = await getBranchName(type);
|
|
1049
|
+
if (!branchName) return;
|
|
1050
|
+
const spinner = ora3(`\u521B\u5EFA\u5206\u652F ${branchName}...`).start();
|
|
1051
|
+
try {
|
|
1052
|
+
execSync4(`git stash branch "${branchName}" stash@{${index}}`, {
|
|
1053
|
+
stdio: "pipe"
|
|
1054
|
+
});
|
|
1055
|
+
spinner.succeed(`\u5206\u652F\u5DF2\u521B\u5EFA: ${branchName} (stash \u5DF2\u81EA\u52A8\u5F39\u51FA)`);
|
|
1056
|
+
} catch {
|
|
1057
|
+
spinner.fail("\u521B\u5EFA\u5206\u652F\u5931\u8D25");
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
async function dropStash(index) {
|
|
1061
|
+
const confirmed = await select5({
|
|
1062
|
+
message: `\u786E\u8BA4\u5220\u9664 stash@{${index}}?`,
|
|
1063
|
+
choices: [
|
|
1064
|
+
{ name: "\u662F", value: true },
|
|
1065
|
+
{ name: "\u5426", value: false }
|
|
1066
|
+
],
|
|
1067
|
+
theme
|
|
1068
|
+
});
|
|
1069
|
+
if (!confirmed) {
|
|
1070
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
const spinner = ora3("\u5220\u9664 stash...").start();
|
|
1074
|
+
try {
|
|
1075
|
+
execSync4(`git stash drop stash@{${index}}`, { stdio: "pipe" });
|
|
1076
|
+
spinner.succeed("Stash \u5DF2\u5220\u9664");
|
|
1077
|
+
} catch {
|
|
1078
|
+
spinner.fail("\u5220\u9664\u5931\u8D25");
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// src/commands/commit.ts
|
|
1083
|
+
import { execSync as execSync5 } from "child_process";
|
|
1084
|
+
import { select as select6, input as input5, confirm as confirm2, checkbox } from "@inquirer/prompts";
|
|
1085
|
+
import ora4 from "ora";
|
|
1086
|
+
var DEFAULT_COMMIT_TYPES = [
|
|
1087
|
+
{ type: "feat", emoji: "\u2728", description: "\u65B0\u529F\u80FD" },
|
|
1088
|
+
{ type: "fix", emoji: "\u{1F41B}", description: "\u4FEE\u590D Bug" },
|
|
1089
|
+
{ type: "docs", emoji: "\u{1F4DD}", description: "\u6587\u6863\u66F4\u65B0" },
|
|
1090
|
+
{ type: "style", emoji: "\u{1F484}", description: "\u4EE3\u7801\u683C\u5F0F (\u4E0D\u5F71\u54CD\u529F\u80FD)" },
|
|
1091
|
+
{ type: "refactor", emoji: "\u267B\uFE0F", description: "\u91CD\u6784 (\u975E\u65B0\u529F\u80FD/\u4FEE\u590D)" },
|
|
1092
|
+
{ type: "perf", emoji: "\u26A1\uFE0F", description: "\u6027\u80FD\u4F18\u5316" },
|
|
1093
|
+
{ type: "test", emoji: "\u2705", description: "\u6D4B\u8BD5\u76F8\u5173" },
|
|
1094
|
+
{ type: "build", emoji: "\u{1F4E6}", description: "\u6784\u5EFA/\u4F9D\u8D56\u76F8\u5173" },
|
|
1095
|
+
{ type: "ci", emoji: "\u{1F477}", description: "CI/CD \u76F8\u5173" },
|
|
1096
|
+
{ type: "chore", emoji: "\u{1F527}", description: "\u5176\u4ED6\u6742\u9879" },
|
|
1097
|
+
{ type: "revert", emoji: "\u23EA", description: "\u56DE\u9000\u63D0\u4EA4" }
|
|
1098
|
+
];
|
|
1099
|
+
function getCommitTypes(config2) {
|
|
1100
|
+
const customEmojis = config2.commitEmojis || {};
|
|
1101
|
+
return DEFAULT_COMMIT_TYPES.map((item) => ({
|
|
1102
|
+
...item,
|
|
1103
|
+
emoji: customEmojis[item.type] || item.emoji
|
|
1104
|
+
}));
|
|
1105
|
+
}
|
|
1106
|
+
function parseGitStatus() {
|
|
1107
|
+
const output = execOutput("git status --porcelain");
|
|
1108
|
+
if (!output) return { staged: [], unstaged: [] };
|
|
1109
|
+
const staged = [];
|
|
1110
|
+
const unstaged = [];
|
|
1111
|
+
for (const line of output.split("\n")) {
|
|
1112
|
+
if (!line) continue;
|
|
1113
|
+
const indexStatus = line[0];
|
|
1114
|
+
const workTreeStatus = line[1];
|
|
1115
|
+
const file = line.slice(3);
|
|
1116
|
+
if (indexStatus !== " " && indexStatus !== "?") {
|
|
1117
|
+
staged.push({ status: indexStatus, file });
|
|
1118
|
+
}
|
|
1119
|
+
if (workTreeStatus !== " " || indexStatus === "?") {
|
|
1120
|
+
const status = indexStatus === "?" ? "?" : workTreeStatus;
|
|
1121
|
+
unstaged.push({ status, file });
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
return { staged, unstaged };
|
|
1125
|
+
}
|
|
1126
|
+
function formatFileStatus(status) {
|
|
1127
|
+
const statusMap = {
|
|
1128
|
+
M: colors.yellow("M"),
|
|
1129
|
+
A: colors.green("A"),
|
|
1130
|
+
D: colors.red("D"),
|
|
1131
|
+
R: colors.yellow("R"),
|
|
1132
|
+
C: colors.yellow("C"),
|
|
1133
|
+
"?": colors.green("?")
|
|
1134
|
+
};
|
|
1135
|
+
return statusMap[status] || status;
|
|
1136
|
+
}
|
|
1137
|
+
async function commit() {
|
|
1138
|
+
const config2 = getConfig();
|
|
1139
|
+
let { staged, unstaged } = parseGitStatus();
|
|
1140
|
+
if (staged.length === 0) {
|
|
1141
|
+
if (unstaged.length === 0) {
|
|
1142
|
+
console.log(colors.yellow("\u5DE5\u4F5C\u533A\u5E72\u51C0\uFF0C\u6CA1\u6709\u9700\u8981\u63D0\u4EA4\u7684\u66F4\u6539"));
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
console.log(colors.yellow("\u6CA1\u6709\u6682\u5B58\u7684\u66F4\u6539"));
|
|
1146
|
+
divider();
|
|
1147
|
+
console.log("\u672A\u6682\u5B58\u7684\u6587\u4EF6:");
|
|
1148
|
+
for (const { status, file } of unstaged) {
|
|
1149
|
+
console.log(` ${formatFileStatus(status)} ${file}`);
|
|
1150
|
+
}
|
|
1151
|
+
divider();
|
|
1152
|
+
const autoStage = config2.autoStage ?? true;
|
|
1153
|
+
if (autoStage) {
|
|
1154
|
+
execSync5("git add -A", { stdio: "pipe" });
|
|
1155
|
+
console.log(colors.green("\u2714 \u5DF2\u81EA\u52A8\u6682\u5B58\u6240\u6709\u66F4\u6539"));
|
|
1156
|
+
divider();
|
|
1157
|
+
const newStatus = parseGitStatus();
|
|
1158
|
+
staged = newStatus.staged;
|
|
1159
|
+
} else {
|
|
1160
|
+
const filesToStage = await checkbox({
|
|
1161
|
+
message: "\u9009\u62E9\u8981\u6682\u5B58\u7684\u6587\u4EF6:",
|
|
1162
|
+
choices: unstaged.map(({ status, file }) => ({
|
|
1163
|
+
name: `${formatFileStatus(status)} ${file}`,
|
|
1164
|
+
value: file,
|
|
1165
|
+
checked: true
|
|
1166
|
+
})),
|
|
1167
|
+
theme
|
|
1168
|
+
});
|
|
1169
|
+
if (filesToStage.length === 0) {
|
|
1170
|
+
console.log(colors.yellow("\u6CA1\u6709\u9009\u62E9\u4EFB\u4F55\u6587\u4EF6\uFF0C\u5DF2\u53D6\u6D88"));
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
for (const file of filesToStage) {
|
|
1174
|
+
execSync5(`git add "${file}"`, { stdio: "pipe" });
|
|
1175
|
+
}
|
|
1176
|
+
console.log(colors.green(`\u2714 \u5DF2\u6682\u5B58 ${filesToStage.length} \u4E2A\u6587\u4EF6`));
|
|
1177
|
+
divider();
|
|
1178
|
+
const newStatus = parseGitStatus();
|
|
1179
|
+
staged = newStatus.staged;
|
|
1180
|
+
}
|
|
1181
|
+
} else {
|
|
1182
|
+
console.log("\u5DF2\u6682\u5B58\u7684\u6587\u4EF6:");
|
|
1183
|
+
for (const { status, file } of staged) {
|
|
1184
|
+
console.log(` ${formatFileStatus(status)} ${file}`);
|
|
1185
|
+
}
|
|
1186
|
+
divider();
|
|
1187
|
+
}
|
|
1188
|
+
const commitTypes = getCommitTypes(config2);
|
|
1189
|
+
const typeChoice = await select6({
|
|
1190
|
+
message: "\u9009\u62E9\u63D0\u4EA4\u7C7B\u578B:",
|
|
1191
|
+
choices: commitTypes.map((t) => ({
|
|
1192
|
+
name: `${t.emoji} ${t.type.padEnd(10)} ${colors.dim(t.description)}`,
|
|
1193
|
+
value: t
|
|
1194
|
+
})),
|
|
1195
|
+
theme
|
|
1196
|
+
});
|
|
1197
|
+
const scope = await input5({
|
|
1198
|
+
message: "\u8F93\u5165\u5F71\u54CD\u8303\u56F4 scope (\u53EF\u8DF3\u8FC7):",
|
|
1199
|
+
theme
|
|
1200
|
+
});
|
|
1201
|
+
const subject = await input5({
|
|
1202
|
+
message: "\u8F93\u5165\u7B80\u77ED\u63CF\u8FF0:",
|
|
1203
|
+
validate: (value) => {
|
|
1204
|
+
if (!value.trim()) return "\u63CF\u8FF0\u4E0D\u80FD\u4E3A\u7A7A";
|
|
1205
|
+
if (value.length > 72) return "\u63CF\u8FF0\u4E0D\u80FD\u8D85\u8FC7 72 \u4E2A\u5B57\u7B26";
|
|
1206
|
+
return true;
|
|
1207
|
+
},
|
|
1208
|
+
theme
|
|
1209
|
+
});
|
|
1210
|
+
const body = await input5({
|
|
1211
|
+
message: "\u8F93\u5165\u8BE6\u7EC6\u63CF\u8FF0 (\u53EF\u8DF3\u8FC7):",
|
|
1212
|
+
theme
|
|
1213
|
+
});
|
|
1214
|
+
const hasBreaking = await confirm2({
|
|
1215
|
+
message: "\u662F\u5426\u5305\u542B\u7834\u574F\u6027\u53D8\u66F4 (BREAKING CHANGE)?",
|
|
1216
|
+
default: false,
|
|
1217
|
+
theme
|
|
1218
|
+
});
|
|
1219
|
+
let breakingDesc = "";
|
|
1220
|
+
if (hasBreaking) {
|
|
1221
|
+
breakingDesc = await input5({
|
|
1222
|
+
message: "\u63CF\u8FF0\u7834\u574F\u6027\u53D8\u66F4:",
|
|
1223
|
+
validate: (value) => value.trim() ? true : "\u8BF7\u63CF\u8FF0\u7834\u574F\u6027\u53D8\u66F4",
|
|
1224
|
+
theme
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
const issues = await input5({
|
|
1228
|
+
message: "\u5173\u8054 Issue (\u5982 #123, \u53EF\u8DF3\u8FC7):",
|
|
1229
|
+
theme
|
|
1230
|
+
});
|
|
1231
|
+
const { type, emoji } = typeChoice;
|
|
1232
|
+
const scopePart = scope ? `(${scope})` : "";
|
|
1233
|
+
const breakingMark = hasBreaking ? "!" : "";
|
|
1234
|
+
const useEmoji = config2.useEmoji ?? true;
|
|
1235
|
+
const emojiPrefix = useEmoji ? `${emoji} ` : "";
|
|
1236
|
+
let message = `${emojiPrefix}${type}${scopePart}${breakingMark}: ${subject}`;
|
|
1237
|
+
if (body || hasBreaking || issues) {
|
|
1238
|
+
message += "\n";
|
|
1239
|
+
if (body) {
|
|
1240
|
+
message += `
|
|
1241
|
+
${body}`;
|
|
1242
|
+
}
|
|
1243
|
+
if (hasBreaking) {
|
|
1244
|
+
message += `
|
|
1245
|
+
|
|
1246
|
+
BREAKING CHANGE: ${breakingDesc}`;
|
|
1247
|
+
}
|
|
1248
|
+
if (issues) {
|
|
1249
|
+
message += `
|
|
1250
|
+
|
|
1251
|
+
${issues}`;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
divider();
|
|
1255
|
+
console.log("\u63D0\u4EA4\u4FE1\u606F\u9884\u89C8:");
|
|
1256
|
+
console.log(colors.green(message));
|
|
1257
|
+
divider();
|
|
1258
|
+
const shouldCommit = await confirm2({
|
|
1259
|
+
message: "\u786E\u8BA4\u63D0\u4EA4?",
|
|
1260
|
+
default: true,
|
|
1261
|
+
theme
|
|
1262
|
+
});
|
|
1263
|
+
if (!shouldCommit) {
|
|
1264
|
+
console.log(colors.yellow("\u5DF2\u53D6\u6D88"));
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
const spinner = ora4("\u6B63\u5728\u63D0\u4EA4...").start();
|
|
1268
|
+
try {
|
|
1269
|
+
const escapedMessage = message.replace(/"/g, '\\"');
|
|
1270
|
+
execSync5(`git commit -m "${escapedMessage}"`, { stdio: "pipe" });
|
|
1271
|
+
spinner.succeed("\u63D0\u4EA4\u6210\u529F");
|
|
1272
|
+
const commitHash = execOutput("git rev-parse --short HEAD");
|
|
1273
|
+
console.log(colors.dim(`commit: ${commitHash}`));
|
|
1274
|
+
} catch (error) {
|
|
1275
|
+
spinner.fail("\u63D0\u4EA4\u5931\u8D25");
|
|
1276
|
+
if (error instanceof Error) {
|
|
1277
|
+
console.log(colors.red(error.message));
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
// src/commands/help.ts
|
|
1283
|
+
function showHelp() {
|
|
1284
|
+
return `
|
|
33
1285
|
\u5206\u652F\u547D\u4EE4:
|
|
34
1286
|
gw feature [--base <branch>] \u521B\u5EFA feature \u5206\u652F
|
|
35
1287
|
gw feat [--base <branch>] \u540C\u4E0A (\u522B\u540D)
|
|
@@ -80,15 +1332,309 @@ Commit \u547D\u4EE4:
|
|
|
80
1332
|
gw c \u4EA4\u4E92\u5F0F\u63D0\u4EA4\u4EE3\u7801
|
|
81
1333
|
|
|
82
1334
|
\u5206\u652F\u547D\u540D\u683C\u5F0F:
|
|
83
|
-
feature/${
|
|
84
|
-
hotfix/${
|
|
85
|
-
|
|
86
|
-
|
|
1335
|
+
feature/${TODAY}-<Story ID>-<\u63CF\u8FF0>
|
|
1336
|
+
hotfix/${TODAY}-<Issue ID>-<\u63CF\u8FF0>
|
|
1337
|
+
`;
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
// src/update-notifier.ts
|
|
1341
|
+
import { execSync as execSync6 } from "child_process";
|
|
1342
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync3 } from "fs";
|
|
1343
|
+
import { homedir } from "os";
|
|
1344
|
+
import { join as join2 } from "path";
|
|
1345
|
+
import boxen from "boxen";
|
|
1346
|
+
import { select as select7 } from "@inquirer/prompts";
|
|
1347
|
+
import ora5 from "ora";
|
|
1348
|
+
var DISMISS_INTERVAL = 1e3 * 60 * 60 * 24;
|
|
1349
|
+
var CACHE_FILE = ".gw-update-check";
|
|
1350
|
+
async function checkForUpdates(currentVersion, packageName = "@zjex/git-workflow") {
|
|
1351
|
+
try {
|
|
1352
|
+
const cache = readCache();
|
|
1353
|
+
const now = Date.now();
|
|
1354
|
+
if (cache?.lastDismiss && now - cache.lastDismiss < DISMISS_INTERVAL) {
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
const latestVersion = await getLatestVersion(packageName);
|
|
1358
|
+
if (latestVersion && latestVersion !== currentVersion) {
|
|
1359
|
+
const action = await showUpdateMessage(
|
|
1360
|
+
currentVersion,
|
|
1361
|
+
latestVersion,
|
|
1362
|
+
packageName
|
|
1363
|
+
);
|
|
1364
|
+
if (action === "update") {
|
|
1365
|
+
await performUpdate(packageName);
|
|
1366
|
+
} else if (action === "dismiss") {
|
|
1367
|
+
writeCache({ lastDismiss: now, latestVersion });
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
} catch (error) {
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
async function getLatestVersion(packageName) {
|
|
1374
|
+
try {
|
|
1375
|
+
const result = execSync6(`npm view ${packageName} version`, {
|
|
1376
|
+
encoding: "utf-8",
|
|
1377
|
+
timeout: 3e3,
|
|
1378
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
1379
|
+
// 忽略 stderr
|
|
1380
|
+
});
|
|
1381
|
+
return result.trim();
|
|
1382
|
+
} catch {
|
|
1383
|
+
return null;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
async function showUpdateMessage(current, latest, packageName) {
|
|
1387
|
+
const message = [
|
|
1388
|
+
colors.bold("\uFFFD \u53D1\u73B0\u65B0\u7248\u65B0\u672C\u53EF\u7528\uFF01"),
|
|
1389
|
+
"",
|
|
1390
|
+
`${colors.dim(current)} \u2192 ${colors.green(colors.bold(latest))}`
|
|
1391
|
+
].join("\n");
|
|
1392
|
+
console.log("");
|
|
1393
|
+
console.log(
|
|
1394
|
+
boxen(message, {
|
|
1395
|
+
padding: 1,
|
|
1396
|
+
margin: 1,
|
|
1397
|
+
borderStyle: "round",
|
|
1398
|
+
borderColor: "yellow",
|
|
1399
|
+
align: "left"
|
|
1400
|
+
})
|
|
1401
|
+
);
|
|
1402
|
+
try {
|
|
1403
|
+
const action = await select7({
|
|
1404
|
+
message: "\u4F60\u60F3\u505A\u4EC0\u4E48\uFF1F",
|
|
1405
|
+
choices: [
|
|
1406
|
+
{
|
|
1407
|
+
name: "\u{1F680} \u7ACB\u5373\u66F4\u65B0",
|
|
1408
|
+
value: "update",
|
|
1409
|
+
description: `\u8FD0\u884C npm install -g ${packageName}`
|
|
1410
|
+
},
|
|
1411
|
+
{
|
|
1412
|
+
name: "\u23ED\uFE0F \u7A0D\u540E\u66F4\u65B0\uFF0C\u7EE7\u7EED\u4F7F\u7528",
|
|
1413
|
+
value: "continue",
|
|
1414
|
+
description: "\u4E0B\u6B21\u542F\u52A8\u65F6\u4F1A\u518D\u6B21\u63D0\u793A"
|
|
1415
|
+
},
|
|
1416
|
+
{
|
|
1417
|
+
name: "\u{1F648} \u8DF3\u8FC7\u6B64\u7248\u672C (24h \u5185\u4E0D\u518D\u63D0\u793A)",
|
|
1418
|
+
value: "dismiss",
|
|
1419
|
+
description: "24 \u5C0F\u65F6\u5185\u4E0D\u4F1A\u518D\u63D0\u793A\u6B64\u7248\u672C"
|
|
1420
|
+
}
|
|
1421
|
+
]
|
|
1422
|
+
});
|
|
1423
|
+
return action;
|
|
1424
|
+
} catch (error) {
|
|
1425
|
+
console.log("");
|
|
1426
|
+
return "continue";
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
async function performUpdate(packageName) {
|
|
1430
|
+
console.log("");
|
|
1431
|
+
const spinner = ora5({
|
|
1432
|
+
text: "\u6B63\u5728\u66F4\u65B0...",
|
|
1433
|
+
spinner: "dots"
|
|
1434
|
+
}).start();
|
|
1435
|
+
try {
|
|
1436
|
+
try {
|
|
1437
|
+
execSync6("npm uninstall -g git-workflow", {
|
|
1438
|
+
encoding: "utf-8",
|
|
1439
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
1440
|
+
});
|
|
1441
|
+
spinner.text = "\u5DF2\u5378\u8F7D\u65E7\u7248\u672C\uFF0C\u6B63\u5728\u5B89\u88C5\u65B0\u7248\u672C...";
|
|
1442
|
+
} catch {
|
|
1443
|
+
}
|
|
1444
|
+
execSync6(`npm install -g ${packageName}`, {
|
|
1445
|
+
encoding: "utf-8",
|
|
1446
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
1447
|
+
});
|
|
1448
|
+
spinner.succeed(colors.green("\u66F4\u65B0\u6210\u529F\uFF01"));
|
|
1449
|
+
console.log("");
|
|
1450
|
+
console.log(colors.cyan(" \u63D0\u793A: \u8BF7\u91CD\u65B0\u8FD0\u884C\u547D\u4EE4\u4EE5\u4F7F\u7528\u65B0\u7248\u672C"));
|
|
1451
|
+
console.log("");
|
|
1452
|
+
process.exit(0);
|
|
1453
|
+
} catch (error) {
|
|
1454
|
+
spinner.fail(colors.red("\u66F4\u65B0\u5931\u8D25"));
|
|
1455
|
+
console.log("");
|
|
1456
|
+
console.log(colors.dim(" \u4F60\u53EF\u4EE5\u624B\u52A8\u8FD0\u884C\u4EE5\u4E0B\u547D\u4EE4\u66F4\u65B0:"));
|
|
1457
|
+
console.log(colors.yellow(" # \u5982\u679C\u4E4B\u524D\u5B89\u88C5\u8FC7\u65E7\u7248\u672C\uFF0C\u5148\u5378\u8F7D:"));
|
|
1458
|
+
console.log(colors.cyan(" npm uninstall -g git-workflow"));
|
|
1459
|
+
console.log("");
|
|
1460
|
+
console.log(colors.yellow(" # \u7136\u540E\u5B89\u88C5\u65B0\u7248\u672C:"));
|
|
1461
|
+
console.log(colors.cyan(` npm install -g ${packageName}`));
|
|
1462
|
+
console.log("");
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
function readCache() {
|
|
1466
|
+
try {
|
|
1467
|
+
const cacheFile = join2(homedir(), CACHE_FILE);
|
|
1468
|
+
if (!existsSync3(cacheFile)) {
|
|
1469
|
+
return null;
|
|
1470
|
+
}
|
|
1471
|
+
const content = readFileSync3(cacheFile, "utf-8");
|
|
1472
|
+
return JSON.parse(content);
|
|
1473
|
+
} catch {
|
|
1474
|
+
return null;
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
function writeCache(cache) {
|
|
1478
|
+
try {
|
|
1479
|
+
const cacheFile = join2(homedir(), CACHE_FILE);
|
|
1480
|
+
writeFileSync3(cacheFile, JSON.stringify(cache), "utf-8");
|
|
1481
|
+
} catch {
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
// src/index.ts
|
|
1486
|
+
process.on("uncaughtException", (err) => {
|
|
1487
|
+
if (err instanceof ExitPromptError) {
|
|
1488
|
+
process.exit(0);
|
|
1489
|
+
}
|
|
1490
|
+
console.error(err);
|
|
1491
|
+
process.exit(1);
|
|
1492
|
+
});
|
|
1493
|
+
var version = true ? "0.2.3" : (await null).default.version;
|
|
1494
|
+
async function mainMenu() {
|
|
1495
|
+
checkForUpdates(version, "@zjex/git-workflow").catch(() => {
|
|
1496
|
+
});
|
|
1497
|
+
console.log(
|
|
1498
|
+
colors.green(`
|
|
87
1499
|
\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557
|
|
88
1500
|
\u255A\u2550\u2550\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u255A\u2588\u2588\u2557\u2588\u2588\u2554\u255D
|
|
89
1501
|
\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557 \u255A\u2588\u2588\u2588\u2554\u255D
|
|
90
1502
|
\u2588\u2588\u2588\u2554\u255D \u2588\u2588 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2554\u2588\u2588\u2557
|
|
91
1503
|
\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2554\u255D \u2588\u2588\u2557
|
|
92
1504
|
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D
|
|
93
|
-
`)
|
|
94
|
-
|
|
1505
|
+
`)
|
|
1506
|
+
);
|
|
1507
|
+
console.log(colors.dim(` git-workflow v${version}
|
|
1508
|
+
`));
|
|
1509
|
+
const action = await select8({
|
|
1510
|
+
message: "\u9009\u62E9\u64CD\u4F5C:",
|
|
1511
|
+
choices: [
|
|
1512
|
+
{
|
|
1513
|
+
name: `[1] \u2728 \u521B\u5EFA feature \u5206\u652F ${colors.dim("gw f")}`,
|
|
1514
|
+
value: "feature"
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
name: `[2] \u{1F41B} \u521B\u5EFA hotfix \u5206\u652F ${colors.dim("gw h")}`,
|
|
1518
|
+
value: "hotfix"
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
name: `[3] \u{1F5D1}\uFE0F \u5220\u9664\u5206\u652F ${colors.dim("gw d")}`,
|
|
1522
|
+
value: "delete"
|
|
1523
|
+
},
|
|
1524
|
+
{
|
|
1525
|
+
name: `[4] \u{1F4DD} \u63D0\u4EA4\u4EE3\u7801 ${colors.dim("gw c")}`,
|
|
1526
|
+
value: "commit"
|
|
1527
|
+
},
|
|
1528
|
+
{
|
|
1529
|
+
name: `[5] \u{1F3F7}\uFE0F \u521B\u5EFA tag ${colors.dim("gw t")}`,
|
|
1530
|
+
value: "tag"
|
|
1531
|
+
},
|
|
1532
|
+
{
|
|
1533
|
+
name: `[6] \u{1F4CB} \u5217\u51FA tags ${colors.dim("gw ts")}`,
|
|
1534
|
+
value: "tags"
|
|
1535
|
+
},
|
|
1536
|
+
{
|
|
1537
|
+
name: `[7] \u{1F4E6} \u53D1\u5E03\u7248\u672C ${colors.dim("gw r")}`,
|
|
1538
|
+
value: "release"
|
|
1539
|
+
},
|
|
1540
|
+
{
|
|
1541
|
+
name: `[8] \u{1F4BE} \u7BA1\u7406 stash ${colors.dim("gw s")}`,
|
|
1542
|
+
value: "stash"
|
|
1543
|
+
},
|
|
1544
|
+
{
|
|
1545
|
+
name: `[9] \u2699\uFE0F \u521D\u59CB\u5316\u914D\u7F6E ${colors.dim("gw init")}`,
|
|
1546
|
+
value: "init"
|
|
1547
|
+
},
|
|
1548
|
+
{ name: "[0] \u2753 \u5E2E\u52A9", value: "help" },
|
|
1549
|
+
{ name: "[q] \u9000\u51FA", value: "exit" }
|
|
1550
|
+
],
|
|
1551
|
+
loop: false,
|
|
1552
|
+
theme
|
|
1553
|
+
});
|
|
1554
|
+
switch (action) {
|
|
1555
|
+
case "feature":
|
|
1556
|
+
checkGitRepo();
|
|
1557
|
+
await createBranch("feature");
|
|
1558
|
+
break;
|
|
1559
|
+
case "hotfix":
|
|
1560
|
+
checkGitRepo();
|
|
1561
|
+
await createBranch("hotfix");
|
|
1562
|
+
break;
|
|
1563
|
+
case "delete":
|
|
1564
|
+
checkGitRepo();
|
|
1565
|
+
await deleteBranch();
|
|
1566
|
+
break;
|
|
1567
|
+
case "tag":
|
|
1568
|
+
checkGitRepo();
|
|
1569
|
+
await createTag();
|
|
1570
|
+
break;
|
|
1571
|
+
case "tags":
|
|
1572
|
+
checkGitRepo();
|
|
1573
|
+
await listTags();
|
|
1574
|
+
break;
|
|
1575
|
+
case "commit":
|
|
1576
|
+
checkGitRepo();
|
|
1577
|
+
await commit();
|
|
1578
|
+
break;
|
|
1579
|
+
case "release":
|
|
1580
|
+
await release();
|
|
1581
|
+
break;
|
|
1582
|
+
case "stash":
|
|
1583
|
+
checkGitRepo();
|
|
1584
|
+
await stash();
|
|
1585
|
+
break;
|
|
1586
|
+
case "init":
|
|
1587
|
+
await init();
|
|
1588
|
+
break;
|
|
1589
|
+
case "help":
|
|
1590
|
+
console.log(showHelp());
|
|
1591
|
+
break;
|
|
1592
|
+
case "exit":
|
|
1593
|
+
break;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
var cli = cac("gw");
|
|
1597
|
+
cli.command("", "\u663E\u793A\u4EA4\u4E92\u5F0F\u83DC\u5355").action(() => {
|
|
1598
|
+
return mainMenu();
|
|
1599
|
+
});
|
|
1600
|
+
cli.command("feature", "\u521B\u5EFA feature \u5206\u652F").alias("feat").alias("f").option("--base <branch>", "\u6307\u5B9A\u57FA\u7840\u5206\u652F").action((options) => {
|
|
1601
|
+
checkGitRepo();
|
|
1602
|
+
return createBranch("feature", options.base);
|
|
1603
|
+
});
|
|
1604
|
+
cli.command("hotfix", "\u521B\u5EFA hotfix \u5206\u652F").alias("fix").alias("h").option("--base <branch>", "\u6307\u5B9A\u57FA\u7840\u5206\u652F").action((options) => {
|
|
1605
|
+
checkGitRepo();
|
|
1606
|
+
return createBranch("hotfix", options.base);
|
|
1607
|
+
});
|
|
1608
|
+
cli.command("delete [branch]", "\u5220\u9664\u672C\u5730/\u8FDC\u7A0B\u5206\u652F").alias("del").alias("d").action((branch) => {
|
|
1609
|
+
checkGitRepo();
|
|
1610
|
+
return deleteBranch(branch);
|
|
1611
|
+
});
|
|
1612
|
+
cli.command("tags [prefix]", "\u5217\u51FA\u6240\u6709 tag\uFF0C\u53EF\u6309\u524D\u7F00\u8FC7\u6EE4").alias("ts").action((prefix) => {
|
|
1613
|
+
checkGitRepo();
|
|
1614
|
+
return listTags(prefix);
|
|
1615
|
+
});
|
|
1616
|
+
cli.command("tag [prefix]", "\u4EA4\u4E92\u5F0F\u9009\u62E9\u7248\u672C\u7C7B\u578B\u5E76\u521B\u5EFA tag").alias("t").action((prefix) => {
|
|
1617
|
+
checkGitRepo();
|
|
1618
|
+
return createTag(prefix);
|
|
1619
|
+
});
|
|
1620
|
+
cli.command("release", "\u4EA4\u4E92\u5F0F\u9009\u62E9\u7248\u672C\u53F7\u5E76\u66F4\u65B0 package.json").alias("r").action(() => {
|
|
1621
|
+
return release();
|
|
1622
|
+
});
|
|
1623
|
+
cli.command("init", "\u521D\u59CB\u5316\u914D\u7F6E\u6587\u4EF6 .gwrc.json").action(() => {
|
|
1624
|
+
return init();
|
|
1625
|
+
});
|
|
1626
|
+
cli.command("stash", "\u4EA4\u4E92\u5F0F\u7BA1\u7406 stash").alias("s").alias("st").action(() => {
|
|
1627
|
+
checkGitRepo();
|
|
1628
|
+
return stash();
|
|
1629
|
+
});
|
|
1630
|
+
cli.command("commit", "\u4EA4\u4E92\u5F0F\u63D0\u4EA4 (Conventional Commits + Gitmoji)").alias("c").alias("cm").action(() => {
|
|
1631
|
+
checkGitRepo();
|
|
1632
|
+
return commit();
|
|
1633
|
+
});
|
|
1634
|
+
cli.help((sections) => {
|
|
1635
|
+
sections.push({
|
|
1636
|
+
body: showHelp()
|
|
1637
|
+
});
|
|
1638
|
+
});
|
|
1639
|
+
cli.version(version);
|
|
1640
|
+
cli.parse();
|