diff --git a/CHANGELOG.yml b/CHANGELOG.yml index 9fd2765..8464b6e 100644 --- a/CHANGELOG.yml +++ b/CHANGELOG.yml @@ -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. diff --git a/changelog-next/2023-05-18T19:24:44.720Z-support_ch.yml b/changelog-next/2023-05-18T19:24:44.720Z-support_ch.yml new file mode 100644 index 0000000..d117f58 --- /dev/null +++ b/changelog-next/2023-05-18T19:24:44.720Z-support_ch.yml @@ -0,0 +1,2 @@ +- desc: support changelog-next directory + type: feat diff --git a/package.json b/package.json index 3725072..0a27a57 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/changelord.js b/src/changelord.js index 83c3579..1dd55d4 100755 --- a/src/changelord.js +++ b/src/changelord.js @@ -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])); }