ActivityPub-federated video streaming platform using P2P directly in your web browser
Clean shell scripts (#398)
Léo Andrès0e4ffb4b6789
diff --git a/scripts/build/client.sh b/scripts/build/client.shindex e3137df37f..8e2004c660 100755--- a/scripts/build/client.sh+++ b/scripts/build/client.sh@@ -1,6 +1,8 @@-#!/bin/bash+#!/bin/sh-cd client || exit -1+set -eu++cd clientrm -rf ./dist ./compileddiff --git a/scripts/build/server.sh b/scripts/build/server.shindex 811da21544..41b59a212c 100755--- a/scripts/build/server.sh+++ b/scripts/build/server.sh@@ -1,4 +1,6 @@-#!/usr/bin/env sh+#!/bin/sh++set -eurm -rf ./distdiff --git a/scripts/clean/client/dist.sh b/scripts/clean/client/dist.shindex ea6f7d6443..19b89de778 100755--- a/scripts/clean/client/dist.sh+++ b/scripts/clean/client/dist.sh@@ -1,4 +1,6 @@-#!/usr/bin/env sh+#!/bin/sh-cd client || exit -1+set -eu++cd clientrm -rf compiled/ dist/ dll/diff --git a/scripts/clean/server/dist.sh b/scripts/clean/server/dist.shindex be8135b8f5..50722cb44c 100755--- a/scripts/clean/server/dist.sh+++ b/scripts/clean/server/dist.sh@@ -1,3 +1,5 @@-#!/usr/bin/env sh+#!/bin/sh++set -eurm -rf dist/diff --git a/scripts/clean/server/test.sh b/scripts/clean/server/test.shindex b56021874a..7d353e3754 100755--- a/scripts/clean/server/test.sh+++ b/scripts/clean/server/test.sh@@ -1,4 +1,6 @@-#!/usr/bin/env sh+#!/bin/sh++set -eufor i in $(seq 1 6); dodropdb "peertube_test$i"diff --git a/scripts/client-report.sh b/scripts/client-report.shindex 586cc2e47a..4dd4b418b5 100755--- a/scripts/client-report.sh+++ b/scripts/client-report.sh@@ -1,5 +1,7 @@-#!/bin/bash+#!/bin/sh-cd client || exit -1+set -eu++cd clientnpm run webpack-bundle-analyzer ./dist/stats.jsondiff --git a/scripts/danger/clean/dev.sh b/scripts/danger/clean/dev.shindex cd8456772e..14b45e13bd 100755--- a/scripts/danger/clean/dev.sh+++ b/scripts/danger/clean/dev.sh@@ -1,8 +1,10 @@#!/bin/bash+set -eu+read -p "This will remove all directories and SQL tables. Are you sure? (y/*) " -n 1 -rechoif [[ "$REPLY" =~ ^[Yy]$ ]]; then- NODE_ENV=test npm run ts-node -- --type-check "./scripts/danger/clean/cleaner"+ NODE_ENV=test npm run ts-node -- --type-check "scripts/danger/clean/cleaner"fidiff --git a/scripts/danger/clean/modules.sh b/scripts/danger/clean/modules.shindex 99555a6935..f59d6b675a 100755--- a/scripts/danger/clean/modules.sh+++ b/scripts/danger/clean/modules.sh@@ -1,5 +1,7 @@#!/bin/bash+set -eu+read -p "This will remove all node server and client modules. Are you sure? " -n 1 -rif [[ "$REPLY" =~ ^[Yy]$ ]]; thendiff --git a/scripts/danger/clean/prod.sh b/scripts/danger/clean/prod.shindex 9103a79441..0675600c4a 100755--- a/scripts/danger/clean/prod.sh+++ b/scripts/danger/clean/prod.sh@@ -1,5 +1,7 @@#!/bin/bash+set -eu+read -p "This will remove all directories and SQL tables. Are you sure? (y/*) " -n 1 -rechodiff --git a/scripts/dev/client.sh b/scripts/dev/client.shindex 6d4e7000e8..ecd934888a 100755--- a/scripts/dev/client.sh+++ b/scripts/dev/client.sh@@ -1,4 +1,6 @@-#!/usr/bin/env sh+#!/bin/sh++set -euNODE_ENV=test concurrently -k \"npm run watch:client" \diff --git a/scripts/dev/index.sh b/scripts/dev/index.shindex 938bf60567..dcbf62d377 100755--- a/scripts/dev/index.sh+++ b/scripts/dev/index.sh@@ -1,4 +1,6 @@-#!/usr/bin/env sh+#!/bin/sh++set -euNODE_ENV=test concurrently -k \"npm run watch:client" \diff --git a/scripts/dev/server.sh b/scripts/dev/server.shindex 3130f1d872..bfe322ce1e 100755--- a/scripts/dev/server.sh+++ b/scripts/dev/server.sh@@ -1,4 +1,6 @@-#!/usr/bin/env sh+#!/bin/sh++set -euif [ ! -f "./client/dist/index.html" ]; thenecho "client/dist/index.html does not exist, compile client files..."diff --git a/scripts/generate-api-doc.sh b/scripts/generate-api-doc.shindex 81b80a0bef..7d48db7a52 100755--- a/scripts/generate-api-doc.sh+++ b/scripts/generate-api-doc.sh@@ -1,3 +1,5 @@-#!/usr/bin/env sh+#!/bin/sh++set -eunpm run spectacle-docs -- -t support/doc/api/html support/doc/api/openapi.yamldiff --git a/scripts/generate-code-contributors.sh b/scripts/generate-code-contributors.shindex eb94d418d7..9c2541cc2c 100755--- a/scripts/generate-code-contributors.sh+++ b/scripts/generate-code-contributors.sh@@ -1,4 +1,6 @@-#!/usr/bin/env bash+#!/bin/sh++set -eucurl -s https://api.github.com/repos/chocobozzz/peertube/contributors | \jq -r 'map("\\\n * [" + .login + "](" + .url + ")") | .[]' | \diff --git a/scripts/help.sh b/scripts/help.shindex a822d5d2e7..318bc63f5f 100755--- a/scripts/help.sh+++ b/scripts/help.sh@@ -1,4 +1,6 @@-#!/usr/bin/env sh+#!/bin/sh++set -euprintf "############# PeerTube help #############\n\n"printf "npm run ...\n"diff --git a/scripts/play.sh b/scripts/play.shindex ac2a10b121..69725da930 100755--- a/scripts/play.sh+++ b/scripts/play.sh@@ -1,4 +1,6 @@-#!/usr/bin/env sh+#!/bin/sh++set -euif [ ! -f "dist/server.js" ]; thenecho "Missing server file (server.js)."@@ -7,7 +9,7 @@ fimax=${1:-3}-for i in $(seq 1 $max); do+for i in $(seq 1 "$max"); doNODE_ENV=test NODE_APP_INSTANCE=$i node dist/server.js &sleep 1donediff --git a/scripts/release.sh b/scripts/release.shindex 8c440975f0..6f4da6a29c 100755--- a/scripts/release.sh+++ b/scripts/release.sh@@ -1,11 +1,13 @@#!/bin/bash+set -eu+shutdown() {# Get our process group id- PGID=$(ps -o pgid= $$ | grep -o [0-9]*)+ PGID=$(ps -o pgid= $$ | grep -o "[0-9]*")# Kill it in a new new process group- setsid kill -- -$PGID+ setsid kill -- -"$PGID"exit 0}@@ -16,7 +18,7 @@ if [ -z "$1" ]; thenexit -1fi-if [ -z $GITHUB_TOKEN ]; then+if [ -z "$GITHUB_TOKEN" ]; thenecho "Need GITHUB_TOKEN env set."exit -1fi@@ -33,43 +35,41 @@ zip_name="peertube-$version.zip"changelog=$(awk -v version="$version" '/## v/ { printit = $2 == version }; printit;' CHANGELOG.md | grep -v "$version" | sed '1{/^$/d}')-echo -e "Changelog will be:\n"-echo "$changelog"-echo+printf "Changelog will be:\n%s\n" "$changelog"read -p "Are you sure to release? " -n 1 -rechoif [[ ! $REPLY =~ ^[Yy]$ ]]then- [[ "$0" = "$BASH_SOURCE" ]] && exit 0+ exit 0fi-cd ./client || exit -1-npm version --no-git-tag-version --no-commit-hooks $1 || exit -1+( cd client+ npm version --no-git-tag-version --no-commit-hooks "$1"+)-cd ../ || exit -1-npm version -f --no-git-tag-version --no-commit-hooks $1 || exit -1+npm version -f --no-git-tag-version --no-commit-hooks "$1"-git commit package.json client/package.json -m "Bumped to version $version" || exit -1+git commit package.json client/package.json -m "Bumped to version $version"git tag -s -a "$version" -m "$version"-npm run build || exit -1-rm "./client/dist/stats.json" || exit -1+npm run build+rm "./client/dist/stats.json"-cd ../ || exit -1+cd ..-ln -s "PeerTube" "$directory_name" || exit -1+ln -s "PeerTube" "$directory_name"zip -r "PeerTube/$zip_name" "$directory_name/CREDITS.md" "$directory_name/FAQ.md" \"$directory_name/LICENSE" "$directory_name/README.md" \"$directory_name/client/dist/" "$directory_name/client/yarn.lock" \"$directory_name/client/package.json" "$directory_name/config" \"$directory_name/dist" "$directory_name/package.json" \"$directory_name/scripts" "$directory_name/support" \- "$directory_name/tsconfig.json" "$directory_name/yarn.lock" \- || exit -1-rm "$directory_name" || exit -1+ "$directory_name/tsconfig.json" "$directory_name/yarn.lock"++rm "$directory_name"-cd "PeerTube" || exit -1+cd "PeerTube"git push origin --tagdiff --git a/scripts/test.sh b/scripts/test.shindex ee7f6e8758..cf88953652 100755--- a/scripts/test.sh+++ b/scripts/test.sh@@ -1,6 +1,8 @@-#!/bin/bash+#!/bin/sh-npm run build:server || exit -1-npm run travis -- lint || exit -1+set -eu++npm run build:server+npm run travis -- lintmocha --exit --require ts-node/register/type-check --bail server/tests/index.tsdiff --git a/scripts/travis.sh b/scripts/travis.shindex ea0dc86997..79be234935 100755--- a/scripts/travis.sh+++ b/scripts/travis.sh@@ -1,4 +1,6 @@-#!/bin/bash+#!/bin/sh++set -euif [ $# -eq 0 ]; thenecho "Need test suite argument."@@ -21,9 +23,9 @@ elif [ "$1" = "api-slow" ]; thennpm run build:servermocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index-slow.tselif [ "$1" = "lint" ]; then- cd client || exit -1- npm run lint || exit -1+ ( cd client+ npm run lint+ )- cd .. || exit -1- npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts" || exit -1+ npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts"fidiff --git a/scripts/upgrade.sh b/scripts/upgrade.shindex bd90ce5602..2be7b49df9 100755--- a/scripts/upgrade.sh+++ b/scripts/upgrade.sh@@ -1,7 +1,6 @@-#!/usr/bin/env bash+#!/bin/sh-# Strict mode-set -e+set -eu# Backup databaseSQL_BACKUP_PATH="/var/www/peertube/backup/sql-peertube_prod-$(date +\"%Y%m%d-%H%M\").bak"@@ -11,19 +10,18 @@ pg_dump -U peertube -W -h localhost -F c peertube_prod -f "$SQL_BACKUP_PATH"# Get and Display the Latest VersionVERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4)echo "Latest Peertube version is $VERSION"-wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip" -O /var/www/peertube/versions/peertube-${VERSION}.zip+wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip" -O "/var/www/peertube/versions/peertube-${VERSION}.zip"cd /var/www/peertube/versions-unzip -o peertube-${VERSION}.zip-rm -f peertube-${VERSION}.zip+unzip -o "peertube-${VERSION}.zip"+rm -f "peertube-${VERSION}.zip"# Upgrade Scriptsrm -rf /var/www/peertube/peertube-latest-ln -s /var/www/peertube/versions/peertube-${VERSION} /var/www/peertube/peertube-latest-cd /var/www/peertube/peertube-latest+ln -s "/var/www/peertube/versions/peertube-${VERSION}" /var/www/peertube/peertube-latest+cd /var/www/peertube/peertube-latestyarn install --production --pure-lockfilecp /var/www/peertube/peertube-latest/config/default.yaml /var/www/peertube/config/default.yamlecho "Differences in configuration files..."-diff /var/www/peertube/versions/peertube-${VERSION}/config/production.yaml.example /var/www/peertube/config/production.yaml+diff "/var/www/peertube/versions/peertube-${VERSION}/config/production.yaml.example" /var/www/peertube/config/production.yaml-exit 0diff --git a/scripts/watch/client.sh b/scripts/watch/client.shindex 2481e22695..710c870370 100755--- a/scripts/watch/client.sh+++ b/scripts/watch/client.sh@@ -1,5 +1,7 @@-#!/usr/bin/env sh+#!/bin/sh-cd client || exit -1+set -eu++cd clientnpm run ng -- server --hmr --host 0.0.0.0 --disable-host-check --port 3000diff --git a/scripts/watch/server.sh b/scripts/watch/server.shindex 448f695521..42a594d857 100755--- a/scripts/watch/server.sh+++ b/scripts/watch/server.sh@@ -1,4 +1,6 @@-#!/usr/bin/env sh+#!/bin/sh++set -euNODE_ENV=test concurrently -k \"npm run tsc -- --sourceMap && npm run nodemon -- --delay 2 --watch ./dist dist/server" \