From 0e03de6ee16d45c772ca429b0159151894fb2d24 Mon Sep 17 00:00:00 2001 From: NaomiFPassarelli Date: Fri, 13 Oct 2017 09:22:26 -0300 Subject: [PATCH 1/4] remove question for each package and add two generic options --- generators/app/index.js | 122 ++++--------------------- generators/app/templates/_package.json | 62 +++---------- 2 files changed, 32 insertions(+), 152 deletions(-) diff --git a/generators/app/index.js b/generators/app/index.js index 45911fc9..661bbca8 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -4,8 +4,6 @@ var _ = require("lodash"); var proptypes = require("prop-types"); var mkdirp = require("mkdirp"); -// var reduxBeacon = require("redux-beacon"); TODO OBLIGATORIO - var Generator = require("yeoman-generator"); class GeneratorReact extends Generator { @@ -40,8 +38,9 @@ class GeneratorReact extends Generator { type: "input", name: "projectName", message: "Your Project name", - default: "Your project name", + default: "Example", store: true, + required: true, validate: val => String(val).match(/^[$A-Z_][0-9A-Z_$]*$/i) ? true @@ -51,8 +50,9 @@ class GeneratorReact extends Generator { type: "input", name: "projectDescription", message: "Description", - default: "Project description", + default: "Description", store: true, + required: true, validate: val => String(val).match(/^[$A-Z_][0-9A-Z_$]*$/i) ? true @@ -62,77 +62,18 @@ class GeneratorReact extends Generator { type: "input", name: "repoUrl", message: "What is the git repo url for this project?", - store: true - }, - { - type: "confirm", - name: "radium", - message: "Would you like to enable Radium?" - }, - { - type: "confirm", - name: "mobileDetect", - message: "Would you like to enable mobile-detect?" - }, - { - type: "confirm", - name: "moment", - message: "Would you like to enable moment?" - }, - { - type: "confirm", - name: "nukaCarousel", - message: "Would you like to enable nuka-carousel?" - }, - { - type: "confirm", - name: "numeral", - message: "Would you like to enable numeral?" - }, - { - type: "confirm", - name: "postcss", - message: "Would you like to enable postcss?" - }, - { - type: "confirm", - name: "reactAlert", - message: "Would you like to enable react-alert?" - }, - { - type: "confirm", - name: "reactModal", - message: "Would you like to enable react-modal?" - }, - { - type: "confirm", - name: "reactGoogleMaps", - message: "Would you like to enable react-google-maps?" - }, - { - type: "confirm", - name: "reactResponsive", - message: "Would you like to enable react-responsive?" - }, - { - type: "confirm", - name: "reactScroll", - message: "Would you like to enable react-scroll?" - }, - { - type: "confirm", - name: "reactShare", - message: "Would you like to enable react-share?" - }, - { - type: "confirm", - name: "reactVirtualized", - message: "Would you like to enable react-virtualized?" + store: true, + required: true }, { - type: "confirm", - name: "recharts", - message: "Would you like to enable recharts?" + type: "list", + name: "typeOfBootstrap", + message: "What type of bootstrap do you want?", + default: "empty", + choices: [ + "empty (react, redux, react-dom, redux-form, redux-beacon, redux-thunk, seamless-immutable, react-redux, react-router, react-router-dom, react-router-redux, react-addons-perf, apisauce, postcss, history, prop-types, lodash, i18next, reselect,)", + "complete (radium, mobile-detect, moment, nuka-carousel, numeral, react-alert, react-modal, react-responsive, react-scroll, react-share, react-virtualized, recharts, react-google-maps)" + ] } ]; @@ -142,19 +83,7 @@ class GeneratorReact extends Generator { this[key] = answers[key]; } - this.includeRadium = answers.radium; - this.includeMobileDetect = answers.mobileDetect; - this.includeMoment = answers.moment; - this.includeNukaCarousel = answers.nukaCarousel; - this.includeNumeral = answers.numeral; - this.includeReactAlert = answers.reactAlert; - this.includeReactModal = answers.reactModal; - this.includeReactGoogleMaps = answers.reactGoogleMaps; - this.includeReactResponsive = answers.reactResponsive; - this.includeReactScroll = answers.reactScroll; - this.includeReactShare = answers.reactShare; - this.includeReactVirtualized = answers.reactVirtualized; - this.includeRecharts = answers.recharts; + this.includeAll = answers.typeOfBootstrap; }.bind(this) ); } @@ -168,20 +97,7 @@ class GeneratorReact extends Generator { projectNameSlugified: _.kebabCase(this.projectName), projectDescription: this.projectDescription, repoUrl: this.repoUrl, - includeRadium: this.includeRadium, - includeInext: this.includeInext, - includeMobileDetect: this.includeMobileDetect, - includeMoment: this.includeMoment, - includeNukaCarousel: this.includeNukaCarousel, - includeNumeral: this.includeNumeral, - includeReactAlert: this.includeReactAlert, - includeReactModal: this.includeReactModal, - includeReactGoogleMaps: this.includeReactGoogleMaps, - includeReactResponsive: this.includeReactResponsive, - includeReactScroll: this.includeReactScroll, - includeReactShare: this.includeReactShare, - includeReactVirtualized: this.includeReactVirtualized, - includeRecharts: this.includeRecharts + includeAll: this.includeAll } ); @@ -299,14 +215,14 @@ class GeneratorReact extends Generator { { projectName: this.projectName } ); - if (this.includeNumeral) { + if (this.includeAll) { this.fs.copy( this.templatePath("src/config/numeral.js"), this.destinationPath("src/config/numeral.js"), {} ); } - if (this.includeReduxBeacon) { + if (this.includeAll) { this.fs.copy( this.templatePath("src/services/AnalyticsService.js"), this.destinationPath("src/services/AnalyticsService.js"), @@ -324,7 +240,7 @@ class GeneratorReact extends Generator { this.destinationPath("src/services/LocalStorageService.js"), {} ); - if (this.includeRadium) { + if (this.includeAll) { this.fs.copy( this.templatePath("src/app/components/Button/index.js"), this.destinationPath("src/app/components/Button/index.js"), diff --git a/generators/app/templates/_package.json b/generators/app/templates/_package.json index 86aaff7d..b4ed111b 100644 --- a/generators/app/templates/_package.json +++ b/generators/app/templates/_package.json @@ -8,55 +8,19 @@ "url": "<%= repoUrl %>" }, "dependencies": { - <% if (includeRadium) {%> - "radium": "^0.19.4",<% - } - - if (includeMobileDetect) {%> - "mobile-detect": "^1.3.7",<% - } - - if (includeMoment) {%> - "moment": "^2.18.1",<% - } - - if (includeNukaCarousel) {%> - "nuka-carousel": "^2.3.0",<% - } - - if (includeNumeral) {%> - "numeral": "^2.0.6",<% - } - - if (includeReactAlert) {%> - "react-alert": "^2.3.0",<% - } - - if (includeReactModal) {%> - "react-modal": "^2.3.2",<% - } - - if (includeReactResponsive) {%> - "react-responsive": "^1.3.4",<% - } - - if (includeReactScroll) {%> - "react-scroll": "^1.5.4",<% - } - - if (includeReactShare) {%> - "react-share": "^1.16.0",<% - } - - if (includeReactVirtualized) {%> - "react-virtualized": "^9.9.0",<% - } - - if (includeRecharts) {%> - "recharts": "^1.0.0-alpha.4",<% - } - - if (includeReactGoogleMaps) {%> + <% if (includeAll) {%> + "radium": "^0.19.4", + "mobile-detect": "^1.3.7", + "moment": "^2.18.1", + "nuka-carousel": "^2.3.0", + "numeral": "^2.0.6", + "react-alert": "^2.3.0", + "react-modal": "^2.3.2", + "react-responsive": "^1.3.4", + "react-scroll": "^1.5.4", + "react-share": "^1.16.0", + "react-virtualized": "^9.9.0", + "recharts": "^1.0.0-alpha.4", "react-google-maps": "^7.3.0",<% }%> "reselect": "^3.0.1", From 0ecab74cfdae3577776565a7619a6aaa9757cba2 Mon Sep 17 00:00:00 2001 From: NaomiFPassarelli Date: Fri, 13 Oct 2017 09:55:22 -0300 Subject: [PATCH 2/4] run empty project - clean all unused components --- generators/app/index.js | 44 ----------- .../src/app/components/Routes/index.js | 9 +-- generators/app/templates/src/app/index.js | 5 +- .../src/app/screens/Dashboard/index.js | 30 ++----- .../screens/Dashboard/screens/Home/index.js | 18 +---- .../screens/Dashboard/screens/Home/layout.js | 21 ----- .../screens/Dashboard/screens/Home/styles.js | 14 ---- .../src/app/screens/Dashboard/styles.js | 23 ------ .../templates/src/app/screens/Login/index.js | 36 --------- .../templates/src/app/screens/Login/layout.js | 79 ------------------- .../src/app/screens/Login/strings.js | 10 --- .../templates/src/app/screens/Login/styles.js | 27 ------- generators/app/templates/src/app/styles.js | 14 ---- .../app/templates/src/redux/Auth/actions.js | 7 +- .../app/templates/src/redux/Auth/reducer.js | 2 + 15 files changed, 18 insertions(+), 321 deletions(-) delete mode 100644 generators/app/templates/src/app/screens/Dashboard/screens/Home/layout.js delete mode 100644 generators/app/templates/src/app/screens/Dashboard/screens/Home/styles.js delete mode 100644 generators/app/templates/src/app/screens/Dashboard/styles.js delete mode 100644 generators/app/templates/src/app/screens/Login/index.js delete mode 100644 generators/app/templates/src/app/screens/Login/layout.js delete mode 100644 generators/app/templates/src/app/screens/Login/strings.js delete mode 100644 generators/app/templates/src/app/screens/Login/styles.js delete mode 100644 generators/app/templates/src/app/styles.js diff --git a/generators/app/index.js b/generators/app/index.js index 661bbca8..adcc9c54 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -138,11 +138,6 @@ class GeneratorReact extends Generator { this.destinationPath("src/app/index.js"), {} ); - this.fs.copy( - this.templatePath("src/app/styles.js"), - this.destinationPath("src/app/styles.js"), - {} - ); this.fs.copy( this.templatePath("src/config/api.js"), this.destinationPath("src/config/api.js"), @@ -326,11 +321,6 @@ class GeneratorReact extends Generator { this.destinationPath("src/app/screens/Dashboard/index.js"), {} ); - this.fs.copy( - this.templatePath("src/app/screens/Dashboard/styles.js"), - this.destinationPath("src/app/screens/Dashboard/styles.js"), - {} - ); this.fs.copy( this.templatePath("src/constants/fonts.js"), this.destinationPath("src/constants/fonts.js"), @@ -346,40 +336,6 @@ class GeneratorReact extends Generator { this.destinationPath("src/app/screens/Dashboard/screens/Home/index.js"), {} ); - this.fs.copy( - this.templatePath("src/app/screens/Dashboard/screens/Home/layout.js"), - this.destinationPath( - "src/app/screens/Dashboard/screens/Home/layout.js" - ), - {} - ); - this.fs.copy( - this.templatePath("src/app/screens/Dashboard/screens/Home/styles.js"), - this.destinationPath( - "src/app/screens/Dashboard/screens/Home/styles.js" - ), - {} - ); - this.fs.copy( - this.templatePath("src/app/screens/Login/index.js"), - this.destinationPath("src/app/screens/Login/index.js"), - {} - ); - this.fs.copy( - this.templatePath("src/app/screens/Login/layout.js"), - this.destinationPath("src/app/screens/Login/layout.js"), - {} - ); - this.fs.copy( - this.templatePath("src/app/screens/Login/strings.js"), - this.destinationPath("src/app/screens/Login/strings.js"), - {} - ); - this.fs.copy( - this.templatePath("src/app/screens/Login/styles.js"), - this.destinationPath("src/app/screens/Login/styles.js"), - {} - ); this.fs.copy( this.templatePath("pull_request_template.md"), this.destinationPath("pull_request_template.md"), diff --git a/generators/app/templates/src/app/components/Routes/index.js b/generators/app/templates/src/app/components/Routes/index.js index 1d4f3619..a26d9daf 100644 --- a/generators/app/templates/src/app/components/Routes/index.js +++ b/generators/app/templates/src/app/components/Routes/index.js @@ -3,8 +3,7 @@ import { ConnectedRouter } from "react-router-redux"; import { Switch } from "react-router-dom"; import { history } from "../../../redux/store"; -import Home from "../../screens/Dashboard/screens/Home"; -import Login from "../../screens/Login"; +import Home from "../../screens/Dashboard"; import AuthenticatedRoute from "./components/AuthenticatedRoute"; import * as Routes from "./constants"; @@ -21,12 +20,6 @@ function AppRoutes() { path={Routes.HOME} component={Home} /> - diff --git a/generators/app/templates/src/app/index.js b/generators/app/templates/src/app/index.js index 3882bce5..37ba73f8 100644 --- a/generators/app/templates/src/app/index.js +++ b/generators/app/templates/src/app/index.js @@ -1,6 +1,5 @@ import React, { Component } from "react"; import { connect } from "react-redux"; -import { StyleRoot } from "radium"; import { apiSetup } from "../config/api"; @@ -13,9 +12,9 @@ class App extends Component { render() { return ( - +
- +
); } } diff --git a/generators/app/templates/src/app/screens/Dashboard/index.js b/generators/app/templates/src/app/screens/Dashboard/index.js index bbe717aa..f182e5df 100644 --- a/generators/app/templates/src/app/screens/Dashboard/index.js +++ b/generators/app/templates/src/app/screens/Dashboard/index.js @@ -1,30 +1,18 @@ import React from "react"; import { connect } from "react-redux"; -import Radium from "radium"; import { Route, Switch, Redirect } from "react-router-dom"; -import PropTypes from "prop-types"; import * as Routes from "../../components/Routes/constants"; import Home from "./screens/Home"; -import Login from "../Login"; -import styles from "./styles"; - -function Dashboard({ loading }) { +function Dashboard() { return ( -
-
- {/* - */} -
- - - - } /> - -
-
+
+ + + } /> +
); } @@ -33,8 +21,4 @@ Dashboard.defaultProps = { loading: false }; -Dashboard.propTypes = { - loading: PropTypes.bool.isRequired -}; - -export default connect()(Radium(Dashboard)); +export default connect()(Dashboard); diff --git a/generators/app/templates/src/app/screens/Dashboard/screens/Home/index.js b/generators/app/templates/src/app/screens/Dashboard/screens/Home/index.js index 2916b29b..72e59840 100644 --- a/generators/app/templates/src/app/screens/Dashboard/screens/Home/index.js +++ b/generators/app/templates/src/app/screens/Dashboard/screens/Home/index.js @@ -1,17 +1,5 @@ -import React, { Component } from "react"; -import { connect } from "react-redux"; +import React from "react"; -import { actionCreators as authActions } from "../../../../../redux/Auth/actions"; -import Home from "./layout"; - -class HomeContainer extends Component { - handleLogout = () => { - this.props.dispatch(authActions.logout()); - }; - - render() { - return ; - } +export default function Home() { + return
; } - -export default connect()(HomeContainer); diff --git a/generators/app/templates/src/app/screens/Dashboard/screens/Home/layout.js b/generators/app/templates/src/app/screens/Dashboard/screens/Home/layout.js deleted file mode 100644 index c0620ffa..00000000 --- a/generators/app/templates/src/app/screens/Dashboard/screens/Home/layout.js +++ /dev/null @@ -1,21 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; - -import Button from "../../../../components/Button"; -import Label from "../../../../components/Label"; - -import styles from "./styles"; - -export default function Home({ onLogout }) { - return ( -
- -
- ); -} - -Home.propTypes = { - onLogout: PropTypes.func.isRequired -}; diff --git a/generators/app/templates/src/app/screens/Dashboard/screens/Home/styles.js b/generators/app/templates/src/app/screens/Dashboard/screens/Home/styles.js deleted file mode 100644 index c38ee11c..00000000 --- a/generators/app/templates/src/app/screens/Dashboard/screens/Home/styles.js +++ /dev/null @@ -1,14 +0,0 @@ -import { green } from "../../../../../utils/colors"; - -export default { - container: { - flex: 1, - alignItems: "center", - justifyContent: "center" - }, - mainButton: { - backgroundColor: green, - padding: 10, - borderRadius: 3 - } -}; diff --git a/generators/app/templates/src/app/screens/Dashboard/styles.js b/generators/app/templates/src/app/screens/Dashboard/styles.js deleted file mode 100644 index 7609b4c3..00000000 --- a/generators/app/templates/src/app/screens/Dashboard/styles.js +++ /dev/null @@ -1,23 +0,0 @@ -// TODO Add this if you need it -// import { sidebarSize, topbarSize } from "../../../constants/sizes"; - -export default { - base: { - textAlign: "center", - display: "flex", - height: "100%" - }, - content: { - // TODO Add this if you need it - // height: `calc(100% - ${topbarSize}px)`, - // marginLeft: sidebarSize, - // marginTop: topbarSize, - // width: `calc(100% - ${sidebarSize}px)` - height: "100%", - width: "100%" - }, - baseContent: { - width: "100%", - flex: 4 - } -}; diff --git a/generators/app/templates/src/app/screens/Login/index.js b/generators/app/templates/src/app/screens/Login/index.js deleted file mode 100644 index f1a72c33..00000000 --- a/generators/app/templates/src/app/screens/Login/index.js +++ /dev/null @@ -1,36 +0,0 @@ -import React, { Component } from "react"; -import { connect } from "react-redux"; - -import { actionCreators as authActions } from "../../../redux/Auth/actions"; - -import Login from "./layout"; - -class LoginContainer extends Component { - state = { invalidInput: false }; - handleSubmit = values => { - const invalidateUser = false; // TODO: Add validation logic - const invalidatePass = false; // TODO: Add validation logic - if ( - values.username === "" || - values.password === "" || - invalidateUser || - invalidatePass - ) { - this.setState({ invalidInput: true }); - } else { - this.setState({ invalidInput: false }); - this.props.dispatch(authActions.login()); - } - }; - - render() { - return ( - - ); - } -} - -export default connect()(LoginContainer); diff --git a/generators/app/templates/src/app/screens/Login/layout.js b/generators/app/templates/src/app/screens/Login/layout.js deleted file mode 100644 index f8ba74d8..00000000 --- a/generators/app/templates/src/app/screens/Login/layout.js +++ /dev/null @@ -1,79 +0,0 @@ -import React from "react"; -import { reduxForm, Field } from "redux-form"; -import PropTypes from "prop-types"; - -import Button from "../../components/Button"; -import { transparent } from "../../../utils/colors"; -import Label from "../../components/Label"; -import TextInput from "../../components/TextInput"; -import InputValidations from "../../../utils/inputValidations"; -import { white } from "../../../utils/colors"; - -import * as Strings from "./strings"; -import styles from "./styles"; - -const userValidations = [ - InputValidations.required(`El ${Strings.user} es requerido`), - InputValidations.minLength(7, Strings.userMinLength), - InputValidations.maxLength(11, Strings.userMaxLength), - InputValidations.numericalDigits(Strings.userFormat) -]; - -const passwordValidations = [ - InputValidations.required(`El ${Strings.password} es requerido`), - InputValidations.minLength(8, Strings.passwordMinLength), - InputValidations.maxLength(255, Strings.passwordMaxLength) -]; - -function Login({ handleSubmit, invalidInput }) { - return ( -
-
- -
-
- -
- - -
- - -
-
- ); -} - -Login.propTypes = { - handleSubmit: PropTypes.func.isRequired, - invalidInput: PropTypes.bool.isRequired -}; - -export default reduxForm({ - form: Strings.formName, - initialValues: { username: "", password: "" } -})(Login); diff --git a/generators/app/templates/src/app/screens/Login/strings.js b/generators/app/templates/src/app/screens/Login/strings.js deleted file mode 100644 index ca039a11..00000000 --- a/generators/app/templates/src/app/screens/Login/strings.js +++ /dev/null @@ -1,10 +0,0 @@ -// Labels -exports.user = "Usuario"; -exports.password = "Contraseña"; -exports.forgotPassword = "Olvidé mi contraseña"; -exports.validationMessage = "Contraseña incorrecta"; -exports.submit = "INGRESAR"; -exports.signUp = "REGISTRARSE"; - -// Others -exports.formName = "loginForm"; diff --git a/generators/app/templates/src/app/screens/Login/styles.js b/generators/app/templates/src/app/screens/Login/styles.js deleted file mode 100644 index 28110940..00000000 --- a/generators/app/templates/src/app/screens/Login/styles.js +++ /dev/null @@ -1,27 +0,0 @@ -import { green, blue, transparent } from "../../../utils/colors"; - -export default { - container: { - flex: 1, - alignItems: "center", - justifyContent: "center" - }, - formElementContainer: { - backgroundColor: transparent, - borderBottomColor: blue, - borderBottomWidth: 1 - }, - formElement: { - padding: 3, - margin: 5, - backgroundColor: transparent, - height: 30, - width: 200 - }, - formButton: { - backgroundColor: green, - padding: 10, - borderRadius: 3, - margin: 20 - } -}; diff --git a/generators/app/templates/src/app/styles.js b/generators/app/templates/src/app/styles.js deleted file mode 100644 index fc45f889..00000000 --- a/generators/app/templates/src/app/styles.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from "react"; -import { Style } from "radium"; - -const styles = { - "body, html, #root, [data-reactroot]": { - padding: 0, - margin: 0, - // TODO Add fontFamily - // fontFamily: , - height: "100%" - } -}; - -export default