@microlink/cli 2.0.13 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +4 -4
  3. package/src/api.js +17 -8
package/README.md CHANGED
@@ -12,7 +12,7 @@ npm install @microlink/cli --global
12
12
 
13
13
  ## License
14
14
 
15
- **microlink** © [Microlink](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/cli/blob/master/LICENSE.md) License.<br>
15
+ **microlink** © [Microlink](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/cli/blob/master/LICENSE.md) License.<br>
16
16
  Authored and maintained by [Kiko Beats](https://kikobeats.com) with help from [contributors](https://github.com/microlinkhq/cli/contributors).
17
17
 
18
18
  > [microlink.io](https://microlink.io) · GitHub [microlinkhq](https://github.com/microlinkhq) · Twitter [@microlinkhq](https://twitter.com/microlinkhq)
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@microlink/cli",
3
3
  "description": "Interacting with Microlink API from your terminal.",
4
4
  "homepage": "https://nicedoc.io/microlinkhq/cli",
5
- "version": "2.0.13",
5
+ "version": "2.1.0",
6
6
  "main": "src/index.js",
7
7
  "bin": {
8
8
  "microlink": "bin/microlink"
@@ -31,14 +31,14 @@
31
31
  "microlink"
32
32
  ],
33
33
  "dependencies": {
34
- "@microlink/mql": "~0.10.10",
34
+ "@microlink/mql": "~0.10.26",
35
35
  "clipboardy": "~2.3.0",
36
36
  "escape-string-regexp": "~4.0.0",
37
- "got": "~11.8.3",
37
+ "got": "~11.8.5",
38
38
  "jsome": "~2.5.0",
39
39
  "meow": "~9.0.0",
40
40
  "ora": "~5.4.0",
41
- "picocolors": "~0.2.1",
41
+ "picocolors": "~1.0.0",
42
42
  "pretty-bytes": "~5.6.0",
43
43
  "pretty-ms": "~7.0.1",
44
44
  "temperment": "~1.0.0",
package/src/api.js CHANGED
@@ -90,9 +90,12 @@ const fetch = async (cli, gotOpts) => {
90
90
  const render = ({ body, response, flags }) => {
91
91
  const { headers, timings, requestUrl: uri } = response
92
92
  if (!flags.pretty) return console.log(body.toString())
93
- const time = prettyMs(timings.end - timings.start)
93
+
94
94
  const contentType = headers['content-type'].toLowerCase()
95
+ const time = prettyMs(timings.end - timings.start)
96
+ const serverTiming = headers['server-timing']
95
97
  const id = headers['x-request-id']
98
+
96
99
  const printMode = (() => {
97
100
  if (body.toString().startsWith('data:')) return 'base64'
98
101
  if (!contentType.includes('utf')) return 'image'
@@ -112,7 +115,8 @@ const render = ({ body, response, flags }) => {
112
115
  break
113
116
  default: {
114
117
  const isText = contentType.includes('text/plain')
115
- const output = isText ? body.toString() : JSON.parse(body)
118
+ const isHtml = contentType.includes('text/html')
119
+ const output = isText || isHtml ? body.toString() : JSON.parse(body)
116
120
  print.json(output, flags)
117
121
  break
118
122
  }
@@ -134,6 +138,7 @@ const render = ({ body, response, flags }) => {
134
138
  const fetchMode = headers['x-fetch-mode']
135
139
  const fetchTime = fetchMode && `(${headers['x-fetch-time']})`
136
140
  const size = Number(headers['content-length'] || Buffer.byteLength(body))
141
+
137
142
  console.log()
138
143
  console.log(
139
144
  print.label('success', 'green'),
@@ -141,28 +146,32 @@ const render = ({ body, response, flags }) => {
141
146
  )
142
147
  console.log()
143
148
 
149
+ if (serverTiming) {
150
+ console.log(' ', print.keyValue(colors.green('timing'), serverTiming))
151
+ }
152
+
144
153
  if (cacheStatus) {
145
154
  console.log(
146
- '',
155
+ ' ',
147
156
  print.keyValue(
148
157
  colors.green('cache'),
149
- `${cacheStatus || '-'} ${colors.gray(expiredAt)}`
158
+ `${cacheStatus} ${colors.gray(expiredAt)}`
150
159
  )
151
160
  )
152
161
  }
153
162
 
154
163
  if (fetchMode) {
155
164
  console.log(
156
- '',
165
+ ' ',
157
166
  print.keyValue(
158
- colors.green(' mode'),
167
+ colors.green('mode'),
159
168
  `${fetchMode} ${colors.gray(fetchTime)}`
160
169
  )
161
170
  )
162
171
  }
163
172
 
164
- console.log(cacheStatus ? ' ' : '', print.keyValue(colors.green('uri'), uri))
165
- console.log(cacheStatus ? ' ' : ' ', print.keyValue(colors.green('id'), id))
173
+ console.log(' ', print.keyValue(colors.green('uri'), uri))
174
+ console.log(' ', print.keyValue(colors.green('id'), id))
166
175
 
167
176
  if (flags.copy) {
168
177
  let copiedValue