@backstage-community/plugin-copilot-backend 0.1.4 → 0.1.6

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,31 @@
1
1
  # @backstage-community/plugin-copilot-backend
2
2
 
3
+ ## 0.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - f6d006d: Added support for specifying private GitHub tokens dedicated to the Copilot plugin. This is useful if you don't want to use the same token for both the Copilot backend and other GitHub integrations. To do this, you can specify a new GitHub integration using a string as the host:
8
+
9
+ ```diff
10
+ integrations:
11
+ github:
12
+ - host: github.com
13
+ token: your_token
14
+ + - host: your_copilot_private_token
15
+ + token: your_super_token
16
+ + apiBaseUrl: https://api.github.com
17
+ copilot:
18
+ - host: github.com
19
+ + host: your_copilot_private_token
20
+ enterprise: your_enterprise
21
+ ```
22
+
23
+ ## 0.1.5
24
+
25
+ ### Patch Changes
26
+
27
+ - e45e2f8: Remove unused @backstage/backend-common package from dependencies.
28
+
3
29
  ## 0.1.4
4
30
 
5
31
  ### Patch Changes
@@ -4,7 +4,6 @@ var integration = require('@backstage/integration');
4
4
 
5
5
  const getGithubInfo = async (config) => {
6
6
  const integrations = integration.ScmIntegrations.fromConfig(config);
7
- const credentialsProvider = integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations);
8
7
  const host = config.getString("copilot.host");
9
8
  const enterprise = config.getString("copilot.enterprise");
10
9
  if (!host) {
@@ -20,12 +19,11 @@ const getGithubInfo = async (config) => {
20
19
  );
21
20
  }
22
21
  const apiBaseUrl = githubConfig.apiBaseUrl ?? "https://api.github.com";
