-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathlts.js
More file actions
126 lines (116 loc) · 2.56 KB
/
lts.js
File metadata and controls
126 lines (116 loc) · 2.56 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env node
'use strict';
const Path = require('path');
const Bossy = require('bossy');
const Lib = require('../lib');
const { writeFileSync } = require('node:fs');
const Svg2png = require('svg2png');
const now = new Date();
const oneYearFromNow = new Date();
oneYearFromNow.setFullYear(now.getFullYear() + 1);
const cliArgs = {
'd': {
description: 'Input LTS JSON file',
alias: 'data',
type: 'string',
require: false,
multiple: false,
default: Path.resolve(__dirname, '..', 'lts.json')
},
's': {
description: 'Query start date',
alias: 'start',
type: 'string',
require: false,
multiple: false,
default: now
},
'e': {
description: 'Query end date',
alias: 'end',
type: 'string',
require: false,
multiple: false,
default: oneYearFromNow
},
'h': {
description: 'HTML output file',
alias: 'html',
type: 'string',
require: false,
multiple: false,
default: null
},
'g': {
description: 'SVG output file',
alias: 'svg',
type: 'string',
require: false,
multiple: false,
default: null
},
'p': {
description: 'PNG output file',
alias: 'png',
type: 'string',
require: false,
multiple: false,
default: null
},
'a': {
description: 'Animate bars on load',
alias: 'animate',
type: 'boolean',
require: false,
multiple: false,
default: false
},
'm': {
description: 'Exclude Main (unstable) in graph',
alias: 'excludeMain',
type: 'boolean',
require: false,
multiple: false,
default: false
},
'n': {
description: 'Project Name',
alias: 'projectName',
type: 'string',
require: false,
multiple: false,
default: 'Node.js'
},
'c': {
description: 'Current date marker',
alias: 'currentDateMarker',
type: 'string',
require: false,
multiple: false,
default: null
}
};
const args = Bossy.parse(cliArgs, { argv: process.argv });
if (args instanceof Error) {
Bossy.usage(cliArgs, args.message);
process.exit(1);
}
const options = {
data: require(args.data),
queryStart: new Date(args.start),
queryEnd: new Date(args.end),
animate: args.animate,
excludeMain: args.excludeMain,
projectName: args.projectName,
currentDateMarker: args.currentDateMarker
};
const d3n = Lib.create(options);
if (args.html) {
writeFileSync(Path.resolve(args.html), d3n.html());
}
if (args.svg) {
writeFileSync(Path.resolve(args.svg), d3n.svgString());
}
if (args.png) {
writeFileSync(Path.resolve(args.png), Svg2png.sync(Buffer.from(d3n.svgString())));
}