Fix frontend deploy and Heroku staging (#1288)

- Heroku reads the Node version from package.json. We're about to upgrade to Node 8 so this change to `engines` is only pre-emptive. It won't have any effect on the production servers.
- The production deploy scripts were missing the frontend files. This fixes that.
- This modifies the build setup to allow `BASE_URL=/`, which makes all requests relative to the page itself. That simplifies deploying the "debugging" frontend to the production servers, and makes it easy to host the frontend on Heroku.
This commit is contained in:
Paul Melnikow
2017-11-29 17:59:01 -05:00
committed by GitHub
parent f3965ae9a5
commit c5e31b5de1
12 changed files with 59 additions and 58 deletions

View File

@@ -17,7 +17,7 @@ before_script:
script:
- npm run lint
- npm run test:js
- if node_modules/.bin/check-node-version --node '< 8.0' > /dev/null; then echo "Skipping build."; else make website; fi
- if node_modules/.bin/check-node-version --node '< 8.0' > /dev/null; then echo "Skipping build."; else BASE_URL=/ npm run build; fi
jobs:
include:

View File

@@ -4,31 +4,28 @@ favicon:
node lib/badge-cli.js '' '' '#bada55' .png > favicon.png
website:
LONG_CACHE=false BASE_URL=https://img.shields.io npm run build
LONG_CACHE=false BASE_URL=/ npm run build
deploy: deploy-s0 deploy-s1 deploy-s2 deploy-gh-pages
deploy: website deploy-s0 deploy-s1 deploy-s2 deploy-gh-pages
deploy-s0:
# Ship a copy of the front end to each server for debugging.
# https://github.com/badges/shields/issues/1220
LONG_CACHE=false BASE_URL=https://s0.shields-server.com npm run build
git add -f Verdana.ttf private/secret.json index.html
git add -f Verdana.ttf private/secret.json build/
git commit -m'MUST NOT BE ON GITHUB'
git push -f s0 HEAD:master
git reset HEAD~1
git checkout master
deploy-s1:
LONG_CACHE=false BASE_URL=https://s1.shields-server.com npm run build
git add -f Verdana.ttf private/secret.json index.html
git add -f Verdana.ttf private/secret.json build/
git commit -m'MUST NOT BE ON GITHUB'
git push -f s1 HEAD:master
git reset HEAD~1
git checkout master
deploy-s2:
LONG_CACHE=false BASE_URL=https://s2.shields-server.com npm run build
git add -f Verdana.ttf private/secret.json index.html
git add -f Verdana.ttf private/secret.json build/
git commit -m'MUST NOT BE ON GITHUB'
git push -f s2 HEAD:master
git reset HEAD~1
@@ -43,7 +40,7 @@ deploy-gh-pages:
git checkout master
deploy-heroku:
git add -f Verdana.ttf private/secret.json index.html
git add -f Verdana.ttf private/secret.json build/
git commit -m'MUST NOT BE ON GITHUB'
git push -f heroku HEAD:master
git reset HEAD~1

View File

@@ -14,6 +14,10 @@
"NPM_CONFIG_PRODUCTION": {
"description": "Configure whether devDependencies are installed (they are needed for the build).",
"value": "false"
},
"BASE_URL": {
"description": "The base URL to use in the frontend build",
"value": "/"
}
},
"formation": {

View File

@@ -1,13 +1,13 @@
import { URL } from '../lib/url-api';
import URLPath from 'url-path';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
function resolveUri (uri, baseUri, options) {
const { longCache } = options || {};
const result = new URL(uri, baseUri);
const result = new URLPath(uri, baseUri);
if (longCache) {
result.searchParams.maxAge = '2592000';
result.searchParams.set('maxAge', '2592000');
}
return result.href;
}

View File

@@ -1,4 +1,4 @@
import { URL } from './url-api';
import URLPath from 'url-path';
export function encodeField(s) {
return encodeURIComponent(s.replace(/-/g, '--').replace(/_/g, '__'));
@@ -6,7 +6,7 @@ export function encodeField(s) {
export default function staticBadgeUri(baseUri, subject, status, color, options) {
const path = [subject, status, color].map(encodeField).join('-');
const uri = new URL(`/badge/${path}.svg`, baseUri);
const uri = new URLPath(`/badge/${path}.svg`, baseUri);
Object.keys(options || {}).forEach(k => {
uri.searchParams.set(k, options[k]);
})

View File

@@ -1,8 +0,0 @@
if (typeof window === 'undefined') {
module.exports = require('url');
} else {
module.exports = {
URL: window.URL,
URLSearchParams: window.URLSearchParams,
};
}

68
package-lock.json generated
View File

@@ -245,6 +245,21 @@
}
}
},
"JSONSelect": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/JSONSelect/-/JSONSelect-0.4.0.tgz",
"integrity": "sha1-oI7cxn6z/L6Z7WMIVTRKDPKCu40="
},
"JSONStream": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz",
"integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=",
"dev": true,
"requires": {
"jsonparse": "1.3.1",
"through": "2.3.8"
}
},
"abab": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz",
@@ -2670,8 +2685,8 @@
"integrity": "sha512-8od6g684Fhi5Vpp4ABRv/RBsW1AY6wSHbJHEK6FGTv+8jvAAnlABniZu/FVmX9TcirkHepaEsa1QGkRvbg0CKw==",
"dev": true,
"requires": {
"is-text-path": "1.0.1",
"JSONStream": "1.3.1",
"is-text-path": "1.0.1",
"lodash": "4.17.4",
"meow": "3.7.0",
"split2": "2.2.0",
@@ -5237,15 +5252,6 @@
}
}
},
"string_decoder": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz",
"integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=",
"dev": true,
"requires": {
"safe-buffer": "5.0.1"
}
},
"string-width": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
@@ -5257,6 +5263,15 @@
"strip-ansi": "3.0.1"
}
},
"string_decoder": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz",
"integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=",
"dev": true,
"requires": {
"safe-buffer": "5.0.1"
}
},
"stringstream": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
@@ -6548,12 +6563,12 @@
"resolved": "https://registry.npmjs.org/jison/-/jison-0.4.13.tgz",
"integrity": "sha1-kEFwfWIkE2f1iDRTK58ZwsNvrHg=",
"requires": {
"JSONSelect": "0.4.0",
"cjson": "0.2.1",
"ebnf-parser": "0.1.10",
"escodegen": "0.0.21",
"esprima": "1.0.4",
"jison-lex": "0.2.1",
"JSONSelect": "0.4.0",
"lex-parser": "0.1.4",
"nomnom": "1.5.2"
},
@@ -6805,21 +6820,6 @@
"integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=",
"dev": true
},
"JSONSelect": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/JSONSelect/-/JSONSelect-0.4.0.tgz",
"integrity": "sha1-oI7cxn6z/L6Z7WMIVTRKDPKCu40="
},
"JSONStream": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz",
"integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=",
"dev": true,
"requires": {
"jsonparse": "1.3.1",
"through": "2.3.8"
}
},
"jsprim": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
@@ -11852,11 +11852,6 @@
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz",
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM="
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
},
"string-hash": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string-hash/-/string-hash-1.1.1.tgz",
@@ -11899,6 +11894,11 @@
}
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
},
"stringstream": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
@@ -12686,6 +12686,12 @@
}
}
},
"url-path": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/url-path/-/url-path-0.1.1.tgz",
"integrity": "sha512-DQByXz6WBWMHVlRRuSgJrW/UYPFAyGnBTpeSB4LWN5iGe7sVuUEQsh3j9Wh34T+6l4Ftyy9ezbme1nY2jvRUEg==",
"dev": true
},
"util": {
"version": "0.10.3",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",

View File

@@ -124,10 +124,11 @@
"rimraf": "^2.6.2",
"sazerac": "^0.4.2",
"semver-regex": "^1.0.0",
"sinon": "^4.0.1"
"sinon": "^4.0.1",
"url-path": "^0.1.1"
},
"engines": {
"node": "6.x",
"node": "8.x",
"npm": "5.x"
}
}

1
public/_next Symbolic link
View File

@@ -0,0 +1 @@
../build/_next

View File

@@ -1 +1 @@
../index.html
../build/index.html

View File

@@ -1 +0,0 @@
../logo.svg

1
public/static Symbolic link
View File

@@ -0,0 +1 @@
../build/static