選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

57 行
1.5 KiB

  1. const path = require('path');
  2. const fs = require('fs');
  3. const frappe_path = process.cwd();
  4. const bench_path = path.resolve(frappe_path, '..', '..');
  5. const sites_path = path.resolve(bench_path, 'sites');
  6. const apps_list =
  7. fs.readFileSync(
  8. path.resolve(sites_path, 'apps.txt'), { encoding: 'utf-8' }
  9. ).split('\n').filter(Boolean);
  10. const assets_path = path.resolve(sites_path, 'assets');
  11. const app_paths = apps_list.reduce((out, app) => {
  12. out[app] = path.resolve(bench_path, 'apps', app, app)
  13. return out;
  14. }, {});
  15. const public_paths = apps_list.reduce((out, app) => {
  16. out[app] = path.resolve(app_paths[app], 'public');
  17. return out;
  18. }, {});
  19. const public_js_paths = apps_list.reduce((out, app) => {
  20. out[app] = path.resolve(app_paths[app], 'public/js');
  21. return out;
  22. }, {});
  23. const bundle_map = apps_list.reduce((out, app) => {
  24. const public_js_path = public_js_paths[app];
  25. if ( fs.existsSync(public_js_path) ) {
  26. const all_files = fs.readdirSync(public_js_path);
  27. const js_files = all_files.filter(file => file.endsWith('.js'));
  28. for (let js_file of js_files) {
  29. const filename = path.basename(js_file).split('.')[0];
  30. out[path.join(app, 'js', filename)] = path.resolve(public_js_path, js_file);
  31. }
  32. }
  33. return out;
  34. }, {});
  35. const get_public_path = app => public_paths[app];
  36. const get_build_json_path = app => path.resolve(get_public_path(app), 'build.json');
  37. const get_app_path = app => app_paths[app];
  38. module.exports = {
  39. sites_path,
  40. bundle_map,
  41. get_public_path,
  42. get_build_json_path,
  43. get_app_path,
  44. apps_list,
  45. assets_path,
  46. bench_path
  47. };