Compare commits
No commits in common. "d826b4191dcad554bd84b4209912323fc96362da" and "e7f70f3aece8912bbef3359972126420273e37b0" have entirely different histories.
d826b4191d
...
e7f70f3aec
@ -8,11 +8,7 @@ releases:
|
|||||||
changes:
|
changes:
|
||||||
- add `git-gather` command
|
- add `git-gather` command
|
||||||
- type: feat
|
- type: feat
|
||||||
desc: " add 'next' to alias to 'upcoming'"
|
desc: add 'next' to alias to 'upcoming'
|
||||||
commit: 363c195477231a6b3b770e74ebfe316296ec5af2
|
|
||||||
- type: feat
|
|
||||||
desc: cutting a release also add a new NEXT release
|
|
||||||
commit: 167f631d1fe4eadba3ed5fdadbe378b8255d4ad2
|
|
||||||
- version: 0.1.0
|
- version: 0.1.0
|
||||||
changes:
|
changes:
|
||||||
- port the core of the Perl changelord to JavaScript.
|
- port the core of the Perl changelord to JavaScript.
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^2.8.8",
|
||||||
"typescript": "^5.0.4",
|
|
||||||
"vitest": "^0.31.0"
|
"vitest": "^0.31.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import yaml from "yaml";
|
|||||||
import fs from "fs-extra";
|
import fs from "fs-extra";
|
||||||
import consola from "consola";
|
import consola from "consola";
|
||||||
import u from "@yanick/updeep-remeda";
|
import u from "@yanick/updeep-remeda";
|
||||||
import { once } from "remeda";
|
|
||||||
|
|
||||||
import print from "./command/print.js";
|
import print from "./command/print.js";
|
||||||
import init from "./command/init.js";
|
import init from "./command/init.js";
|
||||||
@ -21,53 +20,48 @@ import git_gather from "./command/git-gather.js";
|
|||||||
consola.raw = (...args) => console.log(...args);
|
consola.raw = (...args) => console.log(...args);
|
||||||
|
|
||||||
yargs(hideBin(process.argv))
|
yargs(hideBin(process.argv))
|
||||||
.middleware((config) => {
|
.middleware((config) => {
|
||||||
config.consola = consola;
|
config.consola = consola;
|
||||||
config.changelog = once(() =>
|
config.changelog = () =>
|
||||||
fs.readFile(config.source, "utf-8").then(yaml.parse)
|
fs.readFile(config.source, "utf-8").then(yaml.parse);
|
||||||
);
|
config.next_release = next_release.bind(config);
|
||||||
config.save_changelog = async (changelog) => {
|
config.latest_version = latest_version.bind(config);
|
||||||
if (!changelog) changelog = await config.changelog();
|
return config;
|
||||||
return fs.writeFile(config.source, yaml.stringify(changelog));
|
})
|
||||||
};
|
.middleware((argv) => {
|
||||||
config.next_release = next_release.bind(config);
|
argv.add_to_next = async (entry) => {
|
||||||
config.latest_version = latest_version.bind(config);
|
const changelog = yaml.parse(await fs.readFile(argv.source, "utf-8"));
|
||||||
return config;
|
|
||||||
})
|
|
||||||
.middleware((argv) => {
|
|
||||||
argv.add_to_next = async (entry) => {
|
|
||||||
const changelog = yaml.parse(await fs.readFile(argv.source, "utf-8"));
|
|
||||||
|
|
||||||
let next = changelog.releases.find(u.matches({ version: "NEXT" }));
|
let next = changelog.releases.find(u.matches({ version: "NEXT" }));
|
||||||
if (!next) {
|
if (!next) {
|
||||||
next = { version: "NEXT", changes: [] };
|
next = { version: "NEXT", changes: [] };
|
||||||
changelog.releases.unshift(next);
|
changelog.releases.unshift(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(entry).length === 1) {
|
if (Object.keys(entry).length === 1) {
|
||||||
entry = entry.desc;
|
entry = entry.desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
next.changes.push(entry);
|
next.changes.push(entry);
|
||||||
|
|
||||||
return fs.writeFile(argv.source, yaml.stringify(changelog));
|
return fs.writeFile(argv.source, yaml.stringify(changelog));
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.default("source", join(process.cwd(), "CHANGELOG.yml"))
|
.default("source", join(process.cwd(), "CHANGELOG.yml"))
|
||||||
.describe("source", "changelog source")
|
.describe("source", "changelog source")
|
||||||
.command(init)
|
.command(init)
|
||||||
.command(add)
|
.command(add)
|
||||||
.command(print)
|
.command(print)
|
||||||
.command(cut)
|
.command(cut)
|
||||||
.command(schema)
|
.command(schema)
|
||||||
.command(upcoming)
|
.command(upcoming)
|
||||||
.command({
|
.command({
|
||||||
...upcoming,
|
...upcoming,
|
||||||
command: "next",
|
command: "next",
|
||||||
desc: 'alias for "upcoming"',
|
desc: 'alias for "upcoming"',
|
||||||
})
|
})
|
||||||
.command(latest)
|
.command(latest)
|
||||||
.command(git_gather)
|
.command(git_gather)
|
||||||
.strictCommands()
|
.strictCommands()
|
||||||
.help()
|
.help()
|
||||||
.parse();
|
.parse();
|
||||||
|
@ -4,8 +4,6 @@ import u from "@yanick/updeep-remeda";
|
|||||||
import semverInc from "semver/functions/inc.js";
|
import semverInc from "semver/functions/inc.js";
|
||||||
import { simpleGit } from "simple-git";
|
import { simpleGit } from "simple-git";
|
||||||
|
|
||||||
import { base_next_version } from "../utils.js";
|
|
||||||
|
|
||||||
const code_churn = async (previous_version) => {
|
const code_churn = async (previous_version) => {
|
||||||
previous_version = previous_version
|
previous_version = previous_version
|
||||||
? "v" + previous_version.version
|
? "v" + previous_version.version
|
||||||
@ -16,8 +14,7 @@ const code_churn = async (previous_version) => {
|
|||||||
|
|
||||||
const handler = async (config) => {
|
const handler = async (config) => {
|
||||||
config.consola.start("cutting the next version...");
|
config.consola.start("cutting the next version...");
|
||||||
|
const changelog = yaml.parse(await fs.readFile(config.source, "utf-8"));
|
||||||
const changelog = await config.changelog();
|
|
||||||
|
|
||||||
const next = changelog.releases.find(u.matches({ version: "NEXT" }));
|
const next = changelog.releases.find(u.matches({ version: "NEXT" }));
|
||||||
|
|
||||||
@ -43,7 +40,7 @@ const handler = async (config) => {
|
|||||||
next.changes.map(({ type }) => type_to_level(type))
|
next.changes.map(({ type }) => type_to_level(type))
|
||||||
);
|
);
|
||||||
|
|
||||||
if (changelog.project?.with_stats) {
|
if (changelog.project.with_stats) {
|
||||||
next.changes.push({
|
next.changes.push({
|
||||||
type: "stats",
|
type: "stats",
|
||||||
desc: "code churn:" + (await code_churn(previous_version)),
|
desc: "code churn:" + (await code_churn(previous_version)),
|
||||||
@ -55,13 +52,10 @@ const handler = async (config) => {
|
|||||||
bumper
|
bumper
|
||||||
);
|
);
|
||||||
|
|
||||||
// add a new NEXT
|
|
||||||
changelog.releases.unshift(base_next_version);
|
|
||||||
|
|
||||||
if (config.dry) {
|
if (config.dry) {
|
||||||
config.consola.info("running in dry mode, not saving\n", next);
|
config.consola.info("running in dry mode, not saving\n", next);
|
||||||
} else {
|
} else {
|
||||||
await config.save_changelog(changelog);
|
await fs.writeFile(config.source, yaml.stringify(changelog));
|
||||||
}
|
}
|
||||||
|
|
||||||
config.consola.success(`version ${next.version} is cut!`);
|
config.consola.success(`version ${next.version} is cut!`);
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
import { test, expect, vi } from "vitest";
|
|
||||||
import cut from "./cut.js";
|
|
||||||
|
|
||||||
test("add a new NEXT", async () => {
|
|
||||||
const changelog = {
|
|
||||||
releases: [{ version: "NEXT", changes: [] }, { version: "1.0.0" }],
|
|
||||||
};
|
|
||||||
|
|
||||||
const noop = () => {};
|
|
||||||
const config = {
|
|
||||||
consola: {
|
|
||||||
start: noop,
|
|
||||||
success: noop,
|
|
||||||
},
|
|
||||||
changelog: () => changelog,
|
|
||||||
save_changelog: noop,
|
|
||||||
};
|
|
||||||
|
|
||||||
await cut.handler(config);
|
|
||||||
|
|
||||||
expect(changelog.releases[0].version).toBe("NEXT");
|
|
||||||
expect(changelog.releases).toHaveLength(3);
|
|
||||||
});
|
|
@ -1,6 +0,0 @@
|
|||||||
export const base_next_version = {
|
|
||||||
version: "NEXT",
|
|
||||||
changes: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.freeze(base_next_version);
|
|
Loading…
Reference in New Issue
Block a user