@atlaskit/dependency-version-analytics 1.2.0 → 1.2.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/dependency-version-analytics
2
2
 
3
+ ## 1.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2d3cc41d7d6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2d3cc41d7d6) - Removed logic to fetch tags metadata during product flow.
8
+
9
+ ## 1.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`7873dd15ba2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7873dd15ba2) - Updated version analytics events to exclude tags
14
+
3
15
  ## 1.2.0
4
16
 
5
17
  ### Minor Changes
@@ -19,9 +19,8 @@ const createAnalyticsEvents = (packageName, packageVersionHistoryAndTags, since)
19
19
  }
20
20
  const previousVersion = sortedPackageVersionHistory[i - 1] && sortedPackageVersionHistory[i - 1][0];
21
21
  return (0, _analytics.createUpgradeEvent)(packageName, version, previousVersion, time, {
22
- historical: true,
23
- tags
24
- });
22
+ historical: true
23
+ }, tags);
25
24
  }).filter(e => e != null);
26
25
  return upgradeEvents;
27
26
  };
@@ -13,7 +13,6 @@ var statlas = _interopRequireWildcard(require("../../util/statlas"));
13
13
  var _generateCsv = require("./util/generate-csv");
14
14
  var _assert = require("../../util/assert");
15
15
  var _dependencyStore = require("./lib/dependency-store");
16
- var _getPackageVersionHistory = _interopRequireDefault(require("../../util/get-package-version-history"));
17
16
  var _allowedScopes = require("./util/allowed-scopes");
18
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -78,20 +77,6 @@ const getEventsFromHistory = async (packageChangesLog, prevRunHash, {
78
77
  allPackageChanges.push(packageChange);
79
78
  }
80
79
  }
81
- // add dist-tags to upgrade event
82
- allUpgradeEvents = await Promise.all(allUpgradeEvents.map(async upgradeEvent => {
83
- const getPackageTags = await (0, _getPackageVersionHistory.default)(upgradeEvent.dependencyName);
84
- const distTags = getPackageTags['dist-tags'];
85
- Object.keys(distTags).forEach(key => {
86
- if (key.startsWith('rc')) {
87
- upgradeEvent.rcTag = distTags[key];
88
- }
89
- });
90
- upgradeEvent.hotfixTag = distTags['hotfix'] ?? null;
91
- upgradeEvent.latestTag = distTags['latest'] ?? null;
92
- upgradeEvent.nextTag = distTags['next'] ?? null;
93
- return upgradeEvent;
94
- }));
95
80
  return {
96
81
  allPackageChanges,
97
82
  allUpgradeEvents
@@ -48,7 +48,9 @@ function getUpgradeSubType(version, previousVersion) {
48
48
  }
49
49
  return upgradeSubType;
50
50
  }