23
- const credentials = await credentialsProvider.getCredentials({
24
- url: apiBaseUrl
25
- });
26
- if (!credentials.headers) {
27
- throw new Error("Failed to retrieve credentials headers.");
28
- }
22
+ const credentials = {
23
+ type: "token",
24
+ headers: { Authorization: `Bearer ${githubConfig.token}` },
25
+ token: githubConfig.token
26
+ };
29
27
  return {
30
28
  apiBaseUrl,
31
29
  credentials,
@@ -1 +1 @@
1
- {"version":3,"file":"GithubUtils.cjs.js","sources":["../../src/utils/GithubUtils.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\n\nimport { Config } from '@backstage/config';\nimport {\n DefaultGithubCredentialsProvider,\n GithubCredentials,\n ScmIntegrations,\n} from '@backstage/integration';\n\nexport type GithubInfo = {\n credentials: GithubCredentials;\n apiBaseUrl: string;\n enterprise: string;\n};\n\nexport const getGithubInfo = async (config: Config): Promise<GithubInfo> => {\n const integrations = ScmIntegrations.fromConfig(config);\n const credentialsProvider =\n DefaultGithubCredentialsProvider.fromIntegrations(integrations);\n\n const host = config.getString('copilot.host');\n const enterprise = config.getString('copilot.enterprise');\n\n if (!host) {\n throw new Error('The host configuration is missing from the config.');\n }\n\n if (!enterprise) {\n throw new Error('The enterprise configuration is missing from the config.');\n }\n\n const githubConfig = integrations.github.byHost(host)?.config;\n\n if (!githubConfig) {\n throw new Error(\n `GitHub configuration for host \"${host}\" is missing or incomplete.`,\n );\n }\n\n const apiBaseUrl = githubConfig.apiBaseUrl ?? 'https://api.github.com';\n\n const credentials = await credentialsProvider.getCredentials({\n url: apiBaseUrl,\n });\n\n if (!credentials.headers) {\n throw new Error('Failed to retrieve credentials headers.');\n }\n\n return {\n apiBaseUrl,\n credentials,\n enterprise,\n };\n};\n"],"names":["ScmIntegrations","DefaultGithubCredentialsProvider"],"mappings":";;;;AA6Ba,MAAA,aAAA,GAAgB,OAAO,MAAwC,KAAA;AAC1E,EAAM,MAAA,YAAA,GAAeA,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA,CAAA;AACtD,EAAM,MAAA,mBAAA,GACJC,4CAAiC,CAAA,gBAAA,CAAiB,YAAY,CAAA,CAAA;AAEhE,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,cAAc,CAAA,CAAA;AAC5C,EAAM,MAAA,UAAA,GAAa,MAAO,CAAA,SAAA,CAAU,oBAAoB,CAAA,CAAA;AAExD,EAAA,IAAI,CAAC,IAAM,EAAA;AACT,IAAM,MAAA,IAAI,MAAM,oDAAoD,CAAA,CAAA;AAAA,GACtE;AAEA,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAM,MAAA,IAAI,MAAM,0DAA0D,CAAA,CAAA;AAAA,GAC5E;AAEA,EAAA,MAAM,YAAe,GAAA,YAAA,CAAa,MAAO,CAAA,MAAA,CAAO,IAAI,CAAG,EAAA,MAAA,CAAA;AAEvD,EAAA,IAAI,CAAC,YAAc,EAAA;AACjB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,kCAAkC,IAAI,CAAA,2BAAA,CAAA;AAAA,KACxC,CAAA;AAAA,GACF;AAEA,EAAM,MAAA,UAAA,GAAa,aAAa,UAAc,IAAA,wBAAA,CAAA;AAE9C,EAAM,MAAA,WAAA,GAAc,MAAM,mBAAA,CAAoB,cAAe,CAAA;AAAA,IAC3D,GAAK,EAAA,UAAA;AAAA,GACN,CAAA,CAAA;AAED,EAAI,IAAA,CAAC,YAAY,OAAS,EAAA;AACxB,IAAM,MAAA,IAAI,MAAM,yCAAyC,CAAA,CAAA;AAAA,GAC3D;AAEA,EAAO,OAAA;AAAA,IACL,UAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAA;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"GithubUtils.cjs.js","sources":["../../src/utils/GithubUtils.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\n\nimport { Config } from '@backstage/config';\nimport { GithubCredentials, ScmIntegrations } from '@backstage/integration';\n\nexport type GithubInfo = {\n credentials: GithubCredentials;\n apiBaseUrl: string;\n enterprise: string;\n};\n\nexport const getGithubInfo = async (config: Config): Promise<GithubInfo> => {\n const integrations = ScmIntegrations.fromConfig(config);\n\n const host = config.getString('copilot.host');\n const enterprise = config.getString('copilot.enterprise');\n\n if (!host) {\n throw new Error('The host configuration is missing from the config.');\n }\n\n if (!enterprise) {\n throw new Error('The enterprise configuration is missing from the config.');\n }\n\n const githubConfig = integrations.github.byHost(host)?.config;\n\n if (!githubConfig) {\n throw new Error(\n `GitHub configuration for host \"${host}\" is missing or incomplete.`,\n );\n }\n\n const apiBaseUrl = githubConfig.apiBaseUrl ?? 'https://api.github.com';\n\n const credentials: GithubCredentials = {\n type: 'token',\n headers: { Authorization: `Bearer ${githubConfig.token}` },\n token: githubConfig.token,\n };\n\n return {\n apiBaseUrl,\n credentials,\n enterprise,\n };\n};\n"],"names":["ScmIntegrations"],"mappings":";;;;AAyBa,MAAA,aAAA,GAAgB,OAAO,MAAwC,KAAA;AAC1E,EAAM,MAAA,YAAA,GAAeA,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA,CAAA;AAEtD,EAAM,MAAA,IAAA,GAAO,MAAO,CAAA,SAAA,CAAU,cAAc,CAAA,CAAA;AAC5C,EAAM,MAAA,UAAA,GAAa,MAAO,CAAA,SAAA,CAAU,oBAAoB,CAAA,CAAA;AAExD,EAAA,IAAI,CAAC,IAAM,EAAA;AACT,IAAM,MAAA,IAAI,MAAM,oDAAoD,CAAA,CAAA;AAAA,GACtE;AAEA,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAM,MAAA,IAAI,MAAM,0DAA0D,CAAA,CAAA;AAAA,GAC5E;AAEA,EAAA,MAAM,YAAe,GAAA,YAAA,CAAa,MAAO,CAAA,MAAA,CAAO,IAAI,CAAG,EAAA,MAAA,CAAA;AAEvD,EAAA,IAAI,CAAC,YAAc,EAAA;AACjB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,kCAAkC,IAAI,CAAA,2BAAA,CAAA;AAAA,KACxC,CAAA;AAAA,GACF;AAEA,EAAM,MAAA,UAAA,GAAa,aAAa,UAAc,IAAA,wBAAA,CAAA;AAE9C,EAAA,MAAM,WAAiC,GAAA;AAAA,IACrC,IAAM,EAAA,OAAA;AAAA,IACN,SAAS,EAAE,aAAA,EAAe,CAAU,OAAA,EAAA,YAAA,CAAa,KAAK,CAAG,CAAA,EAAA;AAAA,IACzD,OAAO,YAAa,CAAA,KAAA;AAAA,GACtB,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,UAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAA;AAAA,GACF,CAAA;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-copilot-backend",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "homepage": "https://backstage.io",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.cjs.js",
@@ -41,7 +41,6 @@
41
41
  "dependencies": {
42
42
  "@backstage-community/plugin-copilot-common": "^0.2.2",
43
43
  "@backstage/backend-app-api": "^1.0.1",
44
- "@backstage/backend-common": "^0.25.0",
45
44
  "@backstage/backend-defaults": "^0.5.2",
46
45
  "@backstage/backend-plugin-api": "^1.0.1",
47
46
  "@backstage/backend-tasks": "^0.6.1",