@backstage/plugin-scaffolder-backend-module-gitlab 0.9.4-next.0 → 0.9.4-next.1

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,11 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-gitlab
2
2
 
3
+ ## 0.9.4-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 5bb870b: Show additional information about the cause in error messages from GitLab
8
+
3
9
  ## 0.9.4-next.0
4
10
 
5
11
  ### Patch Changes
@@ -26,7 +26,12 @@ function createGitlabApi(options) {
26
26
  function isGitlabError(e) {
27
27
  return errors.isError(e) && "description" in e && typeof e.description === "string";
28
28
  }
29
+ function isGitbeakerRequestError(e) {
30
+ return errors.isError(e) && e.name === "GitbeakerRequestError";
31
+ }
29
32
  function getErrorMessage(e) {
33
+ if (isGitbeakerRequestError(e) && e.cause)
34
+ return `${e} - ${e.cause.description}`;
30
35
  if (isGitlabError(e)) return `${e} - ${e.description}`;
31
36
  return String(e);
32
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.cjs.js","sources":["../../src/actions/helpers.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { parseRepoUrl } from '@backstage/plugin-scaffolder-node';\nimport { ErrorLike, InputError, isError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Gitlab } from '@gitbeaker/rest';\n\nexport function createGitlabApi(options: {\n integrations: ScmIntegrationRegistry;\n token?: string;\n repoUrl: string;\n}): InstanceType<typeof Gitlab> {\n const { integrations, token: providedToken, repoUrl } = options;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n if (!integrationConfig.config.token && !providedToken) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const token = providedToken ?? integrationConfig.config.token!;\n const tokenType = providedToken ? 'oauthToken' : 'token';\n\n return new Gitlab({\n host: integrationConfig.config.baseUrl,\n [tokenType]: token,\n });\n}\n\ninterface GitlabError extends ErrorLike {\n // Errors from Gitlab may also include a description field that contains additional info\n description: string;\n}\n\nfunction isGitlabError(e: unknown): e is GitlabError {\n return isError(e) && 'description' in e && typeof e.description === 'string';\n}\n\nexport function getErrorMessage(e: unknown): string {\n if (isGitlabError(e)) return `${e} - ${e.description}`;\n return String(e);\n}\n"],"names":["parseRepoUrl","InputError","Gitlab","isError"],"mappings":";;;;;;AAoBO,SAAS,gBAAgB,OAIA,EAAA;AAC9B,EAAA,MAAM,EAAE,YAAA,EAAc,KAAO,EAAA,aAAA,EAAe,SAAY,GAAA,OAAA;AAExD,EAAA,MAAM,EAAE,IAAA,EAAS,GAAAA,iCAAA,CAAa,SAAS,YAAY,CAAA;AAEnD,EAAA,MAAM,iBAAoB,GAAA,YAAA,CAAa,MAAO,CAAA,MAAA,CAAO,IAAI,CAAA;AAEzD,EAAA,IAAI,CAAC,iBAAmB,EAAA;AACtB,IAAA,MAAM,IAAIC,iBAAA;AAAA,MACR,kDAAkD,IAAI,CAAA,uCAAA;AAAA,KACxD;AAAA;AAGF,EAAA,IAAI,CAAC,iBAAA,CAAkB,MAAO,CAAA,KAAA,IAAS,CAAC,aAAe,EAAA;AACrD,IAAA,MAAM,IAAIA,iBAAA,CAAW,CAA+B,4BAAA,EAAA,IAAI,CAAE,CAAA,CAAA;AAAA;AAG5D,EAAM,MAAA,KAAA,GAAQ,aAAiB,IAAA,iBAAA,CAAkB,MAAO,CAAA,KAAA;AACxD,EAAM,MAAA,SAAA,GAAY,gBAAgB,YAAe,GAAA,OAAA;AAEjD,EAAA,OAAO,IAAIC,WAAO,CAAA;AAAA,IAChB,IAAA,EAAM,kBAAkB,MAAO,CAAA,OAAA;AAAA,IAC/B,CAAC,SAAS,GAAG;AAAA,GACd,CAAA;AACH;AAOA,SAAS,cAAc,CAA8B,EAAA;AACnD,EAAA,OAAOC,eAAQ,CAAC,CAAA,IAAK,iBAAiB,CAAK,IAAA,OAAO,EAAE,WAAgB,KAAA,QAAA;AACtE;AAEO,SAAS,gBAAgB,CAAoB,EAAA;AAClD,EAAI,IAAA,aAAA,CAAc,CAAC,CAAG,EAAA,OAAO,GAAG,CAAC,CAAA,GAAA,EAAM,EAAE,WAAW,CAAA,CAAA;AACpD,EAAA,OAAO,OAAO,CAAC,CAAA;AACjB;;;;;"}
1
+ {"version":3,"file":"helpers.cjs.js","sources":["../../src/actions/helpers.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { parseRepoUrl } from '@backstage/plugin-scaffolder-node';\nimport { ErrorLike, InputError, isError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { Gitlab } from '@gitbeaker/rest';\nimport { GitbeakerRequestError } from '@gitbeaker/requester-utils';\n\nexport function createGitlabApi(options: {\n integrations: ScmIntegrationRegistry;\n token?: string;\n repoUrl: string;\n}): InstanceType<typeof Gitlab> {\n const { integrations, token: providedToken, repoUrl } = options;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n if (!integrationConfig.config.token && !providedToken) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const token = providedToken ?? integrationConfig.config.token!;\n const tokenType = providedToken ? 'oauthToken' : 'token';\n\n return new Gitlab({\n host: integrationConfig.config.baseUrl,\n [tokenType]: token,\n });\n}\n\ninterface GitlabError extends ErrorLike {\n // Errors from Gitlab may also include a description field that contains additional info\n description: string;\n}\n\nfunction isGitlabError(e: unknown): e is GitlabError {\n return isError(e) && 'description' in e && typeof e.description === 'string';\n}\n\nfunction isGitbeakerRequestError(e: unknown): e is GitbeakerRequestError {\n return isError(e) && e.name === 'GitbeakerRequestError';\n}\n\nexport function getErrorMessage(e: unknown): string {\n if (isGitbeakerRequestError(e) && e.cause)\n return `${e} - ${e.cause.description}`;\n if (isGitlabError(e)) return `${e} - ${e.description}`;\n return String(e);\n}\n"],"names":["parseRepoUrl","InputError","Gitlab","isError"],"mappings":";;;;;;AAqBO,SAAS,gBAAgB,OAIA,EAAA;AAC9B,EAAA,MAAM,EAAE,YAAA,EAAc,KAAO,EAAA,aAAA,EAAe,SAAY,GAAA,OAAA;AAExD,EAAA,MAAM,EAAE,IAAA,EAAS,GAAAA,iCAAA,CAAa,SAAS,YAAY,CAAA;AAEnD,EAAA,MAAM,iBAAoB,GAAA,YAAA,CAAa,MAAO,CAAA,MAAA,CAAO,IAAI,CAAA;AAEzD,EAAA,IAAI,CAAC,iBAAmB,EAAA;AACtB,IAAA,MAAM,IAAIC,iBAAA;AAAA,MACR,kDAAkD,IAAI,CAAA,uCAAA;AAAA,KACxD;AAAA;AAGF,EAAA,IAAI,CAAC,iBAAA,CAAkB,MAAO,CAAA,KAAA,IAAS,CAAC,aAAe,EAAA;AACrD,IAAA,MAAM,IAAIA,iBAAA,CAAW,CAA+B,4BAAA,EAAA,IAAI,CAAE,CAAA,CAAA;AAAA;AAG5D,EAAM,MAAA,KAAA,GAAQ,aAAiB,IAAA,iBAAA,CAAkB,MAAO,CAAA,KAAA;AACxD,EAAM,MAAA,SAAA,GAAY,gBAAgB,YAAe,GAAA,OAAA;AAEjD,EAAA,OAAO,IAAIC,WAAO,CAAA;AAAA,IAChB,IAAA,EAAM,kBAAkB,MAAO,CAAA,OAAA;AAAA,IAC/B,CAAC,SAAS,GAAG;AAAA,GACd,CAAA;AACH;AAOA,SAAS,cAAc,CAA8B,EAAA;AACnD,EAAA,OAAOC,eAAQ,CAAC,CAAA,IAAK,iBAAiB,CAAK,IAAA,OAAO,EAAE,WAAgB,KAAA,QAAA;AACtE;AAEA,SAAS,wBAAwB,CAAwC,EAAA;AACvE,EAAA,OAAOA,cAAQ,CAAA,CAAC,CAAK,IAAA,CAAA,CAAE,IAAS,KAAA,uBAAA;AAClC;AAEO,SAAS,gBAAgB,CAAoB,EAAA;AAClD,EAAI,IAAA,uBAAA,CAAwB,CAAC,CAAA,IAAK,CAAE,CAAA,KAAA;AAClC,IAAA,OAAO,CAAG,EAAA,CAAC,CAAM,GAAA,EAAA,CAAA,CAAE,MAAM,WAAW,CAAA,CAAA;AACtC,EAAI,IAAA,aAAA,CAAc,CAAC,CAAG,EAAA,OAAO,GAAG,CAAC,CAAA,GAAA,EAAM,EAAE,WAAW,CAAA,CAAA;AACpD,EAAA,OAAO,OAAO,CAAC,CAAA;AACjB;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-gitlab",
3
- "version": "0.9.4-next.0",
3
+ "version": "0.9.4-next.1",
4
4
  "backstage": {
5
5
  "role": "backend-plugin-module",
6
6
  "pluginId": "scaffolder",
@@ -58,6 +58,7 @@
58
58
  "@backstage/errors": "1.2.7",
59
59
  "@backstage/integration": "1.17.1",
60
60
  "@backstage/plugin-scaffolder-node": "0.11.0-next.0",
61
+ "@gitbeaker/requester-utils": "^41.2.0",
61
62
  "@gitbeaker/rest": "^41.2.0",
62
63
  "luxon": "^3.0.0",
63
64
  "winston": "^3.2.1",
@@ -66,7 +67,7 @@
66
67
  },
67
68
  "devDependencies": {
68
69
  "@backstage/backend-test-utils": "1.7.1-next.0",
69
- "@backstage/cli": "0.33.2-next.0",
70
+ "@backstage/cli": "0.34.0-next.2",
70
71
  "@backstage/plugin-scaffolder-node-test-utils": "0.3.2-next.0"
71
72
  }
72
73
  }