From a854f893184c567aee910e3550be288f55804373 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 12 Jun 2024 17:22:36 +0200 Subject: [PATCH 1/3] cli: allow explicit null pluginId in package metadata Signed-off-by: Patrik Oldsberg --- packages/cli-node/src/monorepo/PackageGraph.ts | 2 +- packages/cli/src/commands/repo/fix.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli-node/src/monorepo/PackageGraph.ts b/packages/cli-node/src/monorepo/PackageGraph.ts index afa5eed888..027099fe40 100644 --- a/packages/cli-node/src/monorepo/PackageGraph.ts +++ b/packages/cli-node/src/monorepo/PackageGraph.ts @@ -50,7 +50,7 @@ export interface BackstagePackageJson { /** * 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. */ - pluginId?: string; + pluginId?: string | null; /** * The parent plugin package of a module. Must always and only be set for module packages. diff --git a/packages/cli/src/commands/repo/fix.ts b/packages/cli/src/commands/repo/fix.ts index 370e5c0cb1..4e7aefdaa7 100644 --- a/packages/cli/src/commands/repo/fix.ts +++ b/packages/cli/src/commands/repo/fix.ts @@ -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`, ); From 4f2084267e35ed0587dc5d9e33136d139fc6719e Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 12 Jun 2024 17:22:56 +0200 Subject: [PATCH 2/3] cli: allow frontend modules to not define a pluginId Signed-off-by: Patrik Oldsberg --- packages/cli/src/commands/repo/fix.ts | 3 ++- packages/cli/src/lib/publishing.ts | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/repo/fix.ts b/packages/cli/src/commands/repo/fix.ts index 4e7aefdaa7..a55440c53f 100644 --- a/packages/cli/src/commands/repo/fix.ts +++ b/packages/cli/src/commands/repo/fix.ts @@ -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; } diff --git a/packages/cli/src/lib/publishing.ts b/packages/cli/src/lib/publishing.ts index 20e4241985..c213355478 100644 --- a/packages/cli/src/lib/publishing.ts +++ b/packages/cli/src/lib/publishing.ts @@ -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'`, ); From 66aa12fa9c5eeaae8ac47e900259baa54d74b3d0 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 12 Jun 2024 17:40:19 +0200 Subject: [PATCH 3/3] cli-node: document null pluginId Signed-off-by: Patrik Oldsberg --- packages/cli-node/api-report.md | 2 +- packages/cli-node/src/monorepo/PackageGraph.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli-node/api-report.md b/packages/cli-node/api-report.md index a16b4c91a4..9f7e525048 100644 --- a/packages/cli-node/api-report.md +++ b/packages/cli-node/api-report.md @@ -18,7 +18,7 @@ export interface BackstagePackageJson { backstage?: { role?: PackageRole; moved?: string; - pluginId?: string; + pluginId?: string | null; pluginPackage?: string; pluginPackages?: string[]; }; diff --git a/packages/cli-node/src/monorepo/PackageGraph.ts b/packages/cli-node/src/monorepo/PackageGraph.ts index 027099fe40..c8877803d5 100644 --- a/packages/cli-node/src/monorepo/PackageGraph.ts +++ b/packages/cli-node/src/monorepo/PackageGraph.ts @@ -48,7 +48,7 @@ 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 | null;