mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 22:55:24 +00:00
feat: changelog.md release notes, v tags, plugin release notes and videos
This commit is contained in:
1 parent
b9dd3488a5
commit
9bc2be721b
45 files changed
+1462
-816
No files matched your search
@@ -1,5 +1,6 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { changelogSection } = require("./lib/changelog-section.cjs");
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = {};
|
||||
@@ -24,37 +25,10 @@ function fail(message) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function extractSection(notes, name) {
|
||||
const pattern = new RegExp(
|
||||
`<!--\\s*${name}\\s*-->([\\s\\S]*?)<!--\\s*/${name}\\s*-->`,
|
||||
);
|
||||
const match = notes.match(pattern);
|
||||
if (!match) {
|
||||
fail(`missing <!-- ${name} --> section in release notes`);
|
||||
}
|
||||
const value = match[1].trim();
|
||||
if (!value) {
|
||||
fail(`empty <!-- ${name} --> section in release notes`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function youtubeId(raw) {
|
||||
const value = raw.trim();
|
||||
let match = value.match(/[?&]v=([A-Za-z0-9_-]+)/);
|
||||
if (match) return match[1];
|
||||
match = value.match(/youtu\.be\/([A-Za-z0-9_-]+)/);
|
||||
if (match) return match[1];
|
||||
match = value.match(/embed\/([A-Za-z0-9_-]+)/);
|
||||
if (match) return match[1];
|
||||
if (/^[A-Za-z0-9_-]+$/.test(value)) return value;
|
||||
fail(`could not parse a YouTube video id from "${value}"`);
|
||||
}
|
||||
|
||||
function buildTable(version, mobileVersion) {
|
||||
const tag = `release-${version}-tag`;
|
||||
function buildTable(version, mobileVersion, mobileTag) {
|
||||
const tag = `v${version}`;
|
||||
const base = `https://github.com/Termix-SSH/Termix/releases/download/${tag}`;
|
||||
const mobileBase = `https://github.com/Termix-SSH/Mobile/releases/download/release-${mobileVersion}-tag`;
|
||||
const mobileBase = `https://github.com/Termix-SSH/Mobile/releases/download/${mobileTag || `release-${mobileVersion}-tag`}`;
|
||||
|
||||
const win = (file) => `${base}/${file}`;
|
||||
const linux = (file) => `${base}/${file}`;
|
||||
@@ -71,58 +45,49 @@ function buildTable(version, mobileVersion) {
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
function main() {
|
||||
const args = parseArgs(process.argv.slice(2));
|
||||
const version = args.version;
|
||||
const mobileVersion = args["mobile-version"];
|
||||
const notesPath = args.notes || "RELEASE_NOTES.md";
|
||||
|
||||
if (!version || version === true) fail("--version is required");
|
||||
if (!mobileVersion || mobileVersion === true)
|
||||
fail("--mobile-version is required");
|
||||
|
||||
const resolvedNotes = path.resolve(notesPath);
|
||||
if (!fs.existsSync(resolvedNotes)) {
|
||||
fail(`release notes file not found: ${resolvedNotes}`);
|
||||
}
|
||||
|
||||
const notes = fs.readFileSync(resolvedNotes, "utf8");
|
||||
const summary = extractSection(notes, "SUMMARY");
|
||||
const youtube = extractSection(notes, "YOUTUBE");
|
||||
const updateLog = extractSection(notes, "UPDATE_LOG");
|
||||
const bugFixes = extractSection(notes, "BUG_FIXES");
|
||||
|
||||
const videoId = youtubeId(youtube);
|
||||
const embed = [
|
||||
`<a href="https://youtu.be/${videoId}">`,
|
||||
` <img src="./docs/repo-images/YouTube.png" alt="YouTube" width="500">`,
|
||||
`</a>`,
|
||||
].join("\n");
|
||||
|
||||
const table = buildTable(version, mobileVersion);
|
||||
function buildBody({ version, mobileVersion, mobileTag, changelog }) {
|
||||
const notes = changelogSection(changelog, version);
|
||||
if (!notes) fail(`CHANGELOG.md has no notes for ${version}`);
|
||||
|
||||
const donateAlert = [
|
||||
"> [!TIP]",
|
||||
"> Termix is free and always will be. If it's useful to you, consider [donating](https://donate.termix.site/donate/) to support development.",
|
||||
].join("\n");
|
||||
|
||||
const body = [
|
||||
return [
|
||||
donateAlert,
|
||||
"",
|
||||
summary,
|
||||
notes,
|
||||
"",
|
||||
embed,
|
||||
"### Downloads",
|
||||
"",
|
||||
table,
|
||||
"",
|
||||
"Update Log:",
|
||||
updateLog,
|
||||
"",
|
||||
"Bug Fixes:",
|
||||
bugFixes,
|
||||
buildTable(version, mobileVersion, mobileTag),
|
||||
].join("\n");
|
||||
|
||||
process.stdout.write(body + "\n");
|
||||
}
|
||||
|
||||
main();
|
||||
function main() {
|
||||
const args = parseArgs(process.argv.slice(2));
|
||||
const version = args.version;
|
||||
const mobileVersion = args["mobile-version"];
|
||||
const mobileTag =
|
||||
typeof args["mobile-tag"] === "string" ? args["mobile-tag"] : undefined;
|
||||
const changelogPath = path.resolve(args.changelog || "CHANGELOG.md");
|
||||
|
||||
if (!version || version === true) fail("--version is required");
|
||||
if (!mobileVersion || mobileVersion === true)
|
||||
fail("--mobile-version is required");
|
||||
if (!fs.existsSync(changelogPath)) {
|
||||
fail(`changelog not found: ${changelogPath}`);
|
||||
}
|
||||
|
||||
const changelog = fs.readFileSync(changelogPath, "utf8");
|
||||
process.stdout.write(
|
||||
buildBody({ version, mobileVersion, mobileTag, changelog }) + "\n",
|
||||
);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
main();
|
||||
}
|
||||
|
||||
module.exports = { buildBody };
|
||||
Reference in new issue
Block a user