diff --git a/packages/cli/src/commands/create-plugin/createPlugin.ts b/packages/cli/src/commands/create-plugin/createPlugin.ts index 4d264b01f9..da695bee95 100644 --- a/packages/cli/src/commands/create-plugin/createPlugin.ts +++ b/packages/cli/src/commands/create-plugin/createPlugin.ts @@ -405,7 +405,7 @@ const createPlugin = async () => { if (ownerIds && ownerIds.length) { await addCodeownersEntry( codeownersPath!, - path.join('plugins', answers.id), + `/plugins/${answers.id}`, ownerIds, ); } diff --git a/packages/cli/src/commands/create-plugin/lib/codeowners.ts b/packages/cli/src/commands/create-plugin/lib/codeowners.ts index 1ffa640f04..91b0e19782 100644 --- a/packages/cli/src/commands/create-plugin/lib/codeowners.ts +++ b/packages/cli/src/commands/create-plugin/lib/codeowners.ts @@ -20,6 +20,7 @@ import path from 'path'; const TEAM_ID_RE = /^@[-\w]+\/[-\w]+$/; const USER_ID_RE = /^@[-\w]+$/; const EMAIL_RE = /^[^@]+@[-.\w]+\.[-\w]+$/i; +const DEFAULT_OWNER = '@spotify/backstage-core'; type CodeownersEntry = { ownedPath: string; @@ -96,8 +97,11 @@ export async function addCodeownersEntry( const newDeclarationEntries = oldDeclarationEntries .filter(entry => entry.ownedPath !== '*') .concat([{ ownedPath, ownerIds }]) - .sort((l1, l2) => l1.ownedPath.localeCompare(l2.ownedPath)) - .concat([{ ownedPath: '*', ownerIds: ['@spotify/backstage-core'] }]); + .sort((l1, l2) => l1.ownedPath.localeCompare(l2.ownedPath)); + newDeclarationEntries.unshift({ + ownedPath: '*', + ownerIds: [DEFAULT_OWNER], + }); // Calculate longest path to be able to align entries nicely const longestOwnedPath = newDeclarationEntries.reduce(