mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-04 22:14:55 +00:00
@typescript-eslint linter
This commit is contained in:
@@ -4,7 +4,7 @@ import * as semver from 'semver'
|
||||
|
||||
import { Component, Input } from '@angular/core'
|
||||
import { ConfigService, ElectronService } from 'terminus-core'
|
||||
import { IPluginInfo, PluginManagerService } from '../services/pluginManager.service'
|
||||
import { PluginInfo, PluginManagerService } from '../services/pluginManager.service'
|
||||
|
||||
enum BusyState { Installing, Uninstalling }
|
||||
|
||||
@@ -15,10 +15,10 @@ enum BusyState { Installing, Uninstalling }
|
||||
})
|
||||
export class PluginsSettingsTabComponent {
|
||||
BusyState = BusyState
|
||||
@Input() availablePlugins$: Observable<IPluginInfo[]>
|
||||
@Input() availablePlugins$: Observable<PluginInfo[]>
|
||||
@Input() availablePluginsQuery$ = new BehaviorSubject<string>('')
|
||||
@Input() availablePluginsReady = false
|
||||
@Input() knownUpgrades: {[id: string]: IPluginInfo} = {}
|
||||
@Input() knownUpgrades: {[id: string]: PluginInfo} = {}
|
||||
@Input() busy: {[id: string]: BusyState} = {}
|
||||
@Input() erroredPlugin: string
|
||||
@Input() errorMessage: string
|
||||
@@ -58,11 +58,11 @@ export class PluginsSettingsTabComponent {
|
||||
this.availablePluginsQuery$.next(query)
|
||||
}
|
||||
|
||||
isAlreadyInstalled (plugin: IPluginInfo): boolean {
|
||||
isAlreadyInstalled (plugin: PluginInfo): boolean {
|
||||
return this.pluginManager.installedPlugins.some(x => x.name === plugin.name)
|
||||
}
|
||||
|
||||
async installPlugin (plugin: IPluginInfo): Promise<void> {
|
||||
async installPlugin (plugin: PluginInfo): Promise<void> {
|
||||
this.busy[plugin.name] = BusyState.Installing
|
||||
try {
|
||||
await this.pluginManager.installPlugin(plugin)
|
||||
@@ -76,7 +76,7 @@ export class PluginsSettingsTabComponent {
|
||||
}
|
||||
}
|
||||
|
||||
async uninstallPlugin (plugin: IPluginInfo): Promise<void> {
|
||||
async uninstallPlugin (plugin: PluginInfo): Promise<void> {
|
||||
this.busy[plugin.name] = BusyState.Uninstalling
|
||||
try {
|
||||
await this.pluginManager.uninstallPlugin(plugin)
|
||||
@@ -90,21 +90,21 @@ export class PluginsSettingsTabComponent {
|
||||
}
|
||||
}
|
||||
|
||||
async upgradePlugin (plugin: IPluginInfo): Promise<void> {
|
||||
async upgradePlugin (plugin: PluginInfo): Promise<void> {
|
||||
return this.installPlugin(this.knownUpgrades[plugin.name])
|
||||
}
|
||||
|
||||
showPluginInfo (plugin: IPluginInfo) {
|
||||
showPluginInfo (plugin: PluginInfo) {
|
||||
this.electron.shell.openExternal('https://www.npmjs.com/package/' + plugin.packageName)
|
||||
}
|
||||
|
||||
enablePlugin (plugin: IPluginInfo) {
|
||||
enablePlugin (plugin: PluginInfo) {
|
||||
this.config.store.pluginBlacklist = this.config.store.pluginBlacklist.filter(x => x !== plugin.name)
|
||||
this.config.save()
|
||||
this.config.requestRestart()
|
||||
}
|
||||
|
||||
disablePlugin (plugin: IPluginInfo) {
|
||||
disablePlugin (plugin: PluginInfo) {
|
||||
this.config.store.pluginBlacklist = [...this.config.store.pluginBlacklist, plugin.name]
|
||||
this.config.save()
|
||||
this.config.requestRestart()
|
||||
|
@@ -27,6 +27,6 @@ import { PluginsSettingsTabProvider } from './settings'
|
||||
PluginsSettingsTabComponent,
|
||||
],
|
||||
})
|
||||
export default class PluginManagerModule { }
|
||||
export default class PluginManagerModule { } // eslint-disable-line @typescript-eslint/no-extraneous-class
|
||||
|
||||
export { PluginManagerService }
|
||||
|
@@ -8,7 +8,7 @@ const NAME_PREFIX = 'terminus-'
|
||||
const KEYWORD = 'terminus-plugin'
|
||||
const OFFICIAL_NPM_ACCOUNT = 'eugenepankov'
|
||||
|
||||
export interface IPluginInfo {
|
||||
export interface PluginInfo {
|
||||
name: string
|
||||
description: string
|
||||
packageName: string
|
||||
@@ -25,7 +25,7 @@ export class PluginManagerService {
|
||||
logger: Logger
|
||||
builtinPluginsPath: string = (window as any).builtinPluginsPath
|
||||
userPluginsPath: string = (window as any).userPluginsPath
|
||||
installedPlugins: IPluginInfo[] = (window as any).installedPlugins
|
||||
installedPlugins: PluginInfo[] = (window as any).installedPlugins
|
||||
|
||||
private npmReady: Promise<void>
|
||||
private npm: any
|
||||
@@ -57,12 +57,12 @@ export class PluginManagerService {
|
||||
return this.npm
|
||||
}
|
||||
|
||||
listAvailable (query?: string): Observable<IPluginInfo[]> {
|
||||
listAvailable (query?: string): Observable<PluginInfo[]> {
|
||||
return from(
|
||||
axios.get(`https://www.npmjs.com/search?q=keywords%3A${KEYWORD}+${encodeURIComponent(query || '')}&from=0&size=1000`, {
|
||||
headers: {
|
||||
'x-spiferack': '1',
|
||||
}
|
||||
},
|
||||
})
|
||||
).pipe(
|
||||
map(response => response.data.objects.map(item => ({
|
||||
@@ -78,7 +78,7 @@ export class PluginManagerService {
|
||||
)
|
||||
}
|
||||
|
||||
async installPlugin (plugin: IPluginInfo) {
|
||||
async installPlugin (plugin: PluginInfo) {
|
||||
(await this.getNPM()).commands.install([`${plugin.packageName}@${plugin.version}`], err => {
|
||||
if (err) {
|
||||
this.logger.error(err)
|
||||
@@ -88,7 +88,7 @@ export class PluginManagerService {
|
||||
})
|
||||
}
|
||||
|
||||
async uninstallPlugin (plugin: IPluginInfo) {
|
||||
async uninstallPlugin (plugin: PluginInfo) {
|
||||
(await this.getNPM()).commands.remove([plugin.packageName], err => {
|
||||
if (err) {
|
||||
this.logger.error(err)
|
||||
|
Reference in New Issue
Block a user