Last active
January 29, 2019 15:57
-
-
Save vnoitkumar/cdb31ea6b245e2d7b836c5be607a2030 to your computer and use it in GitHub Desktop.
React
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#src: https://gist.github.com/vnoitkumar/cdb31ea6b245e2d7b836c5be607a2030 | |
#Ref: https://marmelab.com/blog/2015/12/17/react-directory-structure.html | |
read -p "Enter the Module name (eg: UserProfile): " moduleName | |
if [ -z "$moduleName" ]; then | |
echo "Module Name required." | |
exit | |
fi | |
if [ $1 ] | |
then | |
cd $1 | |
else | |
mkdir -p src | |
cd src | |
fi | |
dashCase=$(echo $moduleName \ | |
| sed 's/\(.\)\([A-Z]\)/\1-\2/g' \ | |
| tr '[:upper:]' '[:lower:]') | |
camelCase=$(echo $moduleName | sed 's/^[A-Z]/\L&/') | |
mkdir $dashCase | |
cd $dashCase | |
touch "${moduleName}Action.js" | |
touch "${moduleName}Constant.js" | |
touch "${moduleName}Container.js" | |
touch "${moduleName}Component.jsx" | |
touch "${moduleName}-spec.js" | |
touch "${camelCase}Reducer.js" | |
touch "${camelCase}.scss" | |
printf "import React, { Component } from 'react'; | |
import './$camelCase.scss'; | |
class $moduleName extends Component { | |
render() { | |
return ( | |
<h1> | |
$moduleName | |
</h1> | |
); | |
} | |
} | |
export default $moduleName; | |
" > "${moduleName}Components.jsx" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#src: https://gist.github.com/vnoitkumar/cdb31ea6b245e2d7b836c5be607a2030 | |
read -p "Enter the app name : " appName | |
if [ -z "$appName" ]; then | |
echo "App Name required." | |
exit | |
fi | |
npx create-react-app $appName | |
cd $appName | |
# npm i normalize.css | |
# npm i bootstrap | |
# npm i node-sass | |
npm i react-router-dom | |
npm i axios | |
npm i redux react-redux redux-thunk | |
curl https://raw.githubusercontent.com/facebook/react/master/.editorconfig > .editorconfig | |
touch .env.development.local | |
touch .env.test.local | |
touch .env.production.local | |
printf "# Access a value from .env | |
# process.env.NODE_ENV; | |
# ------------------------------------------------------------------------------------------------ | |
# You must create custom environment variables beginning with REACT_APP_ | |
# Changing any environment variables will require you to restart the development server if it is running | |
# ------------------------------------------------------------------------------------------------ | |
# .env: Default. | |
# .env.local: Local overrides. This file is loaded for all environments except test. | |
# .env.development, .env.test, .env.production: Environment-specific settings. | |
# .env.development.local, .env.test.local, .env.production.local: Local overrides of environment-specific settings. | |
# ------------------------------------------------------------------------------------------------ | |
# Expand variables already on your machine for use in your .env file (using dotenv-expand). | |
# For example, | |
# DOMAIN=www.example.com | |
# REACT_APP_FOO=\$DOMAIN/foo | |
# REACT_APP_BAR=\$DOMAIN/bar | |
" > .env.development.local | |
curl https://gist.githubusercontent.com/vnoitkumar/cdb31ea6b245e2d7b836c5be607a2030/raw/02007aa6fa5573657c769f1fd7ab9116c42d848f/create-react-module.sh > create-react-module.sh | |
git init | |
git add . | |
git commit -m "initial commit" | |
npm start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment