locize-cli 7.10.0 → 7.10.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  Project versioning adheres to [Semantic Versioning](http://semver.org/).
6
6
  Change log format is based on [Keep a Changelog](http://keepachangelog.com/).
7
7
 
8
+ ## [7.10.1](https://github.com/locize/locize-cli/compare/v7.10.0...v7.10.1) - 2022-04-07
9
+
10
+ - cache dns lookups
11
+
8
12
  ## [7.10.0](https://github.com/locize/locize-cli/compare/v7.9.1...v7.10.0) - 2022-03-15
9
13
 
10
14
  - gettext_i18next: try to detect v4 format
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locize-cli",
3
- "version": "7.10.0",
3
+ "version": "7.10.1",
4
4
  "description": "locize cli to import locales",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -10,6 +10,7 @@
10
10
  "@js.properties/properties": "0.5.4",
11
11
  "android-string-resource": "2.3.4",
12
12
  "async": "3.2.3",
13
+ "cacheable-lookup": "6.0.4",
13
14
  "colors": "1.4.0",
14
15
  "commander": "9.0.0",
15
16
  "csvjson": "5.1.0",
package/request.js CHANGED
@@ -1,10 +1,19 @@
1
1
  const package = require('./package.json');
2
2
  const fetch = require('node-fetch');
3
3
  const HttpsProxyAgent = require('https-proxy-agent');
4
+ const https = require('https');
5
+ const CacheableLookup = require('cacheable-lookup');
6
+ const cacheable = new CacheableLookup();
7
+ cacheable.install(https.globalAgent);
8
+
4
9
  const httpProxy = process.env.http_proxy || process.env.HTTP_PROXY || process.env.https_proxy || process.env.HTTPS_PROXY;
5
10
 
6
11
  module.exports = (url, options, callback) => {
7
- if (httpProxy) options.agent = new HttpsProxyAgent(httpProxy);
12
+ if (httpProxy) {
13
+ const httpsProxyAgent = new HttpsProxyAgent(httpProxy);
14
+ cacheable.install(httpsProxyAgent);
15
+ options.agent = httpsProxyAgent;
16
+ }
8
17
 
9
18
  options.headers = options.headers || {};
10
19
  options.headers['User-Agent'] = `${package.name}/v${package.version} (node/${process.version}; ${process.platform} ${process.arch})`;
@@ -23,7 +32,11 @@ module.exports = (url, options, callback) => {
23
32
  return { res };
24
33
  }
25
34
  }).then((ret) => callback(null, ret.res, ret.obj)).catch((err) => {
26
- if (err && err.message && err.message.indexOf('ENOTFOUND') > -1) {
35
+ if (err && err.message && (
36
+ err.message.indexOf('ENOTFOUND') > -1 ||
37
+ err.message.indexOf('ENODATA') > -1 ||
38
+ err.message.indexOf('ENOENT') > -1 // Windows: name exists, but not this record type
39
+ )) {
27
40
  setTimeout(() => {
28
41
  fetch(url, options).then((res) => {
29
42
  if (res.headers.get('content-type') && res.headers.get('content-type').indexOf('json') > 0) {
@@ -32,7 +45,7 @@ module.exports = (url, options, callback) => {
32
45
  return { res };
33
46
  }
34
47
  }).then((ret) => callback(null, ret.res, ret.obj)).catch(callback);
35
- }, 3000);
48
+ }, 5000);
36
49
  return;
37
50
  }
38
51
  callback(err);