UNPKG

@ycmd/creds

Version:

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

50 lines (48 loc) 1.43 kB
import { GithubService } from './chunk-WNNF4IDJ.js'; import { GitlabService } from './chunk-FIS3MTUV.js'; import { __name, __require } from './chunk-U2DZE3DI.js'; import { readFile } from 'node:fs/promises'; import { Err } from '@lsk4/err'; import { map } from 'fishbird'; async function upload(serviceDirname, options) { const buildDirDir = options.buildDir || `${serviceDirname}/build`; const config = __require(`${serviceDirname}/config.js`); const serviceName = config.service?.serviceName; if (!serviceName) throw new Err("!serviceName"); let service; if (serviceName === "github") { service = new GithubService({ ...config.service, ...options }); } else if (serviceName === "gitlab") { service = new GitlabService({ ...config.service, ...options }); } else { throw new Err("incorrect serviceName", { serviceName }); } const { files: rawFiles = [], variables, secrets, hooks } = config; const files = await map(rawFiles, async (fileOptions) => { const { filename } = fileOptions; const content = await readFile(`${buildDirDir}/${filename}`).then((f) => f.toString()); return { ...fileOptions, content }; }); await service.uploadAll({ files, variables, secrets, hooks }); } __name(upload, "upload"); export { upload }; //# sourceMappingURL=out.js.map //# sourceMappingURL=chunk-Z3RCUDS6.js.map