UNPKG

@ycmd/creds

Version:

LSK.js CLI Creds is the easiest way to manage GitHub / Gitlab secrets and credentials

17 lines (15 loc) 1.9 kB
import { a as a$1 } from './chunk-6FJTHGBR.js'; import { a as a$3 } from './chunk-3EJAMWK5.js'; import { a as a$2 } from './chunk-3I5644NY.js'; import { a, b } from './chunk-CSGQ5YH5.js'; import { Err } from '@lsk4/err'; import { getComment, jsonToFile } from '@lskjs/stringify'; import { mapSeries } from 'fishbird'; import { unlink, mkdir } from 'fs/promises'; async function U(n){let e=`${n}/config.js`;try{return {path:e,config:b(e)}}catch(i){if(Err.getCode(i)==="MODULE_NOT_FOUND")throw a$1.error(`${e} not found`),new Err(`${e} not found`);if(Err.getCode(i).startsWith("Dynamic require of"))try{let r=await import(e);return {path:e,config:r.default||r}}catch(r){throw Err.getCode(r)==="ERR_MODULE_NOT_FOUND"?(a$1.error(`${e} not found`),new Err(`${e} not found`)):r}throw i}}a(U,"loadConfig");async function R(n,e={}){let i=e.log||a$1,r=e.buildDir||`${n}/build`,{path:h,config:c}=await U(n);await unlink(`${r}`).catch(()=>{}),await mkdir(r,{recursive:!0});let a=c.service?.serviceName;if(!a)throw new Err("!serviceName",{data:{configPath:h}});let t;if(a==="github")t=new a$2({...c.service,...e});else if(a==="gitlab")t=new a$3({...c.service,...e});else throw new Err("incorrect serviceName",{serviceName:a});let{files:w=[]}=c;await mapSeries(w,async m=>{let{type:P,filename:s,handler:v}=m,j=await v(m,c),p=getComment({filename:s,values:[["Server",t.getServiceLink()],["Project",t.getProjectPath()],["Project ID",t.getProjectId()],["Project Url",t.getProjectUrl()],["CI/CD Setting",t.getProjectCICDSettingURL()]],footer:t.getProjectCredsUrl()&&` Auto generated by ${t.getProjectCredsUrl()} If you want to change something, please contact admin repo. `.trim()});await jsonToFile(`${r}/${s}`,j,{type:P,compare:!e.force,comment:p}),i.info(`[build] ${t.getProjectPath()} (${s})`);});}a(R,"build"); export { R as a }; //# sourceMappingURL=out.js.map //# sourceMappingURL=chunk-LHXYNF7N.js.map