-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport.js
31 lines (24 loc) · 946 Bytes
/
report.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
const fs = require('fs')
const url = require('url')
const Report = require('./lib/Report.js')
// This main function will process the command-line arguments,
// generate the schema.org report file for the SensorThings API
// instance, then output the result to a JSON file in an output
// directory.
// Uses an async main function so we can use await for HTTP calls.
async function main() {
/* Collect Input */
// slice out the first two command line arguments of node and script path
let args = process.argv.slice(2)
// URL to the root of the SensorThings API instance to scan
let staURL = new URL(args[0])
// Path to directory in which to output report
let outputDir = args[1]
/* Create and Generate Report */
let report = new Report(staURL)
await report.generate()
/* Output Report */
let filename = `report-${report.timeString()}.json`
fs.writeFileSync(`${outputDir}/${filename}`, report.toJSON())
}
main()