Skip to content

Commit fcab173

Browse files
committed
ran prettier and updated types
1 parent f4f7dad commit fcab173

35 files changed

+455
-537
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: Test
22
on:
33
push:
44
branches:
5-
- "master"
5+
- 'master'
66
pull_request: {}
77
jobs:
88
build:
99
name: Build, lint, and test
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
node: ["12", "14", "16"]
13+
node: ['12', '14', '16']
1414

1515
steps:
1616
- name: Checkout repo

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"bracketSpacing": true,
4+
"printWidth": 120
5+
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: node_js
22
node_js:
3-
- "8"
3+
- '8'
44
cache: yarn
55
script: yarn test

babel.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
module.exports = {
2-
presets: [
3-
["@babel/preset-env", { targets: { node: "current" } }],
4-
"@babel/preset-typescript",
5-
],
2+
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
63
};

cli.ts

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
11
#!/usr/bin/env node
2-
import meow from "meow";
3-
import main from "./index";
4-
import Text from "./lib/text";
5-
import {FlagTypes} from "./types";
6-
import {InvalidInputError} from "./lib/error";
7-
import {sanitizeInput} from './lib/utils/sanitize';
2+
import meow from 'meow';
3+
import main from './index';
4+
import Text from './lib/text';
5+
import { FlagTypes } from './types';
6+
import { InvalidInputError } from './lib/error';
7+
import { sanitizeInput } from './lib/utils/sanitize';
88

99
async function cli(argv: string[]) {
10-
const cli = meow({
11-
argv,
12-
help: Text.mainText.help,
13-
flags: {
14-
auth: {
15-
type: "string",
16-
},
17-
branch: {
18-
type: "string",
19-
},
20-
concurrency: {
21-
type: "number",
22-
default: 10,
23-
},
24-
json: {
25-
type: "boolean",
26-
},
27-
last: {
28-
type: "number",
29-
},
30-
period: {
31-
type: "number",
32-
},
33-
since: {
34-
type: "number",
35-
},
36-
},
37-
});
10+
const cli = meow({
11+
argv,
12+
help: Text.mainText.help,
13+
flags: {
14+
auth: {
15+
type: 'string',
16+
},
17+
branch: {
18+
type: 'string',
19+
},
20+
concurrency: {
21+
type: 'number',
22+
default: 10,
23+
},
24+
json: {
25+
type: 'boolean',
26+
},
27+
last: {
28+
type: 'number',
29+
},
30+
period: {
31+
type: 'number',
32+
},
33+
since: {
34+
type: 'number',
35+
},
36+
},
37+
});
3838

39-
try {
40-
if (cli.input.length < 1) {
41-
cli.showHelp();
42-
}
39+
try {
40+
if (cli.input.length < 1) {
41+
cli.showHelp();
42+
}
4343

44-
const [repoSlug, command] = await sanitizeInput(cli.input);
44+
const [repoSlug, command] = await sanitizeInput(cli.input);
4545

46-
await main({
47-
cwd: __dirname,
48-
repoSlug,
49-
command,
50-
flags: cli.flags as FlagTypes,
51-
});
52-
} catch (err) {
53-
if (err instanceof InvalidInputError) {
54-
console.error(err.getMessage());
55-
} else {
56-
throw err;
57-
}
58-
}
46+
await main({
47+
cwd: __dirname,
48+
repoSlug,
49+
command,
50+
flags: cli.flags as FlagTypes,
51+
});
52+
} catch (err) {
53+
if (err instanceof InvalidInputError) {
54+
console.error(err.getMessage());
55+
} else {
56+
throw err;
57+
}
58+
}
5959
}
6060

6161
cli(process.argv.slice(2)).catch((err) => {
62-
console.error(err);
63-
process.exit(1);
62+
console.error(err);
63+
process.exit(1);
6464
});

index.ts

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,28 @@
1-
import { default as cache } from "./lib/commands/cache";
2-
import { default as calculate } from "./lib/commands/calculate";
3-
import { default as clean } from "./lib/commands/clean";
4-
import { default as download } from "./lib/commands/download";
5-
import { default as history } from "./lib/commands/history";
6-
import { default as success } from "./lib/commands/success";
7-
import { flagsEnum, MainTypes } from "./types";
8-
import pick from "lodash.pick";
1+
import { default as cache } from './lib/commands/cache';
2+
import { default as calculate } from './lib/commands/calculate';
3+
import { default as clean } from './lib/commands/clean';
4+
import { default as download } from './lib/commands/download';
5+
import { default as history } from './lib/commands/history';
6+
import { default as success } from './lib/commands/success';
7+
import { flagsEnum, MainTypes } from './types';
8+
import pick from 'lodash.pick';
99

10-
export const SUPPORTED_COMMANDS = [
11-
'cache',
12-
'calculate',
13-
'clean',
14-
'download',
15-
'history',
16-
'success'
17-
];
10+
export const SUPPORTED_COMMANDS = ['cache', 'calculate', 'clean', 'download', 'history', 'success'];
1811

