@backstage/integration 1.9.1-next.2 → 1.10.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/index.cjs.js +119 -30
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +67 -1
- package/dist/index.esm.js +94 -6
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @backstage/integration
|
|
2
2
|
|
|
3
|
+
## 1.10.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7b11422: Add AWS CodeCommit URL Reader/Integration
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/config@1.2.0
|
|
13
|
+
- @backstage/errors@1.2.4
|
|
14
|
+
|
|
15
|
+
## 1.9.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 0386fa7: Fixed an issue with resolution of SCM URLs against a base URL with a trailing slash.
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @backstage/config@1.2.0
|
|
22
|
+
- @backstage/errors@1.2.4
|
|
23
|
+
|
|
3
24
|
## 1.9.1-next.2
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var parseGitUrl = require('git-url-parse');
|
|
6
4
|
var lodash = require('lodash');
|
|
7
5
|
var identity = require('@azure/identity');
|
|
@@ -10,10 +8,10 @@ var authApp = require('@octokit/auth-app');
|
|
|
10
8
|
var rest = require('@octokit/rest');
|
|
11
9
|
var luxon = require('luxon');
|
|
12
10
|
|
|
13
|
-
function
|
|
11
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
14
12
|
|
|
15
|
-
var parseGitUrl__default = /*#__PURE__*/
|
|
16
|
-
var fetch__default = /*#__PURE__*/
|
|
13
|
+
var parseGitUrl__default = /*#__PURE__*/_interopDefaultCompat(parseGitUrl);
|
|
14
|
+
var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
|
|
17
15
|
|
|
18
16
|
function isValidHost(host) {
|
|
19
17
|
const check = new URL("http://example.com");
|
|
@@ -55,7 +53,7 @@ function defaultScmResolveUrl(options) {
|
|
|
55
53
|
}
|
|
56
54
|
let updated;
|
|
57
55
|
if (url.startsWith("/")) {
|
|
58
|
-
const { href, filepath } = parseGitUrl__default
|
|
56
|
+
const { href, filepath } = parseGitUrl__default.default(base);
|
|
59
57
|
updated = new URL(href);
|
|
60
58
|
const repoRootPath = lodash.trimEnd(
|
|
61
59
|
updated.pathname.substring(0, updated.pathname.length - filepath.length),
|
|
@@ -121,10 +119,10 @@ function readAwsS3IntegrationConfigs(configs) {
|
|
|
121
119
|
return result;
|
|
122
120
|
}
|
|
123
121
|
|
|
124
|
-
var __defProp$
|
|
125
|
-
var __defNormalProp$
|
|
126
|
-
var __publicField$
|
|
127
|
-
__defNormalProp$
|
|
122
|
+
var __defProp$e = Object.defineProperty;
|
|
123
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
124
|
+
var __publicField$e = (obj, key, value) => {
|
|
125
|
+
__defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
128
126
|
return value;
|
|
129
127
|
};
|
|
130
128
|
const _AwsS3Integration = class _AwsS3Integration {
|
|
@@ -148,7 +146,7 @@ const _AwsS3Integration = class _AwsS3Integration {
|
|
|
148
146
|
return url;
|
|
149
147
|
}
|
|
150
148
|
};
|
|
151
|
-
__publicField$
|
|
149
|
+
__publicField$e(_AwsS3Integration, "factory", ({ config }) => {
|
|
152
150
|
var _a;
|
|
153
151
|
const configs = readAwsS3IntegrationConfigs(
|
|
154
152
|
(_a = config.getOptionalConfigArray("integrations.awsS3")) != null ? _a : []
|
|
@@ -160,6 +158,90 @@ __publicField$d(_AwsS3Integration, "factory", ({ config }) => {
|
|
|
160
158
|
});
|
|
161
159
|
let AwsS3Integration = _AwsS3Integration;
|
|
162
160
|
|
|
161
|
+
const AMAZON_AWS_CODECOMMIT_HOST = "console.aws.amazon.com";
|
|
162
|
+
function readAwsCodeCommitIntegrationConfig(config) {
|
|
163
|
+
var _a;
|
|
164
|
+
const accessKeyId = config.getOptionalString("accessKeyId");
|
|
165
|
+
const secretAccessKey = (_a = config.getOptionalString("secretAccessKey")) == null ? void 0 : _a.trim();
|
|
166
|
+
const roleArn = config.getOptionalString("roleArn");
|
|
167
|
+
const externalId = config.getOptionalString("externalId");
|
|
168
|
+
const host = AMAZON_AWS_CODECOMMIT_HOST;
|
|
169
|
+
return {
|
|
170
|
+
host,
|
|
171
|
+
accessKeyId,
|
|
172
|
+
secretAccessKey,
|
|
173
|
+
roleArn,
|
|
174
|
+
externalId
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function readAwsCodeCommitIntegrationConfigs(configs) {
|
|
178
|
+
const result = configs.map(readAwsCodeCommitIntegrationConfig);
|
|
179
|
+
if (!result.some((c) => c.host === AMAZON_AWS_CODECOMMIT_HOST)) {
|
|
180
|
+
result.push({
|
|
181
|
+
host: AMAZON_AWS_CODECOMMIT_HOST
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
var __defProp$d = Object.defineProperty;
|
|
188
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
189
|
+
var __publicField$d = (obj, key, value) => {
|
|
190
|
+
__defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
191
|
+
return value;
|
|
192
|
+
};
|
|
193
|
+
const _AwsCodeCommitIntegration = class _AwsCodeCommitIntegration {
|
|
194
|
+
constructor(integrationConfig) {
|
|
195
|
+
this.integrationConfig = integrationConfig;
|
|
196
|
+
}
|
|
197
|
+
get type() {
|
|
198
|
+
return "awsCodeCommit";
|
|
199
|
+
}
|
|
200
|
+
get config() {
|
|
201
|
+
return this.integrationConfig;
|
|
202
|
+
}
|
|
203
|
+
get title() {
|
|
204
|
+
return this.integrationConfig.host;
|
|
205
|
+
}
|
|
206
|
+
resolveUrl(options) {
|
|
207
|
+
const resolved = defaultScmResolveUrl(options);
|
|
208
|
+
return resolved;
|
|
209
|
+
}
|
|
210
|
+
resolveEditUrl(url) {
|
|
211
|
+
const parsedUrl = new URL(url);
|
|
212
|
+
const pathMatch = parsedUrl.pathname.match(
|
|
213
|
+
/^\/codesuite\/codecommit\/repositories\/([^\/]+)\//
|
|
214
|
+
);
|
|
215
|
+
if (!pathMatch) {
|
|
216
|
+
throw new Error(``);
|
|
217
|
+
}
|
|
218
|
+
const [, repositoryName] = pathMatch;
|
|
219
|
+
return replaceCodeCommitUrlType(url, repositoryName, "edit");
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
__publicField$d(_AwsCodeCommitIntegration, "factory", ({
|
|
223
|
+
config
|
|
224
|
+
}) => {
|
|
225
|
+
var _a;
|
|
226
|
+
const configs = readAwsCodeCommitIntegrationConfigs(
|
|
227
|
+
(_a = config.getOptionalConfigArray("integrations.awsCodeCommit")) != null ? _a : []
|
|
228
|
+
);
|
|
229
|
+
return basicIntegrations(
|
|
230
|
+
configs.map((c) => new _AwsCodeCommitIntegration(c)),
|
|
231
|
+
(i) => i.config.host
|
|
232
|
+
);
|
|
233
|
+
});
|
|
234
|
+
let AwsCodeCommitIntegration = _AwsCodeCommitIntegration;
|
|
235
|
+
function replaceCodeCommitUrlType(url, repositoryName, type) {
|
|
236
|
+
const newString = type === "edit" ? `files/edit` : type;
|
|
237
|
+
return url.replace(
|
|
238
|
+
new RegExp(
|
|
239
|
+
`/codesuite/codecommit/repositories/${repositoryName}/(browse|files/edit)/`
|
|
240
|
+
),
|
|
241
|
+
`/codesuite/codecommit/repositories/${repositoryName}/${newString}/`
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
163
245
|
var __accessCheck = (obj, member, msg) => {
|
|
164
246
|
if (!member.has(obj))
|
|
165
247
|
throw TypeError("Cannot " + msg);
|
|
@@ -812,7 +894,7 @@ const _BitbucketIntegration = class _BitbucketIntegration {
|
|
|
812
894
|
return url.toString();
|
|
813
895
|
}
|
|
814
896
|
resolveEditUrl(url) {
|
|
815
|
-
const urlData = parseGitUrl__default
|
|
897
|
+
const urlData = parseGitUrl__default.default(url);
|
|
816
898
|
const editUrl = new URL(url);
|
|
817
899
|
editUrl.searchParams.set("mode", "edit");
|
|
818
900
|
editUrl.searchParams.set("spa", "0");
|
|
@@ -841,13 +923,13 @@ __publicField$a(_BitbucketIntegration, "factory", ({
|
|
|
841
923
|
let BitbucketIntegration = _BitbucketIntegration;
|
|
842
924
|
|
|
843
925
|
async function getBitbucketDefaultBranch(url, config) {
|
|
844
|
-
const { name: repoName, owner: project, resource } = parseGitUrl__default
|
|
926
|
+
const { name: repoName, owner: project, resource } = parseGitUrl__default.default(url);
|
|
845
927
|
const isHosted = resource === "bitbucket.org";
|
|
846
928
|
let branchUrl = isHosted ? `${config.apiBaseUrl}/repositories/${project}/${repoName}` : `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/default-branch`;
|
|
847
|
-
let response = await fetch__default
|
|
929
|
+
let response = await fetch__default.default(branchUrl, getBitbucketRequestOptions(config));
|
|
848
930
|
if (response.status === 404 && !isHosted) {
|
|
849
931
|
branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches/default`;
|
|
850
|
-
response = await fetch__default
|
|
932
|
+
response = await fetch__default.default(branchUrl, getBitbucketRequestOptions(config));
|
|
851
933
|
}
|
|
852
934
|
if (!response.ok) {
|
|
853
935
|
const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;
|
|
@@ -876,7 +958,7 @@ async function getBitbucketDownloadUrl(url, config) {
|
|
|
876
958
|
protocol,
|
|
877
959
|
resource,
|
|
878
960
|
filepath
|
|
879
|
-
} = parseGitUrl__default
|
|
961
|
+
} = parseGitUrl__default.default(url);
|
|
880
962
|
const isHosted = resource === "bitbucket.org";
|
|
881
963
|
let branch = ref;
|
|
882
964
|
if (!branch) {
|
|
@@ -888,7 +970,7 @@ async function getBitbucketDownloadUrl(url, config) {
|
|
|
888
970
|
}
|
|
889
971
|
function getBitbucketFileFetchUrl(url, config) {
|
|
890
972
|
try {
|
|
891
|
-
const { owner, name, ref, filepathtype, filepath } = parseGitUrl__default
|
|
973
|
+
const { owner, name, ref, filepathtype, filepath } = parseGitUrl__default.default(url);
|
|
892
974
|
if (!owner || !name || filepathtype !== "browse" && filepathtype !== "raw" && filepathtype !== "src") {
|
|
893
975
|
throw new Error("Invalid Bitbucket URL or file path");
|
|
894
976
|
}
|
|
@@ -975,7 +1057,7 @@ const _BitbucketCloudIntegration = class _BitbucketCloudIntegration {
|
|
|
975
1057
|
return resolved;
|
|
976
1058
|
}
|
|
977
1059
|
resolveEditUrl(url) {
|
|
978
|
-
const urlData = parseGitUrl__default
|
|
1060
|
+
const urlData = parseGitUrl__default.default(url);
|
|
979
1061
|
const editUrl = new URL(url);
|
|
980
1062
|
editUrl.searchParams.set("mode", "edit");
|
|
981
1063
|
editUrl.searchParams.set("at", urlData.ref);
|
|
@@ -997,9 +1079,9 @@ __publicField$9(_BitbucketCloudIntegration, "factory", ({
|
|
|
997
1079
|
let BitbucketCloudIntegration = _BitbucketCloudIntegration;
|
|
998
1080
|
|
|
999
1081
|
async function getBitbucketCloudDefaultBranch(url, config) {
|
|
1000
|
-
const { name: repoName, owner: project } = parseGitUrl__default
|
|
1082
|
+
const { name: repoName, owner: project } = parseGitUrl__default.default(url);
|
|
1001
1083
|
const branchUrl = `${config.apiBaseUrl}/repositories/${project}/${repoName}`;
|
|
1002
|
-
const response = await fetch__default
|
|
1084
|
+
const response = await fetch__default.default(
|
|
1003
1085
|
branchUrl,
|
|
1004
1086
|
getBitbucketCloudRequestOptions(config)
|
|
1005
1087
|
);
|
|
@@ -1023,7 +1105,7 @@ async function getBitbucketCloudDownloadUrl(url, config) {
|
|
|
1023
1105
|
ref,
|
|
1024
1106
|
protocol,
|
|
1025
1107
|
resource
|
|
1026
|
-
} = parseGitUrl__default
|
|
1108
|
+
} = parseGitUrl__default.default(url);
|
|
1027
1109
|
let branch = ref;
|
|
1028
1110
|
if (!branch) {
|
|
1029
1111
|
branch = await getBitbucketCloudDefaultBranch(url, config);
|
|
@@ -1032,7 +1114,7 @@ async function getBitbucketCloudDownloadUrl(url, config) {
|
|
|
1032
1114
|
}
|
|
1033
1115
|
function getBitbucketCloudFileFetchUrl(url, config) {
|
|
1034
1116
|
try {
|
|
1035
|
-
const { owner, name, ref, filepathtype, filepath } = parseGitUrl__default
|
|
1117
|
+
const { owner, name, ref, filepathtype, filepath } = parseGitUrl__default.default(url);
|
|
1036
1118
|
if (!owner || !name || filepathtype !== "src" && filepathtype !== "raw") {
|
|
1037
1119
|
throw new Error("Invalid Bitbucket Cloud URL or file path");
|
|
1038
1120
|
}
|
|
@@ -1138,15 +1220,15 @@ __publicField$8(_BitbucketServerIntegration, "factory", ({
|
|
|
1138
1220
|
let BitbucketServerIntegration = _BitbucketServerIntegration;
|
|
1139
1221
|
|
|
1140
1222
|
async function getBitbucketServerDefaultBranch(url, config) {
|
|
1141
|
-
const { name: repoName, owner: project } = parseGitUrl__default
|
|
1223
|
+
const { name: repoName, owner: project } = parseGitUrl__default.default(url);
|
|
1142
1224
|
let branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/default-branch`;
|
|
1143
|
-
let response = await fetch__default
|
|
1225
|
+
let response = await fetch__default.default(
|
|
1144
1226
|
branchUrl,
|
|
1145
1227
|
getBitbucketServerRequestOptions(config)
|
|
1146
1228
|
);
|
|
1147
1229
|
if (response.status === 404) {
|
|
1148
1230
|
branchUrl = `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches/default`;
|
|
1149
|
-
response = await fetch__default
|
|
1231
|
+
response = await fetch__default.default(branchUrl, getBitbucketServerRequestOptions(config));
|
|
1150
1232
|
}
|
|
1151
1233
|
if (!response.ok) {
|
|
1152
1234
|
const message = `Failed to retrieve default branch from ${branchUrl}, ${response.status} ${response.statusText}`;
|
|
@@ -1162,7 +1244,7 @@ async function getBitbucketServerDefaultBranch(url, config) {
|
|
|
1162
1244
|
return defaultBranch;
|
|
1163
1245
|
}
|
|
1164
1246
|
async function getBitbucketServerDownloadUrl(url, config) {
|
|
1165
|
-
const { name: repoName, owner: project, ref, filepath } = parseGitUrl__default
|
|
1247
|
+
const { name: repoName, owner: project, ref, filepath } = parseGitUrl__default.default(url);
|
|
1166
1248
|
let branch = ref;
|
|
1167
1249
|
if (!branch) {
|
|
1168
1250
|
branch = await getBitbucketServerDefaultBranch(url, config);
|
|
@@ -1172,7 +1254,7 @@ async function getBitbucketServerDownloadUrl(url, config) {
|
|
|
1172
1254
|
}
|
|
1173
1255
|
function getBitbucketServerFileFetchUrl(url, config) {
|
|
1174
1256
|
try {
|
|
1175
|
-
const { owner, name, ref, filepathtype, filepath } = parseGitUrl__default
|
|
1257
|
+
const { owner, name, ref, filepathtype, filepath } = parseGitUrl__default.default(url);
|
|
1176
1258
|
if (!owner || !name || filepathtype !== "browse" && filepathtype !== "raw" && filepathtype !== "src") {
|
|
1177
1259
|
throw new Error("Invalid Bitbucket Server URL or file path");
|
|
1178
1260
|
}
|
|
@@ -1565,7 +1647,7 @@ function readGithubIntegrationConfigs(configs) {
|
|
|
1565
1647
|
|
|
1566
1648
|
function getGithubFileFetchUrl(url, config, credentials) {
|
|
1567
1649
|
try {
|
|
1568
|
-
const { owner, name, ref, filepathtype, filepath } = parseGitUrl__default
|
|
1650
|
+
const { owner, name, ref, filepathtype, filepath } = parseGitUrl__default.default(url);
|
|
1569
1651
|
if (!owner || !name || !ref || // GitHub is automatically redirecting tree urls to blob urls so it's
|
|
1570
1652
|
// fine to pass a tree url.
|
|
1571
1653
|
filepathtype !== "blob" && filepathtype !== "raw" && filepathtype !== "tree") {
|
|
@@ -1788,7 +1870,7 @@ const _SingleInstanceGithubCredentialsProvider = class _SingleInstanceGithubCred
|
|
|
1788
1870
|
* @returns A promise of {@link GithubCredentials}.
|
|
1789
1871
|
*/
|
|
1790
1872
|
async getCredentials(opts) {
|
|
1791
|
-
const parsed = parseGitUrl__default
|
|
1873
|
+
const parsed = parseGitUrl__default.default(opts.url);
|
|
1792
1874
|
const owner = parsed.owner || parsed.name;
|
|
1793
1875
|
const repo = parsed.owner ? parsed.name : void 0;
|
|
1794
1876
|
let type = "app";
|
|
@@ -2031,7 +2113,7 @@ async function getProjectId(target, config) {
|
|
|
2031
2113
|
repo.replace(/^\//, "")
|
|
2032
2114
|
)}`
|
|
2033
2115
|
);
|
|
2034
|
-
const response = await fetch__default
|
|
2116
|
+
const response = await fetch__default.default(
|
|
2035
2117
|
repoIDLookup.toString(),
|
|
2036
2118
|
getGitLabRequestOptions(config)
|
|
2037
2119
|
);
|
|
@@ -2165,6 +2247,7 @@ class ScmIntegrations {
|
|
|
2165
2247
|
static fromConfig(config) {
|
|
2166
2248
|
return new ScmIntegrations({
|
|
2167
2249
|
awsS3: AwsS3Integration.factory({ config }),
|
|
2250
|
+
awsCodeCommit: AwsCodeCommitIntegration.factory({ config }),
|
|
2168
2251
|
azure: AzureIntegration.factory({ config }),
|
|
2169
2252
|
bitbucket: BitbucketIntegration.factory({ config }),
|
|
2170
2253
|
bitbucketCloud: BitbucketCloudIntegration.factory({ config }),
|
|
@@ -2178,6 +2261,9 @@ class ScmIntegrations {
|
|
|
2178
2261
|
get awsS3() {
|
|
2179
2262
|
return this.byType.awsS3;
|
|
2180
2263
|
}
|
|
2264
|
+
get awsCodeCommit() {
|
|
2265
|
+
return this.byType.awsCodeCommit;
|
|
2266
|
+
}
|
|
2181
2267
|
get azure() {
|
|
2182
2268
|
return this.byType.azure;
|
|
2183
2269
|
}
|
|
@@ -2241,6 +2327,7 @@ class ScmIntegrations {
|
|
|
2241
2327
|
}
|
|
2242
2328
|
}
|
|
2243
2329
|
|
|
2330
|
+
exports.AwsCodeCommitIntegration = AwsCodeCommitIntegration;
|
|
2244
2331
|
exports.AwsS3Integration = AwsS3Integration;
|
|
2245
2332
|
exports.AzureIntegration = AzureIntegration;
|
|
2246
2333
|
exports.BitbucketCloudIntegration = BitbucketCloudIntegration;
|
|
@@ -2294,6 +2381,8 @@ exports.getGithubFileFetchUrl = getGithubFileFetchUrl;
|
|
|
2294
2381
|
exports.parseGerritGitilesUrl = parseGerritGitilesUrl;
|
|
2295
2382
|
exports.parseGerritJsonResponse = parseGerritJsonResponse;
|
|
2296
2383
|
exports.parseGiteaUrl = parseGiteaUrl;
|
|
2384
|
+
exports.readAwsCodeCommitIntegrationConfig = readAwsCodeCommitIntegrationConfig;
|
|
2385
|
+
exports.readAwsCodeCommitIntegrationConfigs = readAwsCodeCommitIntegrationConfigs;
|
|
2297
2386
|
exports.readAwsS3IntegrationConfig = readAwsS3IntegrationConfig;
|
|
2298
2387
|
exports.readAwsS3IntegrationConfigs = readAwsS3IntegrationConfigs;
|
|
2299
2388
|
exports.readAzureIntegrationConfig = readAzureIntegrationConfig;
|