Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@headsdown/sdk",
"version": "0.2.13",
"version": "0.2.14",
"description": "TypeScript client SDK for the HeadsDown availability API",
"type": "module",
"main": "./dist/index.js",
Expand All @@ -27,6 +27,8 @@
"schema:sync": "node scripts/schema-sync.mjs",
"codegen:types": "node scripts/codegen-types.mjs",
"codegen": "npm run codegen:types",
"preversion": "git diff --exit-code CHANGELOG.md && (echo 'Error: Update CHANGELOG.md before bumping version' && exit 1) || exit 0",
"version": "node scripts/update-changelog.mjs && git add CHANGELOG.md",
"prepare": "npm run build",
"prepublishOnly": "npm run build",
"clean": "rm -rf dist"
Expand Down
24 changes: 24 additions & 0 deletions scripts/update-changelog.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import fs from "node:fs";
import { execSync } from "node:child_process";

const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"));
const version = pkg.version;
const changelogPath = "./CHANGELOG.md";

let changelog = fs.readFileSync(changelogPath, "utf8");

// Check if version already exists in changelog to avoid duplicates
if (changelog.includes(`## ${version}`)) {
process.exit(0);
}

// Insert the new version header after the main title
const titleLine = "# Changelog\n";
if (changelog.startsWith(titleLine)) {
const newContent = `${titleLine}\n## ${version}\n\n- (Add changes here)\n${changelog.slice(titleLine.length)}`;
fs.writeFileSync(changelogPath, newContent);
console.log(`Updated ${changelogPath} with version ${version}`);
} else {
console.error('CHANGELOG.md does not start with "# Changelog"');
process.exit(1);
}