@atlaskit/dependency-version-analytics 1.2.2 → 1.4.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 (42) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/cli.js +6 -1
  3. package/dist/cjs/commands/populate-historic-data/lib/dependency-store.js +3 -2
  4. package/dist/cjs/commands/populate-historic-data/product.js +5 -3
  5. package/dist/cjs/commands/populate-historic-data/util/allowed-scopes.js +15 -2
  6. package/dist/cjs/version.json +1 -1
  7. package/dist/es2019/cli.js +6 -1
  8. package/dist/es2019/commands/populate-historic-data/lib/dependency-store.js +4 -3
  9. package/dist/es2019/commands/populate-historic-data/product.js +5 -3
  10. package/dist/es2019/commands/populate-historic-data/util/allowed-scopes.js +12 -0
  11. package/dist/es2019/version.json +1 -1
  12. package/dist/esm/cli.js +6 -2
  13. package/dist/esm/commands/populate-historic-data/lib/dependency-store.js +4 -2
  14. package/dist/esm/commands/populate-historic-data/product.js +33 -31
  15. package/dist/esm/commands/populate-historic-data/util/allowed-scopes.js +14 -0
  16. package/dist/esm/version.json +1 -1
  17. package/dist/types/commands/populate-historic-data/lib/dependency-store.d.ts +2 -1
  18. package/dist/types/commands/populate-historic-data/product.d.ts +1 -0
  19. package/dist/types/commands/populate-historic-data/util/allowed-scopes.d.ts +6 -0
  20. package/dist/types-ts4.0/cli.d.ts +4 -0
  21. package/dist/types-ts4.0/commands/populate-historic-data/__fixtures__/git.d.ts +2 -0
  22. package/dist/types-ts4.0/commands/populate-historic-data/index.d.ts +2 -0
  23. package/dist/types-ts4.0/commands/populate-historic-data/lib/dependency-store.d.ts +41 -0
  24. package/dist/types-ts4.0/commands/populate-historic-data/package.d.ts +7 -0
  25. package/dist/types-ts4.0/commands/populate-historic-data/product.d.ts +10 -0
  26. package/dist/types-ts4.0/commands/populate-historic-data/types.d.ts +19 -0
  27. package/dist/types-ts4.0/commands/populate-historic-data/util/allowed-scopes.d.ts +8 -0
  28. package/dist/types-ts4.0/commands/populate-historic-data/util/generate-csv.d.ts +3 -0
  29. package/dist/types-ts4.0/constants.d.ts +19 -0
  30. package/dist/types-ts4.0/index.d.ts +3 -0
  31. package/dist/types-ts4.0/types.d.ts +25 -0
  32. package/dist/types-ts4.0/util/analytics.d.ts +12 -0
  33. package/dist/types-ts4.0/util/assert.d.ts +2 -0
  34. package/dist/types-ts4.0/util/env-with-guard.d.ts +1 -0
  35. package/dist/types-ts4.0/util/get-file-history-from-git.d.ts +1 -0
  36. package/dist/types-ts4.0/util/get-package-version-history.d.ts +8 -0
  37. package/dist/types-ts4.0/util/git.d.ts +14 -0
  38. package/dist/types-ts4.0/util/statlas.d.ts +5 -0
  39. package/dist/types-ts4.0/util/yarn.d.ts +2 -0
  40. package/package.json +1 -1
  41. package/report.api.md +1 -0
  42. package/tmp/api-report-tmp.d.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/dependency-version-analytics
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`34c045e90ed`](https://bitbucket.org/atlassian/atlassian-frontend/commits/34c045e90ed) - Added supportedPackages to product flow
8
+
9
+ ## 1.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip minor dependency bump
14
+
3
15
  ## 1.2.2
4
16
 
5
17
  ### Patch Changes
package/dist/cjs/cli.js CHANGED
@@ -31,6 +31,7 @@ ${_chalk.default.yellow.bold('[populate-product] <product>')}
31
31
  ${_chalk.default.yellow('--reset')} Reset change detection to detect changes from the beginning of time
32
32
  ${_chalk.default.yellow('--tag')} Specify a different tag to mark when the tool was last run
33
33
  ${_chalk.default.yellow('--statlas')} Use statlas rather than git tags for storing and sourcing last run info
34
+ ${_chalk.default.yellow('--supported-packages')} List of supported packages in JSON format
34
35
 
35
36
  ${_chalk.default.green('Examples')}
36
37
  ${_chalk.default.dim('$ atlaskit-version-analytics populate-product jira')}
@@ -80,6 +81,9 @@ function run({
80
81
  },
81
82
  includeRestrictedScopes: {
82
83
  type: 'boolean'
84
+ },
85
+ supportedPackages: {
86
+ type: 'string'
83
87
  }
84
88
  }
85
89
  });
@@ -101,7 +105,8 @@ function run({
101
105
  reset: cli.flags.reset || false,
102
106
  statlas: cli.flags.statlas,
103
107
  tag: cli.flags.tag,
104
- includeRestrictedScopes: cli.flags.includeRestrictedScopes || false
108
+ includeRestrictedScopes: cli.flags.includeRestrictedScopes || false,
109
+ supportedPackages: cli.flags.supportedPackages
105
110
  });
