@atlaskit/dependency-version-analytics 1.4.9 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/dependency-version-analytics
2
2
 
3
+ ## 1.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b8ca83aa350`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b8ca83aa350) - Swap exec with spawn to avoid maxBuffer errors
8
+
9
+ ## 1.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`d23cb258eb0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d23cb258eb0) - Using flags.cwd to set current workDir and use package.json from current workDir instead of root
14
+
3
15
  ## 1.4.9
4
16
 
5
17
  ### Patch Changes
@@ -99,8 +99,14 @@ async function getSinceRef(flags) {
99
99
  return tag;
100
100
  }
101
101
  }
102
+ const getWorkDir = cwd => {
103
+ const workDir = cwd ?? process.cwd();
104
+ // Make sure that we're working in needed directory
105
+ process.chdir(workDir);
106
+ return workDir;
107
+ };
102
108
  async function populateProduct(flags) {
103
- const cwd = flags.cwd || process.cwd();
109
+ const cwd = getWorkDir(flags.cwd);
104
110
  const sinceRef = flags.reset ? undefined : await getSinceRef(flags);
105
111
  const log = await (0, _git.getChangesSince)(sinceRef);
106
112
  const supportedScopes = (0, _allowedScopes.getSupportedScopes)(flags.includeRestrictedScopes);
@@ -67,7 +67,7 @@ function createUpgradeEvent(name, version, previousVersion, date, optionalEventA
67
67
  }
68
68
  });
