@alwaysmeticulous/downloading-helpers 2.58.0 → 2.60.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.
|
@@ -8,10 +8,13 @@ const fs_1 = require("fs");
|
|
|
8
8
|
const stream_1 = require("stream");
|
|
9
9
|
const util_1 = require("util");
|
|
10
10
|
const axios_1 = __importDefault(require("axios"));
|
|
11
|
+
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
11
12
|
const promisifiedFinished = (0, util_1.promisify)(stream_1.finished);
|
|
12
13
|
const downloadFile = async (fileUrl, path) => {
|
|
14
|
+
const client = axios_1.default.create();
|
|
15
|
+
(0, axios_retry_1.default)(client, { retries: 3 });
|
|
13
16
|
const writer = (0, fs_1.createWriteStream)(path);
|
|
14
|
-
return
|
|
17
|
+
return client
|
|
15
18
|
.request({ method: "GET", url: fileUrl, responseType: "stream" })
|
|
16
19
|
.then(async (response) => {
|
|
17
20
|
response.data.pipe(writer);
|
|
@@ -8,6 +8,7 @@ const promises_1 = require("fs/promises");
|
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const common_1 = require("@alwaysmeticulous/common");
|
|
10
10
|
const axios_1 = __importDefault(require("axios"));
|
|
11
|
+
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
11
12
|
const loglevel_1 = __importDefault(require("loglevel"));
|
|
12
13
|
const snippets_1 = require("../config/snippets");
|
|
13
14
|
const local_data_utils_1 = require("../file-downloads/local-data.utils");
|
|
@@ -17,10 +18,12 @@ const fetchAsset = async (path) => {
|
|
|
17
18
|
const logger = loglevel_1.default.getLogger(common_1.METICULOUS_LOGGER_NAME);
|
|
18
19
|
const fetchUrl = new URL(path, (0, snippets_1.getSnippetsBaseUrl)()).href;
|
|
19
20
|
const assetFileName = `${(0, path_1.basename)(new URL(fetchUrl).pathname, ".js")}.cjs`;
|
|
21
|
+
const client = axios_1.default.create();
|
|
22
|
+
(0, axios_retry_1.default)(client, { retries: 3 });
|
|
20
23
|
const releaseLock = await (0, local_data_utils_1.waitToAcquireLockOnFile)(await getAssetsFilePath());
|
|
21
24
|
try {
|
|
22
25
|
const assetMetadata = await loadAssetMetadata();
|
|
23
|
-
const etag = (await
|
|
26
|
+
const etag = (await client.head(fetchUrl)).headers["etag"] || "";
|
|
24
27
|
const entry = assetMetadata.assets.find((item) => item.fileName === assetFileName);
|
|
25
28
|
const filePath = (0, path_1.join)(await getOrCreateAssetsDir(), assetFileName);
|
|
26
29
|
if (entry && etag !== "" && etag === entry.etag) {
|
|
@@ -28,7 +31,7 @@ const fetchAsset = async (path) => {
|
|
|
28
31
|
releaseLock();
|
|
29
32
|
return filePath;
|
|
30
33
|
}
|
|
31
|
-
const contents = (await
|
|
34
|
+
const contents = (await client.get(fetchUrl)).data;
|
|
32
35
|
await (0, promises_1.writeFile)(filePath, contents);
|
|
33
36
|
if (entry) {
|
|
34
37
|
logger.debug(`${fetchUrl} updated`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwaysmeticulous/downloading-helpers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.60.0",
|
|
4
4
|
"description": "Helper utilities for downloading files & scripts required to execute replays",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,10 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@alwaysmeticulous/api": "^2.56.0",
|
|
23
|
-
"@alwaysmeticulous/client": "^2.
|
|
24
|
-
"@alwaysmeticulous/common": "^2.
|
|
23
|
+
"@alwaysmeticulous/client": "^2.60.0",
|
|
24
|
+
"@alwaysmeticulous/common": "^2.60.0",
|
|
25
25
|
"adm-zip": "^0.5.9",
|
|
26
26
|
"axios": "^1.2.6",
|
|
27
|
+
"axios-retry": "^3.5.0",
|
|
27
28
|
"loglevel": "^1.8.0",
|
|
28
29
|
"luxon": "^3.2.1",
|
|
29
30
|
"proper-lockfile": "^4.1.2"
|
|
@@ -50,5 +51,5 @@
|
|
|
50
51
|
"bugs": {
|
|
51
52
|
"url": "https://github.com/alwaysmeticulous/meticulous-sdk/issues"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "79db2c64a95e1e13360fc94610cd717bbb9baded"
|
|
54
55
|
}
|