aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/danger/clean
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/danger/clean')
-rw-r--r--scripts/danger/clean/cleaner.js23
-rwxr-xr-xscripts/danger/clean/dev.sh7
-rwxr-xr-xscripts/danger/clean/modules.sh2
-rwxr-xr-xscripts/danger/clean/prod.sh7
-rwxr-xr-xscripts/danger/clean/server.sh8
5 files changed, 38 insertions, 9 deletions
diff --git a/scripts/danger/clean/cleaner.js b/scripts/danger/clean/cleaner.js
new file mode 100644
index 000000000..a63c478e0
--- /dev/null
+++ b/scripts/danger/clean/cleaner.js
@@ -0,0 +1,23 @@
1const rimraf = require('rimraf')
2const mongoose = require('mongoose')
3
4const constants = require('../../../server/initializers/constants')
5
6const mongodbUrl = 'mongodb://' + constants.CONFIG.DATABASE.HOST + ':' + constants.CONFIG.DATABASE.PORT + '/' + constants.CONFIG.DATABASE.DBNAME
7mongoose.connect(mongodbUrl, function () {
8 console.info('Deleting MongoDB %s database.', constants.CONFIG.DATABASE.DBNAME)
9 mongoose.connection.db.dropDatabase(function () {
10 mongoose.connection.close()
11 })
12})
13
14const STORAGE = constants.CONFIG.STORAGE
15Object.keys(STORAGE).forEach(function (storage) {
16 const storageDir = STORAGE[storage]
17
18 rimraf(storageDir, function (err) {
19 if (err) throw err
20
21 console.info('Deleting %s.', storageDir)
22 })
23})
diff --git a/scripts/danger/clean/dev.sh b/scripts/danger/clean/dev.sh
new file mode 100755
index 000000000..5f09565cf
--- /dev/null
+++ b/scripts/danger/clean/dev.sh
@@ -0,0 +1,7 @@
1#!/bin/bash
2
3read -p "This will remove all directories and Mongo database. Are you sure? " -n 1 -r
4
5if [[ "$REPLY" =~ ^[Yy]$ ]]; then
6 NODE_ENV=test node "./scripts/danger/clean/cleaner"
7fi
diff --git a/scripts/danger/clean/modules.sh b/scripts/danger/clean/modules.sh
index 429044b3f..99555a693 100755
--- a/scripts/danger/clean/modules.sh
+++ b/scripts/danger/clean/modules.sh
@@ -1,6 +1,6 @@
1#!/bin/bash 1#!/bin/bash
2 2
3read -p "This will remove all node and typescript modules. Are you sure? " -n 1 -r 3read -p "This will remove all node server and client modules. Are you sure? " -n 1 -r
4 4
5if [[ "$REPLY" =~ ^[Yy]$ ]]; then 5if [[ "$REPLY" =~ ^[Yy]$ ]]; then
6 rm -rf node_modules client/node_modules 6 rm -rf node_modules client/node_modules
diff --git a/scripts/danger/clean/prod.sh b/scripts/danger/clean/prod.sh
new file mode 100755
index 000000000..e6c92671d
--- /dev/null
+++ b/scripts/danger/clean/prod.sh
@@ -0,0 +1,7 @@
1#!/bin/bash
2
3read -p "This will remove all directories and Mongo database. Are you sure? " -n 1 -r
4
5if [[ "$REPLY" =~ ^[Yy]$ ]]; then
6 NODE_ENV=production node "./scripts/danger/clean/cleaner"
7fi
diff --git a/scripts/danger/clean/server.sh b/scripts/danger/clean/server.sh
deleted file mode 100755
index 1a0576112..000000000
--- a/scripts/danger/clean/server.sh
+++ /dev/null
@@ -1,8 +0,0 @@
1#!/bin/bash
2
3read -p "This will remove certs, uploads, database (dev) and logs. Are you sure? " -n 1 -r
4
5if [[ "$REPLY" =~ ^[Yy]$ ]]; then
6 rm -rf ./certs ./logs ./uploads
7 printf "use peertube-dev;\ndb.dropDatabase();" | mongo
8fi