fix: plugin upgrade
This commit is contained in:
parent
a593720c81
commit
5b81c4d07c
@ -89,6 +89,10 @@ export class PluginManager {
|
|||||||
return this.plugins.get(name);
|
return this.plugins.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
has(name: string) {
|
||||||
|
return this.plugins.has(name);
|
||||||
|
}
|
||||||
|
|
||||||
clientWrite(data: any) {
|
clientWrite(data: any) {
|
||||||
const { method, plugins } = data;
|
const { method, plugins } = data;
|
||||||
if (method === 'create') {
|
if (method === 'create') {
|
||||||
|
@ -2,32 +2,41 @@ import { Plugin } from '@nocobase/server';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
export class PresetNocoBase extends Plugin {
|
export class PresetNocoBase extends Plugin {
|
||||||
async addBuiltInPlugins() {
|
getBuiltInPlugins() {
|
||||||
const builtInPlugins = process.env.PRESET_NOCOBASE_PLUGINS
|
return process.env.PRESET_NOCOBASE_PLUGINS
|
||||||
? process.env.PRESET_NOCOBASE_PLUGINS.split(',')
|
? process.env.PRESET_NOCOBASE_PLUGINS.split(',')
|
||||||
: [
|
: [
|
||||||
'error-handler',
|
'error-handler',
|
||||||
'collection-manager',
|
'collection-manager',
|
||||||
'ui-schema-storage',
|
'ui-schema-storage',
|
||||||
'ui-routes-storage',
|
'ui-routes-storage',
|
||||||
'file-manager',
|
'file-manager',
|
||||||
'system-settings',
|
'system-settings',
|
||||||
'verification',
|
'verification',
|
||||||
'users',
|
'users',
|
||||||
'acl',
|
'acl',
|
||||||
'china-region',
|
'china-region',
|
||||||
'workflow',
|
'workflow',
|
||||||
'client',
|
'client',
|
||||||
'export',
|
'export',
|
||||||
'import',
|
'import',
|
||||||
'audit-logs',
|
'audit-logs',
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
getLocalPlugins() {
|
||||||
|
const localPlugins = ['sample-hello', 'oidc', 'saml', 'map'];
|
||||||
|
return localPlugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
async addBuiltInPlugins() {
|
||||||
|
const builtInPlugins = this.getBuiltInPlugins();
|
||||||
await this.app.pm.add(builtInPlugins, {
|
await this.app.pm.add(builtInPlugins, {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
builtIn: true,
|
builtIn: true,
|
||||||
installed: true,
|
installed: true,
|
||||||
});
|
});
|
||||||
const localPlugins = ['sample-hello', 'oidc', 'saml', 'map'];
|
const localPlugins = this.getLocalPlugins();
|
||||||
await this.app.pm.add(localPlugins, {});
|
await this.app.pm.add(localPlugins, {});
|
||||||
await this.app.reload();
|
await this.app.reload();
|
||||||
}
|
}
|
||||||
@ -55,6 +64,20 @@ export class PresetNocoBase extends Plugin {
|
|||||||
console.log(`Initialize all built-in plugins`);
|
console.log(`Initialize all built-in plugins`);
|
||||||
await this.addBuiltInPlugins();
|
await this.addBuiltInPlugins();
|
||||||
}
|
}
|
||||||
|
const builtInPlugins = this.getBuiltInPlugins();
|
||||||
|
await this.app.pm.add(
|
||||||
|
builtInPlugins.filter((plugin) => !this.app.pm.has(plugin)),
|
||||||
|
{
|
||||||
|
enabled: true,
|
||||||
|
builtIn: true,
|
||||||
|
installed: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const localPlugins = this.getLocalPlugins();
|
||||||
|
await this.app.pm.add(
|
||||||
|
localPlugins.filter((plugin) => !this.app.pm.has(plugin)),
|
||||||
|
{},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
this.app.on('beforeInstall', async () => {
|
this.app.on('beforeInstall', async () => {
|
||||||
console.log(`Initialize all built-in plugins`);
|
console.log(`Initialize all built-in plugins`);
|
||||||
|
Loading…
Reference in New Issue
Block a user