Browse Source

refactor(hooks): replace cz-conventional-changelog with cz-commitlint

This change replaces cz-conventional-changelog with cz-commitlint, which
automatically configures Commitizen using our commitlint configuration
file. Currently, we use some manual Javascript magic to load our
Commitizen configuration into commitlint (the opposite of what's
introduced by this change), which can be removed.

With this change, we also move our commitlint configuration into a
new `changelog.yaml` file. This file holds the same data as `.cz.json`
previously did.

Change-Id: I14ff2308f1a0b2b293c2128b28ca2df578ce9c1c
Signed-off-by: Chris Kay <chris.kay@arm.com>
Chris Kay 2 years ago
parent
commit
f64c55826e
7 changed files with 1570 additions and 1089 deletions
  1. 34 12
      .commitlintrc.js
  2. 1 840
      .cz.json
  3. 46 16
      .versionrc.js
  4. 931 0
      changelog.yaml
  5. 4 5
      docs/process/commit-style.rst
  6. 550 213
      package-lock.json
  7. 4 3
      package.json

+ 34 - 12
.commitlintrc.js

@@ -8,26 +8,44 @@
 
 "use strict";
 
-const cz = require("./.cz.json");
+const fs = require("fs");
+const yaml = require("js-yaml");
+
 const { "trailer-exists": trailerExists } = require("@commitlint/rules").default;
 
 /*
- * Recursively fetch the project's supported scopes from the Commitizen configuration file. We use
- * permit only the blessed scope for each section to encourage developers to use a consistent scope
- * scheme.
+ * 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.
  */
-function getScopes(sections) {
-    return sections.flatMap(section => {
-        const scopes = section.scopes;
-        const subscopes = getScopes(section.sections || []);
 
-        const scope = scopes ? [ scopes[0] ] : []; /* Only use the blessed scope */
+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 || []);
 
         return scope.concat(subscopes);
     })
 };
 
-const scopes = getScopes(cz.sections); /* Contains every blessed scope */
+const types = getTypes(changelog.sections).sort(); /* Sort alphabetically */
+const scopes = getScopes(changelog.subsections).sort(); /* Sort alphabetically */
 
 module.exports = {
     extends: ["@commitlint/config-conventional"],
@@ -40,13 +58,17 @@ module.exports = {
         },
     ],
     rules: {
-        "header-max-length": [1, "always", cz.maxHeaderWidth], /* Warning */
-        "body-max-line-length": [1, "always", cz.maxLineWidth], /* Warning */
+        "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 */
 
+        "type-case": [2, "always", "lower-case" ], /* Error */
+        "type-enum": [2, "always", types], /* Error */
+
         "scope-case": [2, "always", "lower-case"], /* Error */
+        "scope-empty": [2, "never"], /* Error */
         "scope-enum": [1, "always", scopes] /* Warning */
     },
 };

+ 1 - 840
.cz.json

@@ -1,842 +1,3 @@
 {
-    "path": "./node_modules/cz-conventional-changelog",
-    "maxHeaderWidth": 50,
-    "maxLineWidth": 72,
-    "types": [
-        {
-            "type": "feat",
-            "title": "New Features",
-            "description": "A new feature"
-        },
-        {
-            "type": "fix",
-            "title": "Resolved Issues",
-            "description": "A bug fix"
-        },
-        {
-            "type": "build",
-            "title": "Build System",
-            "description": "Changes that affect the build system or external dependencies",
-            "hidden": true
-        },
-        {
-            "type": "ci",
-            "title": "Continuous Integration",
-            "description": "Changes to our CI configuration files and scripts",
-            "hidden": true
-        },
-        {
-            "type": "docs",
-            "title": "Build System",
-            "description": "Documentation-only changes",
-            "hidden": true
-        },
-        {
-            "type": "perf",
-            "title": "Performance Improvements",
-            "description": "A code change that improves performance",
-            "hidden": true
-        },
-        {
-            "type": "refactor",
-            "title": "Code Refactoring",
-            "description": "A code change that neither fixes a bug nor adds a feature",
-            "hidden": true
-        },
-        {
-            "type": "revert",
-            "title": "Reverted Changes",
-            "description": "Changes that revert a previous change",
-            "hidden": true
-        },
-        {
-            "type": "style",
-            "title": "Style",
-            "description": "Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)",
-            "hidden": true
-        },
-        {
-            "type": "test",
-            "title": "Tests",
-            "description": "Adding missing tests or correcting existing tests",
-            "hidden": true
-        },
-        {
-            "type": "chore",
-            "title": "Miscellaneous",
-            "description": "Any other change",
-            "hidden": true
-        }
-    ],
-    "sections": [
-        {
-            "title": "Architecture",
-            "sections": [
-                {
-                    "title": "Activity Monitors Extension (FEAT_AMU)",
-                    "scopes": ["amu"]
-                },
-                {
-                    "title": "Support for the `HCRX_EL2` register (FEAT_HCX)",
-                    "scopes": ["hcx"]
-                },
-                {
-                    "title": "Memory Partitioning and Monitoring (MPAM) Extension (FEAT_MPAM)",
-                    "scopes": ["mpam"]
-                },
-                {
-                    "title": "Scalable Matrix Extension (FEAT_SME)",
-                    "scopes": ["sme"]
-                },
-                {
-                    "title": "Scalable Vector Extension (FEAT_SVE)",
-                    "scopes": ["sve"]
-                },
-                {
-                    "title": "System Register Trace Extensions (FEAT_ETMv4, FEAT_ETE and FEAT_ETEv1.1)",
-                    "scopes": ["sys-reg-trace", "sys_reg_trace"]
-                },
-                {
-                    "title": "Trace Buffer Extension (FEAT_TRBE)",
-                    "scopes": ["trbe"]
-                },
-                {
-                    "title": "Self-hosted Trace Extension (FEAT_TRF)",
-                    "scopes": ["trf"]
-                }
-            ]
-        },
-        {
-            "title": "Platforms",
-            "sections": [
-                {
-                    "title": "Allwinner",
-                    "scopes": ["allwinner", "plat/allwinner"]
-                },
-                {
-                    "title": "Arm",
-                    "scopes": ["arm", "plat/arm"],
-                    "sections": [
-                        {
-                            "title": "FPGA",
-                            "scopes": ["fpga", "arm_fgpa", "arm_fpga", "plat/arm_fpga"]
-                        },
-                        {
-                            "title": "FVP",
-                            "scopes": ["fvp", "plat/fvp"]
-                        },
-                        {
-                            "title": "FVP-R",
-                            "scopes": ["fvp-r", "fvp_r"]
-                        },
-                        {
-                            "title": "Juno",
-                            "scopes": ["juno"]
-                        },
-                        {
-                            "title": "Morello",
-                            "scopes": ["morello"]
-                        },
-                        {
-                            "title": "RD",
-                            "scopes": ["rd"],
-                            "sections": [
-                                {
-                                    "title": "RD-N2",
-                                    "scopes": ["rdn2", "board/rdn2"]
-                                }
-                            ]
-                        },
-                        {
-                            "title": "SGI",
-                            "scopes": ["sgi", "plat/sgi", "plat/arm/sgi" ]
-                        },
-                        {
-                            "title": "TC",
-                            "scopes": ["tc"],
-                            "sections": [
-                                {
-                                    "title": "TC0",
-                                    "scopes": ["tc0", "plat/tc0"]
-                                }
-                            ]
-                        }
-                    ]
-                },
-                {
-                    "title": "Marvell",
-                    "scopes": ["marvell", "plat/marvell"],
-                    "sections": [
-                        {
-                            "title": "Armada",
-                            "scopes": ["armada", "plat/marvell/armada"],
-                            "sections": [
-                                {
-                                    "title": "A3K",
-                                    "scopes": ["a3k", "plat/marvell/a3k"]
-                                },
-                                {
-                                    "title": "A8K",
-                                    "scopes": ["a8k", "plat/marvell/a8k"]
-                                }
-                            ]
-                        }
-                    ]
-                },
-                {
-                    "title": "MediaTek",
-                    "scopes": ["mediatek", "plat/mediatek/common", "plat/mediatek"],
-                    "sections": [
-                        {
-                            "title": "MT8183",
-                            "scopes": ["mt8183", "plat/mediatek/mt8183"]
-                        },
-                        {
-                            "title": "MT8192",
-                            "scopes": ["mt8192", "plat/mdeiatek/mt8192"]
-                        },
-                        {
-                            "title": "MT8195",
-                            "scopes": ["mt8195", "plat/mediatek/me8195", "plat/mediatek/mt8195", "plat/mdeiatek/mt8195"]
-                        },
-                        {
-                            "title": "MT8186",
-                            "scopes": ["mt8186", "plat/mediatek/mt8186"]
-                        }
-                    ]
-                },
-                {
-                    "title": "NVIDIA",
-                    "scopes": ["nvidia"],
-                    "sections": [
-                        {
-                            "title": "Tegra",
-                            "scopes": ["tegra", "plat/tegra"],
-                            "sections": [
-                                {
-                                    "title": "Tegra 132",
-                                    "scopes": ["tegra132"]
-                                }
-                            ]
-                        }
-                    ]
-                },
-                {
-                    "title": "NXP",
-                    "scopes": ["nxp", "plat/nxp", "plat/nxp/common"],
-                    "sections": [
-                        {
-                            "title": "i.MX",
-                            "scopes": ["imx", "plat/imx", "plat/imx/imx"],
-                            "sections": [
-                                {
-                                    "title": "i.MX 8M",
-                                    "scopes": ["imx8m", "plat/imx8m", "plat/imx/imx8m"],
-                                    "sections": [
-                                        {
-                                            "title": "i.MX 8M Mini",
-                                            "scopes": ["imx8mm", "plat/imx/imx8m/imx8mm"]
-                                        },
-                                        {
-                                            "title": "i.MX 8M Plus",
-                                            "scopes": ["imx8mp", "plat/imx/imx8m/imx8mp"]
-                                        }
-                                    ]
-                                }
-                            ]
-                        },
-                        {
-                            "title": "Layerscape",
-                            "scopes": ["layerscape", "docs/nxp/layerscape"],
-                            "sections": [
-                                {
-                                    "title": "LX2",
-                                    "scopes": ["lx2", "plat/nxp/lx2"],
-                                    "sections": [
-                                        {
-                                            "title": "LX216",
-                                            "scopes": ["lx216", "plat/nxp/lx216x"],
-                                            "sections": [
-                                                {
-                                                    "title": "LX2160",
-                                                    "scopes": ["lx2160", "plat/soc-lx2160"]
-                                                }
-                                            ]
-                                        },
-                                        {
-                                            "title": "LS1028A",
-                                            "scopes": ["ls1028a", "plat/nxp/ls1028a"],
-                                            "sections": [
-                                                {
-                                                    "title": "LS1028ARDB",
-                                                    "scopes": ["ls1028ardb", "plat/nxp/ls1028ardb"]
-                                                }
-                                            ]
-                                        }
-                                    ]
-                                }
-                            ]
-                        }
-                    ]
-                },
-                {
-                    "title": "QEMU",
-                    "scopes": ["qemu", "plat/qemu"]
-                },
-                {
-                    "title": "QTI",
-                    "scopes": ["qti"],
-                    "sections": [
-                        {
-                            "title": "SC1780",
-                            "scopes": ["sc7180", "plat/qti/sc7180"]
-                        },
-                        {
-                            "title": "SC7280",
-                            "scopes": ["sc7280", "plat/qti/sc7280"]
-                        }
-                    ]
-                },
-                {
-                    "title": "Raspberry Pi",
-                    "scopes": ["rpi"],
-                    "sections": [
-                        {
-                            "title": "Raspberry Pi 4",
-                            "scopes": ["rpi4"]
-                        }
-                    ]
-                },
-                {
-                    "title": "Renesas",
-                    "scopes": ["renesas"],
-                    "sections": [
-                        {
-                            "title": "R-Car",
-                            "scopes": ["rcar", "plat/rcar"],
-                            "sections": [
-                                {
-                                    "title": "R-Car 3",
-                                    "scopes": ["rcar3", "plat/rcar3"]
-                                }
-                            ]
-                        }
-                    ]
-                },
-                {
-                    "title": "Rockchip",
-                    "scopes": ["rockchip"],
-                    "sections": [
-                        {
-                            "title": "RK3399",
-                            "scopes": ["rk3399", "rockchip/rk3399", "rk3399/suspend"]
-                        }
-                    ]
-                },
-                {
-                    "title": "Socionext",
-                    "scopes": ["socionext"],
-                    "sections": [
-                        {
-                            "title": "Synquacer",
-                            "scopes": ["synquacer", "plat/synquacer"]
-                        }
-                    ]
-                },
-                {
-                    "title": "ST",
-                    "scopes": ["st", "plat/st"],
-                    "sections": [
-                        {
-                            "title": "ST32MP1",
-                            "scopes": ["stm32mp1", "plat/st/stm32mp1"]
-                        }
-                    ]
-                },
-                {
-                    "title": "Xilinx",
-                    "scopes": ["xilinx", "plat/xilinx"],
-                    "sections": [
-                        {
-                            "title": "Versal",
-                            "scopes": ["versal", "plat/xilinx/versal/include", "plat/xilinx/versal", "plat/versal"]
-                        },
-                        {
-                            "title": "ZynqMP",
-                            "scopes": ["zynqmp", "plat/zynqmp", "plat/xilinx/zynqmp"]
-                        }
-                    ]
-                }
-            ]
-        },
-        {
-            "title": "Bootloader Images",
-            "scopes": ["bl", "bl_common"],
-            "sections": [
-                {
-                    "title": "BL1",
-                    "scopes": ["bl1"]
-                },
-                {
-                    "title": "BL2",
-                    "scopes": ["bl2"]
-                }
-            ]
-        },
-        {
-            "title": "Services",
-            "scopes": ["services"],
-            "sections": [
-                {
-                    "title": "FF-A",
-                    "scopes": ["ffa", "ff-a"]
-                },
-                {
-                    "title": "RME",
-                    "scopes": ["rme"]
-                },
-                {
-                    "title": "SPM",
-                    "scopes": ["spm", "spmc", "spmd", "SPMD", "spm_mm"]
-                }
-            ]
-        },
-        {
-            "title": "Libraries",
-            "sections": [
-                {
-                    "title": "CPU Support",
-                    "scopes": ["cpus", "cpu", "errata", "errata_report"]
-                },
-                {
-                    "title": "EL3 Runtime",
-                    "scopes": ["el3-runtime", "el3_runtime"]
-                },
-                {
-                    "title": "FCONF",
-                    "scopes": ["fconf"]
-                },
-                {
-                    "title": "MPMM",
-                    "scopes": ["mpmm"]
-                },
-                {
-                    "title": "OP-TEE",
-                    "scopes": ["optee", "lib/optee"]
-                },
-                {
-                    "title": "PSCI",
-                    "scopes": ["psci"]
-                },
-                {
-                    "title": "GPT",
-                    "scopes": ["gpt", "gpt_rme"]
-                },
-                {
-                    "title": "SMCCC",
-                    "scopes": ["smccc"]
-                },
-                {
-                    "title": "Translation Tables",
-                    "scopes": ["xlat"]
-                }
-            ]
-        },
-        {
-            "title": "Drivers",
-            "sections": [
-                {
-                    "title": "Authentication",
-                    "scopes": ["auth", "driver/auth"],
-                    "sections": [
-                        {
-                            "title": "CryptoCell-713",
-                            "scopes": ["cc-713"]
-                        }
-                    ]
-                },
-                {
-                    "title": "FWU",
-                    "scopes": ["fwu", "fwu_metadata"]
-                },
-                {
-                    "title": "I/O",
-                    "scopes": ["io"],
-                    "sections": [
-                        {
-                            "title": "MTD",
-                            "scopes": ["mtd", "io_mtd"]
-                        }
-                    ]
-                },
-                {
-                    "title": "Measured Boot",
-                    "scopes": ["measured-boot", "measured boot", "measured_boot"]
-                },
-                {
-                    "title": "MMC",
-                    "scopes": ["mmc", "drivers/mmc"]
-                },
-                {
-                    "title": "MTD",
-                    "scopes": ["mtd", "drivers/mtd"],
-                    "sections": [
-                        {
-                            "title": "NAND",
-                            "scopes": ["nand"],
-                            "sections": [
-                                {
-                                    "title": "SPI NAND",
-                                    "scopes": ["spi-nand", "spi_nand"]
-                                }
-                            ]
-                        }
-                    ]
-                },
-                {
-                    "title": "SCMI",
-                    "scopes": ["scmi", "scmi_common", "drivers/scmi-msg"]
-                },
-                {
-                    "title": "UFS",
-                    "scopes": ["ufs"]
-                },
-                {
-                    "title": "Arm",
-                    "scopes": ["arm-drivers"],
-                    "sections": [
-                        {
-                            "title": "Ethos-N",
-                            "scopes": ["ethos-n", "drivers/arm/ethosn"]
-                        },
-                        {
-                            "title": "GIC",
-                            "scopes": ["gic"],
-                            "sections": [
-                                {
-                                    "title": "GICv3",
-                                    "scopes": ["gicv3"],
-                                    "sections": [
-                                        {
-                                            "title": "GIC-600AE",
-                                            "scopes": ["gic600ae"]
-                                        }
-                                    ]
-                                }
-                            ]
-                        },
-                        {
-                            "title": "TZC",
-                            "scopes": ["tzc"],
-                            "sections": [
-                                {
-                                    "title": "TZC-400",
-                                    "scopes": ["tzc400", "drivers/tzc400"]
-                                }
-                            ]
-                        }
-                    ]
-                },
-                {
-                    "title": "Marvell",
-                    "scopes": ["marvell-drivers"],
-                    "sections": [
-                        {
-                            "title": "COMPHY",
-                            "scopes": ["marvell-comphy", "drivers/marvell/comphy"],
-                            "sections": [
-                                {
-                                    "title": "Armada 3700",
-                                    "scopes": ["marvell-comphy-3700", "drivers/marvell/comphy-3700"]
-                                },
-                                {
-                                    "title": "CP110",
-                                    "scopes": ["marvell-comphy-cp110", "drivers/marvell/comphy-cp110"]
-                                }
-                            ]
-                        },
-                        {
-                            "title": "UART",
-                            "scopes": ["marvell-uart", "plat/marvell/uart"]
-                        },
-                        {
-                            "title": "Armada",
-                            "scopes": ["armada-drivers"],
-                            "sections": [
-                                {
-                                    "title": "A3K",
-                                    "scopes": ["a3k-drivers"],
-                                    "sections": [
-                                        {
-                                            "title": "A3720",
-                                            "scopes": ["a3720-uart", "plat/marvell/a3720/uart"]
-                                        }
-                                    ]
-                                }
-                            ]
-                        }
-                    ]
-                },
-                {
-                    "title": "MediaTek",
-                    "scopes": ["mediatek-drivers"],
-                    "sections": [
-                        {
-                            "title": "APU",
-                            "scopes": ["mediatek-apu", "plat/mediatek/apu"]
-                        },
-                        {
-                            "title": "EMI MPU",
-                            "scopes": ["mediatek-emi-mpu", "plat/mediatek/mpu"]
-                        },
-                        {
-                            "title": "PMIC Wrapper",
-                            "scopes": ["mediatek-pmic-wrapper", "plat/mediatek/pmic_wrap"]
-                        },
-                        {
-                            "title": "MT8192",
-                            "scopes": ["mt8192-drivers"],
-                            "sections": [
-                                {
-                                    "title": "SPM",
-                                    "scopes": ["mt8192-spm", "mediatek/mt8192/spm"]
-                                }
-                            ]
-                        }
-                    ]
-                },
-                {
-                    "title": "NXP",
-                    "scopes": ["nxp-drivers"],
-                    "sections": [
-                        {
-                            "title": "DCFG",
-                            "scopes": ["nxp-dcfg", "driver/nxp/dcfg"]
-                        },
-                        {
-                            "title": "FLEXSPI",
-                            "scopes": ["flexspi", "include/drivers/flexspi", "driver/nxp/xspi"]
-                        },
-                        {
-                            "title": "SCFG",
-                            "scopes": ["nxp-scfg", "nxp/scfg"]
-                        },
-                        {
-                            "title": "SFP",
-                            "scopes": ["nxp-sfp", "drivers/nxp/sfp"]
-                        }
-                    ]
-                },
-                {
-                    "title": "Renesas",
-                    "scopes": ["renesas-drivers"],
-                    "sections": [
-                        {
-                            "title": "R-Car3",
-                            "scopes": ["rcar3-drivers", "drivers/rcar3"]
-                        }
-                    ]
-                },
-                {
-                    "title": "ST",
-                    "scopes": ["st-drivers", "drivers/st"],
-                    "sections": [
-                        {
-                            "title": "Clock",
-                            "scopes": ["st-clock", "stm32mp_clk", "drivers/st/clk", "stm32mp1_clk"]
-                        },
-                        {
-                            "title": "I/O",
-                            "scopes": ["st-io-drivers"],
-                            "sections": [
-                                {
-                                    "title": "STM32 Image",
-                                    "scopes": ["st-io-stm32image", "io-stm32image", "io_stm32image"]
-                                }
-                            ]
-                        },
-                        {
-                            "title": "SDMMC2",
-                            "scopes": ["st-sdmmc2", "stm32_sdmmc2"]
-                        },
-                        {
-                            "title": "ST PMIC",
-                            "scopes": ["st-pmic", "drivers/st/pmic"]
-                        },
-                        {
-                            "title": "STPMIC1",
-                            "scopes": ["stpmic1"]
-                        },
-                        {
-                            "title": "UART",
-                            "scopes": ["st-uart"],
-                            "sections": [
-                                {
-                                    "title": "STM32 Console",
-                                    "scopes": ["stm32-console", "stm32_console"]
-                                }
-                            ]
-                        },
-                        {
-                            "title": "USB",
-                            "scopes": ["st-usb", "drivers/st/usb"]
-                        }
-                    ]
-                },
-                {
-                    "title": "USB",
-                    "scopes": ["usb", "drivers/usb"]
-                }
-            ]
-        },
-        {
-            "title": "Miscellaneous",
-            "sections": [
-                {
-                    "title": "AArch64",
-                    "scopes": ["aarch64"]
-                },
-                {
-                    "title": "Debug",
-                    "scopes": ["debug", "common/debug"]
-                },
-                {
-                    "title": "CRC32",
-                    "scopes": ["crc32"],
-                    "sections": [
-                        {
-                            "title": "Hardware CRC32",
-                            "scopes": ["hw-crc32", "hw_crc", "hw_crc32"]
-                        },
-                        {
-                            "title": "Software CRC32",
-                            "scopes": ["sw-crc32", "sw_crc32"]
-                        }
-                    ]
-                },
-                {
-                    "title": "DT Bindings",
-                    "scopes": ["dt-bindings"]
-                },
-                {
-                    "title": "FDT Wrappers",
-                    "scopes": ["fdt-wrappers"]
-                },
-                {
-                    "title": "FDTs",
-                    "scopes": ["fdts", "fdt"],
-                    "sections": [
-                        {
-                            "title": "Morello",
-                            "scopes": ["morello-fdts", "fdts/morello"]
-                        },
-                        {
-                            "title": "STM32MP1",
-                            "scopes": ["stm32mp1-fdts", "fdts stm32mp1"]
-                        }
-                    ]
-                },
-                {
-                    "title": "PIE",
-                    "scopes": ["pie"]
-                },
-                {
-                    "title": "Security",
-                    "scopes": ["security"]
-                },
-                {
-                    "title": "SDEI",
-                    "scopes": ["sdei"]
-                },
-                {
-                    "title": "TBBR",
-                    "scopes": ["tbbr"]
-                },
-                {
-                    "title": "NXP",
-                    "sections": [
-                        {
-                            "title": "OCRAM",
-                            "scopes": ["nxp-ocram", "nxp/common/ocram"]
-                        },
-                        {
-                            "title": "PSCI",
-                            "scopes": ["nxp-psci", "plat/nxp/common/psci"]
-                        }
-                    ]
-                }
-            ]
-        },
-        {
-            "title": "Documentation",
-            "scopes": ["docs", "doc"],
-            "sections": [
-                {
-                    "title": "Changelog",
-                    "scopes": ["changelog"]
-                },
-                {
-                    "title": "Commit Style",
-                    "scopes": ["commit-style"]
-                },
-                {
-                    "title": "Contribution Guidelines",
-                    "scopes": ["contributing", "contribution-guidelines", "docs-contributing.rst"]
-                },
-                {
-                    "title": "Maintainers",
-                    "scopes": ["maintainers"]
-                },
-                {
-                    "title": "Prerequisites",
-                    "scopes": ["prerequisites"]
-                }
-            ]
-        },
-        {
-            "title": "Build System",
-            "scopes": ["build", "makefile", "Makefile"],
-            "sections": [
-                {
-                    "title": "Git Hooks",
-                    "scopes": ["hooks"]
-                }
-            ]
-        },
-        {
-            "title": "Tools",
-            "sections": [
-                {
-                    "title": "STM32 Image",
-                    "scopes": ["stm32image", "tools/stm32image"]
-                },
-                {
-                    "title": "fiptool",
-                    "scopes": ["fiptool"]
-                }
-            ]
-        },
-        {
-            "title": "Dependencies",
-            "scopes": ["deps"],
-            "sections": [
-                {
-                    "title": "checkpatch",
-                    "scopes": ["checkpatch"]
-                },
-                {
-                    "title": "commitlint",
-                    "scopes": ["commitlint"]
-                },
-                {
-                    "title": "libfdt",
-                    "scopes": ["libfdt"]
-                },
-                {
-                    "title": "Node Package Manager (NPM)",
-                    "scopes": ["npm"]
-                }
-            ]
-        }
-    ]
+    "path": "@commitlint/cz-commitlint"
 }

