1
1
// run as
2
2
// node generate.js > countly.device.list.js
3
+ // resulting file should be copied to "/frontend/express/public/javascripts/countly"
3
4
4
5
//https://www.theiphonewiki.com/wiki/Models
5
6
//https://gist.github.com/adamawolf/3048717
@@ -15,11 +16,17 @@ var amazon = require("./amazon.json");
15
16
for ( var i in amazon ) {
16
17
devices [ i ] = amazon [ i ] ;
17
18
}
19
+
20
+ // Informative messages are writer to stderr so they don't interfere with the stdout piping to a file
21
+ // When downloading the CSV file it will be UTF-16 LE. It needs to be transformed to UTF-8 (non BOM version)
22
+ // converting with notepad++ or vscode might not work on a windows device. Try on a mac device
23
+ process . stderr . write ( "Starting CSV parsing\n" ) ;
18
24
var csv = require ( 'csvtojson' ) ;
19
25
csv ( )
20
26
//from https://support.google.com/googleplay/answer/1727131?hl=en-GB
21
27
. fromFile ( "./supported_devices.csv" )
22
28
. on ( 'json' , ( jsonObj ) => {
29
+ //process.stderr.write("Parsed data/json line: " + jsonObj);
23
30
var d = jsonObj [ "Marketing Name" ] + "" ;
24
31
var i = jsonObj [ "Model" ] + "" ;
25
32
if ( i != d && d . trim ( ) . length ) {
33
40
}
34
41
}
35
42
} )
43
+ // .on('data', (data)=>{
44
+ // //process.stderr.write("Parsed data line: " + data);
45
+ // })
46
+ // .on('error', (err)=>{
47
+ // process.stderr.write("Error while parsing: " + err);
48
+ // })
36
49
. on ( 'done' , ( ) => {
50
+ process . stderr . write ( "CSV parsing 'done' trigger\n" ) ;
37
51
process . stdout . write ( "/**\n * Object with device models as keys and pretty/marketing device names as values\n * @name countlyDeviceList\n * @global\n * @namespace countlyDeviceList\n */\nvar countlyDeviceList = " + JSON . stringify ( devices , null , 4 ) + ";\n/*global module*/\nif (typeof module !== 'undefined' && module.exports) {\n module.exports = countlyDeviceList;\n}" ) ;
38
- } ) ;
52
+ } ) ;
53
+ process . stderr . write ( "Ending CSV parsing\n" ) ;
0 commit comments