refactor: move blueprints to react package

Signed-off-by: secustor <sebastian@poxhofer.at>
This commit is contained in:
secustor
2025-09-03 18:21:53 +02:00
parent f4d9086331
commit be6cef5dab
17 changed files with 262 additions and 30 deletions
+1
View File
@@ -0,0 +1 @@
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
+5
View File
@@ -0,0 +1,5 @@
# @backstage/plugin-devtools-react
Welcome to the web library package for the devtools plugin!
_This plugin was created through the Backstage CLI_
+10
View File
@@ -0,0 +1,10 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: backstage-plugin-devtools-react
title: '@backstage/plugin-devtools-react'
description: Web library for the devtools plugin
spec:
lifecycle: experimental
type: backstage-web-library
owner: maintainers
+46
View File
@@ -0,0 +1,46 @@
{
"name": "@backstage/plugin-devtools-react",
"version": "0.1.0",
"license": "Apache-2.0",
"private": true,
"description": "Web library for the devtools plugin",
"main": "src/index.ts",
"types": "src/index.ts",
"publishConfig": {
"access": "public",
"main": "dist/index.esm.js",
"types": "dist/index.d.ts"
},
"backstage": {
"role": "web-library",
"pluginId": "devtools"
},
"sideEffects": false,
"scripts": {
"start": "backstage-cli package start",
"build": "backstage-cli package build",
"lint": "backstage-cli package lint",
"test": "backstage-cli package test",
"clean": "backstage-cli package clean",
"prepack": "backstage-cli package prepack",
"postpack": "backstage-cli package postpack"
},
"dependencies": {
"@backstage/core-plugin-api": "workspace:^",
"@backstage/frontend-plugin-api": "workspace:^",
"@material-ui/core": "^4.9.13"
},
"peerDependencies": {
"react": "^16.13.1 || ^17.0.0 || ^18.0.0"
},
"devDependencies": {
"@backstage/cli": "workspace:^",
"@backstage/test-utils": "workspace:^",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
"react": "^16.13.1 || ^17.0.0 || ^18.0.0"
},
"files": [
"dist"
]
}
+54
View File
@@ -0,0 +1,54 @@
## API Report File for "@backstage/plugin-devtools-react"
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { ConfigurableExtensionDataRef } from '@backstage/frontend-plugin-api';
import { ExtensionBlueprint } from '@backstage/frontend-plugin-api';
import { ExtensionDataRef } from '@backstage/frontend-plugin-api';
import { JSX as JSX_2 } from 'react';
// @alpha
export const DevToolsRouteBlueprint: ExtensionBlueprint<{
kind: 'devtools-route';
params: DevToolsRouteBlueprintParams;
output: ExtensionDataRef<DevToolsRouteData, 'devtools.route', {}>;
inputs: {};
config: {};
configInput: {};
dataRefs: {
route: ConfigurableExtensionDataRef<
DevToolsRouteData,
'devtools.route',
{}
>;
};
}>;
// @alpha
export interface DevToolsRouteBlueprintParams {
// (undocumented)
loader: () => Promise<JSX_2.Element>;
// (undocumented)
path: string;
// (undocumented)
title: string;
}
// @alpha
export interface DevToolsRouteData {
// (undocumented)
children: JSX_2.Element;
// (undocumented)
path: string;
// (undocumented)
title: string;
}
// @alpha
export const devToolsRouteDataRef: ConfigurableExtensionDataRef<
DevToolsRouteData,
'devtools.route',
{}
>;
```
@@ -0,0 +1,68 @@
/*
* 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 {
createExtensionBlueprint,
ExtensionBoundary,
} from '@backstage/frontend-plugin-api';
import { devToolsRouteDataRef } from './devToolsRouteDataRef';
import { JSX } from 'react';
/**
* Parameters for creating a DevTools route extension
* @alpha
*/
export interface DevToolsRouteBlueprintParams {
path: string;
title: string;
loader: () => Promise<JSX.Element>;
}
/**
* Extension blueprint for creating DevTools routes
*
* @example
* ```tsx
* const myDevToolsRoute = DevToolsRouteBlueprint.make({
* params: {
* path: 'my-feature',
* title: 'My Feature',
* loader: () => import('./MyContent').then(m => ({ default: m.MyContent }))
* }
* });
* ```
*
* @alpha
*/
export const DevToolsRouteBlueprint = createExtensionBlueprint({
kind: 'devtools-route',
attachTo: { id: 'page:devtools', input: 'routes' },
output: [devToolsRouteDataRef],
factory(params: DevToolsRouteBlueprintParams, { node }) {
const children = ExtensionBoundary.lazy(node, params.loader);
return [
devToolsRouteDataRef({
path: params.path,
title: params.title,
children,
}),
];
},
dataRefs: {
route: devToolsRouteDataRef,
},
});
@@ -0,0 +1,37 @@
/*
* 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 { createExtensionDataRef } from '@backstage/frontend-plugin-api';
import { JSX } from 'react';
/**
* Represents a DevTools route that can be contributed by extensions
* @alpha
*/
export interface DevToolsRouteData {
path: string;
title: string;
children: JSX.Element;
}
/**
* Extension data reference for DevTools routes
* @alpha
*/
export const devToolsRouteDataRef =
createExtensionDataRef<DevToolsRouteData>().with({
id: 'devtools.route',
});
+29
View File
@@ -0,0 +1,29 @@
/*
* Copyright 2025 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.
*/
/**
* Web library for the devtools plugin.
*
* @packageDocumentation
*/
export {
type DevToolsRouteData,
devToolsRouteDataRef,
} from './devToolsRouteDataRef';
export {
type DevToolsRouteBlueprintParams,
DevToolsRouteBlueprint,
} from './devToolsRouteBlueprint.tsx';