canvasxpress-cli 41.2.67 → 41.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/cmds/help.js +22 -22
- package/cmds/io.js +13 -32
- package/cmds/version.js +2 -2
- package/package.json +1 -1
- package/src/canvasXpress.js +1436 -1434
package/cmds/help.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const menus = {
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
main: `
|
|
4
4
|
canvasxpress [command] <options>
|
|
5
5
|
|
|
@@ -12,10 +12,10 @@ const menus = {
|
|
|
12
12
|
canvas ............. run scripts files to test CanvasXpres
|
|
13
13
|
|
|
14
14
|
test ............... test package. Creates images and json file in test directory
|
|
15
|
-
version ............ show this package version
|
|
15
|
+
version ............ show this package version
|
|
16
16
|
help ............... show this help. Add command to show correponding help
|
|
17
17
|
`,
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
canvas: `
|
|
20
20
|
--input, -i ........ <required> path/to/js/file
|
|
21
21
|
--directory, -f .... [optional] directory of CanvasXpres version to check
|
|
@@ -24,14 +24,14 @@ const menus = {
|
|
|
24
24
|
--timeout, -t ...... [optional] timeout in millisecods to close browser
|
|
25
25
|
{default} 500
|
|
26
26
|
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
Examples:
|
|
29
29
|
|
|
30
30
|
canvasxpress canvas -i canvas/scripts/compareImages.js
|
|
31
31
|
|
|
32
32
|
canvasxpress canvas -i canvas/scripts/compareImages.js -g violin -n 11
|
|
33
33
|
`,
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
csv: `
|
|
36
36
|
--input, -i ........ [optional - required] file or url with a csv file:
|
|
37
37
|
file:///path/to/local/file.csv
|
|
@@ -48,13 +48,13 @@ const menus = {
|
|
|
48
48
|
--timeout, -t ...... [optional] timeout in millisecods to close browser
|
|
49
49
|
{default} 500
|
|
50
50
|
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
Examples:
|
|
53
53
|
|
|
54
54
|
canvasxpress csv -i ../src/ToothGrowth.csv -t 3000
|
|
55
55
|
|
|
56
56
|
canvasxpress csv -i https://raw.githubusercontent.com/neuhausi/Rdatasets/master/csv/datasets/ToothGrowth.csv -t 3000
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
canvasxpress csv -i file:///node/src/ToothGrownth.csv -c '{"graphType":"Boxplot","transposeData":true,"asVariableFactors":["dose"],"stringSampleFactors":["dose"],"groupingFactors":["dose"]}' -t 3000
|
|
59
59
|
|
|
60
60
|
canvasxpress csv -d '{"y":{"vars":["Variable1"],"smps":["Sample1","Sample2","Sample3"],"data":[[33,44,55]]}}' -c '{"graphOrientation":"vertical","theme":"CanvasXpress","title":"Bar Graph Title"}' -t 3000
|
|
@@ -70,11 +70,11 @@ const menus = {
|
|
|
70
70
|
--timeout, -t ...... [optional] timeout in millisecods to close browser
|
|
71
71
|
{default} 500
|
|
72
72
|
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
Examples:
|
|
75
75
|
|
|
76
|
-
canvasxpress reproduce -i https://canvasxpress.org/
|
|
77
|
-
|
|
76
|
+
canvasxpress reproduce -i https://canvasxpress.org/examples/layout-7.html
|
|
77
|
+
|
|
78
78
|
canvasxpress reproduce -i file:///node/src/canvasXpress.html
|
|
79
79
|
|
|
80
80
|
canvasxpress reproduce -i ../src/canvasXpress.html
|
|
@@ -97,11 +97,11 @@ const menus = {
|
|
|
97
97
|
--timeout, -t ...... [optional] timeout in millisecods to close browser
|
|
98
98
|
{default} 500
|
|
99
99
|
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
Examples:
|
|
102
102
|
|
|
103
|
-
canvasxpress png -i https://canvasxpress.org/
|
|
104
|
-
|
|
103
|
+
canvasxpress png -i https://canvasxpress.org/examples/bar-3.html
|
|
104
|
+
|
|
105
105
|
canvasxpress png -i file:///node/src/canvasXpress.html
|
|
106
106
|
|
|
107
107
|
canvasxpress png -i ../src/canvasXpress.html
|
|
@@ -126,11 +126,11 @@ const menus = {
|
|
|
126
126
|
--timeout, -t ...... [optional] timeout in millisecods to close browser
|
|
127
127
|
{default} 500
|
|
128
128
|
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
|
|
129
|
-
|
|
129
|
+
|
|
130
130
|
Examples:
|
|
131
131
|
|
|
132
|
-
canvasxpress svg -i https://canvasxpress.org/
|
|
133
|
-
|
|
132
|
+
canvasxpress svg -i https://canvasxpress.org/examples/bar-3.html
|
|
133
|
+
|
|
134
134
|
canvasxpress svg -i file:///node/src/canvasXpress.html
|
|
135
135
|
|
|
136
136
|
canvasxpress svg -i ../src/canvasXpress.html
|
|
@@ -138,7 +138,7 @@ const menus = {
|
|
|
138
138
|
canvasxpress svg -d '{"y":{"vars":["Variable1"],"smps":["Sample1","Sample2","Sample3"],"data":[[33,44,55]]}}'
|
|
139
139
|
-c '{"graphOrientation":"vertical","theme":"CanvasXpress","title":"Bar Graph Title"}'
|
|
140
140
|
`,
|
|
141
|
-
|
|
141
|
+
|
|
142
142
|
json: `
|
|
143
143
|
--input, -i ........ [optional - required] file or url with a html file:
|
|
144
144
|
file:///path/to/local/file.html
|
|
@@ -155,11 +155,11 @@ const menus = {
|
|
|
155
155
|
--timeout, -t ...... [optional] timeout in millisecods to close browser
|
|
156
156
|
{default} 500
|
|
157
157
|
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
|
|
158
|
-
|
|
158
|
+
|
|
159
159
|
Examples:
|
|
160
160
|
|
|
161
|
-
canvasxpress json -i https://canvasxpress.org/
|
|
162
|
-
|
|
161
|
+
canvasxpress json -i https://canvasxpress.org/examples/bar-3.html
|
|
162
|
+
|
|
163
163
|
canvasxpress json -i file:///node/src/canvasXpress.html
|
|
164
164
|
|
|
165
165
|
canvasxpress json -i ../src/canvasXpress.html
|
|
@@ -187,9 +187,9 @@ const menus = {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
module.exports = (args) => {
|
|
190
|
-
|
|
190
|
+
|
|
191
191
|
const subCmd = args._[0] === 'help' ? args._[1] : args._[0];
|
|
192
192
|
|
|
193
193
|
console.log(menus[subCmd] || menus.main);
|
|
194
|
-
|
|
194
|
+
|
|
195
195
|
}
|
package/cmds/io.js
CHANGED
|
@@ -10,15 +10,11 @@ module.exports = async (obj) => {
|
|
|
10
10
|
|
|
11
11
|
const today = new Date().toISOString().replace('-', '').split('T')[0].replace('-', '');
|
|
12
12
|
|
|
13
|
-
const logFile = fs.createWriteStream((
|
|
13
|
+
const logFile = fs.createWriteStream(('/tmp/io-' + today + '.log'), { flags: 'a' });
|
|
14
14
|
|
|
15
15
|
const logStdout = process.stdout;
|
|
16
16
|
|
|
17
|
-
const defhtml = ("file://" + dirname + "/src/canvasXpress.html");
|
|
18
|
-
|
|
19
|
-
if (!fs.existsSync(dirname + '/logs')) {
|
|
20
|
-
fs.mkdirSync(dirname + '/logs');
|
|
21
|
-
}
|
|
17
|
+
const defhtml = ("file://" + dirname + "/src/canvasXpress.html" + (obj.debug ? "?cXH" : ""));
|
|
22
18
|
|
|
23
19
|
console.log = function () {
|
|
24
20
|
logFile.write(util.format.apply(null, arguments) + '\n');
|
|
@@ -38,32 +34,16 @@ module.exports = async (obj) => {
|
|
|
38
34
|
width: 1000,
|
|
39
35
|
height: 1000
|
|
40
36
|
},
|
|
41
|
-
args: [
|
|
37
|
+
args: [
|
|
38
|
+
'--no-sandbox',
|
|
39
|
+
'--disable-setuid-sandbox',
|
|
42
40
|
'--allow-file-access-from-files',
|
|
43
|
-
'--enable-local-file-accesses'
|
|
41
|
+
'--enable-local-file-accesses'
|
|
42
|
+
]
|
|
44
43
|
});
|
|
45
44
|
|
|
46
45
|
const page = await browser.newPage();
|
|
47
46
|
|
|
48
|
-
// Print All
|
|
49
|
-
//page.on("console", (consoleObj) => console.log(consoleObj.text()));
|
|
50
|
-
|
|
51
|
-
// Print All except warnings
|
|
52
|
-
page.on('console', consoleObj => {
|
|
53
|
-
if (consoleObj.type() !== 'warning') {
|
|
54
|
-
console.log(consoleObj.text());
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
/*
|
|
59
|
-
// Print only logs
|
|
60
|
-
page.on('console', consoleObj => {
|
|
61
|
-
if (consoleObj.type() === 'log') {
|
|
62
|
-
console.log(consoleObj.text());
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
47
|
if (obj.input && !obj.input.match(/^file|^http/)) {
|
|
68
48
|
obj.input = "file://" + path.resolve(obj.input);
|
|
69
49
|
}
|
|
@@ -107,7 +87,7 @@ module.exports = async (obj) => {
|
|
|
107
87
|
cx.dataURL = obj.input;
|
|
108
88
|
cx.remoteTransitionEffect = 'none';
|
|
109
89
|
cx.getDataFromURLOrString(obj.target || cx.target, obj.config, false, false, clbk);
|
|
110
|
-
} else {
|
|
90
|
+
} else {
|
|
111
91
|
console.log("Creating " + (obj.cmd == 'csv' ? 'png' : obj.cmd) + " file from " + (obj.input ? obj.input : 'input data') + " (" + obj.output + (obj.target || cx.target) + "." + obj.cmd + ")");
|
|
112
92
|
exec(cx, obj.target || cx.target);
|
|
113
93
|
}
|
|
@@ -128,13 +108,14 @@ module.exports = async (obj) => {
|
|
|
128
108
|
}
|
|
129
109
|
}
|
|
130
110
|
|
|
131
|
-
await page.
|
|
111
|
+
const client = await page.target().createCDPSession()
|
|
112
|
+
await client.send('Page.setDownloadBehavior', {
|
|
132
113
|
behavior: 'allow',
|
|
133
114
|
downloadPath: obj.output
|
|
134
|
-
})
|
|
115
|
+
})
|
|
135
116
|
|
|
136
117
|
if (obj.input) {
|
|
137
|
-
await page.goto(obj.cmd == 'csv' ? defhtml : obj.cmd == 'reproduce' ? obj.input + '?showTransition=false' : obj.input);
|
|
118
|
+
await page.goto(obj.cmd == 'csv' ? defhtml : obj.cmd == 'reproduce' ? obj.input + '?showTransition=false' + (obj.debug ? '&cXH' : '') : obj.input + (obj.debug ? '?cXH' : ''));
|
|
138
119
|
} else {
|
|
139
120
|
await page.goto(defhtml);
|
|
140
121
|
}
|
|
@@ -154,4 +135,4 @@ module.exports = async (obj) => {
|
|
|
154
135
|
|
|
155
136
|
}
|
|
156
137
|
|
|
157
|
-
}
|
|
138
|
+
}
|
package/cmds/version.js
CHANGED