fix: ioc deps not created correctly

This commit is contained in:
Jacob Nguyen
2024-06-10 00:22:10 -05:00
parent bf071b7af4
commit 67bb4d4b9f
5 changed files with 7 additions and 25 deletions

View File

@@ -51,7 +51,6 @@ type ValidDependencyConfig =
export async function makeDependencies (conf: ValidDependencyConfig) {
const container = await __init_container({ autowire: false });
conf(dependencyBuilder(container));
//We only include logger if it does not exist
const includeLogger = !container.hasKey('@sern/logger');
@@ -62,6 +61,7 @@ export async function makeDependencies (conf: ValidDependencyConfig) {
__add_container('@sern/modules', new Map)
__add_container('@sern/emitter', new EventEmitter)
__add_wiredcontainer('@sern/cron', deps => new __Services.Cron(deps))
conf(dependencyBuilder(container));
await container.ready();
}

View File

@@ -89,3 +89,4 @@ export async function Asset(p: string, opts?: { name?: string, encoding: AssetEn
return fs.readFile(filePath, encoding);
}
}

View File

@@ -10,7 +10,6 @@ import { handleCrash } from './handlers/event-utils';
import { useContainerRaw } from './core/ioc/global';
import { UnpackedDependencies } from './types/utility';
import type { PresenceResult } from './core/presences';
import fs from 'fs/promises'
interface Wrapper {
commands: string;
@@ -64,16 +63,3 @@ export function init(maybeWrapper: Wrapper = { commands: "./dist/commands" }) {
// listening to the message stream and interaction stream
merge(messages$, interactions$).pipe(handleCrash(deps)).subscribe();
}
export async function publisher() {
const directoryToWatch = "./src/commands";
const watcher = fs.watch(directoryToWatch, { recursive: true }, );
for await (const { eventType, filename } of watcher) {
switch(eventType) {
case 'change': {
console.log('change', filename)
} break;
}
}
}

View File

@@ -38,20 +38,17 @@ export interface InitArgs<T extends Processed<Module> = Processed<Module>> {
module: T;
absPath: string;
deps: Dependencies
updateModule: (module: Partial<T>) => T
}
export interface Plugin<Args extends any[] = any[]> {
type: PluginType;
execute: (...args: Args) => PluginResult;
}
export interface InitPlugin<Args extends any[] = any[]> {
export interface InitPlugin<Args extends any[] = any[]> extends Plugin<Args> {
type: PluginType.Init;
execute: (...args: Args) => PluginResult;
}
export interface ControlPlugin<Args extends any[] = any[]> {
export interface ControlPlugin<Args extends any[] = any[]> extends Plugin<Args> {
type: PluginType.Control;
execute: (...args: Args) => PluginResult;
}
export type AnyPlugin = ControlPlugin | InitPlugin<[InitArgs<Processed<Module>>]>;

View File

@@ -1,5 +1,4 @@
import type { InteractionReplyOptions, MessageReplyOptions } from 'discord.js';
import type { PayloadType } from '../core/structures/enums';
import type { Module } from './core-modules';
import type { Result } from 'ts-results-es';
@@ -17,11 +16,10 @@ export interface SernEventsMapping {
}
export type Payload =
| { type: PayloadType.Success; module: Module }
| { type: PayloadType.Failure; module?: Module; reason: string | Error }
| { type: PayloadType.Warning; module: undefined; reason: string };
| { type: 'success'; module: Module }
| { type: 'failure'; module?: Module; reason: string | Error }
| { type: 'warning'; module: undefined; reason: string };
//https://github.com/molszanski/iti/blob/0a3a006113b4176316c308805314a135c0f47902/iti/src/_utils.ts#L29C1-L29C76
export type UnpackFunction<T> = T extends (...args: any) => infer U ? U : T
export type UnpackedDependencies = {
[K in keyof Dependencies]: UnpackFunction<Dependencies[K]>