Skip to content

Commit

Permalink
adds full deploy chain to heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelos Zotos committed Mar 7, 2019
1 parent 45d652e commit 84457a3
Show file tree
Hide file tree
Showing 8 changed files with 2,110 additions and 280 deletions.
2 changes: 2 additions & 0 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class App extends Component {

<button onClick={() => this.loadData("/api")}>Get Api</button>
<button onClick={() => this.loadData("/code")}>Get Code</button>

<h1>sweeeeety - once more! oh FULL </h1>

<p>{this.state.text}</p>
<a
Expand Down
67 changes: 63 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,70 @@
const gulp = require("gulp");
const gulpCopy = require("gulp-copy");
const path = require("path");
const shell = require("shelljs");

gulp.task("clean", done => {
shell.rm("-rf", "dist");
done();
});

gulp.task("copy-server", () => {
const serverFiles = ["/server/lib/**/*", "/server/public/**/*"];
//const serverFiles = ["./server/lib/**/*", "./server/public/**/*"];
const serverFiles = [
"./server/**/*",
"./server/.gitignore",
"!server/node_modules/**/*"
];

const serverDest = "dist";

return gulp.src(serverFiles).pipe(gulpCopy(serverDest, { prefix: 1 }));
});

gulp.task("copy-client", () => {
const clientFiles = ["./client/build/**/*"];
const destination = "dist/public";

return gulp.src(clientFiles).pipe(gulpCopy(destination, { prefix: 2 }));
});

gulp.task("build-client", done => {
shell.cd("client");
shell.exec("npm run build");
shell.cd("..");
done();
});

return gulp.src(serverFiles).pipe(gulp.dest("dist"));
gulp.task(
"build",
gulp.series("clean", "copy-server", "build-client", "copy-client")
);

gulp.task("git-push", done => {
shell.cd("dist");

shell.exec("git add .");
shell.exec("git commit -m automated");

//shell.exec("git push");
shell.exec("git push --set-upstream heroku master --force");

shell.cd("..");

done();
});

gulp.task("default", () => {
return gulp.src("package.json").pipe(gulp.dest("bbb"));
gulp.task("git-init", done => {
shell.cd("dist");

shell.exec("git init");
shell.exec("git remote add heroku https://git.heroku.com/zotopia-power1.git");

shell.cd("..");

done();
});

gulp.task("deploy", gulp.series("build", "git-init", "git-push"));

//git.heroku.com/zotopia-power1.git
82 changes: 82 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
"main": "index.js",
"scripts": {
"build": "gulp",
"g":"gulp"
"g": "gulp",
"sh": "node sh.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"gulp": "^4.0.0"
"gulp": "^4.0.0",
"gulp-copy": "^4.0.1",
"shelljs": "^0.8.3"
}
}
1 change: 1 addition & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
6 changes: 5 additions & 1 deletion server/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const express = require("express");
const path = require("path");

const app = express();
const port = 4000;
const port = process.env.PORT || 4000;

const publicFolderPath = path.join(__dirname, "../public");
const indexHtmlPath = path.join(publicFolderPath, "index.html");
Expand All @@ -15,6 +15,10 @@ app.get("/code", (req, res) => {
res.send("/code");
});

app.get("/deploy", (req, res) => {
res.send("/deploy");
});

// register static file middle ware
app.use(express.static(publicFolderPath));

Expand Down
Loading

0 comments on commit 84457a3

Please sign in to comment.