@backstage/integration 1.3.0-next.0 → 1.3.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 CHANGED
@@ -1,5 +1,39 @@
1
1
  # @backstage/integration
2
2
 
3
+ ## 1.3.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - bf5e9030eb: Updated dependency `msw` to `^0.45.0`.
8
+
9
+ ## 1.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 593dea6710: Add support for Basic Auth for Bitbucket Server.
14
+ - ad35364e97: feat(techdocs): add edit button support for bitbucketServer
15
+
16
+ ### Patch Changes
17
+
18
+ - 163243a4d1: Handle incorrect return type from Octokit paginate plugin to resolve reading URLs from GitHub
19
+ - c4b460a47d: Avoid double encoding of the file path in `getBitbucketDownloadUrl`
20
+ - 29f782eb37: Updated dependency `@types/luxon` to `^3.0.0`.
21
+ - 1f27d83933: Fixed bug in getGitLabFileFetchUrl where a target whose path did not contain the
22
+ `/-/` scope would result in a fetch URL that did not support
23
+ private-token-based authentication.
24
+
25
+ ## 1.3.0-next.1
26
+
27
+ ### Minor Changes
28
+
29
+ - ad35364e97: feat(techdocs): add edit button support for bitbucketServer
30
+
31
+ ### Patch Changes
32
+
33
+ - 1f27d83933: Fixed bug in getGitLabFileFetchUrl where a target whose path did not contain the
34
+ `/-/` scope would result in a fetch URL that did not support
35
+ private-token-based authentication.
36
+
3
37
  ## 1.3.0-next.0
4
38
 
5
39
  ### Minor Changes
package/dist/index.cjs.js CHANGED
@@ -8,7 +8,6 @@ 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');
12
11
 
13
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
13
 
@@ -742,19 +741,16 @@ const _BitbucketServerIntegration = class {
742
741
  const resolved = defaultScmResolveUrl(options);
743
742
  if (options.lineNumber) {
744
743
  const url = new URL(resolved);
745
- const filename = url.pathname.split("/").slice(-1)[0];
746
- url.hash = `${filename}-${options.lineNumber}`;
744
+ url.hash = options.lineNumber.toString();
747
745
  return url.toString();
748
746
  }
749
747
  return resolved;
750
748
  }
751
749
  resolveEditUrl(url) {
752
- const urlData = parseGitUrl__default["default"](url);
753
- const editUrl = new URL(url);
754
- editUrl.searchParams.set("mode", "edit");
755
- editUrl.searchParams.set("spa", "0");
756
- editUrl.searchParams.set("at", urlData.ref);
757
- return editUrl.toString();
750
+ if (url.includes("?")) {
751
+ return url.substring(0, url.indexOf("?"));
752
+ }
753
+ return url;
758
754
  }
759
755
  };
760
756
  let BitbucketServerIntegration = _BitbucketServerIntegration;
@@ -1367,11 +1363,8 @@ function getGitLabIntegrationRelativePath(config) {
1367
1363
  }
1368
1364
 
1369
1365
  async function getGitLabFileFetchUrl(url, config) {
1370
- if (url.includes("/-/blob/")) {
1371
- const projectID = await getProjectId(url, config);
1372
- return buildProjectUrl(url, projectID, config).toString();
1373
- }
1374
- return buildRawUrl(url).toString();
1366
+ const projectID = await getProjectId(url, config);
1367
+ return buildProjectUrl(url, projectID, config).toString();
1375
1368
  }
1376
1369
  function getGitLabRequestOptions(config) {
1377
1370
  const { token = "" } = config;
@@ -1381,29 +1374,10 @@ function getGitLabRequestOptions(config) {
1381
1374
  }
1382
1375
  };
1383
1376
  }
1384
- function buildRawUrl(target) {
1385
- try {
1386
- const url = new URL(target);
1387
- const splitPath = url.pathname.split("/").filter(Boolean);
1388
- const blobIndex = splitPath.indexOf("blob", 2);
1389
- if (blobIndex < 2 || blobIndex === splitPath.length - 1) {
1390
- throw new errors.InputError("Wrong GitLab URL");
1391
- }
1392
- const repoPath = splitPath.slice(0, blobIndex);
1393
- const restOfPath = splitPath.slice(blobIndex + 1);
1394
- if (!restOfPath.join("/").match(/\.(yaml|yml)$/)) {
1395
- throw new errors.InputError("Wrong GitLab URL");
1396
- }
1397
- url.pathname = [...repoPath, "raw", ...restOfPath].join("/");
1398
- return url;
1399
- } catch (e) {
1400
- throw new errors.InputError(`Incorrect url: ${target}, ${e}`);
1401
- }
1402
- }
1403
1377
  function buildProjectUrl(target, projectID, config) {
1404
1378
  try {
1405
1379
  const url = new URL(target);
1406
- const branchAndFilePath = url.pathname.split("/-/blob/")[1];
1380
+ const branchAndFilePath = url.pathname.split("/blob/").slice(1).join("/blob/");
1407
1381
  const [branch, ...filePath] = branchAndFilePath.split("/");
1408
1382
  const relativePath = getGitLabIntegrationRelativePath(config);
1409
1383
  url.pathname = [
@@ -1422,11 +1396,11 @@ function buildProjectUrl(target, projectID, config) {
1422
1396
  }
1423
1397
  async function getProjectId(target, config) {
1424
1398
  const url = new URL(target);
1425
- if (!url.pathname.includes("/-/blob/")) {
1399
+ if (!url.pathname.includes("/blob/")) {
1426
1400
  throw new Error("Please provide full path to yaml file from GitLab");
1427
1401
  }
1428
1402
  try {
1429
- let repo = url.pathname.split("/-/blob/")[0];
1403
+ let repo = url.pathname.split("/-/blob/")[0].split("/blob/")[0];
1430
1404
  const relativePath = getGitLabIntegrationRelativePath(config);
1431
1405
  if (relativePath) {
1432
1406
  repo = repo.replace(relativePath, "");
@@ -1545,7 +1519,16 @@ class ScmIntegrations {
1545
1519
  );
1546
1520
  }
1547
1521
  byUrl(url) {
1548
- return Object.values(this.byType).map((i) => i.byUrl(url)).find(Boolean);
1522
+ let candidates = Object.values(this.byType).map((i) => i.byUrl(url)).filter(Boolean);
1523
+ if (candidates.length > 1) {
1524
+ const filteredCandidates = candidates.filter(
1525
+ (x) => !(x instanceof BitbucketIntegration)
1526
+ );
1527
+ if (filteredCandidates.length !== 0) {
1528
+ candidates = filteredCandidates;
1529
+ }
1530
+ }
1531
+ return candidates[0];
1549
1532
  }
1550
1533
  byHost(host) {
1551
1534
  return Object.values(this.byType).map((i) => i.byHost(host)).find(Boolean);