initial commit
This commit is contained in:
18
bin/afterUpdate.sh
Executable file
18
bin/afterUpdate.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd $(dirname "$0")/..
|
||||
|
||||
sourceDir=dist/public/*
|
||||
jsSourceDir=dist/js/
|
||||
|
||||
mkdir -p src/js/lib/
|
||||
|
||||
for d in "vendor/ainias/pwa"*/; do
|
||||
|
||||
find $d$jsSourceDir -name '*.js' -exec cp -r '{}' src/js/lib/ \;
|
||||
# mv $d$jsFile
|
||||
cp -r -R $d$sourceDir public/
|
||||
done
|
||||
#bin/jsConcat.sh src/js public/js/app 1
|
||||
|
||||
node bin/concatTranslator.js
|
||||
78
bin/build.js
Normal file
78
bin/build.js
Normal file
@@ -0,0 +1,78 @@
|
||||
const shouldMangleAndTranspile = (process.argv.length >= 3 && process.argv[2] === "1");
|
||||
// const shouldMangleAndTranspile = (process.argv.length >= 3 && process.argv[2] === "1"); || true;
|
||||
|
||||
const rollup = require('rollup');
|
||||
const fs = require('fs');
|
||||
|
||||
var uglifyJs = null;
|
||||
var babel = null;
|
||||
|
||||
if (shouldMangleAndTranspile) {
|
||||
uglifyJs = require('uglify-es');
|
||||
babel = require('babel-core');
|
||||
}
|
||||
const uglifyOptions = {
|
||||
ecma: "es6",
|
||||
mangle: {
|
||||
// ecma:"es6",
|
||||
properties: {
|
||||
keep_quoted: true,
|
||||
builtins: false,
|
||||
reserved: require('../node_modules/uglify-es/tools/domprops')
|
||||
},
|
||||
// toplevel: true
|
||||
},
|
||||
compress: {
|
||||
ecma: "es6",
|
||||
keep_fargs: false,
|
||||
toplevel: true,
|
||||
dead_code: true,
|
||||
unused: true,
|
||||
passes: 1,
|
||||
},
|
||||
// sourceMap:{
|
||||
// url:"inline"
|
||||
// },
|
||||
// output: {
|
||||
// beautify: true
|
||||
// }
|
||||
};
|
||||
|
||||
const babelOptions = {
|
||||
compact: true,
|
||||
minified: true,
|
||||
presets: ['env'],
|
||||
// sourceMaps:"inline",
|
||||
// plugins: [["minify-mangle-names", {topLevel: true}], "transform-class-properties"]
|
||||
};
|
||||
|
||||
const options = require('../rollup.config');
|
||||
const outputOptions = options.output;
|
||||
options.output = null;
|
||||
const inputOptions = options;
|
||||
|
||||
|
||||
async function build() {
|
||||
const bundle = await rollup.rollup(inputOptions);
|
||||
for (let i = 0, n = outputOptions.length; i < n; i++) {
|
||||
let {code, map} = await bundle.generate(outputOptions[i]);
|
||||
if (shouldMangleAndTranspile) {
|
||||
const uglifyRes = uglifyJs.minify(code, uglifyOptions);
|
||||
code = uglifyRes.code;
|
||||
fs.writeFileSync('transpiled.js', code);
|
||||
const babelRes = babel.transform(code, babelOptions);
|
||||
code = babelRes.code;
|
||||
const uglifyRes2 = uglifyJs.minify(code, {mangle:{toplevel:true},compress: {
|
||||
keep_fargs: false,
|
||||
toplevel: true,
|
||||
dead_code: true,
|
||||
unused: true,
|
||||
passes: 1,
|
||||
},});
|
||||
code = uglifyRes2.code;
|
||||
}
|
||||
fs.writeFileSync(outputOptions[i].file, code);
|
||||
}
|
||||
}
|
||||
|
||||
build();
|
||||
3
bin/build.sh
Normal file
3
bin/build.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
npm run build
|
||||
46
bin/concatTranslator.js
Normal file
46
bin/concatTranslator.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const moduleDirs = ['src/module', 'vendor/ainias'];
|
||||
const outputDir = 'public/js/lang';
|
||||
|
||||
const fs = require('fs');
|
||||
var translations = {};
|
||||
|
||||
var currentLangs = [];
|
||||
for (var i = 2, n = process.argv.length; i < n; i++)
|
||||
{
|
||||
currentLangs.push(process.argv[i].split(".")[0]);
|
||||
}
|
||||
|
||||
for (var i = 0, n = moduleDirs.length; i < n; i++) {
|
||||
var currentModuleDir = moduleDirs[i];
|
||||
var files = fs.readdirSync(currentModuleDir);
|
||||
files.forEach(file => {
|
||||
if (fs.existsSync(currentModuleDir + "/" + file + "/pwa/translations")) {
|
||||
var translationFiles = fs.readdirSync(currentModuleDir + "/" + file + "/pwa/translations");
|
||||
translationFiles.forEach(translationFile => {
|
||||
var language = translationFile.split('.')[0];
|
||||
if (currentLangs.length > 0 && currentLangs.indexOf(language) === -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (typeof translations[language] === 'undefined') {
|
||||
translations[language] = {};
|
||||
}
|
||||
var res = fs.readFileSync(currentModuleDir + "/" + file + "/pwa/translations/" + translationFile, 'utf8');
|
||||
var currentTranslations = JSON.parse(res);
|
||||
for (var key in currentTranslations) {
|
||||
translations[language][key] = currentTranslations[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (var lang in translations)
|
||||
{
|
||||
var langTranslations = JSON.stringify(translations[lang]);
|
||||
fs.writeFile(outputDir+"/"+lang+".json", langTranslations, err => {
|
||||
if (err){
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}
|
||||
3
bin/localLink.sh
Executable file
3
bin/localLink.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
rm -rf /var/www/pwa/stories/vendor/ainias/$2
|
||||
ln -s $1 /var/www/pwa/stories/vendor/ainias/$2
|
||||
BIN
bin/newModule
Executable file
BIN
bin/newModule
Executable file
Binary file not shown.
Reference in New Issue
Block a user