install/uninstall plugin

This commit is contained in:
Jan Prochazka
2020-11-21 17:33:59 +01:00
parent 1f4a93f1d5
commit e14165c403
9 changed files with 234 additions and 83 deletions

View File

@@ -0,0 +1,20 @@
import _ from 'lodash';
export function extractPluginIcon(packageManifest) {
const { links } = packageManifest || {};
const { repository, homepage } = links || {};
const tested = repository || homepage || packageManifest.homepage;
if (tested) {
const match = tested.match(/https:\/\/github.com\/([^/]*)\/([^/]*)/);
if (match) {
return `https://raw.githubusercontent.com/${match[1]}/${match[2]}/master/icon.svg`;
}
}
// eslint-disable-next-line no-undef
return `${process.env.PUBLIC_URL}/unknown.svg`;
}
export function extractPluginAuthor(packageManifest) {
return _.isPlainObject(packageManifest.author) ? packageManifest.author.name : packageManifest.author;
}