arm-trusted-firmware/.commitlintrc.js

74 lines
2.0 KiB
JavaScript
Raw Normal View History

/*
* Copyright (c) 2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/* eslint-env es6 */
"use strict";
const fs = require("fs");
const yaml = require("js-yaml");
const { "trailer-exists": trailerExists } = require("@commitlint/rules").default;
build(docs): introduce release script This change introduces a new NPM run script to automatically generate the release changelog, as well as bump version numbers across the code-base and create the release tag. This script runs [Standard Version] to execute this, which is a tool designed around automating substantial parts of the release process. This can be done by running: npm run release -- [<standard-version args>] Standard Version expects the project to adhere to the [Semantic Versioning] convention which TF-A does not, so you may need to specify the version manually, e.g.: npm run release -- --release-as 2.6.0 Individual steps of the release process may also be skipped at-will, which may be necessary when, for example, tweaking the changelog: npm run release -- --skip.commit --skip.tag Standard Version is configured by the `.versionrc.js` file, which contains information about the Conventional Commits types and scopes used by the project, and how they map to the changelog. To maintain continuity with the existing changelog style - at least to the extent possible in the move from manual to automatic creation - a customized changelog template has been introduced, based on the Conventional Commits template provided by Standard Version. This template package extends the Conventional Commits template package by introducing support for parsing the Conventional Commits scopes into changelog sections, similarly to how they were previously organized. [Standard Version]: https://github.com/conventional-changelog/standard-version [Semantic Versioning]: https://semver.org Change-Id: I5bafa512daedc631baae951651c38c1c62046b0a Signed-off-by: Chris Kay <chris.kay@arm.com>
2021-11-09 20:05:38 +00:00
/*
* The types and scopes accepted by both Commitlint and Commitizen are defined by the changelog
* configuration file - `changelog.yaml` - as they decide which section of the changelog commits
* with a given type and scope are placed in.
build(docs): introduce release script This change introduces a new NPM run script to automatically generate the release changelog, as well as bump version numbers across the code-base and create the release tag. This script runs [Standard Version] to execute this, which is a tool designed around automating substantial parts of the release process. This can be done by running: npm run release -- [<standard-version args>] Standard Version expects the project to adhere to the [Semantic Versioning] convention which TF-A does not, so you may need to specify the version manually, e.g.: npm run release -- --release-as 2.6.0 Individual steps of the release process may also be skipped at-will, which may be necessary when, for example, tweaking the changelog: npm run release -- --skip.commit --skip.tag Standard Version is configured by the `.versionrc.js` file, which contains information about the Conventional Commits types and scopes used by the project, and how they map to the changelog. To maintain continuity with the existing changelog style - at least to the extent possible in the move from manual to automatic creation - a customized changelog template has been introduced, based on the Conventional Commits template provided by Standard Version. This template package extends the Conventional Commits template package by introducing support for parsing the Conventional Commits scopes into changelog sections, similarly to how they were previously organized. [Standard Version]: https://github.com/conventional-changelog/standard-version [Semantic Versioning]: https://semver.org Change-Id: I5bafa512daedc631baae951651c38c1c62046b0a Signed-off-by: Chris Kay <chris.kay@arm.com>
2021-11-09 20:05:38 +00:00
*/
let changelog;
try {
const contents = fs.readFileSync("changelog.yaml", "utf8");
changelog = yaml.load(contents);
} catch (err) {
console.log(err);
throw err;
}
function getTypes(sections) {
return sections.map(section => section.type)
}
function getScopes(subsections) {
return subsections.flatMap(subsection => {
const scope = subsection.scope ? [ subsection.scope ] : [];
const subscopes = getScopes(subsection.subsections || []);
build(docs): introduce release script This change introduces a new NPM run script to automatically generate the release changelog, as well as bump version numbers across the code-base and create the release tag. This script runs [Standard Version] to execute this, which is a tool designed around automating substantial parts of the release process. This can be done by running: npm run release -- [<standard-version args>] Standard Version expects the project to adhere to the [Semantic Versioning] convention which TF-A does not, so you may need to specify the version manually, e.g.: npm run release -- --release-as 2.6.0 Individual steps of the release process may also be skipped at-will, which may be necessary when, for example, tweaking the changelog: npm run release -- --skip.commit --skip.tag Standard Version is configured by the `.versionrc.js` file, which contains information about the Conventional Commits types and scopes used by the project, and how they map to the changelog. To maintain continuity with the existing changelog style - at least to the extent possible in the move from manual to automatic creation - a customized changelog template has been introduced, based on the Conventional Commits template provided by Standard Version. This template package extends the Conventional Commits template package by introducing support for parsing the Conventional Commits scopes into changelog sections, similarly to how they were previously organized. [Standard Version]: https://github.com/conventional-changelog/standard-version [Semantic Versioning]: https://semver.org Change-Id: I5bafa512daedc631baae951651c38c1c62046b0a Signed-off-by: Chris Kay <chris.kay@arm.com>
2021-11-09 20:05:38 +00:00
return scope.concat(subscopes);
})
};
const types = getTypes(changelog.sections).sort(); /* Sort alphabetically */
const scopes = getScopes(changelog.subsections).sort(); /* Sort alphabetically */
build(docs): introduce release script This change introduces a new NPM run script to automatically generate the release changelog, as well as bump version numbers across the code-base and create the release tag. This script runs [Standard Version] to execute this, which is a tool designed around automating substantial parts of the release process. This can be done by running: npm run release -- [<standard-version args>] Standard Version expects the project to adhere to the [Semantic Versioning] convention which TF-A does not, so you may need to specify the version manually, e.g.: npm run release -- --release-as 2.6.0 Individual steps of the release process may also be skipped at-will, which may be necessary when, for example, tweaking the changelog: npm run release -- --skip.commit --skip.tag Standard Version is configured by the `.versionrc.js` file, which contains information about the Conventional Commits types and scopes used by the project, and how they map to the changelog. To maintain continuity with the existing changelog style - at least to the extent possible in the move from manual to automatic creation - a customized changelog template has been introduced, based on the Conventional Commits template provided by Standard Version. This template package extends the Conventional Commits template package by introducing support for parsing the Conventional Commits scopes into changelog sections, similarly to how they were previously organized. [Standard Version]: https://github.com/conventional-changelog/standard-version [Semantic Versioning]: https://semver.org Change-Id: I5bafa512daedc631baae951651c38c1c62046b0a Signed-off-by: Chris Kay <chris.kay@arm.com>
2021-11-09 20:05:38 +00:00
module.exports = {
extends: ["@commitlint/config-conventional"],
plugins: [
{
rules: {
"signed-off-by-exists": trailerExists,
"change-id-exists": trailerExists,
},
},
],
rules: {
"header-max-length": [1, "always", 50], /* Warning */
"body-max-line-length": [1, "always", 72], /* Warning */
"change-id-exists": [1, "always", "Change-Id:"], /* Warning */
"signed-off-by-exists": [1, "always", "Signed-off-by:"], /* Warning */
build(docs): introduce release script This change introduces a new NPM run script to automatically generate the release changelog, as well as bump version numbers across the code-base and create the release tag. This script runs [Standard Version] to execute this, which is a tool designed around automating substantial parts of the release process. This can be done by running: npm run release -- [<standard-version args>] Standard Version expects the project to adhere to the [Semantic Versioning] convention which TF-A does not, so you may need to specify the version manually, e.g.: npm run release -- --release-as 2.6.0 Individual steps of the release process may also be skipped at-will, which may be necessary when, for example, tweaking the changelog: npm run release -- --skip.commit --skip.tag Standard Version is configured by the `.versionrc.js` file, which contains information about the Conventional Commits types and scopes used by the project, and how they map to the changelog. To maintain continuity with the existing changelog style - at least to the extent possible in the move from manual to automatic creation - a customized changelog template has been introduced, based on the Conventional Commits template provided by Standard Version. This template package extends the Conventional Commits template package by introducing support for parsing the Conventional Commits scopes into changelog sections, similarly to how they were previously organized. [Standard Version]: https://github.com/conventional-changelog/standard-version [Semantic Versioning]: https://semver.org Change-Id: I5bafa512daedc631baae951651c38c1c62046b0a Signed-off-by: Chris Kay <chris.kay@arm.com>
2021-11-09 20:05:38 +00:00
"type-case": [2, "always", "lower-case" ], /* Error */
"type-enum": [2, "always", types], /* Error */
"scope-case": [2, "always", "lower-case"], /* Error */
build(docs): introduce release script This change introduces a new NPM run script to automatically generate the release changelog, as well as bump version numbers across the code-base and create the release tag. This script runs [Standard Version] to execute this, which is a tool designed around automating substantial parts of the release process. This can be done by running: npm run release -- [<standard-version args>] Standard Version expects the project to adhere to the [Semantic Versioning] convention which TF-A does not, so you may need to specify the version manually, e.g.: npm run release -- --release-as 2.6.0 Individual steps of the release process may also be skipped at-will, which may be necessary when, for example, tweaking the changelog: npm run release -- --skip.commit --skip.tag Standard Version is configured by the `.versionrc.js` file, which contains information about the Conventional Commits types and scopes used by the project, and how they map to the changelog. To maintain continuity with the existing changelog style - at least to the extent possible in the move from manual to automatic creation - a customized changelog template has been introduced, based on the Conventional Commits template provided by Standard Version. This template package extends the Conventional Commits template package by introducing support for parsing the Conventional Commits scopes into changelog sections, similarly to how they were previously organized. [Standard Version]: https://github.com/conventional-changelog/standard-version [Semantic Versioning]: https://semver.org Change-Id: I5bafa512daedc631baae951651c38c1c62046b0a Signed-off-by: Chris Kay <chris.kay@arm.com>
2021-11-09 20:05:38 +00:00
"scope-enum": [1, "always", scopes] /* Warning */
},
};