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