@secustor/backstage-plugin-renovate-backend 0.17.1 → 0.18.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
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @secustor/backstage-plugin-renovate-backend
|
|
2
2
|
|
|
3
|
+
## 0.18.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#994](https://github.com/secustor/backstage-plugins/pull/994) [`3b8f87c`](https://github.com/secustor/backstage-plugins/commit/3b8f87cebdf312db85a2aae2e8ecfc3e3d7c2435) Thanks [@secustor](https://github.com/secustor)! - Add support for BitBucket Server
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#992](https://github.com/secustor/backstage-plugins/pull/992) [`dc71260`](https://github.com/secustor/backstage-plugins/commit/dc71260c5bf0897c246157fc0a82ed20ff6e1286) Thanks [@secustor](https://github.com/secustor)! - Handles error if no GitHub Credentials Provider could be initialized
|
|
12
|
+
|
|
13
|
+
## 0.17.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#962](https://github.com/secustor/backstage-plugins/pull/962) [`97465c9`](https://github.com/secustor/backstage-plugins/commit/97465c9a90610544d5e2332764f3e7240c655322) Thanks [@renovate](https://github.com/apps/renovate)! - Bump Backstage to 1.47.1
|
|
18
|
+
|
|
3
19
|
## 0.17.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
var integration = require('@backstage/integration');
|
|
4
4
|
|
|
5
5
|
async function getGithubToken(integrations, url) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
try {
|
|
7
|
+
const cred = await integration.DefaultGithubCredentialsProvider.fromIntegrations(
|
|
8
|
+
integrations
|
|
9
|
+
).getCredentials({ url });
|
|
10
|
+
return cred.token;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
exports.getGithubToken = getGithubToken;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github.cjs.js","sources":["../../../src/wrapper/platforms/github.ts"],"sourcesContent":["import {\n DefaultGithubCredentialsProvider,\n ScmIntegrations,\n} from '@backstage/integration';\n\nexport async function getGithubToken(\n integrations: ScmIntegrations,\n url: string,\n): Promise<string | undefined> {\n const cred = await DefaultGithubCredentialsProvider.fromIntegrations(\n
|
|
1
|
+
{"version":3,"file":"github.cjs.js","sources":["../../../src/wrapper/platforms/github.ts"],"sourcesContent":["import {\n DefaultGithubCredentialsProvider,\n ScmIntegrations,\n} from '@backstage/integration';\n\nexport async function getGithubToken(\n integrations: ScmIntegrations,\n url: string,\n): Promise<string | undefined> {\n try {\n const cred = await DefaultGithubCredentialsProvider.fromIntegrations(\n integrations,\n ).getCredentials({ url });\n return cred.token;\n } catch (e) {\n return undefined;\n }\n}\n"],"names":["DefaultGithubCredentialsProvider"],"mappings":";;;;AAKA,eAAsB,cAAA,CACpB,cACA,GAAA,EAC6B;AAC7B,EAAA,IAAI;AACF,IAAA,MAAM,IAAA,GAAO,MAAMA,4CAAA,CAAiC,gBAAA;AAAA,MAClD;AAAA,KACF,CAAE,cAAA,CAAe,EAAE,GAAA,EAAK,CAAA;AACxB,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACd,SAAS,CAAA,EAAG;AACV,IAAA,OAAO,MAAA;AAAA,EACT;AACF;;;;"}
|
|
@@ -21,6 +21,20 @@ async function getPlatformEnvs(target, context) {
|
|
|
21
21
|
const errMsg = `No credentials could be found for url and '${integration$1.type}' type for host ${target.host}`;
|
|
22
22
|
const url = `https://${target.host}/${target.repository}`;
|
|
23
23
|
switch (integration$1.type) {
|
|
24
|
+
case "bitbucket": {
|
|
25
|
+
const bitbucketServerIntegrationConfig = integrations.bitbucketServer.byHost(target.host);
|
|
26
|
+
const config = bitbucketServerIntegrationConfig?.config;
|
|
27
|
+
if (!config || !config.token) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`renovate on ${integration$1.type} requires token in configuration`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
env.RENOVATE_PLATFORM = "bitbucket-server";
|
|
33
|
+
env.RENOVATE_REPOSITORIES = target.repository;
|
|
34
|
+
env.RENOVATE_ENDPOINT = config.apiBaseUrl.replace(/([^\/:]\/).*$/, "$1");
|
|
35
|
+
env.RENOVATE_TOKEN = config.token;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
24
38
|
case "github": {
|
|
25
39
|
env.RENOVATE_PLATFORM = integration$1.type;
|
|
26
40
|
const token = await github.getGithubToken(integrations, url);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../../../src/wrapper/platforms/index.ts"],"sourcesContent":["import {\n DefaultGitlabCredentialsProvider,\n ScmIntegrations,\n} from '@backstage/integration';\nimport is from '@sindresorhus/is';\nimport { PlatformEnvsOptions } from './types';\nimport { TargetRepo } from '@secustor/backstage-plugin-renovate-common';\nimport { getGithubToken } from './github';\n\n/*\n Returns record of Renovate environment variables specific for the platform of targetUrl\n */\nexport async function getPlatformEnvs(\n target: TargetRepo,\n context: PlatformEnvsOptions,\n): Promise<Record<string, string>> {\n const { rootConfig, logger } = context;\n\n const env: Record<string, string> = {};\n // add Renovate platform and tokens\n const integrations = ScmIntegrations.fromConfig(rootConfig);\n const integration = integrations.byHost(target.host);\n if (is.nullOrUndefined(integration)) {\n throw new Error(\n `Could not identify platform for target ${target.host}/${target.repository}`,\n );\n }\n\n const errMsg = `No credentials could be found for url and '${integration.type}' type for host ${target.host}`;\n const url = `https://${target.host}/${target.repository}`;\n switch (integration.type) {\n case 'github': {\n env.RENOVATE_PLATFORM = integration.type;\n const token = await getGithubToken(integrations, url);\n env.RENOVATE_TOKEN = requireConfigVariable(token, errMsg);\n env.RENOVATE_REPOSITORIES = target.repository;\n break;\n }\n case 'gitlab':\n {\n const cred = await DefaultGitlabCredentialsProvider.fromIntegrations(\n integrations,\n ).getCredentials({ url });\n const gitLabIntegrationConfig = requireConfigVariable(\n integrations.gitlab.byHost(target.host)?.config,\n errMsg,\n );\n env.RENOVATE_PLATFORM = integration.type;\n env.RENOVATE_ENDPOINT =\n gitLabIntegrationConfig.apiBaseUrl ?? `https://${target.host}/api/v4`;\n env.RENOVATE_TOKEN = requireConfigVariable(cred.token, errMsg);\n env.RENOVATE_REPOSITORIES = target.repository;\n }\n break;\n default:\n throw new Error(`Unsupported platform type ${integration.type}`);\n }\n
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../src/wrapper/platforms/index.ts"],"sourcesContent":["import {\n DefaultGitlabCredentialsProvider,\n ScmIntegrations,\n} from '@backstage/integration';\nimport is from '@sindresorhus/is';\nimport { PlatformEnvsOptions } from './types';\nimport { TargetRepo } from '@secustor/backstage-plugin-renovate-common';\nimport { getGithubToken } from './github';\n\n/*\n Returns record of Renovate environment variables specific for the platform of targetUrl\n */\nexport async function getPlatformEnvs(\n target: TargetRepo,\n context: PlatformEnvsOptions,\n): Promise<Record<string, string>> {\n const { rootConfig, logger } = context;\n\n const env: Record<string, string> = {};\n // add Renovate platform and tokens\n const integrations = ScmIntegrations.fromConfig(rootConfig);\n const integration = integrations.byHost(target.host);\n if (is.nullOrUndefined(integration)) {\n throw new Error(\n `Could not identify platform for target ${target.host}/${target.repository}`,\n );\n }\n\n const errMsg = `No credentials could be found for url and '${integration.type}' type for host ${target.host}`;\n const url = `https://${target.host}/${target.repository}`;\n switch (integration.type) {\n case 'bitbucket': {\n const bitbucketServerIntegrationConfig =\n integrations.bitbucketServer.byHost(target.host);\n\n const config = bitbucketServerIntegrationConfig?.config;\n if (!config || !config.token) {\n throw new Error(\n `renovate on ${integration.type} requires token in configuration`,\n );\n }\n\n env.RENOVATE_PLATFORM = 'bitbucket-server';\n env.RENOVATE_REPOSITORIES = target.repository;\n env.RENOVATE_ENDPOINT = config.apiBaseUrl.replace(/([^\\/:]\\/).*$/, '$1');\n env.RENOVATE_TOKEN = config.token;\n break;\n }\n\n case 'github': {\n env.RENOVATE_PLATFORM = integration.type;\n const token = await getGithubToken(integrations, url);\n env.RENOVATE_TOKEN = requireConfigVariable(token, errMsg);\n env.RENOVATE_REPOSITORIES = target.repository;\n break;\n }\n case 'gitlab':\n {\n const cred = await DefaultGitlabCredentialsProvider.fromIntegrations(\n integrations,\n ).getCredentials({ url });\n const gitLabIntegrationConfig = requireConfigVariable(\n integrations.gitlab.byHost(target.host)?.config,\n errMsg,\n );\n env.RENOVATE_PLATFORM = integration.type;\n env.RENOVATE_ENDPOINT =\n gitLabIntegrationConfig.apiBaseUrl ?? `https://${target.host}/api/v4`;\n env.RENOVATE_TOKEN = requireConfigVariable(cred.token, errMsg);\n env.RENOVATE_REPOSITORIES = target.repository;\n }\n break;\n default:\n throw new Error(`Unsupported platform type ${integration.type}`);\n }\n const githubComURL = 'https://github.com';\n const githubComIntegration = integrations.github.byUrl(githubComURL);\n if (is.nullOrUndefined(githubComIntegration)) {\n logger.warn(`No Github.com integration has been found`);\n } else {\n const githubComToken = await getGithubToken(integrations, githubComURL);\n if (githubComToken) {\n env.GITHUB_COM_TOKEN = githubComToken;\n } else {\n logger.warn(\n `Could not get token for Github.com token in the defined integrations`,\n );\n }\n }\n return env;\n}\n\nfunction requireConfigVariable<T>(\n input: T | undefined | null,\n errMessage: string,\n): T {\n if (is.nullOrUndefined(input)) {\n throw new Error(errMessage);\n }\n return input;\n}\n\nexport function getFileUrl(options: {\n packageFile: string;\n host: string;\n repository: string;\n}): string | null {\n if (options.host.includes('github')) {\n return `https://${options.host}/${options.repository}/blob/HEAD/${options.packageFile}`;\n }\n return null;\n}\n"],"names":["ScmIntegrations","integration","is","getGithubToken","DefaultGitlabCredentialsProvider"],"mappings":";;;;;;;;;;AAYA,eAAsB,eAAA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CAAM,YAAY,CAAA;AACnE,EAAA,IAAIC,mBAAA,CAAG,eAAA,CAAgB,oBAAoB,CAAA,EAAG;AAC5C,IAAA,MAAA,CAAO,KAAK,CAAA,wCAAA,CAA0C,CAAA;AAAA,EACxD,CAAA,MAAO;AACL,IAAA,MAAM,cAAA,GAAiB,MAAMC,qBAAA,CAAe,YAAA,EAAc,YAAY,CAAA;AACtE,IAAA,IAAI,cAAA,EAAgB;AAClB,MAAA,GAAA,CAAI,gBAAA,GAAmB,cAAA;AAAA,IACzB,CAAA,MAAO;AACL,MAAA,MAAA,CAAO,IAAA;AAAA,QACL,CAAA,oEAAA;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,GAAA;AACT;AAEA,SAAS,qBAAA,CACP,OACA,UAAA,EACG;AACH,EAAA,IAAID,mBAAA,CAAG,eAAA,CAAgB,KAAK,CAAA,EAAG;AAC7B,IAAA,MAAM,IAAI,MAAM,UAAU,CAAA;AAAA,EAC5B;AACA,EAAA,OAAO,KAAA;AACT;AAEO,SAAS,WAAW,OAAA,EAIT;AAChB,EAAA,IAAI,OAAA,CAAQ,IAAA,CAAK,QAAA,CAAS,QAAQ,CAAA,EAAG;AACnC,IAAA,OAAO,CAAA,QAAA,EAAW,QAAQ,IAAI,CAAA,CAAA,EAAI,QAAQ,UAAU,CAAA,WAAA,EAAc,QAAQ,WAAW,CAAA,CAAA;AAAA,EACvF;AACA,EAAA,OAAO,IAAA;AACT;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secustor/backstage-plugin-renovate-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "LGPL-3.0-or-later",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"postpack": "backstage-cli package postpack"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@backstage/backend-defaults": "^0.
|
|
54
|
+
"@backstage/backend-defaults": "^0.15.0",
|
|
55
55
|
"@backstage/backend-openapi-utils": "^0.6.4",
|
|
56
56
|
"@backstage/backend-plugin-api": "^1.6.0",
|
|
57
57
|
"@backstage/catalog-client": "^1.12.1",
|