app.locals repalced
This commit is contained in:
40
utils.js
40
utils.js
@@ -1,31 +1,30 @@
|
||||
const { exec } = require('child_process');
|
||||
const path = require('path');
|
||||
const { permission } = require('process');
|
||||
const { dirname } = require('path');
|
||||
const { File: HotReload } = require(`@services/hotReload.js`);
|
||||
const { service } = require(`@root/server.js`);
|
||||
const { json } = require('body-parser');
|
||||
const { localPath, cache, runtimeFile } = require('@root/globalize.js');
|
||||
// let integratedStartmenuItems = require('@models/integratedStartmenuItems');
|
||||
|
||||
|
||||
global.path = {
|
||||
root: dirname(require.main.filename),
|
||||
source:`${dirname(require.main.filename)}/src`,
|
||||
public: `${dirname(require.main.filename)}/public`,
|
||||
plugins: `${dirname(require.main.filename)}/plugins`
|
||||
};
|
||||
// global.path = {
|
||||
// root: dirname(require.main.filename),
|
||||
// source:`${dirname(require.main.filename)}/src`,
|
||||
// public: `${dirname(require.main.filename)}/public`,
|
||||
// plugins: `${dirname(require.main.filename)}/plugins`
|
||||
// };
|
||||
|
||||
|
||||
global.json = {
|
||||
releaseNotes: new HotReload(path.join(global.path.source, 'models', 'releasenotes.json')),
|
||||
configuration: new HotReload(path.join(global.path.source, 'models', 'configuration.json')),
|
||||
stylesheet: new HotReload(path.join(global.path.source, 'models', 'stylesheet.json')),
|
||||
indexRoutes: new HotReload(path.join(global.path.source, 'routes', 'indexRoutes.js'), { historyLimit: 50, fileType: 'js' }),
|
||||
startMenuItems: new HotReload(path.join(global.path.source, 'models', 'integratedStartMenuItems.json'))
|
||||
}
|
||||
// global.json = {
|
||||
// releaseNotes: new HotReload(path.join(global.path.source, 'models', 'releasenotes.json')),
|
||||
// configuration: new HotReload(path.join(global.path.source, 'models', 'configuration.json')),
|
||||
// stylesheet: new HotReload(path.join(global.path.source, 'models', 'stylesheet.json')),
|
||||
// indexRoutes: new HotReload(path.join(global.path.source, 'routes', 'indexRoutes.js'), { historyLimit: 50, fileType: 'js' }),
|
||||
// startMenuItems: new HotReload(path.join(global.path.source, 'models', 'integratedStartMenuItems.json'))
|
||||
// }
|
||||
|
||||
module.exports = startMenuItems = async function (app, objectGuid) {
|
||||
const debug = global.json.configuration.live.debug.startMenuItems;
|
||||
const debug = runtimeFile.configuration.live.debug.startMenuItems;
|
||||
let logContent = [];
|
||||
|
||||
function safeClone(obj) {
|
||||
@@ -39,9 +38,10 @@ module.exports = startMenuItems = async function (app, objectGuid) {
|
||||
// =========================
|
||||
// Load menu sources
|
||||
// =========================
|
||||
const integratedStartmenuItems =
|
||||
service.get('fileSystemManager')
|
||||
.loadJSON(global.json.startMenuItems.filePath) || [];
|
||||
const integratedStartmenuItems = runtimeFile.startMenuItems.live;
|
||||
// const integratedStartmenuItems =
|
||||
// service.get('fileSystemManager')
|
||||
// .loadJSON(global.json.startMenuItems.filePath) || [];
|
||||
|
||||
const plugins = service
|
||||
.get('pluginManager')
|
||||
@@ -149,7 +149,7 @@ module.exports = startMenuItems = async function (app, objectGuid) {
|
||||
allPlugins = allPlugins
|
||||
.filter(p => !p.onlyAdministration)
|
||||
.filter(p => p.active);
|
||||
app.locals.startMenuItems = allPlugins;
|
||||
cache.startMenuItems = allPlugins;
|
||||
if(debug) {
|
||||
service.get('eventManager').writeLog(objectGuid, 0, 'StartMenuItems', logContent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user