reviewable-enterprise-tools 1.3.5 → 1.3.8
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/extract_data.js +6 -5
- package/load_data.js +6 -6
- package/package.json +1 -1
package/extract_data.js
CHANGED
|
@@ -54,7 +54,8 @@ for (const property of ['repos', 'output']) {
|
|
|
54
54
|
|
|
55
55
|
let uploadedFilesUrlRegex;
|
|
56
56
|
if (uploadedFilesUrl) {
|
|
57
|
-
uploadedFilesUrlRegex =
|
|
57
|
+
uploadedFilesUrlRegex =
|
|
58
|
+
new RegExp(`(${_.escapeRegExp(uploadedFilesUrl)})((?:[^)]|\\(\\d+\\))*)`, 'g');
|
|
58
59
|
} else {
|
|
59
60
|
console.warn(
|
|
60
61
|
'WARNING: no REVIEWABLE_UPLOADS_PROVIDER or REVIEWABLE_UPLOADED_FILES_URL specified, ' +
|
|
@@ -219,13 +220,13 @@ async function extractReviews() {
|
|
|
219
220
|
await forEachLimit(reviewKeys, 25, async reviewKey => {
|
|
220
221
|
let review = await db.child('reviews/:reviewKey', {reviewKey}).get();
|
|
221
222
|
if (review) {
|
|
222
|
-
stripReview(review);
|
|
223
|
+
await stripReview(review, reviewKey);
|
|
223
224
|
await writeItem(`reviews/${reviewKey}`, review);
|
|
224
225
|
} else {
|
|
225
226
|
const archive = await db.child('archivedReviews/:reviewKey', {reviewKey}).get();
|
|
226
227
|
if (archive) {
|
|
227
228
|
review = JSON.parse(zlib.gunzipSync(Buffer.from(archive.payload, 'base64')).toString());
|
|
228
|
-
const placeholdersPresent = await stripReview(review);
|
|
229
|
+
const placeholdersPresent = await stripReview(review, reviewKey);
|
|
229
230
|
if (identityUserMap) mapAllUserKeys(review);
|
|
230
231
|
archive.payload =
|
|
231
232
|
zlib.gzipSync(JSON.stringify(review), {level: zlib.constants.Z_BEST_COMPRESSION})
|
|
@@ -239,7 +240,7 @@ async function extractReviews() {
|
|
|
239
240
|
});
|
|
240
241
|
}
|
|
241
242
|
|
|
242
|
-
async function stripReview(review) {
|
|
243
|
+
async function stripReview(review, key) {
|
|
243
244
|
let placeholderAdded = false;
|
|
244
245
|
review.core = _.omit(review.core, 'lastSweepTimestamp');
|
|
245
246
|
delete review.lastWebhook;
|
|
@@ -257,7 +258,7 @@ async function stripReview(review) {
|
|
|
257
258
|
const dest = path.join(args.download, path.dirname(rest.slice(1)));
|
|
258
259
|
downloadPromises.push(download(url, dest).catch(e => {
|
|
259
260
|
if (args.logging) log(`File download failed:\n${url}\n${e}`);
|
|
260
|
-
brokenFiles.push(url);
|
|
261
|
+
brokenFiles.push(`${url} (${reversePullRequests[key]})`);
|
|
261
262
|
}));
|
|
262
263
|
}
|
|
263
264
|
return PLACEHOLDER_URL + rest;
|
package/load_data.js
CHANGED
|
@@ -53,7 +53,9 @@ if (!process.env.REVIEWABLE_ENCRYPTION_AES_KEY) {
|
|
|
53
53
|
let placeholderUrlRegex, gh;
|
|
54
54
|
if (uploadedFilesUrl) {
|
|
55
55
|
if (!process.env.REVIEWABLE_GITHUB_URL) {
|
|
56
|
-
console.log(
|
|
56
|
+
console.log(
|
|
57
|
+
'ERROR: no REVIEWABLE_GITHUB_URL specified, unable to rewrite uploaded image URLs in comments'
|
|
58
|
+
);
|
|
57
59
|
process.exit(1);
|
|
58
60
|
}
|
|
59
61
|
placeholderUrlRegex = new RegExp(_.escapeRegExp(PLACEHOLDER_URL), 'g');
|
|
@@ -65,11 +67,9 @@ if (uploadedFilesUrl) {
|
|
|
65
67
|
|
|
66
68
|
async function load() {
|
|
67
69
|
await import('./lib/loadFirebase.js');
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
token: await fetchToken(args.admin)
|
|
72
|
-
});
|
|
70
|
+
const host = process.env.REVIEWABLE_GITHUB_URL === 'https://github.com' ?
|
|
71
|
+
'https://api.github.com' : process.env.REVIEWABLE_GITHUB_URL + '/api/v3';
|
|
72
|
+
gh = new Hubkit({host, token: await fetchToken(args.admin)});
|
|
73
73
|
|
|
74
74
|
let sizeRead = 0;
|
|
75
75
|
let fatalError;
|