From c101e683d5a554ec555b1cdff059e62ef488220b Mon Sep 17 00:00:00 2001 From: djamaile Date: Wed, 4 Oct 2023 13:49:19 +0200 Subject: [PATCH] chore: move catalogModuleGithubOrgEntityProvider to its own backend module Signed-off-by: djamaile --- .changeset/strange-dodos-film.md | 5 + .changeset/tame-trainers-visit.md | 5 + .../.eslintrc.js | 1 + .../README.md | 5 + .../api-report.md | 11 +++ .../package.json | 48 ++++++++++ .../src/index.ts | 23 +++++ .../src/module.test.ts} | 4 +- .../src/module.ts} | 4 +- .../alpha-api-report.md | 15 --- .../src/module/index.ts | 5 - yarn.lock | 91 ++++++++++++++++++- 12 files changed, 190 insertions(+), 27 deletions(-) create mode 100644 .changeset/strange-dodos-film.md create mode 100644 .changeset/tame-trainers-visit.md create mode 100644 plugins/catalog-backend-module-github-org/.eslintrc.js create mode 100644 plugins/catalog-backend-module-github-org/README.md create mode 100644 plugins/catalog-backend-module-github-org/api-report.md create mode 100644 plugins/catalog-backend-module-github-org/package.json create mode 100644 plugins/catalog-backend-module-github-org/src/index.ts rename plugins/{catalog-backend-module-github/src/module/catalogModuleGithubOrgEntityProvider.test.ts => catalog-backend-module-github-org/src/module.test.ts} (94%) rename plugins/{catalog-backend-module-github/src/module/catalogModuleGithubOrgEntityProvider.ts => catalog-backend-module-github-org/src/module.ts} (98%) diff --git a/.changeset/strange-dodos-film.md b/.changeset/strange-dodos-film.md new file mode 100644 index 0000000000..78b9119a2b --- /dev/null +++ b/.changeset/strange-dodos-film.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-github-org': minor +--- + +Added `catalogModuleGithubOrgEntityProvider` to ingest users and teams from multiple Github organizations. diff --git a/.changeset/tame-trainers-visit.md b/.changeset/tame-trainers-visit.md new file mode 100644 index 0000000000..5315f3e1d5 --- /dev/null +++ b/.changeset/tame-trainers-visit.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-github': patch +--- + +Removed `catalogModuleGithubOrgEntityProvider`. Import from `@backstage/plugin-catalog-backend-module-github-org` instead. diff --git a/plugins/catalog-backend-module-github-org/.eslintrc.js b/plugins/catalog-backend-module-github-org/.eslintrc.js new file mode 100644 index 0000000000..e2a53a6ad2 --- /dev/null +++ b/plugins/catalog-backend-module-github-org/.eslintrc.js @@ -0,0 +1 @@ +module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); diff --git a/plugins/catalog-backend-module-github-org/README.md b/plugins/catalog-backend-module-github-org/README.md new file mode 100644 index 0000000000..6b03dc299d --- /dev/null +++ b/plugins/catalog-backend-module-github-org/README.md @@ -0,0 +1,5 @@ +# @backstage/plugin-catalog-backend-module-github-org + +The github-org backend module for the catalog plugin. + +_This plugin was created through the Backstage CLI_ diff --git a/plugins/catalog-backend-module-github-org/api-report.md b/plugins/catalog-backend-module-github-org/api-report.md new file mode 100644 index 0000000000..aa40dba005 --- /dev/null +++ b/plugins/catalog-backend-module-github-org/api-report.md @@ -0,0 +1,11 @@ +## API Report File for "@backstage/plugin-catalog-backend-module-github-org" + +> 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'; + +// @public +const catalogModuleGithubOrgEntityProvider: () => BackendFeature; +export default catalogModuleGithubOrgEntityProvider; +``` diff --git a/plugins/catalog-backend-module-github-org/package.json b/plugins/catalog-backend-module-github-org/package.json new file mode 100644 index 0000000000..f6d754ceae --- /dev/null +++ b/plugins/catalog-backend-module-github-org/package.json @@ -0,0 +1,48 @@ +{ + "name": "@backstage/plugin-catalog-backend-module-github-org", + "description": "The github-org backend module for the catalog plugin.", + "version": "0.0.0", + "main": "src/index.ts", + "types": "src/index.ts", + "license": "Apache-2.0", + "publishConfig": { + "access": "public", + "main": "dist/index.cjs.js", + "types": "dist/index.d.ts" + }, + "backstage": { + "role": "backend-plugin-module" + }, + "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/backend-common": "workspace:^", + "@backstage/backend-plugin-api": "workspace:^", + "@backstage/backend-tasks": "workspace:^", + "@backstage/catalog-model": "workspace:^", + "@backstage/config": "workspace:^", + "@backstage/integration": "workspace:^", + "@backstage/plugin-catalog-backend-module-github": "workspace:^", + "@backstage/plugin-catalog-node": "workspace:^", + "@backstage/plugin-events-node": "workspace:^", + "@octokit/graphql": "^7.0.2", + "lodash": "^4.17.21", + "uuid": "^9.0.1", + "winston": "^3.10.0" + }, + "devDependencies": { + "@backstage/backend-test-utils": "workspace:^", + "@backstage/cli": "workspace:^", + "luxon": "^3.0.0" + }, + "files": [ + "dist" + ] +} diff --git a/plugins/catalog-backend-module-github-org/src/index.ts b/plugins/catalog-backend-module-github-org/src/index.ts new file mode 100644 index 0000000000..522add37fa --- /dev/null +++ b/plugins/catalog-backend-module-github-org/src/index.ts @@ -0,0 +1,23 @@ +/* + * 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. + */ + +/** + * The github-org backend module for the catalog plugin. + * + * @packageDocumentation + */ + +export { catalogModuleGithubOrgEntityProvider as default } from './module'; diff --git a/plugins/catalog-backend-module-github/src/module/catalogModuleGithubOrgEntityProvider.test.ts b/plugins/catalog-backend-module-github-org/src/module.test.ts similarity index 94% rename from plugins/catalog-backend-module-github/src/module/catalogModuleGithubOrgEntityProvider.test.ts rename to plugins/catalog-backend-module-github-org/src/module.test.ts index 1b8b115a96..19680b9df3 100644 --- a/plugins/catalog-backend-module-github/src/module/catalogModuleGithubOrgEntityProvider.test.ts +++ b/plugins/catalog-backend-module-github-org/src/module.test.ts @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Backstage Authors + * 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. @@ -19,7 +19,7 @@ import { mockServices, startTestBackend } from '@backstage/backend-test-utils'; import { EntityProvider } from '@backstage/plugin-catalog-node'; import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { Duration } from 'luxon'; -import { catalogModuleGithubOrgEntityProvider } from './catalogModuleGithubOrgEntityProvider'; +import { catalogModuleGithubOrgEntityProvider } from './module'; describe('catalogModuleGithubOrgEntityProvider', () => { it('should register provider at the catalog extension point', async () => { diff --git a/plugins/catalog-backend-module-github/src/module/catalogModuleGithubOrgEntityProvider.ts b/plugins/catalog-backend-module-github-org/src/module.ts similarity index 98% rename from plugins/catalog-backend-module-github/src/module/catalogModuleGithubOrgEntityProvider.ts rename to plugins/catalog-backend-module-github-org/src/module.ts index 4838be54e1..642441951a 100644 --- a/plugins/catalog-backend-module-github/src/module/catalogModuleGithubOrgEntityProvider.ts +++ b/plugins/catalog-backend-module-github-org/src/module.ts @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Backstage Authors + * 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. @@ -64,7 +64,7 @@ export const githubOrgEntityProviderTransformsExtensionPoint = /** * Registers the `GithubMultiOrgEntityProvider` with the catalog processing extension point. * - * @alpha + * @public */ export const catalogModuleGithubOrgEntityProvider = createBackendModule({ pluginId: 'catalog', diff --git a/plugins/catalog-backend-module-github/alpha-api-report.md b/plugins/catalog-backend-module-github/alpha-api-report.md index 3bf72c449b..cd5344f728 100644 --- a/plugins/catalog-backend-module-github/alpha-api-report.md +++ b/plugins/catalog-backend-module-github/alpha-api-report.md @@ -4,25 +4,10 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; -import { ExtensionPoint } from '@backstage/backend-plugin-api'; -import { TeamTransformer } from '@backstage/plugin-catalog-backend-module-github'; -import { UserTransformer } from '@backstage/plugin-catalog-backend-module-github'; // @alpha const catalogModuleGithubEntityProvider: () => BackendFeature; export default catalogModuleGithubEntityProvider; -// @alpha -export const catalogModuleGithubOrgEntityProvider: () => BackendFeature; - -// @alpha -export interface GithubOrgEntityProviderTransformsExtensionPoint { - setTeamTransformer(transformer: TeamTransformer): void; - setUserTransformer(transformer: UserTransformer): void; -} - -// @alpha -export const githubOrgEntityProviderTransformsExtensionPoint: ExtensionPoint; - // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/catalog-backend-module-github/src/module/index.ts b/plugins/catalog-backend-module-github/src/module/index.ts index 7e8a214ca3..9c9331763c 100644 --- a/plugins/catalog-backend-module-github/src/module/index.ts +++ b/plugins/catalog-backend-module-github/src/module/index.ts @@ -15,8 +15,3 @@ */ export { catalogModuleGithubEntityProvider as default } from './catalogModuleGithubEntityProvider'; -export { - catalogModuleGithubOrgEntityProvider, - githubOrgEntityProviderTransformsExtensionPoint, - type GithubOrgEntityProviderTransformsExtensionPoint, -} from './catalogModuleGithubOrgEntityProvider'; diff --git a/yarn.lock b/yarn.lock index 38af62fcd1..02019f1bde 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5497,7 +5497,30 @@ __metadata: languageName: unknown linkType: soft -"@backstage/plugin-catalog-backend-module-github@workspace:plugins/catalog-backend-module-github": +"@backstage/plugin-catalog-backend-module-github-org@workspace:plugins/catalog-backend-module-github-org": + version: 0.0.0-use.local + resolution: "@backstage/plugin-catalog-backend-module-github-org@workspace:plugins/catalog-backend-module-github-org" + dependencies: + "@backstage/backend-common": "workspace:^" + "@backstage/backend-plugin-api": "workspace:^" + "@backstage/backend-tasks": "workspace:^" + "@backstage/backend-test-utils": "workspace:^" + "@backstage/catalog-model": "workspace:^" + "@backstage/cli": "workspace:^" + "@backstage/config": "workspace:^" + "@backstage/integration": "workspace:^" + "@backstage/plugin-catalog-backend-module-github": "workspace:^" + "@backstage/plugin-catalog-node": "workspace:^" + "@backstage/plugin-events-node": "workspace:^" + "@octokit/graphql": ^7.0.2 + lodash: ^4.17.21 + luxon: ^3.0.0 + uuid: ^9.0.1 + winston: ^3.10.0 + languageName: unknown + linkType: soft + +"@backstage/plugin-catalog-backend-module-github@workspace:^, @backstage/plugin-catalog-backend-module-github@workspace:plugins/catalog-backend-module-github": version: 0.0.0-use.local resolution: "@backstage/plugin-catalog-backend-module-github@workspace:plugins/catalog-backend-module-github" dependencies: @@ -14024,6 +14047,17 @@ __metadata: languageName: node linkType: hard +"@octokit/endpoint@npm:^9.0.0": + version: 9.0.1 + resolution: "@octokit/endpoint@npm:9.0.1" + dependencies: + "@octokit/types": ^12.0.0 + is-plain-object: ^5.0.0 + universal-user-agent: ^6.0.0 + checksum: 4f700c66829ed0b5ced3c0d018d63de1ecf1a267064095e450b6cfeb6abddecc704947d3f04e4921ac0d4d73595d81d52802d3306945ba7a642f1386fd8db68b + languageName: node + linkType: hard + "@octokit/graphql-schema@npm:^13.7.0": version: 13.10.0 resolution: "@octokit/graphql-schema@npm:13.10.0" @@ -14045,6 +14079,17 @@ __metadata: languageName: node linkType: hard +"@octokit/graphql@npm:^7.0.2": + version: 7.0.2 + resolution: "@octokit/graphql@npm:7.0.2" + dependencies: + "@octokit/request": ^8.0.1 + "@octokit/types": ^12.0.0 + universal-user-agent: ^6.0.0 + checksum: 05a752c4c2d84fc2900d8e32e1c2d1ee98a5a14349e651cb1109d0741e821e7417a048b1bb40918534ed90a472314aabbda35688868016f248098925f82a3bfa + languageName: node + linkType: hard + "@octokit/oauth-app@npm:^4.0.7, @octokit/oauth-app@npm:^4.2.0, @octokit/oauth-app@npm:^4.2.1": version: 4.2.4 resolution: "@octokit/oauth-app@npm:4.2.4" @@ -14123,6 +14168,13 @@ __metadata: languageName: node linkType: hard +"@octokit/openapi-types@npm:^19.0.0": + version: 19.0.0 + resolution: "@octokit/openapi-types@npm:19.0.0" + checksum: 9a8125ab4e1651ca4b2f734cfa15ca52fe9fa0edd87696e4f57dfa2bcd472767f0f8a99b9324be21f863e6cd91afee423982189f97ac018f3c78a83560e616f5 + languageName: node + linkType: hard + "@octokit/plugin-paginate-rest@npm:^6.0.0, @octokit/plugin-paginate-rest@npm:^6.1.0, @octokit/plugin-paginate-rest@npm:^6.1.2": version: 6.1.2 resolution: "@octokit/plugin-paginate-rest@npm:6.1.2" @@ -14202,6 +14254,17 @@ __metadata: languageName: node linkType: hard +"@octokit/request-error@npm:^5.0.0": + version: 5.0.1 + resolution: "@octokit/request-error@npm:5.0.1" + dependencies: + "@octokit/types": ^12.0.0 + deprecation: ^2.0.0 + once: ^1.4.0 + checksum: a681341e43b4da7a8acb19e1a6ba0355b1af146fa0191f2554a98950cf85f898af6ae3ab0b0287d6c871f5465ec57cb38363b96b5019f9f77ba6f30eca39ede5 + languageName: node + linkType: hard + "@octokit/request@npm:^5.4.14, @octokit/request@npm:^5.6.3": version: 5.6.3 resolution: "@octokit/request@npm:5.6.3" @@ -14230,6 +14293,19 @@ __metadata: languageName: node linkType: hard +"@octokit/request@npm:^8.0.1": + version: 8.1.2 + resolution: "@octokit/request@npm:8.1.2" + dependencies: + "@octokit/endpoint": ^9.0.0 + "@octokit/request-error": ^5.0.0 + "@octokit/types": ^12.0.0 + is-plain-object: ^5.0.0 + universal-user-agent: ^6.0.0 + checksum: 77b9221916f557bba633293ee0d1418766ae59fdfd7ccd626bbcbf0748c6d5dec80fead29f62d8eb427b32e4d8fc4de61c3f9d23999563580890b80b52ccc8e6 + languageName: node + linkType: hard + "@octokit/rest@npm:^19.0.3": version: 19.0.13 resolution: "@octokit/rest@npm:19.0.13" @@ -14249,6 +14325,15 @@ __metadata: languageName: node linkType: hard +"@octokit/types@npm:^12.0.0": + version: 12.0.0 + resolution: "@octokit/types@npm:12.0.0" + dependencies: + "@octokit/openapi-types": ^19.0.0 + checksum: ad55e13cbeef96a63d0088df2ed0a8f3ca764db3f877aa2ecb1693de40b03c1f8e392603bd7fddaaaa74138970ea39f46e4b830d15eeeba74be1671f36440129 + languageName: node + linkType: hard + "@octokit/types@npm:^6.0.3, @octokit/types@npm:^6.10.0, @octokit/types@npm:^6.12.2, @octokit/types@npm:^6.16.1, @octokit/types@npm:^6.8.2": version: 6.41.0 resolution: "@octokit/types@npm:6.41.0" @@ -41842,7 +41927,7 @@ __metadata: languageName: node linkType: hard -"uuid@npm:^9.0.0": +"uuid@npm:^9.0.0, uuid@npm:^9.0.1": version: 9.0.1 resolution: "uuid@npm:9.0.1" bin: @@ -42602,7 +42687,7 @@ __metadata: languageName: node linkType: hard -"winston@npm:^3.2.1": +"winston@npm:^3.10.0, winston@npm:^3.2.1": version: 3.10.0 resolution: "winston@npm:3.10.0" dependencies: