Skip to content

Commit

Permalink
first submit
Browse files Browse the repository at this point in the history
  • Loading branch information
Bosn committed Nov 23, 2017
0 parents commit 2d1c7dd
Show file tree
Hide file tree
Showing 154 changed files with 9,970 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# css
src/**/*.css

# compile files
build
77 changes: 77 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details

"maxerr" : 50, // {int} Maximum error before stopping

// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : false, // true: Require {} for every new block or scope
"eqeqeq" : true, // true: Require triple equals (===) for comparison
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
"freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
"immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
"latedef" : false, // true: Require variables/functions to be defined before being used
"newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()`
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
"noempty" : true, // true: Prohibit use of empty blocks
"nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters.
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
"plusplus" : false, // true: Prohibit use of `++` and `--`
"quotmark" : false, // Quotation mark consistency:
// false : do nothing (default)
// true : ensure whatever is used is consistent
// "single" : require single quotes
// "double" : require double quotes
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
"unused" : true, // Unused variables:
// true : all variables, last function parameter
// "vars" : all variables only
// "strict" : all variables, all function parameters
"strict" : true, // true: Requires all functions run in ES5 Strict Mode
"maxparams" : false, // {int} Max number of formal params allowed per function
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
"maxstatements" : false, // {int} Max number statements per function
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
"maxlen" : false, // {int} Max number of characters per line
"varstmt" : false, // true: Disallow any var statements. Only `let` and `const` are allowed.

// Relaxing
"asi" : true, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
"boss" : false, // true: Tolerate assignments where comparisons would be expected
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // true: Tolerate use of `== null`
"esversion" : 6, // {int} Specify the ECMAScript version to which the code must adhere.
"moz" : true, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
"esnext" : true,
// (ex: `for each`, multiple try/catch, function expression…)
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
"expr" : true, // true: Tolerate `ExpressionStatement` as Programs
"funcscope" : false, // true: Tolerate defining variables inside control statements
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
"iterator" : false, // true: Tolerate using the `__iterator__` property
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
"laxcomma" : false, // true: Tolerate comma-first style coding
"loopfunc" : false, // true: Tolerate functions being defined in loops
"multistr" : false, // true: Tolerate multi-line strings
"noyield" : false, // true: Tolerate generator functions with no yield statement in them.
"notypeof" : false, // true: Tolerate invalid typeof operator values
"proto" : false, // true: Tolerate using the `__proto__` property
"scripturl" : false, // true: Tolerate script-targeted URLs
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
"validthis" : false, // true: Tolerate using this in a non-constructor function

// Environments
"devel" : true, // Development/debugging (alert, confirm, etc)
"jquery" : true, // jQuery
"node" : true, // Node.js
"browser" : true, // Browser


// Custom Globals
"globals" : {} // additional predefined global variables
}
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: node_js

cache:
directories:
- node_modules
- $HOME/.npm

notifications:
email: false
t
node_js:
- '8'

before_install:
- npm i -g npm@^5.5.1

script:
- npm run build
- npm run test

after_success:
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# rap2-dolores

