Skip to content

Commit

Permalink
add script to create changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
noghartt committed Jan 1, 2025
1 parent 08e5e53 commit ab12720
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"astro": "astro",
"create:article": "tsx ./scripts/new-post.ts",
"create:til": "tsx ./scripts/generate-til",
"create:changelog": "tsx ./scripts/generate-changelog.ts",
"generate:bookmarks": "tsx --env-file=./.env ./scripts/generate-bookmarks-reader.ts"
},
"dependencies": {
Expand Down
24 changes: 24 additions & 0 deletions scripts/generate-changelog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import fs from 'fs/promises';
import path from 'path';

const cwd = process.cwd();

(async () => {
const [, , title] = process.argv;

console.log(title);

const changelogPath = path.join(cwd, 'src', 'content', 'changelog', 'changelog.json');
const changelog = await fs.readFile(changelogPath, 'utf-8');
const changelogParse = JSON.parse(changelog);

const changelogUpdated = [
...changelogParse,
{
time: new Date().toISOString(),
title,
},
];

await fs.writeFile(changelogPath, JSON.stringify(changelogUpdated));
})();

0 comments on commit ab12720

Please sign in to comment.