UNPKG

@auto-it/omit-release-notes

Version:

Omit release notes plugin for auto

52 lines 2.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const core_1 = require("@auto-it/core"); const t = tslib_1.__importStar(require("io-ts")); const pattern = t.union([t.string, t.array(t.string)]); const pluginOptions = t.partial({ /** Usernames to omit */ username: pattern, /** Emails to omit */ email: pattern, /** Names to omit */ name: pattern, /** Labels to omit */ labels: pattern, }); /** Ensure a value is an array */ const arrayify = (arr) => (Array.isArray(arr) ? arr : [arr]); /** Filter PRs with release notes that shouldn't make it into a release. */ class ReleaseNotesPlugin { /** Initialize the plugin with it's options */ constructor(options) { /** The name of the plugin */ this.name = "omit-release-notes"; this.options = { username: options.username ? arrayify(options.username) : [], email: options.email ? arrayify(options.email) : [], name: options.name ? arrayify(options.name) : [], labels: options.labels ? arrayify(options.labels) : [], }; } /** Tap into auto plugin points. */ apply(auto) { auto.hooks.validateConfig.tapPromise(this.name, async (name, options) => { if (name === this.name || name === `@auto-it/${this.name}`) { return core_1.validatePluginConfiguration(this.name, pluginOptions, options); } }); auto.hooks.onCreateChangelog.tap(this.name, (changelog) => { changelog.hooks.omitReleaseNotes.tap(this.name, (commit) => { if (commit.authors.find((author) => Boolean(author.name && this.options.name.includes(author.name))) || commit.authors.find((author) => Boolean(author.email && this.options.email.includes(author.email))) || commit.authors.find((author) => Boolean(author.username && this.options.username.includes(author.username))) || commit.labels.find((label) => Boolean(this.options.labels.includes(label)))) { return true; } }); }); } } exports.default = ReleaseNotesPlugin; //# sourceMappingURL=index.js.map