Socket
Socket
Sign inDemoInstall

mongodb-download

Package Overview
Dependencies
120
Maintainers
3
Versions
42
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.6 to 2.2.7

LICENSE.md

1

built/mongodb-download-cli.d.ts

@@ -0,3 +1,4 @@

#!/usr/bin/env node
declare let MongoDBDownload: any;
declare let argv: any;
declare let mongoDBDownload: any;

2

built/mongodb-download.d.ts

@@ -19,3 +19,3 @@ export interface IMongoDBDownloadOptions {

debug: any;
constructor({platform, arch, downloadDir, version, http}: {
constructor({ platform, arch, downloadDir, version, http }: {
platform?: any;

@@ -22,0 +22,0 @@ arch?: any;

@@ -10,8 +10,9 @@ "use strict";

var url = require('url');
var semver = require('semver');
var decompress = require('decompress');
var request = require('request-promise');
var md5File = require('md5-file');
var DOWNLOAD_URI = "https://downloads.mongodb.org";
var DOWNLOAD_URI = "https://fastdl.mongodb.org";
var MONGODB_VERSION = "latest";
var MongoDBDownload = (function () {
var MongoDBDownload = /** @class */ (function () {
function MongoDBDownload(_a) {

@@ -248,3 +249,3 @@ var _b = _a.platform, platform = _b === void 0 ? os.platform() : _b, _c = _a.arch, arch = _c === void 0 ? os.arch() : _c, _d = _a.downloadDir, downloadDir = _d === void 0 ? os.tmpdir() : _d, _e = _a.version, version = _e === void 0 ? MONGODB_VERSION : _e, _f = _a.http, http = _f === void 0 ? {} : _f;

_this.debug("getDownloadMD5Hash content: " + signatureContent);
var signatureMatch = signatureContent.match(/(.*?)\s/);
var signatureMatch = signatureContent.match(/([^\s]*)(\s*|$)/);
var signature = signatureMatch[1];

@@ -394,6 +395,21 @@ _this.debug("getDownloadMD5Hash extracted signature: " + signature);

return new Promise(function (resolve, reject) {
//var name = "mongodb-" + mongo_platform + "-" + mongo_arch;
var name = "mongodb-" +
_this.mongoDBPlatform.getPlatform() + "-" +
_this.mongoDBPlatform.getArch();
var platform = _this.mongoDBPlatform.getPlatform();
var arch = _this.mongoDBPlatform.getArch();
var version = _this.getVersion();
switch (platform) {
case 'osx':
if ((version === 'latest') || semver.satisfies(version, '>=3.5')) {
platform = platform + "-ssl";
}
break;
case 'win32':
// TODO: '2012plus' for 4.x and above
if ((version === 'latest') || semver.satisfies(version, '>=3.5')) {
arch = arch + "-2008plus-ssl";
}
break;
default:
break;
}
var name = "mongodb-" + platform + "-" + arch;
_this.mongoDBPlatform.getOSVersionString().then(function (osString) {

@@ -412,3 +428,3 @@ osString && (name += "-" + osString);

exports.MongoDBDownload = MongoDBDownload;
var MongoDBPlatform = (function () {
var MongoDBPlatform = /** @class */ (function () {
function MongoDBPlatform(platform, arch) {

@@ -473,2 +489,3 @@ this.debug = Debug('mongodb-download-MongoDBPlatform');

else {
// TODO: 'legacy', 'static'
reject("");

@@ -482,3 +499,6 @@ }

var release = parseFloat(os.release);
if (release >= 8.1) {
if (release >= 9.2) {
name += "92";
}
else if (release >= 8.1) {
name += "81";

@@ -523,2 +543,3 @@ }

else {
// TODO: 'rhel57'
this.debug("using legacy release");

@@ -563,2 +584,5 @@ }

}
else if (os.release === "18.04") {
name += "1804";
}
else if (major_version === 16) {

@@ -583,3 +607,3 @@ // default for major 16 to 1604

return "linux";
case "elementary OS"://os.platform() doesn't return linux for elementary OS.
case "elementary OS": //os.platform() doesn't return linux for elementary OS.
return "linux";

@@ -586,0 +610,0 @@ case "sunos":

{
"name": "mongodb-download",
"version": "2.2.6",
"version": "2.2.7",
"description": "download mongodb prebuilt packages from mongodb",

@@ -9,2 +9,3 @@ "main": "built/mongodb-download.js",

"scripts": {
"build": "tsc",
"test": "mocha"

@@ -26,2 +27,3 @@ },

"dependencies": {
"semver": "^5.6.0",
"yargs": "^3.26.0",

@@ -39,5 +41,7 @@ "debug": "^2.2.0",

"chai": "^3.5.0",
"mocha": "^3.2.0"
"mocha": "^5.2.0",
"rewire": "^4.0.1",
"typescript": "^3.1.3"
},
"homepage": "https://github.com/winfinit/mongodb-download#readme"
}

@@ -8,2 +8,3 @@ const os: any = require('os');

const url: any = require('url');
const semver: any = require('semver');
const decompress: any = require('decompress');

@@ -13,3 +14,3 @@ const request: any = require('request-promise');

const DOWNLOAD_URI: string = "https://downloads.mongodb.org";
const DOWNLOAD_URI: string = "https://fastdl.mongodb.org";
const MONGODB_VERSION: string = "latest";

@@ -38,3 +39,3 @@

debug: any;
constructor( {

@@ -54,3 +55,3 @@ platform = os.platform(),

};
this.debug = Debug('mongodb-download-MongoDBDownload');

@@ -66,19 +67,19 @@ this.mongoDBPlatform = new MongoDBPlatform(this.getPlatform(), this.getArch());

}
getPlatform(): string {
return this.options.platform;
}
getArch(): string {
return this.options.arch;
}
getVersion(): string {
return this.options.version;
}
getDownloadDir(): string {
return this.options.downloadDir;
}
getDownloadLocation(): Promise<string> {

@@ -94,3 +95,3 @@ return new Promise<string>((resolve, reject) => {

}
getExtractLocation(): Promise<string> {

@@ -113,3 +114,3 @@ return new Promise<string>((resolve, reject) => {

}
getTempDownloadLocation(): Promise<string> {

@@ -125,3 +126,3 @@ return new Promise<string>((resolve, reject) => {

}
downloadAndExtract(): Promise<string> {

@@ -136,3 +137,3 @@ return new Promise<string>((resolve, reject) => {

}
extract(): Promise<string> {

@@ -152,3 +153,3 @@ return new Promise<string>((resolve, reject) => {

});
});
});
}

@@ -159,6 +160,6 @@ });

}
download(): Promise<string> {
return new Promise<string>((resolve, reject) => {
let httpOptionsPromise: Promise<string> = this.getHttpOptions();

@@ -168,5 +169,5 @@ let downloadLocationPromise: Promise<string> = this.getDownloadLocation();

let createDownloadDirPromise: Promise<boolean> = this.createDownloadDir();
Promise.all([
httpOptionsPromise,
httpOptionsPromise,
downloadLocationPromise,

@@ -180,3 +181,3 @@ tempDownloadLocationPromise,

let downloadDirRes: boolean = values[3];
this.isDownloadPresent().then((isDownloadPresent: boolean) => {

@@ -198,3 +199,3 @@ if ( isDownloadPresent === true ) {

}
// TODO: needs refactoring

@@ -226,3 +227,3 @@ isDownloadPresent(): Promise<boolean> {

}
isExtractPresent(): Promise<boolean> {

@@ -291,3 +292,3 @@ return new Promise<boolean>((resolve, reject) => {

this.debug(`getDownloadMD5Hash content: ${signatureContent}`);
let signatureMatch: string[] = signatureContent.match(/(.*?)\s/);
let signatureMatch: string[] = signatureContent.match(/([^\s]*)(\s*|$)/);
let signature: string = signatureMatch[1];

@@ -323,7 +324,7 @@ this.debug(`getDownloadMD5Hash extracted signature: ${signature}`);

}
httpDownload(httpOptions: any, downloadLocation: string, tempDownloadLocation: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
let fileStream: any = fs.createWriteStream(tempDownloadLocation);
let request: any = http.get(httpOptions, (response: any) => {

@@ -333,5 +334,5 @@ this.downloadProgress.current = 0;

this.downloadProgress.total = Math.round(this.downloadProgress.length / 1048576 * 10) / 10;
response.pipe(fileStream);
fileStream.on('finish', () => {

@@ -344,7 +345,7 @@ fileStream.close(() => {

});
response.on("data", (chunk: any) => {
this.printDownloadProgress(chunk);
});
request.on("error", (e: any) => {

@@ -354,6 +355,6 @@ this.debug("request error:", e);

});
});
});
});
}
getCrReturn(): string {

@@ -364,5 +365,5 @@ if (this.mongoDBPlatform.getPlatform() === "win32") {

return "\r";
}
}
}
locationExists(location: string): boolean {

@@ -380,3 +381,3 @@ let exists: boolean;

}
printDownloadProgress(chunk: any): void {

@@ -389,3 +390,3 @@ let crReturn: string = this.getCrReturn();

let mb_complete: number = Math.round(this.downloadProgress.current / 1048576 * 10) / 10;
let text_to_print: string =
let text_to_print: string =
`Completed: ${percent_complete} % (${mb_complete}mb / ${this.downloadProgress.total}mb${crReturn}`;

@@ -395,6 +396,6 @@ if (this.downloadProgress.lastStdout !== text_to_print) {

process.stdout.write(text_to_print);
}
}
}
getHttpOptions(): Promise<any> {

@@ -411,3 +412,3 @@ return new Promise<string>((resolve, reject) => {

}
getDownloadURI(): Promise<any> {

@@ -424,3 +425,3 @@ return new Promise<string>((resolve, reject) => {

}
getDownloadURIMD5(): Promise<any> {

@@ -435,3 +436,3 @@ return new Promise<string>((resolve, reject) => {

}
createDownloadDir(): Promise<boolean> {

@@ -452,11 +453,27 @@ return new Promise<boolean>((resolve, reject) => {

}
getArchiveName(): Promise<string> {
return new Promise<string>((resolve, reject) => {
//var name = "mongodb-" + mongo_platform + "-" + mongo_arch;
let name = "mongodb-" +
this.mongoDBPlatform.getPlatform() + "-" +
this.mongoDBPlatform.getArch();
let platform: string = this.mongoDBPlatform.getPlatform();
let arch: string = this.mongoDBPlatform.getArch();
let version: string = this.getVersion();
switch (platform) {
case 'osx':
if ((version === 'latest') || semver.satisfies(version, '>=3.5')) {
platform = `${platform}-ssl`;
}
break;
case 'win32':
// TODO: '2012plus' for 4.x and above
if ((version === 'latest') || semver.satisfies(version, '>=3.5')) {
arch = `${arch}-2008plus-ssl`;
}
break;
default:
break;
}
let name: string = `mongodb-${platform}-${arch}`;
this.mongoDBPlatform.getOSVersionString().then(osString => {

@@ -470,3 +487,3 @@ osString && (name += `-${osString}`);

});
});
});
}

@@ -480,3 +497,3 @@ }

debug: any;
constructor(platform: string, arch: string) {

@@ -487,11 +504,11 @@ this.debug = Debug('mongodb-download-MongoDBPlatform');

}
getPlatform(): string {
return this.platform;
}
getArch(): string {
return this.arch;
}
getArchiveType(): string {

@@ -504,3 +521,3 @@ if ( this.getPlatform() === "win32" ) {

}
getCommonReleaseString(): string {

@@ -510,3 +527,3 @@ let name: string = `mongodb-${this.getPlatform()}-${this.getArch()}`;

}
getOSVersionString(): Promise<string> {

@@ -519,3 +536,3 @@ if ( this.getPlatform() === "linux" && this.getArch() !== "i686") {

}
getOtherOSVersionString(): Promise<string> {

@@ -526,3 +543,3 @@ return new Promise<string>((resolve, reject) => {

}
getLinuxOSVersionString(): Promise<string> {

@@ -544,6 +561,7 @@ return new Promise<string>((resolve, reject) => {

} else {
// TODO: 'legacy', 'static'
reject("");
}
}
});
});
});
}

@@ -554,3 +572,5 @@

let release: number = parseFloat(os.release);
if (release >= 8.1) {
if (release >= 9.2) {
name += "92";
} else if (release >= 8.1) {
name += "81";

@@ -564,3 +584,3 @@ } else if (release >= 7.1) {

}
getFedoraVersionString(os: any): string {

@@ -580,3 +600,3 @@ let name: string = "rhel";

}
getRhelVersionString(os: any): string {

@@ -591,2 +611,3 @@ let name: string = "rhel";

} else {
// TODO: 'rhel57'
this.debug("using legacy release");

@@ -596,3 +617,3 @@ }

}
getElementaryOSVersionString(os: any): string {

@@ -602,3 +623,3 @@ let name: string = "ubuntu1404";

}
getSuseVersionString(os: any): string {

@@ -614,3 +635,3 @@ let [release]: [string | null] = os.release.match(/(^11|^12)/) || [null];

}
getUbuntuVersionString(os: any): string {

@@ -633,2 +654,4 @@ let name: string = "ubuntu";

name += "1604";
} else if (os.release === "18.04") {
name += "1804";
} else if (major_version === 16) {

@@ -644,4 +667,4 @@ // default for major 16 to 1604

}
translatePlatform(platform: string): string {

@@ -664,3 +687,3 @@ switch (platform) {

}
translateArch(arch: string, mongoPlatform: string): string {

@@ -683,3 +706,3 @@ if (arch === "ia32") {

}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc