@northflank/cli
Version:
Provides a command-line interface to the Northflank platform.
1 lines • 7.66 kB
JavaScript
const a3q=a3E;(function(m,E){const B=a3E,h=m();while(!![]){try{const I=parseInt(B(0x166))/0x1+parseInt(B(0x1b2))/0x2*(-parseInt(B(0x19a))/0x3)+-parseInt(B(0x1a7))/0x4*(parseInt(B(0x17f))/0x5)+-parseInt(B(0x192))/0x6+-parseInt(B(0x182))/0x7+-parseInt(B(0x1b0))/0x8*(-parseInt(B(0x15f))/0x9)+-parseInt(B(0x1a2))/0xa*(-parseInt(B(0x184))/0xb);if(I===E)break;else h['push'](h['shift']());}catch(T){h['push'](h['shift']());}}}(a3m,0xc2b44));import{ApiClient,CopyType}from'@northflank/js-client';import{assertContextExisting,customUserAgent,getCommand,success}from'../utils.js';import{InquirerHelper}from'../inquirer-helper.js';function a3E(m,E){const h=a3m();return a3E=function(I,T){I=I-0x15c;let e=h[I];return e;},a3E(m,E);}import{capitalize}from'lodash-es';function a3m(){const V=['Connect\x20to\x20specific\x20exec\x20endpoint.','name','Id\x20[NAME]','\x27\x20to\x20local\x20directory\x20\x27','contextProvider','File\x20and\x20directory\x20download\x20for\x20Northflank\x20service.','File\x20and\x20directory\x20upload\x20for\x20Northflank\x20service.','addCommand','getStandardCopyCommand','801cNiLfS','\x20to\x20','askForJob','\x20is\x20required\x20for\x20','askForTeam','FILE_UPLOAD','Remote\x20file\x20or\x20directory','1206421LYgXrP','local','-dir','Path\x20is\x20not\x20specified,\x20the\x20','action','--remote\x20--remotePath\x20[REMOTEPATH]','--noDefaults','alias','files','Instance\x20(pod\x20name)\x20used\x20to\x20','DIRECTORY_DOWNLOAD','download','ensureRelevantPathIsSet','Team\x20id','charAt','s.\x20Please\x20enter\x20a\x20path:','Container\x20used\x20to\x20','File\x20and\x20directory\x20download\x20for\x20Northflank\x20job.','service','Uploaded\x20file\x20from\x20\x27','--container\x20--containerId\x20[NAME]','getCurrentServiceName','\x20(random\x20instance\x20will\x20be\x20chosen\x20if\x20not\x20specified)','FILE_DOWNLOAD','askForProject','5730505QkMNnI','uploadCmd','\x20(random\x20container\x20will\x20be\x20chosen\x20if\x20not\x20specified)','2445443beqNMp','File\x20and\x20directory\x20upload\x20for\x20Northflank\x20job.','20295253RdkQKX','File\x20and\x20directory\x20download\x20for\x20Northflank\x20services\x20and\x20jobs.','\x20file\x20--localPath\x20my_directory/my-file.txt\x20--remotePath\x20/home/my-','--local\x20--localPath\x20[LOCALPATH]','job','Local\x20file\x20or\x20directory','\x20single\x20file:\x20\x20\x20northflank\x20','description','Downloaded\x20file\x20\x27','option','\x20files\x20','\x27\x20to\x20container\x20directory\x20\x27','downloadCmd','logCopyResult','522546RajLFh','\x20directory\x20is\x20used.\x20If\x20the\x20directory\x20for\x20','getCurrentProjectName','askForService','current\x20working','\x27localPath\x27','toUpperCase','askForPath','9lKFQeE','Uploaded\x20all\x20directory\x20contents\x20from\x20\x27','slice','--team\x20--teamId\x20[TEAMID]','org','\x20directory:\x20\x20\x20\x20\x20northflank\x20','Downloaded\x20all\x20directory\x20contents\x20from\x20\x27','file','10iXIxUn','getTokenScope','\x20files','remotePath','askForProjectContext','4RjypEy','from','\x20the\x20specified\x20','\x20--','Project\x20for\x20','--project\x20--projectId\x20[NAME]','apiClient','type','user\x20home','50288oGsPuE','upload','820566qCZFCi'];a3m=function(){return V;};return a3m();}import a3h from'inquirer';export class CliFileCopy{['downloadCmd'];[a3q(0x180)];['apiClient'];['getStandardCopyCommand']=(m,E)=>{const a=a3q,h=capitalize(E),I=E===a(0x1b1)?'remote':a(0x167),T=E===a(0x1b1)?a(0x1af):a(0x196),e=E==='upload'?'to':a(0x1a8),o=getCommand(!![])[a(0x1b4)](a(0x1a1))[a(0x18b)](h+a(0x18e)+e+a(0x1a9)+m+'.\x20If\x20the\x20'+I+a(0x169)+T+a(0x193)+I+'Path\x20does\x20not\x20exist,\x20it\x20will\x20be\x20created.\x0aExamples:\x0a\x20\x20'+h+a(0x18a)+E+'\x20'+m+a(0x186)+E+'ed-file.txt\x0a\x20\x20'+h+a(0x19f)+E+'\x20'+m+'\x20file\x20--localPath\x20my_directory\x20--remotePath\x20/home/'+E+a(0x168))[a(0x18d)](a(0x1ac),a(0x1ab)+E);return this[a(0x1ad)][a(0x1b7)][a(0x1a3)]()===a(0x19e)&&o[a(0x18d)](a(0x19d),a(0x173)),o['option']('--'+m+a(0x1aa)+m+a(0x1b5),m[a(0x174)](0x0)[a(0x198)]()+m[a(0x19c)](0x1)+a(0x160)+E+a(0x1a4))[a(0x18d)]('--instance\x20--instanceName\x20[NAME]',a(0x16f)+E+a(0x17c))['option'](a(0x17a),a(0x176)+E+a(0x181))[a(0x18d)](a(0x187),a(0x189))[a(0x18d)](a(0x16b),a(0x165))[a(0x18d)](a(0x16c),'Don\x27t\x20use\x20context\x20default\x20values,\x20explicitly\x20use\x20options\x20or\x20ask.',![])[a(0x18d)]('--execLocationHint\x20[EXEC-LOCATION-HINT]',a(0x1b3)),o;};constructor(m,E){const R=a3q;this['apiClient']=new ApiClient(m,{'throwErrorOnHttpErrorCode':!![],'customUserAgent':customUserAgent,'agent':E});const h=new InquirerHelper(this['apiClient']);this[R(0x190)]=getCommand()[R(0x1b4)](R(0x171))[R(0x16d)]('dl')['description'](R(0x185)),this[R(0x180)]=getCommand()['name'](R(0x1b1))[R(0x16d)]('ul')[R(0x18b)]('File\x20and\x20directory\x20upload\x20for\x20Northflank\x20services\x20and\x20jobs.');const I=getCommand()[R(0x1b4)](R(0x178))[R(0x18b)](R(0x1b8)),T=getCommand()[R(0x1b4)](R(0x178))[R(0x18b)](R(0x15c)),e=getCommand()[R(0x1b4)]('job')['description'](R(0x177)),o=getCommand()[R(0x1b4)]('job')[R(0x18b)](R(0x183)),g=L=>{const x=R;return this[x(0x15e)](x(0x178),L)[x(0x16a)](async P=>{const D=x,{teamId:X,projectId:W,serviceId:K,containerId:z,instanceName:S,noDefaults:H,quiet:r,execLocationHint:F}=P;assertContextExisting(this[D(0x1ad)]);const t=H?undefined:m[D(0x194)](),{projectId:Y,teamId:N}=await this['askForProjectContext'](m,h,W,X,t),w=H?undefined:m[D(0x17b)](),b=K||w||await h[D(0x195)](Y,N)(),{remotePath:n,localPath:Q}=await this[D(0x172)](L,P),c={'teamId':N,'projectId':Y,'serviceId':b},O=await this[D(0x1ad)][L][D(0x178)]['files'](c,{'containerName':z,'instanceName':S,'localPath':Q,'remotePath':n,'execLocationHint':F});this[D(0x191)](O,r);});},J=L=>{const f=R;return this[f(0x15e)](f(0x188),L)[f(0x16a)](async P=>{const M=f,{projectId:X,teamId:W,jobId:K,instanceName:z,containerId:S,noDefaults:H,quiet:r,execLocationHint:F}=P;assertContextExisting(this[M(0x1ad)]);const t=H?undefined:m[M(0x194)](),{projectId:Y,teamId:N}=await this[M(0x1a6)](m,h,X,W,t),w=K||await h[M(0x161)](Y,N)(),{remotePath:b,localPath:n}=await this[M(0x172)](L,P),Q={'teamId':N,'projectId':Y,'jobId':w},c=await this[M(0x1ad)][L][M(0x188)][M(0x16e)](Q,{'containerName':S,'instanceName':z,'localPath':n,'remotePath':b,'execLocationHint':F});this[M(0x191)](c,r);});};I['addCommand'](g(R(0x171))),e[R(0x15d)](J('download')),T[R(0x15d)](g(R(0x1b1))),o[R(0x15d)](J(R(0x1b1))),this['downloadCmd'][R(0x15d)](I),this[R(0x190)][R(0x15d)](e),this['uploadCmd']['addCommand'](T),this[R(0x180)][R(0x15d)](o);}[a3q(0x1a6)]=async(m,E,h,I,T)=>{const U=a3q,e=m[U(0x1a3)]()===U(0x19e)?I??await E[U(0x163)]()():undefined,o=h||T||await E[U(0x17e)](e)();return{'teamId':e,'projectId':o};};[a3q(0x191)]=(m,E)=>{const C=a3q;if(E)return;const {sourceDirectory:h,targetDirectory:I,sourceFile:T,targetFile:e}=m;switch(m[C(0x1ae)]){case CopyType[C(0x170)]:{success(C(0x1a0)+h+C(0x1b6)+I+'\x27');break;}case CopyType[C(0x17d)]:{success(C(0x18c)+h+'/'+T+'\x27\x20to\x20\x27'+I+'/'+e+'\x27');break;}case CopyType['DIRECTORY_UPLOAD']:{success(C(0x19b)+h+C(0x18f)+I+'\x27');break;}case CopyType[C(0x164)]:{success(C(0x179)+h+'/'+T+'\x27\x20to\x20\x27'+I+'/'+e+'\x27');break;}}};[a3q(0x172)]=async(m,E)=>{const Z=a3q,h=m===Z(0x171)&&E[Z(0x1a5)]===undefined?await this[Z(0x199)]('\x27remotePath\x27','download'):E['remotePath'],I=m===Z(0x1b1)&&E['localPath']===undefined?await this['askForPath'](Z(0x197),'upload'):E['localPath'];return{'localPath':I,'remotePath':h};};[a3q(0x199)]=async(m,E)=>{const i=a3q,h=m+i(0x162)+E+i(0x175);return(await a3h['prompt']([{'type':'input','name':i(0x1b4),'message':h}]))['name'];};}