@atlaskit/dependency-version-analytics 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +5 -3
- package/dist/cjs/cli.js +52 -17
- package/dist/cjs/commands/populate-historic-data/index.js +2 -2
- package/dist/cjs/commands/populate-historic-data/lib/dependency-store.js +227 -451
- package/dist/cjs/commands/populate-historic-data/package.js +31 -75
- package/dist/cjs/commands/populate-historic-data/product.js +129 -289
- package/dist/cjs/commands/populate-historic-data/util/allowed-scopes.js +15 -0
- package/dist/cjs/commands/populate-historic-data/util/generate-csv.js +16 -21
- package/dist/cjs/constants.js +2 -2
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/util/analytics.js +78 -102
- package/dist/cjs/util/get-file-history-from-git.js +4 -4
- package/dist/cjs/util/get-package-version-history.js +7 -5
- package/dist/cjs/util/git.js +75 -205
- package/dist/cjs/util/statlas.js +27 -97
- package/dist/cjs/util/yarn.js +40 -101
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/cli.js +10 -4
- package/dist/es2019/commands/populate-historic-data/lib/dependency-store.js +6 -4
- package/dist/es2019/commands/populate-historic-data/package.js +6 -5
- package/dist/es2019/commands/populate-historic-data/product.js +8 -6
- package/dist/es2019/commands/populate-historic-data/util/allowed-scopes.js +7 -0
- package/dist/es2019/commands/populate-historic-data/util/generate-csv.js +1 -1
- package/dist/es2019/util/analytics.js +5 -4
- package/dist/es2019/util/get-package-version-history.js +2 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/cli.js +8 -3
- package/dist/esm/commands/populate-historic-data/lib/dependency-store.js +20 -15
- package/dist/esm/commands/populate-historic-data/package.js +22 -20
- package/dist/esm/commands/populate-historic-data/product.js +45 -42
- package/dist/esm/commands/populate-historic-data/util/allowed-scopes.js +11 -0
- package/dist/esm/commands/populate-historic-data/util/generate-csv.js +1 -1
- package/dist/esm/util/analytics.js +10 -7
- package/dist/esm/util/get-package-version-history.js +2 -0
- package/dist/esm/util/git.js +14 -13
- package/dist/esm/util/statlas.js +8 -7
- package/dist/esm/util/yarn.js +6 -5
- package/dist/esm/version.json +1 -1
- package/dist/types/commands/populate-historic-data/lib/dependency-store.d.ts +3 -2
- package/dist/types/commands/populate-historic-data/types.d.ts +3 -2
- package/dist/types/commands/populate-historic-data/util/allowed-scopes.d.ts +2 -0
- package/dist/types/commands/populate-historic-data/util/generate-csv.d.ts +2 -2
- package/dist/types/util/analytics.d.ts +2 -3
- package/package.json +2 -2
- package/report.api.md +1 -0
- package/tmp/api-report-tmp.d.ts +1 -0
- package/tokenize-arg-string.ts +0 -0
package/dist/cjs/util/git.js
CHANGED
|
@@ -11,54 +11,29 @@ exports.getHash = getHash;
|
|
|
11
11
|
exports.refetchTag = refetchTag;
|
|
12
12
|
exports.showFile = showFile;
|
|
13
13
|
exports.tagCommit = tagCommit;
|
|
14
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
18
14
|
var _simpleGit = _interopRequireDefault(require("simple-git"));
|
|
19
15
|
var _assert = require("./assert");
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function getChangesSince(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Show filename changes - simple-git parses --stat flag but not --name-only unfortunately
|
|
42
|
-
'--stat=4096',
|
|
43
|
-
// Make +- graph width as small as possible to maximise filename length
|
|
44
|
-
'--stat-graph-width=1'].concat(revisionRange, [
|
|
45
|
-
// Any commit that modifies a package.json
|
|
46
|
-
':(glob)**/package.json']));
|
|
47
|
-
case 3:
|
|
48
|
-
listLogSummary = _context.sent;
|
|
49
|
-
return _context.abrupt("return", _objectSpread(_objectSpread({}, listLogSummary), {}, {
|
|
50
|
-
all: listLogSummary.all.map(function (logLine) {
|
|
51
|
-
return parseLogLine(logLine);
|
|
52
|
-
})
|
|
53
|
-
}));
|
|
54
|
-
case 5:
|
|
55
|
-
case "end":
|
|
56
|
-
return _context.stop();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}, _callee);
|
|
60
|
-
}));
|
|
61
|
-
return _getChangesSince.apply(this, arguments);
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
|
|
18
|
+
async function getChangesSince(since) {
|
|
19
|
+
const revisionRange = since ? [`${since}..`] : [];
|
|
20
|
+
const listLogSummary = await (0, _simpleGit.default)().log([
|
|
21
|
+
// Only commits on mainline master
|
|
22
|
+
'--first-parent',
|
|
23
|
+
// Show merge commit contents
|
|
24
|
+
'-m',
|
|
25
|
+
// Reverse the order
|
|
26
|
+
'--reverse',
|
|
27
|
+
// Show filename changes - simple-git parses --stat flag but not --name-only unfortunately
|
|
28
|
+
'--stat=4096',
|
|
29
|
+
// Make +- graph width as small as possible to maximise filename length
|
|
30
|
+
'--stat-graph-width=1', ...revisionRange,
|
|
31
|
+
// Any commit that modifies a package.json
|
|
32
|
+
':(glob)**/package.json']);
|
|
33
|
+
return {
|
|
34
|
+
...listLogSummary,
|
|
35
|
+
all: listLogSummary.all.map(logLine => parseLogLine(logLine))
|
|
36
|
+
};
|
|
62
37
|
}
|
|
63
38
|
function parseLogLine(logLine) {
|
|
64
39
|
if (!logLine.diff) {
|
|
@@ -66,185 +41,80 @@ function parseLogLine(logLine) {
|
|
|
66
41
|
}
|
|
67
42
|
|
|
68
43
|
// Split files into separate entries when a rename has occurred so both old and new files are processed
|
|
69
|
-
|
|
70
|
-
|
|
44
|
+
const parsedDiffFiles = logLine.diff.files.reduce((acc, curr) => {
|
|
45
|
+
const renameArrowCount = curr.file.match(/ => /g);
|
|
71
46
|
if (renameArrowCount == null) {
|
|
72
|
-
return [
|
|
47
|
+
return [...acc, curr];
|
|
73
48
|
}
|
|
74
49
|
// Multiple rename parts are not supported. They most likely don't exist in git but we check
|
|
75
50
|
// for them anyway just in case
|
|
76
|
-
(0, _assert.assert)(renameArrowCount.length === 1,
|
|
51
|
+
(0, _assert.assert)(renameArrowCount.length === 1, `Multiple rename parts detected: ${curr.file}`);
|
|
77
52
|
/* Matches:
|
|
78
53
|
* - '{new-frontend/src => src}/package.json'
|
|
79
54
|
* - 'new-frontend/.prettierrc.js => .prettierrc.js'
|
|
80
55
|
* - 'src/{ => platform}/analytics/package.json'
|
|
81
56
|
* - 'src/packages/spa/{main => }/package.json'
|
|
82
57
|
*/
|
|
83
|
-
|
|
84
|
-
(0, _assert.assert)(renameMatch != null,
|
|
85
|
-
|
|
58
|
+
const renameMatch = curr.file.match(/\{?([^{]+)? => ([^}]+)?\}?/);
|
|
59
|
+
(0, _assert.assert)(renameMatch != null, `Invalid rename format ${curr.file}`);
|
|
60
|
+
const oldFile = curr.file.replace(renameMatch[0], renameMatch[1] || '')
|
|
86
61
|
// If the previous name segment is empty, we will have a double slash
|
|
87
62
|
.replace('//', '/');
|
|
88
|
-
|
|
89
|
-
return [
|
|
63
|
+
const newFile = curr.file.replace(renameMatch[0], renameMatch[2] || '').replace('//', '/');
|
|
64
|
+
return [...acc, {
|
|
65
|
+
...curr,
|
|
90
66
|
file: oldFile
|
|
91
|
-
}
|
|
67
|
+
}, {
|
|
68
|
+
...curr,
|
|
92
69
|
file: newFile
|
|
93
|
-
}
|
|
70
|
+
}];
|
|
94
71
|
}, []);
|
|
95
|
-
return
|
|
96
|
-
|
|
72
|
+
return {
|
|
73
|
+
...logLine,
|
|
74
|
+
diff: {
|
|
75
|
+
...logLine.diff,
|
|
97
76
|
files: parsedDiffFiles
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function tagCommit(_x2) {
|
|
102
|
-
return _tagCommit.apply(this, arguments);
|
|
103
|
-
}
|
|
104
|
-
function _tagCommit() {
|
|
105
|
-
_tagCommit = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(tag) {
|
|
106
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
107
|
-
while (1) {
|
|
108
|
-
switch (_context2.prev = _context2.next) {
|
|
109
|
-
case 0:
|
|
110
|
-
return _context2.abrupt("return", (0, _simpleGit.default)().tag(['-f', tag]));
|
|
111
|
-
case 1:
|
|
112
|
-
case "end":
|
|
113
|
-
return _context2.stop();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}, _callee2);
|
|
117
|
-
}));
|
|
118
|
-
return _tagCommit.apply(this, arguments);
|
|
119
|
-
}
|
|
120
|
-
function doesTagExist(_x3) {
|
|
121
|
-
return _doesTagExist.apply(this, arguments);
|
|
122
|
-
}
|
|
123
|
-
function _doesTagExist() {
|
|
124
|
-
_doesTagExist = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(tag) {
|
|
125
|
-
var tags;
|
|
126
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
127
|
-
while (1) {
|
|
128
|
-
switch (_context3.prev = _context3.next) {
|
|
129
|
-
case 0:
|
|
130
|
-
_context3.next = 2;
|
|
131
|
-
return (0, _simpleGit.default)().tags((0, _defineProperty2.default)({}, tag, null));
|
|
132
|
-
case 2:
|
|
133
|
-
tags = _context3.sent;
|
|
134
|
-
return _context3.abrupt("return", tags.all.length > 0);
|
|
135
|
-
case 4:
|
|
136
|
-
case "end":
|
|
137
|
-
return _context3.stop();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}, _callee3);
|
|
141
|
-
}));
|
|
142
|
-
return _doesTagExist.apply(this, arguments);
|
|
143
|
-
}
|
|
144
|
-
function refetchTag(_x4) {
|
|
145
|
-
return _refetchTag.apply(this, arguments);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
146
79
|
}
|
|
147
|
-
function
|
|
148
|
-
|
|
149
|
-
var fetchTagResult;
|
|
150
|
-
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
151
|
-
while (1) {
|
|
152
|
-
switch (_context4.prev = _context4.next) {
|
|
153
|
-
case 0:
|
|
154
|
-
_context4.prev = 0;
|
|
155
|
-
_context4.next = 3;
|
|
156
|
-
return (0, _simpleGit.default)().tag(['-d', tag]);
|
|
157
|
-
case 3:
|
|
158
|
-
_context4.next = 9;
|
|
159
|
-
break;
|
|
160
|
-
case 5:
|
|
161
|
-
_context4.prev = 5;
|
|
162
|
-
_context4.t0 = _context4["catch"](0);
|
|
163
|
-
if (/tag.*not found/.test(_context4.t0.message)) {
|
|
164
|
-
_context4.next = 9;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
throw _context4.t0;
|
|
168
|
-
case 9:
|
|
169
|
-
_context4.prev = 9;
|
|
170
|
-
_context4.next = 12;
|
|
171
|
-
return (0, _simpleGit.default)().fetch(['origin', 'tag', tag]);
|
|
172
|
-
case 12:
|
|
173
|
-
fetchTagResult = _context4.sent;
|
|
174
|
-
_context4.next = 19;
|
|
175
|
-
break;
|
|
176
|
-
case 15:
|
|
177
|
-
_context4.prev = 15;
|
|
178
|
-
_context4.t1 = _context4["catch"](9);
|
|
179
|
-
if (/Couldn't find remote ref refs\/tags\//.test(_context4.t1.message)) {
|
|
180
|
-
_context4.next = 19;
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
throw _context4.t1;
|
|
184
|
-
case 19:
|
|
185
|
-
return _context4.abrupt("return", {
|
|
186
|
-
fetchTagResult: fetchTagResult
|
|
187
|
-
});
|
|
188
|
-
case 20:
|
|
189
|
-
case "end":
|
|
190
|
-
return _context4.stop();
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}, _callee4, null, [[0, 5], [9, 15]]);
|
|
194
|
-
}));
|
|
195
|
-
return _refetchTag.apply(this, arguments);
|
|
80
|
+
async function tagCommit(tag) {
|
|
81
|
+
return (0, _simpleGit.default)().tag(['-f', tag]);
|
|
196
82
|
}
|
|
197
|
-
function
|
|
198
|
-
|
|
83
|
+
async function doesTagExist(tag) {
|
|
84
|
+
const tags = await (0, _simpleGit.default)().tags({
|
|
85
|
+
[tag]: null
|
|
86
|
+
});
|
|
87
|
+
return tags.all.length > 0;
|
|
199
88
|
}
|
|
200
|
-
function
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
89
|
+
async function refetchTag(tag) {
|
|
90
|
+
try {
|
|
91
|
+
await (0, _simpleGit.default)().tag(['-d', tag]);
|
|
92
|
+
} catch (e) {
|
|
93
|
+
// Ignore tag not found errors
|
|
94
|
+
if (!/tag.*not found/.test(e.message)) {
|
|
95
|
+
throw e;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
let fetchTagResult;
|
|
99
|
+
try {
|
|
100
|
+
fetchTagResult = await (0, _simpleGit.default)().fetch(['origin', 'tag', tag]);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
// Ignore can't find tag in remote errors
|
|
103
|
+
if (!/Couldn't find remote ref refs\/tags\//.test(e.message)) {
|
|
104
|
+
throw e;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
fetchTagResult
|
|
109
|
+
};
|
|
215
110
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
218
|
-
return (0, _simpleGit.default)(opts.cwd || process.cwd()).show(["".concat(ref, ":").concat(filename)]);
|
|
111
|
+
async function getHash(ref) {
|
|
112
|
+
return (0, _simpleGit.default)().revparse([ref]);
|
|
219
113
|
}
|
|
220
|
-
function
|
|
221
|
-
return
|
|
114
|
+
function showFile(ref, filename, opts = {}) {
|
|
115
|
+
return (0, _simpleGit.default)(opts.cwd || process.cwd()).show([`${ref}:${filename}`]);
|
|
222
116
|
}
|
|
223
|
-
function
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
result,
|
|
227
|
-
_args6 = arguments;
|
|
228
|
-
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
229
|
-
while (1) {
|
|
230
|
-
switch (_context6.prev = _context6.next) {
|
|
231
|
-
case 0:
|
|
232
|
-
opts = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
|
|
233
|
-
_context6.next = 3;
|
|
234
|
-
return (0, _simpleGit.default)(opts.cwd || process.cwd()).raw(['grep', '--name-only', '', ref, '--', ":(glob)".concat(glob)]);
|
|
235
|
-
case 3:
|
|
236
|
-
result = _context6.sent;
|
|
237
|
-
return _context6.abrupt("return", result.split('\n').filter(function (line) {
|
|
238
|
-
return line !== '';
|
|
239
|
-
}).map(function (line) {
|
|
240
|
-
return line.split(':')[1];
|
|
241
|
-
}));
|
|
242
|
-
case 5:
|
|
243
|
-
case "end":
|
|
244
|
-
return _context6.stop();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}, _callee6);
|
|
248
|
-
}));
|
|
249
|
-
return _getFiles.apply(this, arguments);
|
|
117
|
+
async function getFiles(ref, glob, opts = {}) {
|
|
118
|
+
const result = await (0, _simpleGit.default)(opts.cwd || process.cwd()).raw(['grep', '--name-only', '', ref, '--', `:(glob)${glob}`]);
|
|
119
|
+
return result.split('\n').filter(line => line !== '').map(line => line.split(':')[1]);
|
|
250
120
|
}
|
package/dist/cjs/util/statlas.js
CHANGED
|
@@ -6,110 +6,40 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.getMeta = getMeta;
|
|
8
8
|
exports.uploadMeta = uploadMeta;
|
|
9
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
9
|
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
12
|
-
|
|
13
|
-
function getMeta(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function _getMeta() {
|
|
17
|
-
_getMeta = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(product) {
|
|
18
|
-
var response;
|
|
19
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
20
|
-
while (1) {
|
|
21
|
-
switch (_context.prev = _context.next) {
|
|
22
|
-
case 0:
|
|
23
|
-
_context.next = 2;
|
|
24
|
-
return retrieveJSON(getProductMetaPath(product));
|
|
25
|
-
case 2:
|
|
26
|
-
response = _context.sent;
|
|
27
|
-
return _context.abrupt("return", response.json);
|
|
28
|
-
case 4:
|
|
29
|
-
case "end":
|
|
30
|
-
return _context.stop();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}, _callee);
|
|
34
|
-
}));
|
|
35
|
-
return _getMeta.apply(this, arguments);
|
|
10
|
+
const STATLAS_BASE_URL = 'https://statlas.prod.atl-paas.net/af-product-analytics';
|
|
11
|
+
async function getMeta(product) {
|
|
12
|
+
const response = await retrieveJSON(getProductMetaPath(product));
|
|
13
|
+
return response.json;
|
|
36
14
|
}
|
|
37
15
|
function uploadMeta(product, lastRunHash) {
|
|
38
16
|
return uploadJSON(getProductMetaPath(product), {
|
|
39
|
-
lastRunHash
|
|
17
|
+
lastRunHash
|
|
40
18
|
});
|
|
41
19
|
}
|
|
42
20
|
function getProductMetaPath(product) {
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
function retrieveJSON(_x2) {
|
|
46
|
-
return _retrieveJSON.apply(this, arguments);
|
|
21
|
+
return `product/${product}.json`;
|
|
47
22
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
response = _context2.sent;
|
|
59
|
-
json = null;
|
|
60
|
-
if (!response.ok) {
|
|
61
|
-
_context2.next = 8;
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
_context2.next = 7;
|
|
65
|
-
return response.json();
|
|
66
|
-
case 7:
|
|
67
|
-
json = _context2.sent;
|
|
68
|
-
case 8:
|
|
69
|
-
return _context2.abrupt("return", {
|
|
70
|
-
json: json,
|
|
71
|
-
rawResponse: response
|
|
72
|
-
});
|
|
73
|
-
case 9:
|
|
74
|
-
case "end":
|
|
75
|
-
return _context2.stop();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}, _callee2);
|
|
79
|
-
}));
|
|
80
|
-
return _retrieveJSON.apply(this, arguments);
|
|
23
|
+
async function retrieveJSON(filepath) {
|
|
24
|
+
const response = await (0, _nodeFetch.default)(`${STATLAS_BASE_URL}/${filepath}?statlasredirect`);
|
|
25
|
+
let json = null;
|
|
26
|
+
if (response.ok) {
|
|
27
|
+
json = await response.json();
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
json,
|
|
31
|
+
rawResponse: response
|
|
32
|
+
};
|
|
81
33
|
}
|
|
82
|
-
function uploadJSON(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return (0, _nodeFetch.default)("".concat(STATLAS_BASE_URL, "/").concat(filepath), {
|
|
94
|
-
method: 'PUT',
|
|
95
|
-
body: JSON.stringify(json),
|
|
96
|
-
headers: {
|
|
97
|
-
Authorization: "Bearer ".concat(process.env.bamboo_JWT_TOKEN)
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
case 2:
|
|
101
|
-
res = _context3.sent;
|
|
102
|
-
if (res.ok) {
|
|
103
|
-
_context3.next = 5;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
throw new Error("Statlas upload failed: ".concat(res.statusText));
|
|
107
|
-
case 5:
|
|
108
|
-
case "end":
|
|
109
|
-
return _context3.stop();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}, _callee3);
|
|
113
|
-
}));
|
|
114
|
-
return _uploadJSON.apply(this, arguments);
|
|
34
|
+
async function uploadJSON(filepath, json) {
|
|
35
|
+
const res = await (0, _nodeFetch.default)(`${STATLAS_BASE_URL}/${filepath}`, {
|
|
36
|
+
method: 'PUT',
|
|
37
|
+
body: JSON.stringify(json),
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: `Bearer ${process.env.bamboo_JWT_TOKEN}`
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
if (!res.ok) {
|
|
43
|
+
throw new Error(`Statlas upload failed: ${res.statusText}`);
|
|
44
|
+
}
|
|
115
45
|
}
|
package/dist/cjs/util/yarn.js
CHANGED
|
@@ -1,115 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.getWorkspaceGlobs = getWorkspaceGlobs;
|
|
9
8
|
exports.getWorkspacePaths = getWorkspacePaths;
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
9
|
var _path = _interopRequireDefault(require("path"));
|
|
14
10
|
var _debug = _interopRequireDefault(require("debug"));
|
|
15
11
|
var _micromatch = _interopRequireDefault(require("micromatch"));
|
|
16
12
|
var git = _interopRequireWildcard(require("./git"));
|
|
17
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function
|
|
18
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function getWorkspaceGlobs(
|
|
22
|
-
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
const rootPackageJsonPath = 'package.json';
|
|
16
|
+
const debug = (0, _debug.default)('atlaskit:yarn');
|
|
17
|
+
async function getWorkspaceGlobs(ref, cwd) {
|
|
18
|
+
let file;
|
|
19
|
+
try {
|
|
20
|
+
file = await git.showFile(ref, rootPackageJsonPath, {
|
|
21
|
+
cwd
|
|
22
|
+
});
|
|
23
|
+
} catch (e) {
|
|
24
|
+
debug(`${rootPackageJsonPath} does not exist`);
|
|
25
|
+
return new Set([]);
|
|
26
|
+
}
|
|
27
|
+
let rootPackageJsonFile;
|
|
28
|
+
try {
|
|
29
|
+
rootPackageJsonFile = JSON.parse(file);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.error(`Error parsing ${file}@${ref}: ${e}`);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const workspaces = rootPackageJsonFile.workspaces;
|
|
35
|
+
if (!workspaces) {
|
|
36
|
+
return new Set([rootPackageJsonPath]);
|
|
37
|
+
}
|
|
38
|
+
// There are actually two formats for workspaces and they are poorly documented
|
|
39
|
+
const workspacePackages = Array.isArray(workspaces) ? workspaces : workspaces.packages;
|
|
40
|
+
return new Set([rootPackageJsonPath, ...workspacePackages.map(glob => _path.default.join(glob, 'package.json'))]);
|
|
23
41
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
case 3:
|
|
37
|
-
file = _context.sent;
|
|
38
|
-
_context.next = 10;
|
|
39
|
-
break;
|
|
40
|
-
case 6:
|
|
41
|
-
_context.prev = 6;
|
|
42
|
-
_context.t0 = _context["catch"](0);
|
|
43
|
-
debug("".concat(rootPackageJsonPath, " does not exist"));
|
|
44
|
-
return _context.abrupt("return", new Set([]));
|
|
45
|
-
case 10:
|
|
46
|
-
_context.prev = 10;
|
|
47
|
-
rootPackageJsonFile = JSON.parse(file);
|
|
48
|
-
_context.next = 18;
|
|
49
|
-
break;
|
|
50
|
-
case 14:
|
|
51
|
-
_context.prev = 14;
|
|
52
|
-
_context.t1 = _context["catch"](10);
|
|
53
|
-
console.error("Error parsing ".concat(file, "@").concat(ref, ": ").concat(_context.t1));
|
|
54
|
-
return _context.abrupt("return", null);
|
|
55
|
-
case 18:
|
|
56
|
-
workspaces = rootPackageJsonFile.workspaces;
|
|
57
|
-
if (workspaces) {
|
|
58
|
-
_context.next = 21;
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
return _context.abrupt("return", new Set([rootPackageJsonPath]));
|
|
62
|
-
case 21:
|
|
63
|
-
// There are actually two formats for workspaces and they are poorly documented
|
|
64
|
-
workspacePackages = Array.isArray(workspaces) ? workspaces : workspaces.packages;
|
|
65
|
-
return _context.abrupt("return", new Set([rootPackageJsonPath].concat((0, _toConsumableArray2.default)(workspacePackages.map(function (glob) {
|
|
66
|
-
return _path.default.join(glob, 'package.json');
|
|
67
|
-
})))));
|
|
68
|
-
case 23:
|
|
69
|
-
case "end":
|
|
70
|
-
return _context.stop();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}, _callee, null, [[0, 6], [10, 14]]);
|
|
74
|
-
}));
|
|
75
|
-
return _getWorkspaceGlobs.apply(this, arguments);
|
|
76
|
-
}
|
|
77
|
-
function getWorkspacePaths(_x3, _x4, _x5) {
|
|
78
|
-
return _getWorkspacePaths.apply(this, arguments);
|
|
79
|
-
}
|
|
80
|
-
function _getWorkspacePaths() {
|
|
81
|
-
_getWorkspacePaths = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(ref, workspaceGlobs, cwd) {
|
|
82
|
-
var workspacePackageJsons, matchedWorkspaces;
|
|
83
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
84
|
-
while (1) {
|
|
85
|
-
switch (_context2.prev = _context2.next) {
|
|
86
|
-
case 0:
|
|
87
|
-
if (!(workspaceGlobs.size === 0)) {
|
|
88
|
-
_context2.next = 2;
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
return _context2.abrupt("return", []);
|
|
92
|
-
case 2:
|
|
93
|
-
_context2.next = 4;
|
|
94
|
-
return git.getFiles(ref, '**/package.json', {
|
|
95
|
-
cwd: cwd
|
|
96
|
-
});
|
|
97
|
-
case 4:
|
|
98
|
-
workspacePackageJsons = _context2.sent;
|
|
99
|
-
matchedWorkspaces = (0, _micromatch.default)(workspacePackageJsons, (0, _toConsumableArray2.default)(workspaceGlobs));
|
|
100
|
-
if (!(matchedWorkspaces.length === 0)) {
|
|
101
|
-
_context2.next = 8;
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
throw new Error("Could not find any workspace or package.json under ".concat(cwd));
|
|
105
|
-
case 8:
|
|
106
|
-
return _context2.abrupt("return", matchedWorkspaces);
|
|
107
|
-
case 9:
|
|
108
|
-
case "end":
|
|
109
|
-
return _context2.stop();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}, _callee2);
|
|
113
|
-
}));
|
|
114
|
-
return _getWorkspacePaths.apply(this, arguments);
|
|
42
|
+
async function getWorkspacePaths(ref, workspaceGlobs, cwd) {
|
|
43
|
+
if (workspaceGlobs.size === 0) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
const workspacePackageJsons = await git.getFiles(ref, '**/package.json', {
|
|
47
|
+
cwd
|
|
48
|
+
});
|
|
49
|
+
const matchedWorkspaces = (0, _micromatch.default)(workspacePackageJsons, [...workspaceGlobs]);
|
|
50
|
+
if (matchedWorkspaces.length === 0) {
|
|
51
|
+
throw new Error(`Could not find any workspace or package.json under ${cwd}`);
|
|
52
|
+
}
|
|
53
|
+
return matchedWorkspaces;
|
|
115
54
|
}
|
package/dist/cjs/version.json
CHANGED