locize-cli
Advanced tools
Comparing version 7.15.1 to 7.15.2
@@ -8,2 +8,6 @@ # locize-cli change log | ||
## [7.15.2](https://github.com/locize/locize-cli/compare/v7.15.1...v7.15.2) - 2023-01-06 | ||
- optimize --skip-empty false handling for download command | ||
## [7.15.1](https://github.com/locize/locize-cli/compare/v7.15.0...v7.15.1) - 2023-12-19 | ||
@@ -10,0 +14,0 @@ |
@@ -154,2 +154,39 @@ const colors = require('colors'); | ||
const filterDownloads = (opt, downloads) => { | ||
if (opt.skipEmpty) return downloads.filter((d) => d.size > 2); | ||
if (downloads.length < 1) return downloads; | ||
const allNamespaces = []; | ||
const downloadMap = {}; | ||
downloads.forEach((d) => { | ||
const splitted = d.key.split('/'); | ||
const p = splitted[d.isPrivate ? 1 : 0]; | ||
const v = splitted[d.isPrivate ? 2 : 1]; | ||
const l = splitted[d.isPrivate ? 3 : 2]; | ||
const n = splitted[d.isPrivate ? 4 : 3]; | ||
downloadMap[p] = downloadMap[p] || {}; | ||
downloadMap[p][v] = downloadMap[p][v] || {}; | ||
downloadMap[p][v][l] = downloadMap[p][v][l] || {}; | ||
downloadMap[p][v][l][n] = d; | ||
if (allNamespaces.indexOf(n) < 0) allNamespaces.push(n); | ||
}); | ||
Object.keys(downloadMap).forEach((projectId) => { | ||
Object.keys(downloadMap[projectId]).forEach((version) => { | ||
Object.keys(downloadMap[projectId][version]).forEach((language) => { | ||
allNamespaces.forEach((namespace) => { | ||
if (!downloadMap[projectId][version][language][namespace]) { | ||
downloads.push({ | ||
url: `${opt.apiPath}/${projectId}/${version}/${language}/${namespace}`, | ||
key: `${projectId}/${version}/${language}/${namespace}`, | ||
lastModified: '1960-01-01T00:00:00.000Z', | ||
size: 0 | ||
}); | ||
} | ||
}); | ||
}); | ||
}); | ||
}); | ||
return downloads; | ||
}; | ||
const download = (opt, cb) => { | ||
@@ -207,3 +244,2 @@ opt.format = opt.format || 'json'; | ||
}, (err, res, obj) => { | ||
obj = obj || []; | ||
if (res && res.status === 401) { | ||
@@ -214,4 +250,3 @@ opt.apiKey = null; | ||
}, (err, res, obj) => { | ||
obj = obj || []; | ||
if (opt.skipEmpty) obj = obj.filter((d) => d.size > 2); | ||
obj = filterDownloads(opt, obj || []); | ||
handleDownload(opt, url, err, res, obj, cb); | ||
@@ -222,3 +257,3 @@ }); | ||
if (opt.skipEmpty) obj = obj.filter((d) => d.size > 2); | ||
obj = filterDownloads(opt, obj || []); | ||
handleDownload(opt, url, err, res, obj, cb); | ||
@@ -225,0 +260,0 @@ }); |
{ | ||
"name": "locize-cli", | ||
"version": "7.15.1", | ||
"version": "7.15.2", | ||
"description": "locize cli to import locales", | ||
@@ -37,3 +37,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"eslint": "8.53.0", | ||
"eslint": "8.56.0", | ||
"gh-release": "7.0.2", | ||
@@ -40,0 +40,0 @@ "pkg": "5.8.1" |
180523
3103