Remove circular dependencies
In reference to issue #5563 this does the initial work to remove all the circular dependencies that we have encountered while building backstage using bazel. The next step will be to implement a method to catch these circular dependencies before they get merged in Signed-off-by: jrusso1020 <jrusso@brex.com>
This commit is contained in:
@@ -32,7 +32,7 @@ import { Writable } from 'stream';
|
||||
// @public (undocumented)
|
||||
export class AzureUrlReader implements UrlReader {
|
||||
constructor(integration: AzureIntegration, deps: {
|
||||
treeResponseFactory: ReadTreeResponseFactory;
|
||||
treeResponseFactory: IReadTreeResponseFactory;
|
||||
});
|
||||
// (undocumented)
|
||||
static factory: ReaderFactory;
|
||||
@@ -49,7 +49,7 @@ export class AzureUrlReader implements UrlReader {
|
||||
// @public
|
||||
export class BitbucketUrlReader implements UrlReader {
|
||||
constructor(integration: BitbucketIntegration, deps: {
|
||||
treeResponseFactory: ReadTreeResponseFactory;
|
||||
treeResponseFactory: IReadTreeResponseFactory;
|
||||
});
|
||||
// (undocumented)
|
||||
static factory: ReaderFactory;
|
||||
@@ -214,7 +214,7 @@ export class Git {
|
||||
// @public
|
||||
export class GithubUrlReader implements UrlReader {
|
||||
constructor(integration: GitHubIntegration, deps: {
|
||||
treeResponseFactory: ReadTreeResponseFactory;
|
||||
treeResponseFactory: IReadTreeResponseFactory;
|
||||
credentialsProvider: GithubCredentialsProvider;
|
||||
});
|
||||
// (undocumented)
|
||||
@@ -232,7 +232,7 @@ export class GithubUrlReader implements UrlReader {
|
||||
// @public (undocumented)
|
||||
export class GitlabUrlReader implements UrlReader {
|
||||
constructor(integration: GitLabIntegration, deps: {
|
||||
treeResponseFactory: ReadTreeResponseFactory;
|
||||
treeResponseFactory: IReadTreeResponseFactory;
|
||||
});
|
||||
// (undocumented)
|
||||
static factory: ReaderFactory;
|
||||
|
||||
@@ -27,9 +27,9 @@ import parseGitUrl from 'git-url-parse';
|
||||
import { Minimatch } from 'minimatch';
|
||||
import { Readable } from 'stream';
|
||||
import { NotFoundError, NotModifiedError } from '@backstage/errors';
|
||||
import { ReadTreeResponseFactory } from './tree';
|
||||
import { stripFirstDirectoryFromPath } from './tree/util';
|
||||
import {
|
||||
IReadTreeResponseFactory,
|
||||
ReaderFactory,
|
||||
ReadTreeOptions,
|
||||
ReadTreeResponse,
|
||||
@@ -50,7 +50,7 @@ export class AzureUrlReader implements UrlReader {
|
||||
|
||||
constructor(
|
||||
private readonly integration: AzureIntegration,
|
||||
private readonly deps: { treeResponseFactory: ReadTreeResponseFactory },
|
||||
private readonly deps: { treeResponseFactory: IReadTreeResponseFactory },
|
||||
) {}
|
||||
|
||||
async read(url: string): Promise<Buffer> {
|
||||
|
||||
@@ -27,9 +27,9 @@ import parseGitUrl from 'git-url-parse';
|
||||
import { Minimatch } from 'minimatch';
|
||||
import { Readable } from 'stream';
|
||||
import { NotFoundError, NotModifiedError } from '@backstage/errors';
|
||||
import { ReadTreeResponseFactory } from './tree';
|
||||
import { stripFirstDirectoryFromPath } from './tree/util';
|
||||
import {
|
||||
IReadTreeResponseFactory,
|
||||
ReaderFactory,
|
||||
ReadTreeOptions,
|
||||
ReadTreeResponse,
|
||||
@@ -56,7 +56,7 @@ export class BitbucketUrlReader implements UrlReader {
|
||||
|
||||
constructor(
|
||||
private readonly integration: BitbucketIntegration,
|
||||
private readonly deps: { treeResponseFactory: ReadTreeResponseFactory },
|
||||
private readonly deps: { treeResponseFactory: IReadTreeResponseFactory },
|
||||
) {
|
||||
const {
|
||||
host,
|
||||
|
||||
@@ -26,8 +26,8 @@ import parseGitUrl from 'git-url-parse';
|
||||
import { Minimatch } from 'minimatch';
|
||||
import { Readable } from 'stream';
|
||||
import { NotFoundError, NotModifiedError } from '@backstage/errors';
|
||||
import { ReadTreeResponseFactory } from './tree';
|
||||
import {
|
||||
IReadTreeResponseFactory,
|
||||
ReaderFactory,
|
||||
ReadTreeOptions,
|
||||
ReadTreeResponse,
|
||||
@@ -65,7 +65,7 @@ export class GithubUrlReader implements UrlReader {
|
||||
constructor(
|
||||
private readonly integration: GitHubIntegration,
|
||||
private readonly deps: {
|
||||
treeResponseFactory: ReadTreeResponseFactory;
|
||||
treeResponseFactory: IReadTreeResponseFactory;
|
||||
credentialsProvider: GithubCredentialsProvider;
|
||||
},
|
||||
) {
|
||||
|
||||
@@ -25,9 +25,9 @@ import parseGitUrl from 'git-url-parse';
|
||||
import { Minimatch } from 'minimatch';
|
||||
import { Readable } from 'stream';
|
||||
import { NotFoundError, NotModifiedError } from '@backstage/errors';
|
||||
import { ReadTreeResponseFactory } from './tree';
|
||||
import { stripFirstDirectoryFromPath } from './tree/util';
|
||||
import {
|
||||
IReadTreeResponseFactory,
|
||||
ReaderFactory,
|
||||
ReadTreeOptions,
|
||||
ReadTreeResponse,
|
||||
@@ -50,7 +50,7 @@ export class GitlabUrlReader implements UrlReader {
|
||||
|
||||
constructor(
|
||||
private readonly integration: GitLabIntegration,
|
||||
private readonly deps: { treeResponseFactory: ReadTreeResponseFactory },
|
||||
private readonly deps: { treeResponseFactory: IReadTreeResponseFactory },
|
||||
) {}
|
||||
|
||||
async read(url: string): Promise<Buffer> {
|
||||
|
||||
@@ -15,25 +15,16 @@
|
||||
*/
|
||||
|
||||
import os from 'os';
|
||||
import { Readable } from 'stream';
|
||||
import { Config } from '@backstage/config';
|
||||
import { ReadTreeResponse } from '../types';
|
||||
import {
|
||||
ReadTreeResponse,
|
||||
FromArchiveOptions,
|
||||
IReadTreeResponseFactory,
|
||||
} from '../types';
|
||||
import { TarArchiveResponse } from './TarArchiveResponse';
|
||||
import { ZipArchiveResponse } from './ZipArchiveResponse';
|
||||
|
||||
type FromArchiveOptions = {
|
||||
// A binary stream of a tar archive.
|
||||
stream: Readable;
|
||||
// If unset, the files at the root of the tree will be read.
|
||||
// subpath must not contain the name of the top level directory.
|
||||
subpath?: string;
|
||||
// etag of the blob
|
||||
etag: string;
|
||||
// Filter passed on from the ReadTreeOptions
|
||||
filter?: (path: string) => boolean;
|
||||
};
|
||||
|
||||
export class ReadTreeResponseFactory {
|
||||
export class ReadTreeResponseFactory implements IReadTreeResponseFactory {
|
||||
static create(options: { config: Config }): ReadTreeResponseFactory {
|
||||
return new ReadTreeResponseFactory(
|
||||
options.config.getOptionalString('backend.workingDirectory') ??
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Readable } from 'stream';
|
||||
import { Logger } from 'winston';
|
||||
import { Config } from '@backstage/config';
|
||||
import { ReadTreeResponseFactory } from './tree';
|
||||
|
||||
/**
|
||||
* A generic interface for fetching plain data from URLs.
|
||||
@@ -39,7 +39,7 @@ export type UrlReaderPredicateTuple = {
|
||||
export type ReaderFactory = (options: {
|
||||
config: Config;
|
||||
logger: Logger;
|
||||
treeResponseFactory: ReadTreeResponseFactory;
|
||||
treeResponseFactory: IReadTreeResponseFactory;
|
||||
}) => UrlReaderPredicateTuple[];
|
||||
|
||||
/**
|
||||
@@ -105,6 +105,23 @@ export type ReadTreeResponseFile = {
|
||||
content(): Promise<Buffer>;
|
||||
};
|
||||
|
||||
export type FromArchiveOptions = {
|
||||
// A binary stream of a tar archive.
|
||||
stream: Readable;
|
||||
// If unset, the files at the root of the tree will be read.
|
||||
// subpath must not contain the name of the top level directory.
|
||||
subpath?: string;
|
||||
// etag of the blob
|
||||
etag: string;
|
||||
// Filter passed on from the ReadTreeOptions
|
||||
filter?: (path: string) => boolean;
|
||||
};
|
||||
|
||||
export interface IReadTreeResponseFactory {
|
||||
fromTarArchive(options: FromArchiveOptions): Promise<ReadTreeResponse>;
|
||||
fromZipArchive(options: FromArchiveOptions): Promise<ReadTreeResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* An options object for search operations.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user