mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
fix
This commit is contained in:
parent
ab4febf938
commit
516d007c22
@ -5,7 +5,7 @@ const uuidv1 = require('uuid/v1');
|
||||
const byline = require('byline');
|
||||
const socket = require('../utility/socket');
|
||||
const { fork } = require('child_process');
|
||||
const { rundir, uploadsdir, pluginsdir, getPluginPath, packagedPluginList } = require('../utility/directories');
|
||||
const { rundir, uploadsdir, pluginsdir, getPluginBackendPath, packagedPluginList } = require('../utility/directories');
|
||||
const { extractShellApiPlugins, extractShellApiFunctionName } = require('dbgate-tools');
|
||||
const { handleProcessCommunication } = require('../utility/processComm');
|
||||
|
||||
@ -101,7 +101,7 @@ module.exports = {
|
||||
env: {
|
||||
...process.env,
|
||||
DBGATE_API: global['dbgateApiModulePath'] || process.argv[1],
|
||||
..._.fromPairs(pluginNames.map(name => [`PLUGIN_${_.camelCase(name)}`, getPluginPath(name)])),
|
||||
..._.fromPairs(pluginNames.map(name => [`PLUGIN_${_.camelCase(name)}`, getPluginBackendPath(name)])),
|
||||
},
|
||||
});
|
||||
const pipeDispatcher = severity => data =>
|
||||
|
@ -1,6 +1,6 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { pluginsdir, packagedPluginsDir } = require('../utility/directories');
|
||||
const { pluginsdir, packagedPluginsDir, getPluginBackendPath } = require('../utility/directories');
|
||||
const nativeModules = require('../nativeModules');
|
||||
const platformInfo = require('../utility/platformInfo');
|
||||
|
||||
@ -10,26 +10,13 @@ const dbgateEnv = {
|
||||
dbgateApi: null,
|
||||
nativeModules,
|
||||
};
|
||||
|
||||
function getModulePath(packageName) {
|
||||
const packagedModulePath = platformInfo.isDevMode
|
||||
? path.join(packagedPluginsDir(), packageName, 'src', 'backend', 'index.js')
|
||||
: path.join(packagedPluginsDir(), packageName, 'dist', 'backend.js');
|
||||
|
||||
if (fs.existsSync(packagedModulePath)) {
|
||||
return packagedModulePath;
|
||||
}
|
||||
|
||||
return path.join(pluginsdir(), packageName, 'dist', 'backend.js');
|
||||
}
|
||||
|
||||
function requirePlugin(packageName, requiredPlugin = null) {
|
||||
if (!packageName) throw new Error('Missing packageName in plugin');
|
||||
if (loadedPlugins[packageName]) return loadedPlugins[packageName];
|
||||
|
||||
if (requiredPlugin == null) {
|
||||
let module;
|
||||
const modulePath = getModulePath(packageName);
|
||||
const modulePath = getPluginBackendPath(packageName);
|
||||
console.log(`Loading module ${packageName} from ${modulePath}`);
|
||||
try {
|
||||
// @ts-ignore
|
||||
|
@ -60,9 +60,15 @@ function packagedPluginsDir() {
|
||||
const packagedPluginList =
|
||||
packagedPluginsDir() != null ? fs.readdirSync(packagedPluginsDir()).filter(x => x.startsWith('dbgate-plugin-')) : [];
|
||||
|
||||
function getPluginPath(packageName) {
|
||||
if (packagedPluginList.includes(packageName)) return path.join(packagedPluginsDir(), packageName);
|
||||
return path.join(pluginsdir(), packageName);
|
||||
function getPluginBackendPath(packageName) {
|
||||
if (packagedPluginList.includes(packageName)) {
|
||||
if (platformInfo.isDevMode) {
|
||||
return path.join(packagedPluginsDir(), packageName, 'src', 'backend', 'index.js');
|
||||
}
|
||||
return path.join(packagedPluginsDir(), packageName, 'dist', 'backend.js');
|
||||
}
|
||||
|
||||
return path.join(pluginsdir(), packageName, 'dist', 'backend.js');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
@ -76,5 +82,5 @@ module.exports = {
|
||||
filesdir,
|
||||
packagedPluginsDir,
|
||||
packagedPluginList,
|
||||
getPluginPath,
|
||||
getPluginBackendPath,
|
||||
};
|
||||
|
@ -18,6 +18,7 @@
|
||||
"dbgateplugin"
|
||||
],
|
||||
"files": [
|
||||
"src",
|
||||
"dist",
|
||||
"icon.svg"
|
||||
],
|
||||
|
@ -19,6 +19,7 @@
|
||||
],
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"icon.svg"
|
||||
],
|
||||
"scripts": {
|
||||
|
@ -18,6 +18,7 @@
|
||||
],
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"icon.svg"
|
||||
],
|
||||
"scripts": {
|
||||
|
@ -18,6 +18,7 @@
|
||||
],
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"icon.svg"
|
||||
],
|
||||
"scripts": {
|
||||
|
@ -18,6 +18,7 @@
|
||||
],
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"icon.svg"
|
||||
],
|
||||
"scripts": {
|
||||
|
@ -17,6 +17,7 @@
|
||||
],
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"icon.svg"
|
||||
],
|
||||
"scripts": {
|
||||
|
Loading…
Reference in New Issue
Block a user