@atlaskit/dependency-version-analytics 1.1.0 → 1.2.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 (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +5 -3
  3. package/dist/cjs/cli.js +52 -17
  4. package/dist/cjs/commands/populate-historic-data/index.js +2 -2
  5. package/dist/cjs/commands/populate-historic-data/lib/dependency-store.js +227 -451
  6. package/dist/cjs/commands/populate-historic-data/package.js +30 -73
  7. package/dist/cjs/commands/populate-historic-data/product.js +129 -289
  8. package/dist/cjs/commands/populate-historic-data/util/allowed-scopes.js +15 -0
  9. package/dist/cjs/commands/populate-historic-data/util/generate-csv.js +16 -21
  10. package/dist/cjs/constants.js +2 -2
  11. package/dist/cjs/index.js +3 -3
  12. package/dist/cjs/util/analytics.js +77 -102
  13. package/dist/cjs/util/get-file-history-from-git.js +4 -4
  14. package/dist/cjs/util/get-package-version-history.js +5 -5
  15. package/dist/cjs/util/git.js +75 -205
  16. package/dist/cjs/util/statlas.js +27 -97
  17. package/dist/cjs/util/yarn.js +40 -101
  18. package/dist/cjs/version.json +1 -1
  19. package/dist/es2019/cli.js +10 -4
  20. package/dist/es2019/commands/populate-historic-data/lib/dependency-store.js +6 -4
  21. package/dist/es2019/commands/populate-historic-data/package.js +4 -2
  22. package/dist/es2019/commands/populate-historic-data/product.js +8 -6
  23. package/dist/es2019/commands/populate-historic-data/util/allowed-scopes.js +7 -0
  24. package/dist/es2019/commands/populate-historic-data/util/generate-csv.js +1 -1
  25. package/dist/es2019/version.json +1 -1
  26. package/dist/esm/cli.js +8 -3
  27. package/dist/esm/commands/populate-historic-data/lib/dependency-store.js +20 -15
  28. package/dist/esm/commands/populate-historic-data/package.js +20 -17
  29. package/dist/esm/commands/populate-historic-data/product.js +45 -42
  30. package/dist/esm/commands/populate-historic-data/util/allowed-scopes.js +11 -0
  31. package/dist/esm/commands/populate-historic-data/util/generate-csv.js +1 -1
  32. package/dist/esm/util/analytics.js +4 -3
  33. package/dist/esm/util/git.js +14 -13
  34. package/dist/esm/util/statlas.js +8 -7
  35. package/dist/esm/util/yarn.js +6 -5
  36. package/dist/esm/version.json +1 -1
  37. package/dist/types/commands/populate-historic-data/lib/dependency-store.d.ts +3 -2
  38. package/dist/types/commands/populate-historic-data/types.d.ts +3 -2
  39. package/dist/types/commands/populate-historic-data/util/allowed-scopes.d.ts +2 -0
  40. package/dist/types/commands/populate-historic-data/util/generate-csv.d.ts +2 -2
  41. package/package.json +2 -2
  42. package/report.api.md +1 -0
  43. package/tmp/api-report-tmp.d.ts +1 -0
  44. package/tokenize-arg-string.ts +0 -0
@@ -11,6 +11,7 @@ ${chalk.green('Global options')}
11
11
  ${chalk.yellow('--dryRun')} Performs a dry run, prints analytics events to console in JSON format instead of sending them
12
12
  ${chalk.yellow('--limit')} Limit the number of events sent, used for validation purposes
13
13
  ${chalk.yellow('--no-interactive')} Disable any interactive prompts
14
+ ${chalk.yellow('--include-restricted-scopes')} Include analytics for @atlassian and @atlassiansox scoped packages as well
14
15
 
15
16
  ${chalk.yellow.bold('[populate-product] <product>')}
16
17
  Sends analytics events for atlaskit dependency versions changes in package.json.
@@ -20,7 +21,7 @@ ${chalk.yellow.bold('[populate-product] <product>')}
20
21
  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.
21
22
 
22
23
  ${chalk.green('Options')}
23
- ${chalk.yellow('--csv')} Prints AK dependency history in CSV format
24
+ ${chalk.yellow('--csv')} Prints dependency history in CSV format
24
25
  ${chalk.yellow('--reset')} Reset change detection to detect changes from the beginning of time
25
26
  ${chalk.yellow('--tag')} Specify a different tag to mark when the tool was last run
26
27
  ${chalk.yellow('--statlas')} Use statlas rather than git tags for storing and sourcing last run info
@@ -29,7 +30,7 @@ ${chalk.yellow.bold('[populate-product] <product>')}
29
30
  ${chalk.dim('$ atlaskit-version-analytics populate-product jira')}
30
31
 
31
32
  ${chalk.yellow.bold('[populate-package] <package>')}
32
- Sends analytics events for published versions of the specified atlaskit package.
33
+ Sends analytics events for published versions of the specified package.
33
34
 
34
35
  ${chalk.green('Options')}
35
36
  ${chalk.yellow('--since')} Only publish versions since the following JS date string (exclusive)
@@ -70,6 +71,9 @@ export function run({
70
71
  },
71
72
  statlas: {
72
73
  type: 'boolean'
74
+ },
75
+ includeRestrictedScopes: {
76
+ type: 'boolean'
73
77
  }
74
78
  }
75
79
  });
