Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"bin": "built/mongodb-download-cli.js",
"types": "built/mongodb-download.d.ts",
"scripts": {
"build": "tsc",
"test": "mocha"
},
"repository": {
Expand All @@ -22,6 +23,7 @@
"url": "https://github.com/winfinit/mongodb-download/issues"
},
"dependencies": {
"semver": "^5.6.0",
"yargs": "^3.26.0",
"debug": "^2.2.0",
"getos": "^2.7.0",
Expand All @@ -34,7 +36,9 @@
"devDependencies": {
"@types/node": "^6.0.70",
"chai": "^3.5.0",
"mocha": "^3.2.0"
"mocha": "^3.2.0",
"rewire": "^4.0.1",
"typescript": "^3.1.3"
},
"homepage": "https://github.com/winfinit/mongodb-download#readme"
}
31 changes: 25 additions & 6 deletions src/mongodb-download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ const path: any = require('path');
const Debug: any = require('debug');
const getos: any = require('getos');
const url: any = require('url');
const semver: any = require('semver');
const decompress: any = require('decompress');
const request: any = require('request-promise');
const md5File: any = require('md5-file');

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

export interface IMongoDBDownloadOptions {
Expand Down Expand Up @@ -273,7 +274,7 @@ export class MongoDBDownload {
this.getDownloadURIMD5().then((md5URL) => {
request(md5URL).then((signatureContent: string) => {
this.debug(`getDownloadMD5Hash content: ${signatureContent}`);
let signatureMatch: string[] = signatureContent.match(/(.*?)\s/);
let signatureMatch: string[] = signatureContent.match(/([^\s]*)(\s*|$)/);
let signature: string = signatureMatch[1];
this.debug(`getDownloadMD5Hash extracted signature: ${signature}`);
this.cacheMD5Hash(signature).then(() => {
Expand Down Expand Up @@ -426,10 +427,26 @@ export class MongoDBDownload {

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 => {
osString && (name += `-${osString}`);
Expand Down Expand Up @@ -506,6 +523,7 @@ export class MongoDBPlatform {
} else if (/debian/i.test(os.dist)) {
resolve(this.getDebianVersionString(os));
} else {
// TODO: 'legacy', 'static'
reject("");
}
});
Expand Down Expand Up @@ -551,6 +569,7 @@ export class MongoDBPlatform {
} else if (/^5/.test(os.release)) {
name += "55";
} else {
// TODO: 'rhel57'
this.debug("using legacy release");
}
return name;
Expand Down
Loading