@backstage/integration 1.2.0-next.1 → 1.2.1-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 +58 -0
- package/dist/index.cjs.js +56 -42
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +56 -42
- package/dist/index.esm.js.map +1 -1
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
# @backstage/integration
|
|
2
2
|
|
|
3
|
+
## 1.2.1-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8f7b1835df: Updated dependency `msw` to `^0.41.0`.
|
|
8
|
+
|
|
9
|
+
## 1.2.1-next.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 72dfcbc8bf: Gerrit Integration: Handle absolute paths in `resolveUrl` properly.
|
|
14
|
+
|
|
15
|
+
## 1.2.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- e295ce87de: added the possibility to handle raw Gitlab URLs with nested namespaces
|
|
20
|
+
- 6673babab9: Gerrit UrlReader: Implemented `readTree`
|
|
21
|
+
- 1b4e1e2306: Split `bitbucket` integration into `bitbucketCloud` and `bitbucketServer`
|
|
22
|
+
(backwards compatible).
|
|
23
|
+
|
|
24
|
+
In order to migrate to the new integration configs,
|
|
25
|
+
move your configs from `integrations.bitbucket`
|
|
26
|
+
to `integrations.bitbucketCloud` or `integrations.bitbucketServer`.
|
|
27
|
+
|
|
28
|
+
Migration example:
|
|
29
|
+
|
|
30
|
+
**Before:**
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
integrations:
|
|
34
|
+
bitbucket:
|
|
35
|
+
- host: bitbucket.org
|
|
36
|
+
username: bitbucket_user
|
|
37
|
+
appPassword: app-password
|
|
38
|
+
- host: bitbucket-server.company.com
|
|
39
|
+
token: my-token
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**After:**
|
|
43
|
+
|
|
44
|
+
```yaml
|
|
45
|
+
integrations:
|
|
46
|
+
bitbucketCloud:
|
|
47
|
+
- username: bitbucket_user
|
|
48
|
+
appPassword: app-password
|
|
49
|
+
bitbucketServer:
|
|
50
|
+
- host: bitbucket-server.company.com
|
|
51
|
+
token: my-token
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- 566407bf8a: Gerrit Integration: Added the `getGerritProjectsApiUrl` function
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- Updated dependencies
|
|
59
|
+
- @backstage/config@1.0.1
|
|
60
|
+
|
|
3
61
|
## 1.2.0-next.1
|
|
4
62
|
|
|
5
63
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -8,6 +8,7 @@ var fetch = require('cross-fetch');
|
|
|
8
8
|
var authApp = require('@octokit/auth-app');
|
|
9
9
|
var rest = require('@octokit/rest');
|
|
10
10
|
var luxon = require('luxon');
|
|
11
|
+
var errors = require('@backstage/errors');
|
|
11
12
|
|
|
12
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
14
|
|
|
@@ -803,43 +804,6 @@ function readGerritIntegrationConfigs(configs) {
|
|
|
803
804
|
return configs.map(readGerritIntegrationConfig);
|
|
804
805
|
}
|
|
805
806
|
|
|
806
|
-
const _GerritIntegration = class {
|
|
807
|
-
constructor(integrationConfig) {
|
|
808
|
-
this.integrationConfig = integrationConfig;
|
|
809
|
-
}
|
|
810
|
-
get type() {
|
|
811
|
-
return "gerrit";
|
|
812
|
-
}
|
|
813
|
-
get title() {
|
|
814
|
-
return this.integrationConfig.host;
|
|
815
|
-
}
|
|
816
|
-
get config() {
|
|
817
|
-
return this.integrationConfig;
|
|
818
|
-
}
|
|
819
|
-
resolveUrl(options) {
|
|
820
|
-
const { url, base, lineNumber } = options;
|
|
821
|
-
let updated;
|
|
822
|
-
if (url) {
|
|
823
|
-
updated = new URL(url, base);
|
|
824
|
-
} else {
|
|
825
|
-
updated = new URL(base);
|
|
826
|
-
}
|
|
827
|
-
if (lineNumber) {
|
|
828
|
-
updated.hash = lineNumber.toString();
|
|
829
|
-
}
|
|
830
|
-
return updated.toString();
|
|
831
|
-
}
|
|
832
|
-
resolveEditUrl(url) {
|
|
833
|
-
return url;
|
|
834
|
-
}
|
|
835
|
-
};
|
|
836
|
-
let GerritIntegration = _GerritIntegration;
|
|
837
|
-
GerritIntegration.factory = ({ config }) => {
|
|
838
|
-
var _a;
|
|
839
|
-
const configs = readGerritIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.gerrit")) != null ? _a : []);
|
|
840
|
-
return basicIntegrations(configs.map((c) => new _GerritIntegration(c)), (i) => i.config.host);
|
|
841
|
-
};
|
|
842
|
-
|
|
843
807
|
const GERRIT_BODY_PREFIX = ")]}'";
|
|
844
808
|
function parseGerritGitilesUrl(config, url) {
|
|
845
809
|
const urlPath = url.replace(config.gitilesBaseUrl, "");
|
|
@@ -861,6 +825,9 @@ function parseGerritGitilesUrl(config, url) {
|
|
|
861
825
|
project
|
|
862
826
|
};
|
|
863
827
|
}
|
|
828
|
+
function builldGerritGitilesUrl(config, project, branch, filePath) {
|
|
829
|
+
return `${config.gitilesBaseUrl}/${project}/+/refs/heads/${branch}/${lodash.trimStart(filePath, "/")}`;
|
|
830
|
+
}
|
|
864
831
|
function getAuthenticationPrefix(config) {
|
|
865
832
|
return config.password ? "/a/" : "/";
|
|
866
833
|
}
|
|
@@ -902,6 +869,47 @@ async function parseGerritJsonResponse(response) {
|
|
|
902
869
|
throw new Error(`Gerrit JSON body prefix missing. Found: ${responseBody.slice(0, 10)}`);
|
|
903
870
|
}
|
|
904
871
|
|
|
872
|
+
const _GerritIntegration = class {
|
|
873
|
+
constructor(integrationConfig) {
|
|
874
|
+
this.integrationConfig = integrationConfig;
|
|
875
|
+
}
|
|
876
|
+
get type() {
|
|
877
|
+
return "gerrit";
|
|
878
|
+
}
|
|
879
|
+
get title() {
|
|
880
|
+
return this.integrationConfig.host;
|
|
881
|
+
}
|
|
882
|
+
get config() {
|
|
883
|
+
return this.integrationConfig;
|
|
884
|
+
}
|
|
885
|
+
resolveUrl(options) {
|
|
886
|
+
const { url, base, lineNumber } = options;
|
|
887
|
+
let updated;
|
|
888
|
+
if (url.startsWith("/")) {
|
|
889
|
+
const { branch, project } = parseGerritGitilesUrl(this.config, base);
|
|
890
|
+
return builldGerritGitilesUrl(this.config, project, branch, url);
|
|
891
|
+
}
|
|
892
|
+
if (url) {
|
|
893
|
+
updated = new URL(url, base);
|
|
894
|
+
} else {
|
|
895
|
+
updated = new URL(base);
|
|
896
|
+
}
|
|
897
|
+
if (lineNumber) {
|
|
898
|
+
updated.hash = lineNumber.toString();
|
|
899
|
+
}
|
|
900
|
+
return updated.toString();
|
|
901
|
+
}
|
|
902
|
+
resolveEditUrl(url) {
|
|
903
|
+
return url;
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
let GerritIntegration = _GerritIntegration;
|
|
907
|
+
GerritIntegration.factory = ({ config }) => {
|
|
908
|
+
var _a;
|
|
909
|
+
const configs = readGerritIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.gerrit")) != null ? _a : []);
|
|
910
|
+
return basicIntegrations(configs.map((c) => new _GerritIntegration(c)), (i) => i.config.host);
|
|
911
|
+
};
|
|
912
|
+
|
|
905
913
|
const GITHUB_HOST = "github.com";
|
|
906
914
|
const GITHUB_API_BASE_URL = "https://api.github.com";
|
|
907
915
|
const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com";
|
|
@@ -1234,14 +1242,20 @@ function getGitLabRequestOptions(config) {
|
|
|
1234
1242
|
function buildRawUrl(target) {
|
|
1235
1243
|
try {
|
|
1236
1244
|
const url = new URL(target);
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1239
|
-
|
|
1245
|
+
const splitPath = url.pathname.split("/").filter(Boolean);
|
|
1246
|
+
const blobIndex = splitPath.indexOf("blob", 2);
|
|
1247
|
+
if (blobIndex < 2 || blobIndex === splitPath.length - 1) {
|
|
1248
|
+
throw new errors.InputError("Wrong GitLab URL");
|
|
1240
1249
|
}
|
|
1241
|
-
|
|
1250
|
+
const repoPath = splitPath.slice(0, blobIndex);
|
|
1251
|
+
const restOfPath = splitPath.slice(blobIndex + 1);
|
|
1252
|
+
if (!restOfPath.join("/").match(/\.(yaml|yml)$/)) {
|
|
1253
|
+
throw new errors.InputError("Wrong GitLab URL");
|
|
1254
|
+
}
|
|
1255
|
+
url.pathname = [...repoPath, "raw", ...restOfPath].join("/");
|
|
1242
1256
|
return url;
|
|
1243
1257
|
} catch (e) {
|
|
1244
|
-
throw new
|
|
1258
|
+
throw new errors.InputError(`Incorrect url: ${target}, ${e}`);
|
|
1245
1259
|
}
|
|
1246
1260
|
}
|
|
1247
1261
|
function buildProjectUrl(target, projectID) {
|