51
- function createUpgradeEvent(name, version, previousVersion, date, optionalArgs = {}) {
51
+
52
+ // optionalEventArgs will be included within the event.
53
+ function createUpgradeEvent(name, version, previousVersion, date, optionalEventArgs = {}, tags = {}) {
52
54
  if (Number.isNaN(Date.parse(date))) {
53
55
  throw new Error(`Invalid date: '${date}'`);
54
56
  }
@@ -61,7 +63,6 @@ function createUpgradeEvent(name, version, previousVersion, date, optionalArgs =
61
63
  const eventVersion = upgradeType !== 'remove' ? version : previousVersion;
62
64
  const parsedVersion = _semver.default.coerce(eventVersion);
63
65
  let rcKey = null;
64
- const tags = (optionalArgs === null || optionalArgs === void 0 ? void 0 : optionalArgs.tags) ?? {};
65
66
  Object.keys(tags).forEach(key => {
66
67
  if (key.startsWith('rc')) {
67
68
  rcKey = key;
@@ -82,7 +83,7 @@ function createUpgradeEvent(name, version, previousVersion, date, optionalArgs =
82
83
  nextTag: tags['next'] ?? null,
83
84
  hotfixTag: tags['hotfix'] ?? null,
84
85
  rcTag: (rcKey && tags[rcKey]) ?? null,
85
- ...optionalArgs
86
+ ...optionalEventArgs
86
87
  };
87
88
  }
88
89
  async function sendAnalytics(analyticsEvents, {
@@ -9,9 +9,11 @@ function getPackageVersionHistoryAndTags(packageName) {
9
9
  return new Promise((resolve, reject) => {
10
10
  (0, _child_process.exec)(`yarn info ${packageName} --json`, (error, stdout, stderr) => {
11
11
  if (error) {
12
+ console.error(`error: Unable to execute yarn info for ${packageName}`);
12
13
  reject(error);
13
14
  }
14
15
  if (stderr) {
16
+ console.error(`stderr: Unable to execute yarn info for ${packageName}`);
15
17
  reject(stderr);
16
18
  }
17
19
  let json;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dependency-version-analytics",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -14,15 +14,12 @@ const debug = debugModule('atlaskit:dependency');
14
14
  * Stores the state of atlaskit dependencies in a repository
15
15
  */
16
16
  export class DependencyStore {
17
- /** Mapping of dependency names to arrays of unique dependency type + versions */
18
-
19
- /** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
20
-
21
- /** Set of workspace globs. Used to verify that a package.json is a valid workspace */
22
-
23
17
  constructor(cwd = process.cwd(), supportedScopes) {
18
+ /** Mapping of dependency names to arrays of unique dependency type + versions */
24
19
  _defineProperty(this, "dependencies", {});
20
+ /** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
25
21
  _defineProperty(this, "workspaces", {});
22
+ /** Set of workspace globs. Used to verify that a package.json is a valid workspace */
26
23
  _defineProperty(this, "workspaceGlobs", new Set());
27
24
  _defineProperty(this, "initialised", false);
28
25
  this.cwd = cwd;
@@ -12,9 +12,8 @@ const createAnalyticsEvents = (packageName, packageVersionHistoryAndTags, since)
12
12
  }
13
13
  const previousVersion = sortedPackageVersionHistory[i - 1] && sortedPackageVersionHistory[i - 1][0];
14
14
  return createUpgradeEvent(packageName, version, previousVersion, time, {
15
- historical: true,
16
- tags
17
- });
15
+ historical: true
16
+ }, tags);
18
17
  }).filter(e => e != null);
19
18
  return upgradeEvents;
20
19
  };
@@ -6,7 +6,6 @@ import * as statlas from '../../util/statlas';
6
6
  import { generateCSV } from './util/generate-csv';
7
7
  import { assert } from '../../util/assert';
8
8
  import { DependencyStore } from './lib/dependency-store';
9
- import getPackageVersionHistoryAndTags from '../../util/get-package-version-history';
10
9
  import { getSupportedScopes } from './util/allowed-scopes';
11
10
  const getUpgradeEventsFromPkgChange = (oldDeps, newDeps, {
12
11
  date,
@@ -69,21 +68,6 @@ const getEventsFromHistory = async (packageChangesLog, prevRunHash, {
69
68
  allPackageChanges.push(packageChange);
70
69
  }
71
70
  }
72
- // add dist-tags to upgrade event
73
- allUpgradeEvents = await Promise.all(allUpgradeEvents.map(async upgradeEvent => {
74
- var _distTags$hotfix, _distTags$latest, _distTags$next;
75
- const getPackageTags = await getPackageVersionHistoryAndTags(upgradeEvent.dependencyName);
76
- const distTags = getPackageTags['dist-tags'];
77
- Object.keys(distTags).forEach(key => {
78
- if (key.startsWith('rc')) {
79
- upgradeEvent.rcTag = distTags[key];
80
- }
81
- });
82
- upgradeEvent.hotfixTag = (_distTags$hotfix = distTags['hotfix']) !== null && _distTags$hotfix !== void 0 ? _distTags$hotfix : null;
83
- upgradeEvent.latestTag = (_distTags$latest = distTags['latest']) !== null && _distTags$latest !== void 0 ? _distTags$latest : null;
84
- upgradeEvent.nextTag = (_distTags$next = distTags['next']) !== null && _distTags$next !== void 0 ? _distTags$next : null;
85
- return upgradeEvent;
86
- }));
87
71
  return {
88
72
  allPackageChanges,
89
73
  allUpgradeEvents
@@ -38,8 +38,10 @@ function getUpgradeSubType(version, previousVersion) {
38
38
  }
39
39
  return upgradeSubType;
40
40
  }
41
- export function createUpgradeEvent(name, version, previousVersion, date, optionalArgs = {}) {
42
- var _optionalArgs$tags, _ref, _tags$next, _tags$hotfix, _ref2;
41
+
42
+ // optionalEventArgs will be included within the event.
43
+ export function createUpgradeEvent(name, version, previousVersion, date, optionalEventArgs = {}, tags = {}) {
44
+ var _ref, _tags$next, _tags$hotfix, _ref2;
43
45
  if (Number.isNaN(Date.parse(date))) {
44
46
  throw new Error(`Invalid date: '${date}'`);
45
47
  }
@@ -52,7 +54,6 @@ export function createUpgradeEvent(name, version, previousVersion, date, optiona
52
54
  const eventVersion = upgradeType !== 'remove' ? version : previousVersion;
53
55
  const parsedVersion = semver.coerce(eventVersion);
54
56
  let rcKey = null;
55
- const tags = (_optionalArgs$tags = optionalArgs === null || optionalArgs === void 0 ? void 0 : optionalArgs.tags) !== null && _optionalArgs$tags !== void 0 ? _optionalArgs$tags : {};
56
57
  Object.keys(tags).forEach(key => {
57
58
  if (key.startsWith('rc')) {
58
59
  rcKey = key;
@@ -73,7 +74,7 @@ export function createUpgradeEvent(name, version, previousVersion, date, optiona
73
74
  nextTag: (_tags$next = tags['next']) !== null && _tags$next !== void 0 ? _tags$next : null,
74
75
  hotfixTag: (_tags$hotfix = tags['hotfix']) !== null && _tags$hotfix !== void 0 ? _tags$hotfix : null,
75
76
  rcTag: (_ref2 = rcKey && tags[rcKey]) !== null && _ref2 !== void 0 ? _ref2 : null,
76
- ...optionalArgs
77
+ ...optionalEventArgs
77
78
  };
78
79
  }
79
80
  export async function sendAnalytics(analyticsEvents, {
@@ -3,9 +3,11 @@ export default function getPackageVersionHistoryAndTags(packageName) {
3
3
  return new Promise((resolve, reject) => {
4
4
  exec(`yarn info ${packageName} --json`, (error, stdout, stderr) => {
5
5
  if (error) {
6
+ console.error(`error: Unable to execute yarn info for ${packageName}`);
6
7
  reject(error);
7
8
  }
8
9
  if (stderr) {
10
+ console.error(`stderr: Unable to execute yarn info for ${packageName}`);
9
11
  reject(stderr);
10
12
  }
11
13
  let json;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dependency-version-analytics",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "sideEffects": false
5
5
  }