@northflank/cli
Version:
Provides a command-line interface to the Northflank platform.
1 lines • 12.6 kB
JavaScript
;const a15n=a15K;(function(Z,K){const S=a15K,O=Z();while(!![]){try{const g=parseInt(S(0xd8))/0x1+parseInt(S(0xed))/0x2+-parseInt(S(0xf1))/0x3*(parseInt(S(0x9c))/0x4)+-parseInt(S(0xe5))/0x5*(-parseInt(S(0xcd))/0x6)+parseInt(S(0x8d))/0x7*(parseInt(S(0xe4))/0x8)+parseInt(S(0x8c))/0x9+parseInt(S(0xc3))/0xa*(-parseInt(S(0xe1))/0xb);if(g===K)break;else O['push'](O['shift']());}catch(N){O['push'](O['shift']());}}}(a15Z,0xb32d6));function a15Z(){const Z0=['__setModuleDefault','\x20flag\x20or\x20manually\x20append\x20following\x20entry\x20to\x20your\x20hosts\x20file\x20(','forwarding','\x20addon\x20ports','216hqWAbk','throw','next','platform','data','../utils','get','addon','uniq','\x20\x20\x20No\x20running\x20container\x20found\x20for\x20','getCurrentServiceName','1156926yHmbnD','printHostsFileHint','repeat','askForService','warning','http://','noDefaultsText','\x20is\x20exposed\x20on\x20','__createBinding','803627AiwThv','option','\x20service\x20ports','32nrZxut','83145pufuVy','groupBy','skipHostnamesText','apiClient','tunnel-close','SIGINT','port','Cleaning\x20up\x20open\x20connections\x20failed:\x20','1055092cdtdLz','success','skipHostnames','InquirerHelper','2822898pCKnNf','Running\x20in\x20','addCommand','greenBright','__esModule','Port-forwarding\x20for\x20all\x20services\x20and\x20addons\x20in\x20the\x20given\x20project','name','reset','--addon\x20--addonId\x20[NAME]','bold','green','Port-forwarding\x20for\x20the\x20specified\x20addon','\x20\x20\x20\x20\x20\x20\x20\x20\x20','Forwarding\x20addon\x20','flat','Project\x20for\x20forwarding','\x20in\x20project\x20','project\x20for\x20forwarding','\x20\x20If\x20you\x20have\x20added\x20entries\x20to\x20your\x20hosts\x20file,\x20it\x20is\x20recommended\x20to\x20remove\x20them\x20again\x20now.','chalk','\x20is\x20exposed\x20with\x20multiple\x20','type','Failed:\x20','Running\x20on\x20macOS\x20in\x20','\x20\x20-\x20Address:\x20','prototype','then','Port-forwarding\x20for\x20Northflank\x20services\x20and\x20addons.','portName','forEach','configurable','ports','Forwarding\x20service\x20','--project\x20--projectId\x20[NAME]','\x20and\x20','address','log','filter','hosts','1270845VJznSe','1884715DJdydC','all','\x20-\x20','stop','win32','action','assertContextExisting','@northflank/js-client','defineProperty','Services:','CliPortForward','protocol','askForAddon','service','getCurrentProjectName','4xApvor','default','length','askForProject','\x20\x20-\x20port\x20','getCommand','Service\x20to\x20forward','value','Forwarding\x20','getProxyForwarder','\x20with\x20multiple\x20ports:','hostnames','portFwdCmd','entries','Please\x20ensure\x20the\x20','forwardProject','hasOwnProperty','uniqBy','forward','exit','Don\x27t\x20use\x20context\x20default\x20values,\x20explicitly\x20use\x20options\x20or\x20ask.','message','with\x20hostname:\x20','error','join','--skipHostnames','Stop\x20forwarding\x20traffic\x20from\x20','darwin','lodash','__importStar','Only\x20expose\x20on\x20IP\x20address,\x20not\x20on\x20hostnames.\x20With\x20this\x20option,\x20no\x20root\x20permissions\x20are\x20required.','alias','printForwardingInfo','canExecuteWithHostnames','../inquirer-helper','forwardAddon','Port-forwarding\x20for\x20the\x20specified\x20service','ApiClient','Error\x20occured\x20while\x20trying\x20to\x20forward\x20','250sYGTwG','customUserAgent','description','--noDefaults','create','call'];a15Z=function(){return Z0;};return a15Z();}function a15K(Z,K){const O=a15Z();return a15K=function(g,N){g=g-0x79;let H=O[g];return H;},a15K(Z,K);}var __createBinding=this&&this[a15n(0xe0)]||(Object['create']?function(Z,K,O,g){const k=a15n;if(g===undefined)g=O;var N=Object['getOwnPropertyDescriptor'](K,O);(!N||(k(0xd3)in N?!K['__esModule']:N['writable']||N[k(0x83)]))&&(N={'enumerable':!![],'get':function(){return K[O];}}),Object['defineProperty'](Z,g,N);}:function(Z,K,O,g){if(g===undefined)g=O;Z[g]=K[O];}),__setModuleDefault=this&&this[a15n(0xc9)]||(Object[a15n(0xc7)]?function(Z,K){const x=a15n;Object[x(0x95)](Z,'default',{'enumerable':!![],'value':K});}:function(Z,K){Z['default']=K;}),__importStar=this&&this[a15n(0xb9)]||function(Z){const m=a15n;if(Z&&Z[m(0xf5)])return Z;var K={};if(Z!=null){for(var O in Z)if(O!==m(0x9d)&&Object[m(0x7e)][m(0xac)][m(0xc8)](Z,O))__createBinding(K,Z,O);}return __setModuleDefault(K,Z),K;},__awaiter=this&&this['__awaiter']||function(Z,K,O,g){function N(H){return H instanceof O?H:new O(function(o){o(H);});}return new(O||(O=Promise))(function(H,o){const b=a15K;function s(W){const r=a15K;try{y(g[r(0xcf)](W));}catch(B){o(B);}}function R(W){const D=a15K;try{y(g[D(0xce)](W));}catch(B){o(B);}}function y(W){const d=a15K;W['done']?H(W[d(0xa3)]):N(W[d(0xa3)])[d(0x7f)](s,R);}y((g=g['apply'](Z,K||[]))[b(0xcf)]());});},__importDefault=this&&this['__importDefault']||function(Z){const l=a15n;return Z&&Z[l(0xf5)]?Z:{'default':Z};};Object['defineProperty'](exports,a15n(0xf5),{'value':!![]}),exports[a15n(0x97)]=void 0x0;const js_client_1=require(a15n(0x94)),chalk_1=__importDefault(require(a15n(0x104))),utils_1=require(a15n(0xd2)),inquirer_helper_1=require(a15n(0xbe)),os=__importStar(require('os')),lodash_1=require(a15n(0xb8)),{EOL}=require('os');class CliPortForward{constructor(Z,K){const f=a15n;this[f(0xde)]=f(0xb0),this['skipHostnamesText']=f(0xba),this[f(0xe8)]=new js_client_1[(f(0xc1))](Z,{'throwErrorOnHttpErrorCode':!![],'customUserAgent':utils_1[f(0xc4)],'agent':K});const O=new inquirer_helper_1[(f(0xf0))](this[f(0xe8)]);this[f(0xa8)]=(0x0,utils_1['getCommand'])()['name'](f(0xae))[f(0xbb)]('fwd')[f(0xc5)](f(0x80));const g=(0x0,utils_1[f(0xa1)])(!![])[f(0xf7)](f(0x8e))[f(0xc5)](f(0xf6))[f(0xe2)](f(0x86),f(0x102))[f(0xe2)](f(0xc6),this[f(0xde)],![])[f(0xe2)](f(0xb5),this[f(0xe7)],![])['action'](({noDefaults:o,projectId:s,skipHostnames:R})=>__awaiter(this,void 0x0,void 0x0,function*(){const a=f;(0x0,utils_1['assertContextExisting'])(this[a(0xe8)]);const y=this[a(0xa5)](R),W=o?undefined:Z['getCurrentProjectName'](),B=s||W||(yield O[a(0x9f)]());try{const {services:V,addons:M}=yield y[a(0xab)]({'projectId':B},R);if(V['length']+M[a(0x9e)]<=0x0)(0x0,utils_1[a(0xdc)])('No\x20services\x20and\x20addons\x20to\x20forward\x20found\x20in\x20project\x20'+chalk_1[a(0x9d)]['bold'](B));else{const I=V[a(0x8a)](p=>p[a(0x9e)]>0x0)['length'],c=M['filter'](p=>p[a(0x9e)]>0x0)[a(0x9e)],E='\x20in\x20project\x20'+chalk_1[a(0x9d)][a(0xfa)](B);console[a(0x89)](a(0xa4)+chalk_1['default'][a(0xfb)][a(0xfa)](I+a(0xe3))+a(0x87)+chalk_1[a(0x9d)][a(0xfb)][a(0xfa)](c+a(0xcc))+E),console[a(0x89)](),console['log'](chalk_1[a(0x9d)]['bold'](a(0x96))),V[a(0x82)](T=>{const v=a;if(T[v(0x9e)]>=0x1&&!T[0x0]['error'])this[v(0xbc)](T,{'type':v(0x9a),'name':T[0x0][v(0xd1)]['id']},R);}),console[a(0x89)](chalk_1[a(0x9d)][a(0xfa)]('Addons:')),M[a(0x82)](T=>{const L=a;if(T[L(0x9e)]>=0x1&&!T[0x0][L(0xb3)])this[L(0xbc)](T,{'type':L(0xd4),'name':T[0x0][L(0xd1)]['id']},R);}),this['printHostsFileHint']([...V[a(0xff)](),...M[a(0xff)]()],R);}}catch(p){(0x0,utils_1['error'])(a(0x7b)+p['message']);}})),N=(0x0,utils_1[f(0xa1)])(!![])[f(0xf7)]('service')[f(0xc5)](f(0xc0))['option']('--project\x20--projectId\x20[NAME]','Project\x20for\x20forwarding')[f(0xe2)]('--service\x20--serviceId\x20[NAME]',f(0xa2))['option']('--noDefaults',this[f(0xde)],![])[f(0xe2)](f(0xb5),this['skipHostnamesText'],![])['action'](({noDefaults:o,projectId:s,serviceId:R,skipHostnames:y})=>__awaiter(this,void 0x0,void 0x0,function*(){const X=f;(0x0,utils_1[X(0x93)])(this[X(0xe8)]);const W=this[X(0xa5)](y),B=o?undefined:Z[X(0x9b)](),V=s||B||(yield O[X(0x9f)]()),M=o?undefined:Z[X(0xd7)](),I=R||M||(yield O[X(0xdb)](V)());console['log'](X(0x85)+chalk_1[X(0x9d)][X(0xfa)](I)+X(0x101)+chalk_1[X(0x9d)][X(0xfa)](V));try{const c=yield W['forwardService']({'projectId':V,'serviceId':I},y);this['printForwardingInfo'](c,{'name':I,'type':X(0x9a)},y),this[X(0xd9)](c,y);}catch(E){(0x0,utils_1[X(0xb3)])(X(0x7b)+E[X(0xb1)]);}})),H=(0x0,utils_1['getCommand'])(!![])[f(0xf7)](f(0xd4))[f(0xc5)](f(0xfc))['option'](f(0x86),f(0x100))[f(0xe2)](f(0xf9),'Addon\x20to\x20forward')[f(0xe2)]('--skipHostnames',this[f(0xe7)],![])[f(0x92)](({noDefaults:o,projectId:s,addonId:R,skipHostnames:y})=>__awaiter(this,void 0x0,void 0x0,function*(){const e=f;(0x0,utils_1['assertContextExisting'])(this[e(0xe8)]);const W=this[e(0xa5)](y),B=o?undefined:Z['getCurrentProjectName'](),V=s||B||(yield O[e(0x9f)]()),M=R||(yield O[e(0x99)](V)());console[e(0x89)](e(0xfe)+chalk_1[e(0x9d)]['bold'](M)+e(0x101)+chalk_1['default'][e(0xfa)](V));try{const I={'projectId':V,'addonId':M},c=yield W[e(0xbf)](I,y);this[e(0xbc)](c,{'name':M,'type':e(0xd4)},y),this[e(0xd9)](c,y);}catch(E){(0x0,utils_1[e(0xb3)])(e(0x7b)+E[e(0xb1)]);}}));this[f(0xa8)][f(0xf3)](g),this[f(0xa8)][f(0xf3)](N),this[f(0xa8)][f(0xf3)](H);}['getProxyForwarder'](Z=![]){const U=a15n,K=this[U(0xe8)][U(0xcb)];if(!Z){const O=K[U(0xbd)]();if(O[U(0xb3)])throw new Error(O['message']);}return K['on'](U(0xe9),(g,N)=>{const i=U,H=chalk_1[i(0x9d)][i(0xfa)](N['type']+'\x20\x27'+N['id']+'\x27'),o=N[i(0xa7)][i(0x9e)]>0x0;(0x0,utils_1[i(0xdc)])(i(0xb6)+N[i(0x88)]+':'+N[i(0xeb)]+'\x20to\x20'+H),Z&&o&&(0x0,utils_1[i(0xdc)])(i(0x103));}),K['on']('connection-error',(g,N,H)=>{const z=U;(0x0,utils_1[z(0xdc)])('Connection\x20error\x20occurred\x20when\x20forwarding\x20\x27'+N['address']+':'+N[z(0xeb)]+'\x27:\x20\x22'+(H===null||H===void 0x0?void 0x0:H['message'])+'\x22');}),process['on'](U(0xea),()=>__awaiter(this,void 0x0,void 0x0,function*(){const j=U;try{yield K[j(0x90)]();}catch(g){(0x0,utils_1[j(0xb3)])(j(0xec)+g[j(0xb1)]);}finally{process[j(0xaf)]();}})),K;}['printForwardingInfo'](Z,K,O=![]){const G=a15n,{type:g,name:N}=K;if(Z[G(0x9e)]<=0x0){const R=G(0xaa)+K[G(0x7a)]+'\x20is\x20running\x20and\x20reachable.';(0x0,utils_1[G(0xdc)])(G(0xd6)+g+'\x20'+chalk_1[G(0x9d)][G(0xfa)](N)+'.\x20'+R);return;}const H=(0x0,lodash_1[G(0xe6)])(Z,'data.id'),o=y=>'\x20('+(y[G(0x81)]?y[G(0x81)]+G(0x8f):'')+y[G(0x98)]+')';function s(y,W=0x2){const w=G;if(!O){const B=y['protocol']==='HTTP'?w(0xdd):'';y['hostnames'][w(0x82)](V=>{const Q=w;console['log']((0x0,lodash_1[Q(0xda)])('\x20',W)+'-\x20'+B+V+':'+y[Q(0xeb)]);});}}Object[G(0xa9)](H)[G(0x82)](([y,W])=>{const u=G;var B,V;const M='>\x20'+(0x0,lodash_1['capitalize'])(g)+'\x20\x27'+chalk_1[u(0x9d)][u(0xf4)]['bold'](y)+'\x27';if(g==='addon'){if(W[u(0x9e)]===0x1){const I=W[0x0];if(I[u(0xb3)]){(0x0,utils_1['error'])(u(0xc2)+y+':\x20'+I['error'][u(0xb1)]);return;}const c=I['data'],E=!O?'\x20'+chalk_1[u(0x9d)][u(0xf8)](u(0xb2)+c['hostnames'][u(0xb4)](',')):'';(0x0,utils_1[u(0xee)])(M+u(0xdf)+c[u(0x88)]+':'+c[u(0xeb)]+o(c)+E);}else{const p=(0x0,lodash_1[u(0xad)])(W,T=>{const F=u;var J,q;return(q=(J=T===null||T===void 0x0?void 0x0:T[F(0xd1)])===null||J===void 0x0?void 0x0:J[F(0xa7)])===null||q===void 0x0?void 0x0:q[F(0xb4)](',');})[u(0x9e)]>0x1;(0x0,utils_1[u(0xee)])(M+u(0x79)+(p?u(0x8b):u(0x84))+':'),W['forEach'](T=>{const A=u;if(T[A(0xb3)]){(0x0,utils_1[A(0xb3)])('Error\x20occured\x20while\x20trying\x20to\x20forward\x20'+y+':\x20'+T[A(0xb3)]['message']);return;}const J=T[A(0xd1)],q=!O?',\x20hostname:\x20'+J[A(0xa7)]['join'](','):'';console[A(0x89)](A(0x7d)+J[A(0x88)]+':'+J['port']+o(J)+q);});}}if(g===u(0x9a)){if(W[u(0x9e)]===0x1){const T=W[0x0];if(T['error']){(0x0,utils_1[u(0xb3)])(u(0xc2)+y+':\x20'+T[u(0xb3)][u(0xb1)]);return;}const J=T['data'],q=!O?'\x20with\x20these\x20hostnames:':':',Y=J[u(0x88)]+':'+J[u(0xeb)]+o(J);(0x0,utils_1[u(0xee)])(M+u(0xdf)+Y+q),s(J);}else(0x0,utils_1[u(0xee)])(M+'\x20is\x20exposed\x20on\x20'+((V=(B=W[0x0])===null||B===void 0x0?void 0x0:B[u(0xd1)])===null||V===void 0x0?void 0x0:V[u(0x88)])+u(0xa6)),W[u(0x82)](P=>{const h=u;if(P[h(0xb3)]){(0x0,utils_1[h(0xb3)])(h(0xc2)+y+':\x20'+P['error'][h(0xb1)]);return;}const C=P[h(0xd1)];(0x0,utils_1['success'])(h(0xa0)+C[h(0xeb)]+o(C)),s(C,0x4);});}});}[a15n(0xd9)](Z,K=![]){const t=a15n;if(K){const O=Z['flatMap'](W=>W[t(0xd1)])[t(0x8a)](W=>W!==undefined),g=(process===null||process===void 0x0?void 0x0:process[t(0xd0)])===t(0x91),N=os['platform']()===t(0xb7),H=g?'C:/Windows/System32/drivers/etc/hosts':'/etc/hosts',o=chalk_1[t(0x9d)][t(0xfa)](t(0xef)),s=N?EOL+t(0x7c)+o+'\x20mode:\x20the\x20locally\x20forwarded\x20port\x20differs\x20from\x20the\x20actual\x20port\x20on\x20the\x20forwarded\x20service/addon.':undefined;let R=t(0xf2)+o+'\x20mode.\x20If\x20hostname\x20forwarding\x20is\x20required,\x20remove\x20'+t(0xb5)+t(0xca)+H+'):';s!==undefined&&(0x0,utils_1[t(0xdc)])(s!==null&&s!==void 0x0?s:'');(0x0,utils_1[t(0xdc)])(R);const y=O['map'](W=>W['address']+t(0xfd)+W[t(0xa7)][t(0xb4)]('\x20'));console[t(0x89)]((0x0,lodash_1[t(0xd5)])(y)['join'](EOL)),console[t(0x89)]();}}}exports[a15n(0x97)]=CliPortForward;