@backstage/integration 1.3.2 → 1.4.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 +62 -0
- package/config.d.ts +26 -5
- package/dist/index.cjs.js +134 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +132 -16
- package/dist/index.esm.js +126 -17
- package/dist/index.esm.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -761,12 +761,90 @@ declare function getGerritRequestOptions(config: GerritIntegrationConfig): {
|
|
|
761
761
|
*/
|
|
762
762
|
declare function parseGerritJsonResponse(response: Response): Promise<unknown>;
|
|
763
763
|
|
|
764
|
+
/**
|
|
765
|
+
* The configuration for a single Gitea integration.
|
|
766
|
+
*
|
|
767
|
+
* @public
|
|
768
|
+
*/
|
|
769
|
+
declare type GiteaIntegrationConfig = {
|
|
770
|
+
/**
|
|
771
|
+
* The host of the target that this matches on, e.g. "gitea.website.com"
|
|
772
|
+
*/
|
|
773
|
+
host: string;
|
|
774
|
+
/**
|
|
775
|
+
* The optional base URL of the Gitea instance. It is assumed that https
|
|
776
|
+
* is used and that the base path is "/" on the host. If that is not the
|
|
777
|
+
* case set the complete base url to the gitea instance, e.g.
|
|
778
|
+
* "https://gitea.website.com/". This is the url that you would open
|
|
779
|
+
* in a browser.
|
|
780
|
+
*/
|
|
781
|
+
baseUrl?: string;
|
|
782
|
+
/**
|
|
783
|
+
* The username to use for requests to gitea.
|
|
784
|
+
*/
|
|
785
|
+
username?: string;
|
|
786
|
+
/**
|
|
787
|
+
* The password or http token to use for authentication.
|
|
788
|
+
*/
|
|
789
|
+
password?: string;
|
|
790
|
+
};
|
|
791
|
+
/**
|
|
792
|
+
* Parses a location config block for use in GiteaIntegration
|
|
793
|
+
*
|
|
794
|
+
* @public
|
|
795
|
+
*/
|
|
796
|
+
declare function readGiteaConfig(config: Config): GiteaIntegrationConfig;
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* A Gitea based integration.
|
|
800
|
+
*
|
|
801
|
+
* @public
|
|
802
|
+
*/
|
|
803
|
+
declare class GiteaIntegration implements ScmIntegration {
|
|
804
|
+
readonly config: GiteaIntegrationConfig;
|
|
805
|
+
static factory: ScmIntegrationsFactory<GiteaIntegration>;
|
|
806
|
+
constructor(config: GiteaIntegrationConfig);
|
|
807
|
+
get type(): string;
|
|
808
|
+
get title(): string;
|
|
809
|
+
resolveUrl(options: {
|
|
810
|
+
url: string;
|
|
811
|
+
base: string;
|
|
812
|
+
lineNumber?: number | undefined;
|
|
813
|
+
}): string;
|
|
814
|
+
resolveEditUrl(url: string): string;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Given a URL pointing to a file, returns an api URL
|
|
819
|
+
* for fetching the contents of the data.
|
|
820
|
+
*
|
|
821
|
+
* @remarks
|
|
822
|
+
*
|
|
823
|
+
* Converts
|
|
824
|
+
* from: https://gitea.com/a/b/src/branch/branchname/path/to/c.yaml
|
|
825
|
+
* to: https://gitea.com/api/v1/repos/a/b/contents/path/to/c.yaml?ref=branchname
|
|
826
|
+
*
|
|
827
|
+
* @param url - A URL pointing to a file
|
|
828
|
+
* @param config - The relevant provider config
|
|
829
|
+
* @public
|
|
830
|
+
*/
|
|
831
|
+
declare function getGiteaFileContentsUrl(config: GiteaIntegrationConfig, url: string): string;
|
|
832
|
+
/**
|
|
833
|
+
* Return request headers for a Gitea provider.
|
|
834
|
+
*
|
|
835
|
+
* @param config - A Gitea provider config
|
|
836
|
+
* @public
|
|
837
|
+
*/
|
|
838
|
+
declare function getGiteaRequestOptions(config: GiteaIntegrationConfig): {
|
|
839
|
+
headers?: Record<string, string>;
|
|
840
|
+
};
|
|
841
|
+
|
|
764
842
|
/**
|
|
765
843
|
* The configuration parameters for a single GitHub integration.
|
|
766
844
|
*
|
|
767
845
|
* @public
|
|
768
846
|
*/
|
|
769
|
-
declare type
|
|
847
|
+
declare type GithubIntegrationConfig = {
|
|
770
848
|
/**
|
|
771
849
|
* The host of the target that this matches on, e.g. "github.com"
|
|
772
850
|
*/
|
|
@@ -850,7 +928,7 @@ declare type GithubAppConfig = {
|
|
|
850
928
|
* @param config - The config object of a single integration
|
|
851
929
|
* @public
|
|
852
930
|
*/
|
|
853
|
-
declare function
|
|
931
|
+
declare function readGithubIntegrationConfig(config: Config): GithubIntegrationConfig;
|
|
854
932
|
/**
|
|
855
933
|
* Reads a set of GitHub integration configs, and inserts some defaults for
|
|
856
934
|
* public GitHub if not specified.
|
|
@@ -858,7 +936,7 @@ declare function readGitHubIntegrationConfig(config: Config): GitHubIntegrationC
|
|
|
858
936
|
* @param configs - All of the integration config objects
|
|
859
937
|
* @public
|
|
860
938
|
*/
|
|
861
|
-
declare function
|
|
939
|
+
declare function readGithubIntegrationConfigs(configs: Config[]): GithubIntegrationConfig[];
|
|
862
940
|
|
|
863
941
|
/**
|
|
864
942
|
* The type of credentials produced by the credential provider.
|
|
@@ -905,7 +983,7 @@ interface GithubCredentialsProvider {
|
|
|
905
983
|
* @param config - The relevant provider config
|
|
906
984
|
* @public
|
|
907
985
|
*/
|
|
908
|
-
declare function
|
|
986
|
+
declare function getGithubFileFetchUrl(url: string, config: GithubIntegrationConfig, credentials: GithubCredentials): string;
|
|
909
987
|
/**
|
|
910
988
|
* Gets the request options necessary to make requests to a given provider.
|
|
911
989
|
*
|
|
@@ -913,7 +991,7 @@ declare function getGitHubFileFetchUrl(url: string, config: GitHubIntegrationCon
|
|
|
913
991
|
* @param config - The relevant provider config
|
|
914
992
|
* @public
|
|
915
993
|
*/
|
|
916
|
-
declare function getGitHubRequestOptions(config:
|
|
994
|
+
declare function getGitHubRequestOptions(config: GithubIntegrationConfig, credentials: GithubCredentials): {
|
|
917
995
|
headers: Record<string, string>;
|
|
918
996
|
};
|
|
919
997
|
|
|
@@ -922,13 +1000,13 @@ declare function getGitHubRequestOptions(config: GitHubIntegrationConfig, creden
|
|
|
922
1000
|
*
|
|
923
1001
|
* @public
|
|
924
1002
|
*/
|
|
925
|
-
declare class
|
|
1003
|
+
declare class GithubIntegration implements ScmIntegration {
|
|
926
1004
|
private readonly integrationConfig;
|
|
927
|
-
static factory: ScmIntegrationsFactory<
|
|
928
|
-
constructor(integrationConfig:
|
|
1005
|
+
static factory: ScmIntegrationsFactory<GithubIntegration>;
|
|
1006
|
+
constructor(integrationConfig: GithubIntegrationConfig);
|
|
929
1007
|
get type(): string;
|
|
930
1008
|
get title(): string;
|
|
931
|
-
get config():
|
|
1009
|
+
get config(): GithubIntegrationConfig;
|
|
932
1010
|
resolveUrl(options: {
|
|
933
1011
|
url: string;
|
|
934
1012
|
base: string;
|
|
@@ -943,7 +1021,7 @@ declare class GitHubIntegration implements ScmIntegration {
|
|
|
943
1021
|
* @param type - The desired type, e.g. "blob"
|
|
944
1022
|
* @public
|
|
945
1023
|
*/
|
|
946
|
-
declare function
|
|
1024
|
+
declare function replaceGithubUrlType(url: string, type: 'blob' | 'tree' | 'edit'): string;
|
|
947
1025
|
|
|
948
1026
|
/**
|
|
949
1027
|
* The configuration parameters for a single GitLab integration.
|
|
@@ -1043,8 +1121,9 @@ interface ScmIntegrationRegistry extends ScmIntegrationsGroup<ScmIntegration> {
|
|
|
1043
1121
|
bitbucketCloud: ScmIntegrationsGroup<BitbucketCloudIntegration>;
|
|
1044
1122
|
bitbucketServer: ScmIntegrationsGroup<BitbucketServerIntegration>;
|
|
1045
1123
|
gerrit: ScmIntegrationsGroup<GerritIntegration>;
|
|
1046
|
-
github: ScmIntegrationsGroup<
|
|
1124
|
+
github: ScmIntegrationsGroup<GithubIntegration>;
|
|
1047
1125
|
gitlab: ScmIntegrationsGroup<GitLabIntegration>;
|
|
1126
|
+
gitea: ScmIntegrationsGroup<GiteaIntegration>;
|
|
1048
1127
|
/**
|
|
1049
1128
|
* Resolves an absolute or relative URL in relation to a base URL.
|
|
1050
1129
|
*
|
|
@@ -1133,7 +1212,7 @@ declare class DefaultGithubCredentialsProvider implements GithubCredentialsProvi
|
|
|
1133
1212
|
*/
|
|
1134
1213
|
declare class GithubAppCredentialsMux {
|
|
1135
1214
|
private readonly apps;
|
|
1136
|
-
constructor(config:
|
|
1215
|
+
constructor(config: GithubIntegrationConfig);
|
|
1137
1216
|
getAllInstallations(): Promise<RestEndpointMethodTypes['apps']['listInstallations']['response']['data']>;
|
|
1138
1217
|
getAppToken(owner: string, repo?: string): Promise<string | undefined>;
|
|
1139
1218
|
}
|
|
@@ -1148,7 +1227,7 @@ declare class GithubAppCredentialsMux {
|
|
|
1148
1227
|
declare class SingleInstanceGithubCredentialsProvider implements GithubCredentialsProvider {
|
|
1149
1228
|
private readonly githubAppCredentialsMux;
|
|
1150
1229
|
private readonly token?;
|
|
1151
|
-
static create: (config:
|
|
1230
|
+
static create: (config: GithubIntegrationConfig) => GithubCredentialsProvider;
|
|
1152
1231
|
private constructor();
|
|
1153
1232
|
/**
|
|
1154
1233
|
* Returns {@link GithubCredentials} for a given URL.
|
|
@@ -1175,6 +1254,41 @@ declare class SingleInstanceGithubCredentialsProvider implements GithubCredentia
|
|
|
1175
1254
|
}): Promise<GithubCredentials>;
|
|
1176
1255
|
}
|
|
1177
1256
|
|
|
1257
|
+
/**
|
|
1258
|
+
* @public
|
|
1259
|
+
* @deprecated Use {@link getGithubFileFetchUrl} instead.
|
|
1260
|
+
*/
|
|
1261
|
+
declare const getGitHubFileFetchUrl: typeof getGithubFileFetchUrl;
|
|
1262
|
+
/**
|
|
1263
|
+
* @public
|
|
1264
|
+
* @deprecated Use {@link GithubIntegrationConfig} instead.
|
|
1265
|
+
*/
|
|
1266
|
+
declare type GitHubIntegrationConfig = GithubIntegrationConfig;
|
|
1267
|
+
/**
|
|
1268
|
+
* @public
|
|
1269
|
+
* @deprecated Use {@link GithubIntegration} instead.
|
|
1270
|
+
*/
|
|
1271
|
+
declare class GitHubIntegration extends GithubIntegration {
|
|
1272
|
+
static factory: ScmIntegrationsFactory<GitHubIntegration>;
|
|
1273
|
+
constructor(integrationConfig: GitHubIntegrationConfig);
|
|
1274
|
+
get config(): GitHubIntegrationConfig;
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* @public
|
|
1278
|
+
* @deprecated Use {@link readGithubIntegrationConfig} instead.
|
|
1279
|
+
*/
|
|
1280
|
+
declare const readGitHubIntegrationConfig: typeof readGithubIntegrationConfig;
|
|
1281
|
+
/**
|
|
1282
|
+
* @public
|
|
1283
|
+
* @deprecated Use {@link readGithubIntegrationConfigs} instead.
|
|
1284
|
+
*/
|
|
1285
|
+
declare const readGitHubIntegrationConfigs: typeof readGithubIntegrationConfigs;
|
|
1286
|
+
/**
|
|
1287
|
+
* @public
|
|
1288
|
+
* @deprecated Use {@link replaceGithubUrlType} instead.
|
|
1289
|
+
*/
|
|
1290
|
+
declare const replaceGitHubUrlType: typeof replaceGithubUrlType;
|
|
1291
|
+
|
|
1178
1292
|
/**
|
|
1179
1293
|
* Given a URL pointing to a file on a provider, returns a URL that is suitable
|
|
1180
1294
|
* for fetching the contents of the data.
|
|
@@ -1253,8 +1367,9 @@ interface IntegrationsByType {
|
|
|
1253
1367
|
bitbucketCloud: ScmIntegrationsGroup<BitbucketCloudIntegration>;
|
|
1254
1368
|
bitbucketServer: ScmIntegrationsGroup<BitbucketServerIntegration>;
|
|
1255
1369
|
gerrit: ScmIntegrationsGroup<GerritIntegration>;
|
|
1256
|
-
github: ScmIntegrationsGroup<
|
|
1370
|
+
github: ScmIntegrationsGroup<GithubIntegration>;
|
|
1257
1371
|
gitlab: ScmIntegrationsGroup<GitLabIntegration>;
|
|
1372
|
+
gitea: ScmIntegrationsGroup<GiteaIntegration>;
|
|
1258
1373
|
}
|
|
1259
1374
|
/**
|
|
1260
1375
|
* Exposes the set of supported integrations.
|
|
@@ -1274,8 +1389,9 @@ declare class ScmIntegrations implements ScmIntegrationRegistry {
|
|
|
1274
1389
|
get bitbucketCloud(): ScmIntegrationsGroup<BitbucketCloudIntegration>;
|
|
1275
1390
|
get bitbucketServer(): ScmIntegrationsGroup<BitbucketServerIntegration>;
|
|
1276
1391
|
get gerrit(): ScmIntegrationsGroup<GerritIntegration>;
|
|
1277
|
-
get github(): ScmIntegrationsGroup<
|
|
1392
|
+
get github(): ScmIntegrationsGroup<GithubIntegration>;
|
|
1278
1393
|
get gitlab(): ScmIntegrationsGroup<GitLabIntegration>;
|
|
1394
|
+
get gitea(): ScmIntegrationsGroup<GiteaIntegration>;
|
|
1279
1395
|
list(): ScmIntegration[];
|
|
1280
1396
|
byUrl(url: string | URL): ScmIntegration | undefined;
|
|
1281
1397
|
byHost(host: string): ScmIntegration | undefined;
|
|
@@ -1287,4 +1403,4 @@ declare class ScmIntegrations implements ScmIntegrationRegistry {
|
|
|
1287
1403
|
resolveEditUrl(url: string): string;
|
|
1288
1404
|
}
|
|
1289
1405
|
|
|
1290
|
-
export { AwsS3Integration, AwsS3IntegrationConfig, AzureIntegration, AzureIntegrationConfig, BitbucketCloudIntegration, BitbucketCloudIntegrationConfig, BitbucketIntegration, BitbucketIntegrationConfig, BitbucketServerIntegration, BitbucketServerIntegrationConfig, DefaultGithubCredentialsProvider, GerritIntegration, GerritIntegrationConfig, GitHubIntegration, GitHubIntegrationConfig, GitLabIntegration, GitLabIntegrationConfig, GithubAppConfig, GithubAppCredentialsMux, GithubCredentialType, GithubCredentials, GithubCredentialsProvider, GoogleGcsIntegrationConfig, IntegrationsByType, ScmIntegration, ScmIntegrationRegistry, ScmIntegrations, ScmIntegrationsFactory, ScmIntegrationsGroup, SingleInstanceGithubCredentialsProvider, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketCloudDefaultBranch, getBitbucketCloudDownloadUrl, getBitbucketCloudFileFetchUrl, getBitbucketCloudRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getBitbucketServerDefaultBranch, getBitbucketServerDownloadUrl, getBitbucketServerFileFetchUrl, getBitbucketServerRequestOptions, getGerritBranchApiUrl, getGerritCloneRepoUrl, getGerritFileContentsApiUrl, getGerritProjectsApiUrl, getGerritRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabIntegrationRelativePath, getGitLabRequestOptions, parseGerritGitilesUrl, parseGerritJsonResponse, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readBitbucketServerIntegrationConfig, readBitbucketServerIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType, replaceGitLabUrlType };
|
|
1406
|
+
export { AwsS3Integration, AwsS3IntegrationConfig, AzureIntegration, AzureIntegrationConfig, BitbucketCloudIntegration, BitbucketCloudIntegrationConfig, BitbucketIntegration, BitbucketIntegrationConfig, BitbucketServerIntegration, BitbucketServerIntegrationConfig, DefaultGithubCredentialsProvider, GerritIntegration, GerritIntegrationConfig, GitHubIntegration, GitHubIntegrationConfig, GitLabIntegration, GitLabIntegrationConfig, GiteaIntegration, GiteaIntegrationConfig, GithubAppConfig, GithubAppCredentialsMux, GithubCredentialType, GithubCredentials, GithubCredentialsProvider, GithubIntegration, GithubIntegrationConfig, GoogleGcsIntegrationConfig, IntegrationsByType, ScmIntegration, ScmIntegrationRegistry, ScmIntegrations, ScmIntegrationsFactory, ScmIntegrationsGroup, SingleInstanceGithubCredentialsProvider, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketCloudDefaultBranch, getBitbucketCloudDownloadUrl, getBitbucketCloudFileFetchUrl, getBitbucketCloudRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getBitbucketServerDefaultBranch, getBitbucketServerDownloadUrl, getBitbucketServerFileFetchUrl, getBitbucketServerRequestOptions, getGerritBranchApiUrl, getGerritCloneRepoUrl, getGerritFileContentsApiUrl, getGerritProjectsApiUrl, getGerritRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabIntegrationRelativePath, getGitLabRequestOptions, getGiteaFileContentsUrl, getGiteaRequestOptions, getGithubFileFetchUrl, parseGerritGitilesUrl, parseGerritJsonResponse, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readBitbucketServerIntegrationConfig, readBitbucketServerIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGiteaConfig, readGithubIntegrationConfig, readGithubIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType, replaceGitLabUrlType, replaceGithubUrlType };
|
package/dist/index.esm.js
CHANGED
|
@@ -889,7 +889,7 @@ function parseGerritGitilesUrl(config, url) {
|
|
|
889
889
|
project
|
|
890
890
|
};
|
|
891
891
|
}
|
|
892
|
-
function
|
|
892
|
+
function buildGerritGitilesUrl(config, project, branch, filePath) {
|
|
893
893
|
return `${config.gitilesBaseUrl}/${project}/+/refs/heads/${branch}/${trimStart(filePath, "/")}`;
|
|
894
894
|
}
|
|
895
895
|
function getAuthenticationPrefix(config) {
|
|
@@ -961,7 +961,7 @@ const _GerritIntegration = class {
|
|
|
961
961
|
let updated;
|
|
962
962
|
if (url.startsWith("/")) {
|
|
963
963
|
const { branch, project } = parseGerritGitilesUrl(this.config, base);
|
|
964
|
-
return
|
|
964
|
+
return buildGerritGitilesUrl(this.config, project, branch, url);
|
|
965
965
|
}
|
|
966
966
|
if (url) {
|
|
967
967
|
updated = new URL(url, base);
|
|
@@ -989,10 +989,101 @@ GerritIntegration.factory = ({ config }) => {
|
|
|
989
989
|
);
|
|
990
990
|
};
|
|
991
991
|
|
|
992
|
+
function readGiteaConfig(config) {
|
|
993
|
+
const host = config.getString("host");
|
|
994
|
+
let baseUrl = config.getOptionalString("baseUrl");
|
|
995
|
+
const username = config.getOptionalString("username");
|
|
996
|
+
const password = config.getOptionalString("password");
|
|
997
|
+
if (!isValidHost(host)) {
|
|
998
|
+
throw new Error(
|
|
999
|
+
`Invalid Gitea integration config, '${host}' is not a valid host`
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
if (baseUrl) {
|
|
1003
|
+
baseUrl = trimEnd(baseUrl, "/");
|
|
1004
|
+
} else {
|
|
1005
|
+
baseUrl = `https://${host}`;
|
|
1006
|
+
}
|
|
1007
|
+
return {
|
|
1008
|
+
host,
|
|
1009
|
+
baseUrl,
|
|
1010
|
+
username,
|
|
1011
|
+
password
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
function getGiteaEditContentsUrl(config, url) {
|
|
1016
|
+
var _a;
|
|
1017
|
+
try {
|
|
1018
|
+
const baseUrl = (_a = config.baseUrl) != null ? _a : `https://${config.host}`;
|
|
1019
|
+
const [_blank, owner, name, _src, _branch, ref, ...path] = url.replace(baseUrl, "").split("/");
|
|
1020
|
+
const pathWithoutSlash = path.join("/").replace(/^\//, "");
|
|
1021
|
+
return `${baseUrl}/${owner}/${name}/_edit/${ref}/${pathWithoutSlash}`;
|
|
1022
|
+
} catch (e) {
|
|
1023
|
+
throw new Error(`Incorrect URL: ${url}, ${e}`);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
function getGiteaFileContentsUrl(config, url) {
|
|
1027
|
+
var _a;
|
|
1028
|
+
try {
|
|
1029
|
+
const baseUrl = (_a = config.baseUrl) != null ? _a : `https://${config.host}`;
|
|
1030
|
+
const [_blank, owner, name, _src, _branch, ref, ...path] = url.replace(baseUrl, "").split("/");
|
|
1031
|
+
const pathWithoutSlash = path.join("/").replace(/^\//, "");
|
|
1032
|
+
return `${baseUrl}/api/v1/repos/${owner}/${name}/contents/${pathWithoutSlash}?ref=${ref}`;
|
|
1033
|
+
} catch (e) {
|
|
1034
|
+
throw new Error(`Incorrect URL: ${url}, ${e}`);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
function getGiteaRequestOptions(config) {
|
|
1038
|
+
const headers = {};
|
|
1039
|
+
const { username, password } = config;
|
|
1040
|
+
if (!password) {
|
|
1041
|
+
return headers;
|
|
1042
|
+
}
|
|
1043
|
+
if (username) {
|
|
1044
|
+
headers.Authorization = `basic ${Buffer.from(
|
|
1045
|
+
`${username}:${password}`
|
|
1046
|
+
).toString("base64")}`;
|
|
1047
|
+
} else {
|
|
1048
|
+
headers.Authorization = `token ${password}`;
|
|
1049
|
+
}
|
|
1050
|
+
return {
|
|
1051
|
+
headers
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
const _GiteaIntegration = class {
|
|
1056
|
+
constructor(config) {
|
|
1057
|
+
this.config = config;
|
|
1058
|
+
}
|
|
1059
|
+
get type() {
|
|
1060
|
+
return "gitea";
|
|
1061
|
+
}
|
|
1062
|
+
get title() {
|
|
1063
|
+
return this.config.host;
|
|
1064
|
+
}
|
|
1065
|
+
resolveUrl(options) {
|
|
1066
|
+
return defaultScmResolveUrl(options);
|
|
1067
|
+
}
|
|
1068
|
+
resolveEditUrl(url) {
|
|
1069
|
+
return getGiteaEditContentsUrl(this.config, url);
|
|
1070
|
+
}
|
|
1071
|
+
};
|
|
1072
|
+
let GiteaIntegration = _GiteaIntegration;
|
|
1073
|
+
GiteaIntegration.factory = ({ config }) => {
|
|
1074
|
+
var _a;
|
|
1075
|
+
const configs = (_a = config.getOptionalConfigArray("integrations.gitea")) != null ? _a : [];
|
|
1076
|
+
const giteaConfigs = configs.map((c) => readGiteaConfig(c));
|
|
1077
|
+
return basicIntegrations(
|
|
1078
|
+
giteaConfigs.map((c) => new _GiteaIntegration(c)),
|
|
1079
|
+
(gitea) => gitea.config.host
|
|
1080
|
+
);
|
|
1081
|
+
};
|
|
1082
|
+
|
|
992
1083
|
const GITHUB_HOST = "github.com";
|
|
993
1084
|
const GITHUB_API_BASE_URL = "https://api.github.com";
|
|
994
1085
|
const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com";
|
|
995
|
-
function
|
|
1086
|
+
function readGithubIntegrationConfig(config) {
|
|
996
1087
|
var _a, _b;
|
|
997
1088
|
const host = (_a = config.getOptionalString("host")) != null ? _a : GITHUB_HOST;
|
|
998
1089
|
let apiBaseUrl = config.getOptionalString("apiBaseUrl");
|
|
@@ -1025,8 +1116,8 @@ function readGitHubIntegrationConfig(config) {
|
|
|
1025
1116
|
}
|
|
1026
1117
|
return { host, apiBaseUrl, rawBaseUrl, token, apps };
|
|
1027
1118
|
}
|
|
1028
|
-
function
|
|
1029
|
-
const result = configs.map(
|
|
1119
|
+
function readGithubIntegrationConfigs(configs) {
|
|
1120
|
+
const result = configs.map(readGithubIntegrationConfig);
|
|
1030
1121
|
if (!result.some((c) => c.host === GITHUB_HOST)) {
|
|
1031
1122
|
result.push({
|
|
1032
1123
|
host: GITHUB_HOST,
|
|
@@ -1037,7 +1128,7 @@ function readGitHubIntegrationConfigs(configs) {
|
|
|
1037
1128
|
return result;
|
|
1038
1129
|
}
|
|
1039
1130
|
|
|
1040
|
-
function
|
|
1131
|
+
function getGithubFileFetchUrl(url, config, credentials) {
|
|
1041
1132
|
try {
|
|
1042
1133
|
const { owner, name, ref, filepathtype, filepath } = parseGitUrl(url);
|
|
1043
1134
|
if (!owner || !name || !ref || filepathtype !== "blob" && filepathtype !== "raw" && filepathtype !== "tree") {
|
|
@@ -1271,7 +1362,7 @@ class DefaultGithubCredentialsProvider {
|
|
|
1271
1362
|
}
|
|
1272
1363
|
}
|
|
1273
1364
|
|
|
1274
|
-
const
|
|
1365
|
+
const _GithubIntegration = class {
|
|
1275
1366
|
constructor(integrationConfig) {
|
|
1276
1367
|
this.integrationConfig = integrationConfig;
|
|
1277
1368
|
}
|
|
@@ -1285,24 +1376,24 @@ const _GitHubIntegration = class {
|
|
|
1285
1376
|
return this.integrationConfig;
|
|
1286
1377
|
}
|
|
1287
1378
|
resolveUrl(options) {
|
|
1288
|
-
return
|
|
1379
|
+
return replaceGithubUrlType(defaultScmResolveUrl(options), "tree");
|
|
1289
1380
|
}
|
|
1290
1381
|
resolveEditUrl(url) {
|
|
1291
|
-
return
|
|
1382
|
+
return replaceGithubUrlType(url, "edit");
|
|
1292
1383
|
}
|
|
1293
1384
|
};
|
|
1294
|
-
let
|
|
1295
|
-
|
|
1385
|
+
let GithubIntegration = _GithubIntegration;
|
|
1386
|
+
GithubIntegration.factory = ({ config }) => {
|
|
1296
1387
|
var _a;
|
|
1297
|
-
const configs =
|
|
1388
|
+
const configs = readGithubIntegrationConfigs(
|
|
1298
1389
|
(_a = config.getOptionalConfigArray("integrations.github")) != null ? _a : []
|
|
1299
1390
|
);
|
|
1300
1391
|
return basicIntegrations(
|
|
1301
|
-
configs.map((c) => new
|
|
1392
|
+
configs.map((c) => new _GithubIntegration(c)),
|
|
1302
1393
|
(i) => i.config.host
|
|
1303
1394
|
);
|
|
1304
1395
|
};
|
|
1305
|
-
function
|
|
1396
|
+
function replaceGithubUrlType(url, type) {
|
|
1306
1397
|
return url.replace(
|
|
1307
1398
|
/\/\/([^/]+)\/([^/]+)\/([^/]+)\/(blob|tree|edit)\//,
|
|
1308
1399
|
(_, host, owner, repo) => {
|
|
@@ -1311,6 +1402,20 @@ function replaceGitHubUrlType(url, type) {
|
|
|
1311
1402
|
);
|
|
1312
1403
|
}
|
|
1313
1404
|
|
|
1405
|
+
const getGitHubFileFetchUrl = getGithubFileFetchUrl;
|
|
1406
|
+
class GitHubIntegration extends GithubIntegration {
|
|
1407
|
+
constructor(integrationConfig) {
|
|
1408
|
+
super(integrationConfig);
|
|
1409
|
+
}
|
|
1410
|
+
get config() {
|
|
1411
|
+
return super.config;
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
GitHubIntegration.factory = GithubIntegration.factory;
|
|
1415
|
+
const readGitHubIntegrationConfig = readGithubIntegrationConfig;
|
|
1416
|
+
const readGitHubIntegrationConfigs = readGithubIntegrationConfigs;
|
|
1417
|
+
const replaceGitHubUrlType = replaceGithubUrlType;
|
|
1418
|
+
|
|
1314
1419
|
const GITLAB_HOST = "gitlab.com";
|
|
1315
1420
|
const GITLAB_API_BASE_URL = "https://gitlab.com/api/v4";
|
|
1316
1421
|
function readGitLabIntegrationConfig(config) {
|
|
@@ -1482,8 +1587,9 @@ class ScmIntegrations {
|
|
|
1482
1587
|
bitbucketCloud: BitbucketCloudIntegration.factory({ config }),
|
|
1483
1588
|
bitbucketServer: BitbucketServerIntegration.factory({ config }),
|
|
1484
1589
|
gerrit: GerritIntegration.factory({ config }),
|
|
1485
|
-
github:
|
|
1486
|
-
gitlab: GitLabIntegration.factory({ config })
|
|
1590
|
+
github: GithubIntegration.factory({ config }),
|
|
1591
|
+
gitlab: GitLabIntegration.factory({ config }),
|
|
1592
|
+
gitea: GiteaIntegration.factory({ config })
|
|
1487
1593
|
});
|
|
1488
1594
|
}
|
|
1489
1595
|
constructor(integrationsByType) {
|
|
@@ -1513,6 +1619,9 @@ class ScmIntegrations {
|
|
|
1513
1619
|
get gitlab() {
|
|
1514
1620
|
return this.byType.gitlab;
|
|
1515
1621
|
}
|
|
1622
|
+
get gitea() {
|
|
1623
|
+
return this.byType.gitea;
|
|
1624
|
+
}
|
|
1516
1625
|
list() {
|
|
1517
1626
|
return Object.values(this.byType).flatMap(
|
|
1518
1627
|
(i) => i.list()
|
|
@@ -1549,5 +1658,5 @@ class ScmIntegrations {
|
|
|
1549
1658
|
}
|
|
1550
1659
|
}
|
|
1551
1660
|
|
|
1552
|
-
export { AwsS3Integration, AzureIntegration, BitbucketCloudIntegration, BitbucketIntegration, BitbucketServerIntegration, DefaultGithubCredentialsProvider, GerritIntegration, GitHubIntegration, GitLabIntegration, GithubAppCredentialsMux, ScmIntegrations, SingleInstanceGithubCredentialsProvider, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketCloudDefaultBranch, getBitbucketCloudDownloadUrl, getBitbucketCloudFileFetchUrl, getBitbucketCloudRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getBitbucketServerDefaultBranch, getBitbucketServerDownloadUrl, getBitbucketServerFileFetchUrl, getBitbucketServerRequestOptions, getGerritBranchApiUrl, getGerritCloneRepoUrl, getGerritFileContentsApiUrl, getGerritProjectsApiUrl, getGerritRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabIntegrationRelativePath, getGitLabRequestOptions, parseGerritGitilesUrl, parseGerritJsonResponse, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readBitbucketServerIntegrationConfig, readBitbucketServerIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType, replaceGitLabUrlType };
|
|
1661
|
+
export { AwsS3Integration, AzureIntegration, BitbucketCloudIntegration, BitbucketIntegration, BitbucketServerIntegration, DefaultGithubCredentialsProvider, GerritIntegration, GitHubIntegration, GitLabIntegration, GiteaIntegration, GithubAppCredentialsMux, GithubIntegration, ScmIntegrations, SingleInstanceGithubCredentialsProvider, defaultScmResolveUrl, getAzureCommitsUrl, getAzureDownloadUrl, getAzureFileFetchUrl, getAzureRequestOptions, getBitbucketCloudDefaultBranch, getBitbucketCloudDownloadUrl, getBitbucketCloudFileFetchUrl, getBitbucketCloudRequestOptions, getBitbucketDefaultBranch, getBitbucketDownloadUrl, getBitbucketFileFetchUrl, getBitbucketRequestOptions, getBitbucketServerDefaultBranch, getBitbucketServerDownloadUrl, getBitbucketServerFileFetchUrl, getBitbucketServerRequestOptions, getGerritBranchApiUrl, getGerritCloneRepoUrl, getGerritFileContentsApiUrl, getGerritProjectsApiUrl, getGerritRequestOptions, getGitHubFileFetchUrl, getGitHubRequestOptions, getGitLabFileFetchUrl, getGitLabIntegrationRelativePath, getGitLabRequestOptions, getGiteaFileContentsUrl, getGiteaRequestOptions, getGithubFileFetchUrl, parseGerritGitilesUrl, parseGerritJsonResponse, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readBitbucketServerIntegrationConfig, readBitbucketServerIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGiteaConfig, readGithubIntegrationConfig, readGithubIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType, replaceGitLabUrlType, replaceGithubUrlType };
|
|
1553
1662
|
//# sourceMappingURL=index.esm.js.map
|