cli: more informative error message for missing plugin ID for modules during fix

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-06-11 14:42:14 +02:00
parent 11d4ee4030
commit 227b57d5b4
+11 -3
View File
@@ -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) {