@microlink/cli 2.1.48 → 2.1.51

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.
package/LICENSE.md CHANGED
File without changes
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://github.com/microlinkhq/cli",
5
- "version": "2.1.48",
5
+ "version": "2.1.51",
6
6
  "main": "src/index.js",
7
7
  "bin": {
8
8
  "microlink": "bin/microlink",
@@ -34,13 +34,12 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@kikobeats/content-type": "~1.0.1",
37
- "@microlink/mql": "~0.14.0",
37
+ "@microlink/mql": "~0.15.1",
38
38
  "clipboardy": "~2.3.0",
39
39
  "is-local-address": "~2.3.0",
40
40
  "jsome": "~2.5.0",
41
41
  "mri": "~1.2.0",
42
42
  "nanospinner": "~1.2.2",
43
- "picocolors": "~1.1.1",
44
43
  "pretty-bytes": "5",
45
44
  "pretty-ms": "~7.0.1",
46
45
  "restore-cursor": "~3.1.0",
@@ -72,6 +71,17 @@
72
71
  "bin",
73
72
  "src"
74
73
  ],
74
+ "scripts": {
75
+ "clean": "rm -rf node_modules",
76
+ "contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
77
+ "lint": "standard-markdown README.md && standard",
78
+ "postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
79
+ "pretest": "npm run lint",
80
+ "release": "standard-version -a",
81
+ "release:github": "github-generate-release",
82
+ "release:tags": "git push --follow-tags origin HEAD:master",
83
+ "test": "c8 ava"
84
+ },
75
85
  "preferGlobal": true,
76
86
  "license": "MIT",
77
87
  "commitlint": {
@@ -99,16 +109,5 @@
99
109
  "simple-git-hooks": {
100
110
  "commit-msg": "npx commitlint --edit",
101
111
  "pre-commit": "npx nano-staged"
102
- },
103
- "scripts": {
104
- "clean": "rm -rf node_modules",
105
- "contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
106
- "lint": "standard-markdown README.md && standard",
107
- "postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
108
- "pretest": "npm run lint",
109
- "release": "standard-version -a",
110
- "release:github": "github-generate-release",
111
- "release:tags": "git push --follow-tags origin HEAD:master",
112
- "test": "c8 ava"
113
112
  }
114
- }
113
+ }
package/src/api.js CHANGED
@@ -9,11 +9,11 @@ const { URLSearchParams } = require('url')
9
9
  const clipboardy = require('clipboardy')
10
10
  const mql = require('@microlink/mql')
11
11
  const prettyMs = require('pretty-ms')
12
- const colors = require('picocolors')
13
12
  const temp = require('temperment')
14
13
  const fs = require('fs')
15
14
  const os = require('os')
16
15
 
16
+ const { gray, green } = require('./colors')
17
17
  const print = require('./print')
18
18
  const exit = require('./exit')
19
19
 
@@ -113,36 +113,30 @@ const render = ({ response, flags }) => {
113
113
  console.error()
114
114
  console.error(
115
115
  print.label('success', 'green'),
116
- colors.gray(`${print.bytes(size)} in ${time}`)
116
+ gray(`${print.bytes(size)} in ${time}`)
117
117
  )
118
118
  console.error()
119
119
 
120
120
  if (serverTiming) {
121
- console.error(' ', print.keyValue(colors.green('timing'), serverTiming))
121
+ console.error(' ', print.keyValue(green('timing'), serverTiming))
122
122
  }
123
123
 
124
124
  if (cacheStatus) {
125
125
  console.error(
126
126
  ' ',
127
- print.keyValue(
128
- colors.green('cache'),
129
- `${cacheStatus} ${colors.gray(expiredAt)}`
130
- )
127
+ print.keyValue(green('cache'), `${cacheStatus} ${gray(expiredAt)}`)
131
128
  )
132
129
  }
133
130
 
134
131
  if (fetchMode) {
135
132
  console.error(
136
133
  ' ',
137
- print.keyValue(
138
- colors.green('mode'),
139
- `${fetchMode} ${colors.gray(fetchTime)}`
140
- )
134
+ print.keyValue(green('mode'), `${fetchMode} ${gray(fetchTime)}`)
141
135
  )
142
136
  }
143
137
 
144
- console.error(' ', print.keyValue(colors.green('uri'), uri))
145
- console.error(' ', print.keyValue(colors.green('id'), id))
138
+ console.error(' ', print.keyValue(green('uri'), uri))
139
+ console.error(' ', print.keyValue(green('id'), id))
146
140
 
147
141
  if (flags.copy) {
148
142
  let copiedValue
@@ -152,7 +146,7 @@ const render = ({ response, flags }) => {
152
146
  copiedValue = body
153
147
  }
154
148
  clipboardy.writeSync(JSON.stringify(copiedValue, null, 2))
155
- console.error(`\n ${colors.gray('Copied to clipboard!')}`)
149
+ console.error(`\n ${gray('Copied to clipboard!')}`)
156
150
  }
157
151
  }
158
152
 
