jam/scripts/changelog.mjs
Thebora Kompanioni 6a34868e2b
build(deps): update dependencies (#1322)
* build(deps): update dependencies

 @radix-ui/react-accordion      1.2.14  →  1.2.16
 @radix-ui/react-avatar          1.2.0  →   1.2.2
 @radix-ui/react-checkbox        1.3.5  →   1.3.7
 @radix-ui/react-dialog         1.1.17  →  1.1.19
 @radix-ui/react-dropdown-menu  2.1.18  →  2.1.20
 @radix-ui/react-label          2.1.10  →  2.1.11
 @radix-ui/react-popover        1.1.17  →  1.1.19
 @radix-ui/react-radio-group     1.4.1  →   1.4.3
 @radix-ui/react-select          2.3.1  →   2.3.3
 @radix-ui/react-separator      1.1.10  →  1.1.11
 @radix-ui/react-switch          1.3.1  →   1.3.3
 @radix-ui/react-tabs           1.1.15  →  1.1.17
 @radix-ui/react-tooltip        1.2.10  →  1.2.12
 @types/node                    26.0.1  →  26.1.1
 conventional-changelog          7.2.0  →   7.2.1
 lucide-react                   1.22.0  →  1.23.0
 msw                            2.14.6  →  2.15.0
 prettier                        3.9.3  →   3.9.4
 radix-ui                        1.6.0  →   1.6.2
 react-hook-form                7.80.0  →  7.81.0
 typescript-eslint              8.62.1  →  8.63.0
 vite                            8.1.0  →   8.1.3

* build(deps): update eslint-plugin-unicorn to v65.0.1
2026-07-08 23:07:57 +05:30

69 lines
2 KiB
JavaScript

import conventionalChangelog from 'conventional-changelog'
import fs from 'node:fs'
const START_OF_LAST_RELEASE_PATTERN = /(^#+ \[?[0-9]+\.[0-9]+\.[0-9]+|<a name=)/m
const file = 'CHANGELOG.md'
const header = `\
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
`
const types = [
{ type: 'feat', section: 'Added' },
{ type: 'update', section: 'Changed' },
{ type: 'remove', section: 'Removed' },
{ type: 'fix', section: 'Fixed' },
{ type: 'security', section: 'Security' },
{ type: 'chore', hidden: true },
{ type: 'docs', hidden: true },
{ type: 'style', hidden: true },
{ type: 'refactor', hidden: true },
{ type: 'perf', hidden: true },
{ type: 'test', hidden: true },
]
const generateChangelog = (newVersion) => {
return new Promise((resolve, reject) => {
let oldContent = fs.readFileSync(file, 'utf8')
const oldContentStart = oldContent.search(START_OF_LAST_RELEASE_PATTERN)
if (oldContentStart !== -1) {
oldContent = oldContent.substring(oldContentStart)
}
let changelog = ''
const changelogStream = conventionalChangelog(
{
preset: {
name: 'conventionalcommits',
header: header,
types: types,
},
tagPrefix: 'v',
},
{ version: newVersion }
).on('error', function (error) {
return reject(error)
})
changelogStream.on('data', (buffer) => {
changelog += buffer.toString()
})
changelogStream.on('end', () => {
changelog = changelog.replaceAll(/###\s(\w+)/g, '#### $1').replaceAll('\n'.repeat(3), '\n\n')
const finalChangelog = header + '\n' + (changelog + oldContent).replaceAll(/\n+$/, '\n')
fs.writeFileSync(file, finalChangelog, 'utf8')
return resolve()
})
})
}
await generateChangelog(process.env.npm_package_version)