mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
parent
c82abf05d6
commit
012fc1f7b4
14
package-lock.json
generated
14
package-lock.json
generated
@ -27,7 +27,7 @@
|
|||||||
"reflect-metadata": "0.1.13",
|
"reflect-metadata": "0.1.13",
|
||||||
"sharp": "0.31.3",
|
"sharp": "0.31.3",
|
||||||
"ts-node-iptc": "1.0.11",
|
"ts-node-iptc": "1.0.11",
|
||||||
"typeconfig": "2.2.15",
|
"typeconfig": "2.3.1",
|
||||||
"typeorm": "0.3.12",
|
"typeorm": "0.3.12",
|
||||||
"xml2js": "0.6.2"
|
"xml2js": "0.6.2"
|
||||||
},
|
},
|
||||||
@ -20362,9 +20362,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typeconfig": {
|
"node_modules/typeconfig": {
|
||||||
"version": "2.2.15",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.15.tgz",
|
"resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.3.1.tgz",
|
||||||
"integrity": "sha512-aqiuT5BtV0/0MYMMG78c1IqeJrF85r1W1pJckkGolPjHpE0ajA3oOgnRtX5DRDHsn3YzsY5FKMxj1B3J+ISx1g==",
|
"integrity": "sha512-xBdsf0tK/PcXyZzWq/U2xLNDNrVFkRQ9d8V9x3B5eu1LG5GmeDDK7zLScz79zbl0dCZzhjnvx4RRggY6DZAAZA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minimist": "1.2.8"
|
"minimist": "1.2.8"
|
||||||
}
|
}
|
||||||
@ -35283,9 +35283,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"typeconfig": {
|
"typeconfig": {
|
||||||
"version": "2.2.15",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.2.15.tgz",
|
"resolved": "https://registry.npmjs.org/typeconfig/-/typeconfig-2.3.1.tgz",
|
||||||
"integrity": "sha512-aqiuT5BtV0/0MYMMG78c1IqeJrF85r1W1pJckkGolPjHpE0ajA3oOgnRtX5DRDHsn3YzsY5FKMxj1B3J+ISx1g==",
|
"integrity": "sha512-xBdsf0tK/PcXyZzWq/U2xLNDNrVFkRQ9d8V9x3B5eu1LG5GmeDDK7zLScz79zbl0dCZzhjnvx4RRggY6DZAAZA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "1.2.8"
|
"minimist": "1.2.8"
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
"reflect-metadata": "0.1.13",
|
"reflect-metadata": "0.1.13",
|
||||||
"sharp": "0.31.3",
|
"sharp": "0.31.3",
|
||||||
"ts-node-iptc": "1.0.11",
|
"ts-node-iptc": "1.0.11",
|
||||||
"typeconfig": "2.2.15",
|
"typeconfig": "2.3.1",
|
||||||
"typeorm": "0.3.12",
|
"typeorm": "0.3.12",
|
||||||
"xml2js": "0.6.2"
|
"xml2js": "0.6.2"
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import {IExtensionConfig} from './IExtension';
|
import {IExtensionConfig} from './IExtension';
|
||||||
import {Config} from '../../../common/config/private/Config';
|
import {Config} from '../../../common/config/private/Config';
|
||||||
|
import {ServerExtensionsEntryConfig} from '../../../common/config/private/subconfigs/ServerExtensionsConfig';
|
||||||
|
|
||||||
export class ExtensionConfig<C> implements IExtensionConfig<C> {
|
export class ExtensionConfig<C> implements IExtensionConfig<C> {
|
||||||
|
|
||||||
@ -8,8 +9,7 @@ export class ExtensionConfig<C> implements IExtensionConfig<C> {
|
|||||||
|
|
||||||
|
|
||||||
public getConfig(): C {
|
public getConfig(): C {
|
||||||
const c = (Config.Extensions.extensions || [])
|
const c = Config.Extensions.extensions[this.extensionFolder] as ServerExtensionsEntryConfig;
|
||||||
.find(e => e.path === this.extensionFolder);
|
|
||||||
|
|
||||||
return c?.configs as C;
|
return c?.configs as C;
|
||||||
}
|
}
|
||||||
|
@ -92,16 +92,20 @@ export class ExtensionConfigTemplateLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ePaths = this.extensionTemplates.map(et => et.folder);
|
const ePaths = this.extensionTemplates.map(et => et.folder);
|
||||||
|
|
||||||
// delete not existing extensions
|
// delete not existing extensions
|
||||||
config.Extensions.extensions = config.Extensions.extensions
|
for (const prop of config.Extensions.extensions.keys()) {
|
||||||
.filter(ec => ePaths.indexOf(ec.path) !== -1);
|
if (ePaths.indexOf(prop) > -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
config.Extensions.extensions.removeProperty(prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for (let i = 0; i < this.extensionTemplates.length; ++i) {
|
for (let i = 0; i < this.extensionTemplates.length; ++i) {
|
||||||
const ext = this.extensionTemplates[i];
|
const ext = this.extensionTemplates[i];
|
||||||
|
|
||||||
let c = (config.Extensions.extensions || [])
|
let c = config.Extensions.extensions[ext.folder];
|
||||||
.find(e => e.path === ext.folder);
|
|
||||||
|
|
||||||
// set the new structure with the new def values
|
// set the new structure with the new def values
|
||||||
if (!c) {
|
if (!c) {
|
||||||
@ -109,9 +113,7 @@ export class ExtensionConfigTemplateLoader {
|
|||||||
if (ext.template) {
|
if (ext.template) {
|
||||||
c.configs = new ext.template();
|
c.configs = new ext.template();
|
||||||
}
|
}
|
||||||
// TODO: this does not hold if the order of the extensions mixes up.
|
config.Extensions.extensions.addProperty(ext.folder, {type: ServerExtensionsEntryConfig}, c);
|
||||||
// TODO: experiment with a map instead of an array
|
|
||||||
config.Extensions.extensions.push(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import {SQLConnection} from '../database/SQLConnection';
|
|||||||
import {ExtensionObject} from './ExtensionObject';
|
import {ExtensionObject} from './ExtensionObject';
|
||||||
import {ExtensionDecoratorObject} from './ExtensionDecorator';
|
import {ExtensionDecoratorObject} from './ExtensionDecorator';
|
||||||
import * as util from 'util';
|
import * as util from 'util';
|
||||||
|
import {ServerExtensionsEntryConfig} from '../../../common/config/private/subconfigs/ServerExtensionsConfig';
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const exec = util.promisify(require('child_process').exec);
|
const exec = util.promisify(require('child_process').exec);
|
||||||
|
|
||||||
@ -80,7 +81,7 @@ export class ExtensionManager implements IObjectManager {
|
|||||||
extList.sort();
|
extList.sort();
|
||||||
|
|
||||||
|
|
||||||
Logger.debug(LOG_TAG, 'Extensions found: ', JSON.stringify(Config.Extensions.extensions.map(ec => ec.path)));
|
Logger.debug(LOG_TAG, 'Extensions found: ', JSON.stringify(Config.Extensions.extensions.keys()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private createUniqueExtensionObject(name: string, folder: string): IExtensionObject<unknown> {
|
private createUniqueExtensionObject(name: string, folder: string): IExtensionObject<unknown> {
|
||||||
@ -99,11 +100,12 @@ export class ExtensionManager implements IObjectManager {
|
|||||||
|
|
||||||
private async initExtensions() {
|
private async initExtensions() {
|
||||||
|
|
||||||
for (let i = 0; i < Config.Extensions.extensions.length; ++i) {
|
for (const prop of Config.Extensions.extensions.keys()) {
|
||||||
const extFolder = Config.Extensions.extensions[i].path;
|
const extConf: ServerExtensionsEntryConfig = Config.Extensions.extensions[prop] as ServerExtensionsEntryConfig;
|
||||||
|
const extFolder = extConf.path;
|
||||||
let extName = extFolder;
|
let extName = extFolder;
|
||||||
|
|
||||||
if (Config.Extensions.extensions[i].enabled === false) {
|
if (extConf.enabled === false) {
|
||||||
Logger.silly(LOG_TAG, `Skipping ${extFolder} initiation. Extension is disabled.`);
|
Logger.silly(LOG_TAG, `Skipping ${extFolder} initiation. Extension is disabled.`);
|
||||||
}
|
}
|
||||||
const extPath = path.join(ProjectPath.ExtensionFolder, extFolder);
|
const extPath = path.join(ProjectPath.ExtensionFolder, extFolder);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-inferrable-types */
|
/* eslint-disable @typescript-eslint/no-inferrable-types */
|
||||||
import {ConfigProperty, SubConfigClass} from 'typeconfig/common';
|
import {ConfigMap, ConfigProperty, IConfigMap, SubConfigClass} from 'typeconfig/common';
|
||||||
import {ClientExtensionsConfig, ConfigPriority, TAGS} from '../../public/ClientConfig';
|
import {ClientExtensionsConfig, ConfigPriority, TAGS} from '../../public/ClientConfig';
|
||||||
import {GenericConfigType} from 'typeconfig/src/GenericConfigType';
|
import {GenericConfigType} from 'typeconfig/src/GenericConfigType';
|
||||||
|
|
||||||
@ -59,16 +59,14 @@ export class ServerExtensionsConfig extends ClientExtensionsConfig {
|
|||||||
})
|
})
|
||||||
folder: string = 'extensions';
|
folder: string = 'extensions';
|
||||||
|
|
||||||
// TODO: this does not hold if the order of the extensions mixes up.
|
|
||||||
// TODO: experiment with a map instead of an array
|
|
||||||
@ConfigProperty({
|
@ConfigProperty({
|
||||||
arrayType: ServerExtensionsEntryConfig,
|
type: ConfigMap,
|
||||||
tags: {
|
tags: {
|
||||||
name: $localize`Installed extensions`,
|
name: $localize`Installed extensions`,
|
||||||
priority: ConfigPriority.advanced
|
priority: ConfigPriority.advanced
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
extensions: ServerExtensionsEntryConfig[] = [];
|
extensions: IConfigMap<ServerExtensionsEntryConfig> = new ConfigMap();
|
||||||
|
|
||||||
|
|
||||||
@ConfigProperty({
|
@ConfigProperty({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user