@kitschpatrol/tldraw-cli 1.2.0 → 1.2.1
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 +2 -2
- package/package.json +1 -1
- package/readme.md +4 -4
package/bin/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Ot=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var cn="1.
|
|
2
|
+
var Ot=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var cn="1.2.0";import dn from"express";import yi from"node:net";import Oi from"node:os";var ue=class extends Error{constructor(t){super(`${t} is locked`)}},Zt={old:new Set,young:new Set},_i=1e3*15;var ie,Ci=()=>{let s=Oi.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let e of Object.values(s))for(let n of e)t.add(n.address);return t},fn=s=>new Promise((t,e)=>{let n=yi.createServer();n.unref(),n.on("error",e),n.listen(s,()=>{let{port:i}=n.address();n.close(()=>{t(i)})})}),hn=async(s,t)=>{if(s.host||s.port===0)return fn(s);for(let e of t)try{await fn({port:s.port,host:e})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return s.port},xi=function*(s){s&&(yield*s),yield 0};async function ve(s){let t,e=new Set;if(s&&(s.port&&(t=typeof s.port=="number"?[s.port]:s.port),s.exclude)){let i=s.exclude;if(typeof i[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let r of i){if(typeof r!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(r))throw new TypeError(`Number ${r} in the exclude option is not a safe integer and can't be used`)}e=new Set(i)}ie===void 0&&(ie=setTimeout(()=>{ie=void 0,Zt.old=Zt.young,Zt.young=new Set},_i),ie.unref&&ie.unref());let n=Ci();for(let i of xi(t))try{if(e.has(i))continue;let r=await hn({...s,port:i},n);for(;Zt.old.has(r)||Zt.young.has(r);){if(i!==0)throw new ue(i);r=await hn({...s,port:i},n)}return Zt.young.add(r),r}catch(r){if(!["EADDRINUSE","EACCES"].includes(r.code)&&!(r instanceof ue))throw r}throw new Error("No available ports found")}import Fe from"node:fs/promises";import de from"node:os";import jt from"node:path";import{dirname as ji}from"node:path";import{fileURLToPath as Ai}from"node:url";import pn from"puppeteer";import Ei from"node:os";var un=Ei.homedir();function se(s){if(typeof s!="string")throw new TypeError(`Expected a string, got ${typeof s}`);return un?s.replace(/^~(?=$|\/|\\)/,un):s}async function mn(s,t="svg",e="./",n=!1){return s.startsWith("https://www.tldraw.com/")?(n&&console.log("tldraw URL detected"),Pi(s,t,e,n)):(n&&console.log("Local file detected"),Si(s,t,e,n))}async function Pi(s,t,e,n){n&&console.log("Starting Puppeteer...");let r=await(await pn.launch({headless:"new"})).newPage(),a=await r.target().createCDPSession();await a.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:de.tmpdir(),eventsEnabled:!0}),n&&console.log(`Navigating to: ${s}`),await r.goto(s,{waitUntil:"networkidle0"}),n&&console.log("Requesting download"),await $i(r,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${t}`]);let c=await gn(a);n&&console.log("Download complete");let m=jt.join(de.tmpdir(),c),w=se(jt.join(e,`${c}.${t}`));return await Fe.rename(m,w),n&&console.log(`Saved to "${w}"`),w}async function Si(s,t,e,n){let i=ji(Ai(import.meta.url)),r=jt.resolve(se(s));n&&console.log(`Loading tldr file "${r}"`);let a=await Fe.readFile(r,"utf8");n&&console.log("Starting tldraw server...");let c=jt.join(i,i.endsWith("/src/lib")?"../../dist/tldraw":i.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");n&&console.log(`tldraw served from "${c}"`);let m=await Mi(c),{port:w}=m.address();n&&console.log(`tldraw hosted at "http://localhost:${w}"`),n&&console.log("Starting Puppeteer...");let p=await pn.launch({headless:"new"}),u=await p.newPage();await u.setRequestInterception(!0),u.on("request",W=>{W.url().endsWith("favicon.ico")?W.respond({status:200}):W.continue()}),Ii(u,n);let g=await u.target().createCDPSession();await g.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:de.tmpdir(),eventsEnabled:!0}),await u.goto(`http://localhost:${w}`),await u.waitForFunction(()=>window.tldrawExportFile!==void 0),n&&console.log("Requesting download"),await u.evaluate((W,z)=>{window.tldrawExportFile(W,z)},a,t);let y=await gn(g);n&&console.log("Download complete"),await p.close(),n&&console.log("Stopped Puppeteer");let E=jt.basename(s,jt.extname(s)),_=jt.join(de.tmpdir(),y),d=se(jt.join(e,`${E}.${t}`));return await Fe.rename(_,d),n&&console.log(`Saved to "${d}"`),m.close(),n&&console.log("Stopped tldraw server"),jt.resolve(d)}function Ii(s,t){s.on("console",e=>{let n=e.type(),i=e.text();n==="error"?console.error(`[Browser] ${i}`):n==="warning"?console.warn(`[Browser] ${i}`):t&&console.log(`[Browser] ${i}`)})}async function Mi(s){let t=dn(),e=await ve();return t.use(dn.static(s)),new Promise((n,i)=>{let r=t.listen(e,()=>{n(r)});r.on("error",a=>{i(a)})})}async function gn(s){return new Promise((t,e)=>{s.on("Browser.downloadProgress",n=>{n.state==="completed"?t(n.guid):n.state==="canceled"&&e(new Error("Download was canceled"))})})}async function $i(s,t){for(let e of t)await s.waitForSelector(`[data-testid="${e}"]`),await s.click(`[data-testid="${e}"]`)}import{notStrictEqual as ns,strictEqual as is}from"assert";var vi={right:Li,center:zi},Fi=0,pe=1,Ni=2,me=3,Ne=class{constructor(t){var e;this.width=t.width,this.wrap=(e=t.wrap)!==null&&e!==void 0?e:!0,this.rows=[]}span(...t){let e=this.div(...t);e.span=!0}resetOutput(){this.rows=[]}div(...t){if(t.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&typeof t[0]=="string")return this.applyLayoutDSL(t[0]);let e=t.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return t.length===1&&typeof t[0]=="string"&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){let e=t.split(`
|
|
3
3
|
`).map(i=>i.split(" ")),n=0;return e.forEach(i=>{i.length>1&&at.stringWidth(i[0])>n&&(n=Math.min(Math.floor(this.width*.5),at.stringWidth(i[0])))}),e.forEach(i=>{this.div(...i.map((r,a)=>({text:r.trim(),padding:this.measurePadding(r),width:a===0&&i.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(t){return{text:t,padding:this.measurePadding(t)}}measurePadding(t){let e=at.stripAnsi(t);return[0,e.match(/\s*$/)[0].length,0,e.match(/^\s*/)[0].length]}toString(){let t=[];return this.rows.forEach(e=>{this.rowToString(e,t)}),t.filter(e=>!e.hidden).map(e=>e.text).join(`
|
|
4
4
|
`)}rowToString(t,e){return this.rasterize(t).forEach((n,i)=>{let r="";n.forEach((a,c)=>{let{width:m}=t[c],w=this.negatePadding(t[c]),p=a;if(w>at.stringWidth(a)&&(p+=" ".repeat(w-at.stringWidth(a))),t[c].align&&t[c].align!=="left"&&this.wrap){let g=vi[t[c].align];p=g(p,w),at.stringWidth(p)<w&&(p+=" ".repeat((m||0)-at.stringWidth(p)-1))}let u=t[c].padding||[0,0,0,0];u[me]&&(r+=" ".repeat(u[me])),r+=bn(t[c],p,"| "),r+=p,r+=bn(t[c],p," |"),u[pe]&&(r+=" ".repeat(u[pe])),i===0&&e.length>0&&(r=this.renderInline(r,e[e.length-1]))}),e.push({text:r.replace(/ +$/,""),span:t.span})}),e}renderInline(t,e){let n=t.match(/^ */),i=n?n[0].length:0,r=e.text,a=at.stringWidth(r.trimRight());return e.span?this.wrap?i<a?t:(e.hidden=!0,r.trimRight()+" ".repeat(i-a)+t.trimLeft()):(e.hidden=!0,r+t):t}rasterize(t){let e=[],n=this.columnWidths(t),i;return t.forEach((r,a)=>{r.width=n[a],this.wrap?i=at.wrap(r.text,this.negatePadding(r),{hard:!0}).split(`
|
|
5
5
|
`):i=r.text.split(`
|
|
@@ -62,7 +62,7 @@ ${E.join(`
|
|
|
62
62
|
`;g.forEach(E=>{y+=E}),t.fail(y)}};let m={};r.conflicts=function(u,g){j("<string|object> [array|string]",[u,g],arguments.length),typeof u=="object"?Object.keys(u).forEach(y=>{r.conflicts(y,u[y])}):(s.global(u),m[u]||(m[u]=[]),Array.isArray(g)?g.forEach(y=>r.conflicts(u,y)):m[u].push(g))},r.getConflicting=()=>m,r.conflicting=function(u){Object.keys(u).forEach(g=>{m[g]&&m[g].forEach(y=>{y&&u[g]!==void 0&&u[y]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",g,y))})}),s.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(m).forEach(g=>{m[g].forEach(y=>{y&&u[e.Parser.camelCase(g)]!==void 0&&u[e.Parser.camelCase(y)]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",g,y))})})},r.recommendCommands=function(u,g){g=g.sort((d,W)=>W.length-d.length);let E=null,_=1/0;for(let d=0,W;(W=g[d])!==void 0;d++){let z=qn(u,W);z<=3&&z<_&&(_=z,E=W)}E&&t.fail(n("Did you mean %s?",E))},r.reset=function(u){return a=It(a,g=>!u[g]),m=It(m,g=>!u[g]),r};let w=[];return r.freeze=function(){w.push({implied:a,conflicting:m})},r.unfreeze=function(){let u=w.pop();ot(u,void 0,e),{implied:a,conflicting:m}=u},r}var Je=[],ae;function le(s,t,e,n){ae=n;let i={};if(Object.prototype.hasOwnProperty.call(s,"extends")){if(typeof s.extends!="string")return i;let r=/\.json|\..*rc$/.test(s.extends),a=null;if(r)a=Es(t,s.extends);else try{a=Ot.resolve(s.extends)}catch{return s}xs(a),Je.push(a),i=r?JSON.parse(ae.readFileSync(a,"utf8")):Ot(s.extends),delete s.extends,i=le(i,ae.path.dirname(a),e,ae)}return Je=[],e?Jn(i,s):Object.assign({},i,s)}function xs(s){if(Je.indexOf(s)>-1)throw new V(`Circular extended configurations: '${s}'.`)}function Es(s,t){return ae.path.resolve(s,t)}function Jn(s,t){let e={};function n(i){return i&&typeof i=="object"&&!Array.isArray(i)}Object.assign(e,s);for(let i of Object.keys(t))n(t[i])&&n(e[i])?e[i]=Jn(s[i],t[i]):e[i]=t[i];return e}var A=function(s,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?s!==t||!i:!t.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(s,e):i?i.value=e:t.set(s,e),e},o=function(s,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?s!==t||!n:!t.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(s):n?n.value:t.get(s)},tt,Tt,ce,ut,lt,Ce,$t,Ut,xe,dt,Ee,pt,_t,ct,mt,je,te,st,M,Ae,Pe,ft,Ht,ee,Yt,vt,Se,N,Bt,Gt,Vt,D,Ie,Ct,X;function gi(s){return(t=[],e=s.process.cwd(),n)=>{let i=new ln(t,e,n,s);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var Zn=Symbol("copyDoubleDash"),Xn=Symbol("copyDoubleDash"),Ze=Symbol("deleteFromParserHintObject"),kn=Symbol("emitWarning"),ti=Symbol("freeze"),ei=Symbol("getDollarZero"),qt=Symbol("getParserConfiguration"),ni=Symbol("getUsageConfiguration"),Xe=Symbol("guessLocale"),ii=Symbol("guessVersion"),si=Symbol("parsePositionalNumbers"),ke=Symbol("pkgUp"),Ft=Symbol("populateParserHintArray"),ne=Symbol("populateParserHintSingleValueDictionary"),tn=Symbol("populateParserHintArrayDictionary"),en=Symbol("populateParserHintDictionary"),nn=Symbol("sanitizeKey"),sn=Symbol("setKey"),rn=Symbol("unfreeze"),ri=Symbol("validateAsync"),oi=Symbol("getCommandInstance"),ai=Symbol("getContext"),li=Symbol("getHasOutput"),ci=Symbol("getLoggerInstance"),fi=Symbol("getParseContext"),hi=Symbol("getUsageInstance"),ui=Symbol("getValidationInstance"),Me=Symbol("hasParseCallback"),di=Symbol("isGlobalContext"),Kt=Symbol("postProcess"),pi=Symbol("rebase"),on=Symbol("reset"),fe=Symbol("runYargsParserAndExecuteCommands"),an=Symbol("runValidation"),mi=Symbol("setHasOutput"),Qt=Symbol("kTrackManuallySetKeys"),ln=class{constructor(t=[],e,n,i){this.customScriptName=!1,this.parsed=!1,tt.set(this,void 0),Tt.set(this,void 0),ce.set(this,{commands:[],fullCommands:[]}),ut.set(this,null),lt.set(this,null),Ce.set(this,"show-hidden"),$t.set(this,null),Ut.set(this,!0),xe.set(this,{}),dt.set(this,!0),Ee.set(this,[]),pt.set(this,void 0),_t.set(this,{}),ct.set(this,!1),mt.set(this,null),je.set(this,!0),te.set(this,void 0),st.set(this,""),M.set(this,void 0),Ae.set(this,void 0),Pe.set(this,{}),ft.set(this,null),Ht.set(this,null),ee.set(this,{}),Yt.set(this,{}),vt.set(this,void 0),Se.set(this,!1),N.set(this,void 0),Bt.set(this,!1),Gt.set(this,!1),Vt.set(this,!1),D.set(this,void 0),Ie.set(this,{}),Ct.set(this,null),X.set(this,void 0),A(this,N,i,"f"),A(this,vt,t,"f"),A(this,Tt,e,"f"),A(this,Ae,n,"f"),A(this,pt,new ye(this),"f"),this.$0=this[ei](),this[on](),A(this,tt,o(this,tt,"f"),"f"),A(this,D,o(this,D,"f"),"f"),A(this,X,o(this,X,"f"),"f"),A(this,M,o(this,M,"f"),"f"),o(this,M,"f").showHiddenOpt=o(this,Ce,"f"),A(this,te,this[Xn](),"f")}addHelpOpt(t,e){let n="help";return j("[string|boolean] [string]",[t,e],arguments.length),o(this,mt,"f")&&(this[Ze](o(this,mt,"f")),A(this,mt,null,"f")),t===!1&&e===void 0?this:(A(this,mt,typeof t=="string"?t:n,"f"),this.boolean(o(this,mt,"f")),this.describe(o(this,mt,"f"),e||o(this,D,"f").deferY18nLookup("Show help")),this)}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(j("[string|boolean] [string]",[t,e],arguments.length),t===!1&&e===void 0)return this;let n=typeof t=="string"?t:o(this,Ce,"f");return this.boolean(n),this.describe(n,e||o(this,D,"f").deferY18nLookup("Show hidden options")),o(this,M,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return j("<object|string|array> [string|array]",[t,e],arguments.length),this[tn](this.alias.bind(this),"alias",t,e),this}array(t){return j("<array|string>",[t],arguments.length),this[Ft]("array",t),this[Qt](t),this}boolean(t){return j("<array|string>",[t],arguments.length),this[Ft]("boolean",t),this[Qt](t),this}check(t,e){return j("<function> [boolean]",[t,e],arguments.length),this.middleware((n,i)=>Rt(()=>t(n,i.getOptions()),r=>(r?(typeof r=="string"||r instanceof Error)&&o(this,D,"f").fail(r.toString(),r):o(this,D,"f").fail(o(this,N,"f").y18n.__("Argument check failed: %s",t.toString())),n),r=>(o(this,D,"f").fail(r.message?r.message:r.toString(),r),n)),!1,e),this}choices(t,e){return j("<object|string|array> [string|array]",[t,e],arguments.length),this[tn](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(j("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new V("coerce callback must be provided");for(let n of t)this.coerce(n,e);return this}else if(typeof t=="object"){for(let n of Object.keys(t))this.coerce(n,t[n]);return this}if(!e)throw new V("coerce callback must be provided");return o(this,M,"f").key[t]=!0,o(this,pt,"f").addCoerceMiddleware((n,i)=>{let r;return Object.prototype.hasOwnProperty.call(n,t)?Rt(()=>(r=i.getAliases(),e(n[t])),c=>{n[t]=c;let m=i.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[t]&&m!==!0)for(let w of r[t])n[w]=c;return n},c=>{throw new V(c.message)}):n},t),this}conflicts(t,e){return j("<string|object> [string|array]",[t,e],arguments.length),o(this,X,"f").conflicts(t,e),this}config(t="config",e,n){return j("[object|string] [string|function] [function]",[t,e,n],arguments.length),typeof t=="object"&&!Array.isArray(t)?(t=le(t,o(this,Tt,"f"),this[qt]()["deep-merge-config"]||!1,o(this,N,"f")),o(this,M,"f").configObjects=(o(this,M,"f").configObjects||[]).concat(t),this):(typeof e=="function"&&(n=e,e=void 0),this.describe(t,e||o(this,D,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach(i=>{o(this,M,"f").config[i]=n||!0}),this)}completion(t,e,n){return j("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),typeof e=="function"&&(n=e,e=void 0),A(this,lt,t||o(this,lt,"f")||"completion","f"),!e&&e!==!1&&(e="generate completion script"),this.command(o(this,lt,"f"),e),n&&o(this,ut,"f").registerFunction(n),this}command(t,e,n,i,r,a){return j("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,i,r,a],arguments.length),o(this,tt,"f").addHandler(t,e,n,i,r,a),this}commands(t,e,n,i,r,a){return this.command(t,e,n,i,r,a)}commandDir(t,e){j("<string> [object]",[t,e],arguments.length);let n=o(this,Ae,"f")||o(this,N,"f").require;return o(this,tt,"f").addDirectory(t,n,o(this,N,"f").getCallerFile(),e),this}count(t){return j("<array|string>",[t],arguments.length),this[Ft]("count",t),this[Qt](t),this}default(t,e,n){return j("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(Ge(t,o(this,N,"f")),o(this,M,"f").defaultDescription[t]=n),typeof e=="function"&&(Ge(t,o(this,N,"f")),o(this,M,"f").defaultDescription[t]||(o(this,M,"f").defaultDescription[t]=o(this,D,"f").functionDescription(e)),e=e.call()),this[ne](this.default.bind(this),"default",t,e),this}defaults(t,e,n){return this.default(t,e,n)}demandCommand(t=1,e,n,i){return j("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,n,i],arguments.length),typeof e!="number"&&(n=e,e=1/0),this.global("_",!1),o(this,M,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:i},this}demand(t,e,n){return Array.isArray(e)?(e.forEach(i=>{ot(n,!0,o(this,N,"f")),this.demandOption(i,n)}),e=1/0):typeof e!="number"&&(n=e,e=1/0),typeof t=="number"?(ot(n,!0,o(this,N,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach(i=>{ot(n,!0,o(this,N,"f")),this.demandOption(i,n)}):typeof n=="string"?this.demandOption(t,n):(n===!0||typeof n>"u")&&this.demandOption(t),this}demandOption(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[ne](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return j("<string> [string|boolean]",[t,e],arguments.length),o(this,M,"f").deprecatedOptions[t]=e,this}describe(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[sn](t,!0),o(this,D,"f").describe(t,e),this}detectLocale(t){return j("<boolean>",[t],arguments.length),A(this,Ut,t,"f"),this}env(t){return j("[string|boolean]",[t],arguments.length),t===!1?delete o(this,M,"f").envPrefix:o(this,M,"f").envPrefix=t||"",this}epilogue(t){return j("<string>",[t],arguments.length),o(this,D,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return j("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach(n=>this.example(...n)):o(this,D,"f").example(t,e),this}exit(t,e){A(this,ct,!0,"f"),A(this,$t,e,"f"),o(this,dt,"f")&&o(this,N,"f").process.exit(t)}exitProcess(t=!0){return j("[boolean]",[t],arguments.length),A(this,dt,t,"f"),this}fail(t){if(j("<function|boolean>",[t],arguments.length),typeof t=="boolean"&&t!==!1)throw new V("Invalid first argument. Expected function or boolean 'false'");return o(this,D,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return j("<array> [function]",[t,e],arguments.length),e?o(this,ut,"f").getCompletion(t,e):new Promise((n,i)=>{o(this,ut,"f").getCompletion(t,(r,a)=>{r?i(r):n(a)})})}getDemandedOptions(){return j([],0),o(this,M,"f").demandedOptions}getDemandedCommands(){return j([],0),o(this,M,"f").demandedCommands}getDeprecatedOptions(){return j([],0),o(this,M,"f").deprecatedOptions}getDetectLocale(){return o(this,Ut,"f")}getExitProcess(){return o(this,dt,"f")}getGroups(){return Object.assign({},o(this,_t,"f"),o(this,Yt,"f"))}getHelp(){if(A(this,ct,!0,"f"),!o(this,D,"f").hasCachedHelpMessage()){if(!this.parsed){let e=this[fe](o(this,vt,"f"),void 0,void 0,0,!0);if(q(e))return e.then(()=>o(this,D,"f").help())}let t=o(this,tt,"f").runDefaultBuilderOn(this);if(q(t))return t.then(()=>o(this,D,"f").help())}return Promise.resolve(o(this,D,"f").help())}getOptions(){return o(this,M,"f")}getStrict(){return o(this,Bt,"f")}getStrictCommands(){return o(this,Gt,"f")}getStrictOptions(){return o(this,Vt,"f")}global(t,e){return j("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),e!==!1?o(this,M,"f").local=o(this,M,"f").local.filter(n=>t.indexOf(n)===-1):t.forEach(n=>{o(this,M,"f").local.includes(n)||o(this,M,"f").local.push(n)}),this}group(t,e){j("<string|array> <string>",[t,e],arguments.length);let n=o(this,Yt,"f")[e]||o(this,_t,"f")[e];o(this,Yt,"f")[e]&&delete o(this,Yt,"f")[e];let i={};return o(this,_t,"f")[e]=(n||[]).concat(t).filter(r=>i[r]?!1:i[r]=!0),this}hide(t){return j("<string>",[t],arguments.length),o(this,M,"f").hiddenOptions.push(t),this}implies(t,e){return j("<string|object> [number|string|array]",[t,e],arguments.length),o(this,X,"f").implies(t,e),this}locale(t){return j("[string]",[t],arguments.length),t===void 0?(this[Xe](),o(this,N,"f").y18n.getLocale()):(A(this,Ut,!1,"f"),o(this,N,"f").y18n.setLocale(t),this)}middleware(t,e,n){return o(this,pt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return j("<string|object|array> [number]",[t,e],arguments.length),this[ne](this.nargs.bind(this),"narg",t,e),this}normalize(t){return j("<array|string>",[t],arguments.length),this[Ft]("normalize",t),this}number(t){return j("<array|string>",[t],arguments.length),this[Ft]("number",t),this[Qt](t),this}option(t,e){if(j("<string|object> [object]",[t,e],arguments.length),typeof t=="object")Object.keys(t).forEach(n=>{this.options(n,t[n])});else{typeof e!="object"&&(e={}),this[Qt](t),o(this,Ct,"f")&&(t==="version"||e?.alias==="version")&&this[kn](['"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(`
|
|
63
63
|
`),void 0,"versionWarning"),o(this,M,"f").key[t]=!0,e.alias&&this.alias(t,e.alias);let n=e.deprecate||e.deprecated;n&&this.deprecateOption(t,n);let i=e.demand||e.required||e.require;i&&this.demand(t,i),e.demandOption&&this.demandOption(t,typeof e.demandOption=="string"?e.demandOption:void 0),e.conflicts&&this.conflicts(t,e.conflicts),"default"in e&&this.default(t,e.default),e.implies!==void 0&&this.implies(t,e.implies),e.nargs!==void 0&&this.nargs(t,e.nargs),e.config&&this.config(t,e.configParser),e.normalize&&this.normalize(t),e.choices&&this.choices(t,e.choices),e.coerce&&this.coerce(t,e.coerce),e.group&&this.group(t,e.group),(e.boolean||e.type==="boolean")&&(this.boolean(t),e.alias&&this.boolean(e.alias)),(e.array||e.type==="array")&&(this.array(t),e.alias&&this.array(e.alias)),(e.number||e.type==="number")&&(this.number(t),e.alias&&this.number(e.alias)),(e.string||e.type==="string")&&(this.string(t),e.alias&&this.string(e.alias)),(e.count||e.type==="count")&&this.count(t),typeof e.global=="boolean"&&this.global(t,e.global),e.defaultDescription&&(o(this,M,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);let r=e.describe||e.description||e.desc,a=o(this,D,"f").getDescriptions();(!Object.prototype.hasOwnProperty.call(a,t)||typeof r=="string")&&this.describe(t,r),e.hidden&&this.hide(t),e.requiresArg&&this.requiresArg(t)}return this}options(t,e){return this.option(t,e)}parse(t,e,n){j("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[ti](),typeof t>"u"&&(t=o(this,vt,"f")),typeof e=="object"&&(A(this,Ht,e,"f"),e=n),typeof e=="function"&&(A(this,ft,e,"f"),e=!1),e||A(this,vt,t,"f"),o(this,ft,"f")&&A(this,dt,!1,"f");let i=this[fe](t,!!e),r=this.parsed;return o(this,ut,"f").setParsed(this.parsed),q(i)?i.then(a=>(o(this,ft,"f")&&o(this,ft,"f").call(this,o(this,$t,"f"),a,o(this,st,"f")),a)).catch(a=>{throw o(this,ft,"f")&&o(this,ft,"f")(a,this.parsed.argv,o(this,st,"f")),a}).finally(()=>{this[rn](),this.parsed=r}):(o(this,ft,"f")&&o(this,ft,"f").call(this,o(this,$t,"f"),i,o(this,st,"f")),this[rn](),this.parsed=r,i)}parseAsync(t,e,n){let i=this.parse(t,e,n);return q(i)?i:Promise.resolve(i)}parseSync(t,e,n){let i=this.parse(t,e,n);if(q(i))throw new V(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return i}parserConfiguration(t){return j("<object>",[t],arguments.length),A(this,Pe,t,"f"),this}pkgConf(t,e){j("<string> [string]",[t,e],arguments.length);let n=null,i=this[ke](e||o(this,Tt,"f"));return i[t]&&typeof i[t]=="object"&&(n=le(i[t],e||o(this,Tt,"f"),this[qt]()["deep-merge-config"]||!1,o(this,N,"f")),o(this,M,"f").configObjects=(o(this,M,"f").configObjects||[]).concat(n)),this}positional(t,e){j("<string> <object>",[t,e],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=It(e,(a,c)=>a==="type"&&!["string","number","boolean"].includes(c)?!1:n.includes(a));let i=o(this,ce,"f").fullCommands[o(this,ce,"f").fullCommands.length-1],r=i?o(this,tt,"f").cmdToParseOptions(i):{array:[],alias:{},default:{},demand:{}};return Xt(r).forEach(a=>{let c=r[a];Array.isArray(c)?c.indexOf(t)!==-1&&(e[a]=!0):c[t]&&!(a in e)&&(e[a]=c[t])}),this.group(t,o(this,D,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return j("[boolean]",[t],arguments.length),A(this,Se,t,"f"),this}required(t,e,n){return this.demand(t,e,n)}require(t,e,n){return this.demand(t,e,n)}requiresArg(t){return j("<array|string|object> [number]",[t],arguments.length),typeof t=="string"&&o(this,M,"f").narg[t]?this:(this[ne](this.requiresArg.bind(this),"narg",t,NaN),this)}showCompletionScript(t,e){return j("[string] [string]",[t,e],arguments.length),t=t||this.$0,o(this,te,"f").log(o(this,ut,"f").generateCompletionScript(t,e||o(this,lt,"f")||"completion")),this}showHelp(t){if(j("[string|function]",[t],arguments.length),A(this,ct,!0,"f"),!o(this,D,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[fe](o(this,vt,"f"),void 0,void 0,0,!0);if(q(n))return n.then(()=>{o(this,D,"f").showHelp(t)}),this}let e=o(this,tt,"f").runDefaultBuilderOn(this);if(q(e))return e.then(()=>{o(this,D,"f").showHelp(t)}),this}return o(this,D,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return j("[boolean|string] [string]",[t,e],arguments.length),o(this,D,"f").showHelpOnFail(t,e),this}showVersion(t){return j("[string|function]",[t],arguments.length),o(this,D,"f").showVersion(t),this}skipValidation(t){return j("<array|string>",[t],arguments.length),this[Ft]("skipValidation",t),this}strict(t){return j("[boolean]",[t],arguments.length),A(this,Bt,t!==!1,"f"),this}strictCommands(t){return j("[boolean]",[t],arguments.length),A(this,Gt,t!==!1,"f"),this}strictOptions(t){return j("[boolean]",[t],arguments.length),A(this,Vt,t!==!1,"f"),this}string(t){return j("<array|string>",[t],arguments.length),this[Ft]("string",t),this[Qt](t),this}terminalWidth(){return j([],0),o(this,N,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return j("<object>",[t],arguments.length),A(this,Ut,!1,"f"),o(this,N,"f").y18n.updateLocale(t),this}usage(t,e,n,i){if(j("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,i],arguments.length),e!==void 0){if(ot(t,null,o(this,N,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,i);throw new V(".usage() description must start with $0 if being used as alias for .command()")}else return o(this,D,"f").usage(t),this}usageConfiguration(t){return j("<object>",[t],arguments.length),A(this,Ie,t,"f"),this}version(t,e,n){let i="version";if(j("[boolean|string] [string] [string]",[t,e,n],arguments.length),o(this,Ct,"f")&&(this[Ze](o(this,Ct,"f")),o(this,D,"f").version(void 0),A(this,Ct,null,"f")),arguments.length===0)n=this[ii](),t=i;else if(arguments.length===1){if(t===!1)return this;n=t,t=i}else arguments.length===2&&(n=e,e=void 0);return A(this,Ct,typeof t=="string"?t:i,"f"),e=e||o(this,D,"f").deferY18nLookup("Show version number"),o(this,D,"f").version(n||void 0),this.boolean(o(this,Ct,"f")),this.describe(o(this,Ct,"f"),e),this}wrap(t){return j("<number|null|undefined>",[t],arguments.length),o(this,D,"f").wrap(t),this}[(tt=new WeakMap,Tt=new WeakMap,ce=new WeakMap,ut=new WeakMap,lt=new WeakMap,Ce=new WeakMap,$t=new WeakMap,Ut=new WeakMap,xe=new WeakMap,dt=new WeakMap,Ee=new WeakMap,pt=new WeakMap,_t=new WeakMap,ct=new WeakMap,mt=new WeakMap,je=new WeakMap,te=new WeakMap,st=new WeakMap,M=new WeakMap,Ae=new WeakMap,Pe=new WeakMap,ft=new WeakMap,Ht=new WeakMap,ee=new WeakMap,Yt=new WeakMap,vt=new WeakMap,Se=new WeakMap,N=new WeakMap,Bt=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,D=new WeakMap,Ie=new WeakMap,Ct=new WeakMap,X=new WeakMap,Zn)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch{}return t}[Xn](){return{log:(...t)=>{this[Me]()||console.log(...t),A(this,ct,!0,"f"),o(this,st,"f").length&&A(this,st,o(this,st,"f")+`
|
|
64
64
|
`,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")},error:(...t)=>{this[Me]()||console.error(...t),A(this,ct,!0,"f"),o(this,st,"f").length&&A(this,st,o(this,st,"f")+`
|
|
65
|
-
`,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")}}}[Ze](t){Xt(o(this,M,"f")).forEach(e=>{if((i=>i==="configObjects")(e))return;let n=o(this,M,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):typeof n=="object"&&delete n[t]}),delete o(this,D,"f").getDescriptions()[t]}[kn](t,e,n){o(this,xe,"f")[n]||(o(this,N,"f").process.emitWarning(t,e),o(this,xe,"f")[n]=!0)}[ti](){o(this,Ee,"f").push({options:o(this,M,"f"),configObjects:o(this,M,"f").configObjects.slice(0),exitProcess:o(this,dt,"f"),groups:o(this,_t,"f"),strict:o(this,Bt,"f"),strictCommands:o(this,Gt,"f"),strictOptions:o(this,Vt,"f"),completionCommand:o(this,lt,"f"),output:o(this,st,"f"),exitError:o(this,$t,"f"),hasOutput:o(this,ct,"f"),parsed:this.parsed,parseFn:o(this,ft,"f"),parseContext:o(this,Ht,"f")}),o(this,D,"f").freeze(),o(this,X,"f").freeze(),o(this,tt,"f").freeze(),o(this,pt,"f").freeze()}[ei](){let t="",e;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,N,"f").process.argv()[0])?e=o(this,N,"f").process.argv().slice(1,2):e=o(this,N,"f").process.argv().slice(0,1),t=e.map(n=>{let i=this[pi](o(this,Tt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),o(this,N,"f").getEnv("_")&&o(this,N,"f").getProcessArgvBin()===o(this,N,"f").getEnv("_")&&(t=o(this,N,"f").getEnv("_").replace(`${o(this,N,"f").path.dirname(o(this,N,"f").process.execPath())}/`,"")),t}[qt](){return o(this,Pe,"f")}[ni](){return o(this,Ie,"f")}[Xe](){if(!o(this,Ut,"f"))return;let t=o(this,N,"f").getEnv("LC_ALL")||o(this,N,"f").getEnv("LC_MESSAGES")||o(this,N,"f").getEnv("LANG")||o(this,N,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[ii](){return this[ke]().version||"unknown"}[si](t){let e=t["--"]?t["--"]:t._;for(let n=0,i;(i=e[n])!==void 0;n++)o(this,N,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`)))&&(e[n]=Number(i));return t}[ke](t){let e=t||"*";if(o(this,ee,"f")[e])return o(this,ee,"f")[e];let n={};try{let i=t||o(this,N,"f").mainFilename;!t&&o(this,N,"f").path.extname(i)&&(i=o(this,N,"f").path.dirname(i));let r=o(this,N,"f").findUp(i,(a,c)=>{if(c.includes("package.json"))return"package.json"});ot(r,void 0,o(this,N,"f")),n=JSON.parse(o(this,N,"f").readFileSync(r,"utf8"))}catch{}return o(this,ee,"f")[e]=n||{},o(this,ee,"f")[e]}[Ft](t,e){e=[].concat(e),e.forEach(n=>{n=this[nn](n),o(this,M,"f")[t].push(n)})}[ne](t,e,n,i){this[en](t,e,n,i,(r,a,c)=>{o(this,M,"f")[r][a]=c})}[tn](t,e,n,i){this[en](t,e,n,i,(r,a,c)=>{o(this,M,"f")[r][a]=(o(this,M,"f")[r][a]||[]).concat(c)})}[en](t,e,n,i,r){if(Array.isArray(n))n.forEach(a=>{t(a,i)});else if((a=>typeof a=="object")(n))for(let a of Xt(n))t(a,n[a]);else r(e,this[nn](n),i)}[nn](t){return t==="__proto__"?"___proto___":t}[sn](t,e){return this[ne](this[sn].bind(this),"key",t,e),this}[rn](){var t,e,n,i,r,a,c,m,w,p,u,g;let y=o(this,Ee,"f").pop();ot(y,void 0,o(this,N,"f"));let E;t=this,e=this,n=this,i=this,r=this,a=this,c=this,m=this,w=this,p=this,u=this,g=this,{options:{set value(_){A(t,M,_,"f")}}.value,configObjects:E,exitProcess:{set value(_){A(e,dt,_,"f")}}.value,groups:{set value(_){A(n,_t,_,"f")}}.value,output:{set value(_){A(i,st,_,"f")}}.value,exitError:{set value(_){A(r,$t,_,"f")}}.value,hasOutput:{set value(_){A(a,ct,_,"f")}}.value,parsed:this.parsed,strict:{set value(_){A(c,Bt,_,"f")}}.value,strictCommands:{set value(_){A(m,Gt,_,"f")}}.value,strictOptions:{set value(_){A(w,Vt,_,"f")}}.value,completionCommand:{set value(_){A(p,lt,_,"f")}}.value,parseFn:{set value(_){A(u,ft,_,"f")}}.value,parseContext:{set value(_){A(g,Ht,_,"f")}}.value}=y,o(this,M,"f").configObjects=E,o(this,D,"f").unfreeze(),o(this,X,"f").unfreeze(),o(this,tt,"f").unfreeze(),o(this,pt,"f").unfreeze()}[ri](t,e){return Rt(e,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[oi].bind(this),getContext:this[ai].bind(this),getHasOutput:this[li].bind(this),getLoggerInstance:this[ci].bind(this),getParseContext:this[fi].bind(this),getParserConfiguration:this[qt].bind(this),getUsageConfiguration:this[ni].bind(this),getUsageInstance:this[hi].bind(this),getValidationInstance:this[ui].bind(this),hasParseCallback:this[Me].bind(this),isGlobalContext:this[di].bind(this),postProcess:this[Kt].bind(this),reset:this[on].bind(this),runValidation:this[an].bind(this),runYargsParserAndExecuteCommands:this[fe].bind(this),setHasOutput:this[mi].bind(this)}}[oi](){return o(this,tt,"f")}[ai](){return o(this,ce,"f")}[li](){return o(this,ct,"f")}[ci](){return o(this,te,"f")}[fi](){return o(this,Ht,"f")||{}}[hi](){return o(this,D,"f")}[ui](){return o(this,X,"f")}[Me](){return!!o(this,ft,"f")}[di](){return o(this,je,"f")}[Kt](t,e,n,i){return n||q(t)||(e||(t=this[Zn](t)),(this[qt]()["parse-positional-numbers"]||this[qt]()["parse-positional-numbers"]===void 0)&&(t=this[si](t)),i&&(t=zt(t,this,o(this,pt,"f").getMiddleware(),!1))),t}[on](t={}){A(this,M,o(this,M,"f")||{},"f");let e={};e.local=o(this,M,"f").local||[],e.configObjects=o(this,M,"f").configObjects||[];let n={};e.local.forEach(a=>{n[a]=!0,(t[a]||[]).forEach(c=>{n[c]=!0})}),Object.assign(o(this,Yt,"f"),Object.keys(o(this,_t,"f")).reduce((a,c)=>{let m=o(this,_t,"f")[c].filter(w=>!(w in n));return m.length>0&&(a[c]=m),a},{})),A(this,_t,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return i.forEach(a=>{e[a]=(o(this,M,"f")[a]||[]).filter(c=>!n[c])}),r.forEach(a=>{e[a]=It(o(this,M,"f")[a],c=>!n[c])}),e.envPrefix=o(this,M,"f").envPrefix,A(this,M,e,"f"),A(this,D,o(this,D,"f")?o(this,D,"f").reset(n):Yn(this,o(this,N,"f")),"f"),A(this,X,o(this,X,"f")?o(this,X,"f").reset(n):Qn(this,o(this,D,"f"),o(this,N,"f")),"f"),A(this,tt,o(this,tt,"f")?o(this,tt,"f").reset():Tn(o(this,D,"f"),o(this,X,"f"),o(this,pt,"f"),o(this,N,"f")),"f"),o(this,ut,"f")||A(this,ut,Vn(this,o(this,D,"f"),o(this,tt,"f"),o(this,N,"f")),"f"),o(this,pt,"f").reset(),A(this,lt,null,"f"),A(this,st,"","f"),A(this,$t,null,"f"),A(this,ct,!1,"f"),this.parsed=!1,this}[pi](t,e){return o(this,N,"f").path.relative(t,e)}[fe](t,e,n,i=0,r=!1){let a=!!n||r;t=t||o(this,vt,"f"),o(this,M,"f").__=o(this,N,"f").y18n.__,o(this,M,"f").configuration=this[qt]();let c=!!o(this,M,"f").configuration["populate--"],m=Object.assign({},o(this,M,"f").configuration,{"populate--":!0}),w=o(this,N,"f").Parser.detailed(t,Object.assign({},o(this,M,"f"),{configuration:{"parse-positional-numbers":!1,...m}})),p=Object.assign(w.argv,o(this,Ht,"f")),u,g=w.aliases,y=!1,E=!1;Object.keys(p).forEach(_=>{_===o(this,mt,"f")&&p[_]?y=!0:_===o(this,Ct,"f")&&p[_]&&(E=!0)}),p.$0=this.$0,this.parsed=w,i===0&&o(this,D,"f").clearCachedHelpMessage();try{if(this[Xe](),e)return this[Kt](p,c,!!n,!1);o(this,mt,"f")&&[o(this,mt,"f")].concat(g[o(this,mt,"f")]||[]).filter(Y=>Y.length>1).includes(""+p._[p._.length-1])&&(p._.pop(),y=!0),A(this,je,!1,"f");let _=o(this,tt,"f").getCommands(),d=o(this,ut,"f").completionKey in p,W=y||d||r;if(p._.length){if(_.length){let z;for(let Y=i||0,T;p._[Y]!==void 0;Y++)if(T=String(p._[Y]),_.includes(T)&&T!==o(this,lt,"f")){let B=o(this,tt,"f").runCommand(T,this,w,Y+1,r,y||E||r);return this[Kt](B,c,!!n,!1)}else if(!z&&T!==o(this,lt,"f")){z=T;break}!o(this,tt,"f").hasDefaultCommand()&&o(this,Se,"f")&&z&&!W&&o(this,X,"f").recommendCommands(z,_)}o(this,lt,"f")&&p._.includes(o(this,lt,"f"))&&!d&&(o(this,dt,"f")&&Mt(!0),this.showCompletionScript(),this.exit(0))}if(o(this,tt,"f").hasDefaultCommand()&&!W){let z=o(this,tt,"f").runCommand(null,this,w,0,r,y||E||r);return this[Kt](z,c,!!n,!1)}if(d){o(this,dt,"f")&&Mt(!0),t=[].concat(t);let z=t.slice(t.indexOf(`--${o(this,ut,"f").completionKey}`)+1);return o(this,ut,"f").getCompletion(z,(Y,T)=>{if(Y)throw new V(Y.message);(T||[]).forEach(B=>{o(this,te,"f").log(B)}),this.exit(0)}),this[Kt](p,!c,!!n,!1)}if(o(this,ct,"f")||(y?(o(this,dt,"f")&&Mt(!0),a=!0,this.showHelp("log"),this.exit(0)):E&&(o(this,dt,"f")&&Mt(!0),a=!0,o(this,D,"f").showVersion("log"),this.exit(0))),!a&&o(this,M,"f").skipValidation.length>0&&(a=Object.keys(p).some(z=>o(this,M,"f").skipValidation.indexOf(z)>=0&&p[z]===!0)),!a){if(w.error)throw new V(w.error.message);if(!d){let z=this[an](g,{},w.error);n||(u=zt(p,this,o(this,pt,"f").getMiddleware(),!0)),u=this[ri](z,u??p),q(u)&&!n&&(u=u.then(()=>zt(p,this,o(this,pt,"f").getMiddleware(),!1)))}}}catch(_){if(_ instanceof V)o(this,D,"f").fail(_.message,_);else throw _}return this[Kt](u??p,c,!!n,!0)}[an](t,e,n,i){let r={...this.getDemandedOptions()};return a=>{if(n)throw new V(n.message);o(this,X,"f").nonOptionCount(a),o(this,X,"f").requiredArguments(a,r);let c=!1;o(this,Gt,"f")&&(c=o(this,X,"f").unknownCommands(a)),o(this,Bt,"f")&&!c?o(this,X,"f").unknownArguments(a,t,e,!!i):o(this,Vt,"f")&&o(this,X,"f").unknownArguments(a,t,{},!1,!1),o(this,X,"f").limitedChoices(a),o(this,X,"f").implications(a),o(this,X,"f").conflicting(a)}}[mi](){A(this,ct,!0,"f")}[Qt](t){if(typeof t=="string")o(this,M,"f").key[t]=!0;else for(let e of t)o(this,M,"f").key[e]=!0}};function Un(s){return!!s&&typeof s.getInternalMethods=="function"}var js=gi(Be),bi=js;await bi(He(process.argv)).command("$0 <file>",'Convert a tldraw ".tldr" file to an svg or png image',s=>s.positional("
|
|
65
|
+
`,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")}}}[Ze](t){Xt(o(this,M,"f")).forEach(e=>{if((i=>i==="configObjects")(e))return;let n=o(this,M,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):typeof n=="object"&&delete n[t]}),delete o(this,D,"f").getDescriptions()[t]}[kn](t,e,n){o(this,xe,"f")[n]||(o(this,N,"f").process.emitWarning(t,e),o(this,xe,"f")[n]=!0)}[ti](){o(this,Ee,"f").push({options:o(this,M,"f"),configObjects:o(this,M,"f").configObjects.slice(0),exitProcess:o(this,dt,"f"),groups:o(this,_t,"f"),strict:o(this,Bt,"f"),strictCommands:o(this,Gt,"f"),strictOptions:o(this,Vt,"f"),completionCommand:o(this,lt,"f"),output:o(this,st,"f"),exitError:o(this,$t,"f"),hasOutput:o(this,ct,"f"),parsed:this.parsed,parseFn:o(this,ft,"f"),parseContext:o(this,Ht,"f")}),o(this,D,"f").freeze(),o(this,X,"f").freeze(),o(this,tt,"f").freeze(),o(this,pt,"f").freeze()}[ei](){let t="",e;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,N,"f").process.argv()[0])?e=o(this,N,"f").process.argv().slice(1,2):e=o(this,N,"f").process.argv().slice(0,1),t=e.map(n=>{let i=this[pi](o(this,Tt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),o(this,N,"f").getEnv("_")&&o(this,N,"f").getProcessArgvBin()===o(this,N,"f").getEnv("_")&&(t=o(this,N,"f").getEnv("_").replace(`${o(this,N,"f").path.dirname(o(this,N,"f").process.execPath())}/`,"")),t}[qt](){return o(this,Pe,"f")}[ni](){return o(this,Ie,"f")}[Xe](){if(!o(this,Ut,"f"))return;let t=o(this,N,"f").getEnv("LC_ALL")||o(this,N,"f").getEnv("LC_MESSAGES")||o(this,N,"f").getEnv("LANG")||o(this,N,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[ii](){return this[ke]().version||"unknown"}[si](t){let e=t["--"]?t["--"]:t._;for(let n=0,i;(i=e[n])!==void 0;n++)o(this,N,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`)))&&(e[n]=Number(i));return t}[ke](t){let e=t||"*";if(o(this,ee,"f")[e])return o(this,ee,"f")[e];let n={};try{let i=t||o(this,N,"f").mainFilename;!t&&o(this,N,"f").path.extname(i)&&(i=o(this,N,"f").path.dirname(i));let r=o(this,N,"f").findUp(i,(a,c)=>{if(c.includes("package.json"))return"package.json"});ot(r,void 0,o(this,N,"f")),n=JSON.parse(o(this,N,"f").readFileSync(r,"utf8"))}catch{}return o(this,ee,"f")[e]=n||{},o(this,ee,"f")[e]}[Ft](t,e){e=[].concat(e),e.forEach(n=>{n=this[nn](n),o(this,M,"f")[t].push(n)})}[ne](t,e,n,i){this[en](t,e,n,i,(r,a,c)=>{o(this,M,"f")[r][a]=c})}[tn](t,e,n,i){this[en](t,e,n,i,(r,a,c)=>{o(this,M,"f")[r][a]=(o(this,M,"f")[r][a]||[]).concat(c)})}[en](t,e,n,i,r){if(Array.isArray(n))n.forEach(a=>{t(a,i)});else if((a=>typeof a=="object")(n))for(let a of Xt(n))t(a,n[a]);else r(e,this[nn](n),i)}[nn](t){return t==="__proto__"?"___proto___":t}[sn](t,e){return this[ne](this[sn].bind(this),"key",t,e),this}[rn](){var t,e,n,i,r,a,c,m,w,p,u,g;let y=o(this,Ee,"f").pop();ot(y,void 0,o(this,N,"f"));let E;t=this,e=this,n=this,i=this,r=this,a=this,c=this,m=this,w=this,p=this,u=this,g=this,{options:{set value(_){A(t,M,_,"f")}}.value,configObjects:E,exitProcess:{set value(_){A(e,dt,_,"f")}}.value,groups:{set value(_){A(n,_t,_,"f")}}.value,output:{set value(_){A(i,st,_,"f")}}.value,exitError:{set value(_){A(r,$t,_,"f")}}.value,hasOutput:{set value(_){A(a,ct,_,"f")}}.value,parsed:this.parsed,strict:{set value(_){A(c,Bt,_,"f")}}.value,strictCommands:{set value(_){A(m,Gt,_,"f")}}.value,strictOptions:{set value(_){A(w,Vt,_,"f")}}.value,completionCommand:{set value(_){A(p,lt,_,"f")}}.value,parseFn:{set value(_){A(u,ft,_,"f")}}.value,parseContext:{set value(_){A(g,Ht,_,"f")}}.value}=y,o(this,M,"f").configObjects=E,o(this,D,"f").unfreeze(),o(this,X,"f").unfreeze(),o(this,tt,"f").unfreeze(),o(this,pt,"f").unfreeze()}[ri](t,e){return Rt(e,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[oi].bind(this),getContext:this[ai].bind(this),getHasOutput:this[li].bind(this),getLoggerInstance:this[ci].bind(this),getParseContext:this[fi].bind(this),getParserConfiguration:this[qt].bind(this),getUsageConfiguration:this[ni].bind(this),getUsageInstance:this[hi].bind(this),getValidationInstance:this[ui].bind(this),hasParseCallback:this[Me].bind(this),isGlobalContext:this[di].bind(this),postProcess:this[Kt].bind(this),reset:this[on].bind(this),runValidation:this[an].bind(this),runYargsParserAndExecuteCommands:this[fe].bind(this),setHasOutput:this[mi].bind(this)}}[oi](){return o(this,tt,"f")}[ai](){return o(this,ce,"f")}[li](){return o(this,ct,"f")}[ci](){return o(this,te,"f")}[fi](){return o(this,Ht,"f")||{}}[hi](){return o(this,D,"f")}[ui](){return o(this,X,"f")}[Me](){return!!o(this,ft,"f")}[di](){return o(this,je,"f")}[Kt](t,e,n,i){return n||q(t)||(e||(t=this[Zn](t)),(this[qt]()["parse-positional-numbers"]||this[qt]()["parse-positional-numbers"]===void 0)&&(t=this[si](t)),i&&(t=zt(t,this,o(this,pt,"f").getMiddleware(),!1))),t}[on](t={}){A(this,M,o(this,M,"f")||{},"f");let e={};e.local=o(this,M,"f").local||[],e.configObjects=o(this,M,"f").configObjects||[];let n={};e.local.forEach(a=>{n[a]=!0,(t[a]||[]).forEach(c=>{n[c]=!0})}),Object.assign(o(this,Yt,"f"),Object.keys(o(this,_t,"f")).reduce((a,c)=>{let m=o(this,_t,"f")[c].filter(w=>!(w in n));return m.length>0&&(a[c]=m),a},{})),A(this,_t,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return i.forEach(a=>{e[a]=(o(this,M,"f")[a]||[]).filter(c=>!n[c])}),r.forEach(a=>{e[a]=It(o(this,M,"f")[a],c=>!n[c])}),e.envPrefix=o(this,M,"f").envPrefix,A(this,M,e,"f"),A(this,D,o(this,D,"f")?o(this,D,"f").reset(n):Yn(this,o(this,N,"f")),"f"),A(this,X,o(this,X,"f")?o(this,X,"f").reset(n):Qn(this,o(this,D,"f"),o(this,N,"f")),"f"),A(this,tt,o(this,tt,"f")?o(this,tt,"f").reset():Tn(o(this,D,"f"),o(this,X,"f"),o(this,pt,"f"),o(this,N,"f")),"f"),o(this,ut,"f")||A(this,ut,Vn(this,o(this,D,"f"),o(this,tt,"f"),o(this,N,"f")),"f"),o(this,pt,"f").reset(),A(this,lt,null,"f"),A(this,st,"","f"),A(this,$t,null,"f"),A(this,ct,!1,"f"),this.parsed=!1,this}[pi](t,e){return o(this,N,"f").path.relative(t,e)}[fe](t,e,n,i=0,r=!1){let a=!!n||r;t=t||o(this,vt,"f"),o(this,M,"f").__=o(this,N,"f").y18n.__,o(this,M,"f").configuration=this[qt]();let c=!!o(this,M,"f").configuration["populate--"],m=Object.assign({},o(this,M,"f").configuration,{"populate--":!0}),w=o(this,N,"f").Parser.detailed(t,Object.assign({},o(this,M,"f"),{configuration:{"parse-positional-numbers":!1,...m}})),p=Object.assign(w.argv,o(this,Ht,"f")),u,g=w.aliases,y=!1,E=!1;Object.keys(p).forEach(_=>{_===o(this,mt,"f")&&p[_]?y=!0:_===o(this,Ct,"f")&&p[_]&&(E=!0)}),p.$0=this.$0,this.parsed=w,i===0&&o(this,D,"f").clearCachedHelpMessage();try{if(this[Xe](),e)return this[Kt](p,c,!!n,!1);o(this,mt,"f")&&[o(this,mt,"f")].concat(g[o(this,mt,"f")]||[]).filter(Y=>Y.length>1).includes(""+p._[p._.length-1])&&(p._.pop(),y=!0),A(this,je,!1,"f");let _=o(this,tt,"f").getCommands(),d=o(this,ut,"f").completionKey in p,W=y||d||r;if(p._.length){if(_.length){let z;for(let Y=i||0,T;p._[Y]!==void 0;Y++)if(T=String(p._[Y]),_.includes(T)&&T!==o(this,lt,"f")){let B=o(this,tt,"f").runCommand(T,this,w,Y+1,r,y||E||r);return this[Kt](B,c,!!n,!1)}else if(!z&&T!==o(this,lt,"f")){z=T;break}!o(this,tt,"f").hasDefaultCommand()&&o(this,Se,"f")&&z&&!W&&o(this,X,"f").recommendCommands(z,_)}o(this,lt,"f")&&p._.includes(o(this,lt,"f"))&&!d&&(o(this,dt,"f")&&Mt(!0),this.showCompletionScript(),this.exit(0))}if(o(this,tt,"f").hasDefaultCommand()&&!W){let z=o(this,tt,"f").runCommand(null,this,w,0,r,y||E||r);return this[Kt](z,c,!!n,!1)}if(d){o(this,dt,"f")&&Mt(!0),t=[].concat(t);let z=t.slice(t.indexOf(`--${o(this,ut,"f").completionKey}`)+1);return o(this,ut,"f").getCompletion(z,(Y,T)=>{if(Y)throw new V(Y.message);(T||[]).forEach(B=>{o(this,te,"f").log(B)}),this.exit(0)}),this[Kt](p,!c,!!n,!1)}if(o(this,ct,"f")||(y?(o(this,dt,"f")&&Mt(!0),a=!0,this.showHelp("log"),this.exit(0)):E&&(o(this,dt,"f")&&Mt(!0),a=!0,o(this,D,"f").showVersion("log"),this.exit(0))),!a&&o(this,M,"f").skipValidation.length>0&&(a=Object.keys(p).some(z=>o(this,M,"f").skipValidation.indexOf(z)>=0&&p[z]===!0)),!a){if(w.error)throw new V(w.error.message);if(!d){let z=this[an](g,{},w.error);n||(u=zt(p,this,o(this,pt,"f").getMiddleware(),!0)),u=this[ri](z,u??p),q(u)&&!n&&(u=u.then(()=>zt(p,this,o(this,pt,"f").getMiddleware(),!1)))}}}catch(_){if(_ instanceof V)o(this,D,"f").fail(_.message,_);else throw _}return this[Kt](u??p,c,!!n,!0)}[an](t,e,n,i){let r={...this.getDemandedOptions()};return a=>{if(n)throw new V(n.message);o(this,X,"f").nonOptionCount(a),o(this,X,"f").requiredArguments(a,r);let c=!1;o(this,Gt,"f")&&(c=o(this,X,"f").unknownCommands(a)),o(this,Bt,"f")&&!c?o(this,X,"f").unknownArguments(a,t,e,!!i):o(this,Vt,"f")&&o(this,X,"f").unknownArguments(a,t,{},!1,!1),o(this,X,"f").limitedChoices(a),o(this,X,"f").implications(a),o(this,X,"f").conflicting(a)}}[mi](){A(this,ct,!0,"f")}[Qt](t){if(typeof t=="string")o(this,M,"f").key[t]=!0;else for(let e of t)o(this,M,"f").key[e]=!0}};function Un(s){return!!s&&typeof s.getInternalMethods=="function"}var js=gi(Be),bi=js;await bi(He(process.argv)).command("$0 <file-or-url>",'Convert a tldraw ".tldr" file or tldraw.com URL to an svg or png image',s=>s.positional("file-or-url",{demandOption:!0,describe:'The sketch to convert to an image \u2014 either a path to a local ".tldr" file, or a tldraw.com sketch URL',type:"string"}).option("format",{alias:"f",choices:["png","svg"],default:"svg",describe:"Output image format",type:"string"}).option("output",{alias:"o",default:"./",describe:"Output image directory",type:"string"}).option("verbose",{default:!1,describe:"Enable verbose output",type:"boolean"}),async s=>{let{fileOrUrl:t,format:e,output:n,verbose:i}=s;try{await mn(t,e,n,i),process.exit(0)}catch(r){console.error("Error during conversion:",r),process.exit(1)}}).alias("h","help").version("version",cn).alias("v","version").help().parse();
|
|
66
66
|
/*! Bundled license information:
|
|
67
67
|
|
|
68
68
|
yargs-parser/build/lib/string-utils.js:
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -35,12 +35,12 @@ npm --install --global @kitschpatrol/tldraw-cli
|
|
|
35
35
|
### Invocation
|
|
36
36
|
|
|
37
37
|
```sh
|
|
38
|
-
tldraw-cli
|
|
38
|
+
tldraw-cli file-or-url {options}
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
| Argument
|
|
42
|
-
|
|
|
43
|
-
| `
|
|
41
|
+
| Argument | Description |
|
|
42
|
+
| ------------- | ------------------------------------------------------------------------------------------------------ |
|
|
43
|
+
| `file-or-url` | The sketch to convert to an image — either a path to a local ".tldr" file, or a tldraw\.com sketch URL |
|
|
44
44
|
|
|
45
45
|
| Option | Description | Default |
|
|
46
46
|
| ----------------- | ------------------------------------------- | ------- |
|