Fix wrong alpha support in dynamic plugins support
The `alpha` sub-package should not be required for the dynamic plugins to be loaded under the new backend system. Signed-off-by: David Festal <dfestal@redhat.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-dynamic-feature-service': patch
|
||||
---
|
||||
|
||||
Fix wrong `alpha` support in dynamic plugins support: the `alpha` sub-package should not be required for the dynamic plugins to be loaded under the new backend system.
|
||||
@@ -484,6 +484,37 @@ Please add '${mockDir.resolve(
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "alpha manifest preferred but skipped because the `alpha` sub-directory doesn't exist",
|
||||
preferAlpha: true,
|
||||
fileSystem: {
|
||||
backstageRoot: {
|
||||
'dist-dynamic': {
|
||||
'test-backend-plugin': {
|
||||
'package.json': JSON.stringify({
|
||||
name: 'test-backend-plugin-dynamic',
|
||||
version: '0.0.0',
|
||||
main: 'dist/index.cjs.js',
|
||||
backstage: { role: 'backend-plugin' },
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedPluginPackages: [
|
||||
{
|
||||
location: url.pathToFileURL(
|
||||
mockDir.resolve('backstageRoot/dist-dynamic/test-backend-plugin'),
|
||||
),
|
||||
manifest: {
|
||||
name: 'test-backend-plugin-dynamic',
|
||||
version: '0.0.0',
|
||||
main: 'dist/index.cjs.js',
|
||||
backstage: { role: 'backend-plugin' },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'invalid alpha package.json',
|
||||
preferAlpha: true,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import { Config } from '@backstage/config';
|
||||
import { ScannedPluginPackage, ScannedPluginManifest } from './types';
|
||||
import * as fs from 'fs/promises';
|
||||
import { Stats, lstatSync } from 'fs';
|
||||
import { Stats, lstatSync, existsSync } from 'fs';
|
||||
import * as chokidar from 'chokidar';
|
||||
import * as path from 'path';
|
||||
import * as url from 'url';
|
||||
@@ -178,22 +178,24 @@ export class PluginScanner {
|
||||
if (platform === 'node') {
|
||||
if (this.preferAlpha) {
|
||||
const pluginHomeAlpha = path.resolve(pluginHome, 'alpha');
|
||||
if ((await fs.lstat(pluginHomeAlpha)).isDirectory()) {
|
||||
const backstage = scannedPlugin.manifest.backstage;
|
||||
try {
|
||||
scannedPlugin = await this.scanDir(pluginHomeAlpha);
|
||||
} catch (e) {
|
||||
this.logger.error(
|
||||
`failed to load dynamic plugin manifest from '${pluginHomeAlpha}'`,
|
||||
e,
|
||||
if (existsSync(pluginHomeAlpha)) {
|
||||
if ((await fs.lstat(pluginHomeAlpha)).isDirectory()) {
|
||||
const backstage = scannedPlugin.manifest.backstage;
|
||||
try {
|
||||
scannedPlugin = await this.scanDir(pluginHomeAlpha);
|
||||
} catch (e) {
|
||||
this.logger.error(
|
||||
`failed to load dynamic plugin manifest from '${pluginHomeAlpha}'`,
|
||||
e,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
scannedPlugin.manifest.backstage = backstage;
|
||||
} else {
|
||||
this.logger.warn(
|
||||
`skipping '${pluginHomeAlpha}' since it is not a directory`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
scannedPlugin.manifest.backstage = backstage;
|
||||
} else {
|
||||
this.logger.warn(
|
||||
`skipping '${pluginHomeAlpha}' since it is not a directory`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user