@@ -90,7 +94,8 @@ export function run({
90
94
  product,
91
95
  reset: cli.flags.reset || false,
92
96
  statlas: cli.flags.statlas,
93
- tag: cli.flags.tag
97
+ tag: cli.flags.tag,
98
+ includeRestrictedScopes: cli.flags.includeRestrictedScopes || false
94
99
  });
95
100
  } else if (command === 'populate-package') {
96
101
  const pkg = inputs[0];
@@ -104,7 +109,8 @@ export function run({
104
109
  interactive: cli.flags.interactive,
105
110
  limit,
106
111
  pkg,
107
- since: cli.flags.since
112
+ since: cli.flags.since,
113
+ includeRestrictedScopes: cli.flags.includeRestrictedScopes || false
108
114
  });
109
115
  }
110
116
 
@@ -8,6 +8,7 @@ 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
12
  const debug = debugModule('atlaskit:dependency');
12
13
  /**
13
14
  * Stores the state of atlaskit dependencies in a repository
@@ -19,12 +20,13 @@ export class DependencyStore {
19
20
 
20
21
  /** Set of workspace globs. Used to verify that a package.json is a valid workspace */
21
22
 
22
- constructor(cwd = process.cwd()) {
23
+ constructor(cwd = process.cwd(), supportedScopes) {
23
24
  _defineProperty(this, "dependencies", {});
24
25
  _defineProperty(this, "workspaces", {});
25
26
  _defineProperty(this, "workspaceGlobs", new Set());
26
27
  _defineProperty(this, "initialised", false);
27
28
  this.cwd = cwd;
29
+ this.supportedScopes = supportedScopes;
28
30
  }
29
31
 
30
32
  /** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
@@ -140,7 +142,7 @@ export class DependencyStore {
140
142
  packageJsonKey,
141
143
  depTypeName
142
144
  } of DEP_TYPES) {
143
- const wsDeps = DependencyStore.getAkDependencies(json[packageJsonKey] || {}, depTypeName);
145
+ const wsDeps = this.getSupportedDependencies(json[packageJsonKey] || {}, depTypeName);
144
146
  workspaceDeps = {
145
147
  ...workspaceDeps,
146
148
  ...wsDeps
@@ -203,10 +205,10 @@ export class DependencyStore {
203
205
  this.dependencies[depName] = this.dependencies[depName].filter(entry => entry !== depEntry);
204
206
  }
205
207
  }
206
- static getAkDependencies(depMap, type) {
208
+ getSupportedDependencies(depMap, type) {
207
209
  return fromEntries(Object.entries(depMap).filter(
208
210
  // Ignore suffixed `--next` deps in jira used for independent upgrades
209
- ([name]) => name.includes('@atlaskit') && !name.endsWith('--next')).map(([name, version]) => [DependencyStore.transformDepName(name), {
211
+ ([name]) => isPackageFromSupportedScopes(name, this.supportedScopes) && !name.endsWith('--next')).map(([name, version]) => [DependencyStore.transformDepName(name), {
210
212
  version: DependencyStore.transformDepVersion(version),
211
213
  type
212
214
  }]));
@@ -1,6 +1,7 @@
1
1
  import semver from 'semver';
2
2
  import getPackageVersionHistoryAndTags from '../../util/get-package-version-history';
3
3
  import { createUpgradeEvent, sendAnalytics } from '../../util/analytics';
4
+ import { getSupportedScopes, isPackageFromSupportedScopes } from './util/allowed-scopes';
4
5
  const createAnalyticsEvents = (packageName, packageVersionHistoryAndTags, since) => {
5
6
  const packageVersionHistory = packageVersionHistoryAndTags['time'];
6
7
  const tags = packageVersionHistoryAndTags['dist-tags'];
@@ -18,8 +19,9 @@ const createAnalyticsEvents = (packageName, packageVersionHistoryAndTags, since)
18
19
  return upgradeEvents;
19
20
  };
20
21
  export default async function populatePackage(flags) {
21
- if (!flags.pkg.startsWith('@atlaskit/')) {
22
- throw new Error(`Package must start with '@atlaskit/'`);
22
+ const supportedScopes = getSupportedScopes(flags.includeRestrictedScopes);
23
+ if (!isPackageFromSupportedScopes(flags.pkg, supportedScopes)) {
24
+ throw new Error(`Package must start with ${supportedScopes.join(', ')}`);
23
25
  }
24
26
  const packageVersionHistory = await getPackageVersionHistoryAndTags(flags.pkg);
25
27
  if (flags.since && Number.isNaN(Number(new Date(flags.since)))) {
@@ -7,6 +7,7 @@ import { generateCSV } from './util/generate-csv';
7
7
  import { assert } from '../../util/assert';
8
8
  import { DependencyStore } from './lib/dependency-store';
9
9
  import getPackageVersionHistoryAndTags from '../../util/get-package-version-history';
10
+ import { getSupportedScopes } from './util/allowed-scopes';
10
11
  const getUpgradeEventsFromPkgChange = (oldDeps, newDeps, {
11
12
  date,
12
13
  commitHash
@@ -43,21 +44,21 @@ const getUpgradeEventsFromPkgChange = (oldDeps, newDeps, {
43
44
  };
44
45
  const getEventsFromHistory = async (packageChangesLog, prevRunHash, {
45
46
  cwd
46
- }) => {
47
+ }, supportedScopes) => {
47
48
  const allPackageChanges = [];
48
49
  let allUpgradeEvents = [];
49
50
  assert(packageChangesLog.all.length > 0, '');
50
- let dependencyStore = new DependencyStore(cwd);
51
+ let dependencyStore = new DependencyStore(cwd, supportedScopes);
51
52
  let dependencies = await dependencyStore.initialise(prevRunHash);
52
53
  for (let i = 0; i < packageChangesLog.all.length; i++) {
53
54
  let item = packageChangesLog.all[i];
54
55
  if (allPackageChanges.length > 0) {
55
- dependencies = allPackageChanges[allPackageChanges.length - 1].akDeps;
56
+ dependencies = allPackageChanges[allPackageChanges.length - 1].deps;
56
57
  }
57
58
  const newDependencies = await dependencyStore.update(item);
58
59
  const packageChange = {
59
60
  date: new Date(item.date).toISOString(),
60
- akDeps: newDependencies
61
+ deps: newDependencies
61
62
  };
62
63
  const upgradeEvents = getUpgradeEventsFromPkgChange(dependencies, newDependencies, {
63
64
  date: packageChange.date,
@@ -109,6 +110,7 @@ export default async function populateProduct(flags) {
109
110
  const cwd = flags.cwd || process.cwd();
110
111
  const sinceRef = flags.reset ? undefined : await getSinceRef(flags);
111
112
  const log = await getChangesSince(sinceRef);
113
+ const supportedScopes = getSupportedScopes(flags.includeRestrictedScopes);
112
114
  if (log.all.length === 0) {
113
115
  console.log(`No package.json changes found since '${sinceRef}'.`);
114
116
  return;
@@ -118,7 +120,7 @@ export default async function populateProduct(flags) {
118
120
  allUpgradeEvents
119
121
  } = await getEventsFromHistory(log, sinceRef, {
120
122
  cwd
121
- });
123
+ }, supportedScopes);
122
124
  if (flags.csv) {
123
125
  const csv = generateCSV(allPackageChanges);
124
126
  console.log(csv);
@@ -136,7 +138,7 @@ export default async function populateProduct(flags) {
136
138
  skipPrompt: !flags.interactive
137
139
  });
138
140
  } else {
139
- console.log(`Found no AK dependency changes since last run from ref "${sinceRef}"'`);
141
+ console.log(`Found no dependency changes from supported scopes ${supportedScopes.join(', ')} since last run from ref "${sinceRef}"'`);
140
142
  }
141
143
  if (flags.statlas) {
142
144
  // Upload latest commit to statlas
@@ -0,0 +1,7 @@
1
+ const defaultScopes = ['@atlaskit', '@atlassian', '@atlassiansox'];
2
+ export const getSupportedScopes = (enableNonAtlaskitPackages = false) => {
3
+ return enableNonAtlaskitPackages ? defaultScopes : ['@atlaskit'];
4
+ };
5
+ export const isPackageFromSupportedScopes = (packageName, supportedScopes = defaultScopes) => {
6
+ return supportedScopes.some(scope => packageName.startsWith(scope));
7
+ };
@@ -4,7 +4,7 @@ export const generateCSV = packageChanges => {
4
4
  packageChanges.forEach(packageChange => {
5
5
  const firstColumn = csvData[0];
6
6
  const currentRow = firstColumn.push(packageChange.date) - 1;
7
- Object.entries(packageChange.akDeps).forEach(([name, {
7
+ Object.entries(packageChange.deps).forEach(([name, {
8
8
  version
9
9
  }]) => {
10
10
  let depColumnIndex = csvData.findIndex(item => item[0] === name);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dependency-version-analytics",
3
- "version": "1.1.0",
3
+ "version": "1.2.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\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 AK 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 atlaskit 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\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, {
@@ -39,6 +39,9 @@ export function run(_ref) {
39
39
  },
40
40
  statlas: {
41
41
  type: 'boolean'
42
+ },
43
+ includeRestrictedScopes: {
44
+ type: 'boolean'
42
45
  }
43
46
  }
44
47
  });
@@ -61,7 +64,8 @@ export function run(_ref) {
61
64
  product: product,
62
65
  reset: cli.flags.reset || false,
63
66
  statlas: cli.flags.statlas,
64
- tag: cli.flags.tag
67
+ tag: cli.flags.tag,
68
+ includeRestrictedScopes: cli.flags.includeRestrictedScopes || false
65
69
  });
66
70
  } else if (command === 'populate-package') {
67
71
  var pkg = inputs[0];
@@ -75,7 +79,8 @@ export function run(_ref) {
75
79
  interactive: cli.flags.interactive,
76
80
  limit: limit,
77
81
  pkg: pkg,
78
- since: cli.flags.since
82
+ since: cli.flags.since,
83
+ includeRestrictedScopes: cli.flags.includeRestrictedScopes || false
79
84
  });
80
85
  }
81
86
 
@@ -1,3 +1,4 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
4
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
@@ -9,7 +10,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
9
10
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
10
11
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
12
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
- import _regeneratorRuntime from "@babel/runtime/regenerator";
13
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
13
14
  /** Workspace code */
14
15
 
15
16
  import debugModule from 'debug';
@@ -19,6 +20,7 @@ import { showFile } from '../../../util/git';
19
20
  import { DEP_TYPES } from '../../../constants';
20
21
  import { assert } from '../../../util/assert';
21
22
  import micromatch from 'micromatch';
23
+ import { isPackageFromSupportedScopes } from '../util/allowed-scopes';
22
24
  var debug = debugModule('atlaskit:dependency');
23
25
  /**
24
26
  * Stores the state of atlaskit dependencies in a repository
@@ -32,20 +34,22 @@ export var DependencyStore = /*#__PURE__*/function () {
32
34
 
33
35
  function DependencyStore() {
34
36
  var cwd = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : process.cwd();
37
+ var supportedScopes = arguments.length > 1 ? arguments[1] : undefined;
35
38
  _classCallCheck(this, DependencyStore);
36
39
  _defineProperty(this, "dependencies", {});
37
40
  _defineProperty(this, "workspaces", {});
38
41
  _defineProperty(this, "workspaceGlobs", new Set());
39
42
  _defineProperty(this, "initialised", false);
40
43
  this.cwd = cwd;
44
+ this.supportedScopes = supportedScopes;
41
45
  }
42
46
 
43
47
  /** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
44
48
  _createClass(DependencyStore, [{
45
49
  key: "initialise",
46
50
  value: function () {
47
- var _initialise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(gitRef) {
48
- return _regeneratorRuntime.wrap(function _callee$(_context) {
51
+ var _initialise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(gitRef) {
52
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
49
53
  while (1) {
50
54
  switch (_context.prev = _context.next) {
51
55
  case 0:
@@ -76,9 +80,9 @@ export var DependencyStore = /*#__PURE__*/function () {
76
80
  }, {
77
81
  key: "update",
78
82
  value: function () {
79
- var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(logItem) {
83
+ var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(logItem) {
80
84
  var hash, changedPackageJsons, didRootPackageJsonChange, workspaceGlobs, globsChanged, changedWorkspaces, _iterator, _step, workspacePath, workspaceDeps, validWorkspace, noLongerWorkspace;
81
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
85
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
82
86
  while (1) {
83
87
  switch (_context2.prev = _context2.next) {
84
88
  case 0:
@@ -210,9 +214,9 @@ export var DependencyStore = /*#__PURE__*/function () {
210
214
  }, {
211
215
  key: "resetStore",
212
216
  value: function () {
213
- var _resetStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(gitRef) {
217
+ var _resetStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(gitRef) {
214
218
  var workspaceGlobs, workspacePaths, _iterator2, _step2, wsPath, workspaceDeps;
215
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
219
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
216
220
  while (1) {
217
221
  switch (_context3.prev = _context3.next) {
218
222
  case 0:
@@ -285,9 +289,9 @@ export var DependencyStore = /*#__PURE__*/function () {
285
289
  }, {
286
290
  key: "getWorkspaceDependencies",
287
291
  value: function () {
288
- var _getWorkspaceDependencies = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(hash, workspacePath) {
292
+ var _getWorkspaceDependencies = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(hash, workspacePath) {
289
293
  var file, json, workspaceDeps, _iterator3, _step3, _step3$value, packageJsonKey, depTypeName, wsDeps;
290
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
294
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
291
295
  while (1) {
292
296
  switch (_context4.prev = _context4.next) {
293
297
  case 0:
@@ -321,7 +325,7 @@ export var DependencyStore = /*#__PURE__*/function () {
321
325
  try {
322
326
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
323
327
  _step3$value = _step3.value, packageJsonKey = _step3$value.packageJsonKey, depTypeName = _step3$value.depTypeName;
324
- wsDeps = DependencyStore.getAkDependencies(json[packageJsonKey] || {}, depTypeName);
328
+ wsDeps = this.getSupportedDependencies(json[packageJsonKey] || {}, depTypeName);
325
329
  workspaceDeps = _objectSpread(_objectSpread({}, workspaceDeps), wsDeps);
326
330
  }
327
331
  } catch (err) {
@@ -410,15 +414,16 @@ export var DependencyStore = /*#__PURE__*/function () {
410
414
  });
411
415
  }
412
416
  }
413
- }], [{
414
- key: "getAkDependencies",
415
- value: function getAkDependencies(depMap, type) {
417
+ }, {
418
+ key: "getSupportedDependencies",
419
+ value: function getSupportedDependencies(depMap, type) {
420
+ var _this = this;
416
421
  return fromEntries(Object.entries(depMap).filter(
417
422
  // Ignore suffixed `--next` deps in jira used for independent upgrades
418
423
  function (_ref5) {
419
424
  var _ref6 = _slicedToArray(_ref5, 1),
420
425
  name = _ref6[0];
421
- return name.includes('@atlaskit') && !name.endsWith('--next');
426
+ return isPackageFromSupportedScopes(name, _this.supportedScopes) && !name.endsWith('--next');
422
427
  }).map(function (_ref7) {
423
428
  var _ref8 = _slicedToArray(_ref7, 2),
424
429
  name = _ref8[0],
@@ -429,7 +434,7 @@ export var DependencyStore = /*#__PURE__*/function () {
429
434
  }];
430
435
  }));
431
436
  }
432
- }, {
437
+ }], [{
433
438
  key: "getMinimumVersion",
434
439
  value: function getMinimumVersion(versions, depName) {
435
440
  var depOrder = ['dependency', 'peerDependency', 'devDependency', 'optionalDependency'];
@@ -1,9 +1,11 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4
5
  import semver from 'semver';
5
6
  import getPackageVersionHistoryAndTags from '../../util/get-package-version-history';
6
7
  import { createUpgradeEvent, sendAnalytics } from '../../util/analytics';
8
+ import { getSupportedScopes, isPackageFromSupportedScopes } from './util/allowed-scopes';
7
9
  var createAnalyticsEvents = function createAnalyticsEvents(packageName, packageVersionHistoryAndTags, since) {
8
10
  var packageVersionHistory = packageVersionHistoryAndTags['time'];
9
11
  var tags = packageVersionHistoryAndTags['dist-tags'];
@@ -35,46 +37,47 @@ export default function populatePackage(_x) {
35
37
  return _populatePackage.apply(this, arguments);
36
38
  }
37
39
  function _populatePackage() {
38
- _populatePackage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(flags) {
39
- var packageVersionHistory, analyticsEvents;
40
- return _regeneratorRuntime.wrap(function _callee$(_context) {
40
+ _populatePackage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(flags) {
41
+ var supportedScopes, packageVersionHistory, analyticsEvents;
42
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
41
43
  while (1) {
42
44
  switch (_context.prev = _context.next) {
43
45
  case 0:
44
- if (flags.pkg.startsWith('@atlaskit/')) {
45
- _context.next = 2;
46
+ supportedScopes = getSupportedScopes(flags.includeRestrictedScopes);
47
+ if (isPackageFromSupportedScopes(flags.pkg, supportedScopes)) {
48
+ _context.next = 3;
46
49
  break;
47
50
  }
48
- throw new Error("Package must start with '@atlaskit/'");
49
- case 2:
50
- _context.next = 4;
51
+ throw new Error("Package must start with ".concat(supportedScopes.join(', ')));
52
+ case 3:
53
+ _context.next = 5;
51
54
  return getPackageVersionHistoryAndTags(flags.pkg);
52
- case 4:
55
+ case 5:
53
56
  packageVersionHistory = _context.sent;
54
57
  if (!(flags.since && Number.isNaN(Number(new Date(flags.since))))) {
55
- _context.next = 7;
58
+ _context.next = 8;
56
59
  break;
57
60
  }
58
61
  throw new Error("'since' flag is an invalid date");
59
- case 7:
62
+ case 8:
60
63
  analyticsEvents = createAnalyticsEvents(flags.pkg, packageVersionHistory, flags.since);
61
64
  if (!flags.dryRun) {
62
- _context.next = 11;
65
+ _context.next = 12;
63
66
  break;
64
67
  }
65
68
  console.log(JSON.stringify(analyticsEvents));
66
69
  return _context.abrupt("return", analyticsEvents);
67
- case 11:
68
- _context.next = 13;
70
+ case 12:
71
+ _context.next = 14;
69
72
  return sendAnalytics(analyticsEvents, {
70
73
  dev: flags.dev,
71
74
  limit: flags.limit,
72
75
  product: 'atlaskit',
73
76
  skipPrompt: !flags.interactive
74
77
  });
75
- case 13:
76
- return _context.abrupt("return", analyticsEvents);
77
78
  case 14:
79
+ return _context.abrupt("return", analyticsEvents);
80
+ case 15:
78
81
  case "end":
79
82
  return _context.stop();
80
83
  }