Skip to content

Commit 64a435b

Browse files
YozhikMnodkz
authored andcommitted
fix(MongoBinaryDownloadUrl): removed ssl from options (typegoose#57)
Now binaries older than 3.0 version are immediately installed with the ssl. Before and including 3.0 - without. Related typegoose#55
1 parent 5dc0b3d commit 64a435b

6 files changed

+16
-39
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ const mongod = new MongodbMemoryServer({
5858
downloadDir?: string, // by default %HOME/.mongodb-binaries
5959
platform?: string, // by default os.platform()
6060
arch?: string, // by default os.arch()
61-
ssl?: boolean, // by default false (use it if mongodb dist has only ssl version binary)
6261
debug?: boolean, // by default false
6362
},
6463
debug?: boolean, // by default false

src/MongoMemoryServer.js

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export type MongoMemoryServerOptsT = {
2222
downloadDir?: string,
2323
platform?: string,
2424
arch?: string,
25-
ssl?: boolean,
2625
debug?: boolean | Function,
2726
},
2827
debug?: boolean,

src/util/MongoBinary.js

-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export type MongoBinaryOpts = {
1515
downloadDir?: string,
1616
platform?: string,
1717
arch?: string,
18-
ssl?: boolean,
1918
debug?: boolean | Function,
2019
};
2120

@@ -27,7 +26,6 @@ export default class MongoBinary {
2726
downloadDir = path.resolve(os.homedir(), '.mongodb-binaries'),
2827
platform = os.platform(),
2928
arch = os.arch(),
30-
ssl = false,
3129
version = '3.4.4',
3230
} = opts;
3331

@@ -79,7 +77,6 @@ export default class MongoBinary {
7977
downloadDir,
8078
platform,
8179
arch,
82-
ssl,
8380
version,
8481
});
8582

src/util/MongoBinaryDownload.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export type MongoBinaryDownloadOpts = {
1515
downloadDir: string,
1616
platform: string,
1717
arch: string,
18-
ssl: boolean,
1918
debug?: boolean | Function,
2019
};
2120

@@ -32,21 +31,12 @@ export default class MongoBinaryDownload {
3231

3332
downloadDir: string;
3433
arch: string;
35-
ssl: boolean;
3634
version: string;
3735
platform: string;
3836

39-
constructor({
40-
platform,
41-
arch,
42-
ssl,
43-
downloadDir,
44-
version,
45-
debug,
46-
}: $Shape<MongoBinaryDownloadOpts>) {
37+
constructor({ platform, arch, downloadDir, version, debug }: $Shape<MongoBinaryDownloadOpts>) {
4738
this.platform = platform || os.platform();
4839
this.arch = arch || os.arch();
49-
this.ssl = ssl || false;
5040
this.version = version || 'latest';
5141
this.downloadDir = path.resolve(downloadDir || 'mongodb-download');
5242
this.dlProgress = {
@@ -89,7 +79,6 @@ export default class MongoBinaryDownload {
8979
const mbdUrl = new MongoBinaryDownloadUrl({
9080
platform: this.platform,
9181
arch: this.arch,
92-
ssl: this.ssl,
9382
version: this.version,
9483
});
9584

src/util/MongoBinaryDownloadUrl.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,18 @@ export type MongoBinaryDownloadUrlOpts = {
1414
version: string,
1515
platform: string,
1616
arch: string,
17-
ssl?: boolean,
1817
os?: ?OS, // getos() result
1918
};
2019

2120
export default class MongoBinaryDownloadUrl {
2221
platform: string;
2322
arch: string;
24-
ssl: ?boolean;
2523
version: string;
2624
os: ?OS;
2725

28-
constructor({ platform, arch, ssl, version, os }: MongoBinaryDownloadUrlOpts) {
26+
constructor({ platform, arch, version, os }: MongoBinaryDownloadUrlOpts) {
2927
this.platform = this.translatePlatform(platform);
3028
this.arch = this.translateArch(arch, this.platform);
31-
this.ssl = ssl;
3229
this.version = version;
3330
this.os = os;
3431
}
@@ -50,6 +47,7 @@ export default class MongoBinaryDownloadUrl {
5047
}
5148
}
5249

50+
// https://www.mongodb.org/dl/win32
5351
async getArchiveNameWin(): Promise<string> {
5452
let name = `mongodb-${this.platform}`;
5553
name += `-${this.arch}`;
@@ -58,16 +56,24 @@ export default class MongoBinaryDownloadUrl {
5856
return name;
5957
}
6058

59+
// https://www.mongodb.org/dl/osx
6160
async getArchiveNameOsx(): Promise<string> {
6261
let name = `mongodb-osx`;
63-
if (this.ssl) {
62+
if (
63+
!(
64+
this.version.indexOf('3.0') === 0 ||
65+
this.version.indexOf('2.') === 0 ||
66+
this.version.indexOf('1.') === 0
67+
)
68+
) {
6469
name += '-ssl';
6570
}
6671
name += `-${this.arch}`;
6772
name += `-${this.version}.tgz`;
6873
return name;
6974
}
7075

76+
// https://www.mongodb.org/dl/linux
7177
async getArchiveNameLinux(): Promise<string> {
7278
let name = `mongodb-linux`;
7379
name += `-${this.arch}`;

src/util/__tests__/MongoBinaryDownloadUrl-test.js

+4-17
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,25 @@ import MongoBinaryDownloadUrl from '../MongoBinaryDownloadUrl';
55
describe('MongoBinaryDownloadUrl', () => {
66
describe('getDownloadUrl()', () => {
77
describe('for mac', () => {
8-
it('3.6.3 without ssl', async () => {
8+
it('above 3.0', async () => {
99
const du = new MongoBinaryDownloadUrl({
1010
platform: 'darwin',
1111
arch: 'x64',
1212
version: '3.6.3',
1313
});
14-
expect(await du.getDownloadUrl()).toBe(
15-
'https://fastdl.mongodb.org/osx/mongodb-osx-x86_64-3.6.3.tgz'
16-
);
17-
});
18-
19-
it('3.6.3 with ssl', async () => {
20-
const du = new MongoBinaryDownloadUrl({
21-
platform: 'darwin',
22-
arch: 'x64',
23-
version: '3.6.3',
24-
ssl: true,
25-
});
2614
expect(await du.getDownloadUrl()).toBe(
2715
'https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz'
2816
);
2917
});
3018

31-
it('3.6.3 with ssl', async () => {
19+
it('below and include 3.0', async () => {
3220
const du = new MongoBinaryDownloadUrl({
3321
platform: 'darwin',
3422
arch: 'x64',
35-
version: '3.6.3',
36-
ssl: true,
23+
version: '3.0.0',
3724
});
3825
expect(await du.getDownloadUrl()).toBe(
39-
'https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz'
26+
'https://fastdl.mongodb.org/osx/mongodb-osx-x86_64-3.0.0.tgz'
4027
);
4128
});
4229
});

0 commit comments

Comments
 (0)