@backstage/integration 1.11.0 → 1.12.0-next.1
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 +32 -0
- package/dist/ScmIntegrations.esm.js +4 -10
- package/dist/ScmIntegrations.esm.js.map +1 -1
- package/dist/awsCodeCommit/AwsCodeCommitIntegration.esm.js +13 -21
- package/dist/awsCodeCommit/AwsCodeCommitIntegration.esm.js.map +1 -1
- package/dist/awsCodeCommit/config.esm.js +6 -11
- package/dist/awsCodeCommit/config.esm.js.map +1 -1
- package/dist/awsS3/AwsS3Integration.esm.js +11 -19
- package/dist/awsS3/AwsS3Integration.esm.js.map +1 -1
- package/dist/awsS3/config.esm.js +2 -3
- package/dist/awsS3/config.esm.js.map +1 -1
- package/dist/azure/AzureIntegration.esm.js +12 -21
- package/dist/azure/AzureIntegration.esm.js.map +1 -1
- package/dist/azure/AzureUrl.esm.js +72 -76
- package/dist/azure/AzureUrl.esm.js.map +1 -1
- package/dist/azure/CachedAzureDevOpsCredentialsProvider.esm.js +2 -8
- package/dist/azure/CachedAzureDevOpsCredentialsProvider.esm.js.map +1 -1
- package/dist/azure/DefaultAzureDevOpsCredentialsProvider.esm.js +3 -6
- package/dist/azure/DefaultAzureDevOpsCredentialsProvider.esm.js.map +1 -1
- package/dist/azure/config.esm.js +12 -15
- package/dist/azure/config.esm.js.map +1 -1
- package/dist/azure/deprecated.esm.js +2 -3
- package/dist/azure/deprecated.esm.js.map +1 -1
- package/dist/bitbucket/BitbucketIntegration.esm.js +19 -27
- package/dist/bitbucket/BitbucketIntegration.esm.js.map +1 -1
- package/dist/bitbucket/config.esm.js +3 -4
- package/dist/bitbucket/config.esm.js.map +1 -1
- package/dist/bitbucketCloud/BitbucketCloudIntegration.esm.js +13 -21
- package/dist/bitbucketCloud/BitbucketCloudIntegration.esm.js.map +1 -1
- package/dist/bitbucketCloud/config.esm.js +1 -2
- package/dist/bitbucketCloud/config.esm.js.map +1 -1
- package/dist/bitbucketServer/BitbucketServerIntegration.esm.js +13 -21
- package/dist/bitbucketServer/BitbucketServerIntegration.esm.js.map +1 -1
- package/dist/bitbucketServer/config.esm.js +1 -2
- package/dist/bitbucketServer/config.esm.js.map +1 -1
- package/dist/gerrit/GerritIntegration.esm.js +11 -19
- package/dist/gerrit/GerritIntegration.esm.js.map +1 -1
- package/dist/gerrit/config.esm.js +1 -2
- package/dist/gerrit/config.esm.js.map +1 -1
- package/dist/gitea/GiteaIntegration.esm.js +10 -18
- package/dist/gitea/GiteaIntegration.esm.js.map +1 -1
- package/dist/gitea/config.esm.js +1 -2
- package/dist/gitea/config.esm.js.map +1 -1
- package/dist/gitea/core.esm.js +1 -2
- package/dist/gitea/core.esm.js.map +1 -1
- package/dist/github/GithubIntegration.esm.js +11 -19
- package/dist/github/GithubIntegration.esm.js.map +1 -1
- package/dist/github/SingleInstanceGithubCredentialsProvider.esm.js +22 -40
- package/dist/github/SingleInstanceGithubCredentialsProvider.esm.js.map +1 -1
- package/dist/github/config.esm.js +3 -4
- package/dist/github/config.esm.js.map +1 -1
- package/dist/gitlab/GitLabIntegration.esm.js +11 -19
- package/dist/gitlab/GitLabIntegration.esm.js.map +1 -1
- package/dist/gitlab/SingleInstanceGitlabCredentialsProvider.esm.js +5 -12
- package/dist/gitlab/SingleInstanceGitlabCredentialsProvider.esm.js.map +1 -1
- package/dist/gitlab/config.esm.js +1 -2
- package/dist/gitlab/config.esm.js.map +1 -1
- package/dist/harness/HarnessIntegration.esm.js +10 -18
- package/dist/harness/HarnessIntegration.esm.js.map +1 -1
- package/dist/harness/core.esm.js +48 -46
- package/dist/harness/core.esm.js.map +1 -1
- package/dist/index.cjs.js +327 -498
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +54 -37
- package/dist/index.esm.js +1 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
- package/dist/github/deprecated.esm.js +0 -26
- package/dist/github/deprecated.esm.js.map +0 -1
|
@@ -2,16 +2,27 @@ import parseGitUrl from 'git-url-parse';
|
|
|
2
2
|
import { basicIntegrations, defaultScmResolveUrl } from '../helpers.esm.js';
|
|
3
3
|
import { readBitbucketIntegrationConfigs } from './config.esm.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
-
var __publicField = (obj, key, value) => {
|
|
8
|
-
__defNormalProp(obj, key + "" , value);
|
|
9
|
-
return value;
|
|
10
|
-
};
|
|
11
|
-
const _BitbucketIntegration = class _BitbucketIntegration {
|
|
5
|
+
class BitbucketIntegration {
|
|
12
6
|
constructor(integrationConfig) {
|
|
13
7
|
this.integrationConfig = integrationConfig;
|
|
14
8
|
}
|
|
9
|
+
static factory = ({
|
|
10
|
+
config
|
|
11
|
+
}) => {
|
|
12
|
+
const configs = readBitbucketIntegrationConfigs(
|
|
13
|
+
config.getOptionalConfigArray("integrations.bitbucket") ?? [
|
|
14
|
+
// if integrations.bitbucket was not used assume the use was migrated to the new configs
|
|
15
|
+
// and backport for the deprecated integration to be usable for other parts of the system
|
|
16
|
+
// until these got migrated
|
|
17
|
+
...config.getOptionalConfigArray("integrations.bitbucketCloud") ?? [],
|
|
18
|
+
...config.getOptionalConfigArray("integrations.bitbucketServer") ?? []
|
|
19
|
+
]
|
|
20
|
+
);
|
|
21
|
+
return basicIntegrations(
|
|
22
|
+
configs.map((c) => new BitbucketIntegration(c)),
|
|
23
|
+
(i) => i.config.host
|
|
24
|
+
);
|
|
25
|
+
};
|
|
15
26
|
get type() {
|
|
16
27
|
return "bitbucket";
|
|
17
28
|
}
|
|
@@ -42,26 +53,7 @@ const _BitbucketIntegration = class _BitbucketIntegration {
|
|
|
42
53
|
editUrl.searchParams.set("at", urlData.ref);
|
|
43
54
|
return editUrl.toString();
|
|
44
55
|
}
|
|
45
|
-
}
|
|
46
|
-
__publicField(_BitbucketIntegration, "factory", ({
|
|
47
|
-
config
|
|
48
|
-
}) => {
|
|
49
|
-
var _a, _b, _c;
|
|
50
|
-
const configs = readBitbucketIntegrationConfigs(
|
|
51
|
-
(_c = config.getOptionalConfigArray("integrations.bitbucket")) != null ? _c : [
|
|
52
|
-
// if integrations.bitbucket was not used assume the use was migrated to the new configs
|
|
53
|
-
// and backport for the deprecated integration to be usable for other parts of the system
|
|
54
|
-
// until these got migrated
|
|
55
|
-
...(_a = config.getOptionalConfigArray("integrations.bitbucketCloud")) != null ? _a : [],
|
|
56
|
-
...(_b = config.getOptionalConfigArray("integrations.bitbucketServer")) != null ? _b : []
|
|
57
|
-
]
|
|
58
|
-
);
|
|
59
|
-
return basicIntegrations(
|
|
60
|
-
configs.map((c) => new _BitbucketIntegration(c)),
|
|
61
|
-
(i) => i.config.host
|
|
62
|
-
);
|
|
63
|
-
});
|
|
64
|
-
let BitbucketIntegration = _BitbucketIntegration;
|
|
56
|
+
}
|
|
65
57
|
|
|
66
58
|
export { BitbucketIntegration };
|
|
67
59
|
//# sourceMappingURL=BitbucketIntegration.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitbucketIntegration.esm.js","sources":["../../src/bitbucket/BitbucketIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 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 parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketIntegrationConfig,\n readBitbucketIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket based integration.\n *\n * @public\n * @deprecated replaced by the integrations bitbucketCloud and bitbucketServer.\n */\nexport class BitbucketIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucket') ?? [\n // if integrations.bitbucket was not used assume the use was migrated to the new configs\n // and backport for the deprecated integration to be usable for other parts of the system\n // until these got migrated\n ...(config.getOptionalConfigArray('integrations.bitbucketCloud') ?? []),\n ...(config.getOptionalConfigArray('integrations.bitbucketServer') ??\n []),\n ],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: BitbucketIntegrationConfig) {}\n\n get type(): string {\n return 'bitbucket';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n if (!options.lineNumber) {\n return resolved;\n }\n\n const url = new URL(resolved);\n\n if (this.integrationConfig.host === 'bitbucket.org') {\n // Bitbucket Cloud uses the syntax #lines-{start}[:{end}][,...]\n url.hash = `lines-${options.lineNumber}`;\n } else {\n // Bitbucket Server uses the syntax #{start}[-{end}][,...]\n url.hash = `${options.lineNumber}`;\n }\n\n return url.toString();\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n // TODO: Not sure what spa=0 does, at least bitbucket.org doesn't support it\n // but this is taken over from the initial implementation.\n editUrl.searchParams.set('spa', '0');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BitbucketIntegration.esm.js","sources":["../../src/bitbucket/BitbucketIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 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 parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketIntegrationConfig,\n readBitbucketIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket based integration.\n *\n * @public\n * @deprecated replaced by the integrations bitbucketCloud and bitbucketServer.\n */\nexport class BitbucketIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucket') ?? [\n // if integrations.bitbucket was not used assume the use was migrated to the new configs\n // and backport for the deprecated integration to be usable for other parts of the system\n // until these got migrated\n ...(config.getOptionalConfigArray('integrations.bitbucketCloud') ?? []),\n ...(config.getOptionalConfigArray('integrations.bitbucketServer') ??\n []),\n ],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: BitbucketIntegrationConfig) {}\n\n get type(): string {\n return 'bitbucket';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n if (!options.lineNumber) {\n return resolved;\n }\n\n const url = new URL(resolved);\n\n if (this.integrationConfig.host === 'bitbucket.org') {\n // Bitbucket Cloud uses the syntax #lines-{start}[:{end}][,...]\n url.hash = `lines-${options.lineNumber}`;\n } else {\n // Bitbucket Server uses the syntax #{start}[-{end}][,...]\n url.hash = `${options.lineNumber}`;\n }\n\n return url.toString();\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n // TODO: Not sure what spa=0 does, at least bitbucket.org doesn't support it\n // but this is taken over from the initial implementation.\n editUrl.searchParams.set('spa', '0');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":[],"mappings":";;;;AA8BO,MAAM,oBAA+C,CAAA;AAAA,EAoB1D,YAA6B,iBAA+C,EAAA;AAA/C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA,CAAA;AAAA,GAAgD;AAAA,EAnB7E,OAAO,UAAwD,CAAC;AAAA,IAC9D,MAAA;AAAA,GACI,KAAA;AACJ,IAAA,MAAM,OAAU,GAAA,+BAAA;AAAA,MACd,MAAA,CAAO,sBAAuB,CAAA,wBAAwB,CAAK,IAAA;AAAA;AAAA;AAAA;AAAA,QAIzD,GAAI,MAAA,CAAO,sBAAuB,CAAA,6BAA6B,KAAK,EAAC;AAAA,QACrE,GAAI,MAAA,CAAO,sBAAuB,CAAA,8BAA8B,KAC9D,EAAC;AAAA,OACL;AAAA,KACF,CAAA;AACA,IAAO,OAAA,iBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,oBAAA,CAAqB,CAAC,CAAC,CAAA;AAAA,MAC5C,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA,IAAA;AAAA,KAChB,CAAA;AAAA,GACF,CAAA;AAAA,EAIA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,WAAA,CAAA;AAAA,GACT;AAAA,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA,CAAA;AAAA,GAChC;AAAA,EAEA,IAAI,MAAqC,GAAA;AACvC,IAAA,OAAO,IAAK,CAAA,iBAAA,CAAA;AAAA,GACd;AAAA,EAEA,WAAW,OAIA,EAAA;AACT,IAAM,MAAA,QAAA,GAAW,qBAAqB,OAAO,CAAA,CAAA;AAC7C,IAAI,IAAA,CAAC,QAAQ,UAAY,EAAA;AACvB,MAAO,OAAA,QAAA,CAAA;AAAA,KACT;AAEA,IAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA,CAAA;AAE5B,IAAI,IAAA,IAAA,CAAK,iBAAkB,CAAA,IAAA,KAAS,eAAiB,EAAA;AAEnD,MAAI,GAAA,CAAA,IAAA,GAAO,CAAS,MAAA,EAAA,OAAA,CAAQ,UAAU,CAAA,CAAA,CAAA;AAAA,KACjC,MAAA;AAEL,MAAI,GAAA,CAAA,IAAA,GAAO,CAAG,EAAA,OAAA,CAAQ,UAAU,CAAA,CAAA,CAAA;AAAA,KAClC;AAEA,IAAA,OAAO,IAAI,QAAS,EAAA,CAAA;AAAA,GACtB;AAAA,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAM,MAAA,OAAA,GAAU,YAAY,GAAG,CAAA,CAAA;AAC/B,IAAM,MAAA,OAAA,GAAU,IAAI,GAAA,CAAI,GAAG,CAAA,CAAA;AAE3B,IAAQ,OAAA,CAAA,YAAA,CAAa,GAAI,CAAA,MAAA,EAAQ,MAAM,CAAA,CAAA;AAGvC,IAAQ,OAAA,CAAA,YAAA,CAAa,GAAI,CAAA,KAAA,EAAO,GAAG,CAAA,CAAA;AACnC,IAAA,OAAA,CAAQ,YAAa,CAAA,GAAA,CAAI,IAAM,EAAA,OAAA,CAAQ,GAAG,CAAA,CAAA;AAC1C,IAAA,OAAO,QAAQ,QAAS,EAAA,CAAA;AAAA,GAC1B;AACF;;;;"}
|
|
@@ -4,12 +4,11 @@ import { isValidHost } from '../helpers.esm.js';
|
|
|
4
4
|
const BITBUCKET_HOST = "bitbucket.org";
|
|
5
5
|
const BITBUCKET_API_BASE_URL = "https://api.bitbucket.org/2.0";
|
|
6
6
|
function readBitbucketIntegrationConfig(config) {
|
|
7
|
-
|
|
8
|
-
const host = (_a = config.getOptionalString("host")) != null ? _a : BITBUCKET_HOST;
|
|
7
|
+
const host = config.getOptionalString("host") ?? BITBUCKET_HOST;
|
|
9
8
|
let apiBaseUrl = config.getOptionalString("apiBaseUrl");
|
|
10
|
-
const token =
|
|
9
|
+
const token = config.getOptionalString("token")?.trim();
|
|
11
10
|
const username = config.getOptionalString("username");
|
|
12
|
-
const appPassword =
|
|
11
|
+
const appPassword = config.getOptionalString("appPassword")?.trim();
|
|
13
12
|
if (!isValidHost(host)) {
|
|
14
13
|
throw new Error(
|
|
15
14
|
`Invalid Bitbucket integration config, '${host}' is not a valid host`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.esm.js","sources":["../../src/bitbucket/config.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\nconst BITBUCKET_HOST = 'bitbucket.org';\nconst BITBUCKET_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket API provider.\n *\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport type BitbucketIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.org\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://api.bitbucket.org/2.0\",\n * with no trailing slash.\n *\n * Values omitted at the optional property at the app-config will be deduced\n * from the \"host\" value.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n};\n\n/**\n * Reads a single Bitbucket integration config.\n *\n * @param config - The config object of a single integration\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfig(\n config: Config,\n): BitbucketIntegrationConfig {\n const host = config.getOptionalString('host') ?? BITBUCKET_HOST;\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const appPassword = config.getOptionalString('appPassword')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === BITBUCKET_HOST) {\n apiBaseUrl = BITBUCKET_API_BASE_URL;\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n appPassword,\n };\n}\n\n/**\n * Reads a set of Bitbucket integration configs, and inserts some defaults for\n * public Bitbucket if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfigs(\n configs: Config[],\n): BitbucketIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === BITBUCKET_HOST)) {\n result.push({\n host: BITBUCKET_HOST,\n apiBaseUrl: BITBUCKET_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":";;;AAoBA,MAAM,cAAiB,GAAA,eAAA,CAAA;AACvB,MAAM,sBAAyB,GAAA,+BAAA,CAAA;AAoDxB,SAAS,+BACd,MAC4B,EAAA;
|
|
1
|
+
{"version":3,"file":"config.esm.js","sources":["../../src/bitbucket/config.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\nconst BITBUCKET_HOST = 'bitbucket.org';\nconst BITBUCKET_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket API provider.\n *\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport type BitbucketIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.org\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://api.bitbucket.org/2.0\",\n * with no trailing slash.\n *\n * Values omitted at the optional property at the app-config will be deduced\n * from the \"host\" value.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n};\n\n/**\n * Reads a single Bitbucket integration config.\n *\n * @param config - The config object of a single integration\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfig(\n config: Config,\n): BitbucketIntegrationConfig {\n const host = config.getOptionalString('host') ?? BITBUCKET_HOST;\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const appPassword = config.getOptionalString('appPassword')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else if (host === BITBUCKET_HOST) {\n apiBaseUrl = BITBUCKET_API_BASE_URL;\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n appPassword,\n };\n}\n\n/**\n * Reads a set of Bitbucket integration configs, and inserts some defaults for\n * public Bitbucket if not specified.\n *\n * @param configs - All of the integration config objects\n * @public\n * @deprecated bitbucket integration replaced by integrations bitbucketCloud and bitbucketServer.\n */\nexport function readBitbucketIntegrationConfigs(\n configs: Config[],\n): BitbucketIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added, put one in the list as\n // a convenience\n if (!result.some(c => c.host === BITBUCKET_HOST)) {\n result.push({\n host: BITBUCKET_HOST,\n apiBaseUrl: BITBUCKET_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":";;;AAoBA,MAAM,cAAiB,GAAA,eAAA,CAAA;AACvB,MAAM,sBAAyB,GAAA,+BAAA,CAAA;AAoDxB,SAAS,+BACd,MAC4B,EAAA;AAC5B,EAAA,MAAM,IAAO,GAAA,MAAA,CAAO,iBAAkB,CAAA,MAAM,CAAK,IAAA,cAAA,CAAA;AACjD,EAAI,IAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA,CAAA;AACtD,EAAA,MAAM,KAAQ,GAAA,MAAA,CAAO,iBAAkB,CAAA,OAAO,GAAG,IAAK,EAAA,CAAA;AACtD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA,CAAA;AACpD,EAAA,MAAM,WAAc,GAAA,MAAA,CAAO,iBAAkB,CAAA,aAAa,GAAG,IAAK,EAAA,CAAA;AAElE,EAAI,IAAA,CAAC,WAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,0CAA0C,IAAI,CAAA,qBAAA,CAAA;AAAA,KAChD,CAAA;AAAA,GACF;AAEA,EAAA,IAAI,UAAY,EAAA;AACd,IAAa,UAAA,GAAA,OAAA,CAAQ,YAAY,GAAG,CAAA,CAAA;AAAA,GACtC,MAAA,IAAW,SAAS,cAAgB,EAAA;AAClC,IAAa,UAAA,GAAA,sBAAA,CAAA;AAAA,GACR,MAAA;AACL,IAAA,UAAA,GAAa,WAAW,IAAI,CAAA,aAAA,CAAA,CAAA;AAAA,GAC9B;AAEA,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,GACF,CAAA;AACF,CAAA;AAUO,SAAS,gCACd,OAC8B,EAAA;AAE9B,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,8BAA8B,CAAA,CAAA;AAIzD,EAAA,IAAI,CAAC,MAAO,CAAA,IAAA,CAAK,OAAK,CAAE,CAAA,IAAA,KAAS,cAAc,CAAG,EAAA;AAChD,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA,cAAA;AAAA,MACN,UAAY,EAAA,sBAAA;AAAA,KACb,CAAA,CAAA;AAAA,GACH;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
|
|
@@ -2,16 +2,21 @@ import parseGitUrl from 'git-url-parse';
|
|
|
2
2
|
import { basicIntegrations, defaultScmResolveUrl } from '../helpers.esm.js';
|
|
3
3
|
import { readBitbucketCloudIntegrationConfigs } from './config.esm.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
-
var __publicField = (obj, key, value) => {
|
|
8
|
-
__defNormalProp(obj, key + "" , value);
|
|
9
|
-
return value;
|
|
10
|
-
};
|
|
11
|
-
const _BitbucketCloudIntegration = class _BitbucketCloudIntegration {
|
|
5
|
+
class BitbucketCloudIntegration {
|
|
12
6
|
constructor(integrationConfig) {
|
|
13
7
|
this.integrationConfig = integrationConfig;
|
|
14
8
|
}
|
|
9
|
+
static factory = ({
|
|
10
|
+
config
|
|
11
|
+
}) => {
|
|
12
|
+
const configs = readBitbucketCloudIntegrationConfigs(
|
|
13
|
+
config.getOptionalConfigArray("integrations.bitbucketCloud") ?? []
|
|
14
|
+
);
|
|
15
|
+
return basicIntegrations(
|
|
16
|
+
configs.map((c) => new BitbucketCloudIntegration(c)),
|
|
17
|
+
(i) => i.config.host
|
|
18
|
+
);
|
|
19
|
+
};
|
|
15
20
|
get type() {
|
|
16
21
|
return "bitbucketCloud";
|
|
17
22
|
}
|
|
@@ -37,20 +42,7 @@ const _BitbucketCloudIntegration = class _BitbucketCloudIntegration {
|
|
|
37
42
|
editUrl.searchParams.set("at", urlData.ref);
|
|
38
43
|
return editUrl.toString();
|
|
39
44
|
}
|
|
40
|
-
}
|
|
41
|
-
__publicField(_BitbucketCloudIntegration, "factory", ({
|
|
42
|
-
config
|
|
43
|
-
}) => {
|
|
44
|
-
var _a;
|
|
45
|
-
const configs = readBitbucketCloudIntegrationConfigs(
|
|
46
|
-
(_a = config.getOptionalConfigArray("integrations.bitbucketCloud")) != null ? _a : []
|
|
47
|
-
);
|
|
48
|
-
return basicIntegrations(
|
|
49
|
-
configs.map((c) => new _BitbucketCloudIntegration(c)),
|
|
50
|
-
(i) => i.config.host
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
let BitbucketCloudIntegration = _BitbucketCloudIntegration;
|
|
45
|
+
}
|
|
54
46
|
|
|
55
47
|
export { BitbucketCloudIntegration };
|
|
56
48
|
//# sourceMappingURL=BitbucketCloudIntegration.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitbucketCloudIntegration.esm.js","sources":["../../src/bitbucketCloud/BitbucketCloudIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 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 parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketCloudIntegrationConfig,\n readBitbucketCloudIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Cloud based integration.\n *\n * @public\n */\nexport class BitbucketCloudIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketCloudIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketCloudIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketCloud') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketCloudIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketCloudIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketCloud';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketCloudIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Cloud line numbers use the syntax #lines-42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = `lines-${options.lineNumber}`;\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BitbucketCloudIntegration.esm.js","sources":["../../src/bitbucketCloud/BitbucketCloudIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 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 parseGitUrl from 'git-url-parse';\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketCloudIntegrationConfig,\n readBitbucketCloudIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Cloud based integration.\n *\n * @public\n */\nexport class BitbucketCloudIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketCloudIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketCloudIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketCloud') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketCloudIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketCloudIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketCloud';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketCloudIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Cloud line numbers use the syntax #lines-42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = `lines-${options.lineNumber}`;\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n const urlData = parseGitUrl(url);\n const editUrl = new URL(url);\n\n editUrl.searchParams.set('mode', 'edit');\n editUrl.searchParams.set('at', urlData.ref);\n return editUrl.toString();\n }\n}\n"],"names":[],"mappings":";;;;AA6BO,MAAM,yBAAoD,CAAA;AAAA,EAa/D,YACmB,iBACjB,EAAA;AADiB,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA,CAAA;AAAA,GAChB;AAAA,EAdH,OAAO,UAA6D,CAAC;AAAA,IACnE,MAAA;AAAA,GACI,KAAA;AACJ,IAAA,MAAM,OAAU,GAAA,oCAAA;AAAA,MACd,MAAO,CAAA,sBAAA,CAAuB,6BAA6B,CAAA,IAAK,EAAC;AAAA,KACnE,CAAA;AACA,IAAO,OAAA,iBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,yBAAA,CAA0B,CAAC,CAAC,CAAA;AAAA,MACjD,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA,IAAA;AAAA,KAChB,CAAA;AAAA,GACF,CAAA;AAAA,EAMA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,gBAAA,CAAA;AAAA,GACT;AAAA,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA,CAAA;AAAA,GAChC;AAAA,EAEA,IAAI,MAA0C,GAAA;AAC5C,IAAA,OAAO,IAAK,CAAA,iBAAA,CAAA;AAAA,GACd;AAAA,EAEA,WAAW,OAIA,EAAA;AACT,IAAM,MAAA,QAAA,GAAW,qBAAqB,OAAO,CAAA,CAAA;AAG7C,IAAA,IAAI,QAAQ,UAAY,EAAA;AACtB,MAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA,CAAA;AAE5B,MAAI,GAAA,CAAA,IAAA,GAAO,CAAS,MAAA,EAAA,OAAA,CAAQ,UAAU,CAAA,CAAA,CAAA;AACtC,MAAA,OAAO,IAAI,QAAS,EAAA,CAAA;AAAA,KACtB;AAEA,IAAO,OAAA,QAAA,CAAA;AAAA,GACT;AAAA,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAM,MAAA,OAAA,GAAU,YAAY,GAAG,CAAA,CAAA;AAC/B,IAAM,MAAA,OAAA,GAAU,IAAI,GAAA,CAAI,GAAG,CAAA,CAAA;AAE3B,IAAQ,OAAA,CAAA,YAAA,CAAa,GAAI,CAAA,MAAA,EAAQ,MAAM,CAAA,CAAA;AACvC,IAAA,OAAA,CAAQ,YAAa,CAAA,GAAA,CAAI,IAAM,EAAA,OAAA,CAAQ,GAAG,CAAA,CAAA;AAC1C,IAAA,OAAO,QAAQ,QAAS,EAAA,CAAA;AAAA,GAC1B;AACF;;;;"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const BITBUCKET_CLOUD_HOST = "bitbucket.org";
|
|
2
2
|
const BITBUCKET_CLOUD_API_BASE_URL = "https://api.bitbucket.org/2.0";
|
|
3
3
|
function readBitbucketCloudIntegrationConfig(config) {
|
|
4
|
-
var _a;
|
|
5
4
|
const host = BITBUCKET_CLOUD_HOST;
|
|
6
5
|
const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;
|
|
7
6
|
const username = config.getString("username");
|
|
8
|
-
const appPassword =
|
|
7
|
+
const appPassword = config.getString("appPassword")?.trim();
|
|
9
8
|
return {
|
|
10
9
|
host,
|
|
11
10
|
apiBaseUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.esm.js","sources":["../../src/bitbucketCloud/config.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { Config } from '@backstage/config';\n\nconst BITBUCKET_CLOUD_HOST = 'bitbucket.org';\nconst BITBUCKET_CLOUD_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket Cloud API provider.\n *\n * @public\n */\nexport type BitbucketCloudIntegrationConfig = {\n /**\n * Constant. bitbucket.org\n */\n host: string;\n\n /**\n * Constant. https://api.bitbucket.org/2.0\n */\n apiBaseUrl: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n};\n\n/**\n * Reads a single Bitbucket Cloud integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketCloudIntegrationConfig(\n config: Config,\n): BitbucketCloudIntegrationConfig {\n const host = BITBUCKET_CLOUD_HOST;\n const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;\n // If config is provided, we assume authenticated access is desired\n // (as the anonymous one is provided by default).\n const username = config.getString('username');\n const appPassword = config.getString('appPassword')?.trim();\n\n return {\n host,\n apiBaseUrl,\n username,\n appPassword,\n };\n}\n\n/**\n * Reads a set of Bitbucket Cloud integration configs,\n * and inserts one for public Bitbucket Cloud if none specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketCloudIntegrationConfigs(\n configs: Config[],\n): BitbucketCloudIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketCloudIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added,\n // put one in the list as a convenience\n if (result.length === 0) {\n result.push({\n host: BITBUCKET_CLOUD_HOST,\n apiBaseUrl: BITBUCKET_CLOUD_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,oBAAuB,GAAA,eAAA,CAAA;AAC7B,MAAM,4BAA+B,GAAA,+BAAA,CAAA;AAqC9B,SAAS,oCACd,MACiC,EAAA;
|
|
1
|
+
{"version":3,"file":"config.esm.js","sources":["../../src/bitbucketCloud/config.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { Config } from '@backstage/config';\n\nconst BITBUCKET_CLOUD_HOST = 'bitbucket.org';\nconst BITBUCKET_CLOUD_API_BASE_URL = 'https://api.bitbucket.org/2.0';\n\n/**\n * The configuration parameters for a single Bitbucket Cloud API provider.\n *\n * @public\n */\nexport type BitbucketCloudIntegrationConfig = {\n /**\n * Constant. bitbucket.org\n */\n host: string;\n\n /**\n * Constant. https://api.bitbucket.org/2.0\n */\n apiBaseUrl: string;\n\n /**\n * The username to use for requests to Bitbucket Cloud (bitbucket.org).\n */\n username?: string;\n\n /**\n * Authentication with Bitbucket Cloud (bitbucket.org) is done using app passwords.\n *\n * See https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/\n */\n appPassword?: string;\n};\n\n/**\n * Reads a single Bitbucket Cloud integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketCloudIntegrationConfig(\n config: Config,\n): BitbucketCloudIntegrationConfig {\n const host = BITBUCKET_CLOUD_HOST;\n const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;\n // If config is provided, we assume authenticated access is desired\n // (as the anonymous one is provided by default).\n const username = config.getString('username');\n const appPassword = config.getString('appPassword')?.trim();\n\n return {\n host,\n apiBaseUrl,\n username,\n appPassword,\n };\n}\n\n/**\n * Reads a set of Bitbucket Cloud integration configs,\n * and inserts one for public Bitbucket Cloud if none specified.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketCloudIntegrationConfigs(\n configs: Config[],\n): BitbucketCloudIntegrationConfig[] {\n // First read all the explicit integrations\n const result = configs.map(readBitbucketCloudIntegrationConfig);\n\n // If no explicit bitbucket.org integration was added,\n // put one in the list as a convenience\n if (result.length === 0) {\n result.push({\n host: BITBUCKET_CLOUD_HOST,\n apiBaseUrl: BITBUCKET_CLOUD_API_BASE_URL,\n });\n }\n\n return result;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,oBAAuB,GAAA,eAAA,CAAA;AAC7B,MAAM,4BAA+B,GAAA,+BAAA,CAAA;AAqC9B,SAAS,oCACd,MACiC,EAAA;AACjC,EAAA,MAAM,IAAO,GAAA,oBAAA,CAAA;AACb,EAAA,MAAM,UAAa,GAAA,4BAAA,CAAA;AAGnB,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,SAAA,CAAU,UAAU,CAAA,CAAA;AAC5C,EAAA,MAAM,WAAc,GAAA,MAAA,CAAO,SAAU,CAAA,aAAa,GAAG,IAAK,EAAA,CAAA;AAE1D,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,GACF,CAAA;AACF,CAAA;AASO,SAAS,qCACd,OACmC,EAAA;AAEnC,EAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,GAAA,CAAI,mCAAmC,CAAA,CAAA;AAI9D,EAAI,IAAA,MAAA,CAAO,WAAW,CAAG,EAAA;AACvB,IAAA,MAAA,CAAO,IAAK,CAAA;AAAA,MACV,IAAM,EAAA,oBAAA;AAAA,MACN,UAAY,EAAA,4BAAA;AAAA,KACb,CAAA,CAAA;AAAA,GACH;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { basicIntegrations, defaultScmResolveUrl } from '../helpers.esm.js';
|
|
2
2
|
import { readBitbucketServerIntegrationConfigs } from './config.esm.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __publicField = (obj, key, value) => {
|
|
7
|
-
__defNormalProp(obj, key + "" , value);
|
|
8
|
-
return value;
|
|
9
|
-
};
|
|
10
|
-
const _BitbucketServerIntegration = class _BitbucketServerIntegration {
|
|
4
|
+
class BitbucketServerIntegration {
|
|
11
5
|
constructor(integrationConfig) {
|
|
12
6
|
this.integrationConfig = integrationConfig;
|
|
13
7
|
}
|
|
8
|
+
static factory = ({
|
|
9
|
+
config
|
|
10
|
+
}) => {
|
|
11
|
+
const configs = readBitbucketServerIntegrationConfigs(
|
|
12
|
+
config.getOptionalConfigArray("integrations.bitbucketServer") ?? []
|
|
13
|
+
);
|
|
14
|
+
return basicIntegrations(
|
|
15
|
+
configs.map((c) => new BitbucketServerIntegration(c)),
|
|
16
|
+
(i) => i.config.host
|
|
17
|
+
);
|
|
18
|
+
};
|
|
14
19
|
get type() {
|
|
15
20
|
return "bitbucketServer";
|
|
16
21
|
}
|
|
@@ -35,20 +40,7 @@ const _BitbucketServerIntegration = class _BitbucketServerIntegration {
|
|
|
35
40
|
}
|
|
36
41
|
return url;
|
|
37
42
|
}
|
|
38
|
-
}
|
|
39
|
-
__publicField(_BitbucketServerIntegration, "factory", ({
|
|
40
|
-
config
|
|
41
|
-
}) => {
|
|
42
|
-
var _a;
|
|
43
|
-
const configs = readBitbucketServerIntegrationConfigs(
|
|
44
|
-
(_a = config.getOptionalConfigArray("integrations.bitbucketServer")) != null ? _a : []
|
|
45
|
-
);
|
|
46
|
-
return basicIntegrations(
|
|
47
|
-
configs.map((c) => new _BitbucketServerIntegration(c)),
|
|
48
|
-
(i) => i.config.host
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
let BitbucketServerIntegration = _BitbucketServerIntegration;
|
|
43
|
+
}
|
|
52
44
|
|
|
53
45
|
export { BitbucketServerIntegration };
|
|
54
46
|
//# sourceMappingURL=BitbucketServerIntegration.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitbucketServerIntegration.esm.js","sources":["../../src/bitbucketServer/BitbucketServerIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketServerIntegrationConfig,\n readBitbucketServerIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Server based integration.\n *\n * @public\n */\nexport class BitbucketServerIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketServerIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketServerIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketServer') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketServerIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketServerIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketServer';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketServerIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Server line numbers use the syntax #42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = options.lineNumber.toString();\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n // Bitbucket Server doesn't support deep linking to edit mode, therefore there's nothing to do here.\n // We just remove query parameters since they cause issues with TechDocs edit button.\n if (url.includes('?')) {\n return url.substring(0, url.indexOf('?'));\n }\n return url;\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BitbucketServerIntegration.esm.js","sources":["../../src/bitbucketServer/BitbucketServerIntegration.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n BitbucketServerIntegrationConfig,\n readBitbucketServerIntegrationConfigs,\n} from './config';\n\n/**\n * A Bitbucket Server based integration.\n *\n * @public\n */\nexport class BitbucketServerIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<BitbucketServerIntegration> = ({\n config,\n }) => {\n const configs = readBitbucketServerIntegrationConfigs(\n config.getOptionalConfigArray('integrations.bitbucketServer') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new BitbucketServerIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(\n private readonly integrationConfig: BitbucketServerIntegrationConfig,\n ) {}\n\n get type(): string {\n return 'bitbucketServer';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): BitbucketServerIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const resolved = defaultScmResolveUrl(options);\n\n // Bitbucket Server line numbers use the syntax #42, rather than #L42\n if (options.lineNumber) {\n const url = new URL(resolved);\n\n url.hash = options.lineNumber.toString();\n return url.toString();\n }\n\n return resolved;\n }\n\n resolveEditUrl(url: string): string {\n // Bitbucket Server doesn't support deep linking to edit mode, therefore there's nothing to do here.\n // We just remove query parameters since they cause issues with TechDocs edit button.\n if (url.includes('?')) {\n return url.substring(0, url.indexOf('?'));\n }\n return url;\n }\n}\n"],"names":[],"mappings":";;;AA4BO,MAAM,0BAAqD,CAAA;AAAA,EAahE,YACmB,iBACjB,EAAA;AADiB,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA,CAAA;AAAA,GAChB;AAAA,EAdH,OAAO,UAA8D,CAAC;AAAA,IACpE,MAAA;AAAA,GACI,KAAA;AACJ,IAAA,MAAM,OAAU,GAAA,qCAAA;AAAA,MACd,MAAO,CAAA,sBAAA,CAAuB,8BAA8B,CAAA,IAAK,EAAC;AAAA,KACpE,CAAA;AACA,IAAO,OAAA,iBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,0BAAA,CAA2B,CAAC,CAAC,CAAA;AAAA,MAClD,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA,IAAA;AAAA,KAChB,CAAA;AAAA,GACF,CAAA;AAAA,EAMA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,iBAAA,CAAA;AAAA,GACT;AAAA,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA,CAAA;AAAA,GAChC;AAAA,EAEA,IAAI,MAA2C,GAAA;AAC7C,IAAA,OAAO,IAAK,CAAA,iBAAA,CAAA;AAAA,GACd;AAAA,EAEA,WAAW,OAIA,EAAA;AACT,IAAM,MAAA,QAAA,GAAW,qBAAqB,OAAO,CAAA,CAAA;AAG7C,IAAA,IAAI,QAAQ,UAAY,EAAA;AACtB,MAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,QAAQ,CAAA,CAAA;AAE5B,MAAI,GAAA,CAAA,IAAA,GAAO,OAAQ,CAAA,UAAA,CAAW,QAAS,EAAA,CAAA;AACvC,MAAA,OAAO,IAAI,QAAS,EAAA,CAAA;AAAA,KACtB;AAEA,IAAO,OAAA,QAAA,CAAA;AAAA,GACT;AAAA,EAEA,eAAe,GAAqB,EAAA;AAGlC,IAAI,IAAA,GAAA,CAAI,QAAS,CAAA,GAAG,CAAG,EAAA;AACrB,MAAA,OAAO,IAAI,SAAU,CAAA,CAAA,EAAG,GAAI,CAAA,OAAA,CAAQ,GAAG,CAAC,CAAA,CAAA;AAAA,KAC1C;AACA,IAAO,OAAA,GAAA,CAAA;AAAA,GACT;AACF;;;;"}
|
|
@@ -2,10 +2,9 @@ import { trimEnd } from 'lodash';
|
|
|
2
2
|
import { isValidHost } from '../helpers.esm.js';
|
|
3
3
|
|
|
4
4
|
function readBitbucketServerIntegrationConfig(config) {
|
|
5
|
-
var _a;
|
|
6
5
|
const host = config.getString("host");
|
|
7
6
|
let apiBaseUrl = config.getOptionalString("apiBaseUrl");
|
|
8
|
-
const token =
|
|
7
|
+
const token = config.getOptionalString("token")?.trim();
|
|
9
8
|
const username = config.getOptionalString("username");
|
|
10
9
|
const password = config.getOptionalString("password");
|
|
11
10
|
if (!isValidHost(host)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.esm.js","sources":["../../src/bitbucketServer/config.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\n/**\n * The configuration parameters for a single Bitbucket Server API provider.\n *\n * @public\n */\nexport type BitbucketServerIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.company.com\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://<host>/rest/api/1.0\",\n * with no trailing slash.\n *\n * The API will always be preferred if both its base URL and a token are\n * present.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The credentials for Basic Authentication for requests to a Bitbucket Server provider.\n *\n * If `token` was provided, it will be preferred.\n *\n * See https://developer.atlassian.com/server/bitbucket/how-tos/command-line-rest/#authentication\n */\n username?: string;\n\n /**\n * The credentials for Basic Authentication for requests to a Bitbucket Server provider.\n *\n * If `token` was provided, it will be preferred.\n *\n * See https://developer.atlassian.com/server/bitbucket/how-tos/command-line-rest/#authentication\n */\n password?: string;\n};\n\n/**\n * Reads a single Bitbucket Server integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketServerIntegrationConfig(\n config: Config,\n): BitbucketServerIntegrationConfig {\n const host = config.getString('host');\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password');\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket Server integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n password,\n };\n}\n\n/**\n * Reads a set of Bitbucket Server integration configs.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketServerIntegrationConfigs(\n configs: Config[],\n): BitbucketServerIntegrationConfig[] {\n // Read all the explicit integrations\n // No default integration will be added\n return configs.map(readBitbucketServerIntegrationConfig);\n}\n"],"names":[],"mappings":";;;AA0EO,SAAS,qCACd,MACkC,EAAA;
|
|
1
|
+
{"version":3,"file":"config.esm.js","sources":["../../src/bitbucketServer/config.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost } from '../helpers';\n\n/**\n * The configuration parameters for a single Bitbucket Server API provider.\n *\n * @public\n */\nexport type BitbucketServerIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"bitbucket.company.com\"\n */\n host: string;\n\n /**\n * The base URL of the API of this provider, e.g. \"https://<host>/rest/api/1.0\",\n * with no trailing slash.\n *\n * The API will always be preferred if both its base URL and a token are\n * present.\n */\n apiBaseUrl: string;\n\n /**\n * The authorization token to use for requests to a Bitbucket Server provider.\n *\n * See https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html\n *\n * If no token is specified, anonymous access is used.\n */\n token?: string;\n\n /**\n * The credentials for Basic Authentication for requests to a Bitbucket Server provider.\n *\n * If `token` was provided, it will be preferred.\n *\n * See https://developer.atlassian.com/server/bitbucket/how-tos/command-line-rest/#authentication\n */\n username?: string;\n\n /**\n * The credentials for Basic Authentication for requests to a Bitbucket Server provider.\n *\n * If `token` was provided, it will be preferred.\n *\n * See https://developer.atlassian.com/server/bitbucket/how-tos/command-line-rest/#authentication\n */\n password?: string;\n};\n\n/**\n * Reads a single Bitbucket Server integration config.\n *\n * @param config - The config object of a single integration\n * @public\n */\nexport function readBitbucketServerIntegrationConfig(\n config: Config,\n): BitbucketServerIntegrationConfig {\n const host = config.getString('host');\n let apiBaseUrl = config.getOptionalString('apiBaseUrl');\n const token = config.getOptionalString('token')?.trim();\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password');\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Bitbucket Server integration config, '${host}' is not a valid host`,\n );\n }\n\n if (apiBaseUrl) {\n apiBaseUrl = trimEnd(apiBaseUrl, '/');\n } else {\n apiBaseUrl = `https://${host}/rest/api/1.0`;\n }\n\n return {\n host,\n apiBaseUrl,\n token,\n username,\n password,\n };\n}\n\n/**\n * Reads a set of Bitbucket Server integration configs.\n *\n * @param configs - All of the integration config objects\n * @public\n */\nexport function readBitbucketServerIntegrationConfigs(\n configs: Config[],\n): BitbucketServerIntegrationConfig[] {\n // Read all the explicit integrations\n // No default integration will be added\n return configs.map(readBitbucketServerIntegrationConfig);\n}\n"],"names":[],"mappings":";;;AA0EO,SAAS,qCACd,MACkC,EAAA;AAClC,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA,CAAA;AACpC,EAAI,IAAA,UAAA,GAAa,MAAO,CAAA,iBAAA,CAAkB,YAAY,CAAA,CAAA;AACtD,EAAA,MAAM,KAAQ,GAAA,MAAA,CAAO,iBAAkB,CAAA,OAAO,GAAG,IAAK,EAAA,CAAA;AACtD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA,CAAA;AACpD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA,CAAA;AAEpD,EAAI,IAAA,CAAC,WAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,iDAAiD,IAAI,CAAA,qBAAA,CAAA;AAAA,KACvD,CAAA;AAAA,GACF;AAEA,EAAA,IAAI,UAAY,EAAA;AACd,IAAa,UAAA,GAAA,OAAA,CAAQ,YAAY,GAAG,CAAA,CAAA;AAAA,GAC/B,MAAA;AACL,IAAA,UAAA,GAAa,WAAW,IAAI,CAAA,aAAA,CAAA,CAAA;AAAA,GAC9B;AAEA,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,GACF,CAAA;AACF,CAAA;AAQO,SAAS,sCACd,OACoC,EAAA;AAGpC,EAAO,OAAA,OAAA,CAAQ,IAAI,oCAAoC,CAAA,CAAA;AACzD;;;;"}
|
|
@@ -2,16 +2,19 @@ import { basicIntegrations } from '../helpers.esm.js';
|
|
|
2
2
|
import { readGerritIntegrationConfigs } from './config.esm.js';
|
|
3
3
|
import { parseGerritGitilesUrl, buildGerritGitilesUrl } from './core.esm.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
-
var __publicField = (obj, key, value) => {
|
|
8
|
-
__defNormalProp(obj, key + "" , value);
|
|
9
|
-
return value;
|
|
10
|
-
};
|
|
11
|
-
const _GerritIntegration = class _GerritIntegration {
|
|
5
|
+
class GerritIntegration {
|
|
12
6
|
constructor(integrationConfig) {
|
|
13
7
|
this.integrationConfig = integrationConfig;
|
|
14
8
|
}
|
|
9
|
+
static factory = ({ config }) => {
|
|
10
|
+
const configs = readGerritIntegrationConfigs(
|
|
11
|
+
config.getOptionalConfigArray("integrations.gerrit") ?? []
|
|
12
|
+
);
|
|
13
|
+
return basicIntegrations(
|
|
14
|
+
configs.map((c) => new GerritIntegration(c)),
|
|
15
|
+
(i) => i.config.host
|
|
16
|
+
);
|
|
17
|
+
};
|
|
15
18
|
get type() {
|
|
16
19
|
return "gerrit";
|
|
17
20
|
}
|
|
@@ -41,18 +44,7 @@ const _GerritIntegration = class _GerritIntegration {
|
|
|
41
44
|
resolveEditUrl(url) {
|
|
42
45
|
return url;
|
|
43
46
|
}
|
|
44
|
-
}
|
|
45
|
-
__publicField(_GerritIntegration, "factory", ({ config }) => {
|
|
46
|
-
var _a;
|
|
47
|
-
const configs = readGerritIntegrationConfigs(
|
|
48
|
-
(_a = config.getOptionalConfigArray("integrations.gerrit")) != null ? _a : []
|
|
49
|
-
);
|
|
50
|
-
return basicIntegrations(
|
|
51
|
-
configs.map((c) => new _GerritIntegration(c)),
|
|
52
|
-
(i) => i.config.host
|
|
53
|
-
);
|
|
54
|
-
});
|
|
55
|
-
let GerritIntegration = _GerritIntegration;
|
|
47
|
+
}
|
|
56
48
|
|
|
57
49
|
export { GerritIntegration };
|
|
58
50
|
//# sourceMappingURL=GerritIntegration.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GerritIntegration.esm.js","sources":["../../src/gerrit/GerritIntegration.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 { basicIntegrations } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n GerritIntegrationConfig,\n readGerritIntegrationConfigs,\n} from './config';\nimport { parseGerritGitilesUrl, buildGerritGitilesUrl } from './core';\n\n/**\n * A Gerrit based integration.\n *\n * @public\n */\nexport class GerritIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<GerritIntegration> = ({ config }) => {\n const configs = readGerritIntegrationConfigs(\n config.getOptionalConfigArray('integrations.gerrit') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new GerritIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: GerritIntegrationConfig) {}\n\n get type(): string {\n return 'gerrit';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): GerritIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const { url, base, lineNumber } = options;\n let updated;\n if (url.startsWith('/')) {\n const { branch, project } = parseGerritGitilesUrl(this.config, base);\n return buildGerritGitilesUrl(this.config, project, branch, url);\n }\n if (url) {\n updated = new URL(url, base);\n } else {\n updated = new URL(base);\n }\n if (lineNumber) {\n updated.hash = lineNumber.toString();\n }\n return updated.toString();\n }\n\n resolveEditUrl(url: string): string {\n // Not applicable for gerrit.\n return url;\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GerritIntegration.esm.js","sources":["../../src/gerrit/GerritIntegration.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 { basicIntegrations } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport {\n GerritIntegrationConfig,\n readGerritIntegrationConfigs,\n} from './config';\nimport { parseGerritGitilesUrl, buildGerritGitilesUrl } from './core';\n\n/**\n * A Gerrit based integration.\n *\n * @public\n */\nexport class GerritIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<GerritIntegration> = ({ config }) => {\n const configs = readGerritIntegrationConfigs(\n config.getOptionalConfigArray('integrations.gerrit') ?? [],\n );\n return basicIntegrations(\n configs.map(c => new GerritIntegration(c)),\n i => i.config.host,\n );\n };\n\n constructor(private readonly integrationConfig: GerritIntegrationConfig) {}\n\n get type(): string {\n return 'gerrit';\n }\n\n get title(): string {\n return this.integrationConfig.host;\n }\n\n get config(): GerritIntegrationConfig {\n return this.integrationConfig;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number;\n }): string {\n const { url, base, lineNumber } = options;\n let updated;\n if (url.startsWith('/')) {\n const { branch, project } = parseGerritGitilesUrl(this.config, base);\n return buildGerritGitilesUrl(this.config, project, branch, url);\n }\n if (url) {\n updated = new URL(url, base);\n } else {\n updated = new URL(base);\n }\n if (lineNumber) {\n updated.hash = lineNumber.toString();\n }\n return updated.toString();\n }\n\n resolveEditUrl(url: string): string {\n // Not applicable for gerrit.\n return url;\n }\n}\n"],"names":[],"mappings":";;;;AA6BO,MAAM,iBAA4C,CAAA;AAAA,EAWvD,YAA6B,iBAA4C,EAAA;AAA5C,IAAA,IAAA,CAAA,iBAAA,GAAA,iBAAA,CAAA;AAAA,GAA6C;AAAA,EAV1E,OAAO,OAAA,GAAqD,CAAC,EAAE,QAAa,KAAA;AAC1E,IAAA,MAAM,OAAU,GAAA,4BAAA;AAAA,MACd,MAAO,CAAA,sBAAA,CAAuB,qBAAqB,CAAA,IAAK,EAAC;AAAA,KAC3D,CAAA;AACA,IAAO,OAAA,iBAAA;AAAA,MACL,QAAQ,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,iBAAA,CAAkB,CAAC,CAAC,CAAA;AAAA,MACzC,CAAA,CAAA,KAAK,EAAE,MAAO,CAAA,IAAA;AAAA,KAChB,CAAA;AAAA,GACF,CAAA;AAAA,EAIA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,QAAA,CAAA;AAAA,GACT;AAAA,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,iBAAkB,CAAA,IAAA,CAAA;AAAA,GAChC;AAAA,EAEA,IAAI,MAAkC,GAAA;AACpC,IAAA,OAAO,IAAK,CAAA,iBAAA,CAAA;AAAA,GACd;AAAA,EAEA,WAAW,OAIA,EAAA;AACT,IAAA,MAAM,EAAE,GAAA,EAAK,IAAM,EAAA,UAAA,EAAe,GAAA,OAAA,CAAA;AAClC,IAAI,IAAA,OAAA,CAAA;AACJ,IAAI,IAAA,GAAA,CAAI,UAAW,CAAA,GAAG,CAAG,EAAA;AACvB,MAAA,MAAM,EAAE,MAAQ,EAAA,OAAA,KAAY,qBAAsB,CAAA,IAAA,CAAK,QAAQ,IAAI,CAAA,CAAA;AACnE,MAAA,OAAO,qBAAsB,CAAA,IAAA,CAAK,MAAQ,EAAA,OAAA,EAAS,QAAQ,GAAG,CAAA,CAAA;AAAA,KAChE;AACA,IAAA,IAAI,GAAK,EAAA;AACP,MAAU,OAAA,GAAA,IAAI,GAAI,CAAA,GAAA,EAAK,IAAI,CAAA,CAAA;AAAA,KACtB,MAAA;AACL,MAAU,OAAA,GAAA,IAAI,IAAI,IAAI,CAAA,CAAA;AAAA,KACxB;AACA,IAAA,IAAI,UAAY,EAAA;AACd,MAAQ,OAAA,CAAA,IAAA,GAAO,WAAW,QAAS,EAAA,CAAA;AAAA,KACrC;AACA,IAAA,OAAO,QAAQ,QAAS,EAAA,CAAA;AAAA,GAC1B;AAAA,EAEA,eAAe,GAAqB,EAAA;AAElC,IAAO,OAAA,GAAA,CAAA;AAAA,GACT;AACF;;;;"}
|
|
@@ -2,13 +2,12 @@ import { trimEnd } from 'lodash';
|
|
|
2
2
|
import { isValidHost, isValidUrl } from '../helpers.esm.js';
|
|
3
3
|
|
|
4
4
|
function readGerritIntegrationConfig(config) {
|
|
5
|
-
var _a;
|
|
6
5
|
const host = config.getString("host");
|
|
7
6
|
let baseUrl = config.getOptionalString("baseUrl");
|
|
8
7
|
let cloneUrl = config.getOptionalString("cloneUrl");
|
|
9
8
|
let gitilesBaseUrl = config.getOptionalString("gitilesBaseUrl");
|
|
10
9
|
const username = config.getOptionalString("username");
|
|
11
|
-
const password =
|
|
10
|
+
const password = config.getOptionalString("password")?.trim();
|
|
12
11
|
if (!isValidHost(host)) {
|
|
13
12
|
throw new Error(
|
|
14
13
|
`Invalid Gerrit integration config, '${host}' is not a valid host`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.esm.js","sources":["../../src/gerrit/config.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 { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost, isValidUrl } from '../helpers';\n\n/**\n * The configuration parameters for a single Gerrit API provider.\n *\n * @public\n */\nexport type GerritIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"gerrit-review.com\"\n */\n host: string;\n\n /**\n * The optional base URL of the Gerrit instance. It is assumed that https\n * is used and that the base path is \"/\" on the host. If that is not the\n * case set the complete base url to the gerrit instance, e.g.\n * \"https://gerrit-review.com/gerrit\". This is the url that you would open\n * in a browser.\n */\n baseUrl?: string;\n\n /**\n * The optional base url to use for cloning a repository. If not set the\n * baseUrl will be used.\n */\n cloneUrl?: string;\n\n /**\n * Optional base url for Gitiles. This is needed for creating a valid\n * user-friendly url that can be used for browsing the content of the\n * provider. If not set a default value will be created in the same way\n * as the \"baseUrl\" option.\n */\n gitilesBaseUrl?: string;\n\n /**\n * The username to use for requests to gerrit.\n */\n username?: string;\n\n /**\n * The password or http token to use for authentication.\n */\n password?: string;\n};\n\n/**\n * Reads a single Gerrit integration config.\n *\n * @param config - The config object of a single integration\n *\n * @public\n */\nexport function readGerritIntegrationConfig(\n config: Config,\n): GerritIntegrationConfig {\n const host = config.getString('host');\n let baseUrl = config.getOptionalString('baseUrl');\n let cloneUrl = config.getOptionalString('cloneUrl');\n let gitilesBaseUrl = config.getOptionalString('gitilesBaseUrl');\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Gerrit integration config, '${host}' is not a valid host`,\n );\n } else if (baseUrl && !isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n } else if (cloneUrl && !isValidUrl(cloneUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${cloneUrl}' is not a valid cloneUrl`,\n );\n } else if (gitilesBaseUrl && !isValidUrl(gitilesBaseUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${gitilesBaseUrl}' is not a valid gitilesBaseUrl`,\n );\n }\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n if (gitilesBaseUrl) {\n gitilesBaseUrl = trimEnd(gitilesBaseUrl, '/');\n } else {\n gitilesBaseUrl = `https://${host}`;\n }\n if (cloneUrl) {\n cloneUrl = trimEnd(cloneUrl, '/');\n } else {\n cloneUrl = baseUrl;\n }\n\n return {\n host,\n baseUrl,\n cloneUrl,\n gitilesBaseUrl,\n username,\n password,\n };\n}\n\n/**\n * Reads a set of Gerrit integration configs.\n *\n * @param configs - All of the integration config objects\n *\n * @public\n */\nexport function readGerritIntegrationConfigs(\n configs: Config[],\n): GerritIntegrationConfig[] {\n return configs.map(readGerritIntegrationConfig);\n}\n"],"names":[],"mappings":";;;AAwEO,SAAS,4BACd,MACyB,EAAA;
|
|
1
|
+
{"version":3,"file":"config.esm.js","sources":["../../src/gerrit/config.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 { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost, isValidUrl } from '../helpers';\n\n/**\n * The configuration parameters for a single Gerrit API provider.\n *\n * @public\n */\nexport type GerritIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"gerrit-review.com\"\n */\n host: string;\n\n /**\n * The optional base URL of the Gerrit instance. It is assumed that https\n * is used and that the base path is \"/\" on the host. If that is not the\n * case set the complete base url to the gerrit instance, e.g.\n * \"https://gerrit-review.com/gerrit\". This is the url that you would open\n * in a browser.\n */\n baseUrl?: string;\n\n /**\n * The optional base url to use for cloning a repository. If not set the\n * baseUrl will be used.\n */\n cloneUrl?: string;\n\n /**\n * Optional base url for Gitiles. This is needed for creating a valid\n * user-friendly url that can be used for browsing the content of the\n * provider. If not set a default value will be created in the same way\n * as the \"baseUrl\" option.\n */\n gitilesBaseUrl?: string;\n\n /**\n * The username to use for requests to gerrit.\n */\n username?: string;\n\n /**\n * The password or http token to use for authentication.\n */\n password?: string;\n};\n\n/**\n * Reads a single Gerrit integration config.\n *\n * @param config - The config object of a single integration\n *\n * @public\n */\nexport function readGerritIntegrationConfig(\n config: Config,\n): GerritIntegrationConfig {\n const host = config.getString('host');\n let baseUrl = config.getOptionalString('baseUrl');\n let cloneUrl = config.getOptionalString('cloneUrl');\n let gitilesBaseUrl = config.getOptionalString('gitilesBaseUrl');\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Gerrit integration config, '${host}' is not a valid host`,\n );\n } else if (baseUrl && !isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n } else if (cloneUrl && !isValidUrl(cloneUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${cloneUrl}' is not a valid cloneUrl`,\n );\n } else if (gitilesBaseUrl && !isValidUrl(gitilesBaseUrl)) {\n throw new Error(\n `Invalid Gerrit integration config, '${gitilesBaseUrl}' is not a valid gitilesBaseUrl`,\n );\n }\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n if (gitilesBaseUrl) {\n gitilesBaseUrl = trimEnd(gitilesBaseUrl, '/');\n } else {\n gitilesBaseUrl = `https://${host}`;\n }\n if (cloneUrl) {\n cloneUrl = trimEnd(cloneUrl, '/');\n } else {\n cloneUrl = baseUrl;\n }\n\n return {\n host,\n baseUrl,\n cloneUrl,\n gitilesBaseUrl,\n username,\n password,\n };\n}\n\n/**\n * Reads a set of Gerrit integration configs.\n *\n * @param configs - All of the integration config objects\n *\n * @public\n */\nexport function readGerritIntegrationConfigs(\n configs: Config[],\n): GerritIntegrationConfig[] {\n return configs.map(readGerritIntegrationConfig);\n}\n"],"names":[],"mappings":";;;AAwEO,SAAS,4BACd,MACyB,EAAA;AACzB,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA,CAAA;AACpC,EAAI,IAAA,OAAA,GAAU,MAAO,CAAA,iBAAA,CAAkB,SAAS,CAAA,CAAA;AAChD,EAAI,IAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA,CAAA;AAClD,EAAI,IAAA,cAAA,GAAiB,MAAO,CAAA,iBAAA,CAAkB,gBAAgB,CAAA,CAAA;AAC9D,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA,CAAA;AACpD,EAAA,MAAM,QAAW,GAAA,MAAA,CAAO,iBAAkB,CAAA,UAAU,GAAG,IAAK,EAAA,CAAA;AAE5D,EAAI,IAAA,CAAC,WAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,IAAI,CAAA,qBAAA,CAAA;AAAA,KAC7C,CAAA;AAAA,GACS,MAAA,IAAA,OAAA,IAAW,CAAC,UAAA,CAAW,OAAO,CAAG,EAAA;AAC1C,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,OAAO,CAAA,wBAAA,CAAA;AAAA,KAChD,CAAA;AAAA,GACS,MAAA,IAAA,QAAA,IAAY,CAAC,UAAA,CAAW,QAAQ,CAAG,EAAA;AAC5C,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,QAAQ,CAAA,yBAAA,CAAA;AAAA,KACjD,CAAA;AAAA,GACS,MAAA,IAAA,cAAA,IAAkB,CAAC,UAAA,CAAW,cAAc,CAAG,EAAA;AACxD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uCAAuC,cAAc,CAAA,+BAAA,CAAA;AAAA,KACvD,CAAA;AAAA,GACF;AACA,EAAA,IAAI,OAAS,EAAA;AACX,IAAU,OAAA,GAAA,OAAA,CAAQ,SAAS,GAAG,CAAA,CAAA;AAAA,GACzB,MAAA;AACL,IAAA,OAAA,GAAU,WAAW,IAAI,CAAA,CAAA,CAAA;AAAA,GAC3B;AACA,EAAA,IAAI,cAAgB,EAAA;AAClB,IAAiB,cAAA,GAAA,OAAA,CAAQ,gBAAgB,GAAG,CAAA,CAAA;AAAA,GACvC,MAAA;AACL,IAAA,cAAA,GAAiB,WAAW,IAAI,CAAA,CAAA,CAAA;AAAA,GAClC;AACA,EAAA,IAAI,QAAU,EAAA;AACZ,IAAW,QAAA,GAAA,OAAA,CAAQ,UAAU,GAAG,CAAA,CAAA;AAAA,GAC3B,MAAA;AACL,IAAW,QAAA,GAAA,OAAA,CAAA;AAAA,GACb;AAEA,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,cAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,GACF,CAAA;AACF,CAAA;AASO,SAAS,6BACd,OAC2B,EAAA;AAC3B,EAAO,OAAA,OAAA,CAAQ,IAAI,2BAA2B,CAAA,CAAA;AAChD;;;;"}
|
|
@@ -2,16 +2,18 @@ import { basicIntegrations, defaultScmResolveUrl } from '../helpers.esm.js';
|
|
|
2
2
|
import { readGiteaConfig } from './config.esm.js';
|
|
3
3
|
import { getGiteaEditContentsUrl } from './core.esm.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
-
var __publicField = (obj, key, value) => {
|
|
8
|
-
__defNormalProp(obj, key + "" , value);
|
|
9
|
-
return value;
|
|
10
|
-
};
|
|
11
|
-
const _GiteaIntegration = class _GiteaIntegration {
|
|
5
|
+
class GiteaIntegration {
|
|
12
6
|
constructor(config) {
|
|
13
7
|
this.config = config;
|
|
14
8
|
}
|
|
9
|
+
static factory = ({ config }) => {
|
|
10
|
+
const configs = config.getOptionalConfigArray("integrations.gitea") ?? [];
|
|
11
|
+
const giteaConfigs = configs.map((c) => readGiteaConfig(c));
|
|
12
|
+
return basicIntegrations(
|
|
13
|
+
giteaConfigs.map((c) => new GiteaIntegration(c)),
|
|
14
|
+
(gitea) => gitea.config.host
|
|
15
|
+
);
|
|
16
|
+
};
|
|
15
17
|
get type() {
|
|
16
18
|
return "gitea";
|
|
17
19
|
}
|
|
@@ -24,17 +26,7 @@ const _GiteaIntegration = class _GiteaIntegration {
|
|
|
24
26
|
resolveEditUrl(url) {
|
|
25
27
|
return getGiteaEditContentsUrl(this.config, url);
|
|
26
28
|
}
|
|
27
|
-
}
|
|
28
|
-
__publicField(_GiteaIntegration, "factory", ({ config }) => {
|
|
29
|
-
var _a;
|
|
30
|
-
const configs = (_a = config.getOptionalConfigArray("integrations.gitea")) != null ? _a : [];
|
|
31
|
-
const giteaConfigs = configs.map((c) => readGiteaConfig(c));
|
|
32
|
-
return basicIntegrations(
|
|
33
|
-
giteaConfigs.map((c) => new _GiteaIntegration(c)),
|
|
34
|
-
(gitea) => gitea.config.host
|
|
35
|
-
);
|
|
36
|
-
});
|
|
37
|
-
let GiteaIntegration = _GiteaIntegration;
|
|
29
|
+
}
|
|
38
30
|
|
|
39
31
|
export { GiteaIntegration };
|
|
40
32
|
//# sourceMappingURL=GiteaIntegration.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GiteaIntegration.esm.js","sources":["../../src/gitea/GiteaIntegration.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 */\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { GiteaIntegrationConfig, readGiteaConfig } from './config';\nimport { getGiteaEditContentsUrl } from './core';\n\n/**\n * A Gitea based integration.\n *\n * @public\n */\nexport class GiteaIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<GiteaIntegration> = ({ config }) => {\n const configs = config.getOptionalConfigArray('integrations.gitea') ?? [];\n const giteaConfigs = configs.map(c => readGiteaConfig(c));\n\n return basicIntegrations(\n giteaConfigs.map(c => new GiteaIntegration(c)),\n (gitea: GiteaIntegration) => gitea.config.host,\n );\n };\n\n constructor(readonly config: GiteaIntegrationConfig) {}\n\n get type(): string {\n return 'gitea';\n }\n\n get title(): string {\n return this.config.host;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return getGiteaEditContentsUrl(this.config, url);\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GiteaIntegration.esm.js","sources":["../../src/gitea/GiteaIntegration.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 */\nimport { basicIntegrations, defaultScmResolveUrl } from '../helpers';\nimport { ScmIntegration, ScmIntegrationsFactory } from '../types';\nimport { GiteaIntegrationConfig, readGiteaConfig } from './config';\nimport { getGiteaEditContentsUrl } from './core';\n\n/**\n * A Gitea based integration.\n *\n * @public\n */\nexport class GiteaIntegration implements ScmIntegration {\n static factory: ScmIntegrationsFactory<GiteaIntegration> = ({ config }) => {\n const configs = config.getOptionalConfigArray('integrations.gitea') ?? [];\n const giteaConfigs = configs.map(c => readGiteaConfig(c));\n\n return basicIntegrations(\n giteaConfigs.map(c => new GiteaIntegration(c)),\n (gitea: GiteaIntegration) => gitea.config.host,\n );\n };\n\n constructor(readonly config: GiteaIntegrationConfig) {}\n\n get type(): string {\n return 'gitea';\n }\n\n get title(): string {\n return this.config.host;\n }\n\n resolveUrl(options: {\n url: string;\n base: string;\n lineNumber?: number | undefined;\n }): string {\n return defaultScmResolveUrl(options);\n }\n\n resolveEditUrl(url: string): string {\n return getGiteaEditContentsUrl(this.config, url);\n }\n}\n"],"names":[],"mappings":";;;;AAyBO,MAAM,gBAA2C,CAAA;AAAA,EAWtD,YAAqB,MAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;AAAA,GAAiC;AAAA,EAVtD,OAAO,OAAA,GAAoD,CAAC,EAAE,QAAa,KAAA;AACzE,IAAA,MAAM,OAAU,GAAA,MAAA,CAAO,sBAAuB,CAAA,oBAAoB,KAAK,EAAC,CAAA;AACxE,IAAA,MAAM,eAAe,OAAQ,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,eAAA,CAAgB,CAAC,CAAC,CAAA,CAAA;AAExD,IAAO,OAAA,iBAAA;AAAA,MACL,aAAa,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,gBAAA,CAAiB,CAAC,CAAC,CAAA;AAAA,MAC7C,CAAC,KAA4B,KAAA,KAAA,CAAM,MAAO,CAAA,IAAA;AAAA,KAC5C,CAAA;AAAA,GACF,CAAA;AAAA,EAIA,IAAI,IAAe,GAAA;AACjB,IAAO,OAAA,OAAA,CAAA;AAAA,GACT;AAAA,EAEA,IAAI,KAAgB,GAAA;AAClB,IAAA,OAAO,KAAK,MAAO,CAAA,IAAA,CAAA;AAAA,GACrB;AAAA,EAEA,WAAW,OAIA,EAAA;AACT,IAAA,OAAO,qBAAqB,OAAO,CAAA,CAAA;AAAA,GACrC;AAAA,EAEA,eAAe,GAAqB,EAAA;AAClC,IAAO,OAAA,uBAAA,CAAwB,IAAK,CAAA,MAAA,EAAQ,GAAG,CAAA,CAAA;AAAA,GACjD;AACF;;;;"}
|
package/dist/gitea/config.esm.js
CHANGED
|
@@ -2,11 +2,10 @@ import { trimEnd } from 'lodash';
|
|
|
2
2
|
import { isValidHost, isValidUrl } from '../helpers.esm.js';
|
|
3
3
|
|
|
4
4
|
function readGiteaConfig(config) {
|
|
5
|
-
var _a;
|
|
6
5
|
const host = config.getString("host");
|
|
7
6
|
let baseUrl = config.getOptionalString("baseUrl");
|
|
8
7
|
const username = config.getOptionalString("username");
|
|
9
|
-
const password =
|
|
8
|
+
const password = config.getOptionalString("password")?.trim();
|
|
10
9
|
if (!isValidHost(host)) {
|
|
11
10
|
throw new Error(
|
|
12
11
|
`Invalid Gitea integration config, '${host}' is not a valid host`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.esm.js","sources":["../../src/gitea/config.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 { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost, isValidUrl } from '../helpers';\n\n/**\n * The configuration for a single Gitea integration.\n *\n * @public\n */\nexport type GiteaIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"gitea.website.com\"\n */\n host: string;\n /**\n * The optional base URL of the Gitea instance. It is assumed that https\n * is used and that the base path is \"/\" on the host. If that is not the\n * case set the complete base url to the gitea instance, e.g.\n * \"https://gitea.website.com/\". This is the url that you would open\n * in a browser.\n */\n baseUrl?: string;\n /**\n * The username to use for requests to gitea.\n */\n username?: string;\n\n /**\n * The password or http token to use for authentication.\n */\n password?: string;\n};\n\n/**\n * Parses a location config block for use in GiteaIntegration\n *\n * @public\n */\nexport function readGiteaConfig(config: Config): GiteaIntegrationConfig {\n const host = config.getString('host');\n let baseUrl = config.getOptionalString('baseUrl');\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Gitea integration config, '${host}' is not a valid host`,\n );\n } else if (baseUrl && !isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid Gitea integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n }\n\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n\n return {\n host,\n baseUrl,\n username,\n password,\n };\n}\n"],"names":[],"mappings":";;;AAsDO,SAAS,gBAAgB,MAAwC,EAAA;
|
|
1
|
+
{"version":3,"file":"config.esm.js","sources":["../../src/gitea/config.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 { Config } from '@backstage/config';\nimport { trimEnd } from 'lodash';\nimport { isValidHost, isValidUrl } from '../helpers';\n\n/**\n * The configuration for a single Gitea integration.\n *\n * @public\n */\nexport type GiteaIntegrationConfig = {\n /**\n * The host of the target that this matches on, e.g. \"gitea.website.com\"\n */\n host: string;\n /**\n * The optional base URL of the Gitea instance. It is assumed that https\n * is used and that the base path is \"/\" on the host. If that is not the\n * case set the complete base url to the gitea instance, e.g.\n * \"https://gitea.website.com/\". This is the url that you would open\n * in a browser.\n */\n baseUrl?: string;\n /**\n * The username to use for requests to gitea.\n */\n username?: string;\n\n /**\n * The password or http token to use for authentication.\n */\n password?: string;\n};\n\n/**\n * Parses a location config block for use in GiteaIntegration\n *\n * @public\n */\nexport function readGiteaConfig(config: Config): GiteaIntegrationConfig {\n const host = config.getString('host');\n let baseUrl = config.getOptionalString('baseUrl');\n const username = config.getOptionalString('username');\n const password = config.getOptionalString('password')?.trim();\n\n if (!isValidHost(host)) {\n throw new Error(\n `Invalid Gitea integration config, '${host}' is not a valid host`,\n );\n } else if (baseUrl && !isValidUrl(baseUrl)) {\n throw new Error(\n `Invalid Gitea integration config, '${baseUrl}' is not a valid baseUrl`,\n );\n }\n\n if (baseUrl) {\n baseUrl = trimEnd(baseUrl, '/');\n } else {\n baseUrl = `https://${host}`;\n }\n\n return {\n host,\n baseUrl,\n username,\n password,\n };\n}\n"],"names":[],"mappings":";;;AAsDO,SAAS,gBAAgB,MAAwC,EAAA;AACtE,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,MAAM,CAAA,CAAA;AACpC,EAAI,IAAA,OAAA,GAAU,MAAO,CAAA,iBAAA,CAAkB,SAAS,CAAA,CAAA;AAChD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,iBAAA,CAAkB,UAAU,CAAA,CAAA;AACpD,EAAA,MAAM,QAAW,GAAA,MAAA,CAAO,iBAAkB,CAAA,UAAU,GAAG,IAAK,EAAA,CAAA;AAE5D,EAAI,IAAA,CAAC,WAAY,CAAA,IAAI,CAAG,EAAA;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,sCAAsC,IAAI,CAAA,qBAAA,CAAA;AAAA,KAC5C,CAAA;AAAA,GACS,MAAA,IAAA,OAAA,IAAW,CAAC,UAAA,CAAW,OAAO,CAAG,EAAA;AAC1C,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,sCAAsC,OAAO,CAAA,wBAAA,CAAA;AAAA,KAC/C,CAAA;AAAA,GACF;AAEA,EAAA,IAAI,OAAS,EAAA;AACX,IAAU,OAAA,GAAA,OAAA,CAAQ,SAAS,GAAG,CAAA,CAAA;AAAA,GACzB,MAAA;AACL,IAAA,OAAA,GAAU,WAAW,IAAI,CAAA,CAAA,CAAA;AAAA,GAC3B;AAEA,EAAO,OAAA;AAAA,IACL,IAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
package/dist/gitea/core.esm.js
CHANGED
|
@@ -32,8 +32,7 @@ function getGiteaRequestOptions(config) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
function parseGiteaUrl(config, url) {
|
|
35
|
-
|
|
36
|
-
const baseUrl = (_a = config.baseUrl) != null ? _a : `https://${config.host}`;
|
|
35
|
+
const baseUrl = config.baseUrl ?? `https://${config.host}`;
|
|
37
36
|
try {
|
|
38
37
|
const [_blank, owner, name, _src, _branch, ref, ...path] = url.replace(baseUrl, "").split("/");
|
|
39
38
|
const pathWithoutSlash = path.join("/").replace(/^\//, "");
|