From ab12720bf98189b4f7f1a71ed126f42dfb2af595 Mon Sep 17 00:00:00 2001 From: Guilherme Ananias Date: Wed, 1 Jan 2025 01:41:25 -0300 Subject: [PATCH] add script to create changelog --- package.json | 1 + scripts/generate-changelog.ts | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 scripts/generate-changelog.ts diff --git a/package.json b/package.json index 650779d..6e05fe6 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/scripts/generate-changelog.ts b/scripts/generate-changelog.ts new file mode 100644 index 0000000..fd99141 --- /dev/null +++ b/scripts/generate-changelog.ts @@ -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)); +})();