forked from parallax/jsPDF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
96 lines (90 loc) · 3.42 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const inquirer = require("inquirer");
const configuration = require('./modules.conf.js');
console.log(configuration);
function uniq(a) {
var prims = { "boolean": {}, "number": {}, "string": {} }, objs = [];
return a.filter(function (item) {
var type = typeof item;
if (type in prims)
return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true);
else
return objs.indexOf(item) >= 0 ? false : objs.push(item);
});
}
function generateFileList(list) {
var fileList = [];
var file;
for (var i = 0; i < list.length; i++) {
fileList.push(list[i].name + '.js');
console.log(list[i])
console.log(configuration[list[i].name])
for (var j = 0; j < configuration[list[i]].deps.length; j++) {
file = configuration[list[i]].deps[j];
configuration[file].type
fileList.push(configuration[file].type + '/' + '.js');
}
}
fileList = uniq(fileList);
return fileList;
}
/**
* Ask use a few questions on command prompt
* @returns {Promise} The promise with the result of the prompt
*/
function promptUser() {
return inquirer.prompt([
{
type: "list",
name: "env",
message: "Where does your code run?",
default: ["browser"],
choices: [
{ name: "Browser", value: "browser" },
{ name: "Node", value: "node" }
]
},
{
type: "checkbox",
name: "images",
message: "Which ImageTypes should be supported?",
default: ["jpeg_support", 'bmp_support', 'gif_support', 'webp_support'],
choices: [
{ name: "Jpeg", value: "jpeg_support" },
{ name: "Bmp", value: "bmp_support" },
{ name: "Gif", value: "gif_support" },
{ name: "WebP", value: "webp_support" }
]
},
{
type: "checkbox",
name: "modules",
message: "Additional Modules",
default: ['acroform', 'annotations', 'arabic', 'autoprint', 'context2d',
'fileloading', 'filters', 'html', 'javascript', 'outline',
'setlanguage', 'svg', 'total_pages', 'utf8', 'viewerpreferences',
'xmp_metadata'
],
choices: [
{ name: "Acroform", value: "acroform" },
{ name: "Annotations", value: "annotations" },
{ name: "Arabic Parser", value: "arabic" },
{ name: "Autoprint", value: "autoprint" },
{ name: "Context2d", value: "context2d" },
{ name: "File Loading", value: "fileloading" },
{ name: "Filters", value: "filters" },
{ name: "HTML", value: "html" },
{ name: "Javascript", value: "javascript" },
{ name: "Outline", value: "outline" },
{ name: "Language-Tagging", value: "setlanguage" },
{ name: "SVG", value: "svg" },
{ name: "TotalPages", value: "total_pages" },
{ name: "Unicode", value: "utf8" },
{ name: "ViewerPreferences", value: "viewerpreferences" },
{ name: "XMP Metadata", value: "xmp_metadata" }
]
}
]).then(result => {
console.log(generateFileList([...result.images, ...result.modules]));
});
}
promptUser();