@ycmd/creds
Version:
LSK.js CLI Creds is the easiest way to manage GitHub / Gitlab secrets and credentials
2 lines • 2.24 kB
JavaScript
var m=Object.defineProperty;var p=(d,e)=>m(d,"name",{value:e,configurable:!0});import{Err as i}from"@lskjs/err";import{log as o}from"@lskjs/log/log";import f from"axios";import{map as u}from"fishbird";var w=class{static{p(this,"Service")}projectId;projectName;projectPath;projectCredsUrl;token;server;force;client;constructor(e){Object.assign(this,e),this.checkConfig();let a={baseURL:this.getBaseUrl(),headers:this.getHeaders()};this.client=f.create(a)}checkConfig(){throw new i("NOT_IMPLEMENTED")}getBaseUrl(){return null}getHeaders(){return{}}getServiceLink(){return null}getProjectName(){return this.projectName}getProjectId(){return this.projectId}getProjectPath(){return this.projectPath}getProjectUrl(){return null}getProjectCredsUrl(){return this.projectCredsUrl}getProjectCICDSettingURL(){return null}async uploadSecret(e,a){throw new i("NOT_IMPLEMENTED")}async uploadVariable(e,a){throw new i("NOT_IMPLEMENTED")}async removeOldHooks(){}async uploadHook(e){}async uploadHooks(e){if(!e)throw new i("!env");let{hooks:a=[]}=e;try{await this.removeOldHooks()}catch(n){o.error("[ERR] Old hooks removing failed:",n.message)}await u(a,async(n,l)=>{try{await this.uploadHook(n),o.info(`[OK] Hook ${l} uploaded`)}catch(t){o.error(`[ERR] Hook ${l} not uploaded:`,t.message)}})}async uploadAll(e){if(!e)throw new i("!env");let{secrets:a={},variables:n={},files:l=[]}=e;await this.uploadHooks(e),await u(Object.entries(a),async([t,r])=>{try{await this.uploadSecret(t,r),o.info(`[OK] Secret ${t} uploaded`)}catch(s){o.error(`[ERR] Secret ${t} not uploaded, because`,s.message),o.error(s)}}),await u(Object.entries(n),async([t,r])=>{try{await this.uploadVariable(t,r),o.info(`[OK] Variable ${t} uploaded`)}catch(s){o.error(`[ERR] Variable ${t} not uploaded, because`,s.message)}}),await u(l,async({name:t,credType:r,content:s})=>{let c=t,h=s;try{if(r==="variable")await this.uploadVariable(c,h);else if(r==="secret")await this.uploadSecret(c,h);else if(r==="skip"){o.debug(`[SKIP] File ${c} uploaded as ${r}`);return}else throw new i("unknown credType",{credType:r});o.info(`[OK] File ${c} uploaded as ${r}`)}catch(g){o.error(`[ERR] File ${c} not uploaded as ${r}, because`,g.message)}})}};export{w as Service};
//# sourceMappingURL=Service.mjs.map