diff --git a/.changeset/chilled-chefs-notice.md b/.changeset/chilled-chefs-notice.md new file mode 100644 index 0000000000..a12babb2a4 --- /dev/null +++ b/.changeset/chilled-chefs-notice.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-rails': patch +--- + +Make `containerRunner` argument optional diff --git a/.changeset/good-lemons-lick.md b/.changeset/good-lemons-lick.md new file mode 100644 index 0000000000..3fde0c7d84 --- /dev/null +++ b/.changeset/good-lemons-lick.md @@ -0,0 +1,14 @@ +--- +'@backstage/plugin-scaffolder-backend-module-confluence-to-markdown': patch +'@backstage/plugin-scaffolder-backend-module-cookiecutter': patch +'@backstage/plugin-scaffolder-backend-module-bitbucket': patch +'@backstage/plugin-scaffolder-backend-module-gerrit': patch +'@backstage/plugin-scaffolder-backend-module-github': patch +'@backstage/plugin-scaffolder-backend-module-gitlab': patch +'@backstage/plugin-scaffolder-backend-module-sentry': patch +'@backstage/plugin-scaffolder-backend-module-yeoman': patch +'@backstage/plugin-scaffolder-backend-module-azure': patch +'@backstage/plugin-scaffolder-backend-module-rails': patch +--- + +Exporting a default module for the new Backend System diff --git a/.changeset/wild-owls-doubt.md b/.changeset/wild-owls-doubt.md new file mode 100644 index 0000000000..84abffb159 --- /dev/null +++ b/.changeset/wild-owls-doubt.md @@ -0,0 +1,16 @@ +--- +'@backstage/plugin-scaffolder-backend': minor +--- + +The built-in module list has been trimmed down when using the new Backend System. Provider specific modules should now be installed with `backend.add` to provide additional actions to the scaffolder. These modules are as follows: + +- `@backstage/plugin-scaffolder-backend-module-github` +- `@backstage/plugin-scaffolder-backend-module-gitlab` +- `@backstage/plugin-scaffolder-backend-module-bitbucket` +- `@backstage/plugin-scaffolder-backend-module-gitea` +- `@backstage/plugin-scaffolder-backend-module-gerrit` +- `@backstage/plugin-scaffolder-backend-module-confluence-to-markdown` +- `@backstage/plugin-scaffolder-backend-module-cookiecutter` +- `@backstage/plugin-scaffolder-backend-module-rails` +- `@backstage/plugin-scaffolder-backend-module-sentry` +- `@backstage/plugin-scaffolder-backend-module-yeoman` diff --git a/docs/backend-system/building-backends/08-migrating.md b/docs/backend-system/building-backends/08-migrating.md index 45478d632e..fc1a6f1859 100644 --- a/docs/backend-system/building-backends/08-migrating.md +++ b/docs/backend-system/building-backends/08-migrating.md @@ -700,6 +700,26 @@ const backend = createBackend(); backend.add(import('@backstage/plugin-scaffolder-backend/alpha')); ``` +With the new Backend System version of the Scaffolder plugin, any provider specific actions will need to be installed separately. +For example - GitHub actions are now collected under the `@backstage/plugin-scaffolder-backend-module-github` package. + +```ts title="packages/backend/src/index.ts" +const backend = createBackend(); +backend.add(import('@backstage/plugin-scaffolder-backend/alpha')); + +/* highlight-add-next-line */ +backend.add(import('@backstage/plugin-scaffolder-backend-module-github')); +``` + +And of course you'll need to install those separately as well. + +```bash +# from the repository root +yarn add --cwd packages/backend @backstage/plugin-scaffolder-backend-module-github +``` + +You can find a list of the available modules under the [plugins directory](https://github.com/backstage/backstage/tree/master/plugins) in the monorepo. + If you have other customizations made to `plugins/scaffolder.ts`, such as adding custom actions, read on. Otherwise, you should be able to just delete that file at this point. diff --git a/plugins/scaffolder-backend-module-azure/api-report.md b/plugins/scaffolder-backend-module-azure/api-report.md index 427ed2d1bf..d48d00e0e0 100644 --- a/plugins/scaffolder-backend-module-azure/api-report.md +++ b/plugins/scaffolder-backend-module-azure/api-report.md @@ -3,11 +3,16 @@ > 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'; import { Config } from '@backstage/config'; import { JsonObject } from '@backstage/types'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; +// @public +const azureModule: () => BackendFeature; +export default azureModule; + // @public export function createPublishAzureAction(options: { integrations: ScmIntegrationRegistry; diff --git a/plugins/scaffolder-backend-module-azure/package.json b/plugins/scaffolder-backend-module-azure/package.json index ce53811f15..edf927a670 100644 --- a/plugins/scaffolder-backend-module-azure/package.json +++ b/plugins/scaffolder-backend-module-azure/package.json @@ -6,13 +6,22 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" }, "backstage": { "role": "backend-plugin-module" }, + "exports": { + ".": "./src/index.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "package.json": [ + "package.json" + ] + } + }, "scripts": { "start": "backstage-cli package start", "build": "backstage-cli package build", @@ -24,6 +33,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-azure/src/index.ts b/plugins/scaffolder-backend-module-azure/src/index.ts index e804f1a504..b5650d8723 100644 --- a/plugins/scaffolder-backend-module-azure/src/index.ts +++ b/plugins/scaffolder-backend-module-azure/src/index.ts @@ -21,3 +21,4 @@ */ export * from './actions'; +export { azureModule as default } from './module'; diff --git a/plugins/scaffolder-backend-module-azure/src/module.ts b/plugins/scaffolder-backend-module-azure/src/module.ts new file mode 100644 index 0000000000..40ca3f0978 --- /dev/null +++ b/plugins/scaffolder-backend-module-azure/src/module.ts @@ -0,0 +1,48 @@ +/* + * 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 { + createBackendModule, + coreServices, +} from '@backstage/backend-plugin-api'; +import { ScmIntegrations } from '@backstage/integration'; +import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha'; +import { createPublishAzureAction } from './actions'; + +/** + * @public + * The Azure Module for the Scaffolder Backend + */ +export const azureModule = createBackendModule({ + moduleId: 'azure', + pluginId: 'scaffolder', + register({ registerInit }) { + registerInit({ + deps: { + scaffolderActions: scaffolderActionsExtensionPoint, + config: coreServices.rootConfig, + }, + async init({ scaffolderActions, config }) { + const integrations = ScmIntegrations.fromConfig(config); + scaffolderActions.addActions( + createPublishAzureAction({ + integrations, + config, + }), + ); + }, + }); + }, +}); diff --git a/plugins/scaffolder-backend-module-bitbucket/api-report.md b/plugins/scaffolder-backend-module-bitbucket/api-report.md index 0f5f09b5b8..7540b0c113 100644 --- a/plugins/scaffolder-backend-module-bitbucket/api-report.md +++ b/plugins/scaffolder-backend-module-bitbucket/api-report.md @@ -3,11 +3,16 @@ > 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'; import { Config } from '@backstage/config'; import { JsonObject } from '@backstage/types'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; +// @public +const bitbucketModule: () => BackendFeature; +export default bitbucketModule; + // @public export const createBitbucketPipelinesRunAction: (options: { integrations: ScmIntegrationRegistry; diff --git a/plugins/scaffolder-backend-module-bitbucket/package.json b/plugins/scaffolder-backend-module-bitbucket/package.json index e045bb9dc8..492c1d86b0 100644 --- a/plugins/scaffolder-backend-module-bitbucket/package.json +++ b/plugins/scaffolder-backend-module-bitbucket/package.json @@ -6,13 +6,22 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" }, "backstage": { "role": "backend-plugin-module" }, + "exports": { + ".": "./src/index.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "package.json": [ + "package.json" + ] + } + }, "scripts": { "start": "backstage-cli package start", "build": "backstage-cli package build", @@ -24,6 +33,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-bitbucket/src/index.ts b/plugins/scaffolder-backend-module-bitbucket/src/index.ts index 38d973efb8..26f186b6dc 100644 --- a/plugins/scaffolder-backend-module-bitbucket/src/index.ts +++ b/plugins/scaffolder-backend-module-bitbucket/src/index.ts @@ -21,3 +21,4 @@ */ export * from './actions'; +export { bitbucketModule as default } from './module'; diff --git a/plugins/scaffolder-backend-module-bitbucket/src/module.ts b/plugins/scaffolder-backend-module-bitbucket/src/module.ts new file mode 100644 index 0000000000..19554270a7 --- /dev/null +++ b/plugins/scaffolder-backend-module-bitbucket/src/module.ts @@ -0,0 +1,57 @@ +/* + * 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 { + createBitbucketPipelinesRunAction, + createPublishBitbucketCloudAction, + createPublishBitbucketServerAction, + createPublishBitbucketServerPullRequestAction, +} from './actions'; +import { ScmIntegrations } from '@backstage/integration'; + +/** + * @public + * The Bitbucket Module for the Scaffolder Backend + */ +export const bitbucketModule = createBackendModule({ + moduleId: 'bitbucket', + pluginId: 'scaffolder', + register({ registerInit }) { + registerInit({ + deps: { + scaffolder: scaffolderActionsExtensionPoint, + config: coreServices.rootConfig, + }, + async init({ scaffolder, config }) { + const integrations = ScmIntegrations.fromConfig(config); + + scaffolder.addActions( + createPublishBitbucketCloudAction({ integrations, config }), + createPublishBitbucketServerAction({ integrations, config }), + createPublishBitbucketServerPullRequestAction({ + integrations, + config, + }), + createBitbucketPipelinesRunAction({ integrations }), + ); + }, + }); + }, +}); diff --git a/plugins/scaffolder-backend-module-confluence-to-markdown/api-report.md b/plugins/scaffolder-backend-module-confluence-to-markdown/api-report.md index 70428f118c..e5701bfadb 100644 --- a/plugins/scaffolder-backend-module-confluence-to-markdown/api-report.md +++ b/plugins/scaffolder-backend-module-confluence-to-markdown/api-report.md @@ -3,12 +3,17 @@ > 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'; import { Config } from '@backstage/config'; import { JsonObject } from '@backstage/types'; import { ScmIntegrations } from '@backstage/integration'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; import { UrlReader } from '@backstage/backend-common'; +// @public +const confluenceToMarkdownModule: () => BackendFeature; +export default confluenceToMarkdownModule; + // @public (undocumented) export const createConfluenceToMarkdownAction: (options: { reader: UrlReader; diff --git a/plugins/scaffolder-backend-module-confluence-to-markdown/package.json b/plugins/scaffolder-backend-module-confluence-to-markdown/package.json index 2f0bd5188c..c378093001 100644 --- a/plugins/scaffolder-backend-module-confluence-to-markdown/package.json +++ b/plugins/scaffolder-backend-module-confluence-to-markdown/package.json @@ -6,9 +6,7 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" }, "backstage": { "role": "backend-plugin-module" @@ -19,6 +17,17 @@ "url": "https://github.com/backstage/backstage", "directory": "plugins/scaffolder-backend-module-confluence-to-markdown" }, + "exports": { + ".": "./src/index.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "package.json": [ + "package.json" + ] + } + }, "scripts": { "start": "backstage-cli package start", "build": "backstage-cli package build", @@ -31,6 +40,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-confluence-to-markdown/src/index.ts b/plugins/scaffolder-backend-module-confluence-to-markdown/src/index.ts index 80d2e35cb3..04dd3d3221 100644 --- a/plugins/scaffolder-backend-module-confluence-to-markdown/src/index.ts +++ b/plugins/scaffolder-backend-module-confluence-to-markdown/src/index.ts @@ -21,3 +21,4 @@ */ export * from './actions'; +export { confluenceToMarkdownModule as default } from './module'; diff --git a/plugins/scaffolder-backend-module-confluence-to-markdown/src/module.ts b/plugins/scaffolder-backend-module-confluence-to-markdown/src/module.ts new file mode 100644 index 0000000000..402f56c951 --- /dev/null +++ b/plugins/scaffolder-backend-module-confluence-to-markdown/src/module.ts @@ -0,0 +1,50 @@ +/* + * 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 { + createBackendModule, + coreServices, +} from '@backstage/backend-plugin-api'; +import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha'; +import { createConfluenceToMarkdownAction } from './actions'; +import { ScmIntegrations } from '@backstage/integration'; + +/** + * @public + * The Confluence to Markdown Module for the Scaffolder Backend + */ +export const confluenceToMarkdownModule = createBackendModule({ + pluginId: 'scaffolder', + moduleId: 'confluence-to-markdown', + register({ registerInit }) { + registerInit({ + deps: { + scaffolder: scaffolderActionsExtensionPoint, + config: coreServices.rootConfig, + reader: coreServices.urlReader, + }, + async init({ scaffolder, config, reader }) { + const integrations = ScmIntegrations.fromConfig(config); + scaffolder.addActions( + createConfluenceToMarkdownAction({ + config, + integrations, + reader, + }), + ); + }, + }); + }, +}); diff --git a/plugins/scaffolder-backend-module-cookiecutter/api-report.md b/plugins/scaffolder-backend-module-cookiecutter/api-report.md index 927d4b4c55..ed2b044189 100644 --- a/plugins/scaffolder-backend-module-cookiecutter/api-report.md +++ b/plugins/scaffolder-backend-module-cookiecutter/api-report.md @@ -5,12 +5,17 @@ ```ts /// +import { BackendFeature } from '@backstage/backend-plugin-api'; import { ContainerRunner } from '@backstage/backend-common'; import { JsonObject } from '@backstage/types'; import { ScmIntegrations } from '@backstage/integration'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; import { UrlReader } from '@backstage/backend-common'; +// @public +const cookiecutterModule: () => BackendFeature; +export default cookiecutterModule; + // @public export function createFetchCookiecutterAction(options: { reader: UrlReader; diff --git a/plugins/scaffolder-backend-module-cookiecutter/package.json b/plugins/scaffolder-backend-module-cookiecutter/package.json index 98e96a491d..2cf52d1abb 100644 --- a/plugins/scaffolder-backend-module-cookiecutter/package.json +++ b/plugins/scaffolder-backend-module-cookiecutter/package.json @@ -6,9 +6,7 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" }, "backstage": { "role": "backend-plugin-module" @@ -19,6 +17,17 @@ "url": "https://github.com/backstage/backstage", "directory": "plugins/scaffolder-backend-module-cookiecutter" }, + "exports": { + ".": "./src/index.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "package.json": [ + "package.json" + ] + } + }, "scripts": { "start": "backstage-cli package start", "build": "backstage-cli package build", @@ -30,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-cookiecutter/src/index.ts b/plugins/scaffolder-backend-module-cookiecutter/src/index.ts index 4f0ba9a407..c6df8295d1 100644 --- a/plugins/scaffolder-backend-module-cookiecutter/src/index.ts +++ b/plugins/scaffolder-backend-module-cookiecutter/src/index.ts @@ -21,3 +21,4 @@ */ export * from './actions'; +export { cookiecutterModule as default } from './module'; diff --git a/plugins/scaffolder-backend-module-cookiecutter/src/module.ts b/plugins/scaffolder-backend-module-cookiecutter/src/module.ts new file mode 100644 index 0000000000..df1b201518 --- /dev/null +++ b/plugins/scaffolder-backend-module-cookiecutter/src/module.ts @@ -0,0 +1,46 @@ +/* + * 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 { createFetchCookiecutterAction } from './actions'; +import { ScmIntegrations } from '@backstage/integration'; + +/** + * @public + * The Cookiecutter Module for the Scaffolder Backend + */ +export const cookiecutterModule = createBackendModule({ + pluginId: 'scaffolder', + moduleId: 'cookiecutter', + register({ registerInit }) { + registerInit({ + deps: { + scaffolder: scaffolderActionsExtensionPoint, + config: coreServices.rootConfig, + reader: coreServices.urlReader, + }, + async init({ scaffolder, config, reader }) { + const integrations = ScmIntegrations.fromConfig(config); + scaffolder.addActions( + createFetchCookiecutterAction({ reader, integrations }), + ); + }, + }); + }, +}); diff --git a/plugins/scaffolder-backend-module-gerrit/api-report.md b/plugins/scaffolder-backend-module-gerrit/api-report.md index 309de08574..e61de671a8 100644 --- a/plugins/scaffolder-backend-module-gerrit/api-report.md +++ b/plugins/scaffolder-backend-module-gerrit/api-report.md @@ -3,6 +3,7 @@ > 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'; import { Config } from '@backstage/config'; import { JsonObject } from '@backstage/types'; import { ScmIntegrationRegistry } from '@backstage/integration'; @@ -40,4 +41,8 @@ export function createPublishGerritReviewAction(options: { }, JsonObject >; + +// @public +const gerritModule: () => BackendFeature; +export default gerritModule; ``` diff --git a/plugins/scaffolder-backend-module-gerrit/package.json b/plugins/scaffolder-backend-module-gerrit/package.json index 59159560b5..a97d1d7c52 100644 --- a/plugins/scaffolder-backend-module-gerrit/package.json +++ b/plugins/scaffolder-backend-module-gerrit/package.json @@ -6,13 +6,22 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" }, "backstage": { "role": "backend-plugin-module" }, + "exports": { + ".": "./src/index.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "package.json": [ + "package.json" + ] + } + }, "scripts": { "start": "backstage-cli package start", "build": "backstage-cli package build", @@ -23,6 +32,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/index.ts b/plugins/scaffolder-backend-module-gerrit/src/index.ts index b00c307fa5..a3c54a4ec7 100644 --- a/plugins/scaffolder-backend-module-gerrit/src/index.ts +++ b/plugins/scaffolder-backend-module-gerrit/src/index.ts @@ -21,3 +21,4 @@ */ export * from './actions'; +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..32607431f3 --- /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'; + +/** + * @public + * 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.md b/plugins/scaffolder-backend-module-github/api-report.md index 920be79d12..d6a759dfa6 100644 --- a/plugins/scaffolder-backend-module-github/api-report.md +++ b/plugins/scaffolder-backend-module-github/api-report.md @@ -3,6 +3,7 @@ > 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'; import { Config } from '@backstage/config'; import { createPullRequest } from 'octokit-plugin-create-pull-request'; import { GithubCredentialsProvider } from '@backstage/integration'; @@ -377,4 +378,8 @@ export const createPublishGithubPullRequestAction: ( }, JsonObject >; + +// @public +const githubModule: () => BackendFeature; +export default githubModule; ``` diff --git a/plugins/scaffolder-backend-module-github/package.json b/plugins/scaffolder-backend-module-github/package.json index b035096dad..5f92a17e82 100644 --- a/plugins/scaffolder-backend-module-github/package.json +++ b/plugins/scaffolder-backend-module-github/package.json @@ -6,13 +6,22 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" }, "backstage": { "role": "backend-plugin-module" }, + "exports": { + ".": "./src/index.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "package.json": [ + "package.json" + ] + } + }, "scripts": { "start": "backstage-cli package start", "build": "backstage-cli package build", @@ -24,6 +33,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/index.ts b/plugins/scaffolder-backend-module-github/src/index.ts index 948a79d957..219ba54dbb 100644 --- a/plugins/scaffolder-backend-module-github/src/index.ts +++ b/plugins/scaffolder-backend-module-github/src/index.ts @@ -21,3 +21,4 @@ */ export * from './actions'; +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..79c954a6dd --- /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'; + +/** + * @public + * 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.md b/plugins/scaffolder-backend-module-gitlab/api-report.md index 9b3eec5cdf..94aabe9b72 100644 --- a/plugins/scaffolder-backend-module-gitlab/api-report.md +++ b/plugins/scaffolder-backend-module-gitlab/api-report.md @@ -3,6 +3,7 @@ > 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'; import { Config } from '@backstage/config'; import { JsonObject } from '@backstage/types'; import { ScmIntegrationRegistry } from '@backstage/integration'; @@ -191,6 +192,10 @@ export const createPublishGitlabMergeRequestAction: (options: { JsonObject >; +// @public +const gitlabModule: () => BackendFeature; +export default gitlabModule; + // @public export enum IssueType { // (undocumented) diff --git a/plugins/scaffolder-backend-module-gitlab/package.json b/plugins/scaffolder-backend-module-gitlab/package.json index ca7e90f8c8..77497fcd3f 100644 --- a/plugins/scaffolder-backend-module-gitlab/package.json +++ b/plugins/scaffolder-backend-module-gitlab/package.json @@ -5,9 +5,7 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" }, "backstage": { "role": "backend-plugin-module" @@ -21,6 +19,17 @@ "keywords": [ "backstage" ], + "exports": { + ".": "./src/index.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "package.json": [ + "package.json" + ] + } + }, "scripts": { "start": "backstage-cli package start", "build": "backstage-cli package build", @@ -32,6 +41,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/index.ts b/plugins/scaffolder-backend-module-gitlab/src/index.ts index 11d4247569..628b892296 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/index.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/index.ts @@ -21,3 +21,4 @@ */ export * from './actions'; +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..3571575827 --- /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'; + +/** + * @public + * 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/plugins/scaffolder-backend-module-rails/api-report.md b/plugins/scaffolder-backend-module-rails/api-report.md index 06b7dc457f..33ad052b14 100644 --- a/plugins/scaffolder-backend-module-rails/api-report.md +++ b/plugins/scaffolder-backend-module-rails/api-report.md @@ -3,6 +3,7 @@ > 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'; import { ContainerRunner } from '@backstage/backend-common'; import { JsonObject } from '@backstage/types'; import { ScmIntegrations } from '@backstage/integration'; @@ -13,7 +14,7 @@ import { UrlReader } from '@backstage/backend-common'; export function createFetchRailsAction(options: { reader: UrlReader; integrations: ScmIntegrations; - containerRunner: ContainerRunner; + containerRunner?: ContainerRunner; allowedImageNames?: string[]; }): TemplateAction< { @@ -24,4 +25,8 @@ export function createFetchRailsAction(options: { }, JsonObject >; + +// @public +const railsModule: () => BackendFeature; +export default railsModule; ``` diff --git a/plugins/scaffolder-backend-module-rails/package.json b/plugins/scaffolder-backend-module-rails/package.json index 65969643c1..da27657a6f 100644 --- a/plugins/scaffolder-backend-module-rails/package.json +++ b/plugins/scaffolder-backend-module-rails/package.json @@ -6,9 +6,7 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" }, "backstage": { "role": "backend-plugin-module" @@ -19,6 +17,17 @@ "url": "https://github.com/backstage/backstage", "directory": "plugins/scaffolder-backend-module-rails" }, + "exports": { + ".": "./src/index.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "package.json": [ + "package.json" + ] + } + }, "scripts": { "build": "backstage-cli package build", "start": "backstage-cli package start", @@ -30,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-rails/src/actions/fetch/rails/index.ts b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.ts index 2b34f978e3..dfc7bea418 100644 --- a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.ts +++ b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/index.ts @@ -40,7 +40,7 @@ import { RailsNewRunner } from './railsNewRunner'; export function createFetchRailsAction(options: { reader: UrlReader; integrations: ScmIntegrations; - containerRunner: ContainerRunner; + containerRunner?: ContainerRunner; /** A list of image names that are allowed to be passed as imageName input */ allowedImageNames?: string[]; }) { diff --git a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/railsNewRunner.ts b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/railsNewRunner.ts index 7e78c25d62..31cfea4a76 100644 --- a/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/railsNewRunner.ts +++ b/plugins/scaffolder-backend-module-rails/src/actions/fetch/rails/railsNewRunner.ts @@ -27,9 +27,9 @@ import { JsonObject } from '@backstage/types'; import { Writable } from 'stream'; export class RailsNewRunner { - private readonly containerRunner: ContainerRunner; + private readonly containerRunner?: ContainerRunner; - constructor({ containerRunner }: { containerRunner: ContainerRunner }) { + constructor({ containerRunner }: { containerRunner?: ContainerRunner }) { this.containerRunner = containerRunner; } @@ -77,6 +77,11 @@ export class RailsNewRunner { if (!imageName) { throw new Error('No imageName provided'); } + if (!this.containerRunner) { + throw new Error( + 'Command is not available and no container runner provided', + ); + } const arrayExtraArguments = railsArgumentResolver( '/input', railsArguments as RailsRunOptions, diff --git a/plugins/scaffolder-backend-module-rails/src/index.ts b/plugins/scaffolder-backend-module-rails/src/index.ts index 773e1feabd..ef89cc68d2 100644 --- a/plugins/scaffolder-backend-module-rails/src/index.ts +++ b/plugins/scaffolder-backend-module-rails/src/index.ts @@ -21,3 +21,4 @@ */ export * from './actions'; +export { railsModule as default } from './module'; diff --git a/plugins/scaffolder-backend-module-rails/src/module.ts b/plugins/scaffolder-backend-module-rails/src/module.ts new file mode 100644 index 0000000000..ec70610cd3 --- /dev/null +++ b/plugins/scaffolder-backend-module-rails/src/module.ts @@ -0,0 +1,45 @@ +/* + * 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 { createFetchRailsAction } from './actions'; +import { ScmIntegrations } from '@backstage/integration'; + +/** + * @public + * The Rails Module for the Scaffolder Backend + */ +export const railsModule = createBackendModule({ + pluginId: 'scaffolder', + moduleId: 'rails', + register({ registerInit }) { + registerInit({ + deps: { + scaffolder: scaffolderActionsExtensionPoint, + config: coreServices.rootConfig, + reader: coreServices.urlReader, + }, + async init({ scaffolder, config, reader }) { + const integrations = ScmIntegrations.fromConfig(config); + + scaffolder.addActions(createFetchRailsAction({ integrations, reader })); + }, + }); + }, +}); diff --git a/plugins/scaffolder-backend-module-sentry/api-report.md b/plugins/scaffolder-backend-module-sentry/api-report.md index 746cce1348..960fe4ba24 100644 --- a/plugins/scaffolder-backend-module-sentry/api-report.md +++ b/plugins/scaffolder-backend-module-sentry/api-report.md @@ -3,6 +3,7 @@ > 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'; import { Config } from '@backstage/config'; import { JsonObject } from '@backstage/types'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; @@ -21,5 +22,9 @@ export function createSentryCreateProjectAction(options: { JsonObject >; +// @public +const sentryModule: () => BackendFeature; +export default sentryModule; + // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/scaffolder-backend-module-sentry/package.json b/plugins/scaffolder-backend-module-sentry/package.json index 7828713d08..f5b8af13df 100644 --- a/plugins/scaffolder-backend-module-sentry/package.json +++ b/plugins/scaffolder-backend-module-sentry/package.json @@ -5,13 +5,22 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" }, "backstage": { "role": "backend-plugin-module" }, + "exports": { + ".": "./src/index.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "package.json": [ + "package.json" + ] + } + }, "homepage": "https://backstage.io", "repository": { "type": "git", @@ -28,6 +37,7 @@ "postpack": "backstage-cli package postpack" }, "dependencies": { + "@backstage/backend-plugin-api": "workspace:^", "@backstage/config": "workspace:^", "@backstage/errors": "workspace:^", "@backstage/plugin-scaffolder-node": "workspace:^", diff --git a/plugins/scaffolder-backend-module-sentry/src/alpha.ts b/plugins/scaffolder-backend-module-sentry/src/alpha.ts new file mode 100644 index 0000000000..94adcafa53 --- /dev/null +++ b/plugins/scaffolder-backend-module-sentry/src/alpha.ts @@ -0,0 +1,15 @@ +/* + * 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. + */ diff --git a/plugins/scaffolder-backend-module-sentry/src/index.ts b/plugins/scaffolder-backend-module-sentry/src/index.ts index f6c0820874..dc1a68675b 100644 --- a/plugins/scaffolder-backend-module-sentry/src/index.ts +++ b/plugins/scaffolder-backend-module-sentry/src/index.ts @@ -15,3 +15,4 @@ */ export { createSentryCreateProjectAction } from './actions/createProject'; +export { sentryModule as default } from './module'; diff --git a/plugins/scaffolder-backend-module-sentry/src/module.ts b/plugins/scaffolder-backend-module-sentry/src/module.ts new file mode 100644 index 0000000000..dcde344262 --- /dev/null +++ b/plugins/scaffolder-backend-module-sentry/src/module.ts @@ -0,0 +1,42 @@ +/* + * 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 { createSentryCreateProjectAction } from './actions/createProject'; + +/** + * @public + * The Sentry Module for the Scaffolder Backend + */ +export const sentryModule = createBackendModule({ + pluginId: 'scaffolder', + moduleId: 'sentry', + register({ registerInit }) { + registerInit({ + deps: { + scaffolder: scaffolderActionsExtensionPoint, + config: coreServices.rootConfig, + reade: coreServices.urlReader, + }, + async init({ scaffolder, config }) { + scaffolder.addActions(createSentryCreateProjectAction({ config })); + }, + }); + }, +}); diff --git a/plugins/scaffolder-backend-module-yeoman/api-report.md b/plugins/scaffolder-backend-module-yeoman/api-report.md index d8bdcb7b3b..b466ee152b 100644 --- a/plugins/scaffolder-backend-module-yeoman/api-report.md +++ b/plugins/scaffolder-backend-module-yeoman/api-report.md @@ -3,6 +3,7 @@ > 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'; import { JsonObject } from '@backstage/types'; import { TemplateAction } from '@backstage/plugin-scaffolder-node'; @@ -15,4 +16,8 @@ export function createRunYeomanAction(): TemplateAction< }, JsonObject >; + +// @public +const yeomanModule: () => BackendFeature; +export default yeomanModule; ``` diff --git a/plugins/scaffolder-backend-module-yeoman/package.json b/plugins/scaffolder-backend-module-yeoman/package.json index 94883084e4..8393e0be2f 100644 --- a/plugins/scaffolder-backend-module-yeoman/package.json +++ b/plugins/scaffolder-backend-module-yeoman/package.json @@ -5,13 +5,22 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" }, "backstage": { "role": "backend-plugin-module" }, + "exports": { + ".": "./src/index.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "package.json": [ + "package.json" + ] + } + }, "homepage": "https://backstage.io", "repository": { "type": "git", @@ -28,6 +37,7 @@ "clean": "backstage-cli package clean" }, "dependencies": { + "@backstage/backend-plugin-api": "workspace:^", "@backstage/plugin-scaffolder-node": "workspace:^", "@backstage/types": "workspace:^", "winston": "^3.2.1", diff --git a/plugins/scaffolder-backend-module-yeoman/src/index.ts b/plugins/scaffolder-backend-module-yeoman/src/index.ts index 1aac8e12f9..97966d6c08 100644 --- a/plugins/scaffolder-backend-module-yeoman/src/index.ts +++ b/plugins/scaffolder-backend-module-yeoman/src/index.ts @@ -21,3 +21,4 @@ * @packageDocumentation */ export * from './actions'; +export { yeomanModule as default } from './module'; diff --git a/plugins/scaffolder-backend-module-yeoman/src/module.ts b/plugins/scaffolder-backend-module-yeoman/src/module.ts new file mode 100644 index 0000000000..1fdbda28a3 --- /dev/null +++ b/plugins/scaffolder-backend-module-yeoman/src/module.ts @@ -0,0 +1,37 @@ +/* + * 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 { createBackendModule } from '@backstage/backend-plugin-api'; +import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha'; +import { createRunYeomanAction } from './actions'; + +/** + * @public + * The Yeoman Module for the Scaffolder Backend + */ +export const yeomanModule = createBackendModule({ + pluginId: 'scaffolder', + moduleId: 'yeoman', + register({ registerInit }) { + registerInit({ + deps: { + scaffolder: scaffolderActionsExtensionPoint, + }, + async init({ scaffolder }) { + scaffolder.addActions(createRunYeomanAction()); + }, + }); + }, +}); diff --git a/plugins/scaffolder-backend/src/ScaffolderPlugin.ts b/plugins/scaffolder-backend/src/ScaffolderPlugin.ts index beabaa50aa..4da725fde5 100644 --- a/plugins/scaffolder-backend/src/ScaffolderPlugin.ts +++ b/plugins/scaffolder-backend/src/ScaffolderPlugin.ts @@ -32,7 +32,18 @@ import { scaffolderTaskBrokerExtensionPoint, scaffolderTemplatingExtensionPoint, } from '@backstage/plugin-scaffolder-node/alpha'; -import { createBuiltinActions } from './scaffolder'; +import { + createCatalogRegisterAction, + createCatalogWriteAction, + createDebugLogAction, + createFetchCatalogEntityAction, + createFetchPlainAction, + createFetchPlainFileAction, + createFetchTemplateAction, + createFilesystemDeleteAction, + createFilesystemRenameAction, + createWaitAction, +} from './scaffolder'; import { createRouter } from './service/router'; /** @@ -91,20 +102,39 @@ export const scaffolderPlugin = createBackendPlugin({ permissions, }) { const log = loggerToWinstonLogger(logger); + const integrations = ScmIntegrations.fromConfig(config); const actions = [ + // actions provided from other modules ...addedActions, - ...createBuiltinActions({ - integrations: ScmIntegrations.fromConfig(config), - catalogClient, + + // built-in actions for the scaffolder + createFetchPlainAction({ + reader, + integrations, + }), + createFetchPlainFileAction({ + reader, + integrations, + }), + createFetchTemplateAction({ + integrations, reader, - config, additionalTemplateFilters, additionalTemplateGlobals, }), + createDebugLogAction(), + createWaitAction(), + // todo(blam): maybe these should be a -catalog module? + createCatalogRegisterAction({ catalogClient, integrations }), + createFetchCatalogEntityAction({ catalogClient }), + createCatalogWriteAction(), + createFilesystemDeleteAction(), + createFilesystemRenameAction(), ]; const actionIds = actions.map(action => action.id).join(', '); + log.info( `Starting scaffolder with the following actions enabled ${actionIds}`, ); diff --git a/yarn.lock b/yarn.lock index 003e6bd384..2b9dd3d2e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8024,6 +8024,7 @@ __metadata: resolution: "@backstage/plugin-scaffolder-backend-module-azure@workspace:plugins/scaffolder-backend-module-azure" dependencies: "@backstage/backend-common": "workspace:^" + "@backstage/backend-plugin-api": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" "@backstage/errors": "workspace:^" @@ -8039,6 +8040,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:^" @@ -8057,6 +8059,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:^" @@ -8077,6 +8080,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:^" @@ -8098,6 +8102,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:^" @@ -8115,6 +8120,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:^" @@ -8139,6 +8145,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:^" @@ -8160,6 +8167,7 @@ __metadata: resolution: "@backstage/plugin-scaffolder-backend-module-rails@workspace:plugins/scaffolder-backend-module-rails" dependencies: "@backstage/backend-common": "workspace:^" + "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" @@ -8180,6 +8188,7 @@ __metadata: version: 0.0.0-use.local resolution: "@backstage/plugin-scaffolder-backend-module-sentry@workspace:plugins/scaffolder-backend-module-sentry" dependencies: + "@backstage/backend-plugin-api": "workspace:^" "@backstage/backend-test-utils": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/config": "workspace:^" @@ -8196,6 +8205,7 @@ __metadata: resolution: "@backstage/plugin-scaffolder-backend-module-yeoman@workspace:plugins/scaffolder-backend-module-yeoman" dependencies: "@backstage/backend-common": "workspace:^" + "@backstage/backend-plugin-api": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/plugin-scaffolder-node": "workspace:^" "@backstage/types": "workspace:^"