@mongodb-js/mongodb-downloader
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -12,3 +12,3 @@ "use strict"; | ||
const path_1 = __importDefault(require("path")); | ||
const download_1 = __importDefault(require("download")); | ||
const decompress_1 = __importDefault(require("decompress")); | ||
const stream_1 = require("stream"); | ||
@@ -19,4 +19,3 @@ const mongodb_download_url_1 = __importDefault(require("mongodb-download-url")); | ||
async function downloadMongoDb(tmpdir, targetVersionSemverSpecifier = '*', options = {}) { | ||
var _a; | ||
let wantsEnterprise = (_a = options.enterprise) !== null && _a !== void 0 ? _a : false; | ||
let wantsEnterprise = options.enterprise ?? false; | ||
async function lookupDownloadUrl() { | ||
@@ -43,5 +42,4 @@ return (await (0, mongodb_download_url_1.default)({ | ||
async function doDownload(tmpdir, isCryptLibrary, version, lookupDownloadUrl) { | ||
var _a; | ||
const downloadTarget = path_1.default.resolve(tmpdir, `mongodb-${process.platform}-${process.env.DISTRO_ID || 'none'}-${process.arch}-${version}`.replace(/[^a-zA-Z0-9_-]/g, '')); | ||
return ((_a = downloadPromises[downloadTarget]) !== null && _a !== void 0 ? _a : (downloadPromises[downloadTarget] = (async () => { | ||
return (downloadPromises[downloadTarget] ??= (async () => { | ||
const bindir = path_1.default.resolve(downloadTarget, isCryptLibrary && process.platform !== 'win32' ? 'lib' : 'bin'); | ||
@@ -53,3 +51,3 @@ try { | ||
} | ||
catch (_a) { | ||
catch { | ||
} | ||
@@ -59,11 +57,17 @@ await fs_1.promises.mkdir(downloadTarget, { recursive: true }); | ||
debug(`Downloading ${url} into ${downloadTarget}...`); | ||
const HWM = 1024 * 1024; | ||
async function downloadAndExtract(withExtraStripDepth = 0) { | ||
const response = await (0, node_fetch_1.default)(url, { | ||
highWaterMark: HWM, | ||
}); | ||
if (/\.tgz$|\.tar(\.[^.]+)?$/.exec(url)) { | ||
const response = await (0, node_fetch_1.default)(url); | ||
await (0, util_1.promisify)(stream_1.pipeline)(response.body, tar_1.default.x({ cwd: downloadTarget, strip: isCryptLibrary ? 0 : 1 })); | ||
} | ||
else { | ||
await (0, download_1.default)(url, downloadTarget, { | ||
extract: true, | ||
const filename = path_1.default.join(downloadTarget, path_1.default.basename(new URL(url).pathname)); | ||
await (0, util_1.promisify)(stream_1.pipeline)(response.body, (0, fs_1.createWriteStream)(filename, { highWaterMark: HWM })); | ||
debug(`Written file ${url} to ${filename}, extracting...`); | ||
await (0, decompress_1.default)(filename, downloadTarget, { | ||
strip: isCryptLibrary ? 0 : 1, | ||
filter: (file) => path_1.default.extname(file.path) !== '.pdb', | ||
}); | ||
@@ -85,4 +89,4 @@ } | ||
return bindir; | ||
})())); | ||
})()); | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -16,3 +16,3 @@ { | ||
"homepage": "https://github.com/mongodb-js/devtools-shared", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"repository": { | ||
@@ -51,3 +51,3 @@ "type": "git", | ||
"debug": "^4.3.4", | ||
"download": "^8.0.0", | ||
"decompress": "^4.2.1", | ||
"mongodb-download-url": "^1.3.0", | ||
@@ -58,8 +58,8 @@ "node-fetch": "^2.6.11", | ||
"devDependencies": { | ||
"@mongodb-js/eslint-config-devtools": "0.9.9", | ||
"@mongodb-js/mocha-config-compass": "^0.10.0", | ||
"@mongodb-js/eslint-config-devtools": "0.9.10", | ||
"@mongodb-js/mocha-config-devtools": "^1.0.1", | ||
"@mongodb-js/prettier-config-devtools": "^1.0.1", | ||
"@mongodb-js/tsconfig-compass": "^0.6.0", | ||
"@mongodb-js/tsconfig-devtools": "^1.0.1", | ||
"@types/debug": "^4.1.8", | ||
"@types/download": "^8.0.2", | ||
"@types/decompress": "^4.2.4", | ||
"@types/mocha": "^9.0.0", | ||
@@ -76,3 +76,3 @@ "@types/node": "^17.0.35", | ||
}, | ||
"gitHead": "f68234866e6fb0851dbc52bcb93dc5433ae3faf6" | ||
"gitHead": "9c41f233d529e7b5cac1849a0a07ca2076fcdbb0" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20702
91
+ Addeddecompress@^4.2.1
- Removeddownload@^8.0.0
- Removed@sindresorhus/is@0.7.0(transitive)
- Removedarchive-type@4.0.0(transitive)
- Removedcacheable-request@2.1.4(transitive)
- Removedclone-response@1.0.2(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddecompress-response@3.3.0(transitive)
- Removeddownload@8.0.0(transitive)
- Removedduplexer3@0.1.5(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedext-list@2.2.2(transitive)
- Removedext-name@5.0.0(transitive)
- Removedfile-type@11.1.04.4.0(transitive)
- Removedfilename-reserved-regex@2.0.0(transitive)
- Removedfilenamify@3.0.0(transitive)
- Removedfrom2@2.3.0(transitive)
- Removedget-stream@3.0.04.1.0(transitive)
- Removedgot@8.3.2(transitive)
- Removedhas-symbol-support-x@1.4.2(transitive)
- Removedhas-to-string-tag-x@1.4.1(transitive)
- Removedhttp-cache-semantics@3.8.1(transitive)
- Removedinto-stream@3.1.0(transitive)
- Removedis-object@1.0.2(transitive)
- Removedis-plain-obj@1.1.0(transitive)
- Removedis-retry-allowed@1.2.0(transitive)
- Removedisurl@1.0.0(transitive)
- Removedjson-buffer@3.0.0(transitive)
- Removedkeyv@3.0.0(transitive)
- Removedlowercase-keys@1.0.01.0.1(transitive)
- Removedmake-dir@2.1.0(transitive)
- Removedmime-db@1.53.0(transitive)
- Removedmimic-response@1.0.1(transitive)
- Removednormalize-url@2.0.1(transitive)
- Removedp-cancelable@0.4.1(transitive)
- Removedp-event@2.3.1(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedp-is-promise@1.1.0(transitive)
- Removedp-timeout@2.0.1(transitive)
- Removedpify@4.0.1(transitive)
- Removedprepend-http@2.0.0(transitive)
- Removedpump@3.0.2(transitive)
- Removedquery-string@5.1.1(transitive)
- Removedresponselike@1.0.2(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsort-keys@1.1.22.0.0(transitive)
- Removedsort-keys-length@1.0.1(transitive)
- Removedstrict-uri-encode@1.1.0(transitive)
- Removedstrip-outer@1.0.1(transitive)
- Removedtimed-out@4.0.1(transitive)
- Removedtrim-repeated@1.0.0(transitive)
- Removedurl-parse-lax@3.0.0(transitive)
- Removedurl-to-options@1.0.1(transitive)