2021-06-26 16:29:30 +09:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
|
|
import path from "node:path";
|
2023-12-17 19:34:12 +00:00
|
|
|
|
2021-06-26 16:29:30 +09:00
|
|
|
import minimist from "minimist";
|
|
|
|
|
import semver from "semver";
|
2023-12-17 19:34:12 +00:00
|
|
|
|
2021-06-26 16:29:30 +09:00
|
|
|
import {
|
|
|
|
|
changelogUnreleasedDirPath,
|
|
|
|
|
changelogUnreleasedDirs,
|
|
|
|
|
getEntries,
|
|
|
|
|
printEntries,
|
|
|
|
|
replaceVersions,
|
2023-03-28 16:18:53 +08:00
|
|
|
} from "./utils/changelog.js";
|
2021-06-26 16:29:30 +09:00
|
|
|
|
|
|
|
|
const { previousVersion, newVersion } = parseArgv();
|
|
|
|
|
|
|
|
|
|
const entries = changelogUnreleasedDirs.flatMap((dir) => {
|
|
|
|
|
const dirPath = path.join(changelogUnreleasedDirPath, dir.name);
|
|
|
|
|
return getEntries(dirPath);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log(
|
|
|
|
|
replaceVersions(
|
|
|
|
|
printEntries(entries).join("\n\n"),
|
|
|
|
|
previousVersion,
|
|
|
|
|
newVersion,
|
|
|
|
|
/** isPatch */ true,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
function parseArgv() {
|
|
|
|
|
const argv = minimist(process.argv.slice(2));
|
|
|
|
|
const previousVersion = argv["prev-version"];
|
|
|
|
|
const newVersion = argv["new-version"];
|
|
|
|
|
if (
|
|
|
|
|
!previousVersion ||
|
|
|
|
|
!newVersion ||
|
|
|
|
|
semver.compare(previousVersion, newVersion) !== -1
|
|
|
|
|
) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
`Invalid argv, prev-version: ${previousVersion}, new-version: ${newVersion}`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return { previousVersion, newVersion };
|
|
|
|
|
}
|