Merge pull request #25171 from backstage/rugvip/metadata-tweaks

cli: plugin metadata tweaks for some package edge cases
This commit is contained in:
Patrik Oldsberg
2024-06-13 19:14:01 +02:00
committed by GitHub
4 changed files with 11 additions and 8 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ export interface BackstagePackageJson {
backstage?: {
role?: PackageRole;
moved?: string;
pluginId?: string;
pluginId?: string | null;
pluginPackage?: string;
pluginPackages?: string[];
};
@@ -48,9 +48,9 @@ export interface BackstagePackageJson {
moved?: string;
/**
* The ID of the plugin if this is a plugin package. Must always be set for plugin and module packages, and may be set for library packages.
* The ID of the plugin if this is a plugin package. Must always be set for plugin and module packages, and may be set for library packages. A `null` value means that the package is explicitly not a plugin package.
*/
pluginId?: string;
pluginId?: string | null;
/**
* The parent plugin package of a module. Must always and only be set for module packages.
+3 -2
View File
@@ -277,7 +277,7 @@ export function fixPluginId(pkg: FixablePackage) {
const currentId = pkg.packageJson.backstage?.pluginId;
if (currentId !== undefined) {
if (typeof currentId !== 'string') {
if (typeof currentId !== 'string' && currentId !== null) {
throw new Error(
`Invalid 'backstage.pluginId' field in "${pkg.packageJson.name}", must be a string`,
);
@@ -363,7 +363,8 @@ export function fixPluginPackages(
if (
role === 'common-library' ||
role === 'web-library' ||
role === 'node-library'
role === 'node-library' ||
role === 'frontend-plugin-module' // TODO(Rugvip): Remove this once frontend modules are required to have a plugin ID
) {
return;
}
+5 -3
View File
@@ -30,8 +30,9 @@ export function publishPreflightCheck(pkg: BackstagePackage): void {
if (
role === 'backend-plugin' ||
role === 'backend-plugin-module' ||
role === 'frontend-plugin' ||
role === 'frontend-plugin-module'
role === 'frontend-plugin'
// TODO(Rugvip): We currently support plugin-less frontend modules for the new frontend system, but it needs a different solution
// || role === 'frontend-plugin-module'
) {
if (!backstage.pluginId) {
throw new Error(
@@ -62,7 +63,8 @@ export function publishPreflightCheck(pkg: BackstagePackage): void {
}
if (role === 'backend-plugin-module' || role === 'frontend-plugin-module') {
if (!backstage.pluginPackage) {
// TODO(Rugvip): Remove this .pluginId check once frontend modules are required to have a plugin ID
if (backstage.pluginId && !backstage.pluginPackage) {
throw new Error(
`Plugin module package ${name} is missing a backstage.pluginPackage, please run 'backstage-cli repo fix --publish'`,
);