Skip to content

Commit

Permalink
plugin(lighthouse-backend): Removed usages and references of @backsta…
Browse files Browse the repository at this point in the history
…ge/backend-common (#2584)

* plugin(lighthouse-backend): remove Removed usages and references of @backstage/backend-common

Signed-off-by: Kashish Mittal <[email protected]>

* removed deprecated createScheduler

Signed-off-by: Kashish Mittal <[email protected]>

* regen yarn

Signed-off-by: Kashish Mittal <[email protected]>

* updated changeset

Signed-off-by: Kashish Mittal <[email protected]>

* Update workspaces/lighthouse/.changeset/five-guests-joke.md

Co-authored-by: Vincenzo Scamporlino <[email protected]>
Signed-off-by: Kashish Mittal <[email protected]>

---------

Signed-off-by: Kashish Mittal <[email protected]>
Signed-off-by: Kashish Mittal <[email protected]>
Co-authored-by: Vincenzo Scamporlino <[email protected]>
  • Loading branch information
04kash and vinzscam authored Jan 31, 2025
1 parent 289ab35 commit ce2f38e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 106 deletions.
5 changes: 5 additions & 0 deletions workspaces/lighthouse/.changeset/five-guests-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage-community/plugin-lighthouse-backend': minor
---

**BREAKING** Removed support for the legacy backend system. Please refer to the [README](https://github.com/backstage/community-plugins/blob/main/workspaces/lighthouse/plugins/lighthouse-backend/README.md) for instructions on how to use the new backend system.
61 changes: 3 additions & 58 deletions workspaces/lighthouse/plugins/lighthouse-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,16 @@ Lighthouse Backend allows you to run scheduled lighthouse Tests for each Website

## Setup

The Lighthouse backend plugin has support for the [new backend system](https://backstage.io/docs/backend-system/), here's how you can set that up:

1. Install the plugin using:

```bash
# From your Backstage root directory
yarn --cwd packages/backend add @backstage-community/plugin-lighthouse-backend
```

2. Create a `lighthouse.ts` file inside `packages/backend/src/plugins/`:

```typescript
import { createScheduler } from '@backstage-community/plugin-lighthouse-backend';
import { PluginEnvironment } from '../types';
import { CatalogClient } from '@backstage/catalog-client';

export default async function createPlugin(env: PluginEnvironment) {
const { logger, scheduler, config, tokenManager } = env;

const catalogClient = new CatalogClient({
discoveryApi: env.discovery,
});

await createScheduler({
logger,
scheduler,
config,
catalogClient,
tokenManager,
});
}
```

3. Modify your `packages/backend/src/index.ts` to include:

```diff
...

import { Config } from '@backstage/config';
import app from './plugins/app';
+import lighthouse from './plugins/lighthouse';
import scaffolder from './plugins/scaffolder';

...

async function main() {

...

const authEnv = useHotMemoize(module, () => createEnv('auth'));
+ const lighthouseEnv = useHotMemoize(module, () => createEnv('lighthouse'));
const proxyEnv = useHotMemoize(module, () => createEnv('proxy'));

...

const apiRouter = Router();
apiRouter.use('/catalog', await catalog(catalogEnv));
apiRouter.use('/scaffolder', await scaffolder(scaffolderEnv));

+ await lighthouse(lighthouseEnv)
```

#### New Backend System

The Lighthouse 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:
2. In your `packages/backend/src/index.ts` make the following changes:

```diff
import { createBackend } from '@backstage/backend-defaults';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
},
"dependencies": {
"@backstage-community/plugin-lighthouse-common": "workspace:^",
"@backstage/backend-common": "^0.25.0",
"@backstage/backend-plugin-api": "^1.1.0",
"@backstage/backend-tasks": "^0.6.1",
"@backstage/catalog-client": "^1.9.0",
Expand Down
30 changes: 0 additions & 30 deletions workspaces/lighthouse/plugins/lighthouse-backend/report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,7 @@
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { AuthService } from '@backstage/backend-plugin-api';
import { BackendFeature } from '@backstage/backend-plugin-api';
import { CatalogApi } from '@backstage/catalog-client';
import { Config } from '@backstage/config';
import { DiscoveryService } from '@backstage/backend-plugin-api';
import { LoggerService } from '@backstage/backend-plugin-api';
import { PluginTaskScheduler } from '@backstage/backend-tasks';
import { TokenManager } from '@backstage/backend-common';

// @public @deprecated (undocumented)
export interface CreateLighthouseSchedulerOptions {
// (undocumented)
auth?: AuthService;
// (undocumented)
catalogClient: CatalogApi;
// (undocumented)
config: Config;
// (undocumented)
discovery: DiscoveryService;
// (undocumented)
logger: LoggerService;
// (undocumented)
scheduler?: PluginTaskScheduler;
// (undocumented)
tokenManager?: TokenManager;
}

// @public @deprecated (undocumented)
export function createScheduler(
options: CreateLighthouseSchedulerOptions,
): Promise<void>;

// @public
const lighthousePlugin: BackendFeature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,27 @@ import { Config } from '@backstage/config';
import { LighthouseRestApi } from '@backstage-community/plugin-lighthouse-common';
import { stringifyEntityRef } from '@backstage/catalog-model';
import { LighthouseAuditScheduleImpl } from '../config';
import {
createLegacyAuthAdapters,
TokenManager,
} from '@backstage/backend-common';
import {
AuthService,
DiscoveryService,
LoggerService,
} from '@backstage/backend-plugin-api';

/**
* @deprecated Please migrate to the new backend system as this will be removed in the future.
*
* @public **/
/** @internal */
export interface CreateLighthouseSchedulerOptions {
logger: LoggerService;
config: Config;
discovery: DiscoveryService;
scheduler?: PluginTaskScheduler;
catalogClient: CatalogApi;
tokenManager?: TokenManager;
auth?: AuthService;
auth: AuthService;
}

/**
* @deprecated Please migrate to the new backend system as this will be removed in the future.
*
* @public **/
/** @internal */
export async function createScheduler(
options: CreateLighthouseSchedulerOptions,
) {
const { logger, scheduler, catalogClient, config } = options;
const { auth } = createLegacyAuthAdapters(options);
const { logger, scheduler, catalogClient, config, auth } = options;
const lighthouseApi = LighthouseRestApi.fromConfig(config);

const lighthouseAuditConfig = LighthouseAuditScheduleImpl.fromConfig(config, {
Expand Down
1 change: 0 additions & 1 deletion workspaces/lighthouse/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2588,7 +2588,6 @@ __metadata:
resolution: "@backstage-community/plugin-lighthouse-backend@workspace:plugins/lighthouse-backend"
dependencies:
"@backstage-community/plugin-lighthouse-common": "workspace:^"
"@backstage/backend-common": ^0.25.0
"@backstage/backend-plugin-api": ^1.1.0
"@backstage/backend-tasks": ^0.6.1
"@backstage/catalog-client": ^1.9.0
Expand Down

0 comments on commit ce2f38e

Please sign in to comment.