@northflank/cli
Version:
Provides a command-line interface to the Northflank platform.
1 lines • 7.72 kB
JavaScript
'use strict';const a3N=a3a;function a3S(){const U=['apiClient','download','localPath','lodash','FILE_UPLOAD','\x20file\x20--localPath\x20my_directory\x20--remotePath\x20/home/','askForPath','assertContextExisting','103879SggIvA','throw','charAt','name','2649055sGkdUV','8ZOWJWT','file','133lYnUIz','files','--remote\x20--remotePath\x20[REMOTEPATH]','success','action','\x20single\x20file:\x20\x20\x20northflank\x20','getCurrentProjectName','askForJob','InquirerHelper','--project\x20--projectId\x20[NAME]','alias','customUserAgent','option','Project\x20for\x20','defineProperty','14888uxSPmj','type','askForService','1013740ZMBqEg','File\x20and\x20directory\x20upload\x20for\x20Northflank\x20service.','downloadCmd','current\x20working','ensureRelevantPathIsSet','service','remote','getCommand','CopyType','\x20the\x20specified\x20','CliFileCopy','__awaiter','\x27localPath\x27','Local\x20file\x20or\x20directory','DIRECTORY_DOWNLOAD','getStandardCopyCommand','job','13447332FgaoEn','Path\x20is\x20not\x20specified,\x20the\x20','Uploaded\x20file\x20from\x20\x27','\x27\x20to\x20\x27','\x20directory:\x20\x20\x20\x20\x20northflank\x20','Container\x20used\x20to\x20','upload','--container\x20--containerId\x20[NAME]','s.\x20Please\x20enter\x20a\x20path:','Downloaded\x20all\x20directory\x20contents\x20from\x20\x27','prompt','\x20--','Path\x20does\x20not\x20exist,\x20it\x20will\x20be\x20created.\x0aExamples:\x0a\x20\x20','toUpperCase','-dir','input','next','local','../inquirer-helper','addCommand','\x27\x20to\x20local\x20directory\x20\x27','uploadCmd','\x20is\x20required\x20for\x20','description','File\x20and\x20directory\x20upload\x20for\x20Northflank\x20services\x20and\x20jobs.','remotePath','\x20(random\x20container\x20will\x20be\x20chosen\x20if\x20not\x20specified)','\x20file\x20--localPath\x20my_directory/my-file.txt\x20--remotePath\x20/home/my-','\x20directory\x20is\x20used.\x20If\x20the\x20directory\x20for\x20','FILE_DOWNLOAD','2147577WXajtF','\x27\x20to\x20container\x20directory\x20\x27','getCurrentServiceName','1488882bXowwr','18fXKzOm','__esModule','.\x20If\x20the\x20','logCopyResult','Uploaded\x20all\x20directory\x20contents\x20from\x20\x27','value','inquirer','ApiClient','\x20files\x20'];a3S=function(){return U;};return a3S();}function a3a(S,a){const j=a3S();return a3a=function(v,z){v=v-0x147;let s=j[v];return s;},a3a(S,a);}(function(S,a){const c=a3a,j=S();while(!![]){try{const v=-parseInt(c(0x14c))/0x1*(-parseInt(c(0x198))/0x2)+-parseInt(c(0x194))/0x3*(parseInt(c(0x151))/0x4)+-parseInt(c(0x150))/0x5+parseInt(c(0x197))/0x6+-parseInt(c(0x153))/0x7*(parseInt(c(0x162))/0x8)+parseInt(c(0x176))/0x9+parseInt(c(0x165))/0xa;if(v===a)break;else j['push'](j['shift']());}catch(z){j['push'](j['shift']());}}}(a3S,0xbed7c));var __awaiter=this&&this[a3N(0x170)]||function(S,a,j,v){function z(s){return s instanceof j?s:new j(function(u){u(s);});}return new(j||(j=Promise))(function(s,u){const C=a3a;function g(o){const Z=a3a;try{i(v[Z(0x186)](o));}catch(X){u(X);}}function w(o){const D=a3a;try{i(v[D(0x14d)](o));}catch(X){u(X);}}function i(o){const e=a3a;o['done']?s(o[e(0x19d)]):z(o[e(0x19d)])['then'](g,w);}i((v=v['apply'](S,a||[]))[C(0x186)]());});};Object[a3N(0x161)](exports,a3N(0x199),{'value':!![]}),exports['CliFileCopy']=void 0x0;const js_client_1=require('@northflank/js-client'),utils_1=require('../utils'),inquirer_helper_1=require(a3N(0x188)),lodash_1=require(a3N(0x147)),inquirer=require(a3N(0x19e));class CliFileCopy{constructor(S,a){const q=a3N;this[q(0x174)]=(i,o)=>{const b=q,X=(0x0,lodash_1['capitalize'])(o),T=o===b(0x17c)?b(0x16b):b(0x187),H=o===b(0x17c)?'user\x20home':b(0x168),E=o===b(0x17c)?'to':'from';return(0x0,utils_1[b(0x16c)])(!![])[b(0x14f)](b(0x152))[b(0x18d)](X+b(0x1a0)+E+b(0x16e)+i+b(0x19a)+T+b(0x177)+H+b(0x192)+T+b(0x182)+X+b(0x158)+o+'\x20'+i+b(0x191)+o+'ed-file.txt\x0a\x20\x20'+X+b(0x17a)+o+'\x20'+i+b(0x149)+o+b(0x184))[b(0x15f)](b(0x15c),b(0x160)+o)[b(0x15f)]('--'+i+b(0x181)+i+'Id\x20[NAME]',i[b(0x14e)](0x0)[b(0x183)]()+i['slice'](0x1)+'\x20to\x20'+o+'\x20files')[b(0x15f)](b(0x17d),b(0x17b)+o+b(0x190))[b(0x15f)]('--local\x20--localPath\x20[LOCALPATH]',b(0x172))[b(0x15f)](b(0x155),'Remote\x20file\x20or\x20directory')[b(0x15f)]('--noDefaults','Don\x27t\x20use\x20context\x20default\x20values,\x20explicitly\x20use\x20options\x20or\x20ask.',![]);},this[q(0x19b)]=(i,o)=>{const O=q;if(o)return;const {sourceDirectory:X,targetDirectory:T,sourceFile:H,targetFile:E}=i;switch(i[O(0x163)]){case js_client_1[O(0x16d)][O(0x173)]:{(0x0,utils_1[O(0x156)])(O(0x17f)+X+O(0x18a)+T+'\x27');break;}case js_client_1[O(0x16d)][O(0x193)]:{(0x0,utils_1[O(0x156)])('Downloaded\x20file\x20\x27'+X+'/'+H+O(0x179)+T+'/'+E+'\x27');break;}case js_client_1[O(0x16d)]['DIRECTORY_UPLOAD']:{(0x0,utils_1[O(0x156)])(O(0x19c)+X+O(0x195)+T+'\x27');break;}case js_client_1['CopyType'][O(0x148)]:{(0x0,utils_1[O(0x156)])(O(0x178)+X+'/'+H+O(0x179)+T+'/'+E+'\x27');break;}}},this[q(0x169)]=(i,o)=>__awaiter(this,void 0x0,void 0x0,function*(){const h=q,X=i==='download'&&o[h(0x18f)]===undefined?yield this[h(0x14a)]('\x27remotePath\x27',h(0x1a2)):o['remotePath'],T=i==='upload'&&o['localPath']===undefined?yield this[h(0x14a)](h(0x171),'upload'):o[h(0x1a3)];return{'localPath':T,'remotePath':X};}),this[q(0x14a)]=(i,o)=>__awaiter(this,void 0x0,void 0x0,function*(){const B=q,X=i+B(0x18c)+o+B(0x17e);return(yield inquirer[B(0x180)]([{'type':B(0x185),'name':B(0x14f),'message':X}]))['name'];}),this[q(0x1a1)]=new js_client_1[(q(0x19f))](S,{'throwErrorOnHttpErrorCode':!![],'customUserAgent':utils_1[q(0x15e)],'agent':a});const j=new inquirer_helper_1[(q(0x15b))](this['apiClient']);this[q(0x167)]=(0x0,utils_1[q(0x16c)])()['name']('download')[q(0x15d)]('dl')[q(0x18d)]('File\x20and\x20directory\x20download\x20for\x20Northflank\x20services\x20and\x20jobs.'),this[q(0x18b)]=(0x0,utils_1[q(0x16c)])()[q(0x14f)](q(0x17c))[q(0x15d)]('ul')[q(0x18d)](q(0x18e));const v=(0x0,utils_1[q(0x16c)])()[q(0x14f)](q(0x16a))[q(0x18d)]('File\x20and\x20directory\x20download\x20for\x20Northflank\x20service.'),z=(0x0,utils_1[q(0x16c)])()['name'](q(0x16a))[q(0x18d)](q(0x166)),s=(0x0,utils_1[q(0x16c)])()['name'](q(0x175))[q(0x18d)]('File\x20and\x20directory\x20download\x20for\x20Northflank\x20job.'),u=(0x0,utils_1['getCommand'])()['name'](q(0x175))[q(0x18d)]('File\x20and\x20directory\x20upload\x20for\x20Northflank\x20job.'),g=i=>{const F=q;return this[F(0x174)]('service',i)[F(0x157)](o=>__awaiter(this,void 0x0,void 0x0,function*(){const P=F,{projectId:X,serviceId:T,containerId:H,noDefaults:E,quiet:Y}=o;(0x0,utils_1['assertContextExisting'])(this[P(0x1a1)]);const V=E?undefined:S[P(0x159)](),K=X||V||(yield j['askForProject']()),L=E?undefined:S[P(0x196)](),A=T||L||(yield j[P(0x164)](K)()),{remotePath:Q,localPath:R}=yield this['ensureRelevantPathIsSet'](i,o),M={'projectId':K,'serviceId':A},x=yield this[P(0x1a1)][i]['service'][P(0x154)](M,{'containerName':H,'localPath':R,'remotePath':Q});this[P(0x19b)](x,Y);}));},w=i=>{const m=q;return this[m(0x174)](m(0x175),i)[m(0x157)](o=>__awaiter(this,void 0x0,void 0x0,function*(){const y=m,{projectId:X,jobId:T,containerId:H,noDefaults:E,quiet:Y}=o;(0x0,utils_1[y(0x14b)])(this[y(0x1a1)]);const V=E?undefined:S[y(0x159)](),K=X||V||(yield j['askForProject']()),L=T||(yield j[y(0x15a)](K)()),{remotePath:A,localPath:Q}=yield this[y(0x169)](i,o),R={'projectId':K,'jobId':L},M=yield this[y(0x1a1)][i][y(0x175)][y(0x154)](R,{'containerName':H,'localPath':Q,'remotePath':A});this[y(0x19b)](M,Y);}));};v['addCommand'](g(q(0x1a2))),s['addCommand'](w(q(0x1a2))),z[q(0x189)](g(q(0x17c))),u['addCommand'](w(q(0x17c))),this[q(0x167)][q(0x189)](v),this[q(0x167)][q(0x189)](s),this[q(0x18b)]['addCommand'](z),this['uploadCmd'][q(0x189)](u);}}exports[a3N(0x16f)]=CliFileCopy;