@master4n/master-cli 2.2.5 → 2.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +1 -1
- package/package.json +2 -2
package/bin/index.js
CHANGED
|
@@ -31,5 +31,5 @@ let H;!function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARR
|
|
|
31
31
|
* Copyright (c) 2016, Contributors
|
|
32
32
|
* SPDX-License-Identifier: ISC
|
|
33
33
|
*/
|
|
34
|
-
var J,W,Q;const G=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,V=null!==(W=null===(J=null===process||void 0===process?void 0:process.versions)||void 0===J?void 0:J.node)&&void 0!==W?W:null===(Q=null===process||void 0===process?void 0:process.version)||void 0===Q?void 0:Q.slice(1);if(V){if(Number(V.match(/^([^.]+)/)[1])<G)throw Error(`yargs parser supports a minimum Node.js version of ${G}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const Z=process?process.env:{},K=new class{constructor(e){H=e}parse(e,t){const o=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),n=function(e){if(Array.isArray(e))return e.map((e=>"string"!=typeof e?e+"":e));e=e.trim();let t=0,o=null,n=null,r=null;const i=[];for(let s=0;s<e.length;s++)o=n,n=e.charAt(s)," "!==n||r?(n===r?r=null:"'"!==n&&'"'!==n||r||(r=n),i[t]||(i[t]=""),i[t]+=n):" "!==o&&t++;return i}(e),r="string"==typeof e,i=function(e){const t=[],o=Object.create(null);let n=!0;Object.keys(e).forEach((function(o){t.push([].concat(e[o],o))}));for(;n;){n=!1;for(let e=0;e<t.length;e++)for(let o=e+1;o<t.length;o++){if(t[e].filter((function(e){return-1!==t[o].indexOf(e)})).length){t[e]=t[e].concat(t[o]),t.splice(o,1),n=!0;break}}}return t.forEach((function(e){const t=(e=e.filter((function(e,t,o){return o.indexOf(e)===t}))).pop();void 0!==t&&"string"==typeof t&&(o[t]=e)})),o}(Object.assign(Object.create(null),o.alias)),s=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},o.configuration),a=Object.assign(Object.create(null),o.default),c=o.configObjects||[],l=o.envPrefix,p=s["populate--"],u=p?"--":"_",d=Object.create(null),f=Object.create(null),m=o.__||H.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},g=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,y=new RegExp("^--"+s["negation-prefix"]+"(.+)");[].concat(o.array||[]).filter(Boolean).forEach((function(e){const t="object"==typeof e?e.key:e,o=Object.keys(e).map((function(e){return{boolean:"bools",string:"strings",number:"numbers"}[e]})).filter(Boolean).pop();o&&(h[o][t]=!0),h.arrays[t]=!0,h.keys.push(t)})),[].concat(o.boolean||[]).filter(Boolean).forEach((function(e){h.bools[e]=!0,h.keys.push(e)})),[].concat(o.string||[]).filter(Boolean).forEach((function(e){h.strings[e]=!0,h.keys.push(e)})),[].concat(o.number||[]).filter(Boolean).forEach((function(e){h.numbers[e]=!0,h.keys.push(e)})),[].concat(o.count||[]).filter(Boolean).forEach((function(e){h.counts[e]=!0,h.keys.push(e)})),[].concat(o.normalize||[]).filter(Boolean).forEach((function(e){h.normalize[e]=!0,h.keys.push(e)})),"object"==typeof o.narg&&Object.entries(o.narg).forEach((([e,t])=>{"number"==typeof t&&(h.nargs[e]=t,h.keys.push(e))})),"object"==typeof o.coerce&&Object.entries(o.coerce).forEach((([e,t])=>{"function"==typeof t&&(h.coercions[e]=t,h.keys.push(e))})),void 0!==o.config&&(Array.isArray(o.config)||"string"==typeof o.config?[].concat(o.config).filter(Boolean).forEach((function(e){h.configs[e]=!0})):"object"==typeof o.config&&Object.entries(o.config).forEach((([e,t])=>{"boolean"!=typeof t&&"function"!=typeof t||(h.configs[e]=t)}))),function(...e){e.forEach((function(e){Object.keys(e||{}).forEach((function(e){h.aliases[e]||(h.aliases[e]=[].concat(i[e]||[]),h.aliases[e].concat(e).forEach((function(t){if(/-/.test(t)&&s["camel-case-expansion"]){const o=I(t);o!==e&&-1===h.aliases[e].indexOf(o)&&(h.aliases[e].push(o),d[o]=!0)}})),h.aliases[e].concat(e).forEach((function(t){if(t.length>1&&/[A-Z]/.test(t)&&s["camel-case-expansion"]){const o=P(t,"-");o!==e&&-1===h.aliases[e].indexOf(o)&&(h.aliases[e].push(o),d[o]=!0)}})),h.aliases[e].forEach((function(t){h.aliases[t]=[e].concat(h.aliases[e].filter((function(e){return t!==e})))})))}))}))}(o.key,i,o.default,h.arrays),Object.keys(a).forEach((function(e){(h.aliases[e]||[]).forEach((function(t){a[t]=a[e]}))}));let b=null;Object.keys(h.counts).find((e=>R(e,h.arrays)?(b=Error(m("Invalid configuration: %s, opts.count excludes opts.array.",e)),!0):!!R(e,h.nargs)&&(b=Error(m("Invalid configuration: %s, opts.count excludes opts.narg.",e)),!0)));let v=[];const w=Object.assign(Object.create(null),{_:[]}),j={};for(let e=0;e<n.length;e++){const t=n[e],o=t.replace(/^-{3,}/,"---");let r,i,a,c,l,p;if("--"!==t&&/^-/.test(t)&&z(t))S(t);else{if(o.match(/^---+(=|$)/)){S(t);continue}if(t.match(/^--.+=/)||!s["short-option-groups"]&&t.match(/^-.+=/))c=t.match(/^--?([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&(R(c[1],h.arrays)?e=$(e,c[1],n,c[2]):!1!==R(c[1],h.nargs)?e=x(e,c[1],n,c[2]):E(c[1],c[2],!0));else if(t.match(y)&&s["boolean-negation"])c=t.match(y),null!==c&&Array.isArray(c)&&c.length>=2&&(i=c[1],E(i,!!R(i,h.arrays)&&[!1]));else if(t.match(/^--.+/)||!s["short-option-groups"]&&t.match(/^-[^-]+/))c=t.match(/^--?(.+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(i=c[1],R(i,h.arrays)?e=$(e,i,n):!1!==R(i,h.nargs)?e=x(e,i,n):(l=n[e+1],void 0===l||l.match(/^-/)&&!l.match(g)||R(i,h.bools)||R(i,h.counts)?/^(true|false)$/.test(l)?(E(i,l),e++):E(i,F(i)):(E(i,l),e++)));else if(t.match(/^-.\..+=/))c=t.match(/^-([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&E(c[1],c[2]);else if(t.match(/^-.\..+/)&&!t.match(g))l=n[e+1],c=t.match(/^-(.\..+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(i=c[1],void 0===l||l.match(/^-/)||R(i,h.bools)||R(i,h.counts)?E(i,F(i)):(E(i,l),e++));else if(t.match(/^-[^-]+/)&&!t.match(g)){a=t.slice(1,-1).split(""),r=!1;for(let o=0;o<a.length;o++){if(l=t.slice(o+2),a[o+1]&&"="===a[o+1]){p=t.slice(o+3),i=a[o],R(i,h.arrays)?e=$(e,i,n,p):!1!==R(i,h.nargs)?e=x(e,i,n,p):E(i,p),r=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[o])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===R(l,h.bools)){E(a[o],l),r=!0;break}if(a[o+1]&&a[o+1].match(/\W/)){E(a[o],l),r=!0;break}E(a[o],F(a[o]))}else E(a[o],l)}i=t.slice(-1)[0],r||"-"===i||(R(i,h.arrays)?e=$(e,i,n):!1!==R(i,h.nargs)?e=x(e,i,n):(l=n[e+1],void 0===l||/^(-|--)[^-]/.test(l)&&!l.match(g)||R(i,h.bools)||R(i,h.counts)?/^(true|false)$/.test(l)?(E(i,l),e++):E(i,F(i)):(E(i,l),e++)))}else if(t.match(/^-[0-9]$/)&&t.match(g)&&R(t.slice(1),h.bools))i=t.slice(1),E(i,F(i));else{if("--"===t){v=n.slice(e+1);break}if(s["halt-at-non-option"]){v=n.slice(e);break}S(t)}}}function S(e){const t=k("_",e);"string"!=typeof t&&"number"!=typeof t||w._.push(t)}function x(e,t,o,n){let r,i=R(t,h.nargs);if(i="number"!=typeof i||isNaN(i)?1:i,0===i)return L(n)||(b=Error(m("Argument unexpected for: %s",t))),E(t,F(t)),e;let a=L(n)?0:1;if(s["nargs-eats-options"])o.length-(e+1)+a<i&&(b=Error(m("Not enough arguments following: %s",t))),a=i;else{for(r=e+1;r<o.length&&(!o[r].match(/^-[^0-9]/)||o[r].match(g)||z(o[r]));r++)a++;a<i&&(b=Error(m("Not enough arguments following: %s",t)))}let c=Math.min(a,i);for(!L(n)&&c>0&&(E(t,n),c--),r=e+1;r<c+e+1;r++)E(t,o[r]);return e+c}function $(e,t,o,n){let i=[],c=n||o[e+1];const l=R(t,h.nargs);if(R(t,h.bools)&&!/^(true|false)$/.test(c))i.push(!0);else if(L(c)||L(n)&&/^-/.test(c)&&!g.test(c)&&!z(c)){if(void 0!==a[t]){const e=a[t];i=Array.isArray(e)?e:[e]}}else{L(n)||i.push(A(t,n,!0));for(let n=e+1;n<o.length&&!(!s["greedy-arrays"]&&i.length>0||l&&"number"==typeof l&&i.length>=l)&&(c=o[n],!/^-/.test(c)||g.test(c)||z(c));n++)e=n,i.push(A(t,c,r))}return"number"==typeof l&&(l&&i.length<l||isNaN(l)&&0===i.length)&&(b=Error(m("Not enough arguments following: %s",t))),E(t,i),e}function E(e,t,o=r){if(/-/.test(e)&&s["camel-case-expansion"]){const t=e.split(".").map((function(e){return I(e)})).join(".");O(e,t)}const n=A(e,t,o),i=e.split(".");if(N(w,i,n),h.aliases[e]&&h.aliases[e].forEach((function(e){const t=e.split(".");N(w,t,n)})),i.length>1&&s["dot-notation"]&&(h.aliases[i[0]]||[]).forEach((function(t){let o=t.split(".");const r=[].concat(i);r.shift(),o=o.concat(r),(h.aliases[e]||[]).includes(o.join("."))||N(w,o,n)})),R(e,h.normalize)&&!R(e,h.arrays)){[e].concat(h.aliases[e]||[]).forEach((function(e){Object.defineProperty(j,e,{enumerable:!0,get:()=>t,set(e){t="string"==typeof e?H.normalize(e):e}})}))}}function O(e,t){h.aliases[e]&&h.aliases[e].length||(h.aliases[e]=[t],d[t]=!0),h.aliases[t]&&h.aliases[t].length||O(t,e)}function A(e,t,o){o&&(t=function(e){return"string"!=typeof e||"'"!==e[0]&&'"'!==e[0]||e[e.length-1]!==e[0]?e:e.substring(1,e.length-1)}(t)),(R(e,h.bools)||R(e,h.counts))&&"string"==typeof t&&(t="true"===t);let n=Array.isArray(t)?t.map((function(t){return k(e,t)})):k(e,t);return R(e,h.counts)&&(L(n)||"boolean"==typeof n)&&(n=C()),R(e,h.normalize)&&R(e,h.arrays)&&(n=Array.isArray(t)?t.map((e=>H.normalize(e))):H.normalize(t)),n}function k(e,t){if(!s["parse-positional-numbers"]&&"_"===e)return t;if(!R(e,h.strings)&&!R(e,h.bools)&&!Array.isArray(t)){(B(t)&&s["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))||!L(t)&&R(e,h.numbers))&&(t=Number(t))}return t}function M(e,t){Object.keys(e).forEach((function(o){const n=e[o],r=t?t+"."+o:o;"object"==typeof n&&null!==n&&!Array.isArray(n)&&s["dot-notation"]?M(n,r):(!Y(w,r.split("."))||R(r,h.arrays)&&s["combine-arrays"])&&E(r,n)}))}function D(e,t){if(void 0===l)return;const o="string"==typeof l?l:"",n=H.env();Object.keys(n).forEach((function(r){if(""===o||0===r.lastIndexOf(o,0)){const i=r.split("__").map((function(e,t){return 0===t&&(e=e.substring(o.length)),I(e)}));(t&&h.configs[i.join(".")]||!t)&&!Y(e,i)&&E(i.join("."),n[r])}}))}function T(e,t,o,n=!1){Object.keys(o).forEach((function(r){Y(e,r.split("."))||(N(e,r.split("."),o[r]),n&&(f[r]=!0),(t[r]||[]).forEach((function(t){Y(e,t.split("."))||N(e,t.split("."),o[r])})))}))}function Y(e,t){let o=e;s["dot-notation"]||(t=[t.join(".")]),t.slice(0,-1).forEach((function(e){o=o[e]||{}}));const n=t[t.length-1];return"object"==typeof o&&n in o}function N(e,t,o){let n=e;s["dot-notation"]||(t=[t.join(".")]),t.slice(0,-1).forEach((function(e){e=U(e),"object"==typeof n&&void 0===n[e]&&(n[e]={}),"object"!=typeof n[e]||Array.isArray(n[e])?(Array.isArray(n[e])?n[e].push({}):n[e]=[n[e],{}],n=n[e][n[e].length-1]):n=n[e]}));const r=U(t[t.length-1]),i=R(t.join("."),h.arrays),a=Array.isArray(o);let c=s["duplicate-arguments-array"];!c&&R(r,h.nargs)&&(c=!0,(!L(n[r])&&1===h.nargs[r]||Array.isArray(n[r])&&n[r].length===h.nargs[r])&&(n[r]=void 0)),o===C()?n[r]=C(n[r]):Array.isArray(n[r])?c&&i&&a?n[r]=s["flatten-duplicate-arrays"]?n[r].concat(o):(Array.isArray(n[r][0])?n[r]:[n[r]]).concat([o]):c||Boolean(i)!==Boolean(a)?n[r]=n[r].concat([o]):n[r]=o:void 0===n[r]&&i?n[r]=a?o:[o]:!c||void 0===n[r]||R(r,h.counts)||R(r,h.bools)?n[r]=o:n[r]=[n[r],o]}function R(e,t){const o=[].concat(h.aliases[e]||[],e),n=Object.keys(t),r=o.find((e=>n.includes(e)));return!!r&&t[r]}function _(e){const t=Object.keys(h);return[].concat(t.map((e=>h[e]))).some((function(t){return Array.isArray(t)?t.includes(e):t[e]}))}function z(e){return s["unknown-options-as-args"]&&function(e){if(e=e.replace(/^-{3,}/,"--"),e.match(g))return!1;if(function(e){if(e.match(g)||!e.match(/^-[^-]+/))return!1;let t,o=!0;const n=e.slice(1).split("");for(let r=0;r<n.length;r++){if(t=e.slice(r+2),!_(n[r])){o=!1;break}if(n[r+1]&&"="===n[r+1]||"-"===t||/[A-Za-z]/.test(n[r])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(t)||n[r+1]&&n[r+1].match(/\W/))break}return o}(e))return!1;return!function(e,...t){return[].concat(...t).some((function(t){const o=e.match(t);return o&&_(o[1])}))}(e,/^-+([^=]+?)=[\s\S]*$/,y,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}(e)}function F(e){return R(e,h.bools)||R(e,h.counts)||!(`${e}`in a)?function(e){return{[q.BOOLEAN]:!0,[q.STRING]:"",[q.NUMBER]:void 0,[q.ARRAY]:[]}[e]}(function(e){let t=q.BOOLEAN;R(e,h.strings)?t=q.STRING:R(e,h.numbers)?t=q.NUMBER:R(e,h.bools)?t=q.BOOLEAN:R(e,h.arrays)&&(t=q.ARRAY);return t}(e)):a[e]}function L(e){return void 0===e}return D(w,!0),D(w,!1),function(e){const t=Object.create(null);T(t,h.aliases,a),Object.keys(h.configs).forEach((function(o){const n=e[o]||t[o];if(n)try{let e=null;const t=H.resolve(H.cwd(),n),r=h.configs[o];if("function"==typeof r){try{e=r(t)}catch(t){e=t}if(e instanceof Error)return void(b=e)}else e=H.require(t);M(e)}catch(t){"PermissionDenied"===t.name?b=t:e[o]&&(b=Error(m("Invalid JSON config file: %s",n)))}}))}(w),void 0!==c&&c.forEach((function(e){M(e)})),T(w,h.aliases,a,!0),function(e){let t;const o=new Set;Object.keys(e).forEach((function(n){if(!o.has(n)&&(t=R(n,h.coercions),"function"==typeof t))try{const r=k(n,t(e[n]));[].concat(h.aliases[n]||[],n).forEach((t=>{o.add(t),e[t]=r}))}catch(e){b=e}}))}(w),s["set-placeholder-key"]&&function(e){h.keys.forEach((t=>{~t.indexOf(".")||void 0===e[t]&&(e[t]=void 0)}))}(w),Object.keys(h.counts).forEach((function(e){Y(w,e.split("."))||E(e,0)})),p&&v.length&&(w[u]=[]),v.forEach((function(e){w[u].push(e)})),s["camel-case-expansion"]&&s["strip-dashed"]&&Object.keys(w).filter((e=>"--"!==e&&e.includes("-"))).forEach((e=>{delete w[e]})),s["strip-aliased"]&&[].concat(...Object.keys(i).map((e=>i[e]))).forEach((e=>{s["camel-case-expansion"]&&e.includes("-")&&delete w[e.split(".").map((e=>I(e))).join(".")],delete w[e]})),{aliases:Object.assign({},h.aliases),argv:Object.assign(j,w),configuration:s,defaulted:Object.assign({},f),error:b,newAliases:Object.assign({},d)}}}({cwd:process.cwd,env:()=>Z,format:t,normalize:r,resolve:i,require:e=>{if("undefined"!=typeof require)return require(e);if(e.match(/\.json$/))return JSON.parse(u(e,"utf8"));throw Error("only .json config files are supported in ESM")}}),X=function(e,t){return K.parse(e.slice(),t).argv};X.detailed=function(e,t){return K.parse(e.slice(),t)},X.camelCase=I,X.decamelize=P,X.looksLikeNumber=B;new RegExp("(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");var ee={fs:{readFileSync:u,writeFile:m},format:t,resolve:i,exists:e=>{try{return d(e).isFile()}catch(e){return!1}}};let te;class oe{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles="boolean"!=typeof e.updateFiles||e.updateFiles,this.locale=e.locale||"en",this.fallbackToLanguage="boolean"!=typeof e.fallbackToLanguage||e.fallbackToLanguage,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if("string"!=typeof arguments[0])return this._taggedLiteral(arguments[0],...arguments);const t=e.shift();let o=function(){};return"function"==typeof e[e.length-1]&&(o=e.pop()),o=o||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:o})):o(),te.format.apply(te.format,[this.cache[this.locale][t]||t].concat(e))}__n(){const e=Array.prototype.slice.call(arguments),t=e.shift(),o=e.shift(),n=e.shift();let r=function(){};"function"==typeof e[e.length-1]&&(r=e.pop()),this.cache[this.locale]||this._readLocaleFile();let i=1===n?t:o;if(this.cache[this.locale][t]){i=this.cache[this.locale][t][1===n?"one":"other"]}!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]={one:t,other:o},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:r})):r();const s=[i];return~i.indexOf("%d")&&s.push(n),te.format.apply(te.format,s.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){this.cache[this.locale]||this._readLocaleFile();for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(this.cache[this.locale][t]=e[t])}_taggedLiteral(e,...t){let o="";return e.forEach((function(e,n){const r=t[n+1];o+=e,void 0!==r&&(o+="%s")})),this.__.apply(this,[o].concat([].slice.call(t,1)))}_enqueueWrite(e){this.writeQueue.push(e),1===this.writeQueue.length&&this._processWriteQueue()}_processWriteQueue(){const e=this,t=this.writeQueue[0],o=t.directory,n=t.locale,r=t.cb,i=this._resolveLocaleFile(o,n),s=JSON.stringify(this.cache[n],null,2);te.fs.writeFile(i,s,"utf-8",(function(t){e.writeQueue.shift(),e.writeQueue.length>0&&e._processWriteQueue(),r(t)}))}_readLocaleFile(){let e={};const t=this._resolveLocaleFile(this.directory,this.locale);try{te.fs.readFileSync&&(e=JSON.parse(te.fs.readFileSync(t,"utf-8")))}catch(o){if(o instanceof SyntaxError&&(o.message="syntax error in "+t),"ENOENT"!==o.code)throw o;e={}}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let o=te.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(o)&&~t.lastIndexOf("_")){const n=te.resolve(e,"./",t.split("_")[0]+".json");this._fileExistsSync(n)&&(o=n)}return o}_fileExistsSync(e){return te.exists(e)}}let ne;try{ne=y(import.meta.url)}catch(e){ne=process.cwd()}ne.substring(0,ne.lastIndexOf("node_modules"))||process.cwd(),process.cwd,process.exit,process.nextTick,void 0!==process.stdout.columns&&process.stdout.columns,function(e,t){te=t;const o=new oe(e);o.__.bind(o),o.__n.bind(o),o.setLocale.bind(o),o.getLocale.bind(o),o.updateLocale.bind(o),o.locale}({directory:i(ne,"../../../locales"),updateFiles:!1},ee);function re(){return{info:e=>{return console.log(`${b.blue("INFO")} [${b.magenta(S().format("YYYY/MM/DDTHH:mm:ss.SSSSSS"))}] ${t=e,b.white(t)}\n`);var t},warn:e=>{return console.log(`${b.yellow("WARN")} [${b.magenta(S().format("YYYY/MM/DDTHH:mm:ss.SSSSSS"))}] ${t=e,b.white(t)}`);var t},error:e=>{return console.log(`${b.red("ERROR")} [${b.magenta(S().format("YYYY/MM/DDTHH:mm:ss.SSSSSS"))}] ${t=e,b.white(t)}`);var t},debug:e=>{return console.log(`${b.cyan("DEBUG")} [${b.magenta(S().format("YYYY/MM/DDTHH:mm:ss.SSSSSS"))}] ${t=e,b.white(t)}`);var t}}}function ie(e){return{add:(t,o,n,r)=>{e.command({command:t,describe:o,builder:n,handler:r})}}}function se(){const e=x.homedir();return n.join(e,".mfn","cache")}function ae(...e){for(const t of e)if(isNaN(t)||t<1)return!1;return!0}function ce(e,t="INR",o="en-IN"){return new Intl.NumberFormat(o,{style:"currency",currency:t}).format(e)}function le(e){return E(`npm show ${e} version`).toString().trim()}const pe=e=>b.green(e);async function ue(e,t){await $.writeJson(t,e,{spaces:2})}!function(){const e=x.homedir(),t=n.join(e,".mfn","cache");if(!p.existsSync(t))try{p.existsSync(n.join(e,".mfn"))||p.mkdirSync(n.join(e,".mfn")),p.mkdirSync(t,{recursive:!0})}catch(e){}}(),await(async()=>{const e=await(t="M4N-CLI",new Promise(((e,o)=>{v(t,((t,n)=>{t?o(t):e(n)}))})));var t;const o=w(b.hex("#27A244").bold(e),{padding:1,margin:1,dimBorder:!0,borderStyle:"round",borderColor:"#C1C110"}),n=function(){const e=x.platform();return"win32"===e?process.env.USERNAME||"User":"darwin"===e||"linux"===e?process.env.USER||"User":""}();console.log(b.whiteBright.bold("-------------------------------------------------------\n")),console.log(o),n&&n.length>0?console.log(b.magenta(`\n\tWelcome ${n} to the Master4Novice CLI Tool!\n`)):console.log(b.blue("\n\tWelcome to the Master4Novice CLI Tool!\n")),console.log(b.yellow("\tUse this tool to reduce your effort.\n")),console.log(b.white("-------------------------------------------------------\n"))})();const de=e(process.argv.slice(L()+1));const fe=b.hex("#44bcd8").bold("mfn");var me=de.scriptName(fe);const he=re(),ge=(e,t)=>{he.info("Started creating subdirectories..."),t.forEach((t=>{const o=n.join(e,t);p.existsSync(o)?he.warn("Subdirectory already exists..."):(p.mkdirSync(o,{recursive:!0}),he.info(`Created subdirectory - /${t}`))}))},ye=(e,t)=>{he.info(`Current working directory: ${process.cwd()}`);const o=n.join(process.cwd(),e);p.existsSync(o)?(he.warn("Root directory already exist"),t&&t.length>0&&ge(o,t)):(he.info("Started creating root directory inside current working directory..."),p.mkdirSync(o,{recursive:!0}),he.info(`Created root directory - /${e}`),t&&t.length>0&&ge(o,t))},be="md",ve="Make directory and its subdirectories",we=e=>{e.option("d",{alias:"directory",describe:"The root directory to create",type:"string",demandOption:!0}).option("s",{alias:"subdirectories",describe:"Subdirectories to create within the root directory",type:"array"})},je=e=>{if(e.directory&&e.directory.length>0){if(void 0===e.subdirectories)ye(e.directory,e.subdirectories);else{if(0===e.subdirectories.length)return void he.error("Invalid subdirectories name");ye(e.directory,e.subdirectories)}console.log("\n")}else he.error("Invalid directory name")},Se=re(),xe=n.join(se(),"cts_ignore.json");let $e="",Ee=20;let Oe="";async function Ae(){try{return await $.readJson(xe)}catch(e){if("ENOENT"===e.code)return{ignores:[]};throw e}}function ke(e,t,o="",r=0){const i=$.readdirSync(e);i.forEach(((s,a)=>{if(t&&t.includes(s))return;const c=n.join(e,s),l=a===i.length-1,p=$.statSync(c).isDirectory();Oe+=`${o}${l?"└── ":"├── "}${s}`+"\n",p&&ke(c,t,`${o}${l?" ":"│ "}`,r+1)}))}function Me(e,t,o=0,r=new Array){const i=$.readdirSync(e);i.forEach(((s,a)=>{if(t&&t.includes(s))return;const c=n.join(e,s),l=a===i.length-1,p=$.statSync(c).isDirectory();let u="";r.forEach(((e,t)=>{u+=e?"\t".repeat(4):"│"+"\t".repeat(3)})),u+=l?"└── ":"├── ";if($e+=`<text style="white-space: pre;" x="${0*o}" y="${Ee}">${`${u}${s}`}</text>`,Ee+=20,p){const e=[...r,l];Me(c,t,o+1,e)}}))}function De(e){return Buffer.from(e)}const Te=async(e,t,o,r)=>{Se.info(`Processing current working directory: ${process.cwd()}`);const i=n.join(process.cwd()),s=n.basename(i);Oe+=s+"\n",ke(i,t),$e+=`<text x="0" y="20">${s}</text>`,Ee+=20,Me(i,t),$e=`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${o}"><rect width="100%" height="100%" fill="white"/><g fill="black" font-family="monospace" font-size="12">`+$e+"</g></svg>";const a=s+"."+e;switch(e){case"png":{const e=De($e);await A(e).png().toFile(a),Se.info(`Tree structure created for ${s} in file ${a}.`);break}case"jpeg":{const e=De($e);await A(e).jpeg().toFile(a),Se.info(`Tree structure created for ${s} in file ${a}.`);break}case"svg":$.outputFileSync(a,$e),Se.info(`Tree structure created for ${s} in file ${a}.`);break;default:Se.info("Unsupported type...")}Se.debug(Oe)},Ye="cts",Ne="Create tree structure of current working directory and its contents",Re=e=>{e.option("t",{alias:"fileType",describe:"Tree structure will be saved in file type",type:"string",choices:["svg","png","jpeg"],demandOption:!0}).option("i",{alias:"ignores",describe:"Folder list to be ignored in tree structure",type:"array"}).option("l",{alias:"length",describe:"Length of the image",type:"number",default:250}).option("b",{alias:"breadth",describe:"Breadth of the image",type:"number",default:200})},_e=async e=>{if(function(...e){for(const t of e)if(isNaN(t)||t<1||t>1e3)return!1;return!0}(e.length,e.breadth)){let t=e.ignores;if(t&&t.length>0){const e=await Ae();e.ignores=[],await ue(e,xe),e.ignores=[...t],await ue(e,xe),Se.info(`Applying your ignore list: ${t.join(", ")}, updating ignore cache`)}else{const e=await Ae();e.ignores&&e.ignores.length>0&&(Se.info(`Applying your cache ignore list: ${e.ignores.join(", ")}`),t=[...e.ignores])}Te(e.fileType,t,e.length,e.breadth)}else Se.error("Length & Breadth must be valid number (1 to 1000)\n")},ze=re(),Fe=n.join(se(),"sc_ignore.json");async function Le(){try{return await $.readJson(Fe)}catch(e){if("ENOENT"===e.code)return{ignores:[]};throw e}}async function Ie(e,t){if(t&&t.length>0){return await j.prompt([{type:"fuzzypath",name:"filePath",excludePath:e=>t.some((t=>e.includes(t))),excludeFilter:e=>"."==e,message:pe("Select a folder/file:"),itemType:"any",depthLimit:5,rootPath:e}])}return await j.prompt([{type:"fuzzypath",name:"filePath",excludeFilter:e=>"."==e,message:pe("Select a folder/file:"),itemType:"any",depthLimit:5,rootPath:e}])}async function Pe(){return await j.prompt([{type:"confirm",name:"exit",message:pe("Do you want to exit?"),default:!0}])}j.registerPrompt("fuzzypath",k);const Be="sc",qe="Search content of current working directory",He=e=>{e.option("i",{alias:"ignores",describe:"List of directory content to ignore",type:"array"})},Ce=async e=>{let t=process.cwd();let o=e.ignores;if(o&&o.length>0){const e=await Le();e.ignores=[],await ue(e,Fe),e.ignores=[...o],await ue(e,Fe),ze.info(`Applying your ignore list: ${o.join(", ")}, updating ignore cache`)}else{const e=await Le();e.ignores&&e.ignores.length>0&&(ze.info(`Applying your cache ignore list: ${e.ignores.join(", ")}`),o=[...e.ignores])}for(;;){const{filePath:e}=await Ie(t,o),n=$.statSync(e);n.isFile()?(ze.info("Selected content is file..."),ze.info(`${e}`)):n.isDirectory()&&(ze.info("Selected content is directory..."),t=e,process.chdir(t),ze.warn(`${process.cwd()}`));const{exit:r}=await Pe();if(r){ze.warn("Exiting navigation..."),n.isDirectory()&&(ze.info("Use below command to change directory"),ze.info(`cd ${t}`));break}}},Ue=re();const Je="hra",We="Calculate HRA exemption",Qe=e=>{e.option("mb",{alias:"monthlyBasic",describe:"Monthly basic salary",type:"number",demandOption:!0}).option("mr",{alias:"monthlyRent",describe:"Monthly rent paid",type:"number",demandOption:!0}).option("hr",{alias:"hraReceived",describe:"Monthly HRA received from employer",type:"number",demandOption:!0}).option("im",{alias:"isMetro",describe:"Living in a metro city.",type:"boolean",choices:[!0,!1],default:!1})},Ge=e=>{if(!ae(e.monthlyBasic,e.monthlyRent,e.hraReceived))return void Ue.error("Invalid Inputs\n");console.log("HRA exemption is calculated based on the following criteria:\n"),console.log("1. Actual HRA received from the employer."),console.log("2. 50% of salary (basic + DA) for those living in metro cities or 40% for non-metro cities."),console.log("3. Actual rent paid minus 10% of salary (basic + DA).\n");const t={monthlyBasic:e.monthlyBasic,monthlyRent:e.monthlyRent,hraReceived:e.hraReceived,isMetro:e.isMetro};console.log("\n"),Ue.info("Provided Monthly Details:\n"),console.table([{MonthlyBasic:ce(e.monthlyBasic),MonthlyHRAReceived:ce(e.hraReceived),MonthlyRent:ce(e.monthlyRent),IsMetro:e.isMetro}]),console.log("\n");const o=function(e){const{monthlyBasic:t,monthlyRent:o,hraReceived:n,isMetro:r}=e,i=12*t,s=12*n,a=12*o-.1*i,c=(r?.5:.4)*i;return Math.min(s,a,c)}(t);console.log("\n"),Ue.info("Calculated HRA Exemption Details:\n"),console.table([{Basic:ce(12*e.monthlyBasic),HRAReceived:ce(12*e.hraReceived),Rent:ce(12*e.monthlyRent),HRAExemption:ce(o)}]),console.log("\n")},Ve=re();const Ze="sr",Ke="Suggest optimal rent for maximizing HRA exemption",Xe=e=>{e.option("mb",{alias:"monthlyBasic",describe:"Monthly basic salary",type:"number",demandOption:!0}).option("hr",{alias:"hraReceived",describe:"Monthly HRA received from employer",type:"number",demandOption:!0}).option("im",{alias:"isMetro",describe:"Living in a metro city.",type:"boolean",choices:[!0,!1],default:!1})},et=e=>{if(!ae(e.monthlyBasic,e.hraReceived))return void Ve.error("Invalid Inputs\n");console.log("\n"),Ve.info("Provided Details:\n"),console.table([{MonthlyBasic:ce(e.monthlyBasic),MonthlyHRAReceived:ce(e.hraReceived),IsMetro:e.isMetro}]),console.log("\n");const t=(o=e.monthlyBasic,n=e.hraReceived,e.isMetro,(12*o*.1+12*n)/12);var o,n;console.log("\n"),Ve.info("Suggested Rent Details For Maximise HRA Exemption:\n"),console.table([{MonthlyRent:ce(t),AnnualRent:ce(12*t)}]),console.log("\n"),Ve.warn("Suggestions are calculated based on inputs\n")},tt=re();const ot="decode",nt="Decode provided JWT token",rt=e=>{e.option("t",{alias:"token",describe:"JWT token to decode",type:"string",demandOption:!0})},it=e=>{const t=function(e){try{const t=e.split(".");if(3!==t.length)throw new Error("Invalid JWT structure");const o=t[1],n=Buffer.from(o,"base64").toString("utf-8");return JSON.parse(n)}catch(e){return tt.error(`Error decoding JWT: ${e}`),null}}(e.token.replace(/^Bearer\s+/i,""));t&&(console.log("Decoded JWT Payload:\n"),console.log(b.cyanBright.bold("data:"),b.greenBright.bold(JSON.stringify(t,null,2))),console.log("\n"))};j.registerPrompt("date",D),j.registerPrompt("autocomplete",Y);const st=re(),at=M.tz.names(),ct=["YYYY-MM-DD","MM-DD-YYYY","DD-MM-YYYY","MMMM Do YYYY, h:mm:ss a","dddd, MMMM Do YYYY","YYYY-MM-DD HH:mm:ss","MMM DD, YYYY","hh:mm A","HH:mm:ss","MMMM Do YYYY, h:mm:ss a z","ddd, hA","YYYY-MM-DD[T]HH:mm:ss.SSS[Z]","YYYY-MM-DD[T]HH:mm:ssZ"];async function lt(){const{dateTime:e}=await j.prompt({type:"date",name:"dateTime",message:pe("Choose a date to proceed"),clearable:!0});return console.log("\n"),st.info(`Provided date and time is: ${S(e).format("YYYY-MM-DD HH:mm:ss")}`),S(e)}async function pt(){const e=(await lt()).utc();console.log("\n"),st.info(`The UTC date and time is: ${e.format("YYYY-MM-DD HH:mm:ss")} UTC`)}async function ut(){const e=await lt(),t=await async function(){const{timezone:e}=await j.prompt([{type:"autocomplete",name:"timezone",message:pe("Select a timezone:"),source:(e,t)=>(t=t||"",new Promise((e=>{e(T.filter(t,at).map((e=>e.original)))})))}]);return console.log("\n"),e}(),o=e.tz(t);console.log("\n"),st.info(`The date and time in ${t} is: ${o.format("YYYY-MM-DD HH:mm:ss")} ${t}`)}async function dt(){const e=await lt(),t=await async function(){const{format:e}=await j.prompt([{type:"autocomplete",name:"format",message:pe("Select a date format:"),source:(e,t)=>(t=t||"",new Promise((e=>{e(T.filter(t,ct).map((e=>e.original)))})))}]);return console.log("\n"),e}(),o=e.format(t);console.log("\n"),st.info(`The date in the selected format (${t}) is: ${o}`)}const ft="date",mt="Date conversion/operations",ht=e=>e,gt=async e=>{let t=!0,o=!1;do{console.log("\n");const{operation:e}=await j.prompt([{type:"rawlist",name:"operation",message:pe("What do you want to do?"),choices:[{name:"Convert local datetime to UTC datetime",value:"localDateToUTC"},{name:"Convert local datetime to specific timezone datetime",value:"localDateToTimezone"},new j.Separator,{name:"Format date in string",value:"formatDate"},{name:"Exit",value:"exit"}]}]);if("exit"===e)t=!1,o=!1;else switch(console.log("\n"),e){case"localDateToUTC":o=!0,st.info("Operation Local Date To UTC Date\n"),await pt();break;case"localDateToTimezone":o=!0,st.info("Operation Local Date To Timezone\n"),await ut();break;case"formatDate":o=!0,st.info("Operation Format Date\n"),await dt();break;default:st.warn("Invalid option selected.")}if(t&&!o){console.log("\n");const{repeat:e}=await j.prompt([{type:"confirm",name:"repeat",message:pe("Do you want to perform another operation?"),default:!1}]);t=e}}while(t);st.info("Exiting...\n")};j.registerPrompt("date",D),j.registerPrompt("autocomplete",Y);const yt=re();async function bt(){try{const{epochValue:e}=await async function(){return console.log("\n"),await j.prompt({type:"input",name:"epochValue",message:pe("Enter epoch time:"),validate:function(e){return!isNaN(e)||"Please enter a valid epoch time"}})}(),t=N(Number(e));console.log("\n"),yt.info("Epoch to date conversion details:\n"),console.table([{Epoch:`${t.epoch} is in ${t.epochType}`,LocalDateTime:t.localTime,GMTDateTime:t.gmtTime,Relative:t.relative}])}catch(e){console.log("\n"),yt.error(`${e}`)}}async function vt(){try{const e=await async function(){console.log("\n");const{dateTime:e}=await j.prompt({type:"date",name:"dateTime",message:pe("Choose a date to proceed"),clearable:!0});return yt.info(`Provided date and time is: ${S(e).format("YYYY-MM-DD HH:mm:ss")}`),S(e)}(),{epochInSeconds:t,epochInMilliseconds:o,gmtDate:n,timezoneDate:r,timezone:i}=R(e.toDate());console.log("\n"),yt.info("Epoch details:\n"),console.table([{Epochs:`${t} in seconds, ${o} in miliseconds`,LocalDateTime:r,GMTDateTime:n,DetectedTimezone:i}])}catch(e){console.log("\n"),yt.error(`${e}`)}}const wt="epoch",jt="Epoch conversions",St=e=>e,xt=async e=>{let t=!0,o=!1;do{console.log("\n");const{operation:e}=await j.prompt([{type:"rawlist",name:"operation",message:pe("What do you want to do?"),choices:[{name:"Convert epoch to human-readable date",value:"epochToDate"},{name:"Convert human-readable date to epoch",value:"dateToEpoch"},{name:"Exit",value:"exit"}]}]);if("exit"===e)t=!1,o=!1;else switch(console.log("\n"),e){case"epochToDate":o=!0,yt.info("Operation Epoch To Date\n"),await bt();break;case"dateToEpoch":o=!0,yt.info("Operation Date To Epoch\n"),await vt();break;default:yt.warn("Invalid option selected.")}if(t&&!o){console.log("\n");const{repeat:e}=await j.prompt([{type:"confirm",name:"repeat",message:pe("Do you want to perform another operation?"),default:!1}]);t=e}}while(t);yt.info("Exiting...\n")},$t="type Query {\n hello: String\n}\n",Et="const express = require('express');\nconst { ApolloServer } = require('@apollo/server');\nconst { expressMiddleware } = require('@apollo/server/express4');\nconst { readFileSync } = require('fs');\nconst { join } = require('path');\nconst cors = require('cors');\n \nconst getSchema = () => {\n const schemaPath = join(process.cwd(), `resources/schema.graphql`);\n return readFileSync(schemaPath, 'utf-8');\n};\n \nconst typeDefs = getSchema();\n \nconst resolvers = {\n Query: {\n hello: () => 'Hello world!',\n },\n};\n \nconst app = express();\n\nconst server = new ApolloServer({\n typeDefs,\n resolvers,\n});\n \nserver.start().then(() => {\n app.use('/graphql', cors(), express.json(), expressMiddleware(server));\n});\n \napp.listen(4000, () => {\n console.log('🚀 Server ready at http://localhost:4000/graphql');\n});\n",Ot="import express from 'express';\nimport { ApolloServer } from '@apollo/server';\nimport { expressMiddleware } from '@apollo/server/express4';\nimport cors from 'cors';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\n\nconst getSchema = (): string => {\n const schemaPath = join(process.cwd(), `resources/schema.graphql`);\n return readFileSync(schemaPath, 'utf-8');\n};\n\nconst typeDefs = getSchema();\n\nconst resolvers = {\n Query: {\n hello: () => 'Hello world!',\n },\n};\n\nconst app = express();\n\nconst server = new ApolloServer({\n typeDefs,\n resolvers\n});\n\nawait server.start();\n\napp.use('/graphql', cors<cors.CorsRequest>(), express.json(), expressMiddleware(server));\n\napp.listen(4000, () => {\n console.log('🚀 Server ready at http://localhost:4000/graphql');\n});\n",At=re(),kt="create @apollo:express",Mt="Create an Apollo GraphQL Express project",Dt=e=>e,Tt=async e=>{const{projectName:t,moduleType:o}=await async function(e){return await j.prompt(e)}([{type:"input",name:"projectName",message:pe("Enter the project name:"),validate:e=>e.trim().length>0||"Please enter a valid project name."},{type:"expand",name:"moduleType",message:pe("Choose module type:"),choices:[{key:"c",name:"CommonJS",value:"commonjs"},{key:"m",name:"ES Module",value:"module"}],default:0}]),r=S();console.log("\n");const i=_(b.green("@apollo:express:init")).start();try{const e=n.join(process.cwd(),t);p.mkdirSync(e);let s=!1;"module"===o&&(s=!0),function(e,t,o){p.writeFileSync(n.join(e,"package.json"),JSON.stringify(function(e,t,o){const n={"@apollo/server":le("@apollo/server"),cors:le("cors"),express:le("express"),graphql:le("graphql")};let r={},i={};return"module"===e?(r={"@types/cors":le("@types/cors"),"@types/express":le("@types/express"),"@types/node":le("@types/node"),rimraf:le("rimraf"),typescript:le("typescript")},i={name:t.basename(o),version:"1.0.0",main:"./dist/index.js",type:e,scripts:{clean:"rimraf ./dist",build:"npm run clean && tsc",start:"node ./dist/index.js"},dependencies:n,devDependencies:r}):i={name:t.basename(o),version:"1.0.0",main:"src/index.js",type:e,scripts:{start:"node src/index.js"},dependencies:n},i}(o,n,e),null,2)),p.writeFileSync(n.join(e,"README.md"),((e,t)=>"module"===t?`# ${e}\n\nA starter project using apollo graphql and express. It is configured to use the '${t}' system.\n\n## Getting Started\n\n### Prerequisites\n\n- Node.js installed on your machine.\n\n### Build the application\n\nTo build the application, run the following command:\n\n\`\`\`bash\nnpm run build\n\`\`\`\n\n### Running the Server\n\nTo start the server, run the following command:\n\n\`\`\`bash\nnpm run start\n\`\`\`\n\nThe server will be running on [http://localhost:4000/graphql](http://localhost:4000/graphql).\n`:`# ${e}\n\nA starter project using apollo graphql and express. It is configured to use the '${t}' system.\n\n## Getting Started\n\n### Prerequisites\n\n- Node.js installed on your machine.\n\n### Running the Server\n\nTo start the server, run the following command:\n\n\`\`\`bash\nnpm run start\n\`\`\`\n\nThe server will be running on [http://localhost:4000/graphql](http://localhost:4000/graphql).\n`)(n.basename(e),o));const r=n.join(e,"src");p.mkdirSync(r);const i=n.join(e,"resources");p.mkdirSync(i);const s=t?"index.ts":"index.js";(function(e,t,o){p.writeFileSync(n.join(t,"schema.graphql"),$t);const r=o?Ot:Et;p.writeFileSync(e,r)})(n.join(r,s),i,t),t&&function(e){const t={compilerOptions:{target:"es2020",module:"esnext",types:["node"],lib:["es2020"],strict:!0,esModuleInterop:!0,skipLibCheck:!0,outDir:"dist",rootDir:"src",moduleResolution:"node"},include:["./src/**/*"],exclude:["node_modules","dist"]};p.writeFileSync(n.join(e,"tsconfig.json"),JSON.stringify(t,null,2))}(e)}(e,s,o);const a=S(),c=S.duration(a.diff(r)),l=b.dim(`(${c.asSeconds().toFixed(3)})`);i.succeed(`${b.green("@apollo:express:init completed")} ${l}`),function(e,t,o){const n=S();o.start(b.green(`${e}:install`)),process.chdir(t),E("npm install");const r=S(),i=S.duration(r.diff(n)),s=b.dim(`(${i.asSeconds().toFixed(3)})`);o.succeed(`${b.green(`${e}:install completed`)} ${s}`)}("@apollo:express",e,i),console.log("\n"),console.log(b.green(`Project ${n.basename(e)} created successfully.\n`)),console.log("\n")}catch(e){At.error(`: ${e}`),i.fail("Failed to initialize project.")}};const Yt=re(),Nt=n.join(se(),"ports.json");const Rt=e=>new Promise(((t,o)=>{const n="win32"===z()?`taskkill /PID ${e} /F`:`kill -9 ${e}`;O(n,((n,r,i)=>{if(n)return o(n);t(`Process ${e} killed successfully`)}))})),_t=async e=>{try{const t=await Promise.all(e.map((e=>(e=>new Promise((t=>{const o="win32"===z()?`netstat -ano | findstr :${e}`:`lsof -i :${e} | grep LISTEN`;O(o,((o,n,r)=>{if(o||!n)return Yt.warn(`Port ${e} is not in use.\n`),void t(null);if("win32"===z()){const o=n.split("\n")[0],r=o?o.trim().split(/\s+/).pop():null;t(r?{port:e,pid:r}:null)}else{const o=n.split("\n")[0],r=o?o.trim().split(/\s+/)[1]:null;t(r?{port:e,pid:r}:null)}}))})))(e)))),o=t.filter((e=>null!==e));if(0===o.length)return console.log("\n"),void Yt.info("No processes found running on the specified ports\n");const n=o.map((e=>({name:`Port: ${e.port}, PID: ${e.pid}`,value:e.pid})));console.log("\n");const r=await j.prompt([{type:"checkbox",name:"pids",message:pe("Select the processes you want to kill:"),choices:n}]);console.log("\n");for(const e of r.pids){const t=await Rt(e);Yt.info(t)}}catch(e){Yt.error(`${e}`)}},zt="kill",Ft="Kill process running on specific ports",Lt=e=>{e.option("p",{alias:"ports",describe:"List of port numbers",type:"array",coerce:e=>{if(!Array.isArray(e))throw new Error("Ports must be an array");for(const t of e)if(isNaN(Number(t)))throw new Error(`Invalid port number: ${t}`);return e.map(Number)}})},It=async e=>{const t=e.ports,o=await async function(){try{return await $.readJson(Nt)}catch(e){if("ENOENT"===e.code)return{ports:[]};throw e}}();t&&t.length>0?(o.ports=[],await ue(o,Nt),await _t(t),o.ports=[...t],await ue(o,Nt)):o.ports&&o.ports.length>0?(Yt.info(`Using ports [${o.ports.join(", ")}] from cache\n`),await _t(o.ports)):Yt.error("Ports are not provided\n")},Pt=re();async function Bt(e){const t=S(),o=_();console.log("\n");try{o.start(b.green("@start updating/installing")),O(`npm install -g ${e}`,((n,r,i)=>{if(n)return o.fail(b.red("@fail updating/installing")),void Pt.error(`\nError updating package: ${n.message}`);if(i)return void Pt.error(`\nError output: ${i}\n`);const s=S(),a=S.duration(s.diff(t)),c=b.dim(`(${a.asSeconds().toFixed(3)})`);o.succeed(`${b.green("@success updating/installing")} ${c}`),async function(e,t){O(`npm view ${e} version`,((e,o,n)=>{t(e||n?null:o.trim())}))}(e,(t=>{null!==t&&(console.log("\n"),Pt.info(`${e} library updated/installed version -> ${b.green(t)}\n`))}))}))}catch(e){Pt.error(`${e}`)}}const qt="update [package]",Ht="Update the CLI or a specified package to the latest version",Ct=e=>{e.positional("package",{describe:"The name of the package to update",type:"string",default:"@master4n/master-cli"})},Ut=async e=>{Bt(e.package)};var Jt="@master4n/master-cli",Wt="2.2.5",Qt="Command Line Interface For Various Useful Operations",Gt="./bin/index.js",Vt="./bin/index.d.ts",Zt="module",Kt={mfn:"./bin/index.js"},Xt={clean:"rimraf dist",lint:"eslint src/**/*.ts",format:"prettier --write src/**/*.ts",build:"npm run clean && rollup --config"},eo={type:"git",url:"git+https://github.com/Master4Novice/common.git"},to=["cli","helper","module"],oo="dwivna",no={directory:"dist",access:"public"},ro=[{name:"dwivna"}],io={"@master4n/temporal-transformer":"^1.0.4","@types/fs-extra":"^11.0.4","@types/yargs":"^17.0.32",boxen:"^7.1.1",chalk:"^5.3.0",figlet:"^1.7.0","fs-extra":"^11.2.0",fuzzy:"^0.1.3",inquirer:"^9.2.23","inquirer-autocomplete-prompt":"^3.0.1","inquirer-date-prompt":"^3.0.0","inquirer-fuzzy-path":"^2.3.0","is-root":"^3.0.0",moment:"^2.30.1","moment-timezone":"^0.5.45",open:"^10.1.0",sharp:"^0.33.4","update-notifier":"^7.0.0",yargs:"^17.7.2"},so={"@types/figlet":"^1.5.8","@types/inquirer":"^9.0.7","@types/inquirer-fuzzy-path":"^2.3.9","@types/node":"^20.12.12","@types/update-notifier":"^6.0.8",ora:"^8.0.1"},ao="2ef1d0cbf62f6f2742140d6e47cfb1ade721f180",co={name:Jt,version:Wt,description:Qt,main:Gt,types:Vt,type:Zt,bin:Kt,scripts:Xt,repository:eo,keywords:to,author:oo,license:"MIT",homepage:"",publishConfig:no,contributors:ro,dependencies:io,devDependencies:so,gitHead:ao};const lo=F({pkg:Object.freeze({__proto__:null,author:oo,bin:Kt,contributors:ro,default:co,dependencies:io,description:Qt,devDependencies:so,gitHead:ao,homepage:"",keywords:to,license:"MIT",main:Gt,name:Jt,publishConfig:no,repository:eo,scripts:Xt,type:Zt,types:Vt,version:Wt})});ie(me).add(qt,Ht,Ct,Ut),ie(me).add(wt,jt,St,xt),ie(me).add(ft,mt,ht,gt),ie(me).add(ot,nt,rt,it),ie(me).add(kt,Mt,Dt,Tt),ie(me).add(Be,qe,He,Ce),ie(me).add(zt,Ft,Lt,It),ie(me).add(be,ve,we,je),ie(me).add(Ye,Ne,Re,_e),ie(me).add(Je,We,Qe,Ge),ie(me).add(Ze,Ke,Xe,et),me.version().alias("version","v").help().alias("help","h").wrap(null).parse(),lo.notify();
|
|
34
|
+
var J,W,Q;const G=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,V=null!==(W=null===(J=null===process||void 0===process?void 0:process.versions)||void 0===J?void 0:J.node)&&void 0!==W?W:null===(Q=null===process||void 0===process?void 0:process.version)||void 0===Q?void 0:Q.slice(1);if(V){if(Number(V.match(/^([^.]+)/)[1])<G)throw Error(`yargs parser supports a minimum Node.js version of ${G}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const Z=process?process.env:{},K=new class{constructor(e){H=e}parse(e,t){const o=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),n=function(e){if(Array.isArray(e))return e.map((e=>"string"!=typeof e?e+"":e));e=e.trim();let t=0,o=null,n=null,r=null;const i=[];for(let s=0;s<e.length;s++)o=n,n=e.charAt(s)," "!==n||r?(n===r?r=null:"'"!==n&&'"'!==n||r||(r=n),i[t]||(i[t]=""),i[t]+=n):" "!==o&&t++;return i}(e),r="string"==typeof e,i=function(e){const t=[],o=Object.create(null);let n=!0;Object.keys(e).forEach((function(o){t.push([].concat(e[o],o))}));for(;n;){n=!1;for(let e=0;e<t.length;e++)for(let o=e+1;o<t.length;o++){if(t[e].filter((function(e){return-1!==t[o].indexOf(e)})).length){t[e]=t[e].concat(t[o]),t.splice(o,1),n=!0;break}}}return t.forEach((function(e){const t=(e=e.filter((function(e,t,o){return o.indexOf(e)===t}))).pop();void 0!==t&&"string"==typeof t&&(o[t]=e)})),o}(Object.assign(Object.create(null),o.alias)),s=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},o.configuration),a=Object.assign(Object.create(null),o.default),c=o.configObjects||[],l=o.envPrefix,p=s["populate--"],u=p?"--":"_",d=Object.create(null),f=Object.create(null),m=o.__||H.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},g=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,y=new RegExp("^--"+s["negation-prefix"]+"(.+)");[].concat(o.array||[]).filter(Boolean).forEach((function(e){const t="object"==typeof e?e.key:e,o=Object.keys(e).map((function(e){return{boolean:"bools",string:"strings",number:"numbers"}[e]})).filter(Boolean).pop();o&&(h[o][t]=!0),h.arrays[t]=!0,h.keys.push(t)})),[].concat(o.boolean||[]).filter(Boolean).forEach((function(e){h.bools[e]=!0,h.keys.push(e)})),[].concat(o.string||[]).filter(Boolean).forEach((function(e){h.strings[e]=!0,h.keys.push(e)})),[].concat(o.number||[]).filter(Boolean).forEach((function(e){h.numbers[e]=!0,h.keys.push(e)})),[].concat(o.count||[]).filter(Boolean).forEach((function(e){h.counts[e]=!0,h.keys.push(e)})),[].concat(o.normalize||[]).filter(Boolean).forEach((function(e){h.normalize[e]=!0,h.keys.push(e)})),"object"==typeof o.narg&&Object.entries(o.narg).forEach((([e,t])=>{"number"==typeof t&&(h.nargs[e]=t,h.keys.push(e))})),"object"==typeof o.coerce&&Object.entries(o.coerce).forEach((([e,t])=>{"function"==typeof t&&(h.coercions[e]=t,h.keys.push(e))})),void 0!==o.config&&(Array.isArray(o.config)||"string"==typeof o.config?[].concat(o.config).filter(Boolean).forEach((function(e){h.configs[e]=!0})):"object"==typeof o.config&&Object.entries(o.config).forEach((([e,t])=>{"boolean"!=typeof t&&"function"!=typeof t||(h.configs[e]=t)}))),function(...e){e.forEach((function(e){Object.keys(e||{}).forEach((function(e){h.aliases[e]||(h.aliases[e]=[].concat(i[e]||[]),h.aliases[e].concat(e).forEach((function(t){if(/-/.test(t)&&s["camel-case-expansion"]){const o=I(t);o!==e&&-1===h.aliases[e].indexOf(o)&&(h.aliases[e].push(o),d[o]=!0)}})),h.aliases[e].concat(e).forEach((function(t){if(t.length>1&&/[A-Z]/.test(t)&&s["camel-case-expansion"]){const o=P(t,"-");o!==e&&-1===h.aliases[e].indexOf(o)&&(h.aliases[e].push(o),d[o]=!0)}})),h.aliases[e].forEach((function(t){h.aliases[t]=[e].concat(h.aliases[e].filter((function(e){return t!==e})))})))}))}))}(o.key,i,o.default,h.arrays),Object.keys(a).forEach((function(e){(h.aliases[e]||[]).forEach((function(t){a[t]=a[e]}))}));let b=null;Object.keys(h.counts).find((e=>R(e,h.arrays)?(b=Error(m("Invalid configuration: %s, opts.count excludes opts.array.",e)),!0):!!R(e,h.nargs)&&(b=Error(m("Invalid configuration: %s, opts.count excludes opts.narg.",e)),!0)));let v=[];const w=Object.assign(Object.create(null),{_:[]}),j={};for(let e=0;e<n.length;e++){const t=n[e],o=t.replace(/^-{3,}/,"---");let r,i,a,c,l,p;if("--"!==t&&/^-/.test(t)&&z(t))S(t);else{if(o.match(/^---+(=|$)/)){S(t);continue}if(t.match(/^--.+=/)||!s["short-option-groups"]&&t.match(/^-.+=/))c=t.match(/^--?([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&(R(c[1],h.arrays)?e=$(e,c[1],n,c[2]):!1!==R(c[1],h.nargs)?e=x(e,c[1],n,c[2]):E(c[1],c[2],!0));else if(t.match(y)&&s["boolean-negation"])c=t.match(y),null!==c&&Array.isArray(c)&&c.length>=2&&(i=c[1],E(i,!!R(i,h.arrays)&&[!1]));else if(t.match(/^--.+/)||!s["short-option-groups"]&&t.match(/^-[^-]+/))c=t.match(/^--?(.+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(i=c[1],R(i,h.arrays)?e=$(e,i,n):!1!==R(i,h.nargs)?e=x(e,i,n):(l=n[e+1],void 0===l||l.match(/^-/)&&!l.match(g)||R(i,h.bools)||R(i,h.counts)?/^(true|false)$/.test(l)?(E(i,l),e++):E(i,F(i)):(E(i,l),e++)));else if(t.match(/^-.\..+=/))c=t.match(/^-([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&E(c[1],c[2]);else if(t.match(/^-.\..+/)&&!t.match(g))l=n[e+1],c=t.match(/^-(.\..+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(i=c[1],void 0===l||l.match(/^-/)||R(i,h.bools)||R(i,h.counts)?E(i,F(i)):(E(i,l),e++));else if(t.match(/^-[^-]+/)&&!t.match(g)){a=t.slice(1,-1).split(""),r=!1;for(let o=0;o<a.length;o++){if(l=t.slice(o+2),a[o+1]&&"="===a[o+1]){p=t.slice(o+3),i=a[o],R(i,h.arrays)?e=$(e,i,n,p):!1!==R(i,h.nargs)?e=x(e,i,n,p):E(i,p),r=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[o])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===R(l,h.bools)){E(a[o],l),r=!0;break}if(a[o+1]&&a[o+1].match(/\W/)){E(a[o],l),r=!0;break}E(a[o],F(a[o]))}else E(a[o],l)}i=t.slice(-1)[0],r||"-"===i||(R(i,h.arrays)?e=$(e,i,n):!1!==R(i,h.nargs)?e=x(e,i,n):(l=n[e+1],void 0===l||/^(-|--)[^-]/.test(l)&&!l.match(g)||R(i,h.bools)||R(i,h.counts)?/^(true|false)$/.test(l)?(E(i,l),e++):E(i,F(i)):(E(i,l),e++)))}else if(t.match(/^-[0-9]$/)&&t.match(g)&&R(t.slice(1),h.bools))i=t.slice(1),E(i,F(i));else{if("--"===t){v=n.slice(e+1);break}if(s["halt-at-non-option"]){v=n.slice(e);break}S(t)}}}function S(e){const t=k("_",e);"string"!=typeof t&&"number"!=typeof t||w._.push(t)}function x(e,t,o,n){let r,i=R(t,h.nargs);if(i="number"!=typeof i||isNaN(i)?1:i,0===i)return L(n)||(b=Error(m("Argument unexpected for: %s",t))),E(t,F(t)),e;let a=L(n)?0:1;if(s["nargs-eats-options"])o.length-(e+1)+a<i&&(b=Error(m("Not enough arguments following: %s",t))),a=i;else{for(r=e+1;r<o.length&&(!o[r].match(/^-[^0-9]/)||o[r].match(g)||z(o[r]));r++)a++;a<i&&(b=Error(m("Not enough arguments following: %s",t)))}let c=Math.min(a,i);for(!L(n)&&c>0&&(E(t,n),c--),r=e+1;r<c+e+1;r++)E(t,o[r]);return e+c}function $(e,t,o,n){let i=[],c=n||o[e+1];const l=R(t,h.nargs);if(R(t,h.bools)&&!/^(true|false)$/.test(c))i.push(!0);else if(L(c)||L(n)&&/^-/.test(c)&&!g.test(c)&&!z(c)){if(void 0!==a[t]){const e=a[t];i=Array.isArray(e)?e:[e]}}else{L(n)||i.push(A(t,n,!0));for(let n=e+1;n<o.length&&!(!s["greedy-arrays"]&&i.length>0||l&&"number"==typeof l&&i.length>=l)&&(c=o[n],!/^-/.test(c)||g.test(c)||z(c));n++)e=n,i.push(A(t,c,r))}return"number"==typeof l&&(l&&i.length<l||isNaN(l)&&0===i.length)&&(b=Error(m("Not enough arguments following: %s",t))),E(t,i),e}function E(e,t,o=r){if(/-/.test(e)&&s["camel-case-expansion"]){const t=e.split(".").map((function(e){return I(e)})).join(".");O(e,t)}const n=A(e,t,o),i=e.split(".");if(N(w,i,n),h.aliases[e]&&h.aliases[e].forEach((function(e){const t=e.split(".");N(w,t,n)})),i.length>1&&s["dot-notation"]&&(h.aliases[i[0]]||[]).forEach((function(t){let o=t.split(".");const r=[].concat(i);r.shift(),o=o.concat(r),(h.aliases[e]||[]).includes(o.join("."))||N(w,o,n)})),R(e,h.normalize)&&!R(e,h.arrays)){[e].concat(h.aliases[e]||[]).forEach((function(e){Object.defineProperty(j,e,{enumerable:!0,get:()=>t,set(e){t="string"==typeof e?H.normalize(e):e}})}))}}function O(e,t){h.aliases[e]&&h.aliases[e].length||(h.aliases[e]=[t],d[t]=!0),h.aliases[t]&&h.aliases[t].length||O(t,e)}function A(e,t,o){o&&(t=function(e){return"string"!=typeof e||"'"!==e[0]&&'"'!==e[0]||e[e.length-1]!==e[0]?e:e.substring(1,e.length-1)}(t)),(R(e,h.bools)||R(e,h.counts))&&"string"==typeof t&&(t="true"===t);let n=Array.isArray(t)?t.map((function(t){return k(e,t)})):k(e,t);return R(e,h.counts)&&(L(n)||"boolean"==typeof n)&&(n=C()),R(e,h.normalize)&&R(e,h.arrays)&&(n=Array.isArray(t)?t.map((e=>H.normalize(e))):H.normalize(t)),n}function k(e,t){if(!s["parse-positional-numbers"]&&"_"===e)return t;if(!R(e,h.strings)&&!R(e,h.bools)&&!Array.isArray(t)){(B(t)&&s["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))||!L(t)&&R(e,h.numbers))&&(t=Number(t))}return t}function M(e,t){Object.keys(e).forEach((function(o){const n=e[o],r=t?t+"."+o:o;"object"==typeof n&&null!==n&&!Array.isArray(n)&&s["dot-notation"]?M(n,r):(!Y(w,r.split("."))||R(r,h.arrays)&&s["combine-arrays"])&&E(r,n)}))}function D(e,t){if(void 0===l)return;const o="string"==typeof l?l:"",n=H.env();Object.keys(n).forEach((function(r){if(""===o||0===r.lastIndexOf(o,0)){const i=r.split("__").map((function(e,t){return 0===t&&(e=e.substring(o.length)),I(e)}));(t&&h.configs[i.join(".")]||!t)&&!Y(e,i)&&E(i.join("."),n[r])}}))}function T(e,t,o,n=!1){Object.keys(o).forEach((function(r){Y(e,r.split("."))||(N(e,r.split("."),o[r]),n&&(f[r]=!0),(t[r]||[]).forEach((function(t){Y(e,t.split("."))||N(e,t.split("."),o[r])})))}))}function Y(e,t){let o=e;s["dot-notation"]||(t=[t.join(".")]),t.slice(0,-1).forEach((function(e){o=o[e]||{}}));const n=t[t.length-1];return"object"==typeof o&&n in o}function N(e,t,o){let n=e;s["dot-notation"]||(t=[t.join(".")]),t.slice(0,-1).forEach((function(e){e=U(e),"object"==typeof n&&void 0===n[e]&&(n[e]={}),"object"!=typeof n[e]||Array.isArray(n[e])?(Array.isArray(n[e])?n[e].push({}):n[e]=[n[e],{}],n=n[e][n[e].length-1]):n=n[e]}));const r=U(t[t.length-1]),i=R(t.join("."),h.arrays),a=Array.isArray(o);let c=s["duplicate-arguments-array"];!c&&R(r,h.nargs)&&(c=!0,(!L(n[r])&&1===h.nargs[r]||Array.isArray(n[r])&&n[r].length===h.nargs[r])&&(n[r]=void 0)),o===C()?n[r]=C(n[r]):Array.isArray(n[r])?c&&i&&a?n[r]=s["flatten-duplicate-arrays"]?n[r].concat(o):(Array.isArray(n[r][0])?n[r]:[n[r]]).concat([o]):c||Boolean(i)!==Boolean(a)?n[r]=n[r].concat([o]):n[r]=o:void 0===n[r]&&i?n[r]=a?o:[o]:!c||void 0===n[r]||R(r,h.counts)||R(r,h.bools)?n[r]=o:n[r]=[n[r],o]}function R(e,t){const o=[].concat(h.aliases[e]||[],e),n=Object.keys(t),r=o.find((e=>n.includes(e)));return!!r&&t[r]}function _(e){const t=Object.keys(h);return[].concat(t.map((e=>h[e]))).some((function(t){return Array.isArray(t)?t.includes(e):t[e]}))}function z(e){return s["unknown-options-as-args"]&&function(e){if(e=e.replace(/^-{3,}/,"--"),e.match(g))return!1;if(function(e){if(e.match(g)||!e.match(/^-[^-]+/))return!1;let t,o=!0;const n=e.slice(1).split("");for(let r=0;r<n.length;r++){if(t=e.slice(r+2),!_(n[r])){o=!1;break}if(n[r+1]&&"="===n[r+1]||"-"===t||/[A-Za-z]/.test(n[r])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(t)||n[r+1]&&n[r+1].match(/\W/))break}return o}(e))return!1;return!function(e,...t){return[].concat(...t).some((function(t){const o=e.match(t);return o&&_(o[1])}))}(e,/^-+([^=]+?)=[\s\S]*$/,y,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}(e)}function F(e){return R(e,h.bools)||R(e,h.counts)||!(`${e}`in a)?function(e){return{[q.BOOLEAN]:!0,[q.STRING]:"",[q.NUMBER]:void 0,[q.ARRAY]:[]}[e]}(function(e){let t=q.BOOLEAN;R(e,h.strings)?t=q.STRING:R(e,h.numbers)?t=q.NUMBER:R(e,h.bools)?t=q.BOOLEAN:R(e,h.arrays)&&(t=q.ARRAY);return t}(e)):a[e]}function L(e){return void 0===e}return D(w,!0),D(w,!1),function(e){const t=Object.create(null);T(t,h.aliases,a),Object.keys(h.configs).forEach((function(o){const n=e[o]||t[o];if(n)try{let e=null;const t=H.resolve(H.cwd(),n),r=h.configs[o];if("function"==typeof r){try{e=r(t)}catch(t){e=t}if(e instanceof Error)return void(b=e)}else e=H.require(t);M(e)}catch(t){"PermissionDenied"===t.name?b=t:e[o]&&(b=Error(m("Invalid JSON config file: %s",n)))}}))}(w),void 0!==c&&c.forEach((function(e){M(e)})),T(w,h.aliases,a,!0),function(e){let t;const o=new Set;Object.keys(e).forEach((function(n){if(!o.has(n)&&(t=R(n,h.coercions),"function"==typeof t))try{const r=k(n,t(e[n]));[].concat(h.aliases[n]||[],n).forEach((t=>{o.add(t),e[t]=r}))}catch(e){b=e}}))}(w),s["set-placeholder-key"]&&function(e){h.keys.forEach((t=>{~t.indexOf(".")||void 0===e[t]&&(e[t]=void 0)}))}(w),Object.keys(h.counts).forEach((function(e){Y(w,e.split("."))||E(e,0)})),p&&v.length&&(w[u]=[]),v.forEach((function(e){w[u].push(e)})),s["camel-case-expansion"]&&s["strip-dashed"]&&Object.keys(w).filter((e=>"--"!==e&&e.includes("-"))).forEach((e=>{delete w[e]})),s["strip-aliased"]&&[].concat(...Object.keys(i).map((e=>i[e]))).forEach((e=>{s["camel-case-expansion"]&&e.includes("-")&&delete w[e.split(".").map((e=>I(e))).join(".")],delete w[e]})),{aliases:Object.assign({},h.aliases),argv:Object.assign(j,w),configuration:s,defaulted:Object.assign({},f),error:b,newAliases:Object.assign({},d)}}}({cwd:process.cwd,env:()=>Z,format:t,normalize:r,resolve:i,require:e=>{if("undefined"!=typeof require)return require(e);if(e.match(/\.json$/))return JSON.parse(u(e,"utf8"));throw Error("only .json config files are supported in ESM")}}),X=function(e,t){return K.parse(e.slice(),t).argv};X.detailed=function(e,t){return K.parse(e.slice(),t)},X.camelCase=I,X.decamelize=P,X.looksLikeNumber=B;new RegExp("(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");var ee={fs:{readFileSync:u,writeFile:m},format:t,resolve:i,exists:e=>{try{return d(e).isFile()}catch(e){return!1}}};let te;class oe{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles="boolean"!=typeof e.updateFiles||e.updateFiles,this.locale=e.locale||"en",this.fallbackToLanguage="boolean"!=typeof e.fallbackToLanguage||e.fallbackToLanguage,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if("string"!=typeof arguments[0])return this._taggedLiteral(arguments[0],...arguments);const t=e.shift();let o=function(){};return"function"==typeof e[e.length-1]&&(o=e.pop()),o=o||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:o})):o(),te.format.apply(te.format,[this.cache[this.locale][t]||t].concat(e))}__n(){const e=Array.prototype.slice.call(arguments),t=e.shift(),o=e.shift(),n=e.shift();let r=function(){};"function"==typeof e[e.length-1]&&(r=e.pop()),this.cache[this.locale]||this._readLocaleFile();let i=1===n?t:o;if(this.cache[this.locale][t]){i=this.cache[this.locale][t][1===n?"one":"other"]}!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]={one:t,other:o},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:r})):r();const s=[i];return~i.indexOf("%d")&&s.push(n),te.format.apply(te.format,s.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){this.cache[this.locale]||this._readLocaleFile();for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(this.cache[this.locale][t]=e[t])}_taggedLiteral(e,...t){let o="";return e.forEach((function(e,n){const r=t[n+1];o+=e,void 0!==r&&(o+="%s")})),this.__.apply(this,[o].concat([].slice.call(t,1)))}_enqueueWrite(e){this.writeQueue.push(e),1===this.writeQueue.length&&this._processWriteQueue()}_processWriteQueue(){const e=this,t=this.writeQueue[0],o=t.directory,n=t.locale,r=t.cb,i=this._resolveLocaleFile(o,n),s=JSON.stringify(this.cache[n],null,2);te.fs.writeFile(i,s,"utf-8",(function(t){e.writeQueue.shift(),e.writeQueue.length>0&&e._processWriteQueue(),r(t)}))}_readLocaleFile(){let e={};const t=this._resolveLocaleFile(this.directory,this.locale);try{te.fs.readFileSync&&(e=JSON.parse(te.fs.readFileSync(t,"utf-8")))}catch(o){if(o instanceof SyntaxError&&(o.message="syntax error in "+t),"ENOENT"!==o.code)throw o;e={}}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let o=te.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(o)&&~t.lastIndexOf("_")){const n=te.resolve(e,"./",t.split("_")[0]+".json");this._fileExistsSync(n)&&(o=n)}return o}_fileExistsSync(e){return te.exists(e)}}let ne;try{ne=y(import.meta.url)}catch(e){ne=process.cwd()}ne.substring(0,ne.lastIndexOf("node_modules"))||process.cwd(),process.cwd,process.exit,process.nextTick,void 0!==process.stdout.columns&&process.stdout.columns,function(e,t){te=t;const o=new oe(e);o.__.bind(o),o.__n.bind(o),o.setLocale.bind(o),o.getLocale.bind(o),o.updateLocale.bind(o),o.locale}({directory:i(ne,"../../../locales"),updateFiles:!1},ee);function re(){return{info:e=>{return console.log(`${b.blue("INFO")} [${b.magenta(S().format("YYYY/MM/DDTHH:mm:ss.SSSSSS"))}] ${t=e,b.white(t)}\n`);var t},warn:e=>{return console.log(`${b.yellow("WARN")} [${b.magenta(S().format("YYYY/MM/DDTHH:mm:ss.SSSSSS"))}] ${t=e,b.white(t)}`);var t},error:e=>{return console.log(`${b.red("ERROR")} [${b.magenta(S().format("YYYY/MM/DDTHH:mm:ss.SSSSSS"))}] ${t=e,b.white(t)}`);var t},debug:e=>{return console.log(`${b.cyan("DEBUG")} [${b.magenta(S().format("YYYY/MM/DDTHH:mm:ss.SSSSSS"))}] ${t=e,b.white(t)}`);var t}}}function ie(e){return{add:(t,o,n,r)=>{e.command({command:t,describe:o,builder:n,handler:r})}}}function se(){const e=x.homedir();return n.join(e,".mfn","cache")}function ae(...e){for(const t of e)if(isNaN(t)||t<1)return!1;return!0}function ce(e,t="INR",o="en-IN"){return new Intl.NumberFormat(o,{style:"currency",currency:t}).format(e)}function le(e){return E(`npm show ${e} version`).toString().trim()}const pe=e=>b.green(e);async function ue(e,t){await $.writeJson(t,e,{spaces:2})}!function(){const e=x.homedir(),t=n.join(e,".mfn","cache");if(!p.existsSync(t))try{p.existsSync(n.join(e,".mfn"))||p.mkdirSync(n.join(e,".mfn")),p.mkdirSync(t,{recursive:!0})}catch(e){}}(),await(async()=>{const e=await(t="M4N-CLI",new Promise(((e,o)=>{v(t,((t,n)=>{t?o(t):e(n)}))})));var t;const o=w(b.hex("#27A244").bold(e),{padding:1,margin:1,dimBorder:!0,borderStyle:"round",borderColor:"#C1C110"}),n=function(){const e=x.platform();return"win32"===e?process.env.USERNAME||"User":"darwin"===e||"linux"===e?process.env.USER||"User":""}();console.log(b.whiteBright.bold("-------------------------------------------------------\n")),console.log(o),n&&n.length>0?console.log(b.magenta(`\n\tWelcome ${n} to the Master4Novice CLI Tool!\n`)):console.log(b.blue("\n\tWelcome to the Master4Novice CLI Tool!\n")),console.log(b.yellow("\tUse this tool to reduce your effort.\n")),console.log(b.white("-------------------------------------------------------\n"))})();const de=e(process.argv.slice(L()+1));const fe=b.hex("#44bcd8").bold("mfn");var me=de.scriptName(fe);const he=re(),ge=(e,t)=>{he.info("Started creating subdirectories..."),t.forEach((t=>{const o=n.join(e,t);p.existsSync(o)?he.warn("Subdirectory already exists..."):(p.mkdirSync(o,{recursive:!0}),he.info(`Created subdirectory - /${t}`))}))},ye=(e,t)=>{he.info(`Current working directory: ${process.cwd()}`);const o=n.join(process.cwd(),e);p.existsSync(o)?(he.warn("Root directory already exist"),t&&t.length>0&&ge(o,t)):(he.info("Started creating root directory inside current working directory..."),p.mkdirSync(o,{recursive:!0}),he.info(`Created root directory - /${e}`),t&&t.length>0&&ge(o,t))},be="md",ve="Make directory and its subdirectories",we=e=>{e.option("d",{alias:"directory",describe:"The root directory to create",type:"string",demandOption:!0}).option("s",{alias:"subdirectories",describe:"Subdirectories to create within the root directory",type:"array"})},je=e=>{if(e.directory&&e.directory.length>0){if(void 0===e.subdirectories)ye(e.directory,e.subdirectories);else{if(0===e.subdirectories.length)return void he.error("Invalid subdirectories name");ye(e.directory,e.subdirectories)}console.log("\n")}else he.error("Invalid directory name")},Se=re(),xe=n.join(se(),"cts_ignore.json");let $e="",Ee=20;let Oe="";async function Ae(){try{return await $.readJson(xe)}catch(e){if("ENOENT"===e.code)return{ignores:[]};throw e}}function ke(e,t,o="",r=0){const i=$.readdirSync(e);i.forEach(((s,a)=>{if(t&&t.includes(s))return;const c=n.join(e,s),l=a===i.length-1,p=$.statSync(c).isDirectory();Oe+=`${o}${l?"└── ":"├── "}${s}`+"\n",p&&ke(c,t,`${o}${l?" ":"│ "}`,r+1)}))}function Me(e,t,o=0,r=new Array){const i=$.readdirSync(e);i.forEach(((s,a)=>{if(t&&t.includes(s))return;const c=n.join(e,s),l=a===i.length-1,p=$.statSync(c).isDirectory();let u="";r.forEach(((e,t)=>{u+=e?"\t".repeat(4):"│"+"\t".repeat(3)})),u+=l?"└── ":"├── ";if($e+=`<text style="white-space: pre;" x="${0*o}" y="${Ee}">${`${u}${s}`}</text>`,Ee+=20,p){const e=[...r,l];Me(c,t,o+1,e)}}))}function De(e){return Buffer.from(e)}const Te=async(e,t,o,r)=>{Se.info(`Processing current working directory: ${process.cwd()}`);const i=n.join(process.cwd()),s=n.basename(i);Oe+=s+"\n",ke(i,t),$e+=`<text x="0" y="20">${s}</text>`,Ee+=20,Me(i,t),$e=`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${o}"><rect width="100%" height="100%" fill="white"/><g fill="black" font-family="monospace" font-size="12">`+$e+"</g></svg>";const a=s+"."+e;switch(e){case"png":{const e=De($e);await A(e).png().toFile(a),Se.info(`Tree structure created for ${s} in file ${a}.`);break}case"jpeg":{const e=De($e);await A(e).jpeg().toFile(a),Se.info(`Tree structure created for ${s} in file ${a}.`);break}case"svg":$.outputFileSync(a,$e),Se.info(`Tree structure created for ${s} in file ${a}.`);break;default:Se.info("Unsupported type...")}Se.debug(Oe)},Ye="cts",Ne="Create tree structure of current working directory and its contents",Re=e=>{e.option("t",{alias:"fileType",describe:"Tree structure will be saved in file type",type:"string",choices:["svg","png","jpeg"],demandOption:!0}).option("i",{alias:"ignores",describe:"Folder list to be ignored in tree structure",type:"array"}).option("l",{alias:"length",describe:"Length of the image",type:"number",default:250}).option("b",{alias:"breadth",describe:"Breadth of the image",type:"number",default:200})},_e=async e=>{if(function(...e){for(const t of e)if(isNaN(t)||t<1||t>1e3)return!1;return!0}(e.length,e.breadth)){let t=e.ignores;if(t&&t.length>0){const e=await Ae();e.ignores=[],await ue(e,xe),e.ignores=[...t],await ue(e,xe),Se.info(`Applying your ignore list: ${t.join(", ")}, updating ignore cache`)}else{const e=await Ae();e.ignores&&e.ignores.length>0&&(Se.info(`Applying your cache ignore list: ${e.ignores.join(", ")}`),t=[...e.ignores])}Te(e.fileType,t,e.length,e.breadth)}else Se.error("Length & Breadth must be valid number (1 to 1000)\n")},ze=re(),Fe=n.join(se(),"sc_ignore.json");async function Le(){try{return await $.readJson(Fe)}catch(e){if("ENOENT"===e.code)return{ignores:[]};throw e}}async function Ie(e,t){if(t&&t.length>0){return await j.prompt([{type:"fuzzypath",name:"filePath",excludePath:e=>t.some((t=>e.includes(t))),excludeFilter:e=>"."==e,message:pe("Select a folder/file:"),itemType:"any",depthLimit:5,rootPath:e}])}return await j.prompt([{type:"fuzzypath",name:"filePath",excludeFilter:e=>"."==e,message:pe("Select a folder/file:"),itemType:"any",depthLimit:5,rootPath:e}])}async function Pe(){return await j.prompt([{type:"confirm",name:"exit",message:pe("Do you want to exit?"),default:!0}])}j.registerPrompt("fuzzypath",k);const Be="sc",qe="Search content of current working directory",He=e=>{e.option("i",{alias:"ignores",describe:"List of directory content to ignore",type:"array"})},Ce=async e=>{let t=process.cwd();let o=e.ignores;if(o&&o.length>0){const e=await Le();e.ignores=[],await ue(e,Fe),e.ignores=[...o],await ue(e,Fe),ze.info(`Applying your ignore list: ${o.join(", ")}, updating ignore cache`)}else{const e=await Le();e.ignores&&e.ignores.length>0&&(ze.info(`Applying your cache ignore list: ${e.ignores.join(", ")}`),o=[...e.ignores])}for(;;){const{filePath:e}=await Ie(t,o),n=$.statSync(e);n.isFile()?(ze.info("Selected content is file..."),ze.info(`${e}`)):n.isDirectory()&&(ze.info("Selected content is directory..."),t=e,process.chdir(t),ze.warn(`${process.cwd()}`));const{exit:r}=await Pe();if(r){ze.warn("Exiting navigation..."),n.isDirectory()&&(ze.info("Use below command to change directory"),ze.info(`cd ${t}`));break}}},Ue=re();const Je="hra",We="Calculate HRA exemption",Qe=e=>{e.option("mb",{alias:"monthlyBasic",describe:"Monthly basic salary",type:"number",demandOption:!0}).option("mr",{alias:"monthlyRent",describe:"Monthly rent paid",type:"number",demandOption:!0}).option("hr",{alias:"hraReceived",describe:"Monthly HRA received from employer",type:"number",demandOption:!0}).option("im",{alias:"isMetro",describe:"Living in a metro city.",type:"boolean",choices:[!0,!1],default:!1})},Ge=e=>{if(!ae(e.monthlyBasic,e.monthlyRent,e.hraReceived))return void Ue.error("Invalid Inputs\n");console.log("HRA exemption is calculated based on the following criteria:\n"),console.log("1. Actual HRA received from the employer."),console.log("2. 50% of salary (basic + DA) for those living in metro cities or 40% for non-metro cities."),console.log("3. Actual rent paid minus 10% of salary (basic + DA).\n");const t={monthlyBasic:e.monthlyBasic,monthlyRent:e.monthlyRent,hraReceived:e.hraReceived,isMetro:e.isMetro};console.log("\n"),Ue.info("Provided Monthly Details:\n"),console.table([{MonthlyBasic:ce(e.monthlyBasic),MonthlyHRAReceived:ce(e.hraReceived),MonthlyRent:ce(e.monthlyRent),IsMetro:e.isMetro}]),console.log("\n");const o=function(e){const{monthlyBasic:t,monthlyRent:o,hraReceived:n,isMetro:r}=e,i=12*t,s=12*n,a=12*o-.1*i,c=(r?.5:.4)*i;return Math.min(s,a,c)}(t);console.log("\n"),Ue.info("Calculated HRA Exemption Details:\n"),console.table([{Basic:ce(12*e.monthlyBasic),HRAReceived:ce(12*e.hraReceived),Rent:ce(12*e.monthlyRent),HRAExemption:ce(o)}]),console.log("\n")},Ve=re();const Ze="sr",Ke="Suggest optimal rent for maximizing HRA exemption",Xe=e=>{e.option("mb",{alias:"monthlyBasic",describe:"Monthly basic salary",type:"number",demandOption:!0}).option("hr",{alias:"hraReceived",describe:"Monthly HRA received from employer",type:"number",demandOption:!0}).option("im",{alias:"isMetro",describe:"Living in a metro city.",type:"boolean",choices:[!0,!1],default:!1})},et=e=>{if(!ae(e.monthlyBasic,e.hraReceived))return void Ve.error("Invalid Inputs\n");console.log("\n"),Ve.info("Provided Details:\n"),console.table([{MonthlyBasic:ce(e.monthlyBasic),MonthlyHRAReceived:ce(e.hraReceived),IsMetro:e.isMetro}]),console.log("\n");const t=(o=e.monthlyBasic,n=e.hraReceived,e.isMetro,(12*o*.1+12*n)/12);var o,n;console.log("\n"),Ve.info("Suggested Rent Details For Maximise HRA Exemption:\n"),console.table([{MonthlyRent:ce(t),AnnualRent:ce(12*t)}]),console.log("\n"),Ve.warn("Suggestions are calculated based on inputs\n")},tt=re();const ot="decode",nt="Decode provided JWT token",rt=e=>{e.option("t",{alias:"token",describe:"JWT token to decode",type:"string",demandOption:!0})},it=e=>{const t=function(e){try{const t=e.split(".");if(3!==t.length)throw new Error("Invalid JWT structure");const o=t[1],n=Buffer.from(o,"base64").toString("utf-8");return JSON.parse(n)}catch(e){return tt.error(`Error decoding JWT: ${e}`),null}}(e.token.replace(/^Bearer\s+/i,""));t&&(console.log("Decoded JWT Payload:\n"),console.log(b.cyanBright.bold("data:"),b.greenBright.bold(JSON.stringify(t,null,2))),console.log("\n"))};j.registerPrompt("date",D),j.registerPrompt("autocomplete",Y);const st=re(),at=M.tz.names(),ct=["YYYY-MM-DD","MM-DD-YYYY","DD-MM-YYYY","MMMM Do YYYY, h:mm:ss a","dddd, MMMM Do YYYY","YYYY-MM-DD HH:mm:ss","MMM DD, YYYY","hh:mm A","HH:mm:ss","MMMM Do YYYY, h:mm:ss a z","ddd, hA","YYYY-MM-DD[T]HH:mm:ss.SSS[Z]","YYYY-MM-DD[T]HH:mm:ssZ"];async function lt(){const{dateTime:e}=await j.prompt({type:"date",name:"dateTime",message:pe("Choose a date to proceed"),clearable:!0});return console.log("\n"),st.info(`Provided date and time is: ${S(e).format("YYYY-MM-DD HH:mm:ss")}`),S(e)}async function pt(){const e=(await lt()).utc();console.log("\n"),st.info(`The UTC date and time is: ${e.format("YYYY-MM-DD HH:mm:ss")} UTC`)}async function ut(){const e=await lt(),t=await async function(){const{timezone:e}=await j.prompt([{type:"autocomplete",name:"timezone",message:pe("Select a timezone:"),source:(e,t)=>(t=t||"",new Promise((e=>{e(T.filter(t,at).map((e=>e.original)))})))}]);return console.log("\n"),e}(),o=e.tz(t);console.log("\n"),st.info(`The date and time in ${t} is: ${o.format("YYYY-MM-DD HH:mm:ss")} ${t}`)}async function dt(){const e=await lt(),t=await async function(){const{format:e}=await j.prompt([{type:"autocomplete",name:"format",message:pe("Select a date format:"),source:(e,t)=>(t=t||"",new Promise((e=>{e(T.filter(t,ct).map((e=>e.original)))})))}]);return console.log("\n"),e}(),o=e.format(t);console.log("\n"),st.info(`The date in the selected format (${t}) is: ${o}`)}const ft="date",mt="Date conversion/operations",ht=e=>e,gt=async e=>{let t=!0,o=!1;do{console.log("\n");const{operation:e}=await j.prompt([{type:"rawlist",name:"operation",message:pe("What do you want to do?"),choices:[{name:"Convert local datetime to UTC datetime",value:"localDateToUTC"},{name:"Convert local datetime to specific timezone datetime",value:"localDateToTimezone"},new j.Separator,{name:"Format date in string",value:"formatDate"},{name:"Exit",value:"exit"}]}]);if("exit"===e)t=!1,o=!1;else switch(console.log("\n"),e){case"localDateToUTC":o=!0,st.info("Operation Local Date To UTC Date\n"),await pt();break;case"localDateToTimezone":o=!0,st.info("Operation Local Date To Timezone\n"),await ut();break;case"formatDate":o=!0,st.info("Operation Format Date\n"),await dt();break;default:st.warn("Invalid option selected.")}if(t&&!o){console.log("\n");const{repeat:e}=await j.prompt([{type:"confirm",name:"repeat",message:pe("Do you want to perform another operation?"),default:!1}]);t=e}}while(t);st.info("Exiting...\n")};j.registerPrompt("date",D),j.registerPrompt("autocomplete",Y);const yt=re();async function bt(){try{const{epochValue:e}=await async function(){return console.log("\n"),await j.prompt({type:"input",name:"epochValue",message:pe("Enter epoch time:"),validate:function(e){return!isNaN(e)||"Please enter a valid epoch time"}})}(),t=N(Number(e));console.log("\n"),yt.info("Epoch to date conversion details:\n"),console.table([{Epoch:`${t.epoch} is in ${t.epochType}`,LocalDateTime:t.localTime,GMTDateTime:t.gmtTime,Relative:t.relative}])}catch(e){console.log("\n"),yt.error(`${e}`)}}async function vt(){try{const e=await async function(){console.log("\n");const{dateTime:e}=await j.prompt({type:"date",name:"dateTime",message:pe("Choose a date to proceed"),clearable:!0});return yt.info(`Provided date and time is: ${S(e).format("YYYY-MM-DD HH:mm:ss")}`),S(e)}(),{epochInSeconds:t,epochInMilliseconds:o,gmtDate:n,timezoneDate:r,timezone:i}=R(e.toDate());console.log("\n"),yt.info("Epoch details:\n"),console.table([{Epochs:`${t} in seconds, ${o} in miliseconds`,LocalDateTime:r,GMTDateTime:n,DetectedTimezone:i}])}catch(e){console.log("\n"),yt.error(`${e}`)}}const wt="epoch",jt="Epoch conversions",St=e=>e,xt=async e=>{let t=!0,o=!1;do{console.log("\n");const{operation:e}=await j.prompt([{type:"rawlist",name:"operation",message:pe("What do you want to do?"),choices:[{name:"Convert epoch to human-readable date",value:"epochToDate"},{name:"Convert human-readable date to epoch",value:"dateToEpoch"},{name:"Exit",value:"exit"}]}]);if("exit"===e)t=!1,o=!1;else switch(console.log("\n"),e){case"epochToDate":o=!0,yt.info("Operation Epoch To Date\n"),await bt();break;case"dateToEpoch":o=!0,yt.info("Operation Date To Epoch\n"),await vt();break;default:yt.warn("Invalid option selected.")}if(t&&!o){console.log("\n");const{repeat:e}=await j.prompt([{type:"confirm",name:"repeat",message:pe("Do you want to perform another operation?"),default:!1}]);t=e}}while(t);yt.info("Exiting...\n")},$t="type Query {\n hello: String\n}\n",Et="const express = require('express');\nconst { ApolloServer } = require('@apollo/server');\nconst { expressMiddleware } = require('@apollo/server/express4');\nconst { readFileSync } = require('fs');\nconst { join } = require('path');\nconst cors = require('cors');\n \nconst getSchema = () => {\n const schemaPath = join(process.cwd(), `resources/schema.graphql`);\n return readFileSync(schemaPath, 'utf-8');\n};\n \nconst typeDefs = getSchema();\n \nconst resolvers = {\n Query: {\n hello: () => 'Hello world!',\n },\n};\n \nconst app = express();\n\nconst server = new ApolloServer({\n typeDefs,\n resolvers,\n});\n \nserver.start().then(() => {\n app.use('/graphql', cors(), express.json(), expressMiddleware(server));\n});\n \napp.listen(4000, () => {\n console.log('🚀 Server ready at http://localhost:4000/graphql');\n});\n",Ot="import express from 'express';\nimport { ApolloServer } from '@apollo/server';\nimport { expressMiddleware } from '@apollo/server/express4';\nimport cors from 'cors';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\n\nconst getSchema = (): string => {\n const schemaPath = join(process.cwd(), `resources/schema.graphql`);\n return readFileSync(schemaPath, 'utf-8');\n};\n\nconst typeDefs = getSchema();\n\nconst resolvers = {\n Query: {\n hello: () => 'Hello world!',\n },\n};\n\nconst app = express();\n\nconst server = new ApolloServer({\n typeDefs,\n resolvers\n});\n\nawait server.start();\n\napp.use('/graphql', cors<cors.CorsRequest>(), express.json(), expressMiddleware(server));\n\napp.listen(4000, () => {\n console.log('🚀 Server ready at http://localhost:4000/graphql');\n});\n",At=re(),kt="create @apollo:express",Mt="Create an Apollo GraphQL Express project",Dt=e=>e,Tt=async e=>{const{projectName:t,moduleType:o}=await async function(e){return await j.prompt(e)}([{type:"input",name:"projectName",message:pe("Enter the project name:"),validate:e=>e.trim().length>0||"Please enter a valid project name."},{type:"expand",name:"moduleType",message:pe("Choose module type:"),choices:[{key:"c",name:"CommonJS",value:"commonjs"},{key:"m",name:"ES Module",value:"module"}],default:0}]),r=S();console.log("\n");const i=_(b.green("@apollo:express:init")).start();try{const e=n.join(process.cwd(),t);p.mkdirSync(e);let s=!1;"module"===o&&(s=!0),function(e,t,o){p.writeFileSync(n.join(e,"package.json"),JSON.stringify(function(e,t,o){const n={"@apollo/server":le("@apollo/server"),cors:le("cors"),express:le("express"),graphql:le("graphql")};let r={},i={};return"module"===e?(r={"@types/cors":le("@types/cors"),"@types/express":le("@types/express"),"@types/node":le("@types/node"),rimraf:le("rimraf"),typescript:le("typescript")},i={name:t.basename(o),version:"1.0.0",main:"./dist/index.js",type:e,scripts:{clean:"rimraf ./dist",build:"npm run clean && tsc",start:"node ./dist/index.js"},dependencies:n,devDependencies:r}):i={name:t.basename(o),version:"1.0.0",main:"src/index.js",type:e,scripts:{start:"node src/index.js"},dependencies:n},i}(o,n,e),null,2)),p.writeFileSync(n.join(e,"README.md"),((e,t)=>"module"===t?`# ${e}\n\nA starter project using apollo graphql and express. It is configured to use the '${t}' system.\n\n## Getting Started\n\n### Prerequisites\n\n- Node.js installed on your machine.\n\n### Build the application\n\nTo build the application, run the following command:\n\n\`\`\`bash\nnpm run build\n\`\`\`\n\n### Running the Server\n\nTo start the server, run the following command:\n\n\`\`\`bash\nnpm run start\n\`\`\`\n\nThe server will be running on [http://localhost:4000/graphql](http://localhost:4000/graphql).\n`:`# ${e}\n\nA starter project using apollo graphql and express. It is configured to use the '${t}' system.\n\n## Getting Started\n\n### Prerequisites\n\n- Node.js installed on your machine.\n\n### Running the Server\n\nTo start the server, run the following command:\n\n\`\`\`bash\nnpm run start\n\`\`\`\n\nThe server will be running on [http://localhost:4000/graphql](http://localhost:4000/graphql).\n`)(n.basename(e),o));const r=n.join(e,"src");p.mkdirSync(r);const i=n.join(e,"resources");p.mkdirSync(i);const s=t?"index.ts":"index.js";(function(e,t,o){p.writeFileSync(n.join(t,"schema.graphql"),$t);const r=o?Ot:Et;p.writeFileSync(e,r)})(n.join(r,s),i,t),t&&function(e){const t={compilerOptions:{target:"es2020",module:"esnext",types:["node"],lib:["es2020"],strict:!0,esModuleInterop:!0,skipLibCheck:!0,outDir:"dist",rootDir:"src",moduleResolution:"node"},include:["./src/**/*"],exclude:["node_modules","dist"]};p.writeFileSync(n.join(e,"tsconfig.json"),JSON.stringify(t,null,2))}(e)}(e,s,o);const a=S(),c=S.duration(a.diff(r)),l=b.dim(`(${c.asSeconds().toFixed(3)})`);i.succeed(`${b.green("@apollo:express:init completed")} ${l}`),function(e,t,o){const n=S();o.start(b.green(`${e}:install`)),process.chdir(t),E("npm install");const r=S(),i=S.duration(r.diff(n)),s=b.dim(`(${i.asSeconds().toFixed(3)})`);o.succeed(`${b.green(`${e}:install completed`)} ${s}`)}("@apollo:express",e,i),console.log("\n"),console.log(b.green(`Project ${n.basename(e)} created successfully.\n`)),console.log("\n")}catch(e){At.error(`: ${e}`),i.fail("Failed to initialize project.")}};const Yt=re(),Nt=n.join(se(),"ports.json");const Rt=e=>new Promise(((t,o)=>{const n="win32"===z()?`taskkill /PID ${e} /F`:`kill -9 ${e}`;O(n,((n,r,i)=>{if(n)return o(n);t(`Process ${e} killed successfully`)}))})),_t=async e=>{try{const t=await Promise.all(e.map((e=>(e=>new Promise((t=>{const o="win32"===z()?`netstat -ano | findstr :${e}`:`lsof -i :${e} | grep LISTEN`;O(o,((o,n,r)=>{if(o||!n)return Yt.warn(`Port ${e} is not in use.\n`),void t(null);if("win32"===z()){const o=n.split("\n")[0],r=o?o.trim().split(/\s+/).pop():null;t(r?{port:e,pid:r}:null)}else{const o=n.split("\n")[0],r=o?o.trim().split(/\s+/)[1]:null;t(r?{port:e,pid:r}:null)}}))})))(e)))),o=t.filter((e=>null!==e));if(0===o.length)return console.log("\n"),void Yt.info("No processes found running on the specified ports\n");const n=o.map((e=>({name:`Port: ${e.port}, PID: ${e.pid}`,value:e.pid})));console.log("\n");const r=await j.prompt([{type:"checkbox",name:"pids",message:pe("Select the processes you want to kill:"),choices:n}]);console.log("\n");for(const e of r.pids){const t=await Rt(e);Yt.info(t)}}catch(e){Yt.error(`${e}`)}},zt="kill",Ft="Kill process running on specific ports",Lt=e=>{e.option("p",{alias:"ports",describe:"List of port numbers",type:"array",coerce:e=>{if(!Array.isArray(e))throw new Error("Ports must be an array");for(const t of e)if(isNaN(Number(t)))throw new Error(`Invalid port number: ${t}`);return e.map(Number)}})},It=async e=>{const t=e.ports,o=await async function(){try{return await $.readJson(Nt)}catch(e){if("ENOENT"===e.code)return{ports:[]};throw e}}();t&&t.length>0?(o.ports=[],await ue(o,Nt),await _t(t),o.ports=[...t],await ue(o,Nt)):o.ports&&o.ports.length>0?(Yt.info(`Using ports [${o.ports.join(", ")}] from cache\n`),await _t(o.ports)):Yt.error("Ports are not provided\n")},Pt=re();async function Bt(e){const t=S(),o=_();console.log("\n");try{o.start(b.green("@start updating/installing")),O(`npm install -g ${e}`,((n,r,i)=>{if(n)return o.fail(b.red("@fail updating/installing")),void Pt.error(`\nError updating package: ${n.message}`);if(i)return void Pt.error(`\nError output: ${i}\n`);const s=S(),a=S.duration(s.diff(t)),c=b.dim(`(${a.asSeconds().toFixed(3)})`);o.succeed(`${b.green("@success updating/installing")} ${c}`),async function(e,t){O(`npm view ${e} version`,((e,o,n)=>{t(e||n?null:o.trim())}))}(e,(t=>{null!==t&&(console.log("\n"),Pt.info(`${e} library updated/installed version -> ${b.green(t)}\n`))}))}))}catch(e){Pt.error(`${e}`)}}const qt="update [package]",Ht="Update the CLI or a specified package to the latest version",Ct=e=>{e.positional("package",{describe:"The name of the package to update",type:"string",default:"@master4n/master-cli"})},Ut=async e=>{Bt(e.package)};var Jt="@master4n/master-cli",Wt="2.2.6",Qt="Command Line Interface For Various Useful Operations",Gt="./bin/index.js",Vt="./bin/index.d.ts",Zt="module",Kt={mfn:"./bin/index.js"},Xt={clean:"rimraf dist",lint:"eslint src/**/*.ts",format:"prettier --write src/**/*.ts",build:"npm run clean && rollup --config"},eo={type:"git",url:"git+https://github.com/Master4Novice/common.git"},to=["cli","helper","module"],oo="dwivna",no={directory:"dist",access:"public"},ro=[{name:"dwivna"}],io={"@master4n/temporal-transformer":"^1.0.5","@types/fs-extra":"^11.0.4","@types/yargs":"^17.0.32",boxen:"^7.1.1",chalk:"^5.3.0",figlet:"^1.7.0","fs-extra":"^11.2.0",fuzzy:"^0.1.3",inquirer:"^9.2.23","inquirer-autocomplete-prompt":"^3.0.1","inquirer-date-prompt":"^3.0.0","inquirer-fuzzy-path":"^2.3.0","is-root":"^3.0.0",moment:"^2.30.1","moment-timezone":"^0.5.45",open:"^10.1.0",sharp:"^0.33.4","update-notifier":"^7.0.0",yargs:"^17.7.2"},so={"@types/figlet":"^1.5.8","@types/inquirer":"^9.0.7","@types/inquirer-fuzzy-path":"^2.3.9","@types/node":"^20.12.12","@types/update-notifier":"^6.0.8",ora:"^8.0.1"},ao="2ef1d0cbf62f6f2742140d6e47cfb1ade721f180",co={name:Jt,version:Wt,description:Qt,main:Gt,types:Vt,type:Zt,bin:Kt,scripts:Xt,repository:eo,keywords:to,author:oo,license:"MIT",homepage:"",publishConfig:no,contributors:ro,dependencies:io,devDependencies:so,gitHead:ao};const lo=F({pkg:Object.freeze({__proto__:null,author:oo,bin:Kt,contributors:ro,default:co,dependencies:io,description:Qt,devDependencies:so,gitHead:ao,homepage:"",keywords:to,license:"MIT",main:Gt,name:Jt,publishConfig:no,repository:eo,scripts:Xt,type:Zt,types:Vt,version:Wt})});ie(me).add(qt,Ht,Ct,Ut),ie(me).add(wt,jt,St,xt),ie(me).add(ft,mt,ht,gt),ie(me).add(ot,nt,rt,it),ie(me).add(kt,Mt,Dt,Tt),ie(me).add(Be,qe,He,Ce),ie(me).add(zt,Ft,Lt,It),ie(me).add(be,ve,we,je),ie(me).add(Ye,Ne,Re,_e),ie(me).add(Je,We,Qe,Ge),ie(me).add(Ze,Ke,Xe,et),me.version().alias("version","v").help().alias("help","h").wrap(null).parse(),lo.notify();
|
|
35
35
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@master4n/master-cli",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "Command Line Interface For Various Useful Operations",
|
|
5
5
|
"main": "./bin/index.js",
|
|
6
6
|
"types": "./bin/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@master4n/temporal-transformer": "^1.0.
|
|
39
|
+
"@master4n/temporal-transformer": "^1.0.5",
|
|
40
40
|
"@types/fs-extra": "^11.0.4",
|
|
41
41
|
"@types/yargs": "^17.0.32",
|
|
42
42
|
"boxen": "^7.1.1",
|