@backstage/integration 1.2.0 → 1.2.1-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 +6 -0
- package/dist/index.cjs.js +44 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +44 -37
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -804,43 +804,6 @@ function readGerritIntegrationConfigs(configs) {
|
|
|
804
804
|
return configs.map(readGerritIntegrationConfig);
|
|
805
805
|
}
|
|
806
806
|
|
|
807
|
-
const _GerritIntegration = class {
|
|
808
|
-
constructor(integrationConfig) {
|
|
809
|
-
this.integrationConfig = integrationConfig;
|
|
810
|
-
}
|
|
811
|
-
get type() {
|
|
812
|
-
return "gerrit";
|
|
813
|
-
}
|
|
814
|
-
get title() {
|
|
815
|
-
return this.integrationConfig.host;
|
|
816
|
-
}
|
|
817
|
-
get config() {
|
|
818
|
-
return this.integrationConfig;
|
|
819
|
-
}
|
|
820
|
-
resolveUrl(options) {
|
|
821
|
-
const { url, base, lineNumber } = options;
|
|
822
|
-
let updated;
|
|
823
|
-
if (url) {
|
|
824
|
-
updated = new URL(url, base);
|
|
825
|
-
} else {
|
|
826
|
-
updated = new URL(base);
|
|
827
|
-
}
|
|
828
|
-
if (lineNumber) {
|
|
829
|
-
updated.hash = lineNumber.toString();
|
|
830
|
-
}
|
|
831
|
-
return updated.toString();
|
|
832
|
-
}
|
|
833
|
-
resolveEditUrl(url) {
|
|
834
|
-
return url;
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
let GerritIntegration = _GerritIntegration;
|
|
838
|
-
GerritIntegration.factory = ({ config }) => {
|
|
839
|
-
var _a;
|
|
840
|
-
const configs = readGerritIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.gerrit")) != null ? _a : []);
|
|
841
|
-
return basicIntegrations(configs.map((c) => new _GerritIntegration(c)), (i) => i.config.host);
|
|
842
|
-
};
|
|
843
|
-
|
|
844
807
|
const GERRIT_BODY_PREFIX = ")]}'";
|
|
845
808
|
function parseGerritGitilesUrl(config, url) {
|
|
846
809
|
const urlPath = url.replace(config.gitilesBaseUrl, "");
|
|
@@ -862,6 +825,9 @@ function parseGerritGitilesUrl(config, url) {
|
|
|
862
825
|
project
|
|
863
826
|
};
|
|
864
827
|
}
|
|
828
|
+
function builldGerritGitilesUrl(config, project, branch, filePath) {
|
|
829
|
+
return `${config.gitilesBaseUrl}/${project}/+/refs/heads/${branch}/${lodash.trimStart(filePath, "/")}`;
|
|
830
|
+
}
|
|
865
831
|
function getAuthenticationPrefix(config) {
|
|
866
832
|
return config.password ? "/a/" : "/";
|
|
867
833
|
}
|
|
@@ -903,6 +869,47 @@ async function parseGerritJsonResponse(response) {
|
|
|
903
869
|
throw new Error(`Gerrit JSON body prefix missing. Found: ${responseBody.slice(0, 10)}`);
|
|
904
870
|
}
|
|
905
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
|
+
|
|
906
913
|
const GITHUB_HOST = "github.com";
|
|
907
914
|
const GITHUB_API_BASE_URL = "https://api.github.com";
|
|
908
915
|
const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com";
|