UNPKG

@northflank/cli

Version:

Provides a command-line interface to the Northflank platform.

1 lines 6.65 kB
const a3J=a3j;(function(X,j){const g=a3j,V=X();while(!![]){try{const H=-parseInt(g(0x1e1))/0x1*(-parseInt(g(0x201))/0x2)+-parseInt(g(0x20a))/0x3+parseInt(g(0x1ed))/0x4*(-parseInt(g(0x204))/0x5)+parseInt(g(0x21d))/0x6+-parseInt(g(0x1d6))/0x7+parseInt(g(0x1e2))/0x8*(parseInt(g(0x1ea))/0x9)+-parseInt(g(0x215))/0xa;if(H===j)break;else V['push'](V['shift']());}catch(O){V['push'](V['shift']());}}}(a3X,0xb32bd));import{ApiClient,CopyType}from'@northflank/js-client';import{assertContextExisting,customUserAgent,getCommand,success}from'../utils.js';function a3X(){const I=['download','570573xoBSeM','File\x20and\x20directory\x20download\x20for\x20Northflank\x20service.','alias','4SaLWkq','--project\x20--projectId\x20[NAME]','\x27\x20to\x20container\x20directory\x20\x27','upload','askForProject','prompt','.\x20If\x20the\x20','DIRECTORY_DOWNLOAD','Downloaded\x20file\x20\x27','\x27\x20to\x20\x27','logCopyResult','File\x20and\x20directory\x20upload\x20for\x20Northflank\x20services\x20and\x20jobs.','from','Uploaded\x20file\x20from\x20\x27','File\x20and\x20directory\x20download\x20for\x20Northflank\x20services\x20and\x20jobs.','type','s.\x20Please\x20enter\x20a\x20path:','FILE_UPLOAD','option','File\x20and\x20directory\x20download\x20for\x20Northflank\x20job.','323166fEjtSP','\x20single\x20file:\x20\x20\x20northflank\x20','remotePath','34405ckvMQg','--container\x20--containerId\x20[NAME]','askForService','localPath','\x20the\x20specified\x20','\x20files','1661346xhmxEV','toUpperCase','\x20directory\x20is\x20used.\x20If\x20the\x20directory\x20for\x20','FILE_DOWNLOAD','\x20files\x20','files','service','--remote\x20--remotePath\x20[REMOTEPATH]','\x20to\x20','\x27localPath\x27','remote','541280iufTNc','Downloaded\x20all\x20directory\x20contents\x20from\x20\x27','getStandardCopyCommand','description','local','File\x20and\x20directory\x20upload\x20for\x20Northflank\x20service.','ed-file.txt\x0a\x20\x20','askForPath','4243362xXhTOE','slice','job','Local\x20file\x20or\x20directory','-dir','name','askForJob','\x27\x20to\x20local\x20directory\x20\x27','\x27remotePath\x27','2410065hGIjtD','uploadCmd','ensureRelevantPathIsSet','current\x20working','action','Don\x27t\x20use\x20context\x20default\x20values,\x20explicitly\x20use\x20options\x20or\x20ask.','apiClient','Remote\x20file\x20or\x20directory','Path\x20is\x20not\x20specified,\x20the\x20','downloadCmd','\x20file\x20--localPath\x20my_directory/my-file.txt\x20--remotePath\x20/home/my-','1BtRqXc','104eLbpQY','--noDefaults','addCommand','Project\x20for\x20','Id\x20[NAME]','DIRECTORY_UPLOAD','getCurrentProjectName'];a3X=function(){return I;};return a3X();}import{InquirerHelper}from'../inquirer-helper.js';import{capitalize}from'lodash-es';function a3j(X,j){const V=a3X();return a3j=function(H,O){H=H-0x1d0;let F=V[H];return F;},a3j(X,j);}import a3V from'inquirer';export class CliFileCopy{[a3J(0x1df)];[a3J(0x1d7)];['apiClient'];['getStandardCopyCommand']=(X,j)=>{const b=a3J,V=capitalize(j),H=j===b(0x1f0)?b(0x214):b(0x219),O=j===b(0x1f0)?'user\x20home':b(0x1d9),F=j===b(0x1f0)?'to':b(0x1f9);return getCommand(!![])[b(0x1d2)]('file')[b(0x218)](V+b(0x20e)+F+b(0x208)+X+b(0x1f3)+H+b(0x1de)+O+b(0x20c)+H+'Path\x20does\x20not\x20exist,\x20it\x20will\x20be\x20created.\x0aExamples:\x0a\x20\x20'+V+b(0x202)+j+'\x20'+X+b(0x1e0)+j+b(0x21b)+V+'\x20directory:\x20\x20\x20\x20\x20northflank\x20'+j+'\x20'+X+'\x20file\x20--localPath\x20my_directory\x20--remotePath\x20/home/'+j+b(0x1d1))[b(0x1ff)](b(0x1ee),b(0x1e5)+j)['option']('--'+X+'\x20--'+X+b(0x1e6),X['charAt'](0x0)[b(0x20b)]()+X[b(0x21e)](0x1)+b(0x212)+j+b(0x209))[b(0x1ff)](b(0x205),'Container\x20used\x20to\x20'+j+'\x20(random\x20container\x20will\x20be\x20chosen\x20if\x20not\x20specified)')[b(0x1ff)]('--local\x20--localPath\x20[LOCALPATH]',b(0x1d0))[b(0x1ff)](b(0x211),b(0x1dd))[b(0x1ff)](b(0x1e3),b(0x1db),![]);};constructor(X,j){const E=a3J;this[E(0x1dc)]=new ApiClient(X,{'throwErrorOnHttpErrorCode':!![],'customUserAgent':customUserAgent,'agent':j});const V=new InquirerHelper(this[E(0x1dc)]);this['downloadCmd']=getCommand()[E(0x1d2)](E(0x1e9))[E(0x1ec)]('dl')[E(0x218)](E(0x1fb)),this[E(0x1d7)]=getCommand()['name'](E(0x1f0))['alias']('ul')['description'](E(0x1f8));const H=getCommand()[E(0x1d2)](E(0x210))['description'](E(0x1eb)),O=getCommand()[E(0x1d2)]('service')['description'](E(0x21a)),F=getCommand()['name']('job')[E(0x218)](E(0x200)),h=getCommand()[E(0x1d2)]('job')[E(0x218)]('File\x20and\x20directory\x20upload\x20for\x20Northflank\x20job.'),P=C=>{const t=E;return this[t(0x217)](t(0x210),C)[t(0x1da)](async B=>{const Z=t,{projectId:s,serviceId:S,containerId:y,noDefaults:e,quiet:A}=B;assertContextExisting(this['apiClient']);const l=e?undefined:X[Z(0x1e8)](),T=s||l||await V[Z(0x1f1)](),W=e?undefined:X['getCurrentServiceName'](),v=S||W||await V[Z(0x206)](T)(),{remotePath:G,localPath:d}=await this[Z(0x1d8)](C,B),x={'projectId':T,'serviceId':v},M=await this[Z(0x1dc)][C][Z(0x210)][Z(0x20f)](x,{'containerName':y,'localPath':d,'remotePath':G});this[Z(0x1f7)](M,A);});},o=C=>{const w=E;return this[w(0x217)](w(0x21f),C)[w(0x1da)](async B=>{const N=w,{projectId:s,jobId:S,containerId:y,noDefaults:e,quiet:A}=B;assertContextExisting(this['apiClient']);const l=e?undefined:X['getCurrentProjectName'](),T=s||l||await V['askForProject'](),W=S||await V[N(0x1d3)](T)(),{remotePath:v,localPath:G}=await this[N(0x1d8)](C,B),d={'projectId':T,'jobId':W},x=await this[N(0x1dc)][C]['job'][N(0x20f)](d,{'containerName':y,'localPath':G,'remotePath':v});this[N(0x1f7)](x,A);});};H[E(0x1e4)](P('download')),F[E(0x1e4)](o(E(0x1e9))),O[E(0x1e4)](P(E(0x1f0))),h[E(0x1e4)](o('upload')),this[E(0x1df)][E(0x1e4)](H),this[E(0x1df)]['addCommand'](F),this[E(0x1d7)][E(0x1e4)](O),this[E(0x1d7)][E(0x1e4)](h);}[a3J(0x1f7)]=(X,j)=>{const p=a3J;if(j)return;const {sourceDirectory:V,targetDirectory:H,sourceFile:O,targetFile:F}=X;switch(X[p(0x1fc)]){case CopyType[p(0x1f4)]:{success(p(0x216)+V+p(0x1d4)+H+'\x27');break;}case CopyType[p(0x20d)]:{success(p(0x1f5)+V+'/'+O+p(0x1f6)+H+'/'+F+'\x27');break;}case CopyType[p(0x1e7)]:{success('Uploaded\x20all\x20directory\x20contents\x20from\x20\x27'+V+p(0x1ef)+H+'\x27');break;}case CopyType[p(0x1fe)]:{success(p(0x1fa)+V+'/'+O+p(0x1f6)+H+'/'+F+'\x27');break;}}};[a3J(0x1d8)]=async(X,j)=>{const m=a3J,V=X===m(0x1e9)&&j[m(0x203)]===undefined?await this[m(0x21c)](m(0x1d5),m(0x1e9)):j['remotePath'],H=X===m(0x1f0)&&j[m(0x207)]===undefined?await this[m(0x21c)](m(0x213),m(0x1f0)):j[m(0x207)];return{'localPath':H,'remotePath':V};};['askForPath']=async(X,j)=>{const k=a3J,V=X+'\x20is\x20required\x20for\x20'+j+k(0x1fd);return(await a3V[k(0x1f2)]([{'type':'input','name':'name','message':V}]))[k(0x1d2)];};}