cli: add --publish option for repo fix

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-06-08 12:21:19 +02:00
parent cb61f04da8
commit f85a7f2a5a
3 changed files with 13 additions and 8 deletions
+1 -1
View File
@@ -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",
+4
View File
@@ -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',
+8 -7
View File
@@ -428,17 +428,18 @@ export function fixPluginPackages(
}
}
type PackageFixer = (pkg: FixablePackage, packages: FixablePackage[]) => void;
export async function command(opts: OptionValues): Promise<void> {
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) {