list repositories and their plugins

This commit is contained in:
Evert Prants 2020-12-03 19:44:53 +02:00
parent 869eb79faf
commit 9de5c73952
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 27 additions and 5 deletions

View File

@ -17,8 +17,8 @@ export class SqueebotCLI {
} }
private async repositoryCommand(...args: any[]): Promise<void> { private async repositoryCommand(...args: any[]): Promise<void> {
const help = 'repository add <url> | update <name> | remove <name>'; const help = 'repository add <url> | update <name> | remove <name> | plugins <name> | list';
if (!args[0] || args[0] === 'help') { if (!args[0] || (args[0] === 'help' && args[0] !== 'list')) {
logger.log(help); logger.log(help);
return; return;
} }
@ -73,6 +73,28 @@ export class SqueebotCLI {
await this.checkUpdate(repo); await this.checkUpdate(repo);
} }
break; break;
case 'list':
const repos = this.bot.repositoryManager.getAll();
logger.log('List of installed repositories:');
for (const repo of repos) {
logger.log('%s: (%s) with %d plugins | Date: %s',
repo.name, repo.url, repo.plugins.length, new Date(repo.created * 1000).toDateString());
}
break;
case 'plugins': {
if (!args[1]) {
logger.error('Name is required');
return;
}
const repo = this.bot.repositoryManager.getRepoByName(args[1]);
if (!repo) {
logger.error('No such repository "%s" found.', args[1]);
return;
}
logger.log('List of plugins in %s:', args[1],
repo.plugins.map(x => `${x.name}@${x.version}`).join(', '));
break;
}
default: default:
logger.log(help); logger.log(help);
} }

View File

@ -12,7 +12,7 @@ import { Configuration, IEnvironment } from '@squeebot/core/lib/types';
import { ScopedEventEmitter } from '@squeebot/core/lib/util'; import { ScopedEventEmitter } from '@squeebot/core/lib/util';
import { logger } from '@squeebot/core/lib/core'; import { ISqueebotCore, logger } from '@squeebot/core/lib/core';
const defaultConfiguration: {[key: string]: any} = { const defaultConfiguration: {[key: string]: any} = {
channels: [], channels: [],
@ -20,9 +20,9 @@ const defaultConfiguration: {[key: string]: any} = {
name: 'squeebot', name: 'squeebot',
}; };
export class Squeebot { export class Squeebot implements ISqueebotCore {
// TODO: change core module after publishing to npm // TODO: change core module after publishing to npm
private npm: NPMExecutor = new NPMExecutor(this.environment, '~/Squeebot/core'); public npm: NPMExecutor = new NPMExecutor(this.environment, '~/Squeebot/core');
public stream: ScopedEventEmitter = new ScopedEventEmitter(); public stream: ScopedEventEmitter = new ScopedEventEmitter();