@sentry/cli 2.58.4 → 3.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/README.md +21 -0
- package/bin/sentry-cli +1 -1
- package/checksums.txt +10 -10
- package/js/helper.d.ts +60 -94
- package/js/helper.js +36 -67
- package/js/index.d.ts +24 -43
- package/js/index.js +16 -23
- package/js/logger.d.ts +4 -5
- package/js/logger.js +8 -4
- package/js/releases/index.d.ts +30 -60
- package/js/releases/index.js +33 -64
- package/js/releases/options/deploys.d.ts +29 -2
- package/js/releases/options/deploys.js +5 -2
- package/js/releases/options/uploadSourcemaps.d.ts +58 -2
- package/js/releases/options/uploadSourcemaps.js +5 -6
- package/js/types.d.ts +8 -40
- package/js/types.js +2 -1
- package/package.json +12 -13
- package/scripts/install.js +23 -30
package/scripts/install.js
CHANGED
|
@@ -6,19 +6,17 @@ const fs = require('fs');
|
|
|
6
6
|
const os = require('os');
|
|
7
7
|
const path = require('path');
|
|
8
8
|
const crypto = require('crypto');
|
|
9
|
-
const zlib = require('zlib');
|
|
10
9
|
const stream = require('stream');
|
|
11
10
|
const process = require('process');
|
|
12
11
|
|
|
13
|
-
const fetch = require('
|
|
14
|
-
const HttpsProxyAgent = require('https-proxy-agent');
|
|
12
|
+
const { ProxyAgent, fetch } = require('undici');
|
|
15
13
|
const ProgressBar = require('progress');
|
|
16
14
|
const Proxy = require('proxy-from-env');
|
|
17
15
|
const which = require('which');
|
|
18
16
|
|
|
19
17
|
const helper = require('../js/helper');
|
|
20
18
|
const pkgInfo = require('../package.json');
|
|
21
|
-
const Logger = require('../js/logger');
|
|
19
|
+
const { Logger } = require('../js/logger');
|
|
22
20
|
|
|
23
21
|
const logger = new Logger(getLogStream('stderr'));
|
|
24
22
|
|
|
@@ -89,7 +87,7 @@ function getDownloadUrl(platform, arch) {
|
|
|
89
87
|
}
|
|
90
88
|
|
|
91
89
|
function createProgressBar(name, total) {
|
|
92
|
-
const incorrectTotal = typeof total !== 'number' || Number.isNaN(total);
|
|
90
|
+
const incorrectTotal = typeof total !== 'number' || Number.isNaN(total) || total <= 0;
|
|
93
91
|
|
|
94
92
|
if (incorrectTotal || !shouldRenderProgressBar()) {
|
|
95
93
|
return {
|
|
@@ -220,7 +218,7 @@ async function downloadBinary() {
|
|
|
220
218
|
}
|
|
221
219
|
|
|
222
220
|
const proxyUrl = Proxy.getProxyForUrl(downloadUrl);
|
|
223
|
-
const
|
|
221
|
+
const dispatcher = proxyUrl ? new ProxyAgent(proxyUrl) : undefined;
|
|
224
222
|
|
|
225
223
|
logger.log(`Downloading from ${downloadUrl}`);
|
|
226
224
|
|
|
@@ -231,12 +229,8 @@ async function downloadBinary() {
|
|
|
231
229
|
let response;
|
|
232
230
|
try {
|
|
233
231
|
response = await fetch(downloadUrl, {
|
|
234
|
-
agent,
|
|
235
|
-
compress: false,
|
|
236
|
-
headers: {
|
|
237
|
-
'accept-encoding': 'gzip, deflate, br',
|
|
238
|
-
},
|
|
239
232
|
redirect: 'follow',
|
|
233
|
+
dispatcher,
|
|
240
234
|
});
|
|
241
235
|
} catch (error) {
|
|
242
236
|
let errorMsg = `Unable to download sentry-cli binary from ${downloadUrl}.\nError message: ${error.message}`;
|
|
@@ -254,39 +248,38 @@ async function downloadBinary() {
|
|
|
254
248
|
throw new Error(errorMsg);
|
|
255
249
|
}
|
|
256
250
|
|
|
257
|
-
const contentEncoding = response.headers.get('content-encoding');
|
|
258
|
-
let decompressor;
|
|
259
|
-
if (/\bgzip\b/.test(contentEncoding)) {
|
|
260
|
-
decompressor = zlib.createGunzip();
|
|
261
|
-
} else if (/\bdeflate\b/.test(contentEncoding)) {
|
|
262
|
-
decompressor = zlib.createInflate();
|
|
263
|
-
} else if (/\bbr\b/.test(contentEncoding)) {
|
|
264
|
-
decompressor = zlib.createBrotliDecompress();
|
|
265
|
-
} else {
|
|
266
|
-
decompressor = new stream.PassThrough();
|
|
267
|
-
}
|
|
268
251
|
const name = downloadUrl.match(/.*\/(.*?)$/)[1];
|
|
269
252
|
let downloadedBytes = 0;
|
|
270
|
-
|
|
253
|
+
|
|
254
|
+
// Note: content-length might not be available if response was compressed,
|
|
255
|
+
// as native fetch decompresses transparently
|
|
256
|
+
const contentLength = response.headers.get('content-length');
|
|
257
|
+
const totalBytes = contentLength ? parseInt(contentLength, 10) : 0;
|
|
271
258
|
const progressBar = createProgressBar(name, totalBytes);
|
|
272
259
|
const tempPath = getTempFile(cachedPath);
|
|
273
260
|
fs.mkdirSync(path.dirname(tempPath), { recursive: true });
|
|
274
261
|
|
|
275
262
|
await new Promise((resolve, reject) => {
|
|
276
|
-
|
|
263
|
+
// Convert Web ReadableStream to Node.js stream
|
|
264
|
+
const nodeStream = stream.Readable.fromWeb(response.body);
|
|
265
|
+
|
|
266
|
+
nodeStream
|
|
277
267
|
.on('error', (e) => reject(e))
|
|
278
268
|
.on('data', (chunk) => {
|
|
279
269
|
downloadedBytes += chunk.length;
|
|
280
|
-
|
|
270
|
+
|
|
271
|
+
if (!progressBar.complete) {
|
|
272
|
+
progressBar.tick(chunk.length);
|
|
273
|
+
}
|
|
281
274
|
})
|
|
282
|
-
.pipe(decompressor)
|
|
283
275
|
.pipe(fs.createWriteStream(tempPath, { mode: '0755' }))
|
|
284
276
|
.on('error', (e) => reject(e))
|
|
285
|
-
.on('
|
|
286
|
-
if
|
|
287
|
-
|
|
288
|
-
} else {
|
|
277
|
+
.on('finish', () => {
|
|
278
|
+
// Check if we have a total size to validate against
|
|
279
|
+
if (totalBytes > 0 && downloadedBytes < totalBytes) {
|
|
289
280
|
reject(new Error('connection interrupted'));
|
|
281
|
+
} else {
|
|
282
|
+
resolve();
|
|
290
283
|
}
|
|
291
284
|
});
|
|
292
285
|
});
|