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