forked from verdnatura/hedera-web
Extract locale script, refactor
This commit is contained in:
parent
8a8372cc7f
commit
3026333088
|
@ -1,4 +1,8 @@
|
|||
extends: eslint:recommended
|
||||
env:
|
||||
es6: true
|
||||
parserOptions:
|
||||
sourceType: module
|
||||
rules:
|
||||
no-undef: 0
|
||||
no-redeclare: 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
hedera-web (1.405.50) stable; urgency=low
|
||||
hedera-web (1.405.51) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "hedera-web",
|
||||
"version": "1.405.50",
|
||||
"version": "1.405.51",
|
||||
"description": "Verdnatura web page",
|
||||
"license": "GPL-3.0",
|
||||
"repository": {
|
||||
|
@ -8,11 +8,14 @@
|
|||
"url": "https://git.verdnatura.es/hedera-web"
|
||||
},
|
||||
"devDependencies": {
|
||||
"archiver": "^2.1.0",
|
||||
"assets-webpack-plugin": "^3.5.1",
|
||||
"bundle-loader": "^0.5.4",
|
||||
"css-loader": "^0.25.0",
|
||||
"eslint": "^3.16.1",
|
||||
"file-loader": "^0.9.0",
|
||||
"fs-extra": "^5.0.0",
|
||||
"glob": "^7.1.2",
|
||||
"json-loader": "^0.5.4",
|
||||
"raw-loader": "^0.5.1",
|
||||
"style-loader": "^0.19.0",
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"InvalidAction": "Invalid action"
|
||||
|
||||
,"EmptyQuery": "Empty query"
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
SELECT CONCAT_WS('/', c.pdfs_dir, invoice_get_path (#invoice))
|
||||
SELECT CONCAT_WS('/', c.pdfs_dir, invoiceGetPath(#invoice))
|
||||
FROM config c
|
||||
JOIN invoice_view i
|
||||
WHERE i.invoice_id = #invoice
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
var glob = require('glob');
|
||||
var fs = require('fs-extra');
|
||||
var path = require('path');
|
||||
var archiver = require('archiver');
|
||||
|
||||
let lang = process.argv[2];
|
||||
|
||||
if (lang == null)
|
||||
{
|
||||
let baseName = path.basename(process.argv[1]);
|
||||
console.log(`Usage: ${baseName} language_code`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let nDirs;
|
||||
let projectDir;
|
||||
|
||||
fs.remove(lang, () => {
|
||||
fs.realpath(`${__dirname}/..`, (err, realPath) => {
|
||||
projectDir = realPath;
|
||||
let len = projectDir.length + 1;
|
||||
|
||||
glob(`${projectDir}/**/locale/`, (err, localeDirs) => {
|
||||
nDirs = localeDirs.length * 2;
|
||||
|
||||
for (let localeDir of localeDirs) {
|
||||
localeDir = localeDir.substr(len)
|
||||
|
||||
if (/^node_modules\//.test (localeDir))
|
||||
continue;
|
||||
|
||||
exportLocale(localeDir);
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
function exportLocale (localeDir) {
|
||||
let dstDir = `${lang}/${localeDir}`;
|
||||
|
||||
fs.mkdirp(dstDir, err => {
|
||||
if (err) {
|
||||
onError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
let src, dst;
|
||||
|
||||
src = `${projectDir}/${localeDir}/en.json`;
|
||||
dst = `${dstDir}/en.json`;
|
||||
fs.copy(src, dst, onDirEnd);
|
||||
|
||||
src = `${projectDir}/${localeDir}/${lang}.json`;
|
||||
dst = `${dstDir}/${lang}.json`;
|
||||
fs.copy(src, dst, onDirEnd);
|
||||
});
|
||||
}
|
||||
|
||||
function onError (err) {
|
||||
console.log(err);
|
||||
onDirEnd();
|
||||
}
|
||||
|
||||
let output;
|
||||
let archive;
|
||||
|
||||
function onDirEnd() {
|
||||
nDirs--;
|
||||
if (nDirs > 0) return;
|
||||
|
||||
output = fs.createWriteStream(`${lang}.zip`);
|
||||
output.on ('close', onArchiveEnd);
|
||||
|
||||
archive = archiver('zip', {
|
||||
zlib: { level: 9 }
|
||||
});
|
||||
archive.on ('error', err => {
|
||||
throw err;
|
||||
});
|
||||
archive.pipe(output);
|
||||
archive.directory(lang);
|
||||
archive.finalize();
|
||||
}
|
||||
|
||||
function onArchiveEnd() {
|
||||
fs.remove(lang);
|
||||
console.log ('Export finalized!');
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
var path = require ('path');
|
||||
var webpack = require ('webpack');
|
||||
var AssetsWebpackPlugin = require ('assets-webpack-plugin');
|
||||
var WebpackChunkHash = require ('webpack-chunk-hash');
|
||||
var merge = require ('webpack-merge');
|
||||
var wpConfig = require ('./webpack.config.json');
|
||||
var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
var AssetsWebpackPlugin = require('assets-webpack-plugin');
|
||||
var WebpackChunkHash = require('webpack-chunk-hash');
|
||||
var merge = require('webpack-merge');
|
||||
var wpConfig = require('./webpack.config.json');
|
||||
|
||||
var devMode = process.env.NODE_ENV !== 'production';
|
||||
var outputPath = path.join (__dirname, wpConfig.buildDir);
|
||||
var outputPath = path.join(__dirname, wpConfig.buildDir);
|
||||
var publicPath = wpConfig.buildDir +'/';
|
||||
|
||||
var baseConfig = {
|
||||
|
@ -34,12 +34,12 @@ var baseConfig = {
|
|||
__dirname: true
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin ({
|
||||
new webpack.DefinePlugin({
|
||||
_DEV_MODE: devMode,
|
||||
_DEV_SERVER_PORT: wpConfig.devServerPort,
|
||||
_PUBLIC_PATH: JSON.stringify (publicPath)
|
||||
}),
|
||||
new webpack.optimize.CommonsChunkPlugin ({
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
names: ['vendor', 'manifest']
|
||||
})
|
||||
],
|
||||
|
@ -54,15 +54,15 @@ var prodConfig = {
|
|||
chunkFilename: 'chunk.[id].[chunkhash].js'
|
||||
},
|
||||
plugins: [
|
||||
new webpack.optimize.UglifyJsPlugin ({
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
minimize: true,
|
||||
compress: { warnings: false }
|
||||
}),
|
||||
new AssetsWebpackPlugin ({
|
||||
new AssetsWebpackPlugin({
|
||||
path: outputPath
|
||||
}),
|
||||
new webpack.HashedModuleIdsPlugin (),
|
||||
new WebpackChunkHash ()
|
||||
new webpack.HashedModuleIdsPlugin(),
|
||||
new WebpackChunkHash()
|
||||
],
|
||||
devtool: 'source-map'
|
||||
};
|
||||
|
@ -73,7 +73,7 @@ var devConfig = {
|
|||
chunkFilename: 'chunk.[id].js'
|
||||
},
|
||||
plugins: [
|
||||
new webpack.NamedModulesPlugin ()
|
||||
new webpack.NamedModulesPlugin()
|
||||
],
|
||||
devServer: {
|
||||
host: '0.0.0.0',
|
||||
|
@ -85,4 +85,4 @@ var devConfig = {
|
|||
};
|
||||
|
||||
var mrgConfig = devMode ? devConfig : prodConfig;
|
||||
module.exports = merge (baseConfig, mrgConfig);
|
||||
module.exports = merge(baseConfig, mrgConfig);
|
||||
|
|
Loading…
Reference in New Issue