vidup 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +9 -112
- package/package.json +5 -5
- package/dist/.DS_Store +0 -0
package/bin/cli.js
CHANGED
|
@@ -1,114 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var te=(t=0)=>e=>`\x1B[${e+t}m`,re=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,oe=(t=0)=>(e,r,o)=>`\x1B[${38+t};2;${e};${r};${o}m`,u={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},dt=Object.keys(u.modifier),Se=Object.keys(u.color),Ne=Object.keys(u.bgColor),ft=[...Se,...Ne];function Ee(){let t=new Map;for(let[e,r]of Object.entries(u)){for(let[o,n]of Object.entries(r))u[o]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[o]=u[o],t.set(n[0],n[1]);Object.defineProperty(u,e,{value:r,enumerable:!1})}return Object.defineProperty(u,"codes",{value:t,enumerable:!1}),u.color.close="\x1B[39m",u.bgColor.close="\x1B[49m",u.color.ansi=te(),u.color.ansi256=re(),u.color.ansi16m=oe(),u.bgColor.ansi=te(10),u.bgColor.ansi256=re(10),u.bgColor.ansi16m=oe(10),Object.defineProperties(u,{rgbToAnsi256:{value(e,r,o){return e===r&&r===o?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(e){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[o]=r;o.length===3&&(o=[...o].map(i=>i+i).join(""));let n=Number.parseInt(o,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:e=>u.rgbToAnsi256(...u.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,o,n;if(e>=232)r=((e-232)*10+8)/255,o=r,n=r;else{e-=16;let y=e%36;r=Math.floor(e/36)/5,o=Math.floor(y/6)/5,n=y%6/5}let i=Math.max(r,o,n)*2;if(i===0)return 30;let a=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(r));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,r,o)=>u.ansi256ToAnsi(u.rgbToAnsi256(e,r,o)),enumerable:!1},hexToAnsi:{value:e=>u.ansi256ToAnsi(u.hexToAnsi256(e)),enumerable:!1}}),u}var Fe=Ee(),v=Fe;import Y from"node:process";import Re from"node:os";import ne from"node:tty";function w(t,e=globalThis.Deno?globalThis.Deno.args:Y.argv){let r=t.startsWith("-")?"":t.length===1?"-":"--",o=e.indexOf(r+t),n=e.indexOf("--");return o!==-1&&(n===-1||o<n)}var{env:m}=Y,A;w("no-color")||w("no-colors")||w("color=false")||w("color=never")?A=0:(w("color")||w("colors")||w("color=true")||w("color=always"))&&(A=1);function Te(){if("FORCE_COLOR"in m)return m.FORCE_COLOR==="true"?1:m.FORCE_COLOR==="false"?0:m.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(m.FORCE_COLOR,10),3)}function Ie(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function Me(t,{streamIsTTY:e,sniffFlags:r=!0}={}){let o=Te();o!==void 0&&(A=o);let n=r?A:o;if(n===0)return 0;if(r){if(w("color=16m")||w("color=full")||w("color=truecolor"))return 3;if(w("color=256"))return 2}if("TF_BUILD"in m&&"AGENT_NAME"in m)return 1;if(t&&!e&&n===void 0)return 0;let i=n||0;if(m.TERM==="dumb")return i;if(Y.platform==="win32"){let a=Re.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in m)return"GITHUB_ACTIONS"in m||"GITEA_ACTIONS"in m?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(a=>a in m)||m.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in m)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(m.TEAMCITY_VERSION)?1:0;if(m.COLORTERM==="truecolor"||m.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in m){let a=Number.parseInt((m.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(m.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(m.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(m.TERM)||"COLORTERM"in m?1:i}function ie(t,e={}){let r=Me(t,{streamIsTTY:t&&t.isTTY,...e});return Ie(r)}var Ce={stdout:ie({isTTY:ne.isatty(1)}),stderr:ie({isTTY:ne.isatty(2)})},se=Ce;function ae(t,e,r){let o=t.indexOf(e);if(o===-1)return t;let n=e.length,i=0,a="";do a+=t.slice(i,o)+e+r,i=o+n,o=t.indexOf(e,i);while(o!==-1);return a+=t.slice(i),a}function le(t,e,r,o){let n=0,i="";do{let a=t[o-1]==="\r";i+=t.slice(n,a?o-1:o)+e+(a?`\r
|
|
3
3
|
`:`
|
|
4
|
-
`)+
|
|
5
|
-
`,
|
|
6
|
-
`);return
|
|
7
|
-
${String(e)}`)}}async function
|
|
8
|
-
${String(e)}`)}}async function Xt(i,e={}){let{dryRun:t=!1,verbose:n=!1}=e,s=await Ct(i);return ys(s,{dryRun:t,verbose:n})}async function ys(i,e={}){let{dryRun:t=!1,verbose:n=!1}=e,s=G.verbose;G.verbose=n;let r=[];for(let a of i)await qn(a)&&r.push(a);if(!t){G.info(`Found ${r.length} videos with metadata to strip`);for(let a of r)console.log(`Stripping metadata from: ${a}`),await Kn(a)}return G.verbose=s,r}import{BunnyCdnStream as Ps}from"bunnycdn-stream";import{hash as Is}from"hasha";import{readFile as js}from"node:fs/promises";import{rename as ws,writeFile as Os}from"node:fs/promises";import{basename as _s,dirname as Cs,join as xs}from"node:path";import{fileURLToPath as Es}from"node:url";function As(i){let e=i instanceof URL?Es(i):i.toString();return xs(Cs(e),`.${_s(e)}.tmp`)}async function Ss(i,e,t){for(let n=0;n<e;n++)try{return await i()}catch(s){if(n<e-1)await new Promise(r=>setTimeout(r,t));else throw s}}var xt=class{#e;#t;#n=!1;#s=null;#r=null;#o=null;#i=null;#a(e){return this.#i=e,this.#o||=new Promise((t,n)=>{this.#r=[t,n]}),new Promise((t,n)=>{var s;(s=this.#o)==null||s.then(t).catch(n)})}async#l(e){var t,n;this.#n=!0;try{await Os(this.#t,e,"utf-8"),await Ss(async()=>{await ws(this.#t,this.#e)},10,100),(t=this.#s)==null||t[0]()}catch(s){throw s instanceof Error&&((n=this.#s)==null||n[1](s)),s}finally{if(this.#n=!1,this.#s=this.#r,this.#r=this.#o=null,this.#i!==null){let s=this.#i;this.#i=null,await this.write(s)}}}constructor(e){this.#e=e,this.#t=As(e)}async write(e){return this.#n?this.#a(e):this.#l(e)}};var Et=class{#e;#t;constructor(e){this.#e=e,this.#t=new xt(e)}async read(){let e;try{e=await js(this.#e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}return e}write(e){return this.#t.write(e)}};var At=class{#e;#t;#n;constructor(e,{parse:t,stringify:n}){this.#e=new Et(e),this.#t=t,this.#n=n}async read(){let e=await this.#e.read();return e===null?null:this.#t(e)}write(e){return this.#e.write(this.#n(e))}};var St=class extends At{constructor(e){super(e,{parse:JSON.parse,stringify:t=>JSON.stringify(t,null,2)})}};var jt=class{#e=null;read(){return Promise.resolve(this.#e)}write(e){return this.#e=e,Promise.resolve()}};function Ms(i,e){if(i===void 0)throw new Error("lowdb: missing adapter");if(e===void 0)throw new Error("lowdb: missing default data")}var Mt=class{adapter;data;constructor(e,t){Ms(e,t),this.adapter=e,this.data=t}async read(){let e=await this.adapter.read();e&&(this.data=e)}async write(){this.data&&await this.adapter.write(this.data)}async update(e){e(this.data),await this.write()}};async function Jn(i,e){let t=process.env.NODE_ENV==="test"?new jt:new St(i),n=new Mt(t,e);return await n.read(),n}import{createReadStream as Qn}from"node:fs";import ut from"node:path";async function kt(i,e){let{credentials:t,dryRun:n=!1,service:s,verbose:r=!1}=e,a=G.verbose;G.verbose=r;let c=[],b=await Ct(i);G.info(`Found ${b.length} video files in directory "${i}"`);let g=await Jn(ut.join(i,".vidup-state.json"),{syncState:[]});g.data.syncState=g.data.syncState.filter(f=>b.includes(ut.join(i,f.filename)));for(let f of b){let x=ut.basename(f),N=await Is(f,{algorithm:"sha1"}),U=g.data.syncState.find(W=>W.filename===x);U?U.localHash=N:g.data.syncState.push({filename:x,localHash:N,remoteHash:{}})}if(n||await g.write(),s!=="bunny")throw new Error(`Streaming service not yet implemented: ${s}`);let p=new Ps({apiKey:t.key,videoLibrary:t.library}),u=await p.listAllVideos();G.info(`Found ${u.length} video files on ${s} remote streaming service`);let m=u.filter(f=>{let x=g.data.syncState.find(N=>N.filename===f.title);return x!==void 0&&x.localHash===x.remoteHash[s]});for(let f of m)c.push({action:"None",localFile:f.title,remoteId:f.guid});let w=g.data.syncState.filter(f=>!u.some(x=>x.title===f.filename));for(let f of w)c.push({action:"Create",localFile:f.filename,remoteId:"Not yet uploaded (Dry run)"});let C=u.filter(f=>{let x=g.data.syncState.find(N=>N.filename===f.title);return x!==void 0&&x.localHash!==x.remoteHash[s]});for(let f of C)c.push({action:"Update",localFile:f.title,remoteId:"Not yet uploaded (Dry run)"});let O=u.filter(f=>!g.data.syncState.some(x=>x.filename===f.title));for(let f of O)c.push({action:"Delete",localFile:f.title,remoteId:f.guid});if(!n){g.data.lastRun=new Date,await g.write(),G.info("Synchronizing...");for(let[f,x]of O.entries()){if(f===0&&G.info(`Deleting ${O.length} remote videos...`),!(await G.infoSpin(p.deleteVideo(x.guid),`Deleting remote video ${f+1}/${O.length}: ${x.title}`)).success)throw new Error(`Failed to delete remote video: ${x.title}`);g.data.lastUpdate=new Date,await g.write()}for(let[f,x]of w.entries()){f===0&&G.info(`Uploading ${w.length} new local videos...`);let N=Qn(ut.join(i,x.filename)),U=await G.infoSpin(p.createAndUploadVideo(N,{title:x.filename}),`Uploading new video ${f+1}/${w.length}: ${x.filename}`);G.info(`Remote video ${f+1}/${w.length} created with GUID: ${U.guid}`);let W=g.data.syncState.find(le=>le.filename===x.filename);if(W===void 0)throw new Error(`Failed to find state entry for: ${x.filename}`);W.remoteHash[s]=x.localHash,g.data.lastUpdate=new Date,await g.write();let z=c.find(le=>le.localFile===x.filename);if(z===void 0)throw new Error(`Failed to find report entry for: ${x.filename}`);z.remoteId=U.guid}for(let[f,x]of C.entries()){f===0&&(G.info(`Updating ${C.length} remote videos...`),G.warn("Bunny does not currently support updating videos in-place, so vidup will delete and re-uploading instead... this will change the video's GUID!"));let N=g.data.syncState.find(ce=>ce.filename===x.title);if(N===void 0)throw new Error(`Failed to find state entry for: ${x.title}`);if(!(await p.deleteVideo(x.guid)).success)throw new Error(`Failed to delete remote video before updating: ${x.title}`);let W=Qn(ut.join(i,N.filename)),z=await G.infoSpin(p.createAndUploadVideo(W,{title:N.filename}),`Updating remote video ${f+1}/${C.length}: ${x.title}`);G.info(`Updated remote video ${f+1}/${C.length} created with GUID: ${z.guid}`),N.remoteHash[s]=N.localHash,g.data.lastUpdate=new Date,await g.write();let le=c.find(ce=>ce.localFile===N.filename);if(le===void 0)throw new Error(`Failed to find report entry for: ${N.filename}`);le.remoteId=z.guid}G.info(`All ${b.length} videos are now in sync!`)}return G.verbose=a,c}import $r from"node:path";var Zn=i=>Number.isFinite(i)?i:0;function vs(i){return{days:Math.trunc(i/864e5),hours:Math.trunc(i/36e5%24),minutes:Math.trunc(i/6e4%60),seconds:Math.trunc(i/1e3%60),milliseconds:Math.trunc(i%1e3),microseconds:Math.trunc(Zn(i*1e3)%1e3),nanoseconds:Math.trunc(Zn(i*1e6)%1e3)}}function $s(i){return{days:i/86400000n,hours:i/3600000n%24n,minutes:i/60000n%60n,seconds:i/1000n%60n,milliseconds:i%1000n,microseconds:0n,nanoseconds:0n}}function en(i){switch(typeof i){case"number":{if(Number.isFinite(i))return vs(i);break}case"bigint":return $s(i)}throw new TypeError("Expected a finite number or bigint")}var Ns=i=>i===0||i===0n,Fs=(i,e)=>e===1||e===1n?i:`${i}s`,Rs=1e-7,Ds=24n*60n*60n*1000n;function tn(i,e){let t=typeof i=="bigint";if(!t&&!Number.isFinite(i))throw new TypeError("Expected a finite number or bigint");e={...e},e.colonNotation&&(e.compact=!1,e.formatSubMilliseconds=!1,e.separateMilliseconds=!1,e.verbose=!1),e.compact&&(e.unitCount=1,e.secondsDecimalDigits=0,e.millisecondsDecimalDigits=0);let n=[],s=(g,p)=>{let u=Math.floor(g*10**p+Rs);return(Math.round(u)/10**p).toFixed(p)},r=(g,p,u,m)=>{if(!((n.length===0||!e.colonNotation)&&Ns(g)&&!(e.colonNotation&&u==="m"))){if(m=m??String(g),e.colonNotation){let w=m.includes(".")?m.split(".")[0].length:m.length,C=n.length>0?2:1;m="0".repeat(Math.max(0,C-w))+m}else m+=e.verbose?" "+Fs(p,g):u;n.push(m)}},a=en(i),c=BigInt(a.days);if(r(c/365n,"year","y"),r(c%365n,"day","d"),r(Number(a.hours),"hour","h"),r(Number(a.minutes),"minute","m"),e.separateMilliseconds||e.formatSubMilliseconds||!e.colonNotation&&i<1e3){let g=Number(a.seconds),p=Number(a.milliseconds),u=Number(a.microseconds),m=Number(a.nanoseconds);if(r(g,"second","s"),e.formatSubMilliseconds)r(p,"millisecond","ms"),r(u,"microsecond","\xB5s"),r(m,"nanosecond","ns");else{let w=p+u/1e3+m/1e6,C=typeof e.millisecondsDecimalDigits=="number"?e.millisecondsDecimalDigits:0,O=w>=1?Math.round(w):Math.ceil(w),f=C?w.toFixed(C):O;r(Number.parseFloat(f),"millisecond","ms",f)}}else{let g=(t?Number(i%Ds):i)/1e3%60,p=typeof e.secondsDecimalDigits=="number"?e.secondsDecimalDigits:1,u=s(g,p),m=e.keepDecimalsOnWholeSeconds?u:u.replace(/\.0+$/,"");r(Number.parseFloat(m),"second","s",m)}if(n.length===0)return"0"+(e.verbose?" milliseconds":"ms");let b=e.colonNotation?":":" ";return typeof e.unitCount=="number"&&(n=n.slice(0,Math.max(e.unitCount,1))),n.join(b)}import Ts from"node:os";var Xn=Ts.homedir();function nn(i){if(typeof i!="string")throw new TypeError(`Expected a string, got ${typeof i}`);return Xn?i.replace(/^~(?=$|\/|\\)/,Xn):i}import{notStrictEqual as lr,strictEqual as cr}from"assert";var Ls={right:Vs,center:Hs},Ws=0,Pt=1,Us=2,It=3,sn=class{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]=="string")return this.applyLayoutDSL(e[0]);let t=e.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]=="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
|
|
9
|
-
`)
|
|
10
|
-
`)
|
|
11
|
-
`)
|
|
12
|
-
`),r.border&&(s.unshift("."+"-".repeat(this.negatePadding(r)+2)+"."),s.push("'"+"-".repeat(this.negatePadding(r)+2)+"'")),r.padding&&(s.unshift(...new Array(r.padding[Ws]||0).fill("")),s.push(...new Array(r.padding[Us]||0).fill(""))),s.forEach((c,b)=>{t[b]||t.push([]);let g=t[b];for(let p=0;p<a;p++)g[p]===void 0&&g.push("");g.push(c)})}),t}negatePadding(e){let t=e.width||0;return e.padding&&(t-=(e.padding[It]||0)+(e.padding[Pt]||0)),e.border&&(t-=4),t}columnWidths(e){if(!this.wrap)return e.map(a=>a.width||he.stringWidth(a.text));let t=e.length,n=this.width,s=e.map(a=>{if(a.width)return t--,n-=a.width,a.width}),r=t?Math.floor(n/t):0;return s.map((a,c)=>a===void 0?Math.max(r,Bs(e[c])):a)}};function kn(i,e,t){return i.border?/[.']-+[.']/.test(e)?"":e.trim().length!==0?t:" ":""}function Bs(i){let e=i.padding||[],t=1+(e[It]||0)+(e[Pt]||0);return i.border?t+4:t}function zs(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function Vs(i,e){i=i.trim();let t=he.stringWidth(i);return t<e?" ".repeat(e-t)+i:i}function Hs(i,e){i=i.trim();let t=he.stringWidth(i);return t>=e?i:" ".repeat(e-t>>1)+i}var he;function ei(i,e){return he=e,new sn({width:(i==null?void 0:i.width)||zs(),wrap:i==null?void 0:i.wrap})}var ti=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function rn(i){return i.replace(ti,"")}function ni(i,e){let[t,n]=i.match(ti)||["",""];i=rn(i);let s="";for(let r=0;r<i.length;r++)r!==0&&r%e===0&&(s+=`
|
|
13
|
-
`),s+=i.charAt(r);return t&&n&&(s=`${t}${s}${n}`),s}function on(i){return ei(i,{stringWidth:e=>[...e].length,stripAnsi:rn,wrap:ni})}import{dirname as ii,resolve as si}from"path";import{readdirSync as Gs,statSync as Ys}from"fs";function ri(i,e){let t=si(".",i),n;for(Ys(t).isDirectory()||(t=ii(t));;){if(n=e(t,Gs(t)),n)return si(t,n);if(t=ii(n=t),n===t)break}}import{inspect as fr}from"util";import{readFileSync as ur}from"fs";import{fileURLToPath as hr}from"url";import{format as Js}from"util";import{normalize as Qs,resolve as Zs}from"path";function ze(i){if(i!==i.toLowerCase()&&i!==i.toUpperCase()||(i=i.toLowerCase()),i.indexOf("-")===-1&&i.indexOf("_")===-1)return i;{let t="",n=!1,s=i.match(/^-+/);for(let r=s?s[0].length:0;r<i.length;r++){let a=i.charAt(r);n&&(n=!1,a=a.toUpperCase()),r!==0&&(a==="-"||a==="_")?n=!0:a!=="-"&&a!=="_"&&(t+=a)}return t}}function vt(i,e){let t=i.toLowerCase();e=e||"-";let n="";for(let s=0;s<i.length;s++){let r=t.charAt(s),a=i.charAt(s);r!==a&&s>0?n+=`${e}${t.charAt(s)}`:n+=a}return n}function $t(i){return i==null?!1:typeof i=="number"||/^0x[0-9a-f]+$/i.test(i)?!0:/^0[^.]/.test(i)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(i)}function oi(i){if(Array.isArray(i))return i.map(a=>typeof a!="string"?a+"":a);i=i.trim();let e=0,t=null,n=null,s=null,r=[];for(let a=0;a<i.length;a++){if(t=n,n=i.charAt(a),n===" "&&!s){t!==" "&&e++;continue}n===s?s=null:(n==="'"||n==='"')&&!s&&(s=n),r[e]||(r[e]=""),r[e]+=n}return r}var be;(function(i){i.BOOLEAN="boolean",i.STRING="string",i.NUMBER="number",i.ARRAY="array"})(be||(be={}));var $e,Nt=class{constructor(e){$e=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),s=oi(e),r=typeof e=="string",a=qs(Object.assign(Object.create(null),n.alias)),c=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),b=Object.assign(Object.create(null),n.default),g=n.configObjects||[],p=n.envPrefix,u=c["populate--"],m=u?"--":"_",w=Object.create(null),C=Object.create(null),O=n.__||$e.format,f={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},x=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,N=new RegExp("^--"+c["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(l){let d=typeof l=="object"?l.key:l,_=Object.keys(l).map(function(y){return{boolean:"bools",string:"strings",number:"numbers"}[y]}).filter(Boolean).pop();_&&(f[_][d]=!0),f.arrays[d]=!0,f.keys.push(d)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(l){f.bools[l]=!0,f.keys.push(l)}),[].concat(n.string||[]).filter(Boolean).forEach(function(l){f.strings[l]=!0,f.keys.push(l)}),[].concat(n.number||[]).filter(Boolean).forEach(function(l){f.numbers[l]=!0,f.keys.push(l)}),[].concat(n.count||[]).filter(Boolean).forEach(function(l){f.counts[l]=!0,f.keys.push(l)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(l){f.normalize[l]=!0,f.keys.push(l)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([l,d])=>{typeof d=="number"&&(f.nargs[l]=d,f.keys.push(l))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([l,d])=>{typeof d=="function"&&(f.coercions[l]=d,f.keys.push(l))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(l){f.configs[l]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([l,d])=>{(typeof d=="boolean"||typeof d=="function")&&(f.configs[l]=d)})),Be(n.key,a,n.default,f.arrays),Object.keys(b).forEach(function(l){(f.aliases[l]||[]).forEach(function(d){b[d]=b[l]})});let U=null;yt();let W=[],z=Object.assign(Object.create(null),{_:[]}),le={};for(let l=0;l<s.length;l++){let d=s[l],_=d.replace(/^-{3,}/,"---"),y,h,P,A,$,oe;if(d!=="--"&&/^-/.test(d)&&k(d))ce(d);else if(_.match(/^---+(=|$)/)){ce(d);continue}else if(d.match(/^--.+=/)||!c["short-option-groups"]&&d.match(/^-.+=/))A=d.match(/^--?([^=]+)=([\s\S]*)$/),A!==null&&Array.isArray(A)&&A.length>=3&&(R(A[1],f.arrays)?l=We(l,A[1],s,A[2]):R(A[1],f.nargs)!==!1?l=tt(l,A[1],s,A[2]):Y(A[1],A[2],!0));else if(d.match(N)&&c["boolean-negation"])A=d.match(N),A!==null&&Array.isArray(A)&&A.length>=2&&(h=A[1],Y(h,R(h,f.arrays)?[!1]:!1));else if(d.match(/^--.+/)||!c["short-option-groups"]&&d.match(/^-[^-]+/))A=d.match(/^--?(.+)/),A!==null&&Array.isArray(A)&&A.length>=2&&(h=A[1],R(h,f.arrays)?l=We(l,h,s):R(h,f.nargs)!==!1?l=tt(l,h,s):($=s[l+1],$!==void 0&&(!$.match(/^-/)||$.match(x))&&!R(h,f.bools)&&!R(h,f.counts)||/^(true|false)$/.test($)?(Y(h,$),l++):Y(h,ee(h))));else if(d.match(/^-.\..+=/))A=d.match(/^-([^=]+)=([\s\S]*)$/),A!==null&&Array.isArray(A)&&A.length>=3&&Y(A[1],A[2]);else if(d.match(/^-.\..+/)&&!d.match(x))$=s[l+1],A=d.match(/^-(.\..+)/),A!==null&&Array.isArray(A)&&A.length>=2&&(h=A[1],$!==void 0&&!$.match(/^-/)&&!R(h,f.bools)&&!R(h,f.counts)?(Y(h,$),l++):Y(h,ee(h)));else if(d.match(/^-[^-]+/)&&!d.match(x)){P=d.slice(1,-1).split(""),y=!1;for(let fe=0;fe<P.length;fe++){if($=d.slice(fe+2),P[fe+1]&&P[fe+1]==="="){oe=d.slice(fe+3),h=P[fe],R(h,f.arrays)?l=We(l,h,s,oe):R(h,f.nargs)!==!1?l=tt(l,h,s,oe):Y(h,oe),y=!0;break}if($==="-"){Y(P[fe],$);continue}if(/[A-Za-z]/.test(P[fe])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test($)&&R($,f.bools)===!1){Y(P[fe],$),y=!0;break}if(P[fe+1]&&P[fe+1].match(/\W/)){Y(P[fe],$),y=!0;break}else Y(P[fe],ee(P[fe]))}h=d.slice(-1)[0],!y&&h!=="-"&&(R(h,f.arrays)?l=We(l,h,s):R(h,f.nargs)!==!1?l=tt(l,h,s):($=s[l+1],$!==void 0&&(!/^(-|--)[^-]/.test($)||$.match(x))&&!R(h,f.bools)&&!R(h,f.counts)||/^(true|false)$/.test($)?(Y(h,$),l++):Y(h,ee(h))))}else if(d.match(/^-[0-9]$/)&&d.match(x)&&R(d.slice(1),f.bools))h=d.slice(1),Y(h,ee(h));else if(d==="--"){W=s.slice(l+1);break}else if(c["halt-at-non-option"]){W=s.slice(l);break}else ce(d)}V(z,!0),V(z,!1),L(z),se(),Z(z,f.aliases,b,!0),re(z),c["set-placeholder-key"]&&Ue(z),Object.keys(f.counts).forEach(function(l){Ie(z,l.split("."))||Y(l,0)}),u&&W.length&&(z[m]=[]),W.forEach(function(l){z[m].push(l)}),c["camel-case-expansion"]&&c["strip-dashed"]&&Object.keys(z).filter(l=>l!=="--"&&l.includes("-")).forEach(l=>{delete z[l]}),c["strip-aliased"]&&[].concat(...Object.keys(a).map(l=>a[l])).forEach(l=>{c["camel-case-expansion"]&&l.includes("-")&&delete z[l.split(".").map(d=>ze(d)).join(".")],delete z[l]});function ce(l){let d=M("_",l);(typeof d=="string"||typeof d=="number")&&z._.push(d)}function tt(l,d,_,y){let h,P=R(d,f.nargs);if(P=typeof P!="number"||isNaN(P)?1:P,P===0)return xe(y)||(U=Error(O("Argument unexpected for: %s",d))),Y(d,ee(d)),l;let A=xe(y)?0:1;if(c["nargs-eats-options"])_.length-(l+1)+A<P&&(U=Error(O("Not enough arguments following: %s",d))),A=P;else{for(h=l+1;h<_.length&&(!_[h].match(/^-[^0-9]/)||_[h].match(x)||k(_[h]));h++)A++;A<P&&(U=Error(O("Not enough arguments following: %s",d)))}let $=Math.min(A,P);for(!xe(y)&&$>0&&(Y(d,y),$--),h=l+1;h<$+l+1;h++)Y(d,_[h]);return l+$}function We(l,d,_,y){let h=[],P=y||_[l+1],A=R(d,f.nargs);if(R(d,f.bools)&&!/^(true|false)$/.test(P))h.push(!0);else if(xe(P)||xe(y)&&/^-/.test(P)&&!x.test(P)&&!k(P)){if(b[d]!==void 0){let $=b[d];h=Array.isArray($)?$:[$]}}else{xe(y)||h.push(E(d,y,!0));for(let $=l+1;$<_.length&&!(!c["greedy-arrays"]&&h.length>0||A&&typeof A=="number"&&h.length>=A||(P=_[$],/^-/.test(P)&&!x.test(P)&&!k(P)));$++)l=$,h.push(E(d,P,r))}return typeof A=="number"&&(A&&h.length<A||isNaN(A)&&h.length===0)&&(U=Error(O("Not enough arguments following: %s",d))),Y(d,h),l}function Y(l,d,_=r){if(/-/.test(l)&&c["camel-case-expansion"]){let P=l.split(".").map(function(A){return ze(A)}).join(".");I(l,P)}let y=E(l,d,_),h=l.split(".");ve(z,h,y),f.aliases[l]&&f.aliases[l].forEach(function(P){let A=P.split(".");ve(z,A,y)}),h.length>1&&c["dot-notation"]&&(f.aliases[h[0]]||[]).forEach(function(P){let A=P.split("."),$=[].concat(h);$.shift(),A=A.concat($),(f.aliases[l]||[]).includes(A.join("."))||ve(z,A,y)}),R(l,f.normalize)&&!R(l,f.arrays)&&[l].concat(f.aliases[l]||[]).forEach(function(A){Object.defineProperty(le,A,{enumerable:!0,get(){return d},set($){d=typeof $=="string"?$e.normalize($):$}})})}function I(l,d){f.aliases[l]&&f.aliases[l].length||(f.aliases[l]=[d],w[d]=!0),f.aliases[d]&&f.aliases[d].length||I(d,l)}function E(l,d,_){_&&(d=Ks(d)),(R(l,f.bools)||R(l,f.counts))&&typeof d=="string"&&(d=d==="true");let y=Array.isArray(d)?d.map(function(h){return M(l,h)}):M(l,d);return R(l,f.counts)&&(xe(y)||typeof y=="boolean")&&(y=an()),R(l,f.normalize)&&R(l,f.arrays)&&(Array.isArray(d)?y=d.map(h=>$e.normalize(h)):y=$e.normalize(d)),y}function M(l,d){return!c["parse-positional-numbers"]&&l==="_"||!R(l,f.strings)&&!R(l,f.bools)&&!Array.isArray(d)&&($t(d)&&c["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${d}`)))||!xe(d)&&R(l,f.numbers))&&(d=Number(d)),d}function L(l){let d=Object.create(null);Z(d,f.aliases,b),Object.keys(f.configs).forEach(function(_){let y=l[_]||d[_];if(y)try{let h=null,P=$e.resolve($e.cwd(),y),A=f.configs[_];if(typeof A=="function"){try{h=A(P)}catch($){h=$}if(h instanceof Error){U=h;return}}else h=$e.require(P);H(h)}catch(h){h.name==="PermissionDenied"?U=h:l[_]&&(U=Error(O("Invalid JSON config file: %s",y)))}})}function H(l,d){Object.keys(l).forEach(function(_){let y=l[_],h=d?d+"."+_:_;typeof y=="object"&&y!==null&&!Array.isArray(y)&&c["dot-notation"]?H(y,h):(!Ie(z,h.split("."))||R(h,f.arrays)&&c["combine-arrays"])&&Y(h,y)})}function se(){typeof g<"u"&&g.forEach(function(l){H(l)})}function V(l,d){if(typeof p>"u")return;let _=typeof p=="string"?p:"",y=$e.env();Object.keys(y).forEach(function(h){if(_===""||h.lastIndexOf(_,0)===0){let P=h.split("__").map(function(A,$){return $===0&&(A=A.substring(_.length)),ze(A)});(d&&f.configs[P.join(".")]||!d)&&!Ie(l,P)&&Y(P.join("."),y[h])}})}function re(l){let d,_=new Set;Object.keys(l).forEach(function(y){if(!_.has(y)&&(d=R(y,f.coercions),typeof d=="function"))try{let h=M(y,d(l[y]));[].concat(f.aliases[y]||[],y).forEach(P=>{_.add(P),l[P]=h})}catch(h){U=h}})}function Ue(l){return f.keys.forEach(d=>{~d.indexOf(".")||typeof l[d]>"u"&&(l[d]=void 0)}),l}function Z(l,d,_,y=!1){Object.keys(_).forEach(function(h){Ie(l,h.split("."))||(ve(l,h.split("."),_[h]),y&&(C[h]=!0),(d[h]||[]).forEach(function(P){Ie(l,P.split("."))||ve(l,P.split("."),_[h])}))})}function Ie(l,d){let _=l;c["dot-notation"]||(d=[d.join(".")]),d.slice(0,-1).forEach(function(h){_=_[h]||{}});let y=d[d.length-1];return typeof _!="object"?!1:y in _}function ve(l,d,_){let y=l;c["dot-notation"]||(d=[d.join(".")]),d.slice(0,-1).forEach(function(oe){oe=ai(oe),typeof y=="object"&&y[oe]===void 0&&(y[oe]={}),typeof y[oe]!="object"||Array.isArray(y[oe])?(Array.isArray(y[oe])?y[oe].push({}):y[oe]=[y[oe],{}],y=y[oe][y[oe].length-1]):y=y[oe]});let h=ai(d[d.length-1]),P=R(d.join("."),f.arrays),A=Array.isArray(_),$=c["duplicate-arguments-array"];!$&&R(h,f.nargs)&&($=!0,(!xe(y[h])&&f.nargs[h]===1||Array.isArray(y[h])&&y[h].length===f.nargs[h])&&(y[h]=void 0)),_===an()?y[h]=an(y[h]):Array.isArray(y[h])?$&&P&&A?y[h]=c["flatten-duplicate-arrays"]?y[h].concat(_):(Array.isArray(y[h][0])?y[h]:[y[h]]).concat([_]):!$&&!!P==!!A?y[h]=_:y[h]=y[h].concat([_]):y[h]===void 0&&P?y[h]=A?_:[_]:$&&!(y[h]===void 0||R(h,f.counts)||R(h,f.bools))?y[h]=[y[h],_]:y[h]=_}function Be(...l){l.forEach(function(d){Object.keys(d||{}).forEach(function(_){f.aliases[_]||(f.aliases[_]=[].concat(a[_]||[]),f.aliases[_].concat(_).forEach(function(y){if(/-/.test(y)&&c["camel-case-expansion"]){let h=ze(y);h!==_&&f.aliases[_].indexOf(h)===-1&&(f.aliases[_].push(h),w[h]=!0)}}),f.aliases[_].concat(_).forEach(function(y){if(y.length>1&&/[A-Z]/.test(y)&&c["camel-case-expansion"]){let h=vt(y,"-");h!==_&&f.aliases[_].indexOf(h)===-1&&(f.aliases[_].push(h),w[h]=!0)}}),f.aliases[_].forEach(function(y){f.aliases[y]=[_].concat(f.aliases[_].filter(function(h){return y!==h}))}))})})}function R(l,d){let _=[].concat(f.aliases[l]||[],l),y=Object.keys(d),h=_.find(P=>y.includes(P));return h?d[h]:!1}function Yt(l){let d=Object.keys(f);return[].concat(d.map(y=>f[y])).some(function(y){return Array.isArray(y)?y.includes(l):y[l]})}function F(l,...d){return[].concat(...d).some(function(y){let h=l.match(y);return h&&Yt(h[1])})}function J(l){if(l.match(x)||!l.match(/^-[^-]+/))return!1;let d=!0,_,y=l.slice(1).split("");for(let h=0;h<y.length;h++){if(_=l.slice(h+2),!Yt(y[h])){d=!1;break}if(y[h+1]&&y[h+1]==="="||_==="-"||/[A-Za-z]/.test(y[h])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(_)||y[h+1]&&y[h+1].match(/\W/))break}return d}function k(l){return c["unknown-options-as-args"]&&B(l)}function B(l){return l=l.replace(/^-{3,}/,"--"),l.match(x)||J(l)?!1:!F(l,/^-+([^=]+?)=[\s\S]*$/,N,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function ee(l){return!R(l,f.bools)&&!R(l,f.counts)&&`${l}`in b?b[l]:ne(Ce(l))}function ne(l){return{[be.BOOLEAN]:!0,[be.STRING]:"",[be.NUMBER]:void 0,[be.ARRAY]:[]}[l]}function Ce(l){let d=be.BOOLEAN;return R(l,f.strings)?d=be.STRING:R(l,f.numbers)?d=be.NUMBER:R(l,f.bools)?d=be.BOOLEAN:R(l,f.arrays)&&(d=be.ARRAY),d}function xe(l){return l===void 0}function yt(){Object.keys(f.counts).find(l=>R(l,f.arrays)?(U=Error(O("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0):R(l,f.nargs)?(U=Error(O("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0):!1)}return{aliases:Object.assign({},f.aliases),argv:Object.assign(le,z),configuration:c,defaulted:Object.assign({},C),error:U,newAliases:Object.assign({},w)}}};function qs(i){let e=[],t=Object.create(null),n=!0;for(Object.keys(i).forEach(function(s){e.push([].concat(i[s],s))});n;){n=!1;for(let s=0;s<e.length;s++)for(let r=s+1;r<e.length;r++)if(e[s].filter(function(c){return e[r].indexOf(c)!==-1}).length){e[s]=e[s].concat(e[r]),e.splice(r,1),n=!0;break}}return e.forEach(function(s){s=s.filter(function(a,c,b){return b.indexOf(a)===c});let r=s.pop();r!==void 0&&typeof r=="string"&&(t[r]=s)}),t}function an(i){return i!==void 0?i+1:1}function ai(i){return i==="__proto__"?"___proto___":i}function Ks(i){return typeof i=="string"&&(i[0]==="'"||i[0]==='"')&&i[i.length-1]===i[0]?i.substring(1,i.length-1):i}import{readFileSync as Xs}from"fs";var ln,cn,fn,li=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,ci=(cn=(ln=process==null?void 0:process.versions)===null||ln===void 0?void 0:ln.node)!==null&&cn!==void 0?cn:(fn=process==null?void 0:process.version)===null||fn===void 0?void 0:fn.slice(1);if(ci&&Number(ci.match(/^([^.]+)/)[1])<li)throw Error(`yargs parser supports a minimum Node.js version of ${li}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var ks=process?process.env:{},fi=new Nt({cwd:process.cwd,env:()=>ks,format:Js,normalize:Qs,resolve:Zs,require:i=>{if(typeof Se<"u")return Se(i);if(i.match(/\.json$/))return JSON.parse(Xs(i,"utf8"));throw Error("only .json config files are supported in ESM")}}),ht=function(e,t){return fi.parse(e.slice(),t).argv};ht.detailed=function(i,e){return fi.parse(i.slice(),e)};ht.camelCase=ze;ht.decamelize=vt;ht.looksLikeNumber=$t;var un=ht;import{basename as dr,dirname as pr,extname as mr,relative as gr,resolve as gi}from"path";function ui(){return er()?0:1}function er(){return tr()&&!process.defaultApp}function tr(){return!!process.versions.electron}function hn(i){return i.slice(ui()+1)}function hi(){return process.argv[ui()]}var q=class i extends Error{constructor(e){super(e||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,i)}};import{readFileSync as nr,statSync as ir,writeFile as sr}from"fs";import{format as rr}from"util";import{resolve as or}from"path";var di={fs:{readFileSync:nr,writeFile:sr},format:rr,resolve:or,exists:i=>{try{return ir(i).isFile()}catch{return!1}}};var Ae,dn=class{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles=="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage=="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};return typeof e[e.length-1]=="function"&&(n=e.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),Ae.format.apply(Ae.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),s=e.shift(),r=function(){};typeof e[e.length-1]=="function"&&(r=e.pop()),this.cache[this.locale]||this._readLocaleFile();let a=s===1?t:n;this.cache[this.locale][t]&&(a=this.cache[this.locale][t][s===1?"one":"other"]),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:r})):r();let c=[a];return~a.indexOf("%d")&&c.push(s),Ae.format.apply(Ae.format,c.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){this.cache[this.locale]||this._readLocaleFile();for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(this.cache[this.locale][t]=e[t])}_taggedLiteral(e,...t){let n="";return e.forEach(function(s,r){let a=t[r+1];n+=s,typeof a<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){this.writeQueue.push(e),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,s=t.locale,r=t.cb,a=this._resolveLocaleFile(n,s),c=JSON.stringify(this.cache[s],null,2);Ae.fs.writeFile(a,c,"utf-8",function(b){e.writeQueue.shift(),e.writeQueue.length>0&&e._processWriteQueue(),r(b)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{Ae.fs.readFileSync&&(e=JSON.parse(Ae.fs.readFileSync(t,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+t),n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=Ae.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let s=Ae.resolve(e,"./",t.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(e){return Ae.exists(e)}};function pi(i,e){Ae=e;let t=new dn(i);return{__:t.__.bind(t),__n:t.__n.bind(t),setLocale:t.setLocale.bind(t),getLocale:t.getLocale.bind(t),updateLocale:t.updateLocale.bind(t),locale:t.locale}}var ar=i=>pi(i,di),mi=ar;var br="require is not supported by ESM",bi="loading a directory of commands is not supported yet for ESM",dt;try{dt=hr(import.meta.url)}catch{dt=process.cwd()}var yr=dt.substring(0,dt.lastIndexOf("node_modules")),pn={assert:{notStrictEqual:lr,strictEqual:cr},cliui:on,findUp:ri,getEnv:i=>process.env[i],inspect:fr,getCallerFile:()=>{throw new q(bi)},getProcessArgvBin:hi,mainFilename:yr||process.cwd(),Parser:un,path:{basename:dr,dirname:pr,extname:mr,relative:gr,resolve:gi},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(i,e)=>process.emitWarning(i,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:ur,require:()=>{throw new q(br)},requireDirectory:()=>{throw new q(bi)},stringWidth:i=>[...i].length,y18n:mi({directory:gi(dt,"../../../locales"),updateFiles:!1})};function ue(i,e,t,n){t.assert.notStrictEqual(i,e,n)}function mn(i,e){e.assert.strictEqual(typeof i,"string")}function st(i){return Object.keys(i)}function K(i){return!!i&&!!i.then&&typeof i.then=="function"}function Ne(i){let t=i.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,s=t.shift();if(!s)throw new Error(`No command found in: ${i}`);let r={cmd:s.replace(n,""),demanded:[],optional:[]};return t.forEach((a,c)=>{let b=!1;a=a.replace(/\s/g,""),/\.+[\]>]/.test(a)&&c===t.length-1&&(b=!0),/^\[/.test(a)?r.optional.push({cmd:a.replace(n,"").split("|"),variadic:b}):r.demanded.push({cmd:a.replace(n,"").split("|"),variadic:b})}),r}var wr=["first","second","third","fourth","fifth","sixth"];function S(i,e,t){function n(){return typeof i=="object"?[{demanded:[],optional:[]},i,e]:[Ne(`cmd ${i}`),e,t]}try{let s=0,[r,a,c]=n(),b=[].slice.call(a);for(;b.length&&b[b.length-1]===void 0;)b.pop();let g=c||b.length;if(g<r.demanded.length)throw new q(`Not enough arguments provided. Expected ${r.demanded.length} but received ${b.length}.`);let p=r.demanded.length+r.optional.length;if(g>p)throw new q(`Too many arguments provided. Expected max ${p} but received ${g}.`);r.demanded.forEach(u=>{let m=b.shift(),w=yi(m);u.cmd.filter(O=>O===w||O==="*").length===0&&wi(w,u.cmd,s),s+=1}),r.optional.forEach(u=>{if(b.length===0)return;let m=b.shift(),w=yi(m);u.cmd.filter(O=>O===w||O==="*").length===0&&wi(w,u.cmd,s),s+=1})}catch(s){console.warn(s.stack)}}function yi(i){return Array.isArray(i)?"array":i===null?"null":typeof i}function wi(i,e,t){throw new q(`Invalid ${wr[t]||"manyith"} argument. Expected ${e.join(" or ")} but received ${i}.`)}var Ft=class{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,s=!1){if(S("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let r=0;r<e.length;r++){if(typeof e[r]!="function")throw Error("middleware must be a function");let a=e[r];a.applyBeforeValidation=t,a.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e=="function"){let r=e;r.applyBeforeValidation=t,r.global=n,r.mutates=s,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(s=>{let r=[...n[t]||[],t];return s.option?!r.includes(s.option):!0}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();e!==void 0&&(this.globalMiddleware=e)}reset(){this.globalMiddleware=this.globalMiddleware.filter(e=>e.global)}};function Oi(i){return i?i.map(e=>(e.applyBeforeValidation=!1,e)):[]}function Ve(i,e,t,n){return t.reduce((s,r)=>{if(r.applyBeforeValidation!==n)return s;if(r.mutates){if(r.applied)return s;r.applied=!0}if(K(s))return s.then(a=>Promise.all([a,r(a,e)])).then(([a,c])=>Object.assign(a,c));{let a=r(s,e);return K(a)?a.then(c=>Object.assign(s,c)):Object.assign(s,a)}},i)}function He(i,e,t=n=>{throw n}){try{let n=Or(i)?i():i;return K(n)?n.then(s=>e(s)):e(n)}catch(n){return t(n)}}function Or(i){return typeof i=="function"}function gn(i){if(typeof Se>"u")return null;for(let e=0,t=Object.keys(Se.cache),n;e<t.length;e++)if(n=Se.cache[t[e]],n.exports===i)return n;return null}var rt=/(^\*)|(^\$0)/,bn=class{constructor(e,t,n,s){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=s,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,s){s=s||{},typeof s.recurse!="boolean"&&(s.recurse=!1),Array.isArray(s.extensions)||(s.extensions=["js"]);let r=typeof s.visit=="function"?s.visit:a=>a;s.visit=(a,c,b)=>{let g=r(a,c,b);if(g){if(this.requireCache.has(c))return g;this.requireCache.add(c),this.addHandler(g)}return g},this.shim.requireDirectory({require:t,filename:n},e,s)}addHandler(e,t,n,s,r,a){let c=[],b=Oi(r);if(s=s||(()=>{}),Array.isArray(e))if(_r(e))[e,...c]=e;else for(let g of e)this.addHandler(g);else if(xr(e)){let g=Array.isArray(e.command)||typeof e.command=="string"?e.command:this.moduleName(e);e.aliases&&(g=[].concat(g).concat(e.aliases)),this.addHandler(g,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(_i(n)){this.addHandler([e].concat(c),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e=="string"){let g=Ne(e);c=c.map(m=>Ne(m).cmd);let p=!1,u=[g.cmd].concat(c).filter(m=>rt.test(m)?(p=!0,!1):!0);u.length===0&&p&&u.push("$0"),p&&(g.cmd=u[0],c=u.slice(1),e=e.replace(rt,g.cmd)),c.forEach(m=>{this.aliasMap[m]=g.cmd}),t!==!1&&this.usage.command(e,t,p,c,a),this.handlers[g.cmd]={original:e,description:t,handler:s,builder:n||{},middlewares:b,deprecated:a,demanded:g.demanded,optional:g.optional},p&&(this.defaultCommand=this.handlers[g.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,s,r,a){let c=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,b=t.getInternalMethods().getContext(),g=b.commands.slice(),p=!e;e&&(b.commands.push(e),b.fullCommands.push(c.original));let u=this.applyBuilderUpdateUsageAndParse(p,c,t,n.aliases,g,s,r,a);return K(u)?u.then(m=>this.applyMiddlewareAndGetResult(p,c,m.innerArgv,b,r,m.aliases,t)):this.applyMiddlewareAndGetResult(p,c,u.innerArgv,b,r,u.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,s,r,a,c,b){let g=t.builder,p=n;if(Rt(g)){n.getInternalMethods().getUsageInstance().freeze();let u=g(n.getInternalMethods().reset(s),b);if(K(u))return u.then(m=>(p=xi(m)?m:n,this.parseAndUpdateUsage(e,t,p,r,a,c)))}else Cr(g)&&(n.getInternalMethods().getUsageInstance().freeze(),p=n.getInternalMethods().reset(s),Object.keys(t.builder).forEach(u=>{p.option(u,g[u])}));return this.parseAndUpdateUsage(e,t,p,r,a,c)}parseAndUpdateUsage(e,t,n,s,r,a){e&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(s,t),t.description);let c=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,a);return K(c)?c.then(b=>({aliases:n.parsed.aliases,innerArgv:b})):{aliases:n.parsed.aliases,innerArgv:c}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=rt.test(t.original)?t.original.replace(rt,"").trim():t.original,s=e.filter(r=>!rt.test(r));return s.push(n),`$0 ${s.join(" ")}`}handleValidationAndGetResult(e,t,n,s,r,a,c,b){if(!a.getInternalMethods().getHasOutput()){let g=a.getInternalMethods().runValidation(r,b,a.parsed.error,e);n=He(n,p=>(g(p),p))}if(t.handler&&!a.getInternalMethods().getHasOutput()){a.getInternalMethods().setHasOutput();let g=!!a.getOptions().configuration["populate--"];a.getInternalMethods().postProcess(n,g,!1,!1),n=Ve(n,a,c,!1),n=He(n,p=>{let u=t.handler(p);return K(u)?u.then(()=>p):p}),e||a.getInternalMethods().getUsageInstance().cacheHelpMessage(),K(n)&&!a.getInternalMethods().hasParseCallback()&&n.catch(p=>{try{a.getInternalMethods().getUsageInstance().fail(null,p)}catch{}})}return e||(s.commands.pop(),s.fullCommands.pop()),n}applyMiddlewareAndGetResult(e,t,n,s,r,a,c){let b={};if(r)return n;c.getInternalMethods().getHasOutput()||(b=this.populatePositionals(t,n,s,c));let g=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),p=Ve(n,c,g,!0);return K(p)?p.then(u=>this.handleValidationAndGetResult(e,t,u,s,a,c,g,b)):this.handleValidationAndGetResult(e,t,p,s,a,c,g,b)}populatePositionals(e,t,n,s){t._=t._.slice(n.commands.length);let r=e.demanded.slice(0),a=e.optional.slice(0),c={};for(this.validation.positionalCount(r.length,t._.length);r.length;){let b=r.shift();this.populatePositional(b,t,c)}for(;a.length;){let b=a.shift();this.populatePositional(b,t,c)}return t._=n.commands.concat(t._.map(b=>""+b)),this.postProcessPositionals(t,c,this.cmdToParseOptions(e.original),s),c}populatePositional(e,t,n){let s=e.cmd[0];e.variadic?n[s]=t._.splice(0).map(String):t._.length&&(n[s]=[String(t._.shift())])}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=Ne(e);return n.demanded.forEach(s=>{let[r,...a]=s.cmd;s.variadic&&(t.array.push(r),t.default[r]=[]),t.alias[r]=a,t.demand[r]=!0}),n.optional.forEach(s=>{let[r,...a]=s.cmd;s.variadic&&(t.array.push(r),t.default[r]=[]),t.alias[r]=a}),t}postProcessPositionals(e,t,n,s){let r=Object.assign({},s.getOptions());r.default=Object.assign(n.default,r.default);for(let g of Object.keys(n.alias))r.alias[g]=(r.alias[g]||[]).concat(n.alias[g]);r.array=r.array.concat(n.array),r.config={};let a=[];if(Object.keys(t).forEach(g=>{t[g].map(p=>{r.configuration["unknown-options-as-args"]&&(r.key[g]=!0),a.push(`--${g}`),a.push(p)})}),!a.length)return;let c=Object.assign({},r.configuration,{"populate--":!1}),b=this.shim.Parser.detailed(a,Object.assign({},r,{configuration:c}));if(b.error)s.getInternalMethods().getUsageInstance().fail(b.error.message,b.error);else{let g=Object.keys(t);Object.keys(t).forEach(p=>{g.push(...b.aliases[p])}),Object.keys(b.argv).forEach(p=>{g.includes(p)&&(t[p]||(t[p]=b.argv[p]),!this.isInConfigs(s,p)&&!this.isDefaulted(s,p)&&Object.prototype.hasOwnProperty.call(e,p)&&Object.prototype.hasOwnProperty.call(b.argv,p)&&(Array.isArray(e[p])||Array.isArray(b.argv[p]))?e[p]=[].concat(e[p],b.argv[p]):e[p]=b.argv[p])})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some(s=>Object.prototype.hasOwnProperty.call(s,t))||n.some(s=>Object.prototype.hasOwnProperty.call(s,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=rt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(Rt(t))return t(e,!0);_i(t)||Object.keys(t).forEach(n=>{e.option(n,t[n])})}moduleName(e){let t=gn(e);if(!t)throw new Error(`No command name given for module: ${this.shim.inspect(e)}`);return this.commandFromFilename(t.filename)}commandFromFilename(e){return this.shim.path.basename(e,this.shim.path.extname(e))}extractDesc({describe:e,description:t,desc:n}){for(let s of[e,t,n]){if(typeof s=="string"||s===!1)return s;ue(s,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();ue(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function Ci(i,e,t,n){return new bn(i,e,t,n)}function _i(i){return typeof i=="object"&&!!i.builder&&typeof i.handler=="function"}function _r(i){return i.every(e=>typeof e=="string")}function Rt(i){return typeof i=="function"}function Cr(i){return typeof i=="object"}function xr(i){return typeof i=="object"&&!Array.isArray(i)}function Fe(i={},e=()=>!0){let t={};return st(i).forEach(n=>{e(n,i[n])&&(t[n]=i[n])}),t}function Re(i){typeof process>"u"||[process.stdout,process.stderr].forEach(e=>{let t=e;t._handle&&t.isTTY&&typeof t._handle.setBlocking=="function"&&t._handle.setBlocking(i)})}function Er(i){return typeof i=="boolean"}function Ai(i,e){let t=e.y18n.__,n={},s=[];n.failFn=function(E){s.push(E)};let r=null,a=null,c=!0;n.showHelpOnFail=function(E=!0,M){let[L,H]=typeof E=="string"?[!0,E]:[E,M];return i.getInternalMethods().isGlobalContext()&&(a=H),r=H,c=L,n};let b=!1;n.fail=function(E,M){let L=i.getInternalMethods().getLoggerInstance();if(s.length)for(let H=s.length-1;H>=0;--H){let se=s[H];if(Er(se)){if(M)throw M;if(E)throw Error(E)}else se(E,M,n)}else{if(i.getExitProcess()&&Re(!0),!b){b=!0,c&&(i.showHelp("error"),L.error()),(E||M)&&L.error(E||M);let H=r||a;H&&((E||M)&&L.error(""),L.error(H))}if(M=M||new q(E),i.getExitProcess())return i.exit(1);if(i.getInternalMethods().hasParseCallback())return i.exit(1,M);throw M}};let g=[],p=!1;n.usage=(I,E)=>I===null?(p=!0,g=[],n):(p=!1,g.push([I,E||""]),n),n.getUsage=()=>g,n.getUsageDisabled=()=>p,n.getPositionalGroupName=()=>t("Positionals:");let u=[];n.example=(I,E)=>{u.push([I,E||""])};let m=[];n.command=function(E,M,L,H,se=!1){L&&(m=m.map(V=>(V[2]=!1,V))),m.push([E,M||"",L,H,se])},n.getCommands=()=>m;let w={};n.describe=function(E,M){Array.isArray(E)?E.forEach(L=>{n.describe(L,M)}):typeof E=="object"?Object.keys(E).forEach(L=>{n.describe(L,E[L])}):w[E]=M},n.getDescriptions=()=>w;let C=[];n.epilog=I=>{C.push(I)};let O=!1,f;n.wrap=I=>{O=!0,f=I},n.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(O||(f=tt(),O=!0),f);let x="__yargsString__:";n.deferY18nLookup=I=>x+I,n.help=function(){if(W)return W;U();let E=i.customScriptName?i.$0:e.path.basename(i.$0),M=i.getDemandedOptions(),L=i.getDemandedCommands(),H=i.getDeprecatedOptions(),se=i.getGroups(),V=i.getOptions(),re=[];re=re.concat(Object.keys(w)),re=re.concat(Object.keys(M)),re=re.concat(Object.keys(L)),re=re.concat(Object.keys(V.default)),re=re.filter(le),re=Object.keys(re.reduce((F,J)=>(J!=="_"&&(F[J]=!0),F),{}));let Ue=n.getWrap(),Z=e.cliui({width:Ue,wrap:!!Ue});if(!p){if(g.length)g.forEach(F=>{Z.div({text:`${F[0].replace(/\$0/g,E)}`}),F[1]&&Z.div({text:`${F[1]}`,padding:[1,0,0,0]})}),Z.div();else if(m.length){let F=null;L._?F=`${E} <${t("command")}>
|
|
14
|
-
`:F=`${E} [${t("command")}]
|
|
15
|
-
`,Z.div(`${F}`)}}if(m.length>1||m.length===1&&!m[0][2]){Z.div(t("Commands:"));let F=i.getInternalMethods().getContext(),J=F.commands.length?`${F.commands.join(" ")} `:"";i.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(m=m.sort((B,ee)=>B[0].localeCompare(ee[0])));let k=E?`${E} `:"";m.forEach(B=>{let ee=`${k}${J}${B[0].replace(/^\$0 ?/,"")}`;Z.span({text:ee,padding:[0,2,0,2],width:N(m,Ue,`${E}${J}`)+4},{text:B[1]});let ne=[];B[2]&&ne.push(`[${t("default")}]`),B[3]&&B[3].length&&ne.push(`[${t("aliases:")} ${B[3].join(", ")}]`),B[4]&&(typeof B[4]=="string"?ne.push(`[${t("deprecated: %s",B[4])}]`):ne.push(`[${t("deprecated")}]`)),ne.length?Z.div({text:ne.join(" "),padding:[0,0,0,2],align:"right"}):Z.div()}),Z.div()}let Ie=(Object.keys(V.alias)||[]).concat(Object.keys(i.parsed.newAliases)||[]);re=re.filter(F=>!i.parsed.newAliases[F]&&Ie.every(J=>(V.alias[J]||[]).indexOf(F)===-1));let ve=t("Options:");se[ve]||(se[ve]=[]),z(re,V.alias,se,ve);let Be=F=>/^--/.test(Dt(F)),R=Object.keys(se).filter(F=>se[F].length>0).map(F=>{let J=se[F].filter(le).map(k=>{if(Ie.includes(k))return k;for(let B=0,ee;(ee=Ie[B])!==void 0;B++)if((V.alias[ee]||[]).includes(k))return ee;return k});return{groupName:F,normalizedKeys:J}}).filter(({normalizedKeys:F})=>F.length>0).map(({groupName:F,normalizedKeys:J})=>{let k=J.reduce((B,ee)=>(B[ee]=[ee].concat(V.alias[ee]||[]).map(ne=>F===n.getPositionalGroupName()?ne:(/^[0-9]$/.test(ne)?V.boolean.includes(ee)?"-":"--":ne.length>1?"--":"-")+ne).sort((ne,Ce)=>Be(ne)===Be(Ce)?0:Be(ne)?1:-1).join(", "),B),{});return{groupName:F,normalizedKeys:J,switches:k}});if(R.filter(({groupName:F})=>F!==n.getPositionalGroupName()).some(({normalizedKeys:F,switches:J})=>!F.every(k=>Be(J[k])))&&R.filter(({groupName:F})=>F!==n.getPositionalGroupName()).forEach(({normalizedKeys:F,switches:J})=>{F.forEach(k=>{Be(J[k])&&(J[k]=Ar(J[k],4))})}),R.forEach(({groupName:F,normalizedKeys:J,switches:k})=>{Z.div(F),J.forEach(B=>{let ee=k[B],ne=w[B]||"",Ce=null;ne.includes(x)&&(ne=t(ne.substring(x.length))),V.boolean.includes(B)&&(Ce=`[${t("boolean")}]`),V.count.includes(B)&&(Ce=`[${t("count")}]`),V.string.includes(B)&&(Ce=`[${t("string")}]`),V.normalize.includes(B)&&(Ce=`[${t("string")}]`),V.array.includes(B)&&(Ce=`[${t("array")}]`),V.number.includes(B)&&(Ce=`[${t("number")}]`);let xe=d=>typeof d=="string"?`[${t("deprecated: %s",d)}]`:`[${t("deprecated")}]`,yt=[B in H?xe(H[B]):null,Ce,B in M?`[${t("required")}]`:null,V.choices&&V.choices[B]?`[${t("choices:")} ${n.stringifiedValues(V.choices[B])}]`:null,ce(V.default[B],V.defaultDescription[B])].filter(Boolean).join(" ");Z.span({text:Dt(ee),padding:[0,2,0,2+Ei(ee)],width:N(k,Ue)+4},ne);let l=i.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;yt&&!l?Z.div({text:yt,padding:[0,0,0,2],align:"right"}):Z.div()}),Z.div()}),u.length&&(Z.div(t("Examples:")),u.forEach(F=>{F[0]=F[0].replace(/\$0/g,E)}),u.forEach(F=>{F[1]===""?Z.div({text:F[0],padding:[0,2,0,2]}):Z.div({text:F[0],padding:[0,2,0,2],width:N(u,Ue)+4},{text:F[1]})}),Z.div()),C.length>0){let F=C.map(J=>J.replace(/\$0/g,E)).join(`
|
|
16
|
-
`);Z.div(`${F}
|
|
17
|
-
`)}return Z.toString().replace(/\s*$/,"")};function N(I,E,M){let L=0;return Array.isArray(I)||(I=Object.values(I).map(H=>[H])),I.forEach(H=>{L=Math.max(e.stringWidth(M?`${M} ${Dt(H[0])}`:Dt(H[0]))+Ei(H[0]),L)}),E&&(L=Math.min(L,parseInt((E*.5).toString(),10))),L}function U(){let I=i.getDemandedOptions(),E=i.getOptions();(Object.keys(E.alias)||[]).forEach(M=>{E.alias[M].forEach(L=>{w[L]&&n.describe(M,w[L]),L in I&&i.demandOption(M,I[L]),E.boolean.includes(L)&&i.boolean(M),E.count.includes(L)&&i.count(M),E.string.includes(L)&&i.string(M),E.normalize.includes(L)&&i.normalize(M),E.array.includes(L)&&i.array(M),E.number.includes(L)&&i.number(M)})})}let W;n.cacheHelpMessage=function(){W=this.help()},n.clearCachedHelpMessage=function(){W=void 0},n.hasCachedHelpMessage=function(){return!!W};function z(I,E,M,L){let H=[],se=null;return Object.keys(M).forEach(V=>{H=H.concat(M[V])}),I.forEach(V=>{se=[V].concat(E[V]),se.some(re=>H.indexOf(re)!==-1)||M[L].push(V)}),H}function le(I){return i.getOptions().hiddenOptions.indexOf(I)<0||i.parsed.argv[i.getOptions().showHiddenOpt]}n.showHelp=I=>{let E=i.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:E[I])(n.help())},n.functionDescription=I=>["(",I.name?e.Parser.decamelize(I.name,"-"):t("generated-value"),")"].join(""),n.stringifiedValues=function(E,M){let L="",H=M||", ",se=[].concat(E);return!E||!se.length||se.forEach(V=>{L.length&&(L+=H),L+=JSON.stringify(V)}),L};function ce(I,E){let M=`[${t("default:")} `;if(I===void 0&&!E)return null;if(E)M+=E;else switch(typeof I){case"string":M+=`"${I}"`;break;case"object":M+=JSON.stringify(I);break;default:M+=I}return`${M}]`}function tt(){return e.process.stdColumns?Math.min(80,e.process.stdColumns):80}let We=null;n.version=I=>{We=I},n.showVersion=I=>{let E=i.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:E[I])(We)},n.reset=function(E){return r=null,b=!1,g=[],p=!1,C=[],u=[],m=[],w=Fe(w,M=>!E[M]),n};let Y=[];return n.freeze=function(){Y.push({failMessage:r,failureOutput:b,usages:g,usageDisabled:p,epilogs:C,examples:u,commands:m,descriptions:w})},n.unfreeze=function(E=!1){let M=Y.pop();M&&(E?(w={...M.descriptions,...w},m=[...M.commands,...m],g=[...M.usages,...g],u=[...M.examples,...u],C=[...M.epilogs,...C]):{failMessage:r,failureOutput:b,usages:g,usageDisabled:p,epilogs:C,examples:u,commands:m,descriptions:w}=M)},n}function yn(i){return typeof i=="object"}function Ar(i,e){return yn(i)?{text:i.text,indentation:i.indentation+e}:{text:i,indentation:e}}function Ei(i){return yn(i)?i.indentation:0}function Dt(i){return yn(i)?i.text:i}var Si=`###-begin-{{app_name}}-completions-###
|
|
18
|
-
#
|
|
19
|
-
# yargs command completion script
|
|
20
|
-
#
|
|
21
|
-
# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
|
|
22
|
-
# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
|
|
23
|
-
#
|
|
24
|
-
_{{app_name}}_yargs_completions()
|
|
25
|
-
{
|
|
26
|
-
local cur_word args type_list
|
|
27
|
-
|
|
28
|
-
cur_word="\${COMP_WORDS[COMP_CWORD]}"
|
|
29
|
-
args=("\${COMP_WORDS[@]}")
|
|
30
|
-
|
|
31
|
-
# ask yargs to generate completions.
|
|
32
|
-
type_list=$({{app_path}} --get-yargs-completions "\${args[@]}")
|
|
33
|
-
|
|
34
|
-
COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) )
|
|
35
|
-
|
|
36
|
-
# if no match was found, fall back to filename completion
|
|
37
|
-
if [ \${#COMPREPLY[@]} -eq 0 ]; then
|
|
38
|
-
COMPREPLY=()
|
|
39
|
-
fi
|
|
40
|
-
|
|
41
|
-
return 0
|
|
42
|
-
}
|
|
43
|
-
complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
|
|
44
|
-
###-end-{{app_name}}-completions-###
|
|
45
|
-
`,ji=`#compdef {{app_name}}
|
|
46
|
-
###-begin-{{app_name}}-completions-###
|
|
47
|
-
#
|
|
48
|
-
# yargs command completion script
|
|
49
|
-
#
|
|
50
|
-
# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
|
|
51
|
-
# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.
|
|
52
|
-
#
|
|
53
|
-
_{{app_name}}_yargs_completions()
|
|
54
|
-
{
|
|
55
|
-
local reply
|
|
56
|
-
local si=$IFS
|
|
57
|
-
IFS=$'
|
|
58
|
-
' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
|
|
59
|
-
IFS=$si
|
|
60
|
-
_describe 'values' reply
|
|
61
|
-
}
|
|
62
|
-
compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
63
|
-
###-end-{{app_name}}-completions-###
|
|
64
|
-
`;var wn=class{constructor(e,t,n,s){var r,a,c;this.yargs=e,this.usage=t,this.command=n,this.shim=s,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(c=((r=this.shim.getEnv("SHELL"))===null||r===void 0?void 0:r.includes("zsh"))||((a=this.shim.getEnv("ZSH_NAME"))===null||a===void 0?void 0:a.includes("zsh")))!==null&&c!==void 0?c:!1}defaultCompletion(e,t,n,s){let r=this.command.getCommandHandlers();for(let c=0,b=e.length;c<b;++c)if(r[e[c]]&&r[e[c]].builder){let g=r[e[c]].builder;if(Rt(g)){this.indexAfterLastReset=c+1;let p=this.yargs.getInternalMethods().reset();return g(p,!0),p.argv}}let a=[];this.commandCompletions(a,e,n),this.optionCompletions(a,e,t,n),this.choicesFromOptionsCompletions(a,e,t,n),this.choicesFromPositionalsCompletions(a,e,t,n),s(null,a)}commandCompletions(e,t,n){let s=this.yargs.getInternalMethods().getContext().commands;!n.match(/^-/)&&s[s.length-1]!==n&&!this.previousArgHasChoices(t)&&this.usage.getCommands().forEach(r=>{let a=Ne(r[0]).cmd;if(t.indexOf(a)===-1)if(!this.zshShell)e.push(a);else{let c=r[1]||"";e.push(a.replace(/:/g,"\\:")+":"+c)}})}optionCompletions(e,t,n,s){if((s.match(/^-/)||s===""&&e.length===0)&&!this.previousArgHasChoices(t)){let r=this.yargs.getOptions(),a=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(r.key).forEach(c=>{let b=!!r.configuration["boolean-negation"]&&r.boolean.includes(c);!a.includes(c)&&!r.hiddenOptions.includes(c)&&!this.argsContainKey(t,c,b)&&this.completeOptionKey(c,e,s,b&&!!r.default[c])})}}choicesFromOptionsCompletions(e,t,n,s){if(this.previousArgHasChoices(t)){let r=this.getPreviousArgChoices(t);r&&r.length>0&&e.push(...r.map(a=>a.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,s){if(s===""&&e.length>0&&this.previousArgHasChoices(t))return;let r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],a=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),c=r[n._.length-a-1];if(!c)return;let b=this.yargs.getOptions().choices[c]||[];for(let g of b)g.startsWith(s)&&e.push(g.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1&&(n=t,t=e[e.length-2]),!t.startsWith("-"))return;let s=t.replace(/^-+/,""),r=this.yargs.getOptions(),a=[s,...this.yargs.getAliases()[s]||[]],c;for(let b of a)if(Object.prototype.hasOwnProperty.call(r.key,b)&&Array.isArray(r.choices[b])){c=r.choices[b];break}if(c)return c.filter(b=>!n||b.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let s=r=>e.indexOf((/^[^0-9]$/.test(r)?"-":"--")+r)!==-1;if(s(t)||n&&s(`no-${t}`))return!0;if(this.aliases){for(let r of this.aliases[t])if(s(r))return!0}return!1}completeOptionKey(e,t,n,s){var r,a,c,b;let g=e;if(this.zshShell){let w=this.usage.getDescriptions(),C=(a=(r=this===null||this===void 0?void 0:this.aliases)===null||r===void 0?void 0:r[e])===null||a===void 0?void 0:a.find(x=>{let N=w[x];return typeof N=="string"&&N.length>0}),O=C?w[C]:void 0,f=(b=(c=w[e])!==null&&c!==void 0?c:O)!==null&&b!==void 0?b:"";g=`${e.replace(/:/g,"\\:")}:${f.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let p=w=>/^--/.test(w),u=w=>/^[^0-9]$/.test(w),m=!p(n)&&u(e)?"-":"--";t.push(m+g),s&&t.push(m+"no-"+g)}customCompletion(e,t,n,s){if(ue(this.customCompletionFunction,null,this.shim),jr(this.customCompletionFunction)){let r=this.customCompletionFunction(n,t);return K(r)?r.then(a=>{this.shim.process.nextTick(()=>{s(null,a)})}).catch(a=>{this.shim.process.nextTick(()=>{s(a,void 0)})}):s(null,r)}else return Mr(this.customCompletionFunction)?this.customCompletionFunction(n,t,(r=s)=>this.defaultCompletion(e,t,n,r),r=>{s(null,r)}):this.customCompletionFunction(n,t,r=>{s(null,r)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",s=this.yargs.parse(e,!0),r=this.customCompletionFunction?a=>this.customCompletion(e,a,n,t):a=>this.defaultCompletion(e,a,n,t);return K(s)?s.then(r):r(s)}generateCompletionScript(e,t){let n=this.zshShell?ji:Si,s=this.shim.path.basename(e);return e.match(/\.js$/)&&(e=`./${e}`),n=n.replace(/{{app_name}}/g,s),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}};function Mi(i,e,t,n){return new wn(i,e,t,n)}function jr(i){return i.length<3}function Mr(i){return i.length>3}function Pi(i,e){if(i.length===0)return e.length;if(e.length===0)return i.length;let t=[],n;for(n=0;n<=e.length;n++)t[n]=[n];let s;for(s=0;s<=i.length;s++)t[0][s]=s;for(n=1;n<=e.length;n++)for(s=1;s<=i.length;s++)e.charAt(n-1)===i.charAt(s-1)?t[n][s]=t[n-1][s-1]:n>1&&s>1&&e.charAt(n-2)===i.charAt(s-1)&&e.charAt(n-1)===i.charAt(s-2)?t[n][s]=t[n-2][s-2]+1:t[n][s]=Math.min(t[n-1][s-1]+1,Math.min(t[n][s-1]+1,t[n-1][s]+1));return t[e.length][i.length]}var Ii=["$0","--","_"];function vi(i,e,t){let n=t.y18n.__,s=t.y18n.__n,r={};r.nonOptionCount=function(u){let m=i.getDemandedCommands(),C=u._.length+(u["--"]?u["--"].length:0)-i.getInternalMethods().getContext().commands.length;m._&&(C<m._.min||C>m._.max)&&(C<m._.min?m._.minMsg!==void 0?e.fail(m._.minMsg?m._.minMsg.replace(/\$0/g,C.toString()).replace(/\$1/,m._.min.toString()):null):e.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",C,C.toString(),m._.min.toString())):C>m._.max&&(m._.maxMsg!==void 0?e.fail(m._.maxMsg?m._.maxMsg.replace(/\$0/g,C.toString()).replace(/\$1/,m._.max.toString()):null):e.fail(s("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",C,C.toString(),m._.max.toString()))))},r.positionalCount=function(u,m){m<u&&e.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",m,m+"",u+""))},r.requiredArguments=function(u,m){let w=null;for(let C of Object.keys(m))(!Object.prototype.hasOwnProperty.call(u,C)||typeof u[C]>"u")&&(w=w||{},w[C]=m[C]);if(w){let C=[];for(let f of Object.keys(w)){let x=w[f];x&&C.indexOf(x)<0&&C.push(x)}let O=C.length?`
|
|
65
|
-
${C.join(`
|
|
66
|
-
`)}`:"";e.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(w).length,Object.keys(w).join(", ")+O))}},r.unknownArguments=function(u,m,w,C,O=!0){var f;let x=i.getInternalMethods().getCommandInstance().getCommands(),N=[],U=i.getInternalMethods().getContext();if(Object.keys(u).forEach(W=>{!Ii.includes(W)&&!Object.prototype.hasOwnProperty.call(w,W)&&!Object.prototype.hasOwnProperty.call(i.getInternalMethods().getParseContext(),W)&&!r.isValidAndSomeAliasIsNotNew(W,m)&&N.push(W)}),O&&(U.commands.length>0||x.length>0||C)&&u._.slice(U.commands.length).forEach(W=>{x.includes(""+W)||N.push(""+W)}),O){let z=((f=i.getDemandedCommands()._)===null||f===void 0?void 0:f.max)||0,le=U.commands.length+z;le<u._.length&&u._.slice(le).forEach(ce=>{ce=String(ce),!U.commands.includes(ce)&&!N.includes(ce)&&N.push(ce)})}N.length&&e.fail(s("Unknown argument: %s","Unknown arguments: %s",N.length,N.map(W=>W.trim()?W:`"${W}"`).join(", ")))},r.unknownCommands=function(u){let m=i.getInternalMethods().getCommandInstance().getCommands(),w=[],C=i.getInternalMethods().getContext();return(C.commands.length>0||m.length>0)&&u._.slice(C.commands.length).forEach(O=>{m.includes(""+O)||w.push(""+O)}),w.length>0?(e.fail(s("Unknown command: %s","Unknown commands: %s",w.length,w.join(", "))),!0):!1},r.isValidAndSomeAliasIsNotNew=function(u,m){if(!Object.prototype.hasOwnProperty.call(m,u))return!1;let w=i.parsed.newAliases;return[u,...m[u]].some(C=>!Object.prototype.hasOwnProperty.call(w,C)||!w[u])},r.limitedChoices=function(u){let m=i.getOptions(),w={};if(!Object.keys(m.choices).length)return;Object.keys(u).forEach(f=>{Ii.indexOf(f)===-1&&Object.prototype.hasOwnProperty.call(m.choices,f)&&[].concat(u[f]).forEach(x=>{m.choices[f].indexOf(x)===-1&&x!==void 0&&(w[f]=(w[f]||[]).concat(x))})});let C=Object.keys(w);if(!C.length)return;let O=n("Invalid values:");C.forEach(f=>{O+=`
|
|
67
|
-
${n("Argument: %s, Given: %s, Choices: %s",f,e.stringifiedValues(w[f]),e.stringifiedValues(m.choices[f]))}`}),e.fail(O)};let a={};r.implies=function(u,m){S("<string|object> [array|number|string]",[u,m],arguments.length),typeof u=="object"?Object.keys(u).forEach(w=>{r.implies(w,u[w])}):(i.global(u),a[u]||(a[u]=[]),Array.isArray(m)?m.forEach(w=>r.implies(u,w)):(ue(m,void 0,t),a[u].push(m)))},r.getImplied=function(){return a};function c(p,u){let m=Number(u);return u=isNaN(m)?u:m,typeof u=="number"?u=p._.length>=u:u.match(/^--no-.+/)?(u=u.match(/^--no-(.+)/)[1],u=!Object.prototype.hasOwnProperty.call(p,u)):u=Object.prototype.hasOwnProperty.call(p,u),u}r.implications=function(u){let m=[];if(Object.keys(a).forEach(w=>{let C=w;(a[w]||[]).forEach(O=>{let f=C,x=O;f=c(u,f),O=c(u,O),f&&!O&&m.push(` ${C} -> ${x}`)})}),m.length){let w=`${n("Implications failed:")}
|
|
68
|
-
`;m.forEach(C=>{w+=C}),e.fail(w)}};let b={};r.conflicts=function(u,m){S("<string|object> [array|string]",[u,m],arguments.length),typeof u=="object"?Object.keys(u).forEach(w=>{r.conflicts(w,u[w])}):(i.global(u),b[u]||(b[u]=[]),Array.isArray(m)?m.forEach(w=>r.conflicts(u,w)):b[u].push(m))},r.getConflicting=()=>b,r.conflicting=function(u){Object.keys(u).forEach(m=>{b[m]&&b[m].forEach(w=>{w&&u[m]!==void 0&&u[w]!==void 0&&e.fail(n("Arguments %s and %s are mutually exclusive",m,w))})}),i.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(b).forEach(m=>{b[m].forEach(w=>{w&&u[t.Parser.camelCase(m)]!==void 0&&u[t.Parser.camelCase(w)]!==void 0&&e.fail(n("Arguments %s and %s are mutually exclusive",m,w))})})},r.recommendCommands=function(u,m){m=m.sort((f,x)=>x.length-f.length);let C=null,O=1/0;for(let f=0,x;(x=m[f])!==void 0;f++){let N=Pi(u,x);N<=3&&N<O&&(O=N,C=x)}C&&e.fail(n("Did you mean %s?",C))},r.reset=function(u){return a=Fe(a,m=>!u[m]),b=Fe(b,m=>!u[m]),r};let g=[];return r.freeze=function(){g.push({implied:a,conflicting:b})},r.unfreeze=function(){let u=g.pop();ue(u,void 0,t),{implied:a,conflicting:b}=u},r}var On=[],pt;function mt(i,e,t,n){pt=n;let s={};if(Object.prototype.hasOwnProperty.call(i,"extends")){if(typeof i.extends!="string")return s;let r=/\.json|\..*rc$/.test(i.extends),a=null;if(r)a=Ir(e,i.extends);else try{a=Se.resolve(i.extends)}catch{return i}Pr(a),On.push(a),s=r?JSON.parse(pt.readFileSync(a,"utf8")):Se(i.extends),delete i.extends,s=mt(s,pt.path.dirname(a),t,pt)}return On=[],t?$i(s,i):Object.assign({},s,i)}function Pr(i){if(On.indexOf(i)>-1)throw new q(`Circular extended configurations: '${i}'.`)}function Ir(i,e){return pt.path.resolve(i,e)}function $i(i,e){let t={};function n(s){return s&&typeof s=="object"&&!Array.isArray(s)}Object.assign(t,i);for(let s of Object.keys(e))n(e[s])&&n(t[s])?t[s]=$i(i[s],e[s]):t[s]=e[s];return t}var j=function(i,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!s:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(i,t):s?s.value=t:e.set(i,t),t},o=function(i,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(i):n?n.value:e.get(i)},ie,Ge,gt,ye,de,Tt,De,Ye,Lt,we,Wt,Oe,Me,pe,_e,Ut,ot,ae,v,Bt,zt,me,qe,at,Ke,Te,Vt,D,Je,Qe,Ze,T,Ht,Pe,te;function Xi(i){return(e=[],t=i.process.cwd(),n)=>{let s=new vn(e,t,n,i);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var Ni=Symbol("copyDoubleDash"),Fi=Symbol("copyDoubleDash"),_n=Symbol("deleteFromParserHintObject"),Ri=Symbol("emitWarning"),Di=Symbol("freeze"),Ti=Symbol("getDollarZero"),Xe=Symbol("getParserConfiguration"),Li=Symbol("getUsageConfiguration"),Cn=Symbol("guessLocale"),Wi=Symbol("guessVersion"),Ui=Symbol("parsePositionalNumbers"),xn=Symbol("pkgUp"),Le=Symbol("populateParserHintArray"),lt=Symbol("populateParserHintSingleValueDictionary"),En=Symbol("populateParserHintArrayDictionary"),An=Symbol("populateParserHintDictionary"),Sn=Symbol("sanitizeKey"),jn=Symbol("setKey"),Mn=Symbol("unfreeze"),Bi=Symbol("validateAsync"),zi=Symbol("getCommandInstance"),Vi=Symbol("getContext"),Hi=Symbol("getHasOutput"),Gi=Symbol("getLoggerInstance"),Yi=Symbol("getParseContext"),qi=Symbol("getUsageInstance"),Ki=Symbol("getValidationInstance"),Gt=Symbol("hasParseCallback"),Ji=Symbol("isGlobalContext"),ke=Symbol("postProcess"),Qi=Symbol("rebase"),Pn=Symbol("reset"),bt=Symbol("runYargsParserAndExecuteCommands"),In=Symbol("runValidation"),Zi=Symbol("setHasOutput"),et=Symbol("kTrackManuallySetKeys"),vn=class{constructor(e=[],t,n,s){this.customScriptName=!1,this.parsed=!1,ie.set(this,void 0),Ge.set(this,void 0),gt.set(this,{commands:[],fullCommands:[]}),ye.set(this,null),de.set(this,null),Tt.set(this,"show-hidden"),De.set(this,null),Ye.set(this,!0),Lt.set(this,{}),we.set(this,!0),Wt.set(this,[]),Oe.set(this,void 0),Me.set(this,{}),pe.set(this,!1),_e.set(this,null),Ut.set(this,!0),ot.set(this,void 0),ae.set(this,""),v.set(this,void 0),Bt.set(this,void 0),zt.set(this,{}),me.set(this,null),qe.set(this,null),at.set(this,{}),Ke.set(this,{}),Te.set(this,void 0),Vt.set(this,!1),D.set(this,void 0),Je.set(this,!1),Qe.set(this,!1),Ze.set(this,!1),T.set(this,void 0),Ht.set(this,{}),Pe.set(this,null),te.set(this,void 0),j(this,D,s,"f"),j(this,Te,e,"f"),j(this,Ge,t,"f"),j(this,Bt,n,"f"),j(this,Oe,new Ft(this),"f"),this.$0=this[Ti](),this[Pn](),j(this,ie,o(this,ie,"f"),"f"),j(this,T,o(this,T,"f"),"f"),j(this,te,o(this,te,"f"),"f"),j(this,v,o(this,v,"f"),"f"),o(this,v,"f").showHiddenOpt=o(this,Tt,"f"),j(this,ot,this[Fi](),"f")}addHelpOpt(e,t){let n="help";return S("[string|boolean] [string]",[e,t],arguments.length),o(this,_e,"f")&&(this[_n](o(this,_e,"f")),j(this,_e,null,"f")),e===!1&&t===void 0?this:(j(this,_e,typeof e=="string"?e:n,"f"),this.boolean(o(this,_e,"f")),this.describe(o(this,_e,"f"),t||o(this,T,"f").deferY18nLookup("Show help")),this)}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(S("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e=="string"?e:o(this,Tt,"f");return this.boolean(n),this.describe(n,t||o(this,T,"f").deferY18nLookup("Show hidden options")),o(this,v,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return S("<object|string|array> [string|array]",[e,t],arguments.length),this[En](this.alias.bind(this),"alias",e,t),this}array(e){return S("<array|string>",[e],arguments.length),this[Le]("array",e),this[et](e),this}boolean(e){return S("<array|string>",[e],arguments.length),this[Le]("boolean",e),this[et](e),this}check(e,t){return S("<function> [boolean]",[e,t],arguments.length),this.middleware((n,s)=>He(()=>e(n,s.getOptions()),r=>(r?(typeof r=="string"||r instanceof Error)&&o(this,T,"f").fail(r.toString(),r):o(this,T,"f").fail(o(this,D,"f").y18n.__("Argument check failed: %s",e.toString())),n),r=>(o(this,T,"f").fail(r.message?r.message:r.toString(),r),n)),!1,t),this}choices(e,t){return S("<object|string|array> [string|array]",[e,t],arguments.length),this[En](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(S("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new q("coerce callback must be provided");for(let n of e)this.coerce(n,t);return this}else if(typeof e=="object"){for(let n of Object.keys(e))this.coerce(n,e[n]);return this}if(!t)throw new q("coerce callback must be provided");return o(this,v,"f").key[e]=!0,o(this,Oe,"f").addCoerceMiddleware((n,s)=>{let r;return Object.prototype.hasOwnProperty.call(n,e)?He(()=>(r=s.getAliases(),t(n[e])),c=>{n[e]=c;let b=s.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[e]&&b!==!0)for(let g of r[e])n[g]=c;return n},c=>{throw new q(c.message)}):n},e),this}conflicts(e,t){return S("<string|object> [string|array]",[e,t],arguments.length),o(this,te,"f").conflicts(e,t),this}config(e="config",t,n){return S("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e=="object"&&!Array.isArray(e)?(e=mt(e,o(this,Ge,"f"),this[Xe]()["deep-merge-config"]||!1,o(this,D,"f")),o(this,v,"f").configObjects=(o(this,v,"f").configObjects||[]).concat(e),this):(typeof t=="function"&&(n=t,t=void 0),this.describe(e,t||o(this,T,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach(s=>{o(this,v,"f").config[s]=n||!0}),this)}completion(e,t,n){return S("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t=="function"&&(n=t,t=void 0),j(this,de,e||o(this,de,"f")||"completion","f"),!t&&t!==!1&&(t="generate completion script"),this.command(o(this,de,"f"),t),n&&o(this,ye,"f").registerFunction(n),this}command(e,t,n,s,r,a){return S("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,s,r,a],arguments.length),o(this,ie,"f").addHandler(e,t,n,s,r,a),this}commands(e,t,n,s,r,a){return this.command(e,t,n,s,r,a)}commandDir(e,t){S("<string> [object]",[e,t],arguments.length);let n=o(this,Bt,"f")||o(this,D,"f").require;return o(this,ie,"f").addDirectory(e,n,o(this,D,"f").getCallerFile(),t),this}count(e){return S("<array|string>",[e],arguments.length),this[Le]("count",e),this[et](e),this}default(e,t,n){return S("<object|string|array> [*] [string]",[e,t,n],arguments.length),n&&(mn(e,o(this,D,"f")),o(this,v,"f").defaultDescription[e]=n),typeof t=="function"&&(mn(e,o(this,D,"f")),o(this,v,"f").defaultDescription[e]||(o(this,v,"f").defaultDescription[e]=o(this,T,"f").functionDescription(t)),t=t.call()),this[lt](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,s){return S("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,s],arguments.length),typeof t!="number"&&(n=t,t=1/0),this.global("_",!1),o(this,v,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:s},this}demand(e,t,n){return Array.isArray(t)?(t.forEach(s=>{ue(n,!0,o(this,D,"f")),this.demandOption(s,n)}),t=1/0):typeof t!="number"&&(n=t,t=1/0),typeof e=="number"?(ue(n,!0,o(this,D,"f")),this.demandCommand(e,t,n,n)):Array.isArray(e)?e.forEach(s=>{ue(n,!0,o(this,D,"f")),this.demandOption(s,n)}):typeof n=="string"?this.demandOption(e,n):(n===!0||typeof n>"u")&&this.demandOption(e),this}demandOption(e,t){return S("<object|string|array> [string]",[e,t],arguments.length),this[lt](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return S("<string> [string|boolean]",[e,t],arguments.length),o(this,v,"f").deprecatedOptions[e]=t,this}describe(e,t){return S("<object|string|array> [string]",[e,t],arguments.length),this[jn](e,!0),o(this,T,"f").describe(e,t),this}detectLocale(e){return S("<boolean>",[e],arguments.length),j(this,Ye,e,"f"),this}env(e){return S("[string|boolean]",[e],arguments.length),e===!1?delete o(this,v,"f").envPrefix:o(this,v,"f").envPrefix=e||"",this}epilogue(e){return S("<string>",[e],arguments.length),o(this,T,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){return S("<string|array> [string]",[e,t],arguments.length),Array.isArray(e)?e.forEach(n=>this.example(...n)):o(this,T,"f").example(e,t),this}exit(e,t){j(this,pe,!0,"f"),j(this,De,t,"f"),o(this,we,"f")&&o(this,D,"f").process.exit(e)}exitProcess(e=!0){return S("[boolean]",[e],arguments.length),j(this,we,e,"f"),this}fail(e){if(S("<function|boolean>",[e],arguments.length),typeof e=="boolean"&&e!==!1)throw new q("Invalid first argument. Expected function or boolean 'false'");return o(this,T,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){return S("<array> [function]",[e,t],arguments.length),t?o(this,ye,"f").getCompletion(e,t):new Promise((n,s)=>{o(this,ye,"f").getCompletion(e,(r,a)=>{r?s(r):n(a)})})}getDemandedOptions(){return S([],0),o(this,v,"f").demandedOptions}getDemandedCommands(){return S([],0),o(this,v,"f").demandedCommands}getDeprecatedOptions(){return S([],0),o(this,v,"f").deprecatedOptions}getDetectLocale(){return o(this,Ye,"f")}getExitProcess(){return o(this,we,"f")}getGroups(){return Object.assign({},o(this,Me,"f"),o(this,Ke,"f"))}getHelp(){if(j(this,pe,!0,"f"),!o(this,T,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[bt](o(this,Te,"f"),void 0,void 0,0,!0);if(K(t))return t.then(()=>o(this,T,"f").help())}let e=o(this,ie,"f").runDefaultBuilderOn(this);if(K(e))return e.then(()=>o(this,T,"f").help())}return Promise.resolve(o(this,T,"f").help())}getOptions(){return o(this,v,"f")}getStrict(){return o(this,Je,"f")}getStrictCommands(){return o(this,Qe,"f")}getStrictOptions(){return o(this,Ze,"f")}global(e,t){return S("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1?o(this,v,"f").local=o(this,v,"f").local.filter(n=>e.indexOf(n)===-1):e.forEach(n=>{o(this,v,"f").local.includes(n)||o(this,v,"f").local.push(n)}),this}group(e,t){S("<string|array> <string>",[e,t],arguments.length);let n=o(this,Ke,"f")[t]||o(this,Me,"f")[t];o(this,Ke,"f")[t]&&delete o(this,Ke,"f")[t];let s={};return o(this,Me,"f")[t]=(n||[]).concat(e).filter(r=>s[r]?!1:s[r]=!0),this}hide(e){return S("<string>",[e],arguments.length),o(this,v,"f").hiddenOptions.push(e),this}implies(e,t){return S("<string|object> [number|string|array]",[e,t],arguments.length),o(this,te,"f").implies(e,t),this}locale(e){return S("[string]",[e],arguments.length),e===void 0?(this[Cn](),o(this,D,"f").y18n.getLocale()):(j(this,Ye,!1,"f"),o(this,D,"f").y18n.setLocale(e),this)}middleware(e,t,n){return o(this,Oe,"f").addMiddleware(e,!!t,n)}nargs(e,t){return S("<string|object|array> [number]",[e,t],arguments.length),this[lt](this.nargs.bind(this),"narg",e,t),this}normalize(e){return S("<array|string>",[e],arguments.length),this[Le]("normalize",e),this}number(e){return S("<array|string>",[e],arguments.length),this[Le]("number",e),this[et](e),this}option(e,t){if(S("<string|object> [object]",[e,t],arguments.length),typeof e=="object")Object.keys(e).forEach(n=>{this.options(n,e[n])});else{typeof t!="object"&&(t={}),this[et](e),o(this,Pe,"f")&&(e==="version"||(t==null?void 0:t.alias)==="version")&&this[Ri](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
|
|
69
|
-
`),void 0,"versionWarning"),o(this,v,"f").key[e]=!0,t.alias&&this.alias(e,t.alias);let n=t.deprecate||t.deprecated;n&&this.deprecateOption(e,n);let s=t.demand||t.required||t.require;s&&this.demand(e,s),t.demandOption&&this.demandOption(e,typeof t.demandOption=="string"?t.demandOption:void 0),t.conflicts&&this.conflicts(e,t.conflicts),"default"in t&&this.default(e,t.default),t.implies!==void 0&&this.implies(e,t.implies),t.nargs!==void 0&&this.nargs(e,t.nargs),t.config&&this.config(e,t.configParser),t.normalize&&this.normalize(e),t.choices&&this.choices(e,t.choices),t.coerce&&this.coerce(e,t.coerce),t.group&&this.group(e,t.group),(t.boolean||t.type==="boolean")&&(this.boolean(e),t.alias&&this.boolean(t.alias)),(t.array||t.type==="array")&&(this.array(e),t.alias&&this.array(t.alias)),(t.number||t.type==="number")&&(this.number(e),t.alias&&this.number(t.alias)),(t.string||t.type==="string")&&(this.string(e),t.alias&&this.string(t.alias)),(t.count||t.type==="count")&&this.count(e),typeof t.global=="boolean"&&this.global(e,t.global),t.defaultDescription&&(o(this,v,"f").defaultDescription[e]=t.defaultDescription),t.skipValidation&&this.skipValidation(e);let r=t.describe||t.description||t.desc,a=o(this,T,"f").getDescriptions();(!Object.prototype.hasOwnProperty.call(a,e)||typeof r=="string")&&this.describe(e,r),t.hidden&&this.hide(e),t.requiresArg&&this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){S("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[Di](),typeof e>"u"&&(e=o(this,Te,"f")),typeof t=="object"&&(j(this,qe,t,"f"),t=n),typeof t=="function"&&(j(this,me,t,"f"),t=!1),t||j(this,Te,e,"f"),o(this,me,"f")&&j(this,we,!1,"f");let s=this[bt](e,!!t),r=this.parsed;return o(this,ye,"f").setParsed(this.parsed),K(s)?s.then(a=>(o(this,me,"f")&&o(this,me,"f").call(this,o(this,De,"f"),a,o(this,ae,"f")),a)).catch(a=>{throw o(this,me,"f")&&o(this,me,"f")(a,this.parsed.argv,o(this,ae,"f")),a}).finally(()=>{this[Mn](),this.parsed=r}):(o(this,me,"f")&&o(this,me,"f").call(this,o(this,De,"f"),s,o(this,ae,"f")),this[Mn](),this.parsed=r,s)}parseAsync(e,t,n){let s=this.parse(e,t,n);return K(s)?s:Promise.resolve(s)}parseSync(e,t,n){let s=this.parse(e,t,n);if(K(s))throw new q(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return s}parserConfiguration(e){return S("<object>",[e],arguments.length),j(this,zt,e,"f"),this}pkgConf(e,t){S("<string> [string]",[e,t],arguments.length);let n=null,s=this[xn](t||o(this,Ge,"f"));return s[e]&&typeof s[e]=="object"&&(n=mt(s[e],t||o(this,Ge,"f"),this[Xe]()["deep-merge-config"]||!1,o(this,D,"f")),o(this,v,"f").configObjects=(o(this,v,"f").configObjects||[]).concat(n)),this}positional(e,t){S("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=Fe(t,(a,c)=>a==="type"&&!["string","number","boolean"].includes(c)?!1:n.includes(a));let s=o(this,gt,"f").fullCommands[o(this,gt,"f").fullCommands.length-1],r=s?o(this,ie,"f").cmdToParseOptions(s):{array:[],alias:{},default:{},demand:{}};return st(r).forEach(a=>{let c=r[a];Array.isArray(c)?c.indexOf(e)!==-1&&(t[a]=!0):c[e]&&!(a in t)&&(t[a]=c[e])}),this.group(e,o(this,T,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return S("[boolean]",[e],arguments.length),j(this,Vt,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){return S("<array|string|object> [number]",[e],arguments.length),typeof e=="string"&&o(this,v,"f").narg[e]?this:(this[lt](this.requiresArg.bind(this),"narg",e,NaN),this)}showCompletionScript(e,t){return S("[string] [string]",[e,t],arguments.length),e=e||this.$0,o(this,ot,"f").log(o(this,ye,"f").generateCompletionScript(e,t||o(this,de,"f")||"completion")),this}showHelp(e){if(S("[string|function]",[e],arguments.length),j(this,pe,!0,"f"),!o(this,T,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[bt](o(this,Te,"f"),void 0,void 0,0,!0);if(K(n))return n.then(()=>{o(this,T,"f").showHelp(e)}),this}let t=o(this,ie,"f").runDefaultBuilderOn(this);if(K(t))return t.then(()=>{o(this,T,"f").showHelp(e)}),this}return o(this,T,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return S("[boolean|string] [string]",[e,t],arguments.length),o(this,T,"f").showHelpOnFail(e,t),this}showVersion(e){return S("[string|function]",[e],arguments.length),o(this,T,"f").showVersion(e),this}skipValidation(e){return S("<array|string>",[e],arguments.length),this[Le]("skipValidation",e),this}strict(e){return S("[boolean]",[e],arguments.length),j(this,Je,e!==!1,"f"),this}strictCommands(e){return S("[boolean]",[e],arguments.length),j(this,Qe,e!==!1,"f"),this}strictOptions(e){return S("[boolean]",[e],arguments.length),j(this,Ze,e!==!1,"f"),this}string(e){return S("<array|string>",[e],arguments.length),this[Le]("string",e),this[et](e),this}terminalWidth(){return S([],0),o(this,D,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return S("<object>",[e],arguments.length),j(this,Ye,!1,"f"),o(this,D,"f").y18n.updateLocale(e),this}usage(e,t,n,s){if(S("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,s],arguments.length),t!==void 0){if(ue(e,null,o(this,D,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,s);throw new q(".usage() description must start with $0 if being used as alias for .command()")}else return o(this,T,"f").usage(e),this}usageConfiguration(e){return S("<object>",[e],arguments.length),j(this,Ht,e,"f"),this}version(e,t,n){let s="version";if(S("[boolean|string] [string] [string]",[e,t,n],arguments.length),o(this,Pe,"f")&&(this[_n](o(this,Pe,"f")),o(this,T,"f").version(void 0),j(this,Pe,null,"f")),arguments.length===0)n=this[Wi](),e=s;else if(arguments.length===1){if(e===!1)return this;n=e,e=s}else arguments.length===2&&(n=t,t=void 0);return j(this,Pe,typeof e=="string"?e:s,"f"),t=t||o(this,T,"f").deferY18nLookup("Show version number"),o(this,T,"f").version(n||void 0),this.boolean(o(this,Pe,"f")),this.describe(o(this,Pe,"f"),t),this}wrap(e){return S("<number|null|undefined>",[e],arguments.length),o(this,T,"f").wrap(e),this}[(ie=new WeakMap,Ge=new WeakMap,gt=new WeakMap,ye=new WeakMap,de=new WeakMap,Tt=new WeakMap,De=new WeakMap,Ye=new WeakMap,Lt=new WeakMap,we=new WeakMap,Wt=new WeakMap,Oe=new WeakMap,Me=new WeakMap,pe=new WeakMap,_e=new WeakMap,Ut=new WeakMap,ot=new WeakMap,ae=new WeakMap,v=new WeakMap,Bt=new WeakMap,zt=new WeakMap,me=new WeakMap,qe=new WeakMap,at=new WeakMap,Ke=new WeakMap,Te=new WeakMap,Vt=new WeakMap,D=new WeakMap,Je=new WeakMap,Qe=new WeakMap,Ze=new WeakMap,T=new WeakMap,Ht=new WeakMap,Pe=new WeakMap,te=new WeakMap,Ni)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch{}return e}[Fi](){return{log:(...e)=>{this[Gt]()||console.log(...e),j(this,pe,!0,"f"),o(this,ae,"f").length&&j(this,ae,o(this,ae,"f")+`
|
|
70
|
-
`,"f"),j(this,ae,o(this,ae,"f")+e.join(" "),"f")},error:(...e)=>{this[Gt]()||console.error(...e),j(this,pe,!0,"f"),o(this,ae,"f").length&&j(this,ae,o(this,ae,"f")+`
|
|
71
|
-
`,"f"),j(this,ae,o(this,ae,"f")+e.join(" "),"f")}}}[_n](e){st(o(this,v,"f")).forEach(t=>{if((s=>s==="configObjects")(t))return;let n=o(this,v,"f")[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n=="object"&&delete n[e]}),delete o(this,T,"f").getDescriptions()[e]}[Ri](e,t,n){o(this,Lt,"f")[n]||(o(this,D,"f").process.emitWarning(e,t),o(this,Lt,"f")[n]=!0)}[Di](){o(this,Wt,"f").push({options:o(this,v,"f"),configObjects:o(this,v,"f").configObjects.slice(0),exitProcess:o(this,we,"f"),groups:o(this,Me,"f"),strict:o(this,Je,"f"),strictCommands:o(this,Qe,"f"),strictOptions:o(this,Ze,"f"),completionCommand:o(this,de,"f"),output:o(this,ae,"f"),exitError:o(this,De,"f"),hasOutput:o(this,pe,"f"),parsed:this.parsed,parseFn:o(this,me,"f"),parseContext:o(this,qe,"f")}),o(this,T,"f").freeze(),o(this,te,"f").freeze(),o(this,ie,"f").freeze(),o(this,Oe,"f").freeze()}[Ti](){let e="",t;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,D,"f").process.argv()[0])?t=o(this,D,"f").process.argv().slice(1,2):t=o(this,D,"f").process.argv().slice(0,1),e=t.map(n=>{let s=this[Qi](o(this,Ge,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&s.length<n.length?s:n}).join(" ").trim(),o(this,D,"f").getEnv("_")&&o(this,D,"f").getProcessArgvBin()===o(this,D,"f").getEnv("_")&&(e=o(this,D,"f").getEnv("_").replace(`${o(this,D,"f").path.dirname(o(this,D,"f").process.execPath())}/`,"")),e}[Xe](){return o(this,zt,"f")}[Li](){return o(this,Ht,"f")}[Cn](){if(!o(this,Ye,"f"))return;let e=o(this,D,"f").getEnv("LC_ALL")||o(this,D,"f").getEnv("LC_MESSAGES")||o(this,D,"f").getEnv("LANG")||o(this,D,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[Wi](){return this[xn]().version||"unknown"}[Ui](e){let t=e["--"]?e["--"]:e._;for(let n=0,s;(s=t[n])!==void 0;n++)o(this,D,"f").Parser.looksLikeNumber(s)&&Number.isSafeInteger(Math.floor(parseFloat(`${s}`)))&&(t[n]=Number(s));return e}[xn](e){let t=e||"*";if(o(this,at,"f")[t])return o(this,at,"f")[t];let n={};try{let s=e||o(this,D,"f").mainFilename;!e&&o(this,D,"f").path.extname(s)&&(s=o(this,D,"f").path.dirname(s));let r=o(this,D,"f").findUp(s,(a,c)=>{if(c.includes("package.json"))return"package.json"});ue(r,void 0,o(this,D,"f")),n=JSON.parse(o(this,D,"f").readFileSync(r,"utf8"))}catch{}return o(this,at,"f")[t]=n||{},o(this,at,"f")[t]}[Le](e,t){t=[].concat(t),t.forEach(n=>{n=this[Sn](n),o(this,v,"f")[e].push(n)})}[lt](e,t,n,s){this[An](e,t,n,s,(r,a,c)=>{o(this,v,"f")[r][a]=c})}[En](e,t,n,s){this[An](e,t,n,s,(r,a,c)=>{o(this,v,"f")[r][a]=(o(this,v,"f")[r][a]||[]).concat(c)})}[An](e,t,n,s,r){if(Array.isArray(n))n.forEach(a=>{e(a,s)});else if((a=>typeof a=="object")(n))for(let a of st(n))e(a,n[a]);else r(t,this[Sn](n),s)}[Sn](e){return e==="__proto__"?"___proto___":e}[jn](e,t){return this[lt](this[jn].bind(this),"key",e,t),this}[Mn](){var e,t,n,s,r,a,c,b,g,p,u,m;let w=o(this,Wt,"f").pop();ue(w,void 0,o(this,D,"f"));let C;e=this,t=this,n=this,s=this,r=this,a=this,c=this,b=this,g=this,p=this,u=this,m=this,{options:{set value(O){j(e,v,O,"f")}}.value,configObjects:C,exitProcess:{set value(O){j(t,we,O,"f")}}.value,groups:{set value(O){j(n,Me,O,"f")}}.value,output:{set value(O){j(s,ae,O,"f")}}.value,exitError:{set value(O){j(r,De,O,"f")}}.value,hasOutput:{set value(O){j(a,pe,O,"f")}}.value,parsed:this.parsed,strict:{set value(O){j(c,Je,O,"f")}}.value,strictCommands:{set value(O){j(b,Qe,O,"f")}}.value,strictOptions:{set value(O){j(g,Ze,O,"f")}}.value,completionCommand:{set value(O){j(p,de,O,"f")}}.value,parseFn:{set value(O){j(u,me,O,"f")}}.value,parseContext:{set value(O){j(m,qe,O,"f")}}.value}=w,o(this,v,"f").configObjects=C,o(this,T,"f").unfreeze(),o(this,te,"f").unfreeze(),o(this,ie,"f").unfreeze(),o(this,Oe,"f").unfreeze()}[Bi](e,t){return He(t,n=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[zi].bind(this),getContext:this[Vi].bind(this),getHasOutput:this[Hi].bind(this),getLoggerInstance:this[Gi].bind(this),getParseContext:this[Yi].bind(this),getParserConfiguration:this[Xe].bind(this),getUsageConfiguration:this[Li].bind(this),getUsageInstance:this[qi].bind(this),getValidationInstance:this[Ki].bind(this),hasParseCallback:this[Gt].bind(this),isGlobalContext:this[Ji].bind(this),postProcess:this[ke].bind(this),reset:this[Pn].bind(this),runValidation:this[In].bind(this),runYargsParserAndExecuteCommands:this[bt].bind(this),setHasOutput:this[Zi].bind(this)}}[zi](){return o(this,ie,"f")}[Vi](){return o(this,gt,"f")}[Hi](){return o(this,pe,"f")}[Gi](){return o(this,ot,"f")}[Yi](){return o(this,qe,"f")||{}}[qi](){return o(this,T,"f")}[Ki](){return o(this,te,"f")}[Gt](){return!!o(this,me,"f")}[Ji](){return o(this,Ut,"f")}[ke](e,t,n,s){return n||K(e)||(t||(e=this[Ni](e)),(this[Xe]()["parse-positional-numbers"]||this[Xe]()["parse-positional-numbers"]===void 0)&&(e=this[Ui](e)),s&&(e=Ve(e,this,o(this,Oe,"f").getMiddleware(),!1))),e}[Pn](e={}){j(this,v,o(this,v,"f")||{},"f");let t={};t.local=o(this,v,"f").local||[],t.configObjects=o(this,v,"f").configObjects||[];let n={};t.local.forEach(a=>{n[a]=!0,(e[a]||[]).forEach(c=>{n[c]=!0})}),Object.assign(o(this,Ke,"f"),Object.keys(o(this,Me,"f")).reduce((a,c)=>{let b=o(this,Me,"f")[c].filter(g=>!(g in n));return b.length>0&&(a[c]=b),a},{})),j(this,Me,{},"f");let s=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return s.forEach(a=>{t[a]=(o(this,v,"f")[a]||[]).filter(c=>!n[c])}),r.forEach(a=>{t[a]=Fe(o(this,v,"f")[a],c=>!n[c])}),t.envPrefix=o(this,v,"f").envPrefix,j(this,v,t,"f"),j(this,T,o(this,T,"f")?o(this,T,"f").reset(n):Ai(this,o(this,D,"f")),"f"),j(this,te,o(this,te,"f")?o(this,te,"f").reset(n):vi(this,o(this,T,"f"),o(this,D,"f")),"f"),j(this,ie,o(this,ie,"f")?o(this,ie,"f").reset():Ci(o(this,T,"f"),o(this,te,"f"),o(this,Oe,"f"),o(this,D,"f")),"f"),o(this,ye,"f")||j(this,ye,Mi(this,o(this,T,"f"),o(this,ie,"f"),o(this,D,"f")),"f"),o(this,Oe,"f").reset(),j(this,de,null,"f"),j(this,ae,"","f"),j(this,De,null,"f"),j(this,pe,!1,"f"),this.parsed=!1,this}[Qi](e,t){return o(this,D,"f").path.relative(e,t)}[bt](e,t,n,s=0,r=!1){let a=!!n||r;e=e||o(this,Te,"f"),o(this,v,"f").__=o(this,D,"f").y18n.__,o(this,v,"f").configuration=this[Xe]();let c=!!o(this,v,"f").configuration["populate--"],b=Object.assign({},o(this,v,"f").configuration,{"populate--":!0}),g=o(this,D,"f").Parser.detailed(e,Object.assign({},o(this,v,"f"),{configuration:{"parse-positional-numbers":!1,...b}})),p=Object.assign(g.argv,o(this,qe,"f")),u,m=g.aliases,w=!1,C=!1;Object.keys(p).forEach(O=>{O===o(this,_e,"f")&&p[O]?w=!0:O===o(this,Pe,"f")&&p[O]&&(C=!0)}),p.$0=this.$0,this.parsed=g,s===0&&o(this,T,"f").clearCachedHelpMessage();try{if(this[Cn](),t)return this[ke](p,c,!!n,!1);o(this,_e,"f")&&[o(this,_e,"f")].concat(m[o(this,_e,"f")]||[]).filter(U=>U.length>1).includes(""+p._[p._.length-1])&&(p._.pop(),w=!0),j(this,Ut,!1,"f");let O=o(this,ie,"f").getCommands(),f=o(this,ye,"f").completionKey in p,x=w||f||r;if(p._.length){if(O.length){let N;for(let U=s||0,W;p._[U]!==void 0;U++)if(W=String(p._[U]),O.includes(W)&&W!==o(this,de,"f")){let z=o(this,ie,"f").runCommand(W,this,g,U+1,r,w||C||r);return this[ke](z,c,!!n,!1)}else if(!N&&W!==o(this,de,"f")){N=W;break}!o(this,ie,"f").hasDefaultCommand()&&o(this,Vt,"f")&&N&&!x&&o(this,te,"f").recommendCommands(N,O)}o(this,de,"f")&&p._.includes(o(this,de,"f"))&&!f&&(o(this,we,"f")&&Re(!0),this.showCompletionScript(),this.exit(0))}if(o(this,ie,"f").hasDefaultCommand()&&!x){let N=o(this,ie,"f").runCommand(null,this,g,0,r,w||C||r);return this[ke](N,c,!!n,!1)}if(f){o(this,we,"f")&&Re(!0),e=[].concat(e);let N=e.slice(e.indexOf(`--${o(this,ye,"f").completionKey}`)+1);return o(this,ye,"f").getCompletion(N,(U,W)=>{if(U)throw new q(U.message);(W||[]).forEach(z=>{o(this,ot,"f").log(z)}),this.exit(0)}),this[ke](p,!c,!!n,!1)}if(o(this,pe,"f")||(w?(o(this,we,"f")&&Re(!0),a=!0,this.showHelp("log"),this.exit(0)):C&&(o(this,we,"f")&&Re(!0),a=!0,o(this,T,"f").showVersion("log"),this.exit(0))),!a&&o(this,v,"f").skipValidation.length>0&&(a=Object.keys(p).some(N=>o(this,v,"f").skipValidation.indexOf(N)>=0&&p[N]===!0)),!a){if(g.error)throw new q(g.error.message);if(!f){let N=this[In](m,{},g.error);n||(u=Ve(p,this,o(this,Oe,"f").getMiddleware(),!0)),u=this[Bi](N,u??p),K(u)&&!n&&(u=u.then(()=>Ve(p,this,o(this,Oe,"f").getMiddleware(),!1)))}}}catch(O){if(O instanceof q)o(this,T,"f").fail(O.message,O);else throw O}return this[ke](u??p,c,!!n,!0)}[In](e,t,n,s){let r={...this.getDemandedOptions()};return a=>{if(n)throw new q(n.message);o(this,te,"f").nonOptionCount(a),o(this,te,"f").requiredArguments(a,r);let c=!1;o(this,Qe,"f")&&(c=o(this,te,"f").unknownCommands(a)),o(this,Je,"f")&&!c?o(this,te,"f").unknownArguments(a,e,t,!!s):o(this,Ze,"f")&&o(this,te,"f").unknownArguments(a,e,{},!1,!1),o(this,te,"f").limitedChoices(a),o(this,te,"f").implications(a),o(this,te,"f").conflicting(a)}}[Zi](){j(this,pe,!0,"f")}[et](e){if(typeof e=="string")o(this,v,"f").key[e]=!0;else for(let t of e)o(this,v,"f").key[t]=!0}};function xi(i){return!!i&&typeof i.getInternalMethods=="function"}var vr=Xi(pn),ki=vr;var Nr=performance.now(),es=ki(hn(process.argv));await es.scriptName("vidup").usage("$0 [command]","Run a vidup command.").command(["$0 <directory> [options]","sync <directory> [options]"],"Synchronize a remote video streaming service to mirror the contents of a local directory. Warning: This command will irrevocably delete remote videos that are not present in the local directory.",i=>i.positional("directory",{default:void 0,demandOption:!0,describe:"The path to the local directory of video files to sync.",type:"string"}).option("service",{alias:"s",choices:["bunny","mux","cloudflare"],demandOption:!0,describe:"Streaming service / platform to sync local video files to. Only the Bunny.net streaming CDN is supported at this time.",type:"string"}).option("key",{default:void 0,demandOption:!0,describe:"Streaming service API access key.",type:"string"}).option("library",{default:void 0,demandOption:!0,describe:"Streaming service library ID.",type:"string"}).option("strip-metadata",{default:!1,describe:"Remove all metadata from the video files before uploading them to the streaming service. Warning: This will modify local videos in-place.",type:"boolean"}).option("dry-run",{alias:"d",default:!1,describe:"Perform a dry run without making any changes. Useful for testing and debugging. Pairs well with the `--json` command.",type:"boolean"}).option("json",{default:!1,describe:"Output the sync report as JSON.",type:"boolean"}).option("verbose",{default:!1,describe:"Enable verbose logging. All verbose logs and prefixed with their log level and are printed to `stderr` for ease of redirection.",type:"boolean"}).check(e=>{if(e.service==="bunny")return e;throw new Error(`Sorry, vidup doesn't yet implement synchronization support the ${e.service} streaming service. Only Bunny.net is supported at the moment. If you'd like to see support for another service, please open an issue or send a PR on GitHub: https://github.com/kitschpatrol/vidup/issues`)}),async({directory:i,dryRun:e,json:t,key:n,library:s,service:r,stripMetadata:a,verbose:c})=>{G.verbose=c;let b=$r.resolve(nn(i));G.info("Starting video synchronization..."),e&&G.warn("Dry run enabled, not making any changes");let g=a?await Xt(b,{dryRun:e,verbose:c}):[],p=await kt(b,{credentials:{key:n,library:s},dryRun:e,service:r,verbose:c});if(t){for(let u of p)u.stripMetadata=u.localFile!==void 0&&g.includes(u.localFile);process.stdout.write(JSON.stringify(p,void 0,2)),process.stdout.write(`
|
|
72
|
-
`)}else{for(let u of g)process.stdout.write(`${e?"Found":"Stripped"} metadata: "${u}"
|
|
73
|
-
`);for(let u of p)process.stdout.write(`${u.action}: "${u.localFile}" Remote GUID: "${u.remoteId}"
|
|
74
|
-
`)}G.info(`Synchronized video in ${tn(performance.now()-Nr)}`),process.exitCode=0}).demandCommand(1).alias("h","help").version().alias("v","version").help().wrap(process.stdout.isTTY?Math.min(120,es.terminalWidth()):0).parse();
|
|
75
|
-
/*! Bundled license information:
|
|
76
|
-
|
|
77
|
-
yargs-parser/build/lib/string-utils.js:
|
|
78
|
-
(**
|
|
79
|
-
* @license
|
|
80
|
-
* Copyright (c) 2016, Contributors
|
|
81
|
-
* SPDX-License-Identifier: ISC
|
|
82
|
-
*)
|
|
83
|
-
|
|
84
|
-
yargs-parser/build/lib/tokenize-arg-string.js:
|
|
85
|
-
(**
|
|
86
|
-
* @license
|
|
87
|
-
* Copyright (c) 2016, Contributors
|
|
88
|
-
* SPDX-License-Identifier: ISC
|
|
89
|
-
*)
|
|
90
|
-
|
|
91
|
-
yargs-parser/build/lib/yargs-parser-types.js:
|
|
92
|
-
(**
|
|
93
|
-
* @license
|
|
94
|
-
* Copyright (c) 2016, Contributors
|
|
95
|
-
* SPDX-License-Identifier: ISC
|
|
96
|
-
*)
|
|
97
|
-
|
|
98
|
-
yargs-parser/build/lib/yargs-parser.js:
|
|
99
|
-
(**
|
|
100
|
-
* @license
|
|
101
|
-
* Copyright (c) 2016, Contributors
|
|
102
|
-
* SPDX-License-Identifier: ISC
|
|
103
|
-
*)
|
|
104
|
-
|
|
105
|
-
yargs-parser/build/lib/index.js:
|
|
106
|
-
(**
|
|
107
|
-
* @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
|
|
108
|
-
* CJS and ESM environments.
|
|
109
|
-
*
|
|
110
|
-
* @license
|
|
111
|
-
* Copyright (c) 2016, Contributors
|
|
112
|
-
* SPDX-License-Identifier: ISC
|
|
113
|
-
*)
|
|
114
|
-
*/
|
|
4
|
+
`)+r,n=o+1,o=t.indexOf(`
|
|
5
|
+
`,n)}while(o!==-1);return i+=t.slice(n),i}var{stdout:ce,stderr:de}=se,J=Symbol("GENERATOR"),T=Symbol("STYLER"),C=Symbol("IS_EMPTY"),fe=["ansi","ansi","ansi256","ansi16m"],I=Object.create(null),$e=(t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=ce?ce.level:0;t.level=e.level===void 0?r:e.level};var De=t=>{let e=(...r)=>r.join(" ");return $e(e,t),Object.setPrototypeOf(e,$.prototype),e};function $(t){return De(t)}Object.setPrototypeOf($.prototype,Function.prototype);for(let[t,e]of Object.entries(v))I[t]={get(){let r=P(this,K(e.open,e.close,this[T]),this[C]);return Object.defineProperty(this,t,{value:r}),r}};I.visible={get(){let t=P(this,this[T],!0);return Object.defineProperty(this,"visible",{value:t}),t}};var W=(t,e,r,...o)=>t==="rgb"?e==="ansi16m"?v[r].ansi16m(...o):e==="ansi256"?v[r].ansi256(v.rgbToAnsi256(...o)):v[r].ansi(v.rgbToAnsi(...o)):t==="hex"?W("rgb",e,r,...v.hexToRgb(...o)):v[r][t](...o),Ae=["rgb","hex","ansi256"];for(let t of Ae){I[t]={get(){let{level:r}=this;return function(...o){let n=K(W(t,fe[r],"color",...o),v.color.close,this[T]);return P(this,n,this[C])}}};let e="bg"+t[0].toUpperCase()+t.slice(1);I[e]={get(){let{level:r}=this;return function(...o){let n=K(W(t,fe[r],"bgColor",...o),v.bgColor.close,this[T]);return P(this,n,this[C])}}}}var Pe=Object.defineProperties(()=>{},{...I,level:{enumerable:!0,get(){return this[J].level},set(t){this[J].level=t}}}),K=(t,e,r)=>{let o,n;return r===void 0?(o=t,n=e):(o=r.openAll+t,n=e+r.closeAll),{open:t,close:e,openAll:o,closeAll:n,parent:r}},P=(t,e,r)=>{let o=(...n)=>Be(o,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(o,Pe),o[J]=t,o[T]=e,o[C]=r,o},Be=(t,e)=>{if(t.level<=0||!e)return t[C]?"":e;let r=t[T];if(r===void 0)return e;let{openAll:o,closeAll:n}=r;if(e.includes("\x1B"))for(;r!==void 0;)e=ae(e,r.close,r.open),r=r.parent;let i=e.indexOf(`
|
|
6
|
+
`);return i!==-1&&(e=le(e,n,o,i)),o+e+n};Object.defineProperties($.prototype,I);var _e=$(),xt=$({level:de?de.level:0});var O=_e;import{oraPromise as ke}from"ora";var me,ue=((me=process==null?void 0:process.versions)==null?void 0:me.node)!==void 0,Ve={verbose:!1,log(...t){if(!this.verbose)return;let e=O.gray("[Log]");ue?console.warn(e,...t):console.log(e,...t)},logPrefixed(t,...e){this.info(O.blue(`[${t}]`),...e)},info(...t){if(!this.verbose)return;let e=O.green("[Info]");ue?console.warn(e,...t):console.info(e,...t)},infoPrefixed(t,...e){this.info(O.blue(`[${t}]`),...e)},async infoSpin(t,e){return ke(t,{prefixText:O.green("[Info]"),stream:process.stderr,text:e})},warn(...t){console.warn(O.yellow("[Warning]"),...t)},warnPrefixed(t,...e){this.warn(O.blue(`[${t}]`),...e)},error(...t){console.error(O.red("[Error]"),...t)},errorPrefixed(t,...e){this.error(O.blue(`[${t}]`),...e)}},d=Ve;import{execa as pe}from"execa";import B from"ffmpeg-static";import he from"node:fs/promises";import z from"node:path";async function _(t){return(await he.readdir(t)).filter(o=>{let n=z.extname(o);return[".mp4",".mov",".avi",".mkv"].includes(n)}).map(o=>z.join(t,o))}async function ye(t){if(B===null)throw new Error("ffmpeg-static failed to locate ffmpeg binary");try{let{stderr:e,stdout:r}=await pe(B,["-i",t,"-f","ffmetadata","-"]);return r.includes("creation_time")||e.includes("creation_time")}catch(e){throw new Error(`Failed to check metadata for: ${t}:
|
|
7
|
+
${String(e)}`)}}async function ge(t){if(B===null)throw new Error("ffmpeg-static failed to locate ffmpeg binary");try{let e=z.extname(t).slice(1),r=`${t.slice(0,Math.max(0,t.lastIndexOf(".")))}.temp.${e}`;await pe(B,["-i",t,"-map_metadata","-1","-c:v","copy","-c:a","copy",r]),await he.rename(r,t)}catch(e){throw new Error(`Failed to strip metadata from: ${t}:
|
|
8
|
+
${String(e)}`)}}async function Z(t,e={}){let{dryRun:r=!1,verbose:o=!1}=e,n=await _(t);return je(n,{dryRun:r,verbose:o})}async function je(t,e={}){let{dryRun:r=!1,verbose:o=!1}=e,n=d.verbose;d.verbose=o;let i=[];for(let a of t)await ye(a)&&i.push(a);if(!r){d.info(`Found ${i.length} videos with metadata to strip`);for(let a of i)console.log(`Stripping metadata from: ${a}`),await ge(a)}return d.verbose=n,i}import{BunnyCdnStream as qe}from"bunnycdn-stream";import{hash as Qe}from"hasha";import{readFile as ze}from"node:fs/promises";import{rename as Ue,writeFile as Le}from"node:fs/promises";import{basename as Ge,dirname as He,join as Ye}from"node:path";import{fileURLToPath as Je}from"node:url";function We(t){let e=t instanceof URL?Je(t):t.toString();return Ye(He(e),`.${Ge(e)}.tmp`)}async function Ke(t,e,r){for(let o=0;o<e;o++)try{return await t()}catch(n){if(o<e-1)await new Promise(i=>setTimeout(i,r));else throw n}}var k=class{#e;#t;#r=!1;#n=null;#i=null;#s=null;#o=null;#a(e){return this.#o=e,this.#s||=new Promise((r,o)=>{this.#i=[r,o]}),new Promise((r,o)=>{var n;(n=this.#s)==null||n.then(r).catch(o)})}async#l(e){var r,o;this.#r=!0;try{await Le(this.#t,e,"utf-8"),await Ke(async()=>{await Ue(this.#t,this.#e)},10,100),(r=this.#n)==null||r[0]()}catch(n){throw n instanceof Error&&((o=this.#n)==null||o[1](n)),n}finally{if(this.#r=!1,this.#n=this.#i,this.#i=this.#s=null,this.#o!==null){let n=this.#o;this.#o=null,await this.write(n)}}}constructor(e){this.#e=e,this.#t=We(e)}async write(e){return this.#r?this.#a(e):this.#l(e)}};var V=class{#e;#t;constructor(e){this.#e=e,this.#t=new k(e)}async read(){let e;try{e=await ze(this.#e,"utf-8")}catch(r){if(r.code==="ENOENT")return null;throw r}return e}write(e){return this.#t.write(e)}};var j=class{#e;#t;#r;constructor(e,{parse:r,stringify:o}){this.#e=new V(e),this.#t=r,this.#r=o}async read(){let e=await this.#e.read();return e===null?null:this.#t(e)}write(e){return this.#e.write(this.#r(e))}};var U=class extends j{constructor(e){super(e,{parse:JSON.parse,stringify:r=>JSON.stringify(r,null,2)})}};var L=class{#e=null;read(){return Promise.resolve(this.#e)}write(e){return this.#e=e,Promise.resolve()}};function Ze(t,e){if(t===void 0)throw new Error("lowdb: missing adapter");if(e===void 0)throw new Error("lowdb: missing default data")}var G=class{adapter;data;constructor(e,r){Ze(e,r),this.adapter=e,this.data=r}async read(){let e=await this.adapter.read();e&&(this.data=e)}async write(){this.data&&await this.adapter.write(this.data)}async update(e){e(this.data),await this.write()}};async function be(t,e){let r=process.env.NODE_ENV==="test"?new L:new U(t),o=new G(r,e);return await o.read(),o}import{createReadStream as we}from"node:fs";import D from"node:path";async function q(t,e){let{credentials:r,dryRun:o=!1,service:n,verbose:i=!1}=e,a=d.verbose;d.verbose=i;let y=[],S=await _(t);d.info(`Found ${S.length} video files in directory "${t}"`);let c=await be(D.join(t,".vidup-state.json"),{syncState:[]});c.data.syncState=c.data.syncState.filter(s=>S.includes(D.join(t,s.filename)));for(let s of S){let l=D.basename(s),g=await Qe(s,{algorithm:"sha1"}),E=c.data.syncState.find(F=>F.filename===l);E?E.localHash=g:c.data.syncState.push({filename:l,localHash:g,remoteHash:{}})}if(o||await c.write(),n!=="bunny")throw new Error(`Streaming service not yet implemented: ${n}`);let p=new qe({apiKey:r.key,videoLibrary:r.library}),f=await p.listAllVideos();d.info(`Found ${f.length} video files on ${n} remote streaming service`);let h=f.filter(s=>{let l=c.data.syncState.find(g=>g.filename===s.title);return l!==void 0&&l.localHash===l.remoteHash[n]});for(let s of h)y.push({action:"None",localFile:s.title,remoteId:s.guid});let b=c.data.syncState.filter(s=>!f.some(l=>l.title===s.filename));for(let s of b)y.push({action:"Create",localFile:s.filename,remoteId:"Not yet uploaded (Dry run)"});let x=f.filter(s=>{let l=c.data.syncState.find(g=>g.filename===s.title);return l!==void 0&&l.localHash!==l.remoteHash[n]});for(let s of x)y.push({action:"Update",localFile:s.title,remoteId:"Not yet uploaded (Dry run)"});let N=f.filter(s=>!c.data.syncState.some(l=>l.filename===s.title));for(let s of N)y.push({action:"Delete",localFile:s.title,remoteId:s.guid});if(!o){c.data.lastRun=new Date,await c.write(),d.info("Synchronizing...");for(let[s,l]of N.entries()){if(s===0&&d.info(`Deleting ${N.length} remote videos...`),!(await d.infoSpin(p.deleteVideo(l.guid),`Deleting remote video ${s+1}/${N.length}: ${l.title}`)).success)throw new Error(`Failed to delete remote video: ${l.title}`);c.data.lastUpdate=new Date,await c.write()}for(let[s,l]of b.entries()){s===0&&d.info(`Uploading ${b.length} new local videos...`);let g=we(D.join(t,l.filename)),E=await d.infoSpin(p.createAndUploadVideo(g,{title:l.filename}),`Uploading new video ${s+1}/${b.length}: ${l.filename}`);d.info(`Remote video ${s+1}/${b.length} created with GUID: ${E.guid}`);let F=c.data.syncState.find(R=>R.filename===l.filename);if(F===void 0)throw new Error(`Failed to find state entry for: ${l.filename}`);F.remoteHash[n]=l.localHash,c.data.lastUpdate=new Date,await c.write();let M=y.find(R=>R.localFile===l.filename);if(M===void 0)throw new Error(`Failed to find report entry for: ${l.filename}`);M.remoteId=E.guid}for(let[s,l]of x.entries()){s===0&&(d.info(`Updating ${x.length} remote videos...`),d.warn("Bunny does not currently support updating videos in-place, so vidup will delete and re-uploading instead... this will change the video's GUID!"));let g=c.data.syncState.find(H=>H.filename===l.title);if(g===void 0)throw new Error(`Failed to find state entry for: ${l.title}`);if(!(await p.deleteVideo(l.guid)).success)throw new Error(`Failed to delete remote video before updating: ${l.title}`);let F=we(D.join(t,g.filename)),M=await d.infoSpin(p.createAndUploadVideo(F,{title:g.filename}),`Updating remote video ${s+1}/${x.length}: ${l.title}`);d.info(`Updated remote video ${s+1}/${x.length} created with GUID: ${M.guid}`),g.remoteHash[n]=g.localHash,c.data.lastUpdate=new Date,await c.write();let R=y.find(H=>H.localFile===g.filename);if(R===void 0)throw new Error(`Failed to find report entry for: ${g.filename}`);R.remoteId=M.guid}d.info(`All ${S.length} videos are now in sync!`)}return d.verbose=a,y}import st from"node:path";var ve=t=>Number.isFinite(t)?t:0;function Xe(t){return{days:Math.trunc(t/864e5),hours:Math.trunc(t/36e5%24),minutes:Math.trunc(t/6e4%60),seconds:Math.trunc(t/1e3%60),milliseconds:Math.trunc(t%1e3),microseconds:Math.trunc(ve(t*1e3)%1e3),nanoseconds:Math.trunc(ve(t*1e6)%1e3)}}function et(t){return{days:t/86400000n,hours:t/3600000n%24n,minutes:t/60000n%60n,seconds:t/1000n%60n,milliseconds:t%1000n,microseconds:0n,nanoseconds:0n}}function Q(t){switch(typeof t){case"number":{if(Number.isFinite(t))return Xe(t);break}case"bigint":return et(t)}throw new TypeError("Expected a finite number or bigint")}var tt=t=>t===0||t===0n,rt=(t,e)=>e===1||e===1n?t:`${t}s`,ot=1e-7,nt=24n*60n*60n*1000n;function X(t,e){let r=typeof t=="bigint";if(!r&&!Number.isFinite(t))throw new TypeError("Expected a finite number or bigint");e={...e},e.colonNotation&&(e.compact=!1,e.formatSubMilliseconds=!1,e.separateMilliseconds=!1,e.verbose=!1),e.compact&&(e.unitCount=1,e.secondsDecimalDigits=0,e.millisecondsDecimalDigits=0);let o=[],n=(c,p)=>{let f=Math.floor(c*10**p+ot);return(Math.round(f)/10**p).toFixed(p)},i=(c,p,f,h)=>{if(!((o.length===0||!e.colonNotation)&&tt(c)&&!(e.colonNotation&&f==="m"))){if(h=h??String(c),e.colonNotation){let b=h.includes(".")?h.split(".")[0].length:h.length,x=o.length>0?2:1;h="0".repeat(Math.max(0,x-b))+h}else h+=e.verbose?" "+rt(p,c):f;o.push(h)}},a=Q(t),y=BigInt(a.days);if(i(y/365n,"year","y"),i(y%365n,"day","d"),i(Number(a.hours),"hour","h"),i(Number(a.minutes),"minute","m"),e.separateMilliseconds||e.formatSubMilliseconds||!e.colonNotation&&t<1e3){let c=Number(a.seconds),p=Number(a.milliseconds),f=Number(a.microseconds),h=Number(a.nanoseconds);if(i(c,"second","s"),e.formatSubMilliseconds)i(p,"millisecond","ms"),i(f,"microsecond","\xB5s"),i(h,"nanosecond","ns");else{let b=p+f/1e3+h/1e6,x=typeof e.millisecondsDecimalDigits=="number"?e.millisecondsDecimalDigits:0,N=b>=1?Math.round(b):Math.ceil(b),s=x?b.toFixed(x):N;i(Number.parseFloat(s),"millisecond","ms",s)}}else{let c=(r?Number(t%nt):t)/1e3%60,p=typeof e.secondsDecimalDigits=="number"?e.secondsDecimalDigits:1,f=n(c,p),h=e.keepDecimalsOnWholeSeconds?f:f.replace(/\.0+$/,"");i(Number.parseFloat(h),"second","s",h)}if(o.length===0)return"0"+(e.verbose?" milliseconds":"ms");let S=e.colonNotation?":":" ";return typeof e.unitCount=="number"&&(o=o.slice(0,Math.max(e.unitCount,1))),o.join(S)}import it from"node:os";var xe=it.homedir();function ee(t){if(typeof t!="string")throw new TypeError(`Expected a string, got ${typeof t}`);return xe?t.replace(/^~(?=$|\/|\\)/,xe):t}import at from"yargs";import{hideBin as lt}from"yargs/helpers";var ct=performance.now(),Oe=at(lt(process.argv));await Oe.scriptName("vidup").usage("$0 [command]","Run a vidup command.").command(["$0 <directory> [options]","sync <directory> [options]"],"Synchronize a remote video streaming service to mirror the contents of a local directory. Warning: This command will irrevocably delete remote videos that are not present in the local directory.",t=>t.positional("directory",{default:void 0,demandOption:!0,describe:"The path to the local directory of video files to sync.",type:"string"}).option("service",{alias:"s",choices:["bunny","mux","cloudflare"],demandOption:!0,describe:"Streaming service / platform to sync local video files to. Only the Bunny.net streaming CDN is supported at this time.",type:"string"}).option("key",{default:void 0,demandOption:!0,describe:"Streaming service API access key.",type:"string"}).option("library",{default:void 0,demandOption:!0,describe:"Streaming service library ID.",type:"string"}).option("strip-metadata",{default:!1,describe:"Remove all metadata from the video files before uploading them to the streaming service. Warning: This will modify local videos in-place.",type:"boolean"}).option("dry-run",{alias:"d",default:!1,describe:"Perform a dry run without making any changes. Useful for testing and debugging. Pairs well with the `--json` command.",type:"boolean"}).option("json",{default:!1,describe:"Output the sync report as JSON.",type:"boolean"}).option("verbose",{default:!1,describe:"Enable verbose logging. All verbose logs and prefixed with their log level and are printed to `stderr` for ease of redirection.",type:"boolean"}).check(e=>{if(e.service==="bunny")return e;throw new Error(`Sorry, vidup doesn't yet implement synchronization support the ${e.service} streaming service. Only Bunny.net is supported at the moment. If you'd like to see support for another service, please open an issue or send a PR on GitHub: https://github.com/kitschpatrol/vidup/issues`)}),async({directory:t,dryRun:e,json:r,key:o,library:n,service:i,stripMetadata:a,verbose:y})=>{d.verbose=y;let S=st.resolve(ee(t));d.info("Starting video synchronization..."),e&&d.warn("Dry run enabled, not making any changes");let c=a?await Z(S,{dryRun:e,verbose:y}):[],p=await q(S,{credentials:{key:o,library:n},dryRun:e,service:i,verbose:y});if(r){for(let f of p)f.stripMetadata=f.localFile!==void 0&&c.includes(f.localFile);process.stdout.write(JSON.stringify(p,void 0,2)),process.stdout.write(`
|
|
9
|
+
`)}else{for(let f of c)process.stdout.write(`${e?"Found":"Stripped"} metadata: "${f}"
|
|
10
|
+
`);for(let f of p)process.stdout.write(`${f.action}: "${f.localFile}" Remote GUID: "${f.remoteId}"
|
|
11
|
+
`)}d.info(`Synchronized video in ${X(performance.now()-ct)}`),process.exitCode=0}).demandCommand(1).alias("h","help").version().alias("v","version").help().wrap(process.stdout.isTTY?Math.min(120,Oe.terminalWidth()):0).parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vidup",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Synchronize a local directory of video files to remote streaming services.",
|
|
6
6
|
"repository": {
|
|
@@ -48,10 +48,11 @@
|
|
|
48
48
|
"ffmpeg-static": "^5.2.0",
|
|
49
49
|
"fs-extra": "^11.2.0",
|
|
50
50
|
"hasha": "^6.0.0",
|
|
51
|
-
"ora": "^8.0.1"
|
|
51
|
+
"ora": "^8.0.1",
|
|
52
|
+
"yargs": "^17.7.2"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@kitschpatrol/shared-config": "^4.6.
|
|
55
|
+
"@kitschpatrol/shared-config": "^4.6.2",
|
|
55
56
|
"@types/fs-extra": "^11.0.4",
|
|
56
57
|
"@types/node": "^20.12.5",
|
|
57
58
|
"@types/yargs": "^17.0.32",
|
|
@@ -61,8 +62,7 @@
|
|
|
61
62
|
"pretty-ms": "^9.0.0",
|
|
62
63
|
"tsup": "^8.0.2",
|
|
63
64
|
"typescript": "^5.4.4",
|
|
64
|
-
"untildify": "^5.0.0"
|
|
65
|
-
"yargs": "^17.7.2"
|
|
65
|
+
"untildify": "^5.0.0"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
package/dist/.DS_Store
DELETED
|
Binary file
|