diff --git a/deno-runtime/acorn-walk.d.ts b/deno-runtime/acorn-walk.d.ts index b2a6a8d48..25861f3bc 100644 --- a/deno-runtime/acorn-walk.d.ts +++ b/deno-runtime/acorn-walk.d.ts @@ -167,4 +167,4 @@ export function findNodeAround( */ export const findNodeAfter: typeof findNodeAround -export const base: RecursiveVisitors +export const base: RecursiveVisitors diff --git a/deno-runtime/lib/ast/tests/data/ast_blocks.ts b/deno-runtime/lib/ast/tests/data/ast_blocks.ts index 9a3797e3d..330d2bf52 100644 --- a/deno-runtime/lib/ast/tests/data/ast_blocks.ts +++ b/deno-runtime/lib/ast/tests/data/ast_blocks.ts @@ -1,5 +1,5 @@ // @deno-types="../../../../acorn.d.ts" -import { AnyNode, CallExpression, ClassDeclaration, ExpressionStatement, FunctionDeclaration, VariableDeclaration } from 'acorn'; +import { AnyNode, ClassDeclaration, ExpressionStatement, FunctionDeclaration, VariableDeclaration } from 'acorn'; /** * Partial AST blocks to support testing. diff --git a/src/server/runtime/AppsEngineDenoRuntime.ts b/src/server/runtime/AppsEngineDenoRuntime.ts index 6557dbd89..9479a7bce 100644 --- a/src/server/runtime/AppsEngineDenoRuntime.ts +++ b/src/server/runtime/AppsEngineDenoRuntime.ts @@ -52,11 +52,6 @@ export function getDenoWrapperPath(): string { } } -type ControllerDeps = { - accessors: AppAccessorManager; - api: AppApiManager; -}; - export class DenoRuntimeSubprocessController extends EventEmitter { private readonly deno: child_process.ChildProcess; @@ -90,9 +85,9 @@ export class DenoRuntimeSubprocessController extends EventEmitter { this.state = 'invalid'; } - // this.accessors = manager.getAccessorManager(); - // this.api = manager.getApiManager(); - // this.logStorage = manager.getLogStorage(); + this.accessors = manager.getAccessorManager(); + this.api = manager.getApiManager(); + this.logStorage = manager.getLogStorage(); } emit(eventName: string | symbol, ...args: any[]): boolean { @@ -328,19 +323,14 @@ type ExecRequestContext = { export class AppsEngineDenoRuntime { private readonly subprocesses: Record = {}; - private readonly appManager: AppManager; - - // constructor(manager: AppManager) { - // this.accessorManager = manager.getAccessorManager(); - // this.apiManager = manager.getApiManager(); - // } + constructor(private readonly manager: AppManager) {} public async startRuntimeForApp({ appId, appSource }: AppRuntimeParams, options = { force: false }): Promise { if (appId in this.subprocesses && !options.force) { throw new Error('App already has an associated runtime'); } - this.subprocesses[appId] = new DenoRuntimeSubprocessController(appId, appSource, this.appManager); + this.subprocesses[appId] = new DenoRuntimeSubprocessController(appId, appSource, this.manager); await this.subprocesses[appId].setupApp(); } diff --git a/src/server/runtime/index.ts b/src/server/runtime/index.ts index ef91991fb..ff46c3ce9 100644 --- a/src/server/runtime/index.ts +++ b/src/server/runtime/index.ts @@ -1,4 +1,3 @@ -import { AppsEngineDenoRuntime } from './AppsEngineDenoRuntime'; import { AppsEngineNodeRuntime } from './AppsEngineNodeRuntime'; import { AppsEngineVM2Runtime } from './AppsEngineVM2Runtime'; @@ -16,17 +15,3 @@ export function _getRuntime(requiredEnv = 'vm2'): AvailableRuntime { export function getRuntime() { return _getRuntime(process.env?.ROCKETCHAT_APPS_ENGINE_RUNTIME); } - -export function _getDenoRuntime() { - const runtime = new AppsEngineDenoRuntime(); - - runtime.startRuntimeForApp({ - appId: 'appId', - appSource: 'module.exports={ default: new class { constructor() { this.name = "parangarico" } } };console.log("hi from app")', - }); -} - -// Used for testing during dev cycle -if (process.argv.includes('bruh')) { - _getDenoRuntime(); -} diff --git a/tests/server/runtime/DenoRuntimeSubprocessController.spec.ts b/tests/server/runtime/DenoRuntimeSubprocessController.spec.ts index 067dcdc2f..bc8205c7a 100644 --- a/tests/server/runtime/DenoRuntimeSubprocessController.spec.ts +++ b/tests/server/runtime/DenoRuntimeSubprocessController.spec.ts @@ -3,36 +3,35 @@ import { TestFixture, Setup, SetupFixture, Expect, AsyncTest } from 'alsatian'; import { AppAccessorManager, AppApiManager } from '../../../src/server/managers'; import { TestData, TestInfastructureSetup } from '../../test-data/utilities'; import { DenoRuntimeSubprocessController } from '../../../src/server/runtime/AppsEngineDenoRuntime'; +import type { AppManager } from '../../../src/server/AppManager'; @TestFixture('DenoRuntimeSubprocessController') export class DenuRuntimeSubprocessControllerTestFixture { - private accessors: AppAccessorManager; - - private api: AppApiManager; - private simpleAppSource = 'module.exports={ default: new class { constructor() { this.name = "parangarico" } } };console.log("hi from app")'; + private manager: AppManager; + private controller: DenoRuntimeSubprocessController; @SetupFixture public fixture() { const infrastructure = new TestInfastructureSetup(); - const manager = infrastructure.getMockManager(); + this.manager = infrastructure.getMockManager(); - this.accessors = new AppAccessorManager(manager); + const accessors = new AppAccessorManager(this.manager); - manager.getAccessorManager = () => this.accessors; + this.manager.getAccessorManager = () => accessors; - this.api = new AppApiManager(manager); + const api = new AppApiManager(this.manager); - manager.getApiManager = () => this.api; + this.manager.getApiManager = () => api; } @Setup public setup() { const app = TestData.getMockApp('deno-controller', 'Deno Controller test'); - this.controller = new DenoRuntimeSubprocessController(app.getID(), this.simpleAppSource, { accessors: this.accessors, api: this.api }); + this.controller = new DenoRuntimeSubprocessController(app.getID(), this.simpleAppSource, this.manager); } @AsyncTest('correctly identifies a call to the HTTP accessor')