]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Use scripty instead of writing shell commands in package.json
authorChocobozzz <florian.bigard@gmail.com>
Sat, 30 Apr 2016 09:17:50 +0000 (11:17 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Sat, 30 Apr 2016 10:56:36 +0000 (12:56 +0200)
18 files changed:
bin/clean_test.sh [deleted file]
bin/run_servers.sh [deleted file]
config/default.yaml
package.json
scripts/build/client/sass.sh [new file with mode: 0755]
scripts/build/client/tsc.sh [new file with mode: 0755]
scripts/clean/client/sass.sh [new file with mode: 0755]
scripts/clean/client/tsc.sh [new file with mode: 0755]
scripts/clean/server/test.sh [new file with mode: 0755]
scripts/danger/clean/modules.sh [new file with mode: 0755]
scripts/danger/clean/server.sh [new file with mode: 0755]
scripts/dev.sh [new file with mode: 0755]
scripts/help.sh [new file with mode: 0755]
scripts/play.sh [new file with mode: 0755]
scripts/test.sh [new file with mode: 0755]
scripts/watch/client/sass.sh [new file with mode: 0755]
scripts/watch/client/tsc.sh [new file with mode: 0755]
server/tests/api/utils.js

diff --git a/bin/clean_test.sh b/bin/clean_test.sh
deleted file mode 100755 (executable)
index ef146e0..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-basePath=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
-
-for i in $(seq 1 6); do
-  printf "use peertube-test%s;\ndb.dropDatabase();" "$i" | mongo
-  rm -rf "$basePath/../test$i"
-done
diff --git a/bin/run_servers.sh b/bin/run_servers.sh
deleted file mode 100755 (executable)
index 8376817..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-if [ ! -f server.js ]; then
-  echo "The script has to be executed at the root of the project."
-  exit -1
-fi
-
-NODE_ENV=test NODE_APP_INSTANCE=1 node server.js &
-sleep 1
-NODE_ENV=test NODE_APP_INSTANCE=2 node server.js &
-sleep 1
-NODE_ENV=test NODE_APP_INSTANCE=3 node server.js &
index 646113da4ede19654059924eb0994ed4858ff09c..be161640ca4c2a6af450b6008ee83be4b95a9774 100644 (file)
@@ -9,7 +9,7 @@ webserver:
 database:
   host: 'localhost'
   port: 27017
-  suffix: '-suffix'
+  suffix: '-dev'
 
 # From the project root directory
 storage:
index a9d053f6e39bcc44a46ad4dcbbada6509f65a20a..32c0d31f6ff89a6f7ba956eadbc7be2bc7996bf7 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "peertube",
-  "description": "Prototype of a decentralized video streaming platform using P2P (bittorent) directly in the web browser with webtorrent.",
+  "description": "Prototype of a decentralized video streaming platform using P2P (bittorent) directly in the web browser with WebTorrent and Angular 2.",
   "version": "0.0.1",
   "private": true,
   "licence": "GPLv3",
     "url": "git://github.com/Chocobozzz/PeerTube.git"
   },
   "scripts": {
-    "build": "concurrently \"npm run client:sass\" \"npm run client:tsc\"",
-    "client:clean": "concurrently \"npm run client:tsc:clean\" \"npm run client:sass:clean\"",
-    "client:sass:index": "npm run client:sass:index:clean && cd client && node-sass --include-path node_modules/bootstrap-sass/assets/stylesheets/ stylesheets/application.scss stylesheets/index.css",
-    "client:sass:index:watch": "cd client && node-sass -w --include-path node_modules/bootstrap-sass/assets/stylesheets/ stylesheets/application.scss stylesheets/index.css client/angular/**/ client/angular/**/**",
-    "client:sass:index:clean": "cd client && rm -f stylesheets/index.css",
-    "client:sass:angular": "cd client && node-sass angular/ --output angular/",
-    "client:sass:angular:watch": "cd client && node-sass -w angular/ --output angular/",
-    "client:sass:angular:clean": "cd client && rm -f angular/**/*.css",
-    "client:sass": "concurrently \"npm run client:sass:index\" \"npm run client:sass:angular\"",
-    "client:sass:watch": "concurrently \"npm run client:sass:index:watch\" \"npm run client:sass:angular:watch\"",
-    "client:sass:clean": "concurrently \"npm run client:sass:index:clean\" \"npm run client:sass:angular:clean\"",
-    "client:tsc": "cd client && npm run tsc",
-    "client:tsc:watch": "cd client && npm run tsc:w",
-    "client:tsc:clean": "cd client && find angular -regextype posix-egrep -regex \".*\\.(js|map)$\" -exec rm -f {} \\;",
-    "dev": "npm run build && NODE_ENV=test concurrently \"npm run livereload\" \"npm run client:tsc:watch\" \"npm run client:sass:watch\" \"npm start\"",
+    "build": "npm run build:client",
+    "build:client": "SCRIPTY_PARALLEL=true scripty",
+    "build:client:sass": "scripty",
+    "build:client:tsc": "scripty",
+    "clean": "SCRIPTY_PARALLEL=true scripty",
+    "clean:client": "SCRIPTY_PARALLEL=true scripty",
+    "clean:client:sass": "scripty",
+    "clean:client:tsc": "scripty",
+    "clean:server:test": "scripty",
+    "watch:client": "SCRIPTY_PARALLEL=true scripty",
+    "watch:client:sass": "scripty",
+    "watch:client:tsc": "scripty",
+    "danger:clean:server": "scripty",
+    "danger:clean:modules": "scripty",
+    "play": "scripty",
+    "dev": "scripty",
     "livereload": "livereload ./client",
     "start": "node server",
-    "test": "cd client && npm test && cd .. && standard && mocha server/tests",
+    "test": "scripty",
+    "help": "scripty",
     "postinstall": "cd client && npm install"
   },
   "dependencies": {
@@ -73,6 +75,7 @@
     "mocha": "^2.3.3",
     "node-livereload": "^0.6.0",
     "node-sass": "^3.4.2",
+    "scripty": "^1.5.0",
     "standard": "^6.0.1",
     "supertest": "^1.1.0"
   },
