make configLoader return an object
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/frontend-app-api': patch
|
||||
---
|
||||
|
||||
A `configLoader` passed to `createApp` now returns an object, to make room for future expansion
|
||||
@@ -16,7 +16,9 @@ import { SubRouteRef } from '@backstage/frontend-plugin-api';
|
||||
// @public (undocumented)
|
||||
export function createApp(options?: {
|
||||
features?: (BackstagePlugin | ExtensionOverrides)[];
|
||||
configLoader?: () => Promise<ConfigApi>;
|
||||
configLoader?: () => Promise<{
|
||||
config: ConfigApi;
|
||||
}>;
|
||||
bindRoutes?(context: { bind: CreateAppRouteBinder }): void;
|
||||
featureLoader?: (ctx: {
|
||||
config: ConfigApi;
|
||||
|
||||
@@ -33,8 +33,8 @@ import { featureFlagsApiRef, useApi } from '@backstage/core-plugin-api';
|
||||
describe('createApp', () => {
|
||||
it('should allow themes to be installed', async () => {
|
||||
const app = createApp({
|
||||
configLoader: async () =>
|
||||
new MockConfigApi({
|
||||
configLoader: async () => ({
|
||||
config: new MockConfigApi({
|
||||
app: {
|
||||
extensions: [
|
||||
{ 'theme:app/light': false },
|
||||
@@ -42,6 +42,7 @@ describe('createApp', () => {
|
||||
],
|
||||
},
|
||||
}),
|
||||
}),
|
||||
features: [
|
||||
createPlugin({
|
||||
id: 'test',
|
||||
@@ -65,7 +66,7 @@ describe('createApp', () => {
|
||||
it('should deduplicate features keeping the last received one', async () => {
|
||||
const duplicatedFeatureId = 'test';
|
||||
const app = createApp({
|
||||
configLoader: async () => new MockConfigApi({}),
|
||||
configLoader: async () => ({ config: new MockConfigApi({}) }),
|
||||
features: [
|
||||
createPlugin({
|
||||
id: duplicatedFeatureId,
|
||||
@@ -100,7 +101,7 @@ describe('createApp', () => {
|
||||
|
||||
it('should register feature flags', async () => {
|
||||
const app = createApp({
|
||||
configLoader: async () => new MockConfigApi({}),
|
||||
configLoader: async () => ({ config: new MockConfigApi({}) }),
|
||||
features: [
|
||||
createPlugin({
|
||||
id: 'test',
|
||||
@@ -155,7 +156,7 @@ describe('createApp', () => {
|
||||
let appTreeApi: AppTreeApi | undefined = undefined;
|
||||
|
||||
const app = createApp({
|
||||
configLoader: async () => new MockConfigApi({}),
|
||||
configLoader: async () => ({ config: new MockConfigApi({}) }),
|
||||
features: [
|
||||
createPlugin({
|
||||
id: 'my-plugin',
|
||||
|
||||
@@ -238,7 +238,7 @@ function deduplicateFeatures(
|
||||
/** @public */
|
||||
export function createApp(options?: {
|
||||
features?: (BackstagePlugin | ExtensionOverrides)[];
|
||||
configLoader?: () => Promise<ConfigApi>;
|
||||
configLoader?: () => Promise<{ config: ConfigApi }>;
|
||||
bindRoutes?(context: { bind: CreateAppRouteBinder }): void;
|
||||
featureLoader?: (ctx: {
|
||||
config: ConfigApi;
|
||||
@@ -248,7 +248,7 @@ export function createApp(options?: {
|
||||
} {
|
||||
async function appLoader() {
|
||||
const config =
|
||||
(await options?.configLoader?.()) ??
|
||||
(await options?.configLoader?.().then(c => c.config)) ??
|
||||
ConfigReader.fromConfigs(
|
||||
overrideBaseUrlConfigs(defaultConfigLoaderSync()),
|
||||
);
|
||||
|
||||
@@ -128,7 +128,7 @@ function createTestAppRoot({
|
||||
}) {
|
||||
return createApp({
|
||||
features,
|
||||
configLoader: async () => new MockConfigApi(config),
|
||||
configLoader: async () => ({ config: new MockConfigApi(config) }),
|
||||
}).createRoot();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user