@browserless/cli 9.3.0-beta.9 → 9.3.3
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/package.json +4 -4
- package/src/commands/screenshot.js +13 -0
- package/src/index.js +4 -9
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@browserless/cli",
|
|
3
3
|
"description": "CLI to interact with Browserless capabilities",
|
|
4
4
|
"homepage": "https://browserless.js.org",
|
|
5
|
-
"version": "9.3.
|
|
5
|
+
"version": "9.3.3",
|
|
6
6
|
"bin": {
|
|
7
7
|
"browserless": "src/index.js"
|
|
8
8
|
},
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"beauty-error": "~1.2.9",
|
|
35
|
-
"browserless": "^9.3.
|
|
35
|
+
"browserless": "^9.3.3",
|
|
36
36
|
"dark-mode": "~3.0.0",
|
|
37
37
|
"kleur": "~4.1.4",
|
|
38
38
|
"lodash": "~4.17.21",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"ora": "~5.4.1",
|
|
41
41
|
"pretty-bytes": "~5.6.0",
|
|
42
42
|
"process-stats": "~3.5.6",
|
|
43
|
-
"signal-exit": "~3.0.
|
|
43
|
+
"signal-exit": "~3.0.6",
|
|
44
44
|
"term-img": "~5.0.0",
|
|
45
45
|
"unique-random-array": "~2.0.0"
|
|
46
46
|
},
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"test": "exit 0"
|
|
56
56
|
},
|
|
57
57
|
"license": "MIT",
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "e15c8a9fea38ad134170d52c9b8058010a3c7cd1"
|
|
59
59
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const uniqueRandomArray = require('unique-random-array')
|
|
4
|
+
const darkMode = require('dark-mode')
|
|
4
5
|
const termImg = require('term-img')
|
|
5
6
|
const { set } = require('lodash')
|
|
6
7
|
|
|
@@ -39,6 +40,18 @@ module.exports = async ({ url, browserless, opts }) => {
|
|
|
39
40
|
set(opts, 'overlay.browser', opts.browser)
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
if (opts.codeScheme === 'ghcolors') {
|
|
44
|
+
const isDark = darkMode.isDark()
|
|
45
|
+
opts.colorScheme = isDark ? 'dark' : 'light'
|
|
46
|
+
|
|
47
|
+
opts.styles = [
|
|
48
|
+
isDark
|
|
49
|
+
? '#screenshot pre{background:#000}#screenshot .token.string{color:#50e3c2}#screenshot .token.number{color:#f81ce5}'
|
|
50
|
+
: '#screenshot pre{background:#fff}#screenshot .token.string{color:#f81ce5}#screenshot .token.number{color:#50e3c2}',
|
|
51
|
+
'#screenshot .language-js span{font-family:"Roboto Mono"}'
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
|
|
42
55
|
const screenshot = await browserless.screenshot(url, opts)
|
|
43
56
|
|
|
44
57
|
return termImg(screenshot, { width: '50%' })
|
package/src/index.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
const createBrowserless = require('browserless')
|
|
6
6
|
const beautyError = require('beauty-error')
|
|
7
|
-
const darkMode = require('dark-mode')
|
|
8
7
|
const path = require('path')
|
|
9
8
|
const fs = require('fs')
|
|
10
9
|
|
|
@@ -23,6 +22,10 @@ const cli = require('meow')({
|
|
|
23
22
|
codeScheme: {
|
|
24
23
|
type: 'string',
|
|
25
24
|
default: 'ghcolors'
|
|
25
|
+
},
|
|
26
|
+
verbose: {
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
default: true
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
})
|
|
@@ -41,14 +44,6 @@ const run = async () => {
|
|
|
41
44
|
const browserlessFactory = createBrowserless({ headless })
|
|
42
45
|
const browserless = await browserlessFactory.createContext()
|
|
43
46
|
|
|
44
|
-
if (cli.flags.codeScheme === 'ghcolors') {
|
|
45
|
-
const isDark = await darkMode.isDark()
|
|
46
|
-
cli.flags.colorScheme = isDark ? 'dark' : 'light'
|
|
47
|
-
cli.flags.styles = isDark
|
|
48
|
-
? '#screenshot pre{background:#000}#screenshot .token.string{color:#50e3c2}#screenshot .token.number{color:#f81ce5}'
|
|
49
|
-
: '#screenshot pre{background:#fff}#screenshot .token.string{color:#f81ce5}#screenshot .token.number{color:#50e3c2}'
|
|
50
|
-
}
|
|
51
|
-
|
|
52
47
|
const result = await fn({ url, browserless, opts: cli.flags })
|
|
53
48
|
|
|
54
49
|
await browserless.destroyContext()
|