diff --git a/.babelrc b/.babelrc index 6d98894..b2e6ac8 100644 --- a/.babelrc +++ b/.babelrc @@ -1,17 +1,17 @@ { - "presets": [ - ["@babel/preset-env", {"modules": false}], - "@babel/preset-react" - ], - "plugins": [ - "react-hot-loader/babel" - ], - "env": { - "production": { - "presets": ["minify"] - }, - "test": { - "presets": ["@babel/preset-env", "@babel/preset-react"] + "presets": [ + ["@babel/preset-env", {"modules": false}], + "@babel/preset-react" + ], + "plugins": [ + "react-hot-loader/babel" + ], + "env": { + "production": { + "presets": ["minify"] + }, + "test": { + "presets": ["@babel/preset-env", "@babel/preset-react"] + } } - } } diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2536d66 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 4 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.stylelintrc b/.stylelintrc index 40db42c..7cad7a1 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -1,3 +1,3 @@ { - "extends": "stylelint-config-standard" + "extends": "stylelint-config-standard" } diff --git a/.travis.yml b/.travis.yml index 48e0236..7ef0195 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,22 @@ language: node_js sudo: false node_js: - - "stable" + - "stable" cache: - directories: - - "$HOME/.npm" + directories: + - "$HOME/.npm" install: - - "npm ci" + - "npm ci" script: - - "npm run lint" + - "npm run lint" before_deploy: - - "npm run build" + - "npm run build" deploy: - provider: pages - skip-cleanup: true - local-dir: dist - github-token: $GITHUB_TOKEN - on: - repo: Dreamacro/clash-dashboard - branch: master - tags: true + provider: pages + skip-cleanup: true + local-dir: dist + github-token: $GITHUB_TOKEN + on: + repo: Dreamacro/clash-dashboard + branch: master + tags: true diff --git a/LICENSE b/LICENSE index ab07f1c..33e498b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Dreamacro +Copyright (c) 2018 ClashTeam Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/README.md b/README.md index 7af122a..aeb67fc 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # clash-dashboard -web port of clash \ No newline at end of file +web port of clash diff --git a/configs/webpack/common.js b/configs/webpack/common.js index c6af746..67582d4 100644 --- a/configs/webpack/common.js +++ b/configs/webpack/common.js @@ -5,52 +5,52 @@ const StyleLintPlugin = require('stylelint-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin') module.exports = { - resolve: { - extensions: ['.ts', '.tsx', '.js', '.jsx'], - }, - context: resolve(__dirname, '../../src'), - module: { - rules: [ - { - test: /\.js$/, - use: ['babel-loader', 'source-map-loader'], - exclude: /node_modules/, - }, - { - test: /\.tsx?$/, - use: ['babel-loader', 'awesome-typescript-loader'], - }, - { - test: /\.css$/, - use: ['style-loader', { loader: 'css-loader', options: { importLoaders: 1 } }], - }, - { - test: /\.scss$/, - loaders: [ - 'style-loader', - { loader: 'css-loader', options: { importLoaders: 1 } }, - 'sass-loader', + resolve: { + extensions: ['.ts', '.tsx', '.js', '.jsx'], + }, + context: resolve(__dirname, '../../src'), + module: { + rules: [ + { + test: /\.js$/, + use: ['babel-loader', 'source-map-loader'], + exclude: /node_modules/, + }, + { + test: /\.tsx?$/, + use: ['babel-loader', 'awesome-typescript-loader'], + }, + { + test: /\.css$/, + use: ['style-loader', { loader: 'css-loader', options: { importLoaders: 1 } }], + }, + { + test: /\.scss$/, + loaders: [ + 'style-loader', + { loader: 'css-loader', options: { importLoaders: 1 } }, + 'sass-loader', + ], + }, + { + test: /\.(jpe?g|png|gif|svg)$/i, + loaders: [ + 'file-loader?hash=sha512&digest=hex&name=img/[hash].[ext]', + 'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false', + ], + }, ], - }, - { - test: /\.(jpe?g|png|gif|svg)$/i, - loaders: [ - 'file-loader?hash=sha512&digest=hex&name=img/[hash].[ext]', - 'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false', - ], - }, + }, + plugins: [ + new CheckerPlugin(), + new StyleLintPlugin(), + new HtmlWebpackPlugin({ template: 'index.html.ejs', }), ], - }, - plugins: [ - new CheckerPlugin(), - new StyleLintPlugin(), - new HtmlWebpackPlugin({ template: 'index.html.ejs', }), - ], - externals: { - 'react': 'React', - 'react-dom': 'ReactDOM', - }, - performance: { - hints: false, - }, + externals: { + 'react': 'React', + 'react-dom': 'ReactDOM', + }, + performance: { + hints: false, + }, } diff --git a/configs/webpack/dev.js b/configs/webpack/dev.js index 39b3bbf..5bc8727 100644 --- a/configs/webpack/dev.js +++ b/configs/webpack/dev.js @@ -4,19 +4,19 @@ const webpack = require('webpack') const commonConfig = require('./common') module.exports = merge(commonConfig, { - mode: 'development', - entry: [ - 'react-hot-loader/patch', // activate HMR for React - 'webpack-dev-server/client?http://localhost:8080',// bundle the client for webpack-dev-server and connect to the provided endpoint - 'webpack/hot/only-dev-server', // bundle the client for hot reloading, only- means to only hot reload for successful updates - './index.tsx' // the entry point of our app - ], - devServer: { - hot: true, // enable HMR on the server - }, - devtool: 'cheap-module-eval-source-map', - plugins: [ - new webpack.HotModuleReplacementPlugin(), // enable HMR globally - new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates - ], + mode: 'development', + entry: [ + 'react-hot-loader/patch', // activate HMR for React + 'webpack-dev-server/client?http://localhost:8080',// bundle the client for webpack-dev-server and connect to the provided endpoint + 'webpack/hot/only-dev-server', // bundle the client for hot reloading, only- means to only hot reload for successful updates + './index.tsx' // the entry point of our app + ], + devServer: { + hot: true, // enable HMR on the server + }, + devtool: 'cheap-module-eval-source-map', + plugins: [ + new webpack.HotModuleReplacementPlugin(), // enable HMR globally + new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates + ], }) diff --git a/configs/webpack/prod.js b/configs/webpack/prod.js index 85cf9a3..3e6e069 100644 --- a/configs/webpack/prod.js +++ b/configs/webpack/prod.js @@ -5,13 +5,13 @@ const { resolve } = require('path') const commonConfig = require('./common') module.exports = merge(commonConfig, { - mode: 'production', - entry: './index.tsx', - output: { - filename: 'js/bundle.[hash].min.js', - path: resolve(__dirname, '../../dist'), - publicPath: '/', - }, - devtool: 'source-map', - plugins: [], + mode: 'production', + entry: './index.tsx', + output: { + filename: 'js/bundle.[hash].min.js', + path: resolve(__dirname, '../../dist'), + publicPath: '/', + }, + devtool: 'source-map', + plugins: [], }) diff --git a/express.js b/express.js index 4713722..d600106 100644 --- a/express.js +++ b/express.js @@ -6,6 +6,6 @@ const sourceDir = 'dist' app.use(express.static(sourceDir)) app.listen(portNumber, () => { - console.log(`Express web server started: http://localhost:${portNumber}`) - console.log(`Serving content from /${sourceDir}/`) + console.log(`Express web server started: http://localhost:${portNumber}`) + console.log(`Serving content from /${sourceDir}/`) }) diff --git a/package.json b/package.json index b3fe2fe..83f5a8d 100644 --- a/package.json +++ b/package.json @@ -1,65 +1,65 @@ { - "name": "clash-dashboard", - "version": "0.1.0", - "description": "Web port of clash.", - "keywords": [ - "clash", - "dashboard" - ], - "author": "Dreamacro", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/Dreamacro/clash-dashboard.git" - }, - "bugs": { - "url": "https://github.com/Dreamacro/clash-dashboard/issues" - }, - "homepage": "https://github.com/Dreamacro/clash-dashboard", - "scripts": { - "build": "npm run clean-dist && webpack -p --config=configs/webpack/prod.js", - "clean-dist": "rm -f -r -d dist", - "lint": "npm run lint:ts && npm run lint:sass", - "lint:ts": "tslint './src/**/*.ts*' --format stylish --force", - "lint:sass": "stylelint ./src/**/*.scss", - "start": "npm run start-dev", - "start-dev": "webpack-dev-server --config=configs/webpack/dev.js", - "start-prod": "npm run build && node express.js" - }, - "devDependencies": { - "@babel/cli": "^7.0.0", - "@babel/core": "^7.0.0", - "@babel/preset-env": "^7.0.0", - "@babel/preset-react": "^7.0.0", - "@types/node": "^10.7.1", - "@types/react": "^16.4.11", - "@types/react-dom": "^16.0.7", - "awesome-typescript-loader": "^5.2.0", - "babel-loader": "^8.0.0", - "css-loader": "^1.0.0", - "express": "^4.16.3", - "file-loader": "^2.0.0", - "html-webpack-plugin": "^3.2.0", - "image-webpack-loader": "^4.3.1", - "node-sass": "^4.9.3", - "react": "^16.4.2", - "react-addons-test-utils": "^15.6.2", - "react-dom": "^16.4.2", - "react-hot-loader": "^4.3.4", - "sass-loader": "^7.1.0", - "style-loader": "^0.23.0", - "stylelint": "^9.5.0", - "stylelint-config-standard": "^18.2.0", - "stylelint-webpack-plugin": "^0.10.5", - "tslint": "^5.11.0", - "tslint-config-standard": "^7.1.0", - "typescript": "^3.0.1", - "uglifyjs-webpack-plugin": "^1.3.0", - "webpack": "^4.17.1", - "webpack-cli": "^3.1.0", - "webpack-dev-middleware": "^3.1.3", - "webpack-dev-server": "^3.1.5", - "webpack-merge": "^4.1.4" - }, - "dependencies": {} + "name": "clash-dashboard", + "version": "0.1.0", + "description": "Web port of clash.", + "keywords": [ + "clash", + "dashboard" + ], + "author": "Dreamacro", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/Dreamacro/clash-dashboard.git" + }, + "bugs": { + "url": "https://github.com/Dreamacro/clash-dashboard/issues" + }, + "homepage": "https://github.com/Dreamacro/clash-dashboard", + "scripts": { + "build": "npm run clean-dist && webpack -p --config=configs/webpack/prod.js", + "clean-dist": "rm -f -r -d dist", + "lint": "npm run lint:ts && npm run lint:sass", + "lint:ts": "tslint './src/**/*.ts*' --format stylish --force", + "lint:sass": "stylelint ./src/**/*.scss", + "start": "npm run start-dev", + "start-dev": "webpack-dev-server --config=configs/webpack/dev.js", + "start-prod": "npm run build && node express.js" + }, + "devDependencies": { + "@babel/cli": "^7.0.0", + "@babel/core": "^7.0.0", + "@babel/preset-env": "^7.0.0", + "@babel/preset-react": "^7.0.0", + "@types/node": "^10.7.1", + "@types/react": "^16.4.11", + "@types/react-dom": "^16.0.7", + "awesome-typescript-loader": "^5.2.0", + "babel-loader": "^8.0.0", + "css-loader": "^1.0.0", + "express": "^4.16.3", + "file-loader": "^2.0.0", + "html-webpack-plugin": "^3.2.0", + "image-webpack-loader": "^4.3.1", + "node-sass": "^4.9.3", + "react": "^16.4.2", + "react-addons-test-utils": "^15.6.2", + "react-dom": "^16.4.2", + "react-hot-loader": "^4.3.4", + "sass-loader": "^7.1.0", + "style-loader": "^0.23.0", + "stylelint": "^9.5.0", + "stylelint-config-standard": "^18.2.0", + "stylelint-webpack-plugin": "^0.10.5", + "tslint": "^5.11.0", + "tslint-config-standard": "^7.1.0", + "typescript": "^3.0.1", + "uglifyjs-webpack-plugin": "^1.3.0", + "webpack": "^4.17.1", + "webpack-cli": "^3.1.0", + "webpack-dev-middleware": "^3.1.3", + "webpack-dev-server": "^3.1.5", + "webpack-merge": "^4.1.4" + }, + "dependencies": {} } diff --git a/src/assets/scss/App.scss b/src/assets/scss/App.scss index 5125954..30e42e1 100644 --- a/src/assets/scss/App.scss +++ b/src/assets/scss/App.scss @@ -2,11 +2,11 @@ $bg-color: yellow; $border-color: red; .app { - font-family: helvetica, arial, sans-serif; - padding: 2em; - border: 5px solid $border-color; + font-family: helvetica, arial, sans-serif; + padding: 2em; + border: 5px solid $border-color; - p { - background-color: $bg-color; - } + p { + background-color: $bg-color; + } } diff --git a/src/components/App.tsx b/src/components/App.tsx index 099b230..57d0442 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -5,12 +5,12 @@ export interface AppProps { } export default class App extends React.Component { - render () { - return ( -
-

Hello World!

-

Foo to the barz

-
- ) - } + render () { + return ( +
+

Hello World!

+

Foo to the barz

+
+ ) + } } diff --git a/src/index.tsx b/src/index.tsx index 6c4f1c5..5f24aa7 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -6,23 +6,23 @@ import App from './components/App' const rootEl = document.getElementById('root') render( - - - , - rootEl + + + , + rootEl ) // Hot Module Replacement API declare let module: { hot: any } if (module.hot) { - module.hot.accept('./components/App', () => { - const NewApp = require('./components/App').default - render( - - - , - rootEl - ) - }) + module.hot.accept('./components/App', () => { + const NewApp = require('./components/App').default + render( + + + , + rootEl + ) + }) } diff --git a/tslint.json b/tslint.json index 7967051..bead261 100644 --- a/tslint.json +++ b/tslint.json @@ -1,3 +1,8 @@ { - "extends": "tslint-config-standard" + "extends": "tslint-config-standard", + "rules": [ + { + "indent": [true, "spaces", 4] + } + ] } \ No newline at end of file