mirror of
https://github.com/HeyPuter/puter.git
synced 2025-02-03 07:48:46 +08:00
fix: update test kernel
This commit is contained in:
parent
7f5f6f83d7
commit
55c609b3fe
@ -1,12 +1,40 @@
|
|||||||
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
const { AdvancedBase } = require("@heyputer/puter-js-common");
|
||||||
|
const useapi = require("useapi");
|
||||||
|
const { BaseService } = require("../exports");
|
||||||
const CoreModule = require("../src/CoreModule");
|
const CoreModule = require("../src/CoreModule");
|
||||||
const { Context } = require("../src/util/context");
|
const { Context } = require("../src/util/context");
|
||||||
|
|
||||||
|
class TestLogger {
|
||||||
|
constructor () {
|
||||||
|
console.log(
|
||||||
|
`\x1B[36;1mBoot logger started :)\x1B[0m`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
info (...args) {
|
||||||
|
console.log(
|
||||||
|
'\x1B[36;1m[TESTKERNEL/INFO]\x1B[0m',
|
||||||
|
...args,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
error (...args) {
|
||||||
|
console.log(
|
||||||
|
'\x1B[31;1m[TESTKERNEL/ERROR]\x1B[0m',
|
||||||
|
...args,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class TestKernel extends AdvancedBase {
|
class TestKernel extends AdvancedBase {
|
||||||
constructor () {
|
constructor () {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.modules = [];
|
this.modules = [];
|
||||||
|
this.useapi = useapi();
|
||||||
|
|
||||||
|
this.useapi.withuse(() => {
|
||||||
|
def('Module', AdvancedBase)
|
||||||
|
def('Service', BaseService)
|
||||||
|
});
|
||||||
|
|
||||||
this.logfn_ = (...a) => a;
|
this.logfn_ = (...a) => a;
|
||||||
}
|
}
|
||||||
@ -24,13 +52,16 @@ class TestKernel extends AdvancedBase {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { Container } = require('../src/services/Container');
|
const { Container } = require('../src/services/Container');
|
||||||
|
|
||||||
|
this.testLogger = new TestLogger();
|
||||||
|
|
||||||
const services = new Container();
|
const services = new Container({ logger: this.testLogger });
|
||||||
this.services = services;
|
this.services = services;
|
||||||
// app.set('services', services);
|
// app.set('services', services);
|
||||||
|
|
||||||
const root_context = Context.create({
|
const root_context = Context.create({
|
||||||
services,
|
services,
|
||||||
|
useapi: this.useapi,
|
||||||
}, 'app');
|
}, 'app');
|
||||||
globalThis.root_context = root_context;
|
globalThis.root_context = root_context;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user