52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
import fs from "fs-extra";
|
|
import { consola } from "consola";
|
|
import { stringify } from "yaml";
|
|
|
|
const change_types = [
|
|
{ title: "", level: "minor", keywords: [""] },
|
|
{ title: "Features", level: "minor", keywords: ["feat"] },
|
|
{ title: "Bug fixes", level: "patch", keywords: ["fix"] },
|
|
{
|
|
title: "Package maintenance",
|
|
level: "patch",
|
|
keywords: ["chore", "maint", "refactor"],
|
|
},
|
|
{ title: "Statistics", level: "patch", keywords: ["stats"] },
|
|
];
|
|
|
|
export const base_changelog = {
|
|
project: {
|
|
name: null,
|
|
homepage: null,
|
|
with_stats: true,
|
|
},
|
|
releases: [{ version: "NEXT", changes: [] }],
|
|
change_types,
|
|
};
|
|
|
|
const handler = async (config) => {
|
|
if (await fs.pathExists(config.source)) {
|
|
consola.error(`${config.source} already exist, aborting.`);
|
|
process.exit();
|
|
}
|
|
|
|
consola.start(`creating ${config.source}...`);
|
|
|
|
await fs.writeFile(config.source, stringify(base_changelog));
|
|
|
|
consola.success("done!");
|
|
};
|
|
|
|
export default {
|
|
command: "init",
|
|
desc: "initialize new changelog source file",
|
|
builder: (yargs) => {
|
|
yargs
|
|
.boolean("json")
|
|
.boolean("next")
|
|
.default("json", false)
|
|
.default("next", true);
|
|
},
|
|
handler,
|
|
};
|