@northflank/cli
Version:
Provides a command-line interface to the Northflank platform.
1 lines • 10.7 kB
JavaScript
;const a5e=a5a;(function(S,a){const D=a5a,j=S();while(!![]){try{const v=parseInt(D(0x14f))/0x1+-parseInt(D(0x173))/0x2*(-parseInt(D(0x105))/0x3)+parseInt(D(0x132))/0x4*(-parseInt(D(0x16c))/0x5)+-parseInt(D(0x14b))/0x6*(-parseInt(D(0x166))/0x7)+-parseInt(D(0x153))/0x8+parseInt(D(0x13d))/0x9*(-parseInt(D(0x114))/0xa)+-parseInt(D(0x138))/0xb*(-parseInt(D(0x136))/0xc);if(v===a)break;else j['push'](j['shift']());}catch(z){j['push'](j['shift']());}}}(a5S,0x1fa9f));function a5S(){const n=['status','isTTY','with\x20command\x20\x27','\x20to\x20exec\x20into','--instance\x20--instanceName\x20[NAME]','error','action','1168110ohtNOO','Instance\x20to\x20exec\x20into\x20','__esModule','success','53373GyipRU','--group\x20[GROUP]','execAddonSession','--shell-cmd\x20[SHELL-CMD]','2068176AHevem','rows','CliExec','service','\x20in\x20container\x20','keypress','addCommand','Command\x20completed\x20successfully,\x20exit\x20code:\x20','with\x20user:','stdout','Exec\x20','../inquirer-helper','\x27Ctrl+D\x27','Error\x20occured\x20during\x20','stderr','Project\x20for\x20exec','\x20in\x20project\x20','message','stdErr','7rXaCCO','getCurrentProjectName','askForJob','Command\x20didn\x27t\x20complete\x20successfully,\x20status:\x20','job','(random\x20instance\x20will\x20be\x20chosen\x20if\x20not\x20specified)','215brhbpM','greenBright','@northflank/js-client','getStandardExecCommand','resizeTerminal','next','toUpperCase','4ubjFzm','description','__importDefault','emitKeypressEvents','execJobSession','askForProject','(required)\x20','execServiceSession','__awaiter','getCommand','name','(exit\x20with\x20two\x20quick\x20','containerName','../utils','193647hgZZEl','warning','apiClient','Run\x20command\x20with\x20this\x20group','\x20on\x20instance\x20','resize','pipe','apply','stdin','option','columns','Command\x20execution\x20(exec)\x20for\x20Northflank\x20services\x20and\x20jobs.','customUserAgent','stdIn','askForAddon','1990iSDWYa','Command\x20to\x20execute.\x0aIf\x20--shell-cmd\x20option\x20such\x20as\x20\x27bash\x20-c\x27\x20is\x20present,\x20it\x20will\x20run\x20in\x20the\x20specified\x20shell.\x20Otherwise\x20the\x20command\x20will\x20run\x20without\x20a\x20shell.\x20If\x20no\x20command\x20is\x20provided,\x20an\x20interactive\x20session\x20with\x20stdin\x20and\x20tty\x20is\x20opened.','with\x20group:','getTerminalSize','\x20--shell-cmd\x20\x27sh\x27','stdOut','join','--user\x20[USER]','execCmd',',\x20exit\x20code:\x20','waitForCommandResult','none','Run\x20command\x20with\x20shell\x20(e.g.\x20\x27bash\x27,\x27sh\x27).\x0aIf\x20not\x20set\x20and\x20no\x20command\x20is\x20provided,\x20several\x20standard\x20shells\x20will\x20be\x20attempted.\x20If\x20not\x20set\x20and\x20a\x20command\x20is\x20provided,\x20the\x20command\x20will\x20run\x20without\x20shell.',',\x20details:\x20','charAt','exec','Success','instanceName','handleShellSession','Received\x20Ctrl+D\x20twice,\x20exiting\x20shell\x20forcefully.','shell\x20command\x20','Run\x20command\x20with\x20this\x20user','execStartLog','bold','assertContextExisting','Don\x27t\x20use\x20context\x20default\x20values,\x20explicitly\x20use\x20options\x20or\x20ask.','filter','exit','default','exitCode','10940wTeYoE','InquirerHelper','slice','\x20--cmd\x20\x27\x22ls\x20-l\x20/usr\x22\x27\x20--shell-cmd\x20\x27bash\x20-c\x27\x0a\x20\x20Shell\x20session,\x20custom\x20shell:\x20\x20northflank\x20exec\x20','7116qdznmH','sequence','6259EsYEFe','Container\x20within\x20instance\x20to\x20exec\x20into\x20(if\x20not\x20specified,\x20first\x20container\x20of\x20the\x20instance\x20will\x20be\x20selected)','--noDefaults','\x20--','with\x20shell\x20session','9441ZMNiTh','Unknown','value','\x0a\x20\x20Single\x20command,\x20no\x20shell:\x20\x20\x20\x20\x20northflank\x20exec\x20','addon','setRawMode','askForService'];a5S=function(){return n;};return a5S();}function a5a(S,a){const j=a5S();return a5a=function(v,z){v=v-0x100;let s=j[v];return s;},a5a(S,a);}var __awaiter=this&&this[a5e(0x17b)]||function(S,a,j,v){function z(s){return s instanceof j?s:new j(function(u){u(s);});}return new(j||(j=Promise))(function(s,u){const b=a5a;function g(o){const C=a5a;try{i(v[C(0x171)](o));}catch(X){u(X);}}function w(o){try{i(v['throw'](o));}catch(X){u(X);}}function i(o){const q=a5a;o['done']?s(o[q(0x13f)]):z(o[q(0x13f)])['then'](g,w);}i((v=v[b(0x10c)](S,a||[]))[b(0x171)]());});},__importDefault=this&&this[a5e(0x175)]||function(S){const O=a5e;return S&&S[O(0x14d)]?S:{'default':S};};Object['defineProperty'](exports,a5e(0x14d),{'value':!![]}),exports[a5e(0x155)]=void 0x0;const js_client_1=require(a5e(0x16e)),chalk_1=__importDefault(require('chalk')),utils_1=require(a5e(0x104)),inquirer_helper_1=require(a5e(0x15e));class CliExec{constructor(S,a){const h=a5e;this[h(0x16f)]=u=>{const B=h,g=(0x0,utils_1[B(0x100)])(!![])[B(0x101)](u)['description']('Command\x20exec\x20for\x20the\x20specified\x20'+u+(u===B(0x141)?'(only\x20applicable\x20for\x20custom\x20addon\x20types)\x20':'')+'.\x0aExamples:\x0a\x20\x20Shell\x20session:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20northflank\x20exec\x20'+u+B(0x140)+u+'\x20--cmd\x20\x27date\x27\x0a\x20\x20Single\x20command,\x20custom\x20shell:\x20northflank\x20exec\x20'+u+B(0x135)+u+B(0x118))[B(0x10e)]('--project\x20--projectId\x20[NAME]',B(0x162))[B(0x10e)]('--'+u+B(0x13b)+u+'Id\x20[NAME]',u[B(0x122)](0x0)[B(0x172)]()+u[B(0x134)](0x1)+B(0x147))[B(0x10e)](B(0x148),B(0x14c)+(u===B(0x141)?B(0x179):B(0x16b)))[B(0x10e)](B(0x152),B(0x120))[B(0x10e)](B(0x13a),B(0x12d),![])[B(0x10e)]('--cmd\x20--command\x20[COMMAND]',B(0x115));return u!==B(0x141)&&g[B(0x10e)](B(0x11b),B(0x129))[B(0x10e)](B(0x150),B(0x108)),u===B(0x141)&&g['option']('--container\x20--containerName\x20[NAME]',B(0x139)),g;},this[h(0x117)]=()=>({'columns':process[h(0x15c)]['columns'],'rows':process[h(0x15c)][h(0x154)]}),this[h(0x12a)]=(u,g,w,i,o,X,T,H,E,Y)=>{const F=h;if(H===!![])return;const V=i===F(0x11f),K=E!==undefined?F(0x109)+chalk_1[F(0x130)]['bold'](E):'',L=Y!==undefined?F(0x157)+chalk_1[F(0x130)][F(0x12b)](Y):'',A=V?'without\x20shell':i===undefined?F(0x13c):F(0x128)+chalk_1['default']['greenBright'](i),Q=o?F(0x15b)+o:'',R=X?F(0x116)+X:'',M=T?F(0x146)+chalk_1[F(0x130)][F(0x16d)](T)+'\x27':'',x=[M,A,Q,R][F(0x12e)](N=>N!=='')[F(0x11a)]('\x20'),c=F(0x102)+chalk_1[F(0x130)][F(0x12b)](F(0x15f))+')';console['log'](F(0x15d)+u+'\x20'+chalk_1[F(0x130)]['bold'](g)+F(0x163)+chalk_1[F(0x130)][F(0x12b)](w)+K+L+'\x20'+x+'\x20'+c);},this[h(0x126)]=(u,g,w=![])=>__awaiter(this,void 0x0,void 0x0,function*(){const P=h;var i,o;let X=![];try{if(process['stdin'][P(0x145)]){const H=require('readline');H[P(0x176)](process[P(0x10d)]),process[P(0x10d)][P(0x142)](!![]),process['stdout']['on'](P(0x10a),()=>{const m=P;u[m(0x170)](this[m(0x117)]());}),process['stdin']['on'](P(0x158),(E,Y)=>{const y=P;Y[y(0x137)]==='\x04'&&(X?(process[y(0x10d)][y(0x142)](![]),(0x0,utils_1[y(0x106)])(y(0x127)),process[y(0x12f)]()):(X=!![],setTimeout(()=>X=![],0x190)));});}process[P(0x10d)][P(0x10b)](u[P(0x112)]),u[P(0x165)][P(0x10b)](process[P(0x161)]),u[P(0x119)][P(0x10b)](process[P(0x15c)]),u['on'](P(0x149),E=>{const U=P;var Y;(0x0,utils_1[U(0x149)])(U(0x160)+g+'\x20command\x20exec:\x20'+((Y=E['message'])!==null&&Y!==void 0x0?Y:E)),process[U(0x10d)]['isTTY']&&process['stdin'][U(0x142)](![]),process[U(0x12f)](-0x1);});const T=yield u[P(0x11e)]();if(w!==!![]){const E=(i=T===null||T===void 0x0?void 0x0:T[P(0x144)])!==null&&i!==void 0x0?i:P(0x13e),Y=(o=T===null||T===void 0x0?void 0x0:T[P(0x131)])!==null&&o!==void 0x0?o:-0x1,V=(T===null||T===void 0x0?void 0x0:T['message'])?P(0x121)+T[P(0x164)]:'';E===P(0x124)?(0x0,utils_1[P(0x14e)])(P(0x15a)+Y):(0x0,utils_1[P(0x106)])(P(0x169)+E+P(0x11d)+Y+V);}return T;}finally{process['stdin'][P(0x145)]&&process['stdin'][P(0x142)](![]);}}),this[h(0x107)]=new js_client_1['ApiClient'](S,{'throwErrorOnHttpErrorCode':!![],'customUserAgent':utils_1[h(0x111)],'agent':a});const j=new inquirer_helper_1[(h(0x133))](this[h(0x107)]);this[h(0x11c)]=(0x0,utils_1[h(0x100)])()[h(0x101)]('command-exec')['alias'](h(0x123))[h(0x174)](h(0x110));const v=this[h(0x16f)](h(0x156))['action'](u=>__awaiter(this,void 0x0,void 0x0,function*(){const J=h,{noDefaults:g,projectId:w,serviceId:i,instanceName:o}=u,{shellCmd:X,user:T,group:H,command:E,quiet:Y}=u;(0x0,utils_1[J(0x12c)])(this['apiClient']);try{const V=g?undefined:S[J(0x167)](),K=w||V||(yield j['askForProject']()),L=g?undefined:S['getCurrentServiceName'](),A=i||L||(yield j[J(0x143)](K)()),Q=X!==null&&X!==void 0x0?X:E!==undefined?'none':undefined,R=process['stdout'][J(0x10f)],M=process[J(0x15c)][J(0x154)],x={'projectId':K,'serviceId':A},c={'instanceName':o,'command':E,'shell':Q,'user':T,'group':H,'ttyColumns':R,'ttyRows':M},N=yield this[J(0x107)][J(0x123)][J(0x17a)](x,c,Z=>{const W=J;this[W(0x12a)]('service',A,K,X,T,H,E,Y,Z[W(0x125)],Z[W(0x103)]);});yield this[J(0x126)](N,J(0x156),Y);}catch(Z){(0x0,utils_1[J(0x149)])(''+Z[J(0x164)]);}finally{process['exit']();}})),z=this['getStandardExecCommand']('job')[h(0x14a)](u=>__awaiter(this,void 0x0,void 0x0,function*(){const l=h,{projectId:g,jobId:w,instanceName:i}=u,{noDefaults:o,shellCmd:X,user:T,group:H,command:E,quiet:Y}=u;(0x0,utils_1[l(0x12c)])(this[l(0x107)]);try{const V=o?undefined:S[l(0x167)](),K=g||V||(yield j[l(0x178)]()),L=w||(yield j[l(0x168)](K)()),{rows:A,columns:Q}=this[l(0x117)](),R={'projectId':K,'jobId':L},M={'instanceName':i,'command':E,'shell':X,'user':T,'group':H,'ttyColumns':Q,'ttyRows':A},x=yield this[l(0x107)][l(0x123)][l(0x177)](R,M,c=>{const f=l;this[f(0x12a)]('job',L,K,X,T,H,E,Y,c[f(0x125)],c[f(0x103)]);});yield this['handleShellSession'](x,l(0x16a),Y);}catch(c){(0x0,utils_1[l(0x149)])(''+c[l(0x164)]);}finally{process[l(0x12f)]();}})),s=this[h(0x16f)](h(0x141))[h(0x14a)](u=>__awaiter(this,void 0x0,void 0x0,function*(){const I=h,{projectId:g,addonId:w,instanceName:i,containerName:o}=u,{noDefaults:X,shellCmd:T,user:H,group:E,command:Y,quiet:V}=u;(0x0,utils_1['assertContextExisting'])(this['apiClient']);try{const K=X?undefined:S[I(0x167)](),L=g||K||(yield j['askForProject']()),A=w||(yield j[I(0x113)](L)()),{rows:Q,columns:R}=this[I(0x117)](),M=T!==null&&T!==void 0x0?T:Y!==undefined?'none':undefined,x={'projectId':L,'addonId':A},c={'instanceName':i,'containerName':o,'command':Y,'shell':M,'user':H,'group':E,'ttyColumns':R,'ttyRows':Q},N=yield this[I(0x107)][I(0x123)][I(0x151)](x,c,Z=>{const r=I;this[r(0x12a)](r(0x141),A,L,M,H,E,Y,V,Z[r(0x125)],Z['containerName']);});yield this[I(0x126)](N,'addon',V);}catch(Z){(0x0,utils_1[I(0x149)])(''+Z[I(0x164)]);}finally{process['exit']();}}));this[h(0x11c)][h(0x159)](v),this[h(0x11c)]['addCommand'](z),this[h(0x11c)][h(0x159)](s);}}exports[a5e(0x155)]=CliExec;