forked from dzt/ecu-viz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.js
40 lines (34 loc) · 1.19 KB
/
start.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
const input_file = require('./input_examples/http.json');
const lib = require('./lib/index.js');
const utils = require('./lib/utils.js');
const fs = require('fs');
const YAML = require('json-to-pretty-yaml');
const generateDiagram = (input) => {
let connectors = lib.createConnectors(input);
let cables = lib.createCables(connectors.summary, input);
let connections = lib.createConnections(connectors, cables, input);
return { connectors: connectors.data, cables, connections };
}
/* Used for testing */
let output = generateDiagram(input_file);
let data = YAML.stringify(output)
/* ECU Summary Print */
console.log('ECU Summary:');
let summary = utils.getECUSummary(input_file.ecu, false);
console.dir(summary);
/* YAML Generation */
fs.writeFile('out/output.yaml', data, function(error) {
if(error) {
console.log('[write auth]: ' + err);
} else {
console.log('[write auth]: success (output.yaml)');
}
});
/* JSON Generation (for testing) */
fs.writeFile('out/output.json', JSON.stringify(output, null, 4), function(error) {
if(error) {
console.log('[write auth]: ' + err);
} else {
console.log('[write auth]: success (output.json)');
}
});