make-mp-data 1.0.6 → 1.0.8

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.
Files changed (3) hide show
  1. package/cli.js +2 -1
  2. package/index.js +37 -39
  3. package/package.json +1 -1
package/cli.js CHANGED
@@ -10,9 +10,10 @@ makes all the things for mixpanel (v${version || 1})
10
10
  by ak@mixpanel.com
11
11
  `;
12
12
 
13
- console.log(hero);
13
+
14
14
 
15
15
  function cliParams() {
16
+ console.log(hero);
16
17
  const args = yargs(process.argv.splice(2))
17
18
  .scriptName("make-mp-data")
18
19
  .usage(`\nusage:\nnpx $0 [dataModel.js] [options]
package/index.js CHANGED
@@ -32,44 +32,10 @@ Array.prototype.pickOne = pick;
32
32
  const now = dayjs().unix();
33
33
  const dayInSec = 86400;
34
34
 
35
-
36
-
37
- const args = cliParams();
38
- const {
39
- token,
40
- seed,
41
- format,
42
- numDays,
43
- numUsers,
44
- numEvents,
45
- region
46
- } = args;
47
- const suppliedConfig = args._[0];
48
-
49
- //if the user specifics an separate config file
50
- let config = null;
51
- if (suppliedConfig) {
52
- console.log(`using ${suppliedConfig} for data\n`);
53
- config = require(path.resolve(suppliedConfig));
54
- } else {
55
- console.log(`... using default configuration ...\n`);
56
- config = require("./default.js");
57
- }
58
-
59
- //override config with cli params
60
- if (token) config.token = token;
61
- if (seed) config.seed = seed;
62
- if (format) config.format = format;
63
- if (numDays) config.numDays = numDays;
64
- if (numUsers) config.numUsers = numUsers;
65
- if (numEvents) config.numEvents = numEvents;
66
- if (region) config.region = region;
67
-
68
-
69
35
  //our main program
70
36
  async function main(config) {
71
37
 
72
- const {
38
+ let {
73
39
  seed = "every time a rug is micturated upon in this fair city...",
74
40
  numEvents = 100000,
75
41
  numUsers = 1000,
@@ -87,9 +53,9 @@ async function main(config) {
87
53
  format = "csv",
88
54
  token = null,
89
55
  region = "US",
90
- writeToDisk = true
56
+ writeToDisk = false
91
57
  } = config;
92
-
58
+ if (require.main === module) writeToDisk = true;
93
59
  const uuidChance = new Chance(seed);
94
60
 
95
61
  //the function which generates $distinct_id
@@ -206,7 +172,7 @@ async function main(config) {
206
172
  ];
207
173
  console.log("\n");
208
174
 
209
- if (!writeToDisk) return { eventData, userProfilesData, scdTableData, groupProfilesData, lookupTableData };
175
+ if (!writeToDisk && !token) return { eventData, userProfilesData, scdTableData, groupProfilesData, lookupTableData };
210
176
  //write the files
211
177
  for (const pair of pairs) {
212
178
  const [paths, data] = pair;
@@ -376,7 +342,39 @@ function buildFileNames(config) {
376
342
 
377
343
  // this is for CLI
378
344
  if (require.main === module) {
379
- //that's all folks :)
345
+
346
+ const args = cliParams();
347
+ const {
348
+ token,
349
+ seed,
350
+ format,
351
+ numDays,
352
+ numUsers,
353
+ numEvents,
354
+ region
355
+ } = args;
356
+ const suppliedConfig = args._[0];
357
+
358
+ //if the user specifics an separate config file
359
+ let config = null;
360
+ if (suppliedConfig) {
361
+ console.log(`using ${suppliedConfig} for data\n`);
362
+ config = require(path.resolve(suppliedConfig));
363
+ } else {
364
+ console.log(`... using default configuration ...\n`);
365
+ config = require("./default.js");
366
+ }
367
+
368
+ //override config with cli params
369
+ if (token) config.token = token;
370
+ if (seed) config.seed = seed;
371
+ if (format) config.format = format;
372
+ if (numDays) config.numDays = numDays;
373
+ if (numUsers) config.numUsers = numUsers;
374
+ if (numEvents) config.numEvents = numEvents;
375
+ if (region) config.region = region;
376
+
377
+
380
378
  main(config)
381
379
  .then((data) => {
382
380
  console.log(`------------------SUMMARY------------------`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "make-mp-data",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "builds all mixpanel primitives for a given project",
5
5
  "main": "index.js",
6
6
  "scripts": {