make-mp-data 1.2.11 → 1.2.21

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 CHANGED
@@ -204,6 +204,8 @@ async function main(config) {
204
204
  scdTableData,
205
205
  groupProfilesData,
206
206
  lookupTableData,
207
+ import: {},
208
+ files: []
207
209
  };
208
210
  }
209
211
  log(`-----------------WRITES------------------`, `\n\n`);
@@ -487,7 +489,9 @@ if (require.main === module) {
487
489
  main(config)
488
490
  .then((data) => {
489
491
  log(`-----------------SUMMARY-----------------`);
490
- const { events, groups, users } = data.import;
492
+ const d = {success: 0, bytes: 0};
493
+ const darr = [d]
494
+ const { events = d, groups = darr, users = d } = data.import;
491
495
  const files = data.files;
492
496
  const folder = files?.pop();
493
497
  const groupBytes = groups.reduce((acc, group) => {
@@ -504,7 +508,7 @@ if (require.main === module) {
504
508
  bytes: bytesHuman(bytes || 0),
505
509
  };
506
510
  if (bytes > 0) console.table(stats);
507
- log(`\nfiles written to ${folder} ...`);
511
+ log(`\nfiles written to ${folder || "no where; we didn't write anything"} ...`);
508
512
  log(" " + files?.flat().join("\n "));
509
513
  log(`\n----------------SUMMARY-----------------\n\n\n`);
510
514
  })
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "make-mp-data",
3
- "version": "1.2.11",
3
+ "version": "1.2.21",
4
4
  "description": "builds all mixpanel primitives for a given project",
5
5
  "main": "index.js",
6
6
  "types": "types.d.ts",
7
7
  "scripts": {
8
8
  "start": "node index.js",
9
- "prune": "rm ./data/*",
10
- "go": "sh ./scripts/go.sh",
9
+ "dev": "./scripts/go.sh",
10
+ "prune": "rm ./data/*",
11
11
  "post": "npm publish",
12
12
  "test": "jest --runInBand",
13
13
  "deps": "sh ./scripts/deps.sh"
package/scripts/go.sh CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/bin/bash
2
- RUNTIME=local node --inspect index.js --writeToDisk false -u 100 -e 10000
2
+ RUNTIME=local nodemon --inspect index.js --writeToDisk false -u 100 -e 10000
package/utils.js CHANGED
@@ -81,16 +81,24 @@ function day(start, end) {
81
81
  };
82
82
 
83
83
  function choose(value) {
84
- if (typeof value === 'function') {
85
- return value();
86
- }
87
- if (Array.isArray(value)) {
88
- return chance.pickone(value);
89
- }
84
+ try {
85
+ // Keep resolving the value if it's a function
86
+ while (typeof value === 'function') {
87
+ value = value();
88
+ }
90
89
 
91
- return value;
92
- };
90
+ // Now, if the resolved value is an array, use chance.pickone
91
+ if (Array.isArray(value)) {
92
+ return chance.pickone(value);
93
+ }
93
94
 
95
+ // If it's not a function or array, return it as is
96
+ return value;
97
+ }
98
+ catch (e) {
99
+ return '';
100
+ }
101
+ }
94
102
  function exhaust(arr) {
95
103
  return function () {
96
104
  return arr.shift();