Restrict createDevApp options

Limit createDevApp to features and bindRoutes so advanced createApp configuration stays out of the dev-app helper API.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
This commit is contained in:
Patrik Oldsberg
2026-03-16 16:09:40 +01:00
parent 21ba6588f9
commit 989a1dcc9b
5 changed files with 19 additions and 10 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ export function createDevApp(options: CreateDevAppOptions): void;
// @public
export interface CreateDevAppOptions
extends Omit<CreateAppOptions, 'features'> {
extends Pick<CreateAppOptions, 'bindRoutes'> {
features: (FrontendFeature | FrontendFeatureLoader)[];
}
```
@@ -19,11 +19,13 @@ import {
createFrontendPlugin,
} from '@backstage/frontend-plugin-api';
import { within } from '@testing-library/react';
import { mockApis } from '@backstage/test-utils';
import { createDevApp } from './createDevApp';
const anyEnv = (process.env = { ...process.env }) as any;
describe('createDevApp', () => {
afterEach(() => {
delete anyEnv.APP_CONFIG;
document.getElementById('root')?.remove();
});
@@ -44,11 +46,18 @@ describe('createDevApp', () => {
],
});
anyEnv.APP_CONFIG = [
{
context: 'test',
data: {
app: { title: 'Test App' },
backend: { baseUrl: 'http://localhost' },
},
},
];
createDevApp({
features: [testPlugin],
advanced: {
configLoader: async () => ({ config: mockApis.config() }),
},
});
const body = within(document.body);
@@ -46,7 +46,7 @@ const BuiCss = lazy(() => import('./BuiCss'));
* @public
*/
export interface CreateDevAppOptions
extends Omit<CreateAppOptions, 'features'> {
extends Pick<CreateAppOptions, 'bindRoutes'> {
/**
* The list of features to load in the dev app.
*/
@@ -68,13 +68,13 @@ export interface CreateDevAppOptions
* @public
*/
export function createDevApp(options: CreateDevAppOptions): void {
const { features, ...createAppOptions } = options;
const { features, bindRoutes } = options;
const devFeatures: CreateAppOptions['features'] = [
appPluginOverride,
...features,
];
const appOptions: CreateAppOptions = {
...createAppOptions,
bindRoutes,
features: devFeatures,
};
const app = createApp(appOptions);