feat(frontent-app-api): prevent root extension replacement
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
@@ -188,6 +188,14 @@ export interface ExtensionInstanceParameters {
|
||||
config?: unknown;
|
||||
}
|
||||
|
||||
function preventRootExtensionOverride(id: string) {
|
||||
if (id === 'root') {
|
||||
throw new Error(
|
||||
'There is a root extension in the app config file and root extensions are not configurable',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function mergeExtensionParameters(options: {
|
||||
sources: BackstagePlugin[];
|
||||
@@ -220,8 +228,10 @@ export function mergeExtensionParameters(options: {
|
||||
];
|
||||
|
||||
for (const overrideParam of parameters) {
|
||||
const extensionId = overrideParam.id;
|
||||
preventRootExtensionOverride(extensionId);
|
||||
const existingIndex = overrides.findIndex(
|
||||
e => e.extension.id === overrideParam.id,
|
||||
e => e.extension.id === extensionId,
|
||||
);
|
||||
if (existingIndex !== -1) {
|
||||
const existing = overrides[existingIndex];
|
||||
@@ -243,7 +253,7 @@ export function mergeExtensionParameters(options: {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Error(`Extension ${overrideParam.id} does not exist`);
|
||||
throw new Error(`Extension ${extensionId} does not exist`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user