diff --git a/README.md b/README.md index 163f5b1..903f393 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ That is why we decided to maintain a changelog inside of the VCS that can be upd - [3. Add the extension to your installation](#3-add-the-extension-to-your-installation) - [4. Add your first changelog entry](#4-add-your-first-changelog-entry) - [Release History](#release-history) + - [Version 0.8.1](#version-081) + - [Version 0.8.0](#version-080) - [Future possibilities](#future-possibilities) ## How can I use it? @@ -95,7 +97,18 @@ If you see it: congratulations, your setup works! ## Release History -- [Version 0.8.0](https://github.com/BIX-Digital/directus-version-control-changelog/releases/tag/v0.8.0) / 2022-02-14 -> initial release for Bitbucket +### [Version 0.8.1](https://github.com/BIX-Digital/directus-version-control-changelog/releases/tag/v0.8.1) + +2022-02-22 + +- fixing a bug where a hardcoded field name (not respecting the settings) causes a crash +- improved prefix of extension in logger messages + +### [Version 0.8.0](https://github.com/BIX-Digital/directus-version-control-changelog/releases/tag/v0.8.0) + +2022-02-14 + +- initial release for Bitbucket ## Future possibilities diff --git a/package-lock.json b/package-lock.json index 2a0d52e..efae10f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@bix-digital/directus-extension-version-control-changelog", - "version": "0.8.0", + "version": "0.8.1", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index e684406..52f1a5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bix-digital/directus-extension-version-control-changelog", - "version": "0.8.0", + "version": "0.8.1", "description": "A Directus hook extension to push user written change summaries (from a singleton collection text field) to a changelog in a VCS server", "author": { "name" :"BI X Digital Engineers", diff --git a/src/core/ChangelogWriter.ts b/src/core/ChangelogWriter.ts index 2372670..2286afa 100644 --- a/src/core/ChangelogWriter.ts +++ b/src/core/ChangelogWriter.ts @@ -99,11 +99,18 @@ export default class ChangelogWriter { const changeUserId = this.extractUserId(userDetails[0]); const date = new Date().toLocaleString('en-GB', { hour12: false, timeZone: 'UTC', timeZoneName: 'short' }); - const newData = ChangelogFormatter.formatLatestChanges(event.payload.changes,`## ${date} by ${changeUserId}`); - const commitMsg = `Content update from Directus CMS by ${changeUserId}`; - - // do the actual execution - this.vcsAbstraction.addToChangelogFile(newData, commitMsg); + const changeContent = event.payload[this.extensionConfig.fieldName]; + if (changeContent !== undefined) { + const newData = ChangelogFormatter.formatLatestChanges(changeContent,`## ${date} by ${changeUserId}`); + const commitMsg = `Content update from Directus CMS by ${changeUserId}`; + // do the actual execution + this.vcsAbstraction.addToChangelogFile(newData, commitMsg); + } else { + // it seems there is a change in the monitored collection, but not in the field we're looking at + // so we warn the admin that something that might be not intended is possible + this.loggerReference.logMessage(LogLevels.warn, + 'Things in the changelog collection changed, but not in the monitored field. Make sure this is wanted behavior...'); + } } diff --git a/src/core/ExtensionLogger.ts b/src/core/ExtensionLogger.ts index 9f802e9..d91c3b7 100644 --- a/src/core/ExtensionLogger.ts +++ b/src/core/ExtensionLogger.ts @@ -18,7 +18,7 @@ export default class ExtensionLogger { // using "name" to have it before the message itself based on the used formatter // --> see https://github.com/directus/directus/blob/ee7e678f24fd85846798bc3cc1af3103e728ebb7/api/src/logger.ts#L18 // and https://www.npmjs.com/package/pino-colada - this.loggerReference = directusLogger.child({name: 'Version Control Changelog Extension'}); + this.loggerReference = directusLogger.child({name: 'Version Control Changelog Extension >'}); } /**