@atlaskit/dependency-version-analytics 0.4.2 → 1.1.0

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 (50) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -1
  3. package/dist/cjs/cli.js +4 -18
  4. package/dist/cjs/commands/populate-historic-data/index.js +0 -3
  5. package/dist/cjs/commands/populate-historic-data/lib/dependency-store.js +24 -141
  6. package/dist/cjs/commands/populate-historic-data/package.js +8 -29
  7. package/dist/cjs/commands/populate-historic-data/product.js +114 -150
  8. package/dist/cjs/commands/populate-historic-data/util/generate-csv.js +4 -16
  9. package/dist/cjs/index.js +0 -2
  10. package/dist/cjs/util/analytics.js +16 -41
  11. package/dist/cjs/util/assert.js +0 -1
  12. package/dist/cjs/util/env-with-guard.js +0 -2
  13. package/dist/cjs/util/get-file-history-from-git.js +0 -5
  14. package/dist/cjs/util/get-package-version-history.js +8 -10
  15. package/dist/cjs/util/git.js +20 -58
  16. package/dist/cjs/util/statlas.js +0 -25
  17. package/dist/cjs/util/yarn.js +0 -32
  18. package/dist/cjs/version.json +1 -1
  19. package/dist/es2019/cli.js +4 -8
  20. package/dist/es2019/commands/populate-historic-data/lib/dependency-store.js +24 -73
  21. package/dist/es2019/commands/populate-historic-data/package.js +7 -12
  22. package/dist/es2019/commands/populate-historic-data/product.js +21 -23
  23. package/dist/es2019/commands/populate-historic-data/util/generate-csv.js +2 -9
  24. package/dist/es2019/util/analytics.js +17 -19
  25. package/dist/es2019/util/env-with-guard.js +0 -1
  26. package/dist/es2019/util/get-file-history-from-git.js +2 -3
  27. package/dist/es2019/util/get-package-version-history.js +7 -7
  28. package/dist/es2019/util/git.js +29 -24
  29. package/dist/es2019/util/statlas.js +0 -6
  30. package/dist/es2019/util/yarn.js +2 -11
  31. package/dist/es2019/version.json +1 -1
  32. package/dist/esm/cli.js +6 -12
  33. package/dist/esm/commands/populate-historic-data/lib/dependency-store.js +27 -131
  34. package/dist/esm/commands/populate-historic-data/package.js +10 -24
  35. package/dist/esm/commands/populate-historic-data/product.js +114 -134
  36. package/dist/esm/commands/populate-historic-data/util/generate-csv.js +4 -13
  37. package/dist/esm/util/analytics.js +18 -31
  38. package/dist/esm/util/env-with-guard.js +0 -1
  39. package/dist/esm/util/get-file-history-from-git.js +2 -3
  40. package/dist/esm/util/get-package-version-history.js +7 -7
  41. package/dist/esm/util/git.js +21 -50
  42. package/dist/esm/util/statlas.js +0 -19
  43. package/dist/esm/util/yarn.js +0 -19
  44. package/dist/esm/version.json +1 -1
  45. package/dist/types/types.d.ts +7 -0
  46. package/dist/types/util/analytics.d.ts +2 -1
  47. package/dist/types/util/get-package-version-history.d.ts +7 -3
  48. package/package.json +3 -3
  49. package/report.api.md +5 -1
  50. package/tmp/api-report-tmp.d.ts +4 -0
@@ -10,20 +10,19 @@ import * as statlas from '../../util/statlas';
10
10
  import { generateCSV } from './util/generate-csv';
11
11
  import { assert } from '../../util/assert';
12
12
  import { DependencyStore } from './lib/dependency-store';