19-
export default async function main({
20-
command,
21-
repoSlug,
22-
flags,
23-
cwd,
24-
}: MainTypes) {
12+
export default async function main({ command, repoSlug, flags, cwd }: MainTypes) {
2513
let [host, user, repo]: string[] = repoSlug;
2614

2715
switch (command) {
28-
case "download":
16+
case 'download':
2917
await download({
3018
cwd,
3119
host,
3220
user,
3321
repo,
34-
...pick(flags, [
35-
flagsEnum.auth,
36-
flagsEnum.concurrency,
37-
flagsEnum.since,
38-
]),
22+
...pick(flags, [flagsEnum.auth, flagsEnum.concurrency, flagsEnum.since]),
3923
});
4024
break;
41-
case "calculate":
25+
case 'calculate':
4226
await calculate({
4327
cwd,
4428
host,
@@ -54,50 +38,37 @@ export default async function main({
5438
]),
5539
});
5640
break;
57-
case "history":
41+
case 'history':
5842
await history({
5943
cwd,
6044
host,
6145
user,
6246
repo,
63-
...pick(flags, [
64-
flagsEnum.branch,
65-
flagsEnum.result,
66-
flagsEnum.threshold,
67-
flagsEnum.json,
68-
]),
47+
...pick(flags, [flagsEnum.branch, flagsEnum.result, flagsEnum.threshold, flagsEnum.json]),
6948
});
7049
break;
71-
case "success":
50+
case 'success':
7251
await success({
7352
cwd,
7453
host,
7554
user,
7655
repo,
77-
...pick(flags, [
78-
flagsEnum.branch,
79-
flagsEnum.result,
80-
flagsEnum.period,
81-
flagsEnum.last,
82-
flagsEnum.json,
83-
]),
56+
...pick(flags, [flagsEnum.branch, flagsEnum.result, flagsEnum.period, flagsEnum.last, flagsEnum.json]),
8457
});
8558
break;
86-
case "clean":
59+
case 'clean':
8760
await clean({
8861
cwd,
8962
host,
9063
user,
9164
repo,
9265
});
9366
break;
94-
case "cache":
67+
case 'cache':
9568
await cache({ cwd, host, user, repo });
9669
break;
9770
default:
98-
throw new Error(
99-
`Unknown command "${command}", should be ${SUPPORTED_COMMANDS.join(", ")}.`
100-
);
71+
throw new Error(`Unknown command "${command}", should be ${SUPPORTED_COMMANDS.join(', ')}.`);
10172
}
10273
}
10374

lib/adapters/bamboo.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import chalk from "chalk";
2-
import pLimit from "p-limit";
3-
import got from "got";
4-
import ora from "ora";
5-
import path from "path";
6-
import * as fs from "../utils/fs";
7-
import { getLastDownloadedBuildNumber } from "../utils/builds";
1+
import chalk from 'chalk';
2+
import pLimit from 'p-limit';
3+
import got from 'got';
4+
import ora from 'ora';
5+
import path from 'path';
6+
import * as fs from '../utils/fs';
7+
import { getLastDownloadedBuildNumber } from '../utils/builds';
88

99
/**
1010
* URL for build -> curl --user <userName>:<password> https://<url-to-bamboo>/rest/api/latest/result/<ProjectKey-<BuildKey>-latest.json
@@ -16,13 +16,12 @@ function toStandardBuildConfig(build) {
1616
createdOn: build.buildStartedTime,
1717
duration: build.buildDurationInSeconds,
1818
result: build.buildState && build.buildState.toUpperCase(),
19-
refType: "not available",
20-
refName: "master",
19+
refType: 'not available',
20+
refName: 'master',
2121
};
2222
}
2323

24-
const bambooApiUrl = (bambooUrl, planKey) =>
25-
`https://${bambooUrl}/rest/api/latest/result/${planKey}`;
24+
const bambooApiUrl = (bambooUrl, planKey) => `https://${bambooUrl}/rest/api/latest/result/${planKey}`;
2625

2726
async function getTotalBuilds(bambooUrl, planKey, auth) {
2827
const bambooBuildUrl = bambooApiUrl(bambooUrl, planKey);
@@ -39,7 +38,7 @@ export default async function bambooBuilds(
3938
buildsDir,
4039
{ auth, concurrency, downloadHook, repo: planKey, since, user: bambooUrl }
4140
) {
42-
let spinner = ora().start("Initializing download");
41+
let spinner = ora().start('Initializing download');
4342
const limit = pLimit(concurrency);
4443
let lastDownloaded = since;
4544
if (lastDownloaded == undefined) {
@@ -48,7 +47,7 @@ export default async function bambooBuilds(
4847
let startingBuild = lastDownloaded ? lastDownloaded + 1 : 1;
4948
let totalBuilds = await getTotalBuilds(bambooUrl, planKey, auth);
5049
let downloaded = startingBuild - 1;
51-
spinner.text = "Starting download";
50+
spinner.text = 'Starting download';
5251

5352
let requestPromises = [];
5453
/**
@@ -79,9 +78,7 @@ export default async function bambooBuilds(
7978

8079
await Promise.all(requestPromises);
8180

82-
spinner.succeed(
83-
chalk`Download completed. Total Builds: {green ${totalBuilds}}`
84-
);
81+
spinner.succeed(chalk`Download completed. Total Builds: {green ${totalBuilds}}`);
8582
console.log(totalBuilds);
8683
spinner.stop();
8784
return;

0 commit comments

Comments
 (0)