From 9353449515ff6881a54ce6887297b7eab2855186 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 30 Apr 2016 11:17:50 +0200 Subject: Use scripty instead of writing shell commands in package.json --- scripts/build/client/sass.sh | 9 +++++++++ scripts/build/client/tsc.sh | 5 +++++ scripts/clean/client/sass.sh | 5 +++++ scripts/clean/client/tsc.sh | 4 ++++ scripts/clean/server/test.sh | 6 ++++++ scripts/danger/clean/modules.sh | 7 +++++++ scripts/danger/clean/server.sh | 8 ++++++++ scripts/dev.sh | 7 +++++++ scripts/help.sh | 24 ++++++++++++++++++++++++ scripts/play.sh | 11 +++++++++++ scripts/test.sh | 8 ++++++++ scripts/watch/client/sass.sh | 7 +++++++ scripts/watch/client/tsc.sh | 5 +++++ 13 files changed, 106 insertions(+) create mode 100755 scripts/build/client/sass.sh create mode 100755 scripts/build/client/tsc.sh create mode 100755 scripts/clean/client/sass.sh create mode 100755 scripts/clean/client/tsc.sh create mode 100755 scripts/clean/server/test.sh create mode 100755 scripts/danger/clean/modules.sh create mode 100755 scripts/danger/clean/server.sh create mode 100755 scripts/dev.sh create mode 100755 scripts/help.sh create mode 100755 scripts/play.sh create mode 100755 scripts/test.sh create mode 100755 scripts/watch/client/sass.sh create mode 100755 scripts/watch/client/tsc.sh (limited to 'scripts') diff --git a/scripts/build/client/sass.sh b/scripts/build/client/sass.sh new file mode 100755 index 000000000..0caa0df20 --- /dev/null +++ b/scripts/build/client/sass.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +npm run clean:client:sass +cd client || exit -1 + +# Compile index and angular files +concurrently \ + "node-sass --include-path node_modules/bootstrap-sass/assets/stylesheets/ stylesheets/application.scss stylesheets/index.css" \ + "node-sass angular/ --output angular/" diff --git a/scripts/build/client/tsc.sh b/scripts/build/client/tsc.sh new file mode 100755 index 000000000..ec06b643a --- /dev/null +++ b/scripts/build/client/tsc.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +cd client || exit -1 + +npm run tsc diff --git a/scripts/clean/client/sass.sh b/scripts/clean/client/sass.sh new file mode 100755 index 000000000..82c079f28 --- /dev/null +++ b/scripts/clean/client/sass.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +cd client || exit -1 +rm -f stylesheets/index.css +find angular -regextype posix-egrep -regex ".*\.(css)$" -exec rm -f {} \; diff --git a/scripts/clean/client/tsc.sh b/scripts/clean/client/tsc.sh new file mode 100755 index 000000000..775157a54 --- /dev/null +++ b/scripts/clean/client/tsc.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +cd client || exit -1 +find angular -regextype posix-egrep -regex ".*\.(js|map)$" -exec rm -f {} \; diff --git a/scripts/clean/server/test.sh b/scripts/clean/server/test.sh new file mode 100755 index 000000000..927671dd4 --- /dev/null +++ b/scripts/clean/server/test.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +for i in $(seq 1 6); do + printf "use peertube-test%s;\ndb.dropDatabase();" "$i" | mongo + rm -rf "./test$i" +done diff --git a/scripts/danger/clean/modules.sh b/scripts/danger/clean/modules.sh new file mode 100755 index 000000000..1aa6c732b --- /dev/null +++ b/scripts/danger/clean/modules.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +read -p "This will remove all node and typescript modules. Are you sure? " -n 1 -r + +if [[ "$REPLY" =~ ^[Yy]$ ]]; then + rm -rf node_modules client/node_modules client/typings +fi diff --git a/scripts/danger/clean/server.sh b/scripts/danger/clean/server.sh new file mode 100755 index 000000000..0a85eb249 --- /dev/null +++ b/scripts/danger/clean/server.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +read -p "This will remove certs, uploads, database (dev) and logs. Are you sure? " -n 1 -r + +if [[ "$REPLY" =~ ^[Yy]$ ]]; then + rm -rf ./certs ./logs ./uploads + printf "use peertube-dev;\ndb.dropDatabase();" | mongo +fi diff --git a/scripts/dev.sh b/scripts/dev.sh new file mode 100755 index 000000000..d617cd511 --- /dev/null +++ b/scripts/dev.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +npm run build +NODE_ENV=test concurrently \ + "npm run livereload" \ + "npm run watch:client" \ + "npm start" diff --git a/scripts/help.sh b/scripts/help.sh new file mode 100755 index 000000000..3ed9f15cc --- /dev/null +++ b/scripts/help.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +printf "############# PeerTube help #############\n\n" +printf "npm run ...\n" +printf " build -> Build the application\n" +printf " build:client -> Build the client (css, js files)\n" +printf " build:client:sass -> Build the sass files\n" +printf " build:client:tsc -> Build the javascript files\n" +printf " clean -> Clean the application\n" +printf " clean:client -> Clean the client (css, js files)\n" +printf " clean:client:sass -> Clean the sass build files\n" +printf " clean:client:tsc -> Clean the javascript files\n" +printf " clean:server:test -> Clean certificates, logs, uploads and database of the test instances\n" +printf " watch:client -> Watch the client files\n" +printf " watch:client:sass -> Watch the sass client files\n" +printf " watch:client:tsc -> Watch the typescript files\n" +printf " danger:clean:server -> /!\ Clean certificates, logs, uploads and database\n" +printf " danger:clean:modules -> /!\ Clean node and typescript modules\n" +printf " play -> Run 3 fresh nodes so that you can test the communication between them\n" +printf " dev -> Watch, run the livereload and run the server so that you can develop the application\n" +printf " livereload -> Run the livereload on the client\n" +printf " start -> Run the server\n" +printf " test -> Run the tests\n" +printf " help -> Print this help\n" diff --git a/scripts/play.sh b/scripts/play.sh new file mode 100755 index 000000000..33dc1a545 --- /dev/null +++ b/scripts/play.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +if [ ! -f server.js ]; then + echo "Missing server file (server.js)." + exit -1 +fi + +for i in 1 2 3; do + NODE_ENV=test NODE_APP_INSTANCE=$i node server.js & + sleep 1 +done diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 000000000..93dbd8200 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +cd client || exit -1 +npm test + +cd .. || exit -1 +standard +mocha server/tests diff --git a/scripts/watch/client/sass.sh b/scripts/watch/client/sass.sh new file mode 100755 index 000000000..7d716cb7c --- /dev/null +++ b/scripts/watch/client/sass.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh + +cd client || exit -1 + +concurrently \ + "node-sass -w --include-path node_modules/bootstrap-sass/assets/stylesheets/ stylesheets/application.scss stylesheets/index.css client/angular/**/ client/angular/**/**" \ + "node-sass -w angular/ --output angular/" diff --git a/scripts/watch/client/tsc.sh b/scripts/watch/client/tsc.sh new file mode 100755 index 000000000..f00656d2e --- /dev/null +++ b/scripts/watch/client/tsc.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +cd client || exit -1 + +npm run tsc:w -- cgit v1.2.3