13
-
13
+ import getPackageVersionHistoryAndTags from '../../util/get-package-version-history';
14
14
  var getUpgradeEventsFromPkgChange = function getUpgradeEventsFromPkgChange(oldDeps, newDeps, _ref) {
15
15
  var date = _ref.date,
16
- commitHash = _ref.commitHash;
16
+ commitHash = _ref.commitHash;
17
17
  var addOrUpgradeEvents = Object.entries(newDeps).map(function (_ref2) {
18
18
  var _ref3 = _slicedToArray(_ref2, 2),
19
- name = _ref3[0],
20
- _ref3$ = _ref3[1],
21
- version = _ref3$.version,
22
- type = _ref3$.type;
23
-
24
- var prevDep = oldDeps[name]; // Only treat a dependency as previous if the dependency type matches
19
+ name = _ref3[0],
20
+ _ref3$ = _ref3[1],
21
+ version = _ref3$.version,
22
+ type = _ref3$.type;
23
+ var prevDep = oldDeps[name];
24
+ // Only treat a dependency as previous if the dependency type matches
25
25
  // Otherwise, we want separate add/remove events
26
-
27
26
  var prevVersion = prevDep && prevDep.type === type ? prevDep.version : undefined;
28
27
  return createUpgradeEvent(name, version, prevVersion, date, {
29
28
  commitHash: commitHash,
@@ -35,19 +34,18 @@ var getUpgradeEventsFromPkgChange = function getUpgradeEventsFromPkgChange(oldDe
35
34
  });
36
35
  var removeEvents = Object.entries(oldDeps).filter(function (_ref4) {
37
36
  var _ref5 = _slicedToArray(_ref4, 2),
38
- name = _ref5[0],
39
- type = _ref5[1].type;
40
-
41
- return (// Treat the same dep under a different dependency type as a new dep
37
+ name = _ref5[0],
38
+ type = _ref5[1].type;
39
+ return (
40
+ // Treat the same dep under a different dependency type as a new dep
42
41
  newDeps[name] == null || newDeps[name].type !== type
43
42
  );
44
43
  }).map(function (_ref6) {
45
44
  var _ref7 = _slicedToArray(_ref6, 2),
46
- name = _ref7[0],
47
- _ref7$ = _ref7[1],
48
- version = _ref7$.version,
49
- type = _ref7$.type;
50
-
45
+ name = _ref7[0],
46
+ _ref7$ = _ref7[1],
47
+ version = _ref7$.version,
48
+ type = _ref7$.type;
51
49
  return createUpgradeEvent(name, undefined, version, date, {
52
50
  commitHash: commitHash,
53
51
  dependencyType: type,
@@ -58,43 +56,36 @@ var getUpgradeEventsFromPkgChange = function getUpgradeEventsFromPkgChange(oldDe
58
56
  });
59
57
  return [].concat(_toConsumableArray(addOrUpgradeEvents), _toConsumableArray(removeEvents));
60
58
  };
61
-
62
59
  var getEventsFromHistory = /*#__PURE__*/function () {
63
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(packageChangesLog, prevRunHash, _ref8) {
64
- var cwd, allPackageChanges, allUpgradeEvents, dependencyStore, dependencies, i, item, newDependencies, packageChange, upgradeEvents;
65
- return _regeneratorRuntime.wrap(function _callee$(_context) {
60
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(packageChangesLog, prevRunHash, _ref8) {
61
+ var cwd, allPackageChanges, allUpgradeEvents, dependencyStore, dependencies, i, item, newDependencies, packageChange, upgradeEvents, _allUpgradeEvents;
62
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
66
63
  while (1) {
67
- switch (_context.prev = _context.next) {
64
+ switch (_context2.prev = _context2.next) {
68
65
  case 0:
69
66
  cwd = _ref8.cwd;
70
67
  allPackageChanges = [];
71
68
  allUpgradeEvents = [];
72
69
  assert(packageChangesLog.all.length > 0, '');
73
70
  dependencyStore = new DependencyStore(cwd);
74
- _context.next = 7;
71
+ _context2.next = 7;
75
72
  return dependencyStore.initialise(prevRunHash);
76
-
77
73
  case 7:
78
- dependencies = _context.sent;
74
+ dependencies = _context2.sent;
79
75
  i = 0;
80
-
81
76
  case 9:
82
77
  if (!(i < packageChangesLog.all.length)) {
83
- _context.next = 21;
78
+ _context2.next = 21;
84
79
  break;
85
80
  }
86
-
87
81
  item = packageChangesLog.all[i];
88
-
89
82
  if (allPackageChanges.length > 0) {
90
83
  dependencies = allPackageChanges[allPackageChanges.length - 1].akDeps;
91
84
  }
92
-
93
- _context.next = 14;
85
+ _context2.next = 14;
94
86
  return dependencyStore.update(item);
95
-
96
87
  case 14:
97
- newDependencies = _context.sent;
88
+ newDependencies = _context2.sent;
98
89
  packageChange = {
99
90
  date: new Date(item.date).toISOString(),
100
91
  akDeps: newDependencies
@@ -103,229 +94,218 @@ var getEventsFromHistory = /*#__PURE__*/function () {
103
94
  date: packageChange.date,
104
95
  commitHash: item.hash
105
96
  });
106
-
107
97
  if (upgradeEvents.length > 0) {
108
- allUpgradeEvents.push.apply(allUpgradeEvents, _toConsumableArray(upgradeEvents));
98
+ (_allUpgradeEvents = allUpgradeEvents).push.apply(_allUpgradeEvents, _toConsumableArray(upgradeEvents));
109
99
  allPackageChanges.push(packageChange);
110
100
  }
111
-
112
101
  case 18:
113
102
  i++;
114
- _context.next = 9;
103
+ _context2.next = 9;
115
104
  break;
116
-
117
105
  case 21:
118
- return _context.abrupt("return", {
106
+ _context2.next = 23;
107
+ return Promise.all(allUpgradeEvents.map( /*#__PURE__*/function () {
108
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(upgradeEvent) {
109
+ var _distTags$hotfix, _distTags$latest, _distTags$next;
110
+ var getPackageTags, distTags;
111
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
112
+ while (1) {
113
+ switch (_context.prev = _context.next) {
114
+ case 0:
115
+ _context.next = 2;
116
+ return getPackageVersionHistoryAndTags(upgradeEvent.dependencyName);
117
+ case 2:
118
+ getPackageTags = _context.sent;
119
+ distTags = getPackageTags['dist-tags'];
120
+ Object.keys(distTags).forEach(function (key) {
121
+ if (key.startsWith('rc')) {
122
+ upgradeEvent.rcTag = distTags[key];
123
+ }
124
+ });
125
+ upgradeEvent.hotfixTag = (_distTags$hotfix = distTags['hotfix']) !== null && _distTags$hotfix !== void 0 ? _distTags$hotfix : null;
126
+ upgradeEvent.latestTag = (_distTags$latest = distTags['latest']) !== null && _distTags$latest !== void 0 ? _distTags$latest : null;
127
+ upgradeEvent.nextTag = (_distTags$next = distTags['next']) !== null && _distTags$next !== void 0 ? _distTags$next : null;
128
+ return _context.abrupt("return", upgradeEvent);
129
+ case 9:
130
+ case "end":
131
+ return _context.stop();
132
+ }
133
+ }
134
+ }, _callee);
135
+ }));
136
+ return function (_x4) {
137
+ return _ref10.apply(this, arguments);
138
+ };
139
+ }()));
140
+ case 23:
141
+ allUpgradeEvents = _context2.sent;
142
+ return _context2.abrupt("return", {
119
143
  allPackageChanges: allPackageChanges,
120
144
  allUpgradeEvents: allUpgradeEvents
121
145
  });
122
-
123
- case 22:
146
+ case 25:
124
147
  case "end":
125
- return _context.stop();
148
+ return _context2.stop();
126
149
  }
127
150
  }
128
- }, _callee);
151
+ }, _callee2);
129
152
  }));
130
-
131
153
  return function getEventsFromHistory(_x, _x2, _x3) {
132
154
  return _ref9.apply(this, arguments);
133
155
  };
134
156
  }();
135
-
136
- function getSinceRef(_x4) {
157
+ function getSinceRef(_x5) {
137
158
  return _getSinceRef.apply(this, arguments);
138
159
  }
139
-
140
160
  function _getSinceRef() {
141
- _getSinceRef = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(flags) {
161
+ _getSinceRef = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(flags) {
142
162
  var meta, tag, tagExists;
143
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
163
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
144
164
  while (1) {
145
- switch (_context2.prev = _context2.next) {
165
+ switch (_context3.prev = _context3.next) {
146
166
  case 0:
147
167
  if (!flags.statlas) {
148
- _context2.next = 9;
168
+ _context3.next = 9;
149
169
  break;
150
170
  }
151
-
152
- _context2.next = 3;
171
+ _context3.next = 3;
153
172
  return statlas.getMeta(flags.product);
154
-
155
173
  case 3:
156
- meta = _context2.sent;
157
-
174
+ meta = _context3.sent;
158
175
  if (!(!meta || !meta.lastRunHash)) {
159
- _context2.next = 6;
176
+ _context3.next = 6;
160
177
  break;
161
178
  }
162
-
163
179
  throw new Error(chalk.red("Missing or invalid metadata file for ".concat(flags.product, ". Must use --reset for populating from start of history")));
164
-
165
180
  case 6:
166
- return _context2.abrupt("return", meta.lastRunHash);
167
-
181
+ return _context3.abrupt("return", meta.lastRunHash);
168
182
  case 9:
169
183
  tag = flags.tag || DEFAULT_TAG;
170
- _context2.next = 12;
184
+ _context3.next = 12;
171
185
  return refetchTag(tag);
172
-
173
186
  case 12:
174
- _context2.next = 14;
187
+ _context3.next = 14;
175
188
  return doesTagExist(tag);
176
-
177
189
  case 14:
178
- tagExists = _context2.sent;
179
-
190
+ tagExists = _context3.sent;
180
191
  if (tagExists) {
181
- _context2.next = 17;
192
+ _context3.next = 17;
182
193
  break;
183
194
  }
184
-
185
195
  throw new Error(chalk.red("Tag '".concat(tag, "' does not exist. Must use --reset for populating from start of history.")));
186
-
187
196
  case 17:
188
- return _context2.abrupt("return", tag);
189
-
197
+ return _context3.abrupt("return", tag);
190
198
  case 18:
191
199
  case "end":
192
- return _context2.stop();
200
+ return _context3.stop();
193
201
  }
194
202
  }
195
- }, _callee2);
203
+ }, _callee3);
196
204
  }));
197
205
  return _getSinceRef.apply(this, arguments);
198
206
  }
