Skip to content

Instantly share code, notes, and snippets.

@AwsafAlam
Last active January 9, 2019 17:31
Show Gist options
  • Save AwsafAlam/2998d34f4001dcbfac5314b504823722 to your computer and use it in GitHub Desktop.
Save AwsafAlam/2998d34f4001dcbfac5314b504823722 to your computer and use it in GitHub Desktop.
Create Web App

This is a basic script for initializing any type of web application quickly.

The script will initialize any application chosen by the user, I did this to make my development process easier and faster. There are a total of 5 options

  1. Custom Boilerplate
  2. Express Application
  3. ReactJS Application
  4. Simple Progressive Web App
  5. Flutter App

the first option creates a custom folder, and creates all the files neseccary for a basic nodejs project. Rest of the options are for initializing frameworks.

Future Modifications

  1. Check if node js is installed in the device, if not, install node first. This will make the script more generic
  2. check if react JS is installed on device
  3. support for progressive web app
  • This project was done as a part of the OS course CSE 313, and will be modified further to suite my needs.

Author : Md Awsaf Alam 1505114 Dept of CSE, BUET

#!/bin/bash
clear
echo "Starting Web App Maker..."
printf "Specify Type of web app:\n\
1. Custom Boilerplate\n\
2. Express Application\n\
3. ReactJS Application\n\
4. Simple Progressive Web App\n\
5. Flutter App\n---------------------\n"
read type
if [ $type -eq 1 ]; then
mkdir $1
cd $1
echo "Setting up $1.."
echo "Initialised git"
git init
echo "node_modules/
build
npm-debug.log
.env" > .gitignore
touch index.js
echo "<!DOCTYPE html>
<html lang=\"en\">
<head>
<meta charset=\"UTF-8\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">
<title>Document</title>
</head>
<body>
<div id=\"app\">
</div>
</body>
</html>" > index.html
node -v
npm init -y
mkdir assets
cd assets
mkdir js
cd js
touch app.js
cd ..
mkdir css
cd css
touch main.css
cd ..
mkdir img
cd ..
echo "npm init complete"
echo "Creating node server..."
echo "Specify the listening port"
read port
echo "var http = require('http'); //Node JS core module
var app = require('./index');
function onRequest(request,response){
response.writeHead(200, {'Content-Type': 'text/html'}); //Http header
response.write('Hello World');
response.end();
}
http.createServer(onRequest).listen($port);" > server.js
git add -A
git commit -m "Initial commit"
# Vscode
code .
node server.js
elif [ $type -eq 2 ]; then
echo "Initializing Express App"
express $1
cd $1
npm install
code .
echo "Express app initialise on localhost/3000"
npm start
elif [ $type -eq 3 ]; then
echo "Initializing React App"
create-react-app $1
cd $1
code .
npm start
elif [ $type -eq 4 ]; then
echo "Creating PWA"
elif [ $type -eq 5 ]; then
flutter create $1
cd $1
code .
flutter run
fi
# cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment