UNPKG

@northflank/cli

Version:

Provides a command-line interface to the Northflank platform.

1 lines 5.6 kB
const a17P=a17E;(function(m,E){const L=a17E,h=m();while(!![]){try{const I=parseInt(L(0x10c))/0x1*(parseInt(L(0x128))/0x2)+parseInt(L(0x10e))/0x3*(parseInt(L(0x12a))/0x4)+parseInt(L(0x12f))/0x5*(parseInt(L(0x11b))/0x6)+-parseInt(L(0x147))/0x7+parseInt(L(0x12c))/0x8+-parseInt(L(0x13e))/0x9*(-parseInt(L(0x14e))/0xa)+-parseInt(L(0x10b))/0xb*(parseInt(L(0x116))/0xc);if(I===E)break;else h['push'](h['shift']());}catch(T){h['push'](h['shift']());}}}(a17m,0x6667b));import a17h from'chalk';import{Command}from'commander';import{ProxyAgent}from'proxy-agent';import a17I from'node-fetch';import{readFileSync}from'fs';import{fileURLToPath}from'url';import{dirname,join}from'path';const __filename=fileURLToPath(import.meta[a17P(0x126)]),__dirname=dirname(__filename),pgk=JSON[a17P(0x135)](readFileSync(join(__dirname,a17P(0x124)),a17P(0x132)));export const customUserAgent=a17P(0x140)+pgk?.[a17P(0x14d)];export const agent=new ProxyAgent();export const proxyEnvsSet=process['env'][a17P(0x143)]!==undefined||process[a17P(0x12b)][a17P(0x123)]!==undefined;export const decodeJwtPayload=m=>{const W=a17P;try{const E=T=>{const X=a17E,o=T['replace'](/-/g,'+')[X(0x11e)](/_/g,'/')['padEnd'](T[X(0x139)]+(0x4-T[X(0x139)]%0x4)%0x4,'=');return JSON[X(0x135)](Buffer[X(0x129)](o,'base64')[X(0x144)]());},[h,I]=m[W(0x122)]('.');return E(I);}catch(T){return{};}};export async function checkUpdate(m){const z=a17P;function E(h,I){const K=a17E,T=new Date(Number(h));return T['setDate'](T[K(0x112)]()+I),T;}try{if(E(m[z(0x12d)](),0x1)>new Date())return;const h=pgk['version'],{name:I}=pgk;if(!h)return;const T='https://registry.npmjs.org/'+I+z(0x11a),o=await a17I(T,{'agent':agent,'method':z(0x145),'signal':AbortSignal[z(0x150)](0x1388)}),g=(await o[z(0x142)]())[z(0x14d)];needsUpdate(h,g)&&warning(z(0x11f)+h+z(0x111)+g+'.'+(z(0x133)+I+'\x20-g\x27\x20or\x20\x27yarn\x20global\x20add\x20'+I+z(0x117))),await m[z(0x13c)](new Date());}catch(J){}}function needsUpdate(m,E){const S=a17P,h=/(\.0+)+$/,I=m[S(0x11e)](h,'')[S(0x122)]('.'),T=E[S(0x11e)](h,'')[S(0x122)]('.');for(let e=0x0;e<Math[S(0x119)](I[S(0x139)],T['length']);e+=0x1){const o=parseInt(T[e],0xa)-parseInt(I[e],0xa);if(o>0x0)return!![];if(o<0x0)return![];}return T['length']>I[S(0x139)];}export function error(m){const H=a17P;console[H(0x14c)](a17h['redBright'](H(0x14b)+m));}export function warning(m){const r=a17P;console[r(0x14c)](a17h[r(0x13f)](''+m));}export function success(m){const F=a17P;console[F(0x11c)](a17h['green'](''+m));}export function getCommand(m=![]){const t=a17P,E=new Command();return E[t(0x121)](undefined,'Display\x20help\x20for\x20command'),E[t(0x10f)](![]),E[t(0x11d)](![]),E[t(0x114)](![]),E[t(0x14f)](![]),E[t(0x146)](!![]),m&&(E['option'](t(0x14a),t(0x125),![]),E[t(0x149)](t(0x148),t(0x130),![]),E[t(0x149)](t(0x115),t(0x118),![])),E;}function a17E(m,E){const h=a17m();return a17E=function(I,T){I=I-0x10b;let e=h[I];return e;},a17E(m,E);}export const retry=(m,E=0x32)=>h=>{let I=m;const T=async()=>{try{return await h();}catch(o){if(I<=0x0)throw o;return I-=0x1,await new Promise(g=>setTimeout(()=>g(),E)),T();}};return T();};export const asyncSequential=async(m,E)=>{const Y=a17P,h=Promise[Y(0x13a)]([]);return m[Y(0x13d)]((I,T)=>I[Y(0x12e)](e=>E(T)['then'](o=>{const N=Y;return e[N(0x131)](o),e;})),h);};export function isValidJSON(m){const w=a17P;try{return JSON[w(0x135)](m);}catch(E){return![];}}export function assertContextExisting(m){const b=a17P;if(m[b(0x120)][b(0x127)]()===undefined)throw new Error(b(0x141));if(m['contextProvider'][b(0x137)]()===undefined)throw new Error(b(0x110));if(m[b(0x120)][b(0x10d)]()===undefined)throw new Error(b(0x113));}export const parseDateInput=m=>{const n=a17P;try{let E=new Date(m);if(isNaN(E[n(0x134)]())){const h=m['length']===0xd?m/0x3e8:m,I=new Date(0x0);I['setUTCSeconds'](h);if(isNaN(I[n(0x134)]()))throw new Error();return I;}return E;}catch(T){throw new Error(n(0x13b)+m+n(0x136));}};export const tsHint=a17P(0x138);function a17m(){const Q=['110yHwijk','allowExcessArguments','timeout','8517212nJYxrm','34xtxBhp','getCurrentToken','1658787ZRRuzp','addHelpCommand','No\x20API\x20URL\x20present\x20in\x20context.\x20Create\x20new\x20context\x20with\x20\x27northflank\x20login\x27',',\x20the\x20latest\x20version\x20of\x20the\x20cli\x20is\x20','getDate','No\x20token\x20in\x20CLI\x20context.\x20Add\x20token\x20with\x20\x27northflank\x20set-token\x27','allowUnknownOption','--skipValidation','12hWXNeY','\x27\x20**','Do\x20not\x20validate\x20input\x20fields\x20on\x20client\x20side','min','/latest','222spqnov','log','storeOptionsAsProperties','replace','**\x20You\x27re\x20running\x20on\x20version\x20','contextProvider','helpOption','split','HTTPS_PROXY','../package.json','Verbose\x20output','url','getCurrentContext','16520xQFqzI','from','4kqHnDl','env','1057840LhbRwo','getLastUpdateCheck','then','6610hKJrsF','No\x20console\x20output','push','utf-8','\x20Consider\x20updating\x20using\x20\x27npm\x20i\x20','getTime','parse',',\x20expected\x20valid\x20date\x20string\x20(example:\x202020-02-02T02:02:02Z)\x20or\x20unix\x20timestamp\x20(example\x201580608922)','getCurrentBaseUrl','example:\x202020-02-02T02:02:02Z\x20(date\x20string)\x20or\x201580608922\x20(unix\x20ts)','length','resolve','Invalid\x20date\x20received:\x20','setLastUpdateCheck','reduce','574551zXEjlI','yellow','northflank-cli/','No\x20CLI\x20context\x20present.\x20Create\x20context\x20with\x20\x27northflank\x20login\x27','json','HTTP_PROXY','toString','GET','enablePositionalOptions','3663793ckHaYZ','--quiet','option','--verbose','Failed:\x20','error','version'];a17m=function(){return Q;};return a17m();}