UNPKG

@northflank/cli

Version:

Provides a command-line interface to the Northflank platform.

1 lines 12.2 kB
'use strict';const a11Z1=a11K;function a11Z(){const ZH=['Get\x20logs\x20generated\x20before\x20this\x20time,\x20','getStandardLogCommand','askForAddonBackup','../utils','error','next','Id\x20[','\x20for\x20all\x20containers','length','Number\x20of\x20lines\x20to\x20return.','--restore\x20--restoreId\x20[restoreId]','defaultDurationSeconds','1881719tgrjSW','\x20in\x20project\x20','getCommand','--build\x20--buildId\x20[buildId]','Direction\x20of\x20logs.\x20Ignored\x20when\x20tailing.','then','Id]','hasNextPage','toUpperCase',',\x20backup\x20id\x20','315KXwtHx','job','Don\x27t\x20use\x20context\x20default\x20values,\x20explicitly\x20use\x20options\x20or\x20ask.','addonRestore','start','\x20(exit\x20with\x20','apiContext','value','Error\x20while\x20tailing\x20log\x20lines:\x20','\x20to\x20get\x20logs\x20from','json','CliLogs','toISOString','inquirerHelper','askForService','askForAddon','12032883terKDA','Which\x20log\x20types\x20to\x20fetch','logs','choices','Error\x20while\x20fetching\x20log\x20lines:\x20','@northflank/js-client','No\x20logs\x20found\x20for\x20this\x20query.\x20Make\x20sure\x20to\x20select\x20an\x20appropriate\x20time\x20window.','--regexIncludes\x20<regex>','ApiClient','8DLgNKp','\x27Ctrl+C\x27','buildId','close','Filter\x20log\x20lines\x20to\x20match\x20this\x20regular\x20expression','textIncludes','Filter\x20log\x20lines\x20to\x20include\x20this\x20text','restoreId','getSeconds','build-','--noDefaults','\x20of\x20','1371784RQiehB','getFormatter','details','throw','-o,\x20--output\x20[output]','addonBackup','bold','service','askForAddonRestore','--backup\x20--backupId\x20[backupId]','warning','10HzJLVr','forEach','noDefaults','InquirerHelper','Deployment\x20id,\x20example:\x20my-service-54785f4','pagination','cursor','default','assign','Get\x20logs\x20generated\x20after\x20this\x20time,\x20','--textIncludes\x20<text>','Filter\x20log\x20lines\x20to\x20not\x20include\x20this\x20text','1100262KTueda','--deployment\x20--deploymentId\x20[deploymentId]','runId','yaml','Length\x20of\x20timespan\x20in\x20seconds.\x20Only\x20valid\x20if\x20not\x20both,\x20startTime\x20and\x20endTime\x20are\x20set','logRange','--duration\x20[duration]','getCurrentProjectName','--container\x20--containerId\x20[containerId]','slice','-l,\x20--lineLimit\x20[limit]','addOption','Filter\x20log\x20lines\x20to\x20not\x20match\x20this\x20regular\x20expression','commander','Build\x20to\x20get\x20logs\x20from','apply','deploymentId','--startTime\x20<timestamp>','\x20with\x20live-tailing','12012ZINQJr','message','Container\x20to\x20exec\x20into\x20(logs\x20from\x20all\x20containers\x20will\x20be\x20shown\x20if\x20not\x20specified)','askForContainer','Job\x20run\x20id,\x20example:\x20162b1977-6636-4000-929b-cc265b862ff0','--regexNotIncludes\x20<regex>','../formatting/console-format-helpers','parseDateInput','printInitInfo','apiClient','backward','regexNotIncludes',',\x20from:\x20','Only\x20two\x20of\x20\x27startTime\x27,\x20\x27endTime\x27\x20and\x20\x27duration\x27\x20can\x20be\x20set.','logTail','stringify','2436190wzmMCm','assertContextExisting','serviceId','setSeconds','chalk','187ILgvXS','getLogsCommand','askForBuild','\x20--','data','textNotIncludes','regexIncludes','__esModule','Output\x20formatting.\x20Will\x20use\x20advanced\x20formatting\x20by\x20default.','action','getCurrentServiceName','Get\x20log\x20for\x20the\x20specified\x20','tail',',\x20restore\x20id\x20','values','containerId','Option',',\x20duration:\x20','valueOf','customUserAgent','argParser','defineProperty','Backup\x20to\x20get\x20logs\x20from','option','tsHint','Project\x20for\x20logs','\x0aDetails:\x20','--run\x20--runId\x20[runId]','log','>\x20Container\x20logs',',\x20to:\x20','logs-received','addonId','conflicts','--project\x20--projectId\x20[projectId]','../inquirer-helper','yml','319071GKHIYw'];a11Z=function(){return ZH;};return a11Z();}(function(Z,K){const F=a11K,O=Z();while(!![]){try{const g=-parseInt(F(0x10c))/0x1+parseInt(F(0x100))/0x2*(-parseInt(F(0xb9))/0x3)+-parseInt(F(0xf5))/0x4+-parseInt(F(0xd0))/0x5*(-parseInt(F(0x11f))/0x6)+-parseInt(F(0xc6))/0x7*(parseInt(F(0xe9))/0x8)+-parseInt(F(0xe0))/0x9+parseInt(F(0x12f))/0xa*(parseInt(F(0x94))/0xb);if(g===K)break;else O['push'](O['shift']());}catch(N){O['push'](O['shift']());}}}(a11Z,0xa7b04));function a11K(Z,K){const O=a11Z();return a11K=function(g,N){g=g-0x94;let H=O[g];return H;},a11K(Z,K);}var __awaiter=this&&this['__awaiter']||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 t=a11K;function s(W){try{y(g['next'](W));}catch(B){o(B);}}function R(W){const A=a11K;try{y(g[A(0xf8)](W));}catch(B){o(B);}}function y(W){const h=a11K;W['done']?H(W['value']):N(W[h(0xd7)])[h(0xcb)](s,R);}y((g=g[t(0x11b)](Z,K||[]))[t(0xbf)]());});},__importDefault=this&&this['__importDefault']||function(Z){const Z0=a11K;return Z&&Z[Z0(0x9b)]?Z:{'default':Z};};Object[a11Z1(0xa9)](exports,a11Z1(0x9b),{'value':!![]}),exports[a11Z1(0xdb)]=void 0x0;const js_client_1=require(a11Z1(0xe5)),chalk_1=__importDefault(require(a11Z1(0x133))),utils_1=require(a11Z1(0xbd)),inquirer_helper_1=require(a11Z1(0xb7)),commander_1=require(a11Z1(0x119)),console_format_helpers_1=require(a11Z1(0x125)),log_formatter_1=require('./log-formatter');class CliLogs{constructor(Z,K){const Z2=a11Z1;this[Z2(0xd6)]=Z,this[Z2(0xc5)]=0x708,this[Z2(0xbb)]=(O,g,N,H)=>{const Z3=Z2,o=(0x0,utils_1[Z3(0xc8)])(!![])['name']((g?Z3(0xf2):'')+Z3(0xe2))['alias']((g?Z3(0xf2):'')+Z3(0xb0))['description'](Z3(0x9f)+O)['option'](Z3(0xb6),Z3(0xad))[Z3(0xab)]('--'+O+Z3(0x97)+O+Z3(0xc0)+O+Z3(0xcc),O['charAt'](0x0)[Z3(0xce)]()+O[Z3(0x115)](0x1)+Z3(0xd9))[Z3(0xab)](Z3(0x114),Z3(0x121));if(g)o[Z3(0xab)](Z3(0xc9),Z3(0x11a));if(O==='job')o['option'](Z3(0xaf),Z3(0x123));if(O===Z3(0xfc))o['option'](Z3(0x10d),Z3(0x104));if(N)o[Z3(0xab)](Z3(0xfe),Z3(0xaa));if(H)o['option'](Z3(0xc4),'Restore\x20to\x20get\x20logs\x20from');return!g&&!N&&!H&&o[Z3(0x117)](new commander_1[(Z3(0xa4))]('-t,\x20--types\x20<types...>',Z3(0xe1))[Z3(0xe3)](Object[Z3(0xa2)](js_client_1['LogType']))),o[Z3(0xab)]('-f,\x20--tail','Tail\x20will\x20stream\x20logs\x20in\x20real-time.\x20Session\x20will\x20be\x20kept\x20open.')[Z3(0xab)](Z3(0x116),Z3(0xc3))[Z3(0xab)](Z3(0x11d),Z3(0x109)+utils_1[Z3(0xac)],utils_1[Z3(0x126)])['addOption'](new commander_1['Option']('--endTime\x20<timestamp>',Z3(0xba)+utils_1[Z3(0xac)])[Z3(0xa8)](utils_1['parseDateInput'])['conflicts']([Z3(0xa0)]))[Z3(0xab)](Z3(0x112),Z3(0x110))[Z3(0x117)](new commander_1['Option']('-d,\x20--direction\x20<order>',Z3(0xca))[Z3(0xe3)]([Z3(0x129),'forward'])[Z3(0xb5)]([Z3(0xa0)]))[Z3(0x117)](new commander_1[(Z3(0xa4))](Z3(0x10a),Z3(0xef))[Z3(0xb5)]([Z3(0x99),Z3(0x9a),Z3(0x12a)]))[Z3(0x117)](new commander_1[(Z3(0xa4))]('--textNotIncludes\x20<text>',Z3(0x10b))['conflicts'](['textIncludes',Z3(0x9a),Z3(0x12a)]))[Z3(0x117)](new commander_1[(Z3(0xa4))](Z3(0xe7),Z3(0xed))[Z3(0xb5)]([Z3(0x99),Z3(0xee),Z3(0x12a)]))[Z3(0x117)](new commander_1[(Z3(0xa4))](Z3(0x124),Z3(0x118))[Z3(0xb5)](['textNotIncludes','regexIncludes',Z3(0xee)]))[Z3(0xab)](Z3(0xf3),Z3(0xd2),![])[Z3(0x117)](new commander_1[(Z3(0xa4))](Z3(0xf9),Z3(0x9c))[Z3(0xe3)](Object[Z3(0xa2)](['format',Z3(0xda),Z3(0x10f)]))),o;},this[Z2(0x127)]=(O,g,N,H)=>{const Z4=Z2,{containerName:o,restoreId:s,backupId:R,quiet:y,tail:W,startTime:B,endTime:V,duration:M}=H;if(y===!![])return;const I=W?Z4(0xd5)+chalk_1['default'][Z4(0xfb)](Z4(0xea))+')':'',c=W?Z4(0x11e):'',E=new Date(),p=B!==null&&B!==void 0x0?B:new Date(new Date((V!==null&&V!==void 0x0?V:E)[Z4(0xa6)]())[Z4(0x132)]((V!==null&&V!==void 0x0?V:E)[Z4(0xf1)]()-(M!==null&&M!==void 0x0?M:this[Z4(0xc5)]))),T=(V!==null&&V!==void 0x0?V:B!==undefined)?new Date(new Date(B[Z4(0xa6)]())[Z4(0x132)](B[Z4(0xf1)]()+(M!==null&&M!==void 0x0?M:this[Z4(0xc5)]))):E,J=R!==undefined,q=p&&!J?Z4(0x12b)+chalk_1[Z4(0x107)][Z4(0xfb)](p['toISOString']()):'',Y=T&&!J?Z4(0xb2)+chalk_1['default'][Z4(0xfb)](T[Z4(0xdc)]()):'',P=M?Z4(0xa5)+M+'\x20seconds':'',C=o?'\x20for\x20container\x20'+chalk_1[Z4(0x107)][Z4(0xfb)](o):J?'':Z4(0xc1),S=R?Z4(0xcf)+R:'',n=s?Z4(0xa1)+s:'',k=O+'\x20'+chalk_1[Z4(0x107)][Z4(0xfb)](g)+S+n+Z4(0xc7)+chalk_1[Z4(0x107)][Z4(0xfb)](N),x=''+q+Y+P;console[Z4(0xb0)](Z4(0xb1)+c+C+Z4(0xf4)+k+x+I+':');},this[Z2(0xf6)]=(O,g)=>(N,H)=>{const Z5=Z2;if(!O){if(N[Z5(0xc2)]===0x0)console[Z5(0xb0)](Z5(0xe6));N[Z5(0x101)](o=>(0x0,log_formatter_1['formatLogLine'])(o,g));}else(0x0,console_format_helpers_1['printResponse'])(O,N);(H===null||H===void 0x0?void 0x0:H[Z5(0xcd)])&&(0x0,utils_1[Z5(0xff)])('Element\x20count\x20for\x20this\x20request\x20exceeds\x20the\x20line\x20limit,\x20output\x20was\x20truncated.\x20Cut\x20off\x20at\x20timestamp\x20'+H[Z5(0x106)]);},this['apiClient']=new js_client_1[(Z2(0xe8))](Z,{'throwErrorOnHttpErrorCode':!![],'customUserAgent':utils_1[Z2(0xa7)],'agent':K}),this['logsApiClient']=this[Z2(0x128)],this[Z2(0xdd)]=new inquirer_helper_1[(Z2(0x103))](this['apiClient']);}[a11Z1(0x95)](Z,K=![],O=![],g=![]){const Zg=a11Z1,N=(B,V)=>__awaiter(this,void 0x0,void 0x0,function*(){const Z6=a11K,M=V[Z6(0x102)],{apiContext:I,inquirerHelper:c}=this;switch(Z){case Z6(0xfc):{const E=M?undefined:I[Z6(0x9e)]();return V[Z6(0x131)]||E||(yield c[Z6(0xde)](B)());}case Z6(0xd1):{const p=M?undefined:I['getCurrentJobName']();return V['jobId']||p||(yield c['askForJob'](B)());}case'addon':{return V[Z6(0xb4)]||(yield c[Z6(0xdf)](B)());}}}),H=(B,V,M)=>__awaiter(this,void 0x0,void 0x0,function*(){const Z7=a11K;if(K)return M[Z7(0xeb)]||(yield this[Z7(0xdd)][Z7(0x96)](B,Z===Z7(0xfc)?V:undefined,Z==='job'?V:undefined,!![])());return undefined;}),o=(B,V,M)=>__awaiter(this,void 0x0,void 0x0,function*(){const Z8=a11K;if(O||g)return M['backupId']||(yield this[Z8(0xdd)][Z8(0xbc)](B,V)());return undefined;}),s=(B,V,M,I)=>__awaiter(this,void 0x0,void 0x0,function*(){const Z9=a11K;if(g)return I[Z9(0xf0)]||(yield this[Z9(0xdd)][Z9(0xfd)](B,V,M)());return undefined;}),R=(B,V,M)=>__awaiter(this,void 0x0,void 0x0,function*(){const ZZ=a11K;if(!K&&M[ZZ(0xa3)]!==undefined){if(M[ZZ(0xa3)]!==!![])return M[ZZ(0xa3)];return yield this[ZZ(0xdd)][ZZ(0x122)](B,Z===ZZ(0xfc)?V:undefined,Z===ZZ(0xd1)?V:undefined,!![])();}return undefined;}),y=(B,V,M)=>__awaiter(this,void 0x0,void 0x0,function*(){const ZK=a11K;if(Z===ZK(0xd1))return M[ZK(0x10e)]||(yield this[ZK(0xdd)]['askForJobRun'](V,B,!![])());return undefined;}),W=(B,V,M)=>__awaiter(this,void 0x0,void 0x0,function*(){const ZO=a11K;if(Z===ZO(0xfc)){if(M[ZO(0x11c)]!==!![])return M[ZO(0x11c)];return M[ZO(0x11c)];}return undefined;});return this['getStandardLogCommand'](Z,K,O,g)[Zg(0x9d)](B=>__awaiter(this,void 0x0,void 0x0,function*(){const ZN=Zg,{noDefaults:V,projectId:M,quiet:I,tail:c,types:E,textIncludes:p,textNotIncludes:T,regexIncludes:J,regexNotIncludes:q,direction:Y,lineLimit:P,startTime:C,endTime:S,duration:n,output:k}=B;(0x0,utils_1[ZN(0x130)])(this['apiClient']);const {apiContext:x,inquirerHelper:m,logsApiClient:r}=this,D=V?undefined:x[ZN(0x113)](),d=M||D||(yield m['askForProject']()),b=yield N(d,B),l=yield H(d,b,B),f=yield o(d,b,B),a=yield s(d,b,f,B),v=yield y(d,b,B),L=yield W(d,b,B),X=yield R(d,b,B);if(C&&S&&n)throw new Error(ZN(0x12c));const e={'projectId':d,'entityId':b},U={'containerName':X,'types':E,'textIncludes':p,'textNotIncludes':T,'regexIncludes':J,'regexNotIncludes':q,'lineLimit':P,'startTime':C,'duration':n,'runId':v,'buildId':l,'backupId':f,'restoreId':a,'deploymentId':L,'isBuild':K!==null&&K!==void 0x0?K:![]},i=g?ZN(0xd3):O?ZN(0xfa):Z,z=Object[ZN(0x108)](Object[ZN(0x108)]({},U),{'endTime':S,'direction':Y});if(!I&&k!=='yaml'&&k!==ZN(0xb8)&&k!==ZN(0xda))this[ZN(0x127)](Z,b,d,Object[ZN(0x108)](Object['assign']({},z),B));const j=this['getFormatter'](k,p!==null&&p!==void 0x0?p:J);if(c){const G=yield r['logs'][ZN(0x12d)](e,U,i);G['on'](ZN(0xb3),j),G['on'](ZN(0xbe),w=>(0x0,utils_1[ZN(0xbe)])(ZN(0xd8)+w[ZN(0x120)])),G['on'](ZN(0xec),()=>console['log']('Log\x20session\x20ended')),yield G[ZN(0xd4)]();}else{const w=yield r['logs'][ZN(0x111)](e,z,i);if(w[ZN(0xbe)]){const Q=w['error'][ZN(0xf7)],u=Q?ZN(0xae)+JSON[ZN(0x12e)](Q,null,'\x20'):'';(0x0,utils_1[ZN(0xbe)])(ZN(0xe4)+w[ZN(0xbe)]['message']+u);}else j(w[ZN(0x98)],w[ZN(0x105)]);}}));}}exports[a11Z1(0xdb)]=CliLogs;