Merge pull request #11345 from Bonial-International-GmbH/PJ_bitbucketCloud-provider
feat: add new BitbucketCloudEntityProvider and common/shared client lib
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend-module-bitbucket-cloud': minor
|
||||
---
|
||||
|
||||
Add new plugin `catalog-backend-module-bitbucket-cloud` with `BitbucketCloudEntityProvider`.
|
||||
|
||||
This entity provider is an alternative/replacement to the `BitbucketDiscoveryProcessor` **_(for Bitbucket Cloud only!)_**.
|
||||
It replaces use cases using `search=true` and should be powerful enough as a complete replacement.
|
||||
|
||||
If any feature for Bitbucket Cloud is missing and preventing you from switching, please raise an issue.
|
||||
|
||||
**Before:**
|
||||
|
||||
```typescript
|
||||
// packages/backend/src/plugins/catalog.ts
|
||||
|
||||
builder.addProcessor(
|
||||
BitbucketDiscoveryProcessor.fromConfig(env.config, { logger: env.logger }),
|
||||
);
|
||||
```
|
||||
|
||||
```yaml
|
||||
# app-config.yaml
|
||||
|
||||
catalog:
|
||||
locations:
|
||||
- type: bitbucket-discovery
|
||||
target: 'https://bitbucket.org/workspaces/workspace-name/projects/apis-*/repos/service-*?search=true&catalogPath=/catalog-info.yaml'
|
||||
```
|
||||
|
||||
**After:**
|
||||
|
||||
```typescript
|
||||
// packages/backend/src/plugins/catalog.ts
|
||||
builder.addEntityProvider(
|
||||
BitbucketCloudEntityProvider.fromConfig(env.config, {
|
||||
logger: env.logger,
|
||||
schedule: env.scheduler.createScheduledTaskRunner({
|
||||
frequency: { minutes: 30 },
|
||||
timeout: { minutes: 3 },
|
||||
}),
|
||||
}),
|
||||
);
|
||||
```
|
||||
|
||||
```yaml
|
||||
# app-config.yaml
|
||||
|
||||
catalog:
|
||||
providers:
|
||||
bitbucketCloud:
|
||||
yourProviderId: # identifies your ingested dataset
|
||||
catalogPath: /catalog-info.yaml # default value
|
||||
filters: # optional
|
||||
projectKey: '^apis-.*$' # optional; RegExp
|
||||
repoSlug: '^service-.*$' # optional; RegExp
|
||||
workspace: workspace-name
|
||||
```
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
'@backstage/plugin-bitbucket-cloud-common': minor
|
||||
---
|
||||
|
||||
Add new common library `bitbucket-cloud-common` with a client for Bitbucket Cloud.
|
||||
|
||||
This client can be reused across all packages and might be the future place for additional
|
||||
features like managing the rate limits, etc.
|
||||
|
||||
The client itself was generated in parts using the `@openapitools/openapi-generator-cli`.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend-module-bitbucket': minor
|
||||
---
|
||||
|
||||
Integrate `@backstage/plugin-bitbucket-cloud-common` as replacement for the `BitbucketCloudClient`.
|
||||
@@ -15,25 +15,7 @@ plugin.
|
||||
|
||||
## Bitbucket Cloud
|
||||
|
||||
```yaml
|
||||
integrations:
|
||||
bitbucketCloud:
|
||||
- username: ${BITBUCKET_CLOUD_USERNAME}
|
||||
appPassword: ${BITBUCKET_CLOUD_PASSWORD}
|
||||
```
|
||||
|
||||
> Note: A public Bitbucket Cloud provider is added automatically at startup for
|
||||
> convenience, so you only need to list it if you want to supply credentials.
|
||||
|
||||
Directly under the `bitbucketCloud` key is a list of provider configurations, where
|
||||
you can list the Bitbucket Cloud providers you want to fetch data from.
|
||||
In the case of Bitbucket Cloud, you will have up to one entry.
|
||||
|
||||
This one entry will have the following elements:
|
||||
|
||||
- `username`: The Bitbucket Cloud username to use in API requests. If
|
||||
neither a username nor token are supplied, anonymous access will be used.
|
||||
- `appPassword`: The app password for the Bitbucket Cloud user.
|
||||
Please see [the Bitbucket Cloud documentation](../bitbucketCloud/locations.md).
|
||||
|
||||
## Bitbucket Server
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
---
|
||||
id: discovery
|
||||
title: Bitbucket Cloud Discovery
|
||||
sidebar_label: Discovery
|
||||
# prettier-ignore
|
||||
description: Automatically discovering catalog entities from repositories in Bitbucket Cloud
|
||||
---
|
||||
|
||||
The Bitbucket Cloud integration has a special entity provider for discovering
|
||||
catalog files located in [Bitbucket Cloud](https://bitbucket.org).
|
||||
The provider will search your Bitbucket Cloud account and register catalog files matching the configured path
|
||||
as Location entity and via following processing steps add all contained catalog entities.
|
||||
This can be useful as an alternative to static locations or manually adding things to the catalog.
|
||||
|
||||
## Installation
|
||||
|
||||
You will have to add the entity provider in the catalog initialization code of your
|
||||
backend. The provider is not installed by default, therefore you have to add a
|
||||
dependency to `@backstage/plugin-catalog-backend-module-bitbucket-cloud` to your backend
|
||||
package.
|
||||
|
||||
```bash
|
||||
# From your Backstage root directory
|
||||
yarn add --cwd packages/backend @backstage/plugin-catalog-backend-module-bitbucket-cloud
|
||||
```
|
||||
|
||||
And then add the entity provider to your catalog builder:
|
||||
|
||||
```diff
|
||||
// In packages/backend/src/plugins/catalog.ts
|
||||
+ import { BitbucketCloudEntityProvider } from '@backstage/plugin-catalog-backend-module-bitbucket-cloud';
|
||||
|
||||
export default async function createPlugin(
|
||||
env: PluginEnvironment,
|
||||
): Promise<Router> {
|
||||
const builder = await CatalogBuilder.create(env);
|
||||
+ builder.addEntityProvider(
|
||||
+ BitbucketCloudEntityProvider.fromConfig(env.config, {
|
||||
+ logger: env.logger,
|
||||
+ schedule: env.scheduler.createScheduledTaskRunner({
|
||||
+ frequency: { minutes: 30 },
|
||||
+ timeout: { minutes: 3 },
|
||||
+ }),
|
||||
+ }),
|
||||
+ );
|
||||
|
||||
// [...]
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
To use the entity provider, you'll need a [Bitbucket Cloud integration set up](locations.md).
|
||||
Very likely a `username` and `appPassword` will be required
|
||||
(you are restricted to public repositories and a very low rate limit otherwise).
|
||||
|
||||
Additionally, you need to configure your entity provider instance(s):
|
||||
|
||||
```yaml
|
||||
# app-config.yaml
|
||||
|
||||
catalog:
|
||||
providers:
|
||||
bitbucketCloud:
|
||||
yourProviderId: # identifies your ingested dataset
|
||||
catalogPath: /catalog-info.yaml # default value
|
||||
filters: # optional
|
||||
projectKey: '^apis-.*$' # optional; RegExp
|
||||
repoSlug: '^service-.*$' # optional; RegExp
|
||||
workspace: workspace-name
|
||||
```
|
||||
|
||||
> **Note:** It is possible but certainly not recommended to skip the provider ID level.
|
||||
> If you do so, `default` will be used as provider ID.
|
||||
|
||||
- **catalogPath** _(optional)_:
|
||||
Default: `/catalog-info.yaml`.
|
||||
Path where to look for `catalog-info.yaml` files.
|
||||
When started with `/`, it is an absolute path from the repo root.
|
||||
It supports values as allowed by the `path` filter/modifier
|
||||
[at Bitbucket Cloud's code search](https://confluence.atlassian.com/bitbucket/code-search-in-bitbucket-873876782.html#Search-Pathmodifier).
|
||||
- **filters** _(optional)_:
|
||||
- **projectKey** _(optional)_:
|
||||
Regular expression used to filter results based on the project key.
|
||||
- **repoSlug** _(optional)_:
|
||||
Regular expression used to filter results based on the repo slug.
|
||||
- **workspace**:
|
||||
Name of your organization account/workspace.
|
||||
If you want to add multiple workspaces, you need to add one provider config each.
|
||||
|
||||
## Alternative
|
||||
|
||||
_Deprecated!_ Please raise issues for use cases not covered by the entity provider.
|
||||
|
||||
[You can use the `BitbucketDiscoveryProcessor`.](../bitbucket/discovery.md#bitbucket-cloud)
|
||||
@@ -0,0 +1,36 @@
|
||||
---
|
||||
id: locations
|
||||
title: Bitbucket Cloud Locations
|
||||
sidebar_label: Locations
|
||||
# prettier-ignore
|
||||
description: Integrating source code stored in Bitbucket Cloud into the Backstage catalog
|
||||
---
|
||||
|
||||
The Bitbucket Cloud integration supports loading catalog entities from [bitbucket.org](https://bitbucket.org).
|
||||
Entities can be added to
|
||||
[static catalog configuration](../../features/software-catalog/configuration.md),
|
||||
or registered with the
|
||||
[catalog-import](https://github.com/backstage/backstage/tree/master/plugins/catalog-import)
|
||||
plugin.
|
||||
|
||||
## Configuration
|
||||
|
||||
```yaml
|
||||
integrations:
|
||||
bitbucketCloud:
|
||||
- username: ${BITBUCKET_CLOUD_USERNAME}
|
||||
appPassword: ${BITBUCKET_CLOUD_PASSWORD}
|
||||
```
|
||||
|
||||
> Note: A public Bitbucket Cloud provider is added automatically at startup for
|
||||
> convenience, so you only need to list it if you want to supply credentials.
|
||||
|
||||
Directly under the `bitbucketCloud` key is a list of provider configurations, where
|
||||
you can list the Bitbucket Cloud providers you want to fetch data from.
|
||||
In the case of Bitbucket Cloud, you will have up to one entry.
|
||||
|
||||
This one entry will have the following elements:
|
||||
|
||||
- `username`: The Bitbucket Cloud username to use in API requests. If
|
||||
neither a username nor token are supplied, anonymous access will be used.
|
||||
- `appPassword`: The app password for the Bitbucket Cloud user.
|
||||
@@ -149,6 +149,14 @@
|
||||
"integrations/bitbucket/discovery"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "subcategory",
|
||||
"label": "Bitbucket Cloud",
|
||||
"ids": [
|
||||
"integrations/bitbucketCloud/locations",
|
||||
"integrations/bitbucketCloud/discovery"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "subcategory",
|
||||
"label": "Datadog",
|
||||
|
||||
@@ -97,6 +97,9 @@ nav:
|
||||
- Bitbucket:
|
||||
- Locations: 'integrations/bitbucket/locations.md'
|
||||
- Discovery: 'integrations/bitbucket/discovery.md'
|
||||
- Bitbucket Cloud:
|
||||
- Locations: 'integrations/bitbucketCloud/locations.md'
|
||||
- Discovery: 'integrations/bitbucketCloud/discovery.md'
|
||||
- Datadog:
|
||||
- Installation: 'integrations/datadog-rum/installation.md'
|
||||
- Gerrit:
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
|
||||
@@ -0,0 +1,64 @@
|
||||
# @backstage/plugin-bitbucket-cloud-common
|
||||
|
||||
Welcome to the common package for bitbucket-cloud plugins!
|
||||
|
||||
This common package provides a reusable API client for the Bitbucket Cloud API
|
||||
which can be reused in catalog-backend-module plugins, scaffolder modules, etc.
|
||||
|
||||
Using a shared client allows to control all traffic going from Backstage to
|
||||
the Bitbucket Cloud API compared to separate clients or inline API calls.
|
||||
|
||||
We may want to leverage this later to add rate limiting, etc.
|
||||
|
||||
## How to maintain the generated code
|
||||
|
||||
### Update the Models
|
||||
|
||||
This command will
|
||||
|
||||
1. [refresh the schema/OpenAPI Specification](#refresh-the-schema)
|
||||
2. [re-generate the models](#generate-models)
|
||||
3. [reduce the models to the minimal needed](#reduce-models)
|
||||
|
||||
### Refresh the schema
|
||||
|
||||
This command will download the latest version of the Bitbucket Cloud OpenAPI Specification
|
||||
and apply some mutations to fix bugs or improve the schema for a better code generation output.
|
||||
|
||||
```sh
|
||||
yarn refresh-schema
|
||||
```
|
||||
|
||||
### Generate Models
|
||||
|
||||
The models used are created based on the [local OpenAPI Specification file](bitbucket-cloud.oas.json)
|
||||
using a code generator.
|
||||
Some post-cleanup is applied to improve the generated output.
|
||||
|
||||
The client itself using the models is not generated.
|
||||
|
||||
```sh
|
||||
yarn generate-models
|
||||
```
|
||||
|
||||
### Reduce Models
|
||||
|
||||
In order to keep the API surface minimal, this command helps to only keep the minimal part of the
|
||||
generated models by considering all `Models` module members directly or transitively used by the
|
||||
client implementation.
|
||||
|
||||
```sh
|
||||
yarn reduce-models
|
||||
```
|
||||
|
||||
## Adding a New Client Method
|
||||
|
||||
If you want to add a new method to the client implementation which may use a new endpoint or "new" models
|
||||
you can
|
||||
|
||||
1. optionally [refresh the schema](#refresh-the-schema) to get the latest version
|
||||
2. and [generate the models](#generate-models).
|
||||
|
||||
At this point, you have **all** models usable for adding a new method using any of them.
|
||||
|
||||
If you are ready with your addition to the client, you can [reduce the models to the minimal needed](#reduce-models).
|
||||
@@ -0,0 +1,386 @@
|
||||
## API Report File for "@backstage/plugin-bitbucket-cloud-common"
|
||||
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { BitbucketCloudIntegrationConfig } from '@backstage/integration';
|
||||
|
||||
// @public (undocumented)
|
||||
export class BitbucketCloudClient {
|
||||
// (undocumented)
|
||||
static fromConfig(
|
||||
config: BitbucketCloudIntegrationConfig,
|
||||
): BitbucketCloudClient;
|
||||
// (undocumented)
|
||||
listRepositoriesByWorkspace(
|
||||
workspace: string,
|
||||
options?: FilterAndSortOptions & PartialResponseOptions,
|
||||
): WithPagination<Models.PaginatedRepositories, Models.Repository>;
|
||||
// (undocumented)
|
||||
searchCode(
|
||||
workspace: string,
|
||||
query: string,
|
||||
options?: FilterAndSortOptions & PartialResponseOptions,
|
||||
): WithPagination<Models.SearchResultPage, Models.SearchCodeSearchResult>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export type FilterAndSortOptions = {
|
||||
q?: string;
|
||||
sort?: string;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export namespace Models {
|
||||
export interface Account extends ModelObject {
|
||||
account_status?: string;
|
||||
// (undocumented)
|
||||
created_on?: string;
|
||||
// (undocumented)
|
||||
display_name?: string;
|
||||
// (undocumented)
|
||||
has_2fa_enabled?: boolean;
|
||||
// (undocumented)
|
||||
links?: AccountLinks;
|
||||
nickname?: string;
|
||||
// (undocumented)
|
||||
username?: string;
|
||||
// (undocumented)
|
||||
uuid?: string;
|
||||
// (undocumented)
|
||||
website?: string;
|
||||
}
|
||||
// (undocumented)
|
||||
export interface AccountLinks {
|
||||
// (undocumented)
|
||||
avatar?: Link;
|
||||
// (undocumented)
|
||||
followers?: Link;
|
||||
// (undocumented)
|
||||
following?: Link;
|
||||
// (undocumented)
|
||||
html?: Link;
|
||||
// (undocumented)
|
||||
repositories?: Link;
|
||||
// (undocumented)
|
||||
self?: Link;
|
||||
}
|
||||
export interface Author extends ModelObject {
|
||||
raw?: string;
|
||||
// (undocumented)
|
||||
user?: Account;
|
||||
}
|
||||
export interface BaseCommit extends ModelObject {
|
||||
// (undocumented)
|
||||
author?: Author;
|
||||
// (undocumented)
|
||||
date?: string;
|
||||
// (undocumented)
|
||||
hash?: string;
|
||||
// (undocumented)
|
||||
message?: string;
|
||||
// (undocumented)
|
||||
parents?: Array<BaseCommit>;
|
||||
// (undocumented)
|
||||
summary?: BaseCommitSummary;
|
||||
}
|
||||
// (undocumented)
|
||||
export interface BaseCommitSummary {
|
||||
html?: string;
|
||||
markup?: BaseCommitSummaryMarkupEnum;
|
||||
raw?: string;
|
||||
}
|
||||
const BaseCommitSummaryMarkupEnum: {
|
||||
readonly Markdown: 'markdown';
|
||||
readonly Creole: 'creole';
|
||||
readonly Plaintext: 'plaintext';
|
||||
};
|
||||
export type BaseCommitSummaryMarkupEnum =
|
||||
typeof BaseCommitSummaryMarkupEnum[keyof typeof BaseCommitSummaryMarkupEnum];
|
||||
export interface Branch {
|
||||
default_merge_strategy?: string;
|
||||
// (undocumented)
|
||||
links?: RefLinks;
|
||||
merge_strategies?: Array<BranchMergeStrategiesEnum>;
|
||||
name?: string;
|
||||
// (undocumented)
|
||||
target?: Commit;
|
||||
// (undocumented)
|
||||
type: string;
|
||||
}
|
||||
const BranchMergeStrategiesEnum: {
|
||||
readonly MergeCommit: 'merge_commit';
|
||||
readonly Squash: 'squash';
|
||||
readonly FastForward: 'fast_forward';
|
||||
};
|
||||
export type BranchMergeStrategiesEnum =
|
||||
typeof BranchMergeStrategiesEnum[keyof typeof BranchMergeStrategiesEnum];
|
||||
export interface Commit extends BaseCommit {
|
||||
// (undocumented)
|
||||
participants?: Array<Participant>;
|
||||
// (undocumented)
|
||||
repository?: Repository;
|
||||
}
|
||||
export interface CommitFile {
|
||||
// (undocumented)
|
||||
[key: string]: unknown;
|
||||
// (undocumented)
|
||||
attributes?: CommitFileAttributesEnum;
|
||||
// (undocumented)
|
||||
commit?: Commit;
|
||||
escaped_path?: string;
|
||||
path?: string;
|
||||
// (undocumented)
|
||||
type: string;
|
||||
}
|
||||
const // (undocumented)
|
||||
CommitFileAttributesEnum: {
|
||||
readonly Link: 'link';
|
||||
readonly Executable: 'executable';
|
||||
readonly Subrepository: 'subrepository';
|
||||
readonly Binary: 'binary';
|
||||
readonly Lfs: 'lfs';
|
||||
};
|
||||
// (undocumented)
|
||||
export type CommitFileAttributesEnum =
|
||||
typeof CommitFileAttributesEnum[keyof typeof CommitFileAttributesEnum];
|
||||
export interface Link {
|
||||
// (undocumented)
|
||||
href?: string;
|
||||
// (undocumented)
|
||||
name?: string;
|
||||
}
|
||||
export interface ModelObject {
|
||||
// (undocumented)
|
||||
[key: string]: unknown;
|
||||
// (undocumented)
|
||||
type: string;
|
||||
}
|
||||
export interface Paginated<TResultItem> {
|
||||
next?: string;
|
||||
page?: number;
|
||||
pagelen?: number;
|
||||
previous?: string;
|
||||
size?: number;
|
||||
values?: Array<TResultItem> | Set<TResultItem>;
|
||||
}
|
||||
export interface PaginatedRepositories extends Paginated<Repository> {
|
||||
values?: Set<Repository>;
|
||||
}
|
||||
export interface Participant extends ModelObject {
|
||||
// (undocumented)
|
||||
approved?: boolean;
|
||||
participated_on?: string;
|
||||
// (undocumented)
|
||||
role?: ParticipantRoleEnum;
|
||||
// (undocumented)
|
||||
state?: ParticipantStateEnum;
|
||||
// (undocumented)
|
||||
user?: User;
|
||||
}
|
||||
const // (undocumented)
|
||||
ParticipantRoleEnum: {
|
||||
readonly Participant: 'PARTICIPANT';
|
||||
readonly Reviewer: 'REVIEWER';
|
||||
};
|
||||
// (undocumented)
|
||||
export type ParticipantRoleEnum =
|
||||
typeof ParticipantRoleEnum[keyof typeof ParticipantRoleEnum];
|
||||
const // (undocumented)
|
||||
ParticipantStateEnum: {
|
||||
readonly Approved: 'approved';
|
||||
readonly ChangesRequested: 'changes_requested';
|
||||
readonly Null: 'null';
|
||||
};
|
||||
// (undocumented)
|
||||
export type ParticipantStateEnum =
|
||||
typeof ParticipantStateEnum[keyof typeof ParticipantStateEnum];
|
||||
export interface Project extends ModelObject {
|
||||
// (undocumented)
|
||||
created_on?: string;
|
||||
// (undocumented)
|
||||
description?: string;
|
||||
has_publicly_visible_repos?: boolean;
|
||||
is_private?: boolean;
|
||||
key?: string;
|
||||
// (undocumented)
|
||||
links?: ProjectLinks;
|
||||
name?: string;
|
||||
// (undocumented)
|
||||
owner?: Team;
|
||||
// (undocumented)
|
||||
updated_on?: string;
|
||||
uuid?: string;
|
||||
}
|
||||
// (undocumented)
|
||||
export interface ProjectLinks {
|
||||
// (undocumented)
|
||||
avatar?: Link;
|
||||
// (undocumented)
|
||||
html?: Link;
|
||||
}
|
||||
// (undocumented)
|
||||
export interface RefLinks {
|
||||
// (undocumented)
|
||||
commits?: Link;
|
||||
// (undocumented)
|
||||
html?: Link;
|
||||
// (undocumented)
|
||||
self?: Link;
|
||||
}
|
||||
export interface Repository extends ModelObject {
|
||||
// (undocumented)
|
||||
created_on?: string;
|
||||
// (undocumented)
|
||||
description?: string;
|
||||
fork_policy?: RepositoryForkPolicyEnum;
|
||||
full_name?: string;
|
||||
// (undocumented)
|
||||
has_issues?: boolean;
|
||||
// (undocumented)
|
||||
has_wiki?: boolean;
|
||||
// (undocumented)
|
||||
is_private?: boolean;
|
||||
// (undocumented)
|
||||
language?: string;
|
||||
// (undocumented)
|
||||
links?: RepositoryLinks;
|
||||
// (undocumented)
|
||||
mainbranch?: Branch;
|
||||
// (undocumented)
|
||||
name?: string;
|
||||
// (undocumented)
|
||||
owner?: Account;
|
||||
// (undocumented)
|
||||
parent?: Repository;
|
||||
// (undocumented)
|
||||
project?: Project;
|
||||
// (undocumented)
|
||||
scm?: RepositoryScmEnum;
|
||||
// (undocumented)
|
||||
size?: number;
|
||||
slug?: string;
|
||||
// (undocumented)
|
||||
updated_on?: string;
|
||||
uuid?: string;
|
||||
}
|
||||
const RepositoryForkPolicyEnum: {
|
||||
readonly AllowForks: 'allow_forks';
|
||||
readonly NoPublicForks: 'no_public_forks';
|
||||
readonly NoForks: 'no_forks';
|
||||
};
|
||||
export type RepositoryForkPolicyEnum =
|
||||
typeof RepositoryForkPolicyEnum[keyof typeof RepositoryForkPolicyEnum];
|
||||
const // (undocumented)
|
||||
RepositoryScmEnum: {
|
||||
readonly Git: 'git';
|
||||
};
|
||||
// (undocumented)
|
||||
export interface RepositoryLinks {
|
||||
// (undocumented)
|
||||
avatar?: Link;
|
||||
// (undocumented)
|
||||
clone?: Array<Link>;
|
||||
// (undocumented)
|
||||
commits?: Link;
|
||||
// (undocumented)
|
||||
downloads?: Link;
|
||||
// (undocumented)
|
||||
forks?: Link;
|
||||
// (undocumented)
|
||||
hooks?: Link;
|
||||
// (undocumented)
|
||||
html?: Link;
|
||||
// (undocumented)
|
||||
pullrequests?: Link;
|
||||
// (undocumented)
|
||||
self?: Link;
|
||||
// (undocumented)
|
||||
watchers?: Link;
|
||||
}
|
||||
// (undocumented)
|
||||
export type RepositoryScmEnum =
|
||||
typeof RepositoryScmEnum[keyof typeof RepositoryScmEnum];
|
||||
// (undocumented)
|
||||
export interface SearchCodeSearchResult {
|
||||
// (undocumented)
|
||||
readonly content_match_count?: number;
|
||||
// (undocumented)
|
||||
readonly content_matches?: Array<SearchContentMatch>;
|
||||
// (undocumented)
|
||||
file?: CommitFile;
|
||||
// (undocumented)
|
||||
readonly path_matches?: Array<SearchSegment>;
|
||||
// (undocumented)
|
||||
readonly type?: string;
|
||||
}
|
||||
// (undocumented)
|
||||
export interface SearchContentMatch {
|
||||
// (undocumented)
|
||||
readonly lines?: Array<SearchLine>;
|
||||
}
|
||||
// (undocumented)
|
||||
export interface SearchLine {
|
||||
// (undocumented)
|
||||
readonly line?: number;
|
||||
// (undocumented)
|
||||
readonly segments?: Array<SearchSegment>;
|
||||
}
|
||||
// (undocumented)
|
||||
export interface SearchResultPage extends Paginated<SearchCodeSearchResult> {
|
||||
// (undocumented)
|
||||
readonly query_substituted?: boolean;
|
||||
readonly values?: Array<SearchCodeSearchResult>;
|
||||
}
|
||||
// (undocumented)
|
||||
export interface SearchSegment {
|
||||
// (undocumented)
|
||||
readonly match?: boolean;
|
||||
// (undocumented)
|
||||
readonly text?: string;
|
||||
}
|
||||
export interface Team extends Account {}
|
||||
export interface User extends Account {
|
||||
account_id?: string;
|
||||
// (undocumented)
|
||||
is_staff?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export type PaginationOptions = {
|
||||
page?: number;
|
||||
pagelen?: number;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type PartialResponseOptions = {
|
||||
fields?: string;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export type RequestOptions = FilterAndSortOptions &
|
||||
PaginationOptions &
|
||||
PartialResponseOptions & {
|
||||
[key: string]: string | number | undefined;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export class WithPagination<
|
||||
TPage extends Models.Paginated<TResultItem>,
|
||||
TResultItem,
|
||||
> {
|
||||
constructor(
|
||||
createUrl: (options: PaginationOptions) => URL,
|
||||
fetch: (url: URL) => Promise<TPage>,
|
||||
);
|
||||
// (undocumented)
|
||||
getPage(options?: PaginationOptions): Promise<TPage>;
|
||||
// (undocumented)
|
||||
iteratePages(options?: PaginationOptions): AsyncGenerator<TPage, void>;
|
||||
// (undocumented)
|
||||
iterateResults(
|
||||
options?: PaginationOptions,
|
||||
): AsyncGenerator<Awaited<TResultItem>, void, unknown>;
|
||||
}
|
||||
```
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"$schema": "../../node_modules/@openapitools/openapi-generator-cli/config.schema.json",
|
||||
"spaces": 2,
|
||||
"generator-cli": {
|
||||
"version": "6.0.0-beta",
|
||||
"generators": {
|
||||
"backstage": {
|
||||
"generatorName": "typescript-fetch",
|
||||
"glob": "bitbucket-cloud.oas.json",
|
||||
"output": "src",
|
||||
"additionalProperties": {
|
||||
"disallowAdditionalPropertiesIfNotPresent": false,
|
||||
"enumPropertyNaming": "PascalCase",
|
||||
"legacyDiscriminatorBehavior": false,
|
||||
"modelPropertyNaming": "original",
|
||||
"withoutRuntimeChecks": true
|
||||
},
|
||||
"templateDir": "templates"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "@backstage/plugin-bitbucket-cloud-common",
|
||||
"description": "Common functionalities for bitbucket-cloud plugins",
|
||||
"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",
|
||||
"module": "dist/index.esm.js",
|
||||
"types": "dist/index.d.ts"
|
||||
},
|
||||
"backstage": {
|
||||
"role": "common-library"
|
||||
},
|
||||
"scripts": {
|
||||
"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",
|
||||
"refresh-schema": "scripts/prepare-schema.js && prettier --check bitbucket-cloud.oas.json -w",
|
||||
"generate-models": "scripts/generate-models.sh",
|
||||
"reduce-models": "scripts/reduce-models.js",
|
||||
"update-models": "yarn refresh-schema && yarn generate-models && yarn reduce-models"
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/integration": "^1.2.1-next.0",
|
||||
"cross-fetch": "^3.1.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "^0.17.2-next.0",
|
||||
"@openapitools/openapi-generator-cli": "^2.4.26",
|
||||
"msw": "^0.35.0",
|
||||
"ts-morph": "^15.0.0"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
]
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
/*
|
||||
* Copyright 2022 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.
|
||||
*/
|
||||
|
||||
const tsMorph = require('ts-morph');
|
||||
|
||||
function cleanupWrongAllOfModels(modelsModule) {
|
||||
const allOfInterfaces = modelsModule
|
||||
.getInterfaces()
|
||||
.filter(i => i.getName().includes('AllOf'));
|
||||
allOfInterfaces.forEach(i => {
|
||||
const name = i.getName();
|
||||
const realName = name.replace('AllOf', '');
|
||||
|
||||
const realInterface = modelsModule.getInterface(realName);
|
||||
if (realInterface) {
|
||||
i.remove();
|
||||
} else {
|
||||
i.rename(realName);
|
||||
}
|
||||
});
|
||||
|
||||
const allOfTypes = modelsModule
|
||||
.getTypeAliases()
|
||||
.filter(t => t.getName().includes('AllOf'));
|
||||
allOfTypes.forEach(t => {
|
||||
const name = t.getName();
|
||||
const realName = name.replace('AllOf', '');
|
||||
|
||||
const varStmt = modelsModule.getVariableStatementOrThrow(t.getName());
|
||||
|
||||
const realType = modelsModule.getTypeAlias(realName);
|
||||
if (realType) {
|
||||
t.remove();
|
||||
varStmt.remove();
|
||||
} else {
|
||||
t.rename(realName);
|
||||
varStmt.getDeclarationList().getDeclarations()[0].rename(realName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function makePaginatedGeneric(modelsModule) {
|
||||
const paginated = modelsModule.getInterface('Paginated');
|
||||
|
||||
if (paginated.getTypeParameters().length === 0) {
|
||||
paginated.addTypeParameter('TResultItem');
|
||||
}
|
||||
|
||||
const valuesProperty = paginated.getPropertyOrThrow('values');
|
||||
let valuesType = valuesProperty
|
||||
.getType()
|
||||
.getText()
|
||||
.replace('| null ', '')
|
||||
.replace('any[]', 'Array<TResultItem>')
|
||||
.replaceAll('any', 'TResultItem');
|
||||
if (valuesProperty.hasQuestionToken()) {
|
||||
valuesType = valuesType.replace(' | undefined', '');
|
||||
}
|
||||
valuesProperty.setType(valuesType);
|
||||
}
|
||||
|
||||
function setPaginatedResultItemType(modelsModule) {
|
||||
modelsModule
|
||||
.getInterfaces()
|
||||
.filter(i =>
|
||||
i.getExtends().find(it => it.getExpression().getText() === 'Paginated'),
|
||||
)
|
||||
.forEach(i => {
|
||||
const paginatedExtends = i
|
||||
.getExtends()
|
||||
.find(it => it.getExpression().getText() === 'Paginated');
|
||||
|
||||
const valuesProperty = i.getPropertyOrThrow('values');
|
||||
const resultItemType = valuesProperty
|
||||
.getType()
|
||||
.getUnionTypes()
|
||||
.map(it => it.getText())
|
||||
.find(it => it !== 'undefined')
|
||||
.replaceAll(/import[^ ]+.Models./g, '')
|
||||
.replace('[]', '')
|
||||
.replace(/(?:Array|Set)<(.*)>/, '$1');
|
||||
|
||||
paginatedExtends.setExpression(`Paginated<${resultItemType}>`);
|
||||
});
|
||||
}
|
||||
|
||||
const project = new tsMorph.Project({
|
||||
tsConfigFilePath: '../../tsconfig.json',
|
||||
skipAddingFilesFromTsConfig: true,
|
||||
});
|
||||
project.addSourceFilesAtPaths('src/**');
|
||||
|
||||
const modelsFile = project.getSourceFile('src/models/index.ts');
|
||||
const modelsModule = modelsFile.getModuleOrThrow('Models');
|
||||
|
||||
cleanupWrongAllOfModels(modelsModule);
|
||||
makePaginatedGeneric(modelsModule);
|
||||
setPaginatedResultItemType(modelsModule);
|
||||
|
||||
project.saveSync();
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2022 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.
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$(dirname $0)
|
||||
PLUGIN_DIR="${SCRIPT_DIR}/.."
|
||||
|
||||
yarn --cwd "${PLUGIN_DIR}" openapi-generator-cli generate --generator-key backstage
|
||||
rm -d "${PLUGIN_DIR}/src/apis" # empty dir or fails
|
||||
"${SCRIPT_DIR}"/adjust-models.js
|
||||
yarn --cwd "${PLUGIN_DIR}" prettier --check . -w
|
||||
+279
@@ -0,0 +1,279 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
/*
|
||||
* Copyright 2022 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.
|
||||
*/
|
||||
|
||||
const BASE_DOMAIN = 'https://developer.atlassian.com';
|
||||
const SCHEMA_SOURCE = `${BASE_DOMAIN}/cloud/bitbucket/swagger.v3.json`;
|
||||
|
||||
const fetch = require('cross-fetch');
|
||||
const fs = require('fs');
|
||||
|
||||
const destFile = `${__dirname}/../bitbucket-cloud.oas.json`;
|
||||
|
||||
const sortSelectedProperties = (key, value) => {
|
||||
if (key !== 'schemas' && key !== 'properties') {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (value && typeof value === 'object') {
|
||||
return Object.keys(value)
|
||||
.sort()
|
||||
.reduce((o, k) => {
|
||||
o[k] = value[k];
|
||||
return o;
|
||||
}, {});
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
// similar to definition of "slug" at ""#/components/schemas/group"
|
||||
const repoSlugDefinition = {
|
||||
type: 'string',
|
||||
description:
|
||||
'The "sluggified" version of the repository\'s name. This contains only ASCII characters and can therefore be slightly different than the name',
|
||||
};
|
||||
|
||||
const paginatedDefinition = {
|
||||
type: 'object',
|
||||
title: 'Paginated',
|
||||
description: 'A generic paginated list.',
|
||||
discriminator: {
|
||||
propertyName: 'type',
|
||||
},
|
||||
properties: {
|
||||
next: {
|
||||
type: 'string',
|
||||
format: 'uri',
|
||||
description:
|
||||
'Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs.',
|
||||
},
|
||||
page: {
|
||||
type: 'integer',
|
||||
description:
|
||||
'Page number of the current results. This is an optional element that is not provided in all responses.',
|
||||
},
|
||||
pagelen: {
|
||||
type: 'integer',
|
||||
description:
|
||||
'Current number of objects on the existing page. The default value is 10 with 100 being the maximum allowed value. Individual APIs may enforce different values.',
|
||||
},
|
||||
previous: {
|
||||
type: 'string',
|
||||
format: 'uri',
|
||||
description:
|
||||
'Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs.',
|
||||
},
|
||||
size: {
|
||||
type: 'integer',
|
||||
description:
|
||||
'Total number of objects in the response. This is an optional element that is not provided in all responses, as it can be expensive to compute.',
|
||||
},
|
||||
values: {
|
||||
description: 'The values of the current page.',
|
||||
oneOf: [
|
||||
{
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
items: {},
|
||||
uniqueItems: false,
|
||||
},
|
||||
{
|
||||
type: 'array',
|
||||
minItems: 0,
|
||||
items: {},
|
||||
uniqueItems: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const addMissingRepoSlug = json => {
|
||||
const repoProperties = json.components.schemas.repository.allOf.find(
|
||||
item => item.properties,
|
||||
).properties;
|
||||
if (repoProperties.slug) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
'[WARN] repository schema already contains slug property. Patch got obsolete.',
|
||||
);
|
||||
} else {
|
||||
repoProperties.slug = repoSlugDefinition;
|
||||
}
|
||||
|
||||
return json;
|
||||
};
|
||||
|
||||
const removePageDefinition = json => {
|
||||
delete json.components.schemas.page;
|
||||
return json;
|
||||
};
|
||||
|
||||
const renamePaginatedSnippetCommitToPlural = json => {
|
||||
if (!json.components.schemas.paginated_snippet_commit) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
'[WARN] $.components.schemas.paginated_snippet_commit does not exist anymore. Patch got obsolete.',
|
||||
);
|
||||
return json;
|
||||
}
|
||||
|
||||
json.components.schemas.paginated_snippet_commits =
|
||||
json.components.schemas.paginated_snippet_commit;
|
||||
delete json.components.schemas.paginated_snippet_commit;
|
||||
|
||||
return JSON.parse(
|
||||
JSON.stringify(json).replace(
|
||||
'"#/components/schemas/paginated_snippet_commit"',
|
||||
'"#/components/schemas/paginated_snippet_commits"',
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
const addPaginatedDefinition = json => {
|
||||
json.components.schemas.paginated = paginatedDefinition;
|
||||
return json;
|
||||
};
|
||||
|
||||
// Changes "interface PaginatedXyz {" to "interface PaginatedXyz extends Paginated<Xyz> {"
|
||||
// (generic type gets extracted from "values" property)
|
||||
const paginatedDefinitionsExtendPaginated = json => {
|
||||
// exception to the standard naming pattern PaginatedXyz / paginated_xyz
|
||||
const exceptions = [
|
||||
'deployments_ddev_paginated_environments',
|
||||
'deployments_stg_west_paginated_environments',
|
||||
'search_result_page',
|
||||
];
|
||||
|
||||
Object.keys(json.components.schemas)
|
||||
.filter(name => name.startsWith('paginated_') || exceptions.includes(name))
|
||||
.forEach(name => {
|
||||
// modify other paginated_[...] schemas
|
||||
const old = json.components.schemas[name];
|
||||
const title = old.title;
|
||||
const description = old.description;
|
||||
delete old.title;
|
||||
delete old.description;
|
||||
delete old.properties.page;
|
||||
delete old.properties.pagelen;
|
||||
delete old.properties.size;
|
||||
delete old.properties.previous;
|
||||
delete old.properties.next;
|
||||
delete old.additionalProperties;
|
||||
old.properties.values.description =
|
||||
old.properties.values.description ??
|
||||
paginatedDefinition.properties.values.description;
|
||||
|
||||
json.components.schemas[name] = {
|
||||
title: title,
|
||||
description: description,
|
||||
allOf: [
|
||||
{
|
||||
$ref: '#/components/schemas/paginated',
|
||||
},
|
||||
old,
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
return json;
|
||||
};
|
||||
|
||||
const preventHardToDetectDuplicateInterfacesDueToAllOf = json => {
|
||||
Object.keys(json.components.schemas).forEach(name => {
|
||||
const schema = json.components.schemas[name];
|
||||
if (!schema.allOf) {
|
||||
return;
|
||||
}
|
||||
|
||||
schema.allOf.forEach(allOfItem => {
|
||||
if (allOfItem.title) {
|
||||
schema.title = schema.title ?? allOfItem.title;
|
||||
schema.description = schema.description ?? allOfItem.description;
|
||||
delete allOfItem.title;
|
||||
delete allOfItem.description;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return json;
|
||||
};
|
||||
|
||||
const removeBuggyDescription = json => {
|
||||
const valueProp =
|
||||
json.components.schemas.branchrestriction.allOf[1].properties.value;
|
||||
if (!valueProp.description.startsWith('<staticmethod')) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('[WARN] "removeBuggyDescription" is not necessary anymore.');
|
||||
return json;
|
||||
}
|
||||
|
||||
delete valueProp.description;
|
||||
return json;
|
||||
};
|
||||
|
||||
const resolveConflictingInheritance = json => {
|
||||
const schema = json.components.schemas.pipeline_selector;
|
||||
const extension = schema.allOf[1];
|
||||
delete schema.allOf;
|
||||
|
||||
json.components.schemas.pipeline_selector = {
|
||||
...schema,
|
||||
...extension,
|
||||
};
|
||||
|
||||
return json;
|
||||
};
|
||||
|
||||
const escapeTsdocInDescription = json => {
|
||||
const prop = json.components.schemas.commitstatus.allOf[1].properties.url;
|
||||
prop.description = prop.description.replaceAll(/(\S*[{]\S+[}]\S*)/g, '`$1`');
|
||||
|
||||
return json;
|
||||
};
|
||||
|
||||
const relativeToAbsoluteUrls = json => {
|
||||
Object.keys(json.components.schemas).forEach(name => {
|
||||
const schema = json.components.schemas[name];
|
||||
if (schema.description) {
|
||||
schema.description = schema.description.replace(
|
||||
/]\(\/cloud\/bitbucket\//g,
|
||||
`](${BASE_DOMAIN}/cloud/bitbucket/`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return json;
|
||||
};
|
||||
|
||||
fetch(SCHEMA_SOURCE)
|
||||
.then(res => res.json())
|
||||
.then(addMissingRepoSlug)
|
||||
.then(removePageDefinition)
|
||||
.then(renamePaginatedSnippetCommitToPlural)
|
||||
.then(addPaginatedDefinition)
|
||||
.then(paginatedDefinitionsExtendPaginated)
|
||||
.then(preventHardToDetectDuplicateInterfacesDueToAllOf)
|
||||
.then(removeBuggyDescription)
|
||||
.then(resolveConflictingInheritance)
|
||||
.then(escapeTsdocInDescription)
|
||||
.then(relativeToAbsoluteUrls)
|
||||
.then(json => {
|
||||
fs.writeFileSync(destFile, JSON.stringify(json, sortSelectedProperties, 2));
|
||||
return json;
|
||||
});
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
/*
|
||||
* Copyright 2022 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.
|
||||
*/
|
||||
|
||||
const tsMorph = require('ts-morph');
|
||||
|
||||
const project = new tsMorph.Project({
|
||||
tsConfigFilePath: '../../tsconfig.json',
|
||||
skipAddingFilesFromTsConfig: true,
|
||||
});
|
||||
project.addSourceFilesAtPaths('src/**');
|
||||
|
||||
const modelsFile = project.getSourceFile('src/models/index.ts');
|
||||
const modelsModule = modelsFile.getModuleOrThrow('Models');
|
||||
|
||||
const clientFile = project.getSourceFile('src/BitbucketCloudClient.ts');
|
||||
const clientClass = clientFile.getClassOrThrow('BitbucketCloudClient');
|
||||
|
||||
/**
|
||||
* Returns an array of the unique items of the provided array.
|
||||
*
|
||||
* @param {string[]} array array with potentially non-unique items.
|
||||
* @returns {string[]} array with unique items.
|
||||
*/
|
||||
function unique(array) {
|
||||
return [...new Set(array)];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {tsMorph.ClassDeclaration | tsMorph.InterfaceDeclaration | tsMorph.TypeAliasDeclaration} stmt Statement like interface or type alias.
|
||||
* @param {string[]=} processed Keeps track of which statement was already processed.
|
||||
* @returns {string[]}
|
||||
*/
|
||||
function referencedModelsIdentifiers(stmt, processed) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
processed = processed ?? [];
|
||||
const name = stmt.getName();
|
||||
|
||||
if (processed.includes(name)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const referenced = unique(
|
||||
stmt
|
||||
.getDescendantsOfKind(tsMorph.SyntaxKind.Identifier)
|
||||
.map(it => it.getSymbol())
|
||||
.filter(it => it)
|
||||
.map(it => it.getFullyQualifiedName())
|
||||
.filter(it => it.includes('Models.'))
|
||||
.map(it => it.substring(it.indexOf('Models.') + 7))
|
||||
.filter(it => !it.includes('.'))
|
||||
.filter(it => it !== name),
|
||||
);
|
||||
processed.push(name);
|
||||
|
||||
const transitivelyReferenced = referenced
|
||||
.map(
|
||||
it =>
|
||||
modelsModule.getInterface(it) ?? modelsModule.getTypeAliasOrThrow(it),
|
||||
)
|
||||
.flatMap(it => referencedModelsIdentifiers(it, processed));
|
||||
|
||||
return unique([...referenced, ...transitivelyReferenced]);
|
||||
}
|
||||
|
||||
// all directly or transitively referenced/used `Models.[...]` are allowed to stay
|
||||
const allowed = referencedModelsIdentifiers(clientClass);
|
||||
|
||||
// remove everything not part of the "allow list"
|
||||
modelsModule
|
||||
.getInterfaces()
|
||||
.filter(it => !allowed.includes(it.getName()))
|
||||
.forEach(it => it.remove());
|
||||
|
||||
modelsModule
|
||||
.getTypeAliases()
|
||||
.filter(it => !allowed.includes(it.getName()))
|
||||
.forEach(it => {
|
||||
const varStmt = modelsModule.getVariableStatementOrThrow(it.getName());
|
||||
|
||||
it.remove();
|
||||
varStmt.remove();
|
||||
});
|
||||
|
||||
project.saveSync();
|
||||
@@ -0,0 +1,9 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# we maintain this file manually
|
||||
index.ts
|
||||
|
||||
# we only want the models to be generated
|
||||
apis/
|
||||
runtime.ts
|
||||
@@ -0,0 +1 @@
|
||||
models/index.ts
|
||||
@@ -0,0 +1 @@
|
||||
6.0.0-beta
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright 2022 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 { BitbucketCloudIntegrationConfig } from '@backstage/integration';
|
||||
import { rest } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { BitbucketCloudClient } from './BitbucketCloudClient';
|
||||
import { Models } from './models';
|
||||
|
||||
const server = setupServer();
|
||||
|
||||
describe('BitbucketCloudClient', () => {
|
||||
const config: BitbucketCloudIntegrationConfig = {
|
||||
host: 'bitbucket.org',
|
||||
apiBaseUrl: 'https://api.bitbucket.org/2.0',
|
||||
username: 'test-user',
|
||||
appPassword: 'test-pw',
|
||||
};
|
||||
const client = BitbucketCloudClient.fromConfig(config);
|
||||
|
||||
beforeAll(() => server.listen({ onUnhandledRequest: 'error' }));
|
||||
afterAll(() => server.close());
|
||||
afterEach(() => server.resetHandlers());
|
||||
|
||||
it('searchCode', async () => {
|
||||
server.use(
|
||||
rest.get(
|
||||
`https://api.bitbucket.org/2.0/workspaces/ws/search/code`,
|
||||
(req, res, ctx) => {
|
||||
if (
|
||||
req.headers.get('authorization') !==
|
||||
'Basic dGVzdC11c2VyOnRlc3QtcHc='
|
||||
) {
|
||||
return res(ctx.status(400));
|
||||
}
|
||||
|
||||
const query = req.url.searchParams.get('search_query');
|
||||
if (query !== 'query') {
|
||||
return res(ctx.json({ values: [] } as Models.SearchResultPage));
|
||||
}
|
||||
|
||||
const response: Models.SearchResultPage = {
|
||||
values: [
|
||||
{
|
||||
content_match_count: 1,
|
||||
file: {
|
||||
type: 'commit_file',
|
||||
path: 'path/to/file',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
return res(ctx.json(response));
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
const pagination = client.searchCode('ws', 'query');
|
||||
|
||||
const results = [];
|
||||
for await (const result of pagination.iterateResults()) {
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
expect(results).toHaveLength(1);
|
||||
expect(results[0].file!.path).toEqual('path/to/file');
|
||||
});
|
||||
|
||||
it('listRepositoriesByWorkspace', async () => {
|
||||
server.use(
|
||||
rest.get(
|
||||
'https://api.bitbucket.org/2.0/repositories/ws',
|
||||
(_, res, ctx) => {
|
||||
const response = {
|
||||
values: [
|
||||
{
|
||||
type: 'repository',
|
||||
slug: 'repo1',
|
||||
} as Models.Repository,
|
||||
],
|
||||
};
|
||||
return res(ctx.json(response));
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
const pagination = client.listRepositoriesByWorkspace('ws');
|
||||
|
||||
const results = [];
|
||||
for await (const result of pagination.iterateResults()) {
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
expect(results).toHaveLength(1);
|
||||
expect(results[0].slug).toEqual('repo1');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright 2022 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 { BitbucketCloudIntegrationConfig } from '@backstage/integration';
|
||||
import fetch, { Request } from 'cross-fetch';
|
||||
import { Models } from './models';
|
||||
import { WithPagination } from './pagination';
|
||||
import {
|
||||
FilterAndSortOptions,
|
||||
PartialResponseOptions,
|
||||
RequestOptions,
|
||||
} from './types';
|
||||
|
||||
/** @public */
|
||||
export class BitbucketCloudClient {
|
||||
static fromConfig(
|
||||
config: BitbucketCloudIntegrationConfig,
|
||||
): BitbucketCloudClient {
|
||||
return new BitbucketCloudClient(config);
|
||||
}
|
||||
|
||||
private constructor(
|
||||
private readonly config: BitbucketCloudIntegrationConfig,
|
||||
) {}
|
||||
|
||||
searchCode(
|
||||
workspace: string,
|
||||
query: string,
|
||||
options?: FilterAndSortOptions & PartialResponseOptions,
|
||||
): WithPagination<Models.SearchResultPage, Models.SearchCodeSearchResult> {
|
||||
const workspaceEnc = encodeURIComponent(workspace);
|
||||
return new WithPagination(
|
||||
paginationOptions =>
|
||||
this.createUrl(`/workspaces/${workspaceEnc}/search/code`, {
|
||||
...paginationOptions,
|
||||
...options,
|
||||
search_query: query,
|
||||
}),
|
||||
url => this.getTypeMapped(url),
|
||||
);
|
||||
}
|
||||
|
||||
listRepositoriesByWorkspace(
|
||||
workspace: string,
|
||||
options?: FilterAndSortOptions & PartialResponseOptions,
|
||||
): WithPagination<Models.PaginatedRepositories, Models.Repository> {
|
||||
const workspaceEnc = encodeURIComponent(workspace);
|
||||
|
||||
return new WithPagination(
|
||||
paginationOptions =>
|
||||
this.createUrl(`/repositories/${workspaceEnc}`, {
|
||||
...paginationOptions,
|
||||
...options,
|
||||
}),
|
||||
url => this.getTypeMapped(url),
|
||||
);
|
||||
}
|
||||
|
||||
private createUrl(endpoint: string, options?: RequestOptions): URL {
|
||||
const request = new URL(this.config.apiBaseUrl + endpoint);
|
||||
for (const key in options) {
|
||||
if (options[key]) {
|
||||
request.searchParams.append(key, options[key]!.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
private async getTypeMapped<T = any>(url: URL): Promise<T> {
|
||||
return this.get(url).then(
|
||||
(response: Response) => response.json() as Promise<T>,
|
||||
);
|
||||
}
|
||||
|
||||
private async get(url: URL): Promise<Response> {
|
||||
return this.request(new Request(url.toString(), { method: 'GET' }));
|
||||
}
|
||||
|
||||
private async request(req: Request): Promise<Response> {
|
||||
return fetch(req, { headers: this.getAuthHeaders() }).then(
|
||||
(response: Response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Unexpected response for ${req.method} ${req.url}. Expected 200 but got ${response.status} - ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
|
||||
return response;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
private getAuthHeaders(): Record<string, string> {
|
||||
const headers: Record<string, string> = {};
|
||||
|
||||
if (this.config.username) {
|
||||
const buffer = Buffer.from(
|
||||
`${this.config.username}:${this.config.appPassword}`,
|
||||
'utf8',
|
||||
);
|
||||
headers.Authorization = `Basic ${buffer.toString('base64')}`;
|
||||
}
|
||||
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2022 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Common functionalities for bitbucket-cloud plugins.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
export * from './BitbucketCloudClient';
|
||||
export * from './models';
|
||||
export * from './pagination';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,532 @@
|
||||
/*
|
||||
* Copyright 2022 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Bitbucket API
|
||||
* Code against the Bitbucket API to automate simple tasks, embed Bitbucket data into your own site, build mobile or desktop apps, or even add custom UI add-ons into Bitbucket itself using the Connect framework.
|
||||
*
|
||||
* The version of the OpenAPI document: 2.0
|
||||
* Contact: support@bitbucket.org
|
||||
*
|
||||
* NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/** @public */
|
||||
export namespace Models {
|
||||
/**
|
||||
* An account object.
|
||||
* @public
|
||||
*/
|
||||
export interface Account extends ModelObject {
|
||||
/**
|
||||
* The status of the account. Currently the only possible value is "active", but more values may be added in the future.
|
||||
*/
|
||||
account_status?: string;
|
||||
created_on?: string;
|
||||
display_name?: string;
|
||||
has_2fa_enabled?: boolean;
|
||||
links?: AccountLinks;
|
||||
/**
|
||||
* Account name defined by the owner. Should be used instead of the "username" field. Note that "nickname" cannot be used in place of "username" in URLs and queries, as "nickname" is not guaranteed to be unique.
|
||||
*/
|
||||
nickname?: string;
|
||||
username?: string;
|
||||
uuid?: string;
|
||||
website?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface AccountLinks {
|
||||
avatar?: Link;
|
||||
followers?: Link;
|
||||
following?: Link;
|
||||
html?: Link;
|
||||
repositories?: Link;
|
||||
self?: Link;
|
||||
}
|
||||
|
||||
/**
|
||||
* The author of a change in a repository
|
||||
* @public
|
||||
*/
|
||||
export interface Author extends ModelObject {
|
||||
/**
|
||||
* The raw author value from the repository. This may be the only value available if the author does not match a user in Bitbucket.
|
||||
*/
|
||||
raw?: string;
|
||||
user?: Account;
|
||||
}
|
||||
|
||||
/**
|
||||
* The common base type for both repository and snippet commits.
|
||||
* @public
|
||||
*/
|
||||
export interface BaseCommit extends ModelObject {
|
||||
author?: Author;
|
||||
date?: string;
|
||||
hash?: string;
|
||||
message?: string;
|
||||
parents?: Array<BaseCommit>;
|
||||
summary?: BaseCommitSummary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface BaseCommitSummary {
|
||||
/**
|
||||
* The user's content rendered as HTML.
|
||||
*/
|
||||
html?: string;
|
||||
/**
|
||||
* The type of markup language the raw content is to be interpreted in.
|
||||
*/
|
||||
markup?: BaseCommitSummaryMarkupEnum;
|
||||
/**
|
||||
* The text as it was typed by a user.
|
||||
*/
|
||||
raw?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of markup language the raw content is to be interpreted in.
|
||||
* @public
|
||||
*/
|
||||
export const BaseCommitSummaryMarkupEnum = {
|
||||
Markdown: 'markdown',
|
||||
Creole: 'creole',
|
||||
Plaintext: 'plaintext',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* The type of markup language the raw content is to be interpreted in.
|
||||
* @public
|
||||
*/
|
||||
export type BaseCommitSummaryMarkupEnum =
|
||||
typeof BaseCommitSummaryMarkupEnum[keyof typeof BaseCommitSummaryMarkupEnum];
|
||||
|
||||
/**
|
||||
* A branch object, representing a branch in a repository.
|
||||
* @public
|
||||
*/
|
||||
export interface Branch {
|
||||
links?: RefLinks;
|
||||
/**
|
||||
* The name of the ref.
|
||||
*/
|
||||
name?: string;
|
||||
target?: Commit;
|
||||
type: string;
|
||||
/**
|
||||
* The default merge strategy for pull requests targeting this branch.
|
||||
*/
|
||||
default_merge_strategy?: string;
|
||||
/**
|
||||
* Available merge strategies for pull requests targeting this branch.
|
||||
*/
|
||||
merge_strategies?: Array<BranchMergeStrategiesEnum>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Available merge strategies for pull requests targeting this branch.
|
||||
* @public
|
||||
*/
|
||||
export const BranchMergeStrategiesEnum = {
|
||||
MergeCommit: 'merge_commit',
|
||||
Squash: 'squash',
|
||||
FastForward: 'fast_forward',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Available merge strategies for pull requests targeting this branch.
|
||||
* @public
|
||||
*/
|
||||
export type BranchMergeStrategiesEnum =
|
||||
typeof BranchMergeStrategiesEnum[keyof typeof BranchMergeStrategiesEnum];
|
||||
|
||||
/**
|
||||
* A repository commit object.
|
||||
* @public
|
||||
*/
|
||||
export interface Commit extends BaseCommit {
|
||||
participants?: Array<Participant>;
|
||||
repository?: Repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* A file object, representing a file at a commit in a repository
|
||||
* @public
|
||||
*/
|
||||
export interface CommitFile {
|
||||
[key: string]: unknown;
|
||||
attributes?: CommitFileAttributesEnum;
|
||||
commit?: Commit;
|
||||
/**
|
||||
* The escaped version of the path as it appears in a diff. If the path does not require escaping this will be the same as path.
|
||||
*/
|
||||
escaped_path?: string;
|
||||
/**
|
||||
* The path in the repository
|
||||
*/
|
||||
path?: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const CommitFileAttributesEnum = {
|
||||
Link: 'link',
|
||||
Executable: 'executable',
|
||||
Subrepository: 'subrepository',
|
||||
Binary: 'binary',
|
||||
Lfs: 'lfs',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type CommitFileAttributesEnum =
|
||||
typeof CommitFileAttributesEnum[keyof typeof CommitFileAttributesEnum];
|
||||
|
||||
/**
|
||||
* A link to a resource related to this object.
|
||||
* @public
|
||||
*/
|
||||
export interface Link {
|
||||
href?: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base type for most resource objects. It defines the common `type` element that identifies an object's type. It also identifies the element as Swagger's `discriminator`.
|
||||
* @public
|
||||
*/
|
||||
export interface ModelObject {
|
||||
[key: string]: unknown;
|
||||
type: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A generic paginated list.
|
||||
* @public
|
||||
*/
|
||||
export interface Paginated<TResultItem> {
|
||||
/**
|
||||
* Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs.
|
||||
*/
|
||||
next?: string;
|
||||
/**
|
||||
* Page number of the current results. This is an optional element that is not provided in all responses.
|
||||
*/
|
||||
page?: number;
|
||||
/**
|
||||
* Current number of objects on the existing page. The default value is 10 with 100 being the maximum allowed value. Individual APIs may enforce different values.
|
||||
*/
|
||||
pagelen?: number;
|
||||
/**
|
||||
* Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs.
|
||||
*/
|
||||
previous?: string;
|
||||
/**
|
||||
* Total number of objects in the response. This is an optional element that is not provided in all responses, as it can be expensive to compute.
|
||||
*/
|
||||
size?: number;
|
||||
/**
|
||||
* The values of the current page.
|
||||
*/
|
||||
values?: Array<TResultItem> | Set<TResultItem>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A paginated list of repositories.
|
||||
* @public
|
||||
*/
|
||||
export interface PaginatedRepositories extends Paginated<Repository> {
|
||||
/**
|
||||
* The values of the current page.
|
||||
*/
|
||||
values?: Set<Repository>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object describing a user's role on resources like commits or pull requests.
|
||||
* @public
|
||||
*/
|
||||
export interface Participant extends ModelObject {
|
||||
approved?: boolean;
|
||||
/**
|
||||
* The ISO8601 timestamp of the participant's action. For approvers, this is the time of their approval. For commenters and pull request reviewers who are not approvers, this is the time they last commented, or null if they have not commented.
|
||||
*/
|
||||
participated_on?: string;
|
||||
role?: ParticipantRoleEnum;
|
||||
state?: ParticipantStateEnum;
|
||||
user?: User;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const ParticipantRoleEnum = {
|
||||
Participant: 'PARTICIPANT',
|
||||
Reviewer: 'REVIEWER',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ParticipantRoleEnum =
|
||||
typeof ParticipantRoleEnum[keyof typeof ParticipantRoleEnum];
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const ParticipantStateEnum = {
|
||||
Approved: 'approved',
|
||||
ChangesRequested: 'changes_requested',
|
||||
Null: 'null',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ParticipantStateEnum =
|
||||
typeof ParticipantStateEnum[keyof typeof ParticipantStateEnum];
|
||||
|
||||
/**
|
||||
* A Bitbucket project.
|
||||
* Projects are used by teams to organize repositories.
|
||||
* @public
|
||||
*/
|
||||
export interface Project extends ModelObject {
|
||||
created_on?: string;
|
||||
description?: string;
|
||||
/**
|
||||
*
|
||||
* Indicates whether the project contains publicly visible repositories.
|
||||
* Note that private projects cannot contain public repositories.
|
||||
*/
|
||||
has_publicly_visible_repos?: boolean;
|
||||
/**
|
||||
*
|
||||
* Indicates whether the project is publicly accessible, or whether it is
|
||||
* private to the team and consequently only visible to team members.
|
||||
* Note that private projects cannot contain public repositories.
|
||||
*/
|
||||
is_private?: boolean;
|
||||
/**
|
||||
* The project's key.
|
||||
*/
|
||||
key?: string;
|
||||
links?: ProjectLinks;
|
||||
/**
|
||||
* The name of the project.
|
||||
*/
|
||||
name?: string;
|
||||
owner?: Team;
|
||||
updated_on?: string;
|
||||
/**
|
||||
* The project's immutable id.
|
||||
*/
|
||||
uuid?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface ProjectLinks {
|
||||
avatar?: Link;
|
||||
html?: Link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface RefLinks {
|
||||
commits?: Link;
|
||||
html?: Link;
|
||||
self?: Link;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Bitbucket repository.
|
||||
* @public
|
||||
*/
|
||||
export interface Repository extends ModelObject {
|
||||
created_on?: string;
|
||||
description?: string;
|
||||
/**
|
||||
*
|
||||
* Controls the rules for forking this repository.
|
||||
*
|
||||
* * **allow_forks**: unrestricted forking
|
||||
* * **no_public_forks**: restrict forking to private forks (forks cannot
|
||||
* be made public later)
|
||||
* * **no_forks**: deny all forking
|
||||
*/
|
||||
fork_policy?: RepositoryForkPolicyEnum;
|
||||
/**
|
||||
* The concatenation of the repository owner's username and the slugified name, e.g. "evzijst/interruptingcow". This is the same string used in Bitbucket URLs.
|
||||
*/
|
||||
full_name?: string;
|
||||
has_issues?: boolean;
|
||||
has_wiki?: boolean;
|
||||
is_private?: boolean;
|
||||
language?: string;
|
||||
links?: RepositoryLinks;
|
||||
mainbranch?: Branch;
|
||||
name?: string;
|
||||
owner?: Account;
|
||||
parent?: Repository;
|
||||
project?: Project;
|
||||
scm?: RepositoryScmEnum;
|
||||
size?: number;
|
||||
/**
|
||||
* The "sluggified" version of the repository's name. This contains only ASCII characters and can therefore be slightly different than the name
|
||||
*/
|
||||
slug?: string;
|
||||
updated_on?: string;
|
||||
/**
|
||||
* The repository's immutable id. This can be used as a substitute for the slug segment in URLs. Doing this guarantees your URLs will survive renaming of the repository by its owner, or even transfer of the repository to a different user.
|
||||
*/
|
||||
uuid?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Controls the rules for forking this repository.
|
||||
*
|
||||
* * **allow_forks**: unrestricted forking
|
||||
* * **no_public_forks**: restrict forking to private forks (forks cannot
|
||||
* be made public later)
|
||||
* * **no_forks**: deny all forking
|
||||
* @public
|
||||
*/
|
||||
export const RepositoryForkPolicyEnum = {
|
||||
AllowForks: 'allow_forks',
|
||||
NoPublicForks: 'no_public_forks',
|
||||
NoForks: 'no_forks',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
*
|
||||
* Controls the rules for forking this repository.
|
||||
*
|
||||
* * **allow_forks**: unrestricted forking
|
||||
* * **no_public_forks**: restrict forking to private forks (forks cannot
|
||||
* be made public later)
|
||||
* * **no_forks**: deny all forking
|
||||
* @public
|
||||
*/
|
||||
export type RepositoryForkPolicyEnum =
|
||||
typeof RepositoryForkPolicyEnum[keyof typeof RepositoryForkPolicyEnum];
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const RepositoryScmEnum = {
|
||||
Git: 'git',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type RepositoryScmEnum =
|
||||
typeof RepositoryScmEnum[keyof typeof RepositoryScmEnum];
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface RepositoryLinks {
|
||||
avatar?: Link;
|
||||
clone?: Array<Link>;
|
||||
commits?: Link;
|
||||
downloads?: Link;
|
||||
forks?: Link;
|
||||
hooks?: Link;
|
||||
html?: Link;
|
||||
pullrequests?: Link;
|
||||
self?: Link;
|
||||
watchers?: Link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface SearchCodeSearchResult {
|
||||
readonly content_match_count?: number;
|
||||
readonly content_matches?: Array<SearchContentMatch>;
|
||||
file?: CommitFile;
|
||||
readonly path_matches?: Array<SearchSegment>;
|
||||
readonly type?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface SearchContentMatch {
|
||||
readonly lines?: Array<SearchLine>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface SearchLine {
|
||||
readonly line?: number;
|
||||
readonly segments?: Array<SearchSegment>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface SearchResultPage extends Paginated<SearchCodeSearchResult> {
|
||||
readonly query_substituted?: boolean;
|
||||
/**
|
||||
* The values of the current page.
|
||||
*/
|
||||
readonly values?: Array<SearchCodeSearchResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface SearchSegment {
|
||||
readonly match?: boolean;
|
||||
readonly text?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A team object.
|
||||
* @public
|
||||
*/
|
||||
export interface Team extends Account {}
|
||||
|
||||
/**
|
||||
* A user object.
|
||||
* @public
|
||||
*/
|
||||
export interface User extends Account {
|
||||
/**
|
||||
* The user's Atlassian account ID.
|
||||
*/
|
||||
account_id?: string;
|
||||
is_staff?: boolean;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright 2022 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 { Models } from './models';
|
||||
import { WithPagination } from './pagination';
|
||||
|
||||
interface TestResultItem {
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface TestPage extends Models.Paginated<TestResultItem> {}
|
||||
|
||||
describe('WithPagination', () => {
|
||||
const createPagination = () =>
|
||||
new WithPagination<TestPage, TestResultItem>(
|
||||
opts =>
|
||||
new URL(
|
||||
`http://localhost/create-url?page=${opts.page}&pagelen=${opts.pagelen}`,
|
||||
),
|
||||
async url => {
|
||||
const currentPage = Number.parseInt(url.searchParams.get('page')!, 10);
|
||||
const next = new URL(url.toString());
|
||||
next.searchParams.set('page', (currentPage + 1).toString());
|
||||
|
||||
return {
|
||||
page: currentPage,
|
||||
...(currentPage >= 2 ? {} : { next: next.toString() }),
|
||||
values: [
|
||||
{
|
||||
url: url.toString(),
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
it('iterateResults', async () => {
|
||||
const pagination = createPagination();
|
||||
|
||||
const urls = [];
|
||||
for await (const result of pagination.iterateResults()) {
|
||||
urls.push(result.url.toString());
|
||||
}
|
||||
|
||||
expect(urls).toHaveLength(2);
|
||||
expect(urls).toEqual([
|
||||
'http://localhost/create-url?page=1&pagelen=100',
|
||||
'http://localhost/create-url?page=2&pagelen=100',
|
||||
]);
|
||||
});
|
||||
|
||||
it('iteratePages', async () => {
|
||||
const pagination = createPagination();
|
||||
|
||||
const pages = [];
|
||||
for await (const page of pagination.iteratePages()) {
|
||||
pages.push(page);
|
||||
}
|
||||
|
||||
expect(pages).toHaveLength(2);
|
||||
expect(pages).toEqual([
|
||||
{
|
||||
next: 'http://localhost/create-url?page=2&pagelen=100',
|
||||
page: 1,
|
||||
values: [
|
||||
{
|
||||
url: 'http://localhost/create-url?page=1&pagelen=100',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
page: 2,
|
||||
values: [
|
||||
{
|
||||
url: 'http://localhost/create-url?page=2&pagelen=100',
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
describe('getPage', () => {
|
||||
it('default opts', async () => {
|
||||
const pagination = createPagination();
|
||||
|
||||
const page = await pagination.getPage();
|
||||
|
||||
expect(page.page).toEqual(1);
|
||||
expect(page.next).toEqual(
|
||||
'http://localhost/create-url?page=2&pagelen=100',
|
||||
);
|
||||
expect(page.values).toHaveLength(1);
|
||||
expect((page.values! as TestResultItem[])[0].url).toEqual(
|
||||
'http://localhost/create-url?page=1&pagelen=100',
|
||||
);
|
||||
});
|
||||
|
||||
it('custom opts', async () => {
|
||||
const pagination = createPagination();
|
||||
|
||||
const page = await pagination.getPage({ page: 4 });
|
||||
|
||||
expect(page.page).toEqual(4);
|
||||
expect(page.next).toBeUndefined();
|
||||
expect(page.values).toHaveLength(1);
|
||||
expect((page.values! as TestResultItem[])[0].url).toEqual(
|
||||
'http://localhost/create-url?page=4&pagelen=100',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2022 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 { Models } from './models';
|
||||
|
||||
/** @public */
|
||||
export type PaginationOptions = {
|
||||
page?: number;
|
||||
pagelen?: number;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
export class WithPagination<
|
||||
TPage extends Models.Paginated<TResultItem>,
|
||||
TResultItem,
|
||||
> {
|
||||
constructor(
|
||||
private readonly createUrl: (options: PaginationOptions) => URL,
|
||||
private readonly fetch: (url: URL) => Promise<TPage>,
|
||||
) {}
|
||||
|
||||
getPage(options?: PaginationOptions): Promise<TPage> {
|
||||
const opts = { page: 1, pagelen: 100, ...options };
|
||||
const url = this.createUrl(opts);
|
||||
return this.fetch(url);
|
||||
}
|
||||
|
||||
async *iteratePages(
|
||||
options?: PaginationOptions,
|
||||
): AsyncGenerator<TPage, void> {
|
||||
const opts = { page: 1, pagelen: 100, ...options };
|
||||
let url: URL | undefined = this.createUrl(opts);
|
||||
let res;
|
||||
do {
|
||||
res = await this.fetch(url);
|
||||
url = res.next ? new URL(res.next) : undefined;
|
||||
yield res;
|
||||
} while (url);
|
||||
}
|
||||
|
||||
async *iterateResults(options?: PaginationOptions) {
|
||||
const opts = { page: 1, pagelen: 100, ...options };
|
||||
let url: URL | undefined = this.createUrl(opts);
|
||||
let res;
|
||||
do {
|
||||
res = await this.fetch(url);
|
||||
url = res.next ? new URL(res.next) : undefined;
|
||||
for (const item of res.values ?? []) {
|
||||
yield item;
|
||||
}
|
||||
} while (url);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2022 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 {};
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2022 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 { PaginationOptions } from './pagination';
|
||||
|
||||
/** @public */
|
||||
export type FilterAndSortOptions = {
|
||||
q?: string;
|
||||
sort?: string;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
export type PartialResponseOptions = {
|
||||
fields?: string;
|
||||
};
|
||||
|
||||
/** @public */
|
||||
export type RequestOptions = FilterAndSortOptions &
|
||||
PaginationOptions &
|
||||
PartialResponseOptions & {
|
||||
[key: string]: string | number | undefined;
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* {{{appName}}}
|
||||
* {{{appDescription}}}
|
||||
*
|
||||
* {{#version}}The version of the OpenAPI document: {{{.}}}{{/version}}
|
||||
* {{#infoEmail}}Contact: {{{.}}}{{/infoEmail}}
|
||||
*
|
||||
* NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
{{#unescapedDescription}}
|
||||
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
|
||||
{{/unescapedDescription}}
|
||||
* @public
|
||||
{{#deprecated}}
|
||||
* @deprecated
|
||||
{{/deprecated}}
|
||||
*/
|
||||
export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
|
||||
{{#additionalPropertiesType}}
|
||||
[key: string]: unknown;
|
||||
{{/additionalPropertiesType}}
|
||||
{{#vars}}
|
||||
{{#unescapedDescription}}
|
||||
/**
|
||||
* {{#lambda.indented_star_4}}{{{unescapedDescription}}}{{/lambda.indented_star_4}}
|
||||
{{#deprecated}}
|
||||
* @deprecated
|
||||
{{/deprecated}}
|
||||
*/
|
||||
{{/unescapedDescription}}
|
||||
{{^unescapedDescription}}
|
||||
{{#deprecated}}
|
||||
/** @deprecated */
|
||||
{{/deprecated}}
|
||||
{{/unescapedDescription}}
|
||||
{{#isReadOnly}}readonly {{/isReadOnly}}{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};
|
||||
{{/vars}}
|
||||
}{{#hasEnums}}
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
|
||||
/**
|
||||
{{#unescapedDescription}}
|
||||
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
|
||||
{{/unescapedDescription}}
|
||||
* @public
|
||||
{{#deprecated}}
|
||||
* @deprecated
|
||||
{{/deprecated}}
|
||||
*/
|
||||
export const {{classname}}{{enumName}} = {
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
{{{name}}}: {{{value}}}{{^-last}},{{/-last}}
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
} as const;
|
||||
|
||||
/**
|
||||
{{#unescapedDescription}}
|
||||
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
|
||||
{{/unescapedDescription}}
|
||||
* @public
|
||||
{{#deprecated}}
|
||||
* @deprecated
|
||||
{{/deprecated}}
|
||||
*/
|
||||
export type {{classname}}{{enumName}} = typeof {{classname}}{{enumName}}[keyof typeof {{classname}}{{enumName}}];
|
||||
{{/isEnum}}{{/vars}}{{/hasEnums}}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2022 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.
|
||||
*/
|
||||
|
||||
{{>licenseInfo}}
|
||||
/** @public */
|
||||
export namespace Models {
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
{{^withoutRuntimeChecks}}
|
||||
export * from './{{{ classFilename }}}';
|
||||
{{#useSagaAndRecords}}
|
||||
{{^isEnum}}
|
||||
export * from './{{{ classFilename }}}Record';
|
||||
{{/isEnum}}
|
||||
{{/useSagaAndRecords}}
|
||||
{{/withoutRuntimeChecks}}
|
||||
{{#withoutRuntimeChecks}}
|
||||
{{#isEnum}}
|
||||
{{>modelEnumInterfaces}}
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#oneOf}}
|
||||
{{#-first}}
|
||||
{{>modelOneOfInterfaces}}
|
||||
{{/-first}}
|
||||
{{/oneOf}}
|
||||
{{^oneOf}}
|
||||
{{>modelGenericInterfaces}}
|
||||
{{/oneOf}}
|
||||
{{/isEnum}}
|
||||
{{/withoutRuntimeChecks}}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
|
||||
@@ -0,0 +1 @@
|
||||
# @backstage/plugin-catalog-backend-module-bitbucket-cloud
|
||||
@@ -0,0 +1,9 @@
|
||||
# Catalog Backend Module for Bitbucket Cloud
|
||||
|
||||
This is an extension module to the catalog-backend plugin,
|
||||
providing extensions targeted at Bitbucket Cloud offerings.
|
||||
|
||||
## Getting started
|
||||
|
||||
See [Backstage documentation](https://backstage.io/docs/integrations/bitbucketCloud/discovery)
|
||||
for details on how to install and configure the plugin.
|
||||
@@ -0,0 +1,31 @@
|
||||
## API Report File for "@backstage/plugin-catalog-backend-module-bitbucket-cloud"
|
||||
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { Config } from '@backstage/config';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-backend';
|
||||
import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
|
||||
import { Logger } from 'winston';
|
||||
import { TaskRunner } from '@backstage/backend-tasks';
|
||||
|
||||
// @public
|
||||
export class BitbucketCloudEntityProvider implements EntityProvider {
|
||||
// (undocumented)
|
||||
connect(connection: EntityProviderConnection): Promise<void>;
|
||||
// (undocumented)
|
||||
static fromConfig(
|
||||
config: Config,
|
||||
options: {
|
||||
logger: Logger;
|
||||
schedule: TaskRunner;
|
||||
},
|
||||
): BitbucketCloudEntityProvider[];
|
||||
// (undocumented)
|
||||
getProviderName(): string;
|
||||
// (undocumented)
|
||||
getTaskId(): string;
|
||||
// (undocumented)
|
||||
refresh(logger: Logger): Promise<void>;
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2022 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 interface Config {
|
||||
catalog?: {
|
||||
/**
|
||||
* List of provider-specific options and attributes
|
||||
*/
|
||||
providers?: {
|
||||
/**
|
||||
* BitbucketCloudEntityProvider configuration
|
||||
*
|
||||
* Uses "default" as default id for the single config variant.
|
||||
*/
|
||||
bitbucketCloud?:
|
||||
| {
|
||||
/**
|
||||
* (Optional) Path to the catalog file. Default to "/catalog-info.yaml".
|
||||
* @visibility frontend
|
||||
*/
|
||||
catalogPath?: string;
|
||||
/**
|
||||
* (Required) Your workspace.
|
||||
* @visibility frontend
|
||||
*/
|
||||
workspace: string;
|
||||
/**
|
||||
* (Optional) Filters applied to discovered catalog files in repositories.
|
||||
* @visibility frontend
|
||||
*/
|
||||
filters?: {
|
||||
/**
|
||||
* (Optional) Filter for the repository slug.
|
||||
* @visibility frontend
|
||||
*/
|
||||
repoSlug?: RegExp;
|
||||
/**
|
||||
* (Optional) Filter for the project key.
|
||||
* @visibility frontend
|
||||
*/
|
||||
projectKey?: RegExp;
|
||||
};
|
||||
}
|
||||
| Record<
|
||||
string,
|
||||
{
|
||||
/**
|
||||
* (Optional) Path to the catalog file. Default to "/catalog-info.yaml".
|
||||
* @visibility frontend
|
||||
*/
|
||||
catalogPath?: string;
|
||||
/**
|
||||
* (Required) Your workspace.
|
||||
* @visibility frontend
|
||||
*/
|
||||
workspace: string;
|
||||
/**
|
||||
* (Optional) Filters applied to discovered catalog files in repositories.
|
||||
* @visibility frontend
|
||||
*/
|
||||
filters?: {
|
||||
/**
|
||||
* (Optional) Filter for the repository slug.
|
||||
* @visibility frontend
|
||||
*/
|
||||
repoSlug?: RegExp;
|
||||
/**
|
||||
* (Optional) Filter for the project key.
|
||||
* @visibility frontend
|
||||
*/
|
||||
projectKey?: RegExp;
|
||||
};
|
||||
}
|
||||
>;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "@backstage/plugin-catalog-backend-module-bitbucket-cloud",
|
||||
"description": "A Backstage catalog backend module that helps integrate towards Bitbucket Cloud",
|
||||
"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-cloud"
|
||||
},
|
||||
"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-tasks": "^0.3.2-next.0",
|
||||
"@backstage/config": "^1.0.1",
|
||||
"@backstage/integration": "^1.2.1-next.0",
|
||||
"@backstage/plugin-bitbucket-cloud-common": "^0.0.0",
|
||||
"@backstage/plugin-catalog-backend": "^1.2.0-next.0",
|
||||
"uuid": "^8.0.0",
|
||||
"winston": "^3.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/backend-common": "^0.13.6-next.0",
|
||||
"@backstage/backend-test-utils": "^0.1.25-next.0",
|
||||
"@backstage/cli": "^0.17.2-next.0",
|
||||
"msw": "^0.35.0"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"config.d.ts"
|
||||
],
|
||||
"configSchema": "config.d.ts"
|
||||
}
|
||||
+281
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* Copyright 2022 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 { getVoidLogger } from '@backstage/backend-common';
|
||||
import { TaskInvocationDefinition, TaskRunner } from '@backstage/backend-tasks';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
|
||||
import { setupRequestMockHandlers } from '@backstage/backend-test-utils';
|
||||
import { BitbucketCloudEntityProvider } from './BitbucketCloudEntityProvider';
|
||||
import { rest } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
|
||||
class PersistingTaskRunner implements TaskRunner {
|
||||
private tasks: TaskInvocationDefinition[] = [];
|
||||
|
||||
getTasks() {
|
||||
return this.tasks;
|
||||
}
|
||||
|
||||
run(task: TaskInvocationDefinition): Promise<void> {
|
||||
this.tasks.push(task);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
const logger = getVoidLogger();
|
||||
|
||||
const server = setupServer();
|
||||
|
||||
describe('BitbucketCloudEntityProvider', () => {
|
||||
setupRequestMockHandlers(server);
|
||||
afterEach(() => jest.resetAllMocks());
|
||||
|
||||
it('no provider config', () => {
|
||||
const schedule = new PersistingTaskRunner();
|
||||
const config = new ConfigReader({});
|
||||
const providers = BitbucketCloudEntityProvider.fromConfig(config, {
|
||||
logger,
|
||||
schedule,
|
||||
});
|
||||
|
||||
expect(providers).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('single simple provider config', () => {
|
||||
const schedule = new PersistingTaskRunner();
|
||||
const config = new ConfigReader({
|
||||
catalog: {
|
||||
providers: {
|
||||
bitbucketCloud: {
|
||||
workspace: 'test-ws',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const providers = BitbucketCloudEntityProvider.fromConfig(config, {
|
||||
logger,
|
||||
schedule,
|
||||
});
|
||||
|
||||
expect(providers).toHaveLength(1);
|
||||
expect(providers[0].getProviderName()).toEqual(
|
||||
'bitbucketCloud-provider:default',
|
||||
);
|
||||
});
|
||||
|
||||
it('multiple provider configs', () => {
|
||||
const schedule = new PersistingTaskRunner();
|
||||
const config = new ConfigReader({
|
||||
catalog: {
|
||||
providers: {
|
||||
bitbucketCloud: {
|
||||
myProvider: {
|
||||
workspace: 'test-ws1',
|
||||
},
|
||||
anotherProvider: {
|
||||
workspace: 'test-ws2',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const providers = BitbucketCloudEntityProvider.fromConfig(config, {
|
||||
logger,
|
||||
schedule,
|
||||
});
|
||||
|
||||
expect(providers).toHaveLength(2);
|
||||
expect(providers[0].getProviderName()).toEqual(
|
||||
'bitbucketCloud-provider:myProvider',
|
||||
);
|
||||
expect(providers[1].getProviderName()).toEqual(
|
||||
'bitbucketCloud-provider:anotherProvider',
|
||||
);
|
||||
});
|
||||
|
||||
it('apply full update on scheduled execution', async () => {
|
||||
const config = new ConfigReader({
|
||||
catalog: {
|
||||
providers: {
|
||||
bitbucketCloud: {
|
||||
myProvider: {
|
||||
workspace: 'test-ws',
|
||||
catalogPath: 'custom/path/catalog-custom.yaml',
|
||||
filters: {
|
||||
projectKey: 'test-.*',
|
||||
repoSlug: 'test-.*',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const schedule = new PersistingTaskRunner();
|
||||
const entityProviderConnection: EntityProviderConnection = {
|
||||
applyMutation: jest.fn(),
|
||||
};
|
||||
const provider = BitbucketCloudEntityProvider.fromConfig(config, {
|
||||
logger,
|
||||
schedule,
|
||||
})[0];
|
||||
expect(provider.getProviderName()).toEqual(
|
||||
'bitbucketCloud-provider:myProvider',
|
||||
);
|
||||
|
||||
server.use(
|
||||
rest.get(
|
||||
`https://api.bitbucket.org/2.0/workspaces/test-ws/search/code`,
|
||||
(_req, res, ctx) => {
|
||||
const response = {
|
||||
values: [
|
||||
{
|
||||
// skipped as empty
|
||||
path_matches: [],
|
||||
file: {
|
||||
type: 'commit_file',
|
||||
path: 'path/to/ignored/file',
|
||||
},
|
||||
},
|
||||
{
|
||||
path_matches: [
|
||||
{
|
||||
match: true,
|
||||
text: 'catalog-custom.yaml',
|
||||
},
|
||||
],
|
||||
file: {
|
||||
type: 'commit_file',
|
||||
path: 'custom/path/catalog-custom.yaml',
|
||||
commit: {
|
||||
repository: {
|
||||
// skipped as no match with filter
|
||||
slug: 'repo',
|
||||
project: {
|
||||
key: 'test-project',
|
||||
},
|
||||
mainbranch: {
|
||||
name: 'main',
|
||||
},
|
||||
links: {
|
||||
html: {
|
||||
href: 'https://bitbucket.org/test-ws/repo',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path_matches: [
|
||||
{
|
||||
match: true,
|
||||
text: 'catalog-custom.yaml',
|
||||
},
|
||||
],
|
||||
file: {
|
||||
type: 'commit_file',
|
||||
path: 'custom/path/catalog-custom.yaml',
|
||||
commit: {
|
||||
repository: {
|
||||
slug: 'test-repo1',
|
||||
project: {
|
||||
// skipped as no match with filter
|
||||
key: 'project',
|
||||
},
|
||||
mainbranch: {
|
||||
name: 'main',
|
||||
},
|
||||
links: {
|
||||
html: {
|
||||
href: 'https://bitbucket.org/test-ws/test-repo1',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path_matches: [
|
||||
{
|
||||
match: true,
|
||||
text: 'catalog-custom.yaml',
|
||||
},
|
||||
],
|
||||
file: {
|
||||
type: 'commit_file',
|
||||
path: 'custom/path/catalog-custom.yaml',
|
||||
commit: {
|
||||
repository: {
|
||||
slug: 'test-repo2',
|
||||
project: {
|
||||
key: 'test-project',
|
||||
},
|
||||
mainbranch: {
|
||||
name: 'main',
|
||||
},
|
||||
links: {
|
||||
html: {
|
||||
href: 'https://bitbucket.org/test-ws/test-repo2',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
return res(ctx.json(response));
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
await provider.connect(entityProviderConnection);
|
||||
|
||||
const taskDef = schedule.getTasks()[0];
|
||||
expect(taskDef.id).toEqual('bitbucketCloud-provider:myProvider:refresh');
|
||||
await (taskDef.fn as () => Promise<void>)();
|
||||
|
||||
const url = `https://bitbucket.org/test-ws/test-repo2/src/main/custom/path/catalog-custom.yaml`;
|
||||
const expectedEntities = [
|
||||
{
|
||||
entity: {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'Location',
|
||||
metadata: {
|
||||
annotations: {
|
||||
'backstage.io/managed-by-location': `url:${url}`,
|
||||
'backstage.io/managed-by-origin-location': `url:${url}`,
|
||||
},
|
||||
name: 'generated-7c2e6263b6cc2d14e69fd4d029afba601ad6dc3b',
|
||||
},
|
||||
spec: {
|
||||
presence: 'required',
|
||||
target: `${url}`,
|
||||
type: 'url',
|
||||
},
|
||||
},
|
||||
locationKey: 'bitbucketCloud-provider:myProvider',
|
||||
},
|
||||
];
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledTimes(1);
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledWith({
|
||||
type: 'full',
|
||||
entities: expectedEntities,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Copyright 2022 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 { TaskRunner } from '@backstage/backend-tasks';
|
||||
import { Config } from '@backstage/config';
|
||||
import {
|
||||
BitbucketCloudIntegration,
|
||||
ScmIntegrations,
|
||||
} from '@backstage/integration';
|
||||
import {
|
||||
BitbucketCloudClient,
|
||||
Models,
|
||||
} from '@backstage/plugin-bitbucket-cloud-common';
|
||||
import {
|
||||
EntityProvider,
|
||||
EntityProviderConnection,
|
||||
LocationSpec,
|
||||
locationSpecToLocationEntity,
|
||||
} from '@backstage/plugin-catalog-backend';
|
||||
import {
|
||||
BitbucketCloudEntityProviderConfig,
|
||||
readProviderConfigs,
|
||||
} from './BitbucketCloudEntityProviderConfig';
|
||||
import * as uuid from 'uuid';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
const DEFAULT_BRANCH = 'master';
|
||||
|
||||
/**
|
||||
* Discovers catalog files located in [Bitbucket Cloud](https://bitbucket.org).
|
||||
* The provider will search your Bitbucket Cloud account and register catalog files matching the configured path
|
||||
* as Location entity and via following processing steps add all contained catalog entities.
|
||||
* This can be useful as an alternative to static locations or manually adding things to the catalog.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export class BitbucketCloudEntityProvider implements EntityProvider {
|
||||
private readonly client: BitbucketCloudClient;
|
||||
private readonly config: BitbucketCloudEntityProviderConfig;
|
||||
private readonly logger: Logger;
|
||||
private readonly scheduleFn: () => Promise<void>;
|
||||
private connection?: EntityProviderConnection;
|
||||
|
||||
static fromConfig(
|
||||
config: Config,
|
||||
options: {
|
||||
logger: Logger;
|
||||
schedule: TaskRunner;
|
||||
},
|
||||
): BitbucketCloudEntityProvider[] {
|
||||
const integrations = ScmIntegrations.fromConfig(config);
|
||||
const integration = integrations.bitbucketCloud.byHost('bitbucket.org');
|
||||
if (!integration) {
|
||||
// this should never happen as we add a default integration,
|
||||
// but as a general safeguard, e.g. if this approach gets changed
|
||||
throw new Error('No integration for bitbucket.org available');
|
||||
}
|
||||
|
||||
return readProviderConfigs(config).map(
|
||||
providerConfig =>
|
||||
new BitbucketCloudEntityProvider(
|
||||
providerConfig,
|
||||
integration,
|
||||
options.logger,
|
||||
options.schedule,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
private constructor(
|
||||
config: BitbucketCloudEntityProviderConfig,
|
||||
integration: BitbucketCloudIntegration,
|
||||
logger: Logger,
|
||||
schedule: TaskRunner,
|
||||
) {
|
||||
this.client = BitbucketCloudClient.fromConfig(integration.config);
|
||||
this.config = config;
|
||||
this.logger = logger.child({
|
||||
target: this.getProviderName(),
|
||||
});
|
||||
this.scheduleFn = this.createScheduleFn(schedule);
|
||||
}
|
||||
|
||||
private createScheduleFn(schedule: TaskRunner): () => Promise<void> {
|
||||
return async () => {
|
||||
const taskId = this.getTaskId();
|
||||
return schedule.run({
|
||||
id: taskId,
|
||||
fn: async () => {
|
||||
const logger = this.logger.child({
|
||||
class: BitbucketCloudEntityProvider.prototype.constructor.name,
|
||||
taskId,
|
||||
taskInstanceId: uuid.v4(),
|
||||
});
|
||||
|
||||
try {
|
||||
await this.refresh(logger);
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
|
||||
getProviderName(): string {
|
||||
return `bitbucketCloud-provider:${this.config.id}`;
|
||||
}
|
||||
|
||||
/** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getTaskId} */
|
||||
getTaskId(): string {
|
||||
return `${this.getProviderName()}:refresh`;
|
||||
}
|
||||
|
||||
/** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */
|
||||
async connect(connection: EntityProviderConnection): Promise<void> {
|
||||
this.connection = connection;
|
||||
await this.scheduleFn();
|
||||
}
|
||||
|
||||
async refresh(logger: Logger) {
|
||||
if (!this.connection) {
|
||||
throw new Error('Not initialized');
|
||||
}
|
||||
|
||||
logger.info('Discovering catalog files in Bitbucket Cloud repositories');
|
||||
|
||||
const targets = await this.findCatalogFiles();
|
||||
const entities = targets
|
||||
.map(BitbucketCloudEntityProvider.toLocationSpec)
|
||||
.map(location => locationSpecToLocationEntity({ location }))
|
||||
.map(entity => {
|
||||
return {
|
||||
locationKey: this.getProviderName(),
|
||||
entity: entity,
|
||||
};
|
||||
});
|
||||
|
||||
await this.connection.applyMutation({
|
||||
type: 'full',
|
||||
entities: entities,
|
||||
});
|
||||
|
||||
logger.info(
|
||||
`Committed ${entities.length} Locations for catalog files in Bitbucket Cloud repositories`,
|
||||
);
|
||||
}
|
||||
|
||||
private async findCatalogFiles(): Promise<string[]> {
|
||||
const workspace = this.config.workspace;
|
||||
const catalogPath = this.config.catalogPath;
|
||||
|
||||
const catalogFilename = catalogPath.substring(
|
||||
catalogPath.lastIndexOf('/') + 1,
|
||||
);
|
||||
|
||||
// load all fields relevant for creating refs later, but not more
|
||||
const fields = [
|
||||
// exclude code/content match details
|
||||
'-values.content_matches',
|
||||
// include/add relevant repository details
|
||||
'+values.file.commit.repository.mainbranch.name',
|
||||
'+values.file.commit.repository.project.key',
|
||||
'+values.file.commit.repository.slug',
|
||||
// remove irrelevant links
|
||||
'-values.*.links',
|
||||
'-values.*.*.links',
|
||||
'-values.*.*.*.links',
|
||||
// ...except the one we need
|
||||
'+values.file.commit.repository.links.html.href',
|
||||
].join(',');
|
||||
const query = `"${catalogFilename}" path:${catalogPath}`;
|
||||
const searchResults = this.client
|
||||
.searchCode(workspace, query, { fields })
|
||||
.iterateResults();
|
||||
|
||||
const result: string[] = [];
|
||||
|
||||
for await (const searchResult of searchResults) {
|
||||
// not a file match, but a code match
|
||||
if (searchResult.path_matches!.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const repository = searchResult.file!.commit!.repository!;
|
||||
if (this.matchesFilters(repository)) {
|
||||
result.push(
|
||||
BitbucketCloudEntityProvider.toUrl(
|
||||
repository,
|
||||
searchResult.file!.path!,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private matchesFilters(repository: Models.Repository): boolean {
|
||||
const filters = this.config.filters;
|
||||
return (
|
||||
!filters ||
|
||||
((!filters.projectKey ||
|
||||
filters.projectKey.test(repository.project!.key!)) &&
|
||||
(!filters.repoSlug || filters.repoSlug.test(repository.slug!)))
|
||||
);
|
||||
}
|
||||
|
||||
private static toUrl(
|
||||
repository: Models.Repository,
|
||||
filePath: string,
|
||||
): string {
|
||||
const repoUrl = repository.links!.html!.href;
|
||||
const branch = repository.mainbranch?.name ?? DEFAULT_BRANCH;
|
||||
|
||||
return `${repoUrl}/src/${branch}/${filePath}`;
|
||||
}
|
||||
|
||||
private static toLocationSpec(target: string): LocationSpec {
|
||||
return {
|
||||
type: 'url',
|
||||
target: target,
|
||||
presence: 'required',
|
||||
};
|
||||
}
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright 2022 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 { ConfigReader } from '@backstage/config';
|
||||
import { readProviderConfigs } from './BitbucketCloudEntityProviderConfig';
|
||||
|
||||
describe('readProviderConfigs', () => {
|
||||
afterEach(() => jest.resetAllMocks());
|
||||
|
||||
it('no provider config', () => {
|
||||
const config = new ConfigReader({});
|
||||
const providerConfigs = readProviderConfigs(config);
|
||||
|
||||
expect(providerConfigs).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('single simple provider config', () => {
|
||||
const config = new ConfigReader({
|
||||
catalog: {
|
||||
providers: {
|
||||
bitbucketCloud: {
|
||||
workspace: 'test-ws',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const providerConfigs = readProviderConfigs(config);
|
||||
|
||||
expect(providerConfigs).toHaveLength(1);
|
||||
expect(providerConfigs[0].id).toEqual('default');
|
||||
expect(providerConfigs[0].workspace).toEqual('test-ws');
|
||||
});
|
||||
|
||||
it('multiple provider configs', () => {
|
||||
const config = new ConfigReader({
|
||||
catalog: {
|
||||
providers: {
|
||||
bitbucketCloud: {
|
||||
providerWorkspaceOnly: {
|
||||
workspace: 'test-ws1',
|
||||
},
|
||||
providerCustomCatalogPath: {
|
||||
workspace: 'test-ws2',
|
||||
catalogPath: 'custom/path/catalog-info.yaml',
|
||||
},
|
||||
providerWithProjectKeyFilter: {
|
||||
workspace: 'test-ws3',
|
||||
filters: {
|
||||
projectKey: 'projectKey.*filter',
|
||||
},
|
||||
},
|
||||
providerWithRepoSlugFilter: {
|
||||
workspace: 'test-ws4',
|
||||
filters: {
|
||||
repoSlug: 'repoSlug.*filter',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const providerConfigs = readProviderConfigs(config);
|
||||
|
||||
expect(providerConfigs).toHaveLength(4);
|
||||
expect(providerConfigs[0]).toEqual({
|
||||
id: 'providerWorkspaceOnly',
|
||||
workspace: 'test-ws1',
|
||||
catalogPath: '/catalog-info.yaml',
|
||||
filters: {
|
||||
projectKey: undefined,
|
||||
repoSlug: undefined,
|
||||
},
|
||||
});
|
||||
expect(providerConfigs[1]).toEqual({
|
||||
id: 'providerCustomCatalogPath',
|
||||
workspace: 'test-ws2',
|
||||
catalogPath: 'custom/path/catalog-info.yaml',
|
||||
filters: {
|
||||
projectKey: undefined,
|
||||
repoSlug: undefined,
|
||||
},
|
||||
});
|
||||
expect(providerConfigs[2]).toEqual({
|
||||
id: 'providerWithProjectKeyFilter',
|
||||
workspace: 'test-ws3',
|
||||
catalogPath: '/catalog-info.yaml',
|
||||
filters: {
|
||||
projectKey: /^projectKey.*filter$/,
|
||||
repoSlug: undefined,
|
||||
},
|
||||
});
|
||||
expect(providerConfigs[3]).toEqual({
|
||||
id: 'providerWithRepoSlugFilter',
|
||||
workspace: 'test-ws4',
|
||||
catalogPath: '/catalog-info.yaml',
|
||||
filters: {
|
||||
projectKey: undefined,
|
||||
repoSlug: /^repoSlug.*filter$/,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2022 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 { Config } from '@backstage/config';
|
||||
|
||||
const DEFAULT_CATALOG_PATH = '/catalog-info.yaml';
|
||||
const DEFAULT_PROVIDER_ID = 'default';
|
||||
|
||||
export type BitbucketCloudEntityProviderConfig = {
|
||||
id: string;
|
||||
catalogPath: string;
|
||||
workspace: string;
|
||||
filters?: {
|
||||
projectKey?: RegExp;
|
||||
repoSlug?: RegExp;
|
||||
};
|
||||
};
|
||||
|
||||
export function readProviderConfigs(
|
||||
config: Config,
|
||||
): BitbucketCloudEntityProviderConfig[] {
|
||||
const providersConfig = config.getOptionalConfig(
|
||||
'catalog.providers.bitbucketCloud',
|
||||
);
|
||||
if (!providersConfig) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (providersConfig.has('workspace')) {
|
||||
// simple/single config variant
|
||||
return [readProviderConfig(DEFAULT_PROVIDER_ID, providersConfig)];
|
||||
}
|
||||
|
||||
return providersConfig.keys().map(id => {
|
||||
const providerConfig = providersConfig.getConfig(id);
|
||||
|
||||
return readProviderConfig(id, providerConfig);
|
||||
});
|
||||
}
|
||||
|
||||
function readProviderConfig(
|
||||
id: string,
|
||||
config: Config,
|
||||
): BitbucketCloudEntityProviderConfig {
|
||||
const workspace = config.getString('workspace');
|
||||
const catalogPath =
|
||||
config.getOptionalString('catalogPath') ?? DEFAULT_CATALOG_PATH;
|
||||
const projectKeyPattern = config.getOptionalString('filters.projectKey');
|
||||
const repoSlugPattern = config.getOptionalString('filters.repoSlug');
|
||||
|
||||
return {
|
||||
id,
|
||||
catalogPath,
|
||||
workspace,
|
||||
filters: {
|
||||
projectKey: projectKeyPattern
|
||||
? compileRegExp(projectKeyPattern)
|
||||
: undefined,
|
||||
repoSlug: repoSlugPattern ? compileRegExp(repoSlugPattern) : undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles a RegExp while enforcing the pattern to contain
|
||||
* the start-of-line and end-of-line anchors.
|
||||
*
|
||||
* @param pattern
|
||||
*/
|
||||
function compileRegExp(pattern: string): RegExp {
|
||||
let fullLinePattern = pattern;
|
||||
if (!fullLinePattern.startsWith('^')) {
|
||||
fullLinePattern = `^${fullLinePattern}`;
|
||||
}
|
||||
if (!fullLinePattern.endsWith('$')) {
|
||||
fullLinePattern = `${fullLinePattern}$`;
|
||||
}
|
||||
|
||||
return new RegExp(fullLinePattern);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2022 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Backstage catalog backend module that helps integrate towards Bitbucket Cloud
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
export { BitbucketCloudEntityProvider } from './BitbucketCloudEntityProvider';
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2022 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 {};
|
||||
@@ -38,6 +38,7 @@
|
||||
"@backstage/config": "^1.0.1",
|
||||
"@backstage/errors": "^1.0.0",
|
||||
"@backstage/integration": "^1.2.1-next.0",
|
||||
"@backstage/plugin-bitbucket-cloud-common": "^0.0.0",
|
||||
"@backstage/plugin-catalog-backend": "^1.2.0-next.0",
|
||||
"@backstage/types": "^1.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { Models } from '@backstage/plugin-bitbucket-cloud-common';
|
||||
import {
|
||||
LocationSpec,
|
||||
processingResult,
|
||||
@@ -23,7 +24,7 @@ import {
|
||||
import { RequestHandler, rest } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { BitbucketDiscoveryProcessor } from './BitbucketDiscoveryProcessor';
|
||||
import { BitbucketRepository20, PagedResponse, PagedResponse20 } from './lib';
|
||||
import { PagedResponse } from './lib';
|
||||
|
||||
const server = setupServer();
|
||||
|
||||
@@ -84,14 +85,14 @@ function setupStubs(
|
||||
|
||||
function setupBitbucketCloudStubs(
|
||||
workspace: string,
|
||||
repositories: Pick<BitbucketRepository20, 'slug' | 'project'>[],
|
||||
repositories: Pick<Models.Repository, 'slug' | 'project'>[],
|
||||
) {
|
||||
const stubCallerFn = jest.fn();
|
||||
function pagedResponse(values: any): PagedResponse20<any> {
|
||||
function pagedResponse(values: any): Models.PaginatedRepositories {
|
||||
return {
|
||||
values: values,
|
||||
page: 1,
|
||||
} as PagedResponse20<any>;
|
||||
} as Models.PaginatedRepositories;
|
||||
}
|
||||
|
||||
server.use(
|
||||
@@ -121,15 +122,15 @@ function setupBitbucketCloudStubs(
|
||||
|
||||
function setupBitbucketCloudSearchStubs(
|
||||
workspace: string,
|
||||
repositories: Pick<BitbucketRepository20, 'slug' | 'project'>[],
|
||||
repositories: Pick<Models.Repository, 'slug' | 'project'>[],
|
||||
catalogPath: string,
|
||||
) {
|
||||
const stubCallerFn = jest.fn();
|
||||
function pagedResponse(values: any): PagedResponse20<any> {
|
||||
function pagedResponse(values: any): Models.PaginatedRepositories {
|
||||
return {
|
||||
values: values,
|
||||
page: 1,
|
||||
} as PagedResponse20<any>;
|
||||
} as Models.PaginatedRepositories;
|
||||
}
|
||||
|
||||
server.use(
|
||||
@@ -555,8 +556,14 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
|
||||
it('output all repositories by default', async () => {
|
||||
setupBitbucketCloudStubs('myworkspace', [
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{ project: { key: 'prj-two' }, slug: 'repository-two' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
{
|
||||
project: { type: 'project', key: 'prj-two' },
|
||||
slug: 'repository-two',
|
||||
},
|
||||
]);
|
||||
const location: LocationSpec = {
|
||||
type: 'bitbucket-discovery',
|
||||
@@ -590,8 +597,14 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
|
||||
it('uses provided catalog path', async () => {
|
||||
setupBitbucketCloudStubs('myworkspace', [
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{ project: { key: 'prj-two' }, slug: 'repository-two' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
{
|
||||
project: { type: 'project', key: 'prj-two' },
|
||||
slug: 'repository-two',
|
||||
},
|
||||
]);
|
||||
const location: LocationSpec = {
|
||||
type: 'bitbucket-discovery',
|
||||
@@ -626,8 +639,14 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
|
||||
it('output all repositories', async () => {
|
||||
setupBitbucketCloudStubs('myworkspace', [
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{ project: { key: 'prj-two' }, slug: 'repository-two' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
{
|
||||
project: { type: 'project', key: 'prj-two' },
|
||||
slug: 'repository-two',
|
||||
},
|
||||
]);
|
||||
const location: LocationSpec = {
|
||||
type: 'bitbucket-discovery',
|
||||
@@ -662,8 +681,14 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
|
||||
it('output repositories with wildcards', async () => {
|
||||
setupBitbucketCloudStubs('myworkspace', [
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{ project: { key: 'prj-two' }, slug: 'repository-two' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
{
|
||||
project: { type: 'project', key: 'prj-two' },
|
||||
slug: 'repository-two',
|
||||
},
|
||||
]);
|
||||
const location: LocationSpec = {
|
||||
type: 'bitbucket-discovery',
|
||||
@@ -688,9 +713,18 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
|
||||
it('filter unrelated repositories', async () => {
|
||||
setupBitbucketCloudStubs('myworkspace', [
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-two' },
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-three' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-two',
|
||||
},
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-three',
|
||||
},
|
||||
]);
|
||||
const location: LocationSpec = {
|
||||
type: 'bitbucket-discovery',
|
||||
@@ -715,7 +749,10 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
|
||||
it('submits query', async () => {
|
||||
const mockCall = setupBitbucketCloudStubs('myworkspace', [
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
]);
|
||||
const location: LocationSpec = {
|
||||
type: 'bitbucket-discovery',
|
||||
@@ -750,7 +787,10 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
${'https://bitbucket.org/workspaces/myworkspace/projects/prj-one/repos/repository-*/'}
|
||||
`("target '$target' adds default path to catalog", async ({ target }) => {
|
||||
setupBitbucketCloudStubs('myworkspace', [
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
]);
|
||||
|
||||
const location: LocationSpec = {
|
||||
@@ -778,7 +818,10 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
${'https://bitbucket.org/test'}
|
||||
`("target '$target' is rejected", async ({ target }) => {
|
||||
setupBitbucketCloudStubs('myworkspace', [
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
]);
|
||||
|
||||
const location: LocationSpec = {
|
||||
@@ -813,8 +856,14 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
setupBitbucketCloudSearchStubs(
|
||||
'myworkspace',
|
||||
[
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{ project: { key: 'prj-two' }, slug: 'repository-two' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
{
|
||||
project: { type: 'project', key: 'prj-two' },
|
||||
slug: 'repository-two',
|
||||
},
|
||||
],
|
||||
'catalog-info.yaml',
|
||||
);
|
||||
@@ -852,8 +901,14 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
setupBitbucketCloudSearchStubs(
|
||||
'myworkspace',
|
||||
[
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{ project: { key: 'prj-two' }, slug: 'repository-two' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
{
|
||||
project: { type: 'project', key: 'prj-two' },
|
||||
slug: 'repository-two',
|
||||
},
|
||||
],
|
||||
'my/nested/path/catalog.yaml',
|
||||
);
|
||||
@@ -892,8 +947,14 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
setupBitbucketCloudSearchStubs(
|
||||
'myworkspace',
|
||||
[
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{ project: { key: 'prj-two' }, slug: 'repository-two' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
{
|
||||
project: { type: 'project', key: 'prj-two' },
|
||||
slug: 'repository-two',
|
||||
},
|
||||
],
|
||||
'catalog.yaml',
|
||||
);
|
||||
@@ -932,8 +993,14 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
setupBitbucketCloudSearchStubs(
|
||||
'myworkspace',
|
||||
[
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{ project: { key: 'prj-two' }, slug: 'repository-two' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
{
|
||||
project: { type: 'project', key: 'prj-two' },
|
||||
slug: 'repository-two',
|
||||
},
|
||||
],
|
||||
'catalog.yaml',
|
||||
);
|
||||
@@ -962,9 +1029,18 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
setupBitbucketCloudSearchStubs(
|
||||
'myworkspace',
|
||||
[
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-one' },
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-two' },
|
||||
{ project: { key: 'prj-one' }, slug: 'repository-three' },
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-two',
|
||||
},
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-three',
|
||||
},
|
||||
],
|
||||
'catalog.yaml',
|
||||
);
|
||||
@@ -997,7 +1073,12 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
`("target '$target' adds default path to catalog", async ({ target }) => {
|
||||
setupBitbucketCloudSearchStubs(
|
||||
'myworkspace',
|
||||
[{ project: { key: 'prj-one' }, slug: 'repository-one' }],
|
||||
[
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
],
|
||||
'catalog-info.yaml',
|
||||
);
|
||||
|
||||
@@ -1027,7 +1108,12 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
`("target '$target' is rejected", async ({ target }) => {
|
||||
setupBitbucketCloudSearchStubs(
|
||||
'myworkspace',
|
||||
[{ project: { key: 'prj-one' }, slug: 'repository-one' }],
|
||||
[
|
||||
{
|
||||
project: { type: 'project', key: 'prj-one' },
|
||||
slug: 'repository-one',
|
||||
},
|
||||
],
|
||||
'catalog-info.yaml',
|
||||
);
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@ import {
|
||||
ScmIntegrationRegistry,
|
||||
ScmIntegrations,
|
||||
} from '@backstage/integration';
|
||||
import {
|
||||
BitbucketCloudClient,
|
||||
Models,
|
||||
} from '@backstage/plugin-bitbucket-cloud-common';
|
||||
import {
|
||||
CatalogProcessor,
|
||||
CatalogProcessorEmit,
|
||||
@@ -27,14 +31,11 @@ import {
|
||||
} from '@backstage/plugin-catalog-backend';
|
||||
import { Logger } from 'winston';
|
||||
import {
|
||||
BitbucketCloudClient,
|
||||
BitbucketRepository,
|
||||
BitbucketRepository20,
|
||||
BitbucketRepositoryParser,
|
||||
BitbucketServerClient,
|
||||
defaultRepositoryParser,
|
||||
paginated,
|
||||
paginated20,
|
||||
} from './lib';
|
||||
|
||||
const DEFAULT_BRANCH = 'master';
|
||||
@@ -119,9 +120,7 @@ export class BitbucketDiscoveryProcessor implements CatalogProcessor {
|
||||
options: ProcessOptions,
|
||||
): Promise<ResultSummary> {
|
||||
const { location, integration, emit } = options;
|
||||
const client = new BitbucketCloudClient({
|
||||
config: integration.config,
|
||||
});
|
||||
const client = BitbucketCloudClient.fromConfig(integration.config);
|
||||
|
||||
const { searchEnabled } = parseBitbucketCloudUrl(location.target);
|
||||
|
||||
@@ -226,28 +225,40 @@ export async function searchBitbucketCloudLocations(
|
||||
catalogPath.lastIndexOf('/') + 1,
|
||||
);
|
||||
|
||||
const searchResults = paginated20(options =>
|
||||
client.searchCode(
|
||||
workspacePath,
|
||||
`"${catalogFilename}" path:${catalogPath}`,
|
||||
options,
|
||||
),
|
||||
);
|
||||
// load all fields relevant for creating refs later, but not more
|
||||
const fields = [
|
||||
// exclude code/content match details
|
||||
'-values.content_matches',
|
||||
// include/add relevant repository details
|
||||
'+values.file.commit.repository.mainbranch.name',
|
||||
'+values.file.commit.repository.project.key',
|
||||
'+values.file.commit.repository.slug',
|
||||
// remove irrelevant links
|
||||
'-values.*.links',
|
||||
'-values.*.*.links',
|
||||
'-values.*.*.*.links',
|
||||
// ...except the one we need
|
||||
'+values.file.commit.repository.links.html.href',
|
||||
].join(',');
|
||||
const query = `"${catalogFilename}" path:${catalogPath}`;
|
||||
const searchResults = client
|
||||
.searchCode(workspacePath, query, { fields })
|
||||
.iterateResults();
|
||||
|
||||
for await (const searchResult of searchResults) {
|
||||
// not a file match, but a code match
|
||||
if (searchResult.path_matches.length === 0) {
|
||||
if (searchResult.path_matches!.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const repository = searchResult.file.commit.repository;
|
||||
const repository = searchResult.file!.commit!.repository!;
|
||||
if (!matchesPostFilters(repository, projectSearchPath, repoSearchPath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const repoUrl = repository.links.html.href;
|
||||
const repoUrl = repository.links!.html!.href;
|
||||
const branch = repository.mainbranch?.name ?? DEFAULT_BRANCH;
|
||||
const filePath = searchResult.file.path;
|
||||
const filePath = searchResult.file!.path;
|
||||
const location = `${repoUrl}/src/${branch}/${filePath}`;
|
||||
|
||||
result.matches.push(location);
|
||||
@@ -268,7 +279,7 @@ export async function readBitbucketCloudLocations(
|
||||
return readBitbucketCloud(client, target).then(result => {
|
||||
const matches = result.matches.map(repository => {
|
||||
const branch = repository.mainbranch?.name ?? DEFAULT_BRANCH;
|
||||
return `${repository.links.html.href}/src/${branch}${catalogPath}`;
|
||||
return `${repository.links!.html!.href}/src/${branch}${catalogPath}`;
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -281,7 +292,7 @@ export async function readBitbucketCloudLocations(
|
||||
export async function readBitbucketCloud(
|
||||
client: BitbucketCloudClient,
|
||||
target: string,
|
||||
): Promise<Result<BitbucketRepository20>> {
|
||||
): Promise<Result<Models.Repository>> {
|
||||
const {
|
||||
workspacePath,
|
||||
queryParam: q,
|
||||
@@ -289,13 +300,10 @@ export async function readBitbucketCloud(
|
||||
repoSearchPath,
|
||||
} = parseBitbucketCloudUrl(target);
|
||||
|
||||
const repositories = paginated20(
|
||||
options => client.listRepositoriesByWorkspace(workspacePath, options),
|
||||
{
|
||||
q,
|
||||
},
|
||||
);
|
||||
const result: Result<BitbucketRepository20> = {
|
||||
const repositories = client
|
||||
.listRepositoriesByWorkspace(workspacePath, { q })
|
||||
.iterateResults();
|
||||
const result: Result<Models.Repository> = {
|
||||
scanned: 0,
|
||||
matches: [],
|
||||
};
|
||||
@@ -310,13 +318,13 @@ export async function readBitbucketCloud(
|
||||
}
|
||||
|
||||
function matchesPostFilters(
|
||||
repository: BitbucketRepository20,
|
||||
repository: Models.Repository,
|
||||
projectSearchPath: RegExp | undefined,
|
||||
repoSearchPath: RegExp | undefined,
|
||||
): boolean {
|
||||
return (
|
||||
(!projectSearchPath || projectSearchPath.test(repository.project.key)) &&
|
||||
(!repoSearchPath || repoSearchPath.test(repository.slug))
|
||||
(!projectSearchPath || projectSearchPath.test(repository.project!.key!)) &&
|
||||
(!repoSearchPath || repoSearchPath.test(repository.slug!))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* Copyright 2021 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 {
|
||||
BitbucketIntegrationConfig,
|
||||
getBitbucketRequestOptions,
|
||||
} from '@backstage/integration';
|
||||
import fetch from 'node-fetch';
|
||||
import { BitbucketRepository20 } from './types';
|
||||
|
||||
export class BitbucketCloudClient {
|
||||
private readonly config: BitbucketIntegrationConfig;
|
||||
|
||||
constructor(options: { config: BitbucketIntegrationConfig }) {
|
||||
this.config = options.config;
|
||||
}
|
||||
|
||||
async searchCode(
|
||||
workspace: string,
|
||||
query: string,
|
||||
options?: ListOptions20,
|
||||
): Promise<PagedResponse20<CodeSearchResultItem>> {
|
||||
// load all fields relevant for creating refs later, but not more
|
||||
const fields = [
|
||||
// exclude code/content match details
|
||||
'-values.content_matches',
|
||||
// include/add relevant repository details
|
||||
'+values.file.commit.repository.mainbranch.name',
|
||||
'+values.file.commit.repository.project.key',
|
||||
'+values.file.commit.repository.slug',
|
||||
// remove irrelevant links
|
||||
'-values.*.links',
|
||||
'-values.*.*.links',
|
||||
'-values.*.*.*.links',
|
||||
// ...except the one we need
|
||||
'+values.file.commit.repository.links.html.href',
|
||||
].join(',');
|
||||
|
||||
return this.pagedRequest<CodeSearchResultItem>(
|
||||
`${this.config.apiBaseUrl}/workspaces/${encodeURIComponent(
|
||||
workspace,
|
||||
)}/search/code`,
|
||||
{
|
||||
...options,
|
||||
fields: fields,
|
||||
search_query: query,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async listRepositoriesByWorkspace(
|
||||
workspace: string,
|
||||
options?: ListOptions20,
|
||||
): Promise<PagedResponse20<BitbucketRepository20>> {
|
||||
return this.pagedRequest<BitbucketRepository20>(
|
||||
`${this.config.apiBaseUrl}/repositories/${encodeURIComponent(workspace)}`,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
private async pagedRequest<T = any>(
|
||||
endpoint: string,
|
||||
options?: ListOptions20,
|
||||
): Promise<PagedResponse20<T>> {
|
||||
const request = new URL(endpoint);
|
||||
for (const key in options) {
|
||||
if (options[key]) {
|
||||
request.searchParams.append(key, options[key]!.toString());
|
||||
}
|
||||
}
|
||||
|
||||
const response = await fetch(
|
||||
request.toString(),
|
||||
getBitbucketRequestOptions(this.config),
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Unexpected response when fetching ${request.toString()}. Expected 200 but got ${
|
||||
response.status
|
||||
} - ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
return response.json() as Promise<PagedResponse20<T>>;
|
||||
}
|
||||
}
|
||||
|
||||
export type CodeSearchResultItem = {
|
||||
type: string;
|
||||
content_match_count: number;
|
||||
path_matches: Array<{
|
||||
text: string;
|
||||
match?: boolean;
|
||||
}>;
|
||||
file: {
|
||||
path: string;
|
||||
type: string;
|
||||
commit: {
|
||||
repository: BitbucketRepository20;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export type ListOptions20 = {
|
||||
[key: string]: string | number | undefined;
|
||||
page?: number | undefined;
|
||||
pagelen?: number | undefined;
|
||||
};
|
||||
|
||||
export type PagedResponse20<T> = {
|
||||
page: number;
|
||||
pagelen: number;
|
||||
size: number;
|
||||
values: T[];
|
||||
next: string;
|
||||
};
|
||||
|
||||
export async function* paginated20<T = any>(
|
||||
request: (options: ListOptions20) => Promise<PagedResponse20<T>>,
|
||||
options?: ListOptions20,
|
||||
) {
|
||||
const opts = { page: 1, pagelen: 100, ...options };
|
||||
let res;
|
||||
do {
|
||||
res = await request(opts);
|
||||
opts.page = opts.page + 1;
|
||||
for (const item of res.values) {
|
||||
yield item;
|
||||
}
|
||||
} while (res.next);
|
||||
}
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
export { defaultRepositoryParser } from './BitbucketRepositoryParser';
|
||||
export type { BitbucketRepositoryParser } from './BitbucketRepositoryParser';
|
||||
export { BitbucketCloudClient, paginated20 } from './BitbucketCloudClient';
|
||||
export { BitbucketServerClient, paginated } from './BitbucketServerClient';
|
||||
export type { PagedResponse20 } from './BitbucketCloudClient';
|
||||
export type { PagedResponse } from './BitbucketServerClient';
|
||||
export type { BitbucketRepository, BitbucketRepository20 } from './types';
|
||||
export type { BitbucketRepository } from './types';
|
||||
|
||||
@@ -29,33 +29,3 @@ export type BitbucketRepository = BitbucketRepositoryBase & {
|
||||
}[]
|
||||
>;
|
||||
};
|
||||
|
||||
export type BitbucketRepository20 = BitbucketRepositoryBase & {
|
||||
links: Record<
|
||||
| 'self'
|
||||
| 'source'
|
||||
| 'html'
|
||||
| 'avatar'
|
||||
| 'pullrequests'
|
||||
| 'commits'
|
||||
| 'forks'
|
||||
| 'watchers'
|
||||
| 'downloads'
|
||||
| 'hooks',
|
||||
{
|
||||
href: string;
|
||||
name?: string;
|
||||
}
|
||||
> &
|
||||
Record<
|
||||
'clone',
|
||||
{
|
||||
href: string;
|
||||
name?: string;
|
||||
}[]
|
||||
>;
|
||||
mainbranch?: {
|
||||
type: string;
|
||||
name: string;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4224,6 +4224,29 @@
|
||||
resolved "https://registry.npmjs.org/@n1ru4l/push-pull-async-iterable-iterator/-/push-pull-async-iterable-iterator-3.1.0.tgz#be450c97d1c7cd6af1a992d53232704454345df9"
|
||||
integrity sha512-K4scWxGhdQM0masHHy4gIQs2iGiLEXCrXttumknyPJqtdl4J179BjpibWSSQ1fxKdCcHgIlCTKXJU6cMM6D6Wg==
|
||||
|
||||
"@nestjs/common@8.4.4":
|
||||
version "8.4.4"
|
||||
resolved "https://registry.npmjs.org/@nestjs/common/-/common-8.4.4.tgz#0914c6c0540b5a344c7c8fd6072faa1a49af1158"
|
||||
integrity sha512-QHi7QcgH/5Jinz+SCfIZJkFHc6Cch1YsAEGFEhi6wSp6MILb0sJMQ1CX06e9tCOAjSlBwaJj4PH0eFCVau5v9Q==
|
||||
dependencies:
|
||||
axios "0.26.1"
|
||||
iterare "1.2.1"
|
||||
tslib "2.3.1"
|
||||
uuid "8.3.2"
|
||||
|
||||
"@nestjs/core@8.4.4":
|
||||
version "8.4.4"
|
||||
resolved "https://registry.npmjs.org/@nestjs/core/-/core-8.4.4.tgz#94fd2d63fd77791f616fbecafb79faa2235eeeff"
|
||||
integrity sha512-Ef3yJPuzAttpNfehnGqIV5kHIL9SHptB5F4ERxoU7pT61H3xiYpZw6hSjx68cJO7cc6rm7/N+b4zeuJvFHtvBg==
|
||||
dependencies:
|
||||
"@nuxtjs/opencollective" "0.3.2"
|
||||
fast-safe-stringify "2.1.1"
|
||||
iterare "1.2.1"
|
||||
object-hash "3.0.0"
|
||||
path-to-regexp "3.2.0"
|
||||
tslib "2.3.1"
|
||||
uuid "8.3.2"
|
||||
|
||||
"@nodelib/fs.scandir@2.1.3":
|
||||
version "2.1.3"
|
||||
resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b"
|
||||
@@ -4399,6 +4422,15 @@
|
||||
node-gyp "^8.2.0"
|
||||
read-package-json-fast "^2.0.1"
|
||||
|
||||
"@nuxtjs/opencollective@0.3.2":
|
||||
version "0.3.2"
|
||||
resolved "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz#620ce1044f7ac77185e825e1936115bb38e2681c"
|
||||
integrity sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==
|
||||
dependencies:
|
||||
chalk "^4.1.0"
|
||||
consola "^2.15.0"
|
||||
node-fetch "^2.6.1"
|
||||
|
||||
"@octokit/app@^12.0.4":
|
||||
version "12.0.5"
|
||||
resolved "https://registry.npmjs.org/@octokit/app/-/app-12.0.5.tgz#0b25446daffcb36967b26944410eab1ccbba0c06"
|
||||
@@ -4746,6 +4778,27 @@
|
||||
fast-deep-equal "^3.1.3"
|
||||
lodash.clonedeep "^4.5.0"
|
||||
|
||||
"@openapitools/openapi-generator-cli@^2.4.26":
|
||||
version "2.5.1"
|
||||
resolved "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.5.1.tgz#3825be4f7317199183fbd0d464dd8a7ba055fcf5"
|
||||
integrity sha512-WSRQBU0dCSVD+0Qv8iCsv0C4iMaZe/NpJ/CT4SmrEYLH3txoKTE8wEfbdj/kqShS8Or0YEGDPUzhSIKY151L0w==
|
||||
dependencies:
|
||||
"@nestjs/common" "8.4.4"
|
||||
"@nestjs/core" "8.4.4"
|
||||
"@nuxtjs/opencollective" "0.3.2"
|
||||
chalk "4.1.2"
|
||||
commander "8.3.0"
|
||||
compare-versions "4.1.3"
|
||||
concurrently "6.5.1"
|
||||
console.table "0.10.0"
|
||||
fs-extra "10.0.1"
|
||||
glob "7.1.6"
|
||||
inquirer "8.2.2"
|
||||
lodash "4.17.21"
|
||||
reflect-metadata "0.1.13"
|
||||
rxjs "7.5.5"
|
||||
tslib "2.0.3"
|
||||
|
||||
"@opentelemetry/api@^1.0.1":
|
||||
version "1.0.4"
|
||||
resolved "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.4.tgz#a167e46c10d05a07ab299fc518793b0cff8f6924"
|
||||
@@ -5357,6 +5410,16 @@
|
||||
resolved "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad"
|
||||
integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==
|
||||
|
||||
"@ts-morph/common@~0.15.0":
|
||||
version "0.15.0"
|
||||
resolved "https://registry.npmjs.org/@ts-morph/common/-/common-0.15.0.tgz#aece752746fc0d779d2acfaece95fb2c23327ba5"
|
||||
integrity sha512-QefRbadcwfBnd3HWrltpjRJprHgeKfQsnbyGbRF8pEjMqISAljJwq4wfRETxxojsmN4GWuJv3PWG+W7kBIHMMw==
|
||||
dependencies:
|
||||
fast-glob "^3.2.11"
|
||||
minimatch "^5.0.1"
|
||||
mkdirp "^1.0.4"
|
||||
path-browserify "^1.0.1"
|
||||
|
||||
"@tsconfig/node10@^1.0.7":
|
||||
version "1.0.8"
|
||||
resolved "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9"
|
||||
@@ -7912,6 +7975,13 @@ axios-cached-dns-resolve@0.5.2:
|
||||
pino "^5.12.2"
|
||||
pino-pretty "^2.6.0"
|
||||
|
||||
axios@0.26.1:
|
||||
version "0.26.1"
|
||||
resolved "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz#1ede41c51fcf51bbbd6fd43669caaa4f0495aaa9"
|
||||
integrity sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==
|
||||
dependencies:
|
||||
follow-redirects "^1.14.8"
|
||||
|
||||
axios@^0.21.1, axios@^0.21.4:
|
||||
version "0.21.4"
|
||||
resolved "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
|
||||
@@ -8838,6 +8908,14 @@ chalk@4.1.1:
|
||||
ansi-styles "^4.1.0"
|
||||
supports-color "^7.1.0"
|
||||
|
||||
chalk@4.1.2, chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
|
||||
version "4.1.2"
|
||||
resolved "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
|
||||
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
|
||||
dependencies:
|
||||
ansi-styles "^4.1.0"
|
||||
supports-color "^7.1.0"
|
||||
|
||||
chalk@^1.0.0, chalk@^1.1.3:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
|
||||
@@ -8857,14 +8935,6 @@ chalk@^3.0.0:
|
||||
ansi-styles "^4.1.0"
|
||||
supports-color "^7.1.0"
|
||||
|
||||
chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
|
||||
version "4.1.2"
|
||||
resolved "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
|
||||
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
|
||||
dependencies:
|
||||
ansi-styles "^4.1.0"
|
||||
supports-color "^7.1.0"
|
||||
|
||||
change-case-all@1.0.14:
|
||||
version "1.0.14"
|
||||
resolved "https://registry.npmjs.org/change-case-all/-/change-case-all-1.0.14.tgz#bac04da08ad143278d0ac3dda7eccd39280bfba1"
|
||||
@@ -9213,6 +9283,13 @@ co@^4.6.0:
|
||||
resolved "https://registry.npmjs.org/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
|
||||
integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=
|
||||
|
||||
code-block-writer@^11.0.0:
|
||||
version "11.0.0"
|
||||
resolved "https://registry.npmjs.org/code-block-writer/-/code-block-writer-11.0.0.tgz#5956fb186617f6740e2c3257757fea79315dd7d4"
|
||||
integrity sha512-GEqWvEWWsOvER+g9keO4ohFoD3ymwyCnqY3hoTr7GZipYFwEhMHJw+TtV0rfgRhNImM6QWZGO2XYjlJVyYT62w==
|
||||
dependencies:
|
||||
tslib "2.3.1"
|
||||
|
||||
code-error-fragment@0.0.230:
|
||||
version "0.0.230"
|
||||
resolved "https://registry.npmjs.org/code-error-fragment/-/code-error-fragment-0.0.230.tgz#d736d75c832445342eca1d1fedbf17d9618b14d7"
|
||||
@@ -9379,7 +9456,7 @@ command-exists@^1.2.9:
|
||||
resolved "https://registry.npmjs.org/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69"
|
||||
integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==
|
||||
|
||||
commander@*, commander@^8.3.0:
|
||||
commander@*, commander@8.3.0, commander@^8.3.0:
|
||||
version "8.3.0"
|
||||
resolved "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66"
|
||||
integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==
|
||||
@@ -9437,6 +9514,11 @@ compare-func@^2.0.0:
|
||||
array-ify "^1.0.0"
|
||||
dot-prop "^5.1.0"
|
||||
|
||||
compare-versions@4.1.3:
|
||||
version "4.1.3"
|
||||
resolved "https://registry.npmjs.org/compare-versions/-/compare-versions-4.1.3.tgz#8f7b8966aef7dc4282b45dfa6be98434fc18a1a4"
|
||||
integrity sha512-WQfnbDcrYnGr55UwbxKiQKASnTtNnaAWVi8jZyy8NTpVAXWACSne8lMD1iaIo9AiU6mnuLvSVshCzewVuWxHUg==
|
||||
|
||||
component-bind@1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1"
|
||||
@@ -9536,6 +9618,20 @@ concat-with-sourcemaps@^1.1.0:
|
||||
dependencies:
|
||||
source-map "^0.6.1"
|
||||
|
||||
concurrently@6.5.1:
|
||||
version "6.5.1"
|
||||
resolved "https://registry.npmjs.org/concurrently/-/concurrently-6.5.1.tgz#4518c67f7ac680cf5c34d5adf399a2a2047edc8c"
|
||||
integrity sha512-FlSwNpGjWQfRwPLXvJ/OgysbBxPkWpiVjy1042b0U7on7S7qwwMIILRj7WTN1mTgqa582bG6NFuScOoh6Zgdag==
|
||||
dependencies:
|
||||
chalk "^4.1.0"
|
||||
date-fns "^2.16.1"
|
||||
lodash "^4.17.21"
|
||||
rxjs "^6.6.3"
|
||||
spawn-command "^0.0.2-1"
|
||||
supports-color "^8.1.0"
|
||||
tree-kill "^1.2.2"
|
||||
yargs "^16.2.0"
|
||||
|
||||
concurrently@^7.0.0:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.npmjs.org/concurrently/-/concurrently-7.2.1.tgz#88b144060443403060aad46f837dd17451f7e55e"
|
||||
@@ -9576,6 +9672,11 @@ connect-history-api-fallback@^1.6.0:
|
||||
resolved "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz#8b32089359308d111115d81cad3fceab888f97bc"
|
||||
integrity sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg==
|
||||
|
||||
consola@^2.15.0:
|
||||
version "2.15.3"
|
||||
resolved "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz#2e11f98d6a4be71ff72e0bdf07bd23e12cb61550"
|
||||
integrity sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==
|
||||
|
||||
console-browserify@^1.1.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz#67063cef57ceb6cf4993a2ab3a55840ae8c49336"
|
||||
@@ -9586,6 +9687,13 @@ console-control-strings@^1.0.0, console-control-strings@^1.1.0, console-control-
|
||||
resolved "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e"
|
||||
integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=
|
||||
|
||||
console.table@0.10.0:
|
||||
version "0.10.0"
|
||||
resolved "https://registry.npmjs.org/console.table/-/console.table-0.10.0.tgz#0917025588875befd70cf2eff4bef2c6e2d75d04"
|
||||
integrity sha1-CRcCVYiHW+/XDPLv9L7yxuLXXQQ=
|
||||
dependencies:
|
||||
easy-table "1.1.0"
|
||||
|
||||
constant-case@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.npmjs.org/constant-case/-/constant-case-3.0.4.tgz#3b84a9aeaf4cf31ec45e6bf5de91bdfb0589faf1"
|
||||
@@ -11143,6 +11251,13 @@ eastasianwidth@^0.2.0:
|
||||
resolved "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb"
|
||||
integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==
|
||||
|
||||
easy-table@1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.npmjs.org/easy-table/-/easy-table-1.1.0.tgz#86f9ab4c102f0371b7297b92a651d5824bc8cb73"
|
||||
integrity sha1-hvmrTBAvA3G3KXuSplHVgkvIy3M=
|
||||
optionalDependencies:
|
||||
wcwidth ">=1.0.1"
|
||||
|
||||
ecc-jsbn@~0.1.1:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9"
|
||||
@@ -12291,7 +12406,7 @@ fast-equals@^2.0.0:
|
||||
resolved "https://registry.npmjs.org/fast-equals/-/fast-equals-2.0.4.tgz#3add9410585e2d7364c2deeb6a707beadb24b927"
|
||||
integrity sha512-caj/ZmjHljPrZtbzJ3kfH5ia/k4mTJe/qSiXAGzxZWRZgsgDV0cvNaQULqUX8t0/JVlzzEdYOwCN5DmzTxoD4w==
|
||||
|
||||
fast-glob@^3.2.9:
|
||||
fast-glob@^3.2.11, fast-glob@^3.2.9:
|
||||
version "3.2.11"
|
||||
resolved "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9"
|
||||
integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==
|
||||
@@ -12327,7 +12442,7 @@ fast-redact@^2.0.0:
|
||||
resolved "https://registry.npmjs.org/fast-redact/-/fast-redact-2.1.0.tgz#dfe3c1ca69367fb226f110aa4ec10ec85462ffdf"
|
||||
integrity sha512-0LkHpTLyadJavq9sRzzyqIoMZemWli77K2/MGOkafrR64B9ItrvZ9aT+jluvNDsv0YEHjSNhlMBtbokuoqii4A==
|
||||
|
||||
fast-safe-stringify@^2.0.6, fast-safe-stringify@^2.0.7, fast-safe-stringify@^2.1.1:
|
||||
fast-safe-stringify@2.1.1, fast-safe-stringify@^2.0.6, fast-safe-stringify@^2.0.7, fast-safe-stringify@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz#c406a83b6e70d9e35ce3b30a81141df30aeba884"
|
||||
integrity sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==
|
||||
@@ -12626,6 +12741,11 @@ follow-redirects@^1.0.0, follow-redirects@^1.14.0:
|
||||
resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
|
||||
integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
|
||||
|
||||
follow-redirects@^1.14.8:
|
||||
version "1.15.0"
|
||||
resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz#06441868281c86d0dda4ad8bdaead2d02dca89d4"
|
||||
integrity sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==
|
||||
|
||||
for-in@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
|
||||
@@ -12789,6 +12909,15 @@ fs-constants@^1.0.0:
|
||||
resolved "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad"
|
||||
integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==
|
||||
|
||||
fs-extra@10.0.1:
|
||||
version "10.0.1"
|
||||
resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz#27de43b4320e833f6867cc044bfce29fdf0ef3b8"
|
||||
integrity sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==
|
||||
dependencies:
|
||||
graceful-fs "^4.2.0"
|
||||
jsonfile "^6.0.1"
|
||||
universalify "^2.0.0"
|
||||
|
||||
fs-extra@10.1.0, fs-extra@^10.0.0, fs-extra@^10.0.1:
|
||||
version "10.1.0"
|
||||
resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf"
|
||||
@@ -14209,6 +14338,26 @@ inline-style-prefixer@^6.0.0:
|
||||
dependencies:
|
||||
css-in-js-utils "^2.0.0"
|
||||
|
||||
inquirer@8.2.2:
|
||||
version "8.2.2"
|
||||
resolved "https://registry.npmjs.org/inquirer/-/inquirer-8.2.2.tgz#1310517a87a0814d25336c78a20b44c3d9b7629d"
|
||||
integrity sha512-pG7I/si6K/0X7p1qU+rfWnpTE1UIkTONN1wxtzh0d+dHXtT/JG6qBgLxoyHVsQa8cFABxAPh0pD6uUUHiAoaow==
|
||||
dependencies:
|
||||
ansi-escapes "^4.2.1"
|
||||
chalk "^4.1.1"
|
||||
cli-cursor "^3.1.0"
|
||||
cli-width "^3.0.0"
|
||||
external-editor "^3.0.3"
|
||||
figures "^3.0.0"
|
||||
lodash "^4.17.21"
|
||||
mute-stream "0.0.8"
|
||||
ora "^5.4.1"
|
||||
run-async "^2.4.0"
|
||||
rxjs "^7.5.5"
|
||||
string-width "^4.1.0"
|
||||
strip-ansi "^6.0.0"
|
||||
through "^2.3.6"
|
||||
|
||||
inquirer@^7.3.3:
|
||||
version "7.3.3"
|
||||
resolved "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz#04d176b2af04afc157a83fd7c100e98ee0aad003"
|
||||
@@ -15057,6 +15206,11 @@ istanbul-reports@^3.1.3:
|
||||
html-escaper "^2.0.0"
|
||||
istanbul-lib-report "^3.0.0"
|
||||
|
||||
iterare@1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.npmjs.org/iterare/-/iterare-1.2.1.tgz#139c400ff7363690e33abffa33cbba8920f00042"
|
||||
integrity sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==
|
||||
|
||||
jake@^10.8.5:
|
||||
version "10.8.5"
|
||||
resolved "https://registry.npmjs.org/jake/-/jake-10.8.5.tgz#f2183d2c59382cb274226034543b9c03b8164c46"
|
||||
@@ -16766,7 +16920,7 @@ lodash.uniq@^4.5.0:
|
||||
resolved "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
|
||||
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
|
||||
|
||||
lodash@^4.17.10, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.7.0, lodash@~4.17.0, lodash@~4.17.15, lodash@~4.17.4:
|
||||
lodash@4.17.21, lodash@^4.17.10, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.7.0, lodash@~4.17.0, lodash@~4.17.15, lodash@~4.17.4:
|
||||
version "4.17.21"
|
||||
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||
@@ -18671,16 +18825,16 @@ object-copy@^0.1.0:
|
||||
define-property "^0.2.5"
|
||||
kind-of "^3.0.3"
|
||||
|
||||
object-hash@3.0.0, object-hash@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz#73f97f753e7baffc0e2cc9d6e079079744ac82e9"
|
||||
integrity sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==
|
||||
|
||||
object-hash@^2.0.1:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.npmjs.org/object-hash/-/object-hash-2.2.0.tgz#5ad518581eefc443bd763472b8ff2e9c2c0d54a5"
|
||||
integrity sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw==
|
||||
|
||||
object-hash@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz#73f97f753e7baffc0e2cc9d6e079079744ac82e9"
|
||||
integrity sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==
|
||||
|
||||
object-inspect@^1.11.0, object-inspect@^1.12.0, object-inspect@^1.9.0:
|
||||
version "1.12.0"
|
||||
resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz#6e2c120e868fd1fd18cb4f18c31741d0d6e776f0"
|
||||
@@ -19513,6 +19667,11 @@ path-browserify@0.0.1:
|
||||
resolved "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a"
|
||||
integrity sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==
|
||||
|
||||
path-browserify@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd"
|
||||
integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==
|
||||
|
||||
path-case@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.npmjs.org/path-case/-/path-case-3.0.4.tgz#9168645334eb942658375c56f80b4c0cb5f82c6f"
|
||||
@@ -19585,6 +19744,11 @@ path-to-regexp@2.2.1:
|
||||
resolved "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.2.1.tgz#90b617025a16381a879bc82a38d4e8bdeb2bcf45"
|
||||
integrity sha512-gu9bD6Ta5bwGrrU8muHzVOBFFREpp2iRkVfhBJahwJ6p6Xw20SjT0MxLnwkjOibQmGSYhiUnf2FLe7k+jcFmGQ==
|
||||
|
||||
path-to-regexp@3.2.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.2.0.tgz#fa7877ecbc495c601907562222453c43cc204a5f"
|
||||
integrity sha512-jczvQbCUS7XmS7o+y1aEO9OBVFeZBQ1MDSEqmO7xSoPgOPoowY/SxLpZ6Vh97/8qHZOteiCKb7gkG9gA2ZUxJA==
|
||||
|
||||
path-to-regexp@^1.7.0:
|
||||
version "1.8.0"
|
||||
resolved "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a"
|
||||
@@ -21401,7 +21565,7 @@ redux@^4.0.0, redux@^4.0.4, redux@^4.1.2:
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.9.2"
|
||||
|
||||
reflect-metadata@^0.1.13:
|
||||
reflect-metadata@0.1.13, reflect-metadata@^0.1.13:
|
||||
version "0.1.13"
|
||||
resolved "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08"
|
||||
integrity sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==
|
||||
@@ -21995,6 +22159,13 @@ run-script-webpack-plugin@^0.0.14:
|
||||
resolved "https://registry.npmjs.org/run-script-webpack-plugin/-/run-script-webpack-plugin-0.0.14.tgz#fe2362b32c1dab7a8af7a6f1246fc043690cedd7"
|
||||
integrity sha512-DXe6lzzEVXjBr/74zd4m4yOfmz5P6GMjzhQxDDsViOmwG7cap8UCE6RgD5rT7zf4wM83a+ToHnpB3v4efUv5IA==
|
||||
|
||||
rxjs@7.5.5, rxjs@^7.1.0, rxjs@^7.2.0, rxjs@^7.5.1, rxjs@^7.5.5:
|
||||
version "7.5.5"
|
||||
resolved "https://registry.npmjs.org/rxjs/-/rxjs-7.5.5.tgz#2ebad89af0f560f460ad5cc4213219e1f7dd4e9f"
|
||||
integrity sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==
|
||||
dependencies:
|
||||
tslib "^2.1.0"
|
||||
|
||||
rxjs@^6.3.3, rxjs@^6.4.0, rxjs@^6.6.0, rxjs@^6.6.3:
|
||||
version "6.6.7"
|
||||
resolved "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz#90ac018acabf491bf65044235d5863c4dab804c9"
|
||||
@@ -22002,13 +22173,6 @@ rxjs@^6.3.3, rxjs@^6.4.0, rxjs@^6.6.0, rxjs@^6.6.3:
|
||||
dependencies:
|
||||
tslib "^1.9.0"
|
||||
|
||||
rxjs@^7.1.0, rxjs@^7.2.0, rxjs@^7.5.1, rxjs@^7.5.5:
|
||||
version "7.5.5"
|
||||
resolved "https://registry.npmjs.org/rxjs/-/rxjs-7.5.5.tgz#2ebad89af0f560f460ad5cc4213219e1f7dd4e9f"
|
||||
integrity sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==
|
||||
dependencies:
|
||||
tslib "^2.1.0"
|
||||
|
||||
sade@^1.7.3:
|
||||
version "1.8.1"
|
||||
resolved "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz#0a78e81d658d394887be57d2a409bf703a3b2701"
|
||||
@@ -24052,6 +24216,14 @@ ts-log@^2.2.3:
|
||||
resolved "https://registry.npmjs.org/ts-log/-/ts-log-2.2.3.tgz#4da5640fe25a9fb52642cd32391c886721318efb"
|
||||
integrity sha512-XvB+OdKSJ708Dmf9ore4Uf/q62AYDTzFcAdxc8KNML1mmAWywRFVt/dn1KYJH8Agt5UJNujfM3znU5PxgAzA2w==
|
||||
|
||||
ts-morph@^15.0.0:
|
||||
version "15.0.0"
|
||||
resolved "https://registry.npmjs.org/ts-morph/-/ts-morph-15.0.0.tgz#927a85d22909b95fa81e399c94fea655d98be514"
|
||||
integrity sha512-OZkg0TI1h6FVe8DZXyBo6p7NfCN9EZZkkA736f243KzQ3cypYWtaLc9eyNn/JH/fWYfQ4d6wIA4oM0vElRTGcQ==
|
||||
dependencies:
|
||||
"@ts-morph/common" "~0.15.0"
|
||||
code-block-writer "^11.0.0"
|
||||
|
||||
ts-node@^10.0.0, ts-node@^10.2.1, ts-node@^10.4.0:
|
||||
version "10.7.0"
|
||||
resolved "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz#35d503d0fab3e2baa672a0e94f4b40653c2463f5"
|
||||
@@ -24093,16 +24265,21 @@ tsconfig-paths@^3.14.1:
|
||||
minimist "^1.2.6"
|
||||
strip-bom "^3.0.0"
|
||||
|
||||
tslib@2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.npmjs.org/tslib/-/tslib-2.0.3.tgz#8e0741ac45fc0c226e58a17bfc3e64b9bc6ca61c"
|
||||
integrity sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ==
|
||||
|
||||
tslib@2.3.1, tslib@^2, tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.2.0, tslib@^2.3.0, tslib@^2.3.1, tslib@~2.3.0:
|
||||
version "2.3.1"
|
||||
resolved "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
|
||||
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==
|
||||
|
||||
tslib@^1.13.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
|
||||
version "1.14.1"
|
||||
resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
|
||||
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
|
||||
|
||||
tslib@^2, tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.2.0, tslib@^2.3.0, tslib@^2.3.1, tslib@~2.3.0:
|
||||
version "2.3.1"
|
||||
resolved "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
|
||||
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==
|
||||
|
||||
tslib@^2.1.0, tslib@~2.4.0:
|
||||
version "2.4.0"
|
||||
resolved "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"
|
||||
@@ -24730,16 +24907,16 @@ uuid@3.3.2:
|
||||
resolved "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
|
||||
integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==
|
||||
|
||||
uuid@8.3.2, uuid@^8.0.0, uuid@^8.2.0, uuid@^8.3.0, uuid@^8.3.2:
|
||||
version "8.3.2"
|
||||
resolved "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
|
||||
|
||||
uuid@^3.3.2, uuid@^3.4.0:
|
||||
version "3.4.0"
|
||||
resolved "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
|
||||
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
|
||||
|
||||
uuid@^8.0.0, uuid@^8.2.0, uuid@^8.3.0, uuid@^8.3.2:
|
||||
version "8.3.2"
|
||||
resolved "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
|
||||
|
||||
uvu@^0.5.0:
|
||||
version "0.5.3"
|
||||
resolved "https://registry.npmjs.org/uvu/-/uvu-0.5.3.tgz#3d83c5bc1230f153451877bfc7f4aea2392219ae"
|
||||
@@ -24971,7 +25148,7 @@ wbuf@^1.1.0, wbuf@^1.7.3:
|
||||
dependencies:
|
||||
minimalistic-assert "^1.0.0"
|
||||
|
||||
wcwidth@^1.0.0, wcwidth@^1.0.1:
|
||||
wcwidth@>=1.0.1, wcwidth@^1.0.0, wcwidth@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"
|
||||
integrity sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=
|
||||
|
||||
Reference in New Issue
Block a user