@backstage/plugin-scaffolder-backend-module-github 0.9.12 → 0.9.13
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 +8 -0
- package/dist/actions/github.cjs.js +7 -1
- package/dist/actions/github.cjs.js.map +1 -1
- package/dist/actions/githubActionsDispatch.cjs.js +2 -1
- package/dist/actions/githubActionsDispatch.cjs.js.map +1 -1
- package/dist/actions/githubAutolinks.cjs.js +2 -1
- package/dist/actions/githubAutolinks.cjs.js.map +1 -1
- package/dist/actions/githubBranchProtection.cjs.js +2 -1
- package/dist/actions/githubBranchProtection.cjs.js.map +1 -1
- package/dist/actions/githubDeployKey.cjs.js +2 -1
- package/dist/actions/githubDeployKey.cjs.js.map +1 -1
- package/dist/actions/githubEnvironment.cjs.js +2 -1
- package/dist/actions/githubEnvironment.cjs.js.map +1 -1
- package/dist/actions/githubIssuesCreate.cjs.js +2 -1
- package/dist/actions/githubIssuesCreate.cjs.js.map +1 -1
- package/dist/actions/githubIssuesLabel.cjs.js +2 -1
- package/dist/actions/githubIssuesLabel.cjs.js.map +1 -1
- package/dist/actions/githubPagesEnable.cjs.js +2 -1
- package/dist/actions/githubPagesEnable.cjs.js.map +1 -1
- package/dist/actions/githubPullRequest.cjs.js +7 -1
- package/dist/actions/githubPullRequest.cjs.js.map +1 -1
- package/dist/actions/githubRepoCreate.cjs.js +2 -1
- package/dist/actions/githubRepoCreate.cjs.js.map +1 -1
- package/dist/actions/githubRepoPush.cjs.js +7 -1
- package/dist/actions/githubRepoPush.cjs.js.map +1 -1
- package/dist/actions/githubWebhook.cjs.js +7 -1
- package/dist/actions/githubWebhook.cjs.js.map +1 -1
- package/dist/index.d.ts +18 -0
- package/dist/module.cjs.js +30 -13
- package/dist/module.cjs.js.map +1 -1
- package/dist/util.cjs.js +12 -1
- package/dist/util.cjs.js.map +1 -1
- package/package.json +2 -2
package/dist/module.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.cjs.js","sources":["../src/module.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 */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { scaffolderAutocompleteExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createGithubActionsDispatchAction,\n createGithubAutolinksAction,\n createGithubDeployKeyAction,\n createGithubEnvironmentAction,\n createGithubIssuesLabelAction,\n createGithubIssuesCreateAction,\n createGithubRepoCreateAction,\n createGithubRepoPushAction,\n createGithubWebhookAction,\n createPublishGithubAction,\n createPublishGithubPullRequestAction,\n createGithubPagesEnableAction,\n createGithubBranchProtectionAction,\n} from './actions';\nimport {\n DefaultGithubCredentialsProvider,\n ScmIntegrations,\n} from '@backstage/integration';\nimport { createHandleAutocompleteRequest } from './autocomplete/autocomplete';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node';\n\n/**\n * @public\n * The GitHub Module for the Scaffolder Backend\n */\nexport const githubModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'github',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n config: coreServices.rootConfig,\n catalog: catalogServiceRef,\n autocomplete: scaffolderAutocompleteExtensionPoint,\n },\n async init({ scaffolder, config, autocomplete, catalog }) {\n const integrations = ScmIntegrations.fromConfig(config);\n const githubCredentialsProvider =\n DefaultGithubCredentialsProvider.fromIntegrations(integrations);\n\n scaffolder.addActions(\n createGithubActionsDispatchAction({\n integrations,\n githubCredentialsProvider,\n }),\n createGithubAutolinksAction({\n integrations,\n githubCredentialsProvider,\n }),\n createGithubDeployKeyAction({\n integrations,\n }),\n createGithubEnvironmentAction({\n integrations,\n catalog,\n }),\n createGithubIssuesLabelAction({\n integrations,\n githubCredentialsProvider,\n }),\n createGithubIssuesCreateAction({\n integrations,\n githubCredentialsProvider,\n }),\n createGithubRepoCreateAction({\n integrations,\n githubCredentialsProvider,\n }),\n createGithubRepoPushAction({
|
|
1
|
+
{"version":3,"file":"module.cjs.js","sources":["../src/module.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 */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { scaffolderAutocompleteExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';\nimport {\n createGithubActionsDispatchAction,\n createGithubAutolinksAction,\n createGithubDeployKeyAction,\n createGithubEnvironmentAction,\n createGithubIssuesLabelAction,\n createGithubIssuesCreateAction,\n createGithubRepoCreateAction,\n createGithubRepoPushAction,\n createGithubWebhookAction,\n createPublishGithubAction,\n createPublishGithubPullRequestAction,\n createGithubPagesEnableAction,\n createGithubBranchProtectionAction,\n} from './actions';\nimport {\n DefaultGithubCredentialsProvider,\n ScmIntegrations,\n} from '@backstage/integration';\nimport { createHandleAutocompleteRequest } from './autocomplete/autocomplete';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\nimport { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node';\n\n/**\n * @public\n * The GitHub Module for the Scaffolder Backend\n */\nexport const githubModule = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'github',\n register({ registerInit }) {\n registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n config: coreServices.rootConfig,\n catalog: catalogServiceRef,\n autocomplete: scaffolderAutocompleteExtensionPoint,\n },\n async init({ scaffolder, config, autocomplete, catalog }) {\n const integrations = ScmIntegrations.fromConfig(config);\n const requireScmUserCredentials =\n config.getOptionalBoolean('scaffolder.requireScmUserCredentials') ??\n false;\n const githubCredentialsProvider =\n DefaultGithubCredentialsProvider.fromIntegrations(integrations);\n\n scaffolder.addActions(\n createGithubActionsDispatchAction({\n integrations,\n githubCredentialsProvider,\n requireScmUserCredentials,\n }),\n createGithubAutolinksAction({\n integrations,\n githubCredentialsProvider,\n requireScmUserCredentials,\n }),\n createGithubDeployKeyAction({\n integrations,\n requireScmUserCredentials,\n }),\n createGithubEnvironmentAction({\n integrations,\n catalog,\n requireScmUserCredentials,\n }),\n createGithubIssuesLabelAction({\n integrations,\n githubCredentialsProvider,\n requireScmUserCredentials,\n }),\n createGithubIssuesCreateAction({\n integrations,\n githubCredentialsProvider,\n requireScmUserCredentials,\n }),\n createGithubRepoCreateAction({\n integrations,\n githubCredentialsProvider,\n requireScmUserCredentials,\n }),\n createGithubRepoPushAction({\n integrations,\n config,\n requireScmUserCredentials,\n }),\n createGithubWebhookAction({\n integrations,\n githubCredentialsProvider,\n requireScmUserCredentials,\n }),\n createPublishGithubAction({\n integrations,\n config,\n githubCredentialsProvider,\n requireScmUserCredentials,\n }),\n createPublishGithubPullRequestAction({\n integrations,\n githubCredentialsProvider,\n config,\n requireScmUserCredentials,\n }),\n createGithubPagesEnableAction({\n integrations,\n githubCredentialsProvider,\n requireScmUserCredentials,\n }),\n createGithubBranchProtectionAction({\n integrations,\n requireScmUserCredentials,\n }),\n );\n\n autocomplete.addAutocompleteProvider({\n id: 'github',\n handler: createHandleAutocompleteRequest({ integrations }),\n });\n },\n });\n },\n});\n"],"names":["createBackendModule","scaffolderActionsExtensionPoint","coreServices","catalogServiceRef","scaffolderAutocompleteExtensionPoint","autocomplete","ScmIntegrations","DefaultGithubCredentialsProvider","createGithubActionsDispatchAction","createGithubAutolinksAction","createGithubDeployKeyAction","createGithubEnvironmentAction","createGithubIssuesLabelAction","createGithubIssuesCreateAction","createGithubRepoCreateAction","createGithubRepoPushAction","createGithubWebhookAction","createPublishGithubAction","createPublishGithubPullRequestAction","createGithubPagesEnableAction","createGithubBranchProtectionAction","createHandleAutocompleteRequest"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+CO,MAAM,eAAeA,oCAAA,CAAoB;AAAA,EAC9C,QAAA,EAAU,YAAA;AAAA,EACV,QAAA,EAAU,QAAA;AAAA,EACV,QAAA,CAAS,EAAE,YAAA,EAAa,EAAG;AACzB,IAAA,YAAA,CAAa;AAAA,MACX,IAAA,EAAM;AAAA,QACJ,UAAA,EAAYC,oDAAA;AAAA,QACZ,QAAQC,6BAAA,CAAa,UAAA;AAAA,QACrB,OAAA,EAASC,mCAAA;AAAA,QACT,YAAA,EAAcC;AAAA,OAChB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,YAAY,MAAA,gBAAQC,cAAA,EAAc,SAAQ,EAAG;AACxD,QAAA,MAAM,YAAA,GAAeC,2BAAA,CAAgB,UAAA,CAAW,MAAM,CAAA;AACtD,QAAA,MAAM,yBAAA,GACJ,MAAA,CAAO,kBAAA,CAAmB,sCAAsC,CAAA,IAChE,KAAA;AACF,QAAA,MAAM,yBAAA,GACJC,4CAAA,CAAiC,gBAAA,CAAiB,YAAY,CAAA;AAEhE,QAAA,UAAA,CAAW,UAAA;AAAA,UACTC,uDAAA,CAAkC;AAAA,YAChC,YAAA;AAAA,YACA,yBAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,UACDC,2CAAA,CAA4B;AAAA,YAC1B,YAAA;AAAA,YACA,yBAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA,UACDC,2CAAA,CA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ctokitClient(octokitOptions, logger, retryOptions) {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
async function getOctokitOptions(options) {
|
|
45
|
-
const {
|
|
45
|
+
const {
|
|
46
|
+
integrations,
|
|
47
|
+
credentialsProvider,
|
|
48
|
+
requireScmUserCredentials,
|
|
49
|
+
token,
|
|
50
|
+
repoUrl
|
|
51
|
+
} = options;
|
|
46
52
|
const { host, owner, repo } = repoUrl ? pluginScaffolderNode.parseRepoUrl(repoUrl, integrations) : options;
|
|
47
53
|
const requestOptions = {
|
|
48
54
|
// set timeout to 60 seconds
|
|
@@ -60,6 +66,11 @@ async function getOctokitOptions(options) {
|
|
|
60
66
|
request: requestOptions
|
|
61
67
|
};
|
|
62
68
|
}
|
|
69
|
+
if (requireScmUserCredentials) {
|
|
70
|
+
throw new errors.InputError(
|
|
71
|
+
`No user credentials provided for host ${host}, but scaffolder.requireScmUserCredentials is enabled`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
63
74
|
if (!owner || !repo) {
|
|
64
75
|
throw new errors.InputError(
|
|
65
76
|
`No owner and/or repo provided, which is required if a token is not provided`
|
package/dist/util.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.cjs.js","sources":["../src/util.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { InputError } from '@backstage/errors';\nimport {\n DefaultGithubCredentialsProvider,\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { parseRepoUrl } from '@backstage/plugin-scaffolder-node';\nimport { OctokitOptions } from '@octokit/core/dist-types/types';\nimport { Octokit } from 'octokit';\nimport { retry } from '@octokit/plugin-retry';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nconst DEFAULT_TIMEOUT_MS = 60_000;\n\n// By default, octokit/plugin-retry will retry 3 times with a 1 second delay\n// between retries.\nconst DEFAULT_RETRY_ATTEMPTS = 3;\nconst DEFAULT_RETRY_DELAY_MS = 1_000;\n\n/**\n * Options used to override plugin-retry defaults\n * @public\n */\nexport type RetryOptions = {\n // The number of retry attempts for failed requests\n retries?: number;\n // The delay in milliseconds between retry attempts\n retryAfter?: number;\n};\n\n/**\n * Helper function to determine if retries are enabled based on the provided\n * options.\n *\n * @param retryOptions - Optional retry configuration options, including the number\n * of retries and the delay between retries.\n *\n * @returns False if retries/retryAfter are explicitly set to 0 or less.\n * Returns true otherwise.\n */\nexport function isRetryEnabled(retryOptions?: RetryOptions): boolean {\n if (retryOptions === undefined) {\n return true;\n }\n\n if (retryOptions.retries !== undefined && retryOptions.retries <= 0) {\n return false;\n }\n\n if (retryOptions.retryAfter !== undefined && retryOptions.retryAfter <= 0) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Helper for generating an authenticated Octokit client with (or without)\n * retry capabilities.\n *\n * If retries are enabled (default), the client will retry failed requests up\n * to the specified number of retries and delay.\n * To disable retries, set either `retries` or `retryAfter` to 0 in the options.\n * @public\n *\n * @param octokitOptions - The options for configuring the Octokit client.\n * Generally provided by the `getOctokitOptions` helper.\n * @param logger - LoggerService instance for logging retry attempts and\n * failures.\n * @param retryOptions - Optional retry configuration options, including the\n * number of retries and the delay between retries.\n *\n * @returns An authenticated Octokit client instance based on the provided\n * options.\n */\nexport function getOctokitClient(\n octokitOptions: OctokitOptions,\n logger: LoggerService,\n retryOptions?: RetryOptions,\n): Octokit {\n // Default behavior is to enable retries, but allow callers to disable by\n // explicitly setting retries or retryAfter to 0\n if (!isRetryEnabled(retryOptions)) {\n return new Octokit({\n ...octokitOptions,\n log: logger,\n });\n }\n\n // Update the octokit options to include retry configuration with logging\n const OctokitClient = Octokit.plugin(retry);\n\n // From the octokit/plugin-retry documentation, specifying these values will\n // always retry regardless of the response code\n const retries = retryOptions?.retries\n ? retryOptions?.retries\n : DEFAULT_RETRY_ATTEMPTS;\n const retryAfter = retryOptions?.retryAfter\n ? retryOptions?.retryAfter\n : DEFAULT_RETRY_DELAY_MS;\n\n return new OctokitClient({\n ...octokitOptions,\n request: {\n ...octokitOptions.request,\n retries,\n retryAfter,\n },\n log: logger,\n });\n}\n\n/**\n * Helper for generating octokit configuration options.\n * If no token is provided, it will attempt to get a token from the credentials provider.\n * @public\n */\nexport async function getOctokitOptions(options: {\n integrations: ScmIntegrationRegistry;\n credentialsProvider?: GithubCredentialsProvider;\n token?: string;\n host: string;\n owner?: string;\n repo?: string;\n}): Promise<OctokitOptions>;\n\n/**\n * Helper for generating octokit configuration options for given repoUrl.\n * If no token is provided, it will attempt to get a token from the credentials provider.\n * @public\n * @deprecated Use options `host`, `owner` and `repo` instead of `repoUrl`.\n */\nexport async function getOctokitOptions(options: {\n integrations: ScmIntegrationRegistry;\n credentialsProvider?: GithubCredentialsProvider;\n token?: string;\n repoUrl: string;\n}): Promise<OctokitOptions>;\n\nexport async function getOctokitOptions(options: {\n integrations: ScmIntegrationRegistry;\n credentialsProvider?: GithubCredentialsProvider;\n token?: string;\n host?: string;\n owner?: string;\n repo?: string;\n repoUrl?: string;\n}): Promise<OctokitOptions> {\n const {
|
|
1
|
+
{"version":3,"file":"util.cjs.js","sources":["../src/util.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { InputError } from '@backstage/errors';\nimport {\n DefaultGithubCredentialsProvider,\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { parseRepoUrl } from '@backstage/plugin-scaffolder-node';\nimport { OctokitOptions } from '@octokit/core/dist-types/types';\nimport { Octokit } from 'octokit';\nimport { retry } from '@octokit/plugin-retry';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nconst DEFAULT_TIMEOUT_MS = 60_000;\n\n// By default, octokit/plugin-retry will retry 3 times with a 1 second delay\n// between retries.\nconst DEFAULT_RETRY_ATTEMPTS = 3;\nconst DEFAULT_RETRY_DELAY_MS = 1_000;\n\n/**\n * Options used to override plugin-retry defaults\n * @public\n */\nexport type RetryOptions = {\n // The number of retry attempts for failed requests\n retries?: number;\n // The delay in milliseconds between retry attempts\n retryAfter?: number;\n};\n\n/**\n * Helper function to determine if retries are enabled based on the provided\n * options.\n *\n * @param retryOptions - Optional retry configuration options, including the number\n * of retries and the delay between retries.\n *\n * @returns False if retries/retryAfter are explicitly set to 0 or less.\n * Returns true otherwise.\n */\nexport function isRetryEnabled(retryOptions?: RetryOptions): boolean {\n if (retryOptions === undefined) {\n return true;\n }\n\n if (retryOptions.retries !== undefined && retryOptions.retries <= 0) {\n return false;\n }\n\n if (retryOptions.retryAfter !== undefined && retryOptions.retryAfter <= 0) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Helper for generating an authenticated Octokit client with (or without)\n * retry capabilities.\n *\n * If retries are enabled (default), the client will retry failed requests up\n * to the specified number of retries and delay.\n * To disable retries, set either `retries` or `retryAfter` to 0 in the options.\n * @public\n *\n * @param octokitOptions - The options for configuring the Octokit client.\n * Generally provided by the `getOctokitOptions` helper.\n * @param logger - LoggerService instance for logging retry attempts and\n * failures.\n * @param retryOptions - Optional retry configuration options, including the\n * number of retries and the delay between retries.\n *\n * @returns An authenticated Octokit client instance based on the provided\n * options.\n */\nexport function getOctokitClient(\n octokitOptions: OctokitOptions,\n logger: LoggerService,\n retryOptions?: RetryOptions,\n): Octokit {\n // Default behavior is to enable retries, but allow callers to disable by\n // explicitly setting retries or retryAfter to 0\n if (!isRetryEnabled(retryOptions)) {\n return new Octokit({\n ...octokitOptions,\n log: logger,\n });\n }\n\n // Update the octokit options to include retry configuration with logging\n const OctokitClient = Octokit.plugin(retry);\n\n // From the octokit/plugin-retry documentation, specifying these values will\n // always retry regardless of the response code\n const retries = retryOptions?.retries\n ? retryOptions?.retries\n : DEFAULT_RETRY_ATTEMPTS;\n const retryAfter = retryOptions?.retryAfter\n ? retryOptions?.retryAfter\n : DEFAULT_RETRY_DELAY_MS;\n\n return new OctokitClient({\n ...octokitOptions,\n request: {\n ...octokitOptions.request,\n retries,\n retryAfter,\n },\n log: logger,\n });\n}\n\n/**\n * Helper for generating octokit configuration options.\n * If no token is provided, it will attempt to get a token from the credentials provider.\n * @public\n */\nexport async function getOctokitOptions(options: {\n integrations: ScmIntegrationRegistry;\n credentialsProvider?: GithubCredentialsProvider;\n requireScmUserCredentials?: boolean;\n token?: string;\n host: string;\n owner?: string;\n repo?: string;\n}): Promise<OctokitOptions>;\n\n/**\n * Helper for generating octokit configuration options for given repoUrl.\n * If no token is provided, it will attempt to get a token from the credentials provider.\n * @public\n * @deprecated Use options `host`, `owner` and `repo` instead of `repoUrl`.\n */\nexport async function getOctokitOptions(options: {\n integrations: ScmIntegrationRegistry;\n credentialsProvider?: GithubCredentialsProvider;\n requireScmUserCredentials?: boolean;\n token?: string;\n repoUrl: string;\n}): Promise<OctokitOptions>;\n\nexport async function getOctokitOptions(options: {\n integrations: ScmIntegrationRegistry;\n credentialsProvider?: GithubCredentialsProvider;\n requireScmUserCredentials?: boolean;\n token?: string;\n host?: string;\n owner?: string;\n repo?: string;\n repoUrl?: string;\n}): Promise<OctokitOptions> {\n const {\n integrations,\n credentialsProvider,\n requireScmUserCredentials,\n token,\n repoUrl,\n } = options;\n const { host, owner, repo } = repoUrl\n ? parseRepoUrl(repoUrl, integrations)\n : options;\n\n const requestOptions = {\n // set timeout to 60 seconds\n timeout: DEFAULT_TIMEOUT_MS,\n };\n\n const integrationConfig = integrations.github.byHost(host!)?.config;\n\n if (!integrationConfig) {\n throw new InputError(`No integration for host ${host}`);\n }\n\n // short circuit the `githubCredentialsProvider` if there is a token provided by the caller already\n if (token) {\n return {\n auth: token,\n baseUrl: integrationConfig.apiBaseUrl,\n previews: ['nebula-preview'],\n request: requestOptions,\n };\n }\n\n if (requireScmUserCredentials) {\n throw new InputError(\n `No user credentials provided for host ${host}, but scaffolder.requireScmUserCredentials is enabled`,\n );\n }\n\n if (!owner || !repo) {\n throw new InputError(\n `No owner and/or repo provided, which is required if a token is not provided`,\n );\n }\n\n const githubCredentialsProvider =\n credentialsProvider ??\n DefaultGithubCredentialsProvider.fromIntegrations(integrations);\n\n const { token: credentialProviderToken } =\n await githubCredentialsProvider.getCredentials({\n url: `https://${host}/${encodeURIComponent(owner)}/${encodeURIComponent(\n repo,\n )}`,\n });\n\n if (!credentialProviderToken) {\n throw new InputError(\n `No token available for host: ${host}, with owner ${owner}, and repo ${repo}. Make sure GitHub auth is configured correctly. See https://backstage.io/docs/auth/github/provider for more details.`,\n );\n }\n\n return {\n auth: credentialProviderToken,\n baseUrl: integrationConfig.apiBaseUrl,\n previews: ['nebula-preview'],\n };\n}\n"],"names":["Octokit","retry","parseRepoUrl","InputError","DefaultGithubCredentialsProvider"],"mappings":";;;;;;;;AA4BA,MAAM,kBAAA,GAAqB,GAAA;AAI3B,MAAM,sBAAA,GAAyB,CAAA;AAC/B,MAAM,sBAAA,GAAyB,GAAA;AAuBxB,SAAS,eAAe,YAAA,EAAsC;AACnE,EAAA,IAAI,iBAAiB,MAAA,EAAW;AAC9B,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,YAAA,CAAa,OAAA,KAAY,MAAA,IAAa,YAAA,CAAa,WAAW,CAAA,EAAG;AACnE,IAAA,OAAO,KAAA;AAAA,EACT;AAE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,EAAU,CAAC,gBAAgB;AAAA,GAC7B;AACF;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-scaffolder-backend-module-github",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.13",
|
|
4
4
|
"description": "The github module for @backstage/plugin-scaffolder-backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin-module",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@backstage/catalog-model": "^1.10.0",
|
|
55
55
|
"@backstage/config": "^1.3.8",
|
|
56
56
|
"@backstage/errors": "^1.3.1",
|
|
57
|
-
"@backstage/integration": "^2.1.
|
|
57
|
+
"@backstage/integration": "^2.1.1",
|
|
58
58
|
"@backstage/plugin-catalog-node": "^2.2.4",
|
|
59
59
|
"@backstage/plugin-scaffolder-node": "^0.13.6",
|
|
60
60
|
"@backstage/types": "^1.2.2",
|