-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump the changelog file using the bump script (#5963)
* feat: bump changelgo file with bump utility * feat: adapt package scripts to use the manifest changelog * feat: add references to the releasing documentation about bump script and others enhancement * feat: enhance regular expression in bump utility
- Loading branch information
Showing
5 changed files
with
157 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const logger = require('./logger'); | ||
|
||
function updateChangelog( | ||
changelogPath, | ||
{ version, revision, platformVersion }, | ||
) { | ||
if (!changelogPath) { | ||
logger.error( | ||
`changelog file is not defined. Use --manifest-changelog <path/to/file>.`, | ||
); | ||
process.exit(1); | ||
} | ||
const fs = require('fs'); | ||
logger.debug(`Reading file ${changelogPath}`); | ||
const content = fs.readFileSync(changelogPath, 'utf8'); | ||
logger.debug(`Read file ${changelogPath}`); | ||
const reChangelogEntry = `(Wazuh v${version.replace( | ||
/\./g, | ||
'\\.', | ||
)} - [\\w\\s]+) ([\\d.]+) - Revision (\\d+)`; | ||
if (version && (revision || platformVersion)) { | ||
logger.debug( | ||
'Regular expression to find in changelog: ' + reChangelogEntry, | ||
); | ||
if (content.search(reChangelogEntry) > -1) { | ||
const textReplaceEntry = | ||
'$1' + | ||
' ' + | ||
(platformVersion || '$2') + | ||
' ' + | ||
'- Revision' + | ||
' ' + | ||
(revision || '$3'); | ||
logger.debug( | ||
`Update changelog: regular expression ${reChangelogEntry}: ${textReplaceEntry}`, | ||
); | ||
const newContent = content.replace( | ||
new RegExp(reChangelogEntry), | ||
textReplaceEntry, | ||
); | ||
if (newContent !== content) { | ||
logger.debug(`Updating ${changelogPath}`); | ||
fs.writeFileSync(changelogPath, newContent); | ||
logger.info(`Updated ${changelogPath}`); | ||
} | ||
} else { | ||
logger.warn( | ||
`Changelog entry not found for ${[ | ||
{ text: 'version', value: version }, | ||
{ text: 'revision', value: revision }, | ||
{ text: 'platformVersion', value: platformVersion }, | ||
] | ||
.filter(({ value }) => value) | ||
.map(({ text, value }) => `${text}: ${value}`) | ||
.join(', ')}. YOU SHOULD ADD THE ENTRY TO THE CHANGELOG FILE.`, | ||
); | ||
} | ||
} | ||
} | ||
|
||
module.exports = { | ||
updateChangelog: updateChangelog, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters