@ahmadjavaiddev/aura 1.0.1 → 1.0.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/README.md +86 -60
- package/dist/index.js +772 -718
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,52 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var gr=Object.create;var{getPrototypeOf:Ar,defineProperty:F,getOwnPropertyNames:Tr}=Object;var Or=Object.prototype.hasOwnProperty;function Cr(r){return this[r]}var jr,Lr,j=(r,t,o)=>{var i=r!=null&&typeof r==="object";if(i){var n=t?jr??=new WeakMap:Lr??=new WeakMap,s=n.get(r);if(s)return s}o=r!=null?gr(Ar(r)):{};let e=t||!r||!r.__esModule?F(o,"default",{value:r,enumerable:!0}):o;for(let a of Tr(r))if(!Or.call(e,a))F(e,a,{get:Cr.bind(r,a),enumerable:!0});if(i)n.set(r,e);return e};var D=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var q=D((Nt,ee)=>{var z={to(r,t){if(!t)return`\x1B[${r+1}G`;return`\x1B[${t+1};${r+1}H`},move(r,t){let o="";if(r<0)o+=`\x1B[${-r}D`;else if(r>0)o+=`\x1B[${r}C`;if(t<0)o+=`\x1B[${-t}A`;else if(t>0)o+=`\x1B[${t}B`;return o},up:(r=1)=>`\x1B[${r}A`,down:(r=1)=>`\x1B[${r}B`,forward:(r=1)=>`\x1B[${r}C`,backward:(r=1)=>`\x1B[${r}D`,nextLine:(r=1)=>"\x1B[E".repeat(r),prevLine:(r=1)=>"\x1B[F".repeat(r),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Pr={up:(r=1)=>"\x1B[S".repeat(r),down:(r=1)=>"\x1B[T".repeat(r)},Mr={screen:"\x1B[2J",up:(r=1)=>"\x1B[1J".repeat(r),down:(r=1)=>"\x1B[J".repeat(r),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(r){let t="";for(let o=0;o<r;o++)t+=this.line+(o<r-1?z.up():"");if(r)t+=z.left;return t}};ee.exports={cursor:z,scroll:Pr,erase:Mr,beep:"\x07"}});var H=D((gt,U)=>{var P=process||{},re=P.argv||[],L=P.env||{},Gr=!(!!L.NO_COLOR||re.includes("--no-color"))&&(!!L.FORCE_COLOR||re.includes("--color")||P.platform==="win32"||(P.stdout||{}).isTTY&&L.TERM!=="dumb"||!!L.CI),kr=(r,t,o=r)=>(i)=>{let n=""+i,s=n.indexOf(t,r.length);return~s?r+fr(n,t,o,s)+t:r+n+t},fr=(r,t,o,i)=>{let n="",s=0;do n+=r.substring(s,i)+o,s=i+t.length,i=r.indexOf(t,s);while(~i);return n+r.substring(s)},te=(r=Gr)=>{let t=r?kr:()=>String;return{isColorSupported:r,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};U.exports=te();U.exports.createColors=te});var w=j(q(),1),G=j(H(),1);import{stdin as be,stdout as xe}from"node:process";import*as N from"node:readline";import oe from"node:readline";import{WriteStream as Br}from"node:tty";function zr({onlyFirst:r=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,r?void 0:"g")}var qr=zr();function Ee(r){if(typeof r!="string")throw TypeError(`Expected a \`string\`, got \`${typeof r}\``);return r.replace(qr,"")}function ue(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ve={exports:{}};(function(r){var t={};r.exports=t,t.eastAsianWidth=function(i){var n=i.charCodeAt(0),s=i.length==2?i.charCodeAt(1):0,e=n;return 55296<=n&&n<=56319&&56320<=s&&s<=57343&&(n&=1023,s&=1023,e=n<<10|s,e+=65536),e==12288||65281<=e&&e<=65376||65504<=e&&e<=65510?"F":e==8361||65377<=e&&e<=65470||65474<=e&&e<=65479||65482<=e&&e<=65487||65490<=e&&e<=65495||65498<=e&&e<=65500||65512<=e&&e<=65518?"H":4352<=e&&e<=4447||4515<=e&&e<=4519||4602<=e&&e<=4607||9001<=e&&e<=9002||11904<=e&&e<=11929||11931<=e&&e<=12019||12032<=e&&e<=12245||12272<=e&&e<=12283||12289<=e&&e<=12350||12353<=e&&e<=12438||12441<=e&&e<=12543||12549<=e&&e<=12589||12593<=e&&e<=12686||12688<=e&&e<=12730||12736<=e&&e<=12771||12784<=e&&e<=12830||12832<=e&&e<=12871||12880<=e&&e<=13054||13056<=e&&e<=19903||19968<=e&&e<=42124||42128<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||55216<=e&&e<=55238||55243<=e&&e<=55291||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65106||65108<=e&&e<=65126||65128<=e&&e<=65131||110592<=e&&e<=110593||127488<=e&&e<=127490||127504<=e&&e<=127546||127552<=e&&e<=127560||127568<=e&&e<=127569||131072<=e&&e<=194367||177984<=e&&e<=196605||196608<=e&&e<=262141?"W":32<=e&&e<=126||162<=e&&e<=163||165<=e&&e<=166||e==172||e==175||10214<=e&&e<=10221||10629<=e&&e<=10630?"Na":e==161||e==164||167<=e&&e<=168||e==170||173<=e&&e<=174||176<=e&&e<=180||182<=e&&e<=186||188<=e&&e<=191||e==198||e==208||215<=e&&e<=216||222<=e&&e<=225||e==230||232<=e&&e<=234||236<=e&&e<=237||e==240||242<=e&&e<=243||247<=e&&e<=250||e==252||e==254||e==257||e==273||e==275||e==283||294<=e&&e<=295||e==299||305<=e&&e<=307||e==312||319<=e&&e<=322||e==324||328<=e&&e<=331||e==333||338<=e&&e<=339||358<=e&&e<=359||e==363||e==462||e==464||e==466||e==468||e==470||e==472||e==474||e==476||e==593||e==609||e==708||e==711||713<=e&&e<=715||e==717||e==720||728<=e&&e<=731||e==733||e==735||768<=e&&e<=879||913<=e&&e<=929||931<=e&&e<=937||945<=e&&e<=961||963<=e&&e<=969||e==1025||1040<=e&&e<=1103||e==1105||e==8208||8211<=e&&e<=8214||8216<=e&&e<=8217||8220<=e&&e<=8221||8224<=e&&e<=8226||8228<=e&&e<=8231||e==8240||8242<=e&&e<=8243||e==8245||e==8251||e==8254||e==8308||e==8319||8321<=e&&e<=8324||e==8364||e==8451||e==8453||e==8457||e==8467||e==8470||8481<=e&&e<=8482||e==8486||e==8491||8531<=e&&e<=8532||8539<=e&&e<=8542||8544<=e&&e<=8555||8560<=e&&e<=8569||e==8585||8592<=e&&e<=8601||8632<=e&&e<=8633||e==8658||e==8660||e==8679||e==8704||8706<=e&&e<=8707||8711<=e&&e<=8712||e==8715||e==8719||e==8721||e==8725||e==8730||8733<=e&&e<=8736||e==8739||e==8741||8743<=e&&e<=8748||e==8750||8756<=e&&e<=8759||8764<=e&&e<=8765||e==8776||e==8780||e==8786||8800<=e&&e<=8801||8804<=e&&e<=8807||8810<=e&&e<=8811||8814<=e&&e<=8815||8834<=e&&e<=8835||8838<=e&&e<=8839||e==8853||e==8857||e==8869||e==8895||e==8978||9312<=e&&e<=9449||9451<=e&&e<=9547||9552<=e&&e<=9587||9600<=e&&e<=9615||9618<=e&&e<=9621||9632<=e&&e<=9633||9635<=e&&e<=9641||9650<=e&&e<=9651||9654<=e&&e<=9655||9660<=e&&e<=9661||9664<=e&&e<=9665||9670<=e&&e<=9672||e==9675||9678<=e&&e<=9681||9698<=e&&e<=9701||e==9711||9733<=e&&e<=9734||e==9737||9742<=e&&e<=9743||9748<=e&&e<=9749||e==9756||e==9758||e==9792||e==9794||9824<=e&&e<=9825||9827<=e&&e<=9829||9831<=e&&e<=9834||9836<=e&&e<=9837||e==9839||9886<=e&&e<=9887||9918<=e&&e<=9919||9924<=e&&e<=9933||9935<=e&&e<=9953||e==9955||9960<=e&&e<=9983||e==10045||e==10071||10102<=e&&e<=10111||11093<=e&&e<=11097||12872<=e&&e<=12879||57344<=e&&e<=63743||65024<=e&&e<=65039||e==65533||127232<=e&&e<=127242||127248<=e&&e<=127277||127280<=e&&e<=127337||127344<=e&&e<=127386||917760<=e&&e<=917999||983040<=e&&e<=1048573||1048576<=e&&e<=1114109?"A":"N"},t.characterLength=function(i){var n=this.eastAsianWidth(i);return n=="F"||n=="W"||n=="A"?2:1};function o(i){return i.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(i){for(var n=o(i),s=0,e=0;e<n.length;e++)s=s+this.characterLength(n[e]);return s},t.slice=function(i,n,s){textLen=t.length(i),n=n||0,s=s||1,n<0&&(n=textLen+n),s<0&&(s=textLen+s);for(var e="",a=0,d=o(i),l=0;l<d.length;l++){var u=d[l],x=t.length(u);if(a>=n-(x==2?1:0))if(a+x<=s)e+=u;else break;a+=x}return e}})(ve);var Ur=ve.exports,Hr=ue(Ur),$r=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\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])|\uD83C[\uDF3E\uDF73\uDF7C\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\uDF7C\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\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\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\uDF7C\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\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\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\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\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-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*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\u26A7\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-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\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[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},Wr=ue($r);function O(r,t={}){if(typeof r!="string"||r.length===0||(t={ambiguousIsNarrow:!0,...t},r=Ee(r),r.length===0))return 0;r=r.replace(Wr()," ");let o=t.ambiguousIsNarrow?1:2,i=0;for(let n of r){let s=n.codePointAt(0);if(s<=31||s>=127&&s<=159||s>=768&&s<=879)continue;switch(Hr.eastAsianWidth(n)){case"F":case"W":i+=2;break;case"A":i+=o;break;default:i+=1}}return i}var $=10,ne=(r=0)=>(t)=>`\x1B[${t+r}m`,ie=(r=0)=>(t)=>`\x1B[${38+r};5;${t}m`,se=(r=0)=>(t,o,i)=>`\x1B[${38+r};2;${t};${o};${i}m`,b={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],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],gray:[90,39],grey:[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],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(b.modifier);var Jr=Object.keys(b.color),Zr=Object.keys(b.bgColor);[...Jr,...Zr];function Vr(){let r=new Map;for(let[t,o]of Object.entries(b)){for(let[i,n]of Object.entries(o))b[i]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},o[i]=b[i],r.set(n[0],n[1]);Object.defineProperty(b,t,{value:o,enumerable:!1})}return Object.defineProperty(b,"codes",{value:r,enumerable:!1}),b.color.close="\x1B[39m",b.bgColor.close="\x1B[49m",b.color.ansi=ne(),b.color.ansi256=ie(),b.color.ansi16m=se(),b.bgColor.ansi=ne($),b.bgColor.ansi256=ie($),b.bgColor.ansi16m=se($),Object.defineProperties(b,{rgbToAnsi256:{value:(t,o,i)=>t===o&&o===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(o/255*5)+Math.round(i/255*5),enumerable:!1},hexToRgb:{value:(t)=>{let o=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!o)return[0,0,0];let[i]=o;i.length===3&&(i=[...i].map((s)=>s+s).join(""));let n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:(t)=>b.rgbToAnsi256(...b.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value:(t)=>{if(t<8)return 30+t;if(t<16)return 90+(t-8);let o,i,n;if(t>=232)o=((t-232)*10+8)/255,i=o,n=o;else{t-=16;let a=t%36;o=Math.floor(t/36)/5,i=Math.floor(a/6)/5,n=a%6/5}let s=Math.max(o,i,n)*2;if(s===0)return 30;let e=30+(Math.round(n)<<2|Math.round(i)<<1|Math.round(o));return s===2&&(e+=60),e},enumerable:!1},rgbToAnsi:{value:(t,o,i)=>b.ansi256ToAnsi(b.rgbToAnsi256(t,o,i)),enumerable:!1},hexToAnsi:{value:(t)=>b.ansi256ToAnsi(b.hexToAnsi256(t)),enumerable:!1}}),b}var Kr=Vr(),k=new Set(["\x1B",""]),Yr=39,J="\x07",he="[",Xr="]",we="m",Z=`${Xr}8;;`,me=(r)=>`${k.values().next().value}${he}${r}${we}`,ae=(r)=>`${k.values().next().value}${Z}${r}${J}`,Qr=(r)=>r.split(" ").map((t)=>O(t)),W=(r,t,o)=>{let i=[...t],n=!1,s=!1,e=O(Ee(r[r.length-1]));for(let[a,d]of i.entries()){let l=O(d);if(e+l<=o?r[r.length-1]+=d:(r.push(d),e=0),k.has(d)&&(n=!0,s=i.slice(a+1).join("").startsWith(Z)),n){s?d===J&&(n=!1,s=!1):d===we&&(n=!1);continue}e+=l,e===o&&a<i.length-1&&(r.push(""),e=0)}!e&&r[r.length-1].length>0&&r.length>1&&(r[r.length-2]+=r.pop())},Fr=(r)=>{let t=r.split(" "),o=t.length;for(;o>0&&!(O(t[o-1])>0);)o--;return o===t.length?r:t.slice(0,o).join(" ")+t.slice(o).join("")},Dr=(r,t,o={})=>{if(o.trim!==!1&&r.trim()==="")return"";let i="",n,s,e=Qr(r),a=[""];for(let[l,u]of r.split(" ").entries()){o.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let x=O(a[a.length-1]);if(l!==0&&(x>=t&&(o.wordWrap===!1||o.trim===!1)&&(a.push(""),x=0),(x>0||o.trim===!1)&&(a[a.length-1]+=" ",x++)),o.hard&&e[l]>t){let S=t-x,h=1+Math.floor((e[l]-S-1)/t);Math.floor((e[l]-1)/t)<h&&a.push(""),W(a,u,t);continue}if(x+e[l]>t&&x>0&&e[l]>0){if(o.wordWrap===!1&&x<t){W(a,u,t);continue}a.push("")}if(x+e[l]>t&&o.wordWrap===!1){W(a,u,t);continue}a[a.length-1]+=u}o.trim!==!1&&(a=a.map((l)=>Fr(l)));let d=[...a.join(`
|
|
3
|
-
`)];for(let[l
|
|
4
|
-
`?(
|
|
5
|
-
`&&(n&&
|
|
2
|
+
var Zr=Object.create;var{getPrototypeOf:Vr,defineProperty:ae,getOwnPropertyNames:Kr}=Object;var Xr=Object.prototype.hasOwnProperty;function Qr(r){return this[r]}var Fr,Dr,L=(r,t,o)=>{var i=r!=null&&typeof r==="object";if(i){var n=t?Fr??=new WeakMap:Dr??=new WeakMap,a=n.get(r);if(a)return a}o=r!=null?Zr(Vr(r)):{};let e=t||!r||!r.__esModule?ae(o,"default",{value:r,enumerable:!0}):o;for(let c of Kr(r))if(!Xr.call(e,c))ae(e,c,{get:Qr.bind(r,c),enumerable:!0});if(i)n.set(r,e);return e};var ce=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports);var W=ce(($t,me)=>{var j={to(r,t){if(!t)return`\x1B[${r+1}G`;return`\x1B[${t+1};${r+1}H`},move(r,t){let o="";if(r<0)o+=`\x1B[${-r}D`;else if(r>0)o+=`\x1B[${r}C`;if(t<0)o+=`\x1B[${-t}A`;else if(t>0)o+=`\x1B[${t}B`;return o},up:(r=1)=>`\x1B[${r}A`,down:(r=1)=>`\x1B[${r}B`,forward:(r=1)=>`\x1B[${r}C`,backward:(r=1)=>`\x1B[${r}D`,nextLine:(r=1)=>"\x1B[E".repeat(r),prevLine:(r=1)=>"\x1B[F".repeat(r),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},et={up:(r=1)=>"\x1B[S".repeat(r),down:(r=1)=>"\x1B[T".repeat(r)},rt={screen:"\x1B[2J",up:(r=1)=>"\x1B[1J".repeat(r),down:(r=1)=>"\x1B[J".repeat(r),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(r){let t="";for(let o=0;o<r;o++)t+=this.line+(o<r-1?j.up():"");if(r)t+=j.left;return t}};me.exports={cursor:j,scroll:et,erase:rt,beep:"\x07"}});var J=ce((qt,Y)=>{var k=process||{},le=k.argv||[],M=k.env||{},tt=!(!!M.NO_COLOR||le.includes("--no-color"))&&(!!M.FORCE_COLOR||le.includes("--color")||k.platform==="win32"||(k.stdout||{}).isTTY&&M.TERM!=="dumb"||!!M.CI),ot=(r,t,o=r)=>(i)=>{let n=""+i,a=n.indexOf(t,r.length);return~a?r+nt(n,t,o,a)+t:r+n+t},nt=(r,t,o,i)=>{let n="",a=0;do n+=r.substring(a,i)+o,a=i+t.length,i=r.indexOf(t,a);while(~i);return n+r.substring(a)},pe=(r=tt)=>{let t=r?ot:()=>String;return{isColorSupported:r,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};Y.exports=pe();Y.exports.createColors=pe});var E=L(W(),1),G=L(J(),1);import{stdin as ye,stdout as Ie}from"node:process";import*as _ from"node:readline";import de from"node:readline";import{WriteStream as it}from"node:tty";function st({onlyFirst:r=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,r?void 0:"g")}var at=st();function _e(r){if(typeof r!="string")throw TypeError(`Expected a \`string\`, got \`${typeof r}\``);return r.replace(at,"")}function fe(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ne={exports:{}};(function(r){var t={};r.exports=t,t.eastAsianWidth=function(i){var n=i.charCodeAt(0),a=i.length==2?i.charCodeAt(1):0,e=n;return 55296<=n&&n<=56319&&56320<=a&&a<=57343&&(n&=1023,a&=1023,e=n<<10|a,e+=65536),e==12288||65281<=e&&e<=65376||65504<=e&&e<=65510?"F":e==8361||65377<=e&&e<=65470||65474<=e&&e<=65479||65482<=e&&e<=65487||65490<=e&&e<=65495||65498<=e&&e<=65500||65512<=e&&e<=65518?"H":4352<=e&&e<=4447||4515<=e&&e<=4519||4602<=e&&e<=4607||9001<=e&&e<=9002||11904<=e&&e<=11929||11931<=e&&e<=12019||12032<=e&&e<=12245||12272<=e&&e<=12283||12289<=e&&e<=12350||12353<=e&&e<=12438||12441<=e&&e<=12543||12549<=e&&e<=12589||12593<=e&&e<=12686||12688<=e&&e<=12730||12736<=e&&e<=12771||12784<=e&&e<=12830||12832<=e&&e<=12871||12880<=e&&e<=13054||13056<=e&&e<=19903||19968<=e&&e<=42124||42128<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||55216<=e&&e<=55238||55243<=e&&e<=55291||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65106||65108<=e&&e<=65126||65128<=e&&e<=65131||110592<=e&&e<=110593||127488<=e&&e<=127490||127504<=e&&e<=127546||127552<=e&&e<=127560||127568<=e&&e<=127569||131072<=e&&e<=194367||177984<=e&&e<=196605||196608<=e&&e<=262141?"W":32<=e&&e<=126||162<=e&&e<=163||165<=e&&e<=166||e==172||e==175||10214<=e&&e<=10221||10629<=e&&e<=10630?"Na":e==161||e==164||167<=e&&e<=168||e==170||173<=e&&e<=174||176<=e&&e<=180||182<=e&&e<=186||188<=e&&e<=191||e==198||e==208||215<=e&&e<=216||222<=e&&e<=225||e==230||232<=e&&e<=234||236<=e&&e<=237||e==240||242<=e&&e<=243||247<=e&&e<=250||e==252||e==254||e==257||e==273||e==275||e==283||294<=e&&e<=295||e==299||305<=e&&e<=307||e==312||319<=e&&e<=322||e==324||328<=e&&e<=331||e==333||338<=e&&e<=339||358<=e&&e<=359||e==363||e==462||e==464||e==466||e==468||e==470||e==472||e==474||e==476||e==593||e==609||e==708||e==711||713<=e&&e<=715||e==717||e==720||728<=e&&e<=731||e==733||e==735||768<=e&&e<=879||913<=e&&e<=929||931<=e&&e<=937||945<=e&&e<=961||963<=e&&e<=969||e==1025||1040<=e&&e<=1103||e==1105||e==8208||8211<=e&&e<=8214||8216<=e&&e<=8217||8220<=e&&e<=8221||8224<=e&&e<=8226||8228<=e&&e<=8231||e==8240||8242<=e&&e<=8243||e==8245||e==8251||e==8254||e==8308||e==8319||8321<=e&&e<=8324||e==8364||e==8451||e==8453||e==8457||e==8467||e==8470||8481<=e&&e<=8482||e==8486||e==8491||8531<=e&&e<=8532||8539<=e&&e<=8542||8544<=e&&e<=8555||8560<=e&&e<=8569||e==8585||8592<=e&&e<=8601||8632<=e&&e<=8633||e==8658||e==8660||e==8679||e==8704||8706<=e&&e<=8707||8711<=e&&e<=8712||e==8715||e==8719||e==8721||e==8725||e==8730||8733<=e&&e<=8736||e==8739||e==8741||8743<=e&&e<=8748||e==8750||8756<=e&&e<=8759||8764<=e&&e<=8765||e==8776||e==8780||e==8786||8800<=e&&e<=8801||8804<=e&&e<=8807||8810<=e&&e<=8811||8814<=e&&e<=8815||8834<=e&&e<=8835||8838<=e&&e<=8839||e==8853||e==8857||e==8869||e==8895||e==8978||9312<=e&&e<=9449||9451<=e&&e<=9547||9552<=e&&e<=9587||9600<=e&&e<=9615||9618<=e&&e<=9621||9632<=e&&e<=9633||9635<=e&&e<=9641||9650<=e&&e<=9651||9654<=e&&e<=9655||9660<=e&&e<=9661||9664<=e&&e<=9665||9670<=e&&e<=9672||e==9675||9678<=e&&e<=9681||9698<=e&&e<=9701||e==9711||9733<=e&&e<=9734||e==9737||9742<=e&&e<=9743||9748<=e&&e<=9749||e==9756||e==9758||e==9792||e==9794||9824<=e&&e<=9825||9827<=e&&e<=9829||9831<=e&&e<=9834||9836<=e&&e<=9837||e==9839||9886<=e&&e<=9887||9918<=e&&e<=9919||9924<=e&&e<=9933||9935<=e&&e<=9953||e==9955||9960<=e&&e<=9983||e==10045||e==10071||10102<=e&&e<=10111||11093<=e&&e<=11097||12872<=e&&e<=12879||57344<=e&&e<=63743||65024<=e&&e<=65039||e==65533||127232<=e&&e<=127242||127248<=e&&e<=127277||127280<=e&&e<=127337||127344<=e&&e<=127386||917760<=e&&e<=917999||983040<=e&&e<=1048573||1048576<=e&&e<=1114109?"A":"N"},t.characterLength=function(i){var n=this.eastAsianWidth(i);return n=="F"||n=="W"||n=="A"?2:1};function o(i){return i.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(i){for(var n=o(i),a=0,e=0;e<n.length;e++)a=a+this.characterLength(n[e]);return a},t.slice=function(i,n,a){textLen=t.length(i),n=n||0,a=a||1,n<0&&(n=textLen+n),a<0&&(a=textLen+a);for(var e="",c=0,b=o(i),d=0;d<b.length;d++){var l=b[d],m=t.length(l);if(c>=n-(m==2?1:0))if(c+m<=a)e+=l;else break;c+=m}return e}})(Ne);var ct=Ne.exports,mt=fe(ct),lt=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\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])|\uD83C[\uDF3E\uDF73\uDF7C\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\uDF7C\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\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\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\uDF7C\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\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\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\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\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-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*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\u26A7\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-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\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[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},pt=fe(lt);function T(r,t={}){if(typeof r!="string"||r.length===0||(t={ambiguousIsNarrow:!0,...t},r=_e(r),r.length===0))return 0;r=r.replace(pt()," ");let o=t.ambiguousIsNarrow?1:2,i=0;for(let n of r){let a=n.codePointAt(0);if(a<=31||a>=127&&a<=159||a>=768&&a<=879)continue;switch(mt.eastAsianWidth(n)){case"F":case"W":i+=2;break;case"A":i+=o;break;default:i+=1}}return i}var Z=10,ue=(r=0)=>(t)=>`\x1B[${t+r}m`,be=(r=0)=>(t)=>`\x1B[${38+r};5;${t}m`,ge=(r=0)=>(t,o,i)=>`\x1B[${38+r};2;${t};${o};${i}m`,g={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],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],gray:[90,39],grey:[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],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(g.modifier);var dt=Object.keys(g.color),ut=Object.keys(g.bgColor);[...dt,...ut];function bt(){let r=new Map;for(let[t,o]of Object.entries(g)){for(let[i,n]of Object.entries(o))g[i]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},o[i]=g[i],r.set(n[0],n[1]);Object.defineProperty(g,t,{value:o,enumerable:!1})}return Object.defineProperty(g,"codes",{value:r,enumerable:!1}),g.color.close="\x1B[39m",g.bgColor.close="\x1B[49m",g.color.ansi=ue(),g.color.ansi256=be(),g.color.ansi16m=ge(),g.bgColor.ansi=ue(Z),g.bgColor.ansi256=be(Z),g.bgColor.ansi16m=ge(Z),Object.defineProperties(g,{rgbToAnsi256:{value:(t,o,i)=>t===o&&o===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(o/255*5)+Math.round(i/255*5),enumerable:!1},hexToRgb:{value:(t)=>{let o=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!o)return[0,0,0];let[i]=o;i.length===3&&(i=[...i].map((a)=>a+a).join(""));let n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:(t)=>g.rgbToAnsi256(...g.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value:(t)=>{if(t<8)return 30+t;if(t<16)return 90+(t-8);let o,i,n;if(t>=232)o=((t-232)*10+8)/255,i=o,n=o;else{t-=16;let c=t%36;o=Math.floor(t/36)/5,i=Math.floor(c/6)/5,n=c%6/5}let a=Math.max(o,i,n)*2;if(a===0)return 30;let e=30+(Math.round(n)<<2|Math.round(i)<<1|Math.round(o));return a===2&&(e+=60),e},enumerable:!1},rgbToAnsi:{value:(t,o,i)=>g.ansi256ToAnsi(g.rgbToAnsi256(t,o,i)),enumerable:!1},hexToAnsi:{value:(t)=>g.ansi256ToAnsi(g.hexToAnsi256(t)),enumerable:!1}}),g}var gt=bt(),H=new Set(["\x1B",""]),ht=39,K="\x07",Ae="[",xt="]",Oe="m",X=`${xt}8;;`,he=(r)=>`${H.values().next().value}${Ae}${r}${Oe}`,xe=(r)=>`${H.values().next().value}${X}${r}${K}`,Et=(r)=>r.split(" ").map((t)=>T(t)),V=(r,t,o)=>{let i=[...t],n=!1,a=!1,e=T(_e(r[r.length-1]));for(let[c,b]of i.entries()){let d=T(b);if(e+d<=o?r[r.length-1]+=b:(r.push(b),e=0),H.has(b)&&(n=!0,a=i.slice(c+1).join("").startsWith(X)),n){a?b===K&&(n=!1,a=!1):b===Oe&&(n=!1);continue}e+=d,e===o&&c<i.length-1&&(r.push(""),e=0)}!e&&r[r.length-1].length>0&&r.length>1&&(r[r.length-2]+=r.pop())},St=(r)=>{let t=r.split(" "),o=t.length;for(;o>0&&!(T(t[o-1])>0);)o--;return o===t.length?r:t.slice(0,o).join(" ")+t.slice(o).join("")},vt=(r,t,o={})=>{if(o.trim!==!1&&r.trim()==="")return"";let i="",n,a,e=Et(r),c=[""];for(let[d,l]of r.split(" ").entries()){o.trim!==!1&&(c[c.length-1]=c[c.length-1].trimStart());let m=T(c[c.length-1]);if(d!==0&&(m>=t&&(o.wordWrap===!1||o.trim===!1)&&(c.push(""),m=0),(m>0||o.trim===!1)&&(c[c.length-1]+=" ",m++)),o.hard&&e[d]>t){let p=t-m,x=1+Math.floor((e[d]-p-1)/t);Math.floor((e[d]-1)/t)<x&&c.push(""),V(c,l,t);continue}if(m+e[d]>t&&m>0&&e[d]>0){if(o.wordWrap===!1&&m<t){V(c,l,t);continue}c.push("")}if(m+e[d]>t&&o.wordWrap===!1){V(c,l,t);continue}c[c.length-1]+=l}o.trim!==!1&&(c=c.map((d)=>St(d)));let b=[...c.join(`
|
|
3
|
+
`)];for(let[d,l]of b.entries()){if(i+=l,H.has(l)){let{groups:p}=new RegExp(`(?:\\${Ae}(?<code>\\d+)m|\\${X}(?<uri>.*)${K})`).exec(b.slice(d).join(""))||{groups:{}};if(p.code!==void 0){let x=Number.parseFloat(p.code);n=x===ht?void 0:x}else p.uri!==void 0&&(a=p.uri.length===0?void 0:p.uri)}let m=gt.codes.get(Number(n));b[d+1]===`
|
|
4
|
+
`?(a&&(i+=xe("")),n&&m&&(i+=he(m))):l===`
|
|
5
|
+
`&&(n&&m&&(i+=he(n)),a&&(i+=xe(a)))}return i};function Ee(r,t,o){return String(r).normalize().replace(/\r\n/g,`
|
|
6
6
|
`).split(`
|
|
7
|
-
`).map((i)=>
|
|
8
|
-
`)}var
|
|
7
|
+
`).map((i)=>vt(i,t,o)).join(`
|
|
8
|
+
`)}var Rt=Object.defineProperty,yt=(r,t,o)=>(t in r)?Rt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o,v=(r,t,o)=>(yt(r,typeof t!="symbol"?t+"":t,o),o);function It(r,t){if(r===t)return;let o=r.split(`
|
|
9
9
|
`),i=t.split(`
|
|
10
|
-
`),n=[];for(let
|
|
11
|
-
`),
|
|
12
|
-
`).length-1;this.output.write(
|
|
13
|
-
`);this.output.write(i[o]),this._prevFrame=r,this.output.write(
|
|
10
|
+
`),n=[];for(let a=0;a<Math.max(o.length,i.length);a++)o[a]!==i[a]&&n.push(a);return n}var we=Symbol("clack:cancel");function P(r){return r===we}function B(r,t){r.isTTY&&r.setRawMode(t)}var Se=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),_t=new Set(["up","down","left","right","space","enter"]);class C{constructor({render:r,input:t=ye,output:o=Ie,...i},n=!0){v(this,"input"),v(this,"output"),v(this,"rl"),v(this,"opts"),v(this,"_track",!1),v(this,"_render"),v(this,"_cursor",0),v(this,"state","initial"),v(this,"value"),v(this,"error",""),v(this,"subscribers",new Map),v(this,"_prevFrame",""),this.opts=i,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=r.bind(this),this._track=n,this.input=t,this.output=o}prompt(){let r=new it(0);return r._write=(t,o,i)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),i()},this.input.pipe(r),this.rl=de.createInterface({input:this.input,output:r,tabSize:2,prompt:"",escapeCodeTimeout:50}),de.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),B(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((t,o)=>{this.once("submit",()=>{this.output.write(E.cursor.show),this.output.off("resize",this.render),B(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(E.cursor.show),this.output.off("resize",this.render),B(this.input,!1),t(we)})})}on(r,t){let o=this.subscribers.get(r)??[];o.push({cb:t}),this.subscribers.set(r,o)}once(r,t){let o=this.subscribers.get(r)??[];o.push({cb:t,once:!0}),this.subscribers.set(r,o)}emit(r,...t){let o=this.subscribers.get(r)??[],i=[];for(let n of o)n.cb(...t),n.once&&i.push(()=>o.splice(o.indexOf(n),1));for(let n of i)n()}unsubscribe(){this.subscribers.clear()}onKeypress(r,t){if(this.state==="error"&&(this.state="active"),t?.name&&!this._track&&Se.has(t.name)&&this.emit("cursor",Se.get(t.name)),t?.name&&_t.has(t.name)&&this.emit("cursor",t.name),r&&(r.toLowerCase()==="y"||r.toLowerCase()==="n")&&this.emit("confirm",r.toLowerCase()==="y"),r==="\t"&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),r&&this.emit("key",r.toLowerCase()),t?.name==="return"){if(this.opts.validate){let o=this.opts.validate(this.value);o&&(this.error=o,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}r==="\x03"&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
11
|
+
`),B(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let r=Ee(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
12
|
+
`).length-1;this.output.write(E.cursor.move(-999,r*-1))}render(){let r=Ee(this._render(this)??"",process.stdout.columns,{hard:!0});if(r!==this._prevFrame){if(this.state==="initial")this.output.write(E.cursor.hide);else{let t=It(this._prevFrame,r);if(this.restoreCursor(),t&&t?.length===1){let o=t[0];this.output.write(E.cursor.move(0,o)),this.output.write(E.erase.lines(1));let i=r.split(`
|
|
13
|
+
`);this.output.write(i[o]),this._prevFrame=r,this.output.write(E.cursor.move(0,i.length-o-1));return}else if(t&&t?.length>1){let o=t[0];this.output.write(E.cursor.move(0,o)),this.output.write(E.erase.down());let i=r.split(`
|
|
14
14
|
`).slice(o);this.output.write(i.join(`
|
|
15
|
-
`)),this._prevFrame=r;return}this.output.write(
|
|
16
|
-
${
|
|
17
|
-
`,o=r.placeholder?
|
|
18
|
-
${
|
|
19
|
-
${
|
|
20
|
-
`;case"submit":return`${t}${
|
|
21
|
-
`+
|
|
22
|
-
${
|
|
23
|
-
`}}}).prompt();var
|
|
24
|
-
${
|
|
25
|
-
|
|
26
|
-
${
|
|
27
|
-
${
|
|
28
|
-
${
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
${
|
|
32
|
-
|
|
33
|
-
${
|
|
34
|
-
`).
|
|
35
|
-
`
|
|
36
|
-
${
|
|
15
|
+
`)),this._prevFrame=r;return}this.output.write(E.erase.down())}this.output.write(r),this.state==="initial"&&(this.state="active"),this._prevFrame=r}}}class Q extends C{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(r){super(r,!1),this.value=!!r.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(t)=>{this.output.write(E.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var ft=Object.defineProperty,Nt=(r,t,o)=>(t in r)?ft(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o,ve=(r,t,o)=>(Nt(r,typeof t!="symbol"?t+"":t,o),o),Te=class extends C{constructor(r){super(r,!1),ve(this,"options"),ve(this,"cursor",0),this.options=r.options,this.value=[...r.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===r.cursorAt),0),this.on("key",(t)=>{t==="a"&&this.toggleAll()}),this.on("cursor",(t)=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let r=this.value.length===this.options.length;this.value=r?[]:this.options.map((t)=>t.value)}toggleValue(){let r=this.value.includes(this._value);this.value=r?this.value.filter((t)=>t!==this._value):[...this.value,this._value]}};var At=Object.defineProperty,Ot=(r,t,o)=>(t in r)?At(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o,Re=(r,t,o)=>(Ot(r,typeof t!="symbol"?t+"":t,o),o),Pe=class extends C{constructor(r){super(r,!1),Re(this,"options"),Re(this,"cursor",0),this.options=r.options,this.cursor=this.options.findIndex(({value:t})=>t===r.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(t)=>{switch(t){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};var wt=Object.defineProperty,Tt=(r,t,o)=>(t in r)?wt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o,Pt=(r,t,o)=>(Tt(r,typeof t!="symbol"?t+"":t,o),o);class F extends C{constructor(r){super(r),Pt(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=r.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${G.default.inverse(G.default.hidden("_"))}`;else{let t=this.value.slice(0,this.cursor),o=this.value.slice(this.cursor);this.valueWithCursor=`${t}${G.default.inverse(o[0])}${o.slice(1)}`}})}get cursor(){return this._cursor}}var Ct=globalThis.process.platform.startsWith("win");function Ce({input:r=ye,output:t=Ie,overwrite:o=!0,hideCursor:i=!0}={}){let n=_.createInterface({input:r,output:t,prompt:"",tabSize:1});_.emitKeypressEvents(r,n),r.isTTY&&r.setRawMode(!0);let a=(e,{name:c})=>{if(String(e)==="\x03"){i&&t.write(E.cursor.show),process.exit(0);return}if(!o)return;_.moveCursor(t,c==="return"?0:-1,c==="return"?-1:0,()=>{_.clearLine(t,1,()=>{r.once("keypress",a)})})};return i&&t.write(E.cursor.hide),r.once("keypress",a),()=>{r.off("keypress",a),i&&t.write(E.cursor.show),r.isTTY&&!Ct&&r.setRawMode(!1),n.terminal=!1,n.close()}}var s=L(J(),1),O=L(W(),1);import R from"node:process";function Lt(){return R.platform!=="win32"?R.env.TERM!=="linux":!!R.env.CI||!!R.env.WT_SESSION||!!R.env.TERMINUS_SUBLIME||R.env.ConEmuTask==="{cmd::Cmder}"||R.env.TERM_PROGRAM==="Terminus-Sublime"||R.env.TERM_PROGRAM==="vscode"||R.env.TERM==="xterm-256color"||R.env.TERM==="alacritty"||R.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var D=Lt(),h=(r,t)=>D?r:t,Mt=h("◆","*"),Me=h("■","x"),ke=h("▲","x"),Be=h("◇","o"),kt=h("┌","T"),u=h("│","|"),f=h("└","—"),ee=h("●",">"),re=h("○"," "),Bt=h("◻","[•]"),Le=h("◼","[+]"),Gt=h("◻","[ ]"),eo=h("▪","•"),ro=h("─","-"),to=h("╮","+"),oo=h("├","+"),no=h("╯","+"),io=h("●","•"),so=h("◆","*"),ao=h("▲","!"),co=h("■","x"),U=(r)=>{switch(r){case"initial":case"active":return s.default.cyan(Mt);case"cancel":return s.default.red(Me);case"error":return s.default.yellow(ke);case"submit":return s.default.green(Be)}},te=(r)=>{let{cursor:t,options:o,style:i}=r,n=r.maxItems??1/0,a=Math.max(process.stdout.rows-4,0),e=Math.min(a,Math.max(n,5)),c=0;t>=c+e-3?c=Math.max(Math.min(t-e+3,o.length-e),0):t<c+2&&(c=Math.max(t-2,0));let b=e<o.length&&c>0,d=e<o.length&&c+e<o.length;return o.slice(c,c+e).map((l,m,p)=>{let x=m===0&&b,S=m===p.length-1&&d;return x||S?s.default.dim("..."):i(l,m+c===t)})},Ge=(r)=>new F({validate:r.validate,placeholder:r.placeholder,defaultValue:r.defaultValue,initialValue:r.initialValue,render(){let t=`${s.default.gray(u)}
|
|
16
|
+
${U(this.state)} ${r.message}
|
|
17
|
+
`,o=r.placeholder?s.default.inverse(r.placeholder[0])+s.default.dim(r.placeholder.slice(1)):s.default.inverse(s.default.hidden("_")),i=this.value?this.valueWithCursor:o;switch(this.state){case"error":return`${t.trim()}
|
|
18
|
+
${s.default.yellow(u)} ${i}
|
|
19
|
+
${s.default.yellow(f)} ${s.default.yellow(this.error)}
|
|
20
|
+
`;case"submit":return`${t}${s.default.gray(u)} ${s.default.dim(this.value||r.placeholder)}`;case"cancel":return`${t}${s.default.gray(u)} ${s.default.strikethrough(s.default.dim(this.value??""))}${this.value?.trim()?`
|
|
21
|
+
`+s.default.gray(u):""}`;default:return`${t}${s.default.cyan(u)} ${i}
|
|
22
|
+
${s.default.cyan(f)}
|
|
23
|
+
`}}}).prompt();var He=(r)=>{let t=r.active??"Yes",o=r.inactive??"No";return new Q({active:t,inactive:o,initialValue:r.initialValue??!0,render(){let i=`${s.default.gray(u)}
|
|
24
|
+
${U(this.state)} ${r.message}
|
|
25
|
+
`,n=this.value?t:o;switch(this.state){case"submit":return`${i}${s.default.gray(u)} ${s.default.dim(n)}`;case"cancel":return`${i}${s.default.gray(u)} ${s.default.strikethrough(s.default.dim(n))}
|
|
26
|
+
${s.default.gray(u)}`;default:return`${i}${s.default.cyan(u)} ${this.value?`${s.default.green(ee)} ${t}`:`${s.default.dim(re)} ${s.default.dim(t)}`} ${s.default.dim("/")} ${this.value?`${s.default.dim(re)} ${s.default.dim(o)}`:`${s.default.green(ee)} ${o}`}
|
|
27
|
+
${s.default.cyan(f)}
|
|
28
|
+
`}}}).prompt()},y=(r)=>{let t=(o,i)=>{let n=o.label??String(o.value);switch(i){case"selected":return`${s.default.dim(n)}`;case"active":return`${s.default.green(ee)} ${n} ${o.hint?s.default.dim(`(${o.hint})`):""}`;case"cancelled":return`${s.default.strikethrough(s.default.dim(n))}`;default:return`${s.default.dim(re)} ${s.default.dim(n)}`}};return new Pe({options:r.options,initialValue:r.initialValue,render(){let o=`${s.default.gray(u)}
|
|
29
|
+
${U(this.state)} ${r.message}
|
|
30
|
+
`;switch(this.state){case"submit":return`${o}${s.default.gray(u)} ${t(this.options[this.cursor],"selected")}`;case"cancel":return`${o}${s.default.gray(u)} ${t(this.options[this.cursor],"cancelled")}
|
|
31
|
+
${s.default.gray(u)}`;default:return`${o}${s.default.cyan(u)} ${te({cursor:this.cursor,options:this.options,maxItems:r.maxItems,style:(i,n)=>t(i,n?"active":"inactive")}).join(`
|
|
32
|
+
${s.default.cyan(u)} `)}
|
|
33
|
+
${s.default.cyan(f)}
|
|
34
|
+
`}}}).prompt()};var Ue=(r)=>{let t=(o,i)=>{let n=o.label??String(o.value);return i==="active"?`${s.default.cyan(Bt)} ${n} ${o.hint?s.default.dim(`(${o.hint})`):""}`:i==="selected"?`${s.default.green(Le)} ${s.default.dim(n)}`:i==="cancelled"?`${s.default.strikethrough(s.default.dim(n))}`:i==="active-selected"?`${s.default.green(Le)} ${n} ${o.hint?s.default.dim(`(${o.hint})`):""}`:i==="submitted"?`${s.default.dim(n)}`:`${s.default.dim(Gt)} ${s.default.dim(n)}`};return new Te({options:r.options,initialValues:r.initialValues,required:r.required??!0,cursorAt:r.cursorAt,validate(o){if(this.required&&o.length===0)return`Please select at least one option.
|
|
35
|
+
${s.default.reset(s.default.dim(`Press ${s.default.gray(s.default.bgWhite(s.default.inverse(" space ")))} to select, ${s.default.gray(s.default.bgWhite(s.default.inverse(" enter ")))} to submit`))}`},render(){let o=`${s.default.gray(u)}
|
|
36
|
+
${U(this.state)} ${r.message}
|
|
37
|
+
`,i=(n,a)=>{let e=this.value.includes(n.value);return a&&e?t(n,"active-selected"):e?t(n,"selected"):t(n,a?"active":"inactive")};switch(this.state){case"submit":return`${o}${s.default.gray(u)} ${this.options.filter(({value:n})=>this.value.includes(n)).map((n)=>t(n,"submitted")).join(s.default.dim(", "))||s.default.dim("none")}`;case"cancel":{let n=this.options.filter(({value:a})=>this.value.includes(a)).map((a)=>t(a,"cancelled")).join(s.default.dim(", "));return`${o}${s.default.gray(u)} ${n.trim()?`${n}
|
|
38
|
+
${s.default.gray(u)}`:""}`}case"error":{let n=this.error.split(`
|
|
39
|
+
`).map((a,e)=>e===0?`${s.default.yellow(f)} ${s.default.yellow(a)}`:` ${a}`).join(`
|
|
40
|
+
`);return o+s.default.yellow(u)+" "+te({options:this.options,cursor:this.cursor,maxItems:r.maxItems,style:i}).join(`
|
|
41
|
+
${s.default.yellow(u)} `)+`
|
|
37
42
|
`+n+`
|
|
38
|
-
`}default:return`${o}${
|
|
39
|
-
${
|
|
40
|
-
${
|
|
41
|
-
`}}}).prompt()};var
|
|
42
|
-
|
|
43
|
-
`)},
|
|
44
|
-
`)},
|
|
45
|
-
${
|
|
46
|
-
|
|
47
|
-
`)};var
|
|
48
|
-
`);let
|
|
49
|
-
`),
|
|
43
|
+
`}default:return`${o}${s.default.cyan(u)} ${te({options:this.options,cursor:this.cursor,maxItems:r.maxItems,style:i}).join(`
|
|
44
|
+
${s.default.cyan(u)} `)}
|
|
45
|
+
${s.default.cyan(f)}
|
|
46
|
+
`}}}).prompt()};var z=(r="")=>{process.stdout.write(`${s.default.gray(f)} ${s.default.red(r)}
|
|
47
|
+
|
|
48
|
+
`)},oe=(r="")=>{process.stdout.write(`${s.default.gray(kt)} ${r}
|
|
49
|
+
`)},ne=(r="")=>{process.stdout.write(`${s.default.gray(u)}
|
|
50
|
+
${s.default.gray(f)} ${r}
|
|
51
|
+
|
|
52
|
+
`)};var $=()=>{let r=D?["◒","◐","◓","◑"]:["•","o","O","0"],t=D?80:120,o,i,n=!1,a="",e=(x)=>{let S=x>1?"Something went wrong":"Canceled";n&&p(S,x)},c=()=>e(2),b=()=>e(1),d=()=>{process.on("uncaughtExceptionMonitor",c),process.on("unhandledRejection",c),process.on("SIGINT",b),process.on("SIGTERM",b),process.on("exit",e)},l=()=>{process.removeListener("uncaughtExceptionMonitor",c),process.removeListener("unhandledRejection",c),process.removeListener("SIGINT",b),process.removeListener("SIGTERM",b),process.removeListener("exit",e)},m=(x="")=>{n=!0,o=Ce(),a=x.replace(/\.+$/,""),process.stdout.write(`${s.default.gray(u)}
|
|
53
|
+
`);let S=0,A=0;d(),i=setInterval(()=>{let Yr=s.default.magenta(r[S]),Jr=".".repeat(Math.floor(A)).slice(0,3);process.stdout.write(O.cursor.move(-999,0)),process.stdout.write(O.erase.down(1)),process.stdout.write(`${Yr} ${a}${Jr}`),S=S+1<r.length?S+1:0,A=A<r.length?A+0.125:0},t)},p=(x="",S=0)=>{a=x??a,n=!1,clearInterval(i);let A=S===0?s.default.green(Be):S===1?s.default.red(Me):s.default.red(ke);process.stdout.write(O.cursor.move(-999,0)),process.stdout.write(O.erase.down(1)),process.stdout.write(`${A} ${a}
|
|
54
|
+
`),l(),o()};return{start:m,stop:p,message:(x="")=>{a=x??a}}};var ze=async(r,t)=>{let o={},i=Object.keys(r);for(let n of i){let a=r[n],e=await a({results:o})?.catch((c)=>{throw c});if(typeof t?.onCancel=="function"&&P(e)){o[n]="canceled",t.onCancel({results:o});continue}o[n]=e}return o};async function $e(){let r=await ze({caching:()=>y({message:"Select Caching strategy:",options:[{value:"none",label:"None"},{value:"memory",label:"In-memory (Local caching)"},{value:"redis",label:"Redis (Distributed caching)"}]}),logger:()=>y({message:"Select Logging strategy:",options:[{value:"none",label:"None"},{value:"console",label:"Console (Basic terminal logs)"},{value:"otel",label:"OpenTelemetry (Advanced logging + PostHog)"}]}),orm:()=>y({message:"Select a Database ORM:",options:[{value:"prisma",label:"Prisma (PostgreSQL + Typed schemas)"},{value:"drizzle",label:"Drizzle (PostgreSQL + Lightweight SQL)"},{value:"mongoose",label:"Mongoose (MongoDB)"},{value:"none",label:"None"}]}),auth:()=>y({message:"Select an Authentication provider:",options:[{value:"clerk",label:"Clerk (Hosted Auth)"},{value:"betterauth",label:"Better-Auth (Self-hosted)"},{value:"custom",label:"Custom JWT Middleware (Starter)"},{value:"none",label:"None"}]}),rateLimit:()=>y({message:"Select Rate Limiting strategy:",options:[{value:"none",label:"None"},{value:"basic",label:"Basic (Memory-based)"},{value:"redis",label:"Redis-based (Distributed)"}]}),inngest:()=>y({message:"Select Inngest support:",options:[{value:"none",label:"None"},{value:"basic",label:"Basic (Event-driven background functions)"}]}),email:()=>y({message:"Select an Email provider:",options:[{value:"resend",label:"Resend (Modern API)"},{value:"nodemailer",label:"Nodemailer (Traditional SMTP)"},{value:"none",label:"None"}]}),features:()=>Ue({message:"Extra features:",options:[{value:"pagination",label:"Pagination",hint:"Zod pagination helpers"}],required:!1}),formatter:()=>y({message:"Select a formatter/linter:",options:[{value:"biome",label:"Biome (Recommended: Fast formatter & linter)"},{value:"prettier",label:"Prettier + ESLint"},{value:"none",label:"None"}]}),docker:()=>He({message:"Would you like to include Docker support (Dockerfile, docker-compose)?",initialValue:!0}),ci:()=>y({message:"Select a CI/CD setup:",options:[{value:"github",label:"GitHub Actions (Basic CI)"},{value:"none",label:"None"}]})},{onCancel:()=>{z("Operation cancelled."),process.exit(0)}}),t=r.features;return{caching:r.caching,logger:r.logger,orm:r.orm,rateLimit:r.rateLimit,auth:r.auth,email:r.email,pagination:t.includes("pagination"),formatter:r.formatter,inngest:r.inngest,docker:r.docker,ci:r.ci}}import Ur from"fs/promises";import zr from"path";var qe=`{
|
|
50
55
|
"compilerOptions": {
|
|
51
56
|
"lib": ["ESNext"],
|
|
52
57
|
"target": "ESNext",
|
|
@@ -71,7 +76,7 @@ ${m.default.gray(g)} ${r}
|
|
|
71
76
|
"noPropertyAccessFromIndexSignature": false
|
|
72
77
|
}
|
|
73
78
|
}
|
|
74
|
-
`,
|
|
79
|
+
`,je=`# dependencies (bun install)
|
|
75
80
|
node_modules
|
|
76
81
|
generated
|
|
77
82
|
|
|
@@ -110,7 +115,7 @@ tests_output_matrix_v*
|
|
|
110
115
|
|
|
111
116
|
# MacOS files
|
|
112
117
|
.DS_Store
|
|
113
|
-
`,
|
|
118
|
+
`,We=`export class AppError extends Error {
|
|
114
119
|
constructor(
|
|
115
120
|
public statusCode: number,
|
|
116
121
|
message: string,
|
|
@@ -119,7 +124,7 @@ tests_output_matrix_v*
|
|
|
119
124
|
this.name = "AppError";
|
|
120
125
|
}
|
|
121
126
|
}
|
|
122
|
-
`,
|
|
127
|
+
`,Ye=`import { join } from "path";
|
|
123
128
|
import type { RouteConfig } from "./define-route";
|
|
124
129
|
|
|
125
130
|
const ROUTES_DIR = join(import.meta.dir, "../routes");
|
|
@@ -157,7 +162,7 @@ export async function loadRoutes(): Promise<RouteConfig<any, any, any, any>[]> {
|
|
|
157
162
|
|
|
158
163
|
return routes;
|
|
159
164
|
}
|
|
160
|
-
`,
|
|
165
|
+
`,Je=`{
|
|
161
166
|
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
|
|
162
167
|
"organizeImports": {
|
|
163
168
|
"enabled": true
|
|
@@ -174,13 +179,13 @@ export async function loadRoutes(): Promise<RouteConfig<any, any, any, any>[]> {
|
|
|
174
179
|
"indentWidth": 2
|
|
175
180
|
}
|
|
176
181
|
}
|
|
177
|
-
`,
|
|
182
|
+
`,Ze=`{
|
|
178
183
|
"semi": true,
|
|
179
184
|
"singleQuote": false,
|
|
180
185
|
"tabWidth": 2,
|
|
181
186
|
"trailingComma": "all"
|
|
182
187
|
}
|
|
183
|
-
`,
|
|
188
|
+
`,Ve=`import tseslint from 'typescript-eslint';
|
|
184
189
|
|
|
185
190
|
export default tseslint.config(
|
|
186
191
|
...tseslint.configs.recommended,
|
|
@@ -188,268 +193,339 @@ export default tseslint.config(
|
|
|
188
193
|
ignores: ['generated/', 'dist/', 'out/', 'node_modules/']
|
|
189
194
|
}
|
|
190
195
|
);
|
|
191
|
-
`;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
async delPattern(pattern: string): Promise<void> {
|
|
239
|
-
if (!env.IS_CACHE_ENABLED) return;
|
|
240
|
-
const keys = await redisClient.keys(pattern);
|
|
241
|
-
if (keys.length > 0) {
|
|
242
|
-
await redisClient.del(keys);
|
|
243
|
-
}
|
|
244
|
-
},
|
|
196
|
+
`;function Ke(r,t){let o={cors:"^2.8.5",dotenv:"^16.4.5",express:"^5.0.0",helmet:"^7.1.0",zod:"^3.23.8"};if(t.caching==="redis"||t.rateLimit==="redis")o.redis="^4.7.0";if(t.logger==="otel")o["@opentelemetry/api-logs"]="^0.53.0",o["@opentelemetry/exporter-logs-otlp-http"]="^0.53.0",o["@opentelemetry/resources"]="^1.26.0",o["@opentelemetry/sdk-logs"]="^0.53.0";if(t.orm==="prisma")o["@prisma/adapter-pg"]="^7.4.2",o["@prisma/client"]="^7.4.2",o.pg="^8.20.0",o.prisma="^7.4.2";else if(t.orm==="drizzle")o["drizzle-orm"]="^0.33.0",o["drizzle-kit"]="^0.24.0",o.pg="^8.12.0";else if(t.orm==="mongoose")o.mongoose="^8.6.0";if(t.auth==="clerk")o["@clerk/express"]="^1.3.11";else if(t.auth==="betterauth")o["better-auth"]="^1.1.18";else if(t.auth==="custom")o.jsonwebtoken="^9.0.2";if(t.rateLimit!=="none")o["express-rate-limit"]="^7.4.0";if(t.email==="resend")o.resend="^3.5.0";else if(t.email==="nodemailer")o.nodemailer="^6.9.14";if(t.inngest!=="none")o.inngest="latest";let i={"@types/bun":"latest","@types/cors":"^2.8.19","@types/express":"^5.0.6","@types/node":"^22.0.0"};if(t.email==="nodemailer")i["@types/nodemailer"]="^6.4.15";if(t.auth==="custom")i["@types/jsonwebtoken"]="^9.0.7";if(t.orm==="prisma"||t.orm==="drizzle")i["@types/pg"]="^8.11.6";let n={dev:"bun run --watch src/app.ts"};if(t.orm==="prisma")n["db:generate"]="prisma generate";if(t.formatter==="biome")i["@biomejs/biome"]="1.8.3",n.format="biome format --write .",n.lint="biome check .";else if(t.formatter==="prettier")i.prettier="^3.3.3",i.eslint="^9.9.0",i["typescript-eslint"]="^8.0.1",n.format="prettier --write .",n.lint="eslint .";return JSON.stringify({name:r,module:"src/app.ts",type:"module",private:!0,scripts:n,devDependencies:i,peerDependencies:{typescript:"^5"},dependencies:o},null,2)}function Xe(r,t){let o=`PORT=8000
|
|
197
|
+
NODE_ENV=development
|
|
198
|
+
IS_DEV=true
|
|
199
|
+
`;if(r.caching==="redis")o+=`CACHE_ENABLED=true
|
|
200
|
+
REDIS_URL=redis://localhost:6379
|
|
201
|
+
`;if(r.logger==="otel")o+=`SERVICE_NAME=${t}
|
|
202
|
+
POSTHOG_URL=https://us.i.posthog.com/i/v1/logs
|
|
203
|
+
POSTHOG_API_KEY=your_key_here
|
|
204
|
+
`;if(r.orm!=="none")if(r.orm==="mongoose")o+=`DATABASE_URL=mongodb://localhost:27017/my_db
|
|
205
|
+
`;else o+=`DATABASE_URL=postgresql://user:pass@localhost:5432/db?schema=public
|
|
206
|
+
DIRECT_URL=postgresql://user:pass@localhost:5432/db
|
|
207
|
+
`;else if(r.auth==="betterauth")o+=`DATABASE_URL=postgresql://user:pass@localhost:5432/db?schema=public
|
|
208
|
+
`;if(r.auth==="betterauth")o+=`BETTER_AUTH_SECRET=super_secret_string
|
|
209
|
+
BETTER_AUTH_URL=http://localhost:8000
|
|
210
|
+
`;else if(r.auth==="custom")o+=`JWT_SECRET=your_super_secret_jwt_key_here
|
|
211
|
+
`;if(r.email==="resend")o+=`RESEND_API_KEY=re_123456789
|
|
212
|
+
`;else if(r.email==="nodemailer")o+=`SMTP_HOST=smtp.mailtrap.io
|
|
213
|
+
SMTP_PORT=2525
|
|
214
|
+
SMTP_USER=user
|
|
215
|
+
SMTP_PASS=pass
|
|
216
|
+
`;if(r.inngest!=="none")o+=`INNGEST_EVENT_KEY=your_event_key_here
|
|
217
|
+
INNGEST_SIGNING_KEY=your_signing_key_here
|
|
218
|
+
`;return o}function Qe(r,t){return`export const env = {
|
|
219
|
+
IS_DEV: process.env.NODE_ENV !== "production",
|
|
220
|
+
NODE_ENV: process.env.NODE_ENV ?? "development",
|
|
221
|
+
PORT: Number(process.env.PORT) || 8000,
|
|
222
|
+
SERVICE_NAME: process.env.SERVICE_NAME ?? "${t}",
|
|
223
|
+
SERVICE_VERSION: process.env.npm_package_version ?? "1.0.0",
|
|
224
|
+
${r.caching==="redis"?` REDIS_URL: process.env.REDIS_URL,
|
|
225
|
+
IS_CACHE_ENABLED: process.env.CACHE_ENABLED === "true",`:""}
|
|
226
|
+
${r.caching==="memory"?" IS_CACHE_ENABLED: true,":""}
|
|
227
|
+
${r.logger==="otel"?` POSTHOG_API_KEY: process.env.POSTHOG_API_KEY,
|
|
228
|
+
POSTHOG_URL: process.env.POSTHOG_URL,`:""}
|
|
229
|
+
${r.orm!=="none"||r.auth==="betterauth"?" DATABASE_URL: process.env.DATABASE_URL,":""}
|
|
230
|
+
${r.auth==="clerk"?` CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY,
|
|
231
|
+
CLERK_PUBLISHABLE_KEY: process.env.CLERK_PUBLISHABLE_KEY,`:""}
|
|
232
|
+
${r.auth==="betterauth"?` BETTER_AUTH_SECRET: process.env.BETTER_AUTH_SECRET,
|
|
233
|
+
BETTER_AUTH_URL: process.env.BETTER_AUTH_URL,`:""}
|
|
234
|
+
${r.auth==="custom"?" JWT_SECRET: process.env.JWT_SECRET,":""}
|
|
235
|
+
${r.email==="resend"?" RESEND_API_KEY: process.env.RESEND_API_KEY,":""}
|
|
236
|
+
${r.email==="nodemailer"?` SMTP_HOST: process.env.SMTP_HOST,
|
|
237
|
+
SMTP_PORT: Number(process.env.SMTP_PORT) || 587,
|
|
238
|
+
SMTP_USER: process.env.SMTP_USER,
|
|
239
|
+
SMTP_PASS: process.env.SMTP_PASS,`:""}
|
|
240
|
+
${r.inngest!=="none"?` INNGEST_EVENT_KEY: process.env.INNGEST_EVENT_KEY,
|
|
241
|
+
INNGEST_SIGNING_KEY: process.env.INNGEST_SIGNING_KEY,`:""}
|
|
242
|
+
// [AURA_ENV_KEYS]
|
|
245
243
|
};
|
|
246
|
-
|
|
244
|
+
`}function Fe(r){let t=[...new Set(r.imports||[])].join(`
|
|
245
|
+
`),o=[...new Set(r.init||[])].map((e)=>` ${e}`).join(`
|
|
246
|
+
`),i=[...new Set(r.middleware||[])].map((e)=>` ${e}`).join(`
|
|
247
|
+
`),n=[...new Set(r.errorHandler||[])].map((e)=>` ${e}`).join(`
|
|
248
|
+
`),a=[...new Set(r.shutdown||[])].map((e)=>` ${e}`).join(`
|
|
249
|
+
`);return`${t}
|
|
250
|
+
// [AURA_IMPORTS]
|
|
247
251
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
252
|
+
async function init() {
|
|
253
|
+
${o}
|
|
254
|
+
// [AURA_INIT]
|
|
251
255
|
|
|
252
|
-
|
|
256
|
+
${i}
|
|
257
|
+
// [AURA_MIDDLEWARE]
|
|
253
258
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (!env.IS_CACHE_ENABLED) return null;
|
|
257
|
-
const item = store.get(key);
|
|
258
|
-
if (!item) return null;
|
|
259
|
-
if (Date.now() > item.expiresAt) {
|
|
260
|
-
store.delete(key);
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
|
-
return item.value as T;
|
|
264
|
-
},
|
|
259
|
+
${n}
|
|
260
|
+
// [AURA_ERROR_HANDLER]
|
|
265
261
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
store.set(key, {
|
|
269
|
-
value,
|
|
270
|
-
expiresAt: Date.now() + options.ttl * 1000
|
|
271
|
-
});
|
|
272
|
-
},
|
|
273
|
-
|
|
274
|
-
async del(key: string): Promise<void> {
|
|
275
|
-
if (!env.IS_CACHE_ENABLED) return;
|
|
276
|
-
store.delete(key);
|
|
277
|
-
},
|
|
262
|
+
${a}
|
|
263
|
+
// [AURA_SHUTDOWN]
|
|
278
264
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (regex.test(key)) {
|
|
284
|
-
store.delete(key);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
};
|
|
289
|
-
`,Je=`export const cacheKeys = {
|
|
290
|
-
users: {
|
|
291
|
-
detail: (id: string) => \`users:detail:\${id}\`,
|
|
292
|
-
},
|
|
293
|
-
};
|
|
294
|
-
`;var Ze=`import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
|
|
295
|
-
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
296
|
-
import {
|
|
297
|
-
LoggerProvider,
|
|
298
|
-
BatchLogRecordProcessor,
|
|
299
|
-
} from "@opentelemetry/sdk-logs";
|
|
300
|
-
import { SeverityNumber, logs } from "@opentelemetry/api-logs";
|
|
301
|
-
import type { AnyValueMap } from "@opentelemetry/api-logs";
|
|
302
|
-
import { env } from "../config/env";
|
|
265
|
+
app.listen(env.PORT, () => {
|
|
266
|
+
console.log(\`Server started on port \${env.PORT}\`);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
303
269
|
|
|
304
|
-
|
|
305
|
-
"
|
|
306
|
-
|
|
307
|
-
"deployment.environment": env.NODE_ENV,
|
|
270
|
+
init().catch(async (err) => {
|
|
271
|
+
console.error("server.bootstrap_failed", err);
|
|
272
|
+
process.exit(1);
|
|
308
273
|
});
|
|
274
|
+
`}function De(r){return`import { ZodError } from "zod";
|
|
275
|
+
import type { Request, Response, NextFunction } from "express";
|
|
276
|
+
${r.logger!=="none"?'import { logger } from "./logger";':""}
|
|
277
|
+
import { AppError } from "./app-error";
|
|
278
|
+
import type { ApiResponse } from "../base/define-route";
|
|
309
279
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const provider = new LoggerProvider({
|
|
322
|
-
resource,
|
|
323
|
-
processors,
|
|
324
|
-
});
|
|
280
|
+
export function errorHandler(
|
|
281
|
+
err: unknown,
|
|
282
|
+
req: Request,
|
|
283
|
+
res: Response,
|
|
284
|
+
next: NextFunction,
|
|
285
|
+
) {
|
|
286
|
+
const metadata = {
|
|
287
|
+
timestamp: new Date().toISOString(),
|
|
288
|
+
requestId: (req as any).requestId,
|
|
289
|
+
path: req.path,
|
|
290
|
+
};
|
|
325
291
|
|
|
326
|
-
|
|
327
|
-
const
|
|
292
|
+
if (err instanceof ZodError) {
|
|
293
|
+
const response: ApiResponse<null> = {
|
|
294
|
+
success: false,
|
|
295
|
+
error: "Validation Error",
|
|
296
|
+
metadata,
|
|
297
|
+
};
|
|
298
|
+
return res.status(400).json({ ...response, issues: err.flatten() });
|
|
299
|
+
}
|
|
328
300
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
severityNumber,
|
|
338
|
-
body,
|
|
339
|
-
attributes: (attrs ?? {}) as AnyValueMap,
|
|
340
|
-
});
|
|
301
|
+
if (err instanceof AppError) {
|
|
302
|
+
const response: ApiResponse<null> = {
|
|
303
|
+
success: false,
|
|
304
|
+
error: err.message,
|
|
305
|
+
metadata,
|
|
306
|
+
};
|
|
307
|
+
return res.status(err.statusCode).json(response);
|
|
308
|
+
}
|
|
341
309
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
310
|
+
const response: ApiResponse<null> = {
|
|
311
|
+
success: false,
|
|
312
|
+
error: "Internal Server Error",
|
|
313
|
+
metadata,
|
|
314
|
+
};
|
|
345
315
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
console.error(msg);
|
|
349
|
-
break;
|
|
350
|
-
case SeverityNumber.WARN:
|
|
351
|
-
console.warn(msg);
|
|
352
|
-
break;
|
|
353
|
-
case SeverityNumber.DEBUG:
|
|
354
|
-
console.debug(msg);
|
|
355
|
-
break;
|
|
356
|
-
default:
|
|
357
|
-
console.log(msg);
|
|
358
|
-
}
|
|
316
|
+
if (process.env.NODE_ENV !== "production") {
|
|
317
|
+
(response as any).stack = err instanceof Error ? err.stack : undefined;
|
|
359
318
|
}
|
|
319
|
+
|
|
320
|
+
res.status(500).json(response);
|
|
321
|
+
}
|
|
322
|
+
`}function er(r){return`import { z, type ZodType } from "zod";
|
|
323
|
+
|
|
324
|
+
export interface ApiResponse<T> {
|
|
325
|
+
success: boolean;
|
|
326
|
+
data?: T;
|
|
327
|
+
error?: string;
|
|
328
|
+
metadata?: {
|
|
329
|
+
timestamp: string;
|
|
330
|
+
requestId?: string;
|
|
331
|
+
path: string;
|
|
332
|
+
};
|
|
360
333
|
}
|
|
361
334
|
|
|
362
|
-
export
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
emit("WARN", SeverityNumber.WARN, body, attrs),
|
|
367
|
-
error: (body: string, attrs?: object) =>
|
|
368
|
-
emit("ERROR", SeverityNumber.ERROR, body, attrs),
|
|
369
|
-
debug: (body: string, attrs?: object) => {
|
|
370
|
-
if (env.IS_DEV) emit("DEBUG", SeverityNumber.DEBUG, body, attrs);
|
|
371
|
-
},
|
|
372
|
-
};
|
|
335
|
+
${r.auth!=="none"?`export interface AuthUser {
|
|
336
|
+
id: string;
|
|
337
|
+
roles: string[];
|
|
338
|
+
}`:""}
|
|
373
339
|
|
|
374
|
-
export
|
|
375
|
-
logger.info("server.shutdown", { reason: signal });
|
|
376
|
-
await provider.forceFlush();
|
|
377
|
-
await provider.shutdown();
|
|
378
|
-
process.exit(0);
|
|
379
|
-
}
|
|
340
|
+
export type HttpMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
380
341
|
|
|
381
|
-
export
|
|
382
|
-
|
|
342
|
+
export interface RouteConfig<
|
|
343
|
+
TBody extends ZodType = ZodType,
|
|
344
|
+
TQuery extends ZodType = ZodType,
|
|
345
|
+
TParams extends ZodType = ZodType,
|
|
346
|
+
TOutput extends ZodType = ZodType,
|
|
347
|
+
> {
|
|
348
|
+
method: HttpMethod;
|
|
349
|
+
path: string;
|
|
350
|
+
input?: {
|
|
351
|
+
body?: TBody;
|
|
352
|
+
query?: TQuery;
|
|
353
|
+
params?: TParams;
|
|
354
|
+
};
|
|
355
|
+
output: TOutput;
|
|
356
|
+
${r.rateLimit!=="none"?` rateLimit?: {
|
|
357
|
+
enabled: boolean;
|
|
358
|
+
windowMs?: number;
|
|
359
|
+
max?: number;
|
|
360
|
+
};`:""}
|
|
361
|
+
${r.auth!=="none"?` auth?: {
|
|
362
|
+
required: boolean;
|
|
363
|
+
roles?: string[];
|
|
364
|
+
};`:""}
|
|
365
|
+
${r.caching!=="none"?` cache?: {
|
|
366
|
+
enabled: boolean;
|
|
367
|
+
ttl: number;
|
|
368
|
+
key: (ctx: { params: any; query: any${r.auth!=="none"?"; user: any":""} }) => string;
|
|
369
|
+
};`:""}
|
|
370
|
+
${r.logger!=="none"?` logging?: {
|
|
371
|
+
enabled: boolean;
|
|
372
|
+
fields?: Array<keyof z.infer<TOutput>>;
|
|
373
|
+
redact?: Array<keyof z.infer<TOutput>>;
|
|
374
|
+
};`:""}
|
|
383
375
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
|
|
376
|
+
handler: (ctx: {
|
|
377
|
+
body: TBody extends ZodType ? z.infer<TBody> : never;
|
|
378
|
+
query: TQuery extends ZodType ? z.infer<TQuery> : never;
|
|
379
|
+
params: TParams extends ZodType ? z.infer<TParams> : never;
|
|
380
|
+
${r.auth!=="none"?" user?: AuthUser;":""}
|
|
381
|
+
${r.logger!=="none"?" log: (attrs: Record<string, unknown>) => void;":""}
|
|
382
|
+
}) => Promise<z.infer<TOutput>>;
|
|
383
|
+
onRequest?: (ctx: {
|
|
384
|
+
body: TBody extends ZodType ? z.infer<TBody> : undefined;
|
|
385
|
+
query: TQuery extends ZodType ? z.infer<TQuery> : undefined;
|
|
386
|
+
params: TParams extends ZodType ? z.infer<TParams> : undefined;
|
|
387
|
+
${r.auth!=="none"?" user?: AuthUser;":""}
|
|
388
|
+
${r.logger!=="none"?" log: (attrs: Record<string, unknown>) => void;":""}
|
|
389
|
+
}) => Promise<void> | void;
|
|
390
|
+
}
|
|
392
391
|
|
|
393
|
-
export
|
|
394
|
-
|
|
395
|
-
|
|
392
|
+
export function defineRoute<
|
|
393
|
+
TBody extends ZodType,
|
|
394
|
+
TQuery extends ZodType,
|
|
395
|
+
TParams extends ZodType,
|
|
396
|
+
TOutput extends ZodType,
|
|
397
|
+
>(config: RouteConfig<TBody, TQuery, TParams, TOutput>) {
|
|
398
|
+
return config;
|
|
396
399
|
}
|
|
400
|
+
`}function rr(r){return`import {
|
|
401
|
+
type Router,
|
|
402
|
+
type Request,
|
|
403
|
+
type Response,
|
|
404
|
+
type NextFunction,
|
|
405
|
+
} from "express";
|
|
406
|
+
${r.rateLimit!=="none"?'import rateLimit from "express-rate-limit";':""}
|
|
407
|
+
import type { RouteConfig, ApiResponse } from "./define-route";
|
|
408
|
+
${r.caching!=="none"?'import { getCacheOptions, setCacheOptions } from "../utils/cache";':""}
|
|
409
|
+
${r.caching!=="none"?'import { cache } from "../utils/cache";':""}
|
|
410
|
+
${r.auth!=="none"?'import { authMiddleware } from "../middlewares/auth";':""}
|
|
397
411
|
|
|
398
|
-
export
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
412
|
+
export function registerRoute(
|
|
413
|
+
router: Router,
|
|
414
|
+
route: RouteConfig<any, any, any, any>,
|
|
415
|
+
) {
|
|
416
|
+
const middlewares: any[] = [];
|
|
417
|
+
|
|
418
|
+
${r.rateLimit!=="none"?` if (route.rateLimit?.enabled) {
|
|
419
|
+
middlewares.push(
|
|
420
|
+
rateLimit({
|
|
421
|
+
windowMs: route.rateLimit.windowMs ?? 60_000,
|
|
422
|
+
max: route.rateLimit.max ?? 100,
|
|
423
|
+
standardHeaders: true,
|
|
424
|
+
legacyHeaders: false,
|
|
425
|
+
}),
|
|
426
|
+
);
|
|
427
|
+
}`:""}
|
|
405
428
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
requestId: string;
|
|
410
|
-
_log: Record<string, unknown>;
|
|
411
|
-
_disableLogging?: boolean;
|
|
412
|
-
_errorHandled?: boolean;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
429
|
+
${r.auth!=="none"?` if (route.auth?.required) {
|
|
430
|
+
middlewares.push(authMiddleware(route.auth.roles));
|
|
431
|
+
}`:""}
|
|
416
432
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
433
|
+
const handler = async (req: Request, res: Response, next: NextFunction) => {
|
|
434
|
+
try {
|
|
435
|
+
const body = route.input?.body ? route.input.body.parse(req.body) : undefined;
|
|
436
|
+
const query = route.input?.query ? route.input.query.parse(req.query) : undefined;
|
|
437
|
+
const params = route.input?.params ? route.input.params.parse(req.params) : undefined;
|
|
438
|
+
${r.auth!=="none"?" const user = (req as any).user;":""}
|
|
439
|
+
${r.logger!=="none"?` const log = (attrs: Record<string, unknown>) => Object.assign(req._log, attrs);
|
|
440
|
+
req._log.route = route.path;
|
|
421
441
|
|
|
422
|
-
|
|
442
|
+
if (route.logging && !route.logging.enabled) {
|
|
443
|
+
(req as any)._disableLogging = true;
|
|
444
|
+
}`:""}
|
|
423
445
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
return originalJson(body);
|
|
428
|
-
};
|
|
446
|
+
if (route.onRequest) {
|
|
447
|
+
await route.onRequest({ body, query, params${r.auth!=="none"?", user":""}${r.logger!=="none"?", log":""} });
|
|
448
|
+
}
|
|
429
449
|
|
|
430
|
-
|
|
431
|
-
|
|
450
|
+
${r.caching!=="none"?` if (route.cache?.enabled) {
|
|
451
|
+
const key = route.cache.key({ params, query${r.auth!=="none"?", user":""} });
|
|
452
|
+
const cached = await cache.get(key);
|
|
453
|
+
if (cached) {
|
|
454
|
+
return res.json({ success: true, data: cached, fromCache: true });
|
|
455
|
+
}
|
|
456
|
+
}`:""}
|
|
432
457
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
requestId: req.requestId,
|
|
436
|
-
method: req.method,
|
|
437
|
-
path: req.path,
|
|
438
|
-
status: res.statusCode,
|
|
439
|
-
duration_ms: Date.now() - start,
|
|
440
|
-
...logFields,
|
|
441
|
-
};
|
|
458
|
+
const result = await route.handler({ body, query, params${r.auth!=="none"?", user":""}${r.logger!=="none"?", log":""} });
|
|
459
|
+
const validatedOutput = route.output.parse(result);
|
|
442
460
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
461
|
+
const response: ApiResponse<any> = {
|
|
462
|
+
success: true,
|
|
463
|
+
data: validatedOutput,
|
|
464
|
+
metadata: {
|
|
465
|
+
timestamp: new Date().toISOString(),
|
|
466
|
+
requestId: (req as any).requestId,
|
|
467
|
+
path: req.path,
|
|
468
|
+
},
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
res.json(response);
|
|
472
|
+
} catch (err) {
|
|
473
|
+
next(err);
|
|
447
474
|
}
|
|
448
|
-
}
|
|
475
|
+
};
|
|
449
476
|
|
|
450
|
-
|
|
477
|
+
router[route.method](route.path, ...middlewares, handler);
|
|
451
478
|
}
|
|
452
|
-
|
|
479
|
+
`}function tr(r){let t=`export { defineRoute } from "./define-route";
|
|
480
|
+
export { loadRoutes } from "./route-loader";
|
|
481
|
+
export { registerRoute } from "./route-registry";
|
|
482
|
+
export { errorHandler } from "../utils/error-handler";
|
|
483
|
+
export { AppError } from "../utils/app-error";
|
|
484
|
+
`;if(r.caching!=="none")t+=`export { cache } from "../utils/cache";
|
|
485
|
+
export { cacheKeys } from "../utils/cache-keys";
|
|
486
|
+
`;if(r.logger!=="none")t+=`export { logger, gracefulShutdown } from "../utils/logger";
|
|
487
|
+
`;if(r.orm==="prisma")t+=`export { prisma } from "../config/prisma";
|
|
488
|
+
`;else if(r.orm==="drizzle")t+=`export { db } from "../config/drizzle";
|
|
489
|
+
`;else if(r.orm==="mongoose")t+=`export { connectDatabase } from "../config/mongoose";
|
|
490
|
+
`;if(r.auth!=="none")t+=`export { authMiddleware${r.auth==="betterauth"?", authHandler":""} } from "../middlewares/auth";
|
|
491
|
+
`;if(r.pagination)t+=`export { paginationInput, paginatedOutput, paginate } from "../utils/pagination";
|
|
492
|
+
`;if(r.email!=="none")t+=`export { sendEmail } from "../utils/email";
|
|
493
|
+
`;return t}function or(r){return`import { z } from "zod";
|
|
494
|
+
import { defineRoute } from "../base/define-route";
|
|
495
|
+
${r.caching==="redis"?'import { redisClient } from "../config/redis";':""}
|
|
496
|
+
import { env } from "../config/env";
|
|
497
|
+
|
|
498
|
+
const startedAt = Date.now();
|
|
499
|
+
|
|
500
|
+
export const healthRoute = defineRoute({
|
|
501
|
+
method: "get",
|
|
502
|
+
path: "/health",
|
|
503
|
+
output: z.object({
|
|
504
|
+
status: z.string(),
|
|
505
|
+
uptime_s: z.number(),
|
|
506
|
+
version: z.string(),
|
|
507
|
+
${r.caching==="redis"?' redis: z.enum(["connected", "disconnected", "disabled"]),':""}
|
|
508
|
+
}),
|
|
509
|
+
handler: async () => {
|
|
510
|
+
${r.caching==="redis"?` let redis: "connected" | "disconnected" | "disabled" = "disabled";
|
|
511
|
+
if (env.IS_CACHE_ENABLED) {
|
|
512
|
+
try {
|
|
513
|
+
await redisClient.ping();
|
|
514
|
+
redis = "connected";
|
|
515
|
+
} catch {
|
|
516
|
+
redis = "disconnected";
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
`:""}
|
|
520
|
+
return {
|
|
521
|
+
status: "ok",
|
|
522
|
+
uptime_s: Math.floor((Date.now() - startedAt) / 1000),
|
|
523
|
+
version: env.SERVICE_VERSION || "1.0.0",
|
|
524
|
+
${r.caching==="redis"?" redis,":""}
|
|
525
|
+
};
|
|
526
|
+
},
|
|
527
|
+
});
|
|
528
|
+
`}var nr={id:"core",getFiles:(r,t)=>{return[{path:"package.json",content:Ke(t,r)},{path:"tsconfig.json",content:qe},{path:".gitignore",content:je},{path:".env",content:Xe(r,t)},{path:"src/config/env.ts",content:Qe(r,t)},{path:"src/utils/app-error.ts",content:We},{path:"src/utils/error-handler.ts",content:De(r)},{path:"src/base/index.ts",content:tr(r)},{path:"src/base/define-route.ts",content:er(r)},{path:"src/base/route-loader.ts",content:Ye},{path:"src/base/route-registry.ts",content:rr(r)},{path:"src/routes/health-route.ts",content:or(r)}]},getSnippets:(r)=>{return{imports:['import express from "express";','import helmet from "helmet";','import cors from "cors";','import { loadRoutes, registerRoute, errorHandler } from "./base";','import { env } from "./config/env";'],init:["const app = express();","app.use(helmet());","app.use(cors());","app.use(express.json());"],middleware:["const router = express.Router();","const routes = await loadRoutes();","routes.forEach((route) => registerRoute(router, route));",'app.use("/api", router);'],errorHandler:["app.use(errorHandler);"]}}};var ir=`generator client {
|
|
453
529
|
provider = "prisma-client"
|
|
454
530
|
output = "../generated/prisma"
|
|
455
531
|
}
|
|
@@ -464,7 +540,7 @@ model User {
|
|
|
464
540
|
email String @unique
|
|
465
541
|
createdAt DateTime @default(now())
|
|
466
542
|
}
|
|
467
|
-
`,
|
|
543
|
+
`,sr=`import "dotenv/config";
|
|
468
544
|
import { defineConfig, env } from "prisma/config";
|
|
469
545
|
|
|
470
546
|
export default defineConfig({
|
|
@@ -476,7 +552,7 @@ export default defineConfig({
|
|
|
476
552
|
url: env("DIRECT_URL"),
|
|
477
553
|
},
|
|
478
554
|
});
|
|
479
|
-
`,
|
|
555
|
+
`,ar=`import { PrismaPg } from "@prisma/adapter-pg";
|
|
480
556
|
import { PrismaClient } from "@prisma/client";
|
|
481
557
|
import { env } from "./env";
|
|
482
558
|
|
|
@@ -484,7 +560,7 @@ const connectionString = \`\${env.DATABASE_URL}\`;
|
|
|
484
560
|
|
|
485
561
|
const adapter = new PrismaPg({ connectionString });
|
|
486
562
|
export const prisma = new PrismaClient({ adapter });
|
|
487
|
-
`;var
|
|
563
|
+
`;var cr=`import { defineConfig } from "drizzle-kit";
|
|
488
564
|
|
|
489
565
|
export default defineConfig({
|
|
490
566
|
dialect: "postgresql",
|
|
@@ -494,7 +570,7 @@ export default defineConfig({
|
|
|
494
570
|
url: process.env.DATABASE_URL!,
|
|
495
571
|
},
|
|
496
572
|
});
|
|
497
|
-
`,
|
|
573
|
+
`,mr=`import { drizzle } from "drizzle-orm/node-postgres";
|
|
498
574
|
import { Pool } from "pg";
|
|
499
575
|
import { env } from "./env";
|
|
500
576
|
import * as schema from "../db/schema";
|
|
@@ -504,7 +580,7 @@ const pool = new Pool({
|
|
|
504
580
|
});
|
|
505
581
|
|
|
506
582
|
export const db = drizzle(pool, { schema });
|
|
507
|
-
`,
|
|
583
|
+
`,lr=`import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
508
584
|
|
|
509
585
|
export const users = pgTable("users", {
|
|
510
586
|
id: text("id").primaryKey(),
|
|
@@ -512,7 +588,7 @@ export const users = pgTable("users", {
|
|
|
512
588
|
email: text("email").notNull().unique(),
|
|
513
589
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
514
590
|
});
|
|
515
|
-
`;var
|
|
591
|
+
`;var pr=`import mongoose from "mongoose";
|
|
516
592
|
import { env } from "./env";
|
|
517
593
|
|
|
518
594
|
export async function connectDatabase() {
|
|
@@ -528,7 +604,7 @@ export async function connectDatabase() {
|
|
|
528
604
|
}
|
|
529
605
|
}
|
|
530
606
|
}
|
|
531
|
-
`,
|
|
607
|
+
`,dr=`import mongoose from "mongoose";
|
|
532
608
|
|
|
533
609
|
const userSchema = new mongoose.Schema(
|
|
534
610
|
{
|
|
@@ -539,7 +615,7 @@ const userSchema = new mongoose.Schema(
|
|
|
539
615
|
);
|
|
540
616
|
|
|
541
617
|
export const User = mongoose.model("User", userSchema);
|
|
542
|
-
`;var
|
|
618
|
+
`;var ur={id:"orm",getFiles:(r)=>{let t=[];if(r.orm==="prisma")t.push({path:"prisma/schema.prisma",content:ir},{path:"prisma.config.ts",content:sr},{path:"src/config/prisma.ts",content:ar});else if(r.orm==="drizzle")t.push({path:"drizzle.config.ts",content:cr},{path:"src/db/schema.ts",content:lr},{path:"src/config/drizzle.ts",content:mr});else if(r.orm==="mongoose")t.push({path:"src/config/mongoose.ts",content:pr},{path:"src/models/user.model.ts",content:dr});return t},getSnippets:(r)=>{if(r.orm==="none")return{};return{imports:[r.orm==="mongoose"?'import { connectDatabase } from "./config/mongoose";':null].filter(Boolean),init:[r.orm==="mongoose"?"await connectDatabase();":null].filter(Boolean)}}};var br=`import type { Request, Response, NextFunction } from "express";
|
|
543
619
|
import * as jwt from "jsonwebtoken";
|
|
544
620
|
import { env } from "../config/env";
|
|
545
621
|
import { AppError } from "../utils/app-error";
|
|
@@ -570,14 +646,14 @@ export const authMiddleware = (roles?: string[]) => {
|
|
|
570
646
|
}
|
|
571
647
|
};
|
|
572
648
|
};
|
|
573
|
-
`,
|
|
649
|
+
`,gr=`import { requireAuth } from '@clerk/express';
|
|
574
650
|
import type { Request, Response, NextFunction } from "express";
|
|
575
651
|
|
|
576
652
|
// Clerk handles auth via clerkMiddleware() globally in app.ts.
|
|
577
653
|
// requireAuth() ensures the route is protected. Roles are not natively
|
|
578
654
|
// supported by Clerk middleware, use Clerk's RBAC or custom logic.
|
|
579
655
|
export const authMiddleware = (_roles?: string[]) => requireAuth();
|
|
580
|
-
`,
|
|
656
|
+
`,hr=`import { betterAuth } from "better-auth";
|
|
581
657
|
import { toNodeHandler } from "better-auth/node";
|
|
582
658
|
import type { Request, Response, NextFunction } from "express";
|
|
583
659
|
import { env } from "../config/env";
|
|
@@ -618,491 +694,468 @@ export const authMiddleware = (roles?: string[]) => {
|
|
|
618
694
|
}
|
|
619
695
|
};
|
|
620
696
|
};
|
|
621
|
-
`;var
|
|
622
|
-
import { env } from "
|
|
697
|
+
`;var xr={id:"auth",getFiles:(r)=>{let t=[];if(r.auth==="custom")t.push({path:"src/middlewares/auth.ts",content:br});else if(r.auth==="clerk")t.push({path:"src/middlewares/auth.ts",content:gr});else if(r.auth==="betterauth")t.push({path:"src/middlewares/auth.ts",content:hr});return t},getSnippets:(r)=>{if(r.auth==="none")return{};return{imports:[r.auth==="clerk"?'import { clerkMiddleware } from "@clerk/express";':null,r.auth==="betterauth"?'import { authHandler } from "./base";':null].filter(Boolean),middleware:[r.auth==="clerk"?"app.use(clerkMiddleware());":null,r.auth==="betterauth"?'app.all(["/api/auth", "/api/auth/*path"], authHandler);':null].filter(Boolean)}}};var Er=`import { createClient } from "redis";
|
|
698
|
+
import { env } from "./env";
|
|
623
699
|
|
|
624
|
-
const
|
|
700
|
+
export const redisClient = createClient({
|
|
701
|
+
url: env.REDIS_URL,
|
|
702
|
+
});
|
|
625
703
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
704
|
+
if (env.IS_CACHE_ENABLED) {
|
|
705
|
+
redisClient.on("error", (err) =>
|
|
706
|
+
console.error("Redis client error", { error: err.message }),
|
|
707
|
+
);
|
|
708
|
+
redisClient.on("connect", () => console.log("Redis connected"));
|
|
709
|
+
redisClient.on("reconnecting", () => console.log("Redis reconnecting"));
|
|
631
710
|
}
|
|
632
711
|
|
|
633
|
-
export async function
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
subject,
|
|
639
|
-
html,
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
if (error) {
|
|
643
|
-
console.error("Resend API Error:", error);
|
|
644
|
-
return { success: false, error };
|
|
645
|
-
}
|
|
646
|
-
return { success: true, data };
|
|
647
|
-
} catch (error) {
|
|
648
|
-
console.error("Failed to send email via Resend:", error);
|
|
649
|
-
return { success: false, error };
|
|
712
|
+
export async function connectRedis() {
|
|
713
|
+
if (env.IS_CACHE_ENABLED) {
|
|
714
|
+
await redisClient.connect();
|
|
715
|
+
} else {
|
|
716
|
+
console.log("Caching is disabled. Redis will not connect.");
|
|
650
717
|
}
|
|
651
718
|
}
|
|
652
|
-
`,
|
|
719
|
+
`,Sr=`import { redisClient } from "../config/redis";
|
|
653
720
|
import { env } from "../config/env";
|
|
654
721
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
722
|
+
interface CacheOptions {
|
|
723
|
+
ttl: number;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
export const cache = {
|
|
727
|
+
async get<T>(key: string): Promise<T | null> {
|
|
728
|
+
if (!env.IS_CACHE_ENABLED) return null;
|
|
729
|
+
const value = await redisClient.get(key);
|
|
730
|
+
if (!value) return null;
|
|
731
|
+
return JSON.parse(value) as T;
|
|
662
732
|
},
|
|
663
|
-
});
|
|
664
733
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
from?: string;
|
|
670
|
-
}
|
|
734
|
+
async set<T>(key: string, value: T, options: CacheOptions): Promise<void> {
|
|
735
|
+
if (!env.IS_CACHE_ENABLED) return;
|
|
736
|
+
await redisClient.set(key, JSON.stringify(value), { EX: options.ttl });
|
|
737
|
+
},
|
|
671
738
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
to,
|
|
677
|
-
subject,
|
|
678
|
-
html,
|
|
679
|
-
});
|
|
680
|
-
return { success: true, messageId: info.messageId };
|
|
681
|
-
} catch (error) {
|
|
682
|
-
console.error("Failed to send email via Nodemailer:", error);
|
|
683
|
-
return { success: false, error };
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
`;var ar=`import { z, type ZodType } from "zod";
|
|
739
|
+
async del(key: string): Promise<void> {
|
|
740
|
+
if (!env.IS_CACHE_ENABLED) return;
|
|
741
|
+
await redisClient.del(key);
|
|
742
|
+
},
|
|
687
743
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
744
|
+
async delPattern(pattern: string): Promise<void> {
|
|
745
|
+
if (!env.IS_CACHE_ENABLED) return;
|
|
746
|
+
const keys = await redisClient.keys(pattern);
|
|
747
|
+
if (keys.length > 0) {
|
|
748
|
+
await redisClient.del(keys);
|
|
749
|
+
}
|
|
750
|
+
},
|
|
751
|
+
};
|
|
752
|
+
`,vr=`import { env } from "../config/env";
|
|
692
753
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
items: z.array(itemSchema),
|
|
696
|
-
total: z.number(),
|
|
697
|
-
page: z.number(),
|
|
698
|
-
limit: z.number(),
|
|
699
|
-
totalPages: z.number(),
|
|
700
|
-
});
|
|
754
|
+
interface CacheOptions {
|
|
755
|
+
ttl: number;
|
|
701
756
|
}
|
|
702
757
|
|
|
703
|
-
|
|
704
|
-
items: T[],
|
|
705
|
-
total: number,
|
|
706
|
-
page: number,
|
|
707
|
-
limit: number,
|
|
708
|
-
) {
|
|
709
|
-
return {
|
|
710
|
-
items,
|
|
711
|
-
total,
|
|
712
|
-
page,
|
|
713
|
-
limit,
|
|
714
|
-
totalPages: Math.ceil(total / limit),
|
|
715
|
-
};
|
|
716
|
-
}
|
|
717
|
-
`;var cr=`import { Inngest } from "inngest";
|
|
758
|
+
const store = new Map<string, { value: any; expiresAt: number }>();
|
|
718
759
|
|
|
719
|
-
export const
|
|
720
|
-
|
|
760
|
+
export const cache = {
|
|
761
|
+
async get<T>(key: string): Promise<T | null> {
|
|
762
|
+
if (!env.IS_CACHE_ENABLED) return null;
|
|
763
|
+
const item = store.get(key);
|
|
764
|
+
if (!item) return null;
|
|
765
|
+
if (Date.now() > item.expiresAt) {
|
|
766
|
+
store.delete(key);
|
|
767
|
+
return null;
|
|
768
|
+
}
|
|
769
|
+
return item.value as T;
|
|
770
|
+
},
|
|
771
|
+
|
|
772
|
+
async set<T>(key: string, value: T, options: CacheOptions): Promise<void> {
|
|
773
|
+
if (!env.IS_CACHE_ENABLED) return;
|
|
774
|
+
store.set(key, {
|
|
775
|
+
value,
|
|
776
|
+
expiresAt: Date.now() + options.ttl * 1000
|
|
777
|
+
});
|
|
778
|
+
},
|
|
721
779
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
await step.sleep("wait-a-moment", "1s");
|
|
726
|
-
return { message: \`Hello \${event.data.email}!\` };
|
|
780
|
+
async del(key: string): Promise<void> {
|
|
781
|
+
if (!env.IS_CACHE_ENABLED) return;
|
|
782
|
+
store.delete(key);
|
|
727
783
|
},
|
|
728
|
-
);
|
|
729
|
-
`,lr=`import { helloWorld } from "./functions/hello-world";
|
|
730
784
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
785
|
+
async delPattern(pattern: string): Promise<void> {
|
|
786
|
+
if (!env.IS_CACHE_ENABLED) return;
|
|
787
|
+
const regex = new RegExp("^" + pattern.replace("*", ".*") + "$");
|
|
788
|
+
for (const key of store.keys()) {
|
|
789
|
+
if (regex.test(key)) {
|
|
790
|
+
store.delete(key);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
};
|
|
795
|
+
`,Rr=`export const cacheKeys = {
|
|
796
|
+
users: {
|
|
797
|
+
detail: (id: string) => \`users:detail:\${id}\`,
|
|
798
|
+
},
|
|
799
|
+
};
|
|
800
|
+
`;var yr={id:"caching",getFiles:(r)=>{let t=[];if(r.caching==="none")return t;if(t.push({path:"src/utils/cache-keys.ts",content:Rr}),r.caching==="redis")t.push({path:"src/config/redis.ts",content:Er}),t.push({path:"src/utils/cache.ts",content:Sr});else if(r.caching==="memory")t.push({path:"src/utils/cache.ts",content:vr});return t},getSnippets:(r)=>{if(r.caching==="none")return{};return{imports:[r.caching==="redis"?'import { connectRedis } from "./config/redis";':null].filter(Boolean),init:[r.caching==="redis"?"await connectRedis();":null].filter(Boolean),envTs:[r.caching==="redis"?" REDIS_URL: process.env.REDIS_URL":null,` IS_CACHE_ENABLED: ${r.caching==="memory"?"true":'process.env.CACHE_ENABLED === "true"'}`].filter(Boolean)}}};var Ir=`import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
|
|
801
|
+
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
802
|
+
import {
|
|
803
|
+
LoggerProvider,
|
|
804
|
+
BatchLogRecordProcessor,
|
|
805
|
+
} from "@opentelemetry/sdk-logs";
|
|
806
|
+
import { SeverityNumber, logs } from "@opentelemetry/api-logs";
|
|
807
|
+
import type { AnyValueMap } from "@opentelemetry/api-logs";
|
|
808
|
+
import { env } from "../config/env";
|
|
738
809
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
handler: serve({ client: inngest, functions }),
|
|
810
|
+
const resource = resourceFromAttributes({
|
|
811
|
+
"service.name": env.SERVICE_NAME,
|
|
812
|
+
"service.version": env.SERVICE_VERSION,
|
|
813
|
+
"deployment.environment": env.NODE_ENV,
|
|
744
814
|
});
|
|
745
|
-
`;function br(r,t){let o={cors:"^2.8.5",dotenv:"^16.4.5",express:"^5.0.0",helmet:"^7.1.0",zod:"^3.23.8"};if(t.caching==="redis"||t.rateLimit==="redis")o.redis="^4.7.0";if(t.logger==="otel")o["@opentelemetry/api-logs"]="^0.53.0",o["@opentelemetry/exporter-logs-otlp-http"]="^0.53.0",o["@opentelemetry/resources"]="^1.26.0",o["@opentelemetry/sdk-logs"]="^0.53.0";if(t.orm==="prisma")o["@prisma/adapter-pg"]="^7.4.2",o["@prisma/client"]="^7.4.2",o.pg="^8.20.0",o.prisma="^7.4.2";else if(t.orm==="drizzle")o["drizzle-orm"]="^0.33.0",o["drizzle-kit"]="^0.24.0",o.pg="^8.12.0";else if(t.orm==="mongoose")o.mongoose="^8.6.0";if(t.auth==="clerk")o["@clerk/express"]="^1.3.11";else if(t.auth==="betterauth")o["better-auth"]="^1.1.18";else if(t.auth==="custom")o.jsonwebtoken="^9.0.2";if(t.rateLimit!=="none")o["express-rate-limit"]="^7.4.0";if(t.email==="resend")o.resend="^3.5.0";else if(t.email==="nodemailer")o.nodemailer="^6.9.14";if(t.inngest!=="none")o.inngest="latest";let i={"@types/bun":"latest","@types/cors":"^2.8.19","@types/express":"^5.0.6","@types/node":"^22.0.0"};if(t.email==="nodemailer")i["@types/nodemailer"]="^6.4.15";if(t.auth==="custom")i["@types/jsonwebtoken"]="^9.0.7";if(t.orm==="prisma"||t.orm==="drizzle")i["@types/pg"]="^8.11.6";let n={dev:"bun run --watch src/app.ts"};if(t.orm==="prisma")n["db:generate"]="prisma generate";if(t.formatter==="biome")i["@biomejs/biome"]="1.8.3",n.format="biome format --write .",n.lint="biome check .";else if(t.formatter==="prettier")i.prettier="^3.3.3",i.eslint="^9.9.0",i["typescript-eslint"]="^8.0.1",n.format="prettier --write .",n.lint="eslint .";return JSON.stringify({name:r,module:"src/app.ts",type:"module",private:!0,scripts:n,devDependencies:i,peerDependencies:{typescript:"^5"},dependencies:o},null,2)}function xr(r,t){let o=`PORT=8000
|
|
746
|
-
NODE_ENV=development
|
|
747
|
-
IS_DEV=true
|
|
748
|
-
`;if(r.caching==="redis")o+=`CACHE_ENABLED=true
|
|
749
|
-
REDIS_URL=redis://localhost:6379
|
|
750
|
-
`;if(r.logger==="otel")o+=`SERVICE_NAME=${t}
|
|
751
|
-
POSTHOG_URL=https://us.i.posthog.com/i/v1/logs
|
|
752
|
-
POSTHOG_API_KEY=your_key_here
|
|
753
|
-
`;if(r.orm!=="none")if(r.orm==="mongoose")o+=`DATABASE_URL=mongodb://localhost:27017/my_db
|
|
754
|
-
`;else o+=`DATABASE_URL=postgresql://user:pass@localhost:5432/db?schema=public
|
|
755
|
-
DIRECT_URL=postgresql://user:pass@localhost:5432/db
|
|
756
|
-
`;else if(r.auth==="betterauth")o+=`DATABASE_URL=postgresql://user:pass@localhost:5432/db?schema=public
|
|
757
|
-
`;if(r.auth==="betterauth")o+=`BETTER_AUTH_SECRET=super_secret_string
|
|
758
|
-
BETTER_AUTH_URL=http://localhost:8000
|
|
759
|
-
`;else if(r.auth==="custom")o+=`JWT_SECRET=your_super_secret_jwt_key_here
|
|
760
|
-
`;if(r.email==="resend")o+=`RESEND_API_KEY=re_123456789
|
|
761
|
-
`;else if(r.email==="nodemailer")o+=`SMTP_HOST=smtp.mailtrap.io
|
|
762
|
-
SMTP_PORT=2525
|
|
763
|
-
SMTP_USER=user
|
|
764
|
-
SMTP_PASS=pass
|
|
765
|
-
`;if(r.inngest!=="none")o+=`INNGEST_EVENT_KEY=your_event_key_here
|
|
766
|
-
INNGEST_SIGNING_KEY=your_signing_key_here
|
|
767
|
-
`;return o}function Er(r,t){return`export const env = {
|
|
768
|
-
IS_DEV: process.env.NODE_ENV !== "production",
|
|
769
|
-
NODE_ENV: process.env.NODE_ENV ?? "development",
|
|
770
|
-
PORT: Number(process.env.PORT) || 8000,
|
|
771
|
-
SERVICE_NAME: process.env.SERVICE_NAME ?? "${t}",
|
|
772
|
-
SERVICE_VERSION: process.env.npm_package_version ?? "1.0.0",
|
|
773
|
-
${r.caching==="redis"?` REDIS_URL: process.env.REDIS_URL,
|
|
774
|
-
IS_CACHE_ENABLED: process.env.CACHE_ENABLED === "true",`:""}
|
|
775
|
-
${r.caching==="memory"?" IS_CACHE_ENABLED: true,":""}
|
|
776
|
-
${r.logger==="otel"?` POSTHOG_API_KEY: process.env.POSTHOG_API_KEY,
|
|
777
|
-
POSTHOG_URL: process.env.POSTHOG_URL,`:""}
|
|
778
|
-
${r.orm!=="none"||r.auth==="betterauth"?" DATABASE_URL: process.env.DATABASE_URL,":""}
|
|
779
|
-
${r.auth==="clerk"?` CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY,
|
|
780
|
-
CLERK_PUBLISHABLE_KEY: process.env.CLERK_PUBLISHABLE_KEY,`:""}
|
|
781
|
-
${r.auth==="betterauth"?` BETTER_AUTH_SECRET: process.env.BETTER_AUTH_SECRET,
|
|
782
|
-
BETTER_AUTH_URL: process.env.BETTER_AUTH_URL,`:""}
|
|
783
|
-
${r.auth==="custom"?" JWT_SECRET: process.env.JWT_SECRET,":""}
|
|
784
|
-
${r.email==="resend"?" RESEND_API_KEY: process.env.RESEND_API_KEY,":""}
|
|
785
|
-
${r.email==="nodemailer"?` SMTP_HOST: process.env.SMTP_HOST,
|
|
786
|
-
SMTP_PORT: Number(process.env.SMTP_PORT) || 587,
|
|
787
|
-
SMTP_USER: process.env.SMTP_USER,
|
|
788
|
-
SMTP_PASS: process.env.SMTP_PASS,`:""}
|
|
789
|
-
${r.inngest!=="none"?` INNGEST_EVENT_KEY: process.env.INNGEST_EVENT_KEY,
|
|
790
|
-
INNGEST_SIGNING_KEY: process.env.INNGEST_SIGNING_KEY,`:""}
|
|
791
|
-
};
|
|
792
|
-
`}function ur(r){let t=['import express from "express";','import helmet from "helmet";','import cors from "cors";',`import { loadRoutes, registerRoute, errorHandler${r.logger!=="none"?", logger, gracefulShutdown":""}${r.auth==="betterauth"?", authHandler":""} } from "./base";`,r.caching==="redis"?'import { connectRedis } from "./config/redis";':null,r.orm==="mongoose"?'import { connectDatabase } from "./config/mongoose";':null,r.auth==="clerk"?'import { clerkMiddleware } from "@clerk/express";':null,r.logger!=="none"?'import { requestLogger } from "./middlewares/request-logger";':null,r.inngest!=="none"?'import { inngestRoute } from "./routes/inngest-route";':null,'import { env } from "./config/env";'].filter(Boolean).join(`
|
|
793
|
-
`),o=[r.orm==="mongoose"?" await connectDatabase();":null,r.caching==="redis"?" await connectRedis();":null,""," const app = express();"," app.use(helmet());"," app.use(cors());"," app.use(express.json());",r.auth==="clerk"?" app.use(clerkMiddleware());":null,r.logger!=="none"?" app.use(requestLogger);":null,r.auth==="betterauth"?' app.all(["/api/auth", "/api/auth/*path"], authHandler);':null,""," const router = express.Router();"," const routes = await loadRoutes();"," routes.forEach((route) => registerRoute(router, route));",r.inngest!=="none"?" registerRoute(router, inngestRoute);":null,r.logger!=="none"?' logger.info("routes.loaded", { count: routes.length });':" console.log(`Loaded ${routes.length} routes`);","",' app.use("/api", router);'," app.use(errorHandler);","",r.logger!=="none"?` process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
|
|
794
|
-
process.on("SIGINT", () => gracefulShutdown("SIGINT"));`:null,""," app.listen(env.PORT, () => {",r.logger!=="none"?' logger.info("server.started", { port: env.PORT });':" console.log(`Server started on port ${env.PORT}`);"," });"].filter((i)=>i!==null).join(`
|
|
795
|
-
`);return`${t}
|
|
796
815
|
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
816
|
+
const processors = [
|
|
817
|
+
new BatchLogRecordProcessor(
|
|
818
|
+
new OTLPLogExporter({
|
|
819
|
+
url: \`\${env.POSTHOG_URL}\`,
|
|
820
|
+
headers: {
|
|
821
|
+
Authorization: \`Bearer \${env.POSTHOG_API_KEY}\`,
|
|
822
|
+
},
|
|
823
|
+
}),
|
|
824
|
+
),
|
|
825
|
+
];
|
|
800
826
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
await loggerProvider.forceFlush();`:' console.error("server.bootstrap_failed", err);'}
|
|
805
|
-
process.exit(1);
|
|
827
|
+
const provider = new LoggerProvider({
|
|
828
|
+
resource,
|
|
829
|
+
processors,
|
|
806
830
|
});
|
|
807
|
-
`}function vr(r){return`import { ZodError } from "zod";
|
|
808
|
-
import type { Request, Response, NextFunction } from "express";
|
|
809
|
-
${r.logger!=="none"?'import { logger } from "./logger";':""}
|
|
810
|
-
import { AppError } from "./app-error";
|
|
811
831
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
req: Request,
|
|
815
|
-
res: Response,
|
|
816
|
-
next: NextFunction,
|
|
817
|
-
) {
|
|
818
|
-
${r.logger!=="none"?` if (req._disableLogging) {
|
|
819
|
-
if (err instanceof ZodError)
|
|
820
|
-
return res.status(400).json({ success: false, error: "Validation Error", issues: err.flatten() });
|
|
821
|
-
if (err instanceof AppError)
|
|
822
|
-
return res.status(err.statusCode).json({ success: false, error: err.message });
|
|
823
|
-
return res.status(500).json({ success: false, error: "Internal Server Error" });
|
|
824
|
-
}
|
|
832
|
+
logs.setGlobalLoggerProvider(provider);
|
|
833
|
+
const otelLogger = logs.getLogger(env.SERVICE_NAME);
|
|
825
834
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
835
|
+
function emit(
|
|
836
|
+
severityText: string,
|
|
837
|
+
severityNumber: SeverityNumber,
|
|
838
|
+
body: string,
|
|
839
|
+
attrs?: object,
|
|
840
|
+
) {
|
|
841
|
+
otelLogger.emit({
|
|
842
|
+
severityText,
|
|
843
|
+
severityNumber,
|
|
844
|
+
body,
|
|
845
|
+
attributes: (attrs ?? {}) as AnyValueMap,
|
|
846
|
+
});
|
|
836
847
|
|
|
837
|
-
if (
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
success: false,
|
|
841
|
-
error: "Validation Error",
|
|
842
|
-
issues: err.flatten(),
|
|
843
|
-
});
|
|
844
|
-
}
|
|
848
|
+
if (env.IS_DEV) {
|
|
849
|
+
const meta = attrs ? \` \${JSON.stringify(attrs)}\` : "";
|
|
850
|
+
const msg = \`[\${severityText}] \${body}\${meta}\`;
|
|
845
851
|
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
852
|
+
switch (severityNumber) {
|
|
853
|
+
case SeverityNumber.ERROR:
|
|
854
|
+
console.error(msg);
|
|
855
|
+
break;
|
|
856
|
+
case SeverityNumber.WARN:
|
|
857
|
+
console.warn(msg);
|
|
858
|
+
break;
|
|
859
|
+
case SeverityNumber.DEBUG:
|
|
860
|
+
console.debug(msg);
|
|
861
|
+
break;
|
|
862
|
+
default:
|
|
863
|
+
console.log(msg);
|
|
864
|
+
}
|
|
853
865
|
}
|
|
854
|
-
|
|
855
|
-
${r.logger!=="none"?` logger.error("request.unhandled_error", {
|
|
856
|
-
...ctx,
|
|
857
|
-
error: err instanceof Error ? err.message : String(err),
|
|
858
|
-
stack: err instanceof Error ? err.stack : undefined,
|
|
859
|
-
});`:' console.error("request.unhandled_error", err);'}
|
|
860
|
-
|
|
861
|
-
res.status(500).json({ success: false, error: "Internal Server Error" });
|
|
862
866
|
}
|
|
863
|
-
`}function hr(r){return`import { z, type ZodType } from "zod";
|
|
864
|
-
|
|
865
|
-
${r.auth!=="none"?`export interface AuthUser {
|
|
866
|
-
id: string;
|
|
867
|
-
roles: string[];
|
|
868
|
-
}`:""}
|
|
869
|
-
|
|
870
|
-
export type HttpMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
871
867
|
|
|
872
|
-
export
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
params?: TParams;
|
|
884
|
-
};
|
|
885
|
-
output: TOutput;
|
|
886
|
-
${r.rateLimit!=="none"?` rateLimit?: {
|
|
887
|
-
enabled: boolean;
|
|
888
|
-
windowMs?: number;
|
|
889
|
-
max?: number;
|
|
890
|
-
};`:""}
|
|
891
|
-
${r.auth!=="none"?` auth?: {
|
|
892
|
-
required: boolean;
|
|
893
|
-
roles?: string[];
|
|
894
|
-
};`:""}
|
|
895
|
-
${r.caching!=="none"?` cache?: {
|
|
896
|
-
enabled: boolean;
|
|
897
|
-
ttl: number;
|
|
898
|
-
key: (ctx: { params: any; query: any${r.auth!=="none"?"; user: any":""} }) => string;
|
|
899
|
-
};`:""}
|
|
900
|
-
${r.logger!=="none"?` logging?: {
|
|
901
|
-
enabled: boolean;
|
|
902
|
-
fields?: Array<keyof z.infer<TOutput>>;
|
|
903
|
-
redact?: Array<keyof z.infer<TOutput>>;
|
|
904
|
-
};`:""}
|
|
868
|
+
export const logger = {
|
|
869
|
+
info: (body: string, attrs?: object) =>
|
|
870
|
+
emit("INFO", SeverityNumber.INFO, body, attrs),
|
|
871
|
+
warn: (body: string, attrs?: object) =>
|
|
872
|
+
emit("WARN", SeverityNumber.WARN, body, attrs),
|
|
873
|
+
error: (body: string, attrs?: object) =>
|
|
874
|
+
emit("ERROR", SeverityNumber.ERROR, body, attrs),
|
|
875
|
+
debug: (body: string, attrs?: object) => {
|
|
876
|
+
if (env.IS_DEV) emit("DEBUG", SeverityNumber.DEBUG, body, attrs);
|
|
877
|
+
},
|
|
878
|
+
};
|
|
905
879
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
}) => void | Promise<void>;
|
|
880
|
+
export async function gracefulShutdown(signal: string) {
|
|
881
|
+
logger.info("server.shutdown", { reason: signal });
|
|
882
|
+
await provider.forceFlush();
|
|
883
|
+
await provider.shutdown();
|
|
884
|
+
process.exit(0);
|
|
885
|
+
}
|
|
913
886
|
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
${r.auth!=="none"?" user?: AuthUser;":""}
|
|
917
|
-
${r.logger!=="none"?" log: (attrs: Record<string, unknown>) => void;":""}
|
|
918
|
-
}) => void | Promise<void>;
|
|
887
|
+
export { provider as loggerProvider };
|
|
888
|
+
`,_r=`import { env } from "../config/env";
|
|
919
889
|
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
890
|
+
export const logger = {
|
|
891
|
+
info: (body: string, attrs?: object) => console.log(\`[INFO] \${body}\`, attrs ?? ""),
|
|
892
|
+
warn: (body: string, attrs?: object) => console.warn(\`[WARN] \${body}\`, attrs ?? ""),
|
|
893
|
+
error: (body: string, attrs?: object) => console.error(\`[ERROR] \${body}\`, attrs ?? ""),
|
|
894
|
+
debug: (body: string, attrs?: object) => {
|
|
895
|
+
if (env.IS_DEV) console.debug(\`[DEBUG] \${body}\`, attrs ?? "");
|
|
896
|
+
},
|
|
897
|
+
};
|
|
925
898
|
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
params: TParams extends ZodType ? z.infer<TParams> : never;
|
|
930
|
-
${r.auth!=="none"?" user?: AuthUser;":""}
|
|
931
|
-
${r.logger!=="none"?" log: (attrs: Record<string, unknown>) => void;":""}
|
|
932
|
-
}) => Promise<z.infer<TOutput>>;
|
|
899
|
+
export async function gracefulShutdown(signal: string) {
|
|
900
|
+
logger.info("server.shutdown", { reason: signal });
|
|
901
|
+
process.exit(0);
|
|
933
902
|
}
|
|
934
903
|
|
|
935
|
-
export
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
904
|
+
export const loggerProvider = {
|
|
905
|
+
forceFlush: async () => {},
|
|
906
|
+
shutdown: async () => {},
|
|
907
|
+
};
|
|
908
|
+
`,fr=`import type { Request, Response, NextFunction } from "express";
|
|
909
|
+
import { randomUUID } from "crypto";
|
|
910
|
+
import { logger } from "../utils/logger";
|
|
911
|
+
|
|
912
|
+
declare global {
|
|
913
|
+
namespace Express {
|
|
914
|
+
interface Request {
|
|
915
|
+
requestId: string;
|
|
916
|
+
_log: Record<string, unknown>;
|
|
917
|
+
_disableLogging?: boolean;
|
|
918
|
+
_errorHandled?: boolean;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
942
921
|
}
|
|
943
|
-
`}function wr(r){return`import {
|
|
944
|
-
type Router,
|
|
945
|
-
type Request,
|
|
946
|
-
type Response,
|
|
947
|
-
type NextFunction,
|
|
948
|
-
} from "express";
|
|
949
|
-
${r.rateLimit!=="none"?'import rateLimit from "express-rate-limit";':""}
|
|
950
|
-
import type { RouteConfig } from "./define-route";
|
|
951
|
-
${r.auth!=="none"?'import { authMiddleware } from "../middlewares/auth";':""}
|
|
952
|
-
${r.caching!=="none"?'import { cache } from "../utils/cache";':""}
|
|
953
922
|
|
|
954
|
-
export function
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
)
|
|
958
|
-
const middlewares: any[] = [];
|
|
923
|
+
export function requestLogger(req: Request, res: Response, next: NextFunction) {
|
|
924
|
+
req.requestId = randomUUID();
|
|
925
|
+
res.setHeader("X-Request-Id", req.requestId);
|
|
926
|
+
req._log = { _startMs: Date.now() };
|
|
959
927
|
|
|
960
|
-
|
|
961
|
-
middlewares.push(
|
|
962
|
-
rateLimit({
|
|
963
|
-
windowMs: route.rateLimit.windowMs ?? 60_000,
|
|
964
|
-
max: route.rateLimit.max ?? 100,
|
|
965
|
-
standardHeaders: true,
|
|
966
|
-
legacyHeaders: false,
|
|
967
|
-
}),
|
|
968
|
-
);
|
|
969
|
-
}`:""}
|
|
928
|
+
const start = Date.now();
|
|
970
929
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
930
|
+
const originalJson = res.json.bind(res);
|
|
931
|
+
res.json = (body: any) => {
|
|
932
|
+
res.setHeader("X-Response-Time", \`\${Date.now() - start}ms\`);
|
|
933
|
+
return originalJson(body);
|
|
934
|
+
};
|
|
974
935
|
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
const body = route.input?.body ? route.input.body.parse(req.body) : undefined;
|
|
978
|
-
const query = route.input?.query ? route.input.query.parse(req.query) : undefined;
|
|
979
|
-
const params = route.input?.params ? route.input.params.parse(req.params) : undefined;
|
|
980
|
-
${r.auth!=="none"?" const user = (req as any).user;":""}
|
|
981
|
-
${r.logger!=="none"?` const log = (attrs: Record<string, unknown>) => Object.assign(req._log, attrs);
|
|
982
|
-
req._log.route = route.path;
|
|
936
|
+
res.on("finish", () => {
|
|
937
|
+
if (req._disableLogging) return;
|
|
983
938
|
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
939
|
+
const { _startMs, ...logFields } = req._log;
|
|
940
|
+
const attrs = {
|
|
941
|
+
requestId: req.requestId,
|
|
942
|
+
method: req.method,
|
|
943
|
+
path: req.path,
|
|
944
|
+
status: res.statusCode,
|
|
945
|
+
duration_ms: Date.now() - start,
|
|
946
|
+
...logFields,
|
|
947
|
+
};
|
|
987
948
|
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
949
|
+
if (res.statusCode < 400) {
|
|
950
|
+
logger.info("request.completed", attrs);
|
|
951
|
+
} else if (!req._errorHandled) {
|
|
952
|
+
logger.warn("request.rejected", attrs);
|
|
953
|
+
}
|
|
954
|
+
});
|
|
991
955
|
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
if (cached) {
|
|
996
|
-
return res.json({ success: true, data: cached, fromCache: true });
|
|
997
|
-
}
|
|
998
|
-
}`:""}
|
|
956
|
+
next();
|
|
957
|
+
}
|
|
958
|
+
`;var Nr={id:"logger",getFiles:(r)=>{let t=[];if(r.logger==="none")return t;if(r.logger==="otel")t.push({path:"src/utils/logger.ts",content:Ir});else t.push({path:"src/utils/logger.ts",content:_r});return t.push({path:"src/middlewares/request-logger.ts",content:fr}),t},getSnippets:(r)=>{if(r.logger==="none")return{};return{imports:['import { logger, gracefulShutdown } from "./base";','import { requestLogger } from "./middlewares/request-logger";'],middleware:["app.use(requestLogger);"],shutdown:['process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));','process.on("SIGINT", () => gracefulShutdown("SIGINT"));']}}};var Ar=`import { z, type ZodType } from "zod";
|
|
999
959
|
|
|
1000
|
-
|
|
1001
|
-
|
|
960
|
+
export const paginationInput = z.object({
|
|
961
|
+
page: z.coerce.number().int().min(1).default(1),
|
|
962
|
+
limit: z.coerce.number().int().min(1).max(100).default(20),
|
|
963
|
+
});
|
|
1002
964
|
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
965
|
+
export function paginatedOutput<T extends ZodType>(itemSchema: T) {
|
|
966
|
+
return z.object({
|
|
967
|
+
items: z.array(itemSchema),
|
|
968
|
+
total: z.number(),
|
|
969
|
+
page: z.number(),
|
|
970
|
+
limit: z.number(),
|
|
971
|
+
totalPages: z.number(),
|
|
972
|
+
});
|
|
973
|
+
}
|
|
1010
974
|
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
975
|
+
export function paginate<T>(
|
|
976
|
+
items: T[],
|
|
977
|
+
total: number,
|
|
978
|
+
page: number,
|
|
979
|
+
limit: number,
|
|
980
|
+
) {
|
|
981
|
+
return {
|
|
982
|
+
items,
|
|
983
|
+
total,
|
|
984
|
+
page,
|
|
985
|
+
limit,
|
|
986
|
+
totalPages: Math.ceil(total / limit),
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
`;var Or=`import { Resend } from "resend";
|
|
990
|
+
import { env } from "../config/env";
|
|
1019
991
|
|
|
1020
|
-
|
|
1021
|
-
setImmediate(async () => {
|
|
1022
|
-
try {
|
|
1023
|
-
await route.onResponse!({ output: validatedOutput${r.auth!=="none"?", user":""}${r.logger!=="none"?", log":""} });
|
|
1024
|
-
} catch (err) {
|
|
1025
|
-
console.error(\`[onResponse Error] route \${route.path}:\`, err);
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
}
|
|
992
|
+
const resend = new Resend(env.RESEND_API_KEY);
|
|
1029
993
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
await cache.delPattern(key);
|
|
1037
|
-
} else {
|
|
1038
|
-
await cache.del(key);
|
|
1039
|
-
}
|
|
1040
|
-
} catch (err) {
|
|
1041
|
-
console.error(\`[Cache Inval Error]\`, err);
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
1045
|
-
}`:""}
|
|
994
|
+
interface SendEmailParams {
|
|
995
|
+
to: string;
|
|
996
|
+
subject: string;
|
|
997
|
+
html: string;
|
|
998
|
+
from?: string;
|
|
999
|
+
}
|
|
1046
1000
|
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1001
|
+
export async function sendEmail({ to, subject, html, from = "onboarding@resend.dev" }: SendEmailParams) {
|
|
1002
|
+
try {
|
|
1003
|
+
const { data, error } = await resend.emails.send({
|
|
1004
|
+
from,
|
|
1005
|
+
to,
|
|
1006
|
+
subject,
|
|
1007
|
+
html,
|
|
1008
|
+
});
|
|
1009
|
+
|
|
1010
|
+
if (error) {
|
|
1011
|
+
console.error("Resend API Error:", error);
|
|
1012
|
+
return { success: false, error };
|
|
1050
1013
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1014
|
+
return { success: true, data };
|
|
1015
|
+
} catch (error) {
|
|
1016
|
+
console.error("Failed to send email via Resend:", error);
|
|
1017
|
+
return { success: false, error };
|
|
1018
|
+
}
|
|
1054
1019
|
}
|
|
1055
|
-
|
|
1056
|
-
export { loadRoutes } from "./route-loader";
|
|
1057
|
-
export { registerRoute } from "./route-registry";
|
|
1058
|
-
export { errorHandler } from "../utils/error-handler";
|
|
1059
|
-
export { AppError } from "../utils/app-error";
|
|
1060
|
-
`;if(r.caching!=="none")t+=`export { cache } from "../utils/cache";
|
|
1061
|
-
export { cacheKeys } from "../utils/cache-keys";
|
|
1062
|
-
`;if(r.logger!=="none")t+=`export { logger, gracefulShutdown } from "../utils/logger";
|
|
1063
|
-
`;if(r.orm==="prisma")t+=`export { prisma } from "../config/prisma";
|
|
1064
|
-
`;else if(r.orm==="drizzle")t+=`export { db } from "../config/drizzle";
|
|
1065
|
-
`;else if(r.orm==="mongoose")t+=`export { connectDatabase } from "../config/mongoose";
|
|
1066
|
-
`;if(r.auth!=="none")t+=`export { authMiddleware${r.auth==="betterauth"?", authHandler":""} } from "../middlewares/auth";
|
|
1067
|
-
`;if(r.pagination)t+=`export { paginationInput, paginatedOutput, paginate } from "../utils/pagination";
|
|
1068
|
-
`;if(r.email!=="none")t+=`export { sendEmail } from "../utils/email";
|
|
1069
|
-
`;return t}function yr(r){return`import { z } from "zod";
|
|
1070
|
-
import { defineRoute } from "../base/define-route";
|
|
1071
|
-
${r.caching==="redis"?'import { redisClient } from "../config/redis";':""}
|
|
1020
|
+
`,wr=`import nodemailer from "nodemailer";
|
|
1072
1021
|
import { env } from "../config/env";
|
|
1073
1022
|
|
|
1074
|
-
const
|
|
1023
|
+
const transporter = nodemailer.createTransport({
|
|
1024
|
+
host: env.SMTP_HOST,
|
|
1025
|
+
port: env.SMTP_PORT,
|
|
1026
|
+
secure: env.SMTP_PORT === 465,
|
|
1027
|
+
auth: {
|
|
1028
|
+
user: env.SMTP_USER,
|
|
1029
|
+
pass: env.SMTP_PASS,
|
|
1030
|
+
},
|
|
1031
|
+
});
|
|
1075
1032
|
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1033
|
+
interface SendEmailParams {
|
|
1034
|
+
to: string;
|
|
1035
|
+
subject: string;
|
|
1036
|
+
html: string;
|
|
1037
|
+
from?: string;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
export async function sendEmail({ to, subject, html, from = '"API" <no-reply@example.com>' }: SendEmailParams) {
|
|
1041
|
+
try {
|
|
1042
|
+
const info = await transporter.sendMail({
|
|
1043
|
+
from,
|
|
1044
|
+
to,
|
|
1045
|
+
subject,
|
|
1046
|
+
html,
|
|
1047
|
+
});
|
|
1048
|
+
return { success: true, messageId: info.messageId };
|
|
1049
|
+
} catch (error) {
|
|
1050
|
+
console.error("Failed to send email via Nodemailer:", error);
|
|
1051
|
+
return { success: false, error };
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
`;var Tr=`import { Inngest } from "inngest";
|
|
1055
|
+
|
|
1056
|
+
export const inngest = new Inngest({ id: "my-app" });
|
|
1057
|
+
`,Pr=`import { inngest } from "../client";
|
|
1058
|
+
|
|
1059
|
+
export const helloWorld = inngest.createFunction(
|
|
1060
|
+
{ id: "hello-world", triggers: [{ event: "test/hello.world" }] },
|
|
1061
|
+
async ({ event, step }) => {
|
|
1062
|
+
await step.sleep("wait-a-moment", "1s");
|
|
1063
|
+
return { message: \`Hello \${event.data.email}!\` };
|
|
1102
1064
|
},
|
|
1065
|
+
);
|
|
1066
|
+
`,Cr=`import { helloWorld } from "./functions/hello-world";
|
|
1067
|
+
|
|
1068
|
+
export const functions = [helloWorld];
|
|
1069
|
+
`,Lr=`import { serve } from "inngest/express";
|
|
1070
|
+
import { inngest } from "../inngest/client";
|
|
1071
|
+
import { functions } from "../inngest";
|
|
1072
|
+
import { healthRoute } from "./health-route";
|
|
1073
|
+
import { defineRoute } from "../base/define-route";
|
|
1074
|
+
import { z } from "zod";
|
|
1075
|
+
|
|
1076
|
+
export const inngestRoute = defineRoute({
|
|
1077
|
+
method: "post",
|
|
1078
|
+
path: "/inngest",
|
|
1079
|
+
output: z.any(),
|
|
1080
|
+
handler: serve({ client: inngest, functions }),
|
|
1103
1081
|
});
|
|
1104
|
-
|
|
1082
|
+
`;var Mr={id:"extra",getFiles:(r)=>{let t=[];if(r.pagination)t.push({path:"src/utils/pagination.ts",content:Ar});if(r.email==="resend")t.push({path:"src/utils/email.ts",content:Or});else if(r.email==="nodemailer")t.push({path:"src/utils/email.ts",content:wr});if(r.inngest!=="none")t.push({path:"src/inngest/client.ts",content:Tr},{path:"src/inngest/index.ts",content:Cr},{path:"src/inngest/functions/hello-world.ts",content:Pr},{path:"src/routes/inngest-route.ts",content:Lr});if(r.formatter==="biome")t.push({path:"biome.json",content:Je});else if(r.formatter==="prettier")t.push({path:".prettierrc",content:Ze},{path:"eslint.config.js",content:Ve});return t},getSnippets:(r)=>{let t={imports:[],middleware:[]};if(r.inngest!=="none")t.imports.push('import { inngestRoute } from "./routes/inngest-route";'),t.middleware.push("registerRoute(router, inngestRoute);");return t}};var kr={id:"infrastructure",getFiles:(r)=>{let t=[];if(r.docker)t.push({path:"Dockerfile",content:`FROM oven/bun:latest as base
|
|
1083
|
+
WORKDIR /usr/src/app
|
|
1084
|
+
|
|
1085
|
+
FROM base AS install
|
|
1086
|
+
RUN mkdir -p /temp/dev
|
|
1087
|
+
COPY package.json bun.lock /temp/dev/
|
|
1088
|
+
RUN cd /temp/dev && bun install --frozen-lockfile
|
|
1089
|
+
|
|
1090
|
+
FROM base AS prerelease
|
|
1091
|
+
COPY --from=install /temp/dev/node_modules node_modules
|
|
1092
|
+
COPY . .
|
|
1093
|
+
|
|
1094
|
+
FROM base AS release
|
|
1095
|
+
COPY --from=prerelease /usr/src/app/src src
|
|
1096
|
+
COPY --from=prerelease /usr/src/app/package.json .
|
|
1097
|
+
COPY --from=prerelease /usr/src/app/tsconfig.json .
|
|
1098
|
+
|
|
1099
|
+
USER bun
|
|
1100
|
+
EXPOSE 8000/tcp
|
|
1101
|
+
ENTRYPOINT [ "bun", "run", "src/app.ts" ]
|
|
1102
|
+
`}),t.push({path:"docker-compose.yml",content:`version: "3.9"
|
|
1103
|
+
services:
|
|
1104
|
+
app:
|
|
1105
|
+
build: .
|
|
1106
|
+
ports:
|
|
1107
|
+
- "8000:8000"
|
|
1108
|
+
environment:
|
|
1109
|
+
- NODE_ENV=development
|
|
1110
|
+
${r.orm!=="none"?" - DATABASE_URL=postgresql://user:password@db:5432/aura_db":""}
|
|
1111
|
+
${r.caching==="redis"?" - REDIS_URL=redis://redis:6379":""}
|
|
1112
|
+
depends_on:
|
|
1113
|
+
${r.orm==="prisma"||r.orm==="drizzle"?" - db":""}
|
|
1114
|
+
${r.caching==="redis"?" - redis":""}
|
|
1115
|
+
|
|
1116
|
+
${r.orm==="prisma"||r.orm==="drizzle"?` db:
|
|
1117
|
+
image: postgres:15-alpine
|
|
1118
|
+
environment:
|
|
1119
|
+
- POSTGRES_USER=user
|
|
1120
|
+
- POSTGRES_PASSWORD=password
|
|
1121
|
+
- POSTGRES_DB=aura_db
|
|
1122
|
+
ports:
|
|
1123
|
+
- "5432:5432"
|
|
1124
|
+
`:""}
|
|
1125
|
+
|
|
1126
|
+
${r.caching==="redis"?` redis:
|
|
1127
|
+
image: redis:7-alpine
|
|
1128
|
+
ports:
|
|
1129
|
+
- "6379:6379"
|
|
1130
|
+
`:""}
|
|
1131
|
+
`});if(r.ci==="github")t.push({path:".github/workflows/ci.yml",content:`name: CI
|
|
1132
|
+
|
|
1133
|
+
on:
|
|
1134
|
+
push:
|
|
1135
|
+
branches: [main]
|
|
1136
|
+
pull_request:
|
|
1137
|
+
branches: [main]
|
|
1138
|
+
|
|
1139
|
+
jobs:
|
|
1140
|
+
build:
|
|
1141
|
+
runs-on: ubuntu-latest
|
|
1142
|
+
steps:
|
|
1143
|
+
- uses: actions/checkout@v4
|
|
1144
|
+
- uses: oven-sh/setup-bun@v1
|
|
1145
|
+
- run: bun install
|
|
1146
|
+
- run: bunx tsc --noEmit
|
|
1147
|
+
${r.formatter==="biome"?" - run: bun run lint":""}
|
|
1148
|
+
`});return t}};var ie=[nr,ur,xr,yr,Nr,Mr,kr];function Br(r){return ie.filter((t)=>{if(t.id==="core"||t.id==="extra")return!0;if(t.id==="infrastructure"&&(r.docker||r.ci!=="none"))return!0;if(t.id==="orm"&&r.orm!=="none")return!0;if(t.id==="auth"&&r.auth!=="none")return!0;if(t.id==="caching"&&r.caching!=="none")return!0;if(t.id==="logger"&&r.logger!=="none")return!0;return!1})}function Gr(r,t){let o=Br(r),i=[];for(let n of o)i.push(...n.getFiles(r,t));return i}function Hr(r){let t=Br(r),o={imports:[],init:[],middleware:[],errorHandler:[],shutdown:[]};for(let i of t){let n=i.getSnippets?.(r);if(n){if(n.imports)o.imports.push(...n.imports);if(n.init)o.init.push(...n.init);if(n.middleware)o.middleware.push(...n.middleware);if(n.errorHandler)o.errorHandler.push(...n.errorHandler);if(n.shutdown)o.shutdown.push(...n.shutdown)}}return o}async function $r(r,t,o){let i=$();i.start("Scaffolding your project...");let n=Gr(o,t),a=Hr(o);n.push({path:"src/app.ts",content:Fe(a)});for(let e of n){let c=zr.join(r,e.path),b=zr.dirname(c);await Ur.mkdir(b,{recursive:!0}),await Ur.writeFile(c,e.content)}return i.stop("Project generated successfully."),r}import se from"path";var qr={name:"@ahmadjavaiddev/aura",version:"1.0.3",type:"module",description:"Interactive CLI scaffolder to generate custom API structures",main:"./dist/index.js",bin:{aura:"dist/index.js"},files:["dist"],publishConfig:{access:"public"},scripts:{start:"bun run src/cli.ts",build:"bun build ./src/cli.ts --outfile ./dist/index.js --target node --bundle --minify",prepublishOnly:"bun run build"},dependencies:{"@clack/prompts":"^0.8.2"},devDependencies:{"@types/bun":"latest","@types/node":"^22.0.0",typescript:"^5.0.0"}};import I from"fs/promises";import N from"path";async function jr(r,t,o){let i=$();i.start(`Injecting ${t} into your project...`);let n=ie.find((l)=>l.id===t);if(!n)throw Error(`Feature ${t} not found.`);let a=n.getFiles(o,N.basename(r));for(let l of a){let m=N.join(r,l.path),p=N.dirname(m);await I.mkdir(p,{recursive:!0}),await I.writeFile(m,l.content)}let e=n.getDependencies?.(o),c=n.getDevDependencies?.(o);if(e||c){let l=N.join(r,"package.json");try{let m=await I.readFile(l,"utf-8"),p=JSON.parse(m);if(e)p.dependencies={...p.dependencies,...e};if(c)p.devDependencies={...p.devDependencies,...c};await I.writeFile(l,JSON.stringify(p,null,2))}catch(m){console.warn("Could not update package.json, make sure it exists.")}}let b=N.join(r,"src","app.ts");try{let l=await I.readFile(b,"utf-8"),m=n.getSnippets?.(o);if(m){if(l=w(l,"// [AURA_IMPORTS]",m.imports?.join(`
|
|
1149
|
+
`)),l=w(l,"// [AURA_INIT]",m.init?.map((p)=>` ${p}`).join(`
|
|
1150
|
+
`)),l=w(l,"// [AURA_MIDDLEWARE]",m.middleware?.map((p)=>` ${p}`).join(`
|
|
1151
|
+
`)),l=w(l,"// [AURA_ERROR_HANDLER]",m.errorHandler?.map((p)=>` ${p}`).join(`
|
|
1152
|
+
`)),l=w(l,"// [AURA_SHUTDOWN]",m.shutdown?.map((p)=>` ${p}`).join(`
|
|
1153
|
+
`)),await I.writeFile(b,l),m.envTs&&m.envTs.length>0){let p=N.join(r,"src","config","env.ts"),x=await I.readFile(p,"utf-8");x=w(x,"// [AURA_ENV_KEYS]",m.envTs.map((S)=>` ${S},`).join(`
|
|
1154
|
+
`)),await I.writeFile(p,x)}}}catch(l){console.warn("Could not inject snippets. Are you in a valid Aura project directory?")}let d=n.getEnvVars?.(o);if(d){let l=N.join(r,".env");try{await I.appendFile(l,`
|
|
1155
|
+
`+d)}catch(m){console.warn("Could not update .env file.")}}i.stop(`Successfully added ${t} to your project.`)}function w(r,t,o){if(!o||o.trim()==="")return r;if(r.includes(t))return r.replace(t,`${o}
|
|
1156
|
+
${t}`);return r}import Wr from"fs/promises";async function Ut(){let r=process.argv.slice(2);if(r.includes("--version")||r.includes("-v"))console.log(`v${qr.version}`),process.exit(0);if(r.includes("--help")||r.includes("-h"))console.log(`
|
|
1105
1157
|
Usage: aura [project-name]
|
|
1158
|
+
aura add [feature]
|
|
1106
1159
|
|
|
1107
1160
|
Options:
|
|
1108
1161
|
-v, --version Show version number
|
|
@@ -1111,7 +1164,8 @@ Options:
|
|
|
1111
1164
|
Examples:
|
|
1112
1165
|
npx @ahmadjavaiddev/aura my-new-app
|
|
1113
1166
|
aura .
|
|
1114
|
-
|
|
1167
|
+
aura add redis
|
|
1168
|
+
`),process.exit(0);if(r[0]==="add"){let n=r[1];if(!n)console.error("Please specify a feature. Example: aura add redis"),process.exit(1);if(!await Wr.access(se.join(process.cwd(),"src/base/index.ts")).then(()=>!0).catch(()=>!1))console.error("This does not appear to be an Aura project. Cannot add features here."),process.exit(1);let e={caching:"none",logger:"none",orm:"none",rateLimit:"none",auth:"none",email:"none",pagination:!1,formatter:"none",inngest:"none",docker:!1,ci:"none"},c="";if(n==="redis")c="caching",e.caching="redis";else if(n==="memory")c="caching",e.caching="memory";else if(n==="prisma")c="orm",e.orm="prisma";else if(n==="drizzle")c="orm",e.orm="drizzle";else if(n==="mongoose")c="orm",e.orm="mongoose";else if(n==="clerk")c="auth",e.auth="clerk";else if(n==="betterauth")c="auth",e.auth="betterauth";else if(n==="custom-auth")c="auth",e.auth="custom";else if(n==="otel")c="logger",e.logger="otel";else if(n==="console")c="logger",e.logger="console";else if(n==="resend")c="extra",e.email="resend";else if(n==="nodemailer")c="extra",e.email="nodemailer";else if(n==="pagination")c="extra",e.pagination=!0;else if(n==="inngest")c="extra",e.inngest="basic";else if(n==="docker")c="infrastructure",e.docker=!0;else if(n==="github-actions")c="infrastructure",e.ci="github";else console.error(`Unknown feature: ${n}`),process.exit(1);oe(`\uD83D\uDE80 Adding ${n} to Aura project...`),await jr(process.cwd(),c,e),ne(`✨ ${n} added successfully! Remember to run 'bun install'.`),process.exit(0)}oe("\uD83D\uDE80 Welcome to Aura!");let t=r[0];if(!t){let n=await Ge({message:"What is your project named?",placeholder:"my-api",validate:(a)=>{if(!a)return"Please enter a path.";return}});if(P(n))z("Operation cancelled."),process.exit(0);t=n}let o=await $e(),i=se.resolve(process.cwd(),t);await $r(i,t,o),ne(`✨ Project scaffolding complete!
|
|
1115
1169
|
|
|
1116
1170
|
Next steps:
|
|
1117
1171
|
cd ${t}
|
|
@@ -1120,4 +1174,4 @@ Next steps:
|
|
|
1120
1174
|
${o.orm!=="none"?`# Note: Make sure your ${o.orm} database is running`:""}
|
|
1121
1175
|
bun update
|
|
1122
1176
|
bun run dev
|
|
1123
|
-
`)}
|
|
1177
|
+
`)}Ut().catch(console.error);
|