@r5n/sisyphus 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -234
- package/dist/cli.js +167 -166
- package/package.json +2 -6
package/dist/cli.js
CHANGED
|
@@ -1,209 +1,210 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`),
|
|
5
|
-
`){if(
|
|
6
|
-
`){if(
|
|
7
|
-
`)}var
|
|
8
|
-
`),
|
|
9
|
-
`),
|
|
10
|
-
`),
|
|
11
|
-
`).map((a,
|
|
12
|
-
`)}function
|
|
13
|
-
`),
|
|
14
|
-
`).length-1;this.output.write(
|
|
15
|
-
`);this.output.write(o[
|
|
16
|
-
`).slice(
|
|
17
|
-
`)),this._prevFrame=e;return}}this.output.write(V.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}}function wi(e,t){if(e===void 0||t.length===0)return 0;let n=t.findIndex((r)=>r.value===e);return n!==-1?n:0}function vi(e,t){return(t.label??String(t.value)).toLowerCase().includes(e.toLowerCase())}function ki(e,t){if(t)return e?t:t[0]}var Ci=class extends ae{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#t=0;#i="";#e;#s;#a;get cursor(){return this.#t}get userInputWithCursor(){if(!this.userInput)return Qe(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let t=this.userInput.slice(0,this.cursor),n=this.userInput.slice(this.cursor,this.cursor+1),r=this.userInput.slice(this.cursor+1);return`${t}${Qe("inverse",n)}${r}`}get options(){return typeof this.#s=="function"?this.#s():this.#s}constructor(t){super(t),this.#s=t.options,this.#a=t.placeholder;let n=this.options;this.filteredOptions=[...n],this.multiple=t.multiple===!0,this.#e=typeof t.options=="function"?t.filter:t.filter??vi;let r;if(t.initialValue&&Array.isArray(t.initialValue)?this.multiple?r=t.initialValue:r=t.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(r=[this.options[0]?.value]),r)for(let i of r){let s=n.findIndex((o)=>o.value===i);s!==-1&&(this.toggleSelected(i),this.#t=s)}this.focusedValue=this.options[this.#t]?.value,this.on("key",(i,s)=>this.#n(i,s)),this.on("userInput",(i)=>this.#r(i))}_isActionKey(t,n){return t==="\t"||this.multiple&&this.isNavigating&&n.name==="space"&&t!==void 0&&t!==""}#n(t,n){let r=n.name==="up",i=n.name==="down",s=n.name==="return",o=this.userInput===""||this.userInput==="\t",a=this.#a,g=this.options,m=a!==void 0&&a!==""&&g.some((u)=>!u.disabled&&(this.#e?this.#e(a,u):!0));if(n.name==="tab"&&o&&m){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(a,!0),this.isNavigating=!1;return}r||i?(this.#t=oe(this.#t,r?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#t]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):s?this.value=ki(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(n.name==="tab"||this.isNavigating&&n.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(t){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(t)?this.selectedValues=this.selectedValues.filter((n)=>n!==t):this.selectedValues=[...this.selectedValues,t]:this.selectedValues=[t])}#r(t){if(t!==this.#i){this.#i=t;let n=this.options;t&&this.#e?this.filteredOptions=n.filter((s)=>this.#e?.(t,s)):this.filteredOptions=[...n];let r=wi(this.focusedValue,this.filteredOptions);this.#t=oe(r,0,this.filteredOptions);let i=this.filteredOptions[this.#t];i&&!i.disabled?this.focusedValue=i.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};class At extends ae{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(t)=>{this.output.write(V.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var $i={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};function xn(e){return[...e].map((t)=>$i[t])}function Ri(e){let t=new Intl.DateTimeFormat(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),n=[],r="/";for(let i of t)i.type==="literal"?r=i.value.trim()||i.value:(i.type==="year"||i.type==="month"||i.type==="day")&&n.push({type:i.type,len:i.type==="year"?4:2});return{segments:n,separator:r}}function Ft(e){return Number.parseInt((e||"0").replace(/_/g,"0"),10)||0}function Te(e){return{year:Ft(e.year),month:Ft(e.month),day:Ft(e.day)}}function jt(e,t){return new Date(e||2001,t||1,0).getDate()}function Vn(e){let{year:t,month:n,day:r}=Te(e);if(!t||t<0||t>9999||!n||n<1||n>12||!r||r<1)return;let i=new Date(Date.UTC(t,n-1,r));if(!(i.getUTCFullYear()!==t||i.getUTCMonth()!==n-1||i.getUTCDate()!==r))return{year:t,month:n,day:r}}function qn(e){let t=Vn(e);return t?new Date(Date.UTC(t.year,t.month-1,t.day)):void 0}function Si(e,t,n,r){let i=n?{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate()}:null,s=r?{year:r.getUTCFullYear(),month:r.getUTCMonth()+1,day:r.getUTCDate()}:null;return e==="year"?{min:i?.year??1,max:s?.year??9999}:e==="month"?{min:i&&t.year===i.year?i.month:1,max:s&&t.year===s.year?s.month:12}:{min:i&&t.year===i.year&&t.month===i.month?i.day:1,max:s&&t.year===s.year&&t.month===s.month?s.day:jt(t.year,t.month)}}class zn extends ae{#t;#i;#e;#s;#a;#n={segmentIndex:0,positionInSegment:0};#r=!0;#o=null;inlineError="";get segmentCursor(){return{...this.#n}}get segmentValues(){return{...this.#e}}get segments(){return this.#t}get separator(){return this.#i}get formattedValue(){return this.#p(this.#e)}#p(e){return this.#t.map((t)=>e[t.type]).join(this.#i)}#c(){this._setUserInput(this.#p(this.#e)),this._setValue(qn(this.#e)??void 0)}constructor(e){let t=e.format?{segments:xn(e.format),separator:e.separator??"/"}:Ri(e.locale),n=e.separator??t.separator,r=e.format?xn(e.format):t.segments,i=e.initialValue??e.defaultValue,s=i?{year:String(i.getUTCFullYear()).padStart(4,"0"),month:String(i.getUTCMonth()+1).padStart(2,"0"),day:String(i.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},o=r.map((a)=>s[a.type]).join(n);super({...e,initialUserInput:o},!1),this.#t=r,this.#i=n,this.#e=s,this.#s=e.minDate,this.#a=e.maxDate,this.#c(),this.on("cursor",(a)=>this.#h(a)),this.on("key",(a,g)=>this.#f(a,g)),this.on("finalize",()=>this.#d(e))}#g(){let e=Math.max(0,Math.min(this.#n.segmentIndex,this.#t.length-1)),t=this.#t[e];if(t)return this.#n.positionInSegment=Math.max(0,Math.min(this.#n.positionInSegment,t.len-1)),{segment:t,index:e}}#m(e){this.inlineError="",this.#o=null;let t=this.#g();t&&(this.#n.segmentIndex=Math.max(0,Math.min(this.#t.length-1,t.index+e)),this.#n.positionInSegment=0,this.#r=!0)}#l(e){let t=this.#g();if(!t)return;let{segment:n}=t,r=this.#e[n.type],i=!r||r.replace(/_/g,"")==="",s=Number.parseInt((r||"0").replace(/_/g,"0"),10)||0,o=Si(n.type,Te(this.#e),this.#s,this.#a),a;i?a=e===1?o.min:o.max:a=Math.max(Math.min(o.max,s+e),o.min),this.#e={...this.#e,[n.type]:a.toString().padStart(n.len,"0")},this.#r=!0,this.#o=null,this.#c()}#h(e){if(e)switch(e){case"right":return this.#m(1);case"left":return this.#m(-1);case"up":return this.#l(1);case"down":return this.#l(-1)}}#f(e,t){if(t?.name==="backspace"||t?.sequence==="\x7F"||t?.sequence==="\b"||e==="\x7F"||e==="\b"){this.inlineError="";let n=this.#g();if(!n)return;if(!this.#e[n.segment.type].replace(/_/g,"")){this.#m(-1);return}this.#e[n.segment.type]="_".repeat(n.segment.len),this.#r=!0,this.#n.positionInSegment=0,this.#c();return}if(t?.name==="tab"){this.inlineError="";let n=this.#g();if(!n)return;let r=t.shift?-1:1,i=n.index+r;i>=0&&i<this.#t.length&&(this.#n.segmentIndex=i,this.#n.positionInSegment=0,this.#r=!0);return}if(e&&/^[0-9]$/.test(e)){let n=this.#g();if(!n)return;let{segment:r}=n,i=!this.#e[r.type].replace(/_/g,"");if(this.#r&&this.#o!==null&&!i){let y=this.#o+e,b={...this.#e,[r.type]:y},h=this.#u(b,r);if(h){this.inlineError=h,this.#o=null,this.#r=!1;return}this.inlineError="",this.#e[r.type]=y,this.#o=null,this.#r=!1,this.#c(),n.index<this.#t.length-1&&(this.#n.segmentIndex=n.index+1,this.#n.positionInSegment=0,this.#r=!0);return}this.#r&&!i&&(this.#e[r.type]="_".repeat(r.len),this.#n.positionInSegment=0),this.#r=!1,this.#o=null;let s=this.#e[r.type],o=s.indexOf("_"),a=o>=0?o:Math.min(this.#n.positionInSegment,r.len-1);if(a<0||a>=r.len)return;let g=s.slice(0,a)+e+s.slice(a+1),m=!1;if(a===0&&s==="__"&&(r.type==="month"||r.type==="day")){let y=Number.parseInt(e,10);g=`0${e}`,m=y<=(r.type==="month"?1:2)}if(r.type==="year"&&(g=(s.replace(/_/g,"")+e).padStart(r.len,"_")),!g.includes("_")){let y={...this.#e,[r.type]:g},b=this.#u(y,r);if(b){this.inlineError=b;return}}this.inlineError="",this.#e[r.type]=g;let u=g.includes("_")?void 0:Vn(this.#e);if(u){let{year:y,month:b}=u,h=jt(y,b);this.#e={year:String(Math.max(0,Math.min(9999,y))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,b))).padStart(2,"0"),day:String(Math.max(1,Math.min(h,u.day))).padStart(2,"0")}}this.#c();let f=g.indexOf("_");m?(this.#r=!0,this.#o=e):f>=0?this.#n.positionInSegment=f:o>=0&&n.index<this.#t.length-1?(this.#n.segmentIndex=n.index+1,this.#n.positionInSegment=0,this.#r=!0):this.#n.positionInSegment=Math.min(a+1,r.len-1)}}#u(e,t){let{month:n,day:r}=Te(e);if(t.type==="month"&&(n<0||n>12))return W.date.messages.invalidMonth;if(t.type==="day"&&(r<0||r>31))return W.date.messages.invalidDay(31,"any month")}#d(e){let{year:t,month:n,day:r}=Te(this.#e);if(t&&n&&r){let i=jt(t,n);this.#e={...this.#e,day:String(Math.min(r,i)).padStart(2,"0")}}this.value=qn(this.#e)??e.defaultValue??void 0}}var Mi=class extends ae{options;cursor=0;#t;getGroupItems(t){return this.options.filter((n)=>n.group===t)}isGroupSelected(t){let n=this.getGroupItems(t),r=this.value;return r===void 0?!1:n.every((i)=>r.includes(i.value))}toggleValue(){let t=this.options[this.cursor];if(t!==void 0)if(this.value===void 0&&(this.value=[]),t.group===!0){let n=t.value,r=this.getGroupItems(n);this.isGroupSelected(n)?this.value=this.value.filter((i)=>r.findIndex((s)=>s.value===i)===-1):this.value=[...this.value,...r.map((i)=>i.value)],this.value=Array.from(new Set(this.value))}else{let n=this.value.includes(t.value);this.value=n?this.value.filter((r)=>r!==t.value):[...this.value,t.value]}}constructor(t){super(t,!1);let{options:n}=t;this.#t=t.selectableGroups!==!1,this.options=Object.entries(n).flatMap(([r,i])=>[{value:r,group:!0,label:r},...i.map((s)=>({...s,group:r}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:r})=>r===t.cursorAt),this.#t?0:1),this.on("cursor",(r)=>{switch(r){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let i=this.options[this.cursor]?.group===!0;!this.#t&&i&&(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;let i=this.options[this.cursor]?.group===!0;!this.#t&&i&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},Ii=new Set(["up","down","left","right"]);class Yn extends ae{#t=!1;#i;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${e}\u2588`;let t=e.slice(0,this.cursor),n=e.slice(this.cursor,this.cursor+1),r=e.slice(this.cursor+1);return n===`
|
|
3
|
+
var Qi=Object.create;var{getPrototypeOf:en,defineProperty:Ps,getOwnPropertyNames:tn}=Object;var sn=Object.prototype.hasOwnProperty;function nn(e){return this[e]}var rn,on,Cs=(e,t,s)=>{var i=e!=null&&typeof e==="object";if(i){var n=t?rn??=new WeakMap:on??=new WeakMap,r=n.get(e);if(r)return r}s=e!=null?Qi(en(e)):{};let o=t||!e||!e.__esModule?Ps(s,"default",{value:e,enumerable:!0}):s;if(e&&typeof e==="object"||typeof e==="function"){for(let a of tn(e))if(!sn.call(o,a))Ps(o,a,{get:nn.bind(e,a),enumerable:!0})}if(i)n.set(e,o);return o};var an=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var It=an(function(Vo,js){var xt={to(e,t){if(!t)return`\x1B[${e+1}G`;return`\x1B[${t+1};${e+1}H`},move(e,t){let s="";if(e<0)s+=`\x1B[${-e}D`;else if(e>0)s+=`\x1B[${e}C`;if(t<0)s+=`\x1B[${-t}A`;else if(t>0)s+=`\x1B[${t}B`;return s},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},vn={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Pn={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let s=0;s<e;s++)t+=this.line+(s<e-1?xt.up():"");if(e)t+=xt.left;return t}};js.exports={cursor:xt,scroll:vn,erase:Pn,beep:"\x07"}});class te extends Error{constructor(e="Operation cancelled"){super(e)}}class d extends Error{hint;constructor(e,t){super(e);this.hint=t}}import{styleText as Xe}from"util";import{stdout as At,stdin as Us}from"process";import*as me from"readline";import Cn from"readline";var Ss=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(t)=>{let s=0;e.lastIndex=0;while(e.test(t))s+=1;return t.length-s}})(),ks=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Rs=(e)=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var cn=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,ln=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,xs=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,un=/\t{1,1000}/y,Is=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,pn=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,mn=/\p{M}+/gu,gn={limit:1/0,ellipsis:""},Ts=(e,t={},s={})=>{let i=t.limit??1/0,n=t.ellipsis??"",r=t?.ellipsisWidth??(n?Ts(n,gn,s).width:0),o=0,a=s.controlWidth??0,l=s.tabWidth??8,u=s.emojiWidth??2,g=2,f=s.regularWidth??1,y=s.wideWidth??2,b=[[pn,f],[cn,0],[ln,a],[un,l],[Is,u],[xs,y]],h=0,$=0,_=e.length,F=0,P=!1,U=_,E=Math.max(0,i-r),C=0,L=0,O=0,A=0;e:while(!0){if(L>C||$>=_&&$>h){let N=e.slice(C,L)||e.slice(h,$);F=0;for(let se of N.replaceAll(mn,"")){let q=se.codePointAt(0)||0;if(ks(q))A=2;else if(Rs(q))A=y;else A=f;if(O+A>E)U=Math.min(U,Math.max(C,h)+F);if(O+A>i){P=!0;break e}F+=se.length,O+=A}C=L=0}if($>=_)break e;for(let N=0,se=b.length;N<se;N++){let[q,We]=b[N];if(q.lastIndex=$,q.test(e)){if(F=q===xs?Ss(e.slice($,q.lastIndex)):q===Is?1:q.lastIndex-$,A=F*We,O+A>E)U=Math.min(U,$+Math.floor((E-O)/We));if(O+A>i){P=!0;break e}O+=A,C=h,L=$,$=h=q.lastIndex;continue e}}$+=1}return{width:P?E:O,index:P?U:_,truncated:P,ellipsed:P&&i>=r}},Ms=Ts;var hn={limit:1/0,ellipsis:"",ellipsisWidth:0},dn=(e,t={})=>Ms(e,hn,t).width,J=dn;var Je="\x1B",Ds="\x9B",fn=39,kt="\x07",Bs="[",yn="]",Fs="m",Rt=`${yn}8;;`,_s=new RegExp(`(?:\\${Bs}(?<code>\\d+)m|\\${Rt}(?<uri>.*)${kt})`,"y"),As=(e)=>{if(e>=30&&e<=37)return 39;if(e>=90&&e<=97)return 39;if(e>=40&&e<=47)return 49;if(e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0;return},Es=(e)=>`${Je}${Bs}${e}${Fs}`,Os=(e)=>`${Je}${Rt}${e}${kt}`,St=(e,t,s)=>{let i=t[Symbol.iterator](),n=!1,r=!1,o=e.at(-1),a=o===void 0?0:J(o),l=i.next(),u=i.next(),g=0;while(!l.done){let f=l.value,y=J(f);if(a+y<=s)e[e.length-1]+=f;else e.push(f),a=0;if(f===Je||f===Ds)n=!0,r=t.startsWith(Rt,g+1);if(n){if(r){if(f===kt)n=!1,r=!1}else if(f===Fs)n=!1}else if(a+=y,a===s&&!u.done)e.push(""),a=0;l=u,u=i.next(),g+=f.length}if(o=e.at(-1),!a&&o!==void 0&&o.length&&e.length>1)e[e.length-2]+=e.pop()},bn=(e)=>{let t=e.split(" "),s=t.length;while(s){if(J(t[s-1]))break;s--}if(s===t.length)return e;return t.slice(0,s).join(" ")+t.slice(s).join("")},$n=(e,t,s={})=>{if(s.trim!==!1&&e.trim()==="")return"";let i="",n,r,o=e.split(" "),a=[""],l=0;for(let f=0;f<o.length;f++){let y=o[f];if(s.trim!==!1){let h=a.at(-1)??"",$=h.trimStart();if(h.length!==$.length)a[a.length-1]=$,l=J($)}if(f!==0){if(l>=t&&(s.wordWrap===!1||s.trim===!1))a.push(""),l=0;if(l||s.trim===!1)a[a.length-1]+=" ",l++}let b=J(y);if(s.hard&&b>t){let h=t-l,$=1+Math.floor((b-h-1)/t);if(Math.floor((b-1)/t)<$)a.push("");St(a,y,t),l=J(a.at(-1)??"");continue}if(l+b>t&&l&&b){if(s.wordWrap===!1&&l<t){St(a,y,t),l=J(a.at(-1)??"");continue}a.push(""),l=0}if(l+b>t&&s.wordWrap===!1){St(a,y,t),l=J(a.at(-1)??"");continue}a[a.length-1]+=y,l+=b}if(s.trim!==!1)a=a.map((f)=>bn(f));let u=a.join(`
|
|
4
|
+
`),g=!1;for(let f=0;f<u.length;f++){let y=u[f];if(i+=y,!g){if(g=y>="\uD800"&&y<="\uDBFF",g)continue}else g=!1;if(y===Je||y===Ds){_s.lastIndex=f+1;let h=_s.exec(u)?.groups;if(h?.code!==void 0){let $=Number.parseFloat(h.code);n=$===fn?void 0:$}else if(h?.uri!==void 0)r=h.uri.length===0?void 0:h.uri}if(u[f+1]===`
|
|
5
|
+
`){if(r)i+=Os("");let b=n?As(n):void 0;if(n&&b)i+=Es(b)}else if(y===`
|
|
6
|
+
`){if(n&&As(n))i+=Es(n);if(r)i+=Os(r)}}return i},wn=/\r?\n/;function ie(e,t,s){return String(e).normalize().split(wn).map((i)=>$n(i,t,s)).join(`
|
|
7
|
+
`)}var W=Cs(It(),1);import{ReadStream as Ns}from"tty";function oe(e,t,s){if(!s.some((o)=>!o.disabled))return e;let i=e+t,n=Math.max(s.length-1,0),r=i<0?n:i>n?0:i;return s[r]?.disabled?oe(r,t<0?-1:1,s):r}function Ke(e,t,s,i){let n=i.split(`
|
|
8
|
+
`),r=0,o=e;for(let l of n){if(o<=l.length)break;o-=l.length+1,r++}for(r=Math.max(0,Math.min(n.length-1,r+s)),o=Math.min(o,n[r].length)+t;o<0&&r>0;)r--,o+=n[r].length+1;for(;o>n[r].length&&r<n.length-1;)o-=n[r].length+1,r++;o=Math.max(0,Math.min(n[r].length,o));let a=0;for(let l=0;l<r;l++)a+=n[l].length+1;return a+o}var Sn=["up","down","left","right","space","enter","cancel"],kn=["January","February","March","April","May","June","July","August","September","October","November","December"],V={actions:new Set(Sn),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...kn],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:(e)=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:(e)=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function Et(e,t){if(typeof e=="string")return V.aliases.get(e)===t;for(let s of e)if(s!==void 0&&Et(s,t))return!0;return!1}function Rn(e,t){if(e===t)return;let s=e.split(`
|
|
9
|
+
`),i=t.split(`
|
|
10
|
+
`),n=Math.max(s.length,i.length),r=[];for(let o=0;o<n;o++)s[o]!==i[o]&&r.push(o);return{lines:r,numLinesBefore:s.length,numLinesAfter:i.length,numLines:n}}var xn=globalThis.process.platform.startsWith("win"),Mt=Symbol("clack:cancel");function De(e){return e===Mt}function ze(e,t){let s=e;s.isTTY&&s.setRawMode(t)}function Vs({input:e=Us,output:t=At,overwrite:s=!0,hideCursor:i=!0}={}){let n=me.createInterface({input:e,output:t,prompt:"",tabSize:1});me.emitKeypressEvents(e,n),e instanceof Ns&&e.isTTY&&e.setRawMode(!0);let r=(o,{name:a,sequence:l})=>{let u=String(o);if(Et([u,a,l],"cancel")){i&&t.write(W.cursor.show),process.exit(0);return}if(!s)return;me.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{me.clearLine(t,1,()=>{e.once("keypress",r)})})};return i&&t.write(W.cursor.hide),e.once("keypress",r),()=>{e.off("keypress",r),i&&t.write(W.cursor.show),e instanceof Ns&&e.isTTY&&!xn&&e.setRawMode(!1),n.terminal=!1,n.close()}}var Be=(e)=>("columns"in e)&&typeof e.columns=="number"?e.columns:80,Ot=(e)=>("rows"in e)&&typeof e.rows=="number"?e.rows:20;function ge(e,t,s,i=s,n=s,r){let o=Be(e??At);return ie(t,o-s.length,{hard:!0,trim:!1}).split(`
|
|
11
|
+
`).map((a,l,u)=>{let g=r?r(a,l):a;return l===0?`${i}${g}`:l===u.length-1?`${n}${g}`:`${s}${g}`}).join(`
|
|
12
|
+
`)}function Hs(e,t){if("~standard"in e){let s=e["~standard"].validate(t);if(s instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return s.issues?.at(0)?.message}return e(t)}class ae{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,t=!0){let{input:s=Us,output:i=At,render:n,signal:r,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=n.bind(this),this._track=t,this._abortSignal=r,this.input=s,this.output=i}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let s=this._subscribers.get(e)??[];s.push(t),this._subscribers.set(e,s)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let s=this._subscribers.get(e)??[],i=[];for(let n of s)n.cb(...t),n.once&&i.push(()=>s.splice(s.indexOf(n),1));for(let n of i)n()}prompt(){return new Promise((e)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(Mt);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=Cn.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),ze(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(W.cursor.show),this.output.off("resize",this.render),ze(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(W.cursor.show),this.output.off("resize",this.render),ze(this.input,!1),e(Mt)})})}_isActionKey(e,t){return e==="\t"}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,t){if(this._track&&t.name!=="return"&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),t?.name&&(!this._track&&V.aliases.has(t.name)&&this.emit("cursor",V.aliases.get(t.name)),V.actions.has(t.name)&&this.emit("cursor",t.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),this.emit("key",e,t),t?.name==="return"&&this._shouldSubmit(e,t)){if(this.opts.validate){let s=Hs(this.opts.validate,this.value);s&&(this.error=s instanceof Error?s.message:s,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}Et([e,t?.name,t?.sequence],"cancel")&&(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(`
|
|
13
|
+
`),ze(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=ie(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
14
|
+
`).length-1;this.output.write(W.cursor.move(-999,e*-1))}render(){let e=ie(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(W.cursor.hide);else{let t=Rn(this._prevFrame,e),s=Ot(this.output);if(this.restoreCursor(),t){let i=Math.max(0,t.numLinesAfter-s),n=Math.max(0,t.numLinesBefore-s),r=t.lines.find((o)=>o>=i);if(r===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(W.cursor.move(0,r-n)),this.output.write(W.erase.lines(1));let o=e.split(`
|
|
15
|
+
`);this.output.write(o[r]),this._prevFrame=e,this.output.write(W.cursor.move(0,o.length-r-1));return}else if(t.lines.length>1){if(i<n)r=i;else{let a=r-n;a>0&&this.output.write(W.cursor.move(0,a))}this.output.write(W.erase.down());let o=e.split(`
|
|
16
|
+
`).slice(r);this.output.write(o.join(`
|
|
17
|
+
`)),this._prevFrame=e;return}}this.output.write(W.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}}function In(e,t){if(e===void 0||t.length===0)return 0;let s=t.findIndex((i)=>i.value===e);return s!==-1?s:0}function Tn(e,t){return(t.label??String(t.value)).toLowerCase().includes(e.toLowerCase())}function Mn(e,t){if(t)return e?t:t[0]}var _n=class extends ae{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#t=0;#n="";#e;#r;#a;get cursor(){return this.#t}get userInputWithCursor(){if(!this.userInput)return Xe(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let t=this.userInput.slice(0,this.cursor),s=this.userInput.slice(this.cursor,this.cursor+1),i=this.userInput.slice(this.cursor+1);return`${t}${Xe("inverse",s)}${i}`}get options(){return typeof this.#r=="function"?this.#r():this.#r}constructor(t){super(t),this.#r=t.options,this.#a=t.placeholder;let s=this.options;this.filteredOptions=[...s],this.multiple=t.multiple===!0,this.#e=typeof t.options=="function"?t.filter:t.filter??Tn;let i;if(t.initialValue&&Array.isArray(t.initialValue)?this.multiple?i=t.initialValue:i=t.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(i=[this.options[0]?.value]),i)for(let n of i){let r=s.findIndex((o)=>o.value===n);r!==-1&&(this.toggleSelected(n),this.#t=r)}this.focusedValue=this.options[this.#t]?.value,this.on("key",(n,r)=>this.#s(n,r)),this.on("userInput",(n)=>this.#i(n))}_isActionKey(t,s){return t==="\t"||this.multiple&&this.isNavigating&&s.name==="space"&&t!==void 0&&t!==""}#s(t,s){let i=s.name==="up",n=s.name==="down",r=s.name==="return",o=this.userInput===""||this.userInput==="\t",a=this.#a,l=this.options,u=a!==void 0&&a!==""&&l.some((g)=>!g.disabled&&(this.#e?this.#e(a,g):!0));if(s.name==="tab"&&o&&u){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(a,!0),this.isNavigating=!1;return}i||n?(this.#t=oe(this.#t,i?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#t]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):r?this.value=Mn(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(s.name==="tab"||this.isNavigating&&s.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(t){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(t)?this.selectedValues=this.selectedValues.filter((s)=>s!==t):this.selectedValues=[...this.selectedValues,t]:this.selectedValues=[t])}#i(t){if(t!==this.#n){this.#n=t;let s=this.options;t&&this.#e?this.filteredOptions=s.filter((r)=>this.#e?.(t,r)):this.filteredOptions=[...s];let i=In(this.focusedValue,this.filteredOptions);this.#t=oe(i,0,this.filteredOptions);let n=this.filteredOptions[this.#t];n&&!n.disabled?this.focusedValue=n.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};class Dt extends ae{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(t)=>{this.output.write(W.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var An={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};function Ls(e){return[...e].map((t)=>An[t])}function En(e){let t=new Intl.DateTimeFormat(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),s=[],i="/";for(let n of t)n.type==="literal"?i=n.value.trim()||n.value:(n.type==="year"||n.type==="month"||n.type==="day")&&s.push({type:n.type,len:n.type==="year"?4:2});return{segments:s,separator:i}}function Tt(e){return Number.parseInt((e||"0").replace(/_/g,"0"),10)||0}function Ye(e){return{year:Tt(e.year),month:Tt(e.month),day:Tt(e.day)}}function _t(e,t){return new Date(e||2001,t||1,0).getDate()}function Ws(e){let{year:t,month:s,day:i}=Ye(e);if(!t||t<0||t>9999||!s||s<1||s>12||!i||i<1)return;let n=new Date(Date.UTC(t,s-1,i));if(!(n.getUTCFullYear()!==t||n.getUTCMonth()!==s-1||n.getUTCDate()!==i))return{year:t,month:s,day:i}}function Gs(e){let t=Ws(e);return t?new Date(Date.UTC(t.year,t.month-1,t.day)):void 0}function On(e,t,s,i){let n=s?{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate()}:null,r=i?{year:i.getUTCFullYear(),month:i.getUTCMonth()+1,day:i.getUTCDate()}:null;return e==="year"?{min:n?.year??1,max:r?.year??9999}:e==="month"?{min:n&&t.year===n.year?n.month:1,max:r&&t.year===r.year?r.month:12}:{min:n&&t.year===n.year&&t.month===n.month?n.day:1,max:r&&t.year===r.year&&t.month===r.month?r.day:_t(t.year,t.month)}}class qs extends ae{#t;#n;#e;#r;#a;#s={segmentIndex:0,positionInSegment:0};#i=!0;#o=null;inlineError="";get segmentCursor(){return{...this.#s}}get segmentValues(){return{...this.#e}}get segments(){return this.#t}get separator(){return this.#n}get formattedValue(){return this.#p(this.#e)}#p(e){return this.#t.map((t)=>e[t.type]).join(this.#n)}#c(){this._setUserInput(this.#p(this.#e)),this._setValue(Gs(this.#e)??void 0)}constructor(e){let t=e.format?{segments:Ls(e.format),separator:e.separator??"/"}:En(e.locale),s=e.separator??t.separator,i=e.format?Ls(e.format):t.segments,n=e.initialValue??e.defaultValue,r=n?{year:String(n.getUTCFullYear()).padStart(4,"0"),month:String(n.getUTCMonth()+1).padStart(2,"0"),day:String(n.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},o=i.map((a)=>r[a.type]).join(s);super({...e,initialUserInput:o},!1),this.#t=i,this.#n=s,this.#e=r,this.#r=e.minDate,this.#a=e.maxDate,this.#c(),this.on("cursor",(a)=>this.#h(a)),this.on("key",(a,l)=>this.#d(a,l)),this.on("finalize",()=>this.#f(e))}#l(){let e=Math.max(0,Math.min(this.#s.segmentIndex,this.#t.length-1)),t=this.#t[e];if(t)return this.#s.positionInSegment=Math.max(0,Math.min(this.#s.positionInSegment,t.len-1)),{segment:t,index:e}}#u(e){this.inlineError="",this.#o=null;let t=this.#l();t&&(this.#s.segmentIndex=Math.max(0,Math.min(this.#t.length-1,t.index+e)),this.#s.positionInSegment=0,this.#i=!0)}#m(e){let t=this.#l();if(!t)return;let{segment:s}=t,i=this.#e[s.type],n=!i||i.replace(/_/g,"")==="",r=Number.parseInt((i||"0").replace(/_/g,"0"),10)||0,o=On(s.type,Ye(this.#e),this.#r,this.#a),a;n?a=e===1?o.min:o.max:a=Math.max(Math.min(o.max,r+e),o.min),this.#e={...this.#e,[s.type]:a.toString().padStart(s.len,"0")},this.#i=!0,this.#o=null,this.#c()}#h(e){if(e)switch(e){case"right":return this.#u(1);case"left":return this.#u(-1);case"up":return this.#m(1);case"down":return this.#m(-1)}}#d(e,t){if(t?.name==="backspace"||t?.sequence==="\x7F"||t?.sequence==="\b"||e==="\x7F"||e==="\b"){this.inlineError="";let s=this.#l();if(!s)return;if(!this.#e[s.segment.type].replace(/_/g,"")){this.#u(-1);return}this.#e[s.segment.type]="_".repeat(s.segment.len),this.#i=!0,this.#s.positionInSegment=0,this.#c();return}if(t?.name==="tab"){this.inlineError="";let s=this.#l();if(!s)return;let i=t.shift?-1:1,n=s.index+i;n>=0&&n<this.#t.length&&(this.#s.segmentIndex=n,this.#s.positionInSegment=0,this.#i=!0);return}if(e&&/^[0-9]$/.test(e)){let s=this.#l();if(!s)return;let{segment:i}=s,n=!this.#e[i.type].replace(/_/g,"");if(this.#i&&this.#o!==null&&!n){let y=this.#o+e,b={...this.#e,[i.type]:y},h=this.#g(b,i);if(h){this.inlineError=h,this.#o=null,this.#i=!1;return}this.inlineError="",this.#e[i.type]=y,this.#o=null,this.#i=!1,this.#c(),s.index<this.#t.length-1&&(this.#s.segmentIndex=s.index+1,this.#s.positionInSegment=0,this.#i=!0);return}this.#i&&!n&&(this.#e[i.type]="_".repeat(i.len),this.#s.positionInSegment=0),this.#i=!1,this.#o=null;let r=this.#e[i.type],o=r.indexOf("_"),a=o>=0?o:Math.min(this.#s.positionInSegment,i.len-1);if(a<0||a>=i.len)return;let l=r.slice(0,a)+e+r.slice(a+1),u=!1;if(a===0&&r==="__"&&(i.type==="month"||i.type==="day")){let y=Number.parseInt(e,10);l=`0${e}`,u=y<=(i.type==="month"?1:2)}if(i.type==="year"&&(l=(r.replace(/_/g,"")+e).padStart(i.len,"_")),!l.includes("_")){let y={...this.#e,[i.type]:l},b=this.#g(y,i);if(b){this.inlineError=b;return}}this.inlineError="",this.#e[i.type]=l;let g=l.includes("_")?void 0:Ws(this.#e);if(g){let{year:y,month:b}=g,h=_t(y,b);this.#e={year:String(Math.max(0,Math.min(9999,y))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,b))).padStart(2,"0"),day:String(Math.max(1,Math.min(h,g.day))).padStart(2,"0")}}this.#c();let f=l.indexOf("_");u?(this.#i=!0,this.#o=e):f>=0?this.#s.positionInSegment=f:o>=0&&s.index<this.#t.length-1?(this.#s.segmentIndex=s.index+1,this.#s.positionInSegment=0,this.#i=!0):this.#s.positionInSegment=Math.min(a+1,i.len-1)}}#g(e,t){let{month:s,day:i}=Ye(e);if(t.type==="month"&&(s<0||s>12))return V.date.messages.invalidMonth;if(t.type==="day"&&(i<0||i>31))return V.date.messages.invalidDay(31,"any month")}#f(e){let{year:t,month:s,day:i}=Ye(this.#e);if(t&&s&&i){let n=_t(t,s);this.#e={...this.#e,day:String(Math.min(i,n)).padStart(2,"0")}}this.value=Gs(this.#e)??e.defaultValue??void 0}}var Dn=class extends ae{options;cursor=0;#t;getGroupItems(t){return this.options.filter((s)=>s.group===t)}isGroupSelected(t){let s=this.getGroupItems(t),i=this.value;return i===void 0?!1:s.every((n)=>i.includes(n.value))}toggleValue(){let t=this.options[this.cursor];if(t!==void 0)if(this.value===void 0&&(this.value=[]),t.group===!0){let s=t.value,i=this.getGroupItems(s);this.isGroupSelected(s)?this.value=this.value.filter((n)=>i.findIndex((r)=>r.value===n)===-1):this.value=[...this.value,...i.map((n)=>n.value)],this.value=Array.from(new Set(this.value))}else{let s=this.value.includes(t.value);this.value=s?this.value.filter((i)=>i!==t.value):[...this.value,t.value]}}constructor(t){super(t,!1);let{options:s}=t;this.#t=t.selectableGroups!==!1,this.options=Object.entries(s).flatMap(([i,n])=>[{value:i,group:!0,label:i},...n.map((r)=>({...r,group:i}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:i})=>i===t.cursorAt),this.#t?0:1),this.on("cursor",(i)=>{switch(i){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let n=this.options[this.cursor]?.group===!0;!this.#t&&n&&(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;let n=this.options[this.cursor]?.group===!0;!this.#t&&n&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},Bn=new Set(["up","down","left","right"]);class Js extends ae{#t=!1;#n;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${e}\u2588`;let t=e.slice(0,this.cursor),s=e.slice(this.cursor,this.cursor+1),i=e.slice(this.cursor+1);return s===`
|
|
18
18
|
`?`${t}\u2588
|
|
19
|
-
${
|
|
20
|
-
`),this._cursor++,!1);let
|
|
19
|
+
${i}`:`${t}${Xe("inverse",s)}${i}`}get cursor(){return this._cursor}#e(e){if(this.userInput.length===0){this._setUserInput(e);return}this._setUserInput(this.userInput.slice(0,this.cursor)+e+this.userInput.slice(this.cursor))}#r(e){let t=this.value??"";switch(e){case"up":this._cursor=Ke(this._cursor,0,-1,t);return;case"down":this._cursor=Ke(this._cursor,0,1,t);return;case"left":this._cursor=Ke(this._cursor,-1,0,t);return;case"right":this._cursor=Ke(this._cursor,1,0,t);return}}_shouldSubmit(e,t){if(this.#n)return this.focused==="submit"?!0:(this.#e(`
|
|
20
|
+
`),this._cursor++,!1);let s=this.#t;return this.#t=!0,s&&this.cursor===this.userInput.length?(this.userInput[this.cursor-1]===`
|
|
21
21
|
`&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#e(`
|
|
22
|
-
`),this._cursor++,!1)}constructor(e){let t=e.initialUserInput??e.initialValue;super({...e,initialUserInput:t},!1),t!==void 0&&(this._cursor=t.length),this.#
|
|
23
|
-
`);
|
|
22
|
+
`),this._cursor++,!1)}constructor(e){let t=e.initialUserInput??e.initialValue;super({...e,initialUserInput:t},!1),t!==void 0&&(this._cursor=t.length),this.#n=e.showSubmit??!1,this.on("key",(s,i)=>{if(i?.name&&Bn.has(i.name)){this.#t=!1,this.#r(i.name);return}if(s==="\t"&&this.#n){this.focused=this.focused==="editor"?"submit":"editor";return}if(i?.name!=="return"){if(this.#t=!1,i?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(i?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}s&&(this.#n&&this.focused==="submit"&&(this.focused="editor"),this.#e(s??""),this._cursor++)}}),this.on("userInput",(s)=>{this._setValue(s)}),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),this.value===void 0&&(this.value="")})}}class Bt extends ae{options;cursor=0;get _value(){return this.options[this.cursor]?.value}get _enabledOptions(){return this.options.filter((e)=>e.disabled!==!0)}toggleAll(){let e=this._enabledOptions,t=this.value!==void 0&&this.value.length===e.length;this.value=t?[]:e.map((s)=>s.value)}toggleInvert(){let e=this.value;if(!e)return;let t=this._enabledOptions.filter((s)=>!e.includes(s.value));this.value=t.map((s)=>s.value)}toggleValue(){this.value===void 0&&(this.value=[]);let e=this.value.includes(this._value);this.value=e?this.value.filter((t)=>t!==this._value):[...this.value,this._value]}constructor(e){super(e,!1),this.options=e.options,this.value=[...e.initialValues??[]];let t=Math.max(this.options.findIndex(({value:s})=>s===e.cursorAt),0);this.cursor=this.options[t]?.disabled?oe(t,1,this.options):t,this.on("key",(s,i)=>{i.name==="a"&&this.toggleAll(),i.name==="i"&&this.toggleInvert()}),this.on("cursor",(s)=>{switch(s){case"left":case"up":this.cursor=oe(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=oe(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}}var Ks=class extends ae{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let t=this._selectedValue;this.value=t===void 0?void 0:t.value}constructor(t){super(t,!1),this.options=t.options;let s=this.options.findIndex(({value:n})=>n===t.initialValue),i=s===-1?0:s;this.cursor=this.options[i]?.disabled?oe(i,1,this.options):i,this.changeValue(),this.on("cursor",(n)=>{switch(n){case"left":case"up":this.cursor=oe(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=oe(this.cursor,1,this.options);break}this.changeValue()})}};class Ft extends ae{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;let t=e.slice(0,this.cursor),s=e.slice(this.cursor,this.cursor+1),i=e.slice(this.cursor+1);return`${t}${Xe("inverse",s)}${i}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on("userInput",(t)=>{this._setValue(t)}),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),this.value===void 0&&(this.value="")})}}import{styleText as p,stripVTControlCharacters as ta}from"util";import X from"process";var je=Cs(It(),1);function Fn(){if(X.platform!=="win32")return X.env.TERM!=="linux";return Boolean(X.env.CI)||Boolean(X.env.WT_SESSION)||Boolean(X.env.TERMINUS_SUBLIME)||X.env.ConEmuTask==="{cmd::Cmder}"||X.env.TERM_PROGRAM==="Terminus-Sublime"||X.env.TERM_PROGRAM==="vscode"||X.env.TERM==="xterm-256color"||X.env.TERM==="alacritty"||X.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var jt=Fn(),jn=()=>process.env.CI==="true";var x=(e,t)=>jt?e:t,Nn=x("\u25C6","*"),Qs=x("\u25A0","x"),ei=x("\u25B2","x"),et=x("\u25C7","o"),Ln=x("\u250C","T"),v=x("\u2502","|"),he=x("\u2514","\u2014"),ra=x("\u2510","T"),oa=x("\u2518","\u2014"),Nt=x("\u25CF",">"),Qe=x("\u25CB"," "),Gn=x("\u25FB","[\u2022]"),zs=x("\u25FC","[+]"),Ys=x("\u25FB","[ ]"),aa=x("\u25AA","\u2022"),Xs=x("\u2500","-"),Un=x("\u256E","+"),Vn=x("\u251C","+"),Hn=x("\u256F","+"),Wn=x("\u2570","+"),ca=x("\u256D","+"),qn=x("\u25CF","\u2022"),Jn=x("\u25C6","*"),Kn=x("\u25B2","!"),zn=x("\u25A0","x"),tt=(e)=>{switch(e){case"initial":case"active":return p("cyan",Nn);case"cancel":return p("red",Qs);case"error":return p("yellow",ei);case"submit":return p("green",et)}},ti=(e)=>{switch(e){case"initial":case"active":return p("cyan",v);case"cancel":return p("red",v);case"error":return p("yellow",v);case"submit":return p("green",v)}};function si(e,t){let s=[`${t?`${p("cyan",v)} `:""}${e.join(" \u2022 ")}`];return t&&s.push(p("cyan",he)),s}var Zs=(e,t,s,i,n,r=!1)=>{let o=t,a=0;if(r)for(let l=i-1;l>=s;l--){let u=e[l];if(u&&(o-=u.length),a++,o<=n)break}else for(let l=s;l<i;l++){let u=e[l];if(u&&(o-=u.length),a++,o<=n)break}return{lineCount:o,removals:a}},Lt=({cursor:e,options:t,style:s,output:i=process.stdout,maxItems:n=Number.POSITIVE_INFINITY,columnPadding:r=0,rowPadding:o=4})=>{let a=Be(i)-r,l=Ot(i),u=p("dim","..."),g=Math.max(l-o,0),f=Math.max(Math.min(n,g),5),y=0;e>=f-3&&(y=Math.max(Math.min(e-f+3,t.length-f),0));let b=f<t.length&&y>0,h=f<t.length&&y+f<t.length,$=Math.min(y+f,t.length),_=[],F=0;b&&F++,h&&F++;let P=y+(b?1:0),U=$-(h?1:0);for(let C=P;C<U;C++){let L=t[C],O=L?s(L,C===e):"",A=ie(O,a,{hard:!0,trim:!1}).split(`
|
|
23
|
+
`);_.push(A),F+=A.length}if(F>g){let C=0,L=0,O=F,A=e-P,N=g,se=()=>Zs(_,O,0,A,N),q=()=>Zs(_,O,A+1,_.length,N,!0);b?({lineCount:O,removals:C}=se(),O>N&&(h||(N-=1),{lineCount:O,removals:L}=q())):(h||(N-=1),{lineCount:O,removals:L}=q(),O>N&&(N-=1,{lineCount:O,removals:C}=se())),C>0&&(b=!0,_.splice(0,C)),L>0&&(h=!0,_.splice(_.length-L,L))}let E=[];b&&E.push(u);for(let C of _)for(let L of C)E.push(L);return h&&E.push(u),E};var ii=(e)=>{let t=e.active??"Yes",s=e.inactive??"No";return new Dt({active:t,inactive:s,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=e.withGuide??V.withGuide,n=`${tt(this.state)} `,r=i?`${p("gray",v)} `:"",o=ge(e.output,e.message,r,n),a=`${i?`${p("gray",v)}
|
|
24
24
|
`:""}${o}
|
|
25
|
-
`,
|
|
26
|
-
${p("gray",v)}`:""}`}default:{let
|
|
25
|
+
`,l=this.value?t:s;switch(this.state){case"submit":{let u=i?`${p("gray",v)} `:"";return`${a}${u}${p("dim",l)}`}case"cancel":{let u=i?`${p("gray",v)} `:"";return`${a}${u}${p(["strikethrough","dim"],l)}${i?`
|
|
26
|
+
${p("gray",v)}`:""}`}default:{let u=i?`${p("cyan",v)} `:"",g=i?p("cyan",he):"";return`${a}${u}${this.value?`${p("green",Nt)} ${t}`:`${p("dim",Qe)} ${p("dim",t)}`}${e.vertical?i?`
|
|
27
27
|
${p("cyan",v)} `:`
|
|
28
|
-
`:` ${p("dim","/")} `}${this.value?`${p("dim",
|
|
29
|
-
${
|
|
30
|
-
`}}}}).prompt()};var
|
|
31
|
-
`).map((
|
|
32
|
-
`),
|
|
33
|
-
${p("reset",p("dim",`Press ${p(["gray","bgWhite","inverse"]," space ")} to select, ${p("gray",p("bgWhite",p("inverse"," enter ")))} to submit`))}`},render(){let
|
|
34
|
-
`:""}${
|
|
35
|
-
`,a=this.value??[],
|
|
36
|
-
${p("gray",v)}`:""}`}case"error":{let
|
|
37
|
-
`).map((b,h)=>h===0?`${
|
|
28
|
+
`:` ${p("dim","/")} `}${this.value?`${p("dim",Qe)} ${p("dim",s)}`:`${p("green",Nt)} ${s}`}
|
|
29
|
+
${g}
|
|
30
|
+
`}}}}).prompt()};var st=async(e,t)=>{let s={},i=Object.keys(e);for(let n of i){let r=e[n],o=await r({results:s})?.catch((a)=>{throw a});if(typeof t?.onCancel=="function"&&De(o)){s[n]="canceled",t.onCancel({results:s});continue}s[n]=o}return s},Yn=[`${p("dim","\u2191/\u2193")} to navigate`,`${p("dim","Space:")} select`,`${p("dim","Enter:")} confirm`],Fe=(e,t)=>e.split(`
|
|
31
|
+
`).map((s)=>t(s)).join(`
|
|
32
|
+
`),ni=(e)=>{let t=(n,r)=>{let o=n.label??String(n.value);return r==="disabled"?`${p("gray",Ys)} ${Fe(o,(a)=>p(["strikethrough","gray"],a))}${n.hint?` ${p("dim",`(${n.hint??"disabled"})`)}`:""}`:r==="active"?`${p("cyan",Gn)} ${o}${n.hint?` ${p("dim",`(${n.hint})`)}`:""}`:r==="selected"?`${p("green",zs)} ${Fe(o,(a)=>p("dim",a))}${n.hint?` ${p("dim",`(${n.hint})`)}`:""}`:r==="cancelled"?`${Fe(o,(a)=>p(["strikethrough","dim"],a))}`:r==="active-selected"?`${p("green",zs)} ${o}${n.hint?` ${p("dim",`(${n.hint})`)}`:""}`:r==="submitted"?`${Fe(o,(a)=>p("dim",a))}`:`${p("dim",Ys)} ${Fe(o,(a)=>p("dim",a))}`},s=e.required??!0,i=e.showInstructions??!0;return new Bt({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:s,cursorAt:e.cursorAt,validate(n){if(s&&(n===void 0||n.length===0))return`Please select at least one option.
|
|
33
|
+
${p("reset",p("dim",`Press ${p(["gray","bgWhite","inverse"]," space ")} to select, ${p("gray",p("bgWhite",p("inverse"," enter ")))} to submit`))}`},render(){let n=e.withGuide??V.withGuide,r=ge(e.output,e.message,n?`${ti(this.state)} `:"",`${tt(this.state)} `),o=`${n?`${p("gray",v)}
|
|
34
|
+
`:""}${r}
|
|
35
|
+
`,a=this.value??[],l=(u,g)=>{if(u.disabled)return t(u,"disabled");let f=a.includes(u.value);return g&&f?t(u,"active-selected"):f?t(u,"selected"):t(u,g?"active":"inactive")};switch(this.state){case"submit":{let u=this.options.filter(({value:f})=>a.includes(f)).map((f)=>t(f,"submitted")).join(p("dim",", "))||p("dim","none"),g=ge(e.output,u,n?`${p("gray",v)} `:"");return`${o}${g}`}case"cancel":{let u=this.options.filter(({value:f})=>a.includes(f)).map((f)=>t(f,"cancelled")).join(p("dim",", "));if(u.trim()==="")return`${o}${p("gray",v)}`;let g=ge(e.output,u,n?`${p("gray",v)} `:"");return`${o}${g}${n?`
|
|
36
|
+
${p("gray",v)}`:""}`}case"error":{let u=n?`${p("yellow",v)} `:"",g=this.error.split(`
|
|
37
|
+
`).map((b,h)=>h===0?`${n?`${p("yellow",he)} `:""}${p("yellow",b)}`:` ${b}`).join(`
|
|
38
38
|
`),f=o.split(`
|
|
39
|
-
`).length,y=
|
|
40
|
-
`).length+1;return`${o}${
|
|
41
|
-
${
|
|
42
|
-
${
|
|
43
|
-
`}default:{let
|
|
44
|
-
`).length,f=
|
|
45
|
-
`),b=f.length+1;return`${o}${
|
|
46
|
-
${
|
|
39
|
+
`).length,y=g.split(`
|
|
40
|
+
`).length+1;return`${o}${u}${Lt({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:u.length,rowPadding:f+y,style:l}).join(`
|
|
41
|
+
${u}`)}
|
|
42
|
+
${g}
|
|
43
|
+
`}default:{let u=n?`${p("cyan",v)} `:"",g=o.split(`
|
|
44
|
+
`).length,f=i?si(Yn,n):n?[p("cyan",he)]:[],y=f.join(`
|
|
45
|
+
`),b=f.length+1;return`${o}${u}${Lt({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:u.length,rowPadding:g+b,style:l}).join(`
|
|
46
|
+
${u}`)}
|
|
47
47
|
${y}
|
|
48
|
-
`}}}}).prompt()};var
|
|
49
|
-
`);if(f.length>0){let[y,...b]=f;y.length>0?o.push(`${
|
|
48
|
+
`}}}}).prompt()};var m={message:(e=[],{symbol:t=p("gray",v),secondarySymbol:s=p("gray",v),output:i=process.stdout,spacing:n=1,withGuide:r}={})=>{let o=[],a=r??V.withGuide,l=a?s:"",u=a?`${t} `:"",g=a?`${s} `:"";for(let y=0;y<n;y++)o.push(l);let f=Array.isArray(e)?e:e.split(`
|
|
49
|
+
`);if(f.length>0){let[y,...b]=f;y.length>0?o.push(`${u}${y}`):o.push(a?t:"");for(let h of b)h.length>0?o.push(`${g}${h}`):o.push(a?s:"")}i.write(`${o.join(`
|
|
50
50
|
`)}
|
|
51
|
-
`)},info:(e,t)=>{
|
|
52
|
-
`)},
|
|
53
|
-
${p("gray",he)} `:"";
|
|
54
|
-
|
|
55
|
-
`)};var
|
|
56
|
-
`),
|
|
57
|
-
`).map(
|
|
58
|
-
`),
|
|
59
|
-
`:"",f=
|
|
60
|
-
${
|
|
61
|
-
${p("gray",f+
|
|
62
|
-
`)};var
|
|
63
|
-
`);let
|
|
64
|
-
`);
|
|
65
|
-
`);let
|
|
66
|
-
`):
|
|
67
|
-
`)),O(),
|
|
51
|
+
`)},info:(e,t)=>{m.message(e,{...t,symbol:p("blue",qn)})},success:(e,t)=>{m.message(e,{...t,symbol:p("green",Jn)})},step:(e,t)=>{m.message(e,{...t,symbol:p("green",et)})},warn:(e,t)=>{m.message(e,{...t,symbol:p("yellow",Kn)})},warning:(e,t)=>{m.warn(e,t)},error:(e,t)=>{m.message(e,{...t,symbol:p("red",zn)})}};var it=(e="",t)=>{let s=t?.output??process.stdout,i=t?.withGuide??V.withGuide?`${p("gray",Ln)} `:"";s.write(`${i}${e}
|
|
52
|
+
`)},nt=(e="",t)=>{let s=t?.output??process.stdout,i=t?.withGuide??V.withGuide?`${p("gray",v)}
|
|
53
|
+
${p("gray",he)} `:"";s.write(`${i}${e}
|
|
54
|
+
|
|
55
|
+
`)};var Xn=(e)=>e,Zn=(e,t,s)=>{let i={hard:!0,trim:!1},n=ie(e,t,i).split(`
|
|
56
|
+
`),r=n.reduce((l,u)=>Math.max(J(u),l),0),o=n.map(s).reduce((l,u)=>Math.max(J(u),l),0),a=t-(o-r);return ie(e,a,i)},B=(e="",t="",s)=>{let i=s?.output??X.stdout,n=s?.withGuide??V.withGuide,r=s?.format??Xn,o=["",...Zn(e,Be(i)-6,r).split(`
|
|
57
|
+
`).map(r),""],a=J(t),l=Math.max(o.reduce((y,b)=>{let h=J(b);return h>y?h:y},0),a)+2,u=o.map((y)=>`${p("gray",v)} ${y}${" ".repeat(l-J(y))}${p("gray",v)}`).join(`
|
|
58
|
+
`),g=n?`${p("gray",v)}
|
|
59
|
+
`:"",f=n?Vn:Wn;i.write(`${g}${p("green",et)} ${p("reset",t)} ${p("gray",Xs.repeat(Math.max(l-a-1,1))+Un)}
|
|
60
|
+
${u}
|
|
61
|
+
${p("gray",f+Xs.repeat(l+2)+Hn)}
|
|
62
|
+
`)};var Qn=(e)=>p("magenta",e),K=({indicator:e="dots",onCancel:t,output:s=process.stdout,cancelMessage:i,errorMessage:n,frames:r=jt?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],delay:o=jt?80:120,signal:a,...l}={})=>{let u=jn(),g,f,y=!1,b=!1,h="",$,_=performance.now(),F=Be(s),P=l?.styleFrame??Qn,U=(j)=>{let Y=j>1?n??V.messages.error:i??V.messages.cancel;b=j===1,y&&(Oe(Y,j),b&&typeof t=="function"&&t())},E=()=>U(2),C=()=>U(1),L=()=>{process.on("uncaughtExceptionMonitor",E),process.on("unhandledRejection",E),process.on("SIGINT",C),process.on("SIGTERM",C),process.on("exit",U),a&&a.addEventListener("abort",C)},O=()=>{process.removeListener("uncaughtExceptionMonitor",E),process.removeListener("unhandledRejection",E),process.removeListener("SIGINT",C),process.removeListener("SIGTERM",C),process.removeListener("exit",U),a&&a.removeEventListener("abort",C)},A=()=>{if($===void 0)return;u&&s.write(`
|
|
63
|
+
`);let j=ie($,F,{hard:!0,trim:!1}).split(`
|
|
64
|
+
`);j.length>1&&s.write(je.cursor.up(j.length-1)),s.write(je.cursor.to(0)),s.write(je.erase.down())},N=(j)=>j.replace(/\.+$/,""),se=(j)=>{let Y=(performance.now()-j)/1000,ne=Math.floor(Y/60),re=Math.floor(Y%60);return ne>0?`[${ne}m ${re}s]`:`[${re}s]`},q=l.withGuide??V.withGuide,We=(j="")=>{y=!0,g=Vs({output:s}),h=N(j),_=performance.now(),q&&s.write(`${p("gray",v)}
|
|
65
|
+
`);let Y=0,ne=0;L(),f=setInterval(()=>{if(u&&h===$)return;A(),$=h;let re=P(r[Y]),qe;if(u)qe=`${re} ${h}...`;else if(e==="timer")qe=`${re} ${h} ${se(_)}`;else{let Zi=".".repeat(Math.floor(ne)).slice(0,3);qe=`${re} ${h}${Zi}`}let Xi=ie(qe,F,{hard:!0,trim:!1});s.write(Xi),Y=Y+1<r.length?Y+1:0,ne=ne<4?ne+0.125:0},o)},Oe=(j="",Y=0,ne=!1)=>{if(!y)return;y=!1,clearInterval(f),A();let re=Y===0?p("green",et):Y===1?p("red",Qs):p("red",ei);h=j??h,ne||(e==="timer"?s.write(`${re} ${h} ${se(_)}
|
|
66
|
+
`):s.write(`${re} ${h}
|
|
67
|
+
`)),O(),g()};return{start:We,stop:(j="")=>Oe(j,0),message:(j="")=>{h=N(j??h)},cancel:(j="")=>Oe(j,1),error:(j="")=>Oe(j,2),clear:()=>Oe("",0,!0),get isCancelled(){return b}}},la={light:x("\u2500","-"),heavy:x("\u2501","="),block:x("\u2588","#")};var er=[`${p("dim","\u2191/\u2193")} to navigate`,`${p("dim","Enter:")} confirm`],Ze=(e,t)=>e.includes(`
|
|
68
68
|
`)?e.split(`
|
|
69
|
-
`).map((
|
|
70
|
-
`):t(e),
|
|
69
|
+
`).map((s)=>t(s)).join(`
|
|
70
|
+
`):t(e),ri=(e)=>{let t=(i,n)=>{if(i===void 0)return"";let r=i.label??String(i.value);switch(n){case"disabled":return`${p("gray",Qe)} ${Ze(r,(o)=>p("gray",o))}${i.hint?` ${p("dim",`(${i.hint??"disabled"})`)}`:""}`;case"selected":return`${Ze(r,(o)=>p("dim",o))}`;case"active":return`${p("green",Nt)} ${r}${i.hint?` ${p("dim",`(${i.hint})`)}`:""}`;case"cancelled":return`${Ze(r,(o)=>p(["strikethrough","dim"],o))}`;default:return`${p("dim",Qe)} ${Ze(r,(o)=>p("dim",o))}`}},s=e.showInstructions??!0;return new Ks({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let i=e.withGuide??V.withGuide,n=`${tt(this.state)} `,r=`${ti(this.state)} `,o=ge(e.output,e.message,r,n),a=`${i?`${p("gray",v)}
|
|
71
71
|
`:""}${o}
|
|
72
|
-
`;switch(this.state){case"submit":{let
|
|
73
|
-
${p("gray",v)}`:""}`}default:{let
|
|
74
|
-
`).length,
|
|
75
|
-
`),y=
|
|
76
|
-
${
|
|
72
|
+
`;switch(this.state){case"submit":{let l=i?`${p("gray",v)} `:"",u=ge(e.output,t(this.options[this.cursor],"selected"),l);return`${a}${u}`}case"cancel":{let l=i?`${p("gray",v)} `:"",u=ge(e.output,t(this.options[this.cursor],"cancelled"),l);return`${a}${u}${i?`
|
|
73
|
+
${p("gray",v)}`:""}`}default:{let l=i?`${p("cyan",v)} `:"",u=a.split(`
|
|
74
|
+
`).length,g=s?si(er,i):i?[p("cyan",he)]:[],f=g.join(`
|
|
75
|
+
`),y=g.length+1;return`${a}${l}${Lt({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:l.length,rowPadding:u+y,style:(b,h)=>t(b,b.disabled?"disabled":h?"active":"inactive")}).join(`
|
|
76
|
+
${l}`)}
|
|
77
77
|
${f}
|
|
78
|
-
`}}}}).prompt()};var
|
|
78
|
+
`}}}}).prompt()};var ua=`${p("gray",v)} `;var oi=(e)=>new Ft({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??V.withGuide,s=`${`${t?`${p("gray",v)}
|
|
79
79
|
`:""}${tt(this.state)} `}${e.message}
|
|
80
|
-
`,
|
|
81
|
-
${a}${
|
|
82
|
-
${
|
|
83
|
-
`}case"submit":{let o=
|
|
84
|
-
${a}`:""}`}default:{let o=t?`${p("cyan",v)} `:"",a=t?p("cyan",he):"";return`${
|
|
80
|
+
`,i=e.placeholder&&e.placeholder.length>0?p("inverse",e.placeholder[0])+p("dim",e.placeholder.slice(1)):p(["inverse","hidden"],"_"),n=this.userInput?this.userInputWithCursor:i,r=this.value??"";switch(this.state){case"error":{let o=this.error?` ${p("yellow",this.error)}`:"",a=t?`${p("yellow",v)} `:"",l=t?p("yellow",he):"";return`${s.trim()}
|
|
81
|
+
${a}${n}
|
|
82
|
+
${l}${o}
|
|
83
|
+
`}case"submit":{let o=r?` ${p("dim",r)}`:"",a=t?p("gray",v):"";return`${s}${a}${o}`}case"cancel":{let o=r?` ${p(["strikethrough","dim"],r)}`:"",a=t?p("gray",v):"";return`${s}${a}${o}${r.trim()?`
|
|
84
|
+
${a}`:""}`}default:{let o=t?`${p("cyan",v)} `:"",a=t?p("cyan",he):"";return`${s}${o}${n}
|
|
85
85
|
${a}
|
|
86
|
-
`}}}}).prompt();var
|
|
87
|
-
`)}command(e,t){let
|
|
88
|
-
`)}formatPositionalUsage(e){return Object.entries(e).map(([t,
|
|
89
|
-
Run "${
|
|
90
|
-
Run "${this.commandPath} --help" for usage.`),process.exit(1);let o=this.command.prompts&&r.length===0,a=this.buildContext(i,n,o);await this.command.execute(a)}async routeInteractive(){if(!this.command.hasSubcommands()){await this.executeInteractive();return}await this.runSubcommandMenu()}async executeInteractive(){let{args:e}=Wt([],this.command.args),t=Jt([],this.command.positionals),n=this.buildContext(t,e,!0);await this.command.execute?.(n)}async runSubcommandMenu(){while(!0){let e=await this.promptSubcommandSelectionOrBack();if(e===null)return;if(e===Vt){this.options.onExit?.();return}let t=this.command.getSubcommand(e);if(t)await this.executeSubcommand(t)}}async promptSubcommandSelectionOrBack(){try{return await this.promptSubcommandSelection()}catch(e){if(e instanceof te){if(this.options.isRoot)this.options.onExit?.();return null}throw e}}async executeSubcommand(e){try{await new Re(e,this.env,this.commandPath).route([],!0)}catch(t){if(t instanceof te)return;if(t instanceof d){if(l.warn(c.yellow(t.message)),t.hint)l.info(c.dim(t.hint));return}throw t}}promptSubcommandSelection(){let{isRoot:e}=this.options,t=e?{hint:this.env.cli.exitHint,label:this.env.cli.exitLabel??"Exit",value:Vt}:{hint:"Return to previous menu",label:"Back",value:Vt};return ye({message:e?this.env.cli.promptMessage??"Select:":`${this.command.name}:`,options:[...this.command.getSubcommands().map((n)=>({hint:n.description,label:n.name,value:n.name})),t]})}buildContext(e,t,n){return{...this.env,args:t,interactive:n,positionals:e}}isHelpRequest(e){return e.includes("--help")||e.includes("-h")}printHelp(e){let t=e===this.command?this.prefix:this.commandPath;console.log(this.env.formatHelp(e,t))}}var gs={clearOnStart:!0,exitHint:"Close the CLI",exitLabel:"Exit",goodbyeMessage:"Goodbye!",name:"CLI",promptMessage:"What would you like to do?"};class zt{commands=new Map;metadata;configManager;help;bin;globalArgs={help:{alias:"h",description:"Show help",type:"boolean"},interactive:{alias:"i",description:"Enable interactive mode",type:"boolean"},version:{alias:"v",description:"Show version",type:"boolean"}};constructor(e,t){this.configManager=e,this.metadata={...gs,...t},this.bin=this.metadata.bin??this.metadata.name,this.init(),this.help=new qt({bin:this.bin,description:this.metadata.description,name:this.metadata.name,version:this.metadata.version},this.commands,this.globalArgs)}registerCommands(e){for(let t of e)t.init?.(),this.commands.set(t.name,t)}async run(e=process.argv.slice(2)){let{command:t,flags:n,restArgs:r}=hr(e,this.globalArgs);if(n.version&&!t)return console.log(this.help.version());if(n.interactive&&!t)return this.runInteractive();if(!t)return console.log(this.help.global());if(t==="help")return this.printHelpFor(r[0]);await this.runDirect(t,r,!!n.help)}printHelpFor(e){if(!e)return console.log(this.help.global());let t=this.commands.get(e);if(!t)return this.handleUnknownCommand(e);console.log(this.help.command(t))}async runInteractive(){this.showIntro();let e=this.createVirtualRootCommand(),t={cli:this.metadata,config:this.configManager,formatHelp:this.help.command.bind(this.help)},n=new Re(e,t,this.bin,{isRoot:!0,onExit:()=>this.exit()});try{await n.route([],!0)}catch(r){this.handleError(r)}}createVirtualRootCommand(){return{description:this.metadata.description,getSubcommand:(e)=>this.commands.get(e),getSubcommands:()=>Array.from(this.commands.values()),hasSubcommands:()=>!0,name:this.metadata.name}}exit(){it(this.metadata.goodbyeMessage),process.exit(0)}async runDirect(e,t,n){let r=this.commands.get(e);if(!r)return this.handleUnknownCommand(e);let i=t.length>0&&!t[0]?.startsWith("-");if(n&&!i)return console.log(this.help.command(r));try{let s={cli:this.metadata,config:this.configManager,formatHelp:this.help.command.bind(this.help)};await new Re(r,s,this.bin).route(t,!1)}catch(s){this.handleError(s)}}showIntro(){if(this.metadata.clearOnStart)console.clear();let e=this.metadata.version?` v${this.metadata.version}`:"";rt(`${c.bgCyan(c.black(` ${this.metadata.name}${e} `))}`)}handleUnknownCommand(e){let t=Array.from(this.commands.keys());gt("command",e,t,this.bin)}handleError(e){if(this.metadata.onError?.(e))return;if(e instanceof te)process.exit(0);if(e instanceof d){if(l.warn(c.yellow(e.message)),e.hint)l.info(c.dim(e.hint));process.exit(0)}if(e instanceof Error)l.error(c.red(e.message)),process.exit(1);console.error(c.red("Error:"),e),process.exit(1)}}class Ge{args={};positionals={};prompts=!1;subcommands=new Map;registerSubcommands(e){for(let t of e)t.init?.(),this.subcommands.set(t.name,t)}hasSubcommands(){return this.subcommands.size>0}getSubcommand(e){return this.subcommands.get(e)}getSubcommands(){return Array.from(this.subcommands.values())}}function D(e){return e}function _(e){return e}import Se from"fs";import dr from"path";class Yt{config;configPath;defaultConfig;constructor(e,t){this.configPath=dr.resolve(e),this.defaultConfig=t,this.config=this.loadConfig()}get(e){return this.config[e]}set(e,t){this.config[e]=t,this.save()}delete(e){delete this.config[e],this.save()}exists(){return Se.existsSync(this.configPath)}getAll(){return be({},this.config)}save(e){if(e)this.config={...e};this.ensureDirectoryExists();try{Se.writeFileSync(this.configPath,JSON.stringify(this.config,null,2))}catch(t){console.error(`Failed to save config to ${this.configPath}:`,t)}}ensureDirectoryExists(){let e=dr.dirname(this.configPath);if(!Se.existsSync(e))try{Se.mkdirSync(e,{recursive:!0})}catch(t){console.error(`Failed to create config directory at ${e}:`,t)}}loadConfig(){if(!Se.existsSync(this.configPath))return{...this.defaultConfig};try{let e=Se.readFileSync(this.configPath,"utf-8"),t=JSON.parse(e);return be({...this.defaultConfig},t)}catch{return console.warn(`Config file corrupted at ${this.configPath}. Using defaults.`),{...this.defaultConfig}}}}var yr="0.5.1";class I extends Ge{}import{existsSync as Cs}from"fs";import{mkdir as $s,writeFile as Rs}from"fs/promises";import{dirname as Ss}from"path";class fe{owner;repo;constructor(e){this.owner=e.owner,this.repo=e.repo}}class pt extends fe{name="bitbucket";notImplemented(){throw new d("Bitbucket is not supported yet","Bitbucket support is coming soon")}async ensureAvailable(){this.notImplemented()}async getDefaultBranch(){this.notImplemented()}async findPr(e){this.notImplemented()}async createPr(e){this.notImplemented()}async updatePr(e,t){this.notImplemented()}async getPr(e){this.notImplemented()}async getPrFromCurrentBranch(){this.notImplemented()}async getPrCommits(e){this.notImplemented()}async getPrFiles(e){this.notImplemented()}async ensureLabelExists(e,t){this.notImplemented()}async createRelease(e){this.notImplemented()}async deleteRelease(e){this.notImplemented()}}var A="sis",Kt="\uD83E\uDEA8",de="other",Me={build:23,chore:25,ci:24,docs:20,feat:10,"feat!":0,fix:11,"fix!":1,perf:12,refactor:13,style:21,test:22,["other"]:100},Ie=50,lt=".sisyphus",br="stones",Pr="released",ut=7,wr="unknown",xe="unknown",vr="0.0.0",kr="latest",me="main",Cr=4,$r=8,Rr="config.json";var Fe={$schema:"https://raw.githubusercontent.com/r5n-labs/clis/refs/heads/develop/packages/sisyphus/schema.json",changelog:{append:!0,filename:"CHANGELOG.md",generate:!0,packageHeader:"{emoji} {version} ({date})",root:!1,rootHeader:"{date} - {packages}",sections:{breaking:"Breaking changes",build:"Build",chore:"Chores",ci:"CI",dependencies:"Dependency updates",docs:"Documentation",feat:"Features",fix:"Bug fixes",other:"Other changes",perf:"Performance",refactor:"Refactoring",style:"Styling",test:"Tests"}},commit:{author:"r5n-bot",message:"chore(release): {message}"},commits:{skip:{authors:["r5n-bot[bot]"],messagePatterns:["^chore\\(release\\):","^chore: add stone"]}},ignore:[],lastStone:{commit:"",date:""},plugins:[],pr:{labelMapping:{breaking:"major","breaking-change":"major",bug:"patch",chore:"patch",docs:"patch",enhancement:"minor",feature:"minor",fix:"patch"},skip:{authors:["r5n-bot[bot]"],labels:["sisyphus-release","skip-stone"],titlePatterns:["^chore\\(release\\):"]}},release:{createRelease:!1,npm:!1,push:!1,tags:!1},scripts:{post:{},pre:{}},single:!1,sisyphusDir:".sisyphus",stones:[],tag:"latest"};class ht extends fe{name="github";get apiPath(){return`repos/${encodeURIComponent(this.owner)}/${encodeURIComponent(this.repo)}`}async ensureAvailable(){try{await Bun.$`which gh`.quiet()}catch{throw new d("GitHub CLI (gh) is not installed","Install from https://cli.github.com and run: gh auth login")}try{await Bun.$`gh auth status`.quiet()}catch{throw new d("GitHub CLI (gh) is not authenticated","Run: gh auth login")}}async getDefaultBranch(){try{return(await Bun.$`gh repo view --json defaultBranchRef --jq .defaultBranchRef.name`.quiet()).stdout.toString().trim()||me}catch{return me}}async findPr(e){try{let t=[];if(e.head)t.push("--head",e.head);if(e.label)t.push("--label",e.label);let n=await Bun.$`gh pr list --json number,url,title,body,labels,author,headRefName,baseRefName,mergeCommit,state --limit 1 ${t}`.quiet(),r=JSON.parse(n.stdout.toString());if(!r[0])return null;return this.mapPrResponse(r[0])}catch{return null}}async createPr(e){let t=await Bun.$`gh api ${this.apiPath}/pulls --method POST -f head=${e.head} -f base=${e.base} -f title=${e.title} -f body=${e.body}`,r=JSON.parse(t.stdout.toString()).number;if(e.labels&&e.labels.length>0){let i=e.labels.flatMap((s)=>["-f",`labels[]=${s}`]);await Bun.$`gh api ${this.apiPath}/issues/${r}/labels --method POST ${i}`}return this.getPr(r)}async updatePr(e,t){let n=[];if(t.title)n.push("--title",t.title);if(t.body)n.push("--body",t.body);await Bun.$`gh pr edit ${e} ${n}`}async getPr(e){try{let t=await Bun.$`gh api ${this.apiPath}/pulls/${e}`.quiet(),n=JSON.parse(t.stdout.toString());return this.mapRestApiResponse(n)}catch{throw new d(`Failed to fetch PR #${e}`,"Make sure the PR exists and you have access")}}async getPrFromCurrentBranch(){try{let e=await Bun.$`gh pr view --json number,title,body,labels,author,headRefName,baseRefName,url,mergeCommit,state`.quiet(),t=JSON.parse(e.stdout.toString());return this.mapPrResponse(t)}catch{throw new d("No PR found for current branch","Make sure you have an open PR or provide a URL with --url")}}async getPrCommits(e){try{return(await Bun.$`gh api ${this.apiPath}/pulls/${e}/commits --jq '.[].sha'`.quiet()).stdout.toString().trim().split(`
|
|
86
|
+
`}}}}).prompt();var sr=!process.env.NO_COLOR&&(process.env.FORCE_COLOR||(process.stdout?.isTTY??!1)),li=["black","blue","cyan","gray","green","magenta","red","white","yellow"],ir=["bold","dim","italic","underline","reset"],ui={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",reset:"\x1B[0m",underline:"\x1B[4m"},nr={black:"\x1B[30m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",green:"\x1B[32m",magenta:"\x1B[35m",red:"\x1B[31m",white:"\x1B[37m",yellow:"\x1B[33m"},rr={black:"\x1B[40m",blue:"\x1B[44m",cyan:"\x1B[46m",gray:"\x1B[100m",green:"\x1B[42m",magenta:"\x1B[45m",red:"\x1B[41m",white:"\x1B[47m",yellow:"\x1B[43m"},ai={"\x1B[30m":"\x1B[90m","\x1B[31m":"\x1B[91m","\x1B[32m":"\x1B[92m","\x1B[33m":"\x1B[93m","\x1B[34m":"\x1B[94m","\x1B[35m":"\x1B[95m","\x1B[36m":"\x1B[96m","\x1B[37m":"\x1B[97m"};function rt(e){return(t)=>sr?`${e}${t}${ui.reset}`:t}function or(e){for(let t=0;t<e.length;t++){let s=e.charCodeAt(t);if(s<32&&s!==27)return!1}return!0}function ci({bright:e=!1,color:t}){let s=Bun.color(t,"ansi"),i=typeof s==="string"&&s.length>0&&or(s)?s:nr[t];if(!i)return"";return e&&i in ai?ai[i]:i}var ar=li.reduce((e,t)=>{let s=ci({color:t});if(s)e[t]=rt(s);let i=ci({bright:!0,color:t});if(i)e[`${t}Bright`]=rt(i);return e},{}),cr=ir.reduce((e,t)=>(e[t]=rt(ui[t]),e),{}),lr=li.reduce((e,t)=>{let s=rr[t];if(s){let i=`bg${t.charAt(0).toUpperCase()}${t.slice(1)}`;e[i]=rt(s)}return e},{}),c={...ar,...cr,...lr};function ot(e){if(De(e))throw new te;return e}function pr(e){return e.map((t)=>t.key?`${c.bold(t.key)} ${c.dim(t.text)}`:c.dim(t.text)).join(c.dim(" \xB7 "))}function at(e){m.info(pr(e))}var ct={confirm:[{key:"Enter",text:"confirm"},{key:"Esc",text:"cancel"}],multiselect:[{key:"\u2191\u2193",text:"navigate"},{key:"Space",text:"toggle"},{key:"a",text:"all"},{key:"Enter",text:"confirm"},{key:"Esc",text:"cancel"}],select:[{key:"\u2191\u2193",text:"navigate"},{key:"Enter",text:"select"},{key:"Esc",text:"cancel"}],text:[{key:"Enter",text:"submit"},{key:"Esc",text:"cancel"}]};async function T(e){return at(ct.confirm),ot(await ii(e))}async function z(e){return at(ct.text),ot(await oi(e))}async function ye(e){return at(ct.select),ot(await ri({showInstructions:!1,...e}))}async function ce(e){return at(ct.multiselect),ot(await ni({showInstructions:!1,...e}))}var w={arg:c.magenta,cmd:c.cyan,default:c.blue,desc:c.white,flag:c.green,header:(e)=>c.bold(c.yellow(e)),hint:c.dim,name:(e)=>c.bold(c.cyan(e)),placeholder:c.magenta};class Gt{metadata;commands;globalArgs;constructor(e,t,s){this.metadata=e;this.commands=t;this.globalArgs=s}version(){return`${w.name(this.metadata.name)} ${w.hint(this.metadata.version??"0.0.0")}`}global(){let e=[],{name:t,bin:s,version:i,description:n}=this.metadata;if(e.push(""),e.push(`${w.name(t)}${i?` ${w.hint(`v${i}`)}`:""}`),n)e.push(w.desc(n));e.push(""),e.push(w.header("Usage:")),e.push(` ${w.cmd(s)} ${w.placeholder("[command]")} ${w.hint("[options]")}`),e.push(""),e.push(w.header("Commands:"));let r=Array.from(this.commands.values()).map((o)=>[` ${w.cmd(o.name)}`,w.desc(o.description)]);return e.push(...this.formatColumns(r)),e.push(""),e.push(w.header("Options:")),e.push(...this.formatArgDefs(this.globalArgs)),e.push(""),e.push(w.hint(`Run "${s} <command> --help" for command-specific options.`)),e.push(""),e.join(`
|
|
87
|
+
`)}command(e,t){let s=[],i=t??this.metadata.bin,n=`${w.cmd(i)} ${w.cmd(e.name)}`;s.push(""),s.push(`${w.name(e.name)} ${w.hint("-")} ${w.desc(e.description)}`),s.push(""),s.push(w.header("Usage:"));let r=this.formatPositionalUsage(e.positionals);if(e.hasSubcommands())s.push(` ${n} ${w.placeholder("<subcommand>")} ${w.hint("[options]")}`);else{let l=[n];if(r)l.push(r);l.push(w.hint("[options]")),s.push(` ${l.join(" ")}`)}if(e.prompts)s.push(` ${n} ${w.hint("- runs interactively")}`);if(s.push(""),e.hasSubcommands()){s.push(w.header("Subcommands:"));let l=e.getSubcommands().map((u)=>[` ${w.cmd(u.name)}`,w.desc(u.description)]);s.push(...this.formatColumns(l)),s.push("")}if(Object.entries(e.positionals).length>0)s.push(w.header("Arguments:")),s.push(...this.formatPositionalDefs(e.positionals)),s.push("");if(Object.entries(e.args).length>0)s.push(w.header("Options:")),s.push(...this.formatArgDefs(e.args)),s.push("");return s.join(`
|
|
88
|
+
`)}formatPositionalUsage(e){return Object.entries(e).map(([t,s])=>{let i=s.variadic?`${t}...`:t;return s.required?w.arg(`<${i}>`):w.arg(`[${i}]`)}).join(" ")}formatPositionalDefs(e){let t=Object.entries(e).map(([s,i])=>{let n=i.variadic?`${s}...`:s,r=w.desc(i.description??""),o=i.required?"":w.hint(" (optional)");return[` ${w.arg(n)}`,`${r}${o}`]});return this.formatColumns(t)}formatArgDefs(e){let t=[];for(let[s,i]of Object.entries(e)){let r=`${i.alias?`${w.flag(`-${i.alias}`)}, `:" "}${w.flag(`--${s}`)}`,o=w.desc(i.description??""),a=i.default!==void 0?w.hint(` (default: ${w.default(this.formatDefault(i))})`):"";t.push([` ${r}`,`${o}${a}`])}return this.formatColumns(t)}formatDefault(e){if(e.type==="string")return`"${e.default}"`;return String(e.default)}formatColumns(e){if(e.length===0)return[];let t=Math.max(...e.map(([i])=>this.stripAnsi(i).length)),s=2;return e.map(([i,n])=>{let r=t-this.stripAnsi(i).length+s;return`${i}${" ".repeat(r)}${n}`})}stripAnsi(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}}var le=new Uint32Array(65536),mr=(e,t)=>{let s=e.length,i=t.length,n=1<<s-1,r=-1,o=0,a=s,l=s;while(l--)le[e.charCodeAt(l)]|=1<<l;for(l=0;l<i;l++){let u=le[t.charCodeAt(l)],g=u|o;if(u|=(u&r)+r^r,o|=~(u|r),r&=u,o&n)a++;if(r&n)a--;o=o<<1|1,r=r<<1|~(g|o),o&=g}l=s;while(l--)le[e.charCodeAt(l)]=0;return a},gr=(e,t)=>{let s=t.length,i=e.length,n=[],r=[],o=Math.ceil(s/32),a=Math.ceil(i/32);for(let h=0;h<o;h++)r[h]=-1,n[h]=0;let l=0;for(;l<a-1;l++){let h=0,$=-1,_=l*32,F=Math.min(32,i)+_;for(let P=_;P<F;P++)le[e.charCodeAt(P)]|=1<<P;for(let P=0;P<s;P++){let U=le[t.charCodeAt(P)],E=r[P/32|0]>>>P&1,C=n[P/32|0]>>>P&1,L=U|h,O=((U|C)&$)+$^$|U|C,A=h|~(O|$),N=$&O;if(A>>>31^E)r[P/32|0]^=1<<P;if(N>>>31^C)n[P/32|0]^=1<<P;A=A<<1|E,N=N<<1|C,$=N|~(L|A),h=A&L}for(let P=_;P<F;P++)le[e.charCodeAt(P)]=0}let u=0,g=-1,f=l*32,y=Math.min(32,i-f)+f;for(let h=f;h<y;h++)le[e.charCodeAt(h)]|=1<<h;let b=i;for(let h=0;h<s;h++){let $=le[t.charCodeAt(h)],_=r[h/32|0]>>>h&1,F=n[h/32|0]>>>h&1,P=$|u,U=(($|F)&g)+g^g|$|F,E=u|~(U|g),C=g&U;if(b+=E>>>i-1&1,b-=C>>>i-1&1,E>>>31^_)r[h/32|0]^=1<<h;if(C>>>31^F)n[h/32|0]^=1<<h;E=E<<1|_,C=C<<1|F,g=C|~(P|E),u=E&P}for(let h=f;h<y;h++)le[e.charCodeAt(h)]=0;return b},hr=(e,t)=>{if(e.length<t.length){let s=t;t=e,e=s}if(t.length===0)return e.length;if(e.length<=32)return mr(e,t);return gr(e,t)},pi=(e,t)=>{let s=1/0,i=0;for(let n=0;n<t.length;n++){let r=hr(e,t[n]);if(r<s)s=r,i=n}return t[i]};function lt(e,t,s,i){let n=pi(t,s);if(console.error(c.red(`Unknown ${e}: ${t}`)),n)console.error(c.yellow(`Did you mean "${n}"?`));console.error(`
|
|
89
|
+
Run "${i} --help" for usage.`),process.exit(1)}function be(e,t){let s=(n)=>n&&typeof n==="object";if(!s(e)||!s(t))return t;let i={...e};for(let n of Object.keys(t)){let r=i[n],o=t[n];if(Array.isArray(r)&&Array.isArray(o))i[n]=[...o];else if(s(r)&&s(o))i[n]=be(r,o);else i[n]=o}return i}function Ut(e){return e==null?[]:Array.isArray(e)?e:[e]}function dr(e,t,s,i){var n,r=e[t],o=~i.string.indexOf(t)?s==null||s===!0?"":String(s):typeof s==="boolean"?s:~i.boolean.indexOf(t)?s==="false"?!1:s==="true"||(e._.push((n=+s,n*0===0)?n:s),!!s):(n=+s,n*0===0)?n:s;e[t]=r==null?o:Array.isArray(r)?r.concat(o):[r,o]}function ut(e,t){e=e||[],t=t||{};var s,i,n,r,o,a={_:[]},l=0,u=0,g=0,f=e.length;let y=t.alias!==void 0,b=t.unknown!==void 0,h=t.default!==void 0;if(t.alias=t.alias||{},t.string=Ut(t.string),t.boolean=Ut(t.boolean),y)for(s in t.alias){i=t.alias[s]=Ut(t.alias[s]);for(l=0;l<i.length;l++)(t.alias[i[l]]=i.concat(s)).splice(l,1)}for(l=t.boolean.length;l-- >0;){i=t.alias[t.boolean[l]]||[];for(u=i.length;u-- >0;)t.boolean.push(i[u])}for(l=t.string.length;l-- >0;){i=t.alias[t.string[l]]||[];for(u=i.length;u-- >0;)t.string.push(i[u])}if(h){for(s in t.default)if(r=typeof t.default[s],i=t.alias[s]=t.alias[s]||[],t[r]!==void 0){t[r].push(s);for(l=0;l<i.length;l++)t[r].push(i[l])}}let $=b?Object.keys(t.alias):[];for(l=0;l<f;l++){if(n=e[l],n==="--"){a._=a._.concat(e.slice(++l));break}for(u=0;u<n.length;u++)if(n.charCodeAt(u)!==45)break;if(u===0)a._.push(n);else if(n.substring(u,u+3)==="no-"){if(r=n.substring(u+3),b&&!~$.indexOf(r))return t.unknown(n);a[r]=!1}else{for(g=u+1;g<n.length;g++)if(n.charCodeAt(g)===61)break;r=n.substring(u,g),o=n.substring(++g)||(l+1===f||(""+e[l+1]).charCodeAt(0)===45||e[++l]),i=u===2?[r]:r;for(g=0;g<i.length;g++){if(r=i[g],b&&!~$.indexOf(r))return t.unknown("-".repeat(u)+r);dr(a,r,g+1<i.length||o,t)}}}if(h){for(s in t.default)if(a[s]===void 0)a[s]=t.default[s]}if(y)for(s in a){i=t.alias[s]||[];while(i.length>0)a[i.shift()]=a[s]}return a}function fr(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function mi(e){let t={alias:{},boolean:[],default:{},string:[]};for(let[s,i]of Object.entries(e)){if(i.type==="boolean")t.boolean.push(s);else t.string.push(s);if(i.alias)t.alias[i.alias]=s;let n=fr(s);if(n!==s)t.alias[n]=s;if(i.default!==void 0)t.default[s]=i.default}return t}function gi(e,t){let s={...e};for(let[i,n]of Object.entries(t)){if(n.type!=="number")continue;let r=e[i];if(r===void 0||typeof r==="boolean")continue;let o=Number(r);if(Number.isNaN(o))throw Error(`Invalid number for --${i}: "${r}"`);s[i]=o}return s}function hi(e,t){let s=mi(t),i=ut(e,s),n=i._[0],r=n?e.indexOf(n):-1,{_:o,...a}=i,l=gi(a,t);return{command:n,flags:l,restArgs:r>=0?e.slice(r+1):[]}}function Vt(e,t={}){let s=mi(t),i=ut(e,s),{_:n,...r}=i;return{args:gi(r,t),rawPositionals:n}}function Ht(e,t){let s={},i=Object.entries(t);for(let[n,[r,o]]of i.entries())s[r]=o.variadic?e.slice(n):e[n];return s}function di(e,t){for(let[s,i]of Object.entries(t)){if(!i.required)continue;let n=e[s];if(Array.isArray(n)?n.length===0:!n)return`Missing required argument: <${s}${i.variadic?"...":""}>`}return null}var Wt="__exit__";class ke{command;env;prefix;options;constructor(e,t,s,i={}){this.command=e;this.env=t;this.prefix=s;this.options=i}get commandPath(){return this.prefix?`${this.prefix} ${this.command.name}`:this.command.name}async route(e,t){if(t)await this.routeInteractive();else await this.routeDirect(e)}async routeDirect(e){let[t,...s]=e;if(t&&this.command.hasSubcommands()){let i=this.command.getSubcommand(t);if(i){await this.handleSubcommandRoute(i,s);return}if(!t.startsWith("-")){this.handleUnknownSubcommand(t);return}}await this.executeCommand(e)}handleUnknownSubcommand(e){let t=this.command.getSubcommands().map((s)=>s.name);lt("subcommand",e,t,this.commandPath)}async handleSubcommandRoute(e,t){await new ke(e,this.env,this.commandPath).route(t,!1)}async executeCommand(e){if(this.isHelpRequest(e)){this.printHelp(this.command);return}if(this.command.hasSubcommands()&&!this.command.execute){this.printHelp(this.command);return}if(!this.command.execute)return;let{args:s,rawPositionals:i}=Vt(e,this.command.args),n=Ht(i,this.command.positionals),r=di(n,this.command.positionals);if(r)m.error(r),console.error(`
|
|
90
|
+
Run "${this.commandPath} --help" for usage.`),process.exit(1);let o=this.command.prompts&&i.length===0,a=this.buildContext(n,s,o);await this.command.execute(a)}async routeInteractive(){if(!this.command.hasSubcommands()){await this.executeInteractive();return}await this.runSubcommandMenu()}async executeInteractive(){let{args:e}=Vt([],this.command.args),t=Ht([],this.command.positionals),s=this.buildContext(t,e,!0);await this.command.execute?.(s)}async runSubcommandMenu(){while(!0){let e=await this.promptSubcommandSelectionOrBack();if(e===null)return;if(e===Wt){this.options.onExit?.();return}let t=this.command.getSubcommand(e);if(t)await this.executeSubcommand(t)}}async promptSubcommandSelectionOrBack(){try{return await this.promptSubcommandSelection()}catch(e){if(e instanceof te){if(this.options.isRoot)this.options.onExit?.();return null}throw e}}async executeSubcommand(e){try{await new ke(e,this.env,this.commandPath).route([],!0)}catch(t){if(t instanceof te)return;if(t instanceof d){if(m.warn(c.yellow(t.message)),t.hint)m.info(c.dim(t.hint));return}throw t}}promptSubcommandSelection(){let{isRoot:e}=this.options,t=e?{hint:this.env.cli.exitHint,label:this.env.cli.exitLabel??"Exit",value:Wt}:{hint:"Return to previous menu",label:"Back",value:Wt};return ye({message:e?this.env.cli.promptMessage??"Select:":`${this.command.name}:`,options:[...this.command.getSubcommands().map((s)=>({hint:s.description,label:s.name,value:s.name})),t]})}buildContext(e,t,s){return{...this.env,args:t,interactive:s,positionals:e}}isHelpRequest(e){return e.includes("--help")||e.includes("-h")}printHelp(e){let t=e===this.command?this.prefix:this.commandPath;console.log(this.env.formatHelp(e,t))}}var yr={clearOnStart:!0,exitHint:"Close the CLI",exitLabel:"Exit",goodbyeMessage:"Goodbye!",name:"CLI",promptMessage:"What would you like to do?"};class qt{commands=new Map;metadata;configManager;help;bin;globalArgs={help:{alias:"h",description:"Show help",type:"boolean"},interactive:{alias:"i",description:"Enable interactive mode",type:"boolean"},version:{alias:"v",description:"Show version",type:"boolean"}};constructor(e,t){this.configManager=e,this.metadata={...yr,...t},this.bin=this.metadata.bin??this.metadata.name,this.init(),this.help=new Gt({bin:this.bin,description:this.metadata.description,name:this.metadata.name,version:this.metadata.version},this.commands,this.globalArgs)}registerCommands(e){for(let t of e)t.init?.(),this.commands.set(t.name,t)}async run(e=process.argv.slice(2)){let{command:t,flags:s,restArgs:i}=hi(e,this.globalArgs);if(s.version&&!t)return console.log(this.help.version());if(s.interactive&&!t)return this.runInteractive();if(!t)return console.log(this.help.global());if(t==="help")return this.printHelpFor(i[0]);await this.runDirect(t,i,!!s.help)}printHelpFor(e){if(!e)return console.log(this.help.global());let t=this.commands.get(e);if(!t)return this.handleUnknownCommand(e);console.log(this.help.command(t))}async runInteractive(){this.showIntro();let e=this.createVirtualRootCommand(),t={cli:this.metadata,config:this.configManager,formatHelp:this.help.command.bind(this.help)},s=new ke(e,t,this.bin,{isRoot:!0,onExit:()=>this.exit()});try{await s.route([],!0)}catch(i){this.handleError(i)}}createVirtualRootCommand(){return{description:this.metadata.description,getSubcommand:(e)=>this.commands.get(e),getSubcommands:()=>Array.from(this.commands.values()),hasSubcommands:()=>!0,name:this.metadata.name}}exit(){nt(this.metadata.goodbyeMessage),process.exit(0)}async runDirect(e,t,s){let i=this.commands.get(e);if(!i)return this.handleUnknownCommand(e);let n=t.length>0&&!t[0]?.startsWith("-");if(s&&!n)return console.log(this.help.command(i));try{let r={cli:this.metadata,config:this.configManager,formatHelp:this.help.command.bind(this.help)};await new ke(i,r,this.bin).route(t,!1)}catch(r){this.handleError(r)}}showIntro(){if(this.metadata.clearOnStart)console.clear();let e=this.metadata.version?` v${this.metadata.version}`:"";it(`${c.bgCyan(c.black(` ${this.metadata.name}${e} `))}`)}handleUnknownCommand(e){let t=Array.from(this.commands.keys());lt("command",e,t,this.bin)}handleError(e){if(this.metadata.onError?.(e))return;if(e instanceof te)process.exit(0);if(e instanceof d){if(m.warn(c.yellow(e.message)),e.hint)m.info(c.dim(e.hint));process.exit(0)}if(e instanceof Error)m.error(c.red(e.message)),process.exit(1);console.error(c.red("Error:"),e),process.exit(1)}}class Ne{args={};positionals={};prompts=!1;subcommands=new Map;registerSubcommands(e){for(let t of e)t.init?.(),this.subcommands.set(t.name,t)}hasSubcommands(){return this.subcommands.size>0}getSubcommand(e){return this.subcommands.get(e)}getSubcommands(){return Array.from(this.subcommands.values())}}function M(e){return e}function Z(e){return e}import Re from"fs";import fi from"path";class Jt{config;configPath;defaultConfig;constructor(e,t){this.configPath=fi.resolve(e),this.defaultConfig=t,this.config=this.loadConfig()}get(e){return this.config[e]}set(e,t){this.config[e]=t,this.save()}delete(e){delete this.config[e],this.save()}exists(){return Re.existsSync(this.configPath)}getAll(){return be({},this.config)}save(e){if(e)this.config={...e};this.ensureDirectoryExists();try{Re.writeFileSync(this.configPath,JSON.stringify(this.config,null,2))}catch(t){console.error(`Failed to save config to ${this.configPath}:`,t)}}ensureDirectoryExists(){let e=fi.dirname(this.configPath);if(!Re.existsSync(e))try{Re.mkdirSync(e,{recursive:!0})}catch(t){console.error(`Failed to create config directory at ${e}:`,t)}}loadConfig(){if(!Re.existsSync(this.configPath))return{...this.defaultConfig};try{let e=Re.readFileSync(this.configPath,"utf-8"),t=JSON.parse(e);return be({...this.defaultConfig},t)}catch{return console.warn(`Config file corrupted at ${this.configPath}. Using defaults.`),{...this.defaultConfig}}}}var yi="0.7.0";class I extends Ne{}import{existsSync as _r}from"fs";import{mkdir as Ar,writeFile as Er}from"fs/promises";import{dirname as Or}from"path";class de{owner;repo;constructor(e){this.owner=e.owner,this.repo=e.repo}}class pt extends de{name="bitbucket";notImplemented(){throw new d("Bitbucket is not supported yet","Bitbucket support is coming soon")}async ensureAvailable(){this.notImplemented()}async getDefaultBranch(){this.notImplemented()}async findPr(e){this.notImplemented()}async createPr(e){this.notImplemented()}async updatePr(e,t){this.notImplemented()}async getPr(e){this.notImplemented()}async getPrFromCurrentBranch(){this.notImplemented()}async getPrCommits(e){this.notImplemented()}async getPrFiles(e){this.notImplemented()}async ensureLabelExists(e,t){this.notImplemented()}async createRelease(e){this.notImplemented()}async deleteRelease(e){this.notImplemented()}}var D="sis",Kt="\uD83E\uDEA8",fe="other",xe={build:23,chore:25,ci:24,docs:20,feat:10,"feat!":0,fix:11,"fix!":1,perf:12,refactor:13,style:21,test:22,["other"]:100},Ie=50,mt=".sisyphus",bi="stones",$i="released",gt=7,wi="unknown",Le="unknown",vi="0.0.0",Pi="latest",ue="main",Ci=4,Si=8,ki="config.json";var Te={$schema:"https://raw.githubusercontent.com/r5n-labs/clis/refs/heads/develop/packages/sisyphus/schema.json",changelog:{append:!0,filename:"CHANGELOG.md",generate:!0,packageHeader:"{emoji} {version} ({date})",root:!1,rootHeader:"{date} - {packages}",sections:{breaking:"Breaking changes",build:"Build",chore:"Chores",ci:"CI",dependencies:"Dependency updates",docs:"Documentation",feat:"Features",fix:"Bug fixes",other:"Other changes",perf:"Performance",refactor:"Refactoring",style:"Styling",test:"Tests"}},commit:{author:"r5n-bot",message:"chore(release): {message}"},commits:{skip:{authors:["r5n-bot[bot]"],messagePatterns:["^chore\\(release\\):","^chore: add stone"]}},ignore:[],lastStone:{commit:"",date:""},plugins:[],pr:{labelMapping:{breaking:"major","breaking-change":"major",bug:"patch",chore:"patch",docs:"patch",enhancement:"minor",feature:"minor",fix:"patch"},skip:{authors:["r5n-bot[bot]"],labels:["sisyphus-release","skip-stone"],titlePatterns:["^chore\\(release\\):"]}},release:{createRelease:!1,npm:!1,push:!1,tags:!1},scripts:{post:{},pre:{}},single:!1,sisyphusDir:".sisyphus",stones:[],tag:"latest"};class ht extends de{name="github";get apiPath(){return`repos/${encodeURIComponent(this.owner)}/${encodeURIComponent(this.repo)}`}async ensureAvailable(){try{await Bun.$`which gh`.quiet()}catch{throw new d("GitHub CLI (gh) is not installed","Install from https://cli.github.com and run: gh auth login")}try{await Bun.$`gh auth status`.quiet()}catch{throw new d("GitHub CLI (gh) is not authenticated","Run: gh auth login")}}async getDefaultBranch(){try{return(await Bun.$`gh repo view --json defaultBranchRef --jq .defaultBranchRef.name`.quiet()).stdout.toString().trim()||ue}catch{return ue}}async findPr(e){try{let t=[];if(e.head)t.push("--head",e.head);if(e.label)t.push("--label",e.label);let s=await Bun.$`gh pr list --json number,url,title,body,labels,author,headRefName,baseRefName,mergeCommit,state --limit 1 ${t}`.quiet(),i=JSON.parse(s.stdout.toString());if(!i[0])return null;return this.mapPrResponse(i[0])}catch{return null}}async createPr(e){let t=await Bun.$`gh api ${this.apiPath}/pulls --method POST -f head=${e.head} -f base=${e.base} -f title=${e.title} -f body=${e.body}`,i=JSON.parse(t.stdout.toString()).number;if(e.labels&&e.labels.length>0){let n=e.labels.flatMap((r)=>["-f",`labels[]=${r}`]);await Bun.$`gh api ${this.apiPath}/issues/${i}/labels --method POST ${n}`}return this.getPr(i)}async updatePr(e,t){let s=[];if(t.title)s.push("--title",t.title);if(t.body)s.push("--body",t.body);await Bun.$`gh pr edit ${e} ${s}`}async getPr(e){try{let t=await Bun.$`gh api ${this.apiPath}/pulls/${e}`.quiet(),s=JSON.parse(t.stdout.toString());return this.mapRestApiResponse(s)}catch{throw new d(`Failed to fetch PR #${e}`,"Make sure the PR exists and you have access")}}async getPrFromCurrentBranch(){try{let e=await Bun.$`gh pr view --json number,title,body,labels,author,headRefName,baseRefName,url,mergeCommit,state`.quiet(),t=JSON.parse(e.stdout.toString());return this.mapPrResponse(t)}catch{throw new d("No PR found for current branch","Make sure you have an open PR or provide a URL with --url")}}async getPrCommits(e){try{return(await Bun.$`gh api ${this.apiPath}/pulls/${e}/commits --jq '.[].sha'`.quiet()).stdout.toString().trim().split(`
|
|
91
91
|
`).filter(Boolean)}catch{return[]}}async getPrFiles(e){try{return(await Bun.$`gh api ${this.apiPath}/pulls/${e}/files --jq '.[].filename'`.quiet()).stdout.toString().trim().split(`
|
|
92
|
-
`).filter(Boolean)}catch{return[]}}async ensureLabelExists(e,t){try{let
|
|
92
|
+
`).filter(Boolean)}catch{return[]}}async ensureLabelExists(e,t){try{let s=t?.description??"",i=t?.color?["--color",t.color]:[];await Bun.$`gh label create ${e} --description ${s} ${i} --force`.quiet()}catch{}}async createRelease(e){await Bun.$`gh release create ${e.tag} --title ${e.title} --notes ${e.notes}`}async deleteRelease(e){try{await Bun.$`gh release delete ${e} --yes`.quiet()}catch{}}mapRestApiResponse(e){return{author:e.user?.login??Le,baseBranch:e.base?.ref??ue,body:e.body??"",headBranch:e.head?.ref??"",labels:e.labels?.map((t)=>t.name)??[],mergeCommitSha:e.merge_commit_sha,merged:e.merged,number:e.number,title:e.title,url:e.html_url}}mapPrResponse(e){return{author:e.author?.login??Le,baseBranch:e.baseRefName??ue,body:e.body??"",headBranch:e.headRefName??"",labels:e.labels?.map((t)=>t.name)??[],mergeCommitSha:e.mergeCommit?.oid??null,merged:e.state==="MERGED",number:e.number,title:e.title,url:e.url}}}var $r="https://gitlab.com/api/v4";class dt extends de{name="gitlab";authHeader={};apiUrl;projectPath;constructor(e){super(e);this.apiUrl=process.env.CI_API_V4_URL??$r,this.projectPath=encodeURIComponent(`${this.owner}/${this.repo}`)}async ensureAvailable(){this.authHeader=await this.resolveAuth()}async getDefaultBranch(){try{return(await this.api(`/projects/${this.projectPath}`)).default_branch||ue}catch{return ue}}async findPr(e){try{let t=new URLSearchParams({per_page:"1",state:"opened"});if(e.head)t.set("source_branch",e.head);if(e.label)t.set("labels",e.label);let s=await this.api(`/projects/${this.projectPath}/merge_requests?${t}`);if(!s[0])return null;return this.mapMrResponse(s[0])}catch{return null}}async createPr(e){let t={description:e.body,source_branch:e.head,target_branch:e.base,title:e.title};if(e.labels?.length)t.labels=e.labels.join(",");let s=await this.api(`/projects/${this.projectPath}/merge_requests`,{body:JSON.stringify(t),method:"POST"});return this.mapMrResponse(s)}async updatePr(e,t){let s={};if(t.title)s.title=t.title;if(t.body)s.description=t.body;await this.api(`/projects/${this.projectPath}/merge_requests/${e}`,{body:JSON.stringify(s),method:"PUT"})}async getPr(e){try{let t=await this.api(`/projects/${this.projectPath}/merge_requests/${e}`);return this.mapMrResponse(t)}catch{throw new d(`Failed to fetch MR !${e}`,"Make sure the MR exists and you have access")}}async getPrFromCurrentBranch(){try{let t=(await Bun.$`git rev-parse --abbrev-ref HEAD`.quiet()).stdout.toString().trim(),s=new URLSearchParams({per_page:"1",source_branch:t,state:"opened"}),i=await this.api(`/projects/${this.projectPath}/merge_requests?${s}`);if(!i[0])throw Error("No MR found");return this.mapMrResponse(i[0])}catch{throw new d("No MR found for current branch","Make sure you have an open MR or provide a URL with --url")}}async getPrCommits(e){try{return(await this.api(`/projects/${this.projectPath}/merge_requests/${e}/commits`)).map((s)=>s.id)}catch{return[]}}async getPrFiles(e){try{return(await this.api(`/projects/${this.projectPath}/merge_requests/${e}/changes`)).changes?.map((s)=>s.new_path)??[]}catch{return[]}}async ensureLabelExists(e,t){try{let s={name:e};if(t?.description)s.description=t.description;if(t?.color)s.color=`#${t.color}`;await this.api(`/projects/${this.projectPath}/labels`,{body:JSON.stringify(s),method:"POST"})}catch{}}async createRelease(e){await this.api(`/projects/${this.projectPath}/releases`,{body:JSON.stringify({description:e.notes,name:e.title,tag_name:e.tag}),method:"POST"})}async deleteRelease(e){try{await this.api(`/projects/${this.projectPath}/releases/${encodeURIComponent(e)}`,{method:"DELETE"})}catch{}}async resolveAuth(){if(process.env.GITLAB_TOKEN)return{"PRIVATE-TOKEN":process.env.GITLAB_TOKEN};if(process.env.CI_JOB_TOKEN)return{"JOB-TOKEN":process.env.CI_JOB_TOKEN};try{let e=await Bun.$`glab auth status --show-token`.quiet(),s=(e.stdout.toString()+e.stderr.toString()).match(/Token found:\s*(\S+)/);if(s?.[1])return{Authorization:`Bearer ${s[1]}`}}catch{}throw new d("GitLab token not found","Set GITLAB_TOKEN environment variable or install glab CLI and run: glab auth login")}async api(e,t){let s=await fetch(`${this.apiUrl}${e}`,{...t,headers:{"Content-Type":"application/json",...this.authHeader,...t?.headers}});if(!s.ok){let i=await s.text().catch(()=>"");throw Error(`GitLab API error: ${s.status} ${s.statusText}${i?` \u2014 ${i}`:""}`)}return s.json()}mapMrResponse(e){return{author:e.author?.username??Le,baseBranch:e.target_branch??ue,body:e.description??"",headBranch:e.source_branch??"",labels:e.labels??[],mergeCommitSha:e.merge_commit_sha,merged:e.state==="merged",number:e.iid,title:e.title,url:e.web_url}}}var wr=/github\.com[:/]([^/]+)\/([^/.]+)/,vr=/gitlab\.com[:/]([^/]+)\/([^/.]+)/,Pr=/bitbucket\.org[:/]([^/]+)\/([^/.]+)/,Cr=/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/,Sr=/gitlab\.com\/([^/]+)\/([^/]+)\/-\/merge_requests\/(\d+)/,kr=/bitbucket\.org\/([^/]+)\/([^/]+)\/pull-requests\/(\d+)/;async function Me(){let e=await Ri();if(!e)throw new d("Could not detect git provider","Make sure you have a git remote configured (origin)");let t=Rr(e);return await t.ensureAvailable(),t}function Rr(e){switch(e.provider){case"github":return new ht(e);case"gitlab":return new dt(e);case"bitbucket":return new pt(e);default:throw new d(`Unsupported provider: ${e.provider}`)}}async function Ri(){let e=await zt();if(!e)return null;return Yt(e)}async function xi(){let e=await Ri();if(!e)throw new d("Could not detect git provider","Make sure you have a git remote configured (origin)");return e.provider}async function zt(){try{return(await Bun.$`git remote get-url origin`.quiet()).stdout.toString().trim()||null}catch{return null}}function Yt(e){let t=[[wr,"github"],[vr,"gitlab"],[Pr,"bitbucket"]];for(let[s,i]of t){let n=e.match(s);if(!n)continue;let[,r,o]=n;if(r&&o)return{owner:r,provider:i,repo:o}}return null}function Xt(e){let t=[[Cr,"github"],[Sr,"gitlab"],[kr,"bitbucket"]];for(let[s,i]of t){let n=e.match(s);if(!n)continue;let[,r,o,a]=n;if(r&&o&&a)return{number:Number.parseInt(a,10),owner:r,provider:i,repo:o}}return null}import{existsSync as Ii}from"fs";import{readFile as xr}from"fs/promises";import{dirname as Ir,join as Zt}from"path";import{fileURLToPath as Tr}from"url";var ft={"create-stone":{description:"When a PR is merged, create stone and update release PR",name:"Handle PR merge (stone + release PR)"},release:{description:"When the release PR is merged, publish packages",name:"Publish release"}},Mr=Zt(Ir(Tr(import.meta.url)),"templates"),Ti={"create-stone":"sis-create-stone.yml",release:"sis-release.yml"};class Qt{async generate(e){let t=[];for(let s of e){let i=await this.readTemplate(s),n=this.getOutputPath(s);t.push({content:i,path:n})}return t}getExistingFiles(e){return e.map((t)=>this.getOutputPath(t)).filter((t)=>Ii(t))}async readTemplate(e){let t=Zt(Mr,this.provider,Ti[e]);return xr(t,"utf-8")}}class yt extends Qt{provider="github";outputDir=".github/workflows";getOutputPath(e){return Zt(this.outputDir,Ti[e])}}var Ge=".gitlab-ci-sisyphus.yml";class bt extends Qt{provider="gitlab";outputDir=".";async generate(e){let t=[];t.push(`stages:
|
|
93
93
|
- sisyphus
|
|
94
|
-
`);for(let
|
|
95
|
-
`),path:
|
|
96
|
-
- local: '${
|
|
97
|
-
`);let
|
|
98
|
-
${
|
|
99
|
-
`)}`),!await
|
|
100
|
-
${c.bold(o.path)}:`),
|
|
101
|
-
`),c.green("CI workflows created")),
|
|
94
|
+
`);for(let s of e){let i=await this.readTemplate(s);t.push(i)}return[{content:t.join(`
|
|
95
|
+
`),path:Ge}]}getExistingFiles(e){return Ii(Ge)?[Ge]:[]}getIncludeInstruction(){return`include:
|
|
96
|
+
- local: '${Ge}'`}getOutputPath(e){return Ge}}function Mi(e){switch(e){case"github":return new yt;case"gitlab":return new bt;default:throw Error(`CI generation is not supported for ${e}`)}}var Dr={bitbucket:"Bitbucket Pipelines",github:"GitHub Actions",gitlab:"GitLab CI"},Br=M({all:{alias:"a",default:!1,description:"Install all workflows",type:"boolean"},createStone:{default:!1,description:"Install create-stone workflow",type:"boolean"},dryRun:{alias:"d",default:!1,description:"Preview without writing files",type:"boolean"},release:{default:!1,description:"Install release workflow",type:"boolean"},yes:{alias:"y",default:!1,description:"Skip confirmation prompts",type:"boolean"}});class es extends I{name="init";description="Set up CI workflows for automated releases";args=Br;prompts=!0;async execute(e){let t=await xi(),s=Mi(t);m.info(`Detected ${c.bold(Dr[t])} repository
|
|
97
|
+
`);let i=await this.selectWorkflows(e);if(i.length===0){m.info(c.dim("No workflows selected"));return}let n=s.getExistingFiles(i);if(n.length>0&&!e.args.yes){if(!e.interactive)throw new d(`Workflows already exist: ${n.join(", ")}`,"Use --yes to overwrite existing workflows");if(m.warn(`The following files already exist:
|
|
98
|
+
${n.map((a)=>` ${a}`).join(`
|
|
99
|
+
`)}`),!await T({initialValue:!1,message:"Overwrite existing files?"}))return}let r=await s.generate(i);if(e.args.dryRun){for(let o of r)m.info(`
|
|
100
|
+
${c.bold(o.path)}:`),m.info(c.dim(o.content));return}for(let o of r){let a=Or(o.path);if(a!=="."&&!_r(a))await Ar(a,{recursive:!0});await Er(o.path,o.content,"utf-8")}if(B(r.map((o)=>` ${c.green("+")} ${o.path}`).join(`
|
|
101
|
+
`),c.green("CI workflows created")),s instanceof bt)m.info(`
|
|
102
102
|
Add this to your ${c.bold(".gitlab-ci.yml")}:
|
|
103
|
-
`),
|
|
104
|
-
${c.yellow("Note:")} Enable ${c.bold('"Allow GitHub Actions to create and approve pull requests"')}`),
|
|
105
|
-
`).filter(Boolean);
|
|
106
|
-
`).filter(Boolean)}static async getBody(e){return(await Bun.$`git log -1 --pretty=format:"%b" ${e}`.quiet()).stdout.toString().trim()||void 0}static parse(e,t,
|
|
103
|
+
`),m.info(c.cyan(s.getIncludeInstruction())),m.info(""),m.info(`${c.yellow("Note:")} Add a ${c.bold("GITLAB_TOKEN")} CI/CD variable (Personal Access Token with ${c.bold("api")} + ${c.bold("write_repository")} scopes)`),m.info(c.dim("Required for creating release PRs. Settings \u2192 CI/CD \u2192 Variables")),m.info("");if(s instanceof yt)m.info(`
|
|
104
|
+
${c.yellow("Note:")} Enable ${c.bold('"Allow GitHub Actions to create and approve pull requests"')}`),m.info(c.dim("Settings \u2192 Actions \u2192 General \u2192 Workflow permissions")),m.info("");m.info(c.dim("Commit and push these files to enable the workflows."))}async selectWorkflows(e){let t=this.getWorkflowsFromFlags(e);if(t.length>0)return t;if(!e.interactive)throw new d("No workflows specified","Use --all or specify workflows with --createStone, --release");return ce({initialValues:Object.keys(ft),message:"Select workflows to create",options:Object.entries(ft).map(([s,i])=>({hint:i.description,label:i.name,value:s})),required:!1})}getWorkflowsFromFlags(e){if(e.args.all)return Object.keys(ft);let t=[];if(e.args.createStone)t.push("create-stone");if(e.args.release)t.push("release");return t}}var pe;((r)=>{r.Major="major";r.Minor="minor";r.Patch="patch";r.Dependency="dependency";r.Snapshot="snapshot"})(pe||={});var _i={["major"]:5,["minor"]:4,["patch"]:3,["dependency"]:2,["snapshot"]:1},_e={["major"]:"\uD83D\uDEA8",["minor"]:"\u2728",["patch"]:"\uD83D\uDC1B",["dependency"]:"\uD83D\uDCE6",["snapshot"]:"\uD83D\uDCF8"},Ae={["major"]:c.red,["minor"]:c.yellow,["patch"]:c.green,["dependency"]:c.blue,["snapshot"]:c.magenta},$e=["major","minor","patch","dependency","snapshot"];function Fr(e,t){return _i[e]-_i[t]}function Ai(e,t){return Fr(e,t)>=0?e:t}function Ei(e){return Object.values(pe).includes(e)}var jr=/^(\w+)(?:\(([^)]+)\))?(!)?: (.+)$/,ts="\x1F",Nr=new Set(["build","chore","ci","docs","feat","fix","perf","refactor","style","test"]);class G{hash;subject;author;body;type;scope;breaking;message;files;constructor(e){this.hash=e.hash,this.subject=e.subject,this.author=e.author,this.body=e.body,this.type=e.type,this.scope=e.scope,this.breaking=e.breaking,this.message=e.message,this.files=e.files}static async since(e){if(e){let t=await G.tryFetchFromRange(`${e}..HEAD`);if(t)return t}return G.fetchFromRange("HEAD")}static async inRange(e,t){let s=[`origin/${e}..origin/${t}`,`${e}..${t}`];for(let i of s){let n=await G.tryFetchFromRange(i);if(n)return n}return[]}static async fromHash(e){try{let s=(await Bun.$`git log -1 --pretty=format:"%H%x1f%s%x1f%an" ${e}`.quiet()).stdout.toString().trim();if(!s)return null;let i=s.split(ts);if(i.length<3)return null;let[n,r,o]=i;if(!n||!r||!o)return null;return G.hydrate(n,r,o)}catch{return null}}static async fromMerge(e){try{let s=(await Bun.$`git rev-parse ${e}^2`.quiet()).stdout.toString().trim();if(!s)return[];return G.fetchFromRange(`${e}^1..${s}`)}catch{return[]}}static async tryFetchFromRange(e){try{return await G.fetchFromRange(e)}catch{return null}}static async fetchFromRange(e){let i=(await Bun.$`git log ${e} --pretty=format:${"%x00%H%x1f%s%x1f%an%x1f%b%x00"} --name-only --no-merges`.quiet()).stdout.toString().trim();if(!i)return[];let n=i.split("\x00").filter(Boolean),r=[];for(let o=0;o<n.length;o+=2){let a=n[o];if(!a)continue;let l=a.split(ts);if(l.length<3)continue;let[u,g,f]=l;if(!u||!g||!f)continue;let y=l.slice(3).join(ts).trim()||void 0,b=(n[o+1]??"").split(`
|
|
105
|
+
`).filter(Boolean);r.push(G.parse(u,g,f).withFiles(b).withBody(y))}return r}static async hydrate(e,t,s){let i=await G.getFiles(e),n=await G.getBody(e);return G.parse(e,t,s).withFiles(i).withBody(n)}static async getFiles(e){return(await Bun.$`git diff-tree --no-commit-id --name-only -r ${e}`.quiet()).stdout.toString().trim().split(`
|
|
106
|
+
`).filter(Boolean)}static async getBody(e){return(await Bun.$`git log -1 --pretty=format:"%b" ${e}`.quiet()).stdout.toString().trim()||void 0}static parse(e,t,s){let i=t.match(jr);if(i){let[,n="",r,o,a=""]=i;if(n&&Nr.has(n))return new G({author:s,breaking:!!o,files:[],hash:e,message:a,scope:r,subject:t,type:n})}return new G({author:s,breaking:!1,files:[],hash:e,message:t,subject:t,type:fe})}get shortHash(){return this.hash.slice(0,gt)}get isConventional(){return this.type!==fe}withFiles(e){return new G({...this.toOptions(),files:e})}withBody(e){return new G({...this.toOptions(),body:e})}toInfo(e){return{body:this.body,hash:this.shortHash,message:this.message,packages:e,scope:this.scope,subject:this.subject,type:this.type}}toOptions(){return{author:this.author,body:this.body,breaking:this.breaking,files:this.files,hash:this.hash,message:this.message,scope:this.scope,subject:this.subject,type:this.type}}}var H=(e)=>e.length>0?e:void 0;var $t=1,Lr=1,wt=10,Gr=/[.ZT:-]/g,Ur=14,Vr="nightly";class Q{static bump(e,t,s){let[i="0.0.0",n=""]=e.split("-"),[r="",o="0"]=n.split(".");if(t==="snapshot")return Q.formatSnapshot(s);if(s&&t!=="dependency")return Q.formatTagged(i,s,r,o);if(t==="dependency"&&r)return Q.formatTagged(i,r,r,o);return Q.bumpBase(i,t)}static formatLabel(e,t,s,i){let n=Q.bump(t,s,i),r=_e[s];return`${e}@${t} => ${n} ${r}`}static formatSnapshot(e){let t=new Date().toISOString().replace(Gr,"").slice(0,Ur);return`0.0.0-${e||Vr}-${t}`}static formatTagged(e,t,s,i){let n=t===s?Number.parseInt(i,wt)+$t:Lr;return`${e}-${t}.${n}`}static bumpBase(e,t){let[s="0",i="0",n="0"]=e.split("."),r=Number.parseInt(s,wt),o=Number.parseInt(i,wt),a=Number.parseInt(n,wt);switch(t){case"major":return`${r+$t}.0.0`;case"minor":return`${r}.${o+$t}.0`;case"dependency":case"patch":return`${r}.${o}.${a+$t}`;default:return`${r}.${o}.${a}`}}}class ee{name;version;file;dependencyOf;bump;tag;isPrivate;_newVersion;constructor(e){this.name=e.name,this.version=e.version,this.file=e.file,this.dependencyOf=e.dependencyOf??[],this.bump=e.bump,this.tag=e.tag,this.isPrivate=e.isPrivate??!1,this._newVersion=e.newVersion}static fromJson(e,t){return new ee({file:t,isPrivate:e.private??!1,name:e.name,version:e.version||vi})}static applyStone(e,t){let s=[];for(let i of $e)for(let n of e.getPackages(i)){let r=t.get(n);if(r)s.push(r.withBump(i,e.tag))}return s}get newVersion(){if(this._newVersion)return this._newVersion;if(!this.bump)return;return Q.bump(this.version,this.bump,this.tag)}get label(){if(!this.bump)return`${this.name}@${this.version}`;return Q.formatLabel(this.name,this.version,this.bump,this.tag)}withDependencyOf(e){return new ee({...this.toOptions(),dependencyOf:e})}withBump(e,t){return new ee({...this.toOptions(),bump:e,newVersion:void 0,tag:t})}withVersions(e,t){return new ee({...this.toOptions(),newVersion:t,version:e})}toOptions(){return{bump:this.bump,dependencyOf:this.dependencyOf,file:this.file,isPrivate:this.isPrivate,name:this.name,newVersion:this._newVersion,tag:this.tag,version:this.version}}}import{randomUUID as Hr}from"crypto";class R{id;message;tag;description;commits;_packages;constructor(e){this.id=e.id,this.message=e.message,this.tag=e.tag,this.description=e.description,this.commits=e.commits,this._packages=e.packages}static create(e,t=0){let s=R.generateId(t);return R.fromData(s,e)}static fromJson(e){return R.fromData(e.id,e)}static mergeAll(e){let[t,...s]=e;if(!t)throw Error("No stones to merge");if(s.length===0)return t;let i=e.map((n)=>n.message).join("; ");return R.merge(e,i).stone}static merge(e,t){let s=new Map,i=[];for(let g of e)R.collectBumps(g,"major",s,i),R.collectBumps(g,"minor",s,i),R.collectBumps(g,"patch",s,i),R.collectBumps(g,"dependency",s,i);let n=R.categorizeBumps(s),r=e.map((g)=>g.description).filter(Boolean).join(`
|
|
107
107
|
|
|
108
|
-
`),o=e.flatMap((
|
|
108
|
+
`),o=e.flatMap((g)=>g.commits??[]),a=[...new Set(e.map((g)=>g.tag).filter(Boolean))],l=`merged-${Date.now()}`,u=new R({commits:o.length>0?o:void 0,description:r||void 0,id:l,message:t,packages:n,tag:a[0]});return{conflicts:[...new Set(i)],stone:u}}static collectBumps(e,t,s,i){for(let n of e.getPackages(t)){let r=s.get(n);if(!r){s.set(n,t);continue}if(r===t)continue;i.push(n);let o=Ai(t,r);if(o!==r)s.set(n,o)}}static categorizeBumps(e){let t=new Map;for(let s of $e)t.set(s,[]);for(let[s,i]of e)t.get(i)?.push(s);return t}static fromData(e,t){let s=new Map;return s.set("major",t.major??[]),s.set("minor",t.minor??[]),s.set("patch",t.patch??[]),s.set("dependency",t.dependency??[]),s.set("snapshot",t.snapshot??[]),new R({commits:t.commits,description:t.description,id:e,message:t.message,packages:s,tag:t.tag})}static generateId(e){let t=String(e+1).padStart(Ci,"0"),s=Hr().slice(0,Si);return`${t}-${s}`}get major(){return this._packages.get("major")??[]}get minor(){return this._packages.get("minor")??[]}get patch(){return this._packages.get("patch")??[]}get dependency(){return this._packages.get("dependency")??[]}get snapshot(){return this._packages.get("snapshot")??[]}get allPackages(){let e=[];for(let t of this._packages.values())e.push(...t);return e}get isEmpty(){return this.allPackages.length===0}affectsPackage(e){return this.allPackages.includes(e)}getPackages(e){return this._packages.get(e)??[]}withMessage(e){return new R({...this.toOptions(),message:e})}withTag(e){return new R({...this.toOptions(),tag:e})}withDescription(e){return new R({...this.toOptions(),description:e})}withCommits(e){return new R({...this.toOptions(),commits:e})}withPackages(e,t){let s=new Map(this._packages);return s.set(e,t),new R({...this.toOptions(),packages:s})}toOptions(){return{commits:this.commits,description:this.description,id:this.id,message:this.message,packages:new Map(this._packages),tag:this.tag}}toJson(){return{commits:this.commits&&this.commits.length>0?this.commits:void 0,dependency:H(this.dependency),description:this.description,id:this.id,major:H(this.major),message:this.message,minor:H(this.minor),patch:H(this.patch),snapshot:H(this.snapshot),tag:this.tag}}}import{readFile as Jr,rm as Kr,writeFile as Oi}from"fs/promises";import{dirname as zr,join as Yr}from"path";var Wr={bitbucket:"commits",github:"commit",gitlab:"-/commit"},qr={bitbucket:"bitbucket.org",github:"github.com",gitlab:"gitlab.com"};class Ue{cached=void 0;async getRemoteInfo(){if(this.cached!==void 0)return this.cached;let e=await zt();if(!e)return this.cached=null,null;let t=Yt(e);if(!t)return this.cached=null,null;let s=qr[t.provider],i=Wr[t.provider],n=`https://${s}/${t.owner}/${t.repo}`;return this.cached={...t,commitUrl:(r)=>`${n}/${i}/${r}`},this.cached}}class we{config;originals=new Map;remoteParser=new Ue;commitUrlFn=null;constructor(e){this.config=e}async generate(e,t){await this.initCommitLinks();let s=new Map(t.map((i)=>[i.name,i]));for(let i of t){let n=this.filterStonesForPackage(e,i.name),r=this.getBumpedDependencies(e,i.name,s);await this.generateForPackage(n,i,r)}if(this.config.root)await this.generateRoot(e,t)}async initCommitLinks(){let e=await this.remoteParser.getRemoteInfo();this.commitUrlFn=e?.commitUrl??null}getBumpedDependencies(e,t,s){let i=new Set;for(let n of e){if(!n.dependency.includes(t))continue;for(let r of[...n.major,...n.minor,...n.patch])i.add(r)}return[...i].map((n)=>s.get(n)).filter((n)=>n!==void 0)}filterStonesForPackage(e,t){return e.filter((s)=>this.hasDirectChanges(s,t))}hasDirectChanges(e,t){return e.major.includes(t)||e.minor.includes(t)||e.patch.includes(t)}async rollback(){for(let[e,t]of this.originals)if(t===null)await Kr(e,{force:!0});else await Oi(e,t,"utf-8");this.originals.clear()}async generateForPackage(e,t,s){let i=Yr(zr(t.file),this.config.filename),n=this.formatEntry(e,t,s);await this.prependToChangelog(i,n,t.name)}async generateRoot(e,t){let s=this.config.filename,i=this.formatRootEntry(e,t);await this.prependToChangelog(s,i,"Changelog")}async prependToChangelog(e,t,s){let i=await this.readExisting(e);this.originals.set(e,i);let n=i?this.extractTitle(i):`# ${s}`,r=i?this.extractRest(i):"",o=`${n}
|
|
109
109
|
|
|
110
|
-
${t}${
|
|
110
|
+
${t}${r?`
|
|
111
111
|
|
|
112
|
-
${
|
|
113
|
-
`;await
|
|
112
|
+
${r}`:""}
|
|
113
|
+
`;await Oi(e,o,"utf-8")}async readExisting(e){try{return await Jr(e,"utf-8")}catch{return null}}extractTitle(e){let t=e.split(`
|
|
114
114
|
`)[0]??"";return t.startsWith("#")?t:"# Changelog"}extractRest(e){let t=e.split(`
|
|
115
|
-
`);if(!(t[0]??"").startsWith("#"))return e;let
|
|
116
|
-
`).trim()}formatEntry(e,t,
|
|
117
|
-
`)}formatRootEntry(e,t){let
|
|
118
|
-
`)}formatPackageHeader(e){let t=e.newVersion??e.version,
|
|
115
|
+
`);if(!(t[0]??"").startsWith("#"))return e;let i=1;while(i<t.length&&t[i]?.trim()==="")i++;return t.slice(i).join(`
|
|
116
|
+
`).trim()}formatEntry(e,t,s){let i=this.formatPackageHeader(t),n=s.length>0,r=[`## ${i}`];for(let o of e)r.push("",`### ${Kt} ${o.message}`),r.push("",this.formatStoneContent(o,t.name));if(n){r.push("",`### ${this.config.sections.dependencies}`);for(let o of s)r.push(`- \`${o.name}\` ${o.version} \u2192 ${o.newVersion}`)}return r.join(`
|
|
117
|
+
`)}formatRootEntry(e,t){let i=[`## ${this.formatRootHeader(t)}`];i.push("","**Packages**");for(let n of t){let r=this.getEmoji(n),o=n.newVersion?`${n.version} \u2192 ${n.newVersion}`:n.version;i.push(`- ${r} \`${n.name}\` ${o}`)}for(let n of e)i.push("",`### ${Kt} ${n.message}`),i.push(this.formatStonePackages(n)),i.push("",this.formatRootStoneContent(n));return i.join(`
|
|
118
|
+
`)}formatPackageHeader(e){let t=e.newVersion??e.version,s=this.getDate(),i=this.getEmoji(e);return this.config.packageHeader.replace("{emoji}",()=>i).replace("{version}",()=>t).replace("{date}",()=>s)}formatRootHeader(e){let t=this.getDate(),s=e.map((i)=>`${i.name}@${i.newVersion??i.version}`).join(", ");return this.config.rootHeader.replace("{date}",()=>t).replace("{packages}",()=>s)}formatRootStoneContent(e){let t=[];if(e.description)t.push(this.formatDescription(e.description));if(e.commits?.length){let s=!this.isSectionName(e.message);t.push(this.formatRootCommits(e.commits,s))}return t.join(`
|
|
119
119
|
|
|
120
|
-
`)}formatRootCommits(e,t){let
|
|
120
|
+
`)}formatRootCommits(e,t){let s=this.formatCommits(e,t);return`<details>
|
|
121
121
|
<summary>Commits (${e.length})</summary>
|
|
122
122
|
|
|
123
|
-
${
|
|
123
|
+
${s}
|
|
124
124
|
|
|
125
|
-
</details>`}formatStonePackages(e){let t=[...e.major,...e.minor,...e.patch];if(t.length===0)return"";return`**Packages:** ${t.map((
|
|
125
|
+
</details>`}formatStonePackages(e){let t=[...e.major,...e.minor,...e.patch];if(t.length===0)return"";return`**Packages:** ${t.map((i)=>`\`${i}\``).join(" \xB7 ")}`}formatStoneContent(e,t){let s=[];if(e.description)s.push(this.formatDescription(e.description));let i=t&&e.commits?this.filterCommitsForPackage(e.commits,t):e.commits??[];if(i.length>0){let n=!this.isSectionName(e.message);s.push(this.formatCommits(i,n))}return s.join(`
|
|
126
126
|
|
|
127
127
|
`)}isSectionName(e){return Object.values(this.config.sections).includes(e)}formatDescription(e){return`<details>
|
|
128
128
|
<summary>Description</summary>
|
|
129
129
|
|
|
130
130
|
${this.convertHeadersToBold(e).split(`
|
|
131
|
-
`).map((
|
|
131
|
+
`).map((i)=>` ${i}`).join(`
|
|
132
132
|
`)}
|
|
133
|
-
</details>`}convertHeadersToBold(e){return e.replace(/^#{1,6}\s+(.+)$/gm,"**$1**")}getDate(){return new Date().toISOString().split("T")[0]??""}getEmoji(e){return e.bump?
|
|
134
|
-
`);let
|
|
135
|
-
`))}return
|
|
133
|
+
</details>`}convertHeadersToBold(e){return e.replace(/^#{1,6}\s+(.+)$/gm,"**$1**")}getDate(){return new Date().toISOString().split("T")[0]??""}getEmoji(e){return e.bump?_e[e.bump]:"\uD83D\uDCE6"}filterCommitsForPackage(e,t){return e.filter((s)=>s.packages.includes(t))}formatCommits(e,t){if(!t)return e.map((n)=>this.formatCommitLine(n)).join(`
|
|
134
|
+
`);let s=this.groupCommitsByType(e),i=[];for(let[n,r]of s){let o=this.config.sections[n]??`${n} changes`;i.push(`#### ${o}`),i.push(r.map((a)=>this.formatCommitLine(a)).join(`
|
|
135
|
+
`))}return i.join(`
|
|
136
136
|
|
|
137
|
-
`)}groupCommitsByType(e){let t=new Map;for(let
|
|
138
|
-
`).map((
|
|
139
|
-
`);return`${
|
|
137
|
+
`)}groupCommitsByType(e){let t=new Map;for(let s of e){let i=t.get(s.type)??[];i.push(s),t.set(s.type,i)}return Array.from(t.entries()).sort(([s],[i])=>(xe[s]??Ie)-(xe[i]??Ie))}formatCommitLine(e){let s=`- ${this.commitUrlFn?`[\`${e.hash}\`](${this.commitUrlFn(e.hash)})`:`\`${e.hash}\``} ${e.subject}`;if(e.body){let i=e.body.split(`
|
|
138
|
+
`).map((n)=>` ${n}`).join(`
|
|
139
|
+
`);return`${s}
|
|
140
140
|
<details>
|
|
141
141
|
<summary>Details</summary>
|
|
142
142
|
|
|
143
|
-
${
|
|
144
|
-
</details>`}return
|
|
145
|
-
`),
|
|
146
|
-
`).trim()}}catch{return null}}async parseConfig(){try{let e=
|
|
147
|
-
`),
|
|
148
|
-
`).trim()||void 0,major:
|
|
149
|
-
`;await
|
|
150
|
-
`
|
|
151
|
-
`).filter(Boolean)}catch{return
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
`);n.
|
|
155
|
-
`)
|
|
156
|
-
`);return
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
[
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
${c.green("Release PR
|
|
163
|
-
`)}
|
|
164
|
-
`)}
|
|
165
|
-
`)}
|
|
143
|
+
${i}
|
|
144
|
+
</details>`}return s}}import{readdir as Di,readFile as Bi}from"fs/promises";import{join as ss}from"path";var Xr=".changeset",Zr="config.json";class is{root;constructor(e=process.cwd()){this.root=e}get changesetDir(){return ss(this.root,Xr)}async exists(){try{return await Di(this.changesetDir),!0}catch{return!1}}async parse(){let e=[],t=[],s=await this.findChangesetFiles();for(let n of s){let r=await this.parseFile(n);if(r)t.push(r);else e.push(`Failed to parse: ${n}`)}let i=await this.parseConfig();return{changesets:t,config:i,errors:e}}async findChangesetFiles(){try{return(await Di(this.changesetDir)).filter((t)=>t.endsWith(".md")&&t!=="README.md").map((t)=>ss(this.changesetDir,t))}catch{return[]}}async parseFile(e){try{let s=(await Bi(e,"utf-8")).split(`
|
|
145
|
+
`),i=!1,n=[],r=[];for(let l of s)if(l.trim()==="---")i=!i;else if(i)n.push(l);else if(n.length>0)r.push(l);let o={};for(let l of n){let u=l.match(/^"(.+)":\s*(major|minor|patch)$/);if(u?.[1]&&u[2])o[u[1]]=u[2]}if(Object.keys(o).length===0)return null;return{filename:e.split("/").pop()??"",packages:o,summary:r.join(`
|
|
146
|
+
`).trim()}}catch{return null}}async parseConfig(){try{let e=ss(this.changesetDir,Zr),t=await Bi(e,"utf-8");return JSON.parse(t)}catch{return null}}toStoneData(e){let t=[],s=[],i=[];for(let[a,l]of Object.entries(e.packages))switch(l){case"major":t.push(a);break;case"minor":s.push(a);break;case"patch":i.push(a);break}let n=e.summary.split(`
|
|
147
|
+
`),r=n[0]?.trim()||"Migrated from changeset";return{description:n.slice(1).join(`
|
|
148
|
+
`).trim()||void 0,major:H(t),message:r,minor:H(s),patch:H(i)}}}function vt(e){let t=new Map;for(let[s,i]of e){let n=i.file.replace(/\\/g,"/"),r=n.substring(0,n.lastIndexOf("/"))||".";t.set(r,s)}return t}function Ee(e,t){let s=new Set;for(let i of e){let n=t.get(i);if(n?.dependencyOf){for(let r of n.dependencyOf)if(!e.includes(r))s.add(r)}}return Array.from(s)}function Ve(e,t,s=!0){let i=new Set;for(let n of e)for(let[r,o]of t){let a=r===".",l=n.startsWith(`${r}/`);if(a?s:l)i.add(o)}return i}import{existsSync as ve}from"fs";import{mkdir as Fi,readdir as ns,readFile as ji,rename as Qr,unlink as eo,writeFile as to}from"fs/promises";import{join as Pe}from"path";class k{config;constructor(e){this.config=e}get sisyphusDir(){return this.config.get("sisyphusDir")||mt}get stonesPath(){return this.config.get("stonesPath")||Pe(this.sisyphusDir,bi)}get releasedPath(){return Pe(this.sisyphusDir,$i)}async list(){let e=await this.listIds(),t=[];for(let s of e){let i=await this.get(s);if(i)t.push(i)}return t}async listIds(){return await this.ensureStorageExists(),(await ns(this.stonesPath)).filter((t)=>t.endsWith(".json")).map((t)=>t.replace(".json","")).sort()}async get(e){let t=this.getFilePath(e);if(!ve(t))return null;try{let s=await ji(t,"utf-8"),i=JSON.parse(s);return R.fromJson(i)}catch{return null}}async exists(e){return ve(this.getFilePath(e))}async save(e){await this.ensureStorageExists();let t=this.getFilePath(e.id),s=JSON.stringify(e.toJson(),null,2);await to(t,s,"utf-8"),this.addToConfigStones(e.id)}async delete(e){let t=this.getFilePath(e);if(!ve(t))return!1;return await eo(t),this.removeFromConfigStones(e),!0}async deleteMany(e){let t=0;for(let s of e)if(await this.delete(s))t++;return t}async create(e){let t=await this.listIds(),s=R.create(e,t.length);return await this.save(s),s}async count(){return(await this.listIds()).length}async archive(e){if(e.length===0)return"";let t=this.createTimestamp(),s=Pe(this.releasedPath,t);await Fi(s,{recursive:!0});for(let i of e){let n=this.getFilePath(i.id),r=Pe(s,`${i.id}.json`);if(ve(n))await Qr(n,r),this.removeFromConfigStones(i.id)}return t}async getReleasedStones(e){let t=Pe(this.releasedPath,e);if(!ve(t))return[];let s=await ns(t),i=[];for(let n of s){if(!n.endsWith(".json"))continue;try{let r=await ji(Pe(t,n),"utf-8"),o=JSON.parse(r);i.push(R.fromJson(o))}catch(r){m.warn(c.dim(`Failed to parse stone "${n}": ${r}`))}}return i}async listReleasedTimestamps(){if(!ve(this.releasedPath))return[];return(await ns(this.releasedPath,{withFileTypes:!0})).filter((t)=>t.isDirectory()).map((t)=>t.name)}async getAllTrackedCommitHashes(){let t=(await this.list()).flatMap((s)=>s.commits??[]).map((s)=>s.hash);return new Set(t)}async listAllStones(){let e=await this.list(),t=await this.listReleasedTimestamps(),s=await Promise.all(t.map((i)=>this.getReleasedStones(i)));return[...e,...s.flat()]}getFilePath(e){return Pe(this.stonesPath,`${e}.json`)}createTimestamp(){return new Date().toISOString().replace(/[:.]/g,"-")}async ensureStorageExists(){if(!ve(this.stonesPath))await Fi(this.stonesPath,{recursive:!0})}addToConfigStones(e){let t=this.config.getAll();if(!t.stones.includes(e))this.config.set("stones",[...t.stones,e])}removeFromConfigStones(e){let t=this.config.getAll(),s=t.stones.filter((i)=>i!==e);if(s.length!==t.stones.length)this.config.set("stones",s)}}class S{static async scan(e={}){let{filter:t,single:s}=e;if(s)return S.scanRootPackage();let i=await S.getWorkspaces();S.validateWorkspaces(i);let n=await S.scanWorkspaces(i);return{packageNames:S.filterNames(Array.from(n.keys()),t),packages:n}}static async getWorkspaces(){try{let t=(await Bun.file("package.json").json())?.workspaces;if(Array.isArray(t))return t;return t?.packages||[]}catch{throw new d("Could not read package.json","Ensure you're in a project root directory.")}}static validateWorkspaces(e){if(e.length===0)throw new d("No workspaces found in package.json.","Use --single flag or set `single: true` in config for single-package mode.")}static filterNames(e,t){if(!t)return e;return e.filter((s)=>s.includes(t))}static async scanRootPackage(){let e=await Bun.file("package.json").json(),t=ee.fromJson(e,"package.json"),s=new Map;return s.set(t.name,t),{packageNames:[t.name],packages:s}}static async scanWorkspaces(e){let t=new Map,s=new Map;for(let i of e){let n=new Bun.Glob(`${i}/package.json`).scanSync({cwd:process.cwd()});for(let r of n){let o=await S.processPackageFile(r,s);if(o)t.set(o.name,o)}}return S.linkDependencies(t,s),t}static async processPackageFile(e,t){let s=await Bun.file(e).json(),i=ee.fromJson(s,e);return S.trackDependencies(i.name,s,t),i}static trackDependencies(e,t,s){let i={...t.dependencies,...t.devDependencies};for(let[n,r]of Object.entries(i)){if(!r?.startsWith("workspace"))continue;let o=s.get(n)||[];if(!o.includes(e))s.set(n,[...o,e])}}static linkDependencies(e,t){for(let[s,i]of t){let n=e.get(s);if(n)e.set(s,n.withDependencyOf(i))}}}var so={build:"patch",chore:"patch",ci:"patch",docs:"patch",feat:"minor",fix:"patch",perf:"patch",refactor:"patch",style:"patch",test:"patch",[fe]:"patch"};class Ce{config;stoneManager;constructor(e){this.config=e;this.stoneManager=new k(e)}async analyze(e={}){let t=await this.getCommitsSinceLastRelease();if(t.length===0)return[];let s=await this.stoneManager.getAllTrackedCommitHashes();if(s.size>0){if(t=t.filter((n)=>!s.has(n.shortHash)),t.length===0)return[]}let i=this.config.get("commits")?.skip??Te.commits.skip;if(t=t.filter((n)=>!this.shouldSkipCommit(n,i)),t.length===0)return[];return this.groupByPackage(t,e)}shouldSkipCommit(e,t){if(t.authors.includes(e.author))return!0;for(let s of t.messagePatterns)try{if(new RegExp(s,"i").test(e.subject))return!0}catch{m.warn(c.yellow(`Invalid regex pattern in commits.skip.messagePatterns: "${s}"`))}return!1}get commitCount(){return this.getCommitsSinceLastRelease().then((e)=>e.length)}async getCommitsSinceLastRelease(){let t=this.config.get("lastStone")?.commit||void 0;if(!t)return[];return G.since(t)}async groupByPackage(e,t){let{packages:s}=await S.scan({filter:t.filter,single:t.single}),i=vt(s),n=new Map;for(let r of e){let o=Ve(r.files,i);if(o.size===0)continue;let a=r.breaking?"major":so[r.type]||"patch",l=`${r.type}${r.breaking?"!":""}`,u=n.get(l);if(!u){let g=this.getGroupMessage(r);u={bump:a,commits:[],message:g,packages:new Set},n.set(l,u)}u.commits.push(r.toInfo([...o]));for(let g of o)u.packages.add(g)}return Array.from(n.entries()).filter(([,r])=>r.packages.size>0).sort(([r],[o])=>(xe[r]??Ie)-(xe[o]??Ie)).map(([,r])=>r)}getGroupMessage(e){let t=this.config.get("changelog").sections;if(e.breaking)return t.breaking;return t[e.type]??`${e.type} updates`}static buildStoneData(e,t,s){let i=Array.from(e.packages),n=e.commits.length>0?e.commits:void 0,r=Ee(i,t);return{[e.bump]:i,commits:n,dependency:r.length>0?r:void 0,message:e.message,tag:s}}}import{readFile as io,writeFile as Ni}from"fs/promises";class He{originals=new Map;async updateAll(e){this.originals.clear();for(let t of e)await this.updatePackage(t)}async rollback(){for(let[e,t]of this.originals)await Ni(e,t,"utf-8");this.originals.clear()}async updatePackage(e){let t=e.newVersion;if(!t)return;let s=await io(e.file,"utf-8");this.originals.set(e.file,s);let i=JSON.parse(s);i.version=t;let n=this.detectIndent(s),r=`${JSON.stringify(i,null,n)}
|
|
149
|
+
`;await Ni(e.file,r,"utf-8")}detectIndent(e){let t=e.match(/^[\t ]+/m);return t?t[0]:2}}var Li="catalog:",Gi="workspace:",Ui="default",no=2,ro=new Set(["*","^","~"]);function Vi(e){let t=Array.isArray(e.workspaces)?void 0:e.workspaces,s={[Ui]:{...e.catalog,...t?.catalog}};return Object.assign(s,e.catalogs,t?.catalogs),s}function Hi(e){let t={};for(let s of e)t[s.name]={isPrivate:s.isPrivate,version:s.version||null};return t}function oo(e,t,s,i){let n=t.slice(Li.length)||Ui,r=s[n]?.[e];if(!r)throw new d(`Catalog "${n}" has no entry for "${e}" (required by ${i})`,"Add the entry to the root package.json catalog before publishing");return r}function ao(e,t,s,i){let n=t.slice(Gi.length),r=s[e];if(!r)throw new d(`Workspace package "${e}" (required by ${i}) was not found in the workspace`,"Check the dependency name against your workspaces globs");if(r.isPrivate)throw new d(`"${i}" depends on private workspace package "${e}", which is not published to the registry`,`Move "${e}" to devDependencies (bundled CLIs do not need it at runtime) or publish it first`);if(!ro.has(n)){if(!n)throw new d(`Invalid workspace specifier "${t}" for "${e}" (required by ${i})`,"Use workspace:*, workspace:^, workspace:~, or workspace:<range>");return n}let o=r.version;if(!o)throw new d(`Workspace package "${e}" (required by ${i}) has no version in its package.json`,"Add a version field before publishing");return n==="*"?o:`${n}${o}`}function rs(e,t,s,i){if(!e)return e;let n={};for(let[r,o]of Object.entries(e))if(o.startsWith(Li))n[r]=oo(r,o,t,i);else if(o.startsWith(Gi))n[r]=ao(r,o,s,i);else n[r]=o;return n}function co(e,t,s){let{devDependencies:i,...n}=e;return{...n,dependencies:rs(e.dependencies,t,s,e.name),optionalDependencies:rs(e.optionalDependencies,t,s,e.name),peerDependencies:rs(e.peerDependencies,t,s,e.name)}}function Wi(e,t,s){let i=JSON.parse(e),n=co(i,t,s),r=lo(e);return`${JSON.stringify(n,null,r)}
|
|
150
|
+
`}function lo(e){let t=e.match(/^[\t ]+/m);return t?t[0]:no}class os{config;provider=null;constructor(e){this.config=e}async analyze(e){let t=await this.getProvider(),s=e?await this.fetchFromUrl(t,e):await this.fetchFromCurrentBranch(t),i=this.config.get("single"),{packages:n}=await S.scan({single:i}),r=vt(n),o={isSinglePackage:i,packagePaths:r,provider:t,url:e},{commits:a,affectedPackages:l}=s.merged?await this.analyzeAfterMerge(s,o):await this.analyzeBeforeMerge(s,o),u=this.inferBumpFromLabels(s.labels)??this.inferBumpFromTitle(s.title);return{commits:a,packages:l,pr:s,suggestedBump:u}}async analyzeBeforeMerge(e,t){let s=await G.inRange(e.baseBranch,e.branch);return this.processCommits(s,t)}async analyzeAfterMerge(e,t){if(await this.detectMergeMethod(e.mergeCommitSha)==="squash")return this.analyzeSquashMerge(e,t);return this.analyzeMergeCommit(e,t)}async analyzeSquashMerge(e,t){let s=t.url?await this.fetchFilesFromApi(t.provider,t.url):await this.getFilesFromCommit(e.mergeCommitSha),i=Ve(s,t.packagePaths,t.isSinglePackage),n={body:e.body||void 0,hash:e.mergeCommitSha?.slice(0,gt)??wi,message:e.title,packages:[...i],subject:e.title,type:this.inferCommitType(e.title)};return{affectedPackages:i,commits:[n]}}async analyzeMergeCommit(e,t){if(!e.mergeCommitSha)return{affectedPackages:new Set,commits:[]};let s=await G.fromMerge(e.mergeCommitSha);return this.processCommits(s,t)}processCommits(e,t){let s=[],i=new Set;for(let n of e){let r=Ve(n.files,t.packagePaths,t.isSinglePackage);if(r.size===0)continue;s.push(n.toInfo([...r]));for(let o of r)i.add(o)}return{affectedPackages:i,commits:s}}async detectMergeMethod(e){if(!e)return"squash";if(await this.getCommitParentCount(e)===2)return"merge";return"squash"}async getCommitParentCount(e){try{let t=await Bun.$`git rev-parse ${e}^@`.quiet().nothrow();if(t.exitCode!==0)return 1;return t.stdout.toString().trim().split(`
|
|
151
|
+
`).filter(Boolean).length}catch{return 1}}inferCommitType(e){return e.match(/^(\w+)(?:\(.*?\))?!?:/)?.[1]??fe}async getProvider(){if(!this.provider)this.provider=await Me();return this.provider}async fetchFilesFromApi(e,t){let s=Xt(t);if(!s)return[];return e.getPrFiles(s.number)}async fetchFromCurrentBranch(e){let t=await e.getPrFromCurrentBranch();return this.mapPullRequest(t)}async fetchFromUrl(e,t){let s=Xt(t);if(!s)throw new d("Invalid PR URL","Expected a PR/MR URL from GitHub, GitLab, or Bitbucket");if(s.provider!==e.name)throw new d(`PR URL is from ${s.provider}, but repository is on ${e.name}`,"Make sure the PR URL matches the repository provider");let i=await e.getPr(s.number);return this.mapPullRequest(i)}mapPullRequest({headBranch:e,...t}){return{...t,branch:e}}inferBumpFromLabels(e){let t=this.config.get("pr").labelMapping;for(let s of e){let i=s.toLowerCase();for(let[n,r]of Object.entries(t))if(i===n.toLowerCase())return r}return null}inferBumpFromTitle(e){let t=e.toLowerCase();if(t.includes("breaking")||e.includes("!:"))return"major";if(t.includes("feat")||t.includes("feature"))return"minor";if(t.includes("fix")||t.includes("bug"))return"patch";return null}async getFilesFromCommit(e){if(!e)return[];try{return(await Bun.$`git diff-tree --no-commit-id --name-only -r ${e}`.quiet()).stdout.toString().trim().split(`
|
|
152
|
+
`).filter(Boolean)}catch{return[]}}}import{readFile as uo,writeFile as qi}from"fs/promises";import{dirname as Ji,join as po}from"path";class Pt{config;packageUpdater=new He;changelogGenerator;remoteParser=new Ue;provider=null;commitUrlFn=null;options;createdTags=[];createdReleases=[];commitCreated=!1;pushedToRemote=!1;publishContext=null;constructor(e,t){this.config=e;this.options=t,this.changelogGenerator=new we(this.config.get("changelog"))}async getProvider(){if(!this.provider)this.provider=await Me();return this.provider}async initCommitLinks(){if(this.commitUrlFn!==null)return;let e=await this.remoteParser.getRemoteInfo();this.commitUrlFn=e?.commitUrl??null}async preflight(e){if(this.options.dryRun)return;if(await this.hasStagedChanges())throw new d("You have staged changes","Commit or stash them before running roll");let s=await this.getDirtyPackageFiles(e);if(s.length>0)throw new d("Package files have uncommitted changes",`Commit or stash changes in:
|
|
153
|
+
${s.join(`
|
|
154
|
+
`)}`)}async updatePackageVersions(e){if(this.options.dryRun)return;await this.packageUpdater.updateAll(e)}async generateChangelogs(e,t){if(this.options.dryRun)return;await this.changelogGenerator.generate(e,t)}async createCommit(e,t){if(this.options.dryRun)return;let s=t.map((l)=>l.file),i=this.getChangelogFiles(t),n=this.config.get("sisyphusDir"),r=[...s,...i,n],o=this.formatCommitMessage(e,t),a=this.getCommitAuthorArg();await this.run(()=>Bun.$`git add -A -- ${r}`.quiet(),"Failed to stage files"),await this.run(()=>Bun.$`git commit ${a} -m ${o}`.env(this.getCommitterEnv()).quiet(),"Failed to create commit"),this.commitCreated=!0}getCommitAuthorArg(){let{author:e,email:t}=this.config.get("commit");if(!e)return[];return["--author",t?`${e} <${t}>`:e]}getCommitterEnv(){let{author:e,email:t}=this.config.get("commit"),s={...process.env};if(!e)return s;if(s.GIT_COMMITTER_NAME=e,t)s.GIT_COMMITTER_EMAIL=t;return s}getChangelogFiles(e){let t=this.config.get("changelog").filename,s=e.map((i)=>po(Ji(i.file),t));if(this.config.get("changelog").root)s.push(t);return s}async createGitTags(e){if(this.options.dryRun)return;for(let t of e){let s=t.newVersion??t.version,i=`${t.name}@${s}`;await this.run(()=>Bun.$`git tag ${i}`.quiet(),`Failed to create tag ${i}`),this.createdTags.push(i)}}async publishToNpm(e){if(this.options.dryRun)return;for(let t of e){if(t.isPrivate){m.info(c.dim(`Skipping ${t.name} (private)`));continue}await this.publishPackage(t)}}async pushToRemote(){if(this.options.dryRun)return;if(await this.run(()=>Bun.$`git push`.quiet(),"Failed to push commits"),this.createdTags.length>0)await this.pushTags();this.pushedToRemote=!0}async pushTags(){if(this.options.dryRun)return;if(this.createdTags.length===0)return;await this.run(()=>Bun.$`git push --tags`.quiet(),"Failed to push tags")}async createGitRelease(e,t){if(this.options.dryRun)return;await this.initCommitLinks();let s=await this.getProvider();for(let i of t){let n=i.newVersion??i.version,r=`${i.name}@${n}`,o=`${i.name} v${n}`,a=this.filterStonesForPackage(e,i.name),l=this.formatReleaseNotes(a,i);await this.run(()=>s.createRelease({notes:l,tag:r,title:o}),`Failed to create release for ${r}`),this.createdReleases.push(r)}}filterStonesForPackage(e,t){return e.filter((s)=>s.affectsPackage(t))}formatReleaseNotes(e,t){let s=[],i=t.newVersion??t.version;if(s.push(`\`${t.name}\` ${t.version} \u2192 ${i}`),e.length===0)return s.join(`
|
|
155
|
+
`);s.push(""),s.push("<details>"),s.push(`<summary>Stones (${e.length})</summary>`),s.push("");for(let n of e){if(s.push(`### ${n.message}`),s.push(""),n.description)s.push(n.description),s.push("");let r=this.filterCommitsForPackage(n.commits,t.name);if(r.length>0){s.push("<details>"),s.push(`<summary>Commits (${r.length})</summary>`),s.push("");for(let o of r)s.push(this.formatCommitLine(o));s.push(""),s.push("</details>"),s.push("")}}return s.push("</details>"),s.join(`
|
|
156
|
+
`)}filterCommitsForPackage(e,t){if(!e)return[];return e.filter((s)=>s.packages.includes(t))}formatCommitLine(e){return`- ${this.commitUrlFn?`[\`${e.hash}\`](${this.commitUrlFn(e.hash)})`:`\`${e.hash}\``} ${e.subject}`}async rollback(){if(this.createdReleases.length>0){let e=await this.getProvider();for(let t of this.createdReleases)await e.deleteRelease(t)}if(this.createdReleases=[],this.pushedToRemote)for(let e of this.createdTags)try{await Bun.$`git push origin --delete ${e}`.quiet()}catch(t){m.warn(c.dim(`Failed to delete remote tag "${e}": ${t}`))}for(let e of this.createdTags)try{await Bun.$`git tag -d ${e}`.quiet()}catch(t){m.warn(c.dim(`Failed to delete local tag "${e}": ${t}`))}if(this.createdTags=[],this.commitCreated){try{await Bun.$`git reset HEAD~1`.quiet()}catch(e){m.warn(c.dim(`Failed to reset commit: ${e}`))}this.commitCreated=!1}await this.changelogGenerator.rollback(),await this.packageUpdater.rollback()}async publishPackage(e){let t=this.config.get("tag")||Pi,s=Ji(e.file);await this.run(()=>Bun.$`bun run build`.cwd(s).quiet(),`Failed to build ${e.name}`);let i=await uo(e.file,"utf-8");try{let{catalogs:n,workspaceVersions:r}=await this.getPublishContext();await qi(e.file,Wi(i,n,r),"utf-8"),await this.run(()=>Bun.$`npm publish --tag ${t} --access public`.cwd(s).quiet(),`Failed to publish ${e.name}`)}finally{await qi(e.file,i,"utf-8")}}async getPublishContext(){if(!this.publishContext){let e=await Bun.file("package.json").json(),{packages:t}=await S.scan({single:this.config.get("single")});this.publishContext={catalogs:Vi(e),workspaceVersions:Hi(t.values())}}return this.publishContext}formatCommitMessage(e,t){let s=this.config.get("commit").message,i=t.map((r)=>`- ${r.name}@${r.newVersion??r.version}`).join(`
|
|
157
|
+
`);return`${s.replace("{message}",()=>e.message).replace("{packages}",()=>t.map((r)=>r.name).join(", "))}
|
|
158
|
+
|
|
159
|
+
${i}`}async hasStagedChanges(){try{return(await Bun.$`git diff --cached --name-only`.quiet()).stdout.toString().trim().length>0}catch{return!1}}async getDirtyPackageFiles(e){let t=[];for(let s of e)try{if((await Bun.$`git status --porcelain ${s.file}`.quiet()).stdout.toString().trim().length>0)t.push(s.file)}catch{}return t}async run(e,t){try{await e()}catch(s){let i=this.getStderr(s)??(s instanceof Error?s.message:void 0);throw Error(i?`${t}: ${i}`:t)}}getStderr(e){if(e&&typeof e==="object"&&"stderr"in e){let t=e.stderr;if(t instanceof Buffer)return t.toString().trim();if(typeof t==="string")return t.trim()}return}}var Ct="sisyphus/release",as="sisyphus-release",mo="Sisyphus release PR",go="6f42c1",Ki="chore(release):",ho=M({dryRun:{alias:"d",default:!1,description:"Preview without making changes",type:"boolean"}});class cs extends I{name="release-pr";description="Create or update a release PR from pending stones";args=ho;provider=null;async getProvider(){if(!this.provider)this.provider=await Me();return this.provider}async execute(e){let t=await this.checkoutReleaseBranch();try{let{stones:s,packages:i}=await this.collectReleaseData(e);if(s.length===0){m.info(c.dim("No pending stones found, skipping release PR"));return}let n=this.buildPrTitle(i),r=this.buildPrBody(i,s);if(m.info(`${c.bold("Release PR:")} ${n}`),m.info(`${c.dim("Packages:")} ${i.map((o)=>o.name).join(", ")}`),e.args.dryRun){m.info(c.yellow(`
|
|
160
|
+
[dry-run] Would create/update release PR`)),m.info(c.dim(`
|
|
161
|
+
PR Body preview:`)),m.info(r);return}await this.commitAndPushChanges(e,s,i),await this.createOrUpdatePr(n,r)}finally{await this.restoreMainBranch(t)}}async checkoutReleaseBranch(){let t=await(await this.getProvider()).getDefaultBranch();return await Bun.$`git fetch origin ${t}`,await this.stashChanges(),await Bun.$`git checkout -B ${Ct} origin/${t}`,t}async collectReleaseData(e){let t=new k(e.config),s=await this.generateStonesFromCommits(e,t,e.args.dryRun),i=await t.list(),n=e.args.dryRun?[...i,...s]:i;if(n.length===0)return{packages:[],stones:[]};let{packages:r}=await S.scan({single:e.config.get("single")}),o=R.mergeAll(n),a=ee.applyStone(o,r);if(a.length===0)throw new d("No packages to update","Stones don't reference any known packages");return{packages:a,stones:n}}async commitAndPushChanges(e,t,s){let i=K();i.start("Applying release changes...");let n=await this.applyReleaseChanges(e,t,s);for(let o of n)await Bun.$`git add ${o}`.nothrow();if((await Bun.$`git diff --cached --quiet`.nothrow()).exitCode!==0)await Bun.$`git commit -m ${`${Ki} prepare release`}`;await Bun.$`git push origin ${Ct} --force`,i.stop("Release branch ready")}async createOrUpdatePr(e,t){let s=K(),i=await this.findExistingReleasePr();if(i)s.start("Updating PR..."),await this.updatePr(i.number,e,t),s.stop(`PR #${i.number} updated`),m.info(`
|
|
162
|
+
${c.green("Release PR updated:")} ${i.url}`);else{s.start("Creating PR...");let n=await this.createPr(e,t);s.stop(`PR #${n.number} created`),m.info(`
|
|
163
|
+
${c.green("Release PR created:")} ${n.url}`)}}buildPrTitle(e){let t=e.map((s)=>`${s.name}@${s.newVersion}`).join(", ");return`${Ki} ${t}`}buildPrBody(e,t){return[this.buildChangesSection(t),this.buildPackagesSection(e),this.buildStonesSection(t),this.buildFooter()].join(`
|
|
164
|
+
`)}buildChangesSection(e){let t=["## Changes",""];for(let s of e){if(t.push(`### ${s.message}`,""),s.commits&&s.commits.length>0)for(let i of s.commits)t.push(`- ${i.message} (\`${i.hash}\`)`);else if(s.description)t.push(s.description);t.push("")}return t.join(`
|
|
165
|
+
`)}buildPackagesSection(e){let t=["## Packages",""];for(let s of e)t.push(`- \`${s.name}\` ${s.version} \u2192 ${s.newVersion}`);return t.push(""),t.join(`
|
|
166
|
+
`)}buildStonesSection(e){let t=["## Stones",""];for(let s of e)t.push(`- \`${s.id}\`: ${s.message}`);return t.push(""),t.join(`
|
|
166
167
|
`)}buildFooter(){return["---","*This PR was automatically created by [Sisyphus](https://github.com/r5n-labs/clis).*","*Merging this PR will trigger the release workflow.*"].join(`
|
|
167
|
-
`)}async findExistingReleasePr(){let t=await(await this.getProvider()).findPr({head:Ct,label:
|
|
168
|
-
${t}`)}printRootInfo(e){if(!e)return;let t=e.version?c.dim(`@${e.version}`):"";
|
|
169
|
-
`))}printStones(e,t){let
|
|
168
|
+
`)}async findExistingReleasePr(){let t=await(await this.getProvider()).findPr({head:Ct,label:as});return t?{number:t.number,url:t.url}:null}async generateStonesFromCommits(e,t,s){let n=await new Ce(e.config).analyze({single:e.config.get("single")});if(n.length===0)return[];let{packages:r}=await S.scan({single:e.config.get("single")}),o=[];for(let[a,l]of n.entries()){let u=Ce.buildStoneData(l,r);if(s)m.info(`${c.dim("[dry-run] Would generate stone:")} ${l.message}`),o.push(R.create(u,a));else{let g=await t.create(u);o.push(g),m.info(`${c.dim("Generated stone:")} ${g.id}`)}}return o}async findNewestCommitHash(e){let t=e.flatMap((i)=>i.commits??[]).map((i)=>i.hash);if(t.length===0)return null;return(await Bun.$`git log -1 --format=%H ${t}`.quiet().nothrow()).stdout.toString().trim()||null}async stashChanges(){await Bun.$`git stash --include-untracked`.nothrow()}async applyReleaseChanges(e,t,s){let i=[];return i.push(...await this.updatePackages(s)),i.push(...await this.generateChangelogs(e,t,s)),i.push(...await this.archiveStonesAndUpdateConfig(e,t,s)),i}async updatePackages(e){return await new He().updateAll(e),e.map((s)=>s.file)}async generateChangelogs(e,t,s){let i=e.config.get("changelog");if(!i.generate)return[];return await new we(i).generate(t,s),[i.filename,`**/${i.filename}`]}async archiveStonesAndUpdateConfig(e,t,s){let n=await new k(e.config).archive(t),r=this.buildPackageVersions(s);return e.config.set("currentRelease",{packages:r,stoneIds:t.map((o)=>o.id),timestamp:n}),await this.updateLastStone(e,t),[e.config.get("sisyphusDir")]}buildPackageVersions(e){let t={};for(let s of e)if(s.newVersion)t[s.name]={newVersion:s.newVersion,oldVersion:s.version};return t}async updateLastStone(e,t){let s=await this.findNewestCommitHash(t);if(s)e.config.set("lastStone",{commit:s,date:new Date().toISOString()})}async createPr(e,t){let s=await this.getProvider(),i=await s.getDefaultBranch();await s.ensureLabelExists(as,{color:go,description:mo});let n=await s.createPr({base:i,body:t,head:Ct,labels:[as],title:e});return{number:n.number,url:n.url}}async updatePr(e,t,s){await(await this.getProvider()).updatePr(e,{body:s,title:t})}async restoreMainBranch(e){try{await Bun.$`git checkout ${e}`.quiet()}catch(t){m.warn(c.dim(`Failed to restore branch: ${t}`))}}}class ls extends I{name="actions";description="CI/CD integration";init(){this.registerSubcommands([new es,new cs])}}var fo=M({config:{alias:"c",default:!1,description:"Include config in output",type:"boolean"},json:{alias:"j",default:!1,description:"Output as JSON",type:"boolean"}});class us extends I{name="check";description="Show workspace packages and pending stones";args=fo;async execute(e){let t=await this.gatherData(e);if(e.args.json)this.printJson(t);else this.printFormatted(t)}async gatherData(e){let t=e.config.get("single"),{packages:s,packageNames:i}=await S.scan({single:t}),r=(t?null:await S.scan({single:!0}))?.packages.values().next().value??s.values().next().value,a=await new k(e.config).list();return{config:e.args.config?e.config.getAll():void 0,packageNames:i,packages:s,root:r,stones:a}}printJson(e){let t={config:e.config,packages:e.packageNames.map((s)=>({name:s,version:e.packages.get(s)?.version??"0.0.0"})),root:{name:e.root?.name??"",version:e.root?.version??"0.0.0"},stones:e.stones.map((s)=>this.stoneToJson(s,e.packages))};console.log(JSON.stringify(t,null,2))}stoneToJson(e,t){let s=[];for(let i of $e)for(let n of e.getPackages(i)){let o=t.get(n)?.version??"0.0.0";s.push({bump:i,name:n,newVersion:Q.bump(o,i,e.tag),version:o})}return{id:e.id,message:e.message,packages:s,tag:e.tag}}printFormatted(e){if(this.printRootInfo(e.root),this.printPackages(e),e.stones.length>0)this.printStones(e.stones,e.packages);if(e.config)this.printConfig(e.config);B(c.green("Sisyphus check complete."))}printConfig(e){let t=c.dim(JSON.stringify(e,null,2));m.step(`${c.bold(c.green("Config:"))}
|
|
169
|
+
${t}`)}printRootInfo(e){if(!e)return;let t=e.version?c.dim(`@${e.version}`):"";m.step(`${c.bold(c.green("Root package:"))} ${c.cyan(e.name)}${t}`)}printPackages(e){let t=[`${c.bold(c.green("Packages:"))}`];for(let s of e.packageNames){let i=e.packages.get(s),n=i?.version?c.dim(`@${i.version}`):"";t.push(` ${c.dim("\u2022")} ${c.cyan(s)}${n}`)}m.step(t.join(`
|
|
170
|
+
`))}printStones(e,t){let s=e.map((i)=>this.formatStone(i,t)).join(`
|
|
170
171
|
|
|
171
|
-
`);
|
|
172
|
+
`);m.step(`${c.bold(c.green("Stones:"))}
|
|
172
173
|
|
|
173
|
-
${
|
|
174
|
-
`)}}var
|
|
174
|
+
${s}`)}formatStone(e,t){let s=[];if(s.push(`${c.bold("Stone:")} ${c.cyan(e.id)}`),e.tag)s.push(`${c.dim("Tag:")} ${e.tag}`);s.push(`${c.dim("Message:")} ${e.message}`),s.push(`${c.bold("Packages:")}`);for(let i of $e){let n=e.getPackages(i);if(n.length===0)continue;for(let r of n){let a=t.get(r)?.version??"0.0.0",l=Q.bump(a,i,e.tag),u=Ae[i],g=_e[i];s.push(` ${g} ${c.cyan(r)}@${u(l)} ${c.dim(`(${i})`)}`)}}return s.join(`
|
|
175
|
+
`)}}var yo=M({changelog:{description:"Generate changelog for releases",type:"boolean"},commitAuthor:{description:"Commit author name",type:"string"},commitEmail:{description:"Commit author email",type:"string"},commitMessage:{description:"Commit message template",type:"string"},createRelease:{description:"Create a release on git provider",type:"boolean"},default:{alias:"d",default:!1,description:"Reset to default config",type:"boolean"},force:{alias:"f",default:!1,description:"Overwrite existing config",type:"boolean"},npm:{description:"Publish to NPM on release",type:"boolean"},push:{description:"Push commits and tags to remote on release",type:"boolean"},rootChangelog:{description:"Generate combined changelog for monorepo",type:"boolean"},single:{alias:"s",description:"Setup for single package (not monorepo)",type:"boolean"},tag:{alias:"t",description:"Default release tag",type:"string"},tags:{description:"Create git tags on release",type:"boolean"}});class ps extends I{name="init";description="Initializes Sisyphus config or edits it";args=yo;async execute(e){let{default:t,force:s}=e.args;if(t){e.config.save(Te),await this.setLastStoneToHead(e),this.displaySuccessNote(e.cli.version);return}if(!e.interactive&&e.config.exists()&&!s){B(c.yellow("Config already exists. Use --force to replace."));return}let i=e.config.getAll(),{default:n,force:r,...o}=e.args,a=e.interactive?await this.runInitForm(i):o,l=this.mapValuesToConfig(a),u=be({...i},l);e.config.save(u),await this.setLastStoneToHead(e),this.displaySuccessNote(e.cli.version)}mapValuesToConfig(e){let t=(o)=>Object.fromEntries(Object.entries(o).filter(([,a])=>a!==void 0)),s=(o)=>Object.keys(o).length>0,i=t({author:e.commitAuthor,email:e.commitEmail,message:e.commitMessage}),n=t({generate:e.changelog,root:e.rootChangelog}),r=t({createRelease:e.createRelease,npm:e.npm,push:e.push,tags:e.tags});return{...t({single:e.single,tag:e.tag}),...s(i)&&{commit:i},...s(n)&&{changelog:n},...s(r)&&{release:r}}}async runInitForm(e){let t=await st({changelog:()=>T({active:"Yes, generate changelog",inactive:"Skip changelog",initialValue:e.changelog?.generate??!0,message:"Generate changelog for release?"}),commitAuthor:({results:{configureCommit:s}})=>s?z({initialValue:e.commit?.author??"",message:"Commit author",placeholder:"r5n-bot"}):void 0,commitEmail:({results:{configureCommit:s}})=>s?z({initialValue:e.commit?.email??"",message:"Commit author email",placeholder:"r5n-bot@users.noreply.github.com"}):void 0,commitMessage:({results:{configureCommit:s}})=>s?z({initialValue:e.commit?.message??"",message:"Commit message",placeholder:"release: <packageName@version>"}):void 0,configureCommit:()=>T({active:"Yes, configure commit",inactive:"Skip commit config",initialValue:!!(e.commit?.author||e.commit?.email||e.commit?.message),message:"Configure commit for release? Default commit message is `release: <packageName@version>`"}),createRelease:()=>T({active:"Yes, create a release",inactive:"Skip release creation",initialValue:e.release?.createRelease??!1,message:"Create a release on git provider when releasing packages?"}),npm:()=>T({active:"Yes, publish packages to NPM",inactive:"Skip NPM release",initialValue:e.release?.npm??!1,message:"Publish packages to NPM when releasing packages?"}),push:()=>T({active:"Yes, push to remote",inactive:"No, keep local",initialValue:e.release?.push??!1,message:"Should `roll` command push commits and tags to remote?"}),rootChangelog:({results:{changelog:s}})=>s?T({active:"Yes, generate combined changelog",inactive:"Skip root changelog",initialValue:e.changelog?.root??!1,message:"Generate combined changelog for monorepo?"}):void 0,single:()=>T({active:"Yes, setup for root package",inactive:"No, setup for monorepo workspace packages",initialValue:e.single??!1,message:"Setup Sisyphus for only root package?"}),tag:()=>z({initialValue:e.tag??"latest",message:"Tag used when versioning packages. Leave `latest` if you are not sure.",placeholder:"latest"}),tags:()=>T({active:"Yes, create tags for the release",inactive:"Skip tags",initialValue:e.release?.tags??!1,message:"Create tags for the release?"})},{onCancel:()=>{throw new te}});return{changelog:t.changelog,commitAuthor:t.commitAuthor,commitEmail:t.commitEmail,commitMessage:t.commitMessage,createRelease:t.createRelease,npm:t.npm,push:t.push,rootChangelog:t.rootChangelog,single:t.single,tag:t.tag,tags:t.tags}}async setLastStoneToHead(e){try{let s=(await Bun.$`git rev-parse HEAD`.quiet()).stdout.toString().trim();if(s)e.config.set("lastStone",{commit:s,date:new Date().toISOString()})}catch{}}displaySuccessNote(e){B(`${c.magenta(`${c.bold("Sisyphus ")}${c.underline(c.italic(`v${e??"unknown"}`))}`)}${c.green(" is setup to roll stones.")}
|
|
175
176
|
|
|
176
|
-
You can now start by creating a new stone by running ${c.green(
|
|
177
|
+
You can now start by creating a new stone by running ${c.green(D)}${c.blue(" version")}
|
|
177
178
|
and following the prompts.
|
|
178
179
|
|
|
179
|
-
After you finished, you can release it by running ${c.green(
|
|
180
|
-
`)}}var
|
|
181
|
-
`);
|
|
182
|
-
|
|
183
|
-
Run ${c.green(`${
|
|
184
|
-
Run ${c.green(`${
|
|
185
|
-
${c.dim("Packages:")} ${
|
|
186
|
-
${c.dim("Message:")} ${
|
|
187
|
-
`),
|
|
188
|
-
or create another stone with ${c.green(`${
|
|
189
|
-
`))}}var
|
|
190
|
-
`);if(
|
|
180
|
+
After you finished, you can release it by running ${c.green(D)}${c.blue(" roll")}
|
|
181
|
+
`)}}var bo=M({dryRun:{alias:"d",default:!1,description:"Preview migration without making changes",type:"boolean"},yes:{alias:"y",default:!1,description:"Skip confirmation prompts",type:"boolean"}});class ms extends I{name="migrate";description="Migrate from changesets to sisyphus";args=bo;parser=new is;async execute(e){if(!await this.parser.exists())throw new d("No .changeset directory found","This command migrates existing changesets to sisyphus stones");let{changesets:t,config:s}=await this.analyzeChangesets();if(this.displayPreview(t,s),e.args.dryRun){B("No changes made",c.yellow("Dry run"));return}if(!e.args.yes&&!await this.confirmMigration(t.length))return;let i=await this.createStones(e,t);await this.applyConfigMigration(e,s),this.displaySuccess(i)}async analyzeChangesets(){let e=K();e.start("Analyzing changesets...");let t=await this.parser.parse();if(t.errors.length>0){e.error("Found issues while parsing");for(let s of t.errors)m.warn(c.yellow(s))}if(t.changesets.length===0)throw e.stop("No changesets found"),new d("No changeset files to migrate");return e.stop(`Found ${c.bold(String(t.changesets.length))} changeset(s)`),t}displayPreview(e,t){if(this.displayChangesets(e),t)this.displayConfigMapping(t)}async confirmMigration(e){return T({initialValue:!0,message:`Migrate ${e} changeset(s) to stones?`})}async createStones(e,t){let s=K();s.start("Creating stones...");let i=new k(e.config),n=[];for(let r of t){let o=this.parser.toStoneData(r),a=await i.create(o);n.push(a.id)}return s.stop(`Created ${c.bold(String(n.length))} stone(s)`),n}async applyConfigMigration(e,t){if(!t)return;let s=K();s.start("Migrating config..."),this.migrateConfig(e,t),s.stop("Config migrated")}displaySuccess(e){let t=e.map((s)=>` ${c.dim("-")} ${s}`).join(`
|
|
182
|
+
`);B(`${t}
|
|
183
|
+
|
|
184
|
+
Run ${c.green(`${D} stone list`)} to view stones
|
|
185
|
+
Run ${c.green(`${D} preview`)} to see what will be released`,c.green("Migration complete"))}displayChangesets(e){for(let t of e){let s=Object.entries(t.packages).map(([n,r])=>{let o=r==="major"?c.red:r==="minor"?c.yellow:c.green;return`${n} ${c.dim("(")}${o(r)}${c.dim(")")}`}).join(", "),i=t.summary.length>60?`${t.summary.slice(0,60)}...`:t.summary;m.info(`${c.dim(t.filename)}
|
|
186
|
+
${c.dim("Packages:")} ${s}
|
|
187
|
+
${c.dim("Message:")} ${i||c.dim("(empty)")}`)}}displayConfigMapping(e){let t=[{category:"migrate",check:()=>(e.ignore?.length??0)>0,format:()=>`ignore: ${e.ignore?.join(", ")}`},{category:"migrate",check:()=>e.commit===!0,format:()=>"commit: enabled (will enable commit & push)"},{category:"migrate",check:()=>e.access==="public",format:()=>"access: public (will enable npm publishing)"},{category:"migrate",check:()=>e.changelog===!1,format:()=>"changelog: disabled"},{category:"info",check:()=>!!e.baseBranch&&e.baseBranch!=="master",format:()=>`baseBranch: ${e.baseBranch}`},{category:"info",check:()=>!!e.updateInternalDependencies,format:()=>`updateInternalDependencies: ${e.updateInternalDependencies}`},{category:"info",check:()=>Array.isArray(e.changelog)||typeof e.changelog==="string",format:()=>`changelog: ${Array.isArray(e.changelog)?e.changelog[0]:e.changelog}`},{category:"info",check:()=>Array.isArray(e.commit)||typeof e.commit==="string",format:()=>`commit: ${Array.isArray(e.commit)?e.commit[0]:e.commit}`},{category:"unsupported",check:()=>(e.linked?.length??0)>0,format:()=>`linked: ${e.linked?.length} group(s)`},{category:"unsupported",check:()=>(e.fixed?.length??0)>0,format:()=>`fixed: ${e.fixed?.length} group(s)`}],s={info:{color:c.blue,items:[],title:"Info (not migrated)"},migrate:{color:c.green,items:[],title:"Will migrate"},unsupported:{color:c.yellow,items:[],title:"Not yet supported"}};for(let i of t)if(i.check())s[i.category].items.push(c.dim(i.format()));for(let i of[s.migrate,s.info,s.unsupported])if(i.items.length>0)B(i.items.join(`
|
|
188
|
+
`),i.color(i.title))}migrateConfig(e,t){if(t.ignore?.length){let s=e.config.get("ignore")??[],i=[...new Set([...s,...t.ignore])];e.config.set("ignore",i)}if(t.commit===!0){let s=e.config.get("commit")??{},i=e.config.get("release")??{};e.config.set("commit",{...s,author:s.author??"Sisyphus"}),e.config.set("release",{...i,push:!0})}if(t.access==="public"){let s=e.config.get("release")??{};e.config.set("release",{...s,npm:!0})}if(t.changelog===!1){let s=e.config.get("changelog")??{};e.config.set("changelog",{...s,generate:!1})}}}var zi=100,$o=M({bump:{alias:"b",description:"Explicit bump type (major/minor/patch)",type:"string"},dryRun:{alias:"d",default:!1,description:"Preview without writing",type:"boolean"},message:{alias:"m",description:"Override stone message",type:"string"},packages:{alias:"p",description:"Filter packages (comma-separated)",type:"string"},url:{alias:"u",description:"PR URL",type:"string"},yes:{alias:"y",default:!1,description:"Skip confirmations",type:"boolean"}});class gs extends I{name="pr";description="Create a stone from a Pull Request";args=$o;prompts=!0;async execute(e){let s=await new os(e.config).analyze(e.args.url);this.displayPrSummary(s.pr);let i=this.shouldSkipPr(e,s.pr);if(i){m.info(c.dim(`Skipping: ${i}`));return}if(s.packages.size===0)throw new d("No packages affected by this PR","The PR only modifies root files or files outside packages");let n=await this.determineBumpType(e,s.suggestedBump,s.pr.labels),r=await this.determinePackages(e,s.packages);if(r.length===0)throw new d("No packages selected");let{packages:o}=await S.scan({single:e.config.get("single")}),a=`[#${s.pr.number}](${s.pr.url})`,l=e.args.message??`${s.pr.title} (${a})`,u=s.pr.body||void 0,g=this.buildStoneData({allPackages:o,bump:n,commits:s.commits,description:u,message:l,packages:r});if(this.logPreview(g,e.args.dryRun),e.args.dryRun)return;if(!e.args.yes&&e.interactive){if(!await T({initialValue:!0,message:"Create this stone?"}))return}let y=await new k(e.config).create(g);B(`Run ${c.green(`${D} roll`)} to release packages
|
|
189
|
+
or create another stone with ${c.green(`${D} version`)}`,`Stone ${c.bold(y.id)} ${c.green("created")}`)}displayPrSummary(e){if(m.info(`PR #${c.bold(String(e.number))}: ${e.title}`),m.info(`${c.dim("Author:")} ${e.author}`),m.info(`${c.dim("Branch:")} ${e.branch}`),e.labels.length>0)m.info(`${c.dim("Labels:")} ${e.labels.map((t)=>c.cyan(t)).join(", ")}`)}shouldSkipPr(e,t){let s=e.config.get("pr").skip;for(let i of t.labels)if(s.labels.some((n)=>n.toLowerCase()===i.toLowerCase()))return`label "${i}" is in skip list`;if(s.authors.some((i)=>i.toLowerCase()===t.author.toLowerCase()))return`author "${t.author}" is in skip list`;for(let i of s.titlePatterns)try{if(new RegExp(i,"i").test(t.title))return`title matches skip pattern "${i}"`}catch{m.warn(c.yellow(`Invalid regex pattern in pr.skip.titlePatterns: "${i}"`))}return null}async determineBumpType(e,t,s){if(e.args.bump){if(!Ei(e.args.bump))throw new d(`Invalid bump type: ${e.args.bump}`,"Use major, minor, or patch");return e.args.bump}if(t)return m.info(`${c.dim("Detected bump:")} ${c.bold(t)} (from ${this.getBumpSource(t,s,e)})`),t;if(e.args.yes)throw new d("Cannot determine bump type automatically","Add a label to the PR or use --bump to specify explicitly");if(!e.interactive)throw new d("Cannot determine bump type","Use --bump to specify explicitly");return ye({message:"What type of change is this?",options:[{label:"patch - Bug fixes, minor changes",value:"patch"},{label:"minor - New features (backwards compatible)",value:"minor"},{label:"major - Breaking changes",value:"major"}]})}getBumpSource(e,t,s){let i=s.config.get("pr").labelMapping;for(let n of t){let r=n.toLowerCase();for(let[o,a]of Object.entries(i))if(r===o.toLowerCase()&&a===e)return`label: ${n}`}return"title"}async determinePackages(e,t){let s=Array.from(t);if(e.args.packages){let i=e.args.packages.split(",").map((r)=>r.trim()).filter(Boolean),n=i.filter((r)=>!t.has(r));if(n.length>0)throw new d(`Packages not affected by this PR: ${n.join(", ")}`,`Affected packages: ${s.join(", ")}`);return i}if(s.length===1||e.args.yes||!e.interactive)return m.info(`${c.dim("Affected packages:")} ${s.map((i)=>c.bold(i)).join(", ")}`),s;return ce({initialValues:s,message:"Select packages to include",options:s.map((i)=>({label:i,value:i})),required:!0})}buildStoneData(e){let{allPackages:t,bump:s,commits:i,description:n,message:r,packages:o}=e,a={commits:i,description:n,message:r};if(s==="major")a.major=o;else if(s==="minor")a.minor=o;else a.patch=o;return a.dependency=H(Ee(o,t)),a}logPreview(e,t){let s=[];if(t)s.push(c.bold(c.yellow("[dry-run]")));if(s.push(`${c.dim("Stone:")} ${c.bold(e.message)}`),e.major?.length)s.push(` ${c.red("major")}: ${e.major.join(", ")}`);if(e.minor?.length)s.push(` ${c.yellow("minor")}: ${e.minor.join(", ")}`);if(e.patch?.length)s.push(` ${c.green("patch")}: ${e.patch.join(", ")}`);if(e.commits?.length)s.push(` ${c.dim(`${e.commits.length} commit(s)`)}`);if(e.description){let i=e.description.length>zi?`${e.description.slice(0,zi)}...`:e.description;s.push(` ${c.dim("Description:")} ${i}`)}m.step(s.join(`
|
|
190
|
+
`))}}var wo=M({changelog:{alias:"c",description:"Generate changelogs",type:"boolean"},createRelease:{alias:"r",description:"Create a release on git provider",type:"boolean"},dryRun:{alias:"d",default:!1,description:"Preview without making changes",type:"boolean"},noCommit:{default:!1,description:"Skip creating release commit",type:"boolean"},npm:{alias:"n",description:"Publish to NPM",type:"boolean"},preview:{default:!1,description:"Preview changelogs then prompt to delete",type:"boolean"},publishOnly:{default:!1,description:"Publish from currentRelease (no file changes)",type:"boolean"},push:{alias:"p",description:"Push commits and tags to remote",type:"boolean"},tags:{alias:"t",description:"Create git tags",type:"boolean"},yes:{alias:"y",default:!1,description:"Skip confirmation prompts",type:"boolean"}});class hs extends I{name="roll";description="Execute a release from pending stones";args=wo;async execute(e){if(e.args.publishOnly){await this.executePublishOnly(e);return}let t=this.resolveOptions(e),i=await new k(e.config).list();if(i.length===0)throw new d("No pending stones found",`Create a stone with ${c.green(`${D} version`)} first`);let{packages:n}=await S.scan({single:e.config.get("single")}),r=R.mergeAll(i),o=ee.applyStone(r,n);if(o.length===0)throw new d("No packages to update","Stones don't reference any known packages");if(e.args.preview){await this.previewChangelogs(e,i,o);return}if(this.printPreview(r,o,t),!t.dryRun&&!e.args.yes&&e.interactive){if(!await T({initialValue:!0,message:"Proceed with release?"}))return}if(t.dryRun){m.info(c.yellow("Dry run complete - no changes made"));return}await this.executeRelease(e,r,o,i,t)}async previewChangelogs(e,t,s){let i=e.config.get("changelog"),n=new we(i),r=K();r.start("Generating changelog preview..."),await n.generate(t,s),r.stop("Changelog preview generated");let o=s.map((l)=>c.dim(` ${l.name}/CHANGELOG.md`)).join(`
|
|
191
|
+
`);if(m.info(`
|
|
191
192
|
Preview files created:
|
|
192
|
-
${o}`),
|
|
193
|
-
`))}async executeRelease(e,t,
|
|
194
|
-
Run ${c.green(`${
|
|
195
|
-
Run ${c.green(`${
|
|
196
|
-
|
|
197
|
-
`);
|
|
198
|
-
|
|
199
|
-
${
|
|
200
|
-
`))
|
|
201
|
-
`)}}var
|
|
202
|
-
`+t.map((
|
|
203
|
-
`),c.yellow("Conflicts resolved"))}}var
|
|
204
|
-
`))}}class
|
|
205
|
-
Run ${c.green(`${
|
|
206
|
-
or create another stone with ${c.green(`${
|
|
193
|
+
${o}`),i.root)m.info(c.dim(" CHANGELOG.md (root)"));if(m.info(""),await T({initialValue:!0,message:"Revert changes?"}))await n.rollback(),m.info(c.dim("Changes reverted"));else m.info(c.yellow("Changes kept"))}resolveOptions(e){let t=e.config.get("release"),s=e.config.get("changelog"),i=!e.args.noCommit;return{changelog:e.args.changelog??s.generate,commit:i,createRelease:i?e.args.createRelease??t.createRelease:!1,dryRun:e.args.dryRun,npm:e.args.npm??t.npm,push:i?e.args.push??t.push:!1,tags:i?e.args.tags??t.tags:!1}}printPreview(e,t,s){let i=[];if(s.dryRun)i.push(c.bold(c.yellow("[dry-run]")));if(i.push(`${c.bold("Release:")} ${e.message}`),e.tag)i.push(`${c.dim("Tag:")} ${e.tag}`);i.push(""),i.push(c.bold("Packages:"));for(let n of t)i.push(` ${n.label}`);i.push(""),i.push(c.dim(`Changelog: ${s.changelog?"yes":"no"}`)),i.push(c.dim(`Git tags: ${s.tags?"yes":"no"}`)),i.push(c.dim(`NPM publish: ${s.npm?"yes":"no"}`)),i.push(c.dim(`Push to remote: ${s.push?"yes":"no"}`)),i.push(c.dim(`Create release: ${s.createRelease?"yes":"no"}`)),m.step(i.join(`
|
|
194
|
+
`))}async executeRelease(e,t,s,i,n){let r=new Pt(e.config,n);await r.preflight(s);let o=K();try{if(o.start("Updating package versions..."),await r.updatePackageVersions(s),o.stop("Package versions updated"),n.changelog)o.start("Generating changelogs..."),await r.generateChangelogs(i,s),o.stop("Changelogs generated");if(await this.deleteStones(e,i),n.commit)o.start("Creating release commit..."),await r.createCommit(t,s),o.stop("Release commit created");if(e.config.set("lastStone",{commit:await this.getCurrentCommit(),date:new Date().toISOString()}),n.tags)o.start("Creating git tags..."),await r.createGitTags(s),o.stop("Git tags created");if(n.npm)o.start("Publishing to NPM..."),await r.publishToNpm(s),o.stop("Published to NPM");if(n.push)o.start("Pushing to remote..."),await r.pushToRemote(),o.stop("Pushed to remote");if(n.createRelease)o.start("Creating release..."),await r.createGitRelease(i,s),o.stop("Release created");B(`Released ${c.bold(String(s.length))} package(s)
|
|
195
|
+
Run ${c.green(`${D} check`)} to verify`,c.green("Release complete"))}catch(a){o.error("Release failed, rolling back...");try{await r.rollback()}finally{await this.restoreStones(e,i)}throw a}}async deleteStones(e,t){let s=new k(e.config);for(let i of t)await s.delete(i.id)}async restoreStones(e,t){let s=new k(e.config);for(let i of t)await s.save(i)}async getCurrentCommit(){try{return(await Bun.$`git rev-parse HEAD`.quiet()).stdout.toString().trim()}catch{return""}}async executePublishOnly(e){let t=e.config.get("currentRelease");if(!t)throw new d("No currentRelease found in config","Run `sis actions release-pr` first to prepare a release");let s=Object.entries(t.packages);if(s.length===0)throw new d("No packages in currentRelease","The release config appears to be empty");let{packages:i}=await S.scan({single:e.config.get("single")}),n=[];for(let[a,{oldVersion:l,newVersion:u}]of s){let g=i.get(a);if(g)n.push(g.withVersions(l,u))}if(n.length===0)throw new d("No matching packages found","Packages in currentRelease don't exist in workspace");m.info(c.bold("Publish-only mode")),m.info(c.dim(`Timestamp: ${t.timestamp}`)),m.info(c.dim(`Stones: ${t.stoneIds.join(", ")}`)),m.info(""),m.info(c.bold("Packages to publish:"));for(let a of n)m.info(` ${a.name}@${a.newVersion??a.version}`);m.info("");let r=e.config.get("release"),o={createRelease:e.args.createRelease??r.createRelease,dryRun:e.args.dryRun,npm:e.args.npm??r.npm,tags:e.args.tags??r.tags};if(o.dryRun){m.info(c.yellow("[dry-run] Would publish packages"));return}if(!e.args.yes&&e.interactive){if(!await T({initialValue:!0,message:"Proceed with publishing?"}))return}await this.executePublish(e,n,t,o)}async executePublish(e,t,s,i){let n=new Pt(e.config,{changelog:!1,createRelease:i.createRelease,dryRun:i.dryRun,npm:i.npm,push:!1,tags:i.tags}),r=K();try{if(i.tags)r.start("Creating and pushing git tags..."),await n.createGitTags(t),await n.pushTags(),r.stop("Git tags pushed");if(i.npm)r.start("Publishing to NPM..."),await n.publishToNpm(t),r.stop("Published to NPM");if(i.createRelease){r.start("Creating release...");let a=await new k(e.config).getReleasedStones(s.timestamp),l=a.length>0?a:[this.createFallbackStone(t)];await n.createGitRelease(l,t),r.stop("Release created")}e.config.set("lastStone",{commit:await this.getCurrentCommit(),date:new Date().toISOString()}),B(`Published ${c.bold(String(t.length))} package(s)
|
|
196
|
+
Run ${c.green(`${D} check`)} to verify`,c.green("Publish complete"))}catch(o){throw r.error("Publish failed"),o}}createFallbackStone(e){let t=`Release ${e.map((s)=>`${s.name}@${s.newVersion??s.version}`).join(", ")}`;return R.create({message:t},0)}}class Se extends I{async resolveStone(e,t,s){if(s)return this.promptStone(t);if(!e)throw new d("Stone ID is required",`Usage: ${D} stone ${this.name} <id>`);let i=await t.get(e);if(!i)throw new d(`Stone '${e}' not found`,`Run '${D} stone list' to see available stones`);return i}async promptStone(e){let t=await e.list();if(t.length===0)throw new d("No pending stones found");let s=t.map((i)=>({label:`${i.id} - ${i.message}`,value:i}));return ye({message:`Select a stone to ${this.name}`,options:s})}}var vo=Z({id:{description:"Stone ID to delete"}});class ds extends Se{name="delete";description="Delete a pending stone";positionals=vo;prompts=!0;async execute(e){let t=new k(e.config),s=await this.resolveStone(e.positionals.id,t,e.interactive);if(e.interactive){if(!await T({initialValue:!1,message:`Delete stone '${s.id}'?`}))return}await t.delete(s.id),m.success(`Stone '${c.bold(s.id)}' deleted`)}}var Po=Z({id:{description:"Stone ID to edit"}}),Co=M({message:{alias:"m",description:"New commit message",type:"string"}});class fs extends Se{name="edit";description="Edit a pending stone";positionals=Po;args=Co;prompts=!0;async execute(e){let t=new k(e.config),s=await this.resolveStone(e.positionals.id,t,e.interactive),i=await this.resolveMessage(e,s.message),n=s.withMessage(i);await t.save(n),m.success(`Updated commit message for stone '${c.bold(s.id)}'`)}async resolveMessage(e,t){if(e.args.message)return e.args.message;if(!e.interactive)throw new d("--message is required in non-interactive mode");return z({initialValue:t,message:"Commit message",placeholder:t})}}var So=M({json:{alias:"j",default:!1,description:"Output as JSON",type:"boolean"},verbose:{alias:"v",default:!1,description:"Show detailed info",type:"boolean"}});class ys extends I{name="list";description="List all pending stones";args=So;async execute(e){let t=new k(e.config),s=await t.list();if(s.length===0){this.printEmpty(e.args.json);return}if(e.args.json)this.printJson(s,t);else this.printFormatted(s,e.args.verbose)}printEmpty(e){if(e)console.log(JSON.stringify([]));else m.info("No pending stones found")}printJson(e,t){let s=e.map((i)=>({path:t.getFilePath(i.id),...i.toJson()}));console.log(JSON.stringify(s,null,2))}printFormatted(e,t){let s=`Found ${c.bold(String(e.length))} pending stone${e.length>1?"s":""}`,i=e.map((n)=>this.formatStone(n,t)).join(`
|
|
197
|
+
|
|
198
|
+
`);m.info(`${s}
|
|
199
|
+
|
|
200
|
+
${i}`)}formatStone(e,t){let s=[];if(s.push(`${c.dim("-")} ${c.bold(e.id)}`),s.push(` ${c.dim("Message:")} ${e.message}`),e.tag)s.push(` ${c.dim("Tag:")} ${c.cyan(e.tag)}`);if(e.major.length)s.push(` ${c.red("Major:")} ${e.major.join(", ")}`);if(e.minor.length)s.push(` ${c.yellow("Minor:")} ${e.minor.join(", ")}`);if(e.patch.length)s.push(` ${c.green("Patch:")} ${e.patch.join(", ")}`);if(t&&e.description){s.push(` ${c.dim("Description:")}`);for(let i of e.description.split(`
|
|
201
|
+
`))s.push(` ${c.dim(i)}`)}return s.join(`
|
|
202
|
+
`)}}var ko=Z({ids:{description:"Stone IDs to merge (at least 2)",variadic:!0}}),Ro=M({delete:{alias:"d",default:!1,description:"Delete original stones after merge",type:"boolean"},message:{alias:"m",description:"Commit message for merged stone",type:"string"}});class bs extends I{name="merge";description="Merge multiple stones into one";positionals=ko;args=Ro;prompts=!0;async execute(e){let t=new k(e.config),s=await this.resolveStones(e,t),i=await this.resolveMessage(e),{stone:n,conflicts:r}=R.merge(s,i);if(await t.save(n),await this.resolveDelete(e))await t.deleteMany(s.map((a)=>a.id));this.printResult(n.id,r)}async resolveStones(e,t){let s=await t.list();if(s.length<2)throw new d("Need at least 2 stones to merge");if(e.interactive)return this.promptStones(s);let i=e.positionals.ids;if(i.length<2)throw new d("Need at least 2 stone IDs",`Usage: ${D} stone merge <id1> <id2> [...] -m "message"`);let n=s.filter((r)=>i.includes(r.id));if(n.length!==i.length){let r=n.map((a)=>a.id),o=i.filter((a)=>!r.includes(a));throw new d(`Stone(s) not found: ${o.join(", ")}`)}return n}async resolveMessage(e){if(e.args.message)return e.args.message;if(!e.interactive)throw new d("--message is required in non-interactive mode");return z({message:"Commit message for merged stone",placeholder:"feat: combined changes"})}async resolveDelete(e){if(e.args.delete)return!0;if(e.interactive)return T({initialValue:!1,message:"Delete original stones?"});return!1}async promptStones(e){let t=e.map((i)=>({label:`${i.id} - ${i.message}`,value:i})),s=await ce({message:"Select stones to merge (at least 2)",options:t,required:!0});if(s.length<2)throw new d("Need to select at least 2 stones");return s}printResult(e,t){if(m.success(`Created merged stone: ${c.bold(e)}`),t.length>0)B(`Resolved ${t.length} package conflict(s) using highest bump type:
|
|
203
|
+
`+t.map((s)=>` ${c.dim("-")} ${s}`).join(`
|
|
204
|
+
`),c.yellow("Conflicts resolved"))}}var xo=40,Io=Z({id:{description:"Stone ID to display"}}),To=M({json:{alias:"j",default:!1,description:"Output as JSON",type:"boolean"}});class $s extends Se{name="show";description="Show details of a specific stone";positionals=Io;args=To;prompts=!0;async execute(e){let t=new k(e.config),s=await this.resolveStone(e.positionals.id,t,e.interactive);this.printStone(s,t,e.args.json)}printStone(e,t,s){if(s)console.log(JSON.stringify({path:t.getFilePath(e.id),...e.toJson()},null,2));else this.printFormatted(e,t)}printFormatted(e,t){let s=[];if(s.push(c.bold(`Stone: ${e.id}`)),s.push(c.dim(`Path: ${t.getFilePath(e.id)}`)),s.push(c.dim("-".repeat(xo))),s.push(""),s.push(`${c.dim("Message:")} ${e.message}`),e.tag)s.push(`${c.dim("Tag:")} ${c.cyan(e.tag)}`);if(e.description)s.push(`${c.dim("Description:")} ${e.description}`);s.push("");let i=[{bump:"major",packages:e.major},{bump:"minor",packages:e.minor},{bump:"patch",packages:e.patch},{bump:"dependency",packages:e.dependency},{bump:"snapshot",packages:e.snapshot}];for(let{bump:n,packages:r}of i)if(r.length>0){let o=Ae[n];s.push(`${o(n)}: ${r.join(", ")}`)}m.info(s.join(`
|
|
205
|
+
`))}}class ws extends I{name="stone";description="Manage version stones";init(){this.registerSubcommands([new ys,new $s,new ds,new fs,new bs])}}var Mo=Z({message:{description:"Stone message (commit message)"},description:{description:"Stone description (optional details)"}}),_o=M({dryRun:{alias:"d",default:!1,description:"Preview without writing files",type:"boolean"},filter:{alias:"f",description:"Filter packages by name",type:"string"},fromCommits:{default:!1,description:"Generate stones from conventional commits",type:"boolean"},major:{alias:"M",description:"Packages for major bump (comma-separated)",type:"string"},minor:{alias:"m",description:"Packages for minor bump (comma-separated)",type:"string"},patch:{alias:"p",description:"Packages for patch bump (comma-separated)",type:"string"},tag:{alias:"t",description:"Prerelease tag (e.g. beta, alpha)",type:"string"},yes:{alias:"y",default:!1,description:"Skip confirmation prompts",type:"boolean"}});class vs extends I{name="version";description="Create a new version stone";positionals=Mo;args=_o;prompts=!0;async execute(e){if(e.args.fromCommits)await this.executeFromCommits(e);else if(e.interactive)await this.executeInteractive(e);else await this.executeDirect(e)}async executeInteractive(e){let{packages:t,packageNames:s}=await S.scan({single:e.config.get("single")});if(s.length===0)throw new d("No packages found matching the criteria");let i=await this.selectPackagesInteractive(t,s),n=await this.promptMessage(),r=await this.promptDescription(),o=this.buildStoneData({description:r,message:n,packages:t,selection:i});await this.createStone(e,o,t)}async executeDirect(e){let t=this.parsePackageArgs(e.args);if(!e.positionals.message)throw new d("Message positional is required in non-interactive mode");let{packages:s}=await S.scan({filter:e.args.filter,single:e.config.get("single")}),i=this.validatePackages(t,s);if(i.length>0)throw new d(`Unknown packages: ${i.join(", ")}`);let n=this.buildStoneData({description:e.positionals.description,message:e.positionals.message,packages:s,selection:t,tag:e.args.tag});await this.createStone(e,n,s)}parsePackageArgs(e){let t=(n)=>n?.split(",").map((r)=>r.trim()).filter(Boolean)??[],s={major:t(e.major),minor:t(e.minor),patch:t(e.patch)};if(!(s.major.length>0||s.minor.length>0||s.patch.length>0))throw new d("At least one of --major (-M), --minor (-m), or --patch (-p) is required");return s}validatePackages(e,t){return[...e.major,...e.minor,...e.patch].filter((i)=>!t.has(i))}async executeFromCommits(e){let s=await new Ce(e.config).analyze({filter:e.args.filter,single:e.config.get("single")});if(s.length===0){m.info("No conventional commits found since last release");return}let{packages:i}=await S.scan({filter:e.args.filter,single:e.config.get("single")});m.info(`Found ${c.bold(String(s.length))} commit group(s) to process`);let n=new k(e.config),r=0;for(let o of s){let a=Ce.buildStoneData(o,i,e.args.tag);if(e.args.dryRun)this.logDryRunStone(a);else{let l=await n.create(a);r++,m.success(`Created stone: ${c.bold(l.id)}`)}}if(!e.args.dryRun&&r>0)B(`Created ${c.bold(String(r))} stone(s) from commits.
|
|
206
|
+
Run ${c.green(`${D} preview`)} to see what will be released.`,c.green("Success"))}async selectPackagesInteractive(e,t){let s=[],i={major:[],minor:[],patch:[]};for(let n of["major","minor","patch"]){let r=t.filter((a)=>!s.includes(a));if(r.length===0)break;let o=await this.promptPackages(n,r,e);if(s.push(...o),n==="major")i.major=o;else if(n==="minor")i.minor=o;else i.patch=o}if(s.length===0)throw new d("No packages selected");return i}async promptPackages(e,t,s){let i=Ae[e],n=t.map((r)=>{let o=s.get(r);return{label:o?o.withBump(e).label:r,value:r}});return ce({message:`Select packages for ${c.bold(i(e))} bump`,options:n,required:!1})}async promptMessage(){return z({message:"Stone message (used as commit message)",placeholder:"feat: add new feature",validate:(e)=>e?.trim()?void 0:"Message is required"})}async promptDescription(){return(await z({message:"Description (optional, press enter to skip)",placeholder:"Additional details about this change..."}))?.trim()||void 0}buildStoneData(e){let{selection:t,message:s,packages:i,tag:n,description:r}=e,o=[...t.major,...t.minor,...t.patch],a=Ee(o,i);return{dependency:H(a),description:r,major:H(t.major),message:s,minor:H(t.minor),patch:H(t.patch),tag:n}}async createStone(e,t,s){let i=new k(e.config);if(this.logPreview(t,s,e.args.dryRun),e.args.dryRun)return;if(!e.args.yes&&e.interactive){if(!await T({initialValue:!0,message:"Create this stone?"}))return}let n=await i.create(t);B(`Run ${c.green(`${D} roll`)} to release packages
|
|
207
|
+
or create another stone with ${c.green(`${D} version`)}`,`Stone ${c.bold(n.id)} ${c.green("created")}`)}logPreview(e,t,s){let i=[];if(s)i.push(c.bold(c.yellow("[dry-run]")));if(i.push(`${c.dim("Stone:")} ${c.bold(e.message)}`),e.tag)i.push(`${c.dim("Tag:")} ${e.tag}`);let n=[{bump:"major",names:e.major},{bump:"minor",names:e.minor},{bump:"patch",names:e.patch},{bump:"dependency",names:e.dependency}];for(let{bump:r,names:o}of n){if(!o?.length)continue;for(let a of o){let l=t.get(a);if(l)i.push(` ${l.withBump(r,e.tag).label}`)}}m.step(i.join(`
|
|
207
208
|
`))}logDryRunStone(e){let t=[c.bold(c.yellow("[dry-run]")),`Stone: ${e.message}`];if(e.major?.length)t.push(` Major: ${e.major.join(", ")}`);if(e.minor?.length)t.push(` Minor: ${e.minor.join(", ")}`);if(e.patch?.length)t.push(` Patch: ${e.patch.join(", ")}`);if(e.dependency?.length)t.push(` Dependency: ${e.dependency.join(", ")}`);if(e.description)t.push(` ${c.dim("Commits:")}
|
|
208
|
-
${c.dim(e.description)}`);
|
|
209
|
-
`))}}class
|
|
209
|
+
${c.dim(e.description)}`);m.info(t.join(`
|
|
210
|
+
`))}}class Yi extends qt{constructor(){super(new Jt(`${mt}/${ki}`,Te),{bin:D,clearOnStart:!0,exitLabel:"Give Up",goodbyeMessage:"The boulder rolls back down...",name:"SISYPHUS",promptMessage:"Choose your boulder:",version:yi})}init(){this.registerCommands([new ls,new us,new ps,new ms,new gs,new hs,new ws,new vs])}}var Ao=new Yi;Ao.run();
|