From 227b57d5b499e8db9ca01d497f1934d7c5eb4424 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 11 Jun 2024 14:42:14 +0200 Subject: [PATCH] cli: more informative error message for missing plugin ID for modules during fix Signed-off-by: Patrik Oldsberg --- packages/cli/src/commands/repo/fix.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/commands/repo/fix.ts b/packages/cli/src/commands/repo/fix.ts index e7d243ea2c..370e5c0cb1 100644 --- a/packages/cli/src/commands/repo/fix.ts +++ b/packages/cli/src/commands/repo/fix.ts @@ -297,9 +297,17 @@ export function fixPluginId(pkg: FixablePackage) { paths.targetRoot, resolvePath(pkg.dir, 'package.json'), ); - throw new Error( - `Failed to guess plugin ID for "${pkg.packageJson.name}", please set the 'backstage.pluginId' field manually in "${path}"`, - ); + const msg = `Failed to guess plugin ID for "${pkg.packageJson.name}", please set the 'backstage.pluginId' field manually in "${path}"`; + if (role.endsWith('module')) { + const suggestedRole = role.startsWith('frontend') + ? 'web-library' + : 'node-library'; + throw new Error( + `${msg}. It is also possible that this package is not a module, and should use the '${suggestedRole}' role instead.`, + ); + } else { + throw new Error(msg); + } } if (guessedPluginId) {