|
|
|
var Messages = require("../www/common/translations/messages.json");
|
|
|
|
var Exec = require("child_process").exec;
|
|
|
|
|
|
|
|
var ignoreLines = function (source, pattern) {
|
|
|
|
if (!pattern.test(source)) { return source; }
|
|
|
|
return source.split('\n')
|
|
|
|
.map(function (line) {
|
|
|
|
if (pattern.test(line)) { return ''; }
|
|
|
|
return line;
|
|
|
|
})
|
|
|
|
.filter(Boolean)
|
|
|
|
.join("\n");
|
|
|
|
};
|
|
|
|
|
|
|
|
var GENERATED_PATTERNS = [
|
|
|
|
/(admin|settings)_.*(Hint|Title|Button)/,
|
|
|
|
/settings_colortheme/,
|
|
|
|
/loading_(state|drive|pad)_/,
|
|
|
|
/(admin|notifications|support|team|settings)_cat_/,
|
|
|
|
/features_f/,
|
|
|
|
];
|
|
|
|
var isPossiblyGenerated = function (key) {
|
|
|
|
return GENERATED_PATTERNS.some(function (patt) {
|
|
|
|
return patt.test(key);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var grep = function (pattern, cb) {
|
|
|
|
var exclude = [
|
|
|
|
'www/common/translations/*',
|
|
|
|
'www/common/onlyoffice/*',
|
|
|
|
'www/lib/*',
|
|
|
|
'www/common/pdfjs/*',
|
|
|
|
'*.css',
|
|
|
|
'www/common/highlight/*',
|
|
|
|
'*.min.js',
|
|
|
|
'.lesshintrc',
|
|
|
|
'CHANGELOG.md',
|
|
|
|
'LICENSE',
|
|
|
|
'package*.json',
|
|
|
|
'www/debug/chainpad.dist.js',
|
|
|
|
'www/pad/mathjax/MathJax.js',
|
|
|
|
'www/common/hyperscript.js',
|
|
|
|
'www/common/jscolor.js',
|
|
|
|
'.//scripts/*',
|
|
|
|
'./lib/*',
|
|
|
|
'./docs/*',
|
|
|
|
].map(function (patt) {
|
|
|
|
return "':(exclude)" + patt + "'";
|
|
|
|
}).join(' ');
|
|
|
|
|
|
|
|
// grep this repository, ignoring binary files and excluding anything matching the above patterns
|
|
|
|
var ignoreBinaries= '--binary-files=without-match ';
|
|
|
|
var command = 'git grep ' + pattern + " -- ':/' " + exclude;
|
|
|
|
|
|
|
|
Exec(command, function (err, stdout, stderr) {
|
|
|
|
if (err && err.code === 1 && err.killed === false) {
|
|
|
|
if (isPossiblyGenerated(pattern)) {
|
|
|
|
return cb(void 0, true, 'POSSIBLY_GENERATED');
|
|
|
|
}
|
|
|
|
return cb(void 0, true, "NOT_FOUND");
|
|
|
|
}
|
|
|
|
stdout = ignoreLines(stdout, /Binary file/);
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
if (err.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER') {
|
|
|
|
return cb(void 0, true, 'TOO_MUCH');
|
|
|
|
}
|
|
|
|
return void cb(err);
|
|
|
|
}
|
|
|
|
if (/data\-localization/.test(stdout)) {
|
|
|
|
return cb(void 0, true, "DATA_LOCALIZATION");
|
|
|
|
}
|
|
|
|
if (/(Messages|Msg|messages)\./.test(stdout)) {
|
|
|
|
return cb(void 0, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
//console.log(pattern, arguments);
|
|
|
|
cb(void 0, true, 'OTHER', stdout);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var keys = Object.keys(Messages);
|
|
|
|
var total = keys.length;
|
|
|
|
|
|
|
|
var limit = total;
|
|
|
|
|
|
|
|
var next = function () {
|
|
|
|
var key = keys[0];
|
|
|
|
if (!key) { return; }
|
|
|
|
keys.shift();
|
|
|
|
|
|
|
|
if (!limit--) { return void console.log("[DONE]"); }
|
|
|
|
|
|
|
|
grep(key, function (err, flagged, reason, output) {
|
|
|
|
if (err) {
|
|
|
|
return;
|
|
|
|
console.error("[%s]", key, err);
|
|
|
|
console.log();
|
|
|
|
} else if (!flagged) {
|
|
|
|
|
|
|
|
} else if (reason === 'OTHER') {
|
|
|
|
console.log('[%s] flagged for [OTHER]', key, output);
|
|
|
|
console.log();
|
|
|
|
} else {
|
|
|
|
console.log("[%s] flagged for [%s]", key, reason || '???');
|
|
|
|
}
|
|
|
|
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
next();
|