diff --git a/.changeset/perfect-spoons-behave.md b/.changeset/perfect-spoons-behave.md new file mode 100644 index 0000000000..cd7a024596 --- /dev/null +++ b/.changeset/perfect-spoons-behave.md @@ -0,0 +1,5 @@ +--- +'@backstage/frontend-app-api': patch +--- + +A `configLoader` passed to `createApp` now returns an object, to make room for future expansion diff --git a/packages/frontend-app-api/api-report.md b/packages/frontend-app-api/api-report.md index ad3afa27a4..a453463645 100644 --- a/packages/frontend-app-api/api-report.md +++ b/packages/frontend-app-api/api-report.md @@ -16,7 +16,9 @@ import { SubRouteRef } from '@backstage/frontend-plugin-api'; // @public (undocumented) export function createApp(options?: { features?: (BackstagePlugin | ExtensionOverrides)[]; - configLoader?: () => Promise; + configLoader?: () => Promise<{ + config: ConfigApi; + }>; bindRoutes?(context: { bind: CreateAppRouteBinder }): void; featureLoader?: (ctx: { config: ConfigApi; diff --git a/packages/frontend-app-api/src/wiring/createApp.test.tsx b/packages/frontend-app-api/src/wiring/createApp.test.tsx index 32773de7e1..3505c5c63f 100644 --- a/packages/frontend-app-api/src/wiring/createApp.test.tsx +++ b/packages/frontend-app-api/src/wiring/createApp.test.tsx @@ -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', diff --git a/packages/frontend-app-api/src/wiring/createApp.tsx b/packages/frontend-app-api/src/wiring/createApp.tsx index dc6feb9b90..e082f05a3b 100644 --- a/packages/frontend-app-api/src/wiring/createApp.tsx +++ b/packages/frontend-app-api/src/wiring/createApp.tsx @@ -238,7 +238,7 @@ function deduplicateFeatures( /** @public */ export function createApp(options?: { features?: (BackstagePlugin | ExtensionOverrides)[]; - configLoader?: () => Promise; + 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()), ); diff --git a/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts b/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts index 18054a5de2..d533048d2b 100644 --- a/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts @@ -128,7 +128,7 @@ function createTestAppRoot({ }) { return createApp({ features, - configLoader: async () => new MockConfigApi(config), + configLoader: async () => ({ config: new MockConfigApi(config) }), }).createRoot(); }