From 115e4a592c92c13ff0a45eb9dd27a32fb127b70b Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 18 Jan 2024 17:02:52 +0100 Subject: [PATCH] feat: final modules Signed-off-by: blam --- .../api-report-alpha.md | 13 ++++++ .../api-report.md | 2 +- .../package.json | 16 +++++++ .../src/actions/fetch/rails/index.ts | 2 +- .../src/actions/fetch/rails/railsNewRunner.ts | 9 +++- .../src/alpha.ts | 16 +++++++ .../src/module.ts | 45 +++++++++++++++++++ .../api-report-alpha.md | 13 ++++++ .../package.json | 16 +++++++ .../src/alpha.ts | 16 +++++++ .../src/module.ts | 42 +++++++++++++++++ .../api-report-alpha.md | 13 ++++++ .../package.json | 16 +++++++ .../src/alpha.ts | 16 +++++++ .../src/module.ts | 37 +++++++++++++++ 15 files changed, 268 insertions(+), 4 deletions(-) create mode 100644 plugins/scaffolder-backend-module-rails/api-report-alpha.md create mode 100644 plugins/scaffolder-backend-module-rails/src/alpha.ts create mode 100644 plugins/scaffolder-backend-module-rails/src/module.ts create mode 100644 plugins/scaffolder-backend-module-sentry/api-report-alpha.md create mode 100644 plugins/scaffolder-backend-module-sentry/src/alpha.ts create mode 100644 plugins/scaffolder-backend-module-sentry/src/module.ts create mode 100644 plugins/scaffolder-backend-module-yeoman/api-report-alpha.md create mode 100644 plugins/scaffolder-backend-module-yeoman/src/alpha.ts create mode 100644 plugins/scaffolder-backend-module-yeoman/src/module.ts diff --git a/plugins/scaffolder-backend-module-rails/api-report-alpha.md b/plugins/scaffolder-backend-module-rails/api-report-alpha.md new file mode 100644 index 0000000000..67ba4de16b --- /dev/null +++ b/plugins/scaffolder-backend-module-rails/api-report-alpha.md @@ -0,0 +1,13 @@ +## API Report File for "@backstage/plugin-scaffolder-backend-module-rails" + +> 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 railsModule: () => BackendFeature; +export default railsModule; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/scaffolder-backend-module-rails/api-report.md b/plugins/scaffolder-backend-module-rails/api-report.md index 06b7dc457f..0ecdae00f1 100644 --- a/plugins/scaffolder-backend-module-rails/api-report.md +++ b/plugins/scaffolder-backend-module-rails/api-report.md @@ -13,7 +13,7 @@ import { UrlReader } from '@backstage/backend-common'; export function createFetchRailsAction(options: { reader: UrlReader; integrations: ScmIntegrations; - containerRunner: ContainerRunner; + containerRunner?: ContainerRunner; allowedImageNames?: string[]; }): TemplateAction< { diff --git a/plugins/scaffolder-backend-module-rails/package.json b/plugins/scaffolder-backend-module-rails/package.json index 65969643c1..94eb026b07 100644 --- a/plugins/scaffolder-backend-module-rails/package.json +++ b/plugins/scaffolder-backend-module-rails/package.json @@ -19,6 +19,21 @@ "url": "https://github.com/backstage/backstage", "directory": "plugins/scaffolder-backend-module-rails" }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "alpha": [ + "src/alpha.ts" + ], + "package.json": [ + "package.json" + ] + } + }, "scripts": { "build": "backstage-cli package build", "start": "backstage-cli package start", @@ -29,6 +44,7 @@ "clean": "backstage-cli package clean" }, "dependencies": { + "@backstage/backend-plugin-api": "workspace:^", "@backstage/backend-common": "workspace:^", "@backstage/config": "workspace:^", "@backstage/errors": "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/alpha.ts b/plugins/scaffolder-backend-module-rails/src/alpha.ts new file mode 100644 index 0000000000..36b4b3bded --- /dev/null +++ b/plugins/scaffolder-backend-module-rails/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 { 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..06bb8ac395 --- /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'; + +/** + * @alpha + * 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-alpha.md b/plugins/scaffolder-backend-module-sentry/api-report-alpha.md new file mode 100644 index 0000000000..c605fa406a --- /dev/null +++ b/plugins/scaffolder-backend-module-sentry/api-report-alpha.md @@ -0,0 +1,13 @@ +## API Report File for "@backstage/plugin-scaffolder-backend-module-sentry" + +> 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 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..0e3d60864f 100644 --- a/plugins/scaffolder-backend-module-sentry/package.json +++ b/plugins/scaffolder-backend-module-sentry/package.json @@ -12,6 +12,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" + ] + } + }, "homepage": "https://backstage.io", "repository": { "type": "git", @@ -28,6 +43,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..f9e568692e --- /dev/null +++ b/plugins/scaffolder-backend-module-sentry/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 { 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..b936f9f22d --- /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'; + +/** + * @alpha + * 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-alpha.md b/plugins/scaffolder-backend-module-yeoman/api-report-alpha.md new file mode 100644 index 0000000000..16424940cb --- /dev/null +++ b/plugins/scaffolder-backend-module-yeoman/api-report-alpha.md @@ -0,0 +1,13 @@ +## API Report File for "@backstage/plugin-scaffolder-backend-module-yeoman" + +> 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 yeomanModule: () => BackendFeature; +export default yeomanModule; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/scaffolder-backend-module-yeoman/package.json b/plugins/scaffolder-backend-module-yeoman/package.json index 94883084e4..034ee14716 100644 --- a/plugins/scaffolder-backend-module-yeoman/package.json +++ b/plugins/scaffolder-backend-module-yeoman/package.json @@ -12,6 +12,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" + ] + } + }, "homepage": "https://backstage.io", "repository": { "type": "git", @@ -28,6 +43,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/alpha.ts b/plugins/scaffolder-backend-module-yeoman/src/alpha.ts new file mode 100644 index 0000000000..f66c3a1ac8 --- /dev/null +++ b/plugins/scaffolder-backend-module-yeoman/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 { 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..e108f4d367 --- /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'; + +/** + * @alpha + * 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()); + }, + }); + }, +});