chore: created a frontend module

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-08-28 08:52:27 +02:00
parent d103f216b0
commit f1e08f7dd8
3 changed files with 65 additions and 3 deletions
@@ -0,0 +1,62 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createExtension } from './createExtension';
import { createFrontendModule } from './createFrontendModule';
describe('createFrontendModule', () => {
it('should create a frontend module', () => {
expect(
createFrontendModule({
pluginId: 'test',
extensions: [
createExtension({
kind: 'route',
name: 'test',
output: [],
attachTo: { id: 'ignored', input: 'ignored' },
factory: () => [],
}),
],
}),
).toMatchInlineSnapshot(`
{
"$$type": "@backstage/FrontendModule",
"extensions": [
{
"$$type": "@backstage/Extension",
"T": undefined,
"attachTo": {
"id": "ignored",
"input": "ignored",
},
"configSchema": undefined,
"disabled": false,
"factory": [Function],
"id": "route:test/test",
"inputs": {},
"output": [],
"toString": [Function],
"version": "v2",
},
],
"featureFlags": [],
"pluginId": "test",
"toString": [Function],
"version": "v1",
}
`);
});
});
@@ -26,7 +26,7 @@ import {
import { FeatureFlagConfig } from './types';
/** @public */
export interface ModuleOptions<
export interface FrontendModuleOptions<
TPluginId extends string,
TExtensions extends readonly ExtensionDefinition[],
> {
@@ -52,7 +52,7 @@ export interface InternalFrontendModule extends FrontendModule {
export function createFrontendModule<
TId extends string,
TExtensions extends readonly ExtensionDefinition[] = [],
>(options: ModuleOptions<TId, TExtensions>): FrontendModule {
>(options: FrontendModuleOptions<TId, TExtensions>): FrontendModule {
const { pluginId } = options;
const extensions = new Array<Extension<any>>();
@@ -46,7 +46,7 @@ export {
export {
createFrontendModule,
type FrontendModule,
type ModuleOptions,
type FrontendModuleOptions,
} from './createFrontendModule';
export {
createExtensionOverrides,