diff --git a/scripts/build/client/sass.sh b/scripts/build/client/sass.sh
new file mode 100755 (executable)
index 0000000..0caa0df
--- /dev/null
@@ -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 (executable)
index 0000000..ec06b64
--- /dev/null
@@ -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 (executable)
index 0000000..82c079f
--- /dev/null
@@ -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 (executable)
index 0000000..775157a
--- /dev/null
@@ -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 (executable)
index 0000000..927671d
--- /dev/null
@@ -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 (executable)
index 0000000..1aa6c73
--- /dev/null
@@ -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 (executable)
index 0000000..0a85eb2
--- /dev/null
@@ -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 (executable)
index 0000000..d617cd5
--- /dev/null
@@ -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 (executable)
index 0000000..3ed9f15
--- /dev/null
@@ -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 (executable)
index 0000000..33dc1a5
--- /dev/null
@@ -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 (executable)
index 0000000..93dbd82
--- /dev/null
@@ -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 (executable)
index 0000000..7d716cb
--- /dev/null
@@ -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 (executable)
index 0000000..f00656d
--- /dev/null
@@ -0,0 +1,5 @@
+#!/usr/bin/env sh
+
+cd client || exit -1
+
+npm run tsc:w
index d37e12cb207df3ff36d023ccce2e2fa795e57514..c1a01ef372252ca22e069bc672079f48f47268d6 100644 (file)
@@ -25,7 +25,7 @@ const testUtils = {
 // ---------------------- Export functions --------------------
 
 function flushTests (callback) {
-  exec(pathUtils.join(__dirname, '../../../bin/clean_test.sh'), callback)
+  exec('npm run clean:server:test', callback)
 }
 
 function getFriendsList (url, end) {