From 7ef564a6c1be484d8e3ba84429ed79423b9c4c2a Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 21 Jun 2017 20:24:44 +0900 Subject: [PATCH] Project is created. --- config/webpack/webpack.config.base.js | 46 ++++++++++++ config/webpack/webpack.config.dev.js | 72 ++++++++++++++++++ config/webpack/webpack.config.prod.js | 71 ++++++++++++++++++ config/webpack/webpack.config.stats.js | 32 ++++++++ package.json | 91 +++++++++++++++++++++++ public/index.html | 10 +++ src/ts/index.tsx | 7 ++ src/ts/member/api/model/Member.ts | 12 +++ src/ts/member/api/model/MemberStatus.ts | 6 ++ src/ts/member/redux/actions.ts | 25 +++++++ tsconfig.json | 35 +++++++++ tslint.json | 98 +++++++++++++++++++++++++ 12 files changed, 505 insertions(+) create mode 100644 config/webpack/webpack.config.base.js create mode 100644 config/webpack/webpack.config.dev.js create mode 100644 config/webpack/webpack.config.prod.js create mode 100644 config/webpack/webpack.config.stats.js create mode 100644 package.json create mode 100644 public/index.html create mode 100644 src/ts/index.tsx create mode 100644 src/ts/member/api/model/Member.ts create mode 100644 src/ts/member/api/model/MemberStatus.ts create mode 100644 src/ts/member/redux/actions.ts create mode 100644 tsconfig.json create mode 100644 tslint.json diff --git a/config/webpack/webpack.config.base.js b/config/webpack/webpack.config.base.js new file mode 100644 index 0000000..d6d7e84 --- /dev/null +++ b/config/webpack/webpack.config.base.js @@ -0,0 +1,46 @@ +const Path = require('path'); +const TsConfigPathsPlugin = require('awesome-typescript-loader').TsConfigPathsPlugin; +const packages = require('../../package.json'); + +module.exports = { + target: 'web', + entry: { + app: [ + Path.resolve(__dirname, '../../src/ts/index.tsx') + ], + vendor: Object.keys(packages.dependencies) + }, + + output: { + path: Path.resolve(__dirname, '../../dist'), + filename: '[name].js', + publicPath: '/' + }, + + devtool: '', + + resolve: { + extensions: ['.ts', '.tsx', '.js', '.json'], + plugins: [ + new TsConfigPathsPlugin({ + tsconfig: "tsconfig.json", + compiler: "typescript" + }) + ] + }, + + module: { + rules: [ + { + test: /\.tsx?$/, + enforce: 'pre', + exclude: [ + Path.resolve(__dirname, '../../node_modules/') + ], + loader: 'tslint-loader', + } + ] + }, + plugins: [ + ] +}; diff --git a/config/webpack/webpack.config.dev.js b/config/webpack/webpack.config.dev.js new file mode 100644 index 0000000..07484d4 --- /dev/null +++ b/config/webpack/webpack.config.dev.js @@ -0,0 +1,72 @@ +const Path = require('path'); +const Webpack = require('webpack'); +const WebpackMerge = require('webpack-merge'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const configBase = require('./webpack.config.base.js'); + +module.exports = WebpackMerge(configBase, { + entry: { + app: [ + ] + }, + + devtool: 'inline-source-map', + + devServer: { + hot: true, + inline: true, + historyApiFallback: true, + publicPath: '/', // match the output `publicPath` + host: '127.0.0.1', + port: 9091, + stats: { + colors: true + }, + }, + + module: { + rules: [ + { + enforce: 'pre', + test: /\.js$/, + loader: 'source-map-loader', + exclude: [ + Path.resolve(__dirname, '../../node_modules/') + ] + }, + { + enforce: 'pre', + test: /\.tsx?$/, + use: "source-map-loader", + exclude: [ + Path.resolve(__dirname, '../../node_modules/') + ] + }, + { + test: /\.tsx?$/, + loaders: [ + 'awesome-typescript-loader' + ], + exclude: [ + Path.resolve(__dirname, '../../node_modules/') + ], + include: [ + Path.resolve(__dirname, '../../src/') + ] + }, + ] + }, + plugins: [ + new Webpack.HotModuleReplacementPlugin(), + new Webpack.NamedModulesPlugin(), + new Webpack.NoEmitOnErrorsPlugin(), + new HtmlWebpackPlugin({ + template: Path.resolve(__dirname, '../../public/index.html') + }), + new Webpack.optimize.CommonsChunkPlugin({ + name: 'vendor', + minChunks: Infinity, + filename: 'vendor.js' + }), + ] +}); diff --git a/config/webpack/webpack.config.prod.js b/config/webpack/webpack.config.prod.js new file mode 100644 index 0000000..66fd666 --- /dev/null +++ b/config/webpack/webpack.config.prod.js @@ -0,0 +1,71 @@ +const Path = require('path'); +const Webpack = require('webpack'); +const WebpackMerge = require('webpack-merge'); +const configBase = require('./webpack.config.base.js'); + + +module.exports = WebpackMerge(configBase, { + devtool: 'source-map', + + module: { + rules: [ + { + enforce: 'pre', + test: /\.js$/, + loader: 'source-map-loader', + exclude: [ + Path.resolve(__dirname, '../../node_modules/') + ] + }, + { + test: /\.tsx?$/, + loader: 'awesome-typescript-loader', + exclude: [ + Path.resolve(__dirname, '../../node_modules/') + ] + }, + ] + }, + plugins: [ + new Webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify('production') + }, + 'DEBUG': false, + '__DEVTOOLS__': false + }), + // Plugings for optimizing size and performance. + // Here you have all the available by now: + // Webpack 1. https://github.com/webpack/webpack/blob/v1.13.3/lib/optimize + // Webpack 2. https://github.com/webpack/webpack/tree/master/lib/optimize + new Webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false, + screw_ie8: true, + conditionals: true, + unused: true, + comparisons: true, + sequences: true, + dead_code: true, + evaluate: true, + if_return: true, + join_vars: true, + drop_console: true, + drop_debugger: true, + global_defs: { + __REACT_HOT_LOADER__: undefined // eslint-disable-line no-undefined + } + }, + minimize: true, + debug: false, + sourceMap: true, + output: { + comments: false + }, + + }), + // Included by default in webpack 2 + // new webpack.optimize.OccurrenceOrderPlugin(), + new Webpack.optimize.AggressiveMergingPlugin() + ] +}); diff --git a/config/webpack/webpack.config.stats.js b/config/webpack/webpack.config.stats.js new file mode 100644 index 0000000..6f894b6 --- /dev/null +++ b/config/webpack/webpack.config.stats.js @@ -0,0 +1,32 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// WebPack 2 STATS Config +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +// REMEMBER UPLOAD YOUR stats.json to http://webpack.github.io/analyse/ +// IMPORTANT. If you use console.log in this file, the stats.json will not work... +// TODO. Include fileDateTime in stats.json as well. +// +/////////////////////////////////////////////////////////////////////////////////////////////////// + +const Visualizer = require('webpack-visualizer-plugin'); +const WebpackMerge = require('webpack-merge'); + +//////////////////////////////////////////////// +// File name for Visualizer +//////////////////////////////////////////////// +const currentDateTime = new Date(); +const currentDate = currentDateTime.toLocaleDateString('en-GB').replace(/\//g, "-"); +const currentTime = currentDateTime.toLocaleTimeString('en-GB', { hour12: false }).replace(/:/g, "-"); +const fileDateTime = currentDate + "-" + currentTime; +const statisticsFileName = './stats/statistics-' + fileDateTime + '.html'; +const configBase = require('./webpack.config.prod.js'); + + +module.exports = WebpackMerge(configBase, { + plugins: [ + new Visualizer({ + filename: statisticsFileName + }) + ] +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..a900cc7 --- /dev/null +++ b/package.json @@ -0,0 +1,91 @@ +{ + "name": "hello", + "version": "1.0.0", + "description": "Node Hello Project", + "main": "index.js", + "repository": "https://git.loafle.net/prototype/hello.git", + "author": "LOAFLE (rnd@loafle.com)", + "license": "MIT", + "scripts": { + "clean": "./node_modules/.bin/rimraf ./dist", + "prepublish": "yarn run build", + "postpublish": "./node_modules/.bin/greenkeeper-postpublish", + "start": "set NODE_ENV=development && ./node_modules/.bin/webpack-dev-server --open --progress --config ./config/webpack/webpack.config.dev.js", + "test": "yarn run jest", + "test:watch": "yarn run jest -- --watch", + "jest": "PWD=$(pwd) NODE_ENV=test ./node_modules/.bin/jest -w 1 --coverage", + "prebuild": "./node_modules/.bin/check-dependencies && yarn run clean", + "build": "set NODE_ENV=production && ./node_modules/.bin/webpack --progress -profile --colors --config ./config/webpack/webpack.config.prod.js", + "lint": "./node_modules/.bin/tslint -c tslint.json 'src/ts/**/*.{ts,tsx}' && ./node_modules/.bin/sass-lint 'src/**/*.scss'", + "stats": "set NODE_ENV=production && webpack --progress --config ./config/webpack/webpack.config.stats.js --profile --json > ./config/webpack/stats/stats.json" + }, + "devDependencies": { + "@types/jest": "^19.2.4", + "@types/material-ui": "^0.17.11", + "@types/prop-types": "^15.5.1", + "@types/react": "^15.0.24", + "@types/react-addons-test-utils": "^0.14.18", + "@types/react-dom": "^15.5.0", + "@types/react-redux": "4.4.40", + "@types/react-router": "^4.0.9", + "@types/react-router-dom": "^4.0.4", + "@types/react-tap-event-plugin": "^0.0.30", + "@types/redux": "^3.6.0", + "awesome-typescript-loader": "^3.1.3", + "check-dependencies": "^1.0.1", + "copy-webpack-plugin": "^4.0.1", + "css-loader": "^0.28.2", + "extract-text-webpack-plugin": "^2.1.0", + "file-loader": "^0.11.1", + "greenkeeper-postpublish": "^1.0.1", + "html-webpack-plugin": "^2.28.0", + "image-webpack-loader": "^3.3.1", + "jest": "^20.0.4", + "node-sass": "^4.5.3", + "postcss-import": "^10.0.0", + "postcss-loader": "^2.0.5", + "raw-loader": "^0.5.1", + "react-addons-test-utils": "^15.5.1", + "rimraf": "^2.6.1", + "sass-lint": "^1.10.2", + "sass-loader": "^6.0.5", + "source-map-loader": "^0.2.1", + "style-loader": "^0.18.1", + "tslint": "^5.4.3", + "tslint-loader": "^3.5.3", + "tslint-react": "^3.0.0", + "typescript": "^2.3.3", + "webpack": "^2.6.0", + "webpack-dev-server": "^2.4.5", + "webpack-merge": "^4.1.0", + "webpack-visualizer-plugin": "^0.1.11" + }, + "dependencies": { + "immutable": "^3.8.1", + "material-ui": "^0.18.3", + "prop-types":"^15.5.10", + "react": "^15.5.4", + "react-dom": "15.5.4", + "react-immutable-proptypes": "^2.1.0", + "react-redux": "^5.0.5", + "react-router": "^4.1.1", + "react-router-dom": "^4.1.1", + "react-tap-event-plugin": "^2.0.1", + "redux": "^3.6.0", + "redux-actions": "^2.0.3", + "redux-saga": "^0.15.3", + "reselect": "^3.0.1" + }, + + "jest": { + "moduleFileExtensions": [ + "ts", + "tsx", + "js" + ], + "transform": { + "\\.(ts|tsx)$": "/node_modules/ts-jest/preprocessor.js" + }, + "testRegex": "\\./src/ts/(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$" + } +} diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..6aa6c39 --- /dev/null +++ b/public/index.html @@ -0,0 +1,10 @@ + + + + + Hello React! + + +
+ + diff --git a/src/ts/index.tsx b/src/ts/index.tsx new file mode 100644 index 0000000..74cb9cc --- /dev/null +++ b/src/ts/index.tsx @@ -0,0 +1,7 @@ +class Starter { + public static main(): void { + console.log('Hello world.'); + } +} + +Starter.main(); diff --git a/src/ts/member/api/model/Member.ts b/src/ts/member/api/model/Member.ts new file mode 100644 index 0000000..eae7b82 --- /dev/null +++ b/src/ts/member/api/model/Member.ts @@ -0,0 +1,12 @@ +import {MemberStatus} from './MemberStatus'; + + +export interface Member { + id: number; + email: string; + name: string; + phone: string; + companyName: string; + createDate: Date; + status: MemberStatus; +} \ No newline at end of file diff --git a/src/ts/member/api/model/MemberStatus.ts b/src/ts/member/api/model/MemberStatus.ts new file mode 100644 index 0000000..a841669 --- /dev/null +++ b/src/ts/member/api/model/MemberStatus.ts @@ -0,0 +1,6 @@ +export enum MemberStatus { + NOAUTH = 1, + NORMAL = 2, + DORMANCY = 3, + WITHDRAWAL = 4 +} \ No newline at end of file diff --git a/src/ts/member/redux/actions.ts b/src/ts/member/redux/actions.ts new file mode 100644 index 0000000..1e7ec26 --- /dev/null +++ b/src/ts/member/redux/actions.ts @@ -0,0 +1,25 @@ +import { Member } from 'member/api/model/Member'; + +export type REGIST = '@overflow/member/regist/REGIST'; +export const REGIST: REGIST = '@overflow/member/regist/REGIST'; + +export type RegistAction = { + type: REGIST, + by: Member +}; + +function counterReducer(state = INITIAL_STATE, action:CounterAction = OtherAction) { + switch (action.type) { + case INCREMENT_COUNTER: + return state.update({value: state.value + action.by}); + + case DECREMENT_COUNTER: + return state.update({value: state.value - action.by}); + + case LOGOUT_USER: + return INITIAL_STATE; + + default: + return state; + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..b8f2005 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,35 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "baseUrl": "src/ts", + "declaration": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "jsx": "react", + "lib": [ + "dom", + "es5", + "es6" + ], + "module": "commonjs", + "moduleResolution": "node", + "newLine": "LF", + "noImplicitAny": false, + "noImplicitThis": false, + "outDir": "dist/ts/", + "preserveConstEnums": true, + "pretty": true, + "removeComments": true, + "sourceMap": true, + "target": "es5" + }, + "include": [ + "src/ts/**/*" + ], + "exclude": [ + "build", + "config", + "node_modules", + "public" + ] +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..095a286 --- /dev/null +++ b/tslint.json @@ -0,0 +1,98 @@ +{ + "rules": { + "align": [true, + "parameters", + "arguments", + "statements"], + "ban": false, + "class-name": true, + "comment-format": [true, + "check-space" + ], + "curly": true, + "eofline": true, + "forin": true, + "indent": [true, 2, "spaces"], + "interface-name": [true], + "jsdoc-format": true, + "label-position": true, + "max-line-length": [true, 140], + "member-access": true, + "member-ordering": [ + true, + { + "order": [ + "static-field", + "instance-field", + "constructor", + "public-instance-method", + "protected-instance-method", + "private-instance-method" + ] + } + ], + "no-any": false, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-console": [true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-shadowed-variable": true, + "no-duplicate-variable": true, + "no-empty": true, + "no-eval": true, + "no-inferrable-types": [false], + "no-internal-module": true, + "no-require-imports": false, + "no-string-literal": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unused-expression": true, + "no-unused-variable": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "no-var-requires": true, + "object-literal-sort-keys": false, + "one-line": [true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [true, "single", "avoid-escape"], + "radix": true, + "semicolon": [true, "always"], + "switch-default": true, + "trailing-comma": [true, { + "multiline": "always", + "singleline": "never" + }], + "triple-equals": [true, "allow-null-check"], + "typedef": [true, + "call-signature", + "parameter", + "property-declaration", + "member-variable-declaration" + ], + "typedef-whitespace": [true, { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }], + "variable-name": false, + "whitespace": [true, + "check-decl", + "check-operator", + "check-separator" + ] + } +}