show plugin author names

This commit is contained in:
Eugene Pankov 2017-07-05 15:31:23 +02:00
parent 94217f0b01
commit 536d9537ff
3 changed files with 21 additions and 3 deletions

View file

@ -44,6 +44,7 @@ export interface IPluginInfo {
packageName: string packageName: string
isBuiltin: boolean isBuiltin: boolean
version: string version: string
author: string
homepage?: string homepage?: string
path?: string path?: string
info?: any info?: any
@ -116,12 +117,15 @@ export async function findPlugins (): Promise<IPluginInfo[]> {
if (!info.keywords || info.keywords.indexOf('terminus-plugin') === -1) { if (!info.keywords || info.keywords.indexOf('terminus-plugin') === -1) {
continue continue
} }
let author = info.author
author = author.name || author
foundPlugins.push({ foundPlugins.push({
name: pluginName.substring('terminus-'.length), name: pluginName.substring('terminus-'.length),
packageName: pluginName, packageName: pluginName,
isBuiltin: pluginDir === builtinPluginsPath, isBuiltin: pluginDir === builtinPluginsPath,
version: info.version, version: info.version,
description: info.description, description: info.description,
author,
path: pluginPath, path: pluginPath,
info, info,
}) })

View file

@ -15,7 +15,9 @@ h3 Installed
.mr-auto.d-flex.flex-column .mr-auto.d-flex.flex-column
strong {{plugin.name}} strong {{plugin.name}}
small.text-muted.mb-0 {{plugin.description}} 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( button.btn.btn-outline-primary(
*ngIf='npmInstalled', *ngIf='npmInstalled',
(click)='upgradePlugin(plugin)', (click)='upgradePlugin(plugin)',
@ -31,7 +33,10 @@ h3 Installed
.mr-auto.d-flex.flex-column .mr-auto.d-flex.flex-column
strong {{plugin.name}} strong {{plugin.name}}
small.text-muted.mb-0 {{plugin.description}} 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( button.btn.btn-outline-danger(
(click)='uninstallPlugin(plugin)', (click)='uninstallPlugin(plugin)',
*ngIf='!plugin.isBuiltin && npmInstalled', *ngIf='!plugin.isBuiltin && npmInstalled',
@ -73,7 +78,10 @@ div(*ngIf='npmInstalled')
.mr-auto.d-flex.flex-column .mr-auto.d-flex.flex-column
strong {{plugin.name}} strong {{plugin.name}}
small.text-muted.mb-0 {{plugin.description}} 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( button.btn.btn-outline-primary(
(click)='installPlugin(plugin)', (click)='installPlugin(plugin)',
[disabled]='busy[plugin.name] != undefined' [disabled]='busy[plugin.name] != undefined'

View file

@ -8,14 +8,17 @@ import { Logger, LogService, ConfigService, HostAppService, Platform } from 'ter
const NAME_PREFIX = 'terminus-' const NAME_PREFIX = 'terminus-'
const KEYWORD = 'terminus-plugin' const KEYWORD = 'terminus-plugin'
const OFFICIAL_NPM_ACCOUNT = 'eugenepankov'
export interface IPluginInfo { export interface IPluginInfo {
name: string name: string
description: string description: string
packageName: string packageName: string
isBuiltin: boolean isBuiltin: boolean
isOfficial: boolean
version: string version: string
homepage?: string homepage?: string
author: string
path?: string path?: string
} }
@ -65,12 +68,15 @@ export class PluginManagerService {
.fromPromise( .fromPromise(
axios.get(`https://www.npmjs.com/-/search?text=keywords:${KEYWORD}+${encodeURIComponent(query || '')}&from=0&size=1000`) 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 => ({ .map(response => response.data.objects.map(item => ({
name: item.package.name.substring(NAME_PREFIX.length), name: item.package.name.substring(NAME_PREFIX.length),
packageName: item.package.name, packageName: item.package.name,
description: item.package.description, description: item.package.description,
version: item.package.version, version: item.package.version,
homepage: item.package.links.homepage, 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))) .map(plugins => plugins.filter(x => x.packageName.startsWith(NAME_PREFIX)))
} }