Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jun 8, 2024
1 parent c8dad06 commit ba12999
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 130 deletions.
24 changes: 0 additions & 24 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: CI
on:
push:
branches: [ master ]

pull_request:
branches: [ master ]

Expand All @@ -12,6 +11,6 @@ jobs:
name: Node.js
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
version: '16.13.0, 16, 18, 20, 22'
version: '18.7.0, 18, 20, 22'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ test/fixtures/egg/node_modules/egg-core
package-lock.json
run
test/fixtures/*/timing.json
lib/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[download-image]: https://img.shields.io/npm/dm/egg-core.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-core

A core Pluggable framework based on [koa](https://github.com/koajs/koa).
A core plugin framework based on [koa](https://github.com/koajs/koa).

**Don't use it directly, see [egg].**

Expand Down Expand Up @@ -237,6 +237,7 @@ filter | `Function` | a function that filter the exports which can b
## Timing

EggCore record boot progress with `Timing`, include:

- Process start time
- Script start time(node don't implement an interface like `process.uptime` to record the script start running time, framework can implement a prestart file used with node `--require` options to set `process.scriptTime`)
- Application start time
Expand Down
50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "@eggjs/core",
"version": "5.3.1",
"engines": {
"node": ">= 18.7.0"
},
"description": "A core plugin framework based on koa",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -31,47 +34,44 @@
"url": "https://github.com/eggjs/egg/issues"
},
"homepage": "https://github.com/eggjs/egg-core#readme",
"engines": {
"node": ">= 16.13.0"
},
"dependencies": {
"@eggjs/koa": "^2.15.1",
"@eggjs/koa": "^2.17.0",
"@eggjs/router": "^2.0.1",
"@types/depd": "^1.1.32",
"co": "^4.6.0",
"depd": "^2.0.0",
"egg-logger": "^3.3.1",
"egg-path-matching": "^1.0.1",
"extend2": "^1.0.0",
"gals": "^1.0.1",
"get-ready": "^3.0.0",
"egg-logger": "^3.5.0",
"egg-path-matching": "^1.1.0",
"extend2": "^1.0.1",
"get-ready": "^3.1.0",
"globby": "^11.0.2",
"is-type-of": "^1.2.1",
"koa-convert": "^1.2.0",
"node-homedir": "^1.1.1",
"ready-callback": "^3.0.0",
"node-homedir": "^2.0.0",
"ready-callback": "^4.0.0",
"tsconfig-paths": "^4.1.1",
"utility": "^1.16.1"
"utility": "^2.1.0"
},
"devDependencies": {
"@eggjs/tsconfig": "^1.3.3",
"@types/mocha": "^10.0.1",
"@types/node": "^20.2.5",
"await-event": "^2.1.0",
"coffee": "^5.2.1",
"egg-bin": "^6.4.1",
"egg-utils": "^2.4.1",
"eslint": "^8.42.0",
"eslint-config-egg": "^12.2.1",
"@eggjs/tsconfig": "1",
"@types/mocha": "10",
"@types/node": "20",
"await-event": "2",
"coffee": "5",
"egg-bin": "6",
"egg-utils": "2",
"eslint": "8",
"eslint-config-egg": "13",
"gals": "^1.0.2",
"git-contributor": "2",
"js-yaml": "^3.13.1",
"mm": "^3.2.1",
"mm": "3",
"pedding": "^1.1.0",
"spy": "^1.0.0",
"supertest": "^4.0.2",
"ts-node": "^10.9.1",
"typescript": "^5.1.3",
"urllib": "^3.10.0"
"ts-node": "10",
"typescript": "5",
"urllib": "3"
},
"publishConfig": {
"access": "public"
Expand Down
6 changes: 1 addition & 5 deletions src/egg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type { MiddlewareFunc } from '@eggjs/koa';
import { EggConsoleLogger } from 'egg-logger';
import { EggRouter as Router } from '@eggjs/router';
import type { ReadyFunctionArg } from 'get-ready';
import { getAsyncLocalStorage } from 'gals';
import { BaseContextClass } from './utils/base_context_class';
import utils from './utils';
import { Timing } from './utils/timing';
Expand Down Expand Up @@ -56,10 +55,7 @@ export class EggCore extends KoaApplication {
assert(fs.existsSync(options.baseDir), `Directory ${options.baseDir} not exists`);
assert(fs.statSync(options.baseDir).isDirectory(), `Directory ${options.baseDir} is not a directory`);
assert(options.type === 'application' || options.type === 'agent', 'options.type should be application or agent');
// disable koa als and use egg logic
super({ asyncLocalStorage: false });
// can access the AsyncLocalStorage instance in global
this.ctxStorage = getAsyncLocalStorage();
super();

this.timing = new Timing();

Expand Down
2 changes: 1 addition & 1 deletion src/loader/base_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { debuglog } from 'node:util';
import is from 'is-type-of';
import homedir from 'node-homedir';
import type { Logger } from 'egg-logger';
import utility from 'utility';
import FileLoader from './file_loader';
import ContextLoader from './context_loader';
import utility from 'utility';
import utils from '../utils';
import { Timing } from '../utils/timing';
import type { EggCore } from '../egg';
Expand Down
36 changes: 0 additions & 36 deletions test/asyncLocalStorage.test.js

This file was deleted.

1 change: 1 addition & 0 deletions test/asyncLocalStorage.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { strict as assert } from 'node:assert';
import path from 'node:path';
import { AsyncLocalStorage } from 'node:async_hooks';
import request from 'supertest';
import { getAsyncLocalStorage, kGALS } from 'gals';
import { Application } from './fixtures/egg';
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/egg/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ class EggApplication extends EggCore {
}
}

module.exports.Application = EggApplication;
exports.Application = EggApplication;
35 changes: 0 additions & 35 deletions test/utils.js

This file was deleted.

29 changes: 29 additions & 0 deletions test/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import path from 'node:path';
import { setTimeout } from 'node:timers/promises';
import { Application as EggApplication } from './fixtures/egg';

export function getFilepath(name: string) {
return path.join(__dirname, 'fixtures', name);
}

export function createApp(name, options) {
const baseDir = this.getFilepath(name);
options = options || {};
options.baseDir = baseDir;
options.type = options.type || 'application';

let CustomApplication = EggApplication;
if (options.Application) {
CustomApplication = options.Application;
}

return new CustomApplication(options);
};

export async function sleep(ms: number) {
return await setTimeout(ms);
};

export const symbol = {
view: Symbol('view'),
};

0 comments on commit ba12999

Please sign in to comment.