UNPKG

@ks-opdev/cli

Version:

ksodev: A CLI based on the WPS Open Platform

1 lines â€ĸ 7.93 kB
function a3_0x574b(){const _0xfd812d=['fetching\x20packages...','data','\x20You\x20are\x20already\x20using\x20the\x20latest\x20version!','greenBright','start','stderr','trim','resolving','\x20Update\x20available.\x20Use\x20\x27update\x27\x20command\x20to\x20install.','6yNEufZ','fetching','đŸ“Ļ\x20Updating\x20CLI','Do\x20you\x20want\x20to\x20update\x20from\x20','shouldUpdate','config','resolving\x20dependencies...','316680QQydCC','checkVersion','16535761lSTacu','executeNpmUpdate','234020NNWAqN','green','88565owmLfQ','318vGrnSY','split','\x20Updated\x20from\x20','currentVersion','Update\x20Available','updating...','<%=\x20config.bin\x20%>\x20<%=\x20command.id\x20%>\x20--check-only','log','building\x20dependencies...','action','stdout','yellow','345471NvBBVd','toString','check-only','boolean','run','4657540QCrdof','parse','\x20Version\x20Information','status','installing','error','Current:','includes','extractProgressFromNpmOutput','hasUpdate','displayVersionInfo','downloading\x20packages...','❌\x20Update\x20failed','Failed\x20to\x20check\x20for\x20updates:\x20','confirm','\x20to\x20','✅\x20Check\x20completed','pipe','performUpdate','2963988lQwPyv','9dscvvx','stop','✅\x20Update\x20completed','repeat','close','colorize','blue','Status:\x20','Process\x20exited\x20with\x20code\x20','prompt','latestVersion','Up\x20to\x20Date','examples','72dKdkml','confirmUpdate'];a3_0x574b=function(){return _0xfd812d;};return a3_0x574b();}const a3_0x5484c6=a3_0x2247;(function(_0x1a26be,_0x345aeb){const _0x5b2c73=a3_0x2247,_0x5d2e80=_0x1a26be();while(!![]){try{const _0xe1b6a9=-parseInt(_0x5b2c73(0x1af))/0x1*(-parseInt(_0x5b2c73(0x1a8))/0x2)+-parseInt(_0x5b2c73(0x18f))/0x3+parseInt(_0x5b2c73(0x1b3))/0x4+parseInt(_0x5b2c73(0x1b5))/0x5*(-parseInt(_0x5b2c73(0x1b6))/0x6)+-parseInt(_0x5b2c73(0x1c2))/0x7*(parseInt(_0x5b2c73(0x19d))/0x8)+-parseInt(_0x5b2c73(0x190))/0x9*(-parseInt(_0x5b2c73(0x1c7))/0xa)+parseInt(_0x5b2c73(0x1b1))/0xb;if(_0xe1b6a9===_0x345aeb)break;else _0x5d2e80['push'](_0x5d2e80['shift']());}catch(_0x80249){_0x5d2e80['push'](_0x5d2e80['shift']());}}}(a3_0x574b,0x9417c));import{Flags,ux}from'@oclif/core';import a3_0x320f83 from'chalk';import a3_0x5c2552 from'inquirer';function a3_0x2247(_0x3d0dfd,_0x356722){const _0x574b09=a3_0x574b();return a3_0x2247=function(_0x224726,_0x33525f){_0x224726=_0x224726-0x18d;let _0x23dd05=_0x574b09[_0x224726];return _0x23dd05;},a3_0x2247(_0x3d0dfd,_0x356722);}import{spawn}from'node:child_process';import a3_0x1d2728 from'../lib/extends/command.js';import{checkForUpdates,getInstallCommand}from'../lib/utils/update.js';export default class Update extends a3_0x1d2728{static ['description']='Check\x20for\x20updates\x20and\x20update\x20the\x20CLI\x20to\x20the\x20latest\x20version';static [a3_0x5484c6(0x19c)]=['<%=\x20config.bin\x20%>\x20<%=\x20command.id\x20%>','<%=\x20config.bin\x20%>\x20<%=\x20command.id\x20%>\x20--force',a3_0x5484c6(0x1bc)];static ['flags']={'force':Flags[a3_0x5484c6(0x1c5)]({'char':'f','description':'Force\x20update\x20without\x20confirmation','default':![]}),'check-only':Flags[a3_0x5484c6(0x1c5)]({'char':'c','description':'Only\x20check\x20for\x20updates\x20without\x20installing','default':![]})};async[a3_0x5484c6(0x1c6)](){const _0x3e03d8=a3_0x5484c6,{flags:_0x43df28}=await this[_0x3e03d8(0x1c8)](Update);try{ux[_0x3e03d8(0x1bf)][_0x3e03d8(0x1a3)]('🔍\x20Checking\x20for\x20updates');const _0x2b57ae=this[_0x3e03d8(0x1ad)]['version'],_0x197654=await this['checkVersion'](_0x2b57ae);ux[_0x3e03d8(0x1bf)]['stop'](_0x3e03d8(0x1d7)),await this[_0x3e03d8(0x1d1)](_0x197654);if(!_0x197654[_0x3e03d8(0x1d0)]){this['log'](this[_0x3e03d8(0x195)]('✅',_0x3e03d8(0x1b4))+_0x3e03d8(0x1a1));return;}if(_0x43df28[_0x3e03d8(0x1c4)]){this[_0x3e03d8(0x1bd)](this[_0x3e03d8(0x195)]('â„šī¸',_0x3e03d8(0x196))+_0x3e03d8(0x1a7));return;}await this[_0x3e03d8(0x18e)](_0x197654,_0x43df28['force']);}catch(_0x1c502c){this[_0x3e03d8(0x1cc)]('Update\x20check\x20failed:\x20'+_0x1c502c);}}async[a3_0x5484c6(0x1b0)](_0x1d6295){const _0x2a2f39=a3_0x5484c6;try{return await checkForUpdates(_0x1d6295);}catch(_0x1be688){throw new Error(_0x2a2f39(0x1d4)+_0x1be688);}}async['displayVersionInfo'](_0x1201ec){const _0x57595e=a3_0x5484c6,_0x429c72='─'[_0x57595e(0x193)](0x32);this[_0x57595e(0x1bd)](''),this[_0x57595e(0x1bd)](this['colorize']('📋',_0x57595e(0x196))+_0x57595e(0x1c9)),this['log'](_0x429c72),this['log'](this[_0x57595e(0x195)](_0x57595e(0x1cd),_0x57595e(0x1c1))+'\x20\x20'+this['colorize'](_0x1201ec[_0x57595e(0x1b9)],'yellow')),this[_0x57595e(0x1bd)](this[_0x57595e(0x195)]('Latest:\x20','green')+'\x20\x20'+this[_0x57595e(0x195)](_0x1201ec[_0x57595e(0x19a)],'green')),this[_0x57595e(0x1bd)](this[_0x57595e(0x195)](_0x57595e(0x197),_0x57595e(0x196))+'\x20\x20'+(_0x1201ec['hasUpdate']?this[_0x57595e(0x195)](_0x57595e(0x1ba),_0x57595e(0x1c1)):this['colorize'](_0x57595e(0x19b),'green'))),this[_0x57595e(0x1bd)](_0x429c72),this[_0x57595e(0x1bd)]('');}async[a3_0x5484c6(0x18e)](_0x3edc1e,_0x207735){const _0x64b1a2=a3_0x5484c6;if(!_0x207735){const _0x21ff80=await this[_0x64b1a2(0x19e)](_0x3edc1e);if(!_0x21ff80){this[_0x64b1a2(0x1bd)](this[_0x64b1a2(0x195)]('â„šī¸',_0x64b1a2(0x196))+'\x20Update\x20cancelled\x20by\x20user');return;}}ux[_0x64b1a2(0x1bf)][_0x64b1a2(0x1a3)](_0x64b1a2(0x1aa));try{await this[_0x64b1a2(0x1b2)](),ux[_0x64b1a2(0x1bf)][_0x64b1a2(0x191)](_0x64b1a2(0x192)),this[_0x64b1a2(0x1bd)](''),this[_0x64b1a2(0x1bd)](this[_0x64b1a2(0x195)]('🎉',_0x64b1a2(0x1b4))+'\x20CLI\x20updated\x20successfully!'),this['log'](this[_0x64b1a2(0x195)]('📝','blue')+_0x64b1a2(0x1b8)+this[_0x64b1a2(0x195)](_0x3edc1e['currentVersion'],_0x64b1a2(0x1c1))+_0x64b1a2(0x1d6)+this[_0x64b1a2(0x195)](_0x3edc1e[_0x64b1a2(0x19a)],_0x64b1a2(0x1b4))),this[_0x64b1a2(0x1bd)](this[_0x64b1a2(0x195)]('💡',_0x64b1a2(0x196))+'\x20Restart\x20your\x20terminal\x20or\x20run\x20a\x20new\x20command\x20to\x20use\x20the\x20updated\x20version');}catch(_0x29eb9a){ux[_0x64b1a2(0x1bf)][_0x64b1a2(0x191)](_0x64b1a2(0x1d3));throw new Error('Update\x20installation\x20failed:\x20'+_0x29eb9a);}}async['confirmUpdate'](_0x2cf357){const _0x23a2ab=a3_0x5484c6,_0x1c4a32=_0x23a2ab(0x1ab)+a3_0x320f83['yellowBright'](_0x2cf357['currentVersion'])+_0x23a2ab(0x1d6)+a3_0x320f83[_0x23a2ab(0x1a2)](_0x2cf357[_0x23a2ab(0x19a)])+'?',{shouldUpdate:_0x4424ad}=await a3_0x5c2552[_0x23a2ab(0x199)]([{'type':_0x23a2ab(0x1d5),'name':_0x23a2ab(0x1ac),'message':this[_0x23a2ab(0x195)]('❓',_0x23a2ab(0x196))+'\x20'+_0x1c4a32,'default':!![]}]);return _0x4424ad;}async['executeNpmUpdate'](){return new Promise((_0x1add06,_0x46b835)=>{const _0x2d62fe=a3_0x2247,_0x39eaeb=getInstallCommand(),[_0x30f8c7,..._0xfa417b]=_0x39eaeb[_0x2d62fe(0x1b7)]('\x20'),_0x2f3586=spawn(_0x30f8c7,_0xfa417b,{'stdio':_0x2d62fe(0x18d),'shell':!![]});let _0x483962='',_0x35d32e='';_0x2f3586[_0x2d62fe(0x1c0)]?.['on']('data',_0x44fa41=>{const _0x35b1fe=_0x2d62fe;_0x483962+=_0x44fa41[_0x35b1fe(0x1c3)]();const _0x2f7412=_0x44fa41[_0x35b1fe(0x1c3)]()[_0x35b1fe(0x1a5)]();_0x2f7412&&(ux[_0x35b1fe(0x1bf)][_0x35b1fe(0x1ca)]=this['extractProgressFromNpmOutput'](_0x2f7412));}),_0x2f3586[_0x2d62fe(0x1a4)]?.['on'](_0x2d62fe(0x1a0),_0x265134=>{const _0x5a745d=_0x2d62fe;_0x35d32e+=_0x265134[_0x5a745d(0x1c3)]();}),_0x2f3586['on'](_0x2d62fe(0x194),_0x38c4e5=>{const _0x388678=_0x2d62fe;if(_0x38c4e5===0x0)_0x1add06();else{const _0x5357fe=_0x35d32e||_0x483962||_0x388678(0x198)+_0x38c4e5;_0x46b835(new Error(_0x5357fe));}}),_0x2f3586['on']('error',_0x3bb511=>{_0x46b835(_0x3bb511);});});}[a3_0x5484c6(0x1cf)](_0x11602c){const _0x11c862=a3_0x5484c6;if(_0x11602c[_0x11c862(0x1ce)]('downloading'))return _0x11c862(0x1d2);if(_0x11602c['includes'](_0x11c862(0x1cb)))return'installing\x20packages...';if(_0x11602c['includes']('building'))return _0x11c862(0x1be);if(_0x11602c[_0x11c862(0x1ce)](_0x11c862(0x1a6)))return _0x11c862(0x1ae);if(_0x11602c['includes'](_0x11c862(0x1a9)))return _0x11c862(0x19f);return _0x11c862(0x1bb);}}