@backstage/integration 1.2.0 → 1.2.1-next.2
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 +18 -0
- package/dist/index.cjs.js +48 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +48 -37
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -187,6 +187,10 @@ const _AzureUrl = class {
|
|
|
187
187
|
owner = parts[1];
|
|
188
188
|
project = parts[2];
|
|
189
189
|
repo = parts[4];
|
|
190
|
+
} else if (parts[4] === "_git") {
|
|
191
|
+
owner = `${parts[1]}/${parts[2]}`;
|
|
192
|
+
project = parts[3];
|
|
193
|
+
repo = parts[5];
|
|
190
194
|
}
|
|
191
195
|
if (!owner || !project || !repo) {
|
|
192
196
|
throw new Error("Azure URL must point to a git repository");
|
|
@@ -795,43 +799,6 @@ function readGerritIntegrationConfigs(configs) {
|
|
|
795
799
|
return configs.map(readGerritIntegrationConfig);
|
|
796
800
|
}
|
|
797
801
|
|
|
798
|
-
const _GerritIntegration = class {
|
|
799
|
-
constructor(integrationConfig) {
|
|
800
|
-
this.integrationConfig = integrationConfig;
|
|
801
|
-
}
|
|
802
|
-
get type() {
|
|
803
|
-
return "gerrit";
|
|
804
|
-
}
|
|
805
|
-
get title() {
|
|
806
|
-
return this.integrationConfig.host;
|
|
807
|
-
}
|
|
808
|
-
get config() {
|
|
809
|
-
return this.integrationConfig;
|
|
810
|
-
}
|
|
811
|
-
resolveUrl(options) {
|
|
812
|
-
const { url, base, lineNumber } = options;
|
|
813
|
-
let updated;
|
|
814
|
-
if (url) {
|
|
815
|
-
updated = new URL(url, base);
|
|
816
|
-
} else {
|
|
817
|
-
updated = new URL(base);
|
|
818
|
-
}
|
|
819
|
-
if (lineNumber) {
|
|
820
|
-
updated.hash = lineNumber.toString();
|
|
821
|
-
}
|
|
822
|
-
return updated.toString();
|
|
823
|
-
}
|
|
824
|
-
resolveEditUrl(url) {
|
|
825
|
-
return url;
|
|
826
|
-
}
|
|
827
|
-
};
|
|
828
|
-
let GerritIntegration = _GerritIntegration;
|
|
829
|
-
GerritIntegration.factory = ({ config }) => {
|
|
830
|
-
var _a;
|
|
831
|
-
const configs = readGerritIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.gerrit")) != null ? _a : []);
|
|
832
|
-
return basicIntegrations(configs.map((c) => new _GerritIntegration(c)), (i) => i.config.host);
|
|
833
|
-
};
|
|
834
|
-
|
|
835
802
|
const GERRIT_BODY_PREFIX = ")]}'";
|
|
836
803
|
function parseGerritGitilesUrl(config, url) {
|
|
837
804
|
const urlPath = url.replace(config.gitilesBaseUrl, "");
|
|
@@ -853,6 +820,9 @@ function parseGerritGitilesUrl(config, url) {
|
|
|
853
820
|
project
|
|
854
821
|
};
|
|
855
822
|
}
|
|
823
|
+
function builldGerritGitilesUrl(config, project, branch, filePath) {
|
|
824
|
+
return `${config.gitilesBaseUrl}/${project}/+/refs/heads/${branch}/${trimStart(filePath, "/")}`;
|
|
825
|
+
}
|
|
856
826
|
function getAuthenticationPrefix(config) {
|
|
857
827
|
return config.password ? "/a/" : "/";
|
|
858
828
|
}
|
|
@@ -894,6 +864,47 @@ async function parseGerritJsonResponse(response) {
|
|
|
894
864
|
throw new Error(`Gerrit JSON body prefix missing. Found: ${responseBody.slice(0, 10)}`);
|
|
895
865
|
}
|
|
896
866
|
|
|
867
|
+
const _GerritIntegration = class {
|
|
868
|
+
constructor(integrationConfig) {
|
|
869
|
+
this.integrationConfig = integrationConfig;
|
|
870
|
+
}
|
|
871
|
+
get type() {
|
|
872
|
+
return "gerrit";
|
|
873
|
+
}
|
|
874
|
+
get title() {
|
|
875
|
+
return this.integrationConfig.host;
|
|
876
|
+
}
|
|
877
|
+
get config() {
|
|
878
|
+
return this.integrationConfig;
|
|
879
|
+
}
|
|
880
|
+
resolveUrl(options) {
|
|
881
|
+
const { url, base, lineNumber } = options;
|
|
882
|
+
let updated;
|
|
883
|
+
if (url.startsWith("/")) {
|
|
884
|
+
const { branch, project } = parseGerritGitilesUrl(this.config, base);
|
|
885
|
+
return builldGerritGitilesUrl(this.config, project, branch, url);
|
|
886
|
+
}
|
|
887
|
+
if (url) {
|
|
888
|
+
updated = new URL(url, base);
|
|
889
|
+
} else {
|
|
890
|
+
updated = new URL(base);
|
|
891
|
+
}
|
|
892
|
+
if (lineNumber) {
|
|
893
|
+
updated.hash = lineNumber.toString();
|
|
894
|
+
}
|
|
895
|
+
return updated.toString();
|
|
896
|
+
}
|
|
897
|
+
resolveEditUrl(url) {
|
|
898
|
+
return url;
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
let GerritIntegration = _GerritIntegration;
|
|
902
|
+
GerritIntegration.factory = ({ config }) => {
|
|
903
|
+
var _a;
|
|
904
|
+
const configs = readGerritIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.gerrit")) != null ? _a : []);
|
|
905
|
+
return basicIntegrations(configs.map((c) => new _GerritIntegration(c)), (i) => i.config.host);
|
|
906
|
+
};
|
|
907
|
+
|
|
897
908
|
const GITHUB_HOST = "github.com";
|
|
898
909
|
const GITHUB_API_BASE_URL = "https://api.github.com";
|
|
899
910
|
const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com";
|