Skip to content

Commit

Permalink
run prettier formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
  • Loading branch information
freben committed Aug 9, 2021
1 parent 467b758 commit 923491e
Show file tree
Hide file tree
Showing 311 changed files with 1,453 additions and 1,671 deletions.
4 changes: 1 addition & 3 deletions .imgbotconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"ignoredFiles": [
"docs/assets/**/*.svg"
]
"ignoredFiles": ["docs/assets/**/*.svg"]
}
4 changes: 1 addition & 3 deletions docs/auth/add-auth-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ export interface OAuthProviderHandlers {
req: express.Request,
options: Record<string, string>,
): Promise<RedirectInfo>;
handler(
req: express.Request,
): Promise<{
handler(req: express.Request): Promise<{
response: AuthResponse<OAuthProviderInfo>;
refreshToken?: string;
}>;
Expand Down
12 changes: 5 additions & 7 deletions docs/integrations/bitbucket/discovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@ matching repository is processed.
repository.

```typescript
const customRepositoryParser: BitbucketRepositoryParser = async function* customRepositoryParser({
client,
repository,
}) {
// Custom logic for interpret the matching repository.
// See defaultRepositoryParser for an example
};
const customRepositoryParser: BitbucketRepositoryParser =
async function* customRepositoryParser({ client, repository }) {
// Custom logic for interpret the matching repository.
// See defaultRepositoryParser for an example
};
const processor = BitbucketDiscoveryProcessor.fromConfig(env.config, {
parser: customRepositoryParser,
Expand Down
8 changes: 4 additions & 4 deletions packages/backend-common/src/cache/CacheManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('CacheManager', () => {
manager.forPlugin(plugin2Id).getClient({ defaultTtl: expectedTtl });

const client = DefaultCacheClient as jest.Mock;
const cache = (Keyv as unknown) as jest.Mock;
const cache = Keyv as unknown as jest.Mock;
expect(cache).toHaveBeenCalledTimes(2);
expect(client).toHaveBeenCalledTimes(2);

Expand All @@ -124,7 +124,7 @@ describe('CacheManager', () => {
const expectedNamespace = 'test-plugin';
manager.forPlugin(expectedNamespace).getClient();

const cache = (Keyv as unknown) as jest.Mock;
const cache = Keyv as unknown as jest.Mock;
const mockCalls = cache.mock.calls.splice(-1);
const callArgs = mockCalls[0];
expect(callArgs[0].store).toBeInstanceOf(NoStore);
Expand All @@ -138,7 +138,7 @@ describe('CacheManager', () => {
.forPlugin(expectedNamespace)
.getClient({ defaultTtl: expectedTtl });

const cache = (Keyv as unknown) as jest.Mock;
const cache = Keyv as unknown as jest.Mock;
const mockCalls = cache.mock.calls.splice(-1);
const callArgs = mockCalls[0];
expect(callArgs[0]).toMatchObject({
Expand All @@ -162,7 +162,7 @@ describe('CacheManager', () => {
const expectedTtl = 3600;
manager.forPlugin('test').getClient({ defaultTtl: expectedTtl });

const cache = (Keyv as unknown) as jest.Mock;
const cache = Keyv as unknown as jest.Mock;
const mockCacheCalls = cache.mock.calls.splice(-1);
expect(mockCacheCalls[0][0]).toMatchObject({
ttl: expectedTtl,
Expand Down
4 changes: 1 addition & 3 deletions packages/backend-common/src/database/DatabaseManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ export class DatabaseManager {
* @returns Object with client type returned as `client` and boolean representing whether
* or not the client was overridden as `overridden`
*/
private getClientType(
pluginId: string,
): {
private getClientType(pluginId: string): {
client: string;
overridden: boolean;
} {
Expand Down
2 changes: 1 addition & 1 deletion packages/backend-common/src/database/connectors/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export async function ensureMysqlDatabaseExists(
) {
const admin = createMysqlDatabaseClient(dbConfig, {
connection: {
database: (null as unknown) as string,
database: null as unknown as string,
},
});

Expand Down
12 changes: 4 additions & 8 deletions packages/backend-common/src/reading/AzureUrlReader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,17 @@ describe('AzureUrlReader', () => {

it.each([
{
url:
'https://dev.azure.com/org-name/project-name/_git/repo-name?path=my-template.yaml&version=GBmaster',
url: 'https://dev.azure.com/org-name/project-name/_git/repo-name?path=my-template.yaml&version=GBmaster',
config: createConfig(),
response: expect.objectContaining({
url:
'https://dev.azure.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml&version=master',
url: 'https://dev.azure.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml&version=master',
}),
},
{
url:
'https://dev.azure.com/org-name/project-name/_git/repo-name?path=my-template.yaml',
url: 'https://dev.azure.com/org-name/project-name/_git/repo-name?path=my-template.yaml',
config: createConfig(),
response: expect.objectContaining({
url:
'https://dev.azure.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml',
url: 'https://dev.azure.com/org-name/project-name/_apis/git/repositories/repo-name/items?path=my-template.yaml',
}),
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/backend-common/src/reading/AzureUrlReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class AzureUrlReader implements UrlReader {
}

return await this.deps.treeResponseFactory.fromZipArchive({
stream: (archiveAzureResponse.body as unknown) as Readable,
stream: archiveAzureResponse.body as unknown as Readable,
etag: commitSha,
filter: options?.filter,
});
Expand Down
11 changes: 3 additions & 8 deletions packages/backend-common/src/reading/BitbucketUrlReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,8 @@ export class BitbucketUrlReader implements UrlReader {
private readonly integration: BitbucketIntegration,
private readonly deps: { treeResponseFactory: ReadTreeResponseFactory },
) {
const {
host,
apiBaseUrl,
token,
username,
appPassword,
} = integration.config;
const { host, apiBaseUrl, token, username, appPassword } =
integration.config;

if (!apiBaseUrl) {
throw new Error(
Expand Down Expand Up @@ -138,7 +133,7 @@ export class BitbucketUrlReader implements UrlReader {
}

return await this.deps.treeResponseFactory.fromTarArchive({
stream: (archiveBitbucketResponse.body as unknown) as Readable,
stream: archiveBitbucketResponse.body as unknown as Readable,
subpath: filepath,
etag: lastCommitShortHash,
filter: options?.filter,
Expand Down
4 changes: 2 additions & 2 deletions packages/backend-common/src/reading/GithubUrlReader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const treeResponseFactory = DefaultReadTreeResponseFactory.create({
config: new ConfigReader({}),
});

const mockCredentialsProvider = ({
const mockCredentialsProvider = {
getCredentials: jest.fn().mockResolvedValue({ headers: {} }),
} as unknown) as GithubCredentialsProvider;
} as unknown as GithubCredentialsProvider;

const githubProcessor = new GithubUrlReader(
new GitHubIntegration(
Expand Down
18 changes: 10 additions & 8 deletions packages/backend-common/src/reading/GithubUrlReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ import {
ReadUrlResponse,
} from './types';

export type GhRepoResponse = RestEndpointMethodTypes['repos']['get']['response']['data'];
export type GhBranchResponse = RestEndpointMethodTypes['repos']['getBranch']['response']['data'];
export type GhTreeResponse = RestEndpointMethodTypes['git']['getTree']['response']['data'];
export type GhBlobResponse = RestEndpointMethodTypes['git']['getBlob']['response']['data'];
export type GhRepoResponse =
RestEndpointMethodTypes['repos']['get']['response']['data'];
export type GhBranchResponse =
RestEndpointMethodTypes['repos']['getBranch']['response']['data'];
export type GhTreeResponse =
RestEndpointMethodTypes['git']['getTree']['response']['data'];
export type GhBlobResponse =
RestEndpointMethodTypes['git']['getBlob']['response']['data'];

/**
* A processor that adds the ability to read files from GitHub v3 APIs, such as
Expand Down Expand Up @@ -195,7 +199,7 @@ export class GithubUrlReader implements UrlReader {
return await this.deps.treeResponseFactory.fromTarArchive({
// TODO(Rugvip): Underlying implementation of fetch will be node-fetch, we probably want
// to stick to using that in exclusively backend code.
stream: (archive.body as unknown) as Readable,
stream: archive.body as unknown as Readable,
subpath,
etag: sha,
filter: options?.filter,
Expand Down Expand Up @@ -258,9 +262,7 @@ export class GithubUrlReader implements UrlReader {
}));
}

private async getRepoDetails(
url: string,
): Promise<{
private async getRepoDetails(url: string): Promise<{
repo: GhRepoResponse;
branch: GhBranchResponse;
}> {
Expand Down
18 changes: 6 additions & 12 deletions packages/backend-common/src/reading/GitlabUrlReader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,36 +108,30 @@ describe('GitlabUrlReader', () => {
it.each([
// Project URLs
{
url:
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/my/path/to/file.yaml',
url: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/my/path/to/file.yaml',
config: createConfig(),
response: expect.objectContaining({
url:
'https://gitlab.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yaml/raw?ref=branch',
url: 'https://gitlab.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yaml/raw?ref=branch',
headers: expect.objectContaining({
'private-token': '',
}),
}),
},
{
url:
'https://gitlab.example.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/my/path/to/file.yaml',
url: 'https://gitlab.example.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/my/path/to/file.yaml',
config: createConfig('0123456789'),
response: expect.objectContaining({
url:
'https://gitlab.example.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yaml/raw?ref=branch',
url: 'https://gitlab.example.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yaml/raw?ref=branch',
headers: expect.objectContaining({
'private-token': '0123456789',
}),
}),
},
{
url:
'https://gitlab.com/groupA/teams/teamA/repoA/-/blob/branch/my/path/to/file.yaml', // Repo not in subgroup
url: 'https://gitlab.com/groupA/teams/teamA/repoA/-/blob/branch/my/path/to/file.yaml', // Repo not in subgroup
config: createConfig(),
response: expect.objectContaining({
url:
'https://gitlab.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yaml/raw?ref=branch',
url: 'https://gitlab.com/api/v4/projects/12345/repository/files/my%2Fpath%2Fto%2Ffile.yaml/raw?ref=branch',
}),
},

Expand Down
2 changes: 1 addition & 1 deletion packages/backend-common/src/reading/GitlabUrlReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class GitlabUrlReader implements UrlReader {
}

return await this.deps.treeResponseFactory.fromTarArchive({
stream: (archiveGitLabResponse.body as unknown) as Readable,
stream: archiveGitLabResponse.body as unknown as Readable,
subpath: filepath,
etag: commitSha,
filter: options?.filter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
import { stripFirstDirectoryFromPath } from './util';

// Tar types for `Parse` is not a proper constructor, but it should be
const TarParseStream = (Parse as unknown) as { new (): ParseStream };
const TarParseStream = Parse as unknown as { new (): ParseStream };

const pipeline = promisify(pipelineCb);

Expand Down
18 changes: 9 additions & 9 deletions packages/backend-common/src/scm/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ describe('Git', () => {

await git.clone({ url, dir });

const { onAuth } = ((isomorphic.clone as unknown) as jest.Mock<
typeof isomorphic['clone']
>).mock.calls[0][0]!;
const { onAuth } = (
isomorphic.clone as unknown as jest.Mock<typeof isomorphic['clone']>
).mock.calls[0][0]!;

expect(onAuth()).toEqual(auth);
});
Expand Down Expand Up @@ -190,9 +190,9 @@ describe('Git', () => {

await git.fetch({ remote, dir });

const { onAuth } = ((isomorphic.fetch as unknown) as jest.Mock<
typeof isomorphic['fetch']
>).mock.calls[0][0]!;
const { onAuth } = (
isomorphic.fetch as unknown as jest.Mock<typeof isomorphic['fetch']>
).mock.calls[0][0]!;

expect(onAuth()).toEqual(auth);
});
Expand Down Expand Up @@ -279,9 +279,9 @@ describe('Git', () => {

await git.push({ remote, dir });

const { onAuth } = ((isomorphic.push as unknown) as jest.Mock<
typeof isomorphic['push']
>).mock.calls[0][0]!;
const { onAuth } = (
isomorphic.push as unknown as jest.Mock<typeof isomorphic['push']>
).mock.calls[0][0]!;

expect(onAuth()).toEqual(auth);
});
Expand Down
10 changes: 2 additions & 8 deletions packages/backend-common/src/service/lib/ServiceBuilderImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,8 @@ export class ServiceBuilderImpl implements ServiceBuilder {

async start(): Promise<http.Server> {
const app = express();
const {
port,
host,
logger,
corsOptions,
httpsSettings,
helmetOptions,
} = this.getOptions();
const { port, host, logger, corsOptions, httpsSettings, helmetOptions } =
this.getOptions();

app.use(helmet(helmetOptions));
if (corsOptions) {
Expand Down
23 changes: 11 additions & 12 deletions packages/backend-common/src/util/DockerContainerRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,17 @@ export class DockerContainerRunner implements ContainerRunner {
Env.push(`${key}=${value}`);
}

const [
{ Error: error, StatusCode: statusCode },
] = await this.dockerClient.run(imageName, args, logStream, {
Volumes,
HostConfig: {
Binds,
},
...(workingDir ? { WorkingDir: workingDir } : {}),
Entrypoint: command,
Env,
...userOptions,
} as Docker.ContainerCreateOptions);
const [{ Error: error, StatusCode: statusCode }] =
await this.dockerClient.run(imageName, args, logStream, {
Volumes,
HostConfig: {
Binds,
},
...(workingDir ? { WorkingDir: workingDir } : {}),
Entrypoint: command,
Env,
...userOptions,
} as Docker.ContainerCreateOptions);

if (error) {
throw new Error(
Expand Down
Loading

0 comments on commit 923491e

Please sign in to comment.