Skip to content

Commit 89cca35

Browse files
committed
lint , type , fix errors
1 parent 2894827 commit 89cca35

File tree

31 files changed

+270
-69
lines changed

31 files changed

+270
-69
lines changed

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"extends": ["oclif", "oclif-typescript", "prettier"],
3+
"ignorePatterns": ["tmp/**"],
34
"rules": {
45
"unicorn/better-regex": "off",
56
"max-params": "off",

src/commands/apikeys/list.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ import {Command, Flags} from '@oclif/core'
33
import {getDisco} from '../../config.js'
44
import {request} from '../../auth-request.js'
55

6+
export interface ApiKeyItem {
7+
name: string
8+
publicKey: string
9+
privateKey: string
10+
lastUsed: null | string
11+
}
12+
13+
export interface ApiKeysResponse {
14+
apiKeys: ApiKeyItem[]
15+
}
16+
617
export default class ApikeysList extends Command {
718
static override description = 'list all api keys'
819

@@ -18,7 +29,7 @@ export default class ApikeysList extends Command {
1829

1930
const url = `https://${discoConfig.host}/api/api-keys`
2031
const res = await request({method: 'GET', url, discoConfig})
21-
const data = (await res.json()) as any
32+
const data = (await res.json()) as ApiKeysResponse
2233
this.log('Public Private Name')
2334
for (const key of data.apiKeys) {
2435
const lastUsed = key.lastUsed === null ? 'never' : key.lastUsed

src/commands/deploy.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ interface DeployRequest {
99
discoFile?: string
1010
}
1111

12+
export interface DeployResponse {
13+
deployment: {
14+
number: number
15+
}
16+
}
17+
1218
export default class Deploy extends Command {
1319
static override description = 'deploy a project, a specific commit or a disco.json file'
1420

@@ -41,7 +47,7 @@ export default class Deploy extends Command {
4147
}
4248

4349
const res = await request({method: 'POST', url, body: reqBody, discoConfig, expectedStatuses: [201]})
44-
const data = (await res.json()) as any
50+
const data = (await res.json()) as DeployResponse
4551

4652
const deploymentUrl = `https://${discoConfig.host}/api/projects/${flags.project}/deployments/${data.deployment.number}/output`
4753
readEventSource(deploymentUrl, discoConfig, {

src/commands/deploy/list.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ import {Command, Flags} from '@oclif/core'
33
import {getDisco} from '../../config.js'
44
import {request} from '../../auth-request.js'
55

6+
export interface DeploymentItem {
7+
number: number
8+
created: string
9+
status: string
10+
commitHash: null | string
11+
}
12+
13+
export interface DeploymentsResponse {
14+
deployments: DeploymentItem[]
15+
}
16+
617
export default class DeployList extends Command {
718
static override description = 'list the deployments for a project'
819

@@ -19,9 +30,9 @@ export default class DeployList extends Command {
1930
const discoConfig = getDisco(flags.disco || null)
2031
const url = `https://${discoConfig.host}/api/projects/${flags.project}/deployments`
2132
const res = await request({method: 'GET', url, discoConfig})
22-
const data = (await res.json()) as any
33+
const data = (await res.json()) as DeploymentsResponse
2334
for (const deployment of data.deployments) {
24-
console.log(`${deployment.created}\t${deployment.number}\t${deployment.status}`)
35+
this.log(`${deployment.created}\t${deployment.number}\t${deployment.status}`)
2536
}
2637
}
2738
}

src/commands/domains/list.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import {Command, Flags} from '@oclif/core'
33
import {getDisco} from '../../config.js'
44
import {request} from '../../auth-request.js'
55

6+
export interface DomainItem {
7+
id: string
8+
name: string
9+
}
10+
11+
export interface DomainsResponse {
12+
domains: DomainItem[]
13+
}
14+
615
export default class DomainsList extends Command {
716
static override description = 'list the domains'
817

@@ -18,7 +27,7 @@ export default class DomainsList extends Command {
1827
const discoConfig = getDisco(flags.disco || null)
1928
const url = `https://${discoConfig.host}/api/projects/${flags.project}/domains`
2029
const res = await request({method: 'GET', url, discoConfig, expectedStatuses: [200]})
21-
const data = (await res.json()) as any
30+
const data = (await res.json()) as DomainsResponse
2231
for (const domain of data.domains) {
2332
this.log(domain.name)
2433
}

src/commands/env/get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class EnvGet extends Command {
3636
return
3737
}
3838

39-
const data: EnvVarResponse = (await res.json()) as any
39+
const data = (await res.json()) as EnvVarResponse
4040
this.log(data.envVariable.value)
4141
}
4242
}

src/commands/env/list.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import {Command, Flags} from '@oclif/core'
33
import {getDisco} from '../../config.js'
44
import {request} from '../../auth-request.js'
55

6+
export interface EnvVariableItem {
7+
name: string
8+
value: string
9+
}
10+
11+
export interface EnvVariablesResponse {
12+
envVariables: EnvVariableItem[]
13+
}
14+
615
export default class EnvList extends Command {
716
static override description = 'list the env vars'
817

@@ -24,7 +33,7 @@ export default class EnvList extends Command {
2433
return
2534
}
2635

27-
const data = (await res.json()) as any
36+
const data = (await res.json()) as EnvVariablesResponse
2837
for (const variable of data.envVariables) {
2938
this.log(`${variable.name}=${variable.value}`)
3039
}

src/commands/env/remove.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import {Args, Command, Flags} from '@oclif/core'
33
import {getDisco} from '../../config.js'
44
import {request, readEventSource} from '../../auth-request.js'
55

6+
export interface EnvRemoveResponse {
7+
deployment: {
8+
number: number
9+
} | null
10+
}
11+
612
export default class EnvRemove extends Command {
713
static override args = {
814
envVar: Args.string({description: 'variable to remove'}),
@@ -24,7 +30,7 @@ export default class EnvRemove extends Command {
2430
this.log(`Removing env variable for ${flags.project}: ${args.envVar}`)
2531
const url = `https://${discoConfig.host}/api/projects/${flags.project}/env/${args.envVar}`
2632
const res = await request({method: 'DELETE', url, discoConfig})
27-
const data = (await res.json()) as any
33+
const data = (await res.json()) as EnvRemoveResponse
2834
if (data.deployment) {
2935
// stream deployment
3036
const deploymentUrl = `https://${discoConfig.host}/api/projects/${flags.project}/deployments/${data.deployment.number}/output`

src/commands/env/set.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ interface EnvVarRequestBody {
77
envVariables: {name: string; value: string}[]
88
}
99

10+
export interface EnvSetResponse {
11+
deployment: {
12+
number: number
13+
} | null
14+
}
15+
1016
export default class EnvSet extends Command {
1117
static override args = {
1218
variables: Args.string({description: 'variables to set'}),
@@ -49,14 +55,16 @@ export default class EnvSet extends Command {
4955
}
5056

5157
const res = await request({method: 'POST', url, discoConfig, body})
52-
const data = (await res.json()) as any
53-
// stream deployment
54-
const deploymentUrl = `https://${discoConfig.host}/api/projects/${flags.project}/deployments/${data.deployment.number}/output`
55-
readEventSource(deploymentUrl, discoConfig, {
56-
onMessage(event: MessageEvent) {
57-
const output = JSON.parse(event.data)
58-
process.stdout.write(output.text)
59-
},
60-
})
58+
const data = (await res.json()) as EnvSetResponse
59+
if (data.deployment) {
60+
// stream deployment
61+
const deploymentUrl = `https://${discoConfig.host}/api/projects/${flags.project}/deployments/${data.deployment.number}/output`
62+
readEventSource(deploymentUrl, discoConfig, {
63+
onMessage(event: MessageEvent) {
64+
const output = JSON.parse(event.data)
65+
process.stdout.write(output.text)
66+
},
67+
})
68+
}
6169
}
6270
}

src/commands/github/apps/add.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import {Command, Flags} from '@oclif/core'
2-
import {getDisco} from '../../../config.js'
3-
import {request} from '../../../auth-request.js'
4-
import open from 'open'
52
import {input} from '@inquirer/prompts'
3+
import open from 'open'
4+
5+
import {request} from '../../../auth-request.js'
6+
import {getDisco} from '../../../config.js'
7+
8+
export interface GithubAppsCreateResponse {
9+
pendingApp: {
10+
id: string
11+
expires: string
12+
url: string
13+
}
14+
}
615

716
export default class GithubAppsAdd extends Command {
817
static description = 'add a Github app'
@@ -23,7 +32,7 @@ export default class GithubAppsAdd extends Command {
2332
}
2433
const url = `https://${discoConfig.host}/api/github-apps/create`
2534
const res = await request({method: 'POST', url, discoConfig, body, expectedStatuses: [201]})
26-
const respBody = (await res.json()) as any
35+
const respBody = (await res.json()) as GithubAppsCreateResponse
2736

2837
// thanks @robsimmons for this excellent suggestion!
2938
this.log('')

0 commit comments

Comments
 (0)