@atlaskit/dependency-version-analytics 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,3 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
@@ -9,8 +8,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
9
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; }
10
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; } } }; }
11
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); }
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; }
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; }
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; }
12
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
14
13
  /** Workspace code */
15
14
 
16
15
  import debugModule from 'debug';
@@ -26,18 +25,15 @@ var debug = debugModule('atlaskit:dependency');
26
25
  * Stores the state of atlaskit dependencies in a repository
27
26
  */
28
27
  export var DependencyStore = /*#__PURE__*/function () {
29
- /** Mapping of dependency names to arrays of unique dependency type + versions */
30
-
31
- /** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
32
-
33
- /** Set of workspace globs. Used to verify that a package.json is a valid workspace */
34
-
35
28
  function DependencyStore() {
36
29
  var cwd = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : process.cwd();
37
30
  var supportedScopes = arguments.length > 1 ? arguments[1] : undefined;
38
31
  _classCallCheck(this, DependencyStore);
32
+ /** Mapping of dependency names to arrays of unique dependency type + versions */
39
33
  _defineProperty(this, "dependencies", {});
34
+ /** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
40
35
  _defineProperty(this, "workspaces", {});
36
+ /** Set of workspace globs. Used to verify that a package.json is a valid workspace */
41
37
  _defineProperty(this, "workspaceGlobs", new Set());
42
38
  _defineProperty(this, "initialised", false);
43
39
  this.cwd = cwd;
@@ -48,24 +44,22 @@ export var DependencyStore = /*#__PURE__*/function () {
48
44
  _createClass(DependencyStore, [{
49
45
  key: "initialise",
50
46
  value: function () {
51
- var _initialise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(gitRef) {
52
- return _regeneratorRuntime().wrap(function _callee$(_context) {
53
- while (1) {
54
- switch (_context.prev = _context.next) {
55
- case 0:
56
- if (!gitRef) {
57
- _context.next = 3;
58
- break;
59
- }
47
+ var _initialise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(gitRef) {
48
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
49
+ while (1) switch (_context.prev = _context.next) {
50
+ case 0:
51
+ if (!gitRef) {
60
52
  _context.next = 3;
61
- return this.resetStore(gitRef);
62
- case 3:
63
- this.initialised = true;
64
- return _context.abrupt("return", this.getFlattenedDeps());
65
- case 5:
66
- case "end":
67
- return _context.stop();
68
- }
53
+ break;
54
+ }
55
+ _context.next = 3;
56
+ return this.resetStore(gitRef);
57
+ case 3:
58
+ this.initialised = true;
59
+ return _context.abrupt("return", this.getFlattenedDeps());
60
+ case 5:
61
+ case "end":
62
+ return _context.stop();
69
63
  }
70
64
  }, _callee, this);
71
65
  }));
@@ -80,101 +74,99 @@ export var DependencyStore = /*#__PURE__*/function () {
80
74
  }, {
81
75
  key: "update",
82
76
  value: function () {
83
- var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(logItem) {
77
+ var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(logItem) {
84
78
  var hash, changedPackageJsons, didRootPackageJsonChange, workspaceGlobs, globsChanged, changedWorkspaces, _iterator, _step, workspacePath, workspaceDeps, validWorkspace, noLongerWorkspace;
85
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
86
- while (1) {
87
- switch (_context2.prev = _context2.next) {
88
- case 0:
89
- this.assertInitialised();
90
- hash = logItem.hash;
91
- assert(!!logItem.diff, "Diff must exist in log ".concat(logItem, " ").concat(hash));
92
- changedPackageJsons = logItem.diff.files.filter(function (f) {
93
- return f.file === 'package.json' || f.file.endsWith('/package.json');
94
- }).map(function (f) {
95
- return f.file;
96
- });
97
- didRootPackageJsonChange = !!changedPackageJsons.find(function (file) {
98
- return file === 'package.json';
99
- });
100
- if (!didRootPackageJsonChange) {
101
- _context2.next = 15;
102
- break;
103
- }
104
- _context2.next = 8;
105
- return getWorkspaceGlobs(hash, this.cwd);
106
- case 8:
107
- workspaceGlobs = _context2.sent;
108
- globsChanged = workspaceGlobs !== null && (this.workspaceGlobs.size !== workspaceGlobs.size || _toConsumableArray(this.workspaceGlobs).some(function (glob) {
109
- return !workspaceGlobs.has(glob);
110
- }));
111
- if (!globsChanged) {
112
- _context2.next = 15;
113
- break;
114
- }
115
- debug("Workspace globs changed: ".concat(_toConsumableArray(workspaceGlobs), ". Resetting store."));
116
- _context2.next = 14;
117
- return this.resetStore(hash);
118
- case 14:
119
- return _context2.abrupt("return", this.getFlattenedDeps());
120
- case 15:
121
- changedWorkspaces = micromatch(changedPackageJsons, _toConsumableArray(this.workspaceGlobs));
122
- debug("Updating changed workspaces@".concat(hash, ": ").concat(changedWorkspaces));
79
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
80
+ while (1) switch (_context2.prev = _context2.next) {
81
+ case 0:
82
+ this.assertInitialised();
83
+ hash = logItem.hash;
84
+ assert(!!logItem.diff, "Diff must exist in log ".concat(logItem, " ").concat(hash));
85
+ changedPackageJsons = logItem.diff.files.filter(function (f) {
86
+ return f.file === 'package.json' || f.file.endsWith('/package.json');
87
+ }).map(function (f) {
88
+ return f.file;
89
+ });
90
+ didRootPackageJsonChange = !!changedPackageJsons.find(function (file) {
91
+ return file === 'package.json';
92
+ });
93
+ if (!didRootPackageJsonChange) {
94
+ _context2.next = 15;
95
+ break;
96
+ }
97
+ _context2.next = 8;
98
+ return getWorkspaceGlobs(hash, this.cwd);
99
+ case 8:
100
+ workspaceGlobs = _context2.sent;
101
+ globsChanged = workspaceGlobs !== null && (this.workspaceGlobs.size !== workspaceGlobs.size || _toConsumableArray(this.workspaceGlobs).some(function (glob) {
102
+ return !workspaceGlobs.has(glob);
103
+ }));
104
+ if (!globsChanged) {
105
+ _context2.next = 15;
106
+ break;
107
+ }
108
+ debug("Workspace globs changed: ".concat(_toConsumableArray(workspaceGlobs), ". Resetting store."));
109
+ _context2.next = 14;
110
+ return this.resetStore(hash);
111
+ case 14:
112
+ return _context2.abrupt("return", this.getFlattenedDeps());
113
+ case 15:
114
+ changedWorkspaces = micromatch(changedPackageJsons, _toConsumableArray(this.workspaceGlobs));
115
+ debug("Updating changed workspaces@".concat(hash, ": ").concat(changedWorkspaces));
123
116
 
124
- // Iterate over all changed package.jsons rather than only valid workspaces so that we can
125
- // remove older workspaces that are no longer valid
126
- _iterator = _createForOfIteratorHelper(changedPackageJsons);
127
- _context2.prev = 18;
128
- _iterator.s();
129
- case 20:
130
- if ((_step = _iterator.n()).done) {
131
- _context2.next = 33;
132
- break;
133
- }
134
- workspacePath = _step.value;
135
- _context2.next = 24;
136
- return this.getWorkspaceDependencies(hash, workspacePath);
137
- case 24:
138
- workspaceDeps = _context2.sent;
139
- validWorkspace = changedWorkspaces.includes(workspacePath);
140
- if (!(!validWorkspace && !this.workspaces[workspacePath])) {
141
- _context2.next = 28;
142
- break;
143
- }
144
- return _context2.abrupt("continue", 31);
145
- case 28:
146
- // For workspaces that are no longer a valid workspace but were previously, explicitly remove them
147
- noLongerWorkspace = !validWorkspace && this.workspaces[workspacePath];
148
- if (workspaceDeps == null || noLongerWorkspace) {
149
- // If workspaceDeps is undefined, package.json existed but JSON was invalid
150
- // Else if workspaceDeps is null, package.json doesn't exist and has hence been deleted
151
- if (workspaceDeps === undefined) {
152
- console.error("Error parsing metadata for workspace ".concat(workspacePath, "@").concat(hash));
153
- }
154
- // set the workspaceDeps to empty here explicitly to remove any deleted workspaces
155
- workspaceDeps = {};
156
- }
157
- this.updateWorkspaces(workspacePath, workspaceDeps);
158
- case 31:
159
- _context2.next = 20;
117
+ // Iterate over all changed package.jsons rather than only valid workspaces so that we can
118
+ // remove older workspaces that are no longer valid
119
+ _iterator = _createForOfIteratorHelper(changedPackageJsons);
120
+ _context2.prev = 18;
121
+ _iterator.s();
122
+ case 20:
123
+ if ((_step = _iterator.n()).done) {
124
+ _context2.next = 33;
160
125
  break;
161
- case 33:
162
- _context2.next = 38;
126
+ }
127
+ workspacePath = _step.value;
128
+ _context2.next = 24;
129
+ return this.getWorkspaceDependencies(hash, workspacePath);
130
+ case 24:
131
+ workspaceDeps = _context2.sent;
132
+ validWorkspace = changedWorkspaces.includes(workspacePath);
133
+ if (!(!validWorkspace && !this.workspaces[workspacePath])) {
134
+ _context2.next = 28;
163
135
  break;
164
- case 35:
165
- _context2.prev = 35;
166
- _context2.t0 = _context2["catch"](18);
167
- _iterator.e(_context2.t0);
168
- case 38:
169
- _context2.prev = 38;
170
- _iterator.f();
171
- return _context2.finish(38);
172
- case 41:
173
- return _context2.abrupt("return", this.getFlattenedDeps());
174
- case 42:
175
- case "end":
176
- return _context2.stop();
177
- }
136
+ }
137
+ return _context2.abrupt("continue", 31);
138
+ case 28:
139
+ // For workspaces that are no longer a valid workspace but were previously, explicitly remove them
140
+ noLongerWorkspace = !validWorkspace && this.workspaces[workspacePath];
141
+ if (workspaceDeps == null || noLongerWorkspace) {
142
+ // If workspaceDeps is undefined, package.json existed but JSON was invalid
143
+ // Else if workspaceDeps is null, package.json doesn't exist and has hence been deleted
144
+ if (workspaceDeps === undefined) {
145
+ console.error("Error parsing metadata for workspace ".concat(workspacePath, "@").concat(hash));
146
+ }
147
+ // set the workspaceDeps to empty here explicitly to remove any deleted workspaces
148
+ workspaceDeps = {};
149
+ }
150
+ this.updateWorkspaces(workspacePath, workspaceDeps);
151
+ case 31:
152
+ _context2.next = 20;
153
+ break;
154
+ case 33:
155
+ _context2.next = 38;
156
+ break;
157
+ case 35:
158
+ _context2.prev = 35;
159
+ _context2.t0 = _context2["catch"](18);
160
+ _iterator.e(_context2.t0);
161
+ case 38:
162
+ _context2.prev = 38;
163
+ _iterator.f();
164
+ return _context2.finish(38);
165
+ case 41:
166
+ return _context2.abrupt("return", this.getFlattenedDeps());
167
+ case 42:
168
+ case "end":
169
+ return _context2.stop();
178
170
  }
179
171
  }, _callee2, this, [[18, 35, 38, 41]]);
180
172
  }));
@@ -214,70 +206,68 @@ export var DependencyStore = /*#__PURE__*/function () {
214
206
  }, {
215
207
  key: "resetStore",
216
208
  value: function () {
217
- var _resetStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(gitRef) {
209
+ var _resetStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(gitRef) {
218
210
  var workspaceGlobs, workspacePaths, _iterator2, _step2, wsPath, workspaceDeps;
219
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
220
- while (1) {
221
- switch (_context3.prev = _context3.next) {
222
- case 0:
223
- this.dependencies = {};
224
- this.workspaces = {};
225
- _context3.next = 4;
226
- return getWorkspaceGlobs(gitRef, this.cwd);
227
- case 4:
228
- workspaceGlobs = _context3.sent;
229
- if (workspaceGlobs !== null) {
230
- this.workspaceGlobs = workspaceGlobs;
231
- }
232
- _context3.next = 8;
233
- return getWorkspacePaths(gitRef, this.workspaceGlobs, this.cwd);
234
- case 8:
235
- workspacePaths = _context3.sent;
236
- debug("Workspace paths: ".concat(workspacePaths));
237
- _iterator2 = _createForOfIteratorHelper(workspacePaths);
238
- _context3.prev = 11;
239
- _iterator2.s();
240
- case 13:
241
- if ((_step2 = _iterator2.n()).done) {
242
- _context3.next = 25;
243
- break;
244
- }
245
- wsPath = _step2.value;
246
- if (!this.workspaces[wsPath]) {
247
- _context3.next = 17;
248
- break;
249
- }
250
- throw new Error("Duplicate workspace path found: ".concat(wsPath));
251
- case 17:
252
- _context3.next = 19;
253
- return this.getWorkspaceDependencies(gitRef, wsPath);
254
- case 19:
255
- workspaceDeps = _context3.sent;
256
- if (!(workspaceDeps == null)) {
257
- _context3.next = 22;
258
- break;
259
- }
260
- return _context3.abrupt("continue", 23);
261
- case 22:
262
- this.updateWorkspaces(wsPath, workspaceDeps);
263
- case 23:
264
- _context3.next = 13;
211
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
212
+ while (1) switch (_context3.prev = _context3.next) {
213
+ case 0:
214
+ this.dependencies = {};
215
+ this.workspaces = {};
216
+ _context3.next = 4;
217
+ return getWorkspaceGlobs(gitRef, this.cwd);
218
+ case 4:
219
+ workspaceGlobs = _context3.sent;
220
+ if (workspaceGlobs !== null) {
221
+ this.workspaceGlobs = workspaceGlobs;
222
+ }
223
+ _context3.next = 8;
224
+ return getWorkspacePaths(gitRef, this.workspaceGlobs, this.cwd);
225
+ case 8:
226
+ workspacePaths = _context3.sent;
227
+ debug("Workspace paths: ".concat(workspacePaths));
228
+ _iterator2 = _createForOfIteratorHelper(workspacePaths);
229
+ _context3.prev = 11;
230
+ _iterator2.s();
231
+ case 13:
232
+ if ((_step2 = _iterator2.n()).done) {
233
+ _context3.next = 25;
234
+ break;
235
+ }
236
+ wsPath = _step2.value;
237
+ if (!this.workspaces[wsPath]) {
238
+ _context3.next = 17;
265
239
  break;
266
- case 25:
267
- _context3.next = 30;
240
+ }
241
+ throw new Error("Duplicate workspace path found: ".concat(wsPath));
242
+ case 17:
243
+ _context3.next = 19;
244
+ return this.getWorkspaceDependencies(gitRef, wsPath);
245
+ case 19:
246
+ workspaceDeps = _context3.sent;
247
+ if (!(workspaceDeps == null)) {
248
+ _context3.next = 22;
268
249
  break;
269
- case 27:
270
- _context3.prev = 27;
271
- _context3.t0 = _context3["catch"](11);
272
- _iterator2.e(_context3.t0);
273
- case 30:
274
- _context3.prev = 30;
275
- _iterator2.f();
276
- return _context3.finish(30);
277
- case 33:
278
- case "end":
279
- return _context3.stop();
280
- }
250
+ }
251
+ return _context3.abrupt("continue", 23);
252
+ case 22:
253
+ this.updateWorkspaces(wsPath, workspaceDeps);
254
+ case 23:
255
+ _context3.next = 13;
256
+ break;
257
+ case 25:
258
+ _context3.next = 30;
259
+ break;
260
+ case 27:
261
+ _context3.prev = 27;
262
+ _context3.t0 = _context3["catch"](11);
263
+ _iterator2.e(_context3.t0);
264
+ case 30:
265
+ _context3.prev = 30;
266
+ _iterator2.f();
267
+ return _context3.finish(30);
268
+ case 33:
269
+ case "end":
270
+ return _context3.stop();
281
271
  }
282
272
  }, _callee3, this, [[11, 27, 30, 33]]);
283
273
  }));
@@ -289,55 +279,53 @@ export var DependencyStore = /*#__PURE__*/function () {
289
279
  }, {
290
280
  key: "getWorkspaceDependencies",
291
281
  value: function () {
292
- var _getWorkspaceDependencies = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(hash, workspacePath) {
282
+ var _getWorkspaceDependencies = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(hash, workspacePath) {
293
283
  var file, json, workspaceDeps, _iterator3, _step3, _step3$value, packageJsonKey, depTypeName, wsDeps;
294
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
295
- while (1) {
296
- switch (_context4.prev = _context4.next) {
297
- case 0:
298
- _context4.prev = 0;
299
- _context4.next = 3;
300
- return showFile(hash, workspacePath, {
301
- cwd: this.cwd
302
- });
303
- case 3:
304
- file = _context4.sent;
305
- _context4.next = 10;
306
- break;
307
- case 6:
308
- _context4.prev = 6;
309
- _context4.t0 = _context4["catch"](0);
310
- debug("Could not show file ".concat(workspacePath, "@").concat(hash));
311
- return _context4.abrupt("return", null);
312
- case 10:
313
- _context4.prev = 10;
314
- json = JSON.parse(file);
315
- _context4.next = 18;
316
- break;
317
- case 14:
318
- _context4.prev = 14;
319
- _context4.t1 = _context4["catch"](10);
320
- console.error("Error parsing JSON - \"".concat(file, "\"@").concat(hash));
321
- return _context4.abrupt("return", undefined);
322
- case 18:
323
- workspaceDeps = {};
324
- _iterator3 = _createForOfIteratorHelper(DEP_TYPES);
325
- try {
326
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
327
- _step3$value = _step3.value, packageJsonKey = _step3$value.packageJsonKey, depTypeName = _step3$value.depTypeName;
328
- wsDeps = this.getSupportedDependencies(json[packageJsonKey] || {}, depTypeName);
329
- workspaceDeps = _objectSpread(_objectSpread({}, workspaceDeps), wsDeps);
330
- }
331
- } catch (err) {
332
- _iterator3.e(err);
333
- } finally {
334
- _iterator3.f();
284
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
285
+ while (1) switch (_context4.prev = _context4.next) {
286
+ case 0:
287
+ _context4.prev = 0;
288
+ _context4.next = 3;
289
+ return showFile(hash, workspacePath, {
290
+ cwd: this.cwd
291
+ });
292
+ case 3:
293
+ file = _context4.sent;
294
+ _context4.next = 10;
295
+ break;
296
+ case 6:
297
+ _context4.prev = 6;
298
+ _context4.t0 = _context4["catch"](0);
299
+ debug("Could not show file ".concat(workspacePath, "@").concat(hash));
300
+ return _context4.abrupt("return", null);
301
+ case 10:
302
+ _context4.prev = 10;
303
+ json = JSON.parse(file);
304
+ _context4.next = 18;
305
+ break;
306
+ case 14:
307
+ _context4.prev = 14;
308
+ _context4.t1 = _context4["catch"](10);
309
+ console.error("Error parsing JSON - \"".concat(file, "\"@").concat(hash));
310
+ return _context4.abrupt("return", undefined);
311
+ case 18:
312
+ workspaceDeps = {};
313
+ _iterator3 = _createForOfIteratorHelper(DEP_TYPES);
314
+ try {
315
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
316
+ _step3$value = _step3.value, packageJsonKey = _step3$value.packageJsonKey, depTypeName = _step3$value.depTypeName;
317
+ wsDeps = this.getSupportedDependencies(json[packageJsonKey] || {}, depTypeName);
318
+ workspaceDeps = _objectSpread(_objectSpread({}, workspaceDeps), wsDeps);
335
319
  }
336
- return _context4.abrupt("return", workspaceDeps);
337
- case 22:
338
- case "end":
339
- return _context4.stop();
340
- }
320
+ } catch (err) {
321
+ _iterator3.e(err);
322
+ } finally {
323
+ _iterator3.f();
324
+ }
325
+ return _context4.abrupt("return", workspaceDeps);
326
+ case 22:
327
+ case "end":
328
+ return _context4.stop();
341
329
  }
342
330
  }, _callee4, this, [[0, 6], [10, 14]]);
343
331
  }));