199
-
200
- export default function populateProduct(_x5) {
207
+ export default function populateProduct(_x6) {
201
208
  return _populateProduct.apply(this, arguments);
202
209
  }
203
-
204
210
  function _populateProduct() {
205
- _populateProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(flags) {
211
+ _populateProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(flags) {
206
212
  var cwd, sinceRef, log, _yield$getEventsFromH, allPackageChanges, allUpgradeEvents, csv, currentCommit;
207
-
208
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
213
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
209
214
  while (1) {
210
- switch (_context3.prev = _context3.next) {
215
+ switch (_context4.prev = _context4.next) {
211
216
  case 0:
212
217
  cwd = flags.cwd || process.cwd();
213
-
214
218
  if (!flags.reset) {
215
- _context3.next = 5;
219
+ _context4.next = 5;
216
220
  break;
217
221
  }
218
-
219
- _context3.t0 = undefined;
220
- _context3.next = 8;
222
+ _context4.t0 = undefined;
223
+ _context4.next = 8;
221
224
  break;
222
-
223
225
  case 5:
224
- _context3.next = 7;
226
+ _context4.next = 7;
225
227
  return getSinceRef(flags);
226
-
227
228
  case 7:
228
- _context3.t0 = _context3.sent;
229
-
229
+ _context4.t0 = _context4.sent;
230
230
  case 8:
231
- sinceRef = _context3.t0;
232
- _context3.next = 11;
231
+ sinceRef = _context4.t0;
232
+ _context4.next = 11;
233
233
  return getChangesSince(sinceRef);
234
-
235
234
  case 11:
236
- log = _context3.sent;
237
-
235
+ log = _context4.sent;
238
236
  if (!(log.all.length === 0)) {
239
- _context3.next = 15;
237
+ _context4.next = 15;
240
238
  break;
241
239
  }
242
-
243
240
  console.log("No package.json changes found since '".concat(sinceRef, "'."));
244
- return _context3.abrupt("return");
245
-
241
+ return _context4.abrupt("return");
246
242
  case 15:
247
- _context3.next = 17;
243
+ _context4.next = 17;
248
244
  return getEventsFromHistory(log, sinceRef, {
249
245
  cwd: cwd
250
246
  });
251
-
252
247
  case 17:
253
- _yield$getEventsFromH = _context3.sent;
248
+ _yield$getEventsFromH = _context4.sent;
254
249
  allPackageChanges = _yield$getEventsFromH.allPackageChanges;
255
250
  allUpgradeEvents = _yield$getEventsFromH.allUpgradeEvents;
256
-
257
251
  if (!flags.csv) {
258
- _context3.next = 24;
252
+ _context4.next = 24;
259
253
  break;
260
254
  }
261
-
262
255
  csv = generateCSV(allPackageChanges);
263
256
  console.log(csv);
264
- return _context3.abrupt("return");
265
-
257
+ return _context4.abrupt("return");
266
258
  case 24:
267
259
  if (!flags.dryRun) {
268
- _context3.next = 27;
260
+ _context4.next = 27;
269
261
  break;
270
262
  }
271
-
272
263
  console.log(JSON.stringify(allUpgradeEvents));
273
- return _context3.abrupt("return");
274
-
264
+ return _context4.abrupt("return");
275
265
  case 27:
276
266
  if (!(allUpgradeEvents.length > 0)) {
277
- _context3.next = 32;
267
+ _context4.next = 32;
278
268
  break;
279
269
  }
280
-
281
- _context3.next = 30;
270
+ _context4.next = 30;
282
271
  return sendAnalytics(allUpgradeEvents, {
283
272
  dev: flags.dev,
284
273
  limit: flags.limit,
285
274
  product: flags.product,
286
275
  skipPrompt: !flags.interactive
287
276
  });
288
-
289
277
  case 30:
290
- _context3.next = 33;
278
+ _context4.next = 33;
291
279
  break;
292
-
293
280
  case 32:
294
281
  console.log("Found no AK dependency changes since last run from ref \"".concat(sinceRef, "\"'"));
295
-
296
282
  case 33:
297
283
  if (!flags.statlas) {
298
- _context3.next = 42;
284
+ _context4.next = 42;
299
285
  break;
300
286
  }
301
-
302
- _context3.next = 36;
287
+ _context4.next = 36;
303
288
  return getHash('HEAD');
304
-
305
289
  case 36:
306
- currentCommit = _context3.sent;
307
- _context3.next = 39;
290
+ currentCommit = _context4.sent;
291
+ _context4.next = 39;
308
292
  return statlas.uploadMeta(flags.product, currentCommit);
309
-
310
293
  case 39:
311
294
  console.log('Finished');
312
- _context3.next = 46;
295
+ _context4.next = 46;
313
296
  break;
314
-
315
297
  case 42:
316
298
  console.log('Updating tag to current commit...');
317
- _context3.next = 45;
299
+ _context4.next = 45;
318
300
  return tagCommit(DEFAULT_TAG);
319
-
320
301
  case 45:
321
302
  console.log("Finished. Run 'git push origin tag ".concat(sinceRef, "'."));
322
-
323
303
  case 46:
324
304
  case "end":
325
- return _context3.stop();
305
+ return _context4.stop();
326
306
  }
327
307
  }
328
- }, _callee3);
308
+ }, _callee4);
329
309
  }));
