mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 03:55:37 +01:00
drop more dependencies + remove updater
This commit is contained in:
parent
e667928863
commit
8965d60516
8 changed files with 1122 additions and 890 deletions
|
|
@ -1,39 +0,0 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const https = require('https');
|
||||
const chalk = require('chalk');
|
||||
|
||||
const src = path.resolve(__dirname, '../lang');
|
||||
const dest = path.resolve(__dirname, '../public/country');
|
||||
const files = fs.readdirSync(src);
|
||||
|
||||
const getUrl = locale =>
|
||||
`https://raw.githubusercontent.com/umpirsky/country-list/master/data/${locale}/country.json`;
|
||||
|
||||
const asyncForEach = async (array, callback) => {
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
await callback(array[index], index, array);
|
||||
}
|
||||
};
|
||||
|
||||
if (!fs.existsSync(dest)) {
|
||||
fs.mkdirSync(dest);
|
||||
}
|
||||
|
||||
const download = async files => {
|
||||
await asyncForEach(files, async file => {
|
||||
const locale = file.replace('-', '_').replace('.json', '');
|
||||
|
||||
const filename = path.join(dest, file);
|
||||
if (!fs.existsSync(filename)) {
|
||||
await new Promise(resolve => {
|
||||
https.get(getUrl(locale), res => {
|
||||
console.log('Downloaded', chalk.greenBright('->'), filename);
|
||||
resolve(res.pipe(fs.createWriteStream(filename)));
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
download(files);
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const del = require('del');
|
||||
const prettier = require('prettier');
|
||||
const chalk = require('chalk');
|
||||
|
||||
const src = path.resolve(__dirname, '../lang');
|
||||
const dest = path.resolve(__dirname, '../build');
|
||||
const files = fs.readdirSync(src);
|
||||
|
||||
const removed = del.sync([path.join(dest, '*.json')]);
|
||||
|
||||
if (removed.length) {
|
||||
console.log(removed.map(n => `${n} ${chalk.redBright('✗')}`).join('\n'));
|
||||
}
|
||||
|
||||
if (!fs.existsSync(dest)) {
|
||||
fs.mkdirSync(dest);
|
||||
}
|
||||
|
||||
files.forEach(file => {
|
||||
const lang = require(`../lang/${file}`);
|
||||
const keys = Object.keys(lang).sort();
|
||||
|
||||
const formatted = keys.reduce((obj, key) => {
|
||||
obj[key] = { defaultMessage: lang[key] };
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
const json = prettier.format(JSON.stringify(formatted), { parser: 'json' });
|
||||
|
||||
fs.writeFileSync(path.resolve(dest, file), json);
|
||||
|
||||
console.log(path.resolve(src, file), chalk.greenBright('->'), path.resolve(dest, file));
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue