Browse Source

added fullstack project type (front + service)

Brandon Wong 6 years ago
parent
commit
ac6c7a6fa1
5 changed files with 40 additions and 3 deletions
  1. 3 0
      front/main.sh
  2. 27 0
      fullstack/main.sh
  3. 8 1
      maker.sh
  4. 1 1
      service/src/service.js
  5. 1 1
      service/test/service.js

+ 3 - 0
front/main.sh

@@ -25,6 +25,7 @@ yarn add react-bootstrap \
 
 
 # disable auto-open browser
+sed -i "s_console.log(chalk.cyan('Starting the development server_//console.log(chalk.cyan('Starting the development server_g" node_modules/react-scripts/scripts/start.js
 sed -i 's_openBrowser(_//openBrowser(_g' node_modules/react-scripts/scripts/start.js
 
 
@@ -34,10 +35,12 @@ echo "*.swp" >> .gitignore
 
 
 # add to package.json
+sed -i 's/"name": "/"name": "@brwong\//g' package.json
 sed -i 's/"private": true/"private": true,\n  "author": "Brandon Wong <projects@brwong.net> (https:\/\/www.brwong.net\/)"/g' package.json
 
 
 # add to index.html
+sed -i "s_<title>React App</title>_<title>$(echo $foldername | sed 's/-client$//g')</title>_" public/index.html
 sed -i 's_  </head>_\n    <!-- Bootstrap CSS -->\n    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">\n    <!-- Optional Bootstrap theme -->\n    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap-theme.min.css">\n  </head>_' public/index.html
 
 

+ 27 - 0
fullstack/main.sh

@@ -0,0 +1,27 @@
+#!/bin/bash
+
+
+script_folder=`dirname $0`
+foldername="$1"
+maker_folder=`dirname $script_folder`
+
+echo "maker folder $maker_folder"
+echo "folder name $foldername"
+echo "script_folder $script_folder"
+
+cd $foldername
+
+echo "STEP 1: create the server"
+$maker_folder/maker.sh service $foldername-server
+mv $foldername-server server
+rm -Rf server/.git
+
+echo "STEP 2: create the client (don't forget \"proxy\" in the client's package.json!)"
+$maker_folder/maker.sh front $foldername-client
+mv $foldername-client client
+rm -Rf client/.git
+sed -i 's_"private": true,_"private": true,\n  "proxy": "http://localhost:8728",_' client/package.json
+
+echo "ALL DONE!"
+
+

+ 8 - 1
maker.sh

@@ -19,7 +19,14 @@ fi
 
 if [ "$projecttype" = "front" ]
 then
-    $maker_folder/front/main.sh $2
+    $maker_folder/front/main.sh $foldername
+    exit
+fi
+
+if [ "$projecttype" = "fullstack" ]
+then
+    git init $foldername
+    $maker_folder/fullstack/main.sh $foldername
     exit
 fi
 

+ 1 - 1
service/src/service.js

@@ -3,7 +3,7 @@ import express from 'express';
 import http from 'http';
 
 
-const port = process.env.port ? parseInt(process.env.port) : 8080,
+const port = process.env.port ? parseInt(process.env.port) : 8728,
     app = express(),
     httpserver = http.createServer(app);
 

+ 1 - 1
service/test/service.js

@@ -8,7 +8,7 @@ const tapetest = _test(tape);
 
 tapetest('service', async function testService(t) {
     const server = fork('build/service.js'),
-        connstring = 'http://localhost:8080';
+        connstring = 'http://localhost:8728';
 
     try {
         await waitPro();