various fixes

This commit is contained in:
janis
2023-08-28 17:09:56 +02:00
parent a0984782a8
commit 466a4fbd8b
9 changed files with 54 additions and 11 deletions

View File

@@ -11,11 +11,45 @@
This is the plugin manager. It is responsible for installing, updating and uninstalling plugins.
*/
const fs = require( 'fs' );
const path = require( 'path' );
class PluginManager {
constructor () {}
constructor ( settings ) {
this.paymentGateway = settings.payments;
this.allPlugins = {};
fs.readdir( path.join( __dirname + '/others' ), ( err, ls ) => {
for ( let file in ls ) {
const pluginSettings = JSON.parse( fs.readFileSync( path.join( __dirname + '/others/' + ls[ file ] + '/plugin.json' ) ) );
this.allPlugins[ ls[ file ] ] = pluginSettings;
}
} );
}
loadSettings ( plugin ) {
getPlugins () {
}
getPluginDetails ( plugin ) {
return new Promise( ( resolve, reject ) => {
fs.readFile( path.join( __dirname + '/others/' + plugin + '/plugin.json' ), ( err, file ) => {
resolve( file );
} );
} );
}
loadPaymentGatewaySettings () {
return new Promise( ( resolve, reject ) => {
fs.readFile( path.join( __dirname + '/payments/' + this.paymentGateway + '/configOptions.json' ), ( err, options ) => {
fs.readFile( path.join( __dirname + '/payments/' + this.paymentGateway + '/config.payments.json' ), ( err, config ) => {
let f = options;
for ( let s in f ) {
f[ s ][ 'value' ] = config[ s ];
}
resolve( f );
} );
} );
} );
}
saveSettings ( plugin, settings ) {