Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from eggjs:master #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .autod.conf.js

This file was deleted.

10 changes: 0 additions & 10 deletions .eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions .eslintrc

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI

on:
push:
branches: [ master ]

pull_request:
branches: [ master ]

workflow_dispatch: {}

jobs:
Job:
name: Node.js
uses: artusjs/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest'
version: '14, 16, 18'
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

26 changes: 0 additions & 26 deletions assets-with-roadhog/.autod.conf.js

This file was deleted.

8 changes: 2 additions & 6 deletions assets-with-roadhog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@
"react": "^16.2.0"
},
"devDependencies": {
"autod": "^3.0.1",
"autod-egg": "^1.0.0",
"babel-plugin-dva-hmr": "^0.4.0",
"babel-plugin-import": "^1.1.0",
"egg-bin": "^4.3.7",
"egg-mock": "^3.15.0",
"eslint": "^4.18.2",
"eslint-config-egg": "^7.0.0",
"redbox-react": "^1.5.0",
"roadhog": "^2.3.0",
"webstorm-disable-index": "^1.2.0"
"roadhog": "^2.3.0"
},
"engines": {
"node": ">=8.9.0"
Expand All @@ -40,8 +37,7 @@
"test": "egg-bin test",
"cov": "egg-bin cov",
"lint": "eslint .",
"ci": "npm run lint && npm run cov",
"autod": "autod"
"ci": "npm run lint && npm run cov"
},
"ci": {
"version": "8"
Expand Down
20 changes: 0 additions & 20 deletions bin/autod.js

This file was deleted.

1 change: 1 addition & 0 deletions hello-tegg/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
typings/
1 change: 1 addition & 0 deletions hello-tegg/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"root": true,
"extends": "eslint-config-egg/typescript"
}
2 changes: 2 additions & 0 deletions hello-tegg/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ config/**/*.js
app/**/*.map
test/**/*.map
config/**/*.map
*.d.ts
*.tsbuildinfo
4 changes: 2 additions & 2 deletions hello-tegg/app/biz/HelloService.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
ContextProto,
AccessLevel,
SingletonProto,
} from '@eggjs/tegg';

