Skip to content

Commit

Permalink
feat: Many new CLI commands and sub commands, major refactor too
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Jan 31, 2018
1 parent d39b8a4 commit 2259a0f
Show file tree
Hide file tree
Showing 21 changed files with 538 additions and 214 deletions.
12 changes: 0 additions & 12 deletions bin/fly

This file was deleted.

1 change: 1 addition & 0 deletions bin/fly
30 changes: 0 additions & 30 deletions bin/fly-deploy

This file was deleted.

30 changes: 0 additions & 30 deletions bin/fly-fetch

This file was deleted.

11 changes: 0 additions & 11 deletions bin/fly-server

This file was deleted.

23 changes: 0 additions & 23 deletions bin/fly-test

This file was deleted.

116 changes: 116 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
"start": "./bin/fly server ./apps/getting-started",
"test": "mocha",
"coverage": "nyc npm test",
"build:live": "npm run build -- -w",
"build": "tsc",
"build:live": "npm run build -- -w",
"build:cli": "tsc bin/fly.ts",
"build:cli:live": "npm run build:cli -- -w",
"prepublish": "npm run build",
"release": "standard-version"
},
Expand All @@ -20,6 +22,8 @@
"license": "Apache 2.0",
"devDependencies": {
"@types/chai": "^4.0.8",
"@types/fs-extra": "^5.0.0",
"@types/glob": "^5.0.35",
"@types/ioredis": "^3.2.5",
"@types/js-yaml": "^3.10.1",
"@types/mocha": "^2.2.44",
Expand All @@ -44,12 +48,15 @@
"axios": "^0.17.1",
"buffer": "^5.0.8",
"bugsnag": "^2.0.1",
"cli-table2": "^0.2.0",
"commander": "^2.13.0",
"commandpost": "^1.3.0",
"cookie": "^0.3.1",
"css-select": "^1.3.0-rc0",
"domutils": "^1.6.2",
"eventemitter2": "^5.0.1",
"findhit-proxywrap": "^0.3.12",
"fs-extra": "^5.0.0",
"get-stream": "^3.0.0",
"glob": "^7.1.2",
"htmlparser2": "^3.9.2",
Expand All @@ -64,6 +71,7 @@
"mocha": "^4.0.1",
"multiparty": "^4.1.3",
"promise.prototype.finally": "^3.1.0",
"promptly": "^3.0.3",
"readable-stream": "^2.3.3",
"string-to-stream": "^1.1.0",
"text-encoding": "^0.6.4",
Expand Down
35 changes: 35 additions & 0 deletions src/cmd/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import axios from 'axios'
import { AxiosInstance, AxiosPromise, AxiosRequestConfig } from 'axios';
import { getToken } from './root'

let apiClient: AxiosInstance;

export const API = {
get(url: string, config?: AxiosRequestConfig) {
return getAPIClient().get(url, config)
},
put(url: string, data?: any, config?: AxiosRequestConfig) {
return getAPIClient().put(url, data, config)
},
patch(url: string, data?: any, config?: AxiosRequestConfig) {
return getAPIClient().patch(url, data, config)
},
post(url: string, data?: any, config?: AxiosRequestConfig) {
return getAPIClient().post(url, data, config)
},
}

function getAPIClient() {
if (apiClient)
return apiClient

const baseURL = process.env.FLY_BASE_URL || "https://fly.io"

apiClient = axios.create({
baseURL: baseURL,
timeout: 5000,
headers: { "Authorization": `Bearer ${getToken()}` }
})

return apiClient
}
Loading

0 comments on commit 2259a0f

Please sign in to comment.