try to fix pl;ugin directories

This commit is contained in:
Jan Prochazka 2021-12-26 12:59:59 +01:00
parent 3ffe2090e5
commit 266d7d76de
9 changed files with 30 additions and 8 deletions

View File

@ -207,11 +207,20 @@ function createWindow() {
} }
} }
global.API_PACKAGE = process.env.DEVMODE ? '../packages/api/src/index' : '../packages/api/dist/bundle.js'; global.API_PACKAGE = path.resolve(
process.env.DEVMODE ? '../packages/api/src/index' : './packages/api/dist/bundle.js'
);
// console.log('global.API_PACKAGE', global.API_PACKAGE);
const api = require(path.join( const api = require(path.join(
__dirname, __dirname,
process.env.DEVMODE ? '../../packages/api/src/index' : '../packages/api/dist/bundle.js' process.env.DEVMODE ? '../../packages/api/src/index' : '../packages/api/dist/bundle.js'
)); ));
// console.log(
// 'REQUIRED',
// path.resolve(
// path.join(__dirname, process.env.DEVMODE ? '../../packages/api/src/index' : '../packages/api/dist/bundle.js')
// )
// );
const main = api.getMainModule(); const main = api.getMainModule();
main.initializeElectronSender(mainWindow.webContents); main.initializeElectronSender(mainWindow.webContents);
main.useAllControllers(null, electron); main.useAllControllers(null, electron);

View File

@ -137,6 +137,7 @@ module.exports = {
}, },
test(req, res) { test(req, res) {
const subprocess = fork(global['API_PACKAGE'] || process.argv[1], [ const subprocess = fork(global['API_PACKAGE'] || process.argv[1], [
'--is-forked-api',
'--start-process', '--start-process',
'connectProcess', 'connectProcess',
...process.argv.slice(3), ...process.argv.slice(3),

View File

@ -75,6 +75,7 @@ module.exports = {
if (existing) return existing; if (existing) return existing;
const connection = await connections.get({ conid }); const connection = await connections.get({ conid });
const subprocess = fork(global['API_PACKAGE'] || process.argv[1], [ const subprocess = fork(global['API_PACKAGE'] || process.argv[1], [
'--is-forked-api',
'--start-process', '--start-process',
'databaseConnectionProcess', 'databaseConnectionProcess',
...process.argv.slice(3), ...process.argv.slice(3),

View File

@ -38,6 +38,7 @@ module.exports = {
if (existing) return existing; if (existing) return existing;
const connection = await connections.get({ conid }); const connection = await connections.get({ conid });
const subprocess = fork(global['API_PACKAGE'] || process.argv[1], [ const subprocess = fork(global['API_PACKAGE'] || process.argv[1], [
'--is-forked-api',
'--start-process', '--start-process',
'serverConnectionProcess', 'serverConnectionProcess',
...process.argv.slice(3), ...process.argv.slice(3),

View File

@ -66,6 +66,7 @@ module.exports = {
const sesid = uuidv1(); const sesid = uuidv1();
const connection = await connections.get({ conid }); const connection = await connections.get({ conid });
const subprocess = fork(global['API_PACKAGE'] || process.argv[1], [ const subprocess = fork(global['API_PACKAGE'] || process.argv[1], [
'--is-forked-api',
'--start-process', '--start-process',
'sessionProcess', 'sessionProcess',
...process.argv.slice(3), ...process.argv.slice(3),

View File

@ -30,6 +30,7 @@ class DatastoreProxy {
async ensureSubprocess() { async ensureSubprocess() {
if (!this.subprocess) { if (!this.subprocess) {
this.subprocess = fork(global['API_PACKAGE'] || process.argv[1], [ this.subprocess = fork(global['API_PACKAGE'] || process.argv[1], [
'--is-forked-api',
'--start-process', '--start-process',
'jslDatastoreProcess', 'jslDatastoreProcess',
...process.argv.slice(3), ...process.argv.slice(3),

View File

@ -41,6 +41,10 @@ const archivedir = dirFunc('archive');
const filesdir = dirFunc('files'); const filesdir = dirFunc('files');
function packagedPluginsDir() { function packagedPluginsDir() {
// console.log('CALL DIR FROM', new Error('xxx').stack);
// console.log('__dirname', __dirname);
// console.log('platformInfo.isElectronBundle', platformInfo.isElectronBundle);
// console.log('platformInfo.isForkedApi', platformInfo.isForkedApi);
if (platformInfo.isDevMode) { if (platformInfo.isDevMode) {
return path.resolve(__dirname, '../../../../plugins'); return path.resolve(__dirname, '../../../../plugins');
} }
@ -53,6 +57,12 @@ function packagedPluginsDir() {
} }
if (platformInfo.isElectronBundle) { if (platformInfo.isElectronBundle) {
return path.resolve(__dirname, '../../plugins'); return path.resolve(__dirname, '../../plugins');
// if (platformInfo.isForkedApi) {
// return path.resolve(__dirname, '../plugins');
// } else {
// return path.resolve(__dirname, '../../plugins');
// }
} }
return null; return null;
} }

View File

@ -11,6 +11,7 @@ const isLinux = platform === 'linux';
const isDocker = fs.existsSync('/home/dbgate-docker/public'); const isDocker = fs.existsSync('/home/dbgate-docker/public');
const isDevMode = process.env.DEVMODE == '1'; const isDevMode = process.env.DEVMODE == '1';
const isNpmDist = !!global['dbgateApiModulePath']; const isNpmDist = !!global['dbgateApiModulePath'];
const isForkedApi = processArgs.isForkedApi;
// function moduleAvailable(name) { // function moduleAvailable(name) {
// try { // try {
@ -21,14 +22,13 @@ const isNpmDist = !!global['dbgateApiModulePath'];
// } // }
// } // }
const isElectronBundle = processArgs.isElectronBundle;
const platformInfo = { const platformInfo = {
isWindows, isWindows,
isMac, isMac,
isLinux, isLinux,
isDocker, isDocker,
isElectronBundle, isElectronBundle: isElectron() && !isDevMode,
isForkedApi,
isElectron: isElectron(), isElectron: isElectron(),
isDevMode, isDevMode,
isNpmDist, isNpmDist,

View File

@ -7,15 +7,13 @@ function getNamedArg(name) {
} }
const checkParent = process.argv.includes('--checkParent'); const checkParent = process.argv.includes('--checkParent');
const dynport = process.argv.includes('--dynport');
const nativeModules = getNamedArg('--native-modules'); const nativeModules = getNamedArg('--native-modules');
const startProcess = getNamedArg('--start-process'); const startProcess = getNamedArg('--start-process');
const isElectronBundle = process.argv.includes('--is-electron-bundle'); const isForkedApi = process.argv.includes('--is-forked-api');
module.exports = { module.exports = {
checkParent, checkParent,
nativeModules, nativeModules,
startProcess, startProcess,
dynport, isForkedApi,
isElectronBundle,
}; };