diff options
author | Chocobozzz <me@florianbigard.com> | 2020-01-31 16:56:52 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-02-03 08:31:02 +0100 |
commit | a15871560f80e07386c1dabb8370cd2664ecfd1f (patch) | |
tree | 44440e140c9e43b0d7f97ade777a76e649e0553d /server/lib/plugins/plugin-manager.ts | |
parent | a22046d166805222ca76060e471b6cb3d419a32d (diff) | |
download | PeerTube-a15871560f80e07386c1dabb8370cd2664ecfd1f.tar.gz PeerTube-a15871560f80e07386c1dabb8370cd2664ecfd1f.tar.zst PeerTube-a15871560f80e07386c1dabb8370cd2664ecfd1f.zip |
Move to eslintcontain
Diffstat (limited to 'server/lib/plugins/plugin-manager.ts')
-rw-r--r-- | server/lib/plugins/plugin-manager.ts | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index 7ebdabd34..73f7a71ce 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts | |||
@@ -55,30 +55,30 @@ export interface HookInformationValue { | |||
55 | } | 55 | } |
56 | 56 | ||
57 | type AlterableVideoConstant = 'language' | 'licence' | 'category' | 57 | type AlterableVideoConstant = 'language' | 'licence' | 'category' |
58 | type VideoConstant = { [ key in number | string ]: string } | 58 | type VideoConstant = { [key in number | string]: string } |
59 | type UpdatedVideoConstant = { | 59 | type UpdatedVideoConstant = { |
60 | [ name in AlterableVideoConstant ]: { | 60 | [name in AlterableVideoConstant]: { |
61 | [ npmName: string ]: { | 61 | [npmName: string]: { |
62 | added: { key: number | string, label: string }[], | 62 | added: { key: number | string, label: string }[] |
63 | deleted: { key: number | string, label: string }[] | 63 | deleted: { key: number | string, label: string }[] |
64 | } | 64 | } |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | type PluginLocalesTranslations = { | 68 | type PluginLocalesTranslations = { |
69 | [ locale: string ]: PluginTranslation | 69 | [locale: string]: PluginTranslation |
70 | } | 70 | } |
71 | 71 | ||
72 | export class PluginManager implements ServerHook { | 72 | export class PluginManager implements ServerHook { |
73 | 73 | ||
74 | private static instance: PluginManager | 74 | private static instance: PluginManager |
75 | 75 | ||
76 | private registeredPlugins: { [ name: string ]: RegisteredPlugin } = {} | 76 | private registeredPlugins: { [name: string]: RegisteredPlugin } = {} |
77 | private settings: { [ name: string ]: RegisterServerSettingOptions[] } = {} | 77 | private settings: { [name: string]: RegisterServerSettingOptions[] } = {} |
78 | private hooks: { [ name: string ]: HookInformationValue[] } = {} | 78 | private hooks: { [name: string]: HookInformationValue[] } = {} |
79 | private translations: PluginLocalesTranslations = {} | 79 | private translations: PluginLocalesTranslations = {} |
80 | 80 | ||
81 | private updatedVideoConstants: UpdatedVideoConstant = { | 81 | private readonly updatedVideoConstants: UpdatedVideoConstant = { |
82 | language: {}, | 82 | language: {}, |
83 | licence: {}, | 83 | licence: {}, |
84 | category: {} | 84 | category: {} |
@@ -133,7 +133,7 @@ export class PluginManager implements ServerHook { | |||
133 | 133 | ||
134 | // ###################### Hooks ###################### | 134 | // ###################### Hooks ###################### |
135 | 135 | ||
136 | async runHook <T> (hookName: ServerHookName, result?: T, params?: any): Promise<T> { | 136 | async runHook<T> (hookName: ServerHookName, result?: T, params?: any): Promise<T> { |
137 | if (!this.hooks[hookName]) return Promise.resolve(result) | 137 | if (!this.hooks[hookName]) return Promise.resolve(result) |
138 | 138 | ||
139 | const hookType = getHookType(hookName) | 139 | const hookType = getHookType(hookName) |
@@ -312,7 +312,7 @@ export class PluginManager implements ServerHook { | |||
312 | clientScripts[c.script] = c | 312 | clientScripts[c.script] = c |
313 | } | 313 | } |
314 | 314 | ||
315 | this.registeredPlugins[ npmName ] = { | 315 | this.registeredPlugins[npmName] = { |
316 | npmName, | 316 | npmName, |
317 | name: plugin.name, | 317 | name: plugin.name, |
318 | type: plugin.type, | 318 | type: plugin.type, |
@@ -438,7 +438,7 @@ export class PluginManager implements ServerHook { | |||
438 | const plugins: RegisteredPlugin[] = [] | 438 | const plugins: RegisteredPlugin[] = [] |
439 | 439 | ||
440 | for (const npmName of Object.keys(this.registeredPlugins)) { | 440 | for (const npmName of Object.keys(this.registeredPlugins)) { |
441 | const plugin = this.registeredPlugins[ npmName ] | 441 | const plugin = this.registeredPlugins[npmName] |
442 | if (plugin.type !== type) continue | 442 | if (plugin.type !== type) continue |
443 | 443 | ||
444 | plugins.push(plugin) | 444 | plugins.push(plugin) |
@@ -518,11 +518,11 @@ export class PluginManager implements ServerHook { | |||
518 | } | 518 | } |
519 | } | 519 | } |
520 | 520 | ||
521 | private addConstant <T extends string | number> (parameters: { | 521 | private addConstant<T extends string | number> (parameters: { |
522 | npmName: string, | 522 | npmName: string |
523 | type: AlterableVideoConstant, | 523 | type: AlterableVideoConstant |
524 | obj: VideoConstant, | 524 | obj: VideoConstant |
525 | key: T, | 525 | key: T |
526 | label: string | 526 | label: string |
527 | }) { | 527 | }) { |
528 | const { npmName, type, obj, key, label } = parameters | 528 | const { npmName, type, obj, key, label } = parameters |
@@ -545,10 +545,10 @@ export class PluginManager implements ServerHook { | |||
545 | return true | 545 | return true |
546 | } | 546 | } |
547 | 547 | ||
548 | private deleteConstant <T extends string | number> (parameters: { | 548 | private deleteConstant<T extends string | number> (parameters: { |
549 | npmName: string, | 549 | npmName: string |
550 | type: AlterableVideoConstant, | 550 | type: AlterableVideoConstant |
551 | obj: VideoConstant, | 551 | obj: VideoConstant |
552 | key: T | 552 | key: T |
553 | }) { | 553 | }) { |
554 | const { npmName, type, obj, key } = parameters | 554 | const { npmName, type, obj, key } = parameters |
@@ -604,7 +604,7 @@ export class PluginManager implements ServerHook { | |||
604 | const { result: packageJSONValid, badFields } = isPackageJSONValid(packageJSON, pluginType) | 604 | const { result: packageJSONValid, badFields } = isPackageJSONValid(packageJSON, pluginType) |
605 | if (!packageJSONValid) { | 605 | if (!packageJSONValid) { |
606 | const formattedFields = badFields.map(f => `"${f}"`) | 606 | const formattedFields = badFields.map(f => `"${f}"`) |
607 | .join(', ') | 607 | .join(', ') |
608 | 608 | ||
609 | throw new Error(`PackageJSON is invalid (invalid fields: ${formattedFields}).`) | 609 | throw new Error(`PackageJSON is invalid (invalid fields: ${formattedFields}).`) |
610 | } | 610 | } |