davideicardi / live-plugin-manager

Plugin manager and installer for Node.JS
MIT License
233 stars 44 forks source link

Enhance the IPluginInfo to contain also the description #41

Open karlitos opened 3 years ago

karlitos commented 3 years ago

I would really appreciate, if the IPluginInfo could also include the the descritpion of the installed package. My application make a a very good use of live-plugin-manager in a way which offers users the possibility to install additional packages from NPM or local filesystem. The installable packages are shown in a list showing their name and the description.

Having the IPluginInfos location property I can parse the package.json, but this is basically the same thing live-plugin-manager is doing when creating the IPluginInfo.

So far I investigated the code a little bit an it seems, that only a small addition would be necessary to the createPluginInfo method in the PluginManager.ts file

private async createPluginInfo(name: string): Promise<IPluginInfo> {
        const location = this.getPluginLocation(name);
        const packageJson = await this.readPackageJsonFromPath(location);

        const mainFile = path.normalize(path.join(location, packageJson.main || DefaultMainFile));

        return {
            name: packageJson.name,
            description: packageJson.description,
            version: packageJson.version,
            location,
            mainFile,
            dependencies: packageJson.dependencies || {}
        };
    }
davideicardi commented 3 years ago

I confirm that it should be easy. If you are able to create a PR I will be happy to merge it.