330
310
  return _populateProduct.apply(this, arguments);
331
311
  }
@@ -1,5 +1,4 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
-
3
2
  /** Generates a CSV of product package changes over time */
4
3
  export var generateCSV = function generateCSV(packageChanges) {
5
4
  var csvData = [['']];
@@ -8,22 +7,19 @@ export var generateCSV = function generateCSV(packageChanges) {
8
7
  var currentRow = firstColumn.push(packageChange.date) - 1;
9
8
  Object.entries(packageChange.akDeps).forEach(function (_ref) {
10
9
  var _ref2 = _slicedToArray(_ref, 2),
11
- name = _ref2[0],
12
- version = _ref2[1].version;
13
-
10
+ name = _ref2[0],
11
+ version = _ref2[1].version;
14
12
  var depColumnIndex = csvData.findIndex(function (item) {
15
13
  return item[0] === name;
16
14
  });
17
-
18
15
  if (depColumnIndex === -1) {
19
16
  depColumnIndex = csvData.push([name]) - 1;
20
- } // console.log(csvData)
21
-
17
+ }
22
18
 
19
+ // console.log(csvData)
23
20
  csvData[depColumnIndex][currentRow] = version;
24
21
  });
25
22
  });
26
-
27
23
  for (var i = 0; i < csvData.length; i++) {
28
24
  for (var j = 0; j < csvData.length; j++) {
29
25
  if (typeof csvData[i][j] !== 'string') {
@@ -31,23 +27,18 @@ export var generateCSV = function generateCSV(packageChanges) {
31
27
  csvData[i][j] = '';
32
28
  }
33
29
  }
34
-
35
30
  if (i !== 0 && csvData[0].length < csvData[i].length) {}
36
31
  }
37
-
38
32
  var csvStrings = [];
39
33
  csvData.forEach(function (column) {
40
34
  if (!column) {
41
35
  return;
42
36
  }
43
-
44
37
  for (var rowIndex = 0; rowIndex < csvData[0].length; rowIndex++) {
45
38
  var rowItem = column[rowIndex] || '';
46
-
47
39
  if (typeof csvStrings[rowIndex] !== 'string') {
48
40
  csvStrings[rowIndex] = '';
49
41
  }
50
-
51
42
  csvStrings[rowIndex] += "\"".concat(rowItem, "\",");
52
43
  }
53
44
  });
@@ -1,20 +1,15 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
-
5
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
-
7
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
-
9
- import chalk from 'chalk'; // @ts-ignore
10
-
6
+ import chalk from 'chalk';
7
+ // @ts-ignore
11
8
  import inquirer from 'inquirer';
12
9
  import semver from 'semver';
13
10
  /* eslint-disable-next-line import/no-unresolved */
14
-
15
11
  import { analyticsClient } from '@atlassiansox/analytics-node-client';
16
12
  import { version as packageVersion } from '../version.json';
17
-
18
13
  function getUpgradeType(version, previousVersion) {
19
14
  if (previousVersion == null && version != null) {
20
15
  return 'add';
@@ -23,12 +18,10 @@ function getUpgradeType(version, previousVersion) {
23
18
  } else if (previousVersion != null && version != null && previousVersion !== version) {
24
19
  var coercedPrevious = semver.coerce(previousVersion);
25
20
  var coercedNew = semver.coerce(version);
26
-
27
21
  if (coercedNew == null) {
28
22
  console.error("Found invalid version \"".concat(version, "\", skipping"));
29
23
  return null;
30
24
  }
31
-
32
25
  if (coercedPrevious != null && semver.lt(coercedNew, coercedPrevious)) {
33
26
  return 'downgrade';
34
27
  } else {
@@ -38,41 +31,40 @@ function getUpgradeType(version, previousVersion) {
38
31
  return null;
39
32
  }
40
33
  }
41
-
42
34
  function getUpgradeSubType(version, previousVersion) {
43
35
  var upgradeSubType = null;
44
-
45
36
  if (version == null || previousVersion == null) {
46
37
  return upgradeSubType;
47
38
  }
48
-
49
39
  var parsedOld = semver.coerce(previousVersion);
50
40
  var parsedNew = semver.coerce(version);
51
-
52
41
  if (parsedOld && parsedNew) {
53
42
  upgradeSubType = semver.diff(parsedOld.version, parsedNew.version);
54
43
  }
55
-
56
44
  return upgradeSubType;
57
45
  }
58
-
59
46
  export function createUpgradeEvent(name, version, previousVersion, date) {
47
+ var _optionalArgs$tags, _ref, _tags$next, _tags$hotfix, _ref2;
60
48
  var optionalArgs = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
61
-
62
49
  if (Number.isNaN(Date.parse(date))) {
63
50
  throw new Error("Invalid date: '".concat(date, "'"));
64
51
  }
65
-
66
52
  var upgradeType = getUpgradeType(version, previousVersion);
67
-
68
53
  if (!upgradeType) {
69
54
  // Not an upgrade for this dependency, return null
70
55
  return null;
71
56
  }
72
-
73
57
  var upgradeSubType = getUpgradeSubType(version, previousVersion);
74
58
  var eventVersion = upgradeType !== 'remove' ? version : previousVersion;
75
59
  var parsedVersion = semver.coerce(eventVersion);
60
+ var rcKey = null;
61
+ var tags = (_optionalArgs$tags = optionalArgs === null || optionalArgs === void 0 ? void 0 : optionalArgs.tags) !== null && _optionalArgs$tags !== void 0 ? _optionalArgs$tags : {};
62
+ Object.keys(tags).forEach(function (key) {
63
+ if (key.startsWith('rc')) {
64
+ rcKey = key;
65
+ return;
66
+ }
67
+ });
76
68
  return _objectSpread({
77
69
  cliVersion: packageVersion,
78
70
  dependencyName: name,
@@ -82,33 +74,34 @@ export function createUpgradeEvent(name, version, previousVersion, date) {
82
74
  patch: parsedVersion ? "".concat(parsedVersion.patch) : null,
83
75
  date: new Date(date).toISOString(),
84
76
  upgradeType: upgradeType,
85
- upgradeSubType: upgradeSubType
77
+ upgradeSubType: upgradeSubType,
78
+ latestTag: (_ref = tags && tags['latest']) !== null && _ref !== void 0 ? _ref : null,
79
+ nextTag: (_tags$next = tags['next']) !== null && _tags$next !== void 0 ? _tags$next : null,
80
+ hotfixTag: (_tags$hotfix = tags['hotfix']) !== null && _tags$hotfix !== void 0 ? _tags$hotfix : null,
81
+ rcTag: (_ref2 = rcKey && tags[rcKey]) !== null && _ref2 !== void 0 ? _ref2 : null
86
82
  }, optionalArgs);
87
83
  }
88
84
  export function sendAnalytics(_x, _x2) {
89
85
  return _sendAnalytics.apply(this, arguments);
90
86
  }
91
-
92
87
  function _sendAnalytics() {
93
- _sendAnalytics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(analyticsEvents, _ref) {
88
+ _sendAnalytics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(analyticsEvents, _ref3) {
94
89
  var dev, limit, product, skipPrompt, analyticsEnv, eventsToSend, client, answers, promises;
95
90
  return _regeneratorRuntime.wrap(function _callee$(_context) {
96
91
  while (1) {
97
92
  switch (_context.prev = _context.next) {
98
93
  case 0:
99
- dev = _ref.dev, limit = _ref.limit, product = _ref.product, skipPrompt = _ref.skipPrompt;
94
+ dev = _ref3.dev, limit = _ref3.limit, product = _ref3.product, skipPrompt = _ref3.skipPrompt;
100
95
  analyticsEnv = dev ? 'dev' : 'prod';
101
96
  eventsToSend = limit != null ? analyticsEvents.slice(0, limit) : analyticsEvents;
102
97
  client = analyticsClient({
103
98
  env: dev ? 'dev' : 'prod',
104
99
  product: product
105
100
  });
106
-
107
101
  if (skipPrompt) {
108
102
  _context.next = 9;
109
103
  break;
110
104
  }
111
-
112
105
  _context.next = 7;
113
106
  return inquirer.prompt([{
114
107
  type: 'confirm',
@@ -116,15 +109,12 @@ function _sendAnalytics() {
116
109
  message: "Are you sure you want to send ".concat(eventsToSend.length, " historical analytics events to '").concat(analyticsEnv, "' env for product '").concat(product, "?"),
117
110
  default: false
118
111
  }]);
119
-
120
112
  case 7:
121
113
  answers = _context.sent;
122
-
123
114
  if (!answers.continue) {
124
115
  console.log('Aborting');
125
116
  process.exit(0);
126
117
  }
127
-
128
118
  case 9:
129
119
  _context.prev = 9;
130
120
  _context.next = 12;
@@ -142,20 +132,17 @@ function _sendAnalytics() {
142
132
  }
143
133
  });
144
134
  }));
145
-
146
135
  case 12:
147
136
  promises = _context.sent;
148
137
  console.log(chalk.green("Sent ".concat(promises.length, " dependency version upgrade analytics events")));
149
138
  _context.next = 21;
150
139
  break;
151
-
152
140
  case 16:
153
141
  _context.prev = 16;
154
142
  _context.t0 = _context["catch"](9);
155
143
  console.error(chalk.red('Sending analytics failed'));
156
144
  console.error(_context.t0);
157
145
  process.exit(1);
158
-
159
146
  case 21:
160
147
  case "end":
161
148
  return _context.stop();
@@ -2,6 +2,5 @@ export default function (name) {
2
2
  if (!process.env.hasOwnProperty(name) || !process.env[name] || typeof process.env[name] !== 'string') {
3
3
  return null;
4
4
  }
5
-
6
5
  return process.env[name];
7
6
  }
@@ -1,5 +1,6 @@
1
- import { exec } from 'child_process'; // Lock files tend to be huge
1
+ import { exec } from 'child_process';
2
2
 
3
+ // Lock files tend to be huge
3
4
  var FiveMBBuffer = 1024 * 5000;
4
5
  export default function getFileHistoryFromGit(fileName) {
5
6
  return new Promise(function (resolve, reject) {
@@ -9,11 +10,9 @@ export default function getFileHistoryFromGit(fileName) {
9
10
  if (error) {
10
11
  reject(error);
11
12
  }
12
-
13
13
  if (stderr) {
14
14
  reject(stderr);
15
15
  }
16
-
17
16
  resolve(stdout);
18
17
  });
19
18
  });