[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

RPA2 前端。

http://rap2.taobao.org/

## 本地开发

```
npm run dev
```
29 changes: 29 additions & 0 deletions dispatch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
process.env.NODE_ENV = 'production'

// https://nodejs.org/api/cluster.html
// https://github.com/node-modules/graceful/blob/master/example/express_with_cluster/dispatch.js
// http://gitlab.alibaba-inc.com/mm/fb/blob/master/dispatch.js

let cluster = require('cluster')
let path = require('path')
let now = () => new Date().toISOString().replace(/T/, ' ').replace(/Z/, '')

cluster.setupMaster({
exec: path.join(__dirname, 'scripts/worker.js')
})

if (cluster.isMaster) {
require('os').cpus().forEach((cpu, index) => {
cluster.fork()
})
cluster.on('listening', (worker, address) => {
console.error(`[${now()}] master#${process.pid} worker#${worker.process.pid} is now connected to ${address.address}:${address.port}.`)
})
cluster.on('disconnect', (worker) => {
console.error(`[${now()}] master#${process.pid} worker#${worker.process.pid} has disconnected.`)
})
cluster.on('exit', (worker, code, signal) => {
console.error(`[${now()}] master#${process.pid} worker#${worker.process.pid} died (${signal || code}). restarting...`)
cluster.fork()
})
}
75 changes: 75 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "rap2-dolores",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"dev": "npm run start",
"build-css": "node-sass src/ -o src/",
"watch-css": "npm run build-css && node-sass src/ -o src/ --watch --recursive",
"start-js": "react-scripts start",
"start": "npm-run-all -p watch-css start-js",
"build": "npm run build-css && react-scripts build",
"test-backup": "npm run linter && react-scripts test --env=jsdom",
"test": "npm run linter",
"eject": "react-scripts eject",
"linter": "standard --fix"
},
"repository": {
"type": "git",
"url": "[email protected]:thx/rap2-dolores.git"
},
"author": "[email protected]",
"license": "ISC",
"dependencies": {
"animate.css": "3.5.2",
"bootstrap": "^4.0.0-beta.2",
"chart.js": "^2.6.0",
"codemirror": "5.27.2",
"graceful": "1.0.1",
"koa": "2.3.0",
"koa-router": "7.2.1",
"koa-session": "5.3.0",
"koa-static": "3.0.0",
"lodash": "4.17.4",
"mockjs": "1.0.1-beta3",
"moment": "2.18.1",
"node-fetch": "1.7.1",
"nprogress": "0.2.0",
"parsleyjs": "^2.7.2",
"prop-types": "15.5.10",
"react": "15.6.1",
"react-dom": "15.6.1",
"react-icons": "2.2.5",
"react-modal": "2.1.0",
"react-redux": "5.0.5",
"react-router": "4.1.1",
"react-router-config": "1.0.0-beta.3",
"react-router-dom": "4.1.1",
"react-router-redux": "5.0.0-alpha.6",
"redux": "3.7.1",
"redux-saga": "0.15.4",
"sortablejs": "1.6.0",
"urijs": "1.18.10"
},
"standard": {
"parser": "babel-eslint",
"globals": [
"fetch"
],
"ignore": [
"/build"
]
},
"engines": {
"install-node": "9.2.0"
},
"devDependencies": {
"babel-eslint": "7.2.3",
"node-sass": "4.5.3",
"npm-run-all": "4.0.2",
"pre-commit": "1.2.2",
"react-scripts": "0.9.5",
"standard": "10.0.2"
}
}
Binary file added public/favicon.ico
Binary file not shown.
Binary file added public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.png">
<!--
Notice the use of %PUBLIC_URL% in the tag above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>RAP2 Delores</title>
</head>
<body>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start`.
To create a production bundle, use `npm run build`.
-->
</body>
</html>
6 changes: 6 additions & 0 deletions rap2-dolores.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 1. 你可以直接编辑本文件的内容,或者通过工具来帮你校验合法性和自动生成,请点击:http://aliwing.alibaba-inc.com/apprelease/home.htm
# 2. 更多关于Release文件的规范和约定,请点击: http://docs.alibaba-inc.com/pages/viewpage.action?pageId=252891532

# 构建源码语言类型
code.language=nodejs

69 changes: 69 additions & 0 deletions scripts/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const fs = require('fs')
const Koa = require('koa')
const serve = require('koa-static')
const Router = require('koa-router')
const session = require('koa-session')
const config = require('../src/config')
const app = new Koa()

app.keys = config.keys
app.use(session(config.session, app))

app.use(async (ctx, next) => {
const start = new Date()
await next()
const ms = new Date() - start
console.log(`${ctx.method} ${ctx.url} - ${ms}ms`)
})

app.use(async (ctx, next) => {
await next()
if (ctx.response.body && ctx.response.body.url) {
ctx.response.body = JSON.stringify(ctx.response.body, null, 4)
}
})

app.use(serve('build'))

let router = new Router()

router.get('/check.node', (ctx) => {
ctx.body = 'success'
})

router.get('/status.taobao', (ctx) => {
ctx.body = 'success'
})

router.get('/test/test.status', (ctx) => {
ctx.body = 'success'
})

router.get('/env', (ctx, next) => {
ctx.body = process.env.NODE_ENV
})

router.get('/delos', (ctx, next) => {
ctx.body = process.env.RAP2_DELOS
})

router.get('/account/info', (ctx) => {
ctx.body = {
url: ctx.request.url,
data: ctx.session.id ? {
id: ctx.session.id,
empId: ctx.session.empId,
fullname: ctx.session.fullname,
email: ctx.session.email
} : undefined
}
})

router.get('/*', (ctx) => {
ctx.type = 'html'
ctx.body = fs.createReadStream('build/index.html')
})

app.use(router.routes())

module.exports = app
Loading

0 comments on commit 2d1c7dd

Please sign in to comment.