UNPKG

@northflank/cli

Version:

Provides a command-line interface to the Northflank platform.

1 lines 7.66 kB
'use strict';const a3n=a3K;(function(Z,K){const S=a3K,O=Z();while(!![]){try{const g=-parseInt(S(0xc4))/0x1*(parseInt(S(0xb9))/0x2)+-parseInt(S(0x112))/0x3*(parseInt(S(0xb5))/0x4)+-parseInt(S(0x104))/0x5*(-parseInt(S(0xe3))/0x6)+-parseInt(S(0x100))/0x7+-parseInt(S(0xe1))/0x8+-parseInt(S(0x103))/0x9*(-parseInt(S(0xd2))/0xa)+parseInt(S(0xc2))/0xb;if(g===K)break;else O['push'](O['shift']());}catch(N){O['push'](O['shift']());}}}(a3Z,0xc3302));var __awaiter=this&&this[a3n(0xe8)]||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 r=a3K;function s(W){const k=a3K;try{y(g[k(0xb7)](W));}catch(B){o(B);}}function R(W){const x=a3K;try{y(g[x(0xfd)](W));}catch(B){o(B);}}function y(W){const m=a3K;W[m(0xdc)]?H(W[m(0xc9)]):N(W[m(0xc9)])[m(0xcb)](s,R);}y((g=g[r(0xc6)](Z,K||[]))[r(0xb7)]());});};function a3K(Z,K){const O=a3Z();return a3K=function(g,N){g=g-0xb1;let H=O[g];return H;},a3K(Z,K);}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports[a3n(0xd7)]=void 0x0;const js_client_1=require('@northflank/js-client'),utils_1=require(a3n(0x10f)),inquirer_helper_1=require(a3n(0xde)),lodash_1=require(a3n(0xf1)),inquirer=require('inquirer');class CliFileCopy{constructor(Z,K){const D=a3n;this[D(0xe9)]=(y,W)=>{const d=D,B=(0x0,lodash_1[d(0xd9)])(W),V=W===d(0xe5)?d(0xc5):d(0xf9),M=W===d(0xe5)?d(0x111):'current\x20working',I=W===d(0xe5)?'to':d(0xb1);return(0x0,utils_1[d(0xf5)])(!![])[d(0xd8)]('file')[d(0x101)](B+d(0xbf)+I+d(0xb3)+y+d(0xd6)+V+'Path\x20is\x20not\x20specified,\x20the\x20'+M+'\x20directory\x20is\x20used.\x20If\x20the\x20directory\x20for\x20'+V+d(0xe7)+B+'\x20single\x20file:\x20\x20\x20northflank\x20'+W+'\x20'+y+d(0xfb)+W+'ed-file.txt\x0a\x20\x20'+B+d(0xdb)+W+'\x20'+y+'\x20file\x20--localPath\x20my_directory\x20--remotePath\x20/home/'+W+d(0xcd))[d(0xb8)]('--project\x20--projectId\x20[NAME]',d(0xd5)+W)[d(0xb8)]('--'+y+d(0xcc)+y+d(0x106),y[d(0xda)](0x0)[d(0x10e)]()+y[d(0x113)](0x1)+d(0xdd)+W+d(0xea))['option']('--container\x20--containerId\x20[NAME]',d(0xba)+W+'\x20(random\x20container\x20will\x20be\x20chosen\x20if\x20not\x20specified)')[d(0xb8)](d(0xc0),d(0xb2))[d(0xb8)](d(0xc7),d(0xce))[d(0xb8)](d(0xfe),d(0x102),![]);},this[D(0xf0)]=(y,W)=>{const b=D;if(W)return;const {sourceDirectory:B,targetDirectory:V,sourceFile:M,targetFile:I}=y;switch(y[b(0xbe)]){case js_client_1[b(0xeb)][b(0xca)]:{(0x0,utils_1['success'])(b(0x10b)+B+b(0xf6)+V+'\x27');break;}case js_client_1[b(0xeb)][b(0xef)]:{(0x0,utils_1[b(0x105)])(b(0xf3)+B+'/'+M+b(0xdf)+V+'/'+I+'\x27');break;}case js_client_1[b(0xeb)][b(0xc8)]:{(0x0,utils_1[b(0x105)])('Uploaded\x20all\x20directory\x20contents\x20from\x20\x27'+B+b(0xe4)+V+'\x27');break;}case js_client_1[b(0xeb)][b(0x108)]:{(0x0,utils_1['success'])(b(0xd4)+B+'/'+M+b(0xdf)+V+'/'+I+'\x27');break;}}},this[D(0x10c)]=(y,W)=>__awaiter(this,void 0x0,void 0x0,function*(){const l=D,B=y===l(0x109)&&W[l(0xb6)]===undefined?yield this[l(0xbc)]('\x27remotePath\x27','download'):W['remotePath'],V=y===l(0xe5)&&W[l(0xb4)]===undefined?yield this[l(0xbc)](l(0xf4),l(0xe5)):W[l(0xb4)];return{'localPath':V,'remotePath':B};}),this[D(0xbc)]=(y,W)=>__awaiter(this,void 0x0,void 0x0,function*(){const f=D,B=y+'\x20is\x20required\x20for\x20'+W+f(0xec);return(yield inquirer[f(0x110)]([{'type':f(0x107),'name':f(0xd8),'message':B}]))[f(0xd8)];}),this[D(0xee)]=new js_client_1[(D(0xed))](Z,{'throwErrorOnHttpErrorCode':!![],'customUserAgent':utils_1['customUserAgent'],'agent':K});const O=new inquirer_helper_1[(D(0xf7))](this[D(0xee)]);this[D(0xbd)]=(0x0,utils_1[D(0xf5)])()[D(0xd8)]('download')['alias']('dl')['description'](D(0xd0)),this['uploadCmd']=(0x0,utils_1[D(0xf5)])()['name'](D(0xe5))['alias']('ul')[D(0x101)](D(0xc3));const g=(0x0,utils_1[D(0xf5)])()[D(0xd8)](D(0xd1))[D(0x101)](D(0xf2)),N=(0x0,utils_1[D(0xf5)])()[D(0xd8)](D(0xd1))['description'](D(0xe0)),H=(0x0,utils_1[D(0xf5)])()[D(0xd8)](D(0xfa))[D(0x101)](D(0xbb)),o=(0x0,utils_1['getCommand'])()['name']('job')[D(0x101)](D(0xff)),s=y=>{const a=D;return this[a(0xe9)]('service',y)[a(0xe6)](W=>__awaiter(this,void 0x0,void 0x0,function*(){const v=a,{projectId:B,serviceId:V,containerId:M,noDefaults:I,quiet:c}=W;(0x0,utils_1[v(0xc1)])(this[v(0xee)]);const E=I?undefined:Z[v(0xe2)](),p=B||E||(yield O[v(0x10a)]()),T=I?undefined:Z[v(0xcf)](),J=V||T||(yield O['askForService'](p)()),{remotePath:q,localPath:Y}=yield this[v(0x10c)](y,W),P={'projectId':p,'serviceId':J},C=yield this[v(0xee)][y][v(0xd1)]['files'](P,{'containerName':M,'localPath':Y,'remotePath':q});this[v(0xf0)](C,c);}));},R=y=>{const L=D;return this[L(0xe9)](L(0xfa),y)['action'](W=>__awaiter(this,void 0x0,void 0x0,function*(){const X=L,{projectId:B,jobId:V,containerId:M,noDefaults:I,quiet:c}=W;(0x0,utils_1['assertContextExisting'])(this[X(0xee)]);const E=I?undefined:Z[X(0xe2)](),p=B||E||(yield O[X(0x10a)]()),T=V||(yield O[X(0xd3)](p)()),{remotePath:J,localPath:q}=yield this[X(0x10c)](y,W),Y={'projectId':p,'jobId':T},P=yield this['apiClient'][y][X(0xfa)][X(0xfc)](Y,{'containerName':M,'localPath':q,'remotePath':J});this[X(0xf0)](P,c);}));};g['addCommand'](s(D(0x109))),H[D(0x10d)](R(D(0x109))),N[D(0x10d)](s(D(0xe5))),o[D(0x10d)](R('upload')),this[D(0xbd)][D(0x10d)](g),this['downloadCmd']['addCommand'](H),this[D(0xf8)]['addCommand'](N),this[D(0xf8)][D(0x10d)](o);}}function a3Z(){const e=['charAt','\x20directory:\x20\x20\x20\x20\x20northflank\x20','done','\x20to\x20','../inquirer-helper','\x27\x20to\x20\x27','File\x20and\x20directory\x20upload\x20for\x20Northflank\x20service.','11032016OdMFje','getCurrentProjectName','6370326KJzHYn','\x27\x20to\x20container\x20directory\x20\x27','upload','action','Path\x20does\x20not\x20exist,\x20it\x20will\x20be\x20created.\x0aExamples:\x0a\x20\x20','__awaiter','getStandardCopyCommand','\x20files','CopyType','s.\x20Please\x20enter\x20a\x20path:','ApiClient','apiClient','FILE_DOWNLOAD','logCopyResult','lodash','File\x20and\x20directory\x20download\x20for\x20Northflank\x20service.','Downloaded\x20file\x20\x27','\x27localPath\x27','getCommand','\x27\x20to\x20local\x20directory\x20\x27','InquirerHelper','uploadCmd','local','job','\x20file\x20--localPath\x20my_directory/my-file.txt\x20--remotePath\x20/home/my-','files','throw','--noDefaults','File\x20and\x20directory\x20upload\x20for\x20Northflank\x20job.','6740048frbGUY','description','Don\x27t\x20use\x20context\x20default\x20values,\x20explicitly\x20use\x20options\x20or\x20ask.','4047561oZxRYu','5xagdbi','success','Id\x20[NAME]','input','FILE_UPLOAD','download','askForProject','Downloaded\x20all\x20directory\x20contents\x20from\x20\x27','ensureRelevantPathIsSet','addCommand','toUpperCase','../utils','prompt','user\x20home','6753PTlRjY','slice','from','Local\x20file\x20or\x20directory','\x20the\x20specified\x20','localPath','2740ufUagQ','remotePath','next','option','745348pavVNn','Container\x20used\x20to\x20','File\x20and\x20directory\x20download\x20for\x20Northflank\x20job.','askForPath','downloadCmd','type','\x20files\x20','--local\x20--localPath\x20[LOCALPATH]','assertContextExisting','38989665lEczHc','File\x20and\x20directory\x20upload\x20for\x20Northflank\x20services\x20and\x20jobs.','1wHUthx','remote','apply','--remote\x20--remotePath\x20[REMOTEPATH]','DIRECTORY_UPLOAD','value','DIRECTORY_DOWNLOAD','then','\x20--','-dir','Remote\x20file\x20or\x20directory','getCurrentServiceName','File\x20and\x20directory\x20download\x20for\x20Northflank\x20services\x20and\x20jobs.','service','10nihzxN','askForJob','Uploaded\x20file\x20from\x20\x27','Project\x20for\x20','.\x20If\x20the\x20','CliFileCopy','name','capitalize'];a3Z=function(){return e;};return a3Z();}exports[a3n(0xd7)]=CliFileCopy;