106
111
  } else if (command === 'populate-package') {
107
112
  const pkg = inputs[0];
@@ -27,9 +27,10 @@ class DependencyStore {
27
27
  /** Set of workspace globs. Used to verify that a package.json is a valid workspace */
28
28
  workspaceGlobs = new Set();
29
29
  initialised = false;
30
- constructor(cwd = process.cwd(), supportedScopes) {
30
+ constructor(cwd = process.cwd(), supportedScopes, supportedPackages) {
31
31
  this.cwd = cwd;
32
32
  this.supportedScopes = supportedScopes;
33
+ this.supportedPackages = supportedPackages;
33
34
  }
34
35
 
35
36
  /** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
@@ -211,7 +212,7 @@ class DependencyStore {
211
212
  getSupportedDependencies(depMap, type) {
212
213
  return fromEntries(Object.entries(depMap).filter(
213
214
  // Ignore suffixed `--next` deps in jira used for independent upgrades
214
- ([name]) => (0, _allowedScopes.isPackageFromSupportedScopes)(name, this.supportedScopes) && !name.endsWith('--next')).map(([name, version]) => [DependencyStore.transformDepName(name), {
215
+ ([name]) => (0, _allowedScopes.isPackageSupported)(name, this.supportedPackages, this.supportedScopes) && !name.endsWith('--next')).map(([name, version]) => [DependencyStore.transformDepName(name), {
215
216
  version: DependencyStore.transformDepVersion(version),
216
217
  type
217
218
  }]));
@@ -52,11 +52,11 @@ const getUpgradeEventsFromPkgChange = (oldDeps, newDeps, {
52
52
  };
53
53
  const getEventsFromHistory = async (packageChangesLog, prevRunHash, {
54
54
  cwd
55
- }, supportedScopes) => {
55
+ }, supportedScopes, supportedPackages) => {
56
56
  const allPackageChanges = [];
57
57
  let allUpgradeEvents = [];
58
58
  (0, _assert.assert)(packageChangesLog.all.length > 0, '');
59
- let dependencyStore = new _dependencyStore.DependencyStore(cwd, supportedScopes);
59
+ let dependencyStore = new _dependencyStore.DependencyStore(cwd, supportedScopes, supportedPackages);
60
60
  let dependencies = await dependencyStore.initialise(prevRunHash);
61
61
  for (let i = 0; i < packageChangesLog.all.length; i++) {
62
62
  let item = packageChangesLog.all[i];
@@ -104,6 +104,8 @@ async function populateProduct(flags) {
104
104
  const sinceRef = flags.reset ? undefined : await getSinceRef(flags);
105
105
  const log = await (0, _git.getChangesSince)(sinceRef);
106
106
  const supportedScopes = (0, _allowedScopes.getSupportedScopes)(flags.includeRestrictedScopes);
107
+ const supportedPackages = flags.supportedPackages ? JSON.parse(flags.supportedPackages) : [];
108
+ console.log(`Supported packages ${supportedPackages.length} and scopes ${supportedScopes}`);
107
109
  if (log.all.length === 0) {
108
110
  console.log(`No package.json changes found since '${sinceRef}'.`);
109
111
  return;
@@ -113,7 +115,7 @@ async function populateProduct(flags) {
113
115
  allUpgradeEvents
114
116
  } = await getEventsFromHistory(log, sinceRef, {
115
117
  cwd
116
- }, supportedScopes);
118
+ }, supportedScopes, supportedPackages);
117
119
  if (flags.csv) {
118
120
  const csv = (0, _generateCsv.generateCSV)(allPackageChanges);
119
121
  console.log(csv);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isPackageFromSupportedScopes = exports.getSupportedScopes = void 0;
6
+ exports.isPackageSupported = exports.isPackageFromSupportedScopes = exports.getSupportedScopes = void 0;
7
7
  const defaultScopes = ['@atlaskit', '@atlassian', '@atlassiansox'];
8
8
  const getSupportedScopes = (enableNonAtlaskitPackages = false) => {
9
9
  return enableNonAtlaskitPackages ? defaultScopes : ['@atlaskit'];
@@ -12,4 +12,17 @@ exports.getSupportedScopes = getSupportedScopes;
12
12
  const isPackageFromSupportedScopes = (packageName, supportedScopes = defaultScopes) => {
13
13
  return supportedScopes.some(scope => packageName.startsWith(scope));
14
14
  };
15
- exports.isPackageFromSupportedScopes = isPackageFromSupportedScopes;
15
+
16
+ /**
17
+ *
18
+ * Checks if the package is from supported scope
19
+ * and if so, the package is also from supported package list.
20
+ */
21
+ exports.isPackageFromSupportedScopes = isPackageFromSupportedScopes;
22
+ const isPackageSupported = (packageName, supportedPackages = [], supportedScopes = defaultScopes) => {
23
+ if (isPackageFromSupportedScopes(packageName, supportedScopes)) {
24
+ return supportedPackages.length ? supportedPackages.indexOf(packageName) >= 0 : true;
25
+ }
26
+ return false;
27
+ };
28
+ exports.isPackageSupported = isPackageSupported;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dependency-version-analytics",
3
- "version": "1.2.2",
3
+ "version": "1.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -25,6 +25,7 @@ ${chalk.yellow.bold('[populate-product] <product>')}
25
25
  ${chalk.yellow('--reset')} Reset change detection to detect changes from the beginning of time
26
26
  ${chalk.yellow('--tag')} Specify a different tag to mark when the tool was last run
27
27
  ${chalk.yellow('--statlas')} Use statlas rather than git tags for storing and sourcing last run info
28
+ ${chalk.yellow('--supported-packages')} List of supported packages in JSON format
28
29
 
29
30
  ${chalk.green('Examples')}
30
31
  ${chalk.dim('$ atlaskit-version-analytics populate-product jira')}
@@ -74,6 +75,9 @@ export function run({
74
75
  },
75
76
  includeRestrictedScopes: {
76
77
  type: 'boolean'
78
+ },
79
+ supportedPackages: {
80
+ type: 'string'
77
81
  }
78
82
  }
79
83
  });
@@ -95,7 +99,8 @@ export function run({
95
99
  reset: cli.flags.reset || false,
96
100
  statlas: cli.flags.statlas,
97
101
  tag: cli.flags.tag,
98
- includeRestrictedScopes: cli.flags.includeRestrictedScopes || false
102
+ includeRestrictedScopes: cli.flags.includeRestrictedScopes || false,
103
+ supportedPackages: cli.flags.supportedPackages
99
104
  });
100
105
  } else if (command === 'populate-package') {
101
106
  const pkg = inputs[0];
@@ -8,13 +8,13 @@ import { showFile } from '../../../util/git';
8
8
  import { DEP_TYPES } from '../../../constants';
9
9
  import { assert } from '../../../util/assert';
10
10
  import micromatch from 'micromatch';
11
- import { isPackageFromSupportedScopes } from '../util/allowed-scopes';
11
+ import { isPackageSupported } from '../util/allowed-scopes';
12
12
  const debug = debugModule('atlaskit:dependency');
13
13
  /**
14
14
  * Stores the state of atlaskit dependencies in a repository
15
15
  */
16
16
  export class DependencyStore {
17
- constructor(cwd = process.cwd(), supportedScopes) {
17
+ constructor(cwd = process.cwd(), supportedScopes, supportedPackages) {
18
18
  /** Mapping of dependency names to arrays of unique dependency type + versions */
19
19
  _defineProperty(this, "dependencies", {});
20
20
  /** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
@@ -24,6 +24,7 @@ export class DependencyStore {
24
24
  _defineProperty(this, "initialised", false);
25
25
  this.cwd = cwd;
26
26
  this.supportedScopes = supportedScopes;
27
+ this.supportedPackages = supportedPackages;
27
28
  }
28
29
 
29
30
  /** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
@@ -205,7 +206,7 @@ export class DependencyStore {
205
206
  getSupportedDependencies(depMap, type) {
206
207
  return fromEntries(Object.entries(depMap).filter(
207
208
  // Ignore suffixed `--next` deps in jira used for independent upgrades
208
- ([name]) => isPackageFromSupportedScopes(name, this.supportedScopes) && !name.endsWith('--next')).map(([name, version]) => [DependencyStore.transformDepName(name), {
209
+ ([name]) => isPackageSupported(name, this.supportedPackages, this.supportedScopes) && !name.endsWith('--next')).map(([name, version]) => [DependencyStore.transformDepName(name), {
209
210
  version: DependencyStore.transformDepVersion(version),
210
211
  type
211
212
  }]));
@@ -43,11 +43,11 @@ const getUpgradeEventsFromPkgChange = (oldDeps, newDeps, {
43
43
  };
44
44
  const getEventsFromHistory = async (packageChangesLog, prevRunHash, {
45
45
  cwd
46
- }, supportedScopes) => {
46
+ }, supportedScopes, supportedPackages) => {
47
47
  const allPackageChanges = [];
48
48
  let allUpgradeEvents = [];
49
49
  assert(packageChangesLog.all.length > 0, '');
50
- let dependencyStore = new DependencyStore(cwd, supportedScopes);
50
+ let dependencyStore = new DependencyStore(cwd, supportedScopes, supportedPackages);
51
51
  let dependencies = await dependencyStore.initialise(prevRunHash);
52
52
  for (let i = 0; i < packageChangesLog.all.length; i++) {
53
53
  let item = packageChangesLog.all[i];
@@ -95,6 +95,8 @@ export default async function populateProduct(flags) {
95
95
  const sinceRef = flags.reset ? undefined : await getSinceRef(flags);
96
96
  const log = await getChangesSince(sinceRef);
97
97
  const supportedScopes = getSupportedScopes(flags.includeRestrictedScopes);
98
+ const supportedPackages = flags.supportedPackages ? JSON.parse(flags.supportedPackages) : [];
99
+ console.log(`Supported packages ${supportedPackages.length} and scopes ${supportedScopes}`);
98
100
  if (log.all.length === 0) {
99
101
  console.log(`No package.json changes found since '${sinceRef}'.`);
100
102
  return;
@@ -104,7 +106,7 @@ export default async function populateProduct(flags) {
104
106
  allUpgradeEvents
105
107
  } = await getEventsFromHistory(log, sinceRef, {
106
108
  cwd
107
- }, supportedScopes);
109
+ }, supportedScopes, supportedPackages);
108
110
  if (flags.csv) {
109
111
  const csv = generateCSV(allPackageChanges);
110
112
  console.log(csv);
@@ -4,4 +4,16 @@ export const getSupportedScopes = (enableNonAtlaskitPackages = false) => {
4
4
  };
5
5
  export const isPackageFromSupportedScopes = (packageName, supportedScopes = defaultScopes) => {
6
6
  return supportedScopes.some(scope => packageName.startsWith(scope));
7
+ };
8
+
9
+ /**
10
+ *
11
+ * Checks if the package is from supported scope
12
+ * and if so, the package is also from supported package list.
13
+ */
14
+ export const isPackageSupported = (packageName, supportedPackages = [], supportedScopes = defaultScopes) => {
15
+ if (isPackageFromSupportedScopes(packageName, supportedScopes)) {
16
+ return supportedPackages.length ? supportedPackages.indexOf(packageName) >= 0 : true;
17
+ }
18
+ return false;
7
19
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dependency-version-analytics",
3
- "version": "1.2.2",
3
+ "version": "1.4.0",
4
4
  "sideEffects": false
5
5
  }
package/dist/esm/cli.js CHANGED
@@ -6,7 +6,7 @@ import meow from 'meow';
6
6
  import { populateProduct, populatePackage } from './commands/populate-historic-data';
7
7
 
8
8
  // prettier-ignore
9
- var HELP_MSG = "\n".concat(chalk.green('Global options'), "\n ").concat(chalk.yellow('--dev'), " Send analytics to dev analytics pipeline instead of prod\n ").concat(chalk.yellow('--dryRun'), " Performs a dry run, prints analytics events to console in JSON format instead of sending them\n ").concat(chalk.yellow('--limit'), " Limit the number of events sent, used for validation purposes\n ").concat(chalk.yellow('--no-interactive'), " Disable any interactive prompts\n ").concat(chalk.yellow('--include-restricted-scopes'), " Include analytics for @atlassian and @atlassiansox scoped packages as well\n\n").concat(chalk.yellow.bold('[populate-product] <product>'), "\n Sends analytics events for atlaskit dependency versions changes in package.json.\n\n Detects changes since the last time the tool was run by storing the last run in either statlas (--statlas flag) or using the\n 'atlaskit-dependency-version-analytics-last-run' git tag.\n If running the tool for the first time (last run does not exist), --reset must be used to detect changes since the beginning of the repo.\n\n ").concat(chalk.green('Options'), "\n ").concat(chalk.yellow('--csv'), " Prints dependency history in CSV format\n ").concat(chalk.yellow('--reset'), " Reset change detection to detect changes from the beginning of time\n ").concat(chalk.yellow('--tag'), " Specify a different tag to mark when the tool was last run\n ").concat(chalk.yellow('--statlas'), " Use statlas rather than git tags for storing and sourcing last run info\n\n ").concat(chalk.green('Examples'), "\n ").concat(chalk.dim('$ atlaskit-version-analytics populate-product jira'), "\n\n").concat(chalk.yellow.bold('[populate-package] <package>'), "\n Sends analytics events for published versions of the specified package.\n\n ").concat(chalk.green('Options'), "\n ").concat(chalk.yellow('--since'), " Only publish versions since the following JS date string (exclusive)\n\n ").concat(chalk.green('Examples'), "\n ").concat(chalk.dim('$ atlaskit-version-analytics populate-package @atlaskit/button'), "\n");
9
+ var HELP_MSG = "\n".concat(chalk.green('Global options'), "\n ").concat(chalk.yellow('--dev'), " Send analytics to dev analytics pipeline instead of prod\n ").concat(chalk.yellow('--dryRun'), " Performs a dry run, prints analytics events to console in JSON format instead of sending them\n ").concat(chalk.yellow('--limit'), " Limit the number of events sent, used for validation purposes\n ").concat(chalk.yellow('--no-interactive'), " Disable any interactive prompts\n ").concat(chalk.yellow('--include-restricted-scopes'), " Include analytics for @atlassian and @atlassiansox scoped packages as well\n\n").concat(chalk.yellow.bold('[populate-product] <product>'), "\n Sends analytics events for atlaskit dependency versions changes in package.json.\n\n Detects changes since the last time the tool was run by storing the last run in either statlas (--statlas flag) or using the\n 'atlaskit-dependency-version-analytics-last-run' git tag.\n If running the tool for the first time (last run does not exist), --reset must be used to detect changes since the beginning of the repo.\n\n ").concat(chalk.green('Options'), "\n ").concat(chalk.yellow('--csv'), " Prints dependency history in CSV format\n ").concat(chalk.yellow('--reset'), " Reset change detection to detect changes from the beginning of time\n ").concat(chalk.yellow('--tag'), " Specify a different tag to mark when the tool was last run\n ").concat(chalk.yellow('--statlas'), " Use statlas rather than git tags for storing and sourcing last run info\n ").concat(chalk.yellow('--supported-packages'), " List of supported packages in JSON format\n\n ").concat(chalk.green('Examples'), "\n ").concat(chalk.dim('$ atlaskit-version-analytics populate-product jira'), "\n\n").concat(chalk.yellow.bold('[populate-package] <package>'), "\n Sends analytics events for published versions of the specified package.\n\n ").concat(chalk.green('Options'), "\n ").concat(chalk.yellow('--since'), " Only publish versions since the following JS date string (exclusive)\n\n ").concat(chalk.green('Examples'), "\n ").concat(chalk.dim('$ atlaskit-version-analytics populate-package @atlaskit/button'), "\n");
10
10
  export function run(_ref) {
11
11
  var dev = _ref.dev;
12
12
  var cli = meow(HELP_MSG, {
@@ -42,6 +42,9 @@ export function run(_ref) {
42
42
  },
43
43
  includeRestrictedScopes: {
44
44
  type: 'boolean'
45
+ },
46
+ supportedPackages: {
47
+ type: 'string'
45
48
  }
46
49
  }
47
50
  });
@@ -65,7 +68,8 @@ export function run(_ref) {
65
68
  reset: cli.flags.reset || false,
66
69
  statlas: cli.flags.statlas,
67
70
  tag: cli.flags.tag,
68
- includeRestrictedScopes: cli.flags.includeRestrictedScopes || false
71
+ includeRestrictedScopes: cli.flags.includeRestrictedScopes || false,
72
+ supportedPackages: cli.flags.supportedPackages
69
73
  });
70
74
  } else if (command === 'populate-package') {
71
75
  var pkg = inputs[0];
@@ -19,7 +19,7 @@ import { showFile } from '../../../util/git';
19
19
  import { DEP_TYPES } from '../../../constants';
20
20
  import { assert } from '../../../util/assert';
21
21
  import micromatch from 'micromatch';
22
- import { isPackageFromSupportedScopes } from '../util/allowed-scopes';
22
+ import { isPackageSupported } from '../util/allowed-scopes';
23
23
  var debug = debugModule('atlaskit:dependency');
24
24
  /**
25
25
  * Stores the state of atlaskit dependencies in a repository
@@ -28,6 +28,7 @@ export var DependencyStore = /*#__PURE__*/function () {
28
28
  function DependencyStore() {
29
29
  var cwd = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : process.cwd();
30
30
  var supportedScopes = arguments.length > 1 ? arguments[1] : undefined;
31
+ var supportedPackages = arguments.length > 2 ? arguments[2] : undefined;
31
32
  _classCallCheck(this, DependencyStore);
32
33
  /** Mapping of dependency names to arrays of unique dependency type + versions */
33
34
  _defineProperty(this, "dependencies", {});
@@ -38,6 +39,7 @@ export var DependencyStore = /*#__PURE__*/function () {
38
39
  _defineProperty(this, "initialised", false);
39
40
  this.cwd = cwd;
40
41
  this.supportedScopes = supportedScopes;
42
+ this.supportedPackages = supportedPackages;
41
43
  }
42
44
 
43
45
  /** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
@@ -411,7 +413,7 @@ export var DependencyStore = /*#__PURE__*/function () {
411
413
  function (_ref5) {
412
414
  var _ref6 = _slicedToArray(_ref5, 1),
413
415
  name = _ref6[0];
414
- return isPackageFromSupportedScopes(name, _this.supportedScopes) && !name.endsWith('--next');
416
+ return isPackageSupported(name, _this.supportedPackages, _this.supportedScopes) && !name.endsWith('--next');
415
417
  }).map(function (_ref7) {
416
418
  var _ref8 = _slicedToArray(_ref7, 2),
417
419
  name = _ref8[0],
@@ -57,7 +57,7 @@ var getUpgradeEventsFromPkgChange = function getUpgradeEventsFromPkgChange(oldDe
57
57
  return [].concat(_toConsumableArray(addOrUpgradeEvents), _toConsumableArray(removeEvents));
58
58
  };
59
59
  var getEventsFromHistory = /*#__PURE__*/function () {
60
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(packageChangesLog, prevRunHash, _ref8, supportedScopes) {
60
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(packageChangesLog, prevRunHash, _ref8, supportedScopes, supportedPackages) {
61
61
  var cwd, allPackageChanges, allUpgradeEvents, dependencyStore, dependencies, i, item, newDependencies, packageChange, upgradeEvents;
62
62
  return _regeneratorRuntime.wrap(function _callee$(_context) {
63
63
  while (1) switch (_context.prev = _context.next) {
@@ -66,7 +66,7 @@ var getEventsFromHistory = /*#__PURE__*/function () {
66
66
  allPackageChanges = [];
67
67
  allUpgradeEvents = [];
68
68
  assert(packageChangesLog.all.length > 0, '');
69
- dependencyStore = new DependencyStore(cwd, supportedScopes);
69
+ dependencyStore = new DependencyStore(cwd, supportedScopes, supportedPackages);
70
70
  _context.next = 7;
71
71
  return dependencyStore.initialise(prevRunHash);
72
72
  case 7:
@@ -112,11 +112,11 @@ var getEventsFromHistory = /*#__PURE__*/function () {
112
112
  }
113
113
  }, _callee);
114
114
  }));
115
- return function getEventsFromHistory(_x, _x2, _x3, _x4) {
115
+ return function getEventsFromHistory(_x, _x2, _x3, _x4, _x5) {
116
116
  return _ref9.apply(this, arguments);
117
117
  };
118
118
  }();
119
- function getSinceRef(_x5) {
119
+ function getSinceRef(_x6) {
120
120
  return _getSinceRef.apply(this, arguments);
121
121
  }
122
122
  function _getSinceRef() {
@@ -164,12 +164,12 @@ function _getSinceRef() {
164
164
  }));
165
165
  return _getSinceRef.apply(this, arguments);
166
166
  }
167
- export default function populateProduct(_x6) {
167
+ export default function populateProduct(_x7) {
168
168
  return _populateProduct.apply(this, arguments);
169
169
  }
170
170
  function _populateProduct() {
171
171
  _populateProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(flags) {
172
- var cwd, sinceRef, log, supportedScopes, _yield$getEventsFromH, allPackageChanges, allUpgradeEvents, csv, currentCommit;
172
+ var cwd, sinceRef, log, supportedScopes, supportedPackages, _yield$getEventsFromH, allPackageChanges, allUpgradeEvents, csv, currentCommit;
173
173
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
174
174
  while (1) switch (_context3.prev = _context3.next) {
175
175
  case 0:
@@ -193,74 +193,76 @@ function _populateProduct() {
193
193
  case 11:
194
194
  log = _context3.sent;
195
195
  supportedScopes = getSupportedScopes(flags.includeRestrictedScopes);
196
+ supportedPackages = flags.supportedPackages ? JSON.parse(flags.supportedPackages) : [];
197
+ console.log("Supported packages ".concat(supportedPackages.length, " and scopes ").concat(supportedScopes));
196
198
  if (!(log.all.length === 0)) {
197
- _context3.next = 16;
199
+ _context3.next = 18;
198
200
  break;
199
201
  }
200
202
  console.log("No package.json changes found since '".concat(sinceRef, "'."));
201
203
  return _context3.abrupt("return");
202
- case 16:
203
- _context3.next = 18;
204
+ case 18:
205
+ _context3.next = 20;
204
206
  return getEventsFromHistory(log, sinceRef, {
205
207
  cwd: cwd
206
- }, supportedScopes);
207
- case 18:
208
+ }, supportedScopes, supportedPackages);
209
+ case 20:
208
210
  _yield$getEventsFromH = _context3.sent;
209
211
  allPackageChanges = _yield$getEventsFromH.allPackageChanges;
210
212
  allUpgradeEvents = _yield$getEventsFromH.allUpgradeEvents;
211
213
  if (!flags.csv) {
212
- _context3.next = 25;
214
+ _context3.next = 27;
213
215
  break;
214
216
  }
215
217
  csv = generateCSV(allPackageChanges);
216
218
  console.log(csv);
217
219
  return _context3.abrupt("return");
218
- case 25:
220
+ case 27:
219
221
  if (!flags.dryRun) {
220
- _context3.next = 28;
222
+ _context3.next = 30;
221
223
  break;
222
224
  }
223
225
  console.log(JSON.stringify(allUpgradeEvents));
224
226
  return _context3.abrupt("return");
225
- case 28:
227
+ case 30:
226
228
  if (!(allUpgradeEvents.length > 0)) {
227
- _context3.next = 33;
229
+ _context3.next = 35;
228
230
  break;
229
231
  }
230
- _context3.next = 31;
232
+ _context3.next = 33;
231
233
  return sendAnalytics(allUpgradeEvents, {
232
234
  dev: flags.dev,
233
235
  limit: flags.limit,
234
236
  product: flags.product,
235
237
  skipPrompt: !flags.interactive
236
238
  });
237
- case 31:
238
- _context3.next = 34;
239
- break;
240
239
  case 33:
240
+ _context3.next = 36;
241
+ break;
242
+ case 35:
241
243
  console.log("Found no dependency changes from supported scopes ".concat(supportedScopes.join(', '), " since last run from ref \"").concat(sinceRef, "\"'"));
242
- case 34:
244
+ case 36:
243
245
  if (!flags.statlas) {
244
- _context3.next = 43;
246
+ _context3.next = 45;
245
247
  break;
246
248
  }
247
- _context3.next = 37;
249
+ _context3.next = 39;
248
250
  return getHash('HEAD');
249
- case 37:
251
+ case 39:
250
252
  currentCommit = _context3.sent;
251
- _context3.next = 40;
253
+ _context3.next = 42;
252
254
  return statlas.uploadMeta(flags.product, currentCommit);
253
- case 40:
255
+ case 42:
254
256
  console.log('Finished');
255
- _context3.next = 47;
257
+ _context3.next = 49;
256
258
  break;
257
- case 43:
259
+ case 45:
258
260
  console.log('Updating tag to current commit...');
259
- _context3.next = 46;
261
+ _context3.next = 48;
260
262
  return tagCommit(DEFAULT_TAG);
261
- case 46:
263
+ case 48:
262
264
  console.log("Finished. Run 'git push origin tag ".concat(sinceRef, "'."));
263
- case 47:
265
+ case 49:
264
266
  case "end":
265
267
  return _context3.stop();
266
268
  }
@@ -8,4 +8,18 @@ export var isPackageFromSupportedScopes = function isPackageFromSupportedScopes(
8
8
  return supportedScopes.some(function (scope) {
9
9
  return packageName.startsWith(scope);
10
10
  });
11
+ };
12
+
13
+ /**
14
+ *
15
+ * Checks if the package is from supported scope
16
+ * and if so, the package is also from supported package list.
17
+ */
18
+ export var isPackageSupported = function isPackageSupported(packageName) {
19
+ var supportedPackages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
20
+ var supportedScopes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultScopes;
21
+ if (isPackageFromSupportedScopes(packageName, supportedScopes)) {
22
+ return supportedPackages.length ? supportedPackages.indexOf(packageName) >= 0 : true;
23
+ }
24
+ return false;
11
25
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dependency-version-analytics",
3
- "version": "1.2.2",
3
+ "version": "1.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -14,7 +14,8 @@ export declare class DependencyStore {
14
14
  private workspaceGlobs;
15
15
  private initialised;
16
16
  private supportedScopes;
17
- constructor(cwd: string | undefined, supportedScopes: string[]);
17
+ private supportedPackages;
18
+ constructor(cwd: string | undefined, supportedScopes: string[], supportedPackages: string[]);
18
19
  /** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
19
20
  initialise(gitRef: string | undefined): Promise<DependencyMap>;
20
21
  /** Updates the repo dependency store based on the changes in `logItem`.
@@ -5,5 +5,6 @@ export declare type PopulateProductFlags = PopulateHistoricDataFlags & {
5
5
  reset: boolean;
6
6
  statlas?: boolean;
7
7
  tag?: string;
8
+ supportedPackages?: string;
8
9
  };
9
10
  export default function populateProduct(flags: PopulateProductFlags): Promise<void>;
@@ -1,2 +1,8 @@
1
1
  export declare const getSupportedScopes: (enableNonAtlaskitPackages?: boolean) => string[];
2
2
  export declare const isPackageFromSupportedScopes: (packageName: string, supportedScopes?: string[]) => boolean;
3
+ /**
4
+ *
5
+ * Checks if the package is from supported scope
6
+ * and if so, the package is also from supported package list.
7
+ */
8
+ export declare const isPackageSupported: (packageName: string, supportedPackages?: string[], supportedScopes?: string[]) => boolean;
@@ -0,0 +1,4 @@
1
+ /// <reference lib="es2017.object" />
2
+ export declare function run({ dev }: {
3
+ dev: boolean;
4
+ }): Promise<void> | Promise<import("./types").UpgradeEvent[]>;
@@ -0,0 +1,2 @@
1
+ import type { LogResult } from 'simple-git';
2
+ export declare const generateLogs: (fileChanges: string[][]) => LogResult;
@@ -0,0 +1,2 @@
1
+ export { default as populateProduct } from './product';
2
+ export { default as populatePackage } from './package';
@@ -0,0 +1,41 @@
1
+ /** Workspace code */
2
+ import { DependencyMap } from '../types';
3
+ import type { DefaultLogFields, ListLogLine } from 'simple-git';
4
+ /**
5
+ * Stores the state of atlaskit dependencies in a repository
6
+ */
7
+ export declare class DependencyStore {
8
+ private cwd;
9
+ /** Mapping of dependency names to arrays of unique dependency type + versions */
10
+ private dependencies;
11
+ /** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
12
+ private workspaces;
13
+ /** Set of workspace globs. Used to verify that a package.json is a valid workspace */
14
+ private workspaceGlobs;
15
+ private initialised;
16
+ private supportedScopes;
17
+ private supportedPackages;
18
+ constructor(cwd: string | undefined, supportedScopes: string[], supportedPackages: string[]);
19
+ /** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
20
+ initialise(gitRef: string | undefined): Promise<DependencyMap>;
21
+ /** Updates the repo dependency store based on the changes in `logItem`.
22
+ * Returns the updated flattened dependencies
23
+ */
24
+ update(logItem: DefaultLogFields & ListLogLine): Promise<DependencyMap>;
25
+ /** Retrieve a flattened list of p repo dependencies.
26
+ * If multiple versions of a dependency exist, the lowest version is returned.
27
+ * If the dependency is listed under multiple dependency types, 'dependencies' is prioritised over 'devDependencies'
28
+ */
29
+ private getFlattenedDeps;
30
+ private assertInitialised;
31
+ /** Scans all workspaces in repo and rebuilds dependency store */
32
+ private resetStore;
33
+ private getWorkspaceDependencies;
34
+ private updateWorkspaces;
35
+ private addDependency;
36
+ private removeDependency;
37
+ private getSupportedDependencies;
38
+ private static getMinimumVersion;
39
+ private static transformDepName;
40
+ private static transformDepVersion;
41
+ }
@@ -0,0 +1,7 @@
1
+ import { PopulateHistoricDataFlags } from './types';
2
+ import { UpgradeEvent } from '../../types';
3
+ export declare type PopulatePackageFlags = PopulateHistoricDataFlags & {
4
+ since?: string;
5
+ pkg: string;
6
+ };
7
+ export default function populatePackage(flags: PopulatePackageFlags): Promise<UpgradeEvent[]>;
@@ -0,0 +1,10 @@
1
+ import { PopulateHistoricDataFlags } from './types';
2
+ export declare type PopulateProductFlags = PopulateHistoricDataFlags & {
3
+ csv: boolean;
4
+ product: string;
5
+ reset: boolean;
6
+ statlas?: boolean;
7
+ tag?: string;
8
+ supportedPackages?: string;
9
+ };
10
+ export default function populateProduct(flags: PopulateProductFlags): Promise<void>;
@@ -0,0 +1,19 @@
1
+ import { DependencyType } from '../../types';
2
+ export declare type PopulateHistoricDataFlags = {
3
+ cwd?: string;
4
+ dev: boolean;
5
+ dryRun: boolean;
6
+ limit?: number;
7
+ interactive: boolean;
8
+ includeRestrictedScopes?: boolean;
9
+ };
10
+ export declare type DependencyMap = {
11
+ [name: string]: {
12
+ version: string;
13
+ type: DependencyType;
14
+ };
15
+ };
16
+ export declare type PackageChange = {
17
+ deps: DependencyMap;
18
+ date: string;
19
+ };
@@ -0,0 +1,8 @@
1
+ export declare const getSupportedScopes: (enableNonAtlaskitPackages?: boolean) => string[];
2
+ export declare const isPackageFromSupportedScopes: (packageName: string, supportedScopes?: string[]) => boolean;
3
+ /**
4
+ *
5
+ * Checks if the package is from supported scope
6
+ * and if so, the package is also from supported package list.
7
+ */
8
+ export declare const isPackageSupported: (packageName: string, supportedPackages?: string[], supportedScopes?: string[]) => boolean;
@@ -0,0 +1,3 @@
1
+ import { PackageChange } from '../types';
2
+ /** Generates a CSV of product package changes over time */
3
+ export declare const generateCSV: (packageChanges: PackageChange[]) => string;
@@ -0,0 +1,19 @@
1
+ export declare const DEFAULT_TAG = "atlaskit-dependency-version-analytics-last-run";
2
+ export declare const DEP_TYPES: readonly [
3
+ {
4
+ readonly packageJsonKey: "devDependencies";
5
+ readonly depTypeName: "devDependency";
6
+ },
7
+ {
8
+ readonly packageJsonKey: "dependencies";
9
+ readonly depTypeName: "dependency";
10
+ },
11
+ {
12
+ readonly packageJsonKey: "peerDependencies";
13
+ readonly depTypeName: "peerDependency";
14
+ },
15
+ {
16
+ readonly packageJsonKey: "optionalDependencies";
17
+ readonly depTypeName: "optionalDependency";
18
+ }
19
+ ];
@@ -0,0 +1,3 @@
1
+ export { populateProduct, populatePackage, } from './commands/populate-historic-data';
2
+ export { sendAnalytics } from './util/analytics';
3
+ export type { DependencyType, UpgradeType, UpgradeSubType, UpgradeEvent, } from './types';
@@ -0,0 +1,25 @@
1
+ import { ReleaseType } from 'semver';
2
+ export declare type DependencyType = 'devDependency' | 'dependency' | 'optionalDependency' | 'peerDependency';
3
+ export declare type UpgradeType = 'add' | 'upgrade' | 'remove' | 'downgrade';
4
+ export declare type UpgradeSubType = ReleaseType | null;
5
+ export declare type UpgradeEvent = {
6
+ dependencyName: string;
7
+ versionString: string;
8
+ major: string | null;
9
+ minor: string | null;
10
+ patch: string | null;
11
+ date: string;
12
+ upgradeType: UpgradeType;
13
+ upgradeSubType: UpgradeSubType;
14
+ cliVersion: string;
15
+ latestTag: string | null;
16
+ nextTag: string | null;
17
+ hotfixTag: string | null;
18
+ rcTag: string | null;
19
+ dependencyType?: DependencyType;
20
+ historical?: boolean;
21
+ commitHash?: string;
22
+ };
23
+ export declare type DistTagsType = {
24
+ [tag: string]: string;
25
+ };
@@ -0,0 +1,12 @@
1
+ import { UpgradeEvent, DependencyType, DistTagsType } from '../types';
2
+ export declare function createUpgradeEvent(name: string, version: string | undefined, previousVersion: string | undefined, date: string, optionalEventArgs?: {
3
+ commitHash?: string;
4
+ dependencyType?: DependencyType;
5
+ historical?: boolean;
6
+ }, tags?: DistTagsType): UpgradeEvent | null;
7
+ export declare function sendAnalytics(analyticsEvents: UpgradeEvent[], { dev, limit, product, skipPrompt, }: {
8
+ dev?: boolean;
9
+ limit?: number;
10
+ product: string;
11
+ skipPrompt?: boolean;
12
+ }): Promise<void>;
@@ -0,0 +1,2 @@
1
+ /** Generic assertion function */
2
+ export declare function assert(condition: any, msg?: string): asserts condition;
@@ -0,0 +1 @@
1
+ export default function (name: string): string | null;
@@ -0,0 +1 @@
1
+ export default function getFileHistoryFromGit(fileName: string): Promise<string>;
@@ -0,0 +1,8 @@
1
+ import { DistTagsType } from '../types';
2
+ export declare type PackageVersionHistoryAndTagsType = {
3
+ time: {
4
+ [version: string]: string;
5
+ };
6
+ 'dist-tags': DistTagsType;
7
+ };
8
+ export default function getPackageVersionHistoryAndTags(packageName: string): Promise<PackageVersionHistoryAndTagsType>;
@@ -0,0 +1,14 @@
1
+ import type { LogResult } from 'simple-git';
2
+ export declare function getChangesSince(since?: string): Promise<LogResult>;
3
+ export declare function tagCommit(tag: string): Promise<string>;
4
+ export declare function doesTagExist(tag: string): Promise<boolean>;
5
+ export declare function refetchTag(tag: string): Promise<{
6
+ fetchTagResult: import("simple-git").FetchResult | undefined;
7
+ }>;
8
+ export declare function getHash(ref: string): Promise<string>;
9
+ export declare function showFile(ref: string, filename: string, opts?: {
10
+ cwd?: string;
11
+ }): import("simple-git").Response<string>;
12
+ export declare function getFiles(ref: string, glob: string, opts?: {
13
+ cwd?: string;
14
+ }): Promise<string[]>;
@@ -0,0 +1,5 @@
1
+ export declare type Meta = {
2
+ lastRunHash: string;
3
+ };
4
+ export declare function getMeta(product: string): Promise<Meta | null>;
5
+ export declare function uploadMeta(product: string, lastRunHash: string): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export declare function getWorkspaceGlobs(ref: string, cwd: string): Promise<Set<string> | null>;
2
+ export declare function getWorkspacePaths(ref: string, workspaceGlobs: Set<string>, cwd: string): Promise<string[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/dependency-version-analytics",
3
- "version": "1.2.2",
3
+ "version": "1.4.0",
4
4
  "description": "Tool to pull atlaskit version history from a repo",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
package/report.api.md CHANGED
@@ -55,6 +55,7 @@ type PopulateProductFlags = PopulateHistoricDataFlags & {
55
55
  reset: boolean;
56
56
  statlas?: boolean;
57
57
  tag?: string;
58
+ supportedPackages?: string;
58
59
  };
59
60
 
60
61
  // @public (undocumented)
@@ -38,6 +38,7 @@ type PopulateProductFlags = PopulateHistoricDataFlags & {
38
38
  reset: boolean;
39
39
  statlas?: boolean;
40
40
  tag?: string;
41
+ supportedPackages?: string;
41
42
  };
42
43
 
43
44
  // @public (undocumented)