@eighty4/changelog
Version:
Changelog utilities for CICD
40 lines (35 loc) • 1.02 kB
JavaScript
import { CliError } from "./errors.js";
export function parseArgs(args) {
const opts = {};
let shifted;
while ((shifted = args.shift())) {
switch (shifted) {
case '--repo':
const repo = args.shift();
if (!!repo && /[a-z\d]*\/[a-z\d]*/.test(repo)) {
opts.repo = repo;
}
else {
throw new CliError('--repo must be a `eighty4/changelog` style GitHub repository name');
}
break;
default:
throw new CliError(shifted + ' is not a supported arg');
}
}
if (!('repo' in opts)) {
throw new CliError('--repo is required');
}
return opts;
}
export function makeNewChangelogFromCliArgs(args) {
return makeNewChangelog(parseArgs(args));
}
export function makeNewChangelog(opts) {
return `
- ???
[]: https://github.com/${opts.repo}/commits/main
`;
}