mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-02 12:18:15 +08:00
fix: insert a record after pm.add
This commit is contained in:
parent
4eada322ef
commit
f5a4413a9a
@ -12,7 +12,7 @@ export default (app: Application) => {
|
||||
pm.command('add')
|
||||
.arguments('plugin')
|
||||
.action(async (plugin) => {
|
||||
await app.pm.add(plugin);
|
||||
await app.pm.add(plugin, {}, true);
|
||||
});
|
||||
|
||||
pm.command('enable')
|
||||
|
@ -189,7 +189,7 @@ export class PluginManager {
|
||||
await run('yarn', ['install']);
|
||||
}
|
||||
|
||||
async add(plugin?: any, options: any = {}) {
|
||||
async add(plugin?: any, options: any = {}, insert = false) {
|
||||
if (this.has(plugin)) {
|
||||
const name = typeof plugin === 'string' ? plugin : plugin.name;
|
||||
this.app.log.warn(`plugin [${name}] added`);
|
||||
@ -211,6 +211,17 @@ export class PluginManager {
|
||||
if (options.name) {
|
||||
this.pluginAliases.set(options.name, instance);
|
||||
}
|
||||
if (insert && options.name) {
|
||||
const packageName = PluginManager.getPackageName(options.name);
|
||||
const packageJson = PluginManager.getPackageJson(packageName);
|
||||
await this.repository.updateOrCreate({
|
||||
values: {
|
||||
...options,
|
||||
version: packageJson.version,
|
||||
},
|
||||
filterKeys: ['name'],
|
||||
});
|
||||
}
|
||||
await instance.afterAdd();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user