Skip to content

Instantly share code, notes, and snippets.

@twilson63
Last active October 31, 2018 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twilson63/f149937a13c9a8ef7a8fd4d7879a1908 to your computer and use it in GitHub Desktop.
Save twilson63/f149937a13c9a8ef7a8fd4d7879a1908 to your computer and use it in GitHub Desktop.
Deploying API Server and React Client using now
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('../')
@twilson63
Copy link
Author

create a deploy script in your root directories package.json

  "scripts": {
    "deploy": "node deploy.js"
  }
npm run deploy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment