├── .babelrc ├── .eslintrc ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── cli.gif ├── dev.gif ├── package.json ├── src ├── .eslintrc ├── Mingify.js ├── cli.js ├── example │ ├── Display.js │ ├── Example.js │ └── logo.jpg └── index.js ├── test ├── .eslintrc └── index.js └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "react", "stage-0"] 3 | } 4 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "rules": { 4 | "quotes": 0, 5 | "no-trailing-spaces": 0, 6 | "eqeqeq": 0, 7 | "no-underscore-dangle": 0, 8 | "no-undef": 0, 9 | "no-extra-boolean-cast": 0, 10 | "no-mixed-spaces-and-tabs": 0, 11 | "no-alert": 0, 12 | "no-shadow": 0, 13 | "no-empty": 0, 14 | "no-irregular-whitespace": 0, 15 | "no-multi-spaces": 0, 16 | "no-new": 0, 17 | "no-unused-vars": 2, // disallow declaration of variables that are not used in the code 18 | "no-redeclare": 2, // disallow declaring the same variable more then once 19 | "new-cap": 0, 20 | // 21 | // eslint-plugin-react 22 | // 23 | // React specific linting rules for ESLint 24 | // 25 | //"react/display-name": 0, // Prevent missing displayName in a React component definition 26 | "react/jsx-boolean-value": [2, "always"], // Enforce boolean attributes notation in JSX 27 | "react/jsx-no-undef": 2, // Disallow undeclared variables in JSX 28 | "react/jsx-quotes": [2, "double", "avoid-escape"], // Enforce quote style for JSX attributes 29 | "react/jsx-sort-prop-types": 0, // Enforce propTypes declarations alphabetical sorting 30 | "react/jsx-sort-props": 0, // Enforce props alphabetical sorting 31 | "react/jsx-uses-react": 2, // Prevent React to be incorrectly marked as unused 32 | "react/jsx-uses-vars": 2, // Prevent variables used in JSX to be incorrectly marked as unused 33 | //"react/no-did-mount-set-state": 2, // Prevent usage of setState in componentDidMount 34 | "react/no-did-update-set-state": 2, // Prevent usage of setState in componentDidUpdate 35 | "react/no-multi-comp": 0, // Prevent multiple component definition per file 36 | "react/no-unknown-property": 2, // Prevent usage of unknown DOM property 37 | "react/prop-types": 2, // Prevent missing props validation in a React component definition 38 | "react/react-in-jsx-scope": 2, // Prevent missing React when using JSX 39 | "react/require-extension": [1, { "extensions": [".js"] }], // Restrict file extensions that may be required 40 | "react/self-closing-comp": 2, // Prevent extra closing tags for components without children 41 | "react/wrap-multilines": 2 // Prevent missing parentheses around multilines JSX 42 | }, 43 | "globals": { 44 | "jQuery": true, 45 | "$": true, 46 | "reveal": true, 47 | "Pikaday": true, 48 | "NProgress": true, 49 | "cytoscape": true 50 | }, 51 | "plugins": ["react"], 52 | "ecmaFeatures": { 53 | "arrowFunctions": true, 54 | "binaryLiterals": true, 55 | "blockBindings": true, 56 | "classes": true, 57 | "defaultParams": true, 58 | "destructuring": true, 59 | "forOf": true, 60 | "generators": true, 61 | "modules": true, 62 | "objectLiteralComputedProperties": true, 63 | "objectLiteralDuplicateProperties": true, 64 | "objectLiteralShorthandMethods": true, 65 | "objectLiteralShorthandProperties": true, 66 | "octalLiterals": true, 67 | "regexUFlag": true, 68 | "regexYFlag": true, 69 | "spread": true, 70 | "superInFunctions": true, 71 | "templateStrings": true, 72 | "unicodeCodePointEscapes": true, 73 | "globalReturn": true, 74 | "jsx": true 75 | }, 76 | "env": { 77 | "browser": true, 78 | "es6": true 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | /dist/ 11 | 12 | # Dependency directory 13 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 14 | node_modules 15 | 16 | # Precommit hook 17 | .jshint* 18 | 19 | /example/ 20 | .coveralls.yml 21 | /reports/ 22 | gulpfile.js 23 | 24 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - v5 4 | - v4 5 | - '0.12' 6 | - '0.10' 7 | after_script: 8 | - 'npm run coveralls' 9 | - 'npm run coveralls' 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Robert Chang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cht8687/help) 2 | 3 | ![mingify](src/example/logo.jpg) 4 | 5 |

6 | 7 | NPM Version 9 | 10 | 11 | 12 | Coverage Status 13 | 14 | 15 | 16 | Build Status 18 | 19 | 20 | 21 | Downloads 23 | 24 | 25 | 26 | Dependency Status 28 | 29 | 30 | 31 | License 33 | 34 |

35 | 36 |

37 | 38 |

39 | 40 | 41 | 一切起源: 42 | 43 | >[老实说我从来没用过JQUERY,正因为我反感JQUERY。 为什么我反感,因为我完全有开发JQUERY的能力,JQUERY的底层我都了如指掌。](https://github.com/drduan/minggeJS) 44 | >--- mingge 45 | 46 | 引擎(底层)贡献者: 47 | 48 | >[“我完全有开发明哥体生成器的能力,明哥体生成器的底层我都了如指掌”](https://github.com/drduan/minggeJS/issues/148) 49 | > --- jamesliu96 50 | 51 | ## 在线实例 52 | 53 | [http://cht8687.github.io/mingify/example/](http://cht8687.github.io/mingify/example/) 54 | 55 | ## 使用范例 56 | 57 | 如 `mingify("Angular")`返回 58 | 59 | ```js 60 | 老实说我从来没用过Angular,正因为我反感Angular。 为什么我反感,因为我完全有开发Angular的能力,Angular的底层我都了如指掌。 61 | 62 | 虽说我反感Angular,但是Angular却在测试界占有大量的用户份额,之后我有个想法,不如重新开发一个属于自己思想,自己架构的Angular。 63 | 64 | 我给了他一个霸气的名字:MingGeAngular, 65 | 66 | 它的名字叫MingGeAngular,MingGe就是我的大名, 一看到Angular名字,就知道作者是我,知道它是国产的,让别人知道国产Angular一样做得很出色,出众 67 | 68 | 我是mingge 请支持国产minggeAngular,因为我们都是中国人. 69 | ``` 70 | 71 | CLI 72 | 73 | ``` 74 | $ mingify Angular 75 | ``` 76 | 77 | ## 安装 78 | 79 | ### npm 80 | 81 | ``` 82 | $ npm install --save mingify 83 | ``` 84 | 85 | Or install CLI globally 86 | 87 | ``` 88 | $ npm install --global mingify 89 | ``` 90 | 91 | ![mingify](cli.gif) 92 | 93 | ###引用: 94 | 95 | ####ES5 96 | 97 | ```js 98 | var mingify = require('mingify'); 99 | 100 | var result = mingify("Angular"); 101 | ``` 102 | 103 | ####ES6 104 | 105 | ```js 106 | import mingify from 'mingify' 107 | 108 | const result = mingify("Angular"); 109 | ``` 110 | 111 | ## 如何克隆并开发 112 | 113 | ``` 114 | $ git clone git@github.com:cht8687/mingify.git 115 | $ cd mingify 116 | $ npm install 117 | $ webpack-dev-server 118 | ``` 119 | 120 | 然后 121 | 122 | ``` 123 | 打开 http://localhost:8080/webpack-dev-server/ 124 | ``` 125 | ![mingify](dev.gif) 126 | 127 | ## Demo项目使用技术 128 | 129 | 1. React 130 | 2. Webpack 131 | 3. Webpack-hot-reload 132 | 4. ES6 133 | 134 | 然而,在明哥面前,这些都没什么卵用。因为所有底层他都了如指掌。 135 | 136 | ## 贡献者 137 | 138 | * 主引擎,底层:[jamesliu96](https://github.com/jamesliu96) 139 | 140 | * Logo: [tianyuf](https://github.com/tianyuf) 141 | 142 | ## License 143 | 144 | MIT 145 | -------------------------------------------------------------------------------- /cli.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cht8687/mingify/4081c888b6b6137d71fb73f30df505a7e2bf2cd8/cli.gif -------------------------------------------------------------------------------- /dev.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cht8687/mingify/4081c888b6b6137d71fb73f30df505a7e2bf2cd8/dev.gif -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mingify", 3 | "version": "0.2.1", 4 | "description": "明哥体生成器", 5 | "main": "dist/index.js", 6 | "bin": "dist/cli.js", 7 | "scripts": { 8 | "prepublish": "parallelshell -w \"npm run build:dist -s\" \"npm run build:example -s\" \"npm run build:bower -s\"", 9 | "prebuild": "rimraf dist example build", 10 | "build:dist": "babel src --out-dir dist --source-maps --ignore src/example", 11 | "build:example": "webpack --config webpack.config.js", 12 | "postbuild": "npm run test -s", 13 | "test": "babel-node test/index.js | tnyan", 14 | "coverage": "babel-node node_modules/isparta/bin/isparta cover test/index.js", 15 | "coveralls": "npm run coverage -s && coveralls < coverage/lcov.info", 16 | "postcoveralls": "rimraf ./coverage" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/cht8687/mingify.git" 21 | }, 22 | "keywords": [ 23 | "minggejs", 24 | "mingify" 25 | ], 26 | "files": [ 27 | "dist" 28 | ], 29 | "author": "Robert Chang ", 30 | "license": "MIT", 31 | "bugs": { 32 | "url": "https://github.com/cht8687/mingify/issues" 33 | }, 34 | "homepage": "https://github.com/cht8687/mingify#readme", 35 | "devDependencies": { 36 | "babel-cli": "^6.3.17", 37 | "babel-core": "^6.3.26", 38 | "babel-eslint": "^5.0.0-beta6", 39 | "babel-loader": "^6.2.0", 40 | "babel-plugin-react-transform": "^2.0.0-beta1", 41 | "babel-plugin-transform-object-rest-spread": "^6.3.13", 42 | "babel-preset-es2015": "^6.3.13", 43 | "babel-preset-react": "^6.3.13", 44 | "babel-preset-stage-0": "^6.1.2", 45 | "coveralls": "^2.11.6", 46 | "eslint": "^1.3.1", 47 | "eslint-loader": "^1.0.0", 48 | "eslint-plugin-react": "^3.2.3", 49 | "html-webpack-plugin": "^1.6.1", 50 | "isparta": "^4.0.0", 51 | "parallelshell": "^2.0.0", 52 | "react": "^0.14", 53 | "react-dom": "^0.14.0", 54 | "react-hot-loader": "^1.2.9", 55 | "rimraf": "^2.4.3", 56 | "tap-nyan": "0.0.2", 57 | "tape": "^4.4.0", 58 | "webpack": "^1.11.0", 59 | "webpack-dev-server": "^1.10.1" 60 | }, 61 | "dependencies": { 62 | "chalk": "^1.1.1", 63 | "meow": "^3.6.0" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "rules": { 4 | "quotes": 0, 5 | "no-trailing-spaces": 0, 6 | "eqeqeq": 0, 7 | "no-underscore-dangle": 0, 8 | "no-undef": 0, 9 | "no-extra-boolean-cast": 0, 10 | "no-mixed-spaces-and-tabs": 0, 11 | "no-alert": 0, 12 | "no-shadow": 0, 13 | "no-empty": 0, 14 | "no-irregular-whitespace": 0, 15 | "no-multi-spaces": 0, 16 | "no-new": 0, 17 | "no-unused-vars": 2, // disallow declaration of variables that are not used in the code 18 | "no-redeclare": 2, // disallow declaring the same variable more then once 19 | "new-cap": 0, 20 | // 21 | // eslint-plugin-react 22 | // 23 | // React specific linting rules for ESLint 24 | // 25 | //"react/display-name": 0, // Prevent missing displayName in a React component definition 26 | "react/jsx-boolean-value": [2, "always"], // Enforce boolean attributes notation in JSX 27 | "react/jsx-no-undef": 2, // Disallow undeclared variables in JSX 28 | "react/jsx-quotes": [2, "double", "avoid-escape"], // Enforce quote style for JSX attributes 29 | "react/jsx-sort-prop-types": 0, // Enforce propTypes declarations alphabetical sorting 30 | "react/jsx-sort-props": 0, // Enforce props alphabetical sorting 31 | "react/jsx-uses-react": 2, // Prevent React to be incorrectly marked as unused 32 | "react/jsx-uses-vars": 2, // Prevent variables used in JSX to be incorrectly marked as unused 33 | //"react/no-did-mount-set-state": 2, // Prevent usage of setState in componentDidMount 34 | "react/no-did-update-set-state": 2, // Prevent usage of setState in componentDidUpdate 35 | "react/no-multi-comp": 0, // Prevent multiple component definition per file 36 | "react/no-unknown-property": 2, // Prevent usage of unknown DOM property 37 | "react/prop-types": 2, // Prevent missing props validation in a React component definition 38 | "react/react-in-jsx-scope": 2, // Prevent missing React when using JSX 39 | "react/require-extension": [1, { "extensions": [".js"] }], // Restrict file extensions that may be required 40 | "react/self-closing-comp": 2, // Prevent extra closing tags for components without children 41 | "react/wrap-multilines": 2 // Prevent missing parentheses around multilines JSX 42 | }, 43 | "globals": { 44 | "jQuery": true, 45 | "$": true, 46 | "reveal": true, 47 | "Pikaday": true, 48 | "NProgress": true, 49 | "cytoscape": true 50 | }, 51 | "plugins": ["react"], 52 | "ecmaFeatures": { 53 | "arrowFunctions": true, 54 | "binaryLiterals": true, 55 | "blockBindings": true, 56 | "classes": true, 57 | "defaultParams": true, 58 | "destructuring": true, 59 | "forOf": true, 60 | "generators": true, 61 | "modules": true, 62 | "objectLiteralComputedProperties": true, 63 | "objectLiteralDuplicateProperties": true, 64 | "objectLiteralShorthandMethods": true, 65 | "objectLiteralShorthandProperties": true, 66 | "octalLiterals": true, 67 | "regexUFlag": true, 68 | "regexYFlag": true, 69 | "spread": true, 70 | "superInFunctions": true, 71 | "templateStrings": true, 72 | "unicodeCodePointEscapes": true, 73 | "globalReturn": true, 74 | "jsx": true 75 | }, 76 | "env": { 77 | "browser": true, 78 | "es6": true 79 | } 80 | } -------------------------------------------------------------------------------- /src/Mingify.js: -------------------------------------------------------------------------------- 1 | import chalk from 'chalk'; 2 | 3 | export default function mingify(s, target = 'html') { 4 | if (target === 'html') { 5 | s = `${s}`; 6 | } else if (target === 'cli') { 7 | s = chalk.red(s); 8 | } 9 | 10 | return `老实说我从来没用过${s},正因为我反感${s}。 为什么我反感,因为我完全有开发${s}的能力,${s}的底层我都了如指掌。 11 | 虽说我反感${s},但是${s}却占有大量的用户份额,之后我有个想法,不如重新开发一个属于自己思想,自己架构的${s}。 12 | 我给了他一个霸气的名字:MingGe${s}, 13 | 它的名字叫MingGe${s},MingGe就是我的大名, 一看到${s}名字,就知道作者是我,知道它是国产的,让别人知道国产${s}一样做得很出色,出众! 14 | 我是mingge 请支持国产mingge${s},因为我们都是中国人。`; 15 | } 16 | -------------------------------------------------------------------------------- /src/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import chalk from 'chalk'; 3 | import mingify from '.'; 4 | import meow from 'meow'; 5 | 6 | const cli = meow(`Usage 7 | mingify 8 | 9 | example 10 | mingify Angular 11 | `); 12 | 13 | console.log(mingify(cli.input[0], 'cli')); 14 | -------------------------------------------------------------------------------- /src/example/Display.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import mingify from '..'; 3 | 4 | export default class Display extends Component { 5 | 6 | static propTypes = { 7 | text: React.PropTypes.string.isRequired 8 | }; 9 | 10 | render() { 11 | const { text } = this.props; 12 | const result = mingify(text).replace(/\r?\n/g, '
'); 13 | return ( 14 |
15 |

--------明哥体生成结果-----------

16 |

17 |
18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/example/Example.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { render } from 'react-dom'; 3 | import Display from './Display'; 4 | 5 | class App extends Component { 6 | 7 | constructor(props) { 8 | super(props); 9 | this.state = { 10 | text: 'Angular' 11 | } 12 | } 13 | 14 | render() { 15 | 16 | const { text } = this.state; 17 | 18 | return ( 19 |
20 | 25 | 28 |
29 | ); 30 | } 31 | 32 | valueChange(e) { 33 | this.setState({ 34 | text: e.currentTarget.value 35 | }); 36 | } 37 | } 38 | 39 | const appRoot = document.createElement('div'); 40 | appRoot.id = 'app'; 41 | document.body.appendChild(appRoot); 42 | 43 | render(, appRoot); 44 | -------------------------------------------------------------------------------- /src/example/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cht8687/mingify/4081c888b6b6137d71fb73f30df505a7e2bf2cd8/src/example/logo.jpg -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import mingify from './mingify'; 2 | export default mingify; 3 | -------------------------------------------------------------------------------- /test/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../src/.eslintrc", 3 | 4 | "env": { 5 | "jasmine": true 6 | }, 7 | 8 | "rules": { 9 | "one-var": 0, 10 | "no-undefined": 0 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | import test from 'tape'; 2 | import mingify from '../src/mingify'; 3 | 4 | test('mingify', t => { 5 | t.ok(mingify instanceof Function, 'should be function'); 6 | t.end(); 7 | }); 8 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | var webpack = require('webpack'); 2 | var HtmlWebpackPlugin = require('html-webpack-plugin'); 3 | var path = require('path'); 4 | var env = process.env.NODE_ENV || 'development'; 5 | 6 | module.exports = { 7 | devtool: 'source-map', 8 | entry: [ 9 | './src/example/Example.js', 10 | 'webpack-dev-server/client?http://localhost:8080', 11 | 'webpack/hot/only-dev-server' 12 | ], 13 | output: {filename: 'bundle.js', path: path.resolve('example')}, 14 | plugins: [ 15 | new HtmlWebpackPlugin(), 16 | new webpack.DefinePlugin({ 17 | 'process.env': { 18 | NODE_ENV: '"' + env + '"' 19 | } 20 | }), 21 | new webpack.HotModuleReplacementPlugin() 22 | ], 23 | module: { 24 | loaders: [ 25 | { 26 | test: /\.js$/, 27 | loaders: ['react-hot', 'babel'], 28 | include: [path.resolve('src')] 29 | } 30 | ], 31 | preLoaders: [ 32 | { 33 | test: /\.js$/, 34 | loaders: ['eslint-loader'], 35 | include: [path.resolve('src')] 36 | } 37 | ] 38 | }, 39 | resolve: { extensions: ['', '.js'] }, 40 | stats: { colors: true }, 41 | eslint: { configFile: 'src/.eslintrc' }, 42 | devServer: { 43 | hot: true, 44 | historyApiFallback: true, 45 | stats: { 46 | chunkModules: false, 47 | colors: true 48 | } 49 | } 50 | }; 51 | --------------------------------------------------------------------------------