i18nexus-cli 2.0.2 → 2.1.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/package.json +3 -2
- package/pull.js +15 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "i18nexus-cli",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Command line interface (CLI) for accessing the i18nexus API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"@next/env": "^11.0.1",
|
|
18
18
|
"colors": "^1.4.0",
|
|
19
19
|
"commander": "^7.2.0",
|
|
20
|
-
"
|
|
20
|
+
"https-proxy-agent": "^5.0.0",
|
|
21
|
+
"node-fetch": "^2.6.7"
|
|
21
22
|
}
|
|
22
23
|
}
|
package/pull.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const fetch = require('node-fetch');
|
|
3
3
|
const colors = require('colors');
|
|
4
|
+
const HttpsProxyAgent = require('https-proxy-agent');
|
|
4
5
|
|
|
5
6
|
const handleError = async (response, usingVersion) => {
|
|
6
7
|
let json, message;
|
|
@@ -29,7 +30,7 @@ const cleanDirectory = path => {
|
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
// as safety
|
|
33
|
+
// as safety precaution, only delete folders that match regex
|
|
33
34
|
const regex = /^[a-z]{2}(-[A-Z]{2,4})?$/;
|
|
34
35
|
|
|
35
36
|
const contents = fs.readdirSync(path);
|
|
@@ -52,7 +53,19 @@ const pull = async opt => {
|
|
|
52
53
|
|
|
53
54
|
console.log(`Downloading translations to ${opt.path}...`);
|
|
54
55
|
|
|
55
|
-
const
|
|
56
|
+
const proxy =
|
|
57
|
+
process.env.http_proxy ||
|
|
58
|
+
process.env.HTTP_PROXY ||
|
|
59
|
+
process.env.https_proxy ||
|
|
60
|
+
process.env.HTTPS_PROXY;
|
|
61
|
+
|
|
62
|
+
const fetchOptions = {};
|
|
63
|
+
|
|
64
|
+
if (proxy) {
|
|
65
|
+
fetchOptions.agent = new HttpsProxyAgent(proxy);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const response = await fetch(url, fetchOptions);
|
|
56
69
|
|
|
57
70
|
if (response.status !== 200) {
|
|
58
71
|
return handleError(response, usingVersion);
|