Skip to content

Commit

Permalink
feat: support define custom egg framework (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 authored Nov 10, 2020
1 parent 0088cb2 commit f5baba1
Show file tree
Hide file tree
Showing 33 changed files with 370 additions and 236 deletions.
3 changes: 3 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"noCi": true,
"npmClientArgs": [
"--no-package-lock"
],
"nohoist": [
"egg"
]
},
"publish": {
Expand Down
7 changes: 3 additions & 4 deletions packages-serverless/egg-layer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"version": "1.2.10",
"main": "index.js",
"scripts": {
"test": "midway-bin test",
"debug": "midway-bin test",
"cov": "midway-bin cov"
"test": "midway-bin test --forceExit",
"cov": "midway-bin cov --forceExit"
},
"dependencies": {
"egg": "^2.25.0",
"egg": "^2.28.0",
"request": "^2.88.2"
},
"devDependencies": {
Expand Down
5 changes: 2 additions & 3 deletions packages-serverless/express-layer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"version": "1.2.13",
"main": "index.js",
"scripts": {
"test": "midway-bin test",
"debug": "midway-bin test",
"cov": "midway-bin cov"
"test": "midway-bin test --forceExit",
"cov": "midway-bin cov --forceExit"
},
"dependencies": {
"request": "^2.88.2"
Expand Down
9 changes: 4 additions & 5 deletions packages-serverless/koa-layer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"version": "1.2.9",
"main": "index.js",
"scripts": {
"test": "midway-bin test",
"debug": "midway-bin test",
"cov": "midway-bin cov"
"test": "midway-bin test --forceExit",
"cov": "midway-bin cov --forceExit"
},
"dependencies": {
"request": "^2.88.2"
Expand All @@ -18,9 +17,9 @@
"@midwayjs/serverless-fc-trigger": "^1.2.9",
"@midwayjs/serverless-scf-starter": "^1.2.9",
"@midwayjs/serverless-scf-trigger": "^1.2.9",
"koa": "^2.11.0",
"koa": "^2.13.0",
"koa-bodyparser": "^4.2.1",
"koa-router": "^9.1.0",
"koa-router": "^9.4.0",
"supertest": "^4.0.2"
},
"engines": {
Expand Down
6 changes: 3 additions & 3 deletions packages-serverless/runtime-engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"main": "dist/index",
"typings": "dist/index.d.ts",
"dependencies": {
"egg-logger": "^2.3.1",
"egg-logger": "^2.4.2",
"mz": "^2.7.0"
},
"devDependencies": {
"@midwayjs/cli": "^1.0.0"
},
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test --ts",
"cov": "midway-bin cov --ts"
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit"
},
"engines": {
"node": ">= 10"
Expand Down
4 changes: 2 additions & 2 deletions packages-serverless/runtime-mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test --ts",
"cov": "midway-bin cov --ts"
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages-serverless/serverless-aws-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test --ts",
"cov": "midway-bin cov --ts"
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages-serverless/serverless-fc-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test --ts",
"cov": "midway-bin cov --ts"
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages-serverless/serverless-fc-trigger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test --ts",
"cov": "midway-bin cov --ts"
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages-serverless/serverless-http-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test --ts",
"cov": "midway-bin cov --ts"
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages-serverless/serverless-scf-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test --ts",
"cov": "midway-bin cov --ts"
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages-serverless/serverless-scf-trigger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test --ts",
"cov": "midway-bin cov --ts"
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages/bootstrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test",
"cov": "midway-bin test --cov",
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit",
"link": "npm link"
},
"keywords": [
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test",
"cov": "midway-bin cov",
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit",
"link": "npm link"
},
"keywords": [
Expand All @@ -23,7 +23,7 @@
"devDependencies": {
"@midwayjs/cli": "^1.0.0",
"chai": "^4.2.0",
"mm": "^2.5.0",
"mm": "3",
"sinon": "^7.2.2"
},
"dependencies": {
Expand Down
12 changes: 10 additions & 2 deletions packages/core/src/util/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { dirname, resolve, sep, extname } from 'path';
import { readFileSync } from 'fs';

/**
* get all method names from obj or it's prototype
Expand Down Expand Up @@ -33,12 +34,19 @@ export function getPrototypeNames(obj) {
return result.filter(k => ownKeysOnObjectPrototype.indexOf(k) === -1);
}

export const safeRequire = p => {
export const safeRequire = (p, enabledCache = true) => {
if (p.startsWith(`.${sep}`) || p.startsWith(`..${sep}`)) {
p = resolve(dirname(module.parent.filename), p);
}
try {
return require(p);
if (enabledCache) {
return require(p);
} else {
const content = readFileSync(p, {
encoding: 'utf-8',
});
return JSON.parse(content);
}
} catch (err) {
return undefined;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/decorator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test",
"cov": "midway-bin test --cov",
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit",
"ci": "npm run test",
"link": "npm link"
},
Expand All @@ -21,7 +21,7 @@
},
"devDependencies": {
"@midwayjs/cli": "^1.0.0",
"mm": "^2.5.0"
"mm": "3"
},
"keywords": [
"midway",
Expand Down
6 changes: 3 additions & 3 deletions packages/faas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@midwayjs/mock": "^2.3.23",
"@midwayjs/serverless-fc-starter": "^1.0.0",
"@midwayjs/serverless-scf-starter": "^1.0.0",
"mm": "^2.5.0"
"mm": "3"
},
"engines": {
"node": ">= 10"
Expand All @@ -37,8 +37,8 @@
],
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test",
"cov": "midway-bin test --cov"
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit"
},
"repository": {
"type": "git",
Expand Down
5 changes: 2 additions & 3 deletions packages/midway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test",
"cov": "midway-bin test --cov",
"ci": "npm run test",
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit",
"link": "npm link"
},
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions packages/mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test --forceExit",
"cov": "midway-bin test --cov --forceExit",
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit",
"ci": "midway-bin test",
"link": "npm link"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/rabbitmq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test",
"cov": "midway-bin cov",
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit",
"ci": "npm run test"
},
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions packages/socketio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test --forceExit",
"cov": "midway-bin cov --forceExit",
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit",
"ci": "npm run test"
},
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions packages/web-koa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test --forceExit",
"cov": "midway-bin cov --forceExit",
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit",
"ci": "npm run test"
},
"keywords": [
Expand Down
5 changes: 3 additions & 2 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"typings": "dist/index.d.ts",
"scripts": {
"build": "midway-bin build -c",
"test": "midway-bin test --ts",
"cov": "midway-bin cov --ts",
"test": "midway-bin test --ts --forceExit",
"cov": "midway-bin cov --ts --forceExit",
"link": "npm link"
},
"keywords": [
Expand All @@ -30,6 +30,7 @@
"@midwayjs/cli": "^1.0.0",
"@midwayjs/mock": "^2.3.23",
"egg-view-nunjucks": "^2.2.0",
"fake-egg": "1.0.0",
"fs-extra": "^8.0.1",
"pedding": "^1.1.0",
"react": "^16.13.1",
Expand Down
Loading

0 comments on commit f5baba1

Please sign in to comment.