From fbb1071987616a783baf117a91d7d8317ffb46f5 Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 6 Dec 2023 12:33:02 +0100 Subject: [PATCH] chore: create bitbucket modules Signed-off-by: blam --- .../.eslintrc.js | 1 + .../README.md | 5 +++ .../package.json | 42 +++++++++++++++++++ .../src/actions}/bitbucket.examples.test.ts | 5 ++- .../src/actions}/bitbucket.examples.ts | 0 .../src/actions}/bitbucket.test.ts | 6 +-- .../src/actions}/bitbucket.ts | 9 ++-- .../src/actions}/bitbucketCloud.test.ts | 5 ++- .../src/actions}/bitbucketCloud.ts | 10 +++-- .../src/actions}/bitbucketServer.test.ts | 5 ++- .../src/actions}/bitbucketServer.ts | 10 +++-- .../bitbucketServerPullRequest.test.ts | 3 +- .../actions}/bitbucketServerPullRequest.ts | 6 ++- .../src/actions/index.ts | 19 +++++++++ .../src/index.ts | 23 ++++++++++ 15 files changed, 128 insertions(+), 21 deletions(-) create mode 100644 plugins/scaffolder-backend-module-bitbucket/.eslintrc.js create mode 100644 plugins/scaffolder-backend-module-bitbucket/README.md create mode 100644 plugins/scaffolder-backend-module-bitbucket/package.json rename plugins/{scaffolder-backend/src/scaffolder/actions/builtin/publish => scaffolder-backend-module-bitbucket/src/actions}/bitbucket.examples.test.ts (98%) rename plugins/{scaffolder-backend/src/scaffolder/actions/builtin/publish => scaffolder-backend-module-bitbucket/src/actions}/bitbucket.examples.ts (100%) rename plugins/{scaffolder-backend/src/scaffolder/actions/builtin/publish => scaffolder-backend-module-bitbucket/src/actions}/bitbucket.test.ts (98%) rename plugins/{scaffolder-backend/src/scaffolder/actions/builtin/publish => scaffolder-backend-module-bitbucket/src/actions}/bitbucket.ts (98%) rename plugins/{scaffolder-backend/src/scaffolder/actions/builtin/publish => scaffolder-backend-module-bitbucket/src/actions}/bitbucketCloud.test.ts (98%) rename plugins/{scaffolder-backend/src/scaffolder/actions/builtin/publish => scaffolder-backend-module-bitbucket/src/actions}/bitbucketCloud.ts (97%) rename plugins/{scaffolder-backend/src/scaffolder/actions/builtin/publish => scaffolder-backend-module-bitbucket/src/actions}/bitbucketServer.test.ts (99%) rename plugins/{scaffolder-backend/src/scaffolder/actions/builtin/publish => scaffolder-backend-module-bitbucket/src/actions}/bitbucketServer.ts (97%) rename plugins/{scaffolder-backend/src/scaffolder/actions/builtin/publish => scaffolder-backend-module-bitbucket/src/actions}/bitbucketServerPullRequest.test.ts (98%) rename plugins/{scaffolder-backend/src/scaffolder/actions/builtin/publish => scaffolder-backend-module-bitbucket/src/actions}/bitbucketServerPullRequest.ts (98%) create mode 100644 plugins/scaffolder-backend-module-bitbucket/src/actions/index.ts create mode 100644 plugins/scaffolder-backend-module-bitbucket/src/index.ts diff --git a/plugins/scaffolder-backend-module-bitbucket/.eslintrc.js b/plugins/scaffolder-backend-module-bitbucket/.eslintrc.js new file mode 100644 index 0000000000..e2a53a6ad2 --- /dev/null +++ b/plugins/scaffolder-backend-module-bitbucket/.eslintrc.js @@ -0,0 +1 @@ +module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); diff --git a/plugins/scaffolder-backend-module-bitbucket/README.md b/plugins/scaffolder-backend-module-bitbucket/README.md new file mode 100644 index 0000000000..90b8680e80 --- /dev/null +++ b/plugins/scaffolder-backend-module-bitbucket/README.md @@ -0,0 +1,5 @@ +# @backstage/plugin-scaffolder-backend-module-bitbucket + +The bitbucket module for [@backstage/plugin-scaffolder-backend](https://www.npmjs.com/package/@backstage/plugin-scaffolder-backend). + +_This plugin was created through the Backstage CLI_ diff --git a/plugins/scaffolder-backend-module-bitbucket/package.json b/plugins/scaffolder-backend-module-bitbucket/package.json new file mode 100644 index 0000000000..4c92ce01a2 --- /dev/null +++ b/plugins/scaffolder-backend-module-bitbucket/package.json @@ -0,0 +1,42 @@ +{ + "name": "@backstage/plugin-scaffolder-backend-module-bitbucket", + "description": "The bitbucket module for @backstage/plugin-scaffolder-backend", + "version": "0.0.0", + "main": "src/index.ts", + "types": "src/index.ts", + "license": "Apache-2.0", + "publishConfig": { + "access": "public", + "main": "dist/index.cjs.js", + "types": "dist/index.d.ts" + }, + "backstage": { + "role": "backend-plugin-module" + }, + "scripts": { + "start": "backstage-cli package start", + "build": "backstage-cli package build", + "lint": "backstage-cli package lint", + "test": "backstage-cli package test", + "clean": "backstage-cli package clean", + "prepack": "backstage-cli package prepack", + "postpack": "backstage-cli package postpack" + }, + "dependencies": { + "@backstage/backend-common": "workspace:^", + "@backstage/config": "workspace:^", + "@backstage/errors": "workspace:^", + "@backstage/integration": "workspace:^", + "@backstage/plugin-scaffolder-node": "workspace:^", + "node-fetch": "^2.6.7", + "yaml": "^2.0.0" + }, + "devDependencies": { + "@backstage/backend-test-utils": "workspace:^", + "@backstage/cli": "workspace:^", + "msw": "^1.0.0" + }, + "files": [ + "dist" + ] +} diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.examples.test.ts b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucket.examples.test.ts similarity index 98% rename from plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.examples.test.ts rename to plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucket.examples.test.ts index a1564d0498..73325ab5bf 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.examples.test.ts +++ b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucket.examples.test.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -jest.mock('../helpers', () => { +jest.mock('@backstage/plugin-scaffolder-node', () => { return { + ...jest.requireActual('@backstage/plugin-scaffolder-node'), initRepoAndPush: jest.fn().mockResolvedValue({ commitHash: '220f19cc36b551763d157f1b5e4a4b446165dbd6', }), @@ -33,7 +34,7 @@ import { ScmIntegrations } from '@backstage/integration'; import { ConfigReader } from '@backstage/config'; import { getVoidLogger } from '@backstage/backend-common'; import { PassThrough } from 'stream'; -import { initRepoAndPush } from '../helpers'; +import { initRepoAndPush } from '@backstage/plugin-scaffolder-node'; import yaml from 'yaml'; import { sep } from 'path'; import { examples } from './bitbucket.examples'; diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.examples.ts b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucket.examples.ts similarity index 100% rename from plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.examples.ts rename to plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucket.examples.ts diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.test.ts b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucket.test.ts similarity index 98% rename from plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.test.ts rename to plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucket.test.ts index 5d46a28a60..d6e068c039 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.test.ts +++ b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucket.test.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -jest.mock('../helpers', () => { +jest.mock('@backstage/plugin-scaffolder-node', () => { return { + ...jest.requireActual('@backstage/plugin-scaffolder-node'), initRepoAndPush: jest.fn().mockResolvedValue({ commitHash: '220f19cc36b551763d157f1b5e4a4b446165dbd6', }), @@ -24,7 +25,6 @@ jest.mock('../helpers', () => { }), }; }); - import { createPublishBitbucketAction } from './bitbucket'; import { rest } from 'msw'; import { setupServer } from 'msw/node'; @@ -33,7 +33,7 @@ import { ScmIntegrations } from '@backstage/integration'; import { ConfigReader } from '@backstage/config'; import { getVoidLogger } from '@backstage/backend-common'; import { PassThrough } from 'stream'; -import { initRepoAndPush } from '../helpers'; +import { initRepoAndPush } from '@backstage/plugin-scaffolder-node'; describe('publish:bitbucket', () => { const config = new ConfigReader({ diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.ts b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucket.ts similarity index 98% rename from plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.ts rename to plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucket.ts index a4d664e0e7..76fe1de5df 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucket.ts +++ b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucket.ts @@ -19,10 +19,13 @@ import { BitbucketIntegrationConfig, ScmIntegrationRegistry, } from '@backstage/integration'; -import { createTemplateAction } from '@backstage/plugin-scaffolder-node'; +import { + createTemplateAction, + initRepoAndPush, + getRepoSourceDirectory, + parseRepoUrl, +} from '@backstage/plugin-scaffolder-node'; import fetch, { Response, RequestInit } from 'node-fetch'; -import { initRepoAndPush } from '../helpers'; -import { getRepoSourceDirectory, parseRepoUrl } from './util'; import { Config } from '@backstage/config'; import { examples } from './bitbucket.examples'; diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketCloud.test.ts b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketCloud.test.ts similarity index 98% rename from plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketCloud.test.ts rename to plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketCloud.test.ts index 3159bfc562..7045d58e01 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketCloud.test.ts +++ b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketCloud.test.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -jest.mock('../helpers', () => { +jest.mock('@backstage/plugin-scaffolder-node', () => { return { + ...jest.requireActual('@backstage/plugin-scaffolder-node'), initRepoAndPush: jest.fn().mockResolvedValue({ commitHash: '220f19cc36b551763d157f1b5e4a4b446165dbd6', }), @@ -33,7 +34,7 @@ import { ScmIntegrations } from '@backstage/integration'; import { ConfigReader } from '@backstage/config'; import { getVoidLogger } from '@backstage/backend-common'; import { PassThrough } from 'stream'; -import { initRepoAndPush } from '../helpers'; +import { initRepoAndPush } from '@backstage/plugin-scaffolder-node'; describe('publish:bitbucketCloud', () => { const config = new ConfigReader({ diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketCloud.ts b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketCloud.ts similarity index 97% rename from plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketCloud.ts rename to plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketCloud.ts index 00529d5856..c69ae0b147 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketCloud.ts +++ b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketCloud.ts @@ -16,10 +16,14 @@ import { InputError } from '@backstage/errors'; import { ScmIntegrationRegistry } from '@backstage/integration'; -import { createTemplateAction } from '@backstage/plugin-scaffolder-node'; +import { + createTemplateAction, + initRepoAndPush, + getRepoSourceDirectory, + parseRepoUrl, +} from '@backstage/plugin-scaffolder-node'; import fetch, { Response, RequestInit } from 'node-fetch'; -import { initRepoAndPush } from '../helpers'; -import { getRepoSourceDirectory, parseRepoUrl } from './util'; + import { Config } from '@backstage/config'; const createRepository = async (opts: { diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.test.ts b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketServer.test.ts similarity index 99% rename from plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.test.ts rename to plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketServer.test.ts index 67a29210fc..ab7b52996f 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.test.ts +++ b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketServer.test.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -jest.mock('../helpers', () => { +jest.mock('@backstage/plugin-scaffolder-node', () => { return { + ...jest.requireActual('@backstage/plugin-scaffolder-node'), initRepoAndPush: jest.fn().mockResolvedValue({ commitHash: '220f19cc36b551763d157f1b5e4a4b446165dbd6', }), @@ -33,7 +34,7 @@ import { ScmIntegrations } from '@backstage/integration'; import { ConfigReader } from '@backstage/config'; import { getVoidLogger } from '@backstage/backend-common'; import { PassThrough } from 'stream'; -import { initRepoAndPush } from '../helpers'; +import { initRepoAndPush } from '@backstage/plugin-scaffolder-node'; describe('publish:bitbucketServer', () => { const config = new ConfigReader({ diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketServer.ts similarity index 97% rename from plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts rename to plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketServer.ts index 66b7a46f77..31125deab2 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts +++ b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketServer.ts @@ -19,10 +19,14 @@ import { getBitbucketServerRequestOptions, ScmIntegrationRegistry, } from '@backstage/integration'; -import { createTemplateAction } from '@backstage/plugin-scaffolder-node'; +import { + createTemplateAction, + initRepoAndPush, + getRepoSourceDirectory, + parseRepoUrl, +} from '@backstage/plugin-scaffolder-node'; import fetch, { Response, RequestInit } from 'node-fetch'; -import { initRepoAndPush } from '../helpers'; -import { getRepoSourceDirectory, parseRepoUrl } from './util'; + import { Config } from '@backstage/config'; const createRepository = async (opts: { diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServerPullRequest.test.ts b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketServerPullRequest.test.ts similarity index 98% rename from plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServerPullRequest.test.ts rename to plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketServerPullRequest.test.ts index af3999097f..3af47853c3 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServerPullRequest.test.ts +++ b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketServerPullRequest.test.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -jest.mock('../helpers', () => { +jest.mock('@backstage/plugin-scaffolder-node', () => { return { + ...jest.requireActual('@backstage/plugin-scaffolder-node'), initRepoAndPush: jest.fn().mockResolvedValue({ commitHash: '220f19cc36b551763d157f1b5e4a4b446165dbd6', }), diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServerPullRequest.ts b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketServerPullRequest.ts similarity index 98% rename from plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServerPullRequest.ts rename to plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketServerPullRequest.ts index 79711b9d69..dc75145ebc 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServerPullRequest.ts +++ b/plugins/scaffolder-backend-module-bitbucket/src/actions/bitbucketServerPullRequest.ts @@ -19,9 +19,11 @@ import { getBitbucketServerRequestOptions, ScmIntegrationRegistry, } from '@backstage/integration'; -import { createTemplateAction } from '@backstage/plugin-scaffolder-node'; +import { + createTemplateAction, + parseRepoUrl, +} from '@backstage/plugin-scaffolder-node'; import fetch, { RequestInit, Response } from 'node-fetch'; -import { parseRepoUrl } from './util'; import { Config } from '@backstage/config'; const createPullRequest = async (opts: { diff --git a/plugins/scaffolder-backend-module-bitbucket/src/actions/index.ts b/plugins/scaffolder-backend-module-bitbucket/src/actions/index.ts new file mode 100644 index 0000000000..1093b07785 --- /dev/null +++ b/plugins/scaffolder-backend-module-bitbucket/src/actions/index.ts @@ -0,0 +1,19 @@ +/* + * Copyright 2023 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 * from './bitbucket'; +export * from './bitbucketCloud'; +export * from './bitbucketServer'; +export * from './bitbucketServerPullRequest'; diff --git a/plugins/scaffolder-backend-module-bitbucket/src/index.ts b/plugins/scaffolder-backend-module-bitbucket/src/index.ts new file mode 100644 index 0000000000..6448b82c8b --- /dev/null +++ b/plugins/scaffolder-backend-module-bitbucket/src/index.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2023 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. + */ + +/** + * The bitbucket module for @backstage/plugin-scaffolder-backend. + * + * @packageDocumentation + */ + +export * from './actions';