From c444a038845ec8c621243eba935df0d2e203ca97 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Sat, 16 Mar 2024 14:09:10 +0200 Subject: [PATCH] Support installing dev packages, add reply support flag --- package.json | 2 +- src/npm/executor.ts | 5 +++-- src/types/message.ts | 5 +++++ src/types/protocol-flags.ts | 5 +++++ src/types/service.ts | 1 + 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 76cba28..5027e7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@squeebot/core", - "version": "3.6.2", + "version": "3.6.3", "description": "Squeebot v3 core for the execution environment", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/npm/executor.ts b/src/npm/executor.ts index 9f4f6ac..fcb138f 100644 --- a/src/npm/executor.ts +++ b/src/npm/executor.ts @@ -56,8 +56,9 @@ export class NPMExecutor { /** * Install a npm package (examples: `@squeebot/core`, `@squeebot/core@3.3.3`, `node-ical`) * @param pkg Package name + * @param development Install as devDependency */ - public async installPackage(pkg: string): Promise { + public async installPackage(pkg: string, development = false): Promise { if (!(await fs.pathExists(this.packageFile))) { await this.init(); } @@ -92,7 +93,7 @@ export class NPMExecutor { const { code, stderr, stdout } = await spawnProcess( 'npm', - ['install', pkg], + development ? ['install', '--save-dev', pkg] : ['install', pkg], this.environment ); if (code > 0) { diff --git a/src/types/message.ts b/src/types/message.ts index 93ca7a1..68ceaee 100644 --- a/src/types/message.ts +++ b/src/types/message.ts @@ -98,4 +98,9 @@ export interface IMessage { * @param target UserTarget to mention (i.e. `msg.sender`) */ mention(target: IMessageTarget): string; + /** + * Same as `resolve`, but replies (on supported protocols) instead. + * @param args Message data + */ + reply?(...args: any[]): void; } diff --git a/src/types/protocol-flags.ts b/src/types/protocol-flags.ts index 6ab78d6..d046d19 100644 --- a/src/types/protocol-flags.ts +++ b/src/types/protocol-flags.ts @@ -76,6 +76,11 @@ export enum ProtocolFeatureFlag { */ MENTION, + /** + * Protocol supports replying. + */ + REPLY, + /** * Protocol connection manages multiple "servers" */ diff --git a/src/types/service.ts b/src/types/service.ts index 0edcc3b..76680f1 100644 --- a/src/types/service.ts +++ b/src/types/service.ts @@ -17,6 +17,7 @@ export class Service { resolve: () => {}, reject: () => {}, mention: () => '', + reply: () => {}, data: pto, source: pto, text: `Protocol ${pto.fullName} running`,