From 96b627095ce079d0e4255182ecdd2de4af75f429 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Wed, 19 Jun 2024 03:52:57 +0200 Subject: [PATCH] https://github.com/adbayb/termost/pull/31 --- package.json | 5 +- patches/termost+0.12.0.patch | 136 ---------------- yarn.lock | 303 +++++++++-------------------------- 3 files changed, 82 insertions(+), 362 deletions(-) delete mode 100644 patches/termost+0.12.0.patch diff --git a/package.json b/package.json index f9bd101e..d87eefd2 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "url": "git://github.com/keycloakify/keycloakify.git" }, "scripts": { - "prepare": "patch-package && tsx scripts/generate-i18n-messages.ts", + "prepare": "tsx scripts/generate-i18n-messages.ts", "build": "tsx scripts/build.ts", "storybook": "tsx scripts/start-storybook.ts", "link-in-starter": "tsx scripts/link-in-starter.ts", @@ -102,7 +102,6 @@ "lint-staged": "^11.0.0", "magic-string": "^0.30.7", "make-fetch-happen": "^11.0.3", - "patch-package": "^8.0.0", "powerhooks": "^1.0.10", "prettier": "^3.2.5", "properties-parser": "^0.3.1", @@ -111,7 +110,7 @@ "recast": "^0.23.3", "run-exclusive": "^2.2.19", "storybook-dark-mode": "^1.1.2", - "termost": "^0.12.0", + "termost": "^v0.12.1", "tsc-alias": "^1.8.10", "tss-react": "^4.9.10", "typescript": "^4.9.1-beta", diff --git a/patches/termost+0.12.0.patch b/patches/termost+0.12.0.patch deleted file mode 100644 index 6bd647ce..00000000 --- a/patches/termost+0.12.0.patch +++ /dev/null @@ -1,136 +0,0 @@ -diff --git a/node_modules/termost/.DS_Store b/node_modules/termost/.DS_Store -new file mode 100644 -index 0000000..5008ddf -Binary files /dev/null and b/node_modules/termost/.DS_Store differ -diff --git a/node_modules/termost/dist/index.cjs b/node_modules/termost/dist/index.cjs -index b9f3a12..fb19857 100644 ---- a/node_modules/termost/dist/index.cjs -+++ b/node_modules/termost/dist/index.cjs -@@ -1,5 +1,5 @@ --"use strict";var U=Object.create;var C=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var Y=(e,t)=>{for(var o in t)C(e,o,{get:t[o],enumerable:!0})},L=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of B(t))!z.call(e,n)&&n!==o&&C(e,n,{get:()=>t[n],enumerable:!(s=X(t,n))||s.enumerable});return e};var h=(e,t,o)=>(o=e!=null?U(W(e)):{},L(t||!e||!e.__esModule?C(o,"default",{value:e,enumerable:!0}):o,e)),Z=e=>L(C({},"__esModule",{value:!0}),e);var pe={};Y(pe,{helpers:()=>ue,termost:()=>Q});module.exports=Z(pe);var I=require("child_process"),v=async(e,t={hasLiveOutput:!1})=>new Promise((o,s)=>{let n="",l="",[r,...a]=e.split(" "),i=(0,I.spawn)(r,a,{cwd:t.cwd,shell:!0,stdio:t.hasLiveOutput?"inherit":"pipe",env:{...process.env,FORCE_COLOR:"1"}});i.stdout?.on("data",c=>{n+=c}),i.stderr?.on("data",c=>{l+=c}),i.on("close",c=>{if(c!==0){let u=`${l}${n}`;s(u.trim())}else o(n.trim())})});var O=h(require("picocolors")),y=(e,{color:t,modifiers:o}={color:"white",modifiers:[]})=>{let s=[];return s.push(O.default[oe[t??"white"]]),(o??[]).forEach(n=>{n==="uppercase"?e=e.toUpperCase():n==="lowercase"?e=e.toLowerCase():s.push(O.default[ne[n]])}),ee(...s)(e)},ee=(...e)=>e.reduce((t,o)=>s=>t(o(s)),e[0]),M=(e,{label:t,type:o="information"}={})=>{let{color:s,defaultLabel:n,icon:l,method:r}=te[o],a=typeof e=="string"?[e]:e;r(y(` --${l} ${t??n}`,{color:s,modifiers:["bold"]}));for(let i of a)r(y(` ${i}`,{color:s}))},te={error:{color:"red",defaultLabel:"Error",icon:"\u274C",method:console.error},information:{color:"blue",defaultLabel:"Information",icon:"\u2139\uFE0F ",method:console.info},success:{color:"green",defaultLabel:"Success",icon:"\u2705",method:console.log},warning:{color:"yellow",defaultLabel:"Warning",icon:"\u26A0\uFE0F ",method:console.warn}},oe={black:"black",blue:"blue",cyan:"cyan",green:"green",grey:"gray",magenta:"magenta",red:"red",white:"white",yellow:"yellow"},ne={bold:"bold",italic:"italic",strikethrough:"strikethrough",underline:"underline"};var P=h(require("fs")),b=h(require("path")),K=e=>{let t=b.default.resolve(e,"package.json");return re(t)?require(t):K(b.default.resolve(e,".."))},re=e=>{try{return P.default.accessSync(e,P.default.constants.F_OK),!0}catch{return!1}},j=()=>{let e=require.main?.filename;if(!e)throw new Error("Termost was unable to retrieve automatically the package name and version. To fix it, use `termost({ name, description, version })` to define them manually.");return K(b.default.dirname(e))};var T=()=>{let e=process.argv.slice(2),t,o=[],s={},n,l=(a,i)=>{i?s[a]=typeof i=="string"?w(i):!0:n=a},r=()=>{n&&(s[n]=!0,n=void 0)};for(let a of e){let i=se.exec(a)?.groups,c=ae.exec(a)?.groups;if(i?.name){r();let u=i.name.split(""),p=u.length-1;u.forEach((f,m)=>{l(f,p===m?void 0:!0)})}else c?.name?(r(),l(c.name,c.value)):n?(s[n]=w(a),n=void 0):t?o.push(a):t=a}return r(),{command:t,operands:o,options:s}},se=/^-(?(?!-).*)$/,ae=/^--(?.*?)(?:=(?.+))?$/,w=e=>{try{return JSON.parse(e)}catch{return e}};var E=()=>{let e=[];return{enqueue(t){e.push(t)},dequeue(){return e.shift()},isEmpty(){return e.length===0}}};var g=e=>{let t=$[e];if(!t)throw new Error(`No controller has been set for the \`${e}\` command. --Have you run the \`termost\` constructor?`);return t},N=(e,t)=>{let o=E(),s={},n={description:t,options:{"-h, --help":"Display the help center","-v, --version":"Print the version"}},l={addOptionDescription(r,a){n.options[r]=a},addValue(r,a){s[r]=a},addInstruction(r){o.enqueue(r)},async enable(){for(;!o.isEmpty();){let r=o.dequeue();r&&await r()}},getContext(r){return e!==r&&(s={...g(r).getContext(r),...s}),s},getMetadata(r){if(e!==r){let a=g(r).getMetadata(r);n.options={...a.options,...n.options}}return n}};return S[e]=t,$[e]=l,l},R=()=>S,$={},S={};var F=({name:e,description:t},{argv:o,name:s,version:n})=>{let l=e===s,r=o.command===e,a=N(e,t),i=g(s);return setTimeout(()=>{if(l&&!r&&i.enable(),r){let c=Object.keys(o.options);if(c.includes(_[0])||c.includes(_[1])){ie({controller:a,currentCommandName:e,isRootCommand:l,rootCommandName:s});return}if(c.includes(A[0])||c.includes(A[1])){console.info(n);return}a.enable()}},0),e},_=["help","h"],A=["version","v"],ie=({rootCommandName:e,currentCommandName:t,isRootCommand:o,controller:s})=>{let n=s.getMetadata(e),{options:l,description:r}=n,a=R(),i=Object.keys(n.options),c=Object.keys(a),u=i.length>0,p=o&&c.length>1;k("Usage"),x(`${y(`${e}${o?"":` ${String(t)}`}`,{color:"green"})} ${p?" ":""}${u?"[...options]":""}`),r&&(k("Description"),x(r));let f=[...c,...i].reduce((m,d)=>Math.max(m,d.length),0);if(p){k("Commands");for(let m of c){if(m===e)continue;let d=a[m];d&&D(m,d,f)}}if(u){k("Options");for(let m of i)D(m,l[m],f)}},x=(...e)=>{console.log(y(...e))},k=e=>{x(` --${e}:`,{color:"yellow",modifiers:["bold","underline","uppercase"]})},D=(e,t,o)=>{x(` ${y(e.padEnd(o+1," "),{color:"green"})} ${t}`)};var G=require("enquirer"),q=e=>{let{key:t,defaultValue:o,label:s,type:n}=e;return async function(r,a){let i={initial:o,message:typeof s=="function"?s(r,a):s,name:t,type:n};if(e.type==="select"||e.type==="multiselect"){let u=e.type==="multiselect",f=e.options.map(m=>({title:m,value:m,...u&&{selected:(o||[]).includes(m)}}));i.choices=f}let c=await(0,G.prompt)(i);return{key:t,value:c[t]}}};var H=(e,{argv:t})=>o=>{let{key:s,name:n,description:l,defaultValue:r}=o,a=typeof n=="string"?[n]:[n.short,n.long],i=a.map((c,u)=>"-".repeat(a.length>1?u+1:2)+c).join(", ");return e.addOptionDescription(i,l),async function(){let u;for(let p of a)if(p in t.options){u=t.options[p];break}return Promise.resolve({key:s,value:u??r})}};var V=require("listr2"),J=e=>{let{key:t,label:o,handler:s}=e,n=o?new V.Listr([],{rendererOptions:{collapseErrors:!1,formatOutput:"wrap",showErrorMessage:!0,timer:V.PRESET_TIMER}}):null;return async function(r,a){let i;return n?(n.add({...o&&{title:typeof o=="function"?o(r,a):o},task:async()=>i=await s(r,a)}),await n.run()):i=await s(r,a),{key:t,value:i}}};function Q(e,t={}){let o=me(e)?e:{description:e},s=j(),n=o.name??s.name,{command:l=n,options:r,operands:a}=T();return le(t),ce({argv:{command:l,options:r,operands:a},description:o.description??s.description,name:n,version:o.version??s.version})}var ce=e=>{let{argv:t,name:o,description:s}=e,n=o,l=n,r=(i,c)=>{let u=i(c),p=g(l);p.addInstruction(async()=>{let{skip:f}=c,m=p.getContext(n);if(f?.(m,t))return;let d=await u(m,t);!d||!d.key||p.addValue(d.key,d.value)})},a={command(i){return l=F(i,e),this},input(i){return r(q,i),this},option(i){return r(H(g(l),e),i),this},task(i){return r(J,i),this}};return a.command({name:o,description:s}),a},le=({onShutdown:e=()=>{},onException:t=()=>{}})=>{process.on("SIGTERM",()=>{e(),process.exit(0)}),process.on("SIGINT",()=>{e(),process.exit(0)}),process.on("uncaughtException",o=>{t(o),process.exit(1)}),process.on("unhandledRejection",o=>{o instanceof Error&&t(o),process.exit(1)})},me=e=>e!==null&&typeof e=="object";var ue={exec:v,format:y,message:M};0&&(module.exports={helpers,termost}); -+"use strict";var U=Object.create;var C=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var Y=(e,t)=>{for(var n in t)C(e,n,{get:t[n],enumerable:!0})},L=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of B(t))!z.call(e,o)&&o!==n&&C(e,o,{get:()=>t[o],enumerable:!(r=X(t,o))||r.enumerable});return e};var h=(e,t,n)=>(n=e!=null?U(W(e)):{},L(t||!e||!e.__esModule?C(n,"default",{value:e,enumerable:!0}):n,e)),Z=e=>L(C({},"__esModule",{value:!0}),e);var pe={};Y(pe,{helpers:()=>ue,termost:()=>Q});module.exports=Z(pe);var I=require("child_process"),v=async(e,t={hasLiveOutput:!1})=>new Promise((n,r)=>{let o="",c="",[s,...i]=e.split(" "),a=(0,I.spawn)(s,i,{cwd:t.cwd,env:{...process.env,FORCE_COLOR:"1"},shell:!0,stdio:t.hasLiveOutput?"inherit":"pipe"});a.stdout?.on("data",l=>{o+=l}),a.stderr?.on("data",l=>{c+=l}),a.on("close",l=>{if(l!==0){let u=`${c}${o}`;r(u.trim())}else n(o.trim())})});var O=h(require("picocolors")),y=(e,{color:t,modifiers:n}={color:"white",modifiers:[]})=>{let r=[];return r.push(O.default[ne[t??"white"]]),(n??[]).forEach(o=>{o==="uppercase"?e=e.toUpperCase():o==="lowercase"?e=e.toLowerCase():r.push(O.default[oe[o]])}),ee(...r)(e)},ee=(...e)=>e.reduce((t,n)=>r=>t(n(r)),e[0]),K=(e,{label:t,type:n="information"}={})=>{let{color:r,defaultLabel:o,icon:c,method:s}=te[n],i=typeof e=="string"?[e]:e;s(y(` -+${c} ${t??o}`,{color:r,modifiers:["bold"]}));for(let a of i)s(y(` ${a}`,{color:r}))},te={error:{color:"red",defaultLabel:"Error",icon:"\u274C",method:console.error},information:{color:"blue",defaultLabel:"Information",icon:"\u2139\uFE0F ",method:console.info},success:{color:"green",defaultLabel:"Success",icon:"\u2705",method:console.log},warning:{color:"yellow",defaultLabel:"Warning",icon:"\u26A0\uFE0F ",method:console.warn}},ne={black:"black",blue:"blue",cyan:"cyan",green:"green",grey:"gray",magenta:"magenta",red:"red",white:"white",yellow:"yellow"},oe={bold:"bold",italic:"italic",strikethrough:"strikethrough",underline:"underline"};var j=()=>{let e=[];return{dequeue(){return e.shift()},enqueue(t){e.push(t)},isEmpty(){return e.length===0}}};var g=e=>{let t=T[e];if(!t)throw new Error(`No controller has been set for the \`${e}\` command. -+Have you run the \`termost\` constructor?`);return t},M=(e,t)=>{let n=j(),r={},o={description:t,options:{"-h, --help":"Display the help center","-v, --version":"Print the version"}},c={addInstruction(s){n.enqueue(s)},addOptionDescription(s,i){o.options[s]=i},addValue(s,i){r[s]=i},async enable(){for(;!n.isEmpty();){let s=n.dequeue();s&&await s()}},getContext(s){return e!==s&&(r={...g(s).getContext(s),...r}),r},getMetadata(s){if(e!==s){let i=g(s).getMetadata(s);o.options={...i.options,...o.options}}return o}};return E[e]=t,T[e]=c,c},w=()=>E,T={},E={};var S=({name:e,description:t},{name:n,argv:r,version:o})=>{let c=e===n,s=r.command===e,i=M(e,t),a=g(n);return setTimeout(()=>{if(c&&!s&&a.enable(),s){let l=Object.keys(r.options);if(l.includes(N[0])||l.includes(N[1])){re({controller:i,currentCommandName:e,isRootCommand:c,rootCommandName:n});return}if(l.includes(R[0])||l.includes(R[1])){console.info(o);return}i.enable()}},0),e},N=["help","h"],R=["version","v"],re=({controller:e,currentCommandName:t,isRootCommand:n,rootCommandName:r})=>{let o=e.getMetadata(r),{description:c,options:s}=o,i=w(),a=Object.keys(o.options),l=Object.keys(i),u=a.length>0,p=n&&l.length>1;b("Usage"),k(`${y(`${r}${n?"":` ${String(t)}`}`,{color:"green"})} ${p?" ":""}${u?"[...options]":""}`),c&&(b("Description"),k(c));let f=[...l,...a].reduce((m,d)=>Math.max(m,d.length),0);if(p){b("Commands");for(let m of l){if(m===r)continue;let d=i[m];d&&$(m,d,f)}}if(u){b("Options");for(let m of a)$(m,s[m],f)}},k=(...e)=>{console.log(y(...e))},b=e=>{k(` -+${e}:`,{color:"yellow",modifiers:["bold","underline","uppercase"]})},$=(e,t,n)=>{k(` ${y(e.padEnd(n+1," "),{color:"green"})} ${t}`)};var _=require("enquirer"),A=e=>{let{key:t,label:n,defaultValue:r,type:o}=e;return async function(s,i){let a={name:t,initial:r,message:typeof n=="function"?n(s,i):n,type:o};if(e.type==="select"||e.type==="multiselect"){let u=e.type==="multiselect",f=e.options.map(m=>({title:m,value:m,...u&&{selected:(r||[]).includes(m)}}));a.choices=f}let l=await(0,_.prompt)(a);return{key:t,value:l[t]}}};var D=(e,{argv:t})=>n=>{let{key:r,name:o,description:c,defaultValue:s}=n,i=typeof o=="string"?[o]:[o.short,o.long],a=i.map((l,u)=>"-".repeat(i.length>1?u+1:2)+l).join(", ");return e.addOptionDescription(a,c),async function(){let u;for(let p of i)if(p in t.options){u=t.options[p];break}return Promise.resolve({key:r,value:u??s})}};var x=require("listr2"),F=e=>{let{key:t,label:n,handler:r}=e,o=n?new x.Listr([],{rendererOptions:{collapseErrors:!1,formatOutput:"wrap",showErrorMessage:!0,timer:x.PRESET_TIMER}}):null;return async function(s,i){let a;return o?(o.add({...n&&{title:typeof n=="function"?n(s,i):n},task:async()=>a=await r(s,i)}),await o.run()):a=await r(s,i),{key:t,value:a}}};var P=h(require("fs")),V=h(require("path")),G=e=>{let t=V.default.resolve(e,"package.json");return se(t)?require(t):G(V.default.resolve(e,".."))},se=e=>{try{return P.default.accessSync(e,P.default.constants.F_OK),!0}catch{return!1}},q=()=>{let e=require.main?.filename;if(!e)throw new Error("Termost was unable to retrieve automatically the package name and version. To fix it, use `termost({ name, description, version })` to define them manually.");return G(V.default.dirname(e))};var J=()=>{let e=process.argv.slice(2),t,n=[],r={},o,c=(i,a)=>{a?r[i]=typeof a=="string"?H(a):!0:o=i},s=()=>{o&&(r[o]=!0,o=void 0)};for(let i of e){let a=ae.exec(i)?.groups,l=ie.exec(i)?.groups;if(a?.name){s();let u=a.name.split(""),p=u.length-1;u.forEach((f,m)=>{c(f,p===m?void 0:!0)})}else l?.name?(s(),c(l.name,l.value)):o?(r[o]=H(i),o=void 0):t?n.push(i):t=i}return s(),{command:t,operands:n,options:r}},ae=/^-(?(?!-).*)$/,ie=/^--(?.*?)(?:=(?.+))?$/,H=e=>{try{return JSON.parse(e)}catch{return e}};function Q(e,t={}){let{name:n,description:r,version:o}=me(e)?e:{name:void 0,description:e,version:void 0};if(n===void 0||r===void 0||o===void 0){let a=q();n??(n=a.name),r??(r=a.description),o??(o=a.version)}let{command:c=n,operands:s,options:i}=J();return le(t),ce({name:n,description:r,argv:{command:c,operands:s,options:i},version:o})}var ce=e=>{let{name:t,description:n,argv:r}=e,o=t,c=o,s=(a,l)=>{let u=a(l),p=g(c);p.addInstruction(async()=>{let{skip:f}=l,m=p.getContext(o);if(f?.(m,r))return;let d=await u(m,r);!d||!d.key||p.addValue(d.key,d.value)})},i={command(a){return c=S(a,e),this},input(a){return s(A,a),this},option(a){return s(D(g(c),e),a),this},task(a){return s(F,a),this}};return i.command({name:t,description:n}),i},le=({onException:e=()=>{},onShutdown:t=()=>{}})=>{process.on("SIGTERM",()=>{t(),process.exit(0)}),process.on("SIGINT",()=>{t(),process.exit(0)}),process.on("uncaughtException",n=>{e(n),process.exit(1)}),process.on("unhandledRejection",n=>{n instanceof Error&&e(n),process.exit(1)})},me=e=>e!==null&&typeof e=="object";var ue={exec:v,format:y,message:K};0&&(module.exports={helpers,termost}); - //# sourceMappingURL=index.cjs.map -diff --git a/node_modules/termost/dist/index.cjs.map b/node_modules/termost/dist/index.cjs.map -index 6ae5d95..3a2ae79 100644 ---- a/node_modules/termost/dist/index.cjs.map -+++ b/node_modules/termost/dist/index.cjs.map -@@ -1,7 +1,7 @@ - { - "version": 3, -- "sources": ["../src/index.ts", "../src/helpers/process/index.ts", "../src/helpers/stdout/index.ts", "../src/helpers/package/index.ts", "../src/helpers/stdin/index.ts", "../src/api/command/controller/queue.ts", "../src/api/command/controller/index.ts", "../src/api/command/command.ts", "../src/api/input/index.ts", "../src/api/option/index.ts", "../src/api/task/index.ts", "../src/termost.ts"], -- "sourcesContent": ["import { exec } from \"./helpers/process\";\nimport { format, message } from \"./helpers/stdout\";\n\nexport { termost } from \"./termost\";\nexport type { Termost } from \"./termost\";\nexport const helpers = {\n\texec,\n\tformat,\n\tmessage,\n};\n", "import { spawn } from \"child_process\";\n\nexport const exec = async (\n\tcommand: string,\n\toptions: ExecOptions = { hasLiveOutput: false },\n) => {\n\treturn new Promise((resolve, reject) => {\n\t\tlet stdout = \"\";\n\t\tlet stderr = \"\";\n\t\tconst [bin, ...args] = command.split(\" \") as [string, ...string[]];\n\n\t\tconst childProcess = spawn(bin, args, {\n\t\t\tcwd: options.cwd,\n\t\t\tshell: true,\n\t\t\tstdio: options.hasLiveOutput ? \"inherit\" : \"pipe\",\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t// @note: make sure to force color display for spawned processes\n\t\t\t\tFORCE_COLOR: \"1\",\n\t\t\t},\n\t\t});\n\n\t\tchildProcess.stdout?.on(\"data\", (chunk) => {\n\t\t\tstdout += chunk;\n\t\t});\n\n\t\tchildProcess.stderr?.on(\"data\", (chunk) => {\n\t\t\tstderr += chunk;\n\t\t});\n\n\t\tchildProcess.on(\"close\", (exitCode) => {\n\t\t\tif (exitCode !== 0) {\n\t\t\t\tconst output = `${stderr}${stdout}`;\n\n\t\t\t\treject(output.trim());\n\t\t\t} else {\n\t\t\t\tresolve(stdout.trim());\n\t\t\t}\n\t\t});\n\t});\n};\n\ntype ExecOptions = {\n\tcwd?: string;\n\thasLiveOutput?: boolean;\n};\n", "import pico from \"picocolors\";\n\n/**\n * A helper to format an arbitrary text as a message input\n * @param message The text to display\n * @param options The configuration object to control the formatting properties\n * @returns The formatted text\n */\nexport const format = (\n\tmessage: string,\n\t{\n\t\tcolor,\n\t\tmodifiers,\n\t}: {\n\t\tcolor?: Color;\n\t\tmodifiers?: Modifier[];\n\t} = {\n\t\tcolor: \"white\",\n\t\tmodifiers: [],\n\t},\n) => {\n\tconst transformers: ((input: string) => string)[] = [];\n\n\ttransformers.push(pico[colorMapper[color ?? \"white\"]]);\n\n\t(modifiers ?? []).forEach((mod: Modifier) => {\n\t\tif (mod === \"uppercase\") {\n\t\t\tmessage = message.toUpperCase();\n\t\t} else if (mod === \"lowercase\") {\n\t\t\tmessage = message.toLowerCase();\n\t\t} else {\n\t\t\ttransformers.push(pico[modifierMapper[mod]]);\n\t\t}\n\t});\n\n\treturn compose(...transformers)(message);\n};\n\nconst compose = (...fns: ((a: T) => T)[]) =>\n\tfns.reduce(\n\t\t(prevFn, nextFn) => (value) => prevFn(nextFn(value)),\n\t\tfns[0] as (a: T) => T,\n\t);\n\n/**\n * An opinionated helper to display arbitrary text on the console\n * @param message The text to display. Use an array if you need to display a message in several lines\n * @param options The configuration object to define the display type and/or override the default label\n */\nexport const message = (\n\tcontent: string[] | string,\n\t{\n\t\tlabel,\n\t\ttype = \"information\",\n\t}: { type?: MessageType; label?: string } = {},\n) => {\n\tconst { color, defaultLabel, icon, method } = formatPropertiesByType[type];\n\tconst messages = typeof content === \"string\" ? [content] : content;\n\n\tmethod(\n\t\tformat(`\\n${icon} ${label ?? defaultLabel}`, {\n\t\t\tcolor,\n\t\t\tmodifiers: [\"bold\"],\n\t\t}),\n\t);\n\n\tfor (const msg of messages) {\n\t\tmethod(format(` ${msg}`, { color }));\n\t}\n};\n\nconst formatPropertiesByType = {\n\terror: {\n\t\tcolor: \"red\",\n\t\tdefaultLabel: \"Error\",\n\t\ticon: \"\u274C\",\n\t\tmethod: console.error,\n\t},\n\tinformation: {\n\t\tcolor: \"blue\",\n\t\tdefaultLabel: \"Information\",\n\t\ticon: \"\u2139\uFE0F \",\n\t\tmethod: console.info,\n\t},\n\tsuccess: {\n\t\tcolor: \"green\",\n\t\tdefaultLabel: \"Success\",\n\t\ticon: \"\u2705\",\n\t\tmethod: console.log,\n\t},\n\twarning: {\n\t\tcolor: \"yellow\",\n\t\tdefaultLabel: \"Warning\",\n\t\ticon: \"\u26A0\uFE0F \",\n\t\tmethod: console.warn,\n\t},\n} as const;\n\nconst colorMapper = {\n\tblack: \"black\",\n\tblue: \"blue\",\n\tcyan: \"cyan\",\n\tgreen: \"green\",\n\tgrey: \"gray\",\n\tmagenta: \"magenta\",\n\tred: \"red\",\n\twhite: \"white\",\n\tyellow: \"yellow\",\n} as const;\n\nconst modifierMapper = {\n\tbold: \"bold\",\n\titalic: \"italic\",\n\tstrikethrough: \"strikethrough\",\n\tunderline: \"underline\",\n} as const;\n\ntype MessageType = \"error\" | \"information\" | \"success\" | \"warning\";\n\ntype Color =\n\t| \"black\"\n\t| \"blue\"\n\t| \"cyan\"\n\t| \"green\"\n\t| \"grey\"\n\t| \"magenta\"\n\t| \"red\"\n\t| \"white\"\n\t| \"yellow\";\n\ntype Modifier =\n\t| \"bold\"\n\t| \"italic\"\n\t| \"lowercase\"\n\t| \"strikethrough\"\n\t| \"underline\"\n\t| \"uppercase\";\n", "import fs from \"fs\";\nimport path from \"path\";\n\nimport type { PackageMetadata } from \"../../types\";\n\nexport const findNearestPackageJson = (pathname: string): PackageMetadata => {\n\tconst packagePathname = path.resolve(pathname, \"package.json\");\n\n\tif (isFileExists(packagePathname)) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-var-requires\n\t\treturn require(packagePathname) as PackageMetadata;\n\t}\n\n\treturn findNearestPackageJson(path.resolve(pathname, \"..\"));\n};\n\nconst isFileExists = (pathname: string) => {\n\ttry {\n\t\tfs.accessSync(pathname, fs.constants.F_OK);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nexport const getPackageMetadata = () => {\n\tconst mainFilename = require.main?.filename;\n\n\tif (!mainFilename) {\n\t\tthrow new Error(\n\t\t\t\"Termost was unable to retrieve automatically the package name and version. To fix it, use `termost({ name, description, version })` to define them manually.\",\n\t\t);\n\t}\n\n\treturn findNearestPackageJson(path.dirname(mainFilename));\n};\n", "// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const getArguments = () => {\n\tconst parameters = process.argv.slice(2);\n\tlet command: string | undefined;\n\tconst operands: string[] = [];\n\tconst options: Record = {};\n\tlet currentOptionName: string | undefined;\n\n\tconst addOptimisticOption = (name: string, value?: boolean | string) => {\n\t\tif (value) {\n\t\t\toptions[name] = typeof value === \"string\" ? castValue(value) : true;\n\t\t} else {\n\t\t\tcurrentOptionName = name;\n\t\t}\n\t};\n\n\tconst flushOptimisticOption = () => {\n\t\tif (currentOptionName) {\n\t\t\toptions[currentOptionName] = true;\n\t\t\tcurrentOptionName = undefined;\n\t\t}\n\t};\n\n\tfor (const parameter of parameters) {\n\t\tconst shortFlagMatchResult = SHORT_FLAG_REGEX.exec(parameter)?.groups;\n\t\tconst longFlagMatchResult = LONG_FLAG_REGEX.exec(parameter)?.groups;\n\n\t\tif (shortFlagMatchResult?.name) {\n\t\t\tflushOptimisticOption();\n\n\t\t\tconst optionFlags = shortFlagMatchResult.name.split(\"\");\n\t\t\tconst lastIndex = optionFlags.length - 1;\n\n\t\t\toptionFlags.forEach((flag, index) => {\n\t\t\t\taddOptimisticOption(\n\t\t\t\t\tflag,\n\t\t\t\t\tlastIndex === index ? undefined : true,\n\t\t\t\t);\n\t\t\t});\n\t\t} else if (longFlagMatchResult?.name) {\n\t\t\tflushOptimisticOption();\n\t\t\taddOptimisticOption(\n\t\t\t\tlongFlagMatchResult.name,\n\t\t\t\tlongFlagMatchResult.value,\n\t\t\t);\n\t\t} else if (currentOptionName) {\n\t\t\toptions[currentOptionName] = castValue(parameter);\n\t\t\tcurrentOptionName = undefined;\n\t\t} else if (!command) {\n\t\t\tcommand = parameter;\n\t\t} else {\n\t\t\toperands.push(parameter);\n\t\t}\n\t}\n\n\tflushOptimisticOption();\n\n\treturn { command, operands, options };\n};\n\nconst SHORT_FLAG_REGEX = /^-(?(?!-).*)$/;\nconst LONG_FLAG_REGEX = /^--(?.*?)(?:=(?.+))?$/;\n\nconst castValue = (value: string) => {\n\ttry {\n\t\treturn JSON.parse(value) as boolean | number | string;\n\t} catch {\n\t\treturn value;\n\t}\n};\n", "export const createQueue = () => {\n\tconst items: Item[] = [];\n\n\treturn {\n\t\tenqueue(item: Item) {\n\t\t\titems.push(item);\n\t\t},\n\t\tdequeue() {\n\t\t\treturn items.shift();\n\t\t},\n\t\tisEmpty() {\n\t\t\treturn items.length === 0;\n\t\t},\n\t};\n};\n", "import type {\n\tCommandName,\n\tContext,\n\tEmptyObject,\n\tObjectLikeConstraint,\n} from \"../../../types\";\n\nimport { createQueue } from \"./queue\";\n\nexport type CommandController<\n\tValues extends ObjectLikeConstraint = EmptyObject,\n> = {\n\taddValue: (key: Key, value: Values[Key]) => void;\n\taddOptionDescription: (key: string, description: string) => void;\n\taddInstruction: (instruction: Instruction) => void;\n\t/**\n\t * Enables a command by iterating over instructions and executing them\n\t */\n\tenable: () => Promise;\n\tgetContext: (rootCommandName: CommandName) => Context;\n\tgetMetadata: (rootCommandName: CommandName) => CommandMetadata;\n};\n\nexport const getCommandController = (\n\tname: CommandName,\n) => {\n\tconst controller = commandControllerCollection[name];\n\n\tif (!controller) {\n\t\tthrow new Error(\n\t\t\t`No controller has been set for the \\`${name}\\` command.\\nHave you run the \\`termost\\` constructor?`,\n\t\t);\n\t}\n\n\treturn controller as CommandController;\n};\n\nexport const createCommandController = (\n\tname: CommandName,\n\tdescription: CommandMetadata[\"description\"],\n) => {\n\tconst instructions = createQueue();\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\tlet context = {} as Context;\n\n\tconst metadata: CommandMetadata = {\n\t\tdescription,\n\t\toptions: {\n\t\t\t\"-h, --help\": \"Display the help center\",\n\t\t\t\"-v, --version\": \"Print the version\",\n\t\t},\n\t};\n\n\tconst controller: CommandController = {\n\t\taddOptionDescription(key, value) {\n\t\t\tmetadata.options[key] = value;\n\t\t},\n\t\taddValue(key, value) {\n\t\t\tcontext[key] = value;\n\t\t},\n\t\taddInstruction(instruction) {\n\t\t\tinstructions.enqueue(instruction);\n\t\t},\n\t\tasync enable() {\n\t\t\twhile (!instructions.isEmpty()) {\n\t\t\t\tconst task = instructions.dequeue();\n\n\t\t\t\tif (task) {\n\t\t\t\t\tawait task();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tgetContext(rootCommandName) {\n\t\t\t// @note: By design, global values are accessible to subcommands\n\t\t\t// Consequently, root command values are merged with the current command ones:\n\t\t\tif (name !== rootCommandName) {\n\t\t\t\tconst rootController = getCommandController(rootCommandName);\n\n\t\t\t\tconst globalContext =\n\t\t\t\t\trootController.getContext(rootCommandName);\n\n\t\t\t\tcontext = {\n\t\t\t\t\t...globalContext,\n\t\t\t\t\t...context,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn context;\n\t\t},\n\t\tgetMetadata(rootCommandName) {\n\t\t\tif (name !== rootCommandName) {\n\t\t\t\tconst globalMetadata =\n\t\t\t\t\tgetCommandController(rootCommandName).getMetadata(\n\t\t\t\t\t\trootCommandName,\n\t\t\t\t\t);\n\n\t\t\t\tmetadata.options = {\n\t\t\t\t\t...globalMetadata.options,\n\t\t\t\t\t...metadata.options,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn metadata;\n\t\t},\n\t};\n\n\tcommandDescriptionCollection[name] = description;\n\tcommandControllerCollection[name] = controller;\n\n\treturn controller;\n};\n\nexport const getCommandDescriptionCollection = () => {\n\treturn commandDescriptionCollection;\n};\n\ntype CommandMetadata = {\n\tdescription: string;\n\toptions: Record;\n};\n\ntype Instruction = () => Promise;\n\nconst commandControllerCollection: Record<\n\tCommandName,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tCommandController\n> = {};\n\nconst commandDescriptionCollection: Record<\n\tCommandName,\n\tCommandMetadata[\"description\"]\n> = {};\n", "/* eslint-disable sonarjs/cognitive-complexity */\nimport { format } from \"../../helpers/stdout\";\nimport type { ObjectLikeConstraint, ProgramMetadata } from \"../../types\";\n\nimport type { CommandController } from \"./controller\";\nimport {\n\tcreateCommandController,\n\tgetCommandController,\n\tgetCommandDescriptionCollection,\n} from \"./controller\";\n\nexport type CommandParameters = {\n\tname: string;\n\tdescription: string;\n};\n\nexport const createCommand = (\n\t{ name, description }: CommandParameters,\n\t{ argv, name: rootCommandName, version }: ProgramMetadata,\n) => {\n\tconst isRootCommand = name === rootCommandName;\n\tconst isActiveCommand = argv.command === name;\n\tconst controller = createCommandController(name, description);\n\tconst rootController = getCommandController(rootCommandName);\n\n\tsetTimeout(() => {\n\t\t// @note: By design, the root command instructions are always executed\n\t\t// even with subcommands (to share options, messages...)\n\t\tif (isRootCommand && !isActiveCommand) {\n\t\t\tvoid rootController.enable();\n\t\t}\n\n\t\t// @note: enable the current active command instructions:\n\t\tif (isActiveCommand) {\n\t\t\t// @note: setTimeout 0 allows to run activation logic in the next event loop iteration.\n\t\t\t// It'll allow to make sure that the `metadata` is correctly filled with all commands\n\t\t\t// metadata (especially to let the global help option to display all available commands):\n\t\t\tconst optionKeys = Object.keys(argv.options);\n\n\t\t\tif (\n\t\t\t\toptionKeys.includes(OPTION_HELP_NAMES[0]) ||\n\t\t\t\toptionKeys.includes(OPTION_HELP_NAMES[1])\n\t\t\t) {\n\t\t\t\tshowHelp({\n\t\t\t\t\tcontroller,\n\t\t\t\t\tcurrentCommandName: name,\n\t\t\t\t\tisRootCommand,\n\t\t\t\t\trootCommandName,\n\t\t\t\t});\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\toptionKeys.includes(OPTION_VERSION_NAMES[0]) ||\n\t\t\t\toptionKeys.includes(OPTION_VERSION_NAMES[1])\n\t\t\t) {\n\t\t\t\tconsole.info(version);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvoid controller.enable();\n\t\t}\n\t}, 0);\n\n\treturn name;\n};\n\nconst OPTION_HELP_NAMES = [\"help\", \"h\"] as const;\nconst OPTION_VERSION_NAMES = [\"version\", \"v\"] as const;\n\nconst showHelp = ({\n\trootCommandName,\n\tcurrentCommandName,\n\tisRootCommand,\n\tcontroller,\n}: {\n\trootCommandName: string;\n\tcurrentCommandName: string;\n\tisRootCommand: boolean;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcontroller: CommandController;\n}) => {\n\tconst commandMetadata = controller.getMetadata(rootCommandName);\n\tconst { options, description } = commandMetadata;\n\tconst commands = getCommandDescriptionCollection();\n\tconst optionKeys = Object.keys(commandMetadata.options);\n\tconst commandKeys = Object.keys(commands);\n\tconst hasOptions = optionKeys.length > 0;\n\tconst hasCommands = isRootCommand && commandKeys.length > 1;\n\n\tprintTitle(\"Usage\");\n\tprint(\n\t\t`${format(\n\t\t\t`${rootCommandName}${\n\t\t\t\tisRootCommand ? \"\" : ` ${String(currentCommandName)}`\n\t\t\t}`,\n\t\t\t{\n\t\t\t\tcolor: \"green\",\n\t\t\t},\n\t\t)} ${hasCommands ? \" \" : \"\"}${\n\t\t\thasOptions ? \"[...options]\" : \"\"\n\t\t}`,\n\t);\n\n\tif (description) {\n\t\tprintTitle(\"Description\");\n\t\tprint(description);\n\t}\n\n\tconst padding = [...commandKeys, ...optionKeys].reduce((value, item) => {\n\t\treturn Math.max(value, item.length);\n\t}, 0);\n\n\tif (hasCommands) {\n\t\tprintTitle(\"Commands\");\n\n\t\tfor (const name of commandKeys) {\n\t\t\tif (name === rootCommandName) continue;\n\n\t\t\tconst commandDescription = commands[name];\n\n\t\t\tif (commandDescription)\n\t\t\t\tprintLabelValue(name, commandDescription, padding);\n\t\t}\n\t}\n\n\tif (hasOptions) {\n\t\tprintTitle(\"Options\");\n\n\t\tfor (const key of optionKeys) {\n\t\t\tprintLabelValue(key, options[key] as string, padding);\n\t\t}\n\t}\n};\n\nconst print = (...parameters: Parameters) => {\n\tconsole.log(format(...parameters));\n};\n\nconst printTitle = (message: string) => {\n\tprint(`\\n${message}:`, {\n\t\tcolor: \"yellow\",\n\t\tmodifiers: [\"bold\", \"underline\", \"uppercase\"],\n\t});\n};\n\nconst printLabelValue = (label: string, value: string, padding: number) => {\n\tprint(\n\t\t` ${format(label.padEnd(padding + 1, \" \"), {\n\t\t\tcolor: \"green\",\n\t\t})} ${value}`,\n\t);\n};\n", "/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { prompt } from \"enquirer\";\n\nimport type {\n\tCreateInstruction,\n\tInstructionKey,\n\tInstructionParameters,\n\tLabel,\n\tObjectLikeConstraint,\n} from \"../../types\";\n\nexport const createInput: CreateInstruction<\n\tInputParameters\n> = (parameters) => {\n\tconst { key, defaultValue, label, type } = parameters;\n\n\treturn async function execute(context, argv) {\n\t\tconst promptObject: Parameters[0] & {\n\t\t\tchoices?: { title: string; value: string; selected?: boolean }[];\n\t\t} = {\n\t\t\tinitial: defaultValue,\n\t\t\tmessage: typeof label === \"function\" ? label(context, argv) : label,\n\t\t\tname: key,\n\t\t\ttype,\n\t\t};\n\n\t\tif (parameters.type === \"select\" || parameters.type === \"multiselect\") {\n\t\t\tconst isMultiSelect = parameters.type === \"multiselect\";\n\t\t\tconst options = parameters.options as string[];\n\n\t\t\tconst choices = options.map((option) => ({\n\t\t\t\ttitle: option,\n\t\t\t\tvalue: option,\n\t\t\t\t...(isMultiSelect && {\n\t\t\t\t\tselected: ((defaultValue || []) as string[]).includes(\n\t\t\t\t\t\toption,\n\t\t\t\t\t),\n\t\t\t\t}),\n\t\t\t}));\n\n\t\t\tpromptObject.choices = choices;\n\t\t}\n\n\t\tconst data = await prompt(promptObject);\n\n\t\treturn { key, value: data[key] };\n\t};\n};\n\nexport type InputParameters<\n\tValues extends ObjectLikeConstraint,\n\tKey extends keyof Values,\n> = InstructionParameters<\n\tValues,\n\tInstructionKey &\n\t\t(\n\t\t\t| {\n\t\t\t\t\ttype: \"confirm\";\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\tdefaultValue?: Values[Key] extends boolean\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\ttype: \"multiselect\";\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\toptions: Values[Key] extends string[] ? Values[Key] : never;\n\t\t\t\t\tdefaultValue?: Values[Key] extends string[]\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\ttype: \"select\";\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\toptions: Values[Key] extends string ? Values[Key][] : never;\n\t\t\t\t\tdefaultValue?: Values[Key] extends string\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\ttype: \"text\";\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\tdefaultValue?: Values[Key] extends string\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t }\n\t\t)\n>;\n", "/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport type { CommandController } from \"../command\";\nimport type {\n\tCreateInstruction,\n\tInstructionKey,\n\tInstructionParameters,\n\tObjectLikeConstraint,\n\tProgramMetadata,\n} from \"../../types\";\n\nexport const createOption =\n\t(\n\t\tcommandController: CommandController,\n\t\t{ argv }: ProgramMetadata,\n\t): CreateInstruction<\n\t\tOptionParameters\n\t> =>\n\t(parameters) => {\n\t\tconst { key, name, description, defaultValue } = parameters;\n\n\t\tconst aliases =\n\t\t\ttypeof name === \"string\" ? [name] : [name.short, name.long];\n\n\t\tconst metadataKey = aliases\n\t\t\t.map(\n\t\t\t\t(alias, index) =>\n\t\t\t\t\t\"-\".repeat(aliases.length > 1 ? index + 1 : 2) + alias,\n\t\t\t)\n\t\t\t.join(\", \");\n\n\t\tcommandController.addOptionDescription(metadataKey, description);\n\n\t\treturn async function execute() {\n\t\t\tlet value: unknown;\n\n\t\t\tfor (const alias of aliases) {\n\t\t\t\tif (alias in argv.options) {\n\t\t\t\t\tvalue = argv.options[alias];\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn Promise.resolve({ key, value: value ?? defaultValue });\n\t\t};\n\t};\n\nexport type OptionParameters<\n\tValues extends ObjectLikeConstraint,\n\tKey extends keyof Values,\n> = InstructionParameters<\n\tValues,\n\tInstructionKey & {\n\t\tname: string | { long: string; short: string };\n\t\tdescription: string;\n\t\tdefaultValue?: Values[Key];\n\t}\n>;\n", "import { Listr, PRESET_TIMER } from \"listr2\";\n\nimport type {\n\tArgumentValues,\n\tContext,\n\tCreateInstruction,\n\tInstructionKey,\n\tInstructionParameters,\n\tLabel,\n\tObjectLikeConstraint,\n} from \"../../types\";\n\nexport const createTask: CreateInstruction<\n\tTaskParameters\n> = (parameters) => {\n\tconst { key, label, handler } = parameters;\n\n\tconst receiver = label\n\t\t? new Listr([], {\n\t\t\t\trendererOptions: {\n\t\t\t\t\tcollapseErrors: false,\n\t\t\t\t\tformatOutput: \"wrap\",\n\t\t\t\t\tshowErrorMessage: true,\n\t\t\t\t\ttimer: PRESET_TIMER,\n\t\t\t\t},\n\t\t })\n\t\t: null;\n\n\treturn async function execute(context, argv) {\n\t\tlet value: unknown;\n\n\t\tif (!receiver) {\n\t\t\tvalue = await handler(context, argv);\n\t\t} else {\n\t\t\treceiver.add({\n\t\t\t\t...(label && {\n\t\t\t\t\ttitle:\n\t\t\t\t\t\ttypeof label === \"function\"\n\t\t\t\t\t\t\t? label(context, argv)\n\t\t\t\t\t\t\t: label,\n\t\t\t\t}),\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\t\ttask: async () => (value = await handler(context, argv)),\n\t\t\t});\n\n\t\t\tawait receiver.run();\n\t\t}\n\n\t\treturn { key, value };\n\t};\n};\n\nexport type TaskParameters<\n\tValues extends ObjectLikeConstraint,\n\tKey extends keyof Values | undefined = undefined,\n> = InstructionParameters<\n\tValues,\n\tPartial> & {\n\t\tlabel?: Label;\n\t\thandler: (\n\t\t\tcontext: Context,\n\t\t\targv: ArgumentValues,\n\t\t) => Key extends keyof Values\n\t\t\t? Promise | Values[Key]\n\t\t\t: Promise | void;\n\t}\n>;\n", "import { getPackageMetadata } from \"./helpers/package\";\nimport { getArguments } from \"./helpers/stdin\";\nimport type {\n\tCommandName,\n\tCreateInstruction,\n\tEmptyObject,\n\tInstructionParameters,\n\tObjectLikeConstraint,\n\tPackageMetadata,\n\tProgramMetadata,\n} from \"./types\";\nimport type { CommandParameters } from \"./api/command\";\nimport { createCommand, getCommandController } from \"./api/command\";\nimport type { InputParameters } from \"./api/input\";\nimport { createInput } from \"./api/input\";\nimport type { OptionParameters } from \"./api/option\";\nimport { createOption } from \"./api/option\";\nimport type { TaskParameters } from \"./api/task\";\nimport { createTask } from \"./api/task\";\n\n/**\n * The termost fluent interface API\n */\nexport type Termost = {\n\t/**\n\t * Allows to attach a new sub-command to the program\n\t * @param name - The CLI command name\n\t * @param description - The CLI command description\n\t * @returns The Command API\n\t */\n\tcommand: (\n\t\tparams: CommandParameters,\n\t) => Termost;\n\tinput: (\n\t\tparams: InputParameters,\n\t) => Termost;\n\toption: (\n\t\tparams: OptionParameters,\n\t) => Termost;\n\ttask: (\n\t\tparams: TaskParameters,\n\t) => Termost;\n};\n\nexport function termost(\n\tmetadata: Partial | string,\n\tcallbacks: TerminationCallbacks = {},\n) {\n\tconst paramsMetadata: Partial = isObject(metadata)\n\t\t? metadata\n\t\t: { description: metadata };\n\n\tconst packageMetadata = getPackageMetadata();\n\tconst programName = paramsMetadata.name ?? packageMetadata.name;\n\tconst { command = programName, options, operands } = getArguments();\n\n\tsetGracefulListeners(callbacks);\n\n\treturn createProgram({\n\t\targv: { command, options, operands },\n\t\tdescription: paramsMetadata.description ?? packageMetadata.description,\n\t\tname: programName,\n\t\tversion: paramsMetadata.version ?? packageMetadata.version,\n\t});\n}\n\nexport const createProgram = (\n\tmetadata: ProgramMetadata,\n): Termost => {\n\tconst { argv, name, description } = metadata;\n\tconst rootCommandName: CommandName = name;\n\tlet currentCommandName: CommandName = rootCommandName;\n\n\tconst createInstruction = <\n\t\tParameters extends InstructionParameters,\n\t>(\n\t\tfactory: CreateInstruction,\n\t\tparams: InstructionParameters,\n\t) => {\n\t\tconst instruction = factory(params as Parameters);\n\t\tconst controller = getCommandController(currentCommandName);\n\n\t\tcontroller.addInstruction(async () => {\n\t\t\tconst { skip } = params;\n\t\t\tconst context = controller.getContext(rootCommandName);\n\n\t\t\tif (skip?.(context, argv)) return;\n\n\t\t\tconst output = await instruction(context, argv);\n\n\t\t\tif (!output || !output.key) return;\n\n\t\t\tcontroller.addValue(\n\t\t\t\toutput.key,\n\t\t\t\toutput.value as Values[keyof Values],\n\t\t\t);\n\t\t});\n\t};\n\n\tconst program: Termost = {\n\t\tcommand(params: CommandParameters) {\n\t\t\tcurrentCommandName = createCommand(params, metadata);\n\n\t\t\treturn this as Termost;\n\t\t},\n\t\tinput(params) {\n\t\t\tcreateInstruction(createInput, params);\n\n\t\t\treturn this;\n\t\t},\n\t\toption(params) {\n\t\t\tcreateInstruction(\n\t\t\t\tcreateOption(\n\t\t\t\t\tgetCommandController(currentCommandName),\n\t\t\t\t\tmetadata,\n\t\t\t\t),\n\t\t\t\tparams,\n\t\t\t);\n\n\t\t\treturn this;\n\t\t},\n\t\ttask(params) {\n\t\t\tcreateInstruction(createTask, params);\n\n\t\t\treturn this;\n\t\t},\n\t};\n\n\t// @note: the root command is created by default\n\tprogram.command({\n\t\tname,\n\t\tdescription,\n\t});\n\n\treturn program;\n};\n\ntype TerminationCallbacks = Partial<{\n\tonShutdown: () => void;\n\tonException: (error: Error) => void;\n}>;\n\nconst setGracefulListeners = ({\n\tonShutdown = () => {\n\t\treturn;\n\t},\n\tonException = () => {\n\t\treturn;\n\t},\n}: TerminationCallbacks) => {\n\tprocess.on(\"SIGTERM\", () => {\n\t\tonShutdown();\n\t\tprocess.exit(0);\n\t});\n\n\tprocess.on(\"SIGINT\", () => {\n\t\tonShutdown();\n\t\tprocess.exit(0);\n\t});\n\n\tprocess.on(\"uncaughtException\", (error) => {\n\t\tonException(error);\n\t\tprocess.exit(1);\n\t});\n\n\tprocess.on(\"unhandledRejection\", (reason) => {\n\t\tif (reason instanceof Error) {\n\t\t\tonException(reason);\n\t\t}\n\n\t\tprocess.exit(1);\n\t});\n};\n\nconst isObject = (value: unknown): value is ObjectLikeConstraint => {\n\treturn value !== null && typeof value === \"object\";\n};\n"], -- "mappings": "0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,GAAA,YAAAC,IAAA,eAAAC,EAAAJ,ICAA,IAAAK,EAAsB,yBAETC,EAAO,MACnBC,EACAC,EAAuB,CAAE,cAA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CAChC,QAAuBP,EAA2B,CACjD,OAAAH,EAAqBW,EAAcR,EAAQpB,CAAQ,EAE5C,IACR,EACA,MAAMoB,EAAQ,CACb,OAAAF,EAAkBW,EAAaT,CAAM,EAE9B,IACR,EACA,OAAOA,EAAQ,CACd,OAAAF,EACCY,EACCP,EAAqBN,CAAkB,EACvCjB,CACD,EACAoB,CACD,EAEO,IACR,EACA,KAAKA,EAAQ,CACZ,OAAAF,EAAkBa,EAAYX,CAAM,EAE7B,IACR,CACD,EAGA,OAAAO,EAAQ,QAAQ,CACf,KAAAb,EACA,YAAAC,CACD,CAAC,EAEMY,CACR,EAOMhB,GAAuB,CAAC,CAC7B,WAAAqB,EAAa,IAAM,CAEnB,EACA,YAAAC,EAAc,IAAM,CAEpB,CACD,IAA4B,CAC3B,QAAQ,GAAG,UAAW,IAAM,CAC3BD,EAAW,EACX,QAAQ,KAAK,CAAC,CACf,CAAC,EAED,QAAQ,GAAG,SAAU,IAAM,CAC1BA,EAAW,EACX,QAAQ,KAAK,CAAC,CACf,CAAC,EAED,QAAQ,GAAG,oBAAsBE,GAAU,CAC1CD,EAAYC,CAAK,EACjB,QAAQ,KAAK,CAAC,CACf,CAAC,EAED,QAAQ,GAAG,qBAAuBC,GAAW,CACxCA,aAAkB,OACrBF,EAAYE,CAAM,EAGnB,QAAQ,KAAK,CAAC,CACf,CAAC,CACF,EAEMhC,GAAYiC,GACVA,IAAU,MAAQ,OAAOA,GAAU,SX1KpC,IAAMC,GAAU,CACtB,KAAAC,EACA,OAAAC,EACA,QAAAC,CACD", -- "names": ["src_exports", "__export", "helpers", "termost", "__toCommonJS", "import_child_process", "exec", "command", "options", "resolve", "reject", "stdout", "stderr", "bin", "args", "childProcess", "chunk", "exitCode", "output", "import_picocolors", "format", "message", "color", "modifiers", "transformers", "pico", "colorMapper", "mod", "modifierMapper", "compose", "fns", "prevFn", "nextFn", "value", "content", "label", "type", "defaultLabel", "icon", "method", "formatPropertiesByType", "messages", "msg", "import_fs", "import_path", "findNearestPackageJson", "pathname", "packagePathname", "path", "isFileExists", "fs", "getPackageMetadata", "mainFilename", "getArguments", "parameters", "command", "operands", "options", "currentOptionName", "addOptimisticOption", "name", "value", "castValue", "flushOptimisticOption", "parameter", "shortFlagMatchResult", "SHORT_FLAG_REGEX", "longFlagMatchResult", "LONG_FLAG_REGEX", "optionFlags", "lastIndex", "flag", "index", "createQueue", "items", "item", "getCommandController", "name", "controller", "commandControllerCollection", "createCommandController", "description", "instructions", "createQueue", "context", "metadata", "key", "value", "instruction", "task", "rootCommandName", "globalMetadata", "commandDescriptionCollection", "getCommandDescriptionCollection", "createCommand", "name", "description", "argv", "rootCommandName", "version", "isRootCommand", "isActiveCommand", "controller", "createCommandController", "rootController", "getCommandController", "optionKeys", "OPTION_HELP_NAMES", "showHelp", "OPTION_VERSION_NAMES", "currentCommandName", "commandMetadata", "options", "commands", "getCommandDescriptionCollection", "commandKeys", "hasOptions", "hasCommands", "printTitle", "print", "format", "padding", "value", "item", "commandDescription", "printLabelValue", "key", "parameters", "message", "label", "import_enquirer", "createInput", "parameters", "key", "defaultValue", "label", "type", "context", "argv", "promptObject", "isMultiSelect", "choices", "option", "data", "createOption", "commandController", "argv", "parameters", "key", "name", "description", "defaultValue", "aliases", "metadataKey", "alias", "index", "value", "import_listr2", "createTask", "parameters", "key", "label", "handler", "receiver", "context", "argv", "value", "termost", "metadata", "callbacks", "paramsMetadata", "isObject", "packageMetadata", "getPackageMetadata", "programName", "command", "options", "operands", "getArguments", "setGracefulListeners", "createProgram", "argv", "name", "description", "rootCommandName", "currentCommandName", "createInstruction", "factory", "params", "instruction", "controller", "getCommandController", "skip", "context", "output", "program", "createCommand", "createInput", "createOption", "createTask", "onShutdown", "onException", "error", "reason", "value", "helpers", "exec", "format", "message"] -+ "sources": ["../src/index.ts", "../src/helpers/process/index.ts", "../src/helpers/stdout/index.ts", "../src/api/command/controller/queue.ts", "../src/api/command/controller/index.ts", "../src/api/command/command.ts", "../src/api/input/index.ts", "../src/api/option/index.ts", "../src/api/task/index.ts", "../src/helpers/package/index.ts", "../src/helpers/stdin/index.ts", "../src/termost.ts"], -+ "sourcesContent": ["import { exec } from \"./helpers/process\";\nimport { format, message } from \"./helpers/stdout\";\n\nexport { termost } from \"./termost\";\nexport type { Termost } from \"./termost\";\nexport const helpers = {\n\texec,\n\tformat,\n\tmessage,\n};\n", "import { spawn } from \"child_process\";\n\nexport const exec = async (\n\tcommand: string,\n\toptions: ExecOptions = { hasLiveOutput: false },\n) => {\n\treturn new Promise((resolve, reject) => {\n\t\tlet stdout = \"\";\n\t\tlet stderr = \"\";\n\t\tconst [bin, ...args] = command.split(\" \") as [string, ...string[]];\n\n\t\tconst childProcess = spawn(bin, args, {\n\t\t\tcwd: options.cwd,\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t// @note: make sure to force color display for spawned processes\n\t\t\t\tFORCE_COLOR: \"1\",\n\t\t\t},\n\t\t\tshell: true,\n\t\t\tstdio: options.hasLiveOutput ? \"inherit\" : \"pipe\",\n\t\t});\n\n\t\tchildProcess.stdout?.on(\"data\", (chunk) => {\n\t\t\tstdout += chunk;\n\t\t});\n\n\t\tchildProcess.stderr?.on(\"data\", (chunk) => {\n\t\t\tstderr += chunk;\n\t\t});\n\n\t\tchildProcess.on(\"close\", (exitCode) => {\n\t\t\tif (exitCode !== 0) {\n\t\t\t\tconst output = `${stderr}${stdout}`;\n\n\t\t\t\treject(output.trim());\n\t\t\t} else {\n\t\t\t\tresolve(stdout.trim());\n\t\t\t}\n\t\t});\n\t});\n};\n\ntype ExecOptions = {\n\tcwd?: string;\n\thasLiveOutput?: boolean;\n};\n", "import pico from \"picocolors\";\n\n/**\n * A helper to format an arbitrary text as a message input\n * @param message The text to display\n * @param options The configuration object to control the formatting properties\n * @returns The formatted text\n */\nexport const format = (\n\tmessage: string,\n\t{\n\t\tcolor,\n\t\tmodifiers,\n\t}: {\n\t\tcolor?: Color;\n\t\tmodifiers?: Modifier[];\n\t} = {\n\t\tcolor: \"white\",\n\t\tmodifiers: [],\n\t},\n) => {\n\tconst transformers: ((input: string) => string)[] = [];\n\n\ttransformers.push(pico[colorMapper[color ?? \"white\"]]);\n\n\t(modifiers ?? []).forEach((mod: Modifier) => {\n\t\tif (mod === \"uppercase\") {\n\t\t\tmessage = message.toUpperCase();\n\t\t} else if (mod === \"lowercase\") {\n\t\t\tmessage = message.toLowerCase();\n\t\t} else {\n\t\t\ttransformers.push(pico[modifierMapper[mod]]);\n\t\t}\n\t});\n\n\treturn compose(...transformers)(message);\n};\n\nconst compose = (...fns: ((a: T) => T)[]) =>\n\tfns.reduce(\n\t\t(prevFn, nextFn) => (value) => prevFn(nextFn(value)),\n\t\tfns[0] as (a: T) => T,\n\t);\n\n/**\n * An opinionated helper to display arbitrary text on the console\n * @param message The text to display. Use an array if you need to display a message in several lines\n * @param options The configuration object to define the display type and/or override the default label\n */\nexport const message = (\n\tcontent: string[] | string,\n\t{\n\t\tlabel,\n\t\ttype = \"information\",\n\t}: { label?: string; type?: MessageType } = {},\n) => {\n\tconst { color, defaultLabel, icon, method } = formatPropertiesByType[type];\n\tconst messages = typeof content === \"string\" ? [content] : content;\n\n\tmethod(\n\t\tformat(`\\n${icon} ${label ?? defaultLabel}`, {\n\t\t\tcolor,\n\t\t\tmodifiers: [\"bold\"],\n\t\t}),\n\t);\n\n\tfor (const msg of messages) {\n\t\tmethod(format(` ${msg}`, { color }));\n\t}\n};\n\nconst formatPropertiesByType = {\n\terror: {\n\t\tcolor: \"red\",\n\t\tdefaultLabel: \"Error\",\n\t\ticon: \"\u274C\",\n\t\tmethod: console.error,\n\t},\n\tinformation: {\n\t\tcolor: \"blue\",\n\t\tdefaultLabel: \"Information\",\n\t\ticon: \"\u2139\uFE0F \",\n\t\tmethod: console.info,\n\t},\n\tsuccess: {\n\t\tcolor: \"green\",\n\t\tdefaultLabel: \"Success\",\n\t\ticon: \"\u2705\",\n\t\tmethod: console.log,\n\t},\n\twarning: {\n\t\tcolor: \"yellow\",\n\t\tdefaultLabel: \"Warning\",\n\t\ticon: \"\u26A0\uFE0F \",\n\t\tmethod: console.warn,\n\t},\n} as const;\n\nconst colorMapper = {\n\tblack: \"black\",\n\tblue: \"blue\",\n\tcyan: \"cyan\",\n\tgreen: \"green\",\n\tgrey: \"gray\",\n\tmagenta: \"magenta\",\n\tred: \"red\",\n\twhite: \"white\",\n\tyellow: \"yellow\",\n} as const;\n\nconst modifierMapper = {\n\tbold: \"bold\",\n\titalic: \"italic\",\n\tstrikethrough: \"strikethrough\",\n\tunderline: \"underline\",\n} as const;\n\ntype MessageType = \"error\" | \"information\" | \"success\" | \"warning\";\n\ntype Color =\n\t| \"black\"\n\t| \"blue\"\n\t| \"cyan\"\n\t| \"green\"\n\t| \"grey\"\n\t| \"magenta\"\n\t| \"red\"\n\t| \"white\"\n\t| \"yellow\";\n\ntype Modifier =\n\t| \"bold\"\n\t| \"italic\"\n\t| \"lowercase\"\n\t| \"strikethrough\"\n\t| \"underline\"\n\t| \"uppercase\";\n", "export const createQueue = () => {\n\tconst items: Item[] = [];\n\n\treturn {\n\t\tdequeue() {\n\t\t\treturn items.shift();\n\t\t},\n\t\tenqueue(item: Item) {\n\t\t\titems.push(item);\n\t\t},\n\t\tisEmpty() {\n\t\t\treturn items.length === 0;\n\t\t},\n\t};\n};\n", "import type {\n\tCommandName,\n\tContext,\n\tEmptyObject,\n\tObjectLikeConstraint,\n} from \"../../../types\";\n\nimport { createQueue } from \"./queue\";\n\nexport type CommandController<\n\tValues extends ObjectLikeConstraint = EmptyObject,\n> = {\n\taddInstruction: (instruction: Instruction) => void;\n\taddOptionDescription: (key: string, description: string) => void;\n\taddValue: (key: Key, value: Values[Key]) => void;\n\t/**\n\t * Enables a command by iterating over instructions and executing them\n\t */\n\tenable: () => Promise;\n\tgetContext: (rootCommandName: CommandName) => Context;\n\tgetMetadata: (rootCommandName: CommandName) => CommandMetadata;\n};\n\nexport const getCommandController = (\n\tname: CommandName,\n) => {\n\tconst controller = commandControllerCollection[name];\n\n\tif (!controller) {\n\t\tthrow new Error(\n\t\t\t`No controller has been set for the \\`${name}\\` command.\\nHave you run the \\`termost\\` constructor?`,\n\t\t);\n\t}\n\n\treturn controller as CommandController;\n};\n\nexport const createCommandController = (\n\tname: CommandName,\n\tdescription: CommandMetadata[\"description\"],\n) => {\n\tconst instructions = createQueue();\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\tlet context = {} as Context;\n\n\tconst metadata: CommandMetadata = {\n\t\tdescription,\n\t\toptions: {\n\t\t\t\"-h, --help\": \"Display the help center\",\n\t\t\t\"-v, --version\": \"Print the version\",\n\t\t},\n\t};\n\n\tconst controller: CommandController = {\n\t\taddInstruction(instruction) {\n\t\t\tinstructions.enqueue(instruction);\n\t\t},\n\t\taddOptionDescription(key, value) {\n\t\t\tmetadata.options[key] = value;\n\t\t},\n\t\taddValue(key, value) {\n\t\t\tcontext[key] = value;\n\t\t},\n\t\tasync enable() {\n\t\t\twhile (!instructions.isEmpty()) {\n\t\t\t\tconst task = instructions.dequeue();\n\n\t\t\t\tif (task) {\n\t\t\t\t\tawait task();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tgetContext(rootCommandName) {\n\t\t\t// @note: By design, global values are accessible to subcommands\n\t\t\t// Consequently, root command values are merged with the current command ones:\n\t\t\tif (name !== rootCommandName) {\n\t\t\t\tconst rootController = getCommandController(rootCommandName);\n\n\t\t\t\tconst globalContext =\n\t\t\t\t\trootController.getContext(rootCommandName);\n\n\t\t\t\tcontext = {\n\t\t\t\t\t...globalContext,\n\t\t\t\t\t...context,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn context;\n\t\t},\n\t\tgetMetadata(rootCommandName) {\n\t\t\tif (name !== rootCommandName) {\n\t\t\t\tconst globalMetadata =\n\t\t\t\t\tgetCommandController(rootCommandName).getMetadata(\n\t\t\t\t\t\trootCommandName,\n\t\t\t\t\t);\n\n\t\t\t\tmetadata.options = {\n\t\t\t\t\t...globalMetadata.options,\n\t\t\t\t\t...metadata.options,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn metadata;\n\t\t},\n\t};\n\n\tcommandDescriptionCollection[name] = description;\n\tcommandControllerCollection[name] = controller;\n\n\treturn controller;\n};\n\nexport const getCommandDescriptionCollection = () => {\n\treturn commandDescriptionCollection;\n};\n\ntype CommandMetadata = {\n\tdescription: string;\n\toptions: Record;\n};\n\ntype Instruction = () => Promise;\n\nconst commandControllerCollection: Record<\n\tCommandName,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tCommandController\n> = {};\n\nconst commandDescriptionCollection: Record<\n\tCommandName,\n\tCommandMetadata[\"description\"]\n> = {};\n", "/* eslint-disable sonarjs/cognitive-complexity */\nimport { format } from \"../../helpers/stdout\";\nimport type { ObjectLikeConstraint, ProgramMetadata } from \"../../types\";\n\nimport {\n\tcreateCommandController,\n\tgetCommandController,\n\tgetCommandDescriptionCollection,\n} from \"./controller\";\nimport type { CommandController } from \"./controller\";\n\nexport type CommandParameters = {\n\tname: string;\n\tdescription: string;\n};\n\nexport const createCommand = (\n\t{ name, description }: CommandParameters,\n\t{ name: rootCommandName, argv, version }: ProgramMetadata,\n) => {\n\tconst isRootCommand = name === rootCommandName;\n\tconst isActiveCommand = argv.command === name;\n\tconst controller = createCommandController(name, description);\n\tconst rootController = getCommandController(rootCommandName);\n\n\tsetTimeout(() => {\n\t\t// @note: By design, the root command instructions are always executed\n\t\t// even with subcommands (to share options, messages...)\n\t\tif (isRootCommand && !isActiveCommand) {\n\t\t\tvoid rootController.enable();\n\t\t}\n\n\t\t// @note: enable the current active command instructions:\n\t\tif (isActiveCommand) {\n\t\t\t// @note: setTimeout 0 allows to run activation logic in the next event loop iteration.\n\t\t\t// It'll allow to make sure that the `metadata` is correctly filled with all commands\n\t\t\t// metadata (especially to let the global help option to display all available commands):\n\t\t\tconst optionKeys = Object.keys(argv.options);\n\n\t\t\tif (\n\t\t\t\toptionKeys.includes(OPTION_HELP_NAMES[0]) ||\n\t\t\t\toptionKeys.includes(OPTION_HELP_NAMES[1])\n\t\t\t) {\n\t\t\t\tshowHelp({\n\t\t\t\t\tcontroller,\n\t\t\t\t\tcurrentCommandName: name,\n\t\t\t\t\tisRootCommand,\n\t\t\t\t\trootCommandName,\n\t\t\t\t});\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\toptionKeys.includes(OPTION_VERSION_NAMES[0]) ||\n\t\t\t\toptionKeys.includes(OPTION_VERSION_NAMES[1])\n\t\t\t) {\n\t\t\t\tconsole.info(version);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvoid controller.enable();\n\t\t}\n\t}, 0);\n\n\treturn name;\n};\n\nconst OPTION_HELP_NAMES = [\"help\", \"h\"] as const;\nconst OPTION_VERSION_NAMES = [\"version\", \"v\"] as const;\n\nconst showHelp = ({\n\tcontroller,\n\tcurrentCommandName,\n\tisRootCommand,\n\trootCommandName,\n}: {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcontroller: CommandController;\n\tcurrentCommandName: string;\n\tisRootCommand: boolean;\n\trootCommandName: string;\n}) => {\n\tconst commandMetadata = controller.getMetadata(rootCommandName);\n\tconst { description, options } = commandMetadata;\n\tconst commands = getCommandDescriptionCollection();\n\tconst optionKeys = Object.keys(commandMetadata.options);\n\tconst commandKeys = Object.keys(commands);\n\tconst hasOptions = optionKeys.length > 0;\n\tconst hasCommands = isRootCommand && commandKeys.length > 1;\n\n\tprintTitle(\"Usage\");\n\tprint(\n\t\t`${format(\n\t\t\t`${rootCommandName}${\n\t\t\t\tisRootCommand ? \"\" : ` ${String(currentCommandName)}`\n\t\t\t}`,\n\t\t\t{\n\t\t\t\tcolor: \"green\",\n\t\t\t},\n\t\t)} ${hasCommands ? \" \" : \"\"}${\n\t\t\thasOptions ? \"[...options]\" : \"\"\n\t\t}`,\n\t);\n\n\tif (description) {\n\t\tprintTitle(\"Description\");\n\t\tprint(description);\n\t}\n\n\tconst padding = [...commandKeys, ...optionKeys].reduce((value, item) => {\n\t\treturn Math.max(value, item.length);\n\t}, 0);\n\n\tif (hasCommands) {\n\t\tprintTitle(\"Commands\");\n\n\t\tfor (const name of commandKeys) {\n\t\t\tif (name === rootCommandName) continue;\n\n\t\t\tconst commandDescription = commands[name];\n\n\t\t\tif (commandDescription)\n\t\t\t\tprintLabelValue(name, commandDescription, padding);\n\t\t}\n\t}\n\n\tif (hasOptions) {\n\t\tprintTitle(\"Options\");\n\n\t\tfor (const key of optionKeys) {\n\t\t\tprintLabelValue(key, options[key] as string, padding);\n\t\t}\n\t}\n};\n\nconst print = (...parameters: Parameters) => {\n\tconsole.log(format(...parameters));\n};\n\nconst printTitle = (message: string) => {\n\tprint(`\\n${message}:`, {\n\t\tcolor: \"yellow\",\n\t\tmodifiers: [\"bold\", \"underline\", \"uppercase\"],\n\t});\n};\n\nconst printLabelValue = (label: string, value: string, padding: number) => {\n\tprint(\n\t\t` ${format(label.padEnd(padding + 1, \" \"), {\n\t\t\tcolor: \"green\",\n\t\t})} ${value}`,\n\t);\n};\n", "/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { prompt } from \"enquirer\";\n\nimport type {\n\tCreateInstruction,\n\tInstructionKey,\n\tInstructionParameters,\n\tLabel,\n\tObjectLikeConstraint,\n} from \"../../types\";\n\nexport const createInput: CreateInstruction<\n\tInputParameters\n> = (parameters) => {\n\tconst { key, label, defaultValue, type } = parameters;\n\n\treturn async function execute(context, argv) {\n\t\tconst promptObject: Parameters[0] & {\n\t\t\tchoices?: { title: string; selected?: boolean; value: string }[];\n\t\t} = {\n\t\t\tname: key,\n\t\t\tinitial: defaultValue,\n\t\t\tmessage: typeof label === \"function\" ? label(context, argv) : label,\n\t\t\ttype,\n\t\t};\n\n\t\tif (parameters.type === \"select\" || parameters.type === \"multiselect\") {\n\t\t\tconst isMultiSelect = parameters.type === \"multiselect\";\n\t\t\tconst options = parameters.options as string[];\n\n\t\t\tconst choices = options.map((option) => ({\n\t\t\t\ttitle: option,\n\t\t\t\tvalue: option,\n\t\t\t\t...(isMultiSelect && {\n\t\t\t\t\tselected: ((defaultValue || []) as string[]).includes(\n\t\t\t\t\t\toption,\n\t\t\t\t\t),\n\t\t\t\t}),\n\t\t\t}));\n\n\t\t\tpromptObject.choices = choices;\n\t\t}\n\n\t\tconst data = await prompt(promptObject);\n\n\t\treturn { key, value: data[key] };\n\t};\n};\n\nexport type InputParameters<\n\tValues extends ObjectLikeConstraint,\n\tKey extends keyof Values,\n> = InstructionParameters<\n\tValues,\n\tInstructionKey &\n\t\t(\n\t\t\t| {\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\tdefaultValue?: Values[Key] extends boolean\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t\t\ttype: \"confirm\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\tdefaultValue?: Values[Key] extends string\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t\t\toptions: Values[Key] extends string ? Values[Key][] : never;\n\t\t\t\t\ttype: \"select\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\tdefaultValue?: Values[Key] extends string\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t\t\ttype: \"text\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\tdefaultValue?: Values[Key] extends string[]\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t\t\toptions: Values[Key] extends string[] ? Values[Key] : never;\n\t\t\t\t\ttype: \"multiselect\";\n\t\t\t }\n\t\t)\n>;\n", "/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport type {\n\tCreateInstruction,\n\tInstructionKey,\n\tInstructionParameters,\n\tObjectLikeConstraint,\n\tProgramMetadata,\n} from \"../../types\";\nimport type { CommandController } from \"../command\";\n\nexport const createOption =\n\t(\n\t\tcommandController: CommandController,\n\t\t{ argv }: ProgramMetadata,\n\t): CreateInstruction<\n\t\tOptionParameters\n\t> =>\n\t(parameters) => {\n\t\tconst { key, name, description, defaultValue } = parameters;\n\n\t\tconst aliases =\n\t\t\ttypeof name === \"string\" ? [name] : [name.short, name.long];\n\n\t\tconst metadataKey = aliases\n\t\t\t.map(\n\t\t\t\t(alias, index) =>\n\t\t\t\t\t\"-\".repeat(aliases.length > 1 ? index + 1 : 2) + alias,\n\t\t\t)\n\t\t\t.join(\", \");\n\n\t\tcommandController.addOptionDescription(metadataKey, description);\n\n\t\treturn async function execute() {\n\t\t\tlet value: unknown;\n\n\t\t\tfor (const alias of aliases) {\n\t\t\t\tif (alias in argv.options) {\n\t\t\t\t\tvalue = argv.options[alias];\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn Promise.resolve({ key, value: value ?? defaultValue });\n\t\t};\n\t};\n\nexport type OptionParameters<\n\tValues extends ObjectLikeConstraint,\n\tKey extends keyof Values,\n> = InstructionParameters<\n\tValues,\n\tInstructionKey & {\n\t\tname: string | { long: string; short: string };\n\t\tdescription: string;\n\t\tdefaultValue?: Values[Key];\n\t}\n>;\n", "import { Listr, PRESET_TIMER } from \"listr2\";\n\nimport type {\n\tArgumentValues,\n\tContext,\n\tCreateInstruction,\n\tInstructionKey,\n\tInstructionParameters,\n\tLabel,\n\tObjectLikeConstraint,\n} from \"../../types\";\n\nexport const createTask: CreateInstruction<\n\tTaskParameters\n> = (parameters) => {\n\tconst { key, label, handler } = parameters;\n\n\tconst receiver = label\n\t\t? new Listr([], {\n\t\t\t\trendererOptions: {\n\t\t\t\t\tcollapseErrors: false,\n\t\t\t\t\tformatOutput: \"wrap\",\n\t\t\t\t\tshowErrorMessage: true,\n\t\t\t\t\ttimer: PRESET_TIMER,\n\t\t\t\t},\n\t\t })\n\t\t: null;\n\n\treturn async function execute(context, argv) {\n\t\tlet value: unknown;\n\n\t\tif (!receiver) {\n\t\t\tvalue = await handler(context, argv);\n\t\t} else {\n\t\t\treceiver.add({\n\t\t\t\t...(label && {\n\t\t\t\t\ttitle:\n\t\t\t\t\t\ttypeof label === \"function\"\n\t\t\t\t\t\t\t? label(context, argv)\n\t\t\t\t\t\t\t: label,\n\t\t\t\t}),\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\t\ttask: async () => (value = await handler(context, argv)),\n\t\t\t});\n\n\t\t\tawait receiver.run();\n\t\t}\n\n\t\treturn { key, value };\n\t};\n};\n\nexport type TaskParameters<\n\tValues extends ObjectLikeConstraint,\n\tKey extends keyof Values | undefined = undefined,\n> = InstructionParameters<\n\tValues,\n\tPartial> & {\n\t\tlabel?: Label;\n\t\thandler: (\n\t\t\tcontext: Context,\n\t\t\targv: ArgumentValues,\n\t\t) => Key extends keyof Values\n\t\t\t? Promise | Values[Key]\n\t\t\t: Promise | void;\n\t}\n>;\n", "import fs from \"fs\";\nimport path from \"path\";\n\nimport type { PackageMetadata } from \"../../types\";\n\nexport const findNearestPackageJson = (pathname: string): PackageMetadata => {\n\tconst packagePathname = path.resolve(pathname, \"package.json\");\n\n\tif (isFileExists(packagePathname)) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-var-requires\n\t\treturn require(packagePathname) as PackageMetadata;\n\t}\n\n\treturn findNearestPackageJson(path.resolve(pathname, \"..\"));\n};\n\nconst isFileExists = (pathname: string) => {\n\ttry {\n\t\tfs.accessSync(pathname, fs.constants.F_OK);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nexport const getPackageMetadata = () => {\n\tconst mainFilename = require.main?.filename;\n\n\tif (!mainFilename) {\n\t\tthrow new Error(\n\t\t\t\"Termost was unable to retrieve automatically the package name and version. To fix it, use `termost({ name, description, version })` to define them manually.\",\n\t\t);\n\t}\n\n\treturn findNearestPackageJson(path.dirname(mainFilename));\n};\n", "// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const getArguments = () => {\n\tconst parameters = process.argv.slice(2);\n\tlet command: string | undefined;\n\tconst operands: string[] = [];\n\tconst options: Record = {};\n\tlet currentOptionName: string | undefined;\n\n\tconst addOptimisticOption = (name: string, value?: boolean | string) => {\n\t\tif (value) {\n\t\t\toptions[name] = typeof value === \"string\" ? castValue(value) : true;\n\t\t} else {\n\t\t\tcurrentOptionName = name;\n\t\t}\n\t};\n\n\tconst flushOptimisticOption = () => {\n\t\tif (currentOptionName) {\n\t\t\toptions[currentOptionName] = true;\n\t\t\tcurrentOptionName = undefined;\n\t\t}\n\t};\n\n\tfor (const parameter of parameters) {\n\t\tconst shortFlagMatchResult = SHORT_FLAG_REGEX.exec(parameter)?.groups;\n\t\tconst longFlagMatchResult = LONG_FLAG_REGEX.exec(parameter)?.groups;\n\n\t\tif (shortFlagMatchResult?.name) {\n\t\t\tflushOptimisticOption();\n\n\t\t\tconst optionFlags = shortFlagMatchResult.name.split(\"\");\n\t\t\tconst lastIndex = optionFlags.length - 1;\n\n\t\t\toptionFlags.forEach((flag, index) => {\n\t\t\t\taddOptimisticOption(\n\t\t\t\t\tflag,\n\t\t\t\t\tlastIndex === index ? undefined : true,\n\t\t\t\t);\n\t\t\t});\n\t\t} else if (longFlagMatchResult?.name) {\n\t\t\tflushOptimisticOption();\n\t\t\taddOptimisticOption(\n\t\t\t\tlongFlagMatchResult.name,\n\t\t\t\tlongFlagMatchResult.value,\n\t\t\t);\n\t\t} else if (currentOptionName) {\n\t\t\toptions[currentOptionName] = castValue(parameter);\n\t\t\tcurrentOptionName = undefined;\n\t\t} else if (!command) {\n\t\t\tcommand = parameter;\n\t\t} else {\n\t\t\toperands.push(parameter);\n\t\t}\n\t}\n\n\tflushOptimisticOption();\n\n\treturn { command, operands, options };\n};\n\nconst SHORT_FLAG_REGEX = /^-(?(?!-).*)$/;\nconst LONG_FLAG_REGEX = /^--(?.*?)(?:=(?.+))?$/;\n\nconst castValue = (value: string) => {\n\ttry {\n\t\treturn JSON.parse(value) as boolean | number | string;\n\t} catch {\n\t\treturn value;\n\t}\n};\n", "import { createCommand, getCommandController } from \"./api/command\";\nimport type { CommandParameters } from \"./api/command\";\nimport { createInput } from \"./api/input\";\nimport type { InputParameters } from \"./api/input\";\nimport { createOption } from \"./api/option\";\nimport type { OptionParameters } from \"./api/option\";\nimport { createTask } from \"./api/task\";\nimport type { TaskParameters } from \"./api/task\";\nimport { getPackageMetadata } from \"./helpers/package\";\nimport { getArguments } from \"./helpers/stdin\";\nimport type {\n\tCommandName,\n\tCreateInstruction,\n\tEmptyObject,\n\tInstructionParameters,\n\tObjectLikeConstraint,\n\tPackageMetadata,\n\tProgramMetadata,\n} from \"./types\";\n\n/**\n * The termost fluent interface API\n */\nexport type Termost = {\n\t/**\n\t * Allows to attach a new sub-command to the program\n\t * @param name - The CLI command name\n\t * @param description - The CLI command description\n\t * @returns The Command API\n\t */\n\tcommand: (\n\t\tparams: CommandParameters,\n\t) => Termost;\n\tinput: (\n\t\tparams: InputParameters,\n\t) => Termost;\n\toption: (\n\t\tparams: OptionParameters,\n\t) => Termost;\n\ttask: (\n\t\tparams: TaskParameters,\n\t) => Termost;\n};\n\nexport function termost(\n\tmetadata: Partial | string,\n\tcallbacks: TerminationCallbacks = {},\n) {\n\tlet { name, description, version } = isObject(metadata)\n\t\t? metadata\n\t\t: {\n\t\t\t\tname: undefined,\n\t\t\t\tdescription: metadata,\n\t\t\t\tversion: undefined,\n\t\t };\n\n\tif (\n\t\tname === undefined ||\n\t\tdescription === undefined ||\n\t\tversion === undefined\n\t) {\n\t\tconst packageMetadata = getPackageMetadata();\n\n\t\tname ??= packageMetadata.name;\n\t\tdescription ??= packageMetadata.description;\n\t\tversion ??= packageMetadata.version;\n\t}\n\n\tconst { command = name, operands, options } = getArguments();\n\n\tsetGracefulListeners(callbacks);\n\n\treturn createProgram({\n\t\tname,\n\t\tdescription,\n\t\targv: { command, operands, options },\n\t\tversion,\n\t});\n}\n\nexport const createProgram = (\n\tmetadata: ProgramMetadata,\n): Termost => {\n\tconst { name, description, argv } = metadata;\n\tconst rootCommandName: CommandName = name;\n\tlet currentCommandName: CommandName = rootCommandName;\n\n\tconst createInstruction = <\n\t\tParameters extends InstructionParameters,\n\t>(\n\t\tfactory: CreateInstruction,\n\t\tparams: InstructionParameters,\n\t) => {\n\t\tconst instruction = factory(params as Parameters);\n\t\tconst controller = getCommandController(currentCommandName);\n\n\t\tcontroller.addInstruction(async () => {\n\t\t\tconst { skip } = params;\n\t\t\tconst context = controller.getContext(rootCommandName);\n\n\t\t\tif (skip?.(context, argv)) return;\n\n\t\t\tconst output = await instruction(context, argv);\n\n\t\t\tif (!output || !output.key) return;\n\n\t\t\tcontroller.addValue(\n\t\t\t\toutput.key,\n\t\t\t\toutput.value as Values[keyof Values],\n\t\t\t);\n\t\t});\n\t};\n\n\tconst program: Termost = {\n\t\tcommand(params: CommandParameters) {\n\t\t\tcurrentCommandName = createCommand(params, metadata);\n\n\t\t\treturn this as Termost;\n\t\t},\n\t\tinput(params) {\n\t\t\tcreateInstruction(createInput, params);\n\n\t\t\treturn this;\n\t\t},\n\t\toption(params) {\n\t\t\tcreateInstruction(\n\t\t\t\tcreateOption(\n\t\t\t\t\tgetCommandController(currentCommandName),\n\t\t\t\t\tmetadata,\n\t\t\t\t),\n\t\t\t\tparams,\n\t\t\t);\n\n\t\t\treturn this;\n\t\t},\n\t\ttask(params) {\n\t\t\tcreateInstruction(createTask, params);\n\n\t\t\treturn this;\n\t\t},\n\t};\n\n\t// @note: the root command is created by default\n\tprogram.command({\n\t\tname,\n\t\tdescription,\n\t});\n\n\treturn program;\n};\n\ntype TerminationCallbacks = Partial<{\n\tonException: (error: Error) => void;\n\tonShutdown: () => void;\n}>;\n\nconst setGracefulListeners = ({\n\tonException = () => {\n\t\treturn;\n\t},\n\tonShutdown = () => {\n\t\treturn;\n\t},\n}: TerminationCallbacks) => {\n\tprocess.on(\"SIGTERM\", () => {\n\t\tonShutdown();\n\t\tprocess.exit(0);\n\t});\n\n\tprocess.on(\"SIGINT\", () => {\n\t\tonShutdown();\n\t\tprocess.exit(0);\n\t});\n\n\tprocess.on(\"uncaughtException\", (error) => {\n\t\tonException(error);\n\t\tprocess.exit(1);\n\t});\n\n\tprocess.on(\"unhandledRejection\", (reason) => {\n\t\tif (reason instanceof Error) {\n\t\t\tonException(reason);\n\t\t}\n\n\t\tprocess.exit(1);\n\t});\n};\n\nconst isObject = (value: unknown): value is ObjectLikeConstraint => {\n\treturn value !== null && typeof value === \"object\";\n};\n"], -+ "mappings": "0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,GAAA,YAAAC,IAAA,eAAAC,EAAAJ,ICAA,IAAAK,EAAsB,yBAETC,EAAO,MACnBC,EACAC,EAAuB,CAAE,cAAe,EAAM,IAEvC,IAAI,QAAgB,CAACC,EAASC,IAAW,CAC/C,IAAIC,EAAS,GACTC,EAAS,GACP,CAACC,EAAK,GAAGC,CAAI,EAAIP,EAAQ,MAAM,GAAG,EAElCQ,KAAe,SAAMF,EAAKC,EAAM,CACrC,IAAKN,EAAQ,IACb,IAAK,CACJ,GAAG,QAAQ,IAEX,YAAa,GACd,EACA,MAAO,GACP,MAAOA,EAAQ,cAAgB,UAAY,MAC5C,CAAC,EAEDO,EAAa,QAAQ,GAAG,OAASC,GAAU,CAC1CL,GAAUK,CACX,CAAC,EAEDD,EAAa,QAAQ,GAAG,OAASC,GAAU,CAC1CJ,GAAUI,CACX,CAAC,EAEDD,EAAa,GAAG,QAAUE,GAAa,CACtC,GAAIA,IAAa,EAAG,CACnB,IAAMC,EAAS,GAAGN,IAASD,IAE3BD,EAAOQ,EAAO,KAAK,CAAC,OAEpBT,EAAQE,EAAO,KAAK,CAAC,CAEvB,CAAC,CACF,CAAC,ECvCF,IAAAQ,EAAiB,yBAQJC,EAAS,CACrBC,EACA,CACC,MAAAC,EACA,UAAAC,CACD,EAGI,CACH,MAAO,QACP,UAAW,CAAC,CACb,IACI,CACJ,IAAMC,EAA8C,CAAC,EAErD,OAAAA,EAAa,KAAK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C,GAAU,CAC1CF,EAAYE,CAAK,EACjB,QAAQ,KAAK,CAAC,CACf,CAAC,EAED,QAAQ,GAAG,qBAAuBC,GAAW,CACxCA,aAAkB,OACrBH,EAAYG,CAAM,EAGnB,QAAQ,KAAK,CAAC,CACf,CAAC,CACF,EAEM7B,GAAY8B,GACVA,IAAU,MAAQ,OAAOA,GAAU,SXxLpC,IAAMC,GAAU,CACtB,KAAAC,EACA,OAAAC,EACA,QAAAC,CACD", -+ "names": ["src_exports", "__export", "helpers", "termost", "__toCommonJS", "import_child_process", "exec", "command", "options", "resolve", "reject", "stdout", "stderr", "bin", "args", "childProcess", "chunk", "exitCode", "output", "import_picocolors", "format", "message", "color", "modifiers", "transformers", "pico", "colorMapper", "mod", "modifierMapper", "compose", "fns", "prevFn", "nextFn", "value", "content", "label", "type", "defaultLabel", "icon", "method", "formatPropertiesByType", "messages", "msg", "createQueue", "items", "item", "getCommandController", "name", "controller", "commandControllerCollection", "createCommandController", "description", "instructions", "createQueue", "context", "metadata", "instruction", "key", "value", "task", "rootCommandName", "globalMetadata", "commandDescriptionCollection", "getCommandDescriptionCollection", "createCommand", "name", "description", "rootCommandName", "argv", "version", "isRootCommand", "isActiveCommand", "controller", "createCommandController", "rootController", "getCommandController", "optionKeys", "OPTION_HELP_NAMES", "showHelp", "OPTION_VERSION_NAMES", "currentCommandName", "commandMetadata", "options", "commands", "getCommandDescriptionCollection", "commandKeys", "hasOptions", "hasCommands", "printTitle", "print", "format", "padding", "value", "item", "commandDescription", "printLabelValue", "key", "parameters", "message", "label", "import_enquirer", "createInput", "parameters", "key", "label", "defaultValue", "type", "context", "argv", "promptObject", "isMultiSelect", "choices", "option", "data", "createOption", "commandController", "argv", "parameters", "key", "name", "description", "defaultValue", "aliases", "metadataKey", "alias", "index", "value", "import_listr2", "createTask", "parameters", "key", "label", "handler", "receiver", "context", "argv", "value", "import_fs", "import_path", "findNearestPackageJson", "pathname", "packagePathname", "path", "isFileExists", "fs", "getPackageMetadata", "mainFilename", "getArguments", "parameters", "command", "operands", "options", "currentOptionName", "addOptimisticOption", "name", "value", "castValue", "flushOptimisticOption", "parameter", "shortFlagMatchResult", "SHORT_FLAG_REGEX", "longFlagMatchResult", "LONG_FLAG_REGEX", "optionFlags", "lastIndex", "flag", "index", "termost", "metadata", "callbacks", "name", "description", "version", "isObject", "packageMetadata", "getPackageMetadata", "command", "operands", "options", "getArguments", "setGracefulListeners", "createProgram", "argv", "rootCommandName", "currentCommandName", "createInstruction", "factory", "params", "instruction", "controller", "getCommandController", "skip", "context", "output", "program", "createCommand", "createInput", "createOption", "createTask", "onException", "onShutdown", "error", "reason", "value", "helpers", "exec", "format", "message"] - } -diff --git a/node_modules/termost/dist/index.d.ts b/node_modules/termost/dist/index.d.ts -index 4fc7d15..c8befdd 100644 ---- a/node_modules/termost/dist/index.d.ts -+++ b/node_modules/termost/dist/index.d.ts -@@ -6,13 +6,13 @@ export type EmptyObject = {}; - */ - export type ArgumentValues = { - command: CommandName; -- options: Record; - operands: string[]; -+ options: Record; - }; - export type PackageMetadata = { - name: string; -- version: string; - description: string; -+ version: string; - }; - export type Context = Values; - export type InstructionParameters = ExtraParameters & { -@@ -31,23 +31,23 @@ export type CommandParameters = { - description: string; - }; - export type InputParameters = InstructionParameters & ({ -- type: "confirm"; - label: Label; - defaultValue?: Values[Key] extends boolean ? Values[Key] : never; -+ type: "confirm"; - } | { -- type: "multiselect"; - label: Label; -- options: Values[Key] extends string[] ? Values[Key] : never; -- defaultValue?: Values[Key] extends string[] ? Values[Key] : never; --} | { -+ defaultValue?: Values[Key] extends string ? Values[Key] : never; -+ options: Values[Key] extends string ? Values[Key][] : never; - type: "select"; -+} | { - label: Label; -- options: Values[Key] extends string ? Values[Key][] : never; - defaultValue?: Values[Key] extends string ? Values[Key] : never; --} | { - type: "text"; -+} | { - label: Label; -- defaultValue?: Values[Key] extends string ? Values[Key] : never; -+ defaultValue?: Values[Key] extends string[] ? Values[Key] : never; -+ options: Values[Key] extends string[] ? Values[Key] : never; -+ type: "multiselect"; - })>; - export type OptionParameters = InstructionParameters & { - name: string | { -@@ -78,8 +78,8 @@ export type Termost = { - }; - export declare function termost(metadata: Partial | string, callbacks?: TerminationCallbacks): Termost; - export type TerminationCallbacks = Partial<{ -- onShutdown: () => void; - onException: (error: Error) => void; -+ onShutdown: () => void; - }>; - export declare const helpers: { - exec: (command: string, options?: { -@@ -91,8 +91,8 @@ export declare const helpers: { - modifiers?: ("bold" | "italic" | "lowercase" | "strikethrough" | "underline" | "uppercase")[]; - }) => string; - message: (content: string | string[], { label, type, }?: { -- type?: "error" | "information" | "success" | "warning"; - label?: string; -+ type?: "error" | "information" | "success" | "warning"; - }) => void; - }; - -diff --git a/node_modules/termost/dist/index.mjs b/node_modules/termost/dist/index.mjs -index ae1fb10..28fbfac 100644 ---- a/node_modules/termost/dist/index.mjs -+++ b/node_modules/termost/dist/index.mjs -@@ -1,5 +1,5 @@ --var k=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,o)=>(typeof require<"u"?require:t)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});import{spawn as F}from"child_process";var V=async(e,t={hasLiveOutput:!1})=>new Promise((o,s)=>{let r="",l="",[n,...a]=e.split(" "),i=F(n,a,{cwd:t.cwd,shell:!0,stdio:t.hasLiveOutput?"inherit":"pipe",env:{...process.env,FORCE_COLOR:"1"}});i.stdout?.on("data",c=>{r+=c}),i.stderr?.on("data",c=>{l+=c}),i.on("close",c=>{if(c!==0){let u=`${l}${r}`;s(u.trim())}else o(r.trim())})});import h from"picocolors";var y=(e,{color:t,modifiers:o}={color:"white",modifiers:[]})=>{let s=[];return s.push(h[H[t??"white"]]),(o??[]).forEach(r=>{r==="uppercase"?e=e.toUpperCase():r==="lowercase"?e=e.toLowerCase():s.push(h[J[r]])}),G(...s)(e)},G=(...e)=>e.reduce((t,o)=>s=>t(o(s)),e[0]),O=(e,{label:t,type:o="information"}={})=>{let{color:s,defaultLabel:r,icon:l,method:n}=q[o],a=typeof e=="string"?[e]:e;n(y(` --${l} ${t??r}`,{color:s,modifiers:["bold"]}));for(let i of a)n(y(` ${i}`,{color:s}))},q={error:{color:"red",defaultLabel:"Error",icon:"\u274C",method:console.error},information:{color:"blue",defaultLabel:"Information",icon:"\u2139\uFE0F ",method:console.info},success:{color:"green",defaultLabel:"Success",icon:"\u2705",method:console.log},warning:{color:"yellow",defaultLabel:"Warning",icon:"\u26A0\uFE0F ",method:console.warn}},H={black:"black",blue:"blue",cyan:"cyan",green:"green",grey:"gray",magenta:"magenta",red:"red",white:"white",yellow:"yellow"},J={bold:"bold",italic:"italic",strikethrough:"strikethrough",underline:"underline"};import P from"fs";import x from"path";var L=e=>{let t=x.resolve(e,"package.json");return Q(t)?k(t):L(x.resolve(e,".."))},Q=e=>{try{return P.accessSync(e,P.constants.F_OK),!0}catch{return!1}},I=()=>{let e=k.main?.filename;if(!e)throw new Error("Termost was unable to retrieve automatically the package name and version. To fix it, use `termost({ name, description, version })` to define them manually.");return L(x.dirname(e))};var M=()=>{let e=process.argv.slice(2),t,o=[],s={},r,l=(a,i)=>{i?s[a]=typeof i=="string"?v(i):!0:r=a},n=()=>{r&&(s[r]=!0,r=void 0)};for(let a of e){let i=U.exec(a)?.groups,c=X.exec(a)?.groups;if(i?.name){n();let u=i.name.split(""),p=u.length-1;u.forEach((f,m)=>{l(f,p===m?void 0:!0)})}else c?.name?(n(),l(c.name,c.value)):r?(s[r]=v(a),r=void 0):t?o.push(a):t=a}return n(),{command:t,operands:o,options:s}},U=/^-(?(?!-).*)$/,X=/^--(?.*?)(?:=(?.+))?$/,v=e=>{try{return JSON.parse(e)}catch{return e}};var K=()=>{let e=[];return{enqueue(t){e.push(t)},dequeue(){return e.shift()},isEmpty(){return e.length===0}}};var g=e=>{let t=T[e];if(!t)throw new Error(`No controller has been set for the \`${e}\` command. --Have you run the \`termost\` constructor?`);return t},j=(e,t)=>{let o=K(),s={},r={description:t,options:{"-h, --help":"Display the help center","-v, --version":"Print the version"}},l={addOptionDescription(n,a){r.options[n]=a},addValue(n,a){s[n]=a},addInstruction(n){o.enqueue(n)},async enable(){for(;!o.isEmpty();){let n=o.dequeue();n&&await n()}},getContext(n){return e!==n&&(s={...g(n).getContext(n),...s}),s},getMetadata(n){if(e!==n){let a=g(n).getMetadata(n);r.options={...a.options,...r.options}}return r}};return E[e]=t,T[e]=l,l},w=()=>E,T={},E={};var S=({name:e,description:t},{argv:o,name:s,version:r})=>{let l=e===s,n=o.command===e,a=j(e,t),i=g(s);return setTimeout(()=>{if(l&&!n&&i.enable(),n){let c=Object.keys(o.options);if(c.includes(N[0])||c.includes(N[1])){B({controller:a,currentCommandName:e,isRootCommand:l,rootCommandName:s});return}if(c.includes(R[0])||c.includes(R[1])){console.info(r);return}a.enable()}},0),e},N=["help","h"],R=["version","v"],B=({rootCommandName:e,currentCommandName:t,isRootCommand:o,controller:s})=>{let r=s.getMetadata(e),{options:l,description:n}=r,a=w(),i=Object.keys(r.options),c=Object.keys(a),u=i.length>0,p=o&&c.length>1;C("Usage"),b(`${y(`${e}${o?"":` ${String(t)}`}`,{color:"green"})} ${p?" ":""}${u?"[...options]":""}`),n&&(C("Description"),b(n));let f=[...c,...i].reduce((m,d)=>Math.max(m,d.length),0);if(p){C("Commands");for(let m of c){if(m===e)continue;let d=a[m];d&&$(m,d,f)}}if(u){C("Options");for(let m of i)$(m,l[m],f)}},b=(...e)=>{console.log(y(...e))},C=e=>{b(` --${e}:`,{color:"yellow",modifiers:["bold","underline","uppercase"]})},$=(e,t,o)=>{b(` ${y(e.padEnd(o+1," "),{color:"green"})} ${t}`)};import{prompt as W}from"enquirer";var _=e=>{let{key:t,defaultValue:o,label:s,type:r}=e;return async function(n,a){let i={initial:o,message:typeof s=="function"?s(n,a):s,name:t,type:r};if(e.type==="select"||e.type==="multiselect"){let u=e.type==="multiselect",f=e.options.map(m=>({title:m,value:m,...u&&{selected:(o||[]).includes(m)}}));i.choices=f}let c=await W(i);return{key:t,value:c[t]}}};var A=(e,{argv:t})=>o=>{let{key:s,name:r,description:l,defaultValue:n}=o,a=typeof r=="string"?[r]:[r.short,r.long],i=a.map((c,u)=>"-".repeat(a.length>1?u+1:2)+c).join(", ");return e.addOptionDescription(i,l),async function(){let u;for(let p of a)if(p in t.options){u=t.options[p];break}return Promise.resolve({key:s,value:u??n})}};import{Listr as z,PRESET_TIMER as Y}from"listr2";var D=e=>{let{key:t,label:o,handler:s}=e,r=o?new z([],{rendererOptions:{collapseErrors:!1,formatOutput:"wrap",showErrorMessage:!0,timer:Y}}):null;return async function(n,a){let i;return r?(r.add({...o&&{title:typeof o=="function"?o(n,a):o},task:async()=>i=await s(n,a)}),await r.run()):i=await s(n,a),{key:t,value:i}}};function Z(e,t={}){let o=oe(e)?e:{description:e},s=I(),r=o.name??s.name,{command:l=r,options:n,operands:a}=M();return te(t),ee({argv:{command:l,options:n,operands:a},description:o.description??s.description,name:r,version:o.version??s.version})}var ee=e=>{let{argv:t,name:o,description:s}=e,r=o,l=r,n=(i,c)=>{let u=i(c),p=g(l);p.addInstruction(async()=>{let{skip:f}=c,m=p.getContext(r);if(f?.(m,t))return;let d=await u(m,t);!d||!d.key||p.addValue(d.key,d.value)})},a={command(i){return l=S(i,e),this},input(i){return n(_,i),this},option(i){return n(A(g(l),e),i),this},task(i){return n(D,i),this}};return a.command({name:o,description:s}),a},te=({onShutdown:e=()=>{},onException:t=()=>{}})=>{process.on("SIGTERM",()=>{e(),process.exit(0)}),process.on("SIGINT",()=>{e(),process.exit(0)}),process.on("uncaughtException",o=>{t(o),process.exit(1)}),process.on("unhandledRejection",o=>{o instanceof Error&&t(o),process.exit(1)})},oe=e=>e!==null&&typeof e=="object";var Ee={exec:V,format:y,message:O};export{Ee as helpers,Z as termost}; -+var k=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,t)=>(typeof require<"u"?require:n)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});import{spawn as F}from"child_process";var V=async(e,n={hasLiveOutput:!1})=>new Promise((t,s)=>{let o="",c="",[r,...i]=e.split(" "),a=F(r,i,{cwd:n.cwd,env:{...process.env,FORCE_COLOR:"1"},shell:!0,stdio:n.hasLiveOutput?"inherit":"pipe"});a.stdout?.on("data",l=>{o+=l}),a.stderr?.on("data",l=>{c+=l}),a.on("close",l=>{if(l!==0){let u=`${c}${o}`;s(u.trim())}else t(o.trim())})});import h from"picocolors";var y=(e,{color:n,modifiers:t}={color:"white",modifiers:[]})=>{let s=[];return s.push(h[H[n??"white"]]),(t??[]).forEach(o=>{o==="uppercase"?e=e.toUpperCase():o==="lowercase"?e=e.toLowerCase():s.push(h[J[o]])}),G(...s)(e)},G=(...e)=>e.reduce((n,t)=>s=>n(t(s)),e[0]),O=(e,{label:n,type:t="information"}={})=>{let{color:s,defaultLabel:o,icon:c,method:r}=q[t],i=typeof e=="string"?[e]:e;r(y(` -+${c} ${n??o}`,{color:s,modifiers:["bold"]}));for(let a of i)r(y(` ${a}`,{color:s}))},q={error:{color:"red",defaultLabel:"Error",icon:"\u274C",method:console.error},information:{color:"blue",defaultLabel:"Information",icon:"\u2139\uFE0F ",method:console.info},success:{color:"green",defaultLabel:"Success",icon:"\u2705",method:console.log},warning:{color:"yellow",defaultLabel:"Warning",icon:"\u26A0\uFE0F ",method:console.warn}},H={black:"black",blue:"blue",cyan:"cyan",green:"green",grey:"gray",magenta:"magenta",red:"red",white:"white",yellow:"yellow"},J={bold:"bold",italic:"italic",strikethrough:"strikethrough",underline:"underline"};var P=()=>{let e=[];return{dequeue(){return e.shift()},enqueue(n){e.push(n)},isEmpty(){return e.length===0}}};var g=e=>{let n=v[e];if(!n)throw new Error(`No controller has been set for the \`${e}\` command. -+Have you run the \`termost\` constructor?`);return n},L=(e,n)=>{let t=P(),s={},o={description:n,options:{"-h, --help":"Display the help center","-v, --version":"Print the version"}},c={addInstruction(r){t.enqueue(r)},addOptionDescription(r,i){o.options[r]=i},addValue(r,i){s[r]=i},async enable(){for(;!t.isEmpty();){let r=t.dequeue();r&&await r()}},getContext(r){return e!==r&&(s={...g(r).getContext(r),...s}),s},getMetadata(r){if(e!==r){let i=g(r).getMetadata(r);o.options={...i.options,...o.options}}return o}};return K[e]=n,v[e]=c,c},I=()=>K,v={},K={};var T=({name:e,description:n},{name:t,argv:s,version:o})=>{let c=e===t,r=s.command===e,i=L(e,n),a=g(t);return setTimeout(()=>{if(c&&!r&&a.enable(),r){let l=Object.keys(s.options);if(l.includes(j[0])||l.includes(j[1])){Q({controller:i,currentCommandName:e,isRootCommand:c,rootCommandName:t});return}if(l.includes(M[0])||l.includes(M[1])){console.info(o);return}i.enable()}},0),e},j=["help","h"],M=["version","v"],Q=({controller:e,currentCommandName:n,isRootCommand:t,rootCommandName:s})=>{let o=e.getMetadata(s),{description:c,options:r}=o,i=I(),a=Object.keys(o.options),l=Object.keys(i),u=a.length>0,p=t&&l.length>1;C("Usage"),b(`${y(`${s}${t?"":` ${String(n)}`}`,{color:"green"})} ${p?" ":""}${u?"[...options]":""}`),c&&(C("Description"),b(c));let f=[...l,...a].reduce((m,d)=>Math.max(m,d.length),0);if(p){C("Commands");for(let m of l){if(m===s)continue;let d=i[m];d&&w(m,d,f)}}if(u){C("Options");for(let m of a)w(m,r[m],f)}},b=(...e)=>{console.log(y(...e))},C=e=>{b(` -+${e}:`,{color:"yellow",modifiers:["bold","underline","uppercase"]})},w=(e,n,t)=>{b(` ${y(e.padEnd(t+1," "),{color:"green"})} ${n}`)};import{prompt as U}from"enquirer";var E=e=>{let{key:n,label:t,defaultValue:s,type:o}=e;return async function(r,i){let a={name:n,initial:s,message:typeof t=="function"?t(r,i):t,type:o};if(e.type==="select"||e.type==="multiselect"){let u=e.type==="multiselect",f=e.options.map(m=>({title:m,value:m,...u&&{selected:(s||[]).includes(m)}}));a.choices=f}let l=await U(a);return{key:n,value:l[n]}}};var N=(e,{argv:n})=>t=>{let{key:s,name:o,description:c,defaultValue:r}=t,i=typeof o=="string"?[o]:[o.short,o.long],a=i.map((l,u)=>"-".repeat(i.length>1?u+1:2)+l).join(", ");return e.addOptionDescription(a,c),async function(){let u;for(let p of i)if(p in n.options){u=n.options[p];break}return Promise.resolve({key:s,value:u??r})}};import{Listr as X,PRESET_TIMER as B}from"listr2";var R=e=>{let{key:n,label:t,handler:s}=e,o=t?new X([],{rendererOptions:{collapseErrors:!1,formatOutput:"wrap",showErrorMessage:!0,timer:B}}):null;return async function(r,i){let a;return o?(o.add({...t&&{title:typeof t=="function"?t(r,i):t},task:async()=>a=await s(r,i)}),await o.run()):a=await s(r,i),{key:n,value:a}}};import $ from"fs";import x from"path";var S=e=>{let n=x.resolve(e,"package.json");return W(n)?k(n):S(x.resolve(e,".."))},W=e=>{try{return $.accessSync(e,$.constants.F_OK),!0}catch{return!1}},_=()=>{let e=k.main?.filename;if(!e)throw new Error("Termost was unable to retrieve automatically the package name and version. To fix it, use `termost({ name, description, version })` to define them manually.");return S(x.dirname(e))};var D=()=>{let e=process.argv.slice(2),n,t=[],s={},o,c=(i,a)=>{a?s[i]=typeof a=="string"?A(a):!0:o=i},r=()=>{o&&(s[o]=!0,o=void 0)};for(let i of e){let a=z.exec(i)?.groups,l=Y.exec(i)?.groups;if(a?.name){r();let u=a.name.split(""),p=u.length-1;u.forEach((f,m)=>{c(f,p===m?void 0:!0)})}else l?.name?(r(),c(l.name,l.value)):o?(s[o]=A(i),o=void 0):n?t.push(i):n=i}return r(),{command:n,operands:t,options:s}},z=/^-(?(?!-).*)$/,Y=/^--(?.*?)(?:=(?.+))?$/,A=e=>{try{return JSON.parse(e)}catch{return e}};function Z(e,n={}){let{name:t,description:s,version:o}=ne(e)?e:{name:void 0,description:e,version:void 0};if(t===void 0||s===void 0||o===void 0){let a=_();t??(t=a.name),s??(s=a.description),o??(o=a.version)}let{command:c=t,operands:r,options:i}=D();return te(n),ee({name:t,description:s,argv:{command:c,operands:r,options:i},version:o})}var ee=e=>{let{name:n,description:t,argv:s}=e,o=n,c=o,r=(a,l)=>{let u=a(l),p=g(c);p.addInstruction(async()=>{let{skip:f}=l,m=p.getContext(o);if(f?.(m,s))return;let d=await u(m,s);!d||!d.key||p.addValue(d.key,d.value)})},i={command(a){return c=T(a,e),this},input(a){return r(E,a),this},option(a){return r(N(g(c),e),a),this},task(a){return r(R,a),this}};return i.command({name:n,description:t}),i},te=({onException:e=()=>{},onShutdown:n=()=>{}})=>{process.on("SIGTERM",()=>{n(),process.exit(0)}),process.on("SIGINT",()=>{n(),process.exit(0)}),process.on("uncaughtException",t=>{e(t),process.exit(1)}),process.on("unhandledRejection",t=>{t instanceof Error&&e(t),process.exit(1)})},ne=e=>e!==null&&typeof e=="object";var Ee={exec:V,format:y,message:O};export{Ee as helpers,Z as termost}; - //# sourceMappingURL=index.mjs.map -diff --git a/node_modules/termost/dist/index.mjs.map b/node_modules/termost/dist/index.mjs.map -index bfe0ab9..9901423 100644 ---- a/node_modules/termost/dist/index.mjs.map -+++ b/node_modules/termost/dist/index.mjs.map -@@ -1,7 +1,7 @@ - { - "version": 3, -- "sources": ["../src/helpers/process/index.ts", "../src/helpers/stdout/index.ts", "../src/helpers/package/index.ts", "../src/helpers/stdin/index.ts", "../src/api/command/controller/queue.ts", "../src/api/command/controller/index.ts", "../src/api/command/command.ts", "../src/api/input/index.ts", "../src/api/option/index.ts", "../src/api/task/index.ts", "../src/termost.ts", "../src/index.ts"], -- "sourcesContent": ["import { spawn } from \"child_process\";\n\nexport const exec = async (\n\tcommand: string,\n\toptions: ExecOptions = { hasLiveOutput: false },\n) => {\n\treturn new Promise((resolve, reject) => {\n\t\tlet stdout = \"\";\n\t\tlet stderr = \"\";\n\t\tconst [bin, ...args] = command.split(\" \") as [string, ...string[]];\n\n\t\tconst childProcess = spawn(bin, args, {\n\t\t\tcwd: options.cwd,\n\t\t\tshell: true,\n\t\t\tstdio: options.hasLiveOutput ? \"inherit\" : \"pipe\",\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t// @note: make sure to force color display for spawned processes\n\t\t\t\tFORCE_COLOR: \"1\",\n\t\t\t},\n\t\t});\n\n\t\tchildProcess.stdout?.on(\"data\", (chunk) => {\n\t\t\tstdout += chunk;\n\t\t});\n\n\t\tchildProcess.stderr?.on(\"data\", (chunk) => {\n\t\t\tstderr += chunk;\n\t\t});\n\n\t\tchildProcess.on(\"close\", (exitCode) => {\n\t\t\tif (exitCode !== 0) {\n\t\t\t\tconst output = `${stderr}${stdout}`;\n\n\t\t\t\treject(output.trim());\n\t\t\t} else {\n\t\t\t\tresolve(stdout.trim());\n\t\t\t}\n\t\t});\n\t});\n};\n\ntype ExecOptions = {\n\tcwd?: string;\n\thasLiveOutput?: boolean;\n};\n", "import pico from \"picocolors\";\n\n/**\n * A helper to format an arbitrary text as a message input\n * @param message The text to display\n * @param options The configuration object to control the formatting properties\n * @returns The formatted text\n */\nexport const format = (\n\tmessage: string,\n\t{\n\t\tcolor,\n\t\tmodifiers,\n\t}: {\n\t\tcolor?: Color;\n\t\tmodifiers?: Modifier[];\n\t} = {\n\t\tcolor: \"white\",\n\t\tmodifiers: [],\n\t},\n) => {\n\tconst transformers: ((input: string) => string)[] = [];\n\n\ttransformers.push(pico[colorMapper[color ?? \"white\"]]);\n\n\t(modifiers ?? []).forEach((mod: Modifier) => {\n\t\tif (mod === \"uppercase\") {\n\t\t\tmessage = message.toUpperCase();\n\t\t} else if (mod === \"lowercase\") {\n\t\t\tmessage = message.toLowerCase();\n\t\t} else {\n\t\t\ttransformers.push(pico[modifierMapper[mod]]);\n\t\t}\n\t});\n\n\treturn compose(...transformers)(message);\n};\n\nconst compose = (...fns: ((a: T) => T)[]) =>\n\tfns.reduce(\n\t\t(prevFn, nextFn) => (value) => prevFn(nextFn(value)),\n\t\tfns[0] as (a: T) => T,\n\t);\n\n/**\n * An opinionated helper to display arbitrary text on the console\n * @param message The text to display. Use an array if you need to display a message in several lines\n * @param options The configuration object to define the display type and/or override the default label\n */\nexport const message = (\n\tcontent: string[] | string,\n\t{\n\t\tlabel,\n\t\ttype = \"information\",\n\t}: { type?: MessageType; label?: string } = {},\n) => {\n\tconst { color, defaultLabel, icon, method } = formatPropertiesByType[type];\n\tconst messages = typeof content === \"string\" ? [content] : content;\n\n\tmethod(\n\t\tformat(`\\n${icon} ${label ?? defaultLabel}`, {\n\t\t\tcolor,\n\t\t\tmodifiers: [\"bold\"],\n\t\t}),\n\t);\n\n\tfor (const msg of messages) {\n\t\tmethod(format(` ${msg}`, { color }));\n\t}\n};\n\nconst formatPropertiesByType = {\n\terror: {\n\t\tcolor: \"red\",\n\t\tdefaultLabel: \"Error\",\n\t\ticon: \"\u274C\",\n\t\tmethod: console.error,\n\t},\n\tinformation: {\n\t\tcolor: \"blue\",\n\t\tdefaultLabel: \"Information\",\n\t\ticon: \"\u2139\uFE0F \",\n\t\tmethod: console.info,\n\t},\n\tsuccess: {\n\t\tcolor: \"green\",\n\t\tdefaultLabel: \"Success\",\n\t\ticon: \"\u2705\",\n\t\tmethod: console.log,\n\t},\n\twarning: {\n\t\tcolor: \"yellow\",\n\t\tdefaultLabel: \"Warning\",\n\t\ticon: \"\u26A0\uFE0F \",\n\t\tmethod: console.warn,\n\t},\n} as const;\n\nconst colorMapper = {\n\tblack: \"black\",\n\tblue: \"blue\",\n\tcyan: \"cyan\",\n\tgreen: \"green\",\n\tgrey: \"gray\",\n\tmagenta: \"magenta\",\n\tred: \"red\",\n\twhite: \"white\",\n\tyellow: \"yellow\",\n} as const;\n\nconst modifierMapper = {\n\tbold: \"bold\",\n\titalic: \"italic\",\n\tstrikethrough: \"strikethrough\",\n\tunderline: \"underline\",\n} as const;\n\ntype MessageType = \"error\" | \"information\" | \"success\" | \"warning\";\n\ntype Color =\n\t| \"black\"\n\t| \"blue\"\n\t| \"cyan\"\n\t| \"green\"\n\t| \"grey\"\n\t| \"magenta\"\n\t| \"red\"\n\t| \"white\"\n\t| \"yellow\";\n\ntype Modifier =\n\t| \"bold\"\n\t| \"italic\"\n\t| \"lowercase\"\n\t| \"strikethrough\"\n\t| \"underline\"\n\t| \"uppercase\";\n", "import fs from \"fs\";\nimport path from \"path\";\n\nimport type { PackageMetadata } from \"../../types\";\n\nexport const findNearestPackageJson = (pathname: string): PackageMetadata => {\n\tconst packagePathname = path.resolve(pathname, \"package.json\");\n\n\tif (isFileExists(packagePathname)) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-var-requires\n\t\treturn require(packagePathname) as PackageMetadata;\n\t}\n\n\treturn findNearestPackageJson(path.resolve(pathname, \"..\"));\n};\n\nconst isFileExists = (pathname: string) => {\n\ttry {\n\t\tfs.accessSync(pathname, fs.constants.F_OK);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nexport const getPackageMetadata = () => {\n\tconst mainFilename = require.main?.filename;\n\n\tif (!mainFilename) {\n\t\tthrow new Error(\n\t\t\t\"Termost was unable to retrieve automatically the package name and version. To fix it, use `termost({ name, description, version })` to define them manually.\",\n\t\t);\n\t}\n\n\treturn findNearestPackageJson(path.dirname(mainFilename));\n};\n", "// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const getArguments = () => {\n\tconst parameters = process.argv.slice(2);\n\tlet command: string | undefined;\n\tconst operands: string[] = [];\n\tconst options: Record = {};\n\tlet currentOptionName: string | undefined;\n\n\tconst addOptimisticOption = (name: string, value?: boolean | string) => {\n\t\tif (value) {\n\t\t\toptions[name] = typeof value === \"string\" ? castValue(value) : true;\n\t\t} else {\n\t\t\tcurrentOptionName = name;\n\t\t}\n\t};\n\n\tconst flushOptimisticOption = () => {\n\t\tif (currentOptionName) {\n\t\t\toptions[currentOptionName] = true;\n\t\t\tcurrentOptionName = undefined;\n\t\t}\n\t};\n\n\tfor (const parameter of parameters) {\n\t\tconst shortFlagMatchResult = SHORT_FLAG_REGEX.exec(parameter)?.groups;\n\t\tconst longFlagMatchResult = LONG_FLAG_REGEX.exec(parameter)?.groups;\n\n\t\tif (shortFlagMatchResult?.name) {\n\t\t\tflushOptimisticOption();\n\n\t\t\tconst optionFlags = shortFlagMatchResult.name.split(\"\");\n\t\t\tconst lastIndex = optionFlags.length - 1;\n\n\t\t\toptionFlags.forEach((flag, index) => {\n\t\t\t\taddOptimisticOption(\n\t\t\t\t\tflag,\n\t\t\t\t\tlastIndex === index ? undefined : true,\n\t\t\t\t);\n\t\t\t});\n\t\t} else if (longFlagMatchResult?.name) {\n\t\t\tflushOptimisticOption();\n\t\t\taddOptimisticOption(\n\t\t\t\tlongFlagMatchResult.name,\n\t\t\t\tlongFlagMatchResult.value,\n\t\t\t);\n\t\t} else if (currentOptionName) {\n\t\t\toptions[currentOptionName] = castValue(parameter);\n\t\t\tcurrentOptionName = undefined;\n\t\t} else if (!command) {\n\t\t\tcommand = parameter;\n\t\t} else {\n\t\t\toperands.push(parameter);\n\t\t}\n\t}\n\n\tflushOptimisticOption();\n\n\treturn { command, operands, options };\n};\n\nconst SHORT_FLAG_REGEX = /^-(?(?!-).*)$/;\nconst LONG_FLAG_REGEX = /^--(?.*?)(?:=(?.+))?$/;\n\nconst castValue = (value: string) => {\n\ttry {\n\t\treturn JSON.parse(value) as boolean | number | string;\n\t} catch {\n\t\treturn value;\n\t}\n};\n", "export const createQueue = () => {\n\tconst items: Item[] = [];\n\n\treturn {\n\t\tenqueue(item: Item) {\n\t\t\titems.push(item);\n\t\t},\n\t\tdequeue() {\n\t\t\treturn items.shift();\n\t\t},\n\t\tisEmpty() {\n\t\t\treturn items.length === 0;\n\t\t},\n\t};\n};\n", "import type {\n\tCommandName,\n\tContext,\n\tEmptyObject,\n\tObjectLikeConstraint,\n} from \"../../../types\";\n\nimport { createQueue } from \"./queue\";\n\nexport type CommandController<\n\tValues extends ObjectLikeConstraint = EmptyObject,\n> = {\n\taddValue: (key: Key, value: Values[Key]) => void;\n\taddOptionDescription: (key: string, description: string) => void;\n\taddInstruction: (instruction: Instruction) => void;\n\t/**\n\t * Enables a command by iterating over instructions and executing them\n\t */\n\tenable: () => Promise;\n\tgetContext: (rootCommandName: CommandName) => Context;\n\tgetMetadata: (rootCommandName: CommandName) => CommandMetadata;\n};\n\nexport const getCommandController = (\n\tname: CommandName,\n) => {\n\tconst controller = commandControllerCollection[name];\n\n\tif (!controller) {\n\t\tthrow new Error(\n\t\t\t`No controller has been set for the \\`${name}\\` command.\\nHave you run the \\`termost\\` constructor?`,\n\t\t);\n\t}\n\n\treturn controller as CommandController;\n};\n\nexport const createCommandController = (\n\tname: CommandName,\n\tdescription: CommandMetadata[\"description\"],\n) => {\n\tconst instructions = createQueue();\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\tlet context = {} as Context;\n\n\tconst metadata: CommandMetadata = {\n\t\tdescription,\n\t\toptions: {\n\t\t\t\"-h, --help\": \"Display the help center\",\n\t\t\t\"-v, --version\": \"Print the version\",\n\t\t},\n\t};\n\n\tconst controller: CommandController = {\n\t\taddOptionDescription(key, value) {\n\t\t\tmetadata.options[key] = value;\n\t\t},\n\t\taddValue(key, value) {\n\t\t\tcontext[key] = value;\n\t\t},\n\t\taddInstruction(instruction) {\n\t\t\tinstructions.enqueue(instruction);\n\t\t},\n\t\tasync enable() {\n\t\t\twhile (!instructions.isEmpty()) {\n\t\t\t\tconst task = instructions.dequeue();\n\n\t\t\t\tif (task) {\n\t\t\t\t\tawait task();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tgetContext(rootCommandName) {\n\t\t\t// @note: By design, global values are accessible to subcommands\n\t\t\t// Consequently, root command values are merged with the current command ones:\n\t\t\tif (name !== rootCommandName) {\n\t\t\t\tconst rootController = getCommandController(rootCommandName);\n\n\t\t\t\tconst globalContext =\n\t\t\t\t\trootController.getContext(rootCommandName);\n\n\t\t\t\tcontext = {\n\t\t\t\t\t...globalContext,\n\t\t\t\t\t...context,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn context;\n\t\t},\n\t\tgetMetadata(rootCommandName) {\n\t\t\tif (name !== rootCommandName) {\n\t\t\t\tconst globalMetadata =\n\t\t\t\t\tgetCommandController(rootCommandName).getMetadata(\n\t\t\t\t\t\trootCommandName,\n\t\t\t\t\t);\n\n\t\t\t\tmetadata.options = {\n\t\t\t\t\t...globalMetadata.options,\n\t\t\t\t\t...metadata.options,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn metadata;\n\t\t},\n\t};\n\n\tcommandDescriptionCollection[name] = description;\n\tcommandControllerCollection[name] = controller;\n\n\treturn controller;\n};\n\nexport const getCommandDescriptionCollection = () => {\n\treturn commandDescriptionCollection;\n};\n\ntype CommandMetadata = {\n\tdescription: string;\n\toptions: Record;\n};\n\ntype Instruction = () => Promise;\n\nconst commandControllerCollection: Record<\n\tCommandName,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tCommandController\n> = {};\n\nconst commandDescriptionCollection: Record<\n\tCommandName,\n\tCommandMetadata[\"description\"]\n> = {};\n", "/* eslint-disable sonarjs/cognitive-complexity */\nimport { format } from \"../../helpers/stdout\";\nimport type { ObjectLikeConstraint, ProgramMetadata } from \"../../types\";\n\nimport type { CommandController } from \"./controller\";\nimport {\n\tcreateCommandController,\n\tgetCommandController,\n\tgetCommandDescriptionCollection,\n} from \"./controller\";\n\nexport type CommandParameters = {\n\tname: string;\n\tdescription: string;\n};\n\nexport const createCommand = (\n\t{ name, description }: CommandParameters,\n\t{ argv, name: rootCommandName, version }: ProgramMetadata,\n) => {\n\tconst isRootCommand = name === rootCommandName;\n\tconst isActiveCommand = argv.command === name;\n\tconst controller = createCommandController(name, description);\n\tconst rootController = getCommandController(rootCommandName);\n\n\tsetTimeout(() => {\n\t\t// @note: By design, the root command instructions are always executed\n\t\t// even with subcommands (to share options, messages...)\n\t\tif (isRootCommand && !isActiveCommand) {\n\t\t\tvoid rootController.enable();\n\t\t}\n\n\t\t// @note: enable the current active command instructions:\n\t\tif (isActiveCommand) {\n\t\t\t// @note: setTimeout 0 allows to run activation logic in the next event loop iteration.\n\t\t\t// It'll allow to make sure that the `metadata` is correctly filled with all commands\n\t\t\t// metadata (especially to let the global help option to display all available commands):\n\t\t\tconst optionKeys = Object.keys(argv.options);\n\n\t\t\tif (\n\t\t\t\toptionKeys.includes(OPTION_HELP_NAMES[0]) ||\n\t\t\t\toptionKeys.includes(OPTION_HELP_NAMES[1])\n\t\t\t) {\n\t\t\t\tshowHelp({\n\t\t\t\t\tcontroller,\n\t\t\t\t\tcurrentCommandName: name,\n\t\t\t\t\tisRootCommand,\n\t\t\t\t\trootCommandName,\n\t\t\t\t});\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\toptionKeys.includes(OPTION_VERSION_NAMES[0]) ||\n\t\t\t\toptionKeys.includes(OPTION_VERSION_NAMES[1])\n\t\t\t) {\n\t\t\t\tconsole.info(version);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvoid controller.enable();\n\t\t}\n\t}, 0);\n\n\treturn name;\n};\n\nconst OPTION_HELP_NAMES = [\"help\", \"h\"] as const;\nconst OPTION_VERSION_NAMES = [\"version\", \"v\"] as const;\n\nconst showHelp = ({\n\trootCommandName,\n\tcurrentCommandName,\n\tisRootCommand,\n\tcontroller,\n}: {\n\trootCommandName: string;\n\tcurrentCommandName: string;\n\tisRootCommand: boolean;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcontroller: CommandController;\n}) => {\n\tconst commandMetadata = controller.getMetadata(rootCommandName);\n\tconst { options, description } = commandMetadata;\n\tconst commands = getCommandDescriptionCollection();\n\tconst optionKeys = Object.keys(commandMetadata.options);\n\tconst commandKeys = Object.keys(commands);\n\tconst hasOptions = optionKeys.length > 0;\n\tconst hasCommands = isRootCommand && commandKeys.length > 1;\n\n\tprintTitle(\"Usage\");\n\tprint(\n\t\t`${format(\n\t\t\t`${rootCommandName}${\n\t\t\t\tisRootCommand ? \"\" : ` ${String(currentCommandName)}`\n\t\t\t}`,\n\t\t\t{\n\t\t\t\tcolor: \"green\",\n\t\t\t},\n\t\t)} ${hasCommands ? \" \" : \"\"}${\n\t\t\thasOptions ? \"[...options]\" : \"\"\n\t\t}`,\n\t);\n\n\tif (description) {\n\t\tprintTitle(\"Description\");\n\t\tprint(description);\n\t}\n\n\tconst padding = [...commandKeys, ...optionKeys].reduce((value, item) => {\n\t\treturn Math.max(value, item.length);\n\t}, 0);\n\n\tif (hasCommands) {\n\t\tprintTitle(\"Commands\");\n\n\t\tfor (const name of commandKeys) {\n\t\t\tif (name === rootCommandName) continue;\n\n\t\t\tconst commandDescription = commands[name];\n\n\t\t\tif (commandDescription)\n\t\t\t\tprintLabelValue(name, commandDescription, padding);\n\t\t}\n\t}\n\n\tif (hasOptions) {\n\t\tprintTitle(\"Options\");\n\n\t\tfor (const key of optionKeys) {\n\t\t\tprintLabelValue(key, options[key] as string, padding);\n\t\t}\n\t}\n};\n\nconst print = (...parameters: Parameters) => {\n\tconsole.log(format(...parameters));\n};\n\nconst printTitle = (message: string) => {\n\tprint(`\\n${message}:`, {\n\t\tcolor: \"yellow\",\n\t\tmodifiers: [\"bold\", \"underline\", \"uppercase\"],\n\t});\n};\n\nconst printLabelValue = (label: string, value: string, padding: number) => {\n\tprint(\n\t\t` ${format(label.padEnd(padding + 1, \" \"), {\n\t\t\tcolor: \"green\",\n\t\t})} ${value}`,\n\t);\n};\n", "/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { prompt } from \"enquirer\";\n\nimport type {\n\tCreateInstruction,\n\tInstructionKey,\n\tInstructionParameters,\n\tLabel,\n\tObjectLikeConstraint,\n} from \"../../types\";\n\nexport const createInput: CreateInstruction<\n\tInputParameters\n> = (parameters) => {\n\tconst { key, defaultValue, label, type } = parameters;\n\n\treturn async function execute(context, argv) {\n\t\tconst promptObject: Parameters[0] & {\n\t\t\tchoices?: { title: string; value: string; selected?: boolean }[];\n\t\t} = {\n\t\t\tinitial: defaultValue,\n\t\t\tmessage: typeof label === \"function\" ? label(context, argv) : label,\n\t\t\tname: key,\n\t\t\ttype,\n\t\t};\n\n\t\tif (parameters.type === \"select\" || parameters.type === \"multiselect\") {\n\t\t\tconst isMultiSelect = parameters.type === \"multiselect\";\n\t\t\tconst options = parameters.options as string[];\n\n\t\t\tconst choices = options.map((option) => ({\n\t\t\t\ttitle: option,\n\t\t\t\tvalue: option,\n\t\t\t\t...(isMultiSelect && {\n\t\t\t\t\tselected: ((defaultValue || []) as string[]).includes(\n\t\t\t\t\t\toption,\n\t\t\t\t\t),\n\t\t\t\t}),\n\t\t\t}));\n\n\t\t\tpromptObject.choices = choices;\n\t\t}\n\n\t\tconst data = await prompt(promptObject);\n\n\t\treturn { key, value: data[key] };\n\t};\n};\n\nexport type InputParameters<\n\tValues extends ObjectLikeConstraint,\n\tKey extends keyof Values,\n> = InstructionParameters<\n\tValues,\n\tInstructionKey &\n\t\t(\n\t\t\t| {\n\t\t\t\t\ttype: \"confirm\";\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\tdefaultValue?: Values[Key] extends boolean\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\ttype: \"multiselect\";\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\toptions: Values[Key] extends string[] ? Values[Key] : never;\n\t\t\t\t\tdefaultValue?: Values[Key] extends string[]\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\ttype: \"select\";\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\toptions: Values[Key] extends string ? Values[Key][] : never;\n\t\t\t\t\tdefaultValue?: Values[Key] extends string\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\ttype: \"text\";\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\tdefaultValue?: Values[Key] extends string\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t }\n\t\t)\n>;\n", "/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport type { CommandController } from \"../command\";\nimport type {\n\tCreateInstruction,\n\tInstructionKey,\n\tInstructionParameters,\n\tObjectLikeConstraint,\n\tProgramMetadata,\n} from \"../../types\";\n\nexport const createOption =\n\t(\n\t\tcommandController: CommandController,\n\t\t{ argv }: ProgramMetadata,\n\t): CreateInstruction<\n\t\tOptionParameters\n\t> =>\n\t(parameters) => {\n\t\tconst { key, name, description, defaultValue } = parameters;\n\n\t\tconst aliases =\n\t\t\ttypeof name === \"string\" ? [name] : [name.short, name.long];\n\n\t\tconst metadataKey = aliases\n\t\t\t.map(\n\t\t\t\t(alias, index) =>\n\t\t\t\t\t\"-\".repeat(aliases.length > 1 ? index + 1 : 2) + alias,\n\t\t\t)\n\t\t\t.join(\", \");\n\n\t\tcommandController.addOptionDescription(metadataKey, description);\n\n\t\treturn async function execute() {\n\t\t\tlet value: unknown;\n\n\t\t\tfor (const alias of aliases) {\n\t\t\t\tif (alias in argv.options) {\n\t\t\t\t\tvalue = argv.options[alias];\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn Promise.resolve({ key, value: value ?? defaultValue });\n\t\t};\n\t};\n\nexport type OptionParameters<\n\tValues extends ObjectLikeConstraint,\n\tKey extends keyof Values,\n> = InstructionParameters<\n\tValues,\n\tInstructionKey & {\n\t\tname: string | { long: string; short: string };\n\t\tdescription: string;\n\t\tdefaultValue?: Values[Key];\n\t}\n>;\n", "import { Listr, PRESET_TIMER } from \"listr2\";\n\nimport type {\n\tArgumentValues,\n\tContext,\n\tCreateInstruction,\n\tInstructionKey,\n\tInstructionParameters,\n\tLabel,\n\tObjectLikeConstraint,\n} from \"../../types\";\n\nexport const createTask: CreateInstruction<\n\tTaskParameters\n> = (parameters) => {\n\tconst { key, label, handler } = parameters;\n\n\tconst receiver = label\n\t\t? new Listr([], {\n\t\t\t\trendererOptions: {\n\t\t\t\t\tcollapseErrors: false,\n\t\t\t\t\tformatOutput: \"wrap\",\n\t\t\t\t\tshowErrorMessage: true,\n\t\t\t\t\ttimer: PRESET_TIMER,\n\t\t\t\t},\n\t\t })\n\t\t: null;\n\n\treturn async function execute(context, argv) {\n\t\tlet value: unknown;\n\n\t\tif (!receiver) {\n\t\t\tvalue = await handler(context, argv);\n\t\t} else {\n\t\t\treceiver.add({\n\t\t\t\t...(label && {\n\t\t\t\t\ttitle:\n\t\t\t\t\t\ttypeof label === \"function\"\n\t\t\t\t\t\t\t? label(context, argv)\n\t\t\t\t\t\t\t: label,\n\t\t\t\t}),\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\t\ttask: async () => (value = await handler(context, argv)),\n\t\t\t});\n\n\t\t\tawait receiver.run();\n\t\t}\n\n\t\treturn { key, value };\n\t};\n};\n\nexport type TaskParameters<\n\tValues extends ObjectLikeConstraint,\n\tKey extends keyof Values | undefined = undefined,\n> = InstructionParameters<\n\tValues,\n\tPartial> & {\n\t\tlabel?: Label;\n\t\thandler: (\n\t\t\tcontext: Context,\n\t\t\targv: ArgumentValues,\n\t\t) => Key extends keyof Values\n\t\t\t? Promise | Values[Key]\n\t\t\t: Promise | void;\n\t}\n>;\n", "import { getPackageMetadata } from \"./helpers/package\";\nimport { getArguments } from \"./helpers/stdin\";\nimport type {\n\tCommandName,\n\tCreateInstruction,\n\tEmptyObject,\n\tInstructionParameters,\n\tObjectLikeConstraint,\n\tPackageMetadata,\n\tProgramMetadata,\n} from \"./types\";\nimport type { CommandParameters } from \"./api/command\";\nimport { createCommand, getCommandController } from \"./api/command\";\nimport type { InputParameters } from \"./api/input\";\nimport { createInput } from \"./api/input\";\nimport type { OptionParameters } from \"./api/option\";\nimport { createOption } from \"./api/option\";\nimport type { TaskParameters } from \"./api/task\";\nimport { createTask } from \"./api/task\";\n\n/**\n * The termost fluent interface API\n */\nexport type Termost = {\n\t/**\n\t * Allows to attach a new sub-command to the program\n\t * @param name - The CLI command name\n\t * @param description - The CLI command description\n\t * @returns The Command API\n\t */\n\tcommand: (\n\t\tparams: CommandParameters,\n\t) => Termost;\n\tinput: (\n\t\tparams: InputParameters,\n\t) => Termost;\n\toption: (\n\t\tparams: OptionParameters,\n\t) => Termost;\n\ttask: (\n\t\tparams: TaskParameters,\n\t) => Termost;\n};\n\nexport function termost(\n\tmetadata: Partial | string,\n\tcallbacks: TerminationCallbacks = {},\n) {\n\tconst paramsMetadata: Partial = isObject(metadata)\n\t\t? metadata\n\t\t: { description: metadata };\n\n\tconst packageMetadata = getPackageMetadata();\n\tconst programName = paramsMetadata.name ?? packageMetadata.name;\n\tconst { command = programName, options, operands } = getArguments();\n\n\tsetGracefulListeners(callbacks);\n\n\treturn createProgram({\n\t\targv: { command, options, operands },\n\t\tdescription: paramsMetadata.description ?? packageMetadata.description,\n\t\tname: programName,\n\t\tversion: paramsMetadata.version ?? packageMetadata.version,\n\t});\n}\n\nexport const createProgram = (\n\tmetadata: ProgramMetadata,\n): Termost => {\n\tconst { argv, name, description } = metadata;\n\tconst rootCommandName: CommandName = name;\n\tlet currentCommandName: CommandName = rootCommandName;\n\n\tconst createInstruction = <\n\t\tParameters extends InstructionParameters,\n\t>(\n\t\tfactory: CreateInstruction,\n\t\tparams: InstructionParameters,\n\t) => {\n\t\tconst instruction = factory(params as Parameters);\n\t\tconst controller = getCommandController(currentCommandName);\n\n\t\tcontroller.addInstruction(async () => {\n\t\t\tconst { skip } = params;\n\t\t\tconst context = controller.getContext(rootCommandName);\n\n\t\t\tif (skip?.(context, argv)) return;\n\n\t\t\tconst output = await instruction(context, argv);\n\n\t\t\tif (!output || !output.key) return;\n\n\t\t\tcontroller.addValue(\n\t\t\t\toutput.key,\n\t\t\t\toutput.value as Values[keyof Values],\n\t\t\t);\n\t\t});\n\t};\n\n\tconst program: Termost = {\n\t\tcommand(params: CommandParameters) {\n\t\t\tcurrentCommandName = createCommand(params, metadata);\n\n\t\t\treturn this as Termost;\n\t\t},\n\t\tinput(params) {\n\t\t\tcreateInstruction(createInput, params);\n\n\t\t\treturn this;\n\t\t},\n\t\toption(params) {\n\t\t\tcreateInstruction(\n\t\t\t\tcreateOption(\n\t\t\t\t\tgetCommandController(currentCommandName),\n\t\t\t\t\tmetadata,\n\t\t\t\t),\n\t\t\t\tparams,\n\t\t\t);\n\n\t\t\treturn this;\n\t\t},\n\t\ttask(params) {\n\t\t\tcreateInstruction(createTask, params);\n\n\t\t\treturn this;\n\t\t},\n\t};\n\n\t// @note: the root command is created by default\n\tprogram.command({\n\t\tname,\n\t\tdescription,\n\t});\n\n\treturn program;\n};\n\ntype TerminationCallbacks = Partial<{\n\tonShutdown: () => void;\n\tonException: (error: Error) => void;\n}>;\n\nconst setGracefulListeners = ({\n\tonShutdown = () => {\n\t\treturn;\n\t},\n\tonException = () => {\n\t\treturn;\n\t},\n}: TerminationCallbacks) => {\n\tprocess.on(\"SIGTERM\", () => {\n\t\tonShutdown();\n\t\tprocess.exit(0);\n\t});\n\n\tprocess.on(\"SIGINT\", () => {\n\t\tonShutdown();\n\t\tprocess.exit(0);\n\t});\n\n\tprocess.on(\"uncaughtException\", (error) => {\n\t\tonException(error);\n\t\tprocess.exit(1);\n\t});\n\n\tprocess.on(\"unhandledRejection\", (reason) => {\n\t\tif (reason instanceof Error) {\n\t\t\tonException(reason);\n\t\t}\n\n\t\tprocess.exit(1);\n\t});\n};\n\nconst isObject = (value: unknown): value is ObjectLikeConstraint => {\n\treturn value !== null && typeof value === \"object\";\n};\n", "import { exec } from \"./helpers/process\";\nimport { format, message } from \"./helpers/stdout\";\n\nexport { termost } from \"./termost\";\nexport type { Termost } from \"./termost\";\nexport const helpers = {\n\texec,\n\tformat,\n\tmessage,\n};\n"], -- "mappings": "6PAAA,OAAS,SAAAA,MAAa,gBAEf,IAAMC,EAAO,MACnBC,EACAC,EAAuB,CAAE,cAAe,EAAM,IAEvC,IAAI,QAAgB,CAACC,EAASC,IAAW,CAC/C,IAAIC,EAAS,GACTC,EAAS,GACP,CAACC,EAAK,GAAGC,CAAI,EAAIP,EAAQ,MAAM,GAAG,EAElCQ,EAAeV,E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AE9B,IACR,EACA,OAAOA,EAAQ,CACd,OAAAF,EACCY,EACCP,EAAqBN,CAAkB,EACvCjB,CACD,EACAoB,CACD,EAEO,IACR,EACA,KAAKA,EAAQ,CACZ,OAAAF,EAAkBa,EAAYX,CAAM,EAE7B,IACR,CACD,EAGA,OAAAO,EAAQ,QAAQ,CACf,KAAAb,EACA,YAAAC,CACD,CAAC,EAEMY,CACR,EAOMhB,GAAuB,CAAC,CAC7B,WAAAqB,EAAa,IAAM,CAEnB,EACA,YAAAC,EAAc,IAAM,CAEpB,CACD,IAA4B,CAC3B,QAAQ,GAAG,UAAW,IAAM,CAC3BD,EAAW,EACX,QAAQ,KAAK,CAAC,CACf,CAAC,EAED,QAAQ,GAAG,SAAU,IAAM,CAC1BA,EAAW,EACX,QAAQ,KAAK,CAAC,CACf,CAAC,EAED,QAAQ,GAAG,oBAAsBE,GAAU,CAC1CD,EAAYC,CAAK,EACjB,QAAQ,KAAK,CAAC,CACf,CAAC,EAED,QAAQ,GAAG,qBAAuBC,GAAW,CACxCA,aAAkB,OACrBF,EAAYE,CAAM,EAGnB,QAAQ,KAAK,CAAC,CACf,CAAC,CACF,EAEMhC,GAAYiC,GACVA,IAAU,MAAQ,OAAOA,GAAU,SC1KpC,IAAMC,GAAU,CACtB,KAAAC,EACA,OAAAC,EACA,QAAAC,CACD", -- "names": ["spawn", "exec", "command", "options", "resolve", "reject", "stdout", "stderr", "bin", "args", "childProcess", "chunk", "exitCode", "output", "pico", "format", "message", "color", "modifiers", "transformers", "colorMapper", "mod", "modifierMapper", "compose", "fns", "prevFn", "nextFn", "value", "content", "label", "type", "defaultLabel", "icon", "method", "formatPropertiesByType", "messages", "msg", "fs", "path", "findNearestPackageJson", "pathname", "packagePathname", "path", "isFileExists", "__require", "fs", "getPackageMetadata", "mainFilename", "getArguments", "parameters", "command", "operands", "options", "currentOptionName", "addOptimisticOption", "name", "value", "castValue", "flushOptimisticOption", "parameter", "shortFlagMatchResult", "SHORT_FLAG_REGEX", "longFlagMatchResult", "LONG_FLAG_REGEX", "optionFlags", "lastIndex", "flag", "index", "createQueue", "items", "item", "getCommandController", "name", "controller", "commandControllerCollection", "createCommandController", "description", "instructions", "createQueue", "context", "metadata", "key", "value", "instruction", "task", "rootCommandName", "globalMetadata", "commandDescriptionCollection", "getCommandDescriptionCollection", "createCommand", "name", "description", "argv", "rootCommandName", "version", "isRootCommand", "isActiveCommand", "controller", "createCommandController", "rootController", "getCommandController", "optionKeys", "OPTION_HELP_NAMES", "showHelp", "OPTION_VERSION_NAMES", "currentCommandName", "commandMetadata", "options", "commands", "getCommandDescriptionCollection", "commandKeys", "hasOptions", "hasCommands", "printTitle", "print", "format", "padding", "value", "item", "commandDescription", "printLabelValue", "key", "parameters", "message", "label", "prompt", "createInput", "parameters", "key", "defaultValue", "label", "type", "context", "argv", "promptObject", "isMultiSelect", "choices", "option", "data", "createOption", "commandController", "argv", "parameters", "key", "name", "description", "defaultValue", "aliases", "metadataKey", "alias", "index", "value", "Listr", "PRESET_TIMER", "createTask", "parameters", "key", "label", "handler", "receiver", "context", "argv", "value", "termost", "metadata", "callbacks", "paramsMetadata", "isObject", "packageMetadata", "getPackageMetadata", "programName", "command", "options", "operands", "getArguments", "setGracefulListeners", "createProgram", "argv", "name", "description", "rootCommandName", "currentCommandName", "createInstruction", "factory", "params", "instruction", "controller", "getCommandController", "skip", "context", "output", "program", "createCommand", "createInput", "createOption", "createTask", "onShutdown", "onException", "error", "reason", "value", "helpers", "exec", "format", "message"] -+ "sources": ["../src/helpers/process/index.ts", "../src/helpers/stdout/index.ts", "../src/api/command/controller/queue.ts", "../src/api/command/controller/index.ts", "../src/api/command/command.ts", "../src/api/input/index.ts", "../src/api/option/index.ts", "../src/api/task/index.ts", "../src/helpers/package/index.ts", "../src/helpers/stdin/index.ts", "../src/termost.ts", "../src/index.ts"], -+ "sourcesContent": ["import { spawn } from \"child_process\";\n\nexport const exec = async (\n\tcommand: string,\n\toptions: ExecOptions = { hasLiveOutput: false },\n) => {\n\treturn new Promise((resolve, reject) => {\n\t\tlet stdout = \"\";\n\t\tlet stderr = \"\";\n\t\tconst [bin, ...args] = command.split(\" \") as [string, ...string[]];\n\n\t\tconst childProcess = spawn(bin, args, {\n\t\t\tcwd: options.cwd,\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t// @note: make sure to force color display for spawned processes\n\t\t\t\tFORCE_COLOR: \"1\",\n\t\t\t},\n\t\t\tshell: true,\n\t\t\tstdio: options.hasLiveOutput ? \"inherit\" : \"pipe\",\n\t\t});\n\n\t\tchildProcess.stdout?.on(\"data\", (chunk) => {\n\t\t\tstdout += chunk;\n\t\t});\n\n\t\tchildProcess.stderr?.on(\"data\", (chunk) => {\n\t\t\tstderr += chunk;\n\t\t});\n\n\t\tchildProcess.on(\"close\", (exitCode) => {\n\t\t\tif (exitCode !== 0) {\n\t\t\t\tconst output = `${stderr}${stdout}`;\n\n\t\t\t\treject(output.trim());\n\t\t\t} else {\n\t\t\t\tresolve(stdout.trim());\n\t\t\t}\n\t\t});\n\t});\n};\n\ntype ExecOptions = {\n\tcwd?: string;\n\thasLiveOutput?: boolean;\n};\n", "import pico from \"picocolors\";\n\n/**\n * A helper to format an arbitrary text as a message input\n * @param message The text to display\n * @param options The configuration object to control the formatting properties\n * @returns The formatted text\n */\nexport const format = (\n\tmessage: string,\n\t{\n\t\tcolor,\n\t\tmodifiers,\n\t}: {\n\t\tcolor?: Color;\n\t\tmodifiers?: Modifier[];\n\t} = {\n\t\tcolor: \"white\",\n\t\tmodifiers: [],\n\t},\n) => {\n\tconst transformers: ((input: string) => string)[] = [];\n\n\ttransformers.push(pico[colorMapper[color ?? \"white\"]]);\n\n\t(modifiers ?? []).forEach((mod: Modifier) => {\n\t\tif (mod === \"uppercase\") {\n\t\t\tmessage = message.toUpperCase();\n\t\t} else if (mod === \"lowercase\") {\n\t\t\tmessage = message.toLowerCase();\n\t\t} else {\n\t\t\ttransformers.push(pico[modifierMapper[mod]]);\n\t\t}\n\t});\n\n\treturn compose(...transformers)(message);\n};\n\nconst compose = (...fns: ((a: T) => T)[]) =>\n\tfns.reduce(\n\t\t(prevFn, nextFn) => (value) => prevFn(nextFn(value)),\n\t\tfns[0] as (a: T) => T,\n\t);\n\n/**\n * An opinionated helper to display arbitrary text on the console\n * @param message The text to display. Use an array if you need to display a message in several lines\n * @param options The configuration object to define the display type and/or override the default label\n */\nexport const message = (\n\tcontent: string[] | string,\n\t{\n\t\tlabel,\n\t\ttype = \"information\",\n\t}: { label?: string; type?: MessageType } = {},\n) => {\n\tconst { color, defaultLabel, icon, method } = formatPropertiesByType[type];\n\tconst messages = typeof content === \"string\" ? [content] : content;\n\n\tmethod(\n\t\tformat(`\\n${icon} ${label ?? defaultLabel}`, {\n\t\t\tcolor,\n\t\t\tmodifiers: [\"bold\"],\n\t\t}),\n\t);\n\n\tfor (const msg of messages) {\n\t\tmethod(format(` ${msg}`, { color }));\n\t}\n};\n\nconst formatPropertiesByType = {\n\terror: {\n\t\tcolor: \"red\",\n\t\tdefaultLabel: \"Error\",\n\t\ticon: \"\u274C\",\n\t\tmethod: console.error,\n\t},\n\tinformation: {\n\t\tcolor: \"blue\",\n\t\tdefaultLabel: \"Information\",\n\t\ticon: \"\u2139\uFE0F \",\n\t\tmethod: console.info,\n\t},\n\tsuccess: {\n\t\tcolor: \"green\",\n\t\tdefaultLabel: \"Success\",\n\t\ticon: \"\u2705\",\n\t\tmethod: console.log,\n\t},\n\twarning: {\n\t\tcolor: \"yellow\",\n\t\tdefaultLabel: \"Warning\",\n\t\ticon: \"\u26A0\uFE0F \",\n\t\tmethod: console.warn,\n\t},\n} as const;\n\nconst colorMapper = {\n\tblack: \"black\",\n\tblue: \"blue\",\n\tcyan: \"cyan\",\n\tgreen: \"green\",\n\tgrey: \"gray\",\n\tmagenta: \"magenta\",\n\tred: \"red\",\n\twhite: \"white\",\n\tyellow: \"yellow\",\n} as const;\n\nconst modifierMapper = {\n\tbold: \"bold\",\n\titalic: \"italic\",\n\tstrikethrough: \"strikethrough\",\n\tunderline: \"underline\",\n} as const;\n\ntype MessageType = \"error\" | \"information\" | \"success\" | \"warning\";\n\ntype Color =\n\t| \"black\"\n\t| \"blue\"\n\t| \"cyan\"\n\t| \"green\"\n\t| \"grey\"\n\t| \"magenta\"\n\t| \"red\"\n\t| \"white\"\n\t| \"yellow\";\n\ntype Modifier =\n\t| \"bold\"\n\t| \"italic\"\n\t| \"lowercase\"\n\t| \"strikethrough\"\n\t| \"underline\"\n\t| \"uppercase\";\n", "export const createQueue = () => {\n\tconst items: Item[] = [];\n\n\treturn {\n\t\tdequeue() {\n\t\t\treturn items.shift();\n\t\t},\n\t\tenqueue(item: Item) {\n\t\t\titems.push(item);\n\t\t},\n\t\tisEmpty() {\n\t\t\treturn items.length === 0;\n\t\t},\n\t};\n};\n", "import type {\n\tCommandName,\n\tContext,\n\tEmptyObject,\n\tObjectLikeConstraint,\n} from \"../../../types\";\n\nimport { createQueue } from \"./queue\";\n\nexport type CommandController<\n\tValues extends ObjectLikeConstraint = EmptyObject,\n> = {\n\taddInstruction: (instruction: Instruction) => void;\n\taddOptionDescription: (key: string, description: string) => void;\n\taddValue: (key: Key, value: Values[Key]) => void;\n\t/**\n\t * Enables a command by iterating over instructions and executing them\n\t */\n\tenable: () => Promise;\n\tgetContext: (rootCommandName: CommandName) => Context;\n\tgetMetadata: (rootCommandName: CommandName) => CommandMetadata;\n};\n\nexport const getCommandController = (\n\tname: CommandName,\n) => {\n\tconst controller = commandControllerCollection[name];\n\n\tif (!controller) {\n\t\tthrow new Error(\n\t\t\t`No controller has been set for the \\`${name}\\` command.\\nHave you run the \\`termost\\` constructor?`,\n\t\t);\n\t}\n\n\treturn controller as CommandController;\n};\n\nexport const createCommandController = (\n\tname: CommandName,\n\tdescription: CommandMetadata[\"description\"],\n) => {\n\tconst instructions = createQueue();\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\tlet context = {} as Context;\n\n\tconst metadata: CommandMetadata = {\n\t\tdescription,\n\t\toptions: {\n\t\t\t\"-h, --help\": \"Display the help center\",\n\t\t\t\"-v, --version\": \"Print the version\",\n\t\t},\n\t};\n\n\tconst controller: CommandController = {\n\t\taddInstruction(instruction) {\n\t\t\tinstructions.enqueue(instruction);\n\t\t},\n\t\taddOptionDescription(key, value) {\n\t\t\tmetadata.options[key] = value;\n\t\t},\n\t\taddValue(key, value) {\n\t\t\tcontext[key] = value;\n\t\t},\n\t\tasync enable() {\n\t\t\twhile (!instructions.isEmpty()) {\n\t\t\t\tconst task = instructions.dequeue();\n\n\t\t\t\tif (task) {\n\t\t\t\t\tawait task();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tgetContext(rootCommandName) {\n\t\t\t// @note: By design, global values are accessible to subcommands\n\t\t\t// Consequently, root command values are merged with the current command ones:\n\t\t\tif (name !== rootCommandName) {\n\t\t\t\tconst rootController = getCommandController(rootCommandName);\n\n\t\t\t\tconst globalContext =\n\t\t\t\t\trootController.getContext(rootCommandName);\n\n\t\t\t\tcontext = {\n\t\t\t\t\t...globalContext,\n\t\t\t\t\t...context,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn context;\n\t\t},\n\t\tgetMetadata(rootCommandName) {\n\t\t\tif (name !== rootCommandName) {\n\t\t\t\tconst globalMetadata =\n\t\t\t\t\tgetCommandController(rootCommandName).getMetadata(\n\t\t\t\t\t\trootCommandName,\n\t\t\t\t\t);\n\n\t\t\t\tmetadata.options = {\n\t\t\t\t\t...globalMetadata.options,\n\t\t\t\t\t...metadata.options,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn metadata;\n\t\t},\n\t};\n\n\tcommandDescriptionCollection[name] = description;\n\tcommandControllerCollection[name] = controller;\n\n\treturn controller;\n};\n\nexport const getCommandDescriptionCollection = () => {\n\treturn commandDescriptionCollection;\n};\n\ntype CommandMetadata = {\n\tdescription: string;\n\toptions: Record;\n};\n\ntype Instruction = () => Promise;\n\nconst commandControllerCollection: Record<\n\tCommandName,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tCommandController\n> = {};\n\nconst commandDescriptionCollection: Record<\n\tCommandName,\n\tCommandMetadata[\"description\"]\n> = {};\n", "/* eslint-disable sonarjs/cognitive-complexity */\nimport { format } from \"../../helpers/stdout\";\nimport type { ObjectLikeConstraint, ProgramMetadata } from \"../../types\";\n\nimport {\n\tcreateCommandController,\n\tgetCommandController,\n\tgetCommandDescriptionCollection,\n} from \"./controller\";\nimport type { CommandController } from \"./controller\";\n\nexport type CommandParameters = {\n\tname: string;\n\tdescription: string;\n};\n\nexport const createCommand = (\n\t{ name, description }: CommandParameters,\n\t{ name: rootCommandName, argv, version }: ProgramMetadata,\n) => {\n\tconst isRootCommand = name === rootCommandName;\n\tconst isActiveCommand = argv.command === name;\n\tconst controller = createCommandController(name, description);\n\tconst rootController = getCommandController(rootCommandName);\n\n\tsetTimeout(() => {\n\t\t// @note: By design, the root command instructions are always executed\n\t\t// even with subcommands (to share options, messages...)\n\t\tif (isRootCommand && !isActiveCommand) {\n\t\t\tvoid rootController.enable();\n\t\t}\n\n\t\t// @note: enable the current active command instructions:\n\t\tif (isActiveCommand) {\n\t\t\t// @note: setTimeout 0 allows to run activation logic in the next event loop iteration.\n\t\t\t// It'll allow to make sure that the `metadata` is correctly filled with all commands\n\t\t\t// metadata (especially to let the global help option to display all available commands):\n\t\t\tconst optionKeys = Object.keys(argv.options);\n\n\t\t\tif (\n\t\t\t\toptionKeys.includes(OPTION_HELP_NAMES[0]) ||\n\t\t\t\toptionKeys.includes(OPTION_HELP_NAMES[1])\n\t\t\t) {\n\t\t\t\tshowHelp({\n\t\t\t\t\tcontroller,\n\t\t\t\t\tcurrentCommandName: name,\n\t\t\t\t\tisRootCommand,\n\t\t\t\t\trootCommandName,\n\t\t\t\t});\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\toptionKeys.includes(OPTION_VERSION_NAMES[0]) ||\n\t\t\t\toptionKeys.includes(OPTION_VERSION_NAMES[1])\n\t\t\t) {\n\t\t\t\tconsole.info(version);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvoid controller.enable();\n\t\t}\n\t}, 0);\n\n\treturn name;\n};\n\nconst OPTION_HELP_NAMES = [\"help\", \"h\"] as const;\nconst OPTION_VERSION_NAMES = [\"version\", \"v\"] as const;\n\nconst showHelp = ({\n\tcontroller,\n\tcurrentCommandName,\n\tisRootCommand,\n\trootCommandName,\n}: {\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcontroller: CommandController;\n\tcurrentCommandName: string;\n\tisRootCommand: boolean;\n\trootCommandName: string;\n}) => {\n\tconst commandMetadata = controller.getMetadata(rootCommandName);\n\tconst { description, options } = commandMetadata;\n\tconst commands = getCommandDescriptionCollection();\n\tconst optionKeys = Object.keys(commandMetadata.options);\n\tconst commandKeys = Object.keys(commands);\n\tconst hasOptions = optionKeys.length > 0;\n\tconst hasCommands = isRootCommand && commandKeys.length > 1;\n\n\tprintTitle(\"Usage\");\n\tprint(\n\t\t`${format(\n\t\t\t`${rootCommandName}${\n\t\t\t\tisRootCommand ? \"\" : ` ${String(currentCommandName)}`\n\t\t\t}`,\n\t\t\t{\n\t\t\t\tcolor: \"green\",\n\t\t\t},\n\t\t)} ${hasCommands ? \" \" : \"\"}${\n\t\t\thasOptions ? \"[...options]\" : \"\"\n\t\t}`,\n\t);\n\n\tif (description) {\n\t\tprintTitle(\"Description\");\n\t\tprint(description);\n\t}\n\n\tconst padding = [...commandKeys, ...optionKeys].reduce((value, item) => {\n\t\treturn Math.max(value, item.length);\n\t}, 0);\n\n\tif (hasCommands) {\n\t\tprintTitle(\"Commands\");\n\n\t\tfor (const name of commandKeys) {\n\t\t\tif (name === rootCommandName) continue;\n\n\t\t\tconst commandDescription = commands[name];\n\n\t\t\tif (commandDescription)\n\t\t\t\tprintLabelValue(name, commandDescription, padding);\n\t\t}\n\t}\n\n\tif (hasOptions) {\n\t\tprintTitle(\"Options\");\n\n\t\tfor (const key of optionKeys) {\n\t\t\tprintLabelValue(key, options[key] as string, padding);\n\t\t}\n\t}\n};\n\nconst print = (...parameters: Parameters) => {\n\tconsole.log(format(...parameters));\n};\n\nconst printTitle = (message: string) => {\n\tprint(`\\n${message}:`, {\n\t\tcolor: \"yellow\",\n\t\tmodifiers: [\"bold\", \"underline\", \"uppercase\"],\n\t});\n};\n\nconst printLabelValue = (label: string, value: string, padding: number) => {\n\tprint(\n\t\t` ${format(label.padEnd(padding + 1, \" \"), {\n\t\t\tcolor: \"green\",\n\t\t})} ${value}`,\n\t);\n};\n", "/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport { prompt } from \"enquirer\";\n\nimport type {\n\tCreateInstruction,\n\tInstructionKey,\n\tInstructionParameters,\n\tLabel,\n\tObjectLikeConstraint,\n} from \"../../types\";\n\nexport const createInput: CreateInstruction<\n\tInputParameters\n> = (parameters) => {\n\tconst { key, label, defaultValue, type } = parameters;\n\n\treturn async function execute(context, argv) {\n\t\tconst promptObject: Parameters[0] & {\n\t\t\tchoices?: { title: string; selected?: boolean; value: string }[];\n\t\t} = {\n\t\t\tname: key,\n\t\t\tinitial: defaultValue,\n\t\t\tmessage: typeof label === \"function\" ? label(context, argv) : label,\n\t\t\ttype,\n\t\t};\n\n\t\tif (parameters.type === \"select\" || parameters.type === \"multiselect\") {\n\t\t\tconst isMultiSelect = parameters.type === \"multiselect\";\n\t\t\tconst options = parameters.options as string[];\n\n\t\t\tconst choices = options.map((option) => ({\n\t\t\t\ttitle: option,\n\t\t\t\tvalue: option,\n\t\t\t\t...(isMultiSelect && {\n\t\t\t\t\tselected: ((defaultValue || []) as string[]).includes(\n\t\t\t\t\t\toption,\n\t\t\t\t\t),\n\t\t\t\t}),\n\t\t\t}));\n\n\t\t\tpromptObject.choices = choices;\n\t\t}\n\n\t\tconst data = await prompt(promptObject);\n\n\t\treturn { key, value: data[key] };\n\t};\n};\n\nexport type InputParameters<\n\tValues extends ObjectLikeConstraint,\n\tKey extends keyof Values,\n> = InstructionParameters<\n\tValues,\n\tInstructionKey &\n\t\t(\n\t\t\t| {\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\tdefaultValue?: Values[Key] extends boolean\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t\t\ttype: \"confirm\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\tdefaultValue?: Values[Key] extends string\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t\t\toptions: Values[Key] extends string ? Values[Key][] : never;\n\t\t\t\t\ttype: \"select\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\tdefaultValue?: Values[Key] extends string\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t\t\ttype: \"text\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tlabel: Label;\n\t\t\t\t\tdefaultValue?: Values[Key] extends string[]\n\t\t\t\t\t\t? Values[Key]\n\t\t\t\t\t\t: never;\n\t\t\t\t\toptions: Values[Key] extends string[] ? Values[Key] : never;\n\t\t\t\t\ttype: \"multiselect\";\n\t\t\t }\n\t\t)\n>;\n", "/* eslint-disable @typescript-eslint/no-unsafe-assignment */\nimport type {\n\tCreateInstruction,\n\tInstructionKey,\n\tInstructionParameters,\n\tObjectLikeConstraint,\n\tProgramMetadata,\n} from \"../../types\";\nimport type { CommandController } from \"../command\";\n\nexport const createOption =\n\t(\n\t\tcommandController: CommandController,\n\t\t{ argv }: ProgramMetadata,\n\t): CreateInstruction<\n\t\tOptionParameters\n\t> =>\n\t(parameters) => {\n\t\tconst { key, name, description, defaultValue } = parameters;\n\n\t\tconst aliases =\n\t\t\ttypeof name === \"string\" ? [name] : [name.short, name.long];\n\n\t\tconst metadataKey = aliases\n\t\t\t.map(\n\t\t\t\t(alias, index) =>\n\t\t\t\t\t\"-\".repeat(aliases.length > 1 ? index + 1 : 2) + alias,\n\t\t\t)\n\t\t\t.join(\", \");\n\n\t\tcommandController.addOptionDescription(metadataKey, description);\n\n\t\treturn async function execute() {\n\t\t\tlet value: unknown;\n\n\t\t\tfor (const alias of aliases) {\n\t\t\t\tif (alias in argv.options) {\n\t\t\t\t\tvalue = argv.options[alias];\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn Promise.resolve({ key, value: value ?? defaultValue });\n\t\t};\n\t};\n\nexport type OptionParameters<\n\tValues extends ObjectLikeConstraint,\n\tKey extends keyof Values,\n> = InstructionParameters<\n\tValues,\n\tInstructionKey & {\n\t\tname: string | { long: string; short: string };\n\t\tdescription: string;\n\t\tdefaultValue?: Values[Key];\n\t}\n>;\n", "import { Listr, PRESET_TIMER } from \"listr2\";\n\nimport type {\n\tArgumentValues,\n\tContext,\n\tCreateInstruction,\n\tInstructionKey,\n\tInstructionParameters,\n\tLabel,\n\tObjectLikeConstraint,\n} from \"../../types\";\n\nexport const createTask: CreateInstruction<\n\tTaskParameters\n> = (parameters) => {\n\tconst { key, label, handler } = parameters;\n\n\tconst receiver = label\n\t\t? new Listr([], {\n\t\t\t\trendererOptions: {\n\t\t\t\t\tcollapseErrors: false,\n\t\t\t\t\tformatOutput: \"wrap\",\n\t\t\t\t\tshowErrorMessage: true,\n\t\t\t\t\ttimer: PRESET_TIMER,\n\t\t\t\t},\n\t\t })\n\t\t: null;\n\n\treturn async function execute(context, argv) {\n\t\tlet value: unknown;\n\n\t\tif (!receiver) {\n\t\t\tvalue = await handler(context, argv);\n\t\t} else {\n\t\t\treceiver.add({\n\t\t\t\t...(label && {\n\t\t\t\t\ttitle:\n\t\t\t\t\t\ttypeof label === \"function\"\n\t\t\t\t\t\t\t? label(context, argv)\n\t\t\t\t\t\t\t: label,\n\t\t\t\t}),\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\t\ttask: async () => (value = await handler(context, argv)),\n\t\t\t});\n\n\t\t\tawait receiver.run();\n\t\t}\n\n\t\treturn { key, value };\n\t};\n};\n\nexport type TaskParameters<\n\tValues extends ObjectLikeConstraint,\n\tKey extends keyof Values | undefined = undefined,\n> = InstructionParameters<\n\tValues,\n\tPartial> & {\n\t\tlabel?: Label;\n\t\thandler: (\n\t\t\tcontext: Context,\n\t\t\targv: ArgumentValues,\n\t\t) => Key extends keyof Values\n\t\t\t? Promise | Values[Key]\n\t\t\t: Promise | void;\n\t}\n>;\n", "import fs from \"fs\";\nimport path from \"path\";\n\nimport type { PackageMetadata } from \"../../types\";\n\nexport const findNearestPackageJson = (pathname: string): PackageMetadata => {\n\tconst packagePathname = path.resolve(pathname, \"package.json\");\n\n\tif (isFileExists(packagePathname)) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-var-requires\n\t\treturn require(packagePathname) as PackageMetadata;\n\t}\n\n\treturn findNearestPackageJson(path.resolve(pathname, \"..\"));\n};\n\nconst isFileExists = (pathname: string) => {\n\ttry {\n\t\tfs.accessSync(pathname, fs.constants.F_OK);\n\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nexport const getPackageMetadata = () => {\n\tconst mainFilename = require.main?.filename;\n\n\tif (!mainFilename) {\n\t\tthrow new Error(\n\t\t\t\"Termost was unable to retrieve automatically the package name and version. To fix it, use `termost({ name, description, version })` to define them manually.\",\n\t\t);\n\t}\n\n\treturn findNearestPackageJson(path.dirname(mainFilename));\n};\n", "// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const getArguments = () => {\n\tconst parameters = process.argv.slice(2);\n\tlet command: string | undefined;\n\tconst operands: string[] = [];\n\tconst options: Record = {};\n\tlet currentOptionName: string | undefined;\n\n\tconst addOptimisticOption = (name: string, value?: boolean | string) => {\n\t\tif (value) {\n\t\t\toptions[name] = typeof value === \"string\" ? castValue(value) : true;\n\t\t} else {\n\t\t\tcurrentOptionName = name;\n\t\t}\n\t};\n\n\tconst flushOptimisticOption = () => {\n\t\tif (currentOptionName) {\n\t\t\toptions[currentOptionName] = true;\n\t\t\tcurrentOptionName = undefined;\n\t\t}\n\t};\n\n\tfor (const parameter of parameters) {\n\t\tconst shortFlagMatchResult = SHORT_FLAG_REGEX.exec(parameter)?.groups;\n\t\tconst longFlagMatchResult = LONG_FLAG_REGEX.exec(parameter)?.groups;\n\n\t\tif (shortFlagMatchResult?.name) {\n\t\t\tflushOptimisticOption();\n\n\t\t\tconst optionFlags = shortFlagMatchResult.name.split(\"\");\n\t\t\tconst lastIndex = optionFlags.length - 1;\n\n\t\t\toptionFlags.forEach((flag, index) => {\n\t\t\t\taddOptimisticOption(\n\t\t\t\t\tflag,\n\t\t\t\t\tlastIndex === index ? undefined : true,\n\t\t\t\t);\n\t\t\t});\n\t\t} else if (longFlagMatchResult?.name) {\n\t\t\tflushOptimisticOption();\n\t\t\taddOptimisticOption(\n\t\t\t\tlongFlagMatchResult.name,\n\t\t\t\tlongFlagMatchResult.value,\n\t\t\t);\n\t\t} else if (currentOptionName) {\n\t\t\toptions[currentOptionName] = castValue(parameter);\n\t\t\tcurrentOptionName = undefined;\n\t\t} else if (!command) {\n\t\t\tcommand = parameter;\n\t\t} else {\n\t\t\toperands.push(parameter);\n\t\t}\n\t}\n\n\tflushOptimisticOption();\n\n\treturn { command, operands, options };\n};\n\nconst SHORT_FLAG_REGEX = /^-(?(?!-).*)$/;\nconst LONG_FLAG_REGEX = /^--(?.*?)(?:=(?.+))?$/;\n\nconst castValue = (value: string) => {\n\ttry {\n\t\treturn JSON.parse(value) as boolean | number | string;\n\t} catch {\n\t\treturn value;\n\t}\n};\n", "import { createCommand, getCommandController } from \"./api/command\";\nimport type { CommandParameters } from \"./api/command\";\nimport { createInput } from \"./api/input\";\nimport type { InputParameters } from \"./api/input\";\nimport { createOption } from \"./api/option\";\nimport type { OptionParameters } from \"./api/option\";\nimport { createTask } from \"./api/task\";\nimport type { TaskParameters } from \"./api/task\";\nimport { getPackageMetadata } from \"./helpers/package\";\nimport { getArguments } from \"./helpers/stdin\";\nimport type {\n\tCommandName,\n\tCreateInstruction,\n\tEmptyObject,\n\tInstructionParameters,\n\tObjectLikeConstraint,\n\tPackageMetadata,\n\tProgramMetadata,\n} from \"./types\";\n\n/**\n * The termost fluent interface API\n */\nexport type Termost = {\n\t/**\n\t * Allows to attach a new sub-command to the program\n\t * @param name - The CLI command name\n\t * @param description - The CLI command description\n\t * @returns The Command API\n\t */\n\tcommand: (\n\t\tparams: CommandParameters,\n\t) => Termost;\n\tinput: (\n\t\tparams: InputParameters,\n\t) => Termost;\n\toption: (\n\t\tparams: OptionParameters,\n\t) => Termost;\n\ttask: (\n\t\tparams: TaskParameters,\n\t) => Termost;\n};\n\nexport function termost(\n\tmetadata: Partial | string,\n\tcallbacks: TerminationCallbacks = {},\n) {\n\tlet { name, description, version } = isObject(metadata)\n\t\t? metadata\n\t\t: {\n\t\t\t\tname: undefined,\n\t\t\t\tdescription: metadata,\n\t\t\t\tversion: undefined,\n\t\t };\n\n\tif (\n\t\tname === undefined ||\n\t\tdescription === undefined ||\n\t\tversion === undefined\n\t) {\n\t\tconst packageMetadata = getPackageMetadata();\n\n\t\tname ??= packageMetadata.name;\n\t\tdescription ??= packageMetadata.description;\n\t\tversion ??= packageMetadata.version;\n\t}\n\n\tconst { command = name, operands, options } = getArguments();\n\n\tsetGracefulListeners(callbacks);\n\n\treturn createProgram({\n\t\tname,\n\t\tdescription,\n\t\targv: { command, operands, options },\n\t\tversion,\n\t});\n}\n\nexport const createProgram = (\n\tmetadata: ProgramMetadata,\n): Termost => {\n\tconst { name, description, argv } = metadata;\n\tconst rootCommandName: CommandName = name;\n\tlet currentCommandName: CommandName = rootCommandName;\n\n\tconst createInstruction = <\n\t\tParameters extends InstructionParameters,\n\t>(\n\t\tfactory: CreateInstruction,\n\t\tparams: InstructionParameters,\n\t) => {\n\t\tconst instruction = factory(params as Parameters);\n\t\tconst controller = getCommandController(currentCommandName);\n\n\t\tcontroller.addInstruction(async () => {\n\t\t\tconst { skip } = params;\n\t\t\tconst context = controller.getContext(rootCommandName);\n\n\t\t\tif (skip?.(context, argv)) return;\n\n\t\t\tconst output = await instruction(context, argv);\n\n\t\t\tif (!output || !output.key) return;\n\n\t\t\tcontroller.addValue(\n\t\t\t\toutput.key,\n\t\t\t\toutput.value as Values[keyof Values],\n\t\t\t);\n\t\t});\n\t};\n\n\tconst program: Termost = {\n\t\tcommand(params: CommandParameters) {\n\t\t\tcurrentCommandName = createCommand(params, metadata);\n\n\t\t\treturn this as Termost;\n\t\t},\n\t\tinput(params) {\n\t\t\tcreateInstruction(createInput, params);\n\n\t\t\treturn this;\n\t\t},\n\t\toption(params) {\n\t\t\tcreateInstruction(\n\t\t\t\tcreateOption(\n\t\t\t\t\tgetCommandController(currentCommandName),\n\t\t\t\t\tmetadata,\n\t\t\t\t),\n\t\t\t\tparams,\n\t\t\t);\n\n\t\t\treturn this;\n\t\t},\n\t\ttask(params) {\n\t\t\tcreateInstruction(createTask, params);\n\n\t\t\treturn this;\n\t\t},\n\t};\n\n\t// @note: the root command is created by default\n\tprogram.command({\n\t\tname,\n\t\tdescription,\n\t});\n\n\treturn program;\n};\n\ntype TerminationCallbacks = Partial<{\n\tonException: (error: Error) => void;\n\tonShutdown: () => void;\n}>;\n\nconst setGracefulListeners = ({\n\tonException = () => {\n\t\treturn;\n\t},\n\tonShutdown = () => {\n\t\treturn;\n\t},\n}: TerminationCallbacks) => {\n\tprocess.on(\"SIGTERM\", () => {\n\t\tonShutdown();\n\t\tprocess.exit(0);\n\t});\n\n\tprocess.on(\"SIGINT\", () => {\n\t\tonShutdown();\n\t\tprocess.exit(0);\n\t});\n\n\tprocess.on(\"uncaughtException\", (error) => {\n\t\tonException(error);\n\t\tprocess.exit(1);\n\t});\n\n\tprocess.on(\"unhandledRejection\", (reason) => {\n\t\tif (reason instanceof Error) {\n\t\t\tonException(reason);\n\t\t}\n\n\t\tprocess.exit(1);\n\t});\n};\n\nconst isObject = (value: unknown): value is ObjectLikeConstraint => {\n\treturn value !== null && typeof value === \"object\";\n};\n", "import { exec } from \"./helpers/process\";\nimport { format, message } from \"./helpers/stdout\";\n\nexport { termost } from \"./termost\";\nexport type { Termost } from \"./termost\";\nexport const helpers = {\n\texec,\n\tformat,\n\tmessage,\n};\n"], -+ "mappings": "6PAAA,OAAS,SAAAA,MAAa,gBAEf,IAAMC,EAAO,MACnBC,EACAC,EAAuB,CAAE,cAAe,EAAM,IAEvC,IAAI,QAAgB,CAACC,EAASC,IAAW,CAC/C,IAAIC,EAAS,GACTC,EAAS,GACP,CAACC,EAAK,GAAGC,CAAI,EAAIP,EAAQ,MAAM,GAAG,EAElCQ,EAAeV,EAAMQ,EAAKC,EAAM,CACrC,IAAKN,EAAQ,IACb,IAAK,CACJ,GAAG,QAAQ,IAEX,YAAa,GACd,EACA,MAAO,GACP,MAAOA,EAAQ,cAAgB,UAAY,MAC5C,CAAC,EAEDO,EAAa,QAAQ,GAAG,OAASC,GAAU,CAC1CL,GAAUK,CACX,CAAC,EAEDD,EAAa,QAAQ,GAAG,OAASC,GAAU,CAC1CJ,GAAUI,CACX,CAAC,EAEDD,EAAa,GAAG,QAAUE,GAAa,CACtC,GAAIA,IAAa,EAAG,CACnB,IAAMC,EAAS,GAAGN,IAASD,IAE3BD,EAAOQ,EAAO,KAAK,CAAC,OAEpBT,EAAQE,EAAO,KAAK,CAAC,CAEvB,CAAC,CACF,CAAC,ECvCF,OAAOQ,MAAU,aAQV,IAAMC,EAAS,CACrBC,EACA,CACC,MAAAC,EACA,UAAAC,CACD,EAGI,CACH,MAAO,QACP,UAAW,CAAC,CACb,IACI,CACJ,IAAMC,EAA8C,CAAC,EAErD,OAAAA,EAAa,KAAKL,EAAKM,EAAYH,GAAS,OAAO,CAAC,CAAC,GAEpDC,GAAa,CAAC,GAAG,QAASG,GAAkB,CACxCA,IAAQ,YACXL,EAAUA,EAAQ,YAAY,EACpBK,IAAQ,YAClBL,EAAUA,EAAQ,YAAY,EAE9BG,EAAa,KAAKL,EAAKQ,EAAeD,CAAG,CAAC,CAAC,CAE7C,CAAC,EAEME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U,SCxLpC,IAAMC,GAAU,CACtB,KAAAC,EACA,OAAAC,EACA,QAAAC,CACD", -+ "names": ["spawn", "exec", "command", "options", "resolve", "reject", "stdout", "stderr", "bin", "args", "childProcess", "chunk", "exitCode", "output", "pico", "format", "message", "color", "modifiers", "transformers", "colorMapper", "mod", "modifierMapper", "compose", "fns", "prevFn", "nextFn", "value", "content", "label", "type", "defaultLabel", "icon", "method", "formatPropertiesByType", "messages", "msg", "createQueue", "items", "item", "getCommandController", "name", "controller", "commandControllerCollection", "createCommandController", "description", "instructions", "createQueue", "context", "metadata", "instruction", "key", "value", "task", "rootCommandName", "globalMetadata", "commandDescriptionCollection", "getCommandDescriptionCollection", "createCommand", "name", "description", "rootCommandName", "argv", "version", "isRootCommand", "isActiveCommand", "controller", "createCommandController", "rootController", "getCommandController", "optionKeys", "OPTION_HELP_NAMES", "showHelp", "OPTION_VERSION_NAMES", "currentCommandName", "commandMetadata", "options", "commands", "getCommandDescriptionCollection", "commandKeys", "hasOptions", "hasCommands", "printTitle", "print", "format", "padding", "value", "item", "commandDescription", "printLabelValue", "key", "parameters", "message", "label", "prompt", "createInput", "parameters", "key", "label", "defaultValue", "type", "context", "argv", "promptObject", "isMultiSelect", "choices", "option", "data", "createOption", "commandController", "argv", "parameters", "key", "name", "description", "defaultValue", "aliases", "metadataKey", "alias", "index", "value", "Listr", "PRESET_TIMER", "createTask", "parameters", "key", "label", "handler", "receiver", "context", "argv", "value", "fs", "path", "findNearestPackageJson", "pathname", "packagePathname", "path", "isFileExists", "__require", "fs", "getPackageMetadata", "mainFilename", "getArguments", "parameters", "command", "operands", "options", "currentOptionName", "addOptimisticOption", "name", "value", "castValue", "flushOptimisticOption", "parameter", "shortFlagMatchResult", "SHORT_FLAG_REGEX", "longFlagMatchResult", "LONG_FLAG_REGEX", "optionFlags", "lastIndex", "flag", "index", "termost", "metadata", "callbacks", "name", "description", "version", "isObject", "packageMetadata", "getPackageMetadata", "command", "operands", "options", "getArguments", "setGracefulListeners", "createProgram", "argv", "rootCommandName", "currentCommandName", "createInstruction", "factory", "params", "instruction", "controller", "getCommandController", "skip", "context", "output", "program", "createCommand", "createInput", "createOption", "createTask", "onException", "onShutdown", "error", "reason", "value", "helpers", "exec", "format", "message"] - } diff --git a/yarn.lock b/yarn.lock index 42ce7d9c..0f68cf9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3886,11 +3886,6 @@ resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== -"@yarnpkg/lockfile@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31" - integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ== - accepts@~1.3.5, accepts@~1.3.8: version "1.3.8" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" @@ -4040,12 +4035,10 @@ ansi-escapes@^4.3.0: dependencies: type-fest "^0.21.3" -ansi-escapes@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-5.0.0.tgz#b6a0caf0eef0c41af190e9a749e0c00ec04bb2a6" - integrity sha512-5GFMVX8HqE/TB+FuBJGuO5XG0WrsA6ptUqoODaT/n9mmUaZFkqnBueB4leqGBCmrUHnCnC4PCZTCd0E7QQ83bA== - dependencies: - type-fest "^1.0.2" +ansi-escapes@^6.2.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-6.2.1.tgz#76c54ce9b081dad39acec4b5d53377913825fb0f" + integrity sha512-4nJ3yixlEthEJ9Rk4vPcdBRkZvQZlYyu8j4/Mqz5sgIkddmEnH2Yj2ZrnP9S3tQOvSNRUIgVNF/1yPpRAGNRig== ansi-html-community@0.0.8, ansi-html-community@^0.0.8: version "0.0.8" @@ -4091,7 +4084,7 @@ ansi-styles@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== -ansi-styles@^6.0.0, ansi-styles@^6.1.0: +ansi-styles@^6.0.0, ansi-styles@^6.2.1: version "6.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== @@ -4881,17 +4874,6 @@ call-bind@^1.0.0, call-bind@^1.0.2: function-bind "^1.1.1" get-intrinsic "^1.0.2" -call-bind@^1.0.5: - version "1.0.7" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.7.tgz#06016599c40c56498c18769d2730be242b6fa3b9" - integrity sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w== - dependencies: - es-define-property "^1.0.0" - es-errors "^1.3.0" - function-bind "^1.1.2" - get-intrinsic "^1.2.4" - set-function-length "^1.2.1" - call-me-maybe@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.2.tgz#03f964f19522ba643b1b0693acb9152fe2074baa" @@ -5121,11 +5103,6 @@ ci-info@^2.0.0: resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== -ci-info@^3.7.0: - version "3.9.0" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" - integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ== - cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" @@ -5206,13 +5183,13 @@ cli-truncate@2.1.0, cli-truncate@^2.1.0: slice-ansi "^3.0.0" string-width "^4.2.0" -cli-truncate@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-3.1.0.tgz#3f23ab12535e3d73e839bb43e73c9de487db1389" - integrity sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA== +cli-truncate@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-4.0.0.tgz#6cc28a2924fee9e25ce91e973db56c7066e6172a" + integrity sha512-nPdaFdQ0h/GEigbPClz11D0v/ZJEwxmeVZGeMo3Z5StPtUTkA9o1lD6QwoirYiSDzbcwn2XcjwmCp68W1IS4TA== dependencies: slice-ansi "^5.0.0" - string-width "^5.0.0" + string-width "^7.0.0" cliui@^5.0.0: version "5.0.0" @@ -5785,15 +5762,6 @@ default-browser-id@^1.0.4: meow "^3.1.0" untildify "^2.0.0" -define-data-property@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" - integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== - dependencies: - es-define-property "^1.0.0" - es-errors "^1.3.0" - gopd "^1.0.1" - define-lazy-prop@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz#3f7ae421129bcaaac9bc74905c98a0009ec9ee7f" @@ -6024,11 +5992,6 @@ duplexify@^3.4.2, duplexify@^3.6.0: readable-stream "^2.0.0" stream-shift "^1.0.0" -eastasianwidth@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" - integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== - ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -6064,6 +6027,11 @@ elliptic@^6.5.3: minimalistic-assert "^1.0.1" minimalistic-crypto-utils "^1.0.1" +emoji-regex@^10.3.0: + version "10.3.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-10.3.0.tgz#76998b9268409eb3dae3de989254d456e70cfe23" + integrity sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw== + emoji-regex@^7.0.1: version "7.0.3" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" @@ -6074,11 +6042,6 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -emoji-regex@^9.2.2: - version "9.2.2" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" - integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== - emojis-list@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" @@ -6225,18 +6188,6 @@ es-array-method-boxes-properly@^1.0.0: resolved "https://registry.yarnpkg.com/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz#873f3e84418de4ee19c5be752990b2e44718d09e" integrity sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA== -es-define-property@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.0.tgz#c7faefbdff8b2696cf5f46921edfb77cc4ba3845" - integrity sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ== - dependencies: - get-intrinsic "^1.2.4" - -es-errors@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" - integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== - es-get-iterator@^1.0.2, es-get-iterator@^1.1.2: version "1.1.3" resolved "https://registry.yarnpkg.com/es-get-iterator/-/es-get-iterator-1.1.3.tgz#3ef87523c5d464d41084b2c3c9c214f1199763d6" @@ -6867,13 +6818,6 @@ find-versions@^4.0.0: dependencies: semver-regex "^3.1.2" -find-yarn-workspace-root@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd" - integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ== - dependencies: - micromatch "^4.0.2" - flat-cache@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" @@ -7064,11 +7008,6 @@ function-bind@^1.1.1: resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== -function-bind@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" - integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== - function.prototype.name@^1.1.0, function.prototype.name@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.5.tgz#cce0505fe1ffb80503e6f9e46cc64e46a12a9621" @@ -7109,6 +7048,11 @@ get-caller-file@^2.0.1, get-caller-file@^2.0.5: resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== +get-east-asian-width@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/get-east-asian-width/-/get-east-asian-width-1.2.0.tgz#5e6ebd9baee6fb8b7b6bd505221065f0cd91f64e" + integrity sha512-2nk+7SIVb14QrgXFHcm84tD4bKQz0RxPuMT8Ag5KPOq7J5fEmAg0UbXdTOSHqNuHSU28k55qnceesxXRZGzKWA== + get-func-name@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" @@ -7128,17 +7072,6 @@ get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@ has "^1.0.3" has-symbols "^1.0.3" -get-intrinsic@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.4.tgz#e385f5a4b5227d449c3eabbad05494ef0abbeadd" - integrity sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ== - dependencies: - es-errors "^1.3.0" - function-bind "^1.1.2" - has-proto "^1.0.1" - has-symbols "^1.0.3" - hasown "^2.0.0" - get-own-enumerable-property-symbols@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz#b5fde77f22cbe35f390b4e089922c50bce6ef664" @@ -7349,13 +7282,6 @@ has-property-descriptors@^1.0.0: dependencies: get-intrinsic "^1.1.1" -has-property-descriptors@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" - integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== - dependencies: - es-define-property "^1.0.0" - has-proto@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.1.tgz#1885c1305538958aff469fef37937c22795408e0" @@ -7433,13 +7359,6 @@ hash.js@^1.0.0, hash.js@^1.0.3: inherits "^2.0.3" minimalistic-assert "^1.0.1" -hasown@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" - integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== - dependencies: - function-bind "^1.1.2" - hast-to-hyperscript@^9.0.0: version "9.0.1" resolved "https://registry.yarnpkg.com/hast-to-hyperscript/-/hast-to-hyperscript-9.0.1.tgz#9b67fd188e4c81e8ad66f803855334173920218d" @@ -8048,6 +7967,13 @@ is-fullwidth-code-point@^4.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz#fae3167c729e7463f8461ce512b080a49268aa88" integrity sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ== +is-fullwidth-code-point@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-5.0.0.tgz#9609efced7c2f97da7b60145ef481c787c7ba704" + integrity sha512-OVa3u9kkBbw7b8Xw5F9P+D/T9X+Z4+JruYVNapTjPYZYUznQ5YfWeFkOj606XYYW8yugTfC8Pj0hYqvi4ryAhA== + dependencies: + get-east-asian-width "^1.0.0" + is-function@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.2.tgz#4f097f30abf6efadac9833b17ca5dc03f8144e08" @@ -8493,16 +8419,6 @@ json-schema-traverse@^0.4.1: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== -json-stable-stringify@^1.0.2: - version "1.1.1" - resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.1.1.tgz#52d4361b47d49168bcc4e564189a42e5a7439454" - integrity sha512-SU/971Kt5qVQfJpyDveVhQ/vya+5hvrjClFOcr8c0Fq5aODJjMwutrOfCU+eCnVD5gpx1Q3fEqkyom77zH1iIg== - dependencies: - call-bind "^1.0.5" - isarray "^2.0.5" - jsonify "^0.0.1" - object-keys "^1.1.1" - json5@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" @@ -8524,11 +8440,6 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" -jsonify@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.1.tgz#2aa3111dae3d34a0f151c63f3a45d995d9420978" - integrity sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg== - junk@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/junk/-/junk-3.1.0.tgz#31499098d902b7e98c5d9b9c80f43457a88abfa1" @@ -8558,13 +8469,6 @@ kind-of@^6.0.0, kind-of@^6.0.2: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== -klaw-sync@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c" - integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ== - dependencies: - graceful-fs "^4.1.11" - kleur@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" @@ -8633,17 +8537,17 @@ listr2@^3.12.2: through "^2.3.8" wrap-ansi "^7.0.0" -listr2@^7.0.1: - version "7.0.2" - resolved "https://registry.yarnpkg.com/listr2/-/listr2-7.0.2.tgz#3aa3e1549dfaf3c57ab5eeaba754da3b87f33063" - integrity sha512-rJysbR9GKIalhTbVL2tYbF2hVyDnrf7pFUZBwjPaMIdadYHmeT+EVi/Bu3qd7ETQPahTotg2WRCatXwRBW554g== +listr2@^8.0.1: + version "8.2.1" + resolved "https://registry.yarnpkg.com/listr2/-/listr2-8.2.1.tgz#06a1a6efe85f23c5324180d7c1ddbd96b5eefd6d" + integrity sha512-irTfvpib/rNiD637xeevjO2l3Z5loZmuaRi0L0YE5LfijwVY96oyVn0DFD3o/teAok7nfobMG1THvvcHh/BP6g== dependencies: - cli-truncate "^3.1.0" + cli-truncate "^4.0.0" colorette "^2.0.20" eventemitter3 "^5.0.1" - log-update "^5.0.1" - rfdc "^1.3.0" - wrap-ansi "^8.1.0" + log-update "^6.0.0" + rfdc "^1.3.1" + wrap-ansi "^9.0.0" load-json-file@^1.0.0: version "1.1.0" @@ -8749,16 +8653,16 @@ log-update@^4.0.0: slice-ansi "^4.0.0" wrap-ansi "^6.2.0" -log-update@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/log-update/-/log-update-5.0.1.tgz#9e928bf70cb183c1f0c9e91d9e6b7115d597ce09" - integrity sha512-5UtUDQ/6edw4ofyljDNcOVJQ4c7OjDro4h3y8e1GQL5iYElYclVHJ3zeWchylvMaKnDbDilC8irOVyexnA/Slw== +log-update@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/log-update/-/log-update-6.0.0.tgz#0ddeb7ac6ad658c944c1de902993fce7c33f5e59" + integrity sha512-niTvB4gqvtof056rRIrTZvjNYE4rCUzO6X/X+kYjd7WFxXeJ0NwEFnRxX6ehkvv3jTwrXnNdtAak5XYZuIyPFw== dependencies: - ansi-escapes "^5.0.0" + ansi-escapes "^6.2.0" cli-cursor "^4.0.0" - slice-ansi "^5.0.0" - strip-ansi "^7.0.1" - wrap-ansi "^8.0.1" + slice-ansi "^7.0.0" + strip-ansi "^7.1.0" + wrap-ansi "^9.0.0" loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0: version "1.4.0" @@ -9688,7 +9592,7 @@ onetime@^6.0.0: dependencies: mimic-fn "^4.0.0" -open@^7.0.3, open@^7.4.2: +open@^7.0.3: version "7.4.2" resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321" integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q== @@ -9732,11 +9636,6 @@ os-homedir@^1.0.0: resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" integrity sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ== -os-tmpdir@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== - p-all@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/p-all/-/p-all-2.1.0.tgz#91419be56b7dee8fe4c5db875d55e0da084244a0" @@ -9948,27 +9847,6 @@ pascalcase@^0.1.1: resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" integrity sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw== -patch-package@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-8.0.0.tgz#d191e2f1b6e06a4624a0116bcb88edd6714ede61" - integrity sha512-da8BVIhzjtgScwDJ2TtKsfT5JFWz1hYoBl9rUQ1f38MC2HwnEIkK8VN3dKMKcP7P7bvvgzNDbfNHtx3MsQb5vA== - dependencies: - "@yarnpkg/lockfile" "^1.1.0" - chalk "^4.1.2" - ci-info "^3.7.0" - cross-spawn "^7.0.3" - find-yarn-workspace-root "^2.0.0" - fs-extra "^9.0.0" - json-stable-stringify "^1.0.2" - klaw-sync "^6.0.0" - minimist "^1.2.6" - open "^7.4.2" - rimraf "^2.6.3" - semver "^7.5.3" - slash "^2.0.0" - tmp "^0.0.33" - yaml "^2.2.2" - path-browserify@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" @@ -11061,6 +10939,11 @@ rfdc@^1.3.0: resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== +rfdc@^1.3.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.4.1.tgz#778f76c4fb731d93414e8f925fbecf64cce7f6ca" + integrity sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA== + rimraf@^2.5.4, rimraf@^2.6.3: version "2.7.1" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" @@ -11267,11 +11150,6 @@ semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7: dependencies: lru-cache "^6.0.0" -semver@^7.5.3: - version "7.6.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.2.tgz#1e3b34759f896e8f14d6134732ce798aeb0c6e13" - integrity sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w== - send@0.18.0: version "0.18.0" resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be" @@ -11338,18 +11216,6 @@ set-blocking@^2.0.0: resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw== -set-function-length@^1.2.1: - version "1.2.2" - resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" - integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== - dependencies: - define-data-property "^1.1.4" - es-errors "^1.3.0" - function-bind "^1.1.2" - get-intrinsic "^1.2.4" - gopd "^1.0.1" - has-property-descriptors "^1.0.2" - set-value@^2.0.0, set-value@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" @@ -11479,6 +11345,14 @@ slice-ansi@^5.0.0: ansi-styles "^6.0.0" is-fullwidth-code-point "^4.0.0" +slice-ansi@^7.0.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-7.1.0.tgz#cd6b4655e298a8d1bdeb04250a433094b347b9a9" + integrity sha512-bSiSngZ/jWeX93BqeIAbImyTbEihizcwNjFoRUIY/T1wWQsfsm2Vw1agPKylXvQTU7iASGdHhyqRlqQzfz+Htg== + dependencies: + ansi-styles "^6.2.1" + is-fullwidth-code-point "^5.0.0" + smart-buffer@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.2.0.tgz#6e1d71fa4f18c05f7d0ff216dd16a481d0e8d9ae" @@ -11768,14 +11642,14 @@ string-width@^3.0.0, string-width@^3.1.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" -string-width@^5.0.0, string-width@^5.0.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" - integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== +string-width@^7.0.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-7.1.0.tgz#d994252935224729ea3719c49f7206dc9c46550a" + integrity sha512-SEIJCWiX7Kg4c129n48aDRwLbFb2LJmXXFrWBG4NGaRtMQ3myKPKbwrD1BKqQn74oCoNMBVrfDEr5M9YxCsrkw== dependencies: - eastasianwidth "^0.2.0" - emoji-regex "^9.2.2" - strip-ansi "^7.0.1" + emoji-regex "^10.3.0" + get-east-asian-width "^1.0.0" + strip-ansi "^7.1.0" string.prototype.codepointat@^0.2.0: version "0.2.1" @@ -11885,10 +11759,10 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: dependencies: ansi-regex "^5.0.1" -strip-ansi@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2" - integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== +strip-ansi@^7.1.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== dependencies: ansi-regex "^6.0.1" @@ -12045,13 +11919,13 @@ telejson@^6.0.8: lodash "^4.17.21" memoizerific "^1.11.3" -termost@^0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/termost/-/termost-0.12.0.tgz#ca15c83fe3b2dfc83be0dcf4215aafad3bc6c018" - integrity sha512-7MbYVQvdhaZHSy/mO8TM6yXcDTS2wkeLiWIwoUL43n6wo4NSO38V3GNsBRlI4zcl8vQzm+bmqplyqOTYVZCpFw== +termost@^v0.12.1: + version "0.12.1" + resolved "https://registry.yarnpkg.com/termost/-/termost-0.12.1.tgz#c1debbaaa8ae503c6ab57d2aa94518ae71647b29" + integrity sha512-jcfEHVbbYseoc2WRlb0c9vuV65Za/duEMm+A/O9nGXkhSqNBd5GkbcS6cSu4xOTQ/NTrXYQ3muONnniRaQTKuQ== dependencies: enquirer "^2.4.1" - listr2 "^7.0.1" + listr2 "^8.0.1" picocolors "^1.0.0" terser-webpack-plugin@^1.4.3: @@ -12171,13 +12045,6 @@ tinyspy@^2.2.0: resolved "https://registry.yarnpkg.com/tinyspy/-/tinyspy-2.2.1.tgz#117b2342f1f38a0dbdcc73a50a454883adf861d1" integrity sha512-KYad6Vy5VDWV4GH3fjpseMQ/XU2BhIYP7Vzd0LG44qRWm/Yt2WCOTicFdvmgo6gWaqooMQCawTtILVQJupKu7A== -tmp@^0.0.33: - version "0.0.33" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" - integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== - dependencies: - os-tmpdir "~1.0.2" - tmpl@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" @@ -12355,11 +12222,6 @@ type-fest@^0.8.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== -type-fest@^1.0.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-1.4.0.tgz#e9fb813fe3bf1744ec359d55d1affefa76f14be1" - integrity sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA== - type-is@~1.6.18: version "1.6.18" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" @@ -13147,14 +13009,14 @@ wrap-ansi@^7.0.0: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^8.0.1, wrap-ansi@^8.1.0: - version "8.1.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" - integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== +wrap-ansi@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-9.0.0.tgz#1a3dc8b70d85eeb8398ddfb1e4a02cd186e58b3e" + integrity sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q== dependencies: - ansi-styles "^6.1.0" - string-width "^5.0.1" - strip-ansi "^7.0.1" + ansi-styles "^6.2.1" + string-width "^7.0.0" + strip-ansi "^7.1.0" wrappy@1: version "1.0.2" @@ -13213,11 +13075,6 @@ yaml@^1.10.0, yaml@^1.7.2: resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== -yaml@^2.2.2: - version "2.4.3" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.4.3.tgz#0777516b8c7880bcaa0f426a5410e8d6b0be1f3d" - integrity sha512-sntgmxj8o7DE7g/Qi60cqpLBA3HG3STcDA0kO+WfB05jEKhZMbY7umNm2rBpQvsmZ16/lPXCJGW2672dgOUkrg== - yargs-parser@^13.1.2: version "13.1.2" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38"