From 536d9537ffa4f28f00a3062f7b5e9f9ee5eecb2b Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 5 Jul 2017 15:31:23 +0200 Subject: [PATCH] show plugin author names --- app/src/plugins.ts | 4 ++++ .../components/pluginsSettingsTab.component.pug | 14 +++++++++++--- .../src/services/pluginManager.service.ts | 6 ++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/src/plugins.ts b/app/src/plugins.ts index 4434fd7b..60072267 100644 --- a/app/src/plugins.ts +++ b/app/src/plugins.ts @@ -44,6 +44,7 @@ export interface IPluginInfo { packageName: string isBuiltin: boolean version: string + author: string homepage?: string path?: string info?: any @@ -116,12 +117,15 @@ export async function findPlugins (): Promise { if (!info.keywords || info.keywords.indexOf('terminus-plugin') === -1) { continue } + let author = info.author + author = author.name || author foundPlugins.push({ name: pluginName.substring('terminus-'.length), packageName: pluginName, isBuiltin: pluginDir === builtinPluginsPath, version: info.version, description: info.description, + author, path: pluginPath, info, }) diff --git a/terminus-plugin-manager/src/components/pluginsSettingsTab.component.pug b/terminus-plugin-manager/src/components/pluginsSettingsTab.component.pug index 82645730..d050900f 100644 --- a/terminus-plugin-manager/src/components/pluginsSettingsTab.component.pug +++ b/terminus-plugin-manager/src/components/pluginsSettingsTab.component.pug @@ -15,7 +15,9 @@ h3 Installed .mr-auto.d-flex.flex-column strong {{plugin.name}} small.text-muted.mb-0 {{plugin.description}} - p.mb-0.mr-3 {{plugin.version}} + .d-flex.flex-column.align-items-end.mr-3 + div {{plugin.version}} + small.text-muted {{plugin.author}} button.btn.btn-outline-primary( *ngIf='npmInstalled', (click)='upgradePlugin(plugin)', @@ -31,7 +33,10 @@ h3 Installed .mr-auto.d-flex.flex-column strong {{plugin.name}} small.text-muted.mb-0 {{plugin.description}} - p.mb-0.mr-3 {{plugin.version}} + .d-flex.flex-column.align-items-end.mr-3 + div {{plugin.version}} + small.text-muted {{plugin.author}} + i.fa.fa-check.text-success.ml-1(*ngIf='plugin.isOfficial', title='Official') button.btn.btn-outline-danger( (click)='uninstallPlugin(plugin)', *ngIf='!plugin.isBuiltin && npmInstalled', @@ -73,7 +78,10 @@ div(*ngIf='npmInstalled') .mr-auto.d-flex.flex-column strong {{plugin.name}} small.text-muted.mb-0 {{plugin.description}} - p.mb-0.mr-3 {{plugin.version}} + .d-flex.flex-column.align-items-end.mr-3 + div {{plugin.version}} + small.text-muted {{plugin.author}} + i.fa.fa-check.text-success.ml-1(*ngIf='plugin.isOfficial', title='Official') button.btn.btn-outline-primary( (click)='installPlugin(plugin)', [disabled]='busy[plugin.name] != undefined' diff --git a/terminus-plugin-manager/src/services/pluginManager.service.ts b/terminus-plugin-manager/src/services/pluginManager.service.ts index 2e4ab379..8452f478 100644 --- a/terminus-plugin-manager/src/services/pluginManager.service.ts +++ b/terminus-plugin-manager/src/services/pluginManager.service.ts @@ -8,14 +8,17 @@ import { Logger, LogService, ConfigService, HostAppService, Platform } from 'ter const NAME_PREFIX = 'terminus-' const KEYWORD = 'terminus-plugin' +const OFFICIAL_NPM_ACCOUNT = 'eugenepankov' export interface IPluginInfo { name: string description: string packageName: string isBuiltin: boolean + isOfficial: boolean version: string homepage?: string + author: string path?: string } @@ -65,12 +68,15 @@ export class PluginManagerService { .fromPromise( axios.get(`https://www.npmjs.com/-/search?text=keywords:${KEYWORD}+${encodeURIComponent(query || '')}&from=0&size=1000`) ) + .do(response => console.log(response.data.objects)) .map(response => response.data.objects.map(item => ({ name: item.package.name.substring(NAME_PREFIX.length), packageName: item.package.name, description: item.package.description, version: item.package.version, homepage: item.package.links.homepage, + author: (item.package.author || {}).name, + isOfficial: item.package.publisher.username === OFFICIAL_NPM_ACCOUNT, }))) .map(plugins => plugins.filter(x => x.packageName.startsWith(NAME_PREFIX))) }