Skip to content

Commit

Permalink
bugfix: Plugins now loaded from relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
evias committed Oct 8, 2021
1 parent dd62067 commit 27b93e4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 98 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dhealth-wallet",
"description": "dHealth Wallet",
"homepage": "https://github.com/dhealthproject/dhealth-wallet",
"version": "1.1.2",
"version": "1.1.3",
"license": "Apache-2.0",
"author": {
"name": "Using Blockchain Ltd",
Expand Down
6 changes: 3 additions & 3 deletions plugins/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if ('registerComponents' in plugin0) {
window.PluginPackages.push({
plugin: '@yourdlt/plugin-dummy',
module: plugin0.default,
path: '/Users/greg/Sources/using-blockchain/dhealth-wallet/node_modules/@yourdlt/plugin-dummy',
path: './node_modules/@yourdlt/plugin-dummy',
main: 'dist/YourDLTWalletPluginDummy.common.js'
});
}
Expand All @@ -30,7 +30,7 @@ if ('registerComponents' in plugin1) {
window.PluginPackages.push({
plugin: '@yourdlt/plugin-librarian',
module: plugin1.default,
path: '/Users/greg/Sources/using-blockchain/dhealth-wallet/node_modules/@yourdlt/plugin-librarian',
path: './node_modules/@yourdlt/plugin-librarian',
main: 'dist/YourDLTWalletPluginLibrarian.common.js'
});
}
Expand All @@ -41,7 +41,7 @@ if ('registerComponents' in plugin2) {
window.PluginPackages.push({
plugin: '@yourdlt/plugin-ninjazzz',
module: plugin2.default,
path: '/Users/greg/Sources/using-blockchain/dhealth-wallet/node_modules/@yourdlt/plugin-ninjazzz',
path: './node_modules/@yourdlt/plugin-ninjazzz',
main: 'dist/YourDLTWalletPluginNinjaZZZ.common.js'
});
}
Expand Down
93 changes: 1 addition & 92 deletions public/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,99 +370,8 @@ class AppPluginManager {
AppMainWindow.webContents.send('onPluginsResolved', JSON.stringify(plugins))
}
)

// Handles request of installations for plugins (builds plugins.json)
// ipcMain.removeAllListeners('onPluginsInstallRequest');
// ipcMain.on('onPluginsInstallRequest', (event, recipeJson) => {
// try {
// const recipe = JSON.parse(recipeJson)
// console.log(`[INFO][public/bundler.js] main received onPluginsInstallRequest with ${Object.keys(recipe).length} plugin(s) from App`)

// // Hook to execute *before* recipe is uploaded
// AppMainWindow.webContents.send('onBeforeRecipeUploaded', recipeJson)

// // Send recipe to build server (Jenkins)
// this.buildRecipe(recipe, this.buildPlatform).then((buildNumber) => {

// // Hook to execute when recipe was uploaded
// AppMainWindow.webContents.send('onRecipeUploaded', buildNumber)

// // Start polling for build job status (30 seconds)
// this.startBuildJobStatusPolling(buildNumber)
// }).catch(
// (reason) => AppMainWindow.webContents.send('onRecipeBuildError', reason.toString())
// )
// }
// catch (e) {
// AppMainWindow.webContents.send('onRecipeBuildError', `Error parsing JSON for dApps recipe.`)
// }

// // // First install plugin
// // this.installPlugin(npmModule, 'latest').then(() => {

// // // Then load plugin definition
// // const instance = this.loadPlugin(npmModule)

// // // Send information about installed plugin to App
// // AppMainWindow.webContents.send('onPluginInstalled', JSON.stringify(instance))

// // // Call the plugins bundler (injecter)
// // this.callBundler(npmModule);
// // }).catch(
// // (reason) => AppMainWindow.webContents.send('onPluginInstallError', reason.toString())
// // )
// })
}

// async callBundler(npmModule) {

// if (!!npmModule && npmModule.length) {
// // Hook to execute *before* plugin injection starts
// AppMainWindow.webContents.send('onBeforePluginInjected', npmModule);
// }

// console.log(`[DEBUG][public/bundler.js] Now executing plugins.js with execPath '${process.execPath}'.`);

// return new Promise(async (resolve, reject) => {

// // Prepare bundler spawn arguments
// const callSignature = ['./node_modules/electron/cli.js', './dist/plugins.js'];
// if (!!npmModule && npmModule.length) {
// callSignature.push(npmModule);
// }

// // Spawn a new child process with electron
// const injecterProc = child_process.spawn(
// process.execPath,
// callSignature,
// { stdio: 'pipe' },
// )

// // When injecter is recreated, reload the app
// injecterProc.on('exit', (code, sig) => {
// console.log(`[DEBUG][public/bundler.js] Injecter process exited with code ${code}.`);

// if (!!npmModule && npmModule.length) {
// // Send information about injected new plugins
// AppMainWindow.webContents.send('onPluginInjected', npmModule);

// // Reload the app and injected plugins
// lastPageReloadTime = new Date().valueOf();
// AppMainWindow.reload();
// }

// resolve(code);
// })

// // In case of errors, monitor
// injecterProc.on('error', (error) => {
// console.log(`[ERROR][public/bundler.js] Child process for plugin injecter failed with error: ${error.message}.`)

// reject(error);
// })
// });
// }

async loadPlugins() {

// Reads the plugins.json configuration file
Expand Down Expand Up @@ -509,7 +418,7 @@ class AppPluginManager {
// Merge loaded plugin and package information
const instance = {
npmModule: pkg.name,
installPath: installPath,
installPath: `${installPath.replace(/(.*)(node_modules([\/\\]).*)/, '.$3$2')}`,
name: plugin,
version: pkg.version,
main: pkg.main,
Expand Down
2 changes: 1 addition & 1 deletion public/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const pluginManager = require('electron-plugin-manager')
// Merge loaded plugin and package information
this.plugins.push({
npmModule: pkg.name,
installPath: installPath,
installPath: `${installPath.replace(/(.*)(node_modules([\/\\]).*)/, '.$3$2')}`,
name: pluginSlug,
version: pkg.version,
main: pkg.main,
Expand Down

0 comments on commit 27b93e4

Please sign in to comment.