@northflank/cli
Version:
Provides a command-line interface to the Northflank platform.
1 lines • 5.53 kB
JavaScript
const a16C=a16j;(function(X,j){const o=a16j,V=X();while(!![]){try{const H=parseInt(o(0x187))/0x1*(parseInt(o(0x181))/0x2)+parseInt(o(0x15d))/0x3*(-parseInt(o(0x179))/0x4)+-parseInt(o(0x16d))/0x5+parseInt(o(0x18a))/0x6*(parseInt(o(0x18e))/0x7)+parseInt(o(0x15a))/0x8*(parseInt(o(0x17e))/0x9)+parseInt(o(0x196))/0xa+-parseInt(o(0x15c))/0xb;if(H===j)break;else V['push'](V['shift']());}catch(O){V['push'](V['shift']());}}}(a16X,0x8ed35));import a16V from'chalk';import{Command}from'commander';import{ProxyAgent}from'proxy-agent';import a16H from'node-fetch';import{readFileSync}from'fs';function a16X(){const M=['Failed:\x20','**\x20You\x27re\x20running\x20on\x20version\x20','northflank-cli/','setUTCSeconds','45705Mtxmzv','json','example:\x202020-02-02T02:02:02Z\x20(date\x20string)\x20or\x201580608922\x20(unix\x20ts)','getCurrentToken','GET','HTTPS_PROXY','toString','base64','getCurrentContext','green','allowUnknownOption','version','8eczJzQ','--skipValidation','reduce','redBright','url','181278HlyFBv','getTime','getLastUpdateCheck','638214fuDIRc','setLastUpdateCheck','from',',\x20expected\x20valid\x20date\x20string\x20(example:\x202020-02-02T02:02:02Z)\x20or\x20unix\x20timestamp\x20(example\x201580608922)','--verbose','error','3qVDeLY','split','Do\x20not\x20validate\x20input\x20fields\x20on\x20client\x20side','65862bQNePV','setDate','allowExcessArguments','utf-8','371UkVPvM','log','Verbose\x20output','parse','HTTP_PROXY','getCurrentBaseUrl','https://registry.npmjs.org/','replace','9221530ggwbQr','contextProvider','No\x20CLI\x20context\x20present.\x20Create\x20context\x20with\x20\x27northflank\x20login\x27','option','Display\x20help\x20for\x20command','72kgrpoK','storeOptionsAsProperties','21108065rPwzIM','194196eqiVrz','getDate','No\x20token\x20in\x20CLI\x20context.\x20Add\x20token\x20with\x20\x27northflank\x20set-token\x27','Invalid\x20date\x20received:\x20','yellow','--quiet','env','then','/latest','timeout','padEnd','length'];a16X=function(){return M;};return a16X();}import{fileURLToPath}from'url';import{dirname,join}from'path';const __filename=fileURLToPath(import.meta[a16C(0x17d)]),__dirname=dirname(__filename),pgk=JSON[a16C(0x191)](readFileSync(join(__dirname,'../package.json'),a16C(0x18d)));export const customUserAgent=a16C(0x16b)+pgk?.[a16C(0x178)];export const agent=new ProxyAgent();export const proxyEnvsSet=process[a16C(0x163)][a16C(0x192)]!==undefined||process[a16C(0x163)][a16C(0x172)]!==undefined;export const decodeJwtPayload=X=>{const s=a16C;try{const j=O=>{const B=a16j,F=O[B(0x195)](/-/g,'+')[B(0x195)](/_/g,'/')[B(0x167)](O[B(0x168)]+(0x4-O[B(0x168)]%0x4)%0x4,'=');return JSON[B(0x191)](Buffer[B(0x183)](F,B(0x174))[B(0x173)]());},[V,H]=X[s(0x188)]('.');return j(H);}catch(O){return{};}};export async function checkUpdate(X){const y=a16C;function j(V,H){const S=a16j,O=new Date(Number(V));return O[S(0x18b)](O[S(0x15e)]()+H),O;}try{if(j(X[y(0x180)](),0x1)>new Date())return;const V=pgk[y(0x178)],{name:H}=pgk;if(!V)return;const O=y(0x194)+H+y(0x165),F=await a16H(O,{'agent':agent,'method':y(0x171),'signal':AbortSignal[y(0x166)](0x1388)}),h=(await F[y(0x16e)]())['version'];needsUpdate(V,h)&&warning(y(0x16a)+V+',\x20the\x20latest\x20version\x20of\x20the\x20cli\x20is\x20'+h+'.'+('\x20Consider\x20updating\x20using\x20\x27npm\x20i\x20'+H+'\x20-g\x27\x20or\x20\x27yarn\x20global\x20add\x20'+H+'\x27\x20**')),await X[y(0x182)](new Date());}catch(P){}}function needsUpdate(X,j){const e=a16C,V=/(\.0+)+$/,H=X[e(0x195)](V,'')[e(0x188)]('.'),O=j[e(0x195)](V,'')[e(0x188)]('.');for(let F=0x0;F<Math['min'](H[e(0x168)],O[e(0x168)]);F+=0x1){const h=parseInt(O[F],0xa)-parseInt(H[F],0xa);if(h>0x0)return!![];if(h<0x0)return![];}return O[e(0x168)]>H[e(0x168)];}export function error(X){const A=a16C;console[A(0x186)](a16V[A(0x17c)](A(0x169)+X));}export function warning(X){const l=a16C;console['error'](a16V[l(0x161)](''+X));}export function success(X){const T=a16C;console[T(0x18f)](a16V[T(0x176)](''+X));}export function getCommand(X=![]){const W=a16C,j=new Command();return j['helpOption'](undefined,W(0x159)),j['addHelpCommand'](![]),j[W(0x15b)](![]),j[W(0x177)](![]),j[W(0x18c)](![]),j['enablePositionalOptions'](!![]),X&&(j['option'](W(0x185),W(0x190),![]),j[W(0x158)](W(0x162),'No\x20console\x20output',![]),j[W(0x158)](W(0x17a),W(0x189),![])),j;}export const retry=(X,j=0x32)=>V=>{let H=X;const O=async()=>{try{return await V();}catch(F){if(H<=0x0)throw F;return H-=0x1,await new Promise(h=>setTimeout(()=>h(),j)),O();}};return O();};export const asyncSequential=async(X,j)=>{const v=a16C,V=Promise['resolve']([]);return X[v(0x17b)]((H,O)=>H[v(0x164)](F=>j(O)[v(0x164)](h=>{return F['push'](h),F;})),V);};export function isValidJSON(X){const G=a16C;try{return JSON[G(0x191)](X);}catch(j){return![];}}export function assertContextExisting(X){const d=a16C;if(X[d(0x197)][d(0x175)]()===undefined)throw new Error(d(0x157));if(X['contextProvider'][d(0x193)]()===undefined)throw new Error('No\x20API\x20URL\x20present\x20in\x20context.\x20Create\x20new\x20context\x20with\x20\x27northflank\x20login\x27');if(X['contextProvider'][d(0x170)]()===undefined)throw new Error(d(0x15f));}function a16j(X,j){const V=a16X();return a16j=function(H,O){H=H-0x157;let F=V[H];return F;},a16j(X,j);}export const parseDateInput=X=>{const x=a16C;try{let j=new Date(X);if(isNaN(j[x(0x17f)]())){const V=X[x(0x168)]===0xd?X/0x3e8:X,H=new Date(0x0);H[x(0x16c)](V);if(isNaN(H[x(0x17f)]()))throw new Error();return H;}return j;}catch(O){throw new Error(x(0x160)+X+x(0x184));}};export const tsHint=a16C(0x16f);