Merge pull request #18320 from awanlin/topic/implement-new-backend
Added support for new backend system (Azure DevOps, DevTools, and Linguist)
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
'@backstage/plugin-azure-devops-backend': patch
|
||||
'@backstage/plugin-devtools-backend': patch
|
||||
'@backstage/plugin-linguist-backend': patch
|
||||
---
|
||||
|
||||
Added alpha support for the [new backend system](https://backstage.io/docs/backend-system/)
|
||||
@@ -26,13 +26,17 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/backend-defaults": "workspace:^",
|
||||
"@backstage/backend-tasks": "workspace:^",
|
||||
"@backstage/plugin-app-backend": "workspace:^",
|
||||
"@backstage/plugin-auth-node": "workspace:^",
|
||||
"@backstage/plugin-azure-devops-backend": "workspace:^",
|
||||
"@backstage/plugin-badges-backend": "workspace:^",
|
||||
"@backstage/plugin-catalog-backend": "workspace:^",
|
||||
"@backstage/plugin-catalog-backend-module-unprocessed": "workspace:^",
|
||||
"@backstage/plugin-devtools-backend": "workspace:^",
|
||||
"@backstage/plugin-entity-feedback-backend": "workspace:^",
|
||||
"@backstage/plugin-kubernetes-backend": "workspace:^",
|
||||
"@backstage/plugin-linguist-backend": "workspace:^",
|
||||
"@backstage/plugin-permission-backend": "workspace:^",
|
||||
"@backstage/plugin-permission-common": "workspace:^",
|
||||
"@backstage/plugin-permission-node": "workspace:^",
|
||||
|
||||
@@ -33,6 +33,10 @@ import { todoPlugin } from '@backstage/plugin-todo-backend';
|
||||
import { entityFeedbackPlugin } from '@backstage/plugin-entity-feedback-backend';
|
||||
import { catalogModuleUnprocessedEntities } from '@backstage/plugin-catalog-backend-module-unprocessed';
|
||||
import { badgesPlugin } from '@backstage/plugin-badges-backend';
|
||||
import { azureDevOpsPlugin } from '@backstage/plugin-azure-devops-backend';
|
||||
import { linguistPlugin } from '@backstage/plugin-linguist-backend';
|
||||
import { devtoolsPlugin } from '@backstage/plugin-devtools-backend';
|
||||
import { TaskScheduleDefinition } from '@backstage/backend-tasks';
|
||||
|
||||
const backend = createBackend();
|
||||
|
||||
@@ -41,9 +45,31 @@ backend.add(appPlugin({ appPackageName: 'example-app' }));
|
||||
// Badges
|
||||
backend.add(badgesPlugin());
|
||||
|
||||
// Azure DevOps
|
||||
backend.add(azureDevOpsPlugin());
|
||||
|
||||
// DevTools
|
||||
backend.add(devtoolsPlugin());
|
||||
|
||||
// Entity Feedback
|
||||
backend.add(entityFeedbackPlugin());
|
||||
|
||||
// Linguist
|
||||
const linguistSchedule: TaskScheduleDefinition = {
|
||||
frequency: { minutes: 2 },
|
||||
timeout: { minutes: 15 },
|
||||
initialDelay: { seconds: 15 },
|
||||
};
|
||||
|
||||
backend.add(
|
||||
linguistPlugin({
|
||||
schedule: linguistSchedule,
|
||||
age: { days: 30 },
|
||||
batchSize: 2,
|
||||
useSourceLocation: false,
|
||||
}),
|
||||
);
|
||||
|
||||
// Todo
|
||||
backend.add(todoPlugin());
|
||||
|
||||
|
||||
@@ -70,6 +70,25 @@ Here's how to get the backend up and running:
|
||||
4. Now run `yarn start-backend` from the repo root
|
||||
5. Finally open `http://localhost:7007/api/azure-devops/health` in a browser and it should return `{"status":"ok"}`
|
||||
|
||||
#### New Backend System
|
||||
|
||||
The Azure DevOps backend plugin has support for the [new backend system](https://backstage.io/docs/backend-system/), here's how you can set that up:
|
||||
|
||||
In your `packages/backend/src/index.ts` make the following changes:
|
||||
|
||||
```diff
|
||||
import { createBackend } from '@backstage/backend-defaults';
|
||||
+ import { azureDevOpsPlugin } from '@backstage/plugin-azure-devops-backend';
|
||||
|
||||
const backend = createBackend();
|
||||
|
||||
// ... other feature additions
|
||||
|
||||
+ backend.add(azureDevOpsPlugin());
|
||||
|
||||
backend.start();
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
- [Frontend part of the plugin](https://github.com/backstage/backstage/tree/master/plugins/azure-devops)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
import { Build } from 'azure-devops-node-api/interfaces/BuildInterfaces';
|
||||
import { BuildDefinitionReference } from 'azure-devops-node-api/interfaces/BuildInterfaces';
|
||||
import { BuildRun } from '@backstage/plugin-azure-devops-common';
|
||||
@@ -94,6 +95,9 @@ export class AzureDevOpsApi {
|
||||
}): Promise<TeamMember[] | undefined>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export const azureDevOpsPlugin: () => BackendFeature;
|
||||
|
||||
// @public (undocumented)
|
||||
export function createRouter(options: RouterOptions): Promise<express.Router>;
|
||||
|
||||
@@ -108,6 +112,4 @@ export interface RouterOptions {
|
||||
// (undocumented)
|
||||
reader: UrlReader;
|
||||
}
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
```
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/backend-common": "workspace:^",
|
||||
"@backstage/backend-plugin-api": "workspace:^",
|
||||
"@backstage/config": "workspace:^",
|
||||
"@backstage/plugin-azure-devops-common": "workspace:^",
|
||||
"@types/express": "^4.17.6",
|
||||
|
||||
@@ -13,5 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Azure DevOps backend plugin that contains the API for retrieving builds, pull requests, etc. which is used by the Azure DevOps frontend plugin.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
export { AzureDevOpsApi } from './api';
|
||||
export * from './service/router';
|
||||
export { azureDevOpsPlugin } from './plugin';
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2023 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 { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import {
|
||||
coreServices,
|
||||
createBackendPlugin,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { createRouter } from './service/router';
|
||||
|
||||
/**
|
||||
* Azure DevOps backend plugin
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const azureDevOpsPlugin = createBackendPlugin({
|
||||
pluginId: 'azure-devops',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
config: coreServices.config,
|
||||
logger: coreServices.logger,
|
||||
reader: coreServices.urlReader,
|
||||
httpRouter: coreServices.httpRouter,
|
||||
},
|
||||
async init({ config, logger, reader, httpRouter }) {
|
||||
httpRouter.use(
|
||||
await createRouter({
|
||||
config,
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
reader,
|
||||
}),
|
||||
);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -49,7 +49,26 @@ Here's how to get the DevTools Backend up and running:
|
||||
4. Now run `yarn start-backend` from the repo root
|
||||
5. Finally open `http://localhost:7007/api/devtools/health` in a browser and it should return `{"status":"ok"}`
|
||||
|
||||
### New Backend System
|
||||
|
||||
The DevTools backend plugin has support for the [new backend system](https://backstage.io/docs/backend-system/), here's how you can set that up:
|
||||
|
||||
In your `packages/backend/src/index.ts` make the following changes:
|
||||
|
||||
```diff
|
||||
import { createBackend } from '@backstage/backend-defaults';
|
||||
+ import { devtoolsPlugin } from '@backstage/plugin-devtools-backend';
|
||||
|
||||
const backend = createBackend();
|
||||
|
||||
// ... other feature additions
|
||||
|
||||
+ backend.add(devtoolsPlugin());
|
||||
|
||||
backend.start();
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
- [Frontend part of the plugin](../devtools/README.md)
|
||||
- [Frontend part of the plugin](https://github.com/backstage/backstage/tree/master/plugins/devtools)
|
||||
- [The Backstage homepage](https://backstage.io)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
import { Config } from '@backstage/config';
|
||||
import { ConfigInfo } from '@backstage/plugin-devtools-common';
|
||||
import { DevToolsInfo } from '@backstage/plugin-devtools-common';
|
||||
@@ -25,6 +26,9 @@ export class DevToolsBackendApi {
|
||||
listInfo(): Promise<DevToolsInfo>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export const devtoolsPlugin: () => BackendFeature;
|
||||
|
||||
// @public (undocumented)
|
||||
export interface RouterOptions {
|
||||
// (undocumented)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/backend-common": "workspace:^",
|
||||
"@backstage/backend-plugin-api": "workspace:^",
|
||||
"@backstage/cli-common": "workspace:^",
|
||||
"@backstage/config": "workspace:^",
|
||||
"@backstage/config-loader": "workspace:^",
|
||||
|
||||
@@ -22,3 +22,4 @@
|
||||
|
||||
export { DevToolsBackendApi } from './api';
|
||||
export * from './service/router';
|
||||
export { devtoolsPlugin } from './plugin';
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2023 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 { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import {
|
||||
coreServices,
|
||||
createBackendPlugin,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { createRouter } from './service/router';
|
||||
|
||||
/**
|
||||
* DevTools backend plugin
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const devtoolsPlugin = createBackendPlugin({
|
||||
pluginId: 'devtools',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
config: coreServices.config,
|
||||
logger: coreServices.logger,
|
||||
permissions: coreServices.permissions,
|
||||
httpRouter: coreServices.httpRouter,
|
||||
},
|
||||
async init({ config, logger, permissions, httpRouter }) {
|
||||
httpRouter.use(
|
||||
await createRouter({
|
||||
config,
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
permissions,
|
||||
}),
|
||||
);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -56,6 +56,38 @@ Here's how to get the backend up and running:
|
||||
4. Now run `yarn start-backend` from the repo root
|
||||
5. Finally open `http://localhost:7007/api/linguist/health` in a browser and it should return `{"status":"ok"}`
|
||||
|
||||
#### New Backend System
|
||||
|
||||
The Linguist backend plugin has support for the [new backend system](https://backstage.io/docs/backend-system/), here's how you can set that up:
|
||||
|
||||
In your `packages/backend/src/index.ts` make the following changes:
|
||||
|
||||
```diff
|
||||
import { createBackend } from '@backstage/backend-defaults';
|
||||
+ import { linguistPlugin } from '@backstage/plugin-linguist-backend';
|
||||
|
||||
const backend = createBackend();
|
||||
|
||||
// ... other feature additions
|
||||
|
||||
+ const linguistSchedule: TaskScheduleDefinition = {
|
||||
+ frequency: { minutes: 2 },
|
||||
+ timeout: { minutes: 15 },
|
||||
+ initialDelay: { seconds: 15 },
|
||||
+ };
|
||||
|
||||
+ backend.add(
|
||||
+ linguistPlugin({
|
||||
+ schedule: linguistSchedule,
|
||||
+ age: { days: 30 },
|
||||
+ batchSize: 2,
|
||||
+ useSourceLocation: false,
|
||||
+ }),
|
||||
+ );
|
||||
|
||||
backend.start();
|
||||
```
|
||||
|
||||
## Plugin Option
|
||||
|
||||
The Linguist backend has various plugin options that you can provide to the `createRouter` function in your `packages/backend/src/plugins/linguist.ts` file that will allow you to configure various aspects of how it works. The following sections go into the details of these options
|
||||
@@ -114,5 +146,5 @@ return createRouter(
|
||||
|
||||
## Links
|
||||
|
||||
- [Frontend part of the plugin](../linguist/README.md)
|
||||
- [Frontend part of the plugin](https://github.com/backstage/backstage/tree/master/plugins/linguist)
|
||||
- [The Backstage homepage](https://backstage.io)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
import express from 'express';
|
||||
import { HumanDuration } from '@backstage/types';
|
||||
import { Languages } from '@backstage/plugin-linguist-common';
|
||||
@@ -28,6 +29,25 @@ export interface LinguistBackendApi {
|
||||
processEntities(): Promise<void>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export const linguistPlugin: (options: LinguistPluginOptions) => BackendFeature;
|
||||
|
||||
// @public
|
||||
export interface LinguistPluginOptions {
|
||||
// (undocumented)
|
||||
age?: HumanDuration;
|
||||
// (undocumented)
|
||||
batchSize?: number;
|
||||
// (undocumented)
|
||||
kind?: string[];
|
||||
// (undocumented)
|
||||
linguistJsOptions?: Record<string, unknown>;
|
||||
// (undocumented)
|
||||
schedule?: TaskScheduleDefinition;
|
||||
// (undocumented)
|
||||
useSourceLocation?: boolean;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface PluginOptions {
|
||||
// (undocumented)
|
||||
@@ -61,6 +81,4 @@ export interface RouterOptions {
|
||||
// (undocumented)
|
||||
tokenManager: TokenManager;
|
||||
}
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
```
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/backend-common": "workspace:^",
|
||||
"@backstage/backend-plugin-api": "workspace:^",
|
||||
"@backstage/backend-tasks": "workspace:^",
|
||||
"@backstage/catalog-client": "workspace:^",
|
||||
"@backstage/catalog-model": "workspace:^",
|
||||
|
||||
@@ -14,5 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Linguist backend plugin that contains the API for generating and retrieving language breakdown which is used by the Linguist frontend plugin.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
export * from './service/router';
|
||||
export type { LinguistBackendApi } from './api';
|
||||
export { linguistPlugin } from './plugin';
|
||||
export type { LinguistPluginOptions } from './plugin';
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2023 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 { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import {
|
||||
coreServices,
|
||||
createBackendPlugin,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { createRouter } from './service/router';
|
||||
import { TaskScheduleDefinition } from '@backstage/backend-tasks';
|
||||
import { HumanDuration } from '@backstage/types';
|
||||
|
||||
/**
|
||||
* Options for Linguist backend plugin
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface LinguistPluginOptions {
|
||||
schedule?: TaskScheduleDefinition;
|
||||
age?: HumanDuration;
|
||||
batchSize?: number;
|
||||
useSourceLocation?: boolean;
|
||||
linguistJsOptions?: Record<string, unknown>;
|
||||
kind?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Linguist backend plugin
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const linguistPlugin = createBackendPlugin(
|
||||
(options: LinguistPluginOptions) => ({
|
||||
pluginId: 'linguist',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
logger: coreServices.logger,
|
||||
reader: coreServices.urlReader,
|
||||
database: coreServices.database,
|
||||
discovery: coreServices.discovery,
|
||||
scheduler: coreServices.scheduler,
|
||||
tokenManager: coreServices.tokenManager,
|
||||
httpRouter: coreServices.httpRouter,
|
||||
},
|
||||
async init({
|
||||
logger,
|
||||
reader,
|
||||
database,
|
||||
discovery,
|
||||
scheduler,
|
||||
tokenManager,
|
||||
httpRouter,
|
||||
}) {
|
||||
httpRouter.use(
|
||||
await createRouter(
|
||||
{
|
||||
...options,
|
||||
},
|
||||
{
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
reader,
|
||||
database,
|
||||
discovery,
|
||||
scheduler,
|
||||
tokenManager,
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
});
|
||||
},
|
||||
}),
|
||||
);
|
||||
@@ -5011,6 +5011,7 @@ __metadata:
|
||||
resolution: "@backstage/plugin-azure-devops-backend@workspace:plugins/azure-devops-backend"
|
||||
dependencies:
|
||||
"@backstage/backend-common": "workspace:^"
|
||||
"@backstage/backend-plugin-api": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/config": "workspace:^"
|
||||
"@backstage/plugin-azure-devops-common": "workspace:^"
|
||||
@@ -6353,6 +6354,7 @@ __metadata:
|
||||
resolution: "@backstage/plugin-devtools-backend@workspace:plugins/devtools-backend"
|
||||
dependencies:
|
||||
"@backstage/backend-common": "workspace:^"
|
||||
"@backstage/backend-plugin-api": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/cli-common": "workspace:^"
|
||||
"@backstage/config": "workspace:^"
|
||||
@@ -7723,6 +7725,7 @@ __metadata:
|
||||
resolution: "@backstage/plugin-linguist-backend@workspace:plugins/linguist-backend"
|
||||
dependencies:
|
||||
"@backstage/backend-common": "workspace:^"
|
||||
"@backstage/backend-plugin-api": "workspace:^"
|
||||
"@backstage/backend-tasks": "workspace:^"
|
||||
"@backstage/backend-test-utils": "workspace:^"
|
||||
"@backstage/catalog-client": "workspace:^"
|
||||
@@ -24925,14 +24928,18 @@ __metadata:
|
||||
resolution: "example-backend-next@workspace:packages/backend-next"
|
||||
dependencies:
|
||||
"@backstage/backend-defaults": "workspace:^"
|
||||
"@backstage/backend-tasks": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/plugin-app-backend": "workspace:^"
|
||||
"@backstage/plugin-auth-node": "workspace:^"
|
||||
"@backstage/plugin-azure-devops-backend": "workspace:^"
|
||||
"@backstage/plugin-badges-backend": "workspace:^"
|
||||
"@backstage/plugin-catalog-backend": "workspace:^"
|
||||
"@backstage/plugin-catalog-backend-module-unprocessed": "workspace:^"
|
||||
"@backstage/plugin-devtools-backend": "workspace:^"
|
||||
"@backstage/plugin-entity-feedback-backend": "workspace:^"
|
||||
"@backstage/plugin-kubernetes-backend": "workspace:^"
|
||||
"@backstage/plugin-linguist-backend": "workspace:^"
|
||||
"@backstage/plugin-permission-backend": "workspace:^"
|
||||
"@backstage/plugin-permission-common": "workspace:^"
|
||||
"@backstage/plugin-permission-node": "workspace:^"
|
||||
|
||||
Reference in New Issue
Block a user