#!/bin/bash # 5086 # The purpose of this script is to add several components and views to a Vite React Login Authentication APP # Tutorial: https://www.webune.com/forums/add-authentication-to-react-vite-using-laravel-backend.html # source: /f/apachefriends/xampp/htdocs/over-imgV5/REACT/MYOWN/vite-upload-login APP_NAME="" while [[ $APP_NAME == "" ]] do read -p "Enter the name of the Application: " APP_NAME set -e done #rm -rf $APP_NAME echo "This script will create a new Vite React App called $APP_NAME" ORVERIDE_DEFAULT="no" if [ -d "$APP_NAME" ]; then read -p "$APP_NAME already exists, do you want to REBUILD? yes/no [$ORVERIDE_DEFAULT] " ORVERIDE if [[ $ORVERIDE == "yes" ]]; then ORVERIDE_DEFAULT="yes" rm -rf $APP_NAME set -e echo "App Deleted. Rebuilding App $APP_NAME" fi else # set $ORVERIDE to yes because the directory does not exist so its new app ORVERIDE="yes" fi if [[ $ORVERIDE == "yes" ]]; then echo "Building New App $APP_NAME" npm create vite@latest $APP_NAME -- --template react cd $APP_NAME set -e npm install set -e cd ../ set -e else echo "APP was not rebuilt. Adding Authentication Login to Existing App." fi cd $APP_NAME # INSTALL DEPENCIES packages=("react-router-dom" "axios" "vite-plugin-mkcert -D" "bootstrap") for package in ${packages[@]}; do npm i $package set -e done # ROOT FILES ROOT_FILES=(".env" "vite.config.js") for ROOT_FILE in ${ROOT_FILES[@]}; do curl -o ./$ROOT_FILE https://www.webune.com/forums/$ROOT_FILE.html set -e done # src/ files loginFiles=("router.jsx" "main.jsx" "Dashboard.jsx" "axios-client.js") for file in ${loginFiles[@]}; do echo "### src/$file " curl -o src/$file https://www.webune.com/forums/$file.html set -e done # COMPONENTS src/components LOGIN_DIR="src/components" mkdir -p $LOGIN_DIR set -e # DOWNLOAD LOGIN FILES with array # https://www.freecodecamp.org/news/bash-array-how-to-declare-an-array-of-strings-in-a-bash-script/ loginFiles=("DefaultLayout" "GuestLayout" "Header") for file in ${loginFiles[@]}; do echo "@@@ src/$file.jsx " curl -o $LOGIN_DIR/$file.jsx https://www.webune.com/forums/$file.jsx.html set -e done # VIEWS src/views - CREATE ALL THE NECESSARY USER AUTHENTICATION FILES LOGIN_DIR="src/views" mkdir -p $LOGIN_DIR set -e # DOWNLOAD LOGIN FILES with array # https://www.freecodecamp.org/news/bash-array-how-to-declare-an-array-of-strings-in-a-bash-script/ loginFiles=("Login" "NotFound" "Signup" "Users" "UserForm") for file in ${loginFiles[@]}; do echo "*** src/$file.jsx " curl -o $LOGIN_DIR/$file.jsx https://www.webune.com/forums/$file.jsx.html set -e done # CONTEXT CONTEXT_DIR="src/context" # DOWNLOAD CONTEXT PROVIDER mkdir -p $CONTEXT_DIR set -e curl -o $CONTEXT_DIR/ContextProvider.jsx https://www.webune.com/forums/ContextProvider.jsx.html set -e echo 'starting server' #sleep 5 code . set -e set -e npm run dev set -e # import packages #sed -i '1 i\import axios from "axios";' Readme.md