seitime-frappe/rollup.utils.js
Faris Ansari 92e8856588
New Build System: Rollup (#5010)
* JS build working

* Css build working!

* Uglify JS in production

* fix codacy

* Add frappe.commands.popen

* FIx ESLint errors

* Add socket.io to package.json

* ignore subprocess warnings

* Add babel-runtime

* sleep 20 after bench start

* remove set -e

* [FIX] non-shell subprocess call

* [FIX] use shell = False

* split commands
2018-02-20 13:47:48 +05:30

56 lines
1.5 KiB
JavaScript

const path = require('path');
const fs = require('fs');
const frappe_path = process.cwd();
const bench_path = path.resolve(frappe_path, '..', '..');
const sites_path = path.resolve(bench_path, 'sites');
const apps_list =
fs.readFileSync(
path.resolve(sites_path, 'apps.txt'), { encoding: 'utf-8' }
).split('\n').filter(Boolean);
const assets_path = path.resolve(sites_path, 'assets');
const app_paths = apps_list.reduce((out, app) => {
out[app] = path.resolve(bench_path, 'apps', app, app)
return out;
}, {});
const public_paths = apps_list.reduce((out, app) => {
out[app] = path.resolve(app_paths[app], 'public');
return out;
}, {});
const public_js_paths = apps_list.reduce((out, app) => {
out[app] = path.resolve(app_paths[app], 'public/js');
return out;
}, {});
const bundle_map = apps_list.reduce((out, app) => {
const public_js_path = public_js_paths[app];
if ( fs.existsSync(public_js_path) ) {
const all_files = fs.readdirSync(public_js_path);
const js_files = all_files.filter(file => file.endsWith('.js'));
for (let js_file of js_files) {
const filename = path.basename(js_file).split('.')[0];
out[path.join(app, 'js', filename)] = path.resolve(public_js_path, js_file);
}
}
return out;
}, {});
const get_public_path = app => public_paths[app];
const get_build_json_path = app => path.resolve(get_public_path(app), 'build.json');
const get_app_path = app => app_paths[app];
module.exports = {
sites_path,
bundle_map,
get_public_path,
get_build_json_path,
get_app_path,
apps_list,
assets_path,
bench_path
};