Last active
October 31, 2018 20:28
-
-
Save twilson63/f149937a13c9a8ef7a8fd4d7879a1908 to your computer and use it in GitHub Desktop.
Deploying API Server and React Client using now
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
const colors = require("colors"); | |
const shell = require("shelljs"); | |
if (!shell.which("now")) { | |
return console.log("exited: now is not installed - npm install now -g"); | |
} | |
if (!shell.which("json")) { | |
return console.log("exited: json is not installed - npm install json -g"); | |
} | |
// deploy api | |
shell.cd("api") | |
const apiAlias = "api.twilson63.xyz" | |
shell.exec(`json -I -f package.json -e 'this.now.alias = "${apiAlias}"'`) | |
shell.exec("now -e DB=@db") | |
shell.exec("now alias") | |
shell.exec(`now scale ${apiAlias} sfo1 1 5`) | |
shell.cd("../") | |
// see https://zeit.co/docs/examples/create-react-app | |
// to setup react app for now | |
// deploy app | |
shell.cd('app') | |
const appAlias = 'app.twilson.xyz' | |
shell.exec(`json -I -f now.json -e 'this.alias = "${appAlias}"'`) | |
shell.exec('now') | |
shell.exec('now alias') | |
shell.exec(`now scale ${appAlias} sfo 1 5`) | |
shell.cd('../') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
create a deploy script in your root directories package.json