@backstage/integration 1.2.2-next.1 → 1.2.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 +46 -0
- package/dist/index.cjs.js +21 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.esm.js +21 -8
- package/dist/index.esm.js.map +1 -1
- package/package.json +11 -11
package/dist/index.d.ts
CHANGED
|
@@ -975,6 +975,14 @@ declare function readGitLabIntegrationConfig(config: Config): GitLabIntegrationC
|
|
|
975
975
|
* @public
|
|
976
976
|
*/
|
|
977
977
|
declare function readGitLabIntegrationConfigs(configs: Config[]): GitLabIntegrationConfig[];
|
|
978
|
+
/**
|
|
979
|
+
* Reads a GitLab integration config, and returns
|
|
980
|
+
* relative path.
|
|
981
|
+
*
|
|
982
|
+
* @param config - GitLabIntegrationConfig object
|
|
983
|
+
* @public
|
|
984
|
+
*/
|
|
985
|
+
declare function getGitLabIntegrationRelativePath(config: GitLabIntegrationConfig): string;
|
|
978
986
|
|
|
979
987
|
/**
|
|
980
988
|
* A GitLab based integration.
|
|
@@ -1263,4 +1271,4 @@ declare class ScmIntegrations implements ScmIntegrationRegistry {
|
|
|
1263
1271
|
resolveEditUrl(url: string): string;
|
|
1264
1272
|
}
|
|
1265
1273
|
|
|
1266
|
-
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, getGitLabRequestOptions, parseGerritGitilesUrl, parseGerritJsonResponse, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readBitbucketServerIntegrationConfig, readBitbucketServerIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType, replaceGitLabUrlType };
|
|
1274
|
+
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 };
|
package/dist/index.esm.js
CHANGED
|
@@ -730,7 +730,7 @@ async function getBitbucketServerDownloadUrl(url, config) {
|
|
|
730
730
|
if (!branch) {
|
|
731
731
|
branch = await getBitbucketServerDefaultBranch(url, config);
|
|
732
732
|
}
|
|
733
|
-
const path = filepath ? `&path=${encodeURIComponent(filepath)}` : "";
|
|
733
|
+
const path = filepath ? `&path=${encodeURIComponent(decodeURIComponent(filepath))}` : "";
|
|
734
734
|
return `${config.apiBaseUrl}/projects/${project}/repos/${repoName}/archive?format=tgz&at=${branch}&prefix=${project}-${repoName}${path}`;
|
|
735
735
|
}
|
|
736
736
|
function getBitbucketServerFileFetchUrl(url, config) {
|
|
@@ -1038,7 +1038,7 @@ class GithubAppManager {
|
|
|
1038
1038
|
auth: result.data.token
|
|
1039
1039
|
});
|
|
1040
1040
|
const repos = await installationClient.paginate(installationClient.apps.listReposAccessibleToInstallation);
|
|
1041
|
-
const hasRepo = repos.some((repository) => {
|
|
1041
|
+
const hasRepo = repos.repositories.some((repository) => {
|
|
1042
1042
|
return repository.name === repo;
|
|
1043
1043
|
});
|
|
1044
1044
|
if (!hasRepo) {
|
|
@@ -1218,11 +1218,18 @@ function readGitLabIntegrationConfigs(configs) {
|
|
|
1218
1218
|
}
|
|
1219
1219
|
return result;
|
|
1220
1220
|
}
|
|
1221
|
+
function getGitLabIntegrationRelativePath(config) {
|
|
1222
|
+
let relativePath = "";
|
|
1223
|
+
if (config.host !== GITLAB_HOST) {
|
|
1224
|
+
relativePath = new URL(config.baseUrl).pathname;
|
|
1225
|
+
}
|
|
1226
|
+
return trimEnd(relativePath, "/");
|
|
1227
|
+
}
|
|
1221
1228
|
|
|
1222
1229
|
async function getGitLabFileFetchUrl(url, config) {
|
|
1223
1230
|
if (url.includes("/-/blob/")) {
|
|
1224
1231
|
const projectID = await getProjectId(url, config);
|
|
1225
|
-
return buildProjectUrl(url, projectID).toString();
|
|
1232
|
+
return buildProjectUrl(url, projectID, config).toString();
|
|
1226
1233
|
}
|
|
1227
1234
|
return buildRawUrl(url).toString();
|
|
1228
1235
|
}
|
|
@@ -1253,13 +1260,15 @@ function buildRawUrl(target) {
|
|
|
1253
1260
|
throw new InputError(`Incorrect url: ${target}, ${e}`);
|
|
1254
1261
|
}
|
|
1255
1262
|
}
|
|
1256
|
-
function buildProjectUrl(target, projectID) {
|
|
1263
|
+
function buildProjectUrl(target, projectID, config) {
|
|
1257
1264
|
try {
|
|
1258
1265
|
const url = new URL(target);
|
|
1259
1266
|
const branchAndFilePath = url.pathname.split("/-/blob/")[1];
|
|
1260
1267
|
const [branch, ...filePath] = branchAndFilePath.split("/");
|
|
1268
|
+
const relativePath = getGitLabIntegrationRelativePath(config);
|
|
1261
1269
|
url.pathname = [
|
|
1262
|
-
|
|
1270
|
+
...relativePath ? [relativePath] : [],
|
|
1271
|
+
"api/v4/projects",
|
|
1263
1272
|
projectID,
|
|
1264
1273
|
"repository/files",
|
|
1265
1274
|
encodeURIComponent(decodeURIComponent(filePath.join("/"))),
|
|
@@ -1277,8 +1286,12 @@ async function getProjectId(target, config) {
|
|
|
1277
1286
|
throw new Error("Please provide full path to yaml file from GitLab");
|
|
1278
1287
|
}
|
|
1279
1288
|
try {
|
|
1280
|
-
|
|
1281
|
-
const
|
|
1289
|
+
let repo = url.pathname.split("/-/blob/")[0];
|
|
1290
|
+
const relativePath = getGitLabIntegrationRelativePath(config);
|
|
1291
|
+
if (relativePath) {
|
|
1292
|
+
repo = repo.replace(relativePath, "");
|
|
1293
|
+
}
|
|
1294
|
+
const repoIDLookup = new URL(`${url.origin}${relativePath}/api/v4/projects/${encodeURIComponent(repo.replace(/^\//, ""))}`);
|
|
1282
1295
|
const response = await fetch(repoIDLookup.toString(), getGitLabRequestOptions(config));
|
|
1283
1296
|
const data = await response.json();
|
|
1284
1297
|
if (!response.ok) {
|
|
@@ -1397,5 +1410,5 @@ class ScmIntegrations {
|
|
|
1397
1410
|
}
|
|
1398
1411
|
}
|
|
1399
1412
|
|
|
1400
|
-
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, getGitLabRequestOptions, parseGerritGitilesUrl, parseGerritJsonResponse, readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs, readAzureIntegrationConfig, readAzureIntegrationConfigs, readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs, readBitbucketIntegrationConfig, readBitbucketIntegrationConfigs, readBitbucketServerIntegrationConfig, readBitbucketServerIntegrationConfigs, readGerritIntegrationConfig, readGerritIntegrationConfigs, readGitHubIntegrationConfig, readGitHubIntegrationConfigs, readGitLabIntegrationConfig, readGitLabIntegrationConfigs, readGoogleGcsIntegrationConfig, replaceGitHubUrlType, replaceGitLabUrlType };
|
|
1413
|
+
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 };
|
|
1401
1414
|
//# sourceMappingURL=index.esm.js.map
|