@naesofteak/naeso 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +46 -2
- package/package.json +48 -4
- package/src/core/cache.js +39 -0
- package/src/core/checksum.js +33 -0
- package/src/core/compatibility.js +152 -0
- package/src/core/downloader.js +234 -0
- package/src/core/environment.js +225 -0
- package/src/core/extractor.js +235 -0
- package/src/core/installer.js +691 -0
- package/src/core/package-downloader.js +284 -0
- package/src/core/package-manager.js +0 -0
- package/src/core/package-resolver.js +125 -0
- package/src/core/platform.js +41 -0
- package/src/core/registry.js +70 -0
- package/src/core/target.js +56 -0
- package/src/core/uninstaller.js +389 -0
- package/src/index.js +635 -0
- package/src/registry/packages/mongodb/package.json +100 -0
- package/src/services/launchd.js +174 -0
- package/src/services/mongodb.js +166 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Naesofteak Private Limited
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Naeso
|
|
2
|
+
|
|
3
|
+
**Naeso** is a package manager for macOS developed and maintained by **Naesofteak Private Limited**.
|
|
4
|
+
|
|
5
|
+
Naeso provides a simple command-line interface for discovering, installing, verifying, managing, and running software packages on macOS.
|
|
6
|
+
|
|
7
|
+
The project is designed to support both **Intel (x86_64)** and **Apple Silicon (arm64)** Macs.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- Package search
|
|
14
|
+
- Package information
|
|
15
|
+
- Package compatibility detection
|
|
16
|
+
- Automatic architecture detection
|
|
17
|
+
- Version-aware package resolution
|
|
18
|
+
- Download progress display
|
|
19
|
+
- SHA-256 verification where official checksums are available
|
|
20
|
+
- Multi-artifact package installation
|
|
21
|
+
- Automatic installation directory management
|
|
22
|
+
- Automatic PATH configuration
|
|
23
|
+
- Package uninstall
|
|
24
|
+
- macOS `launchd` service management
|
|
25
|
+
- Package status management
|
|
26
|
+
- Intel and Apple Silicon support
|
|
27
|
+
- Local package cache
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Requirements
|
|
32
|
+
|
|
33
|
+
- macOS
|
|
34
|
+
- Node.js 18 or newer
|
|
35
|
+
- Intel (x86_64) or Apple Silicon (arm64)
|
|
36
|
+
- Internet connection for downloading packages
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
Install Naeso globally using npm:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install -g @naesofteak/naeso
|
|
46
|
+
|
|
2
47
|
|
|
3
|
-
This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naesofteak/naeso",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Naesofteak Package Manager for macOS",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"bin": {
|
|
8
|
+
"naeso": "src/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"start": "node src/index.js",
|
|
17
|
+
"test": "node src/index.js --help"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"naeso",
|
|
21
|
+
"naesofteak",
|
|
22
|
+
"package-manager",
|
|
23
|
+
"macos",
|
|
24
|
+
"installer",
|
|
25
|
+
"cli",
|
|
26
|
+
"mongodb",
|
|
27
|
+
"node",
|
|
28
|
+
"nginx",
|
|
29
|
+
"redis"
|
|
30
|
+
],
|
|
31
|
+
"author": "Naesofteak Private Limited",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"commander": "^15.0.0"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/naesofteak/naeso#readme",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/naesofteak/naeso.git"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/naesofteak/naeso/issues"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const CACHE_ROOT = path.join(
|
|
5
|
+
process.env.HOME,
|
|
6
|
+
".naeso",
|
|
7
|
+
"cache"
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
function getPackageCachePath(packageName) {
|
|
11
|
+
return path.join(
|
|
12
|
+
CACHE_ROOT,
|
|
13
|
+
packageName
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function ensurePackageCache(packageName) {
|
|
18
|
+
const cachePath =
|
|
19
|
+
getPackageCachePath(packageName);
|
|
20
|
+
|
|
21
|
+
fs.mkdirSync(cachePath, {
|
|
22
|
+
recursive: true
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return cachePath;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getCachedFile(packageName, filename) {
|
|
29
|
+
return path.join(
|
|
30
|
+
getPackageCachePath(packageName),
|
|
31
|
+
filename
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
getPackageCachePath,
|
|
37
|
+
ensurePackageCache,
|
|
38
|
+
getCachedFile
|
|
39
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const crypto = require("crypto");
|
|
3
|
+
|
|
4
|
+
function calculateSHA256(filePath) {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const hash = crypto.createHash("sha256");
|
|
7
|
+
const stream = fs.createReadStream(filePath);
|
|
8
|
+
|
|
9
|
+
stream.on("data", (data) => {
|
|
10
|
+
hash.update(data);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
stream.on("end", () => {
|
|
14
|
+
resolve(hash.digest("hex"));
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
stream.on("error", reject);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function verifySHA256(filePath, expectedHash) {
|
|
22
|
+
const actualHash = await calculateSHA256(filePath);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
actualHash.toLowerCase() ===
|
|
26
|
+
expectedHash.toLowerCase()
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = {
|
|
31
|
+
calculateSHA256,
|
|
32
|
+
verifySHA256
|
|
33
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
function getLatestVersion(pkg) {
|
|
2
|
+
const versions = Object.keys(
|
|
3
|
+
pkg.versions || {}
|
|
4
|
+
);
|
|
5
|
+
|
|
6
|
+
if (versions.length === 0) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return versions.sort(compareVersions).at(-1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function compareVersions(a, b) {
|
|
14
|
+
const pa = a.split(".").map(Number);
|
|
15
|
+
const pb = b.split(".").map(Number);
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < 3; i++) {
|
|
18
|
+
const av = pa[i] || 0;
|
|
19
|
+
const bv = pb[i] || 0;
|
|
20
|
+
|
|
21
|
+
if (av !== bv) {
|
|
22
|
+
return av - bv;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getVersionConfig(
|
|
30
|
+
pkg,
|
|
31
|
+
version = null
|
|
32
|
+
) {
|
|
33
|
+
const selectedVersion =
|
|
34
|
+
version || getLatestVersion(pkg);
|
|
35
|
+
|
|
36
|
+
if (!selectedVersion) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const config =
|
|
41
|
+
pkg.versions[selectedVersion];
|
|
42
|
+
|
|
43
|
+
if (!config) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
version: selectedVersion,
|
|
49
|
+
config
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function isPackageSupported(
|
|
54
|
+
pkg,
|
|
55
|
+
target,
|
|
56
|
+
version = null
|
|
57
|
+
) {
|
|
58
|
+
const versionConfig =
|
|
59
|
+
getVersionConfig(pkg, version);
|
|
60
|
+
|
|
61
|
+
if (!versionConfig) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const targetConfig =
|
|
66
|
+
versionConfig.config.targets?.[target];
|
|
67
|
+
|
|
68
|
+
if (!targetConfig) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/*
|
|
73
|
+
* Multi-artifact package
|
|
74
|
+
*/
|
|
75
|
+
if (targetConfig.artifacts) {
|
|
76
|
+
const artifacts =
|
|
77
|
+
Object.values(targetConfig.artifacts);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
artifacts.length > 0 &&
|
|
81
|
+
artifacts.every(
|
|
82
|
+
(artifact) =>
|
|
83
|
+
artifact &&
|
|
84
|
+
typeof artifact.url === "string" &&
|
|
85
|
+
artifact.url.length > 0
|
|
86
|
+
)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
* Legacy single-artifact package
|
|
92
|
+
*/
|
|
93
|
+
return Boolean(
|
|
94
|
+
targetConfig.url
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getSupportedTargets(
|
|
99
|
+
pkg,
|
|
100
|
+
version = null
|
|
101
|
+
) {
|
|
102
|
+
const versionConfig =
|
|
103
|
+
getVersionConfig(pkg, version);
|
|
104
|
+
|
|
105
|
+
if (!versionConfig) {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return Object.keys(
|
|
110
|
+
versionConfig.config.targets || {}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function getArtifacts(
|
|
115
|
+
pkg,
|
|
116
|
+
target,
|
|
117
|
+
version = null
|
|
118
|
+
) {
|
|
119
|
+
const versionConfig =
|
|
120
|
+
getVersionConfig(pkg, version);
|
|
121
|
+
|
|
122
|
+
if (!versionConfig) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const targetConfig =
|
|
127
|
+
versionConfig.config.targets?.[target];
|
|
128
|
+
|
|
129
|
+
if (!targetConfig) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (targetConfig.artifacts) {
|
|
134
|
+
return targetConfig.artifacts;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (targetConfig.url) {
|
|
138
|
+
return {
|
|
139
|
+
default: targetConfig
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
module.exports = {
|
|
147
|
+
getLatestVersion,
|
|
148
|
+
getVersionConfig,
|
|
149
|
+
isPackageSupported,
|
|
150
|
+
getSupportedTargets,
|
|
151
|
+
getArtifacts
|
|
152
|
+
};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const https = require("https");
|
|
4
|
+
const http = require("http");
|
|
5
|
+
|
|
6
|
+
function formatBytes(bytes) {
|
|
7
|
+
if (bytes === 0) return "0 B";
|
|
8
|
+
|
|
9
|
+
const units = ["B", "KB", "MB", "GB"];
|
|
10
|
+
const index = Math.floor(
|
|
11
|
+
Math.log(bytes) / Math.log(1024)
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
return `${(
|
|
15
|
+
bytes / Math.pow(1024, index)
|
|
16
|
+
).toFixed(index === 0 ? 0 : 1)} ${units[index]}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function formatTime(seconds) {
|
|
20
|
+
if (!Number.isFinite(seconds) || seconds < 0) {
|
|
21
|
+
return "--";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (seconds < 60) {
|
|
25
|
+
return `${Math.ceil(seconds)}s`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const minutes = Math.floor(seconds / 60);
|
|
29
|
+
const remainingSeconds =
|
|
30
|
+
Math.ceil(seconds % 60);
|
|
31
|
+
|
|
32
|
+
return `${minutes}m ${remainingSeconds}s`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function renderProgress(
|
|
36
|
+
filename,
|
|
37
|
+
downloaded,
|
|
38
|
+
total,
|
|
39
|
+
speed,
|
|
40
|
+
eta
|
|
41
|
+
) {
|
|
42
|
+
const width = 40;
|
|
43
|
+
|
|
44
|
+
const percentage =
|
|
45
|
+
total > 0
|
|
46
|
+
? downloaded / total
|
|
47
|
+
: 0;
|
|
48
|
+
|
|
49
|
+
const completed =
|
|
50
|
+
Math.round(width * percentage);
|
|
51
|
+
|
|
52
|
+
const remaining =
|
|
53
|
+
width - completed;
|
|
54
|
+
|
|
55
|
+
const bar =
|
|
56
|
+
"█".repeat(completed) +
|
|
57
|
+
"░".repeat(remaining);
|
|
58
|
+
|
|
59
|
+
const percentText =
|
|
60
|
+
`${(percentage * 100).toFixed(0)}%`;
|
|
61
|
+
|
|
62
|
+
const line =
|
|
63
|
+
`Downloading ${filename}\n` +
|
|
64
|
+
`[${bar}] ${percentText} ` +
|
|
65
|
+
`${formatBytes(downloaded)} / ` +
|
|
66
|
+
`${formatBytes(total)}\n` +
|
|
67
|
+
`Speed: ${formatBytes(speed)}/s ` +
|
|
68
|
+
`ETA: ${formatTime(eta)}`;
|
|
69
|
+
|
|
70
|
+
process.stdout.write(
|
|
71
|
+
`\r\x1b[3A\x1b[0J${line}`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function downloadFile(url, destination) {
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
77
|
+
|
|
78
|
+
const protocol =
|
|
79
|
+
url.startsWith("https://")
|
|
80
|
+
? https
|
|
81
|
+
: http;
|
|
82
|
+
|
|
83
|
+
const directory =
|
|
84
|
+
path.dirname(destination);
|
|
85
|
+
|
|
86
|
+
fs.mkdirSync(directory, {
|
|
87
|
+
recursive: true
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const request =
|
|
91
|
+
protocol.get(url, (response) => {
|
|
92
|
+
|
|
93
|
+
// --------------------------------
|
|
94
|
+
// Redirect
|
|
95
|
+
// --------------------------------
|
|
96
|
+
|
|
97
|
+
if (
|
|
98
|
+
response.statusCode >= 300 &&
|
|
99
|
+
response.statusCode < 400 &&
|
|
100
|
+
response.headers.location
|
|
101
|
+
) {
|
|
102
|
+
response.resume();
|
|
103
|
+
|
|
104
|
+
return downloadFile(
|
|
105
|
+
response.headers.location,
|
|
106
|
+
destination
|
|
107
|
+
)
|
|
108
|
+
.then(resolve)
|
|
109
|
+
.catch(reject);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// --------------------------------
|
|
113
|
+
// HTTP error
|
|
114
|
+
// --------------------------------
|
|
115
|
+
|
|
116
|
+
if (response.statusCode !== 200) {
|
|
117
|
+
response.resume();
|
|
118
|
+
|
|
119
|
+
return reject(
|
|
120
|
+
new Error(
|
|
121
|
+
`Download failed: HTTP ${response.statusCode}`
|
|
122
|
+
)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// --------------------------------
|
|
127
|
+
// Existing file protection
|
|
128
|
+
// --------------------------------
|
|
129
|
+
|
|
130
|
+
let file;
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
file = fs.createWriteStream(
|
|
134
|
+
destination,
|
|
135
|
+
{
|
|
136
|
+
flags: "wx"
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
return reject(error);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const total =
|
|
144
|
+
Number(
|
|
145
|
+
response.headers["content-length"]
|
|
146
|
+
) || 0;
|
|
147
|
+
|
|
148
|
+
let downloaded = 0;
|
|
149
|
+
|
|
150
|
+
const startTime =
|
|
151
|
+
Date.now();
|
|
152
|
+
|
|
153
|
+
console.log("");
|
|
154
|
+
console.log("");
|
|
155
|
+
console.log("");
|
|
156
|
+
|
|
157
|
+
response.on("data", (chunk) => {
|
|
158
|
+
|
|
159
|
+
downloaded += chunk.length;
|
|
160
|
+
|
|
161
|
+
const elapsed =
|
|
162
|
+
(Date.now() - startTime) / 1000;
|
|
163
|
+
|
|
164
|
+
const speed =
|
|
165
|
+
elapsed > 0
|
|
166
|
+
? downloaded / elapsed
|
|
167
|
+
: 0;
|
|
168
|
+
|
|
169
|
+
const remaining =
|
|
170
|
+
total > downloaded
|
|
171
|
+
? total - downloaded
|
|
172
|
+
: 0;
|
|
173
|
+
|
|
174
|
+
const eta =
|
|
175
|
+
speed > 0
|
|
176
|
+
? remaining / speed
|
|
177
|
+
: Infinity;
|
|
178
|
+
|
|
179
|
+
renderProgress(
|
|
180
|
+
path.basename(destination),
|
|
181
|
+
downloaded,
|
|
182
|
+
total,
|
|
183
|
+
speed,
|
|
184
|
+
eta
|
|
185
|
+
);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
response.pipe(file);
|
|
189
|
+
|
|
190
|
+
response.on("end", () => {
|
|
191
|
+
process.stdout.write("\n\n");
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
file.on("finish", () => {
|
|
195
|
+
|
|
196
|
+
file.close(() => {
|
|
197
|
+
resolve(destination);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
file.on("error", (error) => {
|
|
202
|
+
|
|
203
|
+
file.close();
|
|
204
|
+
|
|
205
|
+
fs.unlink(
|
|
206
|
+
destination,
|
|
207
|
+
() => {}
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
reject(error);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
request.setTimeout(
|
|
215
|
+
30000,
|
|
216
|
+
() => {
|
|
217
|
+
request.destroy(
|
|
218
|
+
new Error(
|
|
219
|
+
"Download timed out."
|
|
220
|
+
)
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
request.on(
|
|
226
|
+
"error",
|
|
227
|
+
reject
|
|
228
|
+
);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
module.exports = {
|
|
233
|
+
downloadFile
|
|
234
|
+
};
|