@backstage/plugin-catalog-backend-module-github 0.7.8-next.2 → 0.7.9-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/dist/analyzers/GithubLocationAnalyzer.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-github
|
|
2
2
|
|
|
3
|
+
## 0.7.9-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8379bf4: Remove usages of `PluginDatabaseManager` and `PluginEndpointDiscovery` and replace with their equivalent service types
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/plugin-catalog-backend@1.30.0-next.0
|
|
10
|
+
- @backstage/backend-plugin-api@1.1.1-next.0
|
|
11
|
+
- @backstage/catalog-client@1.9.0
|
|
12
|
+
- @backstage/catalog-model@1.7.2
|
|
13
|
+
- @backstage/config@1.3.1
|
|
14
|
+
- @backstage/integration@1.16.0
|
|
15
|
+
- @backstage/plugin-catalog-common@1.1.2
|
|
16
|
+
- @backstage/plugin-catalog-node@1.15.1-next.0
|
|
17
|
+
- @backstage/plugin-events-node@0.4.7-next.0
|
|
18
|
+
|
|
19
|
+
## 0.7.8
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 468bbcc: Pass in a default schedule to the `GithubEntityProvider` if none is provided
|
|
24
|
+
- 5c9cc05: Use native fetch instead of node-fetch
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @backstage/plugin-catalog-backend@1.29.0
|
|
27
|
+
- @backstage/integration@1.16.0
|
|
28
|
+
- @backstage/backend-plugin-api@1.1.0
|
|
29
|
+
- @backstage/plugin-catalog-node@1.15.0
|
|
30
|
+
- @backstage/plugin-events-node@0.4.6
|
|
31
|
+
- @backstage/catalog-client@1.9.0
|
|
32
|
+
- @backstage/catalog-model@1.7.2
|
|
33
|
+
- @backstage/config@1.3.1
|
|
34
|
+
- @backstage/plugin-catalog-common@1.1.2
|
|
35
|
+
|
|
3
36
|
## 0.7.8-next.2
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GithubLocationAnalyzer.cjs.js","sources":["../../src/analyzers/GithubLocationAnalyzer.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CatalogApi, CatalogClient } from '@backstage/catalog-client';\nimport {\n DefaultGithubCredentialsProvider,\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport { Octokit } from '@octokit/rest';\nimport { isEmpty, trimEnd } from 'lodash';\nimport parseGitUrl from 'git-url-parse';\nimport {\n AnalyzeOptions,\n ScmLocationAnalyzer,\n} from '@backstage/plugin-catalog-node';\nimport {\n
|
|
1
|
+
{"version":3,"file":"GithubLocationAnalyzer.cjs.js","sources":["../../src/analyzers/GithubLocationAnalyzer.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CatalogApi, CatalogClient } from '@backstage/catalog-client';\nimport {\n DefaultGithubCredentialsProvider,\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport { Octokit } from '@octokit/rest';\nimport { isEmpty, trimEnd } from 'lodash';\nimport parseGitUrl from 'git-url-parse';\nimport {\n AnalyzeOptions,\n ScmLocationAnalyzer,\n} from '@backstage/plugin-catalog-node';\nimport {\n TokenManager,\n createLegacyAuthAdapters,\n} from '@backstage/backend-common';\nimport { Config } from '@backstage/config';\nimport { AuthService, DiscoveryService } from '@backstage/backend-plugin-api';\nimport { extname } from 'path';\n\n/** @public */\nexport type GithubLocationAnalyzerOptions = {\n config: Config;\n discovery: DiscoveryService;\n tokenManager?: TokenManager;\n auth?: AuthService;\n githubCredentialsProvider?: GithubCredentialsProvider;\n catalog?: CatalogApi;\n};\n\n/** @public */\nexport class GithubLocationAnalyzer implements ScmLocationAnalyzer {\n private readonly catalogClient: CatalogApi;\n private readonly githubCredentialsProvider: GithubCredentialsProvider;\n private readonly integrations: ScmIntegrationRegistry;\n private readonly auth: AuthService;\n\n constructor(options: GithubLocationAnalyzerOptions) {\n this.catalogClient =\n options.catalog ?? new CatalogClient({ discoveryApi: options.discovery });\n this.integrations = ScmIntegrations.fromConfig(options.config);\n this.githubCredentialsProvider =\n options.githubCredentialsProvider ||\n DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);\n\n this.auth = createLegacyAuthAdapters({\n auth: options.auth,\n discovery: options.discovery,\n tokenManager: options.tokenManager,\n }).auth;\n }\n\n supports(url: string) {\n const integration = this.integrations.byUrl(url);\n return integration?.type === 'github';\n }\n\n async analyze(options: AnalyzeOptions) {\n const { url, catalogFilename } = options;\n const { owner, name: repo } = parseGitUrl(url);\n\n const catalogFile = catalogFilename || 'catalog-info.yaml';\n const extension = extname(catalogFile);\n const extensionQuery = !isEmpty(extension)\n ? `extension:${extension.replace('.', '')}`\n : '';\n\n const query = `filename:${catalogFile} ${extensionQuery} repo:${owner}/${repo}`;\n\n const integration = this.integrations.github.byUrl(url);\n if (!integration) {\n throw new Error('Make sure you have a GitHub integration configured');\n }\n\n const { token: githubToken } =\n await this.githubCredentialsProvider.getCredentials({\n url,\n });\n\n const octokitClient = new Octokit({\n auth: githubToken,\n baseUrl: integration.config.apiBaseUrl,\n });\n\n const searchResult = await octokitClient.search\n .code({ q: query })\n .catch(e => {\n throw new Error(`Couldn't search repository for metadata file, ${e}`);\n });\n\n const exists = searchResult.data.total_count > 0;\n if (exists) {\n const repoInformation = await octokitClient.repos\n .get({ owner, repo })\n .catch(e => {\n throw new Error(`Couldn't fetch repo data, ${e}`);\n });\n const defaultBranch = repoInformation.data.default_branch;\n\n const { token: serviceToken } = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: 'catalog',\n });\n\n const result = await Promise.all(\n searchResult.data.items\n .map(i => `${trimEnd(url, '/')}/blob/${defaultBranch}/${i.path}`)\n .map(async target => {\n const addLocationResult = await this.catalogClient.addLocation(\n {\n type: 'url',\n target,\n dryRun: true,\n },\n { token: serviceToken },\n );\n return addLocationResult.entities.map(e => ({\n location: { type: 'url', target },\n isRegistered: !!addLocationResult.exists,\n entity: e,\n }));\n }),\n );\n\n return { existing: result.flat() };\n }\n return { existing: [] };\n }\n}\n"],"names":["CatalogClient","ScmIntegrations","DefaultGithubCredentialsProvider","createLegacyAuthAdapters","parseGitUrl","extname","isEmpty","Octokit","trimEnd"],"mappings":";;;;;;;;;;;;;;AAiDO,MAAM,sBAAsD,CAAA;AAAA,EAChD,aAAA;AAAA,EACA,yBAAA;AAAA,EACA,YAAA;AAAA,EACA,IAAA;AAAA,EAEjB,YAAY,OAAwC,EAAA;AAClD,IAAK,IAAA,CAAA,aAAA,GACH,QAAQ,OAAW,IAAA,IAAIA,4BAAc,EAAE,YAAA,EAAc,OAAQ,CAAA,SAAA,EAAW,CAAA;AAC1E,IA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,CAAK,CAAA,KAAA,CAAA,EAAGC,eAAQ,GAAK,EAAA,GAAG,CAAC,CAAS,MAAA,EAAA,aAAa,IAAI,CAAE,CAAA,IAAI,EAAE,CAC/D,CAAA,GAAA,CAAI,OAAM,MAAU,KAAA;AACnB,UAAM,MAAA,iBAAA,GAAoB,MAAM,IAAA,CAAK,aAAc,CAAA,WAAA;AAAA,YACjD;AAAA,cACE,IAAM,EAAA,KAAA;AAAA,cACN,MAAA;AAAA,cACA,MAAQ,EAAA;AAAA,aACV;AAAA,YACA,EAAE,OAAO,YAAa;AAAA,WACxB;AACA,UAAO,OAAA,iBAAA,CAAkB,QAAS,CAAA,GAAA,CAAI,CAAM,CAAA,MAAA;AAAA,YAC1C,QAAU,EAAA,EAAE,IAAM,EAAA,KAAA,EAAO,MAAO,EAAA;AAAA,YAChC,YAAA,EAAc,CAAC,CAAC,iBAAkB,CAAA,MAAA;AAAA,YAClC,MAAQ,EAAA;AAAA,WACR,CAAA,CAAA;AAAA,SACH;AAAA,OACL;AAEA,MAAA,OAAO,EAAE,QAAA,EAAU,MAAO,CAAA,IAAA,EAAO,EAAA;AAAA;AAEnC,IAAO,OAAA,EAAE,QAAU,EAAA,EAAG,EAAA;AAAA;AAE1B;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
2
|
-
import { AuthService, LoggerService, SchedulerServiceTaskRunner, SchedulerService } from '@backstage/backend-plugin-api';
|
|
2
|
+
import { DiscoveryService, AuthService, LoggerService, SchedulerServiceTaskRunner, SchedulerService } from '@backstage/backend-plugin-api';
|
|
3
3
|
import * as _backstage_catalog_model from '@backstage/catalog-model';
|
|
4
4
|
import { Entity, UserEntity } from '@backstage/catalog-model';
|
|
5
5
|
import { CatalogApi } from '@backstage/catalog-client';
|
|
6
6
|
import { GithubCredentialsProvider, ScmIntegrationRegistry, GithubIntegrationConfig } from '@backstage/integration';
|
|
7
7
|
import { ScmLocationAnalyzer, AnalyzeOptions, CatalogProcessor, LocationSpec, CatalogProcessorEmit, EntityProvider, EntityProviderConnection } from '@backstage/plugin-catalog-node';
|
|
8
|
-
import {
|
|
8
|
+
import { TokenManager } from '@backstage/backend-common';
|
|
9
9
|
import { Config } from '@backstage/config';
|
|
10
10
|
import { graphql } from '@octokit/graphql';
|
|
11
11
|
import { EventSubscriber, EventsService, EventParams } from '@backstage/plugin-events-node';
|
|
@@ -20,7 +20,7 @@ declare const githubCatalogModule: _backstage_backend_plugin_api.BackendFeature;
|
|
|
20
20
|
/** @public */
|
|
21
21
|
type GithubLocationAnalyzerOptions = {
|
|
22
22
|
config: Config;
|
|
23
|
-
discovery:
|
|
23
|
+
discovery: DiscoveryService;
|
|
24
24
|
tokenManager?: TokenManager;
|
|
25
25
|
auth?: AuthService;
|
|
26
26
|
githubCredentialsProvider?: GithubCredentialsProvider;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-backend-module-github",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9-next.0",
|
|
4
4
|
"description": "A Backstage catalog backend module that helps integrate towards GitHub",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -62,15 +62,15 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@backstage/backend-common": "^0.25.0",
|
|
65
|
-
"@backstage/backend-plugin-api": "1.1.
|
|
66
|
-
"@backstage/catalog-client": "1.9.0
|
|
67
|
-
"@backstage/catalog-model": "1.7.2
|
|
68
|
-
"@backstage/config": "1.3.1
|
|
69
|
-
"@backstage/integration": "1.16.0
|
|
70
|
-
"@backstage/plugin-catalog-backend": "1.
|
|
71
|
-
"@backstage/plugin-catalog-common": "1.1.2
|
|
72
|
-
"@backstage/plugin-catalog-node": "1.15.
|
|
73
|
-
"@backstage/plugin-events-node": "0.4.
|
|
65
|
+
"@backstage/backend-plugin-api": "1.1.1-next.0",
|
|
66
|
+
"@backstage/catalog-client": "1.9.0",
|
|
67
|
+
"@backstage/catalog-model": "1.7.2",
|
|
68
|
+
"@backstage/config": "1.3.1",
|
|
69
|
+
"@backstage/integration": "1.16.0",
|
|
70
|
+
"@backstage/plugin-catalog-backend": "1.30.0-next.0",
|
|
71
|
+
"@backstage/plugin-catalog-common": "1.1.2",
|
|
72
|
+
"@backstage/plugin-catalog-node": "1.15.1-next.0",
|
|
73
|
+
"@backstage/plugin-events-node": "0.4.7-next.0",
|
|
74
74
|
"@octokit/graphql": "^5.0.0",
|
|
75
75
|
"@octokit/rest": "^19.0.3",
|
|
76
76
|
"git-url-parse": "^15.0.0",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"uuid": "^11.0.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@backstage/backend-test-utils": "1.2.
|
|
83
|
-
"@backstage/cli": "0.29.
|
|
82
|
+
"@backstage/backend-test-utils": "1.2.1-next.0",
|
|
83
|
+
"@backstage/cli": "0.29.5-next.0",
|
|
84
84
|
"@types/lodash": "^4.14.151",
|
|
85
85
|
"luxon": "^3.0.0",
|
|
86
86
|
"msw": "^2.0.0"
|