+ 46 - 16
.versionrc.js

@@ -8,26 +8,56 @@
 
 "use strict";
 
-const cz = require("./.cz.json");
+const fs = require("fs");
+const yaml = require("js-yaml");
 
 /*
- * Convert the Commitizen types array into the format accepted by the Conventional Changelog
- * Conventional Commits plugin (which our own plugin extends).
+ * 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.
  */
-const types = cz.types.map(type => {
-    if (!type.hidden) {
-        /*
-         * Conventional Changelog prevents each section from appearing only if it has no designated
-         * title, regardless of the value of the `hidden` flag.
-         */
-        type.section = type.title;
-    }
 
-    delete type.title;
-    delete type.description;
+let changelog;
 
-    return type;
-});
+try {
+    const contents = fs.readFileSync("changelog.yaml", "utf8");
+
+    changelog = yaml.load(contents);
+} catch (err) {
+    console.log(err);
+
+    throw err;
+}
+
+/*
+ * The next couple of functions are just used to transform the changelog YAML configuration
+ * structure into one accepted by the Conventional Changelog adapter (conventional-changelog-tf-a).
+ */
+
+function getTypes(sections) {
+    return sections.map(section => {
+        return {
+            "type": section.type,
+            "section": section.hidden ? undefined : section.title,
+            "hidden": section.hidden || false,
+        };
+    })
+}
+
+function getSections(subsections) {
+    return subsections.flatMap(subsection => {
+        const scope = subsection.scope ? [ subsection.scope ] : [];
+
+        return {
+            "title": subsection.title,
+            "sections": getSections(subsection.subsections || []),
+            "scopes": scope.concat(subsection.deprecated || []),
+        };
+    })
+};
+
+const types = getTypes(changelog.sections);
+const sections = getSections(changelog.subsections);
 
 module.exports = {
     "header": "# Change Log & Release Notes\n\nThis document contains a summary of the new features, changes, fixes and known\nissues in each release of Trusted Firmware-A.\n",
@@ -38,7 +68,7 @@ module.exports = {
         "userUrlFormat": "https://github.com/{{user}}",
 
         "types": types,
-        "sections": cz.sections,
+        "sections": sections,
     },
     "bumpFiles": [
         {

+ 931 - 0
changelog.yaml

@@ -0,0 +1,931 @@
+#
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+#
+# The following block describes the top-level sections of the changelog. Commits are categorized
+# into these top-level sections based on the commit message "type":
+#
+#     feat(xyz): add the xyz feature
+#     ^^^^
+#
+
+sections:
+  - title: New Features
+    description: A new feature
+    type: feat
+
+  - title: Resolved Issues
+    description: A bug fix
+    type: fix
+
+  - title: Build System
+    description: Changes that affect the build system or external dependencies
+    type: build
+    hidden: true
+
+  - title: Continuous Integration
+    description: Changes to our CI configuration files and scripts
+    type: ci
+    hidden: true
+
+  - title: Build System
+    description: Documentation-only changes
+    type: docs
+    hidden: true
+
+  - title: Performance Improvements
+    description: A code change that improves performance
+    type: perf
+    hidden: true
+
+  - title: Code Refactoring
+    description: A code change that neither fixes a bug nor adds a feature
+    type: refactor
+    hidden: true
+
+  - title: Reverted Changes
+    description: Changes that revert a previous change
+    type: revert
+    hidden: true
+
+  - title: Style
+    description: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)
+    type: style
+    hidden: true
+
+  - title: Tests
+    description: Adding missing tests or correcting existing tests
+    type: test
+    hidden: true
+
+  - title: Miscellaneous
+    description: Any other change
+    type: chore
+    hidden: true
+
+#
+# The following block describes the sub-sections of the changelog. These sub-sections may appear in
+# any of the top-level sections, and describe the individual components that a change may relate to.
+#
+# Sub-sections have an optional associated commit message "scope":
+#
+#     feat(xyz): add the xyz feature
+#          ^^^
+#
+# This file also describes deprecated scopes, which are scopes that were used before we introduced
+# scope enforcement. These will not pass CI checks when used, but they will be used to generate the
+# changelog.
+#
+# Please note that new scopes should be kebab-case: https://en.wiktionary.org/wiki/kebab_case
+#
+
+subsections:
+  - title: Architecture
+
+    subsections:
+      - title: Activity Monitors Extension (FEAT_AMU)
+        scope: amu
+
+      - title: Support for the `HCRX_EL2` register (FEAT_HCX)
+        scope: hcx
+
+      - title: Memory Partitioning and Monitoring (MPAM) Extension (FEAT_MPAM)
+        scope: mpam
+
+      - title: Scalable Matrix Extension (FEAT_SME)
+        scope: sme
+
+      - title: Scalable Vector Extension (FEAT_SVE)
+        scope: sve
+
+      - title: System Register Trace Extensions (FEAT_ETMv4, FEAT_ETE and FEAT_ETEv1.1)
+        scope: sys-reg-trace
+
+        deprecated:
+          - sys_reg_trace
+
+      - title: Trace Buffer Extension (FEAT_TRBE)
+        scope: trbe
+
+      - title: Self-hosted Trace Extensions (FEAT_TRF)
+        scope: trf
+
+  - title: Platforms
+
+    subsections:
+      - title: Allwinner
+        scope: allwinner
+
+        deprecated:
+          - plat/allwinner
+
+      - title: Arm
+        scope: arm
+
+        deprecated:
+          - plat/arm
+
+        subsections:
+          - title: FPGA
+            scope: fpga
+
+            deprecated:
+              - arm_fgpa
+              - arm_fpga
+              - plat/arm_fpga
+
+          - title: FVP
+            scope: fvp
+
+            deprecated:
+              - plat/fvp
+
+          - title: FVP-R
+            scope: fvp-r
+
+            deprecated:
+              - fvp_r
+
+          - title: Juno
+            scope: juno
+
+          - title: Morello
+            scope: morello
+
+          - title: RD
+            scope: rd
+
+            subsections:
+              - title: RD-N2
+                scope: rdn2
+
+                deprecated:
+                  - board/rdn2
+
+          - title: SGI
+            scope: sgi
+
+            deprecated:
+              - plat/sgi
+              - plat/arm/sgi
+
+          - title: TC
+            scope: tc
+
+            subsections:
+              - title: TC0
+                scope: tc0
+
+                deprecated:
+                  - plat/tc0
+
+      - title: Marvell
+        scope: marvell
+
+        deprecated:
+          - plat/marvell
+
+        subsections:
+          - title: Armada
+            scope: armada
+
+            deprecated:
+              - plat/marvell/armada
+
+            subsections:
+              - title: A3K
+                scope: a3k
+
+                deprecated:
+                  - plat/marvell/a3k
+
+              - title: A8K
+                scope: a8k
+
+                deprecated:
+                  - plat/marvell/a8k
+
+      - title: MediaTek
+        scope: mediatek
+
+        deprecated:
+          - plat/mediatek/common
+          - plat/mediatek
+
+        subsections:
+          - title: MT8183
+            scope: mt8183
+
+            deprecated:
+              - plat/mediatek/mt8183
+
+          - title: MT8192
+            scope: mt8192
+
+            deprecated:
+              - plat/mdeiatek/mt8192
+
+          - title: MT8195
+            scope: mt8195
+
+            deprecated:
+              - plat/mediatek/me8195
+              - plat/mediatek/mt8195
+              - plat/mdeiatek/mt8195
+
+      - title: NVIDIA
+        scope: nvidia
+
+        subsections:
+          - title: Tegra
+            scope: tegra
+
+            deprecated:
+              - plat/tegra
+
+            subsections:
+              - title: Tegra 132
+                scope: tegra132
+
+      - title: NXP
+        scope: nxp
+
+        deprecated:
+          - plat/nxp
+          - plat/nxp/common
+
+        subsections:
+          - title: i.MX
+            scope: imx
+
+            deprecated:
+              - plat/imx
+              - plat/imx/imx
+
+            subsections:
+              - title: i.MX 8M
+                scope: imx8m
+
+                deprecated:
+                  - plat/imx8m
+                  - plat/imx/imx8m
+
+                subsections:
+                  - title: i.MX 8M Mini
+                    scope: imx8mm
+
+                    deprecated:
+                      - plat/imx/imx8m/imx8mm
+
+                  - title: i.MX 8M Plus
+                    scope: imx8mp
+
+                    deprecated:
+                      - plat/imx/imx8m/imx8mp
+
+          - title: Layerscape
+            scope: layerscape
+
+            deprecated:
+              - docs/nxp/layerscape
+
+            subsections:
+              - title: LS1028A
+                scope: ls1028a
+
+                deprecated:
+                  - plat/nxp/ls1028a
+
+                subsections:
+                  - title: LS1028ARDB
+                    scope: ls1028ardb
+
+                    deprecated:
+                      - plat/nxp/ls1028ardb
+
+              - title: LX2
+                scope: lx2
+
+                deprecated:
+                  - plat/nxp/lx2
+
+                subsections:
+                  - title: LX216
+                    scope: lx216
+
+                    deprecated:
+                      - plat/nxp/lx216x
+
+                    subsections:
+                      - title: LX2160
+                        scope: lx2160
+
+                        deprecated:
+                          - plat/soc-lx2160
+
+      - title: QEMU
+        scope: qemu
+
+        deprecated:
+          - plat/qemu
+
+      - title: QTI
+        scope: qti
+
+        subsections:
+          - title: SC1780
+            scope: sc7180
+
+            deprecated:
+              - plat/qti/sc7180
+
+          - title: SC7280
+            scope: sc7280
+
+            deprecated:
+              - plat/qti/sc7280
+
+      - title: Raspberry Pi
+        scope: rpi
+
+        subsections:
+          - title: Raspberry Pi 4
+            scope: rpi4
+
+      - title: Renesas
+        scope: renesas
+
+        subsections:
+          - title: R-Car
+            scope: rcar
+
+            deprecated:
+              - plat/rcar
+
+            subsections:
+              - title: R-Car 3
+                scope: rcar3
+
+                deprecated:
+                  - plat/rcar3
+
+      - title: Rockchip
+        scope: rockchip
+
+        subsections:
+          - title: RK3399
+            scope: rk3399
+
+            deprecated:
+              - rockchip/rk3399
+              - rk3399/suspend
+
+      - title: Socionext
+        scope: socionext
+
+        subsections:
+          - title: Synquacer
+            scope: synquacer
+
+            deprecated:
+              - plat/synquacer
+
+      - title: ST
+        scope: st
+
+        deprecated:
+          - plat/st
+
+        subsections:
+          - title: ST32MP1
+            scope: stm32mp1
+
+            deprecated:
+              - plat/st/stm32mp1
+
+      - title: Xilinx
+        scope: xilinx
+
+        deprecated:
+          - plat/xilinx
+
+        subsections:
+          - title: Versal
+            scope: versal
+
+            deprecated:
+              - plat/xilinx/versal/include
+              - plat/xilinx/versal
+              - plat/versal
+
+          - title: ZynqMP
+            scope: zynqmp
+
+            deprecated:
+              - plat/zynqmp
+              - plat/xilinx/zynqmp
+
+  - title: Bootloader Images
+    scope: bl
+
+    deprecated:
+      - bl_common
+
+    subsections:
+      - title: BL1
+        scope: bl1
+
+      - title: BL2
+        scope: bl2
+
+  - title: Services
+    scope: services
+
+    subsections:
+      - title: FF-A
+        scope: ffa
+
+        deprecated:
+          - ff-a
+
+      - title: RME
+        scope: rme
+
+      - title: SPM
+        scope: spm
+
+        deprecated:
+          - spmc
+          - spmd
+          - SPMD
+          - spm_mm
+
+  - title: Libraries
+
+    subsections:
+      - title: CPU Support
+        scope: cpus
+
+        deprecated:
+          - cpu
+          - errata
+          - errata_report
+
+      - title: EL3 Runtime
+        scope: el3-runtime
+
+        deprecated:
+          - el3_runtime
+
+      - title: FCONF
+        scope: fconf
+
+      - title: MPMM
+        scope: mpmm
+
+      - title: OP-TEE
+        scope: optee
+
+        deprecated:
+          - lib/optee
+
+      - title: PSCI
+        scope: psci
+
+      - title: GPT
+        scope: gpt
+
+        deprecated:
+          - gpt_rme
+
+      - title: SMCCC
+        scope: smccc
+
+      - title: Translation Tables
+        scope: xlat
+
+  - title: Drivers
+
+    subsections:
+      - title: Authentication
+        scope: auth
+
+        deprecated:
+          - driver/auth
+
+        subsections:
+          - title: CryptoCell-713
+            scope: cc-713
+
+      - title: FWU
+        scope: fwu
+
+        deprecated:
+          - fwu_metadata
+
+      - title: I/O
+        scope: io
+
+        subsections:
+          - title: MTD
+            scope: mtd
+
+            deprecated:
+              - io_mtd
+
+      - title: Measured Boot
+        scope: measured-boot
+
+        deprecated:
+          - measured boot
+          - measured_boot
+
+      - title: MMC
+        scope: mmc
+
+        deprecated:
+          - drivers/mmc
+
+      - title: MTD
+        scope: mtd
+
+        deprecated:
+          - drivers/mtd
+
+        subsections:
+          - title: NAND
+            scope: nand
+
+            subsections:
+              - title: SPI NAND
+                scope: spi-nand
+
+                deprecated:
+                  - spi_nand
+
+      - title: SCMI
+        scope: scmi
+
+        deprecated:
+          - scmi_common
+          - drivers/scmi-msg
+
+      - title: UFS
+        scope: ufs
+
+      - title: Arm
+        scope: arm-drivers
+
+        subsections:
+          - title: Ethos-N
+            scope: ethos-n
+
+            deprecated:
+              - drivers/arm/ethosn
+
+          - title: GIC
+            scope: gic
+
+            subsections:
+              - title: GICv3
+                scope: gicv3
+
+                subsections:
+                  - title: GIC-600AE
+                    scope: gic600ae
+
+          - title: TZC
+            scope: tzc
+
+            subsections:
+              - title: TZC-400
+                scope: tzc400
+
+                deprecated:
+                  - drivers/tzc400
+
+      - title: Marvell
+        scope: marvell-drivers
+
+        subsections:
+          - title: COMPHY
+            scope: marvell-comphy
+
+            deprecated:
+              - drivers/marvell/comphy
+
+            subsections:
+              - title: Armada 3700
+                scope: marvell-comphy-3700
+
+                deprecated:
+                  - drivers/marvell/comphy-3700
+
+              - title: CP110
+                scope: marvell-comphy-cp110
+
+                deprecated:
+                  - drivers/marvell/comphy-cp110
+
+          - title: UART
+            scope: marvell-uart
+
+            deprecated:
+              - plat/marvell/uart
+
+          - title: Armada
+            scope: armada-drivers
+
+            subsections:
+              - title: A3K
+                scope: a3k-drivers
+
+                subsections:
+                  - title: A3720
+                    scope: a3720-uart
+
+                    deprecated:
+                      - plat/marvell/a3720/uart
+
+      - title: MediaTek
+        scope: mediatek-drivers
+
+        subsections:
+          - title: APU
+            scope: mediatek-apu
+
+            deprecated:
+              - plat/mediatek/apu
+
+          - title: EMI MPU
+            scope: mediatek-emi-mpu
+
+            deprecated:
+              - plat/mediatek/mpu
+
+          - title: PMIC Wrapper
+            scope: mediatek-pmic-wrapper
+
+            deprecated:
+              - plat/mediatek/pmic_wrap
+
+          - title: MT8192
+            scope: mt8192-drivers
+
+            subsections:
+              - title: SPM
+                scope: mt8192-spm
+
+                deprecated:
+                  - mediatek/mt8192/spm
+
+      - title: NXP
+        scope: nxp-drivers
+
+        subsections:
+          - title: DCFG
+            scope: nxp-dcfg
+
+            deprecated:
+              - driver/nxp/dcfg
+
+          - title: FLEXSPI
+            scope: flexspi
+
+            deprecated:
+              - include/drivers/flexspi
+              - driver/nxp/xspi
+
+          - title: SCFG
+            scope: nxp-scfg
+
+            deprecated:
+              - nxp/scfg
+
+          - title: SFP
+            scope: nxp-sfp
+
+            deprecated:
+              - drivers/nxp/sfp
+
+      - title: Renesas
+        scope: renesas-drivers
+
+        subsections:
+          - title: R-Car3
+            scope: rcar3-drivers
+
+            deprecated:
+              - drivers/rcar3
+
+      - title: ST
+        scope: st-drivers
+
+        deprecated:
+          - drivers/st
+
+        subsections:
+          - title: Clock
+            scope: st-clock
+
+            deprecated:
+              - stm32mp_clk
+              - drivers/st/clk
+              - stm32mp1_clk
+
+          - title: I/O
+            scope: st-io-drivers
+
+            subsections:
+              - title: STM32 Image
+                scope: st-io-stm32image
+
+                deprecated:
+                  - io-stm32image
+                  - io_stm32image
+
+              - title: fiptool
+                scope: fiptool
+
+          - title: SDMMC2
+            scope: st-sdmmc2
+
+            deprecated:
+              - stm32_sdmmc2
+
+          - title: ST PMIC
+            scope: st-pmic
+
+            deprecated:
+              - drivers/st/pmic
+
+          - title: STPMIC1
+            scope: stpmic1
+
+          - title: UART
+            scope: st-uart
+
+            subsections:
+              - title: STM32 Console
+                scope: stm32-console
+
+                deprecated:
+                  - stm32_console
+
+          - title: USB
+            scope: st-usb
+
+            deprecated:
+              - drivers/st/usb
+
+      - title: USB
+        scope: usb
+
+        deprecated:
+          - drivers/usb
+
+  - title: Miscellaneous
+
+    subsections:
+      - title: AArch64
+        scope: aarch64
+
+      - title: Debug
+        scope: debug
+
+        deprecated:
+          - common/debug
+
+      - title: CRC32
+        scope: crc32
+
+        subsections:
+          - title: Hardware CRC32
+            scope: hw-crc32
+
+            deprecated:
+              - hw_crc
+              - hw_crc32
+
+          - title: Software CRC32
+            scope: sw-crc32
+
+            deprecated:
+              - sw_crc32
+
+      - title: DT Bindings
+        scope: dt-bindings
+
+      - title: FDT Wrappers
+        scope: fdt-wrappers
+
+      - title: FDTs
+        scope: fdts
+
+        deprecated:
+          - fdt
+
+        subsections:
+          - title: Morello
+            scope: morello-fdts
+
+            deprecated:
+              - fdts/morello
+
+          - title: STM32MP1
+            scope: stm32mp1-fdts
+
+            deprecated:
+              - fdts stm32mp1
+
+      - title: PIE
+        scope: pie
+
+      - title: Security
+        scope: security
+
+      - title: SDEI
+        scope: sdei
+
+      - title: TBBR
+        scope: tbbr
+
+      - title: NXP
+
+        subsections:
+          - title: OCRAM
+            scope: nxp-ocram
+
+            deprecated:
+              - nxp/common/ocram
+
+          - title: PSCI
+            scope: nxp-psci
+
+            deprecated:
+              - plat/nxp/common/psci
+
+  - title: Documentation
+    scope: docs
+
+    deprecated:
+      - doc
+
+    subsections:
+      - title: Changelog
+        scope: changelog
+
+      - title: Commit Style
+        scope: commit-style
+
+      - title: Contribution Guidelines
+        scope: contributing
+
+        deprecated:
+          - contribution-guidelines
+          - docs-contributing.rst
+
+      - title: Maintainers
+        scope: maintainers
+
+      - title: Prerequisites
+        scope: prerequisites
+
+  - title: Build System
+    scope: build
+
+    deprecated:
+      - makefile
+      - Makefile
+
+    subsections:
+      - title: Git Hooks
+        scope: hooks
+
+  - title: Tools
+
+    subsections:
+      - title: STM32 Image
+        scope: stm32image
+
+        deprecated:
+          - tools/stm32image
+
+  - title: Dependencies
+    scope: deps
+
+    subsections:
+      - title: checkpatch
+        scope: checkpatch
+
+      - title: commitlint
+        scope: commitlint
+
+      - title: libfdt
+        scope: libfdt
+
+      - title: Node Package Manager (NPM)
+        scope: npm

+ 4 - 5
docs/process/commit-style.rst

@@ -79,11 +79,10 @@ The following `types` are permissible and are strictly enforced:
 +--------------+---------------------------------------------------------------+
 
 The permissible `scopes` are more flexible, and we maintain a list of them in
-our :download:`Commitizen configuration file <../../.cz.json>`. Scopes in this
-file are organized by their changelog section, each of which may have one or
-more accepted scopes, but only the first of which is considered to be "blessed".
-Scopes that are not blessed exist for changes submitted before scope enforcement
-came into effect, and are considered deprecated.
+our :download:`changelog configuration file <../../changelog.yaml>`. Scopes in
+this file are organized by their changelog section, where each changelog section
+has a single scope that is considered to be blessed, and possibly several
+deprecated scopes. Please avoid using deprecated scopes.
 
 While we don't enforce scopes strictly, we do ask that commits use these if they
 can, or add their own if no appropriate one exists (see :ref:`Adding Scopes`).

File diff suppressed because it is too large
+ 550 - 213
package-lock.json


+ 4 - 3
package.json

@@ -8,12 +8,13 @@
     "release": "standard-version -i docs/change-log.md"
   },
   "devDependencies": {
-    "@commitlint/cli": "^14.1.0",
-    "@commitlint/config-conventional": "^14.1.0",
+    "@commitlint/cli": "^16.1.0",
+    "@commitlint/config-conventional": "^16.0.0",
+    "@commitlint/cz-commitlint": "^16.1.0",
     "commitizen": "^4.2.4",
     "conventional-changelog-tf-a": "file:tools/conventional-changelog-tf-a",
-    "cz-conventional-changelog": "^3.3.0",
     "husky": "^7.0.4",
+    "js-yaml": "^4.1.0",
     "standard-version": "^9.3.2"
   }
 }

Some files were not shown because too many files changed in this diff