@ContextProto({
@SingletonProto({
accessLevel: AccessLevel.PUBLIC,
})
export class HelloService {
Expand Down
4 changes: 2 additions & 2 deletions hello-tegg/app/controller/HelloController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
Inject,
} from '@eggjs/tegg';
import { EggLogger } from 'egg';
import { traceMethod } from '../middleware/trace_method';
import { HelloService } from '../biz/HelloService';
import { traceMethod } from 'app/middleware/trace_method';
import { HelloService } from 'app/biz/HelloService';

@HTTPController()
@Middleware(traceMethod)
Expand Down
50 changes: 24 additions & 26 deletions hello-tegg/package.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
{
"name": "hello-tegg",
"version": "1.0.0",
"description": "",
"main": "index.js",
"private": true,
"description": "tegg application example",
"scripts": {
"start": "egg-scripts start",
"dev": "egg-bin dev -r egg-ts-helper/register",
"debug": "egg-bin debug -r egg-ts-helper/register",
"test-local": "egg-bin test -r egg-ts-helper/register",
"stop": "egg-scripts stop",
"dev": "egg-bin dev",
"debug": "egg-bin debug",
"test-local": "egg-bin test",
"test": "npm run lint -- --fix && npm run test-local",
"cov": "egg-bin cov -r egg-ts-helper/register",
"cov": "egg-bin cov",
"tsc": "tsc -p tsconfig.json",
"ci": "npm run lint && npm run cov && npm run tsc",
"autod": "autod",
"lint": "eslint .",
"clean": "tsc -b --clean"
},
"egg": {
"typescript": true
},
"author": "",
"license": "ISC",
"license": "MIT",
"dependencies": {
"@eggjs/tegg": "^0.1.1",
"@eggjs/tegg-config": "^0.1.0",
"@eggjs/tegg-controller-plugin": "^0.1.1",
"@eggjs/tegg-eventbus-plugin": "^0.1.1",
"@eggjs/tegg-plugin": "^0.1.1",
"egg": "^2.29.4"
"@eggjs/tegg": "^3.2.1",
"@eggjs/tegg-controller-plugin": "^3.2.1",
"@eggjs/tegg-plugin": "^3.2.1",
"@eggjs/tsconfig": "^1.2.0",
"@eggjs/tegg-config": "^3.1.0",
"egg": "^3.9.1",
"egg-scripts": "^2.17.0"
},
"devDependencies": {
"@eggjs/tsconfig": "^1.0.0",
"@types/mocha": "^8.2.3",
"@types/node": "^16.4.0",
"egg-bin": "^4.16.4",
"egg-mock": "^3.26.0",
"egg-ts-helper": "^1.25.9",
"eslint": "^7.31.0",
"eslint-config-egg": "^9.0.0",
"typescript": "^4.3.5"
}
"@types/mocha": "^10.0.1",
"@types/node": "^16.18.10",
"egg-bin": "^6.0.0",
"egg-mock": "^5.4.0",
"eslint": "^8.30.0",
"eslint-config-egg": "^12.1.0",
"typescript": "^4.9.4"
},
"repository": "[email protected]:eggjs/examples.git"
}
5 changes: 4 additions & 1 deletion hello-tegg/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "@eggjs/tsconfig"
"extends": "@eggjs/tsconfig",
"compilerOptions": {
"baseUrl": "./"
}
}
23 changes: 6 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@
"egg"
],
"devDependencies": {
"autod": "^2.7.1",
"autod-egg": "^1.0.0",
"chalk": "^1.1.3",
"eslint": "^5.6.1",
"eslint-config-egg": "^7.1.0",
"npminstall": "3",
"semver": "^5.3.0",
"common-bin": "^2.7.1",
"globby": "^6.1.0"
"globby": "^6.1.0",
"npminstall": "^6.6.2",
"runscript": "^1.5.3",
"semver": "^5.3.0"
},
"scripts": {
"lint": "eslint .",
"lint": "echo 'ignore'",
"test": "./example.js test",
"test-cn": "./example.js test -c",
"ci": "npm run lint && npm test",
"autod": "./example.js autod",
"list": "./example.js list"
},
"homepage": "https://github.com/eggjs/examples",
Expand All @@ -34,14 +30,7 @@
"url": "https://github.com/eggjs/egg/issues"
},
"engines": {
"node": ">= 8.0.0"
},
"ci": {
"version": "8",
"license": {
"year": 2017
},
"afterScript": false
"node": ">= 14.17.0"
},
"license": "MIT",
"private": true
Expand Down
4 changes: 2 additions & 2 deletions sequelize-ts/app/model/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Application } from 'egg';
export default function(app: Application) {
const { STRING, INTEGER, DATE } = app.Sequelize;

const Post = app.model.define('post', {
const Model = app.model.define('post', {
id: {
type: INTEGER,
primaryKey: true,
Expand All @@ -18,7 +18,7 @@ export default function(app: Application) {
updated_at: DATE(6),
});

return class extends Post {
return class Post extends Model {
static associate() {
app.model.Post.belongsTo(app.model.User, { as: 'user', foreignKey: 'user_id' });
}
Expand Down
4 changes: 2 additions & 2 deletions sequelize-ts/app/model/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Application } from 'egg';

export default function(app: Application) {
const { STRING, INTEGER, DATE } = app.Sequelize;
const User = app.model.define('user', {
const Model = app.model.define('user', {
id: {
type: INTEGER,
primaryKey: true,
Expand All @@ -16,7 +16,7 @@ export default function(app: Application) {
updated_at: DATE(6),
});

return class extends User {
return class User extends Model {
static associate() {
app.model.User.hasMany(app.model.Post, { as: 'posts' });
}
Expand Down
12 changes: 12 additions & 0 deletions unittest-jest/__tests__/controller/home.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

const { app } = require('egg-mock/bootstrap');

describe('__tests__/controller/home.test.js', () => {
it('should status 200 and get the body', () => {
return app.httpRequest()
.get('/')
.expect(200)
.expect('hello world');
});
});
18 changes: 1 addition & 17 deletions unittest-jest/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
'use strict';

const mock = require('egg-mock');
const { app } = require('egg-mock/bootstrap');

describe('__tests__/index.test.js', () => {
let app;
beforeAll(() => {
app = mock.app();
return app.ready();
});

afterEach(mock.restore);
afterAll(() => app.close());

it('should app exist', () => {
expect(app.test).toBe('123');
});

it('should status 200 and get the body', () => {
return app.httpRequest()
.get('/')
.expect(200)
.expect('hello world');
});
});