ChengLei Shao 797f566d70
feat(gateway): response cli result when run nocobase command (#2563)
* chore(gateway): refresh message in websocket

* chore(gateway): throw error when cli error

* chore(gateway): await ipc server response

* chore: notification message

* fix: build

* chore: notification type

* feat: notification

---------

Co-authored-by: chenos <chenlinxh@gmail.com>
2023-09-01 16:11:27 +08:00

45 lines
1.1 KiB
TypeScript

import Application from '../application';
import { PluginCommandError } from '../errors/plugin-command-error';
export default (app: Application) => {
const pm = app.command('pm');
pm.command('create')
.arguments('plugin')
.action(async (plugin) => {
await app.pm.create(plugin);
});
pm.command('add')
.arguments('plugin')
.action(async (plugin) => {
await app.pm.add(plugin, {}, true);
});
pm.command('enable')
.arguments('<plugins...>')
.action(async (plugins) => {
try {
await app.pm.enable(plugins);
} catch (error) {
throw new PluginCommandError(`Failed to enable plugin: ${error.message}`);
}
});
pm.command('disable')
.arguments('<plugins...>')
.action(async (plugins) => {
try {
await app.pm.disable(plugins);
} catch (error) {
throw new PluginCommandError(`Failed to disable plugin: ${error.message}`);
}
});
pm.command('remove')
.arguments('<plugins...>')
.action(async (plugins) => {
await app.pm.remove(plugins);
});
};