From 84c80636e7f468b64fa4599cca5dd96e45cd8270 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 18 Jan 2024 16:45:08 +0100 Subject: [PATCH] feat: gerrit, github, gitlab ported Signed-off-by: blam --- .../api-report-alpha.md | 13 +++ .../package.json | 16 +++ .../src/alpha.ts | 16 +++ .../src/module.ts | 49 ++++++++++ .../api-report-alpha.md | 13 +++ .../package.json | 16 +++ .../src/alpha.ts | 16 +++ .../src/module.ts | 97 +++++++++++++++++++ .../api-report-alpha.md | 13 +++ .../package.json | 16 +++ .../src/alpha.ts | 16 +++ .../src/module.ts | 62 ++++++++++++ yarn.lock | 6 ++ 13 files changed, 349 insertions(+) create mode 100644 plugins/scaffolder-backend-module-gerrit/api-report-alpha.md create mode 100644 plugins/scaffolder-backend-module-gerrit/src/alpha.ts create mode 100644 plugins/scaffolder-backend-module-gerrit/src/module.ts create mode 100644 plugins/scaffolder-backend-module-github/api-report-alpha.md create mode 100644 plugins/scaffolder-backend-module-github/src/alpha.ts create mode 100644 plugins/scaffolder-backend-module-github/src/module.ts create mode 100644 plugins/scaffolder-backend-module-gitlab/api-report-alpha.md create mode 100644 plugins/scaffolder-backend-module-gitlab/src/alpha.ts create mode 100644 plugins/scaffolder-backend-module-gitlab/src/module.ts diff --git a/plugins/scaffolder-backend-module-gerrit/api-report-alpha.md b/plugins/scaffolder-backend-module-gerrit/api-report-alpha.md new file mode 100644 index 0000000000..7cf8910734 --- /dev/null +++ b/plugins/scaffolder-backend-module-gerrit/api-report-alpha.md @@ -0,0 +1,13 @@ +## API Report File for "@backstage/plugin-scaffolder-backend-module-gerrit" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// @alpha +const gerritModule: () => BackendFeature; +export default gerritModule; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/scaffolder-backend-module-gerrit/package.json b/plugins/scaffolder-backend-module-gerrit/package.json index 59159560b5..e0a3bb933c 100644 --- a/plugins/scaffolder-backend-module-gerrit/package.json +++ b/plugins/scaffolder-backend-module-gerrit/package.json @@ -13,6 +13,21 @@ "backstage": { "role": "backend-plugin-module" }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "alpha": [ + "src/alpha.ts" + ], + "package.json": [ + "package.json" + ] + } + }, "scripts": { "start": "backstage-cli package start", "build": "backstage-cli package build", @@ -23,6 +38,7 @@ "postpack": "backstage-cli package postpack" }, "dependencies": { + "@backstage/backend-plugin-api": "workspace:^", "@backstage/config": "workspace:^", "@backstage/errors": "workspace:^", "@backstage/integration": "workspace:^", diff --git a/plugins/scaffolder-backend-module-gerrit/src/alpha.ts b/plugins/scaffolder-backend-module-gerrit/src/alpha.ts new file mode 100644 index 0000000000..30d2fa4c67 --- /dev/null +++ b/plugins/scaffolder-backend-module-gerrit/src/alpha.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export { gerritModule as default } from './module'; diff --git a/plugins/scaffolder-backend-module-gerrit/src/module.ts b/plugins/scaffolder-backend-module-gerrit/src/module.ts new file mode 100644 index 0000000000..f8819f1fa1 --- /dev/null +++ b/plugins/scaffolder-backend-module-gerrit/src/module.ts @@ -0,0 +1,49 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { + coreServices, + createBackendModule, +} from '@backstage/backend-plugin-api'; +import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha'; +import { + createPublishGerritAction, + createPublishGerritReviewAction, +} from './actions'; +import { ScmIntegrations } from '@backstage/integration'; + +/** + * @alpha + * The Gerrit Module for the Scaffolder Backend + */ +export const gerritModule = createBackendModule({ + pluginId: 'scaffolder', + moduleId: 'geritt', + register({ registerInit }) { + registerInit({ + deps: { + scaffolder: scaffolderActionsExtensionPoint, + config: coreServices.rootConfig, + }, + async init({ scaffolder, config }) { + const integrations = ScmIntegrations.fromConfig(config); + scaffolder.addActions( + createPublishGerritAction({ integrations, config }), + createPublishGerritReviewAction({ integrations, config }), + ); + }, + }); + }, +}); diff --git a/plugins/scaffolder-backend-module-github/api-report-alpha.md b/plugins/scaffolder-backend-module-github/api-report-alpha.md new file mode 100644 index 0000000000..6ac8bafbd3 --- /dev/null +++ b/plugins/scaffolder-backend-module-github/api-report-alpha.md @@ -0,0 +1,13 @@ +## API Report File for "@backstage/plugin-scaffolder-backend-module-github" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// @alpha +const githubModule: () => BackendFeature; +export default githubModule; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/scaffolder-backend-module-github/package.json b/plugins/scaffolder-backend-module-github/package.json index b035096dad..8b432949ba 100644 --- a/plugins/scaffolder-backend-module-github/package.json +++ b/plugins/scaffolder-backend-module-github/package.json @@ -13,6 +13,21 @@ "backstage": { "role": "backend-plugin-module" }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "alpha": [ + "src/alpha.ts" + ], + "package.json": [ + "package.json" + ] + } + }, "scripts": { "start": "backstage-cli package start", "build": "backstage-cli package build", @@ -24,6 +39,7 @@ }, "dependencies": { "@backstage/backend-common": "workspace:^", + "@backstage/backend-plugin-api": "workspace:^", "@backstage/config": "workspace:^", "@backstage/errors": "workspace:^", "@backstage/integration": "workspace:^", diff --git a/plugins/scaffolder-backend-module-github/src/alpha.ts b/plugins/scaffolder-backend-module-github/src/alpha.ts new file mode 100644 index 0000000000..f4342bbc42 --- /dev/null +++ b/plugins/scaffolder-backend-module-github/src/alpha.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export { githubModule as default } from './module'; diff --git a/plugins/scaffolder-backend-module-github/src/module.ts b/plugins/scaffolder-backend-module-github/src/module.ts new file mode 100644 index 0000000000..0d528d5cd3 --- /dev/null +++ b/plugins/scaffolder-backend-module-github/src/module.ts @@ -0,0 +1,97 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { + coreServices, + createBackendModule, +} from '@backstage/backend-plugin-api'; +import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha'; +import { + createGithubActionsDispatchAction, + createGithubAutolinksAction, + createGithubDeployKeyAction, + createGithubEnvironmentAction, + createGithubIssuesLabelAction, + createGithubRepoCreateAction, + createGithubRepoPushAction, + createGithubWebhookAction, + createPublishGithubAction, + createPublishGithubPullRequestAction, +} from './actions'; +import { + DefaultGithubCredentialsProvider, + ScmIntegrations, +} from '@backstage/integration'; + +/** + * @alpha + * The GitHub Module for the Scaffolder Backend + */ +export const githubModule = createBackendModule({ + pluginId: 'scaffolder', + moduleId: 'github', + register({ registerInit }) { + registerInit({ + deps: { + scaffolder: scaffolderActionsExtensionPoint, + config: coreServices.rootConfig, + }, + async init({ scaffolder, config }) { + const integrations = ScmIntegrations.fromConfig(config); + const githubCredentialsProvider = + DefaultGithubCredentialsProvider.fromIntegrations(integrations); + + scaffolder.addActions( + createGithubActionsDispatchAction({ + integrations, + githubCredentialsProvider, + }), + createGithubAutolinksAction({ + integrations, + githubCredentialsProvider, + }), + createGithubDeployKeyAction({ + integrations, + }), + createGithubEnvironmentAction({ + integrations, + }), + createGithubIssuesLabelAction({ + integrations, + githubCredentialsProvider, + }), + createGithubRepoCreateAction({ + integrations, + githubCredentialsProvider, + }), + createGithubRepoPushAction({ integrations, config }), + createGithubWebhookAction({ + integrations, + githubCredentialsProvider, + }), + createPublishGithubAction({ + integrations, + config, + githubCredentialsProvider, + }), + createPublishGithubPullRequestAction({ + integrations, + githubCredentialsProvider, + }), + ); + }, + }); + }, +}); diff --git a/plugins/scaffolder-backend-module-gitlab/api-report-alpha.md b/plugins/scaffolder-backend-module-gitlab/api-report-alpha.md new file mode 100644 index 0000000000..1c777d0240 --- /dev/null +++ b/plugins/scaffolder-backend-module-gitlab/api-report-alpha.md @@ -0,0 +1,13 @@ +## API Report File for "@backstage/plugin-scaffolder-backend-module-gitlab" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// @alpha +const gitlabModule: () => BackendFeature; +export default gitlabModule; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/scaffolder-backend-module-gitlab/package.json b/plugins/scaffolder-backend-module-gitlab/package.json index ca7e90f8c8..17f2ff79e8 100644 --- a/plugins/scaffolder-backend-module-gitlab/package.json +++ b/plugins/scaffolder-backend-module-gitlab/package.json @@ -21,6 +21,21 @@ "keywords": [ "backstage" ], + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "alpha": [ + "src/alpha.ts" + ], + "package.json": [ + "package.json" + ] + } + }, "scripts": { "start": "backstage-cli package start", "build": "backstage-cli package build", @@ -32,6 +47,7 @@ }, "dependencies": { "@backstage/backend-common": "workspace:^", + "@backstage/backend-plugin-api": "workspace:^", "@backstage/config": "workspace:^", "@backstage/errors": "workspace:^", "@backstage/integration": "workspace:^", diff --git a/plugins/scaffolder-backend-module-gitlab/src/alpha.ts b/plugins/scaffolder-backend-module-gitlab/src/alpha.ts new file mode 100644 index 0000000000..22598357a2 --- /dev/null +++ b/plugins/scaffolder-backend-module-gitlab/src/alpha.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export { gitlabModule as default } from './module'; diff --git a/plugins/scaffolder-backend-module-gitlab/src/module.ts b/plugins/scaffolder-backend-module-gitlab/src/module.ts new file mode 100644 index 0000000000..37bf488fbd --- /dev/null +++ b/plugins/scaffolder-backend-module-gitlab/src/module.ts @@ -0,0 +1,62 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { + coreServices, + createBackendModule, +} from '@backstage/backend-plugin-api'; +import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha'; +import { + createGitlabGroupEnsureExistsAction, + createGitlabIssueAction, + createGitlabProjectAccessTokenAction, + createGitlabProjectDeployTokenAction, + createGitlabProjectVariableAction, + createGitlabRepoPushAction, + createPublishGitlabAction, + createPublishGitlabMergeRequestAction, +} from './actions'; +import { ScmIntegrations } from '@backstage/integration'; + +/** + * @alpha + * The GitLab Module for the Scaffolder Backend + */ +export const gitlabModule = createBackendModule({ + pluginId: 'scaffolder', + moduleId: 'gitlab', + register({ registerInit }) { + registerInit({ + deps: { + scaffolder: scaffolderActionsExtensionPoint, + config: coreServices.rootConfig, + }, + async init({ scaffolder, config }) { + const integrations = ScmIntegrations.fromConfig(config); + + scaffolder.addActions( + createGitlabGroupEnsureExistsAction({ integrations }), + createGitlabIssueAction({ integrations }), + createGitlabProjectAccessTokenAction({ integrations }), + createGitlabProjectDeployTokenAction({ integrations }), + createGitlabProjectVariableAction({ integrations }), + createGitlabRepoPushAction({ integrations }), + createPublishGitlabAction({ config, integrations }), + createPublishGitlabMergeRequestAction({ integrations }), + ); + }, + }); + }, +}); diff --git a/yarn.lock b/yarn.lock index 43aa026e77..b4973ea228 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8010,6 +8010,7 @@ __metadata: resolution: "@backstage/plugin-scaffolder-backend-module-bitbucket@workspace:plugins/scaffolder-backend-module-bitbucket" dependencies: "@backstage/backend-common": "workspace:^" + "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" @@ -8027,6 +8028,7 @@ __metadata: resolution: "@backstage/plugin-scaffolder-backend-module-confluence-to-markdown@workspace:plugins/scaffolder-backend-module-confluence-to-markdown" dependencies: "@backstage/backend-common": "workspace:^" + "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" @@ -8047,6 +8049,7 @@ __metadata: resolution: "@backstage/plugin-scaffolder-backend-module-cookiecutter@workspace:plugins/scaffolder-backend-module-cookiecutter" dependencies: "@backstage/backend-common": "workspace:^" + "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" @@ -8068,6 +8071,7 @@ __metadata: resolution: "@backstage/plugin-scaffolder-backend-module-gerrit@workspace:plugins/scaffolder-backend-module-gerrit" dependencies: "@backstage/backend-common": "workspace:^" + "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" @@ -8085,6 +8089,7 @@ __metadata: resolution: "@backstage/plugin-scaffolder-backend-module-github@workspace:plugins/scaffolder-backend-module-github" dependencies: "@backstage/backend-common": "workspace:^" + "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" @@ -8109,6 +8114,7 @@ __metadata: resolution: "@backstage/plugin-scaffolder-backend-module-gitlab@workspace:plugins/scaffolder-backend-module-gitlab" dependencies: "@backstage/backend-common": "workspace:^" + "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^"