添加功能:pretest discuss user dashboard statistics

This commit is contained in:
undefined committed 2020-04-27 12:18:36 +08:00
1 parent 61cba6f180
commit 15d43636c0
41 files changed
+920 -523

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
const fs = require('fs');
const root = require('./root');
try {
fs.rmdirSync(root('.build'));
} catch (e) { }
fs.mkdirSync(root('.build'));
let progress = (name) => ((prog) => {
console.log(name, prog);
});
require('./locales')('locales', progress);
require('./webpack')('webpack', progress);
+16
View File
@@ -0,0 +1,16 @@
const yaml = require('js-yaml');
const fs = require('fs');
const root = require('./root');
const build = async (next) => {
let langs = fs.readdirSync(root('locales'));
next({ total: langs.length });
let lang = {};
let count = 0;
for (let i of langs) {
const content = fs.readFileSync(root(`locales/${i}`)).toString();
lang[i.split('.')[0]] = yaml.safeLoad(content);
next({ progress: ++count });
}
fs.writeFileSync(root('.build/locales.json'), JSON.stringify(lang));
}
module.exports = build;
+5
View File
@@ -0,0 +1,5 @@
const path = require('path');
function root(name) {
return path.resolve(__dirname, '..', name);
}
module.exports = root;
+40
View File
@@ -0,0 +1,40 @@
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const root = require('./root');
const build = async (next) => {
const modules = fs.readdirSync(root('hydro', 'module'));
const config = {
mode: 'production',
entry: {
development: root('hydro/development.js'),
install: root('hydro/install.js'),
uninstall: root('hydro/uninstall.js')
},
output: {
filename: '[name].js',
path: root('.build')
},
target: 'node',
module: {}
};
for (let i of modules) {
if (fs.statSync(path.resolve(__dirname, 'hydro', 'module', i)).isDirectory()) {
config.entry[root(`.build/module/${i}`)] = root(`./hydro/module/${i}/index.js`);
} else {
config.entry[root(`.build/module/${i}`)] = root(`./hydro/module/${i}`);
}
}
const compiler = webpack(config);
function compilerCallback(err, stats) {
if (err) {
console.error(err.stack || err);
if (err.details) console.error(err.details);
process.exit(1);
}
}
if (!watch && stats.hasErrors()) process.exitCode = 1;
compiler.run(compilerCallback);
next({ total: 100 });
}
module.exports = build;