diff --git a/package.json b/package.json index 2951eb8540..c81cb98d34 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "dev": "yarn workspaces foreach -A --include example-backend --include example-app --parallel -v -i run start", "dev:next": "yarn workspaces foreach -A --include example-backend --include example-app-next --parallel -v -i run start", "docker-build": "yarn tsc && yarn workspace example-backend build && yarn workspace example-backend build-image", - "fix": "backstage-cli repo fix", + "fix": "backstage-cli repo fix --publish", "postinstall": "husky || true", "lint": "backstage-cli repo lint --since origin/master", "lint:all": "backstage-cli repo lint", diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 3554ddfbef..25a3a4e26c 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -70,6 +70,10 @@ export function registerRepoCommand(program: Command) { command .command('fix') .description('Automatically fix packages in the project') + .option( + '--publish', + 'Enable additional fixes that only apply when publishing packages', + ) .option( '--check', 'Fail if any packages would have been changed by the command', diff --git a/packages/cli/src/commands/repo/fix.ts b/packages/cli/src/commands/repo/fix.ts index c96484e2ed..88070ceb8f 100644 --- a/packages/cli/src/commands/repo/fix.ts +++ b/packages/cli/src/commands/repo/fix.ts @@ -428,17 +428,18 @@ export function fixPluginPackages( } } +type PackageFixer = (pkg: FixablePackage, packages: FixablePackage[]) => void; + export async function command(opts: OptionValues): Promise { const packages = await readFixablePackages(); const fixRepositoryField = createRepositoryFieldFixer(); - const fixers = [ - fixPackageExports, - fixSideEffects, - fixRepositoryField, - fixPluginId, - fixPluginPackages, - ]; + const fixers: PackageFixer[] = [fixPackageExports, fixSideEffects]; + + // Fixers that only apply to repos that publish packages + if (opts.publish) { + fixers.push(fixRepositoryField, fixPluginId, fixPluginPackages); + } for (const fixer of fixers) { for (const pkg of packages) {