package/src/colors.js ADDED
@@ -0,0 +1,18 @@
1
+ 'use strict'
2
+
3
+ const { styleText } = require('node:util')
4
+
5
+ const gray = str => styleText('gray', str)
6
+
7
+ const white = str => styleText('white', str)
8
+
9
+ const green = str => styleText('green', str)
10
+
11
+ const red = str => styleText('red', str)
12
+
13
+ const yellow = str => styleText('yellow', str)
14
+
15
+ const label = (text, color) =>
16
+ styleText(['inverse', 'bold', color], ` ${text.toUpperCase()} `)
17
+
18
+ module.exports = { gray, white, green, red, yellow, label }
package/src/exit.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const colors = require('picocolors')
3
+ const { gray, red } = require('./colors')
4
4
 
5
5
  const print = require('./print')
6
6
 
@@ -15,31 +15,27 @@ module.exports = async (promise, { flags }) => {
15
15
  console.log(
16
16
  ' ',
17
17
  print.label((error.status || 'fail').toUpperCase(), 'red'),
18
- colors.gray(error.message.replace(`${error.code}, `, ''))
18
+ gray(error.message.replace(`${error.code}, `, ''))
19
19
  )
20
20
  console.log()
21
21
  if (error.data) {
22
22
  console.log(print.keyValue(' ', JSON.stringify(error.data)))
23
23
  console.log()
24
24
  }
25
- id && console.log(' ', print.keyValue(colors.red('id'), id))
26
- error.url &&
27
- console.log(' ', print.keyValue(colors.red('uri'), error.url))
25
+ id && console.log(' ', print.keyValue(red('id'), id))
26
+ error.url && console.log(' ', print.keyValue(red('uri'), error.url))
28
27
  error.code &&
29
28
  console.log(
30
29
  ' ',
31
30
  print.keyValue(
32
- colors.red('code'),
31
+ red('code'),
33
32
  `${error.code} ${error.statusCode ? `(${error.statusCode})` : ''}`
34
33
  )
35
34
  )
36
35
  error.more &&
37
36
  console.log(
38
37
  ' ',
39
- print.keyValue(
40
- colors.red('more'),
41
- print.link('click to report', error.more)
42
- )
38
+ print.keyValue(red('more'), print.link('click to report', error.more))
43
39
  )
44
40
 
45
41
  process.exit(1)
package/src/help.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { gray, white } = require('picocolors')
3
+ const { gray, white } = require('./colors')
4
4
 
5
5
  const code = str => `\`${str}\``
6
6
 
package/src/print.js CHANGED
@@ -5,10 +5,11 @@ const restoreCursor = require('restore-cursor')
5
5
  const terminalLink = require('terminal-link')
6
6
  const prettyBytes = require('pretty-bytes')
7
7
  const prettyMs = require('pretty-ms')
8
- const colors = require('picocolors')
9
8
  const termImg = require('term-img')
10
9
  const jsome = require('jsome')
11
10
 
11
+ const { gray, yellow, label } = require('./colors')
12
+
12
13
  const TICK_INTERVAL = 50
13
14
 
14
15
  jsome.colors = {
@@ -55,19 +56,18 @@ module.exports = {
55
56
  json: (payload, { color: colorize = true } = {}) =>
56
57
  colorize ? jsome(payload) : console.log(payload),
57
58
 
58
- label: (text, color) =>
59
- colors.inverse(colors.bold(colors[color](` ${text.toUpperCase()} `))),
59
+ label,
60
60
 
61
61
  bytes: prettyBytes,
62
62
 
63
- keyValue: (key, value) => key + ' ' + colors.gray(value),
63
+ keyValue: (key, value) => key + ' ' + gray(value),
64
64
 
65
65
  image: filepath =>
66
66
  console.log(
67
67
  termImg(filepath, {
68
68
  width: '50%',
69
69
  fallback: () =>
70
- `\n${colors.yellow(' tip:')} ${colors.gray(
70
+ `\n${yellow(' tip:')} ${gray(
71
71
  'use iTerm >=3 to see the image here!'
72
72
  )}`
73
73
  })
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const cli = require('../src/cli')
4
- cli.flags.endpoint = 'https://beta.microlink.io'
5
- delete cli.flags.apiKey
6
-
7
- require('../src/api')(cli, {
8
- headers: {
9
- authorization: require('../../api/src/constant').MICROLINK_API_AUTHORIZATION
10
- }
11
- })
package/bin/microlink-dev DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const cli = require('../src/cli')
4
- cli.flags.endpoint = 'http://localhost:3000'
5
- delete cli.flags.apiKey
6
-
7
- require('../src/api')(cli, {
8
- retry: 0,
9
- headers: {
10
- authorization: require('../../api/src/constant').AUTHORIZATION
11
- }
12
- })
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const cli = require('../src/cli')
4
- cli.flags.endpoint = 'https://next.microlink.io'
5
- delete cli.flags.apiKey
6
-
7
- require('../src/api')(cli, {
8
- headers: {
9
- authorization: require('../../api/src/constant').AUTHORIZATION_TOKEN
10
- }
11
- })
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const cli = require('../src/cli')
4
- cli.flags.endpoint = 'https://vercel.microlink.io'
5
- require('../src/api')(cli)