Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit e44afa9

Browse files
committed
converted to TypeScript
1 parent 6962878 commit e44afa9

15 files changed

+1021
-314
lines changed

README.md

+27-30
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,49 @@ $ mongodb-download --version=3.0.6
1414
## Synopsis
1515

1616
```javascript
17-
var download = require('mongodb-download')
18-
19-
download({
20-
version: '3.0.6',
21-
arch: 'ia32',
22-
platform: 'win32',
23-
download_dir: './temp_download', // defaults to os.tmpdir()
24-
http_opts: {} // extra options that one would want to pass to http request
25-
}, function (err, location) {
26-
// location will be the path of the archive that it downloaded.
27-
})
17+
let {MongoDBDownload} = require('mongodb-download');
18+
19+
let mongoDBDownload: any = new MongoDBDownload({});
20+
21+
mongoDBDownload.download().then((downloadLocation: string) => {
22+
console.log(`Downloaded MongoDB: ${downloadLocation}`);
23+
}, (err: any) => {
24+
throw err;
25+
});
2826
```
2927

30-
if you don't specify `arch` or `platform` args it will use `require('os')` to get them from the current OS. specifying `version` is mandatory.
28+
if you don't specify `arch` or `platform` args it will use `require('os')` to get them from the current OS.
3129

3230
## Options
3331

34-
### version (required)
35-
MongoDB version to download
32+
### version (optional)
33+
MongoDB version to download, "latest" is by default
3634

3735
### arch (optional)
3836
32 or 64 bit version architecture, possible values: ia32 or x64
3937

4038
### platform (optional)
4139
Target platform of a download, possible values: "win32", "darwin", "osx", "linux" or "elementary OS"
4240

43-
### download_dir (optional)
41+
### downloadDir (optional)
4442
Download path
4543

46-
### http_opts (optional)
44+
### http (optional)
4745
Additional options that are going to be passed to http library, such as "agent".
4846

4947
```javascript
50-
var download = require('mongodb-download');
51-
var https_proxy_agent = require('https-proxy-agent');
52-
53-
var proxy_url = "https://localhost:3128";
54-
var proxy_agent = new https_proxy_agent(proxy_url);
55-
56-
download({
57-
version: '3.0.6',
58-
http_opts: {
59-
agent: proxy_agent
60-
}
61-
}, function (err, location) {
62-
// location will be the path of the archive that it downloaded.
63-
})
48+
let {MongoDBDownload} = require('mongodb-download');
49+
let httpsProxyAgent = require('https-proxy-agent');
50+
51+
var proxyUrl = "https://localhost:3128";
52+
var proxyAgent = new httpsProxyAgent(proxy_url);
53+
54+
let mongoDBDownload: any = new MongoDBDownload({
55+
version: '3.0.6',
56+
http: {
57+
agent: proxyAgent
58+
}
59+
});
60+
6461

6562
```

built/mongodb-download-cli.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare let MongoDBDownload: any;
2+
declare let argv: any;
3+
declare let mongoDBDownload: any;

built/mongodb-download-cli.js

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

built/mongodb-download-cli.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

built/mongodb-download.d.ts

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
export interface IMongoDBDownloadOptions {
2+
platform: string;
3+
arch: string;
4+
version: string;
5+
downloadDir: string;
6+
http: any;
7+
}
8+
export interface IMongoDBDownloadProgress {
9+
current: number;
10+
length: number;
11+
total: number;
12+
lastStdout: string;
13+
}
14+
export declare class MongoDBDownload {
15+
options: IMongoDBDownloadOptions;
16+
mongoDBPlatform: MongoDBPlatform;
17+
downloadProgress: IMongoDBDownloadProgress;
18+
constructor({platform, arch, downloadDir, version, http}: {
19+
platform?: any;
20+
arch?: any;
21+
downloadDir?: any;
22+
version?: string;
23+
http?: {};
24+
});
25+
getPlatform(): string;
26+
getArch(): string;
27+
getVersion(): string;
28+
getDownloadDir(): string;
29+
getDownloadLocation(): Promise<string>;
30+
getTempDownloadLocation(): Promise<string>;
31+
download(): Promise<string>;
32+
httpDownload(httpOptions: any, downloadLocation: string, tempDownloadLocation: string): Promise<string>;
33+
getCrReturn(): string;
34+
locationExists(location: string): boolean;
35+
printDownloadProgress(chunk: any): void;
36+
getHttpOptions(): Promise<any>;
37+
getDownloadURI(): Promise<any>;
38+
createDownloadDir(): Promise<string>;
39+
getArchiveName(): Promise<string>;
40+
}
41+
export declare class MongoDBPlatform {
42+
platform: string;
43+
arch: string;
44+
constructor(platform: string, arch: string);
45+
getPlatform(): string;
46+
getArch(): string;
47+
getArchiveType(): string;
48+
getCommonReleaseString(): string;
49+
getOSVersionString(): Promise<string>;
50+
getOtherOSVersionString(): Promise<string>;
51+
getLinuxOSVersionString(): Promise<string>;
52+
getDebianVersionString(os: any): string;
53+
getFedoraVersionString(os: any): string;
54+
getRhelVersionString(os: any): string;
55+
getElementaryOSVersionString(os: any): string;
56+
getSuseVersionString(os: any): string;
57+
getUbuntuVersionString(os: any): string;
58+
translatePlatform(platform: string): string;
59+
translateArch(arch: string, mongoPlatform: string): string;
60+
}

0 commit comments

Comments
 (0)