move out bitbucket into a separate module too

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-03-09 17:07:43 +01:00
parent 0dd12e3f35
commit 47a5ae5dd2
22 changed files with 218 additions and 85 deletions
@@ -1,3 +1 @@
module.exports = {
extends: [require.resolve('@backstage/cli/config/eslint.backend')],
};
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
@@ -0,0 +1 @@
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
@@ -0,0 +1,8 @@
# Catalog Backend Module for Bitbucket
This is an extension module to the plugin-catalog-backend plugin, providing extensions targeted at Bitbucket offerings.
## Getting started
See [Backstage documentation](https://backstage.io/docs/integrations/bitbucket/discovery) for details on how to install
and configure the plugin.
@@ -0,0 +1,49 @@
## API Report File for "@backstage/plugin-catalog-backend-module-bitbucket"
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { BitbucketIntegration } from '@backstage/integration';
import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
import { CatalogProcessorResult } from '@backstage/plugin-catalog-backend';
import { Config } from '@backstage/config';
import { LocationSpec } from '@backstage/plugin-catalog-backend';
import { Logger } from 'winston';
import { ScmIntegrationRegistry } from '@backstage/integration';
// @public (undocumented)
export class BitbucketDiscoveryProcessor implements CatalogProcessor {
constructor(options: {
integrations: ScmIntegrationRegistry;
parser?: (options: {
integration: BitbucketIntegration;
target: string;
presence?: 'optional' | 'required';
logger: Logger;
}) => AsyncIterable<CatalogProcessorResult>;
logger: Logger;
});
// (undocumented)
static fromConfig(
config: Config,
options: {
parser?: (options: {
integration: BitbucketIntegration;
target: string;
presence?: 'optional' | 'required';
logger: Logger;
}) => AsyncIterable<CatalogProcessorResult>;
logger: Logger;
},
): BitbucketDiscoveryProcessor;
// (undocumented)
getProcessorName(): string;
// (undocumented)
readLocation(
location: LocationSpec,
_optional: boolean,
emit: CatalogProcessorEmit,
): Promise<boolean>;
}
```
@@ -0,0 +1,56 @@
{
"name": "@backstage/plugin-catalog-backend-module-bitbucket",
"description": "A Backstage catalog backend module that helps integrate towards Bitbucket",
"version": "0.0.0",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
"private": false,
"publishConfig": {
"access": "public",
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts"
},
"backstage": {
"role": "backend-plugin-module"
},
"homepage": "https://backstage.io",
"repository": {
"type": "git",
"url": "https://github.com/backstage/backstage",
"directory": "plugins/catalog-backend-module-bitbucket"
},
"keywords": [
"backstage"
],
"scripts": {
"build": "backstage-cli package build",
"lint": "backstage-cli package lint",
"test": "backstage-cli package test",
"prepack": "backstage-cli package prepack",
"postpack": "backstage-cli package postpack",
"clean": "backstage-cli package clean",
"start": "backstage-cli package start"
},
"dependencies": {
"@backstage/backend-common": "^0.12.0",
"@backstage/catalog-model": "^0.12.0",
"@backstage/config": "^0.1.15",
"@backstage/errors": "^0.2.2",
"@backstage/integration": "^0.8.0",
"@backstage/plugin-catalog-backend": "^0.23.0",
"@backstage/types": "^0.1.3",
"lodash": "^4.17.21",
"msw": "^0.35.0",
"node-fetch": "^2.6.7",
"winston": "^3.2.1"
},
"devDependencies": {
"@backstage/backend-test-utils": "^0.1.20",
"@backstage/cli": "^0.15.0",
"@types/lodash": "^4.14.151"
},
"files": [
"dist"
]
}
@@ -15,12 +15,15 @@
*/
import { getVoidLogger } from '@backstage/backend-common';
import { BitbucketDiscoveryProcessor } from './BitbucketDiscoveryProcessor';
import { ConfigReader } from '@backstage/config';
import {
LocationSpec,
processingResult,
} from '@backstage/plugin-catalog-backend';
import { RequestHandler, rest } from 'msw';
import { setupServer } from 'msw/node';
import { BitbucketDiscoveryProcessor } from './BitbucketDiscoveryProcessor';
import { BitbucketRepository20, PagedResponse, PagedResponse20 } from './lib';
import { LocationSpec, processingResult } from '../../api';
const server = setupServer();
@@ -14,28 +14,27 @@
* limitations under the License.
*/
import { Logger } from 'winston';
import { Config } from '@backstage/config';
import {
BitbucketIntegration,
ScmIntegrationRegistry,
ScmIntegrations,
} from '@backstage/integration';
import {
BitbucketClient,
defaultRepositoryParser,
paginated,
paginated20,
BitbucketRepository,
BitbucketRepository20,
} from './lib';
import {
CatalogProcessor,
CatalogProcessorEmit,
CatalogProcessorResult,
LocationSpec,
} from '../../api';
} from '@backstage/plugin-catalog-backend';
import { Logger } from 'winston';
import {
BitbucketClient,
BitbucketRepository,
BitbucketRepository20,
defaultRepositoryParser,
paginated,
paginated20,
} from './lib';
const DEFAULT_BRANCH = 'master';
const DEFAULT_CATALOG_LOCATION = '/catalog-info.yaml';
@@ -1,5 +1,5 @@
/*
* Copyright 2022 The Backstage Authors
* Copyright 2020 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.
@@ -14,5 +14,10 @@
* limitations under the License.
*/
/**
* A Backstage catalog backend module that helps integrate towards GitLab
*
* @packageDocumentation
*/
export { BitbucketDiscoveryProcessor } from './BitbucketDiscoveryProcessor';
export type { BitbucketRepositoryParser } from './lib';
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { processingResult } from '../../../api';
import { processingResult } from '@backstage/plugin-catalog-backend';
import { defaultRepositoryParser } from './BitbucketRepositoryParser';
describe('BitbucketRepositoryParser', () => {
@@ -15,13 +15,12 @@
*/
import { BitbucketIntegration } from '@backstage/integration';
import {
CatalogProcessorResult,
processingResult,
} from '@backstage/plugin-catalog-backend';
import { Logger } from 'winston';
import { CatalogProcessorResult, processingResult } from '../../../api';
/**
* @public
* @deprecated type inlined.
*/
export type BitbucketRepositoryParser = (options: {
integration: BitbucketIntegration;
target: string;
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import fetch from 'node-fetch';
import {
BitbucketIntegrationConfig,
getBitbucketRequestOptions,
} from '@backstage/integration';
import fetch from 'node-fetch';
import { BitbucketRepository20 } from './types';
export class BitbucketClient {
@@ -14,8 +14,8 @@
* limitations under the License.
*/
export { BitbucketClient, paginated, paginated20 } from './client';
export { defaultRepositoryParser } from './BitbucketRepositoryParser';
export type { BitbucketRepositoryParser } from './BitbucketRepositoryParser';
export { BitbucketClient, paginated, paginated20 } from './client';
export type { PagedResponse, PagedResponse20 } from './client';
export type { BitbucketRepository, BitbucketRepository20 } from './types';
export type { BitbucketRepositoryParser } from './BitbucketRepositoryParser';
@@ -0,0 +1,17 @@
/*
* Copyright 2020 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 {};
@@ -1,3 +1 @@
module.exports = {
extends: [require.resolve('@backstage/cli/config/eslint.backend')],
};
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
-44
View File
@@ -5,7 +5,6 @@
```ts
/// <reference types="node" />
import { BitbucketIntegration } from '@backstage/integration';
import { CatalogApi } from '@backstage/catalog-client';
import { CatalogEntityDocument as CatalogEntityDocument_2 } from '@backstage/plugin-catalog-common';
import { CompoundEntityRef } from '@backstage/catalog-model';
@@ -97,49 +96,6 @@ export class AnnotateScmSlugEntityProcessor implements CatalogProcessor {
preProcessEntity(entity: Entity, location: LocationSpec): Promise<Entity>;
}
// @public (undocumented)
export class BitbucketDiscoveryProcessor implements CatalogProcessor {
constructor(options: {
integrations: ScmIntegrationRegistry;
parser?: (options: {
integration: BitbucketIntegration;
target: string;
presence?: 'optional' | 'required';
logger: Logger;
}) => AsyncIterable<CatalogProcessorResult>;
logger: Logger;
});
// (undocumented)
static fromConfig(
config: Config,
options: {
parser?: (options: {
integration: BitbucketIntegration;
target: string;
presence?: 'optional' | 'required';
logger: Logger;
}) => AsyncIterable<CatalogProcessorResult>;
logger: Logger;
},
): BitbucketDiscoveryProcessor;
// (undocumented)
getProcessorName(): string;
// (undocumented)
readLocation(
location: LocationSpec,
_optional: boolean,
emit: CatalogProcessorEmit,
): Promise<boolean>;
}
// @public @deprecated (undocumented)
export type BitbucketRepositoryParser = (options: {
integration: BitbucketIntegration;
target: string;
presence?: 'optional' | 'required';
logger: Logger;
}) => AsyncIterable<CatalogProcessorResult>;
// @public (undocumented)
export class BuiltinKindsEntityProcessor implements CatalogProcessor {
// (undocumented)
@@ -14,7 +14,6 @@
* limitations under the License.
*/
export * from './bitbucket';
export * from './codeowners';
export * from './core';
export * from './github';
@@ -45,7 +45,6 @@ import {
} from '../api';
import {
AnnotateLocationEntityProcessor,
BitbucketDiscoveryProcessor,
BuiltinKindsEntityProcessor,
CodeOwnersProcessor,
FileReaderProcessor,
@@ -357,7 +356,6 @@ export class CatalogBuilder {
return [
new FileReaderProcessor(),
BitbucketDiscoveryProcessor.fromConfig(config, { logger }),
GithubDiscoveryProcessor.fromConfig(config, {
logger,
githubCredentialsProvider,