Closed neaplus closed 4 years ago
This is the expected behavior. The idea is that the local plugin folder is just a cache. So if you install again a dependency no new files is downloaded, but I suggest to store the list of plugins somewhere else (like in a database). This is also required when you have your app scaled to multiple instances: some instances can be new, with the directory empty.
You can always reinstall that files from filesystem if you want to just reuse that.
What do you think?
Thanks for quick reply. i know that expected behavior but optionaly supporting a method for scan cache folder would be nice.
So in my case stateless worker client app, managed remotely. i install and update packages when required except this, i want to keep working app even it crashes and restarts automaticaly without any state restore or check dependencies.
bellow code works for me now i've written temporary. something like lpm.scan()
method in the library with better implementation can be helpfull.
const fs = require("fs"), lpm = new(require('live-plugin-manager')).PluginManager(),
setTimeout(async () => {
const packages = fs.readdirSync(lpm.options.pluginsPath, {
withFileTypes: true
})
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name)
packages.forEach(async (package) => lpm.installedPlugins.push(await lpm.createPluginInfo(package)));
setTimeout(() => console.log('PACKAGES', packages, lpm.list()), 1000);
}, 0);
make sense?
I suggest to store the list of the installed plugins in a custom storage. It can be a simple text file. And at startup just read this file and install all. Otherwise you can have some side effects. For example if you want to install plugin A, but it depends on B, you will end up with 2 plugins, while logically the plugins is only 1.
The code seems to be correct, but not officially supported ;-).
But I can think for a similar feature for a next release...as usual any help/PR is appreciated!
Closing this issue for now. We can then open a new one more specific, I think something like: "Allow to re install plugins from file system cache"
it's better to scan installed plugins from folder every startup. because, if you installed some plugins dynamically and if application restarts depending to crash or some reason. you need to check and send install same packages that already installed in folder again is not fancy.