From 4ba38d1f27246b96b035479ba3378c02e8487160 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Wed, 6 Jul 2022 16:08:25 +0200 Subject: [PATCH] Move shared types into catalog-node package Signed-off-by: Johan Haals --- packages/backend-app-api/package.json | 8 +- packages/backend-plugin-api/package.json | 8 +- packages/backend/src/next/index.ts | 40 ++--- .../src/service/CatalogPlugin.ts | 26 +--- plugins/catalog-backend/src/service/index.ts | 4 +- plugins/catalog-node/api-report.md | 10 ++ plugins/catalog-node/package.json | 1 + plugins/catalog-node/src/extensions.ts | 32 ++++ plugins/catalog-node/src/index.ts | 2 + yarn.lock | 146 +----------------- 10 files changed, 82 insertions(+), 195 deletions(-) create mode 100644 plugins/catalog-node/src/extensions.ts diff --git a/packages/backend-app-api/package.json b/packages/backend-app-api/package.json index 6ad48f86d5..ae6f7eb03b 100644 --- a/packages/backend-app-api/package.json +++ b/packages/backend-app-api/package.json @@ -35,15 +35,15 @@ }, "dependencies": { "@backstage/backend-plugin-api": "^0.0.0", - "@backstage/backend-common": "^0.14.0", - "@backstage/backend-tasks": "^0.3.2", - "@backstage/plugin-permission-node": "^0.6.2", + "@backstage/backend-common": "^0.14.1-next.2", + "@backstage/backend-tasks": "^0.3.3-next.2", + "@backstage/plugin-permission-node": "^0.6.3-next.1", "express": "^4.17.1", "express-promise-router": "^4.1.0", "winston": "^3.2.1" }, "devDependencies": { - "@backstage/cli": "^0.17.2-next.0" + "@backstage/cli": "^0.18.0-next.2" }, "files": [ "dist", diff --git a/packages/backend-plugin-api/package.json b/packages/backend-plugin-api/package.json index dc52366c65..24d2012374 100644 --- a/packages/backend-plugin-api/package.json +++ b/packages/backend-plugin-api/package.json @@ -35,13 +35,13 @@ }, "dependencies": { "@backstage/config": "^1.0.1", - "@backstage/backend-common": "^0.14.0", - "@backstage/plugin-permission-common": "^0.6.2", - "@backstage/backend-tasks": "^0.3.2", + "@backstage/backend-common": "^0.14.1-next.2", + "@backstage/plugin-permission-common": "^0.6.3-next.0", + "@backstage/backend-tasks": "^0.3.3-next.2", "express": "^4.17.1" }, "devDependencies": { - "@backstage/cli": "^0.17.2-next.0", + "@backstage/cli": "^0.18.0-next.2", "@types/express": "^4.17.6" }, "files": [ diff --git a/packages/backend/src/next/index.ts b/packages/backend/src/next/index.ts index f0f246343d..0a16160a23 100644 --- a/packages/backend/src/next/index.ts +++ b/packages/backend/src/next/index.ts @@ -15,34 +15,34 @@ */ import { createBackend } from '@backstage/backend-app-api'; -import { createBackendModule } from '@backstage/backend-plugin-api'; +// import { createBackendModule } from '@backstage/backend-plugin-api'; import { catalogPlugin, - catalogProcessingInitApiRef, + // catalogProcessingInitApiRef, } from '@backstage/plugin-catalog-backend'; -import { ScaffolderEntitiesProcessor } from '@backstage/plugin-scaffolder-backend'; +// import { ScaffolderEntitiesProcessor } from '@backstage/plugin-scaffolder-backend'; -export const scaffolderCatalogExtension = createBackendModule({ - moduleId: 'scaffolder.extention', - pluginId: 'catalog', - register(env) { - env.registerInit({ - deps: { - catalogProcessingInitApi: catalogProcessingInitApiRef, - }, - async init({ catalogProcessingInitApi }) { - catalogProcessingInitApi.addProcessor( - new ScaffolderEntitiesProcessor(), - ); - }, - }); - }, -}); +// export const scaffolderCatalogExtension = createBackendModule({ +// moduleId: 'scaffolder.extention', +// pluginId: 'catalog', +// register(env) { +// env.registerInit({ +// deps: { +// catalogProcessingInitApi: catalogProcessingInitApiRef, +// }, +// async init({ catalogProcessingInitApi }) { +// catalogProcessingInitApi.addProcessor( +// new ScaffolderEntitiesProcessor(), +// ); +// }, +// }); +// }, +// }); const backend = createBackend({ apis: [], }); backend.add(catalogPlugin({})); -backend.add(scaffolderCatalogExtension({})); +// backend.add(scaffolderCatalogExtension({})); backend.start(); diff --git a/plugins/catalog-backend/src/service/CatalogPlugin.ts b/plugins/catalog-backend/src/service/CatalogPlugin.ts index 6742757294..d6dc4d11da 100644 --- a/plugins/catalog-backend/src/service/CatalogPlugin.ts +++ b/plugins/catalog-backend/src/service/CatalogPlugin.ts @@ -17,32 +17,20 @@ import { loggerToWinstonLogger } from '@backstage/backend-app-api'; import { configServiceRef, createBackendPlugin, - createServiceRef, databaseServiceRef, loggerServiceRef, permissionsServiceRef, urlReaderServiceRef, httpRouterServiceRef, } from '@backstage/backend-plugin-api'; -import { CatalogProcessor } from '../api/processor'; +import { CatalogProcessor } from '@backstage/plugin-catalog-node'; import { CatalogBuilder } from './CatalogBuilder'; +import { + CatalogProcessingExtensionPoint, + catalogProcessingExtentionPoint, +} from '@backstage/plugin-catalog-node'; -/** - * @alpha - */ -export interface CatalogProcessingInitApi { - addProcessor(processor: CatalogProcessor): void; -} - -/** - * @alpha - */ -export const catalogProcessingInitApiRef = - createServiceRef({ - id: 'catalog.processing', - }); - -class CatalogExtensionPointImpl implements CatalogProcessingInitApi { +class CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint { #processors = new Array(); addProcessor(processor: CatalogProcessor): void { @@ -64,7 +52,7 @@ export const catalogPlugin = createBackendPlugin({ const processingExtensions = new CatalogExtensionPointImpl(); // plugins depending on this API will be initialized before this plugins init method is executed. env.registerExtensionPoint( - catalogProcessingInitApiRef, + catalogProcessingExtentionPoint, processingExtensions, ); diff --git a/plugins/catalog-backend/src/service/index.ts b/plugins/catalog-backend/src/service/index.ts index ed24780c5a..7e0c6025c3 100644 --- a/plugins/catalog-backend/src/service/index.ts +++ b/plugins/catalog-backend/src/service/index.ts @@ -16,6 +16,4 @@ export type { CatalogEnvironment } from './CatalogBuilder'; export { CatalogBuilder } from './CatalogBuilder'; - -export type { CatalogProcessingInitApi } from './CatalogPlugin'; -export { catalogPlugin, catalogProcessingInitApiRef } from './CatalogPlugin'; +export { catalogPlugin } from './CatalogPlugin'; diff --git a/plugins/catalog-node/api-report.md b/plugins/catalog-node/api-report.md index d3460e4e27..cf81f494c5 100644 --- a/plugins/catalog-node/api-report.md +++ b/plugins/catalog-node/api-report.md @@ -8,6 +8,16 @@ import { CompoundEntityRef } from '@backstage/catalog-model'; import { Entity } from '@backstage/catalog-model'; import { JsonValue } from '@backstage/types'; +import { ServiceRef } from '@backstage/backend-plugin-api'; + +// @alpha (undocumented) +export interface CatalogProcessingExtensionPoint { + // (undocumented) + addProcessor(processor: CatalogProcessor): void; +} + +// @alpha (undocumented) +export const catalogProcessingExtentionPoint: ServiceRef; // @public (undocumented) export type CatalogProcessor = { diff --git a/plugins/catalog-node/package.json b/plugins/catalog-node/package.json index a1c96990a0..d6228c717f 100644 --- a/plugins/catalog-node/package.json +++ b/plugins/catalog-node/package.json @@ -25,6 +25,7 @@ "postpack": "backstage-cli package postpack" }, "dependencies": { + "@backstage/backend-plugin-api": "^0.0.0", "@backstage/catalog-model": "^1.1.0-next.2", "@backstage/errors": "1.1.0-next.0", "@backstage/types": "^1.0.0" diff --git a/plugins/catalog-node/src/extensions.ts b/plugins/catalog-node/src/extensions.ts new file mode 100644 index 0000000000..61605d3b26 --- /dev/null +++ b/plugins/catalog-node/src/extensions.ts @@ -0,0 +1,32 @@ +/* + * Copyright 2022 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 { createServiceRef } from '@backstage/backend-plugin-api'; +import { CatalogProcessor } from './api/processor'; + +/** + * @alpha + */ +export interface CatalogProcessingExtensionPoint { + addProcessor(processor: CatalogProcessor): void; +} + +/** + * @alpha + */ +export const catalogProcessingExtentionPoint = + createServiceRef({ + id: 'catalog.processing', + }); diff --git a/plugins/catalog-node/src/index.ts b/plugins/catalog-node/src/index.ts index 6a1accfcbd..fc7a1b1b67 100644 --- a/plugins/catalog-node/src/index.ts +++ b/plugins/catalog-node/src/index.ts @@ -20,5 +20,7 @@ * @packageDocumentation */ +export type { CatalogProcessingExtensionPoint } from './extensions'; +export { catalogProcessingExtentionPoint } from './extensions'; export * from './api'; export * from './processing'; diff --git a/yarn.lock b/yarn.lock index fe5ff8cb76..e35aee85fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1557,126 +1557,6 @@ lodash "^4.17.21" uuid "^8.0.0" -"@backstage/cli@^0.17.2-next.0": - version "0.17.2" - resolved "https://registry.npmjs.org/@backstage/cli/-/cli-0.17.2.tgz#2387b8d24d8af4828b84baaa62e6b444ec4330e6" - integrity sha512-stRJWmokD7SXnclZ1dsVfA1stUP4PQPkbi3GkwY1zM84y4M20dU+YHde7MrTILMPnhMY+16WdTdfbeqLfXOJrw== - dependencies: - "@backstage/cli-common" "^0.1.9" - "@backstage/config" "^1.0.1" - "@backstage/config-loader" "^1.1.2" - "@backstage/errors" "^1.0.0" - "@backstage/release-manifests" "^0.0.4" - "@backstage/types" "^1.0.0" - "@hot-loader/react-dom-v16" "npm:@hot-loader/react-dom@^16.0.2" - "@hot-loader/react-dom-v17" "npm:@hot-loader/react-dom@^17.0.2" - "@manypkg/get-packages" "^1.1.3" - "@octokit/request" "^5.4.12" - "@rollup/plugin-commonjs" "^22.0.0" - "@rollup/plugin-json" "^4.1.0" - "@rollup/plugin-node-resolve" "^13.0.0" - "@rollup/plugin-yaml" "^3.1.0" - "@spotify/eslint-config-base" "^13.0.0" - "@spotify/eslint-config-react" "^13.0.0" - "@spotify/eslint-config-typescript" "^13.0.0" - "@sucrase/jest-plugin" "^2.1.1" - "@sucrase/webpack-loader" "^2.0.0" - "@svgr/plugin-jsx" "6.2.x" - "@svgr/plugin-svgo" "6.2.x" - "@svgr/rollup" "6.2.x" - "@svgr/webpack" "6.2.x" - "@types/webpack-env" "^1.15.2" - "@typescript-eslint/eslint-plugin" "^5.9.0" - "@typescript-eslint/parser" "^5.9.0" - "@yarnpkg/lockfile" "^1.1.0" - "@yarnpkg/parsers" "^3.0.0-rc.4" - bfj "^7.0.2" - buffer "^6.0.3" - chalk "^4.0.0" - chokidar "^3.3.1" - commander "^9.1.0" - css-loader "^6.5.1" - diff "^5.0.0" - esbuild "^0.14.10" - esbuild-loader "^2.18.0" - eslint "^8.6.0" - eslint-config-prettier "^8.3.0" - eslint-formatter-friendly "^7.0.0" - eslint-plugin-deprecation "^1.3.2" - eslint-plugin-import "^2.25.4" - eslint-plugin-jest "^26.1.2" - eslint-plugin-jsx-a11y "^6.5.1" - eslint-plugin-monorepo "^0.3.2" - eslint-plugin-react "^7.28.0" - eslint-plugin-react-hooks "^4.3.0" - eslint-webpack-plugin "^3.1.1" - express "^4.17.1" - fork-ts-checker-webpack-plugin "^7.0.0-alpha.8" - fs-extra "10.1.0" - glob "^7.1.7" - global-agent "^3.0.0" - handlebars "^4.7.3" - html-webpack-plugin "^5.3.1" - inquirer "^8.2.0" - jest "^27.5.1" - jest-css-modules "^2.1.0" - jest-runtime "^27.5.1" - jest-transform-yaml "^1.0.0" - json-schema "^0.4.0" - lodash "^4.17.21" - mini-css-extract-plugin "^2.4.2" - minimatch "5.1.0" - node-fetch "^2.6.7" - node-libs-browser "^2.2.1" - npm-packlist "^5.0.0" - ora "^5.3.0" - postcss "^8.1.0" - process "^0.11.10" - react-dev-utils "^12.0.0-next.60" - react-hot-loader "^4.13.0" - recursive-readdir "^2.2.2" - replace-in-file "^6.0.0" - rollup "^2.60.2" - rollup-plugin-dts "^4.0.1" - rollup-plugin-esbuild "^4.7.2" - rollup-plugin-postcss "^4.0.0" - rollup-pluginutils "^2.8.2" - run-script-webpack-plugin "^0.0.14" - semver "^7.3.2" - style-loader "^3.3.1" - sucrase "^3.20.2" - tar "^6.1.2" - terser-webpack-plugin "^5.1.3" - util "^0.12.3" - webpack "^5.66.0" - webpack-dev-server "^4.7.3" - webpack-node-externals "^3.0.0" - yaml "^1.10.0" - yml-loader "^2.1.0" - yn "^4.0.0" - zod "^3.11.6" - -"@backstage/config-loader@^1.1.2": - version "1.1.2" - resolved "https://registry.npmjs.org/@backstage/config-loader/-/config-loader-1.1.2.tgz#72cb0d7b2647f5a646bb279360bc34732e06521f" - integrity sha512-c5ZO7xDJn609DBIsYAWGE5kgh+7SPYUmG2ADtVX9SbXaql3VCafGlhc2hAZQa/O12W04qi3GgwGg0bqSFmx5uw== - dependencies: - "@backstage/cli-common" "^0.1.9" - "@backstage/config" "^1.0.1" - "@backstage/errors" "^1.0.0" - "@backstage/types" "^1.0.0" - "@types/json-schema" "^7.0.6" - ajv "^8.10.0" - chokidar "^3.5.2" - fs-extra "10.1.0" - json-schema "^0.4.0" - json-schema-merge-allof "^0.8.1" - json-schema-traverse "^1.0.0" - node-fetch "^2.6.7" - typescript-json-schema "^0.53.0" - yaml "^1.9.2" - yup "^0.32.9" - "@backstage/core-components@^0.9.0", "@backstage/core-components@^0.9.5": version "0.9.5" resolved "https://registry.npmjs.org/@backstage/core-components/-/core-components-0.9.5.tgz#5a0b34867aaee0549bfa67b39a69c09588fa3c7a" @@ -5675,7 +5555,7 @@ dependencies: "@rollup/pluginutils" "^3.0.8" -"@rollup/plugin-node-resolve@^13.0.0", "@rollup/plugin-node-resolve@^13.0.6": +"@rollup/plugin-node-resolve@^13.0.6": version "13.3.0" resolved "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz#da1c5c5ce8316cef96a2f823d111c1e4e498801c" integrity sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw== @@ -20624,11 +20504,6 @@ path-case@^3.0.4: dot-case "^3.0.4" tslib "^2.0.3" -path-equal@1.1.2: - version "1.1.2" - resolved "https://registry.npmjs.org/path-equal/-/path-equal-1.1.2.tgz#260e7c449c4c2022f68cc5fa6e617e892858250d" - integrity sha512-p5kxPPwCdbf5AdXzT1bUBJomhgBlEjRBavYNr1XUpMFIE4Hnf2roueCMXudZK5tnaAu1tTmp3GPzqwJK45IHEA== - path-equal@^1.1.2: version "1.2.2" resolved "https://registry.npmjs.org/path-equal/-/path-equal-1.2.2.tgz#fa2997f0a829de22ec8f5f86461ca5590d49b832" @@ -23153,11 +23028,6 @@ run-parallel@^1.1.9: resolved "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679" integrity sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q== -run-script-webpack-plugin@^0.0.14: - version "0.0.14" - resolved "https://registry.npmjs.org/run-script-webpack-plugin/-/run-script-webpack-plugin-0.0.14.tgz#fe2362b32c1dab7a8af7a6f1246fc043690cedd7" - integrity sha512-DXe6lzzEVXjBr/74zd4m4yOfmz5P6GMjzhQxDDsViOmwG7cap8UCE6RgD5rT7zf4wM83a+ToHnpB3v4efUv5IA== - run-script-webpack-plugin@^0.1.0: version "0.1.1" resolved "https://registry.npmjs.org/run-script-webpack-plugin/-/run-script-webpack-plugin-0.1.1.tgz#dad3114be32eb864d2160306e4d9c52a2c1cfd59" @@ -25441,20 +25311,6 @@ typedarray@^0.0.6: resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript-json-schema@^0.53.0: - version "0.53.1" - resolved "https://registry.npmjs.org/typescript-json-schema/-/typescript-json-schema-0.53.1.tgz#9204547f3e145169b40928998366ff6d28b81d32" - integrity sha512-Hg+RnOKUd38MOzC0rDft03a8xvwO+gCcj1F77smw2tCoZYQpFoLtrXWBGdvCX+REliko5WYel2kux17HPFqjLQ== - dependencies: - "@types/json-schema" "^7.0.9" - "@types/node" "^16.9.2" - glob "^7.1.7" - path-equal "1.1.2" - safe-stable-stringify "^2.2.0" - ts-node "^10.2.1" - typescript "~4.6.0" - yargs "^17.1.1" - typescript-json-schema@^0.54.0: version "0.54.0" resolved "https://registry.npmjs.org/typescript-json-schema/-/typescript-json-schema-0.54.0.tgz#b3fc42ad90df6a0f6ab57571ebc8b4d41125df4f"