include the dir entries to the changelog

main
Yanick Champoux 2023-05-18 15:26:47 -04:00
parent f759989698
commit 251dce5b56
4 changed files with 33 additions and 5 deletions

View File

@ -6,18 +6,16 @@ project:
releases:
- version: NEXT
changes:
- add `git-gather` command
- type: feat
desc: " add 'next' to alias to 'upcoming'"
commit: 363c195477231a6b3b770e74ebfe316296ec5af2
desc: add `git-gather` command
- type: feat
desc: add 'next' to alias to 'upcoming'
- type: feat
desc: cutting a release also add a new NEXT release
commit: 167f631d1fe4eadba3ed5fdadbe378b8255d4ad2
- type: feat
desc: git-gather also filters on descs
- type: feat
desc: add the validate command
commit: 5ba75a8e3d42f633e38c3584898ef0085c48fb04
- version: 0.1.0
changes:
- port the core of the Perl changelord to JavaScript.

View File

@ -0,0 +1,2 @@
- desc: support changelog-next directory
type: feat

View File

@ -30,6 +30,7 @@
"consola": "^3.1.0",
"filenamify": "^6.0.0",
"fs-extra": "^11.1.1",
"globby": "^13.1.4",
"markdown-utils": "^1.0.0",
"nanoid": "^4.0.2",
"remeda": "^1.14.0",

View File

@ -23,6 +23,8 @@ import latest, { latest_version } from "./command/latest-version.js";
import validate from "./command/validate.js";
import git_gather from "./command/git-gather.js";
import schemaV1 from "./changelog-schema.js";
import { globby } from "globby";
import { flatMap } from "remeda";
consola.raw = (...args) => console.log(...args);
@ -34,6 +36,27 @@ yargs(hideBin(process.argv))
fs
.readFile(config.source, "utf-8")
.then(yaml.parse)
.then(async (doc) => {
if (!doc.project.next_directory) return doc;
const changes = await globby([
doc.project.next_directory + "/*.yml",
doc.project.next_directory + "/*.yaml",
])
.then((files) =>
Promise.all(
files.map((f) => fs.readFile(f, "utf-8").then(yaml.parse))
)
)
.then((r) => r.flat());
if (changes.length)
doc.releases
.find((r) => r.version === "NEXT")
.changes.push(...changes);
return doc;
})
.then((doc) => {
const ajv = new Ajv();
const validate = ajv.compile(schemaV1);
@ -63,6 +86,7 @@ yargs(hideBin(process.argv))
const filename = join(
dir,
[
new Date().toISOString(),
entry.ticket,
entry.feat,
slugify(entry.desc, {
@ -77,6 +101,9 @@ yargs(hideBin(process.argv))
argv.consola.error(`file ${filename} already exist`);
yargs.exit(1);
}
if (Object.keys(entry).length === 1) {
entry = entry.desc;
}
return fs.writeFile(filename, yaml.stringify([entry]));
}