From 56df4368d4cca07cc2a516dbb1e89183e504752c Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Sat, 6 Apr 2024 17:25:57 -0500 Subject: [PATCH 1/9] Update with all core features Signed-off-by: Andre Wanlin --- .../building-backends/08-migrating.md | 286 ++++++++++++++++++ package.json | 1 + scripts/verify-backend-feature.js | 86 ++++++ yarn.lock | 8 + 4 files changed, 381 insertions(+) create mode 100644 scripts/verify-backend-feature.js diff --git a/docs/backend-system/building-backends/08-migrating.md b/docs/backend-system/building-backends/08-migrating.md index e8cebf4eb9..f5f851e39b 100644 --- a/docs/backend-system/building-backends/08-migrating.md +++ b/docs/backend-system/building-backends/08-migrating.md @@ -1063,3 +1063,289 @@ backend.start(); ``` > You can track the progress of the module migration efforts [here](https://github.com/backstage/backstage/issues/19476). + +### The Search Plugin + +A basic installation of the Search plugin will look as follows: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-search-backend/alpha')); +/* highlight-add-end */ +``` + +> Note: this will use the Lunr search engine which stores its index in memory + +#### Search Engines + +The following sections outline how you can add other Search engines + +##### Postgres + +An installation of the Search plugin using the Postgres search engine will look as follows: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-search-backend/alpha')); +backend.add(import('@backstage/plugin-search-backend-module-pg/alpha')); +/* highlight-add-end */ +``` + +##### Elasticsearch + +A basic installation of the Search plugin using the Elasticsearch search engine will look as follows: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-search-backend/alpha')); +backend.add( + import('@backstage/plugin-search-backend-module-elasticsearch/alpha'), +); +/* highlight-add-end */ +``` + +#### Search Collators + +The following sections outline how you add the Catalog and TechDocs search collators + +##### Catalog + +A basic installation of the Search plugin with the Catalog collator will look as follows: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-search-backend/alpha')); +backend.add(import('@backstage/plugin-search-backend-module-catalog/alpha')); +/* highlight-add-end */ +``` + +##### TechDocs + +A basic installation of the Search plugin with the TechDocs collator will look as follows: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-search-backend/alpha')); +backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha')); +/* highlight-add-end */ +``` + +### The Permissions Plugin + +A basic installation of the Permission plugin will look as follows: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-permission-backend/alpha')); +backend.add( + import('@backstage/plugin-permission-backend-module-allow-all-policy'), +); +/* highlight-add-end */ +``` + +> Note: the above includes a default allow all policy, if that is not what you want do not add the 2nd line. + +#### Custom Permission Policy + +In order to add your own permission policy you'll need to do the following: + +```ts +import { createBackendModule } from '@backstage/backend-plugin-api'; +import { BackstageIdentityResponse } from '@backstage/plugin-auth-node'; +import { + PolicyDecision, + AuthorizeResult, +} from '@backstage/plugin-permission-common'; +import { + PermissionPolicy, + PolicyQuery, +} from '@backstage/plugin-permission-node'; +import { policyExtensionPoint } from '@backstage/plugin-permission-node/alpha'; + +class ExampleAllowAllPermissionPolicy implements PermissionPolicy { + async handle( + _request: PolicyQuery, + _user?: BackstageIdentityResponse, + ): Promise { + return { + result: AuthorizeResult.ALLOW, + }; + } +} + +const customPermissionBackendModule = createBackendModule({ + pluginId: 'permission', + moduleId: 'allow-all-policy', + register(reg) { + reg.registerInit({ + deps: { policy: policyExtensionPoint }, + async init({ policy }) { + policy.setPolicy(new ExampleAllowAllPermissionPolicy()); + }, + }); + }, +}); + +const backend = createBackend(); + +// Other plugins... + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-permission-backend/alpha')); +backend.add(customPermissionBackendModule); +/* highlight-add-end */ +``` + +### The TechDocs Plugin + +A basic installation of the TechDocs plugin will look as follows: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-search-backend-module-catalog/alpha')); +/* highlight-add-end */ +``` + +### The Kubernetes Plugin + +A basic installation of the Kubernetes plugin will look as follows: + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); + +// Other plugins... + +/* highlight-add-start */ +backend.add(import('@backstage/plugin-kubernetes-backend/alpha')); +/* highlight-add-end */ +``` + +### The Plugins in Backstage Repo + +The vast majority of the backend plugins that currently live in the Backstage Repo have been migrated and their respective `README`s have details on how they should be installed using the New Backend System. + +| Package | Role | Migrated | Uses Alpha Export | Link to `README` | +| ------------------------------------------------------------------ | --------------------- | -------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------- | +| @backstage/plugin-adr-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/adr-backend/README.md) | +| @backstage/plugin-airbrake-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/airbrake-backend/README.md) | +| @backstage/plugin-app-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/app-backend/README.md) | +| @backstage/plugin-auth-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend/README.md) | +| @backstage/plugin-auth-backend-module-atlassian-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-atlassian-provider/README.md) | +| @backstage/plugin-auth-backend-module-aws-alb-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-aws-alb-provider/README.md) | +| @backstage/plugin-auth-backend-module-gcp-iap-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-gcp-iap-provider/README.md) | +| @backstage/plugin-auth-backend-module-github-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-github-provider/README.md) | +| @backstage/plugin-auth-backend-module-gitlab-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-gitlab-provider/README.md) | +| @backstage/plugin-auth-backend-module-google-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-google-provider/README.md) | +| @backstage/plugin-auth-backend-module-guest-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-guest-provider/README.md) | +| @backstage/plugin-auth-backend-module-microsoft-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-microsoft-provider/README.md) | +| @backstage/plugin-auth-backend-module-oauth2-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-oauth2-provider/README.md) | +| @backstage/plugin-auth-backend-module-oauth2-proxy-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-oauth2-proxy-provider/README.md) | +| @backstage/plugin-auth-backend-module-oidc-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-oidc-provider/README.md) | +| @backstage/plugin-auth-backend-module-okta-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-okta-provider/README.md) | +| @backstage/plugin-auth-backend-module-pinniped-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-pinniped-provider/README.md) | +| @backstage/plugin-auth-backend-module-vmware-cloud-provider | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/auth-backend-module-vmware-cloud-provider/README.md) | +| @backstage/plugin-azure-devops-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/azure-devops-backend/README.md) | +| @backstage/plugin-azure-sites-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/azure-sites-backend/README.md) | +| @backstage/plugin-badges-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/badges-backend/README.md) | +| @backstage/plugin-bazaar-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/bazaar-backend/README.md) | +| @backstage/plugin-catalog-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend/README.md) | +| @backstage/plugin-catalog-backend-module-aws | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-aws/README.md) | +| @backstage/plugin-catalog-backend-module-azure | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-azure/README.md) | +| @backstage/plugin-catalog-backend-module-backstage-openapi | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-backstage-openapi/README.md) | +| @backstage/plugin-catalog-backend-module-bitbucket-cloud | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-bitbucket-cloud/README.md) | +| @backstage/plugin-catalog-backend-module-bitbucket-server | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-bitbucket-server/README.md) | +| @backstage/plugin-catalog-backend-module-gcp | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-gcp/README.md) | +| @backstage/plugin-catalog-backend-module-gerrit | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-gerrit/README.md) | +| @backstage/plugin-catalog-backend-module-github | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-github/README.md) | +| @backstage/plugin-catalog-backend-module-github-org | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-github-org/README.md) | +| @backstage/plugin-catalog-backend-module-gitlab | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-gitlab/README.md) | +| @backstage/plugin-catalog-backend-module-incremental-ingestion | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-incremental-ingestion/README.md) | +| @backstage/plugin-catalog-backend-module-ldap | backend-plugin-module | | | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-ldap/README.md) | +| @backstage/plugin-catalog-backend-module-msgraph | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-msgraph/README.md) | +| @backstage/plugin-catalog-backend-module-openapi | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-openapi/README.md) | +| @backstage/plugin-catalog-backend-module-puppetdb | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-puppetdb/README.md) | +| @backstage/plugin-catalog-backend-module-scaffolder-entity-model | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-scaffolder-entity-model/README.md) | +| @backstage/plugin-catalog-backend-module-unprocessed | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/catalog-backend-module-unprocessed/README.md) | +| @backstage/plugin-code-coverage-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/code-coverage-backend/README.md) | +| @backstage/plugin-devtools-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/devtools-backend/README.md) | +| @backstage/plugin-entity-feedback-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/entity-feedback-backend/README.md) | +| @backstage/plugin-events-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/events-backend/README.md) | +| @backstage/plugin-events-backend-module-aws-sqs | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/events-backend-module-aws-sqs/README.md) | +| @backstage/plugin-events-backend-module-azure | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/events-backend-module-azure/README.md) | +| @backstage/plugin-events-backend-module-bitbucket-cloud | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/events-backend-module-bitbucket-cloud/README.md) | +| @backstage/plugin-events-backend-module-gerrit | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/events-backend-module-gerrit/README.md) | +| @backstage/plugin-events-backend-module-github | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/events-backend-module-github/README.md) | +| @backstage/plugin-events-backend-module-gitlab | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/events-backend-module-gitlab/README.md) | +| @internal/plugin-todo-list-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/example-todo-list-backend/README.md) | +| @backstage/plugin-explore-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/explore-backend/README.md) | +| @backstage/plugin-jenkins-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/jenkins-backend/README.md) | +| @backstage/plugin-kafka-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/kafka-backend/README.md) | +| @backstage/plugin-kubernetes-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/kubernetes-backend/README.md) | +| @backstage/plugin-lighthouse-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/lighthouse-backend/README.md) | +| @backstage/plugin-linguist-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/linguist-backend/README.md) | +| @backstage/plugin-nomad-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/nomad-backend/README.md) | +| @backstage/plugin-notifications-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/notifications-backend/README.md) | +| @backstage/plugin-periskop-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/periskop-backend/README.md) | +| @backstage/plugin-permission-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/permission-backend/README.md) | +| @backstage/plugin-permission-backend-module-allow-all-policy | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/permission-backend-module-policy-allow-all/README.md) | +| @backstage/plugin-playlist-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/playlist-backend/README.md) | +| @backstage/plugin-proxy-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/proxy-backend/README.md) | +| @backstage/plugin-rollbar-backend | backend-plugin | | | [README](https://github.com/backstage/backstage/blob/master/plugins/rollbar-backend/README.md) | +| @backstage/plugin-scaffolder-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend/README.md) | +| @backstage/plugin-scaffolder-backend-module-azure | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-azure/README.md) | +| @backstage/plugin-scaffolder-backend-module-bitbucket | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-bitbucket/README.md) | +| @backstage/plugin-scaffolder-backend-module-bitbucket-cloud | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-bitbucket-cloud/README.md) | +| @backstage/plugin-scaffolder-backend-module-bitbucket-server | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-bitbucket-server/README.md) | +| @backstage/plugin-scaffolder-backend-module-confluence-to-markdown | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-confluence-to-markdown/README.md) | +| @backstage/plugin-scaffolder-backend-module-cookiecutter | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-cookiecutter/README.md) | +| @backstage/plugin-scaffolder-backend-module-gerrit | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-gerrit/README.md) | +| @backstage/plugin-scaffolder-backend-module-gitea | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-gitea/README.md) | +| @backstage/plugin-scaffolder-backend-module-github | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-github/README.md) | +| @backstage/plugin-scaffolder-backend-module-gitlab | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-gitlab/README.md) | +| @backstage/plugin-scaffolder-backend-module-rails | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-rails/README.md) | +| @backstage/plugin-scaffolder-backend-module-sentry | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-sentry/README.md) | +| @backstage/plugin-scaffolder-backend-module-yeoman | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/scaffolder-backend-module-yeoman/README.md) | +| @backstage/plugin-search-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/search-backend/README.md) | +| @backstage/plugin-search-backend-module-catalog | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/search-backend-module-catalog/README.md) | +| @backstage/plugin-search-backend-module-elasticsearch | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/search-backend-module-elasticsearch/README.md) | +| @backstage/plugin-search-backend-module-explore | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/search-backend-module-explore/README.md) | +| @backstage/plugin-search-backend-module-pg | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/search-backend-module-pg/README.md) | +| @backstage/plugin-search-backend-module-stack-overflow-collator | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/search-backend-module-stack-overflow-collator/README.md) | +| @backstage/plugin-search-backend-module-techdocs | backend-plugin-module | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/search-backend-module-techdocs/README.md) | +| @backstage/plugin-signals-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/signals-backend/README.md) | +| @backstage/plugin-sonarqube-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/sonarqube-backend/README.md) | +| @backstage/plugin-stack-overflow-backend | backend-plugin | | | [README](https://github.com/backstage/backstage/blob/master/plugins/stack-overflow-backend/README.md) | +| @backstage/plugin-tech-insights-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/tech-insights-backend/README.md) | +| @backstage/plugin-tech-insights-backend-module-jsonfc | backend-plugin-module | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/tech-insights-backend-module-jsonfc/README.md) | +| @backstage/plugin-techdocs-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/techdocs-backend/README.md) | +| @backstage/plugin-todo-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/todo-backend/README.md) | +| @backstage/plugin-user-settings-backend | backend-plugin | true | true | [README](https://github.com/backstage/backstage/blob/master/plugins/user-settings-backend/README.md) | +| @backstage/plugin-vault-backend | backend-plugin | true | | [README](https://github.com/backstage/backstage/blob/master/plugins/vault-backend/README.md) | diff --git a/package.json b/package.json index 413d0dd56a..c89878f60e 100644 --- a/package.json +++ b/package.json @@ -109,6 +109,7 @@ "@techdocs/cli": "workspace:*", "@types/node": "^18.17.8", "@types/webpack": "^5.28.0", + "array-to-table": "^1.0.1", "command-exists": "^1.2.9", "cross-env": "^7.0.0", "e2e-test": "workspace:*", diff --git a/scripts/verify-backend-feature.js b/scripts/verify-backend-feature.js new file mode 100644 index 0000000000..53cff217b1 --- /dev/null +++ b/scripts/verify-backend-feature.js @@ -0,0 +1,86 @@ +#!/usr/bin/env node +/* + * 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. + */ + +const fs = require('fs-extra'); +const { getPackages } = require('@manypkg/get-packages'); +const { resolve, join } = require('path'); +const arrayToTable = require('array-to-table'); + +async function main(args) { + const rootPath = resolve(__dirname, '..'); + const { packages } = await getPackages(rootPath); + + const backendFeatureReports = []; + + for (const pkg of packages) { + pkgRole = pkg.packageJson.backstage?.role; + + if (pkgRole === 'backend-plugin' || pkgRole === 'backend-plugin-module') { + const backendFeatureReport = { + package: undefined, + role: undefined, + migrated: undefined, + alpha: undefined, + readme: undefined, + }; + backendFeatureReport.package = pkg.packageJson.name; + backendFeatureReport.role = pkgRole; + backendFeatureReport.readme = `[README](${pkg.packageJson.repository.url}/blob/master/${pkg.packageJson.repository.directory}/README.md)`; + const apiReportPath = join(pkg.dir, 'api-report.md'); + const apiReport = (await fs.readFile(apiReportPath)).toString(); + // console.log(apiReport) + if ( + apiReport.includes( + "import { BackendFeature } from '@backstage/backend-plugin-api';", + ) + ) { + backendFeatureReport.migrated = true; + backendFeatureReport.alpha = false; + } + + const apiReportAlphaPath = join(pkg.dir, 'api-report-alpha.md'); + if (fs.existsSync(apiReportAlphaPath)) { + const apiReportAlpha = ( + await fs.readFile(apiReportAlphaPath) + ).toString(); + if ( + apiReportAlpha.includes( + "import { BackendFeature } from '@backstage/backend-plugin-api';", + ) + ) { + backendFeatureReport.migrated = true; + backendFeatureReport.alpha = true; + } + } + + backendFeatureReports.push(backendFeatureReport); + } + } + + const table = args.includes('--table'); + + if (table) { + console.log(arrayToTable(backendFeatureReports)); + } else { + console.log(backendFeatureReports); + } +} + +main(process.argv.slice(2)).catch(error => { + console.error(error.stack || error); + process.exit(1); +}); diff --git a/yarn.lock b/yarn.lock index 7aea3a40b1..2b09754001 100644 --- a/yarn.lock +++ b/yarn.lock @@ -21367,6 +21367,13 @@ __metadata: languageName: node linkType: hard +"array-to-table@npm:^1.0.1": + version: 1.0.1 + resolution: "array-to-table@npm:1.0.1" + checksum: 3ca021c642b8698dc2ab3ca48c969af8d3f3d2f0444c5306b456cb716daf6ecdfb442be4bec54b9331de895b384de4e7e77e6f8b453e265e8328519bedd8f9a7 + languageName: node + linkType: hard + "array-union@npm:^2.1.0": version: 2.1.0 resolution: "array-union@npm:2.1.0" @@ -41151,6 +41158,7 @@ __metadata: "@types/node": ^18.17.8 "@types/webpack": ^5.28.0 "@useoptic/optic": ^0.50.10 + array-to-table: ^1.0.1 command-exists: ^1.2.9 cross-env: ^7.0.0 e2e-test: "workspace:*" From 9bf2616db673845a3f4c6b5da49c642af5dcb609 Mon Sep 17 00:00:00 2001 From: Andre Wanlin <67169551+awanlin@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:53:15 -0500 Subject: [PATCH 2/9] Update docs/backend-system/building-backends/08-migrating.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com> --- docs/backend-system/building-backends/08-migrating.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend-system/building-backends/08-migrating.md b/docs/backend-system/building-backends/08-migrating.md index f5f851e39b..e53bd6e7cc 100644 --- a/docs/backend-system/building-backends/08-migrating.md +++ b/docs/backend-system/building-backends/08-migrating.md @@ -1118,7 +1118,7 @@ backend.add( #### Search Collators -The following sections outline how you add the Catalog and TechDocs search collators +The following sections outline how you add search collators (input sources for the search indexing process). ##### Catalog From fcb2425df37e3ac7bc2ef2b42928d633348ed725 Mon Sep 17 00:00:00 2001 From: Andre Wanlin <67169551+awanlin@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:53:20 -0500 Subject: [PATCH 3/9] Update docs/backend-system/building-backends/08-migrating.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com> --- docs/backend-system/building-backends/08-migrating.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend-system/building-backends/08-migrating.md b/docs/backend-system/building-backends/08-migrating.md index e53bd6e7cc..bf856410a9 100644 --- a/docs/backend-system/building-backends/08-migrating.md +++ b/docs/backend-system/building-backends/08-migrating.md @@ -1082,7 +1082,7 @@ backend.add(import('@backstage/plugin-search-backend/alpha')); #### Search Engines -The following sections outline how you can add other Search engines +The following sections outline how you can add other Search engines than the default lunr engine. ##### Postgres From 9179ea4944c51426aee8cff9060ec426b86e4532 Mon Sep 17 00:00:00 2001 From: Andre Wanlin <67169551+awanlin@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:53:26 -0500 Subject: [PATCH 4/9] Update docs/backend-system/building-backends/08-migrating.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com> --- docs/backend-system/building-backends/08-migrating.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend-system/building-backends/08-migrating.md b/docs/backend-system/building-backends/08-migrating.md index bf856410a9..622be11160 100644 --- a/docs/backend-system/building-backends/08-migrating.md +++ b/docs/backend-system/building-backends/08-migrating.md @@ -1150,7 +1150,7 @@ backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha')); /* highlight-add-end */ ``` -### The Permissions Plugin +### The Permission Plugin A basic installation of the Permission plugin will look as follows: From 989903ee9af6f15d41430745aabb8c52cd0127b6 Mon Sep 17 00:00:00 2001 From: Andre Wanlin <67169551+awanlin@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:53:31 -0500 Subject: [PATCH 5/9] Update docs/backend-system/building-backends/08-migrating.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com> --- docs/backend-system/building-backends/08-migrating.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend-system/building-backends/08-migrating.md b/docs/backend-system/building-backends/08-migrating.md index 622be11160..6dcf17431e 100644 --- a/docs/backend-system/building-backends/08-migrating.md +++ b/docs/backend-system/building-backends/08-migrating.md @@ -1167,7 +1167,7 @@ backend.add( /* highlight-add-end */ ``` -> Note: the above includes a default allow all policy, if that is not what you want do not add the 2nd line. +> Note: The above example includes a default allow-all policy. If that is not what you want, do not add the second line and instead investigate one of the options below. #### Custom Permission Policy From 4ce6979b63fd62fe7f00620c7a462e7c9e475c21 Mon Sep 17 00:00:00 2001 From: Andre Wanlin <67169551+awanlin@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:53:55 -0500 Subject: [PATCH 6/9] Update docs/backend-system/building-backends/08-migrating.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com> --- docs/backend-system/building-backends/08-migrating.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend-system/building-backends/08-migrating.md b/docs/backend-system/building-backends/08-migrating.md index 6dcf17431e..9216192cb9 100644 --- a/docs/backend-system/building-backends/08-migrating.md +++ b/docs/backend-system/building-backends/08-migrating.md @@ -1199,7 +1199,7 @@ class ExampleAllowAllPermissionPolicy implements PermissionPolicy { const customPermissionBackendModule = createBackendModule({ pluginId: 'permission', - moduleId: 'allow-all-policy', + moduleId: 'custom-policy', register(reg) { reg.registerInit({ deps: { policy: policyExtensionPoint }, From cd716e42f60ef6d8262541de7b25e85ef5bdf1f2 Mon Sep 17 00:00:00 2001 From: Andre Wanlin <67169551+awanlin@users.noreply.github.com> Date: Mon, 8 Apr 2024 09:54:02 -0500 Subject: [PATCH 7/9] Update docs/backend-system/building-backends/08-migrating.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com> --- docs/backend-system/building-backends/08-migrating.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend-system/building-backends/08-migrating.md b/docs/backend-system/building-backends/08-migrating.md index 9216192cb9..24cd0f7826 100644 --- a/docs/backend-system/building-backends/08-migrating.md +++ b/docs/backend-system/building-backends/08-migrating.md @@ -1204,7 +1204,7 @@ const customPermissionBackendModule = createBackendModule({ reg.registerInit({ deps: { policy: policyExtensionPoint }, async init({ policy }) { - policy.setPolicy(new ExampleAllowAllPermissionPolicy()); + policy.setPolicy(new CustomPermissionPolicy()); }, }); }, From b718da632061145cc035b622554ae710bd1dd14d Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Mon, 8 Apr 2024 10:10:42 -0500 Subject: [PATCH 8/9] Updates based on feedback Signed-off-by: Andre Wanlin --- docs/backend-system/building-backends/08-migrating.md | 10 ++++++---- ...rify-backend-feature.js => list-backend-feature.js} | 0 2 files changed, 6 insertions(+), 4 deletions(-) rename scripts/{verify-backend-feature.js => list-backend-feature.js} (100%) diff --git a/docs/backend-system/building-backends/08-migrating.md b/docs/backend-system/building-backends/08-migrating.md index 24cd0f7826..0e59fa5367 100644 --- a/docs/backend-system/building-backends/08-migrating.md +++ b/docs/backend-system/building-backends/08-migrating.md @@ -1186,11 +1186,13 @@ import { } from '@backstage/plugin-permission-node'; import { policyExtensionPoint } from '@backstage/plugin-permission-node/alpha'; -class ExampleAllowAllPermissionPolicy implements PermissionPolicy { +class CustomPermissionPolicy implements PermissionPolicy { async handle( - _request: PolicyQuery, - _user?: BackstageIdentityResponse, + request: PolicyQuery, + user?: BackstageIdentityResponse, ): Promise { + // TODO: Add code here that inspects the incoming request and user, and returns AuthorizeResult.ALLOW, AuthorizeResult.DENY, or AuthorizeResult.CONDITIONAL as needed. See the docs at https://backstage.io/docs/permissions/writing-a-policy for more information + return { result: AuthorizeResult.ALLOW, }; @@ -1230,7 +1232,7 @@ const backend = createBackend(); // Other plugins... /* highlight-add-start */ -backend.add(import('@backstage/plugin-search-backend-module-catalog/alpha')); +backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha')); /* highlight-add-end */ ``` diff --git a/scripts/verify-backend-feature.js b/scripts/list-backend-feature.js similarity index 100% rename from scripts/verify-backend-feature.js rename to scripts/list-backend-feature.js From 50f3193facabe43c6f612e7642f4fac7a098cdfb Mon Sep 17 00:00:00 2001 From: Andre Wanlin Date: Mon, 8 Apr 2024 11:34:27 -0500 Subject: [PATCH 9/9] Corrected TechDocs import Signed-off-by: Andre Wanlin --- docs/backend-system/building-backends/08-migrating.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/backend-system/building-backends/08-migrating.md b/docs/backend-system/building-backends/08-migrating.md index 0e59fa5367..b85de9bf3b 100644 --- a/docs/backend-system/building-backends/08-migrating.md +++ b/docs/backend-system/building-backends/08-migrating.md @@ -1232,7 +1232,7 @@ const backend = createBackend(); // Other plugins... /* highlight-add-start */ -backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha')); +backend.add(import('@backstage/plugin-techdocs-backend/alpha')); /* highlight-add-end */ ```