make-mp-data 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +45 -31
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -87,6 +87,7 @@ async function main(config) {
|
|
|
87
87
|
format = "csv",
|
|
88
88
|
token = null,
|
|
89
89
|
region = "US",
|
|
90
|
+
writeToDisk = true
|
|
90
91
|
} = config;
|
|
91
92
|
|
|
92
93
|
const uuidChance = new Chance(seed);
|
|
@@ -204,6 +205,8 @@ async function main(config) {
|
|
|
204
205
|
[lookupFiles, lookupTableData],
|
|
205
206
|
];
|
|
206
207
|
console.log("\n");
|
|
208
|
+
|
|
209
|
+
if (!writeToDisk) return { eventData, userProfilesData, scdTableData, groupProfilesData, lookupTableData };
|
|
207
210
|
//write the files
|
|
208
211
|
for (const pair of pairs) {
|
|
209
212
|
const [paths, data] = pair;
|
|
@@ -371,34 +374,45 @@ function buildFileNames(config) {
|
|
|
371
374
|
return writePaths;
|
|
372
375
|
}
|
|
373
376
|
|
|
374
|
-
//
|
|
375
|
-
main
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
377
|
+
// this is for CLI
|
|
378
|
+
if (require.main === module) {
|
|
379
|
+
//that's all folks :)
|
|
380
|
+
main(config)
|
|
381
|
+
.then((data) => {
|
|
382
|
+
console.log(`------------------SUMMARY------------------`);
|
|
383
|
+
const { events, groups, users } = data.import;
|
|
384
|
+
const files = data.files;
|
|
385
|
+
const folder = files.pop();
|
|
386
|
+
const groupBytes = groups.reduce((acc, group) => { return acc + group.bytes; }, 0);
|
|
387
|
+
const groupSuccess = groups.reduce((acc, group) => { return acc + group.success; }, 0);
|
|
388
|
+
const bytes = events.bytes + groupBytes + users.bytes;
|
|
389
|
+
const stats = {
|
|
390
|
+
events: comma(events.success || 0),
|
|
391
|
+
users: comma(users.success || 0),
|
|
392
|
+
groups: comma(groupSuccess || 0),
|
|
393
|
+
bytes: bytesHuman(bytes || 0)
|
|
394
|
+
};
|
|
395
|
+
if (bytes > 0) console.table(stats);
|
|
396
|
+
console.log(`\nfiles written to ${folder}...`);
|
|
397
|
+
console.log("\t" + files.flat().join('\n\t'));
|
|
398
|
+
console.log(`\n------------------SUMMARY------------------\n\n\n`);
|
|
399
|
+
})
|
|
400
|
+
.catch((e) => {
|
|
401
|
+
console.log(`------------------ERROR------------------`);
|
|
402
|
+
console.error(e);
|
|
403
|
+
console.log(`------------------ERROR------------------`);
|
|
404
|
+
debugger;
|
|
405
|
+
})
|
|
406
|
+
.finally(() => {
|
|
407
|
+
console.log('have a wonderful day :)');
|
|
408
|
+
openFinder(path.resolve("./data"));
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
else {
|
|
414
|
+
module.exports = main;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|