@atlaskit/dependency-version-analytics 0.4.2 → 1.1.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.
- package/CHANGELOG.md +12 -0
- package/README.md +2 -1
- package/dist/cjs/cli.js +4 -18
- package/dist/cjs/commands/populate-historic-data/index.js +0 -3
- package/dist/cjs/commands/populate-historic-data/lib/dependency-store.js +24 -141
- package/dist/cjs/commands/populate-historic-data/package.js +8 -29
- package/dist/cjs/commands/populate-historic-data/product.js +114 -150
- package/dist/cjs/commands/populate-historic-data/util/generate-csv.js +4 -16
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/util/analytics.js +16 -41
- package/dist/cjs/util/assert.js +0 -1
- package/dist/cjs/util/env-with-guard.js +0 -2
- package/dist/cjs/util/get-file-history-from-git.js +0 -5
- package/dist/cjs/util/get-package-version-history.js +8 -10
- package/dist/cjs/util/git.js +20 -58
- package/dist/cjs/util/statlas.js +0 -25
- package/dist/cjs/util/yarn.js +0 -32
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/cli.js +4 -8
- package/dist/es2019/commands/populate-historic-data/lib/dependency-store.js +24 -73
- package/dist/es2019/commands/populate-historic-data/package.js +7 -12
- package/dist/es2019/commands/populate-historic-data/product.js +21 -23
- package/dist/es2019/commands/populate-historic-data/util/generate-csv.js +2 -9
- package/dist/es2019/util/analytics.js +17 -19
- package/dist/es2019/util/env-with-guard.js +0 -1
- package/dist/es2019/util/get-file-history-from-git.js +2 -3
- package/dist/es2019/util/get-package-version-history.js +7 -7
- package/dist/es2019/util/git.js +29 -24
- package/dist/es2019/util/statlas.js +0 -6
- package/dist/es2019/util/yarn.js +2 -11
- package/dist/es2019/version.json +1 -1
- package/dist/esm/cli.js +6 -12
- package/dist/esm/commands/populate-historic-data/lib/dependency-store.js +27 -131
- package/dist/esm/commands/populate-historic-data/package.js +10 -24
- package/dist/esm/commands/populate-historic-data/product.js +114 -134
- package/dist/esm/commands/populate-historic-data/util/generate-csv.js +4 -13
- package/dist/esm/util/analytics.js +18 -31
- package/dist/esm/util/env-with-guard.js +0 -1
- package/dist/esm/util/get-file-history-from-git.js +2 -3
- package/dist/esm/util/get-package-version-history.js +7 -7
- package/dist/esm/util/git.js +21 -50
- package/dist/esm/util/statlas.js +0 -19
- package/dist/esm/util/yarn.js +0 -19
- package/dist/esm/version.json +1 -1
- package/dist/types/types.d.ts +7 -0
- package/dist/types/util/analytics.d.ts +2 -1
- package/dist/types/util/get-package-version-history.d.ts +7 -3
- package/package.json +3 -3
- package/report.api.md +5 -1
- package/tmp/api-report-tmp.d.ts +4 -0
|
@@ -4,20 +4,14 @@ 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
|
-
|
|
8
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; }
|
|
9
|
-
|
|
10
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; }
|
|
11
|
-
|
|
12
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; } } }; }
|
|
13
|
-
|
|
14
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); }
|
|
15
|
-
|
|
16
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; }
|
|
17
|
-
|
|
18
12
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
19
|
-
|
|
20
13
|
/** Workspace code */
|
|
14
|
+
|
|
21
15
|
import debugModule from 'debug';
|
|
22
16
|
import semver from 'semver';
|
|
23
17
|
import { getWorkspacePaths, getWorkspaceGlobs } from '../../../util/yarn';
|
|
@@ -26,7 +20,6 @@ import { DEP_TYPES } from '../../../constants';
|
|
|
26
20
|
import { assert } from '../../../util/assert';
|
|
27
21
|
import micromatch from 'micromatch';
|
|
28
22
|
var debug = debugModule('atlaskit:dependency');
|
|
29
|
-
|
|
30
23
|
/**
|
|
31
24
|
* Stores the state of atlaskit dependencies in a repository
|
|
32
25
|
*/
|
|
@@ -36,24 +29,18 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
36
29
|
/** Mapping of workspaces to their dependency map. Each dependency in their map links to an entry in `dependencies` */
|
|
37
30
|
|
|
38
31
|
/** Set of workspace globs. Used to verify that a package.json is a valid workspace */
|
|
32
|
+
|
|
39
33
|
function DependencyStore() {
|
|
40
34
|
var cwd = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : process.cwd();
|
|
41
|
-
|
|
42
35
|
_classCallCheck(this, DependencyStore);
|
|
43
|
-
|
|
44
36
|
_defineProperty(this, "dependencies", {});
|
|
45
|
-
|
|
46
37
|
_defineProperty(this, "workspaces", {});
|
|
47
|
-
|
|
48
38
|
_defineProperty(this, "workspaceGlobs", new Set());
|
|
49
|
-
|
|
50
39
|
_defineProperty(this, "initialised", false);
|
|
51
|
-
|
|
52
40
|
this.cwd = cwd;
|
|
53
41
|
}
|
|
54
|
-
/** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
|
|
55
|
-
|
|
56
42
|
|
|
43
|
+
/** Scans the repo for dependencies at the specified git ref and return the flattened dependency map */
|
|
57
44
|
_createClass(DependencyStore, [{
|
|
58
45
|
key: "initialise",
|
|
59
46
|
value: function () {
|
|
@@ -66,14 +53,11 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
66
53
|
_context.next = 3;
|
|
67
54
|
break;
|
|
68
55
|
}
|
|
69
|
-
|
|
70
56
|
_context.next = 3;
|
|
71
57
|
return this.resetStore(gitRef);
|
|
72
|
-
|
|
73
58
|
case 3:
|
|
74
59
|
this.initialised = true;
|
|
75
60
|
return _context.abrupt("return", this.getFlattenedDeps());
|
|
76
|
-
|
|
77
61
|
case 5:
|
|
78
62
|
case "end":
|
|
79
63
|
return _context.stop();
|
|
@@ -81,23 +65,19 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
81
65
|
}
|
|
82
66
|
}, _callee, this);
|
|
83
67
|
}));
|
|
84
|
-
|
|
85
68
|
function initialise(_x) {
|
|
86
69
|
return _initialise.apply(this, arguments);
|
|
87
70
|
}
|
|
88
|
-
|
|
89
71
|
return initialise;
|
|
90
72
|
}()
|
|
91
73
|
/** Updates the repo dependency store based on the changes in `logItem`.
|
|
92
74
|
* Returns the updated flattened dependencies
|
|
93
75
|
*/
|
|
94
|
-
|
|
95
76
|
}, {
|
|
96
77
|
key: "update",
|
|
97
78
|
value: function () {
|
|
98
79
|
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(logItem) {
|
|
99
80
|
var hash, changedPackageJsons, didRootPackageJsonChange, workspaceGlobs, globsChanged, changedWorkspaces, _iterator, _step, workspacePath, workspaceDeps, validWorkspace, noLongerWorkspace;
|
|
100
|
-
|
|
101
81
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
102
82
|
while (1) {
|
|
103
83
|
switch (_context2.prev = _context2.next) {
|
|
@@ -113,105 +93,80 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
113
93
|
didRootPackageJsonChange = !!changedPackageJsons.find(function (file) {
|
|
114
94
|
return file === 'package.json';
|
|
115
95
|
});
|
|
116
|
-
|
|
117
96
|
if (!didRootPackageJsonChange) {
|
|
118
97
|
_context2.next = 15;
|
|
119
98
|
break;
|
|
120
99
|
}
|
|
121
|
-
|
|
122
100
|
_context2.next = 8;
|
|
123
101
|
return getWorkspaceGlobs(hash, this.cwd);
|
|
124
|
-
|
|
125
102
|
case 8:
|
|
126
103
|
workspaceGlobs = _context2.sent;
|
|
127
104
|
globsChanged = workspaceGlobs !== null && (this.workspaceGlobs.size !== workspaceGlobs.size || _toConsumableArray(this.workspaceGlobs).some(function (glob) {
|
|
128
105
|
return !workspaceGlobs.has(glob);
|
|
129
106
|
}));
|
|
130
|
-
|
|
131
107
|
if (!globsChanged) {
|
|
132
108
|
_context2.next = 15;
|
|
133
109
|
break;
|
|
134
110
|
}
|
|
135
|
-
|
|
136
111
|
debug("Workspace globs changed: ".concat(_toConsumableArray(workspaceGlobs), ". Resetting store."));
|
|
137
112
|
_context2.next = 14;
|
|
138
113
|
return this.resetStore(hash);
|
|
139
|
-
|
|
140
114
|
case 14:
|
|
141
115
|
return _context2.abrupt("return", this.getFlattenedDeps());
|
|
142
|
-
|
|
143
116
|
case 15:
|
|
144
117
|
changedWorkspaces = micromatch(changedPackageJsons, _toConsumableArray(this.workspaceGlobs));
|
|
145
|
-
debug("Updating changed workspaces@".concat(hash, ": ").concat(changedWorkspaces));
|
|
146
|
-
// remove older workspaces that are no longer valid
|
|
118
|
+
debug("Updating changed workspaces@".concat(hash, ": ").concat(changedWorkspaces));
|
|
147
119
|
|
|
120
|
+
// Iterate over all changed package.jsons rather than only valid workspaces so that we can
|
|
121
|
+
// remove older workspaces that are no longer valid
|
|
148
122
|
_iterator = _createForOfIteratorHelper(changedPackageJsons);
|
|
149
123
|
_context2.prev = 18;
|
|
150
|
-
|
|
151
124
|
_iterator.s();
|
|
152
|
-
|
|
153
125
|
case 20:
|
|
154
126
|
if ((_step = _iterator.n()).done) {
|
|
155
127
|
_context2.next = 33;
|
|
156
128
|
break;
|
|
157
129
|
}
|
|
158
|
-
|
|
159
130
|
workspacePath = _step.value;
|
|
160
131
|
_context2.next = 24;
|
|
161
132
|
return this.getWorkspaceDependencies(hash, workspacePath);
|
|
162
|
-
|
|
163
133
|
case 24:
|
|
164
134
|
workspaceDeps = _context2.sent;
|
|
165
135
|
validWorkspace = changedWorkspaces.includes(workspacePath);
|
|
166
|
-
|
|
167
136
|
if (!(!validWorkspace && !this.workspaces[workspacePath])) {
|
|
168
137
|
_context2.next = 28;
|
|
169
138
|
break;
|
|
170
139
|
}
|
|
171
|
-
|
|
172
140
|
return _context2.abrupt("continue", 31);
|
|
173
|
-
|
|
174
141
|
case 28:
|
|
175
142
|
// For workspaces that are no longer a valid workspace but were previously, explicitly remove them
|
|
176
143
|
noLongerWorkspace = !validWorkspace && this.workspaces[workspacePath];
|
|
177
|
-
|
|
178
144
|
if (workspaceDeps == null || noLongerWorkspace) {
|
|
179
145
|
// If workspaceDeps is undefined, package.json existed but JSON was invalid
|
|
180
146
|
// Else if workspaceDeps is null, package.json doesn't exist and has hence been deleted
|
|
181
147
|
if (workspaceDeps === undefined) {
|
|
182
148
|
console.error("Error parsing metadata for workspace ".concat(workspacePath, "@").concat(hash));
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
149
|
+
}
|
|
150
|
+
// set the workspaceDeps to empty here explicitly to remove any deleted workspaces
|
|
186
151
|
workspaceDeps = {};
|
|
187
152
|
}
|
|
188
|
-
|
|
189
153
|
this.updateWorkspaces(workspacePath, workspaceDeps);
|
|
190
|
-
|
|
191
154
|
case 31:
|
|
192
155
|
_context2.next = 20;
|
|
193
156
|
break;
|
|
194
|
-
|
|
195
157
|
case 33:
|
|
196
158
|
_context2.next = 38;
|
|
197
159
|
break;
|
|
198
|
-
|
|
199
160
|
case 35:
|
|
200
161
|
_context2.prev = 35;
|
|
201
162
|
_context2.t0 = _context2["catch"](18);
|
|
202
|
-
|
|
203
163
|
_iterator.e(_context2.t0);
|
|
204
|
-
|
|
205
164
|
case 38:
|
|
206
165
|
_context2.prev = 38;
|
|
207
|
-
|
|
208
166
|
_iterator.f();
|
|
209
|
-
|
|
210
167
|
return _context2.finish(38);
|
|
211
|
-
|
|
212
168
|
case 41:
|
|
213
169
|
return _context2.abrupt("return", this.getFlattenedDeps());
|
|
214
|
-
|
|
215
170
|
case 42:
|
|
216
171
|
case "end":
|
|
217
172
|
return _context2.stop();
|
|
@@ -219,31 +174,26 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
219
174
|
}
|
|
220
175
|
}, _callee2, this, [[18, 35, 38, 41]]);
|
|
221
176
|
}));
|
|
222
|
-
|
|
223
177
|
function update(_x2) {
|
|
224
178
|
return _update.apply(this, arguments);
|
|
225
179
|
}
|
|
226
|
-
|
|
227
180
|
return update;
|
|
228
181
|
}()
|
|
229
182
|
/** Retrieve a flattened list of p repo dependencies.
|
|
230
183
|
* If multiple versions of a dependency exist, the lowest version is returned.
|
|
231
184
|
* If the dependency is listed under multiple dependency types, 'dependencies' is prioritised over 'devDependencies'
|
|
232
185
|
*/
|
|
233
|
-
|
|
234
186
|
}, {
|
|
235
187
|
key: "getFlattenedDeps",
|
|
236
188
|
value: function getFlattenedDeps() {
|
|
237
189
|
var deps = Object.entries(this.dependencies).filter(function (_ref) {
|
|
238
190
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
239
|
-
|
|
240
|
-
|
|
191
|
+
versions = _ref2[1];
|
|
241
192
|
return versions.length > 0;
|
|
242
193
|
}).map(function (_ref3) {
|
|
243
194
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
195
|
+
depName = _ref4[0],
|
|
196
|
+
versions = _ref4[1];
|
|
247
197
|
return [depName, DependencyStore.getMinimumVersion(versions, depName)];
|
|
248
198
|
});
|
|
249
199
|
return fromEntries(deps);
|
|
@@ -255,14 +205,13 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
255
205
|
throw new Error('Class must be initialised first with `.initialise()`');
|
|
256
206
|
}
|
|
257
207
|
}
|
|
258
|
-
/** Scans all workspaces in repo and rebuilds dependency store */
|
|
259
208
|
|
|
209
|
+
/** Scans all workspaces in repo and rebuilds dependency store */
|
|
260
210
|
}, {
|
|
261
211
|
key: "resetStore",
|
|
262
212
|
value: function () {
|
|
263
213
|
var _resetStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(gitRef) {
|
|
264
214
|
var workspaceGlobs, workspacePaths, _iterator2, _step2, wsPath, workspaceDeps;
|
|
265
|
-
|
|
266
215
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
267
216
|
while (1) {
|
|
268
217
|
switch (_context3.prev = _context3.next) {
|
|
@@ -271,78 +220,56 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
271
220
|
this.workspaces = {};
|
|
272
221
|
_context3.next = 4;
|
|
273
222
|
return getWorkspaceGlobs(gitRef, this.cwd);
|
|
274
|
-
|
|
275
223
|
case 4:
|
|
276
224
|
workspaceGlobs = _context3.sent;
|
|
277
|
-
|
|
278
225
|
if (workspaceGlobs !== null) {
|
|
279
226
|
this.workspaceGlobs = workspaceGlobs;
|
|
280
227
|
}
|
|
281
|
-
|
|
282
228
|
_context3.next = 8;
|
|
283
229
|
return getWorkspacePaths(gitRef, this.workspaceGlobs, this.cwd);
|
|
284
|
-
|
|
285
230
|
case 8:
|
|
286
231
|
workspacePaths = _context3.sent;
|
|
287
232
|
debug("Workspace paths: ".concat(workspacePaths));
|
|
288
233
|
_iterator2 = _createForOfIteratorHelper(workspacePaths);
|
|
289
234
|
_context3.prev = 11;
|
|
290
|
-
|
|
291
235
|
_iterator2.s();
|
|
292
|
-
|
|
293
236
|
case 13:
|
|
294
237
|
if ((_step2 = _iterator2.n()).done) {
|
|
295
238
|
_context3.next = 25;
|
|
296
239
|
break;
|
|
297
240
|
}
|
|
298
|
-
|
|
299
241
|
wsPath = _step2.value;
|
|
300
|
-
|
|
301
242
|
if (!this.workspaces[wsPath]) {
|
|
302
243
|
_context3.next = 17;
|
|
303
244
|
break;
|
|
304
245
|
}
|
|
305
|
-
|
|
306
246
|
throw new Error("Duplicate workspace path found: ".concat(wsPath));
|
|
307
|
-
|
|
308
247
|
case 17:
|
|
309
248
|
_context3.next = 19;
|
|
310
249
|
return this.getWorkspaceDependencies(gitRef, wsPath);
|
|
311
|
-
|
|
312
250
|
case 19:
|
|
313
251
|
workspaceDeps = _context3.sent;
|
|
314
|
-
|
|
315
252
|
if (!(workspaceDeps == null)) {
|
|
316
253
|
_context3.next = 22;
|
|
317
254
|
break;
|
|
318
255
|
}
|
|
319
|
-
|
|
320
256
|
return _context3.abrupt("continue", 23);
|
|
321
|
-
|
|
322
257
|
case 22:
|
|
323
258
|
this.updateWorkspaces(wsPath, workspaceDeps);
|
|
324
|
-
|
|
325
259
|
case 23:
|
|
326
260
|
_context3.next = 13;
|
|
327
261
|
break;
|
|
328
|
-
|
|
329
262
|
case 25:
|
|
330
263
|
_context3.next = 30;
|
|
331
264
|
break;
|
|
332
|
-
|
|
333
265
|
case 27:
|
|
334
266
|
_context3.prev = 27;
|
|
335
267
|
_context3.t0 = _context3["catch"](11);
|
|
336
|
-
|
|
337
268
|
_iterator2.e(_context3.t0);
|
|
338
|
-
|
|
339
269
|
case 30:
|
|
340
270
|
_context3.prev = 30;
|
|
341
|
-
|
|
342
271
|
_iterator2.f();
|
|
343
|
-
|
|
344
272
|
return _context3.finish(30);
|
|
345
|
-
|
|
346
273
|
case 33:
|
|
347
274
|
case "end":
|
|
348
275
|
return _context3.stop();
|
|
@@ -350,11 +277,9 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
350
277
|
}
|
|
351
278
|
}, _callee3, this, [[11, 27, 30, 33]]);
|
|
352
279
|
}));
|
|
353
|
-
|
|
354
280
|
function resetStore(_x3) {
|
|
355
281
|
return _resetStore.apply(this, arguments);
|
|
356
282
|
}
|
|
357
|
-
|
|
358
283
|
return resetStore;
|
|
359
284
|
}()
|
|
360
285
|
}, {
|
|
@@ -362,7 +287,6 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
362
287
|
value: function () {
|
|
363
288
|
var _getWorkspaceDependencies = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(hash, workspacePath) {
|
|
364
289
|
var file, json, workspaceDeps, _iterator3, _step3, _step3$value, packageJsonKey, depTypeName, wsDeps;
|
|
365
|
-
|
|
366
290
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
367
291
|
while (1) {
|
|
368
292
|
switch (_context4.prev = _context4.next) {
|
|
@@ -372,34 +296,28 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
372
296
|
return showFile(hash, workspacePath, {
|
|
373
297
|
cwd: this.cwd
|
|
374
298
|
});
|
|
375
|
-
|
|
376
299
|
case 3:
|
|
377
300
|
file = _context4.sent;
|
|
378
301
|
_context4.next = 10;
|
|
379
302
|
break;
|
|
380
|
-
|
|
381
303
|
case 6:
|
|
382
304
|
_context4.prev = 6;
|
|
383
305
|
_context4.t0 = _context4["catch"](0);
|
|
384
306
|
debug("Could not show file ".concat(workspacePath, "@").concat(hash));
|
|
385
307
|
return _context4.abrupt("return", null);
|
|
386
|
-
|
|
387
308
|
case 10:
|
|
388
309
|
_context4.prev = 10;
|
|
389
310
|
json = JSON.parse(file);
|
|
390
311
|
_context4.next = 18;
|
|
391
312
|
break;
|
|
392
|
-
|
|
393
313
|
case 14:
|
|
394
314
|
_context4.prev = 14;
|
|
395
315
|
_context4.t1 = _context4["catch"](10);
|
|
396
316
|
console.error("Error parsing JSON - \"".concat(file, "\"@").concat(hash));
|
|
397
317
|
return _context4.abrupt("return", undefined);
|
|
398
|
-
|
|
399
318
|
case 18:
|
|
400
319
|
workspaceDeps = {};
|
|
401
320
|
_iterator3 = _createForOfIteratorHelper(DEP_TYPES);
|
|
402
|
-
|
|
403
321
|
try {
|
|
404
322
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
405
323
|
_step3$value = _step3.value, packageJsonKey = _step3$value.packageJsonKey, depTypeName = _step3$value.depTypeName;
|
|
@@ -411,9 +329,7 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
411
329
|
} finally {
|
|
412
330
|
_iterator3.f();
|
|
413
331
|
}
|
|
414
|
-
|
|
415
332
|
return _context4.abrupt("return", workspaceDeps);
|
|
416
|
-
|
|
417
333
|
case 22:
|
|
418
334
|
case "end":
|
|
419
335
|
return _context4.stop();
|
|
@@ -421,39 +337,31 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
421
337
|
}
|
|
422
338
|
}, _callee4, this, [[0, 6], [10, 14]]);
|
|
423
339
|
}));
|
|
424
|
-
|
|
425
340
|
function getWorkspaceDependencies(_x4, _x5) {
|
|
426
341
|
return _getWorkspaceDependencies.apply(this, arguments);
|
|
427
342
|
}
|
|
428
|
-
|
|
429
343
|
return getWorkspaceDependencies;
|
|
430
344
|
}()
|
|
431
345
|
}, {
|
|
432
346
|
key: "updateWorkspaces",
|
|
433
347
|
value: function updateWorkspaces(workspacePath, workspaceDeps) {
|
|
434
348
|
debug("Updating workspace ".concat(workspacePath));
|
|
435
|
-
|
|
436
349
|
if (!this.workspaces[workspacePath]) {
|
|
437
350
|
this.workspaces[workspacePath] = {};
|
|
438
351
|
}
|
|
439
|
-
|
|
440
352
|
var prevWorkspaceDeps = this.workspaces[workspacePath];
|
|
441
|
-
|
|
442
353
|
for (var _i = 0, _Object$keys = Object.keys(prevWorkspaceDeps); _i < _Object$keys.length; _i++) {
|
|
443
354
|
var depName = _Object$keys[_i];
|
|
444
|
-
|
|
445
355
|
if (!workspaceDeps[depName]) {
|
|
446
356
|
this.removeDependency(workspacePath, depName, prevWorkspaceDeps[depName]);
|
|
447
357
|
}
|
|
448
358
|
}
|
|
449
|
-
|
|
450
359
|
for (var _i2 = 0, _Object$entries = Object.entries(workspaceDeps); _i2 < _Object$entries.length; _i2++) {
|
|
451
360
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
361
|
+
_depName = _Object$entries$_i[0],
|
|
362
|
+
_Object$entries$_i$ = _Object$entries$_i[1],
|
|
363
|
+
version = _Object$entries$_i$.version,
|
|
364
|
+
type = _Object$entries$_i$.type;
|
|
457
365
|
this.addDependency(workspacePath, _depName, version, type);
|
|
458
366
|
}
|
|
459
367
|
}
|
|
@@ -464,21 +372,17 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
464
372
|
debug("Adding new dep ".concat(depName));
|
|
465
373
|
this.dependencies[depName] = [];
|
|
466
374
|
}
|
|
467
|
-
|
|
468
375
|
var prevEntry = this.workspaces[workspacePath][depName];
|
|
469
376
|
var existingEntry = this.dependencies[depName].find(function (entry) {
|
|
470
377
|
return entry.version === version && entry.type === type;
|
|
471
378
|
});
|
|
472
|
-
|
|
473
379
|
if (existingEntry && existingEntry === prevEntry) {
|
|
474
380
|
// We haven't added or updated the dep, exit early
|
|
475
381
|
return;
|
|
476
382
|
}
|
|
477
|
-
|
|
478
383
|
if (prevEntry) {
|
|
479
384
|
this.removeDependency(workspacePath, depName, prevEntry);
|
|
480
385
|
}
|
|
481
|
-
|
|
482
386
|
if (existingEntry) {
|
|
483
387
|
existingEntry.workspaces.add(workspacePath);
|
|
484
388
|
this.workspaces[workspacePath][depName] = existingEntry;
|
|
@@ -499,7 +403,6 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
499
403
|
debug("".concat(depName, " removed from ").concat(workspacePath));
|
|
500
404
|
assert(depEntry && depEntry.workspaces, "Dep entry should exist for ".concat(depName));
|
|
501
405
|
depEntry.workspaces.delete(workspacePath);
|
|
502
|
-
|
|
503
406
|
if (depEntry.workspaces.size === 0) {
|
|
504
407
|
debug("No more workspaces depend on ".concat(depName, "@").concat(depEntry.version, " as a ").concat(depEntry.type, ", deleting"));
|
|
505
408
|
this.dependencies[depName] = this.dependencies[depName].filter(function (entry) {
|
|
@@ -510,17 +413,16 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
510
413
|
}], [{
|
|
511
414
|
key: "getAkDependencies",
|
|
512
415
|
value: function getAkDependencies(depMap, type) {
|
|
513
|
-
return fromEntries(Object.entries(depMap).filter(
|
|
416
|
+
return fromEntries(Object.entries(depMap).filter(
|
|
417
|
+
// Ignore suffixed `--next` deps in jira used for independent upgrades
|
|
514
418
|
function (_ref5) {
|
|
515
419
|
var _ref6 = _slicedToArray(_ref5, 1),
|
|
516
|
-
|
|
517
|
-
|
|
420
|
+
name = _ref6[0];
|
|
518
421
|
return name.includes('@atlaskit') && !name.endsWith('--next');
|
|
519
422
|
}).map(function (_ref7) {
|
|
520
423
|
var _ref8 = _slicedToArray(_ref7, 2),
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
424
|
+
name = _ref8[0],
|
|
425
|
+
version = _ref8[1];
|
|
524
426
|
return [DependencyStore.transformDepName(name), {
|
|
525
427
|
version: DependencyStore.transformDepVersion(version),
|
|
526
428
|
type: type
|
|
@@ -530,18 +432,15 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
530
432
|
}, {
|
|
531
433
|
key: "getMinimumVersion",
|
|
532
434
|
value: function getMinimumVersion(versions, depName) {
|
|
533
|
-
var depOrder = ['dependency', 'peerDependency', 'devDependency', 'optionalDependency'];
|
|
534
|
-
|
|
435
|
+
var depOrder = ['dependency', 'peerDependency', 'devDependency', 'optionalDependency'];
|
|
436
|
+
// Sort deps before devDeps and then take the lowest version
|
|
535
437
|
var sorted = versions.sort(function (a, b) {
|
|
536
438
|
var depSort = depOrder.indexOf(a.type) - depOrder.indexOf(b.type);
|
|
537
|
-
|
|
538
439
|
if (depSort !== 0) {
|
|
539
440
|
return depSort;
|
|
540
441
|
}
|
|
541
|
-
|
|
542
442
|
var aVersion = semver.coerce(a.version);
|
|
543
443
|
var bVersion = semver.coerce(b.version);
|
|
544
|
-
|
|
545
444
|
if (!aVersion) {
|
|
546
445
|
console.error("Invalid version ".concat(depName, "@").concat(a.version));
|
|
547
446
|
return 1;
|
|
@@ -549,10 +448,8 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
549
448
|
console.error("Invalid version ".concat(depName, "@").concat(b.version));
|
|
550
449
|
return -1;
|
|
551
450
|
}
|
|
552
|
-
|
|
553
451
|
return semver.compare(aVersion, bVersion);
|
|
554
452
|
});
|
|
555
|
-
|
|
556
453
|
if (sorted.length > 1) {
|
|
557
454
|
debug("Multiple versions found for ".concat(depName, ": ").concat(JSON.stringify(sorted.map(function (depInfo) {
|
|
558
455
|
return _objectSpread(_objectSpread({}, depInfo), {}, {
|
|
@@ -560,7 +457,6 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
560
457
|
});
|
|
561
458
|
}))));
|
|
562
459
|
}
|
|
563
|
-
|
|
564
460
|
return sorted[0];
|
|
565
461
|
}
|
|
566
462
|
}, {
|
|
@@ -569,12 +465,12 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
569
465
|
// Treat `--current` as the standard dependency
|
|
570
466
|
return name.replace(/--current$/, '');
|
|
571
467
|
}
|
|
468
|
+
|
|
572
469
|
/* Coerce non-standard versions to a semver version.
|
|
573
470
|
* This essentially ignores everything up until the first number and then tries to parse a version
|
|
574
471
|
* out of that.
|
|
575
472
|
* Used to yarn alias versions used by jira's independent upgrades, e.g. npm:@atlaskit/button@^15.0.8
|
|
576
473
|
*/
|
|
577
|
-
|
|
578
474
|
}, {
|
|
579
475
|
key: "transformDepVersion",
|
|
580
476
|
value: function transformDepVersion(version) {
|
|
@@ -582,14 +478,14 @@ export var DependencyStore = /*#__PURE__*/function () {
|
|
|
582
478
|
return parts[parts.length - 1];
|
|
583
479
|
}
|
|
584
480
|
}]);
|
|
585
|
-
|
|
586
481
|
return DependencyStore;
|
|
587
|
-
}();
|
|
482
|
+
}();
|
|
588
483
|
|
|
484
|
+
// Object.fromEntries polyfill, remove when upgraded to node 10
|
|
589
485
|
function fromEntries(iterable) {
|
|
590
486
|
return _toConsumableArray(iterable).reduce(function (obj, _ref9) {
|
|
591
487
|
var key = _ref9[0],
|
|
592
|
-
|
|
488
|
+
val = _ref9[1];
|
|
593
489
|
return Object.assign(obj, _defineProperty({}, key, val));
|
|
594
490
|
}, {});
|
|
595
491
|
}
|
|
@@ -2,41 +2,38 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import semver from 'semver';
|
|
5
|
-
import
|
|
5
|
+
import getPackageVersionHistoryAndTags from '../../util/get-package-version-history';
|
|
6
6
|
import { createUpgradeEvent, sendAnalytics } from '../../util/analytics';
|
|
7
|
-
|
|
8
|
-
var
|
|
7
|
+
var createAnalyticsEvents = function createAnalyticsEvents(packageName, packageVersionHistoryAndTags, since) {
|
|
8
|
+
var packageVersionHistory = packageVersionHistoryAndTags['time'];
|
|
9
|
+
var tags = packageVersionHistoryAndTags['dist-tags'];
|
|
9
10
|
var sortedPackageVersionHistory = Object.entries(packageVersionHistory).filter(function (_ref) {
|
|
10
11
|
var _ref2 = _slicedToArray(_ref, 1),
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
version = _ref2[0];
|
|
13
13
|
return semver.valid(version);
|
|
14
14
|
}).sort(function (a, b) {
|
|
15
15
|
return Number(new Date(a[1])) - Number(new Date(b[1]));
|
|
16
16
|
});
|
|
17
17
|
var upgradeEvents = sortedPackageVersionHistory.map(function (_ref3, i) {
|
|
18
18
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
version = _ref4[0],
|
|
20
|
+
time = _ref4[1];
|
|
22
21
|
if (since && Number(new Date(time)) <= Number(new Date(since))) {
|
|
23
22
|
return null;
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
var previousVersion = sortedPackageVersionHistory[i - 1] && sortedPackageVersionHistory[i - 1][0];
|
|
27
25
|
return createUpgradeEvent(packageName, version, previousVersion, time, {
|
|
28
|
-
historical: true
|
|
26
|
+
historical: true,
|
|
27
|
+
tags: tags
|
|
29
28
|
});
|
|
30
29
|
}).filter(function (e) {
|
|
31
30
|
return e != null;
|
|
32
31
|
});
|
|
33
32
|
return upgradeEvents;
|
|
34
33
|
};
|
|
35
|
-
|
|
36
34
|
export default function populatePackage(_x) {
|
|
37
35
|
return _populatePackage.apply(this, arguments);
|
|
38
36
|
}
|
|
39
|
-
|
|
40
37
|
function _populatePackage() {
|
|
41
38
|
_populatePackage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(flags) {
|
|
42
39
|
var packageVersionHistory, analyticsEvents;
|
|
@@ -48,34 +45,25 @@ function _populatePackage() {
|
|
|
48
45
|
_context.next = 2;
|
|
49
46
|
break;
|
|
50
47
|
}
|
|
51
|
-
|
|
52
48
|
throw new Error("Package must start with '@atlaskit/'");
|
|
53
|
-
|
|
54
49
|
case 2:
|
|
55
50
|
_context.next = 4;
|
|
56
|
-
return
|
|
57
|
-
|
|
51
|
+
return getPackageVersionHistoryAndTags(flags.pkg);
|
|
58
52
|
case 4:
|
|
59
53
|
packageVersionHistory = _context.sent;
|
|
60
|
-
|
|
61
54
|
if (!(flags.since && Number.isNaN(Number(new Date(flags.since))))) {
|
|
62
55
|
_context.next = 7;
|
|
63
56
|
break;
|
|
64
57
|
}
|
|
65
|
-
|
|
66
58
|
throw new Error("'since' flag is an invalid date");
|
|
67
|
-
|
|
68
59
|
case 7:
|
|
69
60
|
analyticsEvents = createAnalyticsEvents(flags.pkg, packageVersionHistory, flags.since);
|
|
70
|
-
|
|
71
61
|
if (!flags.dryRun) {
|
|
72
62
|
_context.next = 11;
|
|
73
63
|
break;
|
|
74
64
|
}
|
|
75
|
-
|
|
76
65
|
console.log(JSON.stringify(analyticsEvents));
|
|
77
66
|
return _context.abrupt("return", analyticsEvents);
|
|
78
|
-
|
|
79
67
|
case 11:
|
|
80
68
|
_context.next = 13;
|
|
81
69
|
return sendAnalytics(analyticsEvents, {
|
|
@@ -84,10 +72,8 @@ function _populatePackage() {
|
|
|
84
72
|
product: 'atlaskit',
|
|
85
73
|
skipPrompt: !flags.interactive
|
|
86
74
|
});
|
|
87
|
-
|
|
88
75
|
case 13:
|
|
89
76
|
return _context.abrupt("return", analyticsEvents);
|
|
90
|
-
|
|
91
77
|
case 14:
|
|
92
78
|
case "end":
|
|
93
79
|
return _context.stop();
|