#!/usr/bin/env node 'use strict'; const yargs = require('yargs'); const helpers = require('yargs/helpers'); const execa = require('execa'); const prompts = require('prompts'); const c$1 = require('chalk'); const fig = require('figures'); const require$$2 = require('fs'); const require$$0 = require('util'); require('rimraf'); const pathe = require('pathe'); const require$$1 = require('path'); const require$$3 = require('os'); const require$$4 = require('tty'); const ora = require('ora'); const notifier = require('node-notifier'); const child_process = require('child_process'); const yaml = require('js-yaml'); const fsExtra = require('fs-extra'); const Table = require('cli-table3'); const lodash = require('lodash'); const semver = require('semver'); const readline = require('readline'); const project = require('@trapezedev/project'); const sortPackageJson = require('sort-package-json'); const zod = require('zod'); function findup(rootDir, fn) { let dir = rootDir; while (dir !== pathe.dirname(dir)) { const res = fn(dir); if (res) { return res; } dir = pathe.dirname(dir); } return null; } var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function commonjsRequire(path) { throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); } function u(u){return u&&"object"==typeof u&&"default"in u?u.default:u}var D=u(require$$0),e=require$$1,t=require$$2,r=u(require$$3),n=u(require$$4);function s(u,D){return u(D={exports:{}},D.exports),D.exports}var o,i=(o=Object.freeze({__proto__:null,default:[{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Shippable",constant:"SHIPPABLE",env:"SHIPPABLE",pr:{IS_PULL_REQUEST:"true"}},{name:"Solano CI",constant:"SOLANO",env:"TDDIUM",pr:"TDDIUM_PR_ID"},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"Solano CI",constant:"TDDIUM",env:"TDDIUM",pr:"TDDIUM_PR_ID",deprecated:!0},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Team Foundation Server",constant:"TFS",env:"TF_BUILD"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}}]}))&&o.default||o,a=s((function(u,D){var e=process.env;function t(u){return "string"==typeof u?!!e[u]:Object.keys(u).every((function(D){return e[D]===u[D]}))}Object.defineProperty(D,"_vendors",{value:i.map((function(u){return u.constant}))}),D.name=null,D.isPR=null,i.forEach((function(u){var r=(Array.isArray(u.env)?u.env:[u.env]).every((function(u){return t(u)}));if(D[u.constant]=r,r)switch(D.name=u.name,typeof u.pr){case"string":D.isPR=!!e[u.pr];break;case"object":"env"in u.pr?D.isPR=u.pr.env in e&&e[u.pr.env]!==u.pr.ne:"any"in u.pr?D.isPR=u.pr.any.some((function(u){return !!e[u]})):D.isPR=t(u.pr);break;default:D.isPR=null;}})),D.isCI=!!(e.CI||e.CONTINUOUS_INTEGRATION||e.BUILD_NUMBER||e.RUN_ID||D.name);})),l=(a.name,a.isPR,a.isCI,!1),c=!1,h=!1,F="development",C="undefined"!=typeof window,f="",E=!1;function g(u){return !(!u||"false"===u)}"undefined"!=typeof process&&(process.platform&&(f=String(process.platform)),process.stdout&&(h=g(process.stdout.isTTY)),l=Boolean(a.isCI),process.env&&(process.env.NODE_ENV&&(F=process.env.NODE_ENV),c=g(process.env.DEBUG),E=g(process.env.MINIMAL)));var d={browser:C,test:"test"===F,dev:"development"===F||"dev"===F,production:"production"===F,debug:c,ci:l,tty:h,minimal:void 0,minimalCLI:void 0,windows:/^win/i.test(f),darwin:/^darwin/i.test(f),linux:/^linux/i.test(f)};d.minimal=E||d.ci||d.test||!d.tty,d.minimalCLI=d.minimal;var p=Object.freeze(d);const m={};m[m.Fatal=0]="Fatal",m[m.Error=0]="Error",m[m.Warn=1]="Warn",m[m.Log=2]="Log",m[m.Info=3]="Info",m[m.Success=3]="Success",m[m.Debug=4]="Debug",m[m.Trace=5]="Trace",m[m.Silent=-1/0]="Silent",m[m.Verbose=1/0]="Verbose";var b={silent:{level:-1},fatal:{level:m.Fatal},error:{level:m.Error},warn:{level:m.Warn},log:{level:m.Log},info:{level:m.Info},success:{level:m.Success},debug:{level:m.Debug},trace:{level:m.Trace},verbose:{level:m.Trace},ready:{level:m.Info},start:{level:m.Info}};function y(u){return D=u,"[object Object]"===Object.prototype.toString.call(D)&&(!(!u.message&&!u.args)&&!u.stack);var D;}let B=!1;const v=[];class _{constructor(u={}){this._reporters=u.reporters||[],this._types=u.types||b,this.level=void 0!==u.level?u.level:3,this._defaults=u.defaults||{},this._async=void 0!==u.async?u.async:void 0,this._stdout=u.stdout,this._stderr=u.stderr,this._mockFn=u.mockFn,this._throttle=u.throttle||1e3,this._throttleMin=u.throttleMin||5;for(const u in this._types){const D={type:u,...this._types[u],...this._defaults};this[u]=this._wrapLogFn(D),this[u].raw=this._wrapLogFn(D,!0);}this._mockFn&&this.mockTypes(),this._lastLogSerialized=void 0,this._lastLog=void 0,this._lastLogTime=void 0,this._lastLogCount=0,this._throttleTimeout=void 0;}get stdout(){return this._stdout||console._stdout}get stderr(){return this._stderr||console._stderr}create(u){return new _(Object.assign({reporters:this._reporters,level:this.level,types:this._types,defaults:this._defaults,stdout:this._stdout,stderr:this._stderr,mockFn:this._mockFn},u))}withDefaults(u){return this.create({defaults:Object.assign({},this._defaults,u)})}withTag(u){return this.withDefaults({tag:this._defaults.tag?this._defaults.tag+":"+u:u})}addReporter(u){return this._reporters.push(u),this}removeReporter(u){if(u){const D=this._reporters.indexOf(u);if(D>=0)return this._reporters.splice(D,1)}else this._reporters.splice(0);return this}setReporters(u){return this._reporters=Array.isArray(u)?u:[u],this}wrapAll(){this.wrapConsole(),this.wrapStd();}restoreAll(){this.restoreConsole(),this.restoreStd();}wrapConsole(){for(const u in this._types)console["__"+u]||(console["__"+u]=console[u]),console[u]=this[u].raw;}restoreConsole(){for(const u in this._types)console["__"+u]&&(console[u]=console["__"+u],delete console["__"+u]);}wrapStd(){this._wrapStream(this.stdout,"log"),this._wrapStream(this.stderr,"log");}_wrapStream(u,D){u&&(u.__write||(u.__write=u.write),u.write=u=>{this[D].raw(String(u).trim());});}restoreStd(){this._restoreStream(this.stdout),this._restoreStream(this.stderr);}_restoreStream(u){u&&u.__write&&(u.write=u.__write,delete u.__write);}pauseLogs(){B=!0;}resumeLogs(){B=!1;const u=v.splice(0);for(const D of u)D[0]._logFn(D[1],D[2]);}mockTypes(u){if(this._mockFn=u||this._mockFn,"function"==typeof this._mockFn)for(const u in this._types)this[u]=this._mockFn(u,this._types[u])||this[u],this[u].raw=this[u];}_wrapLogFn(u,D){return (...e)=>{if(!B)return this._logFn(u,e,D);v.push([this,u,e,D]);}}_logFn(u,D,e){if(u.level>this.level)return !!this._async&&Promise.resolve(!1);const t=Object.assign({date:new Date,args:[]},u);!e&&1===D.length&&y(D[0])?Object.assign(t,D[0]):t.args=Array.from(D),t.message&&(t.args.unshift(t.message),delete t.message),t.additional&&(Array.isArray(t.additional)||(t.additional=t.additional.split("\n")),t.args.push("\n"+t.additional.join("\n")),delete t.additional),t.type="string"==typeof t.type?t.type.toLowerCase():"",t.tag="string"==typeof t.tag?t.tag.toLowerCase():"";const r=(u=!1)=>{const D=this._lastLogCount-this._throttleMin;if(this._lastLog&&D>0){const u=[...this._lastLog.args];D>1&&u.push(`(repeated ${D} times)`),this._log({...this._lastLog,args:u}),this._lastLogCount=1;}if(u){if(this._lastLog=t,this._async)return this._logAsync(t);this._log(t);}};clearTimeout(this._throttleTimeout);const n=this._lastLogTime?t.date-this._lastLogTime:0;if(this._lastLogTime=t.date,nthis._throttleMin))return void(this._throttleTimeout=setTimeout(r,this._throttle))}catch(u){}r(!0);}_log(u){for(const D of this._reporters)D.log(u,{async:!1,stdout:this.stdout,stderr:this.stderr});}_logAsync(u){return Promise.all(this._reporters.map(D=>D.log(u,{async:!0,stdout:this.stdout,stderr:this.stderr})))}}function A(u){const D=process.cwd()+e.sep;return u.split("\n").splice(1).map(u=>u.trim().replace("file://","").replace(D,""))}_.prototype.add=_.prototype.addReporter,_.prototype.remove=_.prototype.removeReporter,_.prototype.clear=_.prototype.removeReporter,_.prototype.withScope=_.prototype.withTag,_.prototype.mock=_.prototype.mockTypes,_.prototype.pause=_.prototype.pauseLogs,_.prototype.resume=_.prototype.resumeLogs;var w=s((function(u,D){u.exports=function(){var u="millisecond",D="second",e="minute",t="hour",r="day",n="week",s="month",o="quarter",i="year",a=/^(\d{4})-?(\d{1,2})-?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?.?(\d{1,3})?$/,l=/\[([^\]]+)]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,c=function(u,D,e){var t=String(u);return !t||t.length>=D?u:""+Array(D+1-t.length).join(e)+u},h={s:c,z:function(u){var D=-u.utcOffset(),e=Math.abs(D),t=Math.floor(e/60),r=e%60;return (D<=0?"+":"-")+c(t,2,"0")+":"+c(r,2,"0")},m:function(u,D){var e=12*(D.year()-u.year())+(D.month()-u.month()),t=u.clone().add(e,s),r=D-t<0,n=u.clone().add(e+(r?-1:1),s);return Number(-(e+(D-t)/(r?t-n:n-t))||0)},a:function(u){return u<0?Math.ceil(u)||0:Math.floor(u)},p:function(a){return {M:s,y:i,w:n,d:r,D:"date",h:t,m:e,s:D,ms:u,Q:o}[a]||String(a||"").toLowerCase().replace(/s$/,"")},u:function(u){return void 0===u}},F={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},C="en",f={};f[C]=F;var E=function(u){return u instanceof m},g=function(u,D,e){var t;if(!u)return C;if("string"==typeof u)f[u]&&(t=u),D&&(f[u]=D,t=u);else {var r=u.name;f[r]=u,t=r;}return !e&&t&&(C=t),t||!e&&C},d=function(u,D){if(E(u))return u.clone();var e="object"==typeof D?D:{};return e.date=u,e.args=arguments,new m(e)},p=h;p.l=g,p.i=E,p.w=function(u,D){return d(u,{locale:D.$L,utc:D.$u,$offset:D.$offset})};var m=function(){function c(u){this.$L=this.$L||g(u.locale,null,!0),this.parse(u);}var h=c.prototype;return h.parse=function(u){this.$d=function(u){var D=u.date,e=u.utc;if(null===D)return new Date(NaN);if(p.u(D))return new Date;if(D instanceof Date)return new Date(D);if("string"==typeof D&&!/Z$/i.test(D)){var t=D.match(a);if(t)return e?new Date(Date.UTC(t[1],t[2]-1,t[3]||1,t[4]||0,t[5]||0,t[6]||0,t[7]||0)):new Date(t[1],t[2]-1,t[3]||1,t[4]||0,t[5]||0,t[6]||0,t[7]||0)}return new Date(D)}(u),this.init();},h.init=function(){var u=this.$d;this.$y=u.getFullYear(),this.$M=u.getMonth(),this.$D=u.getDate(),this.$W=u.getDay(),this.$H=u.getHours(),this.$m=u.getMinutes(),this.$s=u.getSeconds(),this.$ms=u.getMilliseconds();},h.$utils=function(){return p},h.isValid=function(){return !("Invalid Date"===this.$d.toString())},h.isSame=function(u,D){var e=d(u);return this.startOf(D)<=e&&e<=this.endOf(D)},h.isAfter=function(u,D){return d(u)u?`[${u}]`:"";class S{constructor(u){this.options=Object.assign({},O,u);}formatStack(u){return " "+A(u).join("\n ")}formatArgs(u){const e=u.map(u=>u&&"string"==typeof u.stack?u.message+"\n"+this.formatStack(u.stack):u);return "function"==typeof D.formatWithOptions?D.formatWithOptions(this.options.formatOptions,...e):D.format(...e)}formatDate(u){return this.options.formatOptions.date?function(u,D){return w(D).format(u)}(this.options.dateFormat,u):""}filterAndJoin(u){return u.filter(u=>u).join(" ")}formatLogObj(u){const D=this.formatArgs(u.args);return this.filterAndJoin([M(u.type),M(u.tag),D])}log(u,{async:D,stdout:e,stderr:r}={}){return function(u,D,e="default"){const r=D.__write||D.write;switch(e){case"async":return new Promise(e=>{!0===r.call(D,u)?e():D.once("drain",()=>{e();});});case"sync":return t.writeSync(D.fd,u);default:return r.call(D,u)}}(this.formatLogObj(u,{width:e.columns||0})+"\n",u.level<2?r:e,D?"async":"default")}}var I=u=>"string"==typeof u?u.replace((({onlyFirst:u=!1}={})=>{const D=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(D,u?void 0:"g")})(),""):u;const k=u=>!Number.isNaN(u)&&(u>=4352&&(u<=4447||9001===u||9002===u||11904<=u&&u<=12871&&12351!==u||12880<=u&&u<=19903||19968<=u&&u<=42182||43360<=u&&u<=43388||44032<=u&&u<=55203||63744<=u&&u<=64255||65040<=u&&u<=65049||65072<=u&&u<=65131||65281<=u&&u<=65376||65504<=u&&u<=65510||110592<=u&&u<=110593||127488<=u&&u<=127569||131072<=u&&u<=262141));var R=k,T=k;R.default=T;const L=u=>{if("string"!=typeof(u=u.replace(/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g," "))||0===u.length)return 0;u=I(u);let D=0;for(let e=0;e=127&&t<=159||(t>=768&&t<=879||(t>65535&&e++,D+=R(t)?2:1));}return D};var $=L,x=L;$.default=x;var U=/[|\\{}()[\]^$+*?.]/g,j=function(u){if("string"!=typeof u)throw new TypeError("Expected a string");return u.replace(U,"\\$&")};const{platform:P}=process,N={tick:"✔",cross:"✖",star:"★",square:"▇",squareSmall:"◻",squareSmallFilled:"◼",play:"▶",circle:"◯",circleFilled:"◉",circleDotted:"◌",circleDouble:"◎",circleCircle:"ⓞ",circleCross:"ⓧ",circlePipe:"Ⓘ",circleQuestionMark:"?⃝",bullet:"●",dot:"․",line:"─",ellipsis:"…",pointer:"❯",pointerSmall:"›",info:"ℹ",warning:"⚠",hamburger:"☰",smiley:"㋡",mustache:"෴",heart:"♥",nodejs:"⬢",arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",checkboxCircleOn:"ⓧ",checkboxCircleOff:"Ⓘ",questionMarkPrefix:"?⃝",oneHalf:"½",oneThird:"⅓",oneQuarter:"¼",oneFifth:"⅕",oneSixth:"⅙",oneSeventh:"⅐",oneEighth:"⅛",oneNinth:"⅑",oneTenth:"⅒",twoThirds:"⅔",twoFifths:"⅖",threeQuarters:"¾",threeFifths:"⅗",threeEighths:"⅜",fourFifths:"⅘",fiveSixths:"⅚",fiveEighths:"⅝",sevenEighths:"⅞"},q={tick:"√",cross:"×",star:"*",square:"█",squareSmall:"[ ]",squareSmallFilled:"[█]",play:"►",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(○)",circleCross:"(×)",circlePipe:"(│)",circleQuestionMark:"(?)",bullet:"*",dot:".",line:"─",ellipsis:"...",pointer:">",pointerSmall:"»",info:"i",warning:"‼",hamburger:"≡",smiley:"☺",mustache:"┌─┐",heart:N.heart,nodejs:"♦",arrowUp:N.arrowUp,arrowDown:N.arrowDown,arrowLeft:N.arrowLeft,arrowRight:N.arrowRight,radioOn:"(*)",radioOff:"( )",checkboxOn:"[×]",checkboxOff:"[ ]",checkboxCircleOn:"(×)",checkboxCircleOff:"( )",questionMarkPrefix:"?",oneHalf:"1/2",oneThird:"1/3",oneQuarter:"1/4",oneFifth:"1/5",oneSixth:"1/6",oneSeventh:"1/7",oneEighth:"1/8",oneNinth:"1/9",oneTenth:"1/10",twoThirds:"2/3",twoFifths:"2/5",threeQuarters:"3/4",threeFifths:"3/5",threeEighths:"3/8",fourFifths:"4/5",fiveSixths:"5/6",fiveEighths:"5/8",sevenEighths:"7/8"};"linux"===P&&(N.questionMarkPrefix="?");const Y="win32"===P?q:N;var H=Object.assign(u=>{if(Y===N)return u;for(const[D,e]of Object.entries(N))e!==Y[D]&&(u=u.replace(new RegExp(j(e),"g"),Y[D]));return u},Y),V=N,W=q;H.main=V,H.windows=W;var G={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};const z={};for(const u of Object.keys(G))z[G[u]]=u;const Q={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};var J=Q;for(const u of Object.keys(Q)){if(!("channels"in Q[u]))throw new Error("missing channels property: "+u);if(!("labels"in Q[u]))throw new Error("missing channel labels property: "+u);if(Q[u].labels.length!==Q[u].channels)throw new Error("channel and label counts mismatch: "+u);const{channels:D,labels:e}=Q[u];delete Q[u].channels,delete Q[u].labels,Object.defineProperty(Q[u],"channels",{value:D}),Object.defineProperty(Q[u],"labels",{value:e});}function K(u){const D=function(){const u={},D=Object.keys(J);for(let e=D.length,t=0;t1&&(r-=1)),[360*r,100*n,100*a]},Q.rgb.hwb=function(u){const D=u[0],e=u[1];let t=u[2];const r=Q.rgb.hsl(u)[0],n=1/255*Math.min(D,Math.min(e,t));return t=1-1/255*Math.max(D,Math.max(e,t)),[r,100*n,100*t]},Q.rgb.cmyk=function(u){const D=u[0]/255,e=u[1]/255,t=u[2]/255,r=Math.min(1-D,1-e,1-t);return [100*((1-D-r)/(1-r)||0),100*((1-e-r)/(1-r)||0),100*((1-t-r)/(1-r)||0),100*r]},Q.rgb.keyword=function(u){const D=z[u];if(D)return D;let e,t=1/0;for(const D of Object.keys(G)){const s=(n=G[D],((r=u)[0]-n[0])**2+(r[1]-n[1])**2+(r[2]-n[2])**2);s.04045?((D+.055)/1.055)**2.4:D/12.92,e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,t=t>.04045?((t+.055)/1.055)**2.4:t/12.92;return [100*(.4124*D+.3576*e+.1805*t),100*(.2126*D+.7152*e+.0722*t),100*(.0193*D+.1192*e+.9505*t)]},Q.rgb.lab=function(u){const D=Q.rgb.xyz(u);let e=D[0],t=D[1],r=D[2];e/=95.047,t/=100,r/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,t=t>.008856?t**(1/3):7.787*t+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;return [116*t-16,500*(e-t),200*(t-r)]},Q.hsl.rgb=function(u){const D=u[0]/360,e=u[1]/100,t=u[2]/100;let r,n,s;if(0===e)return s=255*t,[s,s,s];r=t<.5?t*(1+e):t+e-t*e;const o=2*t-r,i=[0,0,0];for(let u=0;u<3;u++)n=D+1/3*-(u-1),n<0&&n++,n>1&&n--,s=6*n<1?o+6*(r-o)*n:2*n<1?r:3*n<2?o+(r-o)*(2/3-n)*6:o,i[u]=255*s;return i},Q.hsl.hsv=function(u){const D=u[0];let e=u[1]/100,t=u[2]/100,r=e;const n=Math.max(t,.01);t*=2,e*=t<=1?t:2-t,r*=n<=1?n:2-n;return [D,100*(0===t?2*r/(n+r):2*e/(t+e)),100*((t+e)/2)]},Q.hsv.rgb=function(u){const D=u[0]/60,e=u[1]/100;let t=u[2]/100;const r=Math.floor(D)%6,n=D-Math.floor(D),s=255*t*(1-e),o=255*t*(1-e*n),i=255*t*(1-e*(1-n));switch(t*=255,r){case 0:return [t,i,s];case 1:return [o,t,s];case 2:return [s,t,i];case 3:return [s,o,t];case 4:return [i,s,t];case 5:return [t,s,o]}},Q.hsv.hsl=function(u){const D=u[0],e=u[1]/100,t=u[2]/100,r=Math.max(t,.01);let n,s;s=(2-e)*t;const o=(2-e)*r;return n=e*r,n/=o<=1?o:2-o,n=n||0,s/=2,[D,100*n,100*s]},Q.hwb.rgb=function(u){const D=u[0]/360;let e=u[1]/100,t=u[2]/100;const r=e+t;let n;r>1&&(e/=r,t/=r);const s=Math.floor(6*D),o=1-t;n=6*D-s,0!=(1&s)&&(n=1-n);const i=e+n*(o-e);let a,l,c;switch(s){default:case 6:case 0:a=o,l=i,c=e;break;case 1:a=i,l=o,c=e;break;case 2:a=e,l=o,c=i;break;case 3:a=e,l=i,c=o;break;case 4:a=i,l=e,c=o;break;case 5:a=o,l=e,c=i;}return [255*a,255*l,255*c]},Q.cmyk.rgb=function(u){const D=u[0]/100,e=u[1]/100,t=u[2]/100,r=u[3]/100;return [255*(1-Math.min(1,D*(1-r)+r)),255*(1-Math.min(1,e*(1-r)+r)),255*(1-Math.min(1,t*(1-r)+r))]},Q.xyz.rgb=function(u){const D=u[0]/100,e=u[1]/100,t=u[2]/100;let r,n,s;return r=3.2406*D+-1.5372*e+-.4986*t,n=-.9689*D+1.8758*e+.0415*t,s=.0557*D+-.204*e+1.057*t,r=r>.0031308?1.055*r**(1/2.4)-.055:12.92*r,n=n>.0031308?1.055*n**(1/2.4)-.055:12.92*n,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,r=Math.min(Math.max(0,r),1),n=Math.min(Math.max(0,n),1),s=Math.min(Math.max(0,s),1),[255*r,255*n,255*s]},Q.xyz.lab=function(u){let D=u[0],e=u[1],t=u[2];D/=95.047,e/=100,t/=108.883,D=D>.008856?D**(1/3):7.787*D+16/116,e=e>.008856?e**(1/3):7.787*e+16/116,t=t>.008856?t**(1/3):7.787*t+16/116;return [116*e-16,500*(D-e),200*(e-t)]},Q.lab.xyz=function(u){let D,e,t;e=(u[0]+16)/116,D=u[1]/500+e,t=e-u[2]/200;const r=e**3,n=D**3,s=t**3;return e=r>.008856?r:(e-16/116)/7.787,D=n>.008856?n:(D-16/116)/7.787,t=s>.008856?s:(t-16/116)/7.787,D*=95.047,e*=100,t*=108.883,[D,e,t]},Q.lab.lch=function(u){const D=u[0],e=u[1],t=u[2];let r;r=360*Math.atan2(t,e)/2/Math.PI,r<0&&(r+=360);return [D,Math.sqrt(e*e+t*t),r]},Q.lch.lab=function(u){const D=u[0],e=u[1],t=u[2]/360*2*Math.PI;return [D,e*Math.cos(t),e*Math.sin(t)]},Q.rgb.ansi16=function(u,D=null){const[e,t,r]=u;let n=null===D?Q.rgb.hsv(u)[2]:D;if(n=Math.round(n/50),0===n)return 30;let s=30+(Math.round(r/255)<<2|Math.round(t/255)<<1|Math.round(e/255));return 2===n&&(s+=60),s},Q.hsv.ansi16=function(u){return Q.rgb.ansi16(Q.hsv.rgb(u),u[2])},Q.rgb.ansi256=function(u){const D=u[0],e=u[1],t=u[2];if(D===e&&e===t)return D<8?16:D>248?231:Math.round((D-8)/247*24)+232;return 16+36*Math.round(D/255*5)+6*Math.round(e/255*5)+Math.round(t/255*5)},Q.ansi16.rgb=function(u){let D=u%10;if(0===D||7===D)return u>50&&(D+=3.5),D=D/10.5*255,[D,D,D];const e=.5*(1+~~(u>50));return [(1&D)*e*255,(D>>1&1)*e*255,(D>>2&1)*e*255]},Q.ansi256.rgb=function(u){if(u>=232){const D=10*(u-232)+8;return [D,D,D]}let D;u-=16;return [Math.floor(u/36)/5*255,Math.floor((D=u%36)/6)/5*255,D%6/5*255]},Q.rgb.hex=function(u){const D=(((255&Math.round(u[0]))<<16)+((255&Math.round(u[1]))<<8)+(255&Math.round(u[2]))).toString(16).toUpperCase();return "000000".substring(D.length)+D},Q.hex.rgb=function(u){const D=u.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!D)return [0,0,0];let e=D[0];3===D[0].length&&(e=e.split("").map(u=>u+u).join(""));const t=parseInt(e,16);return [t>>16&255,t>>8&255,255&t]},Q.rgb.hcg=function(u){const D=u[0]/255,e=u[1]/255,t=u[2]/255,r=Math.max(Math.max(D,e),t),n=Math.min(Math.min(D,e),t),s=r-n;let o,i;return o=s<1?n/(1-s):0,i=s<=0?0:r===D?(e-t)/s%6:r===e?2+(t-D)/s:4+(D-e)/s,i/=6,i%=1,[360*i,100*s,100*o]},Q.hsl.hcg=function(u){const D=u[1]/100,e=u[2]/100,t=e<.5?2*D*e:2*D*(1-e);let r=0;return t<1&&(r=(e-.5*t)/(1-t)),[u[0],100*t,100*r]},Q.hsv.hcg=function(u){const D=u[1]/100,e=u[2]/100,t=D*e;let r=0;return t<1&&(r=(e-t)/(1-t)),[u[0],100*t,100*r]},Q.hcg.rgb=function(u){const D=u[0]/360,e=u[1]/100,t=u[2]/100;if(0===e)return [255*t,255*t,255*t];const r=[0,0,0],n=D%1*6,s=n%1,o=1-s;let i=0;switch(Math.floor(n)){case 0:r[0]=1,r[1]=s,r[2]=0;break;case 1:r[0]=o,r[1]=1,r[2]=0;break;case 2:r[0]=0,r[1]=1,r[2]=s;break;case 3:r[0]=0,r[1]=o,r[2]=1;break;case 4:r[0]=s,r[1]=0,r[2]=1;break;default:r[0]=1,r[1]=0,r[2]=o;}return i=(1-e)*t,[255*(e*r[0]+i),255*(e*r[1]+i),255*(e*r[2]+i)]},Q.hcg.hsv=function(u){const D=u[1]/100,e=D+u[2]/100*(1-D);let t=0;return e>0&&(t=D/e),[u[0],100*t,100*e]},Q.hcg.hsl=function(u){const D=u[1]/100,e=u[2]/100*(1-D)+.5*D;let t=0;return e>0&&e<.5?t=D/(2*e):e>=.5&&e<1&&(t=D/(2*(1-e))),[u[0],100*t,100*e]},Q.hcg.hwb=function(u){const D=u[1]/100,e=D+u[2]/100*(1-D);return [u[0],100*(e-D),100*(1-e)]},Q.hwb.hcg=function(u){const D=u[1]/100,e=1-u[2]/100,t=e-D;let r=0;return t<1&&(r=(e-t)/(1-t)),[u[0],100*t,100*r]},Q.apple.rgb=function(u){return [u[0]/65535*255,u[1]/65535*255,u[2]/65535*255]},Q.rgb.apple=function(u){return [u[0]/255*65535,u[1]/255*65535,u[2]/255*65535]},Q.gray.rgb=function(u){return [u[0]/100*255,u[0]/100*255,u[0]/100*255]},Q.gray.hsl=function(u){return [0,0,u[0]]},Q.gray.hsv=Q.gray.hsl,Q.gray.hwb=function(u){return [0,100,u[0]]},Q.gray.cmyk=function(u){return [0,0,0,u[0]]},Q.gray.lab=function(u){return [u[0],0,0]},Q.gray.hex=function(u){const D=255&Math.round(u[0]/100*255),e=((D<<16)+(D<<8)+D).toString(16).toUpperCase();return "000000".substring(e.length)+e},Q.rgb.gray=function(u){return [(u[0]+u[1]+u[2])/3/255*100]};const uu={};Object.keys(J).forEach(u=>{uu[u]={},Object.defineProperty(uu[u],"channels",{value:J[u].channels}),Object.defineProperty(uu[u],"labels",{value:J[u].labels});const D=function(u){const D=K(u),e={},t=Object.keys(D);for(let u=t.length,r=0;r{const t=D[e];uu[u][e]=function(u){const D=function(...D){const e=D[0];if(null==e)return e;e.length>1&&(D=e);const t=u(D);if("object"==typeof t)for(let u=t.length,D=0;D1&&(D=e),u(D))};return "conversion"in u&&(D.conversion=u.conversion),D}(t);});});var Du=uu,eu=s((function(u){const D=(u,D)=>(...e)=>`[${u(...e)+D}m`,e=(u,D)=>(...e)=>{const t=u(...e);return `[${38+D};5;${t}m`},t=(u,D)=>(...e)=>{const t=u(...e);return `[${38+D};2;${t[0]};${t[1]};${t[2]}m`},r=u=>u,n=(u,D,e)=>[u,D,e],s=(u,D,e)=>{Object.defineProperty(u,D,{get:()=>{const t=e();return Object.defineProperty(u,D,{value:t,enumerable:!0,configurable:!0}),t},enumerable:!0,configurable:!0});};let o;const i=(u,D,e,t)=>{void 0===o&&(o=Du);const r=t?10:0,n={};for(const[t,s]of Object.entries(o)){const o="ansi16"===t?"ansi":t;t===D?n[o]=u(e,r):"object"==typeof s&&(n[o]=u(s[D],r));}return n};Object.defineProperty(u,"exports",{enumerable:!0,get:function(){const u=new Map,o={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};o.color.gray=o.color.blackBright,o.bgColor.bgGray=o.bgColor.bgBlackBright,o.color.grey=o.color.blackBright,o.bgColor.bgGrey=o.bgColor.bgBlackBright;for(const[D,e]of Object.entries(o)){for(const[D,t]of Object.entries(e))o[D]={open:`[${t[0]}m`,close:`[${t[1]}m`},e[D]=o[D],u.set(t[0],t[1]);Object.defineProperty(o,D,{value:e,enumerable:!1});}return Object.defineProperty(o,"codes",{value:u,enumerable:!1}),o.color.close="",o.bgColor.close="",s(o.color,"ansi",()=>i(D,"ansi16",r,!1)),s(o.color,"ansi256",()=>i(e,"ansi256",r,!1)),s(o.color,"ansi16m",()=>i(t,"rgb",n,!1)),s(o.bgColor,"ansi",()=>i(D,"ansi16",r,!0)),s(o.bgColor,"ansi256",()=>i(e,"ansi256",r,!0)),s(o.bgColor,"ansi16m",()=>i(t,"rgb",n,!0)),o}});})),tu=(u,D=process.argv)=>{const e=u.startsWith("-")?"":1===u.length?"-":"--",t=D.indexOf(e+u),r=D.indexOf("--");return -1!==t&&(-1===r||t=2,has16m:u>=3}}function ou(u,D){if(0===nu)return 0;if(tu("color=16m")||tu("color=full")||tu("color=truecolor"))return 3;if(tu("color=256"))return 2;if(u&&!D&&void 0===nu)return 0;const e=nu||0;if("dumb"===ru.TERM)return e;if("win32"===process.platform){const u=r.release().split(".");return Number(u[0])>=10&&Number(u[2])>=10586?Number(u[2])>=14931?3:2:1}if("CI"in ru)return ["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(u=>u in ru)||"codeship"===ru.CI_NAME?1:e;if("TEAMCITY_VERSION"in ru)return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(ru.TEAMCITY_VERSION)?1:0;if("GITHUB_ACTIONS"in ru)return 1;if("truecolor"===ru.COLORTERM)return 3;if("TERM_PROGRAM"in ru){const u=parseInt((ru.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(ru.TERM_PROGRAM){case"iTerm.app":return u>=3?3:2;case"Apple_Terminal":return 2}}return /-256(color)?$/i.test(ru.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(ru.TERM)||"COLORTERM"in ru?1:e}tu("no-color")||tu("no-colors")||tu("color=false")||tu("color=never")?nu=0:(tu("color")||tu("colors")||tu("color=true")||tu("color=always"))&&(nu=1),"FORCE_COLOR"in ru&&(nu="true"===ru.FORCE_COLOR?1:"false"===ru.FORCE_COLOR?0:0===ru.FORCE_COLOR.length?1:Math.min(parseInt(ru.FORCE_COLOR,10),3));var iu={supportsColor:function(u){return su(ou(u,u&&u.isTTY))},stdout:su(ou(!0,n.isatty(1))),stderr:su(ou(!0,n.isatty(2)))};var au={stringReplaceAll:(u,D,e)=>{let t=u.indexOf(D);if(-1===t)return u;const r=D.length;let n=0,s="";do{s+=u.substr(n,t-n)+D+e,n=t+r,t=u.indexOf(D,n);}while(-1!==t);return s+=u.substr(n),s},stringEncaseCRLFWithFirstIndex:(u,D,e,t)=>{let r=0,n="";do{const s="\r"===u[t-1];n+=u.substr(r,(s?t-1:t)-r)+D+(s?"\r\n":"\n")+e,r=t+1,t=u.indexOf("\n",r);}while(-1!==t);return n+=u.substr(r),n}};const lu=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,cu=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,hu=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,Fu=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,Cu=new Map([["n","\n"],["r","\r"],["t","\t"],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e",""],["a",""]]);function fu(u){const D="u"===u[0],e="{"===u[1];return D&&!e&&5===u.length||"x"===u[0]&&3===u.length?String.fromCharCode(parseInt(u.slice(1),16)):D&&e?String.fromCodePoint(parseInt(u.slice(2,-1),16)):Cu.get(u)||u}function Eu(u,D){const e=[],t=D.trim().split(/\s*,\s*/g);let r;for(const D of t){const t=Number(D);if(Number.isNaN(t)){if(!(r=D.match(hu)))throw new Error(`Invalid Chalk template style argument: ${D} (in style '${u}')`);e.push(r[2].replace(Fu,(u,D,e)=>D?fu(D):e));}else e.push(t);}return e}function gu(u){cu.lastIndex=0;const D=[];let e;for(;null!==(e=cu.exec(u));){const u=e[1];if(e[2]){const t=Eu(u,e[2]);D.push([u].concat(t));}else D.push([u]);}return D}function du(u,D){const e={};for(const u of D)for(const D of u.styles)e[D[0]]=u.inverse?null:D.slice(1);let t=u;for(const[u,D]of Object.entries(e))if(Array.isArray(D)){if(!(u in t))throw new Error("Unknown Chalk style: "+u);t=D.length>0?t[u](...D):t[u];}return t}var pu=(u,D)=>{const e=[],t=[];let r=[];if(D.replace(lu,(D,n,s,o,i,a)=>{if(n)r.push(fu(n));else if(o){const D=r.join("");r=[],t.push(0===e.length?D:du(u,e)(D)),e.push({inverse:s,styles:gu(o)});}else if(i){if(0===e.length)throw new Error("Found extraneous } in Chalk template literal");t.push(du(u,e)(r.join(""))),r=[],e.pop();}else r.push(a);}),t.push(r.join("")),e.length>0){const u=`Chalk template literal is missing ${e.length} closing bracket${1===e.length?"":"s"} (\`}\`)`;throw new Error(u)}return t.join("")};const{stdout:mu,stderr:bu}=iu,{stringReplaceAll:yu,stringEncaseCRLFWithFirstIndex:Bu}=au,vu=["ansi","ansi","ansi256","ansi16m"],_u=Object.create(null);class Au{constructor(u){return wu(u)}}const wu=u=>{const D={};return ((u,D={})=>{if(D.level&&!(Number.isInteger(D.level)&&D.level>=0&&D.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const e=mu?mu.level:0;u.level=void 0===D.level?e:D.level;})(D,u),D.template=(...u)=>Lu(D.template,...u),Object.setPrototypeOf(D,Ou.prototype),Object.setPrototypeOf(D.template,D),D.template.constructor=()=>{throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.")},D.template.Instance=Au,D.template};function Ou(u){return wu(u)}for(const[u,D]of Object.entries(eu))_u[u]={get(){const e=ku(this,Iu(D.open,D.close,this._styler),this._isEmpty);return Object.defineProperty(this,u,{value:e}),e}};_u.visible={get(){const u=ku(this,this._styler,!0);return Object.defineProperty(this,"visible",{value:u}),u}};const Mu=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(const u of Mu)_u[u]={get(){const{level:D}=this;return function(...e){const t=Iu(eu.color[vu[D]][u](...e),eu.color.close,this._styler);return ku(this,t,this._isEmpty)}}};for(const u of Mu){_u["bg"+u[0].toUpperCase()+u.slice(1)]={get(){const{level:D}=this;return function(...e){const t=Iu(eu.bgColor[vu[D]][u](...e),eu.bgColor.close,this._styler);return ku(this,t,this._isEmpty)}}};}const Su=Object.defineProperties(()=>{},{..._u,level:{enumerable:!0,get(){return this._generator.level},set(u){this._generator.level=u;}}}),Iu=(u,D,e)=>{let t,r;return void 0===e?(t=u,r=D):(t=e.openAll+u,r=D+e.closeAll),{open:u,close:D,openAll:t,closeAll:r,parent:e}},ku=(u,D,e)=>{const t=(...u)=>Ru(t,1===u.length?""+u[0]:u.join(" "));return Object.setPrototypeOf(t,Su),t._generator=u,t._styler=D,t._isEmpty=e,t},Ru=(u,D)=>{if(u.level<=0||!D)return u._isEmpty?"":D;let e=u._styler;if(void 0===e)return D;const{openAll:t,closeAll:r}=e;if(-1!==D.indexOf(""))for(;void 0!==e;)D=yu(D,e.close,e.open),e=e.parent;const n=D.indexOf("\n");return -1!==n&&(D=Bu(D,r,t,n)),t+D+r};let Tu;const Lu=(u,...D)=>{const[e]=D;if(!Array.isArray(e))return D.join(" ");const t=D.slice(1),r=[e.raw[0]];for(let u=1;u" "+u.replace(/^at +/,u=>D(u)).replace(/\((.+)\)/,(u,D)=>`(${e(D)})`)).join("\n")}formatType(u,D){const e=Nu[u.type]||qu[u.level]||this.options.secondaryColor;if(D)return function(u){let D=Pu[u];return D||(D="#"===u[0]?xu.bgHex(u):xu["bg"+u[0].toUpperCase()+u.slice(1)]||xu.bgKeyword(u),Pu[u]=D,D)}(e).black(` ${u.type.toUpperCase()} `);const t="string"==typeof Hu[u.type]?Hu[u.type]:u.icon||u.type;return t?ju(e)(t):""}formatLogObj(u,{width:D}){const[e,...t]=this.formatArgs(u.args).split("\n"),r=void 0!==u.badge?Boolean(u.badge):u.level<2,n=ju(this.options.secondaryColor),s=this.formatDate(u.date),o=s&&n(s),i=this.formatType(u,r),a=u.tag?n(u.tag):"",l=e.replace(/`([^`]+)`/g,(u,D)=>xu.cyan(D));let c;const h=this.filterAndJoin([i,l]),F=this.filterAndJoin([a,o]),C=D-$(h)-$(F)-2;return c=C>0&&D>=80?h+" ".repeat(C)+F:h,c+=t.length?"\n"+t.join("\n"):"",r?"\n"+c+"\n":c}}class Wu{constructor({stream:u}={}){this.stream=u||process.stdout;}log(u){this.stream.write(JSON.stringify(u)+"\n");}}const Gu="undefined"!=typeof __non_webpack_require__?__non_webpack_require__:commonjsRequire;class zu{constructor(u){if(u&&u.log)this.logger=u;else {const D=Gu("winston");this.logger=D.createLogger(Object.assign({level:"info",format:D.format.simple(),transports:[new D.transports.Console]},u));}}log(u){const D=[].concat(u.args),e=D.shift();this.logger.log({level:Qu[u.level]||"info",label:u.tag,message:e,args:D,timestamp:u.date.getTime()/1e3});}}const Qu={0:"error",1:"warn",2:"info",3:"verbose",4:"debug",5:"silly"};commonjsGlobal.consola||(commonjsGlobal.consola=function(){let u=p.debug?4:3;process.env.CONSOLA_LEVEL&&(u=parseInt(process.env.CONSOLA_LEVEL)||u);const D=new _({level:u,reporters:[p.ci||p.test?new S:new Vu]});return D.Consola=_,D.BasicReporter=S,D.FancyReporter=Vu,D.JSONReporter=Wu,D.WinstonReporter=zu,D.LogLevel=m,D}());var Ju=commonjsGlobal.consola;var consola=Ju; function detectNewline(string) { if (typeof string !== "string") { throw new TypeError("Expected a string"); } const newlines = string.match(/(?:\r?\n)/g) || []; if (newlines.length === 0) { return; } const crlf = newlines.filter((newline) => newline === "\r\n").length; const lf = newlines.length - crlf; return crlf > lf ? "\r\n" : "\n"; } class Log { constructor(title) { this.title = title; } start(message, opts) { const msg = this.message(message || "Starting...", { icon: opts?.icon || c$1.gray(fig.tick), title: opts?.title }); consola.log(msg); } wait(message) { const o = ora({ text: this.message(message || "Loading..."), color: "yellow" }).start(); return { ora: o, text: (message2, opts) => { o.text = this.message(message2, opts); }, persist: (message2, opts) => { let msg = message2 || ""; const hasNewLine = !!detectNewline(msg); if (hasNewLine) { msg = c$1.dim("...") + "\n" + msg; } o.stopAndPersist({ text: this.message(msg, opts), symbol: c$1.dim(opts?.icon || fig.info) }); o.start(); }, ok: (message2) => { let msg = message2 || ""; const hasNewLine = !!detectNewline(msg); if (hasNewLine) { msg = c$1.dim("...") + "\n" + msg; } o.succeed(this.message(msg || "Done!")); }, fail: (message2) => { let msg = message2 || ""; const hasNewLine = !!detectNewline(msg); if (hasNewLine) { msg = c$1.dim("...") + "\n" + msg; } o.fail(this.message(msg || "Failed!")); } }; } abort(message, opts) { const msg = this.message(message || "Aborted.", { icon: opts?.icon || c$1.yellow(fig.cross), title: opts?.title }); consola.log(msg); } ok(message, opts) { const msg = this.message(message || "Done!", { icon: opts?.icon || c$1.green(fig.tick), title: opts?.title }); consola.log(msg); } fail(message, opts) { const msg = this.message(message || "Failed!", { icon: opts?.icon || c$1.red(fig.cross), title: opts?.title }); consola.log(msg); } warn(message, opts) { const msg = this.message(message, { icon: opts?.icon || c$1.yellow(fig.warning), title: opts?.title }); consola.log(msg); } info(message, opts) { const msg = this.message(message, { icon: opts?.icon || c$1.blue(fig.info), title: opts?.title }); consola.log(msg); } notify(subtitle, message) { const icon = require$$1.join(__dirname, "vrt-icon.png"); notifier.notify({ title: `Vortex CLI`, subtitle, message, icon, contentImage: icon, sound: "Ping", wait: true }); } message(message, opts) { const parts = []; if (opts?.icon) { parts.push(opts?.icon); } if (opts?.title !== null) { parts.push(c$1.dim.bold(opts?.title || this.title)); } if (opts?.title !== null && message) { parts.push(c$1.dim(fig.pointerSmall)); } if (message) { parts.push(message); } return parts.join(" "); } } const packageManagerLocks = { yarn: "yarn.lock", npm: "package-lock.json", pnpm: "pnpm-lock.yaml" }; function getPackageManager(rootDir) { return findup(rootDir, (dir) => { for (const name in packageManagerLocks) { if (require$$2.existsSync(pathe.resolve(dir, packageManagerLocks[name]))) { return name; } } }); } function getPackageManagerVersion(name) { return child_process.execSync(`${name} --version`).toString("utf8").trim(); } const log$e = new Log("Clean"); const cleanCommand = { command: "clean", describe: c$1.dim("Recursively delete all node_modules and build folder.."), builder: (yargs) => yargs.options({}).example([]), handler: async () => { const { name } = yaml.load( fsExtra.readFileSync("vortex.yaml", "utf-8") ); const answers = await prompts([ { type: "confirm", name: "isConfirmed", message: "This will recursively delete all node_modules and build folder. Are you sure?", initial: false } ]); if (answers.isConfirmed) { const loader = log$e.wait(`Cleaning up ${name}...`); try { await execa.command( "find . -name node_modules -type d -prune -exec rm -rf {} +" ); loader.persist(`Yes, ${c$1.bold("node_modules")} deleted.`); await execa.command( "find . -name dist -type d -prune -exec rm -rf {} +" ); loader.persist(`Yes, ${c$1.bold("dist")} deleted.`); await execa.command( "find . -name build -type d -prune -exec rm -rf {} +" ); loader.persist(`Yes, ${c$1.bold("build")} deleted.`); loader.ok(); } catch (error) { loader.fail(error?.message || "Failed to clean."); } } else { log$e.abort(); } } }; const log$d = new Log("Info"); const infoCommand = { command: "info", describe: c$1.dim("Info."), builder: (yargs) => yargs.options({}).example([]), handler: (args) => { try { const rootDir = pathe.resolve(args._[0] || "."); const { name, description, version, build } = findManifest( rootDir ); findPackage(rootDir); let packageManager = getPackageManager(rootDir); if (packageManager) { packageManager += "@" + getPackageManagerVersion(packageManager); } else { packageManager = "unknown"; } log$d.ok(c$1.bold.green("Vortex CLI"), { title: null }); log$d.info(c$1.dim(rootDir), { title: "Directory" }); console.log(""); const table = new Table({ chars: { top: "", "top-mid": "", "top-left": "", "top-right": "", bottom: "", "bottom-mid": "", "bottom-left": "", "bottom-right": "", left: "", "left-mid": "", mid: "", "mid-mid": "", right: "", "right-mid": "", middle: " " }, style: { "padding-left": 0, "padding-right": 0, compact: true } }); table.push([c$1.bold("System")]); table.push(line("Operating system ", require$$3.type())); table.push(line("Node version", process.version)); table.push(line("Package manager", packageManager)); table.push([""]); table.push([c$1.bold("Project")]); table.push(line("Name", name)); table.push(line("Description", description)); table.push(line("Version", version)); table.push(line("Build", build)); console.log(table.toString()); console.log( "\nFor more information, check ", c$1.underline.red("https://cli.vortex.so"), "\n" ); } catch (error) { log$d.fail(error?.message); } } }; function findManifest(rootDir) { return findup(rootDir, (dir) => { const p = pathe.resolve(dir, "vortex.yaml"); if (fsExtra.existsSync(p)) { return yaml.load(fsExtra.readFileSync(p, "utf-8")); } }) || {}; } function findPackage(rootDir) { return findup(rootDir, (dir) => { const p = pathe.resolve(dir, "package.json"); if (fsExtra.existsSync(p)) { return fsExtra.readJSONSync(p); } }) || {}; } function line(key, value) { return [c$1.dim(key), c$1.dim(":"), value]; } function getManifest(file) { const manifest = yaml.load(fsExtra.readFileSync(file, "utf-8")); return manifest; } function isManifest(obj) { return obj && typeof obj === "object" && isOptionalString(obj.name) && isOptionalString(obj.version) && isOptionalString(obj.description); } function isOptionalString(value) { const type = typeof value; return value === null || type === "undefined" || type === "string"; } async function getInput(operation) { const { name, namespace, handle, kind, type, description, version, build } = getManifest("vortex.yaml"); if (!name) throw new Error("Missing name."); if (!namespace) throw new Error("Missing namespace."); if (!handle) throw new Error("Missing handle."); if (!description) throw new Error("Missing description."); if (!version) throw new Error("Missing version."); if (build === void 0) throw new Error("Missing build."); if (!semver.valid(version)) { throw new Error("Version is invalid."); } if (typeof build != "number") { throw new Error("Build is invalid."); } return operation.update({ name, namespace, handle, description, kind, type, version, oldVersionSource: "vortex.yaml", oldVersion: version, oldBuild: build }); } const COMPONENT_TYPES = { enums: ["fe", "be", "me", "pkg", "db", "ui"], choices: [ { label: "Back-end", value: "be" }, { label: "Front-end", value: "fe" }, { label: "Mobile", value: "me" }, { label: "Interface", value: "ui" }, { label: "Package", value: "pkg" }, { label: "Database", value: "db" } ] }; const log$c = new Log("Ship"); async function gitAdd() { try { await execa.command("git add .", { stdio: "inherit" }); } catch (error) { throw Error(`Failed to add files to Git. ${error?.message}`); } } async function gitCommit(operation) { const answers = await prompts([ { type: "confirm", name: "isConfirmed", message: "Are you sure you want to commit new version?", initial: false } ]); if (!answers.isConfirmed) throw Error(`Cancelled.`); const { handle, oldVersion, oldBuild } = operation.state; const version = `${oldVersion}-${oldBuild}`; try { await execa( "git", [ "commit", "-m", `chore(${handle}): evolved to version ${version}`, "--no-verify" ], { stdio: "inherit" } ); } catch (error) { throw Error(`Failed to commit to Git. ${error?.message}`); } } async function gitTag(operation) { const answers = await prompts([ { type: "confirm", name: "isConfirmed", message: "Are you sure you want to tag new version?", initial: false } ]); if (!answers.isConfirmed) throw Error(`Cancelled.`); const { name, type, handle, oldVersion, oldBuild } = operation.state; const version = `${oldVersion}-${oldBuild}`; const componentTypes = COMPONENT_TYPES.enums.filter((t) => { return type?.includes(t); }); const componenTypeStrings = componentTypes.join(",").toLowerCase(); try { await execa( "git", [ "tag", "-a", `${handle}@${oldVersion}`, "-m", `${name} ${componenTypeStrings} component, version ${version}` ], { stdio: "inherit" } ); log$c.ok(`${name} tagged with ${c$1.bold(`${handle}@${oldVersion}`)}.`); } catch (error) { throw Error(`Failed to tag to Git. ${error?.message}`); } } class Operation { constructor(options) { this.state = { name: "", namespace: "", handle: "", description: "", kind: void 0, type: void 0, release: void 0, oldVersionSource: "", oldVersion: "", oldBuild: void 0, newVersion: "", newBuild: void 0, commitMessage: "", tagName: "", updatedFiles: [], skippedFiles: [] }; this.options = options; } get results() { const options = this.options; const state = this.state; return { name: state.name, namespace: state.namespace, handle: state.handle, description: state.description, release: state.release, oldVersion: state.oldVersion, newVersion: state.newVersion, oldBuild: state.oldBuild, newBuild: state.newBuild, commit: options.commit ? state.commitMessage : false, tag: options.tag ? state.tagName : false, updatedFiles: state.updatedFiles.slice(), skippedFiles: state.skippedFiles.slice() }; } static async start(options) { return new Operation(options); } update(newState) { Object.assign(this.state, newState); return this; } } const log$b = new Log("Ship"); async function commit() { const operation = await Operation.start({ release: { type: "prompt", preid: "beta" }, push: false, files: ["vortex.yaml"], cwd: process.cwd(), ignoreScripts: false, interface: { input: process.stdin, output: process.stdout } }); try { await getInput(operation); await gitAdd(); await gitCommit(operation); log$b.ok("All done!"); } catch (error) { log$b.fail(error?.message || "Something is failed."); } } const log$a = new Log("Ship"); async function commitTag() { const operation = await Operation.start({ release: { type: "prompt", preid: "beta" }, push: false, files: ["vortex.yaml"], cwd: process.cwd(), ignoreScripts: false, interface: { input: process.stdin, output: process.stdout } }); try { await getInput(operation); await gitAdd(); await gitCommit(operation); await gitTag(operation); log$a.ok("All done!"); } catch (error) { log$a.fail(error?.message || "Something is failed."); } } const log$9 = new Log("Ship"); async function publish() { let operation = await Operation.start({ release: { type: "prompt", preid: "beta" }, push: false, files: ["vortex.yaml"], cwd: process.cwd(), ignoreScripts: false, interface: { input: process.stdin, output: process.stdout } }); operation = await getInput(operation); const { name, type, version } = operation.state; if (!type?.includes("pkg")) { throw Error("This component is not package, can't publish it."); } const answers = await prompts([ { type: "confirm", name: "isConfirmed", message: `Are you sure you want to publish ${c$1.bold.green(name)}?`, initial: false } ]); if (!answers.isConfirmed) throw Error(`Cancelled.`); const loader = log$9.wait(); try { if (!version) throw new Error("Missing version."); if (!semver.valid(version)) { throw new Error("Version is invalid."); } loader.text(`Building ${c$1.bold.green(name)} v${version}...`); const { stdout: r1 } = await execa("yarn", ["build"]); if (r1) loader.persist(c$1.gray(r1)); const command = ["yarn", "npm", "publish"]; const isBeta = version.includes("beta"); if (isBeta) command.push("--tag", "beta"); loader.text(`Publishing ${c$1.bold.green(name)} v${version} to NPM...`); const { stdout: r2 } = await execa.command(command.join(" ")); if (r2) loader.persist(c$1.gray(r2)); loader.ok(`${c$1.bold.green(name)} v${version} has been published to NPM!`); } catch (error) { loader.fail(c$1.gray(error?.message || "Something is failed.")); } } const log$8 = new Log("Ship"); async function tag() { const operation = await Operation.start({ release: { type: "prompt", preid: "beta" }, push: false, files: ["vortex.yaml"], cwd: process.cwd(), ignoreScripts: false, interface: { input: process.stdin, output: process.stdout } }); try { await getInput(operation); await gitTag(operation); log$8.ok("All done!"); } catch (error) { log$8.fail(error?.message || "Something is failed."); } } const prereleaseTypes = [ "premajor", "preminor", "prepatch", "prerelease" ]; const releaseTypes = prereleaseTypes.concat([ "major", "minor", "patch" ]); function isPrerelease(value) { return prereleaseTypes.includes(value); } const log$7 = new Log("Ship"); async function getOutput(operation) { const { release } = operation.options; const { name, oldVersion, oldBuild } = operation.state; log$7.info(`Evolving ${c$1.bold.green(name)} version...`); operation.update({ newBuild: oldBuild || 0 + 1 }); switch (release.type) { case "prompt": return promptForNewVersion(operation); case "version": const newSemVer = new semver.SemVer(release.version, true); return operation.update({ newVersion: newSemVer.version }); default: return operation.update({ release: release.type, newVersion: getNextVersion(oldVersion, release) }); } } function getNextVersion(oldVersion, release) { const oldSemVer = new semver.SemVer(oldVersion); const newSemVer = oldSemVer.inc(release.type, release.preid); if (isPrerelease(release.type) && newSemVer.prerelease.length === 2 && newSemVer.prerelease[0] === release.preid && String(newSemVer.prerelease[1]) === "0") { newSemVer.prerelease[1] = "1"; newSemVer.format(); } return newSemVer.version; } function getNextVersions(oldVersion, preid) { const next = {}; for (const type of releaseTypes) { next[type] = getNextVersion(oldVersion, { type, preid }); } return next; } async function promptForNewVersion(operation) { const { oldVersion, oldBuild } = operation.state; const release = operation.options.release; const next = getNextVersions(oldVersion, release.preid); let isCancelled = false; const answers = await prompts( [ { type: "autocomplete", name: "release", message: `Current version: ${c$1.bold.dim(oldVersion)}`, initial: "patch", choices: [ { value: "major", title: "major - " + c$1.bold.red(next.major) }, { value: "minor", title: "minor - " + c$1.bold.yellow(next.minor) }, { value: "patch", title: "patch - " + c$1.bold.yellow(next.patch) }, { value: "premajor", title: "pre-release major - " + c$1.bold.green(next.premajor) }, { value: "preminor", title: "pre-release minor - " + c$1.bold.green(next.preminor) }, { value: "prepatch", title: "pre-release patch - " + c$1.bold.green(next.prepatch) }, { value: "prerelease", title: "pre-release - " + c$1.bold.green(next.prerelease) }, { value: "none", title: "leave as-is - " + c$1.bold.dim(oldVersion) }, { value: "custom", title: "custom..." } ] }, { type: (prev) => prev === "custom" ? "text" : null, name: "custom", message: "Enter the new version number:", initial: oldVersion, validate: (custom) => { if (!semver.valid(custom)) return "That's not a valid version number!"; if (semver.lt(custom, oldVersion)) return "You can't downgrade. Please, grow up."; else return true; } } ], { onCancel() { readline.moveCursor(process.stdout, 0, -2); readline.clearLine(process.stdout, 0); readline.clearLine(process.stdout, 0); isCancelled = true; } } ); if (isCancelled) throw Error("Cancelled!"); const newVersion = answers.release === "none" ? oldVersion : answers.release === "custom" ? semver.clean(answers.custom) : next[answers.release]; if (!newVersion) { throw Error("Cancelled, can't get new version."); } if (newVersion === oldVersion) { throw Error("Cancelled, version stays the same."); } const newBuild = oldBuild ? oldBuild + 1 : 1; switch (answers.release) { case "none": return operation.update({ newVersion }); case "custom": return operation.update({ newVersion, newBuild }); default: return operation.update({ release: answers.release, newVersion, newBuild }); } } const log$6 = new Log("Ship"); async function updateFiles(operation) { const { name, newVersion, oldBuild, newBuild } = operation.state; const manifestFiles = ["vortex.yaml", "package.json"]; for (const filePath of manifestFiles) { await updateManifestFile(filePath, operation); } if (operation.state.type?.includes("me")) { await updateMobileFiles(operation); } log$6.ok( `${c$1.bold.green(name)} has been evolved to version ${c$1.bold( newVersion )}.` ); log$6.ok( `${c$1.bold.green(name)} build number has been evolved from ${c$1.bold( oldBuild )} to ${c$1.bold(newBuild)}.` ); return operation; } async function updateManifestFile(filePath, operation) { const { name, description, newVersion, newBuild } = operation.state; let isModified = false; let file = void 0; if (filePath.includes("yaml")) { file = yaml.load(fsExtra.readFileSync(filePath, "utf-8")); } else if (filePath.includes("json")) { file = await fsExtra.readJson(filePath, { encoding: "utf-8" }); } else { return false; } if (isManifest(file)) { file.name = name; file.description = description; file.version = newVersion; file.build = newBuild; if (filePath.includes("yaml")) { const yamlData = yaml.dump(file); await fsExtra.writeFile(filePath, yamlData, { encoding: "utf-8" }); } else if (filePath.includes("json")) { const loader = log$6.wait("Sorting package.json data..."); const sortedJson = sortPackageJson(file); loader.ok("Sorted package.json."); await fsExtra.writeJson(filePath, sortedJson, { spaces: 2 }); } isModified = true; } return isModified; } async function updateMobileFiles(operation) { const { newVersion, oldBuild, newBuild } = operation.state; const { ios, android } = getManifest("vortex.yaml"); let isModified = false; const rootDir = process.cwd(); const iosDir = require$$1.resolve(rootDir, ios?.path || "ios"); const androidDir = require$$1.resolve(rootDir, android?.path || "android"); const config = { ios: { path: ios?.path || "ios" }, android: { path: android?.path || "android" } }; const project$1 = new project.MobileProject(rootDir, config); await project$1.load(); try { const appTarget = project$1.ios?.getAppTarget(); if (!appTarget) { throw new Error(`Couldn't find iOS App target in ${iosDir}`); } if (!appTarget.buildConfigurations) { throw new Error( `Couldn't find iOS App target build configurations in ${iosDir}` ); } const _newBuild = newBuild ?? 1; for (const build of appTarget.buildConfigurations) { await project$1.ios?.setVersion(appTarget.name, build.name, newVersion); await project$1.ios?.setBuild(appTarget.name, build.name, _newBuild); } log$6.ok( `Updated iOS build from ${c$1.bold(oldBuild)} to ${c$1.bold( _newBuild )}.` ); log$6.ok(`Updated iOS version to ${c$1.bold(newVersion)}.`); const androidVersionCode = await project$1.android?.getVersionCode(); if (!androidVersionCode) { throw new Error(`Couldn't find Android app in ${androidDir}`); } await project$1.android?.setVersionName(newVersion); log$6.ok(`Updated Android version to ${c$1.bold(newVersion)}`); await project$1.android?.setVersionCode(_newBuild); log$6.ok( `Updated Android version code from ${c$1.bold( oldBuild )} to ${c$1.bold(_newBuild)}.` ); await project$1.commit(); isModified = true; return isModified; } catch (error) { log$6.warn("Canceled, app update failed."); log$6.fail(error); return isModified; } } const log$5 = new Log("Ship"); async function version() { const operation = await Operation.start({ release: { type: "prompt", preid: "beta" }, push: false, files: ["vortex.yaml"], cwd: process.cwd(), ignoreScripts: false, interface: { input: process.stdin, output: process.stdout } }); try { await getInput(operation); await getOutput(operation); await updateFiles(operation); log$5.ok("All done!"); } catch (error) { log$5.fail(error?.message || "Something is failed."); } } const manifestSchema = zod.z.object({ name: zod.z.string({ required_error: "Name is required." }), namespace: zod.z.string({ required_error: "Namespace is required." }), org: zod.z.string({ required_error: "Organization is required." }), handle: zod.z.string({ required_error: "Component is required." }), kind: zod.z.enum(["component", "repository"]), type: zod.z.array(zod.z.enum(["fe", "be", "me", "pkg", "db", "ui"])).optional(), description: zod.z.string(), version: zod.z.string(), build: zod.z.number(), repo: zod.z.object({ name: zod.z.string(), url: zod.z.string(), host: zod.z.string() }) }).refine((data) => data.kind === "component" ? !!data.type : true, { message: "Component type is required.", path: ["type"] }); const log$4 = new Log("Vault"); async function getEnv(env) { const loader = log$4.wait(); try { const { name, handle, org } = getManifest("vortex.yaml"); if (!handle) throw new Error("Missing handle."); if (!org) throw new Error("Missing org."); loader.persist( `Getting secrets for ${c$1.bold.green(env)} environment of ${c$1.bold.green( name )}...` ); const getValues = await execa.command( `vault kv get -format=json vars/${org}/${handle}/${env}`, { shell: true, env: { VAULT_ADDR: "https://vault.vortex.so" } } ); if (getValues.stderr) loader.persist(c$1.gray(getValues.stderr)); const resp = JSON.parse(getValues.stdout); const secrets = resp?.data?.data; if (!secrets) throw new Error("No secrets found."); const variables = Object.keys(secrets).map((key) => `${key}="${secrets[key]}"`).join("\n"); const saveValues = await execa.command( `echo '${variables}' > .env.${env}`, { shell: true } ); if (saveValues.stderr) loader.persist(c$1.gray(saveValues.stderr)); const file = c$1.bold.green(`.env.${env}`); loader.ok(`Secrets have been generated into ${file}!`); } catch (error) { loader.fail(c$1.gray(error?.message || "Something is failed.")); } } const CONTEXTS = { vrt: { name: "Vortex", namespace: "@vortex.so", repo: { namespace: "with-vortex", host: "gitlab.com" } }, neo: { name: "Neon", namespace: "@neon.id", repo: { namespace: "neon.id", host: "gitlab.com" } }, neu: { name: "Neutron", namespace: "@neutron.co.id", repo: { namespace: "neutron-yogyakarta", host: "gitlab.com" } } }; const log$3 = new Log("Init"); const initComand = { command: "init", describe: c$1.dim("Initialize workspace."), builder: (yargs) => yargs.options({}).example([]), handler: async () => { let manifest = void 0; try { manifest = yaml.load( fsExtra.readFileSync("vortex.yaml", "utf-8") ); log$3.info( "There is existing Vortex manifest file, using it as initial values." ); prompts.override(manifest); } catch (error) { log$3.warn(`There isn't any Vortex manifest file, let's create one.`); } await new Promise((resolve) => setTimeout(resolve, 300)); const answers = await prompts([ { type: "select", name: "kind", message: "What do you want to initialize?", choices: [ { title: "Component", value: "component" }, { title: "Repository", value: "repository" } ], initial: 0 }, { type: "select", name: "context", message: "Choose context of the project.", choices: [ { title: "Vortex", value: "vrt" }, { title: "Neon", value: "neo" }, { title: "Neutron", value: "neu" } ] }, { type: "text", name: "handle", message: `What's the project handle?`, validate: (v) => { if (!v) return "Project handle is required."; if (v !== v.toLowerCase()) return "Project handle must be in lowercase."; else return true; } }, { type: "text", name: "description", message: `Describe the project.` }, { type: (_, answers2) => { if (answers2.kind === "component") return "multiselect"; else return null; }, name: "type", message: "What type of component is this?", choices: [ { title: "Back-end", value: "be" }, { title: "Front-end", value: "fe" }, { title: "Mobile", value: "me" }, { title: "Package", value: "pkg" }, { title: "Interface", value: "ui" } ], max: 2, hint: "- Space to select. Return to submit" } ]); if (answers.kind === "component" && typeof answers.type === "string") { answers.type = [answers.type]; } try { const context = CONTEXTS[answers.context]; manifest = manifestSchema.parse({ name: `${context.namespace}/${answers.handle}`, org: answers.context, namespace: context.namespace, handle: answers.handle, kind: answers.kind, type: answers.type, description: answers.description, version: manifest?.version || "0.1.0", build: manifest?.build || 0, repo: manifest?.repo || { name: `${context.repo.namespace}/__repo___`, url: `gitlab.com/${context.repo.namespace}/__repo___`, host: context.repo.host } }); const yamlData = yaml.dump(manifest); await fsExtra.writeFile("vortex.yaml", yamlData, { encoding: "utf-8" }); log$3.ok(`${c$1.bold("vortex.yaml")} has been updated.`); } catch (error) { const fmt = error?.flatten(); for (const key in fmt?.fieldErrors) { const messages = fmt.fieldErrors[key]; for (const msg of messages) { log$3.fail(msg, { title: lodash.upperFirst(key) }); } } log$3.abort(); return; } const loader = log$3.wait("Starting..."); try { const { stdout: version } = await execa.command("yarn -v"); loader.persist(`Yarn is on version ${c$1.green.bold(version)}`); if (semver.major(version) === 1) { loader.text("Upgrading to Yarn Berry..."); await execa.command("yarn set version stable"); await execa.command("yarn set version latest"); } loader.text("Importing Yarn plugins..."); await execa.command("yarn plugin import interactive-tools"); await execa.command("yarn plugin import typescript"); await execa.command("yarn plugin import workspace-tools"); loader.ok("Workspace initialized!"); } catch (error) { log$3.abort(); } } }; const log$2 = new Log("Ping"); const pingCommand = { command: "ping", describe: c$1.dim("Ping."), builder: (yargs) => yargs.options({}).example([]), handler: () => { try { log$2.ok("Pong!"); } catch (error) { log$2.fail(error?.message); } } }; const log$1 = new Log("Ship"); const shipCommand = { command: "ship [command]", describe: c$1.dim("Ship 'em up!"), builder: { command: { alias: "c", type: "string", describe: "Command to execute.", choices: [ "version", "version:commit-tag", "version:commit", "version:tag", "publish" ] } }, handler: async (args) => { prompts.override({ command: args.command }); try { const answers = await prompts([ { type: "select", name: "command", message: "What kind of shipment do you want to do?", choices: [ { title: "Version", value: "version", description: "Bump project version." }, { title: "Commit and tag version", value: "version:commit-tag", description: "Commit and tag project version" }, { title: "Commit version", value: "version:commit", description: "Commit project version." }, { title: "Tag version", value: "version:tag", description: "Tag project version." }, { title: "Publish", value: "publish", description: "Publish package to NPM." } ] } ]); switch (answers.command) { case "version": await version(); break; case "version:commit-tag": await commitTag(); break; case "version:commit": await commit(); break; case "version:tag": await tag(); break; case "publish": await publish(); break; default: log$1.abort("Not shipping anything."); break; } } catch (error) { log$1.fail(error?.message); } } }; const log = new Log("Vault"); const vaultCommand = { command: "vault [env]", describe: c$1.dim("Get your secrets!"), builder: { env: { type: "string", describe: "Command to execute.", choices: ["local", "dev", "prod"] } }, handler: async (args) => { prompts.override({ env: args.env }); try { const answers = await prompts([ { type: "select", name: "env", message: "What environment do you need the secrets for?", choices: [ { title: "local", value: "local", description: "Local environment." }, { title: "dev", value: "dev", description: "Development environment." }, { title: "prod", value: "prod", description: "Production environment." } ] } ]); if (answers.env) { await getEnv(answers.env); } else { log.abort(); } } catch (error) { log.fail(error?.message); } } }; async function main() { try { const cli = yargs(helpers.hideBin(process.argv)).scriptName(c$1.bold("vortex")).command( "$0", c$1.dim("Vortex CLI usage."), () => void 0, () => { yargs.showHelp(); } ).command(pingCommand).command(infoCommand).command(initComand).command(cleanCommand).command(shipCommand).command(vaultCommand).completion("completion", c$1.dim("Generate completion script.")).strict().alias({ h: "help" }).alias({ v: "version" }).epilogue( `For more information, check ${c$1.underline.bold.red( "https://cli.vortex.so" )}.` ); cli.argv; } catch (error) { throw error; } } main().catch((err) => { console.error(err); process.exit(1); });