@northflank/cli 0.9.6 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-helpers.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/context/contextCommands.js +1 -1
- package/dist/defaults.js +1 -1
- package/dist/exec/index.js +1 -1
- package/dist/formatting/command-overview.js +1 -1
- package/dist/formatting/console-format-helpers.js +1 -1
- package/dist/formatting/terminal-chart.js +1 -1
- package/dist/inquirer-helper.js +1 -1
- package/dist/login/browser-login.js +1 -1
- package/dist/logs/index.js +1 -1
- package/dist/logs/log-formatter.js +1 -1
- package/dist/metrics/index.js +1 -1
- package/dist/pagination/inquirer-pagination-prompt.js +1 -1
- package/dist/port-forward/index.js +1 -1
- package/dist/utils.js +1 -1
- package/package.json +2 -2
package/dist/api-helpers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';const a0I2=a0z;(function(I,z){const I1=a0z,g=I();while(!![]){try{const Z=-parseInt(I1(0xd4))/0x1+-parseInt(I1(0xbc))/0x2*(-parseInt(I1(0xbb))/0x3)+-parseInt(I1(0xce))/0x4*(-parseInt(I1(0xdc))/0x5)+-parseInt(I1(0xe0))/0x6*(-parseInt(I1(0xed))/0x7)+parseInt(I1(0xf8))/0x8+-parseInt(I1(0xf6))/0x9*(parseInt(I1(0xe5))/0xa)+-parseInt(I1(0xc2))/0xb;if(Z===z)break;else g['push'](g['shift']());}catch(y){g['push'](g['shift']());}}}(a0I,0xf2c9a));var __awaiter=this&&this[a0I2(0xcf)]||function(I,z,g,Z){function y(i){return i instanceof g?i:new g(function(t){t(i);});}return new(g||(g=Promise))(function(i,t){const I5=a0z;function u(G){const I3=a0z;try{M(Z[I3(0xba)](G));}catch(h){t(h);}}function v(G){try{M(Z['throw'](G));}catch(h){t(h);}}function M(G){const I4=a0z;G[I4(0xf5)]?i(G['value']):y(G['value'])['then'](u,v);}M((Z=Z[I5(0xd5)](I,z||[]))['next']());});};Object[a0I2(0xcb)](exports,a0I2(0xd9),{'value':!![]}),exports[a0I2(0xc3)]=void 0x0;const utils_1=require(a0I2(0xe9)),defaultPaginationPageSize=0x32,getProjects=I=>z=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){const I6=a0I2;var g;const Z=yield I[I6(0xc1)][I6(0xea)]({'options':{'per_page':defaultPaginationPageSize,'cursor':z===null||z===void 0x0?void 0x0:z[I6(0xc6)]}});return{'elements':Z[I6(0xcd)]['projects']['map'](y=>y['id']),'nextPageCursor':(g=Z['pagination'])===null||g===void 0x0?void 0x0:g[I6(0xc5)]};}),getServices=(I,z)=>g=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){const I7=a0I2;var Z;const y=yield I[I7(0xc1)]['services']({'parameters':{'projectId':z},'options':{'per_page':defaultPaginationPageSize,'cursor':g===null||g===void 0x0?void 0x0:g[I7(0xc6)]}});return{'elements':y[I7(0xcd)][I7(0xe2)]['map'](i=>i['id']),'nextPageCursor':(Z=y[I7(0xdd)])===null||Z===void 0x0?void 0x0:Z[I7(0xc5)]};}),getAddons=(I,z)=>g=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){const I8=a0I2;var Z;const y=yield I[I8(0xc1)][I8(0xf7)]({'parameters':{'projectId':z},'options':{'per_page':defaultPaginationPageSize,'cursor':g===null||g===void 0x0?void 0x0:g['nextPageCursor']}});return{'elements':y[I8(0xcd)][I8(0xf7)][I8(0xf1)](i=>i['id']),'nextPageCursor':(Z=y[I8(0xdd)])===null||Z===void 0x0?void 0x0:Z['cursor']};}),getAddonBackups=(I,z,g)=>Z=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){const I9=a0I2;var y;const i=yield I[I9(0xb8)]['addon'][I9(0xd3)]({'parameters':{'projectId':z,'addonId':g},'options':{'per_page':defaultPaginationPageSize,'cursor':Z===null||Z===void 0x0?void 0x0:Z['nextPageCursor']}});return{'elements':i[I9(0xcd)]['backups'][I9(0xf1)](t=>t['id']),'nextPageCursor':(y=i[I9(0xdd)])===null||y===void 0x0?void 0x0:y[I9(0xc5)]};});function fetchResourceList(I,z,g,Z,y,i){var t,u,v,M,G,P,h,L,R,w,Q,K;return __awaiter(this,void 0x0,void 0x0,function*(){const II=a0z,J=undefined;try{if(I===II(0xf0)){const f=yield z[II(0xc1)][II(0xc9)]({}),x=f[II(0xcd)][II(0xc9)][II(0xf1)](o=>{const Iz=II;var d;return(d=o===null||o===void 0x0?void 0x0:o[Iz(0xdf)])!==null&&d!==void 0x0?d:o===null||o===void 0x0?void 0x0:o['id'];});return{'choices':x,'defaultValue':J};}if(I===II(0xcc)&&!(g===null||g===void 0x0?void 0x0:g['includes']('logSink'))){const o=yield z['list'][II(0xd1)]({}),d=o[II(0xcd)][II(0xd1)][II(0xf1)](n=>{const Ig=II;var A;return(A=n===null||n===void 0x0?void 0x0:n[Ig(0xdf)])!==null&&A!==void 0x0?A:n===null||n===void 0x0?void 0x0:n['id'];});return{'choices':d,'defaultValue':J};}if(I===II(0xe6)){const n=yield getProjects(z),{elements:A,nextPageCursor:T}=yield n();return{'choices':A,'defaultValue':J,'pagination':{'nextPageCursor':T,'loadMore':n}};}if(I===II(0xe1)){const m=yield z['list'][II(0xf3)]({}),b=m['data'][II(0xe1)][II(0xf1)](O=>O['id']);return{'choices':b,'defaultValue':J};}const j=y===null||y===void 0x0?void 0x0:y[II(0xe6)],F=I===II(0xb9)||I==='id'&&(i===null||i===void 0x0?void 0x0:i['includes'](II(0xf4)));if(j!==undefined&&F){const O=yield getServices(z,j),{elements:V,nextPageCursor:k}=yield O();return{'choices':V,'defaultValue':J,'pagination':{'nextPageCursor':k,'loadMore':O}};}const s=g===null||g===void 0x0?void 0x0:g[II(0xe3)]('addon');if(s){const N=a=>__awaiter(this,void 0x0,void 0x0,function*(){const IZ=II;var D;const H=yield z[IZ(0xb8)][IZ(0xde)][IZ(0xee)]({});return(D=H['data'][IZ(0xd8)])===null||D===void 0x0?void 0x0:D['find'](Y=>Y[IZ(0xbf)]===a);});if(I===II(0xbf)){const a=yield z[II(0xb8)][II(0xde)][II(0xee)]({}),D=(t=a[II(0xcd)][II(0xd8)])===null||t===void 0x0?void 0x0:t['map'](H=>H[II(0xbf)]);return{'choices':D,'defaultValue':J};}if(I===II(0xf9)&&(Z===null||Z===void 0x0?void 0x0:Z['type'])!==undefined){const H=(u=yield N(Z[II(0xbf)]))===null||u===void 0x0?void 0x0:u[II(0xc7)];return{'choices':H,'defaultValue':J};}if(I===II(0xb7)&&(Z===null||Z===void 0x0?void 0x0:Z[II(0xbf)])!==undefined){const Y=(M=(v=yield N(Z[II(0xbf)]))===null||v===void 0x0?void 0x0:v[II(0xbe)])===null||M===void 0x0?void 0x0:M[II(0xb7)];return{'choices':Y===null||Y===void 0x0?void 0x0:Y[II(0xef)],'defaultValue':Y===null||Y===void 0x0?void 0x0:Y[II(0xc4)]};}if(I===II(0xd7)&&(Z===null||Z===void 0x0?void 0x0:Z[II(0xbf)])!==undefined){const r=(P=(G=yield N(Z[II(0xbf)]))===null||G===void 0x0?void 0x0:G[II(0xbe)])===null||P===void 0x0?void 0x0:P[II(0xd7)];return{'choices':r===null||r===void 0x0?void 0x0:r[II(0xef)],'defaultValue':r===null||r===void 0x0?void 0x0:r[II(0xc4)]};}}if(I==='addonId'&&(y===null||y===void 0x0?void 0x0:y[II(0xe6)])!==undefined){const X=yield getAddons(z,y===null||y===void 0x0?void 0x0:y[II(0xe6)]),{elements:l,nextPageCursor:S}=yield X();return{'choices':l,'defaultValue':J,'pagination':{'nextPageCursor':S,'loadMore':X}};}if(I===II(0xdb)&&(y===null||y===void 0x0?void 0x0:y[II(0xe6)])!==undefined&&((h=Z===null||Z===void 0x0?void 0x0:Z[II(0xd2)])===null||h===void 0x0?void 0x0:h[II(0xeb)])!==undefined){const q=yield getAddonBackups(z,y===null||y===void 0x0?void 0x0:y[II(0xe6)],(L=Z===null||Z===void 0x0?void 0x0:Z['source'])===null||L===void 0x0?void 0x0:L[II(0xeb)]),{elements:E,nextPageCursor:W}=yield q();return{'choices':E,'defaultValue':J,'pagination':{'nextPageCursor':W,'loadMore':q}};}const C=(R=y===null||y===void 0x0?void 0x0:y[II(0xeb)])!==null&&R!==void 0x0?R:(w=Z===null||Z===void 0x0?void 0x0:Z[II(0xd6)])===null||w===void 0x0?void 0x0:w[II(0xeb)];if((g===null||g===void 0x0?void 0x0:g[II(0xda)](''))===II(0xe8)&&I==='version'&&(y===null||y===void 0x0?void 0x0:y['projectId'])!==undefined&&C!==undefined){const {upgradeTo:B}=(yield z[II(0xb8)]['addon'][II(0xf9)]({'parameters':{'addonId':C,'projectId':y===null||y===void 0x0?void 0x0:y['projectId']}}))[II(0xcd)];if(B===undefined||B['length']<=0x0){(0x0,utils_1[II(0xc0)])(II(0xbd));throw new Error();}return{'choices':B[II(0xf1)](p=>p[II(0xf9)]),'defaultValue':J};}if(I==='templateId'){const p=yield z[II(0xc1)][II(0xca)]({}),c=p['data'][II(0xca)][II(0xf1)](U=>U===null||U===void 0x0?void 0x0:U['id']);return{'choices':c,'defaultValue':J};}if(((g===null||g===void 0x0?void 0x0:g['includes'](II(0xe4)))||(g===null||g===void 0x0?void 0x0:g[II(0xe3)](II(0xf2))))&&I===II(0xc8)&&C!==undefined&&(y===null||y===void 0x0?void 0x0:y[II(0xe6)])!==undefined){const U=(yield z[II(0xb8)][II(0xde)]['credentials']({'parameters':{'addonId':C,'projectId':y===null||y===void 0x0?void 0x0:y[II(0xe6)]}}))['data'];return{'choices':[...(Q=Object['keys'](U===null||U===void 0x0?void 0x0:U[II(0xec)]))!==null&&Q!==void 0x0?Q:[],...(K=Object[II(0xd0)](U===null||U===void 0x0?void 0x0:U[II(0xe7)]))!==null&&K!==void 0x0?K:[]]};}}catch(I0){}return{'choices':undefined,'defaultValue':J};});}function a0I(){const Iy=['keyName','plans','templates','defineProperty','region','data','12276oGtpYt','__awaiter','keys','regions','source','backups','883487TtGejC','apply','addonDependencies','replicas','addonTypes','__esModule','join','backupId','2455vvBvyd','pagination','addon','internalId','69798PaVXKV','credentials','services','includes','secretLink','81520TGZSpJ','projectId','secrets','updateaddonversion','./utils','projects','addonId','envs','616fBITSx','types','options','deploymentPlan','map','secret','registries','owningObject','done','351PWZqQK','addons','3520408hTdaVh','version','storage','get','serviceId','next','153OidFuN','58674gHDKIC','No\x20available\x20versions\x20to\x20upgrade\x20to.','resources','type','warning','list','24980428IJGvmY','fetchResourceList','default','cursor','nextPageCursor','versions'];a0I=function(){return Iy;};return a0I();}function a0z(I,z){const g=a0I();return a0z=function(Z,y){Z=Z-0xb7;let i=g[Z];return i;},a0z(I,z);}exports[a0I2(0xc3)]=fetchResourceList;
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';const a1uR=a1z;function a1z(u,z){const D=a1u();return a1z=function(M,H){M=M-0x189;let O=D[M];return O;},a1z(u,z);}(function(u,z){const uX=a1z,D=u();while(!![]){try{const M=-parseInt(uX(0x1b8))/0x1+parseInt(uX(0x1e0))/0x2+parseInt(uX(0x250))/0x3+parseInt(uX(0x206))/0x4+parseInt(uX(0x21b))/0x5+-parseInt(uX(0x25c))/0x6*(-parseInt(uX(0x195))/0x7)+parseInt(uX(0x242))/0x8*(-parseInt(uX(0x1d9))/0x9);if(M===z)break;else D['push'](D['shift']());}catch(H){D['push'](D['shift']());}}}(a1u,0xcc321));var __createBinding=this&&this[a1uR(0x189)]||(Object['create']?function(u,z,D,M){const ub=a1uR;if(M===undefined)M=D;var H=Object[ub(0x233)](z,D);(!H||(ub(0x258)in H?!z['__esModule']:H['writable']||H[ub(0x1ae)]))&&(H={'enumerable':!![],'get':function(){return z[D];}}),Object[ub(0x21f)](u,M,H);}:function(u,z,D,M){if(M===undefined)M=D;u[M]=z[D];}),__setModuleDefault=this&&this['__setModuleDefault']||(Object['create']?function(u,z){const uA=a1uR;Object[uA(0x21f)](u,uA(0x1d2),{'enumerable':!![],'value':z});}:function(u,z){const uo=a1uR;u[uo(0x1d2)]=z;}),__importStar=this&&this[a1uR(0x251)]||function(u){const ud=a1uR;if(u&&u[ud(0x266)])return u;var z={};if(u!=null){for(var D in u)if(D!==ud(0x1d2)&&Object['prototype'][ud(0x1b7)][ud(0x227)](u,D))__createBinding(z,u,D);}return __setModuleDefault(z,u),z;},__awaiter=this&&this[a1uR(0x1b1)]||function(u,z,D,M){function H(O){return O instanceof D?O:new D(function(t){t(O);});}return new(D||(D=Promise))(function(O,t){const uy=a1z;function g(N){const uK=a1z;try{h(M[uK(0x21a)](N));}catch(Z){t(Z);}}function T(N){try{h(M['throw'](N));}catch(Z){t(Z);}}function h(N){const uw=a1z;N['done']?O(N[uw(0x257)]):H(N[uw(0x257)])[uw(0x244)](g,T);}h((M=M[uy(0x19a)](u,z||[]))['next']());});},__importDefault=this&&this[a1uR(0x221)]||function(u){const uk=a1uR;return u&&u[uk(0x266)]?u:{'default':u};};Object[a1uR(0x21f)](exports,a1uR(0x266),{'value':!![]}),exports[a1uR(0x214)]=void 0x0;const js_client_1=require(a1uR(0x203)),commander_1=__importDefault(require('commander')),fs_1=__importDefault(require('fs')),ajv_1=__importDefault(require('ajv')),chalk_1=__importDefault(require('chalk')),_=__importStar(require(a1uR(0x1f2))),contextCommands_1=require('./context/contextCommands'),utils_1=require('./utils'),defaults=__importStar(require('./defaults')),inquirer_helper_1=require(a1uR(0x1ee)),console_format_helpers_1=require(a1uR(0x1fa)),command_overview_1=require(a1uR(0x223)),port_forward_1=require(a1uR(0x260)),exec_1=require(a1uR(0x1ba)),logs_1=require('./logs'),metrics_1=require(a1uR(0x24c)),yaml=require(a1uR(0x1be)),pgk=require(a1uR(0x1b2)),getProgram=u=>{const ul=a1uR,z=new commander_1[(ul(0x1d2))][(ul(0x1da))]('northflank');z[ul(0x1cb)](ul(0x23a)),z[ul(0x23e)](!![]),z['version'](ul(0x240)+chalk_1[ul(0x1d2)]['underline'](pgk[ul(0x24d)]),ul(0x1cc),ul(0x236));const D=new js_client_1[(ul(0x1cf))](u,{'throwErrorOnHttpErrorCode':![],'customUserAgent':utils_1[ul(0x19c)]}),M=new contextCommands_1[(ul(0x234))](D),H=new port_forward_1[(ul(0x198))](u),O=new exec_1['CliExec'](u),t=new logs_1['CliLogs'](u),g=new metrics_1[(ul(0x1e4))](u);return z[ul(0x1a4)](H['portFwdCmd']),z['addCommand'](O[ul(0x1ab)]),z[ul(0x1a4)](M['login']),z[ul(0x1a4)](M[ul(0x1e2)]),generateCommands(D,D[ul(0x1d6)],z,t,g),z[ul(0x1a4)]((0x0,command_overview_1[ul(0x1e5)])(z)),z;};exports[a1uR(0x214)]=getProgram,((()=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){const uW=a1uR;try{const u=new js_client_1['ApiClientFileContextProvider']();yield(0x0,utils_1['checkUpdate'])(u);const z=(0x0,exports[uW(0x214)])(u);yield z[uW(0x247)](process[uW(0x273)]);}catch(D){(0x0,utils_1[uW(0x1dd)])('Error\x20occured\x20while\x20trying\x20to\x20run\x20command,\x20error:\x20'+D[uW(0x1c4)]),process['argv'][uW(0x1b9)](M=>M===uW(0x1db))&&console[uW(0x1f3)](D),process['exitCode']=0x1;}}))());function a1u(){const us=['error','requiredPermissions','subdomainId','3022794mBvwzB','askForJobRun','contexts','API\x20request\x20failed\x0a\x09Message:\x20','CliMetrics','getCommandOverview','repository','credentialId','url','yml','plans','aliases','job','docsTagsPath','./inquirer-helper','required','svc','upperFirst','lodash','log','askForSubdomain','includes','projects','delete','templateRunId','getLogsCommand','./formatting/console-format-helpers','VERBOSE:\x20Request\x20body\x20->\x20','=>\x20running\x20command\x20with:\x20','OPTIONAL:\x20','addon','match\x20exactly\x20one\x20schema\x20in\x20oneOf','askForAddon','path','clearLine','@northflank/js-client','runId','runtimeFiles/additionalProperties','2453200KZTjCO','-f,\x20--file\x20<file-path>','cursor','asyncSequential','askConfirm','askForVolume','map','askForPipeline','secretId','isString','getCurrentServiceName','defaults','green','askForJob','getProgram','File\x20to\x20load\x20resource\x20json\x20from','askForLogSink','force','service','name','next','21085smpcpf','list','query','branch','defineProperty','bind','__importDefault','option','./formatting/command-overview','contextProvider','parse','region','call','brn','validate','entries','custom-columns=','JSON-formatted\x20resource\x20definition,\x20takes\x20precedence\x20over\x20\x22--file\x22','template','handleYamlOutput','addons','invoices','forEach','backupId','getOwnPropertyDescriptor','CliContext','existsSync','Print\x20the\x20current\x20version\x20of\x20the\x20Northflank\x20cli','credentials','volumes','status','Manage\x20your\x20Northflank\x20resources\x20from\x20the\x20command\x20line','moveCursor','startsWith','toString','enablePositionalOptions','printAsTable','Northflank\x20cli\x20version:\x20','api.','13354312icwIwc','propToType','then','details','join','parseAsync','stdout','domain','split','grey','./metrics','version','askForService','secret','3198873JraokD','__importStar','safeLoad','opt','credential','keys',',\x20-','value','get','volume','setPathVars','getCommand','6ptCdHx','length','getMetricsCommand','after','./port-forward','templates','\x20--','/docs/v1/api/','assign','templateId','__esModule','runs','Update\x20Northflank\x20','getCurrentJobName','logSinkId','errors','askForTemplate','project','\x0a>\x20Token\x20permissions\x20required:\x20','inv','askForAddonBackup','retrievePayloadViaInteractiveCli','invoice','argv','__createBinding','action','addonId','toLowerCase','VERBOSE:\x20Using\x20endpoint\x20->\x20','services','has','isEqual','getOwnPropertyNames','backups','Documentation:\x20','repositories','1700608rNMeZk','domainId','some','CliPortForward','toUpperCase','apply','Unknown\x20input\x20file\x20type:\x20','customUserAgent','Unknown\x20input\x20format.\x20Not\x20valid\x20json\x20and\x20not\x20valid\x20yaml.','omit','base','output','askForBuild','vol','projectId','addCommand','sort','askForDomain','json','replace','pln','\x20properties','execCmd','pipelineId','filter','configurable','Resource\x20was\x20not\x20deleted.','buildId','__awaiter','../package.json','Failed\x20to\x20validate\x20input\x20(schema\x20mismatch):\x0a','body','addHelpText','kebabCase','hasOwnProperty','932475cNmOsE','find','./exec','resource','adn','warning','js-yaml','-i,\x20--input\x20<resource-def>','tpl','\x20Northflank\x20resources','Failed\x20to\x20validate\x20input\x20(incorrect\x20format):\x20','\x0a\x09details\x20:','message','set','stringify','jobId','host','opts','File\x20does\x20not\x20exist:\x20','description','-v,\x20--version','serviceId','count','ApiClient','assertContextExisting','regions','default','verbose','repo','endsWith','endpoints','method','InquirerHelper','9wAcLLT','Command','--verbose','file'];a1u=function(){return us;};return a1u();}function isListCommand(u){const uF=a1uR,z=[['get',uF(0x1fe),uF(0x192)],[uF(0x258),uF(0x1ec),uF(0x267)]];return u[uF(0x1b9)](D=>D===uF(0x21c))||z['some'](D=>_['isEqual'](u,D));}function generateCommands(u,z,D,M,H,O=defaults[a1uR(0x211)],t=[]){const uI=a1uR,g=new inquirer_helper_1[(uI(0x1d8))](new js_client_1['ApiClient'](u[uI(0x224)],{'throwErrorOnHttpErrorCode':!![],'customUserAgent':utils_1['customUserAgent']}));function T(X,R){const uq=uI;return X[uq(0x1ef)]!==![]&&R===undefined;}function h(X,R){const ue=uI,{opt:b,name:A}=X,o=b[ue(0x1d2)],d=T(b,o),K=F=>F[ue(0x25d)]>0x1?'--'+F:'-'+F,w=b===null||b===void 0x0?void 0x0:b['alias'],y=w?_['isArray'](w)?'-'+(w===null||w===void 0x0?void 0x0:w[ue(0x20c)](F=>K(F))['join'](ue(0x256)))+',':''+K(w):'',k=d?'':ue(0x1fd),l=typeof b['type']==='boolean'?y+'\x20--'+A:y+ue(0x262)+A+'\x20<'+A[ue(0x199)]()+'>',W=k+b[ue(0x1cb)];R[ue(0x222)](l,W,o);}function N(){const uQ=uI;if(D['commands'][uQ(0x197)](X=>X[uQ(0x219)]()==='logs'))return;_[uQ(0x190)](t,[uQ(0x258),uQ(0x218)])&&(D[uQ(0x1a4)](M[uQ(0x1f9)]('service')),D[uQ(0x1a4)](H[uQ(0x25e)](uQ(0x218))),D[uQ(0x1a4)](M[uQ(0x1f9)](uQ(0x218),!![])),D[uQ(0x1a4)](H['getMetricsCommand'](uQ(0x218),!![]))),_[uQ(0x190)](t,[uQ(0x258),'job'])&&(D[uQ(0x1a4)](M[uQ(0x1f9)](uQ(0x1ec))),D['addCommand'](H[uQ(0x25e)](uQ(0x1ec))),D[uQ(0x1a4)](M[uQ(0x1f9)]('job',!![])),D[uQ(0x1a4)](H[uQ(0x25e)](uQ(0x1ec),!![]))),_[uQ(0x190)](t,['get',uQ(0x1fe)])&&(D[uQ(0x1a4)](M[uQ(0x1f9)](uQ(0x1fe))),D[uQ(0x1a4)](H[uQ(0x25e)]('addon')));}return Object[uI(0x191)](O)['forEach'](X=>{const uf=uI,R=z[X],b=O[X],A=t['concat']([X]);function o(q,e){const ur=a1z,Q=Object['getOwnPropertyNames'](q||{});Q[ur(0x20c)](r=>{return{'name':r,'opt':q[r]};})[ur(0x1a5)]((r,i)=>!T(r[ur(0x253)])?!T(i[ur(0x253)])?0x0:0x1:-0x1)[ur(0x231)](r=>{h(r,e);});}function d(q,e){const ui=a1z,Q=[[ui(0x26d),ui(0x1f6),'prj'],[ui(0x218),ui(0x18e),ui(0x1f0)],[ui(0x237),ui(0x254),'cred'],[ui(0x1fe),ui(0x22f),ui(0x1bc)],['job','jobs'],['plan',ui(0x1ea),ui(0x1a9)],[ui(0x226),ui(0x1d1),'rgn'],['domain','domains','dmn'],[ui(0x24f),'secrets','scrt'],[ui(0x238),ui(0x259),ui(0x1a2)],['branches',ui(0x21e),ui(0x228)],[ui(0x272),ui(0x230),ui(0x26f)],[ui(0x22d),ui(0x261),ui(0x1c0)],['repos',ui(0x1e6),ui(0x194),ui(0x1d4)]],r=Q[ui(0x1b9)](i=>i[ui(0x1f5)](e));if(r!==undefined)q[ui(0x1eb)](r[ui(0x1ad)](i=>i!==e));}function K(q){var e,Q;return __awaiter(this,void 0x0,void 0x0,function*(){const uU=a1z,r={},{contextProvider:i}=u,U=A[uU(0x1f5)](uU(0x1f7)),L=q['noDefaults']===!![];function C(j,J,a){var V,m;return __awaiter(this,void 0x0,void 0x0,function*(){const uL=a1z;if(_[uL(0x18f)]((m=(V=b[uL(0x253)])===null||V===void 0x0?void 0x0:V[uL(0x201)])!==null&&m!==void 0x0?m:{},j)){const B=!L&&!U&&a?a():undefined,f=q[j]||B||(yield J());_['set'](r,j,f);}});}return yield(0x0,utils_1[uU(0x209)])(Object[uU(0x22a)]((Q=(e=b['opt'])===null||e===void 0x0?void 0x0:e[uU(0x201)])!==null&&Q!==void 0x0?Q:{}),([j,J])=>__awaiter(this,void 0x0,void 0x0,function*(){const uC=uU,a=r===null||r===void 0x0?void 0x0:r[uC(0x1a3)],V=r===null||r===void 0x0?void 0x0:r[uC(0x265)];switch(j){case uC(0x1a3):return yield C(uC(0x1a3),g['askForProject']['bind'](g),i['getCurrentProjectName'][uC(0x220)](i));case uC(0x1cd):return yield C(uC(0x1cd),g[uC(0x24e)](a)[uC(0x220)](g),i[uC(0x210)][uC(0x220)](i));case uC(0x18b):return yield C(uC(0x18b),g[uC(0x200)](a)[uC(0x220)](g));case uC(0x1c7):return yield C('jobId',g[uC(0x213)](a)[uC(0x220)](g),i[uC(0x269)][uC(0x220)](i));case uC(0x204):return yield C(uC(0x204),g[uC(0x1e1)](r[uC(0x1c7)],a)['bind'](g));case uC(0x20e):return yield C(uC(0x20e),g['askForSecret'](a)['bind'](g));case uC(0x249):case uC(0x196):return yield C(uC(0x249),g[uC(0x1a6)][uC(0x220)](g));case uC(0x1e7):return yield C('credentialId',g['askForCredentials'][uC(0x220)](g));case'volumeId':return yield C('volumeId',g[uC(0x20b)](a)['bind'](g));case'subdomain':return yield C('subdomain',g['askForSubdomain'](r[uC(0x249)])[uC(0x220)](g));case uC(0x1df):return yield C(uC(0x1df),g[uC(0x1f4)](r[uC(0x196)])[uC(0x220)](g));case uC(0x232):return yield C(uC(0x232),g[uC(0x270)](a,r['addonId'])[uC(0x220)](g));case'buildId':return yield C(uC(0x1b0),g[uC(0x1a1)](a,r[uC(0x1cd)],r[uC(0x1c7)])[uC(0x220)](g));case uC(0x265):return yield C('templateId',g[uC(0x26c)]()['bind'](g));case uC(0x1f8):return yield C(uC(0x1f8),g['askForTemplateRun'](V)[uC(0x220)](g));case uC(0x26a):return yield C(uC(0x26a),g[uC(0x216)]()[uC(0x220)](g));case uC(0x1ac):return yield C(uC(0x1ac),g[uC(0x20d)](a)[uC(0x220)](g));default:return yield C(j,g['askGeneric'](j,J===null||J===void 0x0?void 0x0:J['description'])['bind'](g));}})),r;});}function w(q){var e,Q;return __awaiter(this,void 0x0,void 0x0,function*(){const uj=a1z,r={},i=Object[uj(0x255)]((Q=(e=b[uj(0x253)])===null||e===void 0x0?void 0x0:e[uj(0x21d)])!==null&&Q!==void 0x0?Q:{});return yield(0x0,utils_1[uj(0x209)])(i,U=>__awaiter(this,void 0x0,void 0x0,function*(){const uJ=uj;if(q[U]!==undefined)return q[U];const L={},{required:C,schema:j}=b[uJ(0x253)][uJ(0x21d)][U];return yield g[uJ(0x243)]([''+U],j,L,C),L[U]!==undefined&&_[uJ(0x1c5)](r,U,L[U]),L;})),r;});}function y(){const ua=a1z;switch(A[0x0]){case'get':return'Get\x20information\x20about\x20Northflank\x20'+(A[0x1]||ua(0x1bb))+'s';case'update':return ua(0x268)+(A[0x1]||ua(0x1bb))+ua(0x1aa);default:return _[ua(0x1f1)](X)+ua(0x1c1);}}function k(q,e){const uV=a1z;var Q,r,i,U,L,C;if(!e){const G=(0x0,utils_1[uV(0x25b)])()[uV(0x219)](_[uV(0x1b6)](X))['description'](y());return d(G,X),G;}const j=(q===null||q===void 0x0?void 0x0:q[uV(0x1de)])?chalk_1['default'][uV(0x24b)](uV(0x26e)+q[uV(0x1de)]):'',J=u[uV(0x224)]['getCurrentContext'](),a=J!==undefined&&((Q=b===null||b===void 0x0?void 0x0:b[uV(0x253)])===null||Q===void 0x0?void 0x0:Q[uV(0x1ed)])!==undefined,V=J===null||J===void 0x0?void 0x0:J[uV(0x1c8)][uV(0x1a8)](uV(0x241),''),m=a?uV(0x193)+V+uV(0x263)+((r=b===null||b===void 0x0?void 0x0:b['opt'])===null||r===void 0x0?void 0x0:r[uV(0x1ed)]):'',B=(q===null||q===void 0x0?void 0x0:q[uV(0x1cb)])||'',f=(0x0,utils_1[uV(0x25b)])(!![])[uV(0x219)](_[uV(0x1b6)](X))[uV(0x1cb)](B)[uV(0x1b5)](uV(0x25f),[j,m][uV(0x246)]('\x0a'));return d(f,X),((i=b[uV(0x253)])===null||i===void 0x0?void 0x0:i[uV(0x1b4)])&&(f['option'](uV(0x207),uV(0x215)),f[uV(0x222)](uV(0x1bf),uV(0x22c))),o((U=b['opt'])===null||U===void 0x0?void 0x0:U[uV(0x201)],f),o((L=b[uV(0x253)])===null||L===void 0x0?void 0x0:L[uV(0x21d)],f),o((C=b['opt'])===null||C===void 0x0?void 0x0:C[uV(0x19f)],f),f[uV(0x18a)](()=>__awaiter(this,void 0x0,void 0x0,function*(){const um=uV;var Y,P,s,v;(0x0,utils_1[um(0x1d0)])(u);const x=f[um(0x1c9)](),p=x===null||x===void 0x0?void 0x0:x[um(0x1a0)],n=p===um(0x1a7),c=p==='yaml'||p===um(0x1e9),S=yield K(x);g[um(0x25a)](S);const u0=yield w(x),u1=Object['keys']((P=(Y=b[um(0x253)])===null||Y===void 0x0?void 0x0:Y['path'])!==null&&P!==void 0x0?P:{})['map'](u6=>u6+'='+chalk_1[um(0x1d2)][um(0x212)](S[u6]))[um(0x246)](',\x20');if(u1[um(0x25d)]>0x0&&!n&&!c){const u6=um(0x1fc)+u1;console[um(0x1f3)](u6);}const u2=((s=b[um(0x253)])===null||s===void 0x0?void 0x0:s[um(0x1b4)])?yield E(x,b,A):undefined;if(!x[um(0x217)]&&A['includes'](um(0x1f7))&&!(yield g['deleteWarningPrompt']())){(0x0,utils_1[um(0x1bd)])(um(0x1af));return;}function u3(u7,u8=![],u9=0x0){return __awaiter(this,void 0x0,void 0x0,function*(){const uB=a1z,{data:uu,request:uz,error:uD,pagination:uM}=yield R['call']({'parameters':S,'options':Object[uB(0x264)](Object[uB(0x264)]({},u0),{'cursor':u7}),'data':u2});(x===null||x===void 0x0?void 0x0:x[uB(0x1d3)])&&(console['log'](uB(0x18d)+uz[uB(0x1d7)]+':'+uz[uB(0x1e8)]),console[uB(0x1f3)](uB(0x1fb)+uz['body']));if(uD){const uH=uD['details']?uB(0x1c3)+JSON[uB(0x1c6)](uD[uB(0x245)]):'',uO=(uD===null||uD===void 0x0?void 0x0:uD['id'])?',\x20NF\x20error\x20id:\x20'+uD['id']:'',ut='(HTTP\x20status\x20code:\x20'+uD[uB(0x239)]+uO+')';throw new Error(uB(0x1e3)+uD[uB(0x1c4)]+'\x20'+ut+uH);}if(!(x===null||x===void 0x0?void 0x0:x['quiet'])){if(n)(0x0,console_format_helpers_1['handleJsonOutput'])(x===null||x===void 0x0?void 0x0:x[uB(0x1a0)],uu);else{if(c)(0x0,console_format_helpers_1[uB(0x22e)])(x===null||x===void 0x0?void 0x0:x[uB(0x1a0)],uu);else{if(isListCommand(A)){const ug=(p===null||p===void 0x0?void 0x0:p[uB(0x23c)](uB(0x22b)))?p['replace'](uB(0x22b),'')['split'](',')[uB(0x20c)](uE=>uE[uB(0x18c)]()):undefined,uT=A[A[uB(0x25d)]-0x1],uh=''+uT+(uT[uB(0x1d5)]('s')?'':'s'),uN=_['upperFirst'](uh),uZ=_[uB(0x18f)](uu,uh)?uu[uh]:uu;(0x0,console_format_helpers_1[uB(0x23f)])(uZ,uN,ug,u8,u9);}else console[uB(0x1f3)]((0x0,console_format_helpers_1['consoleFormat'])(uu));}}}return uM;});}let u4=yield u3(),u5=0x0;if(!x['quiet']&&(u4===null||u4===void 0x0?void 0x0:u4[um(0x208)]))while(u4[um(0x208)]){const u7=yield g[um(0x20a)]('there\x20are\x20more\x20rows,\x20load?');u7&&(process[um(0x248)][um(0x23b)](0x0,-0x1),process[um(0x248)][um(0x202)](0x1),u5+=(v=u4[um(0x1ce)])!==null&&v!==void 0x0?v:0x0,u4=yield u3(u4[um(0x208)],!![],u5));}})),f;}const l=_['has'](b,uf(0x253)),W=R,F=k(W,l);D['addCommand'](F),N();const I=_[uf(0x19e)](b,'opt');Object[uf(0x255)](I)[uf(0x25d)]>0x0&&generateCommands(u,R,F,M,H,I,A);});function Z(X,R,b){return __awaiter(this,void 0x0,void 0x0,function*(){const uG=a1z,{input:A,file:o}=X;if(A!==undefined)try{return JSON[uG(0x225)](A);}catch(K){try{return yaml[uG(0x252)](A);}catch(w){throw new Error(uG(0x19d));}}if(o!==undefined){if(!fs_1[uG(0x1d2)][uG(0x235)](o))throw new Error(uG(0x1ca)+o);const y=fs_1['default']['readFileSync'](o)[uG(0x23d)]();let k;try{if(_[uG(0x20f)](y)){if(X[uG(0x1dc)][uG(0x1d5)]('.json'))k=JSON[uG(0x225)](y);else{if(X['file'][uG(0x1d5)]('.yaml')||X[uG(0x1dc)][uG(0x1d5)](uG(0x1e9)))k=yaml[uG(0x252)](y);else throw new Error(uG(0x19b)+X[uG(0x1dc)][uG(0x24a)]('.')['pop']());}}else k=y;return k;}catch(l){throw new Error(uG(0x1c2)+l[uG(0x1c4)]);}}return yield g[uG(0x271)](R,{'cmdPath':b});});}function E(X,R,b){var A;return __awaiter(this,void 0x0,void 0x0,function*(){const uY=a1z,o=yield Z(X,R,b),d=new ajv_1[(uY(0x1d2))]({'allErrors':!![],'keywords':['example'],'validateFormats':![],'strict':![],'unicodeRegExp':![]});let K=![];try{K=d[uY(0x229)](R['opt'][uY(0x1b4)],o);}catch(y){if(y[uY(0x1c4)]['includes'](uY(0x205)))K=!![];else throw y;}const w=(A=d===null||d===void 0x0?void 0x0:d['errors'])===null||A===void 0x0?void 0x0:A[uY(0x1ad)](k=>{const uP=uY;var l;return!((l=k===null||k===void 0x0?void 0x0:k['message'])===null||l===void 0x0?void 0x0:l[uP(0x1f5)](uP(0x1ff)));});if(!K&&w!==undefined&&(w===null||w===void 0x0?void 0x0:w[uY(0x25d)])>0x0)throw new Error(uY(0x1b3)+JSON['stringify'](d[uY(0x26b)],null,'\x20'));return o;});}}
|
|
2
|
+
'use strict';const a1IR=a1z;function a1I(){const Iq=['repos','projects','Resource\x20was\x20not\x20deleted.','next','askForTemplateRun','CliLogs','\x20properties','details','apply','Print\x20the\x20current\x20version\x20of\x20the\x20Northflank\x20cli','VERBOSE:\x20Request\x20body\x20->\x20','delete','filter','branches','version','forEach','invoices','update','chalk','option','entries','__esModule','./inquirer-helper','serviceId','askForService','InquirerHelper','consoleFormat','askForTemplate','file','assertContextExisting','askForVolume','948292GRFAEs','includes','readFileSync','region','8981316IQuxba','addons','custom-columns=','vol','safeLoad','parse','clearLine','backups','join','path','prototype','lodash','after','message','base','method',',\x20-','plan','query','pipelineId','project','alias','CliExec','dmn','cred','\x20--','./metrics','Unknown\x20input\x20format.\x20Not\x20valid\x20json\x20and\x20not\x20valid\x20yaml.','hasOwnProperty','upperFirst','warning','addonId','toString','omit','description','configurable','body','verbose','File\x20to\x20load\x20resource\x20json\x20from','count','5CceVMO','ajv','resource','askForBuild','repository','=>\x20running\x20command\x20with:\x20','-i,\x20--input\x20<resource-def>','buildId','name','stringify','VERBOSE:\x20Using\x20endpoint\x20->\x20','writable','login','prj','requiredPermissions','getCommand','repo','host','noDefaults','keys','domain','6rxWyRH','subdomain','askForDomain','argv','handleYamlOutput','find',',\x20NF\x20error\x20id:\x20','isEqual','.json','output','defineProperty','assign','./defaults','retrievePayloadViaInteractiveCli','create','JSON-formatted\x20resource\x20definition,\x20takes\x20precedence\x20over\x20\x22--file\x22','get','quiet','propToType','kebabCase','logSinkId','addon','9568880XmJccI','addHelpText','templates','sort','opt','value','askForJob','credential','json','__createBinding','split','has','length','/docs/v1/api/','logs','getProgram','brn','isArray','runId','subdomainId','runtimeFiles/additionalProperties','commands','northflank','projectId','891278OxowZG','55090MTGOdz','domains','backupId','services','credentials','--verbose','contexts','boolean','askForCredentials','(HTTP\x20status\x20code:\x20','commander','enablePositionalOptions','replace','throw','askGeneric','templateRunId','set','4832992LtqFeP','CliPortForward','getLogsCommand','call','getOwnPropertyNames','there\x20are\x20more\x20rows,\x20load?','contextProvider','execCmd','example','job','78849jdcNFk','concat','secret','errors','type','opts','bind','askForAddon','domainId','askForSecret','addCommand','ApiClient','yml','exitCode','log','Unknown\x20input\x20file\x20type:\x20','setPathVars','ApiClientFileContextProvider','underline','90bNxxeS','repositories','./port-forward','default','CliMetrics','credentialId','CliContext','__importStar','map','cursor','getMetricsCommand','@northflank/js-client','existsSync','\x0a>\x20Token\x20permissions\x20required:\x20','-f,\x20--file\x20<file-path>','svc','branch','url','Failed\x20to\x20validate\x20input\x20(schema\x20mismatch):\x0a','yaml','jobId','Documentation:\x20','secretId','handleJsonOutput','./logs','inv','validate','__awaiter','portFwdCmd','\x20Northflank\x20resources','then','Northflank\x20cli\x20version:\x20','secrets','./formatting/console-format-helpers','service','./exec','some','checkUpdate','\x0a\x09details\x20:','customUserAgent','getCommandOverview','templateId','parseAsync','OPTIONAL:\x20','endsWith','docsTagsPath','__importDefault'];a1I=function(){return Iq;};return a1I();}(function(I,z){const IL=a1z,g=I();while(!![]){try{const Z=parseInt(IL(0x21c))/0x1+-parseInt(IL(0x200))/0x2*(-parseInt(IL(0x2be))/0x3)+-parseInt(IL(0x27d))/0x4*(-parseInt(IL(0x2a9))/0x5)+parseInt(IL(0x22f))/0x6*(-parseInt(IL(0x201))/0x7)+-parseInt(IL(0x212))/0x8+parseInt(IL(0x281))/0x9+-parseInt(IL(0x2d4))/0xa;if(Z===z)break;else g['push'](g['shift']());}catch(y){g['push'](g['shift']());}}}(a1I,0x806ee));var __createBinding=this&&this[a1IR(0x1f1)]||(Object[a1IR(0x2cc)]?function(I,z,g,Z){const Iw=a1IR;if(Z===undefined)Z=g;var y=Object['getOwnPropertyDescriptor'](z,g);(!y||(Iw(0x2ce)in y?!z['__esModule']:y[Iw(0x2b4)]||y[Iw(0x2a4)]))&&(y={'enumerable':!![],'get':function(){return z[g];}}),Object[Iw(0x2c8)](I,Z,y);}:function(I,z,g,Z){if(Z===undefined)Z=g;I[Z]=z[g];}),__setModuleDefault=this&&this['__setModuleDefault']||(Object[a1IR(0x2cc)]?function(I,z){const IQ=a1IR;Object[IQ(0x2c8)](I,'default',{'enumerable':!![],'value':z});}:function(I,z){const IK=a1IR;I[IK(0x232)]=z;}),__importStar=this&&this[a1IR(0x236)]||function(I){const IJ=a1IR;if(I&&I[IJ(0x273)])return I;var z={};if(I!=null){for(var g in I)if(g!==IJ(0x232)&&Object[IJ(0x28b)][IJ(0x29d)]['call'](I,g))__createBinding(z,I,g);}return __setModuleDefault(z,I),z;},__awaiter=this&&this[a1IR(0x24a)]||function(I,z,g,Z){function y(i){return i instanceof g?i:new g(function(t){t(i);});}return new(g||(g=Promise))(function(i,t){const IC=a1z;function u(G){const Ij=a1z;try{M(Z[Ij(0x261)](G));}catch(h){t(h);}}function v(G){const IF=a1z;try{M(Z[IF(0x20e)](G));}catch(h){t(h);}}function M(G){const Is=a1z;G['done']?i(G[Is(0x2d9)]):y(G[Is(0x2d9)])[Is(0x24d)](u,v);}M((Z=Z[IC(0x266)](I,z||[]))['next']());});},__importDefault=this&&this[a1IR(0x25d)]||function(I){const If=a1IR;return I&&I[If(0x273)]?I:{'default':I};};Object[a1IR(0x2c8)](exports,a1IR(0x273),{'value':!![]}),exports[a1IR(0x1f7)]=void 0x0;const js_client_1=require(a1IR(0x23a)),commander_1=__importDefault(require(a1IR(0x20b))),fs_1=__importDefault(require('fs')),ajv_1=__importDefault(require(a1IR(0x2aa))),chalk_1=__importDefault(require(a1IR(0x270))),_=__importStar(require(a1IR(0x28c))),contextCommands_1=require('./context/contextCommands'),utils_1=require('./utils'),defaults=__importStar(require(a1IR(0x2ca))),inquirer_helper_1=require(a1IR(0x274)),console_format_helpers_1=require(a1IR(0x250)),command_overview_1=require('./formatting/command-overview'),port_forward_1=require(a1IR(0x231)),exec_1=require(a1IR(0x252)),logs_1=require(a1IR(0x247)),metrics_1=require(a1IR(0x29b)),yaml=require('js-yaml'),pgk=require('../package.json'),getProgram=I=>{const Ix=a1IR,z=new commander_1[(Ix(0x232))]['Command'](Ix(0x1fe));z[Ix(0x2a3)]('Manage\x20your\x20Northflank\x20resources\x20from\x20the\x20command\x20line'),z[Ix(0x20c)](!![]),z[Ix(0x26c)](Ix(0x24e)+chalk_1[Ix(0x232)][Ix(0x22e)](pgk[Ix(0x26c)]),'-v,\x20--version',Ix(0x267));const g=new js_client_1[(Ix(0x227))](I,{'throwErrorOnHttpErrorCode':![],'customUserAgent':utils_1[Ix(0x256)]}),Z=new contextCommands_1[(Ix(0x235))](g),y=new port_forward_1[(Ix(0x213))](I),i=new exec_1[(Ix(0x297))](I),t=new logs_1[(Ix(0x263))](I),u=new metrics_1[(Ix(0x233))](I);return z[Ix(0x226)](y[Ix(0x24b)]),z[Ix(0x226)](i[Ix(0x219)]),z[Ix(0x226)](Z[Ix(0x2b5)]),z[Ix(0x226)](Z[Ix(0x207)]),generateCommands(g,g['endpoints'],z,t,u),z[Ix(0x226)]((0x0,command_overview_1[Ix(0x257)])(z)),z;};exports[a1IR(0x1f7)]=getProgram,((()=>__awaiter(void 0x0,void 0x0,void 0x0,function*(){const Io=a1IR;try{const I=new js_client_1[(Io(0x22d))]();yield(0x0,utils_1[Io(0x254)])(I);const z=(0x0,exports['getProgram'])(I);yield z[Io(0x259)](process[Io(0x2c1)]);}catch(g){(0x0,utils_1['error'])('Error\x20occured\x20while\x20trying\x20to\x20run\x20command,\x20error:\x20'+g[Io(0x28e)]),process['argv'][Io(0x2c3)](Z=>Z===Io(0x206))&&console[Io(0x22a)](g),process[Io(0x229)]=0x1;}}))());function isListCommand(I){const Id=a1IR,z=[[Id(0x2ce),'addon',Id(0x288)],[Id(0x2ce),Id(0x21b),'runs']];return I['find'](g=>g==='list')||z['some'](g=>_[Id(0x2c5)](I,g));}function a1z(I,z){const g=a1I();return a1z=function(Z,y){Z=Z-0x1ee;let i=g[Z];return i;},a1z(I,z);}function generateCommands(I,z,g,Z,y,i=defaults['defaults'],t=[]){const In=a1IR,u=new inquirer_helper_1[(In(0x277))](new js_client_1[(In(0x227))](I['contextProvider'],{'throwErrorOnHttpErrorCode':!![],'customUserAgent':utils_1[In(0x256)]}));function v(L,R){return L['required']!==![]&&R===undefined;}function M(L,R){const IA=In,{opt:w,name:Q}=L,K=w[IA(0x232)],J=v(w,K),j=o=>o['length']>0x1?'--'+o:'-'+o,F=w===null||w===void 0x0?void 0x0:w[IA(0x296)],s=F?_[IA(0x1f9)](F)?'-'+(F===null||F===void 0x0?void 0x0:F['map'](o=>j(o))[IA(0x289)](IA(0x291)))+',':''+j(F):'',C=J?'':IA(0x25a),f=typeof w[IA(0x220)]===IA(0x208)?s+IA(0x29a)+Q:s+IA(0x29a)+Q+'\x20<'+Q['toUpperCase']()+'>',x=C+w[IA(0x2a3)];R[IA(0x271)](f,x,K);}function G(){const IT=In;if(g[IT(0x1fd)][IT(0x253)](L=>L[IT(0x2b1)]()===IT(0x1f6)))return;_['isEqual'](t,['get',IT(0x251)])&&(g[IT(0x226)](Z[IT(0x214)](IT(0x251))),g[IT(0x226)](y[IT(0x239)]('service')),g['addCommand'](Z[IT(0x214)]('service',!![])),g[IT(0x226)](y['getMetricsCommand']('service',!![]))),_[IT(0x2c5)](t,[IT(0x2ce),IT(0x21b)])&&(g['addCommand'](Z[IT(0x214)]('job')),g[IT(0x226)](y[IT(0x239)](IT(0x21b))),g[IT(0x226)](Z[IT(0x214)](IT(0x21b),!![])),g[IT(0x226)](y[IT(0x239)](IT(0x21b),!![]))),_[IT(0x2c5)](t,['get',IT(0x2d3)])&&(g['addCommand'](Z[IT(0x214)](IT(0x2d3))),g['addCommand'](y[IT(0x239)](IT(0x2d3))));}return Object[In(0x216)](i)[In(0x26d)](L=>{const Im=In,R=z[L],w=i[L],Q=t[Im(0x21d)]([L]);function K(n,A){const Ib=Im,T=Object['getOwnPropertyNames'](n||{});T[Ib(0x237)](m=>{return{'name':m,'opt':n[m]};})[Ib(0x2d7)]((m,b)=>!v(m['opt'])?!v(b[Ib(0x2d8)])?0x0:0x1:-0x1)[Ib(0x26d)](m=>{M(m,A);});}function J(n,A){const IO=Im,T=[[IO(0x295),IO(0x25f),IO(0x2b6)],['service',IO(0x204),IO(0x23e)],[IO(0x205),IO(0x1ef),IO(0x299)],[IO(0x2d3),IO(0x282),'adn'],[IO(0x21b),'jobs'],[IO(0x292),'plans','pln'],[IO(0x280),'regions','rgn'],['domain',IO(0x202),IO(0x298)],[IO(0x21e),IO(0x24f),'scrt'],['volumes','volume',IO(0x284)],[IO(0x26b),IO(0x23f),IO(0x1f8)],['invoice',IO(0x26e),IO(0x248)],['template',IO(0x2d6),'tpl'],[IO(0x25e),IO(0x2ad),IO(0x230),IO(0x2b9)]],m=T[IO(0x2c3)](b=>b[IO(0x27e)](A));if(m!==undefined)n['aliases'](m[IO(0x26a)](b=>b!==A));}function j(n){var A,T;return __awaiter(this,void 0x0,void 0x0,function*(){const IV=a1z,m={},{contextProvider:b}=I,O=Q[IV(0x27e)](IV(0x269)),V=n[IV(0x2bb)]===!![];function k(N,a,D){var H,Y;return __awaiter(this,void 0x0,void 0x0,function*(){const Ik=a1z;if(_[Ik(0x1f3)]((Y=(H=w[Ik(0x2d8)])===null||H===void 0x0?void 0x0:H[Ik(0x28a)])!==null&&Y!==void 0x0?Y:{},N)){const r=!V&&!O&&D?D():undefined,X=n[N]||r||(yield a());_[Ik(0x211)](m,N,X);}});}return yield(0x0,utils_1['asyncSequential'])(Object[IV(0x272)]((T=(A=w[IV(0x2d8)])===null||A===void 0x0?void 0x0:A[IV(0x28a)])!==null&&T!==void 0x0?T:{}),([N,a])=>__awaiter(this,void 0x0,void 0x0,function*(){const IN=IV,D=m===null||m===void 0x0?void 0x0:m['projectId'],H=m===null||m===void 0x0?void 0x0:m[IN(0x258)];switch(N){case'projectId':return yield k(IN(0x1ff),u['askForProject'][IN(0x222)](u),b['getCurrentProjectName'][IN(0x222)](b));case'serviceId':return yield k(IN(0x275),u[IN(0x276)](D)[IN(0x222)](u),b['getCurrentServiceName'][IN(0x222)](b));case IN(0x2a0):return yield k(IN(0x2a0),u[IN(0x223)](D)[IN(0x222)](u));case'jobId':return yield k('jobId',u[IN(0x1ee)](D)[IN(0x222)](u),b['getCurrentJobName'][IN(0x222)](b));case IN(0x1fa):return yield k('runId',u['askForJobRun'](m[IN(0x243)],D,![])[IN(0x222)](u));case'secretId':return yield k(IN(0x245),u[IN(0x225)](D)[IN(0x222)](u));case'domain':case IN(0x224):return yield k(IN(0x2bd),u[IN(0x2c0)][IN(0x222)](u));case IN(0x234):return yield k(IN(0x234),u[IN(0x209)][IN(0x222)](u));case'volumeId':return yield k('volumeId',u[IN(0x27c)](D)[IN(0x222)](u));case IN(0x2bf):return yield k(IN(0x2bf),u['askForSubdomain'](m[IN(0x2bd)])[IN(0x222)](u));case IN(0x1fb):return yield k(IN(0x1fb),u['askForSubdomain'](m[IN(0x224)])[IN(0x222)](u));case IN(0x203):return yield k(IN(0x203),u['askForAddonBackup'](D,m[IN(0x2a0)])['bind'](u));case IN(0x2b0):return yield k(IN(0x2b0),u[IN(0x2ac)](D,m[IN(0x275)],m[IN(0x243)])['bind'](u));case IN(0x258):return yield k(IN(0x258),u[IN(0x279)]()[IN(0x222)](u));case IN(0x210):return yield k(IN(0x210),u[IN(0x262)](H)['bind'](u));case IN(0x2d2):return yield k('logSinkId',u['askForLogSink']()[IN(0x222)](u));case IN(0x294):return yield k(IN(0x294),u['askForPipeline'](D)[IN(0x222)](u));default:return yield k(N,u[IN(0x20f)](N,a===null||a===void 0x0?void 0x0:a[IN(0x2a3)])['bind'](u));}})),m;});}function F(n){var A,T;return __awaiter(this,void 0x0,void 0x0,function*(){const Ia=a1z,m={},b=Object['keys']((T=(A=w[Ia(0x2d8)])===null||A===void 0x0?void 0x0:A[Ia(0x293)])!==null&&T!==void 0x0?T:{});return yield(0x0,utils_1['asyncSequential'])(b,O=>__awaiter(this,void 0x0,void 0x0,function*(){const ID=Ia;if(n[O]!==undefined)return n[O];const V={},{required:k,schema:N}=w[ID(0x2d8)][ID(0x293)][O];return yield u[ID(0x2d0)]([''+O],N,V,k),V[O]!==undefined&&_[ID(0x211)](m,O,V[O]),V;})),m;});}function s(){const IH=Im;switch(Q[0x0]){case'get':return'Get\x20information\x20about\x20Northflank\x20'+(Q[0x1]||IH(0x2ab))+'s';case IH(0x26f):return'Update\x20Northflank\x20'+(Q[0x1]||'resource')+IH(0x264);default:return _[IH(0x29e)](L)+IH(0x24c);}}function C(n,A){const IY=Im;var T,m,b,O,V,k;if(!A){const l=(0x0,utils_1[IY(0x2b8)])()['name'](_[IY(0x2d1)](L))['description'](s());return J(l,L),l;}const N=(n===null||n===void 0x0?void 0x0:n[IY(0x2b7)])?chalk_1[IY(0x232)]['grey'](IY(0x23c)+n[IY(0x2b7)]):'',a=I[IY(0x218)]['getCurrentContext'](),D=a!==undefined&&((T=w===null||w===void 0x0?void 0x0:w['opt'])===null||T===void 0x0?void 0x0:T[IY(0x25c)])!==undefined,H=a===null||a===void 0x0?void 0x0:a[IY(0x2ba)][IY(0x20d)]('api.',''),Y=D?IY(0x244)+H+IY(0x1f5)+((m=w===null||w===void 0x0?void 0x0:w['opt'])===null||m===void 0x0?void 0x0:m[IY(0x25c)]):'',r=(n===null||n===void 0x0?void 0x0:n[IY(0x2a3)])||'',X=(0x0,utils_1[IY(0x2b8)])(!![])['name'](_[IY(0x2d1)](L))[IY(0x2a3)](r)[IY(0x2d5)](IY(0x28d),[N,Y]['join']('\x0a'));return J(X,L),((b=w[IY(0x2d8)])===null||b===void 0x0?void 0x0:b[IY(0x2a5)])&&(X['option'](IY(0x23d),IY(0x2a7)),X[IY(0x271)](IY(0x2af),IY(0x2cd))),K((O=w['opt'])===null||O===void 0x0?void 0x0:O[IY(0x28a)],X),K((V=w[IY(0x2d8)])===null||V===void 0x0?void 0x0:V['query'],X),K((k=w['opt'])===null||k===void 0x0?void 0x0:k[IY(0x28f)],X),X['action'](()=>__awaiter(this,void 0x0,void 0x0,function*(){const Ir=IY;var S,e,q,E;(0x0,utils_1[Ir(0x27b)])(I);const W=X[Ir(0x221)](),B=W===null||W===void 0x0?void 0x0:W[Ir(0x2c7)],p=B===Ir(0x1f0),c=B===Ir(0x242)||B==='yml',U=yield j(W);u[Ir(0x22c)](U);const I0=yield F(W),I1=Object[Ir(0x2bc)]((e=(S=w[Ir(0x2d8)])===null||S===void 0x0?void 0x0:S['path'])!==null&&e!==void 0x0?e:{})['map'](I6=>I6+'='+chalk_1[Ir(0x232)]['green'](U[I6]))[Ir(0x289)](',\x20');if(I1[Ir(0x1f4)]>0x0&&!p&&!c){const I6=Ir(0x2ae)+I1;console['log'](I6);}const I2=((q=w[Ir(0x2d8)])===null||q===void 0x0?void 0x0:q['body'])?yield h(W,w,Q):undefined;if(!W['force']&&Q[Ir(0x27e)](Ir(0x269))&&!(yield u['deleteWarningPrompt']())){(0x0,utils_1[Ir(0x29f)])(Ir(0x260));return;}function I3(I7,I8=![],I9=0x0){return __awaiter(this,void 0x0,void 0x0,function*(){const IX=a1z,{data:II,request:Iz,error:Ig,pagination:IZ}=yield R[IX(0x215)]({'parameters':U,'options':Object[IX(0x2c9)](Object[IX(0x2c9)]({},I0),{'cursor':I7}),'data':I2});(W===null||W===void 0x0?void 0x0:W[IX(0x2a6)])&&(console[IX(0x22a)](IX(0x2b3)+Iz[IX(0x290)]+':'+Iz[IX(0x240)]),console[IX(0x22a)](IX(0x268)+Iz[IX(0x2a5)]));if(Ig){const Iy=Ig[IX(0x265)]?IX(0x255)+JSON[IX(0x2b2)](Ig[IX(0x265)]):'',Ii=(Ig===null||Ig===void 0x0?void 0x0:Ig['id'])?IX(0x2c4)+Ig['id']:'',It=IX(0x20a)+Ig['status']+Ii+')';throw new Error('API\x20request\x20failed\x0a\x09Message:\x20'+Ig['message']+'\x20'+It+Iy);}if(!(W===null||W===void 0x0?void 0x0:W['quiet'])){if(p)(0x0,console_format_helpers_1[IX(0x246)])(W===null||W===void 0x0?void 0x0:W[IX(0x2c7)],II);else{if(c)(0x0,console_format_helpers_1[IX(0x2c2)])(W===null||W===void 0x0?void 0x0:W[IX(0x2c7)],II);else{if(isListCommand(Q)){const Iu=(B===null||B===void 0x0?void 0x0:B['startsWith'](IX(0x283)))?B[IX(0x20d)]('custom-columns=','')['split'](',')['map'](Ih=>Ih['toLowerCase']()):undefined,Iv=Q[Q[IX(0x1f4)]-0x1],IM=''+Iv+(Iv[IX(0x25b)]('s')?'':'s'),IG=_['upperFirst'](IM),IP=_[IX(0x1f3)](II,IM)?II[IM]:II;(0x0,console_format_helpers_1['printAsTable'])(IP,IG,Iu,I8,I9);}else console['log']((0x0,console_format_helpers_1[IX(0x278)])(II));}}}return IZ;});}let I4=yield I3(),I5=0x0;if(!W[Ir(0x2cf)]&&(I4===null||I4===void 0x0?void 0x0:I4['cursor']))while(I4['cursor']){const I7=yield u['askConfirm'](Ir(0x217));I7&&(process['stdout']['moveCursor'](0x0,-0x1),process['stdout'][Ir(0x287)](0x1),I5+=(E=I4[Ir(0x2a8)])!==null&&E!==void 0x0?E:0x0,I4=yield I3(I4[Ir(0x238)],!![],I5));}})),X;}const f=_[Im(0x1f3)](w,Im(0x2d8)),x=R,o=C(x,f);g[Im(0x226)](o),G();const d=_[Im(0x2a2)](w,Im(0x2d8));Object[Im(0x2bc)](d)[Im(0x1f4)]>0x0&&generateCommands(I,R,o,Z,y,d,Q);});function P(L,R,w){return __awaiter(this,void 0x0,void 0x0,function*(){const Il=a1z,{input:Q,file:K}=L;if(Q!==undefined)try{return JSON['parse'](Q);}catch(J){try{return yaml[Il(0x285)](Q);}catch(j){throw new Error(Il(0x29c));}}if(K!==undefined){if(!fs_1[Il(0x232)][Il(0x23b)](K))throw new Error('File\x20does\x20not\x20exist:\x20'+K);const F=fs_1['default'][Il(0x27f)](K)[Il(0x2a1)]();let s;try{if(_['isString'](F)){if(L['file']['endsWith'](Il(0x2c6)))s=JSON[Il(0x286)](F);else{if(L[Il(0x27a)]['endsWith']('.yaml')||L[Il(0x27a)][Il(0x25b)](Il(0x228)))s=yaml[Il(0x285)](F);else throw new Error(Il(0x22b)+L[Il(0x27a)][Il(0x1f2)]('.')['pop']());}}else s=F;return s;}catch(C){throw new Error('Failed\x20to\x20validate\x20input\x20(incorrect\x20format):\x20'+C[Il(0x28e)]);}}return yield u[Il(0x2cb)](R,{'cmdPath':w});});}function h(L,R,w){var Q;return __awaiter(this,void 0x0,void 0x0,function*(){const IS=a1z,K=yield P(L,R,w),J=new ajv_1[(IS(0x232))]({'allErrors':!![],'keywords':[IS(0x21a)],'validateFormats':![],'strict':![],'unicodeRegExp':![]});let j=![];try{j=J[IS(0x249)](R[IS(0x2d8)]['body'],K);}catch(s){if(s['message'][IS(0x27e)](IS(0x1fc)))j=!![];else throw s;}const F=(Q=J===null||J===void 0x0?void 0x0:J[IS(0x21f)])===null||Q===void 0x0?void 0x0:Q[IS(0x26a)](C=>{const Ie=IS;var f;return!((f=C===null||C===void 0x0?void 0x0:C[Ie(0x28e)])===null||f===void 0x0?void 0x0:f['includes']('match\x20exactly\x20one\x20schema\x20in\x20oneOf'));});if(!j&&F!==undefined&&(F===null||F===void 0x0?void 0x0:F[IS(0x1f4)])>0x0)throw new Error(IS(0x241)+JSON[IS(0x2b2)](J[IS(0x21f)],null,'\x20'));return K;});}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';const a2d=a2z;(function(u,z){const o=a2z,D=u();while(!![]){try{const M=-parseInt(o(0x108))/0x1+parseInt(o(0xf4))/0x2*(parseInt(o(0xdd))/0x3)+parseInt(o(0x150))/0x4+-parseInt(o(0x12b))/0x5+-parseInt(o(0xbb))/0x6*(-parseInt(o(0x155))/0x7)+-parseInt(o(0x146))/0x8+parseInt(o(0xf8))/0x9;if(M===z)break;else D['push'](D['shift']());}catch(H){D['push'](D['shift']());}}}(a2u,0xd040d));function a2z(u,z){const D=a2u();return a2z=function(M,H){M=M-0xba;let O=D[M];return O;},a2z(u,z);}function a2u(){const c=['227926WJkkvi','next','alias','value','16026786usoUnh','service','update-token','__esModule','getOwnPropertyDescriptor','Choose\x20the\x20context\x20to\x20','-n,\x20--name\x20[NAME]','getCurrentProjectName','get','../formatting/console-format-helpers','Token\x20for\x20current\x20context\x20\x27','--do-not-open-browser','host','addContext','Retrieve\x20and\x20update\x20local\x20context\x20settings.','__createBinding','1687900khotnr','useJobId','name','getCurrentName','../inquirer-helper','Token\x20for\x20this\x20context.\x20When\x20set,\x20browser\x20login\x20is\x20not\x20used','--token-login','valueOf','use\x20from\x20now\x20on','Contexts','default','token','loadContextWrapper','\x20successful','error','apiClient','success','Error\x20occured\x20during\x20browser\x20login:\x20','Project\x20name\x20(internal\x20id)\x20to\x20use\x20as\x20default\x20in\x20context','No\x20project\x20in\x20current\x20context.\x20Please\x20set\x20project\x20before\x20setting\x20a\x20project-scoped\x20resource','Use\x20job\x20with\x20id:','tokenPrompt','apiTokenLogin','moveCursor','action','stdout','browserLogin','GET','Change\x20the\x20default\x20job\x20in\x20the\x20current\x20local\x20context','sessionToken=********','prompt','Change\x20current\x20context\x20to\x20context\x20identified\x20by\x20this\x20name','No\x20context\x20available.\x20Please\x20use\x20\x27northflank\x20login\x27\x20to\x20create\x20context.','contextAvailable','No\x20context\x20available.\x20Use\x20\x27northflank\x20login\x27\x20to\x20create\x20context.','1822385XcSVES','-h,\x20--host\x20[HOST]','getInfo','Failed\x20to\x20login\x20with\x20the\x20provided\x20token,\x20make\x20sure\x20to\x20use\x20a\x20valid\x20token\x20and\x20host.','../utils','browser-opened','length','printAsTable','current','__awaiter','Name\x20for\x20login\x20context','dir','getCurrentContext','verifyToken','useContext','Service\x20name\x20(internal\x20id)\x20to\x20use\x20as\x20default\x20in\x20context','-t,\x20--token\x20[TOKEN]','Change\x20the\x20default\x20project\x20in\x20the\x20current\x20local\x20context','map','done','../login/browser-login','Shows\x20full\x20context\x20information\x20(including\x20tokens)','then','catch','useProjectId','Update\x20token\x20for\x20current\x20context','askForJob','10422080dbggJe','https://api.northflank.com','Failed\x20to\x20login\x20with\x20the\x20provided\x20token.\x20Token\x20was\x20not\x20changed','hasOwnProperty','Login\x20to\x20','Changed\x20current\x20context\x20to\x20','sort','askForService','Local\x20context\x20\x27','Switch\x20between\x20your\x20local\x20contexts','4299076mErLGW','getCommand','override','\x0aSuccessfully\x20logged\x20in\x20using\x20browser\x20login,\x20added\x20context\x20with\x20name\x20','Job\x20name\x20(internal\x20id)\x20to\x20use\x20as\x20default\x20in\x20context','2947LDanTs','use','Display\x20full\x20URL\x20to\x20allow\x20opening\x20the\x20link\x20manually','message','7908qZNrZC','description','askForContext','Override\x20existing\x20contexts\x20(this\x20will\x20remove\x20project\x20and\x20service\x20context)','Remove\x20a\x20context','project','chalk','Local\x20context\x20name\x20to\x20remove.','warning','\x27\x20successfully\x20updated.','NorthflankApiBrowserLogin','italic','defaultBaseUrl','Token\x20for\x20this\x20context','Use\x20project\x20with\x20id:','https://','__setModuleDefault','.\x20Using\x20fallback.','askForProject','replace','contextProvider','remove','Use\x20manual\x20login\x20with\x20API\x20token','node-fetch','Change\x20the\x20default\x20service\x20in\x20the\x20current\x20local\x20context','login','fullUrl','CliContext','prototype','option','getCurrentToken','log','sanitiseHostname','useServiceId','21URVuMf','throw','-i,\x20--id\x20[ID]','getCurrentBaseUrl','contexts','Open\x20this\x20URL\x20in\x20your\x20browser\x20and\x20follow\x20the\x20steps:\x0a\x09','context','retry','updateToken','autologin-','Use\x20browser\x20login\x20but\x20only\x20print\x20URL\x20which\x20can\x20be\x20used\x20to\x20login','create','\x27\x20successfully\x20removed.','--override','Use\x20service\x20with\x20id:','getProjectName','removeContext','job','set','addCommand','close','host\x20url\x20for\x20this\x20context','defineProperty'];a2u=function(){return c;};return a2u();}var __createBinding=this&&this[a2d(0x107)]||(Object[a2d(0xe8)]?function(u,z,D,M){const K=a2d;if(M===undefined)M=D;var H=Object[K(0xfc)](z,D);(!H||(K(0x100)in H?!z[K(0xfb)]:H['writable']||H['configurable']))&&(H={'enumerable':!![],'get':function(){return z[D];}}),Object['defineProperty'](u,M,H);}:function(u,z,D,M){if(M===undefined)M=D;u[M]=z[D];}),__setModuleDefault=this&&this[a2d(0xcb)]||(Object[a2d(0xe8)]?function(u,z){const w=a2d;Object['defineProperty'](u,w(0x112),{'enumerable':!![],'value':z});}:function(u,z){const y=a2d;u[y(0x112)]=z;}),__importStar=this&&this['__importStar']||function(u){const k=a2d;if(u&&u['__esModule'])return u;var z={};if(u!=null){for(var D in u)if(D!==k(0x112)&&Object[k(0xd7)][k(0x149)]['call'](u,D))__createBinding(z,u,D);}return __setModuleDefault(z,u),z;},__awaiter=this&&this[a2d(0x134)]||function(u,z,D,M){function H(O){return O instanceof D?O:new D(function(t){t(O);});}return new(D||(D=Promise))(function(O,t){const I=a2z;function g(N){const l=a2z;try{h(M[l(0xf5)](N));}catch(Z){t(Z);}}function T(N){const W=a2z;try{h(M[W(0xde)](N));}catch(Z){t(Z);}}function h(N){const F=a2z;N[F(0x13e)]?O(N[F(0xf7)]):H(N[F(0xf7)])[F(0x141)](g,T);}h((M=M['apply'](u,z||[]))[I(0xf5)]());});},__importDefault=this&&this['__importDefault']||function(u){const q=a2d;return u&&u[q(0xfb)]?u:{'default':u};};Object[a2d(0xf3)](exports,a2d(0xfb),{'value':!![]}),exports[a2d(0xd6)]=void 0x0;const _=__importStar(require('lodash')),node_fetch_1=__importDefault(require(a2d(0xd2))),chalk_1=__importDefault(require(a2d(0xc1))),utils_1=require(a2d(0x12f)),inquirer_helper_1=require(a2d(0x10c)),console_format_helpers_1=require(a2d(0x101)),browser_login_1=require(a2d(0x13f)),inquirer=require('inquirer');class CliContext{constructor(u,z=a2d(0x147)){const e=a2d;this[e(0xc7)]=z,this[e(0xdb)]=Z=>{const Q=e;let E=Z;return!/^https?:\/\//i['test'](E)&&(E=Q(0xca)+E),E=E[Q(0xce)](/\/+$/,''),E;},this['apiClient']=u;const D=new inquirer_helper_1['InquirerHelper'](u);this[e(0xd4)]=(0x0,utils_1['getCommand'])()[e(0x10a)](e(0xd4))[e(0xbc)]('Connect\x20the\x20CLI\x20to\x20your\x20Northflank\x20account.')[e(0xd8)](e(0x10e),e(0xd1),![])[e(0xd8)](e(0x103),e(0xe7),![])[e(0xd8)]('-n,\x20--name\x20[NAME]',e(0x135))[e(0xd8)](e(0x13b),e(0x10d))[e(0xd8)](e(0x12c),e(0xf2),this[e(0xc7)])['option'](e(0xea),e(0xbe),![])[e(0x120)](Z=>__awaiter(this,void 0x0,void 0x0,function*(){const r=e;_[r(0xef)](Z,r(0x104),this[r(0xdb)](Z[r(0x104)]));const {name:E,host:X,token:R,override:b}=Z['tokenLogin']||Z['token']!==undefined?yield this['apiTokenLogin'](Z,D):yield this[r(0x122)](Z,D);try{yield this[r(0x117)][r(0xcf)][r(0x105)]({'name':E,'host':X,'token':R},b);}catch(A){(0x0,utils_1[r(0x116)])(A[r(0xba)]);return;}!(yield this[r(0x138)]())?((0x0,utils_1[r(0x116)])(r(0x12e)),yield this['apiClient'][r(0xcf)][r(0xed)](E)):(0x0,utils_1[r(0x118)])(r(0x14a)+X+r(0x115));})),this[e(0xe1)]=(0x0,utils_1[e(0x151)])()[e(0x10a)](e(0xe3))[e(0xbc)](e(0x106))[e(0xf6)](e(0xe1))[e(0xf6)]('ctx');const M=(0x0,utils_1[e(0x151)])()[e(0x10a)]('list')['name']('ls')[e(0xbc)]('List\x20all\x20available\x20contexts')[e(0xd8)]('--all',e(0x140))[e(0x120)](Z=>__awaiter(this,void 0x0,void 0x0,function*(){const i=e;console[i(0xda)](u[i(0xcf)][i(0x12d)]());const E=u[i(0xcf)][i(0x114)]();if(Z['all']===!![]){console[i(0x136)](E);return;}const X=E[i(0x133)],R=E['contexts'][i(0x14c)]((b,A)=>b[i(0x10a)]===X?-0x1:A[i(0x10a)]===X?0x1:0x0)[i(0x13d)](b=>{const U=i,A=X===b['name']?'\x20(current)':'';return{'Name':''+b[U(0x10a)]+A,'Host':b['host'],'Default\x20Project':b['project']||'-','Default\x20Service':b[U(0xf9)]||'-'};});(0x0,console_format_helpers_1[i(0x132)])(R,i(0x111));})),H=(0x0,utils_1['getCommand'])();H['name'](e(0x156))[e(0xbc)](e(0x14f))['option'](e(0xfe),e(0x127))[e(0x120)](Z=>__awaiter(this,void 0x0,void 0x0,function*(){const L=e,E=(Z===null||Z===void 0x0?void 0x0:Z[L(0x10a)])||(yield this[L(0xbd)]('use'));yield this[L(0x117)][L(0xcf)][L(0x139)](E),(0x0,utils_1[L(0x118)])('Changed\x20current\x20context\x20to\x20'+E);}));const O=e(0xdf),t=(0x0,utils_1[e(0x151)])()[e(0x10a)](e(0xc0))[e(0xbc)](e(0x13c))['option'](O,e(0x11a))[e(0x120)](Z=>__awaiter(this,void 0x0,void 0x0,function*(){const C=e,E=(Z===null||Z===void 0x0?void 0x0:Z['id'])||(yield D[C(0xcd)]());yield this[C(0x117)][C(0xcf)][C(0x143)](E),console['log'](C(0xc9),E);})),g=(0x0,utils_1[e(0x151)])()['name'](e(0xf9))[e(0xbc)](e(0xd3))[e(0xd8)](O,e(0x13a))[e(0x120)](Z=>__awaiter(this,void 0x0,void 0x0,function*(){const j=e,E=(Z===null||Z===void 0x0?void 0x0:Z['id'])||(yield D[j(0x14d)](this[j(0xec)]())());console[j(0xda)](j(0xeb),E),yield this[j(0x117)]['contextProvider'][j(0xdc)](E);})),T=(0x0,utils_1[e(0x151)])()[e(0x10a)](e(0xee))['description'](e(0x124))[e(0xd8)](O,e(0x154))[e(0x120)](Z=>__awaiter(this,void 0x0,void 0x0,function*(){const J=e,E=(Z===null||Z===void 0x0?void 0x0:Z['id'])||(yield D[J(0x145)](this[J(0xec)]())());console[J(0xda)](J(0x11c),E),yield this[J(0x117)][J(0xcf)][J(0x109)](E);}));H['addCommand'](t),H['addCommand'](T),H[e(0xf0)](g);const h=(0x0,utils_1['getCommand'])()[e(0x10a)](e(0xd0))[e(0xf6)]('delete')[e(0xf6)]('rm')['description'](e(0xbf))[e(0xd8)](O,e(0xc2))[e(0x120)](Z=>__awaiter(this,void 0x0,void 0x0,function*(){const a=e;var E;const X=(Z===null||Z===void 0x0?void 0x0:Z['id'])||(yield this[a(0xbd)]('remove')),R=(E=this[a(0x117)][a(0xcf)][a(0x137)]())===null||E===void 0x0?void 0x0:E[a(0x10a)];yield this[a(0x117)]['contextProvider']['removeContext'](X),(0x0,utils_1[a(0x118)])(a(0x14e)+X+a(0xe9));if(!this[a(0x129)]()){(0x0,utils_1[a(0xc3)])(a(0x12a));return;}if(R===X){const b=(Z===null||Z===void 0x0?void 0x0:Z[a(0x10a)])||(yield this[a(0xbd)](a(0x110)));yield this[a(0x117)][a(0xcf)]['useContext'](b),(0x0,utils_1['success'])(a(0x14b)+b);}})),N=(0x0,utils_1['getCommand'])()[e(0x10a)](e(0xfa))['alias']('set-token')[e(0xbc)](e(0x144))[e(0xd8)]('-t,\x20--token\x20[TOKEN]',e(0xc8))['action'](Z=>__awaiter(this,void 0x0,void 0x0,function*(){const V=e,{contextProvider:E}=this[V(0x117)],X=(Z===null||Z===void 0x0?void 0x0:Z[V(0x113)])||(yield D[V(0x11d)]()),R=E[V(0xd9)]();yield E[V(0xe5)](X);if(yield this[V(0x138)]())(0x0,utils_1[V(0x118)])(V(0x102)+E[V(0x10b)]()+V(0xc4));else{if(R)yield E[V(0xe5)](R);(0x0,utils_1[V(0x116)])(V(0x148));}}));this[e(0xe1)]['addCommand'](M),this[e(0xe1)][e(0xf0)](H),this[e(0xe1)][e(0xf0)](h),this[e(0xe1)][e(0xf0)](N);}[a2d(0x122)](u,z){var D,M,H,O;return __awaiter(this,void 0x0,void 0x0,function*(){const m=a2z,t=!u['doNotOpenBrowser'],g=(D=u[m(0x104)])!==null&&D!==void 0x0?D:this['defaultBaseUrl'],T=new browser_login_1[(m(0xc5))](g,t);let h;T['on'](m(0x130),({url:X})=>{const B=m;if(t){const R=X[B(0xce)](/sessionToken=.*/,B(0x125));console[B(0xda)]('Follow\x20the\x20steps\x20displayed\x20on\x20the\x20page\x20opened\x20in\x20the\x20browser\x20(URL\x20opened:\x20'+R+')'),h=inquirer[B(0x126)]([{'type':'confirm','name':B(0xd5),'message':B(0x157),'default':![]}]),h[B(0x141)](b=>{const f=B;process[f(0x121)][f(0x11f)](0x0,-0x1),process[f(0x121)]['clearLine'](0x1),b['fullUrl']&&console['log'](f(0xe2)+X+'\x20');});}else console[B(0xda)]('Open\x20this\x20URL\x20in\x20your\x20browser\x20and\x20follow\x20the\x20steps:\x0a\x09'+X+'\x20');});const {token:N,contextName:Z}=yield T['startLogin']()[m(0x142)](X=>__awaiter(this,void 0x0,void 0x0,function*(){const G=m;(0x0,utils_1[G(0x116)])(G(0x119)+X['message']+G(0xcc));const R=yield this[G(0x11e)](u,z);return{'token':R[G(0x113)],'contextName':R['name']};}))['finally'](()=>{const Y=m;if(h)h['ui'][Y(0xf1)]();}),E=(H=(M=u[m(0x10a)])!==null&&M!==void 0x0?M:Z)!==null&&H!==void 0x0?H:m(0xe6)+new Date()[m(0x10f)]();return(0x0,utils_1[m(0x118)])(m(0x153)+chalk_1[m(0x112)][m(0xc6)](E)),{'name':E,'token':N,'host':g,'override':(O=u[m(0x152)])!==null&&O!==void 0x0?O:![]};});}['apiTokenLogin'](u,z){return __awaiter(this,void 0x0,void 0x0,function*(){const P=a2z,D=this['apiClient'][P(0xcf)]['loadContextWrapper']()[P(0xe1)],{name:M,token:H,host:O,override:t}=yield z['loginPrompt'](u,D);return{'name':M,'token':H,'host':O,'override':t};});}[a2d(0xec)](){const s=a2d,u=this['apiClient'][s(0xcf)][s(0xff)]();if(u===undefined)throw new Error(s(0x11b));return u;}[a2d(0xbd)](u){return __awaiter(this,void 0x0,void 0x0,function*(){const v=a2z;if(!this[v(0x129)]())throw new Error(v(0x128));const z=this[v(0x117)][v(0xcf)][v(0x114)]()[v(0xe1)]['map'](M=>M[v(0x10a)]),D=z[v(0x131)]>0x4?'search-list':'list';return(yield inquirer[v(0x126)]([{'type':D,'name':v(0x10a),'message':v(0xfd)+u+':','choices':z}]))['name'];});}[a2d(0x129)](){const x=a2d;return this[x(0x117)][x(0xcf)][x(0x114)]()[x(0xe1)][x(0x131)]>0x0;}[a2d(0x138)](){return __awaiter(this,void 0x0,void 0x0,function*(){const p=a2z;try{const u=this['apiClient'][p(0xcf)][p(0xe0)](),z=this['apiClient'][p(0xcf)]['getCurrentToken'](),D=u+'/v1/login',M={'Authorization':'Bearer\x20'+z},H=yield(0x0,utils_1[p(0xe4)])(0x3)(()=>__awaiter(this,void 0x0,void 0x0,function*(){const n=p;return(0x0,node_fetch_1[n(0x112)])(D,{'method':n(0x123),'timeout':0xbb8,'headers':M});}));if(H['ok'])return!![];return![];}catch(O){return![];}});}}exports['CliContext']=CliContext;
|
|
1
|
+
'use strict';const a2j=a2z;function a2z(I,z){const g=a2I();return a2z=function(Z,y){Z=Z-0xdf;let i=g[Z];return i;},a2z(I,z);}function a2I(){const c=['updateToken','browserLogin','Use\x20service\x20with\x20id:','getCurrentContext','option','Name\x20for\x20login\x20context','Failed\x20to\x20login\x20with\x20the\x20provided\x20token.\x20Token\x20was\x20not\x20changed','defineProperty','No\x20project\x20in\x20current\x20context.\x20Please\x20set\x20project\x20before\x20setting\x20a\x20project-scoped\x20resource','Local\x20context\x20\x27','useContext','lodash','\x27\x20successfully\x20updated.','action','No\x20context\x20available.\x20Please\x20use\x20\x27northflank\x20login\x27\x20to\x20create\x20context.','catch','service','--all','verifyToken','set','hasOwnProperty','../login/browser-login','No\x20context\x20available.\x20Use\x20\x27northflank\x20login\x27\x20to\x20create\x20context.','1015662PByMhz','../formatting/console-format-helpers','retry','name','\x27\x20successfully\x20removed.','Open\x20this\x20URL\x20in\x20your\x20browser\x20and\x20follow\x20the\x20steps:\x0a\x09','getCurrentName','askForProject','281806GTZGqn','Display\x20full\x20URL\x20to\x20allow\x20opening\x20the\x20link\x20manually','token','19oDvyHm','askForJob','Use\x20project\x20with\x20id:','660ifvgms','dir','success','apiTokenLogin','https://','sort','Error\x20occured\x20during\x20browser\x20login:\x20','getOwnPropertyDescriptor','log','close','login','warning','Project\x20name\x20(internal\x20id)\x20to\x20use\x20as\x20default\x20in\x20context','askForService','defaultBaseUrl','host','Token\x20for\x20current\x20context\x20\x27','getProjectName','getInfo','addCommand','get','Change\x20the\x20default\x20project\x20in\x20the\x20current\x20local\x20context','printAsTable','Failed\x20to\x20login\x20with\x20the\x20provided\x20token,\x20make\x20sure\x20to\x20use\x20a\x20valid\x20token\x20and\x20host.','moveCursor','prompt','delete','-h,\x20--host\x20[HOST]','finally','sanitiseHostname','\x20(current)','list','test','93390XnjexH','InquirerHelper','Update\x20token\x20for\x20current\x20context','Override\x20existing\x20contexts\x20(this\x20will\x20remove\x20project\x20and\x20service\x20context)','List\x20all\x20available\x20contexts','4TSPdZZ','message','loadContextWrapper','writable','Changed\x20current\x20context\x20to\x20','use','remove','doNotOpenBrowser','Use\x20job\x20with\x20id:','-i,\x20--id\x20[ID]','description','getCurrentProjectName','create','contextProvider','https://api.northflank.com','-n,\x20--name\x20[NAME]','project','--token-login','getCurrentToken','stdout','value','useJobId','--do-not-open-browser','all','alias','fullUrl','next','Change\x20current\x20context\x20to\x20context\x20identified\x20by\x20this\x20name','search-list','Use\x20manual\x20login\x20with\x20API\x20token','call','tokenPrompt','map','Login\x20to\x20','throw','clearLine','37248RvnUoG','then','GET','/v1/login','__importDefault','__esModule','useServiceId','done','job','CliContext','\x0aSuccessfully\x20logged\x20in\x20using\x20browser\x20login,\x20added\x20context\x20with\x20name\x20','contexts','Token\x20for\x20this\x20context','getCurrentBaseUrl','contextAvailable','browser-opened','default','Service\x20name\x20(internal\x20id)\x20to\x20use\x20as\x20default\x20in\x20context','removeContext','getCommand','prototype','1288070kLsTqO','apiClient','sessionToken=********','Remove\x20a\x20context','use\x20from\x20now\x20on','184059gqoSuA','error','__setModuleDefault','Connect\x20the\x20CLI\x20to\x20your\x20Northflank\x20account.','.\x20Using\x20fallback.','startLogin','autologin-','Retrieve\x20and\x20update\x20local\x20context\x20settings.','149178pFXtFo','askForContext','length','tokenLogin','replace','configurable','32LbwLqq','context','-t,\x20--token\x20[TOKEN]'];a2I=function(){return c;};return a2I();}(function(I,z){const K=a2z,g=I();while(!![]){try{const Z=-parseInt(K(0xff))/0x1*(-parseInt(K(0x14c))/0x2)+-parseInt(K(0xf4))/0x3*(-parseInt(K(0x128))/0x4)+parseInt(K(0x161))/0x5+-parseInt(K(0x16e))/0x6+parseInt(K(0xfc))/0x7*(-parseInt(K(0x174))/0x8)+-parseInt(K(0x166))/0x9+parseInt(K(0x123))/0xa*(-parseInt(K(0x102))/0xb);if(Z===z)break;else g['push'](g['shift']());}catch(y){g['push'](g['shift']());}}}(a2I,0x2cc2a));var __createBinding=this&&this['__createBinding']||(Object['create']?function(I,z,g,Z){const J=a2z;if(Z===undefined)Z=g;var y=Object[J(0x109)](z,g);(!y||(J(0x116)in y?!z['__esModule']:y[J(0x12b)]||y[J(0x173)]))&&(y={'enumerable':!![],'get':function(){return z[g];}}),Object[J(0xe4)](I,Z,y);}:function(I,z,g,Z){if(Z===undefined)Z=g;I[Z]=z[g];}),__setModuleDefault=this&&this[a2j(0x168)]||(Object[a2j(0x134)]?function(I,z){const F=a2j;Object[F(0xe4)](I,'default',{'enumerable':!![],'value':z});}:function(I,z){const s=a2j;I[s(0x15c)]=z;}),__importStar=this&&this['__importStar']||function(I){const C=a2j;if(I&&I['__esModule'])return I;var z={};if(I!=null){for(var g in I)if(g!==C(0x15c)&&Object[C(0x160)][C(0xf1)][C(0x146)](I,g))__createBinding(z,I,g);}return __setModuleDefault(z,I),z;},__awaiter=this&&this['__awaiter']||function(I,z,g,Z){function y(i){return i instanceof g?i:new g(function(t){t(i);});}return new(g||(g=Promise))(function(i,t){const d=a2z;function u(G){const f=a2z;try{M(Z[f(0x142)](G));}catch(h){t(h);}}function v(G){const x=a2z;try{M(Z[x(0x14a)](G));}catch(h){t(h);}}function M(G){const o=a2z;G[o(0x153)]?i(G[o(0x13c)]):y(G['value'])[o(0x14d)](u,v);}M((Z=Z['apply'](I,z||[]))[d(0x142)]());});},__importDefault=this&&this[a2j(0x150)]||function(I){const n=a2j;return I&&I[n(0x151)]?I:{'default':I};};Object[a2j(0xe4)](exports,'__esModule',{'value':!![]}),exports['CliContext']=void 0x0;const _=__importStar(require(a2j(0xe8))),node_fetch_1=__importDefault(require('node-fetch')),chalk_1=__importDefault(require('chalk')),utils_1=require('../utils'),inquirer_helper_1=require('../inquirer-helper'),console_format_helpers_1=require(a2j(0xf5)),browser_login_1=require(a2j(0xf2)),inquirer=require('inquirer');class CliContext{constructor(I,z=a2j(0x136)){const A=a2j;this[A(0x110)]=z,this[A(0x11f)]=P=>{const T=A;let h=P;return!/^https?:\/\//i[T(0x122)](h)&&(h=T(0x106)+h),h=h[T(0x172)](/\/+$/,''),h;},this[A(0x162)]=I;const g=new inquirer_helper_1[(A(0x124))](I);this[A(0x10c)]=(0x0,utils_1[A(0x15f)])()['name']('login')[A(0x132)](A(0x169))[A(0xe1)](A(0x139),A(0x145),![])[A(0xe1)](A(0x13e),'Use\x20browser\x20login\x20but\x20only\x20print\x20URL\x20which\x20can\x20be\x20used\x20to\x20login',![])[A(0xe1)]('-n,\x20--name\x20[NAME]',A(0xe2))[A(0xe1)]('-t,\x20--token\x20[TOKEN]','Token\x20for\x20this\x20context.\x20When\x20set,\x20browser\x20login\x20is\x20not\x20used')[A(0xe1)](A(0x11d),'host\x20url\x20for\x20this\x20context',this[A(0x110)])[A(0xe1)]('--override',A(0x126),![])[A(0xea)](P=>__awaiter(this,void 0x0,void 0x0,function*(){const m=A;_[m(0xf0)](P,'host',this['sanitiseHostname'](P[m(0x111)]));const {name:h,host:L,token:R,override:w}=P[m(0x171)]||P[m(0xfe)]!==undefined?yield this[m(0x105)](P,g):yield this[m(0x178)](P,g);try{yield this[m(0x162)][m(0x135)]['addContext']({'name':h,'host':L,'token':R},w);}catch(Q){(0x0,utils_1[m(0x167)])(Q['message']);return;}!(yield this[m(0xef)]())?((0x0,utils_1[m(0x167)])(m(0x119)),yield this[m(0x162)][m(0x135)]['removeContext'](h)):(0x0,utils_1['success'])(m(0x149)+L+'\x20successful');})),this[A(0x157)]=(0x0,utils_1['getCommand'])()[A(0xf7)](A(0x175))[A(0x132)](A(0x16d))[A(0x140)](A(0x157))[A(0x140)]('ctx');const Z=(0x0,utils_1[A(0x15f)])()['name'](A(0x121))[A(0xf7)]('ls')['description'](A(0x127))['option'](A(0xee),'Shows\x20full\x20context\x20information\x20(including\x20tokens)')['action'](P=>__awaiter(this,void 0x0,void 0x0,function*(){const b=A;console['log'](I[b(0x135)][b(0x114)]());const h=I[b(0x135)][b(0x12a)]();if(P[b(0x13f)]===!![]){console[b(0x103)](h);return;}const L=h['current'],R=h[b(0x157)][b(0x107)]((w,Q)=>w[b(0xf7)]===L?-0x1:Q[b(0xf7)]===L?0x1:0x0)[b(0x148)](w=>{const O=b,Q=L===w[O(0xf7)]?O(0x120):'';return{'Name':''+w[O(0xf7)]+Q,'Host':w[O(0x111)],'Default\x20Project':w[O(0x138)]||'-','Default\x20Service':w[O(0xed)]||'-'};});(0x0,console_format_helpers_1[b(0x118)])(R,'Contexts');})),y=(0x0,utils_1['getCommand'])();y[A(0xf7)](A(0x12d))[A(0x132)]('Switch\x20between\x20your\x20local\x20contexts')[A(0xe1)](A(0x137),A(0x143))[A(0xea)](P=>__awaiter(this,void 0x0,void 0x0,function*(){const V=A,h=(P===null||P===void 0x0?void 0x0:P[V(0xf7)])||(yield this[V(0x16f)](V(0x12d)));yield this[V(0x162)][V(0x135)][V(0xe7)](h),(0x0,utils_1[V(0x104)])('Changed\x20current\x20context\x20to\x20'+h);}));const i=A(0x131),t=(0x0,utils_1[A(0x15f)])()[A(0xf7)](A(0x138))[A(0x132)](A(0x117))['option'](i,A(0x10e))['action'](P=>__awaiter(this,void 0x0,void 0x0,function*(){const k=A,h=(P===null||P===void 0x0?void 0x0:P['id'])||(yield g[k(0xfb)]());yield this[k(0x162)][k(0x135)]['useProjectId'](h),console['log'](k(0x101),h);})),u=(0x0,utils_1[A(0x15f)])()[A(0xf7)]('service')['description']('Change\x20the\x20default\x20service\x20in\x20the\x20current\x20local\x20context')[A(0xe1)](i,A(0x15d))[A(0xea)](P=>__awaiter(this,void 0x0,void 0x0,function*(){const N=A,h=(P===null||P===void 0x0?void 0x0:P['id'])||(yield g[N(0x10f)](this[N(0x113)]())());console[N(0x10a)](N(0xdf),h),yield this[N(0x162)][N(0x135)][N(0x152)](h);})),v=(0x0,utils_1[A(0x15f)])()[A(0xf7)](A(0x154))[A(0x132)]('Change\x20the\x20default\x20job\x20in\x20the\x20current\x20local\x20context')[A(0xe1)](i,'Job\x20name\x20(internal\x20id)\x20to\x20use\x20as\x20default\x20in\x20context')[A(0xea)](P=>__awaiter(this,void 0x0,void 0x0,function*(){const a=A,h=(P===null||P===void 0x0?void 0x0:P['id'])||(yield g[a(0x100)](this[a(0x113)]())());console[a(0x10a)](a(0x130),h),yield this[a(0x162)]['contextProvider'][a(0x13d)](h);}));y[A(0x115)](t),y['addCommand'](v),y['addCommand'](u);const M=(0x0,utils_1[A(0x15f)])()['name'](A(0x12e))['alias'](A(0x11c))[A(0x140)]('rm')[A(0x132)](A(0x164))['option'](i,'Local\x20context\x20name\x20to\x20remove.')[A(0xea)](P=>__awaiter(this,void 0x0,void 0x0,function*(){const D=A;var h;const L=(P===null||P===void 0x0?void 0x0:P['id'])||(yield this[D(0x16f)](D(0x12e))),R=(h=this[D(0x162)][D(0x135)][D(0xe0)]())===null||h===void 0x0?void 0x0:h['name'];yield this[D(0x162)][D(0x135)][D(0x15e)](L),(0x0,utils_1[D(0x104)])(D(0xe6)+L+D(0xf8));if(!this[D(0x15a)]()){(0x0,utils_1[D(0x10d)])(D(0xf3));return;}if(R===L){const w=(P===null||P===void 0x0?void 0x0:P[D(0xf7)])||(yield this['askForContext'](D(0x165)));yield this['apiClient'][D(0x135)][D(0xe7)](w),(0x0,utils_1[D(0x104)])(D(0x12c)+w);}})),G=(0x0,utils_1['getCommand'])()[A(0xf7)]('update-token')[A(0x140)]('set-token')[A(0x132)](A(0x125))['option'](A(0x176),A(0x158))[A(0xea)](P=>__awaiter(this,void 0x0,void 0x0,function*(){const H=A,{contextProvider:h}=this[H(0x162)],L=(P===null||P===void 0x0?void 0x0:P[H(0xfe)])||(yield g[H(0x147)]()),R=h[H(0x13a)]();yield h[H(0x177)](L);if(yield this[H(0xef)]())(0x0,utils_1[H(0x104)])(H(0x112)+h[H(0xfa)]()+H(0xe9));else{if(R)yield h['updateToken'](R);(0x0,utils_1[H(0x167)])(H(0xe3));}}));this['contexts'][A(0x115)](Z),this['contexts'][A(0x115)](y),this[A(0x157)][A(0x115)](M),this[A(0x157)]['addCommand'](G);}['browserLogin'](I,z){var g,Z,y,i;return __awaiter(this,void 0x0,void 0x0,function*(){const Y=a2z,t=!I[Y(0x12f)],u=(g=I[Y(0x111)])!==null&&g!==void 0x0?g:this[Y(0x110)],v=new browser_login_1['NorthflankApiBrowserLogin'](u,t);let M;v['on'](Y(0x15b),({url:L})=>{const r=Y;if(t){const R=L['replace'](/sessionToken=.*/,r(0x163));console[r(0x10a)]('Follow\x20the\x20steps\x20displayed\x20on\x20the\x20page\x20opened\x20in\x20the\x20browser\x20(URL\x20opened:\x20'+R+')'),M=inquirer['prompt']([{'type':'confirm','name':r(0x141),'message':r(0xfd),'default':![]}]),M[r(0x14d)](w=>{const X=r;process[X(0x13b)][X(0x11a)](0x0,-0x1),process[X(0x13b)][X(0x14b)](0x1),w['fullUrl']&&console['log'](X(0xf9)+L+'\x20');});}else console[r(0x10a)](r(0xf9)+L+'\x20');});const {token:G,contextName:P}=yield v[Y(0x16b)]()[Y(0xec)](L=>__awaiter(this,void 0x0,void 0x0,function*(){const l=Y;(0x0,utils_1[l(0x167)])(l(0x108)+L[l(0x129)]+l(0x16a));const R=yield this[l(0x105)](I,z);return{'token':R['token'],'contextName':R['name']};}))[Y(0x11e)](()=>{const S=Y;if(M)M['ui'][S(0x10b)]();}),h=(y=(Z=I[Y(0xf7)])!==null&&Z!==void 0x0?Z:P)!==null&&y!==void 0x0?y:Y(0x16c)+new Date()['valueOf']();return(0x0,utils_1[Y(0x104)])(Y(0x156)+chalk_1['default']['italic'](h)),{'name':h,'token':G,'host':u,'override':(i=I['override'])!==null&&i!==void 0x0?i:![]};});}[a2j(0x105)](I,z){return __awaiter(this,void 0x0,void 0x0,function*(){const e=a2z,g=this[e(0x162)][e(0x135)][e(0x12a)]()[e(0x157)],{name:Z,token:y,host:i,override:t}=yield z['loginPrompt'](I,g);return{'name':Z,'token':y,'host':i,'override':t};});}[a2j(0x113)](){const q=a2j,I=this[q(0x162)][q(0x135)][q(0x133)]();if(I===undefined)throw new Error(q(0xe5));return I;}['askForContext'](I){return __awaiter(this,void 0x0,void 0x0,function*(){const E=a2z;if(!this[E(0x15a)]())throw new Error(E(0xeb));const z=this[E(0x162)]['contextProvider'][E(0x12a)]()[E(0x157)][E(0x148)](Z=>Z[E(0xf7)]),g=z[E(0x170)]>0x4?E(0x144):E(0x121);return(yield inquirer[E(0x11b)]([{'type':g,'name':'name','message':'Choose\x20the\x20context\x20to\x20'+I+':','choices':z}]))[E(0xf7)];});}[a2j(0x15a)](){const W=a2j;return this[W(0x162)][W(0x135)]['loadContextWrapper']()[W(0x157)]['length']>0x0;}[a2j(0xef)](){return __awaiter(this,void 0x0,void 0x0,function*(){const B=a2z;try{const I=this[B(0x162)][B(0x135)][B(0x159)](),z=this[B(0x162)][B(0x135)][B(0x13a)](),g=I+B(0x14f),Z={'Authorization':'Bearer\x20'+z},y=yield(0x0,utils_1[B(0xf6)])(0x3)(()=>__awaiter(this,void 0x0,void 0x0,function*(){const p=B;return(0x0,node_fetch_1['default'])(g,{'method':p(0x14e),'timeout':0xbb8,'headers':Z});}));if(y['ok'])return!![];return![];}catch(i){return![];}});}}exports[a2j(0x155)]=CliContext;
|