-
Notifications
You must be signed in to change notification settings - Fork 737
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
feat: update to new egg-bin #63
Changes from 7 commits
5be0add
d32144e
335c7e1
855aec9
aa318fd
a468bab
1caffa1
2ca8ba8
fc5c182
f223092
c2d8047
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
coverage/ | ||
**/*.d.ts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "eslint-config-egg", | ||
"parser": "typescript-eslint-parser", | ||
"plugins": [ | ||
"typescript" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,19 @@ | ||
logs/ | ||
npm-debug.log | ||
node_modules/ | ||
coverage/ | ||
.idea/ | ||
run/ | ||
logs/ | ||
.DS_Store | ||
.vscode | ||
*.swp | ||
*.lock | ||
*.js | ||
|
||
app/**/*.js | ||
test/**/*.js | ||
config/**/*.js | ||
*.map | ||
run | ||
logs | ||
|
||
# Created by https://www.gitignore.io/api/node | ||
|
||
### Node ### | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
|
||
# End of https://www.gitignore.io/api/node | ||
app/**/*.map | ||
test/**/*.map | ||
config/**/*.map |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,13 @@ | |
"files.exclude": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"USE_GITIGNORE": true, | ||
"**/*.js": { | ||
"when": "$(basename).ts" | ||
// "when": "$(basename).ts" | ||
}, | ||
"**/*.map": true, | ||
"run": true, | ||
"logs": true, | ||
"out": true, | ||
"node_modules": true | ||
} | ||
}, | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个用处是? 是不是可以直接加到 tsconfig.json 的? |
||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { Application } from 'egg'; | ||
|
||
export default (app: Application) => { | ||
const controller = app.controller; | ||
app.redirect('/', '/news'); | ||
app.router.get('/news', controller.news.list); | ||
app.router.get('/news/item/:id', controller.news.detail); | ||
app.router.get('/news/user/:id', controller.news.user); | ||
const { controller, router } = app; | ||
|
||
// router.redirect('/', '/news'); | ||
router.get('/news', controller.news.list); | ||
router.get('/news/item/:id', controller.news.detail); | ||
router.get('/news/user/:id', controller.news.user); | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
import { EggAppConfig } from 'egg'; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
export default (appInfo: EggAppConfig) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EggAppInfo 的那个改改,这里不对 |
||
return { | ||
keys: appInfo.name + '123456', | ||
siteFile: { | ||
'/favicon.ico': fs.readFileSync( | ||
path.join(appInfo.baseDir, 'app/public/favicon.png'), | ||
), | ||
}, | ||
view: { | ||
defaultViewEngine: 'nunjucks', | ||
mapping: { | ||
'.tpl': 'nunjucks', | ||
}, | ||
}, | ||
news: { | ||
pageSize: 30, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这几个地方都加注释的话,是否能 IDE 提示? |
||
serverUrl: 'https://hacker-news.firebaseio.com/v0', | ||
}, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const info = { | ||
msg: 'hello', | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default { | ||
info: { | ||
msg: 'hello', | ||
}, | ||
}; |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { EggAppConfig } from 'egg'; | ||
import defaultConfig from './config.default'; | ||
import * as localConfig from './config.local'; | ||
import prodConfig from './config.prod'; | ||
|
||
type DefaultConfig = ReturnType<typeof defaultConfig>; | ||
type LocalConfig = typeof localConfig; | ||
type ProdConfig = typeof prodConfig; | ||
type NewAppConfig = EggAppConfig & DefaultConfig & LocalConfig & ProdConfig; | ||
|
||
declare module 'egg' { | ||
interface Application { | ||
config: NewAppConfig; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,15 @@ | |
"version": "1.0.0", | ||
"description": "hackernews showcase using async/await for egg", | ||
"private": true, | ||
"egg": { | ||
"typescript": true | ||
}, | ||
"dependencies": { | ||
"egg": "^2.0.0", | ||
"egg-view-nunjucks": "^2.1.4", | ||
"moment": "^2.19.4", | ||
"source-map-support": "^0.5.0", | ||
"tslib": "^1.8.1", | ||
"typescript": "^2.6.2" | ||
"egg": "^2.5.0", | ||
"egg-scripts": "^2.5.1", | ||
"egg-view-nunjucks": "^2.2.0", | ||
"moment": "^2.21.0", | ||
"source-map-support": "^0.5.4" | ||
}, | ||
"devDependencies": { | ||
"@types/cheerio": "^0.22.1", | ||
|
@@ -19,25 +21,32 @@ | |
"autod": "^3.0.1", | ||
"autod-egg": "^1.1.0", | ||
"cheerio": "^1.0.0-rc.2", | ||
"egg-bin": "^4.3.7", | ||
"egg-mock": "^3.14.0", | ||
"egg-bin": "^4.6.0", | ||
"egg-mock": "^3.16.0", | ||
"egg-ts-helper": "^1.1.3", | ||
"eslint": "^4.19.1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eslint 干掉 |
||
"eslint-config-egg": "^7.0.0", | ||
"eslint-plugin-typescript": "^0.11.0", | ||
"rimraf": "^2.6.1", | ||
"tslint": "^4.0.0" | ||
"tslib": "^1.8.1", | ||
"tslint": "^4.0.0", | ||
"typescript": "^2.6.2", | ||
"typescript-eslint-parser": "^14.0.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 干掉 |
||
}, | ||
"engines": { | ||
"node": ">=8.9.0" | ||
}, | ||
"scripts": { | ||
"clean": "rimraf app/**/*.{js,map} test/**/*.{js,map} config/**/*.{js,map}", | ||
"tsc": "tsc -p tsconfig.json", | ||
"tsc:w": "tsc -p tsconfig.json -w", | ||
"debug": "egg-bin debug", | ||
"dev": "egg-bin dev", | ||
"test": "npm run tsc && npm run test-local", | ||
"test-local": "egg-bin test", | ||
"start": "egg-scripts start", | ||
"dev": "egg-bin dev -r 'egg-ts-helper/register'", | ||
"tsc": "ets && tsc -p tsconfig.json", | ||
"clean": "rimraf ./app.js ./agent.js ./{app,test,config}/**/*.{js,map}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 换为 |
||
"test": "npm run lint -- --fix && npm run test-local", | ||
"test-local": "egg-bin test -r 'egg-ts-helper/register'", | ||
"cov": "egg-bin cov", | ||
"lint": "tslint .", | ||
"ci": "npm run lint && npm run cov", | ||
"debug": "egg-bin debug", | ||
"autod": "autod" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个干掉, eslint 也干掉,先保持 tslint 吧