Tutorial 1: Team/code owner usage
Step-by-step tutorial to add Team/Codeowner information to components and analyze them.
1
CODEOWNERS file
# Default owner for all files
* @acme/design-system
# Owners for specific applications
applications/mail/ @acme/mail-team
applications/calendar/ @acme/calendar-team
applications/drive/ @acme/drive-team
applications/vpn-settings/ @acme/vpn-team
applications/pass/ @acme/pass-team
# Owners for shared packages
packages/components/ @acme/frontend-team
packages/utils/ @acme/frontend-team
# Owners for configuration and tooling
.yarn/ @acme/devops-team
.eslintrc.js @acme/devops-team
.prettier.config.mjs @acme/devops-team2
Setting up the hook script
const Codeowners = require("codeowners");
const repo = new Codeowners();
function getOwners(filePath) {
const owners = repo.getOwner(`${filePath}`);
if (owners.length === 0) {
owners.push("unknown");
}
return owners
.filter((o) => o !== "")
.map((o) => `${o}`)
.join(",");
}
/**
* @type {import('@omlet/cli').CliHookModule}
*/
module.exports = {
async afterScan(components) {
for (const component of components) {
const owners = getOwners(component.filePath);
component.setMetadata("Codeowner", owners);
}
},
};3
Last updated



