Fixes after second round of review
Signed-off-by: David Festal <dfestal@redhat.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
```ts
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
import { BackstagePackageJson } from '@backstage/cli-node';
|
||||
import { CatalogBuilder } from '@backstage/plugin-catalog-backend';
|
||||
import { Config } from '@backstage/config';
|
||||
import { EventBroker } from '@backstage/plugin-events-node';
|
||||
@@ -150,8 +151,6 @@ export interface ModuleLoader {
|
||||
bootstrap(backstageRoot: string, dynamicPluginPaths: string[]): Promise<void>;
|
||||
// (undocumented)
|
||||
load(id: string): Promise<any>;
|
||||
// (undocumented)
|
||||
logger: LoggerService;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
@@ -182,18 +181,11 @@ export class PluginManager implements BackendPluginProvider {
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ScannedPluginManifest {
|
||||
// (undocumented)
|
||||
backstage: {
|
||||
role: PackageRole;
|
||||
export type ScannedPluginManifest = BackstagePackageJson &
|
||||
Required<Pick<BackstagePackageJson, 'main'>> &
|
||||
Required<Pick<BackstagePackageJson, 'backstage'>> & {
|
||||
backstage: Required<BackstagePackageJson['backstage']>;
|
||||
};
|
||||
// (undocumented)
|
||||
main: string;
|
||||
// (undocumented)
|
||||
name: string;
|
||||
// (undocumented)
|
||||
version: string;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ScannedPluginPackage {
|
||||
|
||||
@@ -14,14 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { LoggerService } from '@backstage/backend-plugin-api';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ModuleLoader {
|
||||
logger: LoggerService;
|
||||
|
||||
bootstrap(backstageRoot: string, dynamicPluginPaths: string[]): Promise<void>;
|
||||
|
||||
load(id: string): Promise<any>;
|
||||
|
||||
@@ -640,8 +640,45 @@ Please add '/backstageRoot/node_modules' to the 'NODE_PATH' when running the bac
|
||||
message:
|
||||
"failed to load dynamic plugin manifest from '/backstageRoot/dist-dynamic/test-backend-plugin'",
|
||||
meta: {
|
||||
name: 'TypeError',
|
||||
message: "Cannot read properties of undefined (reading 'role')",
|
||||
name: 'Error',
|
||||
message: "field 'backstage.role' not found in 'package.json'",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'missing main field in package.json',
|
||||
fileSystem: {
|
||||
'/backstageRoot': mockFs.directory({
|
||||
items: {
|
||||
'dist-dynamic': mockFs.directory({
|
||||
items: {
|
||||
'test-backend-plugin': mockFs.directory({
|
||||
items: {
|
||||
'package.json': mockFs.file({
|
||||
content: JSON.stringify({
|
||||
name: 'test-backend-plugin-dynamic',
|
||||
version: '0.0.0',
|
||||
backstage: { role: 'backend-plugin' },
|
||||
}),
|
||||
}),
|
||||
},
|
||||
}),
|
||||
},
|
||||
}),
|
||||
},
|
||||
}),
|
||||
},
|
||||
expectedPluginPackages: [],
|
||||
expectedLogs: {
|
||||
errors: [
|
||||
{
|
||||
message:
|
||||
"failed to load dynamic plugin manifest from '/backstageRoot/dist-dynamic/test-backend-plugin'",
|
||||
meta: {
|
||||
name: 'Error',
|
||||
message: "field 'main' not found in 'package.json'",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -143,21 +143,19 @@ export class PluginScanner {
|
||||
}
|
||||
|
||||
let scannedPlugin: ScannedPluginPackage;
|
||||
try {
|
||||
scannedPlugin = await this.scanDir(pluginHome);
|
||||
} catch (e) {
|
||||
this.logger.error(
|
||||
`failed to load dynamic plugin manifest from '${pluginHome}'`,
|
||||
e,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
let platform: PackagePlatform;
|
||||
try {
|
||||
platform = PackageRoles.getRoleInfo(
|
||||
scannedPlugin.manifest.backstage.role,
|
||||
).platform;
|
||||
scannedPlugin = await this.scanDir(pluginHome);
|
||||
if (!scannedPlugin.manifest.main) {
|
||||
throw new Error("field 'main' not found in 'package.json'");
|
||||
}
|
||||
if (scannedPlugin.manifest.backstage?.role) {
|
||||
platform = PackageRoles.getRoleInfo(
|
||||
scannedPlugin.manifest.backstage.role,
|
||||
).platform;
|
||||
} else {
|
||||
throw new Error("field 'backstage.role' not found in 'package.json'");
|
||||
}
|
||||
} catch (e) {
|
||||
this.logger.error(
|
||||
`failed to load dynamic plugin manifest from '${pluginHome}'`,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { PackageRole } from '@backstage/cli-node';
|
||||
import { BackstagePackageJson } from '@backstage/cli-node';
|
||||
|
||||
/**
|
||||
* @public
|
||||
@@ -27,11 +27,8 @@ export interface ScannedPluginPackage {
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ScannedPluginManifest {
|
||||
name: string;
|
||||
version: string;
|
||||
backstage: {
|
||||
role: PackageRole;
|
||||
export type ScannedPluginManifest = BackstagePackageJson &
|
||||
Required<Pick<BackstagePackageJson, 'main'>> &
|
||||
Required<Pick<BackstagePackageJson, 'backstage'>> & {
|
||||
backstage: Required<BackstagePackageJson['backstage']>;
|
||||
};
|
||||
main: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user