chore: cleanup travis scripts (#766)

* chore: cleanup travis scripts

* remove unused script
This commit is contained in:
Nolan Lawson 2018-12-08 17:15:01 -08:00 committed by GitHub
parent b73dd548ae
commit 8eb30d02e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 21 deletions

8
bin/backup-mastodon-data.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -x
set -e
PGPASSWORD=pinafore pg_dump -U pinafore -w pinafore_development > fixtures/dump.sql
cd mastodon/public/system
tar -czf ../../../fixtures/system.tgz .

8
bin/deploy-all-travis.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e
set -x
if [ "$TRAVIS_BRANCH" = master -a "$TRAVIS_PULL_REQUEST" = false ]; then
npm run deploy-dev
fi

38
bin/deploy.sh Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -e
set -x
PATH="$PATH:./node_modules/.bin"
# set up robots.txt
if [[ "$DEPLOY_TYPE" == "prod" ]]; then
printf 'User-agent: *\nDisallow: /' > assets/robots.txt
else
rm -f assets/robots.txt
fi
# if in travis, use the $NOW_TOKEN
NOW_COMMAND="now --team nolanlawson"
if [[ ! -z "$NOW_TOKEN" ]]; then
NOW_COMMAND="$NOW_COMMAND --token $NOW_TOKEN"
fi
#launch
$NOW_COMMAND -e SAPPER_TIMESTAMP=$(date +%s%3N)
# fixes issues with now being unavailable immediately
sleep 60
# choose the right alias
NOW_ALIAS="dev.pinafore.social"
if [[ "$DEPLOY_TYPE" == "prod" ]]; then
NOW_ALIAS="pinafore.social"
fi
# alias
$NOW_COMMAND alias "$NOW_ALIAS"
# cleanup
$NOW_COMMAND rm pinafore --safe --yes

View File

@ -33,22 +33,10 @@
"wait-for-mastodon-data": "node -r esm bin/wait-for-mastodon-data.js",
"globalize-css": "node ./bin/globalize-css.js",
"deglobalize-css": "node ./bin/globalize-css.js --reverse",
"stage-dev": "printf 'User-agent: *\nDisallow: /' > assets/robots.txt",
"stage-prod": "rm -f assets/robots.txt",
"launch": "now -e SAPPER_TIMESTAMP=$(date +%s%3N) --team nolanlawson && sleep 60",
"launch-travis": "now -e SAPPER_TIMESTAMP=$(date +%s%3N) --team nolanlawson --token $NOW_TOKEN && sleep 60",
"alias-prod": "now alias pinafore.social --team nolanlawson",
"alias-prod-travis": "now alias pinafore.social --team nolanlawson --token $NOW_TOKEN",
"alias-dev": "now alias dev.pinafore.social --team nolanlawson",
"alias-dev-travis": "now alias dev.pinafore.social --team nolanlawson --token $NOW_TOKEN",
"cleanup": "now rm pinafore --safe --yes --team nolanlawson",
"cleanup-travis": "now rm pinafore --safe --yes --team nolanlawson --token $NOW_TOKEN",
"deploy-prod": "run-s stage-prod launch alias-prod cleanup",
"deploy-dev": "run-s stage-dev launch alias-dev cleanup",
"deploy-dev-travis": "run-s stage-dev launch-travis alias-dev-travis cleanup-travis; fi",
"deploy-prod-travis": "if echo $TRAVIS_COMMIT_MESSAGE | grep -q -E '\\d+\\.\\d+\\.\\d+'; then run-s stage-prod launch-travis alias-prod-travis cleanup-travis; fi",
"deploy-all-travis": "if [ $TRAVIS_BRANCH = master -a $TRAVIS_PULL_REQUEST = false ]; then run-s deploy-dev-travis deploy-prod-travis; fi",
"backup-mastodon-data": "PGPASSWORD=pinafore pg_dump -U pinafore -w pinafore_development > fixtures/dump.sql && cd mastodon/public/system && tar -czf ../../../fixtures/system.tgz ."
"deploy-prod": "DEPLOY_TYPE=prod ./bin/deploy.sh",
"deploy-dev": "DEPLOY_TYPE=dev ./bin/deploy.sh",
"deploy-all-travis": "./bin/deploy-all-travis.sh",
"backup-mastodon-data": "./bin/backup-mastodon-data.sh"
},
"dependencies": {
"@gamestdio/websocket": "^0.2.8",

View File

@ -1,13 +1,9 @@
const isLocalhost = !process.browser ||
location.hostname === 'localhost' ||
location.hostname === '127.0.0.1'
function targetIsLocalhost (instanceName) {
return instanceName.startsWith('localhost:') || instanceName.startsWith('127.0.0.1:')
}
export function basename (instanceName) {
if (isLocalhost && targetIsLocalhost(instanceName)) {
if (targetIsLocalhost(instanceName)) {
return `http://${instanceName}`
}
return `https://${instanceName}`