69
69
  return {
70
- cliVersion: "1.4.9",
70
+ cliVersion: "1.5.1",
71
71
  dependencyName: name,
72
72
  versionString: eventVersion,
73
73
  major: parsedVersion ? `${parsedVersion.major}` : null,
@@ -7,26 +7,29 @@ exports.default = getPackageVersionHistoryAndTags;
7
7
  var _child_process = require("child_process");
8
8
  function getPackageVersionHistoryAndTags(packageName) {
9
9
  return new Promise((resolve, reject) => {
10
- (0, _child_process.exec)(`yarn info ${packageName} --json`, (error, stdout, stderr) => {
11
- if (error) {
12
- console.error(`error: Unable to execute yarn info for ${packageName}`);
13
- reject(error);
14
- }
15
- if (stderr) {
16
- console.error(`stderr: Unable to execute yarn info for ${packageName}`);
17
- reject(stderr);
10
+ let stdoutData = '';
11
+ const child = (0, _child_process.spawn)(`yarn`, ['info', packageName, '--json']);
12
+ child.stdout.on('data', function (data) {
13
+ stdoutData += data.toString();
14
+ });
15
+ child.stderr.on('data', function (data) {
16
+ console.error(`error: Unable to execute yarn info for ${packageName}`, data);
17
+ reject(data);
18
+ });
19
+ child.on('close', function (code) {
20
+ if (code !== 0) {
21
+ return;
18
22
  }
19
- let json;
20
23
  try {
21
- const parseData = JSON.parse(stdout).data;
22
- json = {
24
+ const parseData = JSON.parse(stdoutData).data;
25
+ resolve({
23
26
  time: parseData['time'],
24
27
  'dist-tags': parseData['dist-tags']
25
- };
26
- } catch (e) {
27
- reject(`Error parsing json output: ${e}`);
28
+ });
29
+ } catch (error) {
30
+ console.error(`Error parsing json output: ${error}`);
31
+ reject(error);
28
32
  }
29
- resolve(json);
30
33
  });
31
34
  });
32
35
  }
@@ -12,16 +12,24 @@ var _micromatch = _interopRequireDefault(require("micromatch"));
12
12
  var git = _interopRequireWildcard(require("./git"));
13
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
- const rootPackageJsonPath = 'package.json';
16
15
  const debug = (0, _debug.default)('atlaskit:yarn');
17
16
  async function getWorkspacePackageJsonPaths(hash, cwd) {
18
17
  let file;
19
18
  try {
20
- file = await git.showFile(hash, rootPackageJsonPath, {
19
+ /**
20
+ * We need to use package.json from current working directory, not from root
21
+ * The reason is - some repositories have their package.json not in root
22
+ * For example "confluence-frontend" repo has package.json at "confluence-frontend/confluence/package.json"
23
+ */
24
+ file = await git.showFile(hash, `./package.json`, {
21
25
  cwd
22
26
  });
23
- } catch (e) {
24
- debug(`${rootPackageJsonPath} does not exist`);
27
+ } catch (error) {
28
+ const errorMessage = `File by hash "${hash}" and path "${cwd}/package.json" does not exist`;
29
+ debug(errorMessage, {
30
+ error
31
+ });
32
+ console.error(errorMessage, error);
25
33
  return new Set([]);
26
34
  }
27
35
  let rootPackageJsonFile;
@@ -33,11 +41,11 @@ async function getWorkspacePackageJsonPaths(hash, cwd) {
33
41
  }
34
42
  const workspaces = rootPackageJsonFile.workspaces;
35
43
  if (!workspaces) {
36
- return new Set([rootPackageJsonPath]);
44
+ return new Set(['package.json']);
37
45
  }
38
46
  // There are actually two formats for workspaces and they are poorly documented
39
47
  const workspacePackages = Array.isArray(workspaces) ? workspaces : workspaces.packages;
40
- return new Set([rootPackageJsonPath, ...workspacePackages.map(glob => _path.default.join(glob, 'package.json'))]);
48
+ return new Set(['package.json', ...workspacePackages.map(glob => _path.default.join(glob, 'package.json'))]);
41
49
  }
42
50
  async function getWorkspacePaths(ref, workspaceGlobs, cwd) {
43
51
  if (workspaceGlobs.size === 0) {
@@ -48,7 +56,7 @@ async function getWorkspacePaths(ref, workspaceGlobs, cwd) {
48
56
  });
49
57
  const matchedWorkspaces = (0, _micromatch.default)(workspacePackageJsons, [...workspaceGlobs]);
50
58
  if (matchedWorkspaces.length === 0) {
51
- throw new Error(`Could not find any workspace or package.json under ${cwd}`);
59
+ throw new Error(`Could not find any workspace or package.json under "${cwd}" for "${ref}" tag`);
52
60
  }
53
61
  return matchedWorkspaces;
54
62
  }
@@ -90,8 +90,14 @@ async function getSinceRef(flags) {
90
90
  return tag;
91
91
  }
92
92
  }
93
+ const getWorkDir = cwd => {
94
+ const workDir = cwd !== null && cwd !== void 0 ? cwd : process.cwd();
95
+ // Make sure that we're working in needed directory
96
+ process.chdir(workDir);
97
+ return workDir;
98
+ };
93
99
  export default async function populateProduct(flags) {
94
- const cwd = flags.cwd || process.cwd();
100
+ const cwd = getWorkDir(flags.cwd);
95
101
  const sinceRef = flags.reset ? undefined : await getSinceRef(flags);
96
102
  const log = await getChangesSince(sinceRef);
97
103
  const supportedScopes = getSupportedScopes(flags.includeRestrictedScopes);
@@ -59,7 +59,7 @@ export function createUpgradeEvent(name, version, previousVersion, date, optiona
59
59
  }
60
60
  });
61
61
  return {
62
- cliVersion: "1.4.9",
62
+ cliVersion: "1.5.1",
63
63
  dependencyName: name,
64
64
  versionString: eventVersion,
65
65
  major: parsedVersion ? `${parsedVersion.major}` : null,
@@ -1,26 +1,29 @@
1
- import { exec } from 'child_process';
1
+ import { spawn } from 'child_process';
2
2
  export default function getPackageVersionHistoryAndTags(packageName) {
3
3
  return new Promise((resolve, reject) => {
4
- exec(`yarn info ${packageName} --json`, (error, stdout, stderr) => {
5
- if (error) {
6
- console.error(`error: Unable to execute yarn info for ${packageName}`);
7
- reject(error);
8
- }
9
- if (stderr) {
10
- console.error(`stderr: Unable to execute yarn info for ${packageName}`);
11
- reject(stderr);
4
+ let stdoutData = '';
5
+ const child = spawn(`yarn`, ['info', packageName, '--json']);
6
+ child.stdout.on('data', function (data) {
7
+ stdoutData += data.toString();
8
+ });
9
+ child.stderr.on('data', function (data) {
10
+ console.error(`error: Unable to execute yarn info for ${packageName}`, data);
11
+ reject(data);
12
+ });
13
+ child.on('close', function (code) {
14
+ if (code !== 0) {
15
+ return;
12
16
  }
13
- let json;
14
17
  try {
15
- const parseData = JSON.parse(stdout).data;
16
- json = {
18
+ const parseData = JSON.parse(stdoutData).data;
19
+ resolve({
17
20
  time: parseData['time'],
18
21
  'dist-tags': parseData['dist-tags']
19
- };
20
- } catch (e) {
21
- reject(`Error parsing json output: ${e}`);
22
+ });
23
+ } catch (error) {
24
+ console.error(`Error parsing json output: ${error}`);
25
+ reject(error);
22
26
  }
23
- resolve(json);
24
27
  });
25
28
  });
26
29
  }
@@ -2,16 +2,24 @@ import path from 'path';
2
2
  import debugModule from 'debug';
3
3
  import micromatch from 'micromatch';
4
4
  import * as git from './git';
5
- const rootPackageJsonPath = 'package.json';
6
5
  const debug = debugModule('atlaskit:yarn');
7
6
  export async function getWorkspacePackageJsonPaths(hash, cwd) {
8
7
  let file;
9
8
  try {
10
- file = await git.showFile(hash, rootPackageJsonPath, {
9
+ /**
10
+ * We need to use package.json from current working directory, not from root
11
+ * The reason is - some repositories have their package.json not in root
12
+ * For example "confluence-frontend" repo has package.json at "confluence-frontend/confluence/package.json"
13
+ */
14
+ file = await git.showFile(hash, `./package.json`, {
11
15
  cwd
12
16
  });
13
- } catch (e) {
14
- debug(`${rootPackageJsonPath} does not exist`);
17
+ } catch (error) {
18
+ const errorMessage = `File by hash "${hash}" and path "${cwd}/package.json" does not exist`;
19
+ debug(errorMessage, {
20
+ error
21
+ });
22
+ console.error(errorMessage, error);
15
23
  return new Set([]);
16
24
  }
17
25
  let rootPackageJsonFile;
@@ -23,11 +31,11 @@ export async function getWorkspacePackageJsonPaths(hash, cwd) {
23
31
  }
24
32
  const workspaces = rootPackageJsonFile.workspaces;
25
33
  if (!workspaces) {
26
- return new Set([rootPackageJsonPath]);
34
+ return new Set(['package.json']);
27
35
  }
28
36
  // There are actually two formats for workspaces and they are poorly documented
29
37
  const workspacePackages = Array.isArray(workspaces) ? workspaces : workspaces.packages;
30
- return new Set([rootPackageJsonPath, ...workspacePackages.map(glob => path.join(glob, 'package.json'))]);
38
+ return new Set(['package.json', ...workspacePackages.map(glob => path.join(glob, 'package.json'))]);
31
39
  }
32
40
  export async function getWorkspacePaths(ref, workspaceGlobs, cwd) {
33
41
  if (workspaceGlobs.size === 0) {
@@ -38,7 +46,7 @@ export async function getWorkspacePaths(ref, workspaceGlobs, cwd) {
38
46
  });
39
47
  const matchedWorkspaces = micromatch(workspacePackageJsons, [...workspaceGlobs]);
40
48
  if (matchedWorkspaces.length === 0) {
41
- throw new Error(`Could not find any workspace or package.json under ${cwd}`);
49
+ throw new Error(`Could not find any workspace or package.json under "${cwd}" for "${ref}" tag`);
42
50
  }
43
51
  return matchedWorkspaces;
44
52
  }
@@ -4,8 +4,8 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
4
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
5
5
  import _createClass from "@babel/runtime/helpers/createClass";
6
6
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
9
  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
10
  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
11
  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; }
@@ -164,6 +164,12 @@ function _getSinceRef() {
164
164
  }));
165
165
  return _getSinceRef.apply(this, arguments);
166
166
  }
167
+ var getWorkDir = function getWorkDir(cwd) {
168
+ var workDir = cwd !== null && cwd !== void 0 ? cwd : process.cwd();
169
+ // Make sure that we're working in needed directory
170
+ process.chdir(workDir);
171
+ return workDir;
172
+ };
167
173
  export default function populateProduct(_x7) {
168
174
  return _populateProduct.apply(this, arguments);
169
175
  }
@@ -173,7 +179,7 @@ function _populateProduct() {
173
179
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
174
180
  while (1) switch (_context3.prev = _context3.next) {
175
181
  case 0:
176
- cwd = flags.cwd || process.cwd();
182
+ cwd = getWorkDir(flags.cwd);
177
183
  if (!flags.reset) {
178
184
  _context3.next = 5;
179
185
  break;
@@ -1,8 +1,8 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  import chalk from 'chalk';
7
7
  import inquirer from 'inquirer';
8
8
  import semver from 'semver';
@@ -66,7 +66,7 @@ export function createUpgradeEvent(name, version, previousVersion, date) {
66
66
  }
67
67
  });
68
68
  return _objectSpread({
69
- cliVersion: "1.4.9",
69
+ cliVersion: "1.5.1",
70
70
  dependencyName: name,
71
71
  versionString: eventVersion,
72
72
  major: parsedVersion ? "".concat(parsedVersion.major) : null,
@@ -1,26 +1,29 @@
1
- import { exec } from 'child_process';
1
+ import { spawn } from 'child_process';
2
2
  export default function getPackageVersionHistoryAndTags(packageName) {
3
3
  return new Promise(function (resolve, reject) {
4
- exec("yarn info ".concat(packageName, " --json"), function (error, stdout, stderr) {
5
- if (error) {
6
- console.error("error: Unable to execute yarn info for ".concat(packageName));
7
- reject(error);
8
- }
9
- if (stderr) {
10
- console.error("stderr: Unable to execute yarn info for ".concat(packageName));
11
- reject(stderr);
4
+ var stdoutData = '';
5
+ var child = spawn("yarn", ['info', packageName, '--json']);
6
+ child.stdout.on('data', function (data) {
7
+ stdoutData += data.toString();
8
+ });
9
+ child.stderr.on('data', function (data) {
10
+ console.error("error: Unable to execute yarn info for ".concat(packageName), data);
11
+ reject(data);
12
+ });
13
+ child.on('close', function (code) {
14
+ if (code !== 0) {
15
+ return;
12
16
  }
13
- var json;
14
17
  try {
15
- var parseData = JSON.parse(stdout).data;
16
- json = {
18
+ var parseData = JSON.parse(stdoutData).data;
19
+ resolve({
17
20
  time: parseData['time'],
18
21
  'dist-tags': parseData['dist-tags']
19
- };
20
- } catch (e) {
21
- reject("Error parsing json output: ".concat(e));
22
+ });
23
+ } catch (error) {
24
+ console.error("Error parsing json output: ".concat(error));
25
+ reject(error);
22
26
  }
23
- resolve(json);
24
27
  });
25
28
  });
26
29
  }
@@ -2,8 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  import git from 'simple-git';
8
8
  import { assert } from './assert';
9
9
  export function getChangesSince(_x) {
@@ -5,59 +5,62 @@ import path from 'path';
5
5
  import debugModule from 'debug';
6
6
  import micromatch from 'micromatch';
7
7
  import * as git from './git';
8
- var rootPackageJsonPath = 'package.json';
9
8
  var debug = debugModule('atlaskit:yarn');
10
9
  export function getWorkspacePackageJsonPaths(_x, _x2) {
11
10
  return _getWorkspacePackageJsonPaths.apply(this, arguments);
12
11
  }
13
12
  function _getWorkspacePackageJsonPaths() {
14
13
  _getWorkspacePackageJsonPaths = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(hash, cwd) {
15
- var file, rootPackageJsonFile, workspaces, workspacePackages;
14
+ var file, errorMessage, rootPackageJsonFile, workspaces, workspacePackages;
16
15
  return _regeneratorRuntime.wrap(function _callee$(_context) {
17
16
  while (1) switch (_context.prev = _context.next) {
18
17
  case 0:
19
18
  _context.prev = 0;
20
19
  _context.next = 3;
21
- return git.showFile(hash, rootPackageJsonPath, {
20
+ return git.showFile(hash, "./package.json", {
22
21
  cwd: cwd
23
22
  });
24
23
  case 3:
25
24
  file = _context.sent;
26
- _context.next = 10;
25
+ _context.next = 12;
27
26
  break;
28
27
  case 6:
29
28
  _context.prev = 6;
30
29
  _context.t0 = _context["catch"](0);
31
- debug("".concat(rootPackageJsonPath, " does not exist"));
30
+ errorMessage = "File by hash \"".concat(hash, "\" and path \"").concat(cwd, "/package.json\" does not exist");
31
+ debug(errorMessage, {
32
+ error: _context.t0
33
+ });
34
+ console.error(errorMessage, _context.t0);
32
35
  return _context.abrupt("return", new Set([]));
33
- case 10:
34
- _context.prev = 10;
36
+ case 12:
37
+ _context.prev = 12;
35
38
  rootPackageJsonFile = JSON.parse(file);
36
- _context.next = 18;
39
+ _context.next = 20;
37
40
  break;
38
- case 14:
39
- _context.prev = 14;
40
- _context.t1 = _context["catch"](10);
41
+ case 16:
42
+ _context.prev = 16;
43
+ _context.t1 = _context["catch"](12);
41
44
  console.error("Error parsing ".concat(file, "@").concat(hash, ": ").concat(_context.t1));
42
45
  return _context.abrupt("return", null);
43
- case 18:
46
+ case 20:
44
47
  workspaces = rootPackageJsonFile.workspaces;
45
48
  if (workspaces) {
46
- _context.next = 21;
49
+ _context.next = 23;
47
50
  break;
48
51
  }
49
- return _context.abrupt("return", new Set([rootPackageJsonPath]));
50
- case 21:
52
+ return _context.abrupt("return", new Set(['package.json']));
53
+ case 23:
51
54
  // There are actually two formats for workspaces and they are poorly documented
52
55
  workspacePackages = Array.isArray(workspaces) ? workspaces : workspaces.packages;
53
- return _context.abrupt("return", new Set([rootPackageJsonPath].concat(_toConsumableArray(workspacePackages.map(function (glob) {
56
+ return _context.abrupt("return", new Set(['package.json'].concat(_toConsumableArray(workspacePackages.map(function (glob) {
54
57
  return path.join(glob, 'package.json');
55
58
  })))));
56
- case 23:
59
+ case 25:
57
60
  case "end":
58
61
  return _context.stop();
59
62
  }
60
- }, _callee, null, [[0, 6], [10, 14]]);
63
+ }, _callee, null, [[0, 6], [12, 16]]);
61
64
  }));
62
65
  return _getWorkspacePackageJsonPaths.apply(this, arguments);
63
66
  }
@@ -87,7 +90,7 @@ function _getWorkspacePaths() {
87
90
  _context2.next = 8;
88
91
  break;
89
92
  }
90
- throw new Error("Could not find any workspace or package.json under ".concat(cwd));
93
+ throw new Error("Could not find any workspace or package.json under \"".concat(cwd, "\" for \"").concat(ref, "\" tag"));
91
94
  case 8:
92
95
  return _context2.abrupt("return", matchedWorkspaces);
93
96
  case 9:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/dependency-version-analytics",
3
- "version": "1.4.9",
3
+ "version": "1.5.1",
4
4
  "description": "Tool to pull atlaskit version history from a repo",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"