UNPKG

@northflank/cli

Version:

Provides a command-line interface to the Northflank platform.

1 lines 8.82 kB
'use strict';const a5k=a5K;(function(Z,K){const n=a5K,O=Z();while(!![]){try{const g=-parseInt(n(0x19c))/0x1+parseInt(n(0x16d))/0x2+parseInt(n(0x178))/0x3+-parseInt(n(0x173))/0x4*(-parseInt(n(0x1a3))/0x5)+-parseInt(n(0x193))/0x6+-parseInt(n(0x17e))/0x7+parseInt(n(0x183))/0x8;if(g===K)break;else O['push'](O['shift']());}catch(N){O['push'](O['shift']());}}}(a5Z,0xc029d));function a5Z(){const e=['slice','getStandardExecCommand','greenBright','__esModule','pipe','7753501OieDZH','addCommand','__awaiter','resize','Id\x20[NAME]','14018424ZKvYkl','customUserAgent','service','option','isTTY','setRawMode','ApiClient','--group\x20[GROUP]','then','warning','\x27Ctrl+D\x27','action','CliExec','stdin','execServiceSession','shell\x20command\x20','8824128OtWBdp','--container\x20--containerId\x20[NAME]','exec','\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','\x20--','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.','\x20command\x20exec:\x20','execStartLog','columns','837209nMVQlD','default','\x20in\x20project\x20','filter','bold','execCmd','askForProject','15VxiFiE','apiClient','readline','stdout','exit','stdIn','Exec\x20','log','defineProperty','\x20--cmd\x20\x27date\x27\x0a\x20\x20Single\x20command,\x20custom\x20shell:\x20northflank\x20exec\x20','stdOut','emitKeypressEvents','value','assertContextExisting','Project\x20for\x20exec','--user\x20[USER]','\x20to\x20exec\x20into','keypress','apply',',\x20exit\x20code:\x20','__importDefault','Command\x20execution\x20(exec)\x20for\x20Northflank\x20services\x20and\x20jobs.','askForService','with\x20group:','--shell-cmd\x20[SHELL-CMD]','rows','Received\x20Ctrl+D\x20twice,\x20exiting\x20shell\x20forcefully.','name','getTerminalSize','join','waitForCommandResult','Command\x20exec\x20for\x20the\x20specified\x20','job','message','../utils','askForJob','../inquirer-helper','Unknown','getCurrentServiceName','Run\x20command\x20with\x20this\x20group','Command\x20completed\x20successfully,\x20exit\x20code:\x20','description','InquirerHelper','Don\x27t\x20use\x20context\x20default\x20values,\x20explicitly\x20use\x20options\x20or\x20ask.','3081042CFekHg','status','chalk','next','error','getCommand','892396DQDiEJ','handleShellSession','resizeTerminal','getCurrentProjectName','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.','721560NsrjkR'];a5Z=function(){return e;};return a5Z();}var __awaiter=this&&this[a5k(0x180)]||function(Z,K,O,g){function N(H){return H instanceof O?H:new O(function(o){o(H);});}return new(O||(O=Promise))(function(H,o){const r=a5K;function s(W){const x=a5K;try{y(g[x(0x170)](W));}catch(B){o(B);}}function R(W){try{y(g['throw'](W));}catch(B){o(B);}}function y(W){const m=a5K;W['done']?H(W['value']):N(W[m(0x1af)])[m(0x18b)](s,R);}y((g=g[r(0x1b5)](Z,K||[]))[r(0x170)]());});},__importDefault=this&&this[a5k(0x1b7)]||function(Z){const D=a5k;return Z&&Z[D(0x17c)]?Z:{'default':Z};};Object[a5k(0x1ab)](exports,a5k(0x17c),{'value':!![]}),exports[a5k(0x18f)]=void 0x0;const js_client_1=require('@northflank/js-client'),chalk_1=__importDefault(require(a5k(0x16f))),utils_1=require(a5k(0x1c5)),inquirer_helper_1=require(a5k(0x1c7));function a5K(Z,K){const O=a5Z();return a5K=function(g,N){g=g-0x167;let H=O[g];return H;},a5K(Z,K);}class CliExec{constructor(Z,K){const d=a5k;this[d(0x17a)]=H=>(0x0,utils_1['getCommand'])(!![])['name'](H)['description'](d(0x1c2)+H+'.\x0aExamples:\x0a\x20\x20Shell\x20session:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20northflank\x20exec\x20'+H+'\x0a\x20\x20Single\x20command,\x20no\x20shell:\x20\x20\x20\x20\x20northflank\x20exec\x20'+H+d(0x1ac)+H+d(0x196)+H+'\x20--shell-cmd\x20\x27sh\x27')['option']('--project\x20--projectId\x20[NAME]',d(0x1b1))[d(0x186)]('--'+H+d(0x197)+H+d(0x182),H['charAt'](0x0)['toUpperCase']()+H[d(0x179)](0x1)+d(0x1b3))[d(0x186)](d(0x194),'Container\x20to\x20exec\x20into\x20(random\x20container\x20will\x20be\x20chosen\x20if\x20not\x20specified)')[d(0x186)](d(0x1bb),d(0x177))[d(0x186)](d(0x1b2),'Run\x20command\x20with\x20this\x20user')[d(0x186)](d(0x18a),d(0x168))[d(0x186)]('--noDefaults',d(0x16c),![])[d(0x186)]('--cmd\x20--command\x20[COMMAND]',d(0x198)),this[d(0x1bf)]=()=>({'columns':process[d(0x1a6)][d(0x19b)],'rows':process[d(0x1a6)][d(0x1bc)]}),this[d(0x19a)]=(H,o,s,R,y,W,B,V)=>{const b=d;if(V===!![])return;const M=R==='none',I=M?'without\x20shell':R===undefined?'with\x20shell\x20session':b(0x192)+chalk_1[b(0x19d)][b(0x17b)](R),c=y!==undefined?'with\x20user:'+y:'',E=W!==undefined?b(0x1ba)+W:'',p=B!==undefined?'with\x20command\x20\x27'+chalk_1[b(0x19d)][b(0x17b)](B)+'\x27':'',T=[p,I,c,E][b(0x19f)](q=>q!=='')[b(0x1c0)]('\x20'),J='(exit\x20with\x20two\x20quick\x20'+chalk_1['default']['bold'](b(0x18d))+')';console[b(0x1aa)](b(0x1a9)+H+'\x20'+chalk_1['default'][b(0x1a0)](o)+b(0x19e)+chalk_1[b(0x19d)][b(0x1a0)](s)+'\x20'+T+'\x20'+J);},this[d(0x174)]=(H,o,s=![])=>__awaiter(this,void 0x0,void 0x0,function*(){const l=d;var R,y;let W=![];try{if(process['stdin'][l(0x187)]){const V=require(l(0x1a5));V[l(0x1ae)](process[l(0x190)]),process[l(0x190)][l(0x188)](!![]),process[l(0x1a6)]['on'](l(0x181),()=>{const f=l;H[f(0x175)](this[f(0x1bf)]());}),process['stdin']['on'](l(0x1b4),(M,I)=>{const a=l;I['sequence']==='\x04'&&(W?(process[a(0x190)]['setRawMode'](![]),(0x0,utils_1[a(0x18c)])(a(0x1bd)),process[a(0x1a7)]()):(W=!![],setTimeout(()=>W=![],0x190)));});}process[l(0x190)]['pipe'](H[l(0x1a8)]),H['stdErr']['pipe'](process['stderr']),H[l(0x1ad)][l(0x17d)](process[l(0x1a6)]),H['on']('error',M=>{const v=l;var I;(0x0,utils_1['error'])('Error\x20occured\x20during\x20'+o+v(0x199)+((I=M[v(0x1c4)])!==null&&I!==void 0x0?I:M)),process[v(0x190)][v(0x187)]&&process[v(0x190)]['setRawMode'](![]),process['exit'](-0x1);});const B=yield H[l(0x1c1)]();if(s!==!![]){const M=(R=B===null||B===void 0x0?void 0x0:B[l(0x16e)])!==null&&R!==void 0x0?R:l(0x1c8),I=(y=B===null||B===void 0x0?void 0x0:B['exitCode'])!==null&&y!==void 0x0?y:-0x1,c=(B===null||B===void 0x0?void 0x0:B[l(0x1c4)])?',\x20details:\x20'+B['message']:'';M==='Success'?(0x0,utils_1['success'])(l(0x169)+I):(0x0,utils_1[l(0x18c)])('Command\x20didn\x27t\x20complete\x20successfully,\x20status:\x20'+M+l(0x1b6)+I+c);}return B;}finally{process['stdin'][l(0x187)]&&process['stdin']['setRawMode'](![]);}}),this['apiClient']=new js_client_1[(d(0x189))](Z,{'throwErrorOnHttpErrorCode':!![],'customUserAgent':utils_1[d(0x184)],'agent':K});const O=new inquirer_helper_1[(d(0x16b))](this['apiClient']);this[d(0x1a1)]=(0x0,utils_1[d(0x172)])()[d(0x1be)]('command-exec')['alias'](d(0x195))[d(0x16a)](d(0x1b8));const g=this['getStandardExecCommand'](d(0x185))[d(0x18e)](H=>__awaiter(this,void 0x0,void 0x0,function*(){const L=d,{noDefaults:o,projectId:s,serviceId:R,containerId:y,shellCmd:W,user:B,group:V,command:M,quiet:I}=H;(0x0,utils_1[L(0x1b0)])(this[L(0x1a4)]);try{const c=o?undefined:Z[L(0x176)](),E=s||c||(yield O[L(0x1a2)]()),p=o?undefined:Z[L(0x167)](),T=R||p||(yield O[L(0x1b9)](E)()),J=W!==null&&W!==void 0x0?W:M!==undefined?'none':undefined;this[L(0x19a)](L(0x185),T,E,J,B,V,M,I);const q=process[L(0x1a6)][L(0x19b)],Y=process[L(0x1a6)][L(0x1bc)],P={'projectId':E,'serviceId':T},C=yield this[L(0x1a4)][L(0x195)][L(0x191)](P,{'containerName':y,'command':M,'shell':J,'user':B,'group':V,'ttyColumns':q,'ttyRows':Y});yield this[L(0x174)](C,'service',I);}catch(S){(0x0,utils_1[L(0x171)])(''+S[L(0x1c4)]);}finally{process['exit']();}})),N=this[d(0x17a)](d(0x1c3))[d(0x18e)](H=>__awaiter(this,void 0x0,void 0x0,function*(){const X=d,{projectId:o,jobId:s,containerId:R,noDefaults:y,shellCmd:W,user:B,group:V,command:M,quiet:I}=H;(0x0,utils_1[X(0x1b0)])(this[X(0x1a4)]);try{const c=y?undefined:Z[X(0x176)](),E=o||c||(yield O['askForProject']()),p=s||(yield O[X(0x1c6)](E)());this[X(0x19a)](X(0x1c3),p,E,W,I);const {rows:T,columns:J}=this[X(0x1bf)](),q={'projectId':E,'jobId':p},Y=yield this[X(0x1a4)][X(0x195)]['execJobSession'](q,{'containerName':R,'command':M,'shell':W,'user':B,'group':V,'ttyColumns':J,'ttyRows':T});yield this[X(0x174)](Y,X(0x1c3),I);}catch(P){(0x0,utils_1[X(0x171)])(''+P['message']);}finally{process[X(0x1a7)]();}}));this[d(0x1a1)][d(0x17f)](g),this[d(0x1a1)][d(0x17f)](N);}}exports['CliExec']=CliExec;