From e94324c7a4d4e293fe3e38fa3c1becec146372e9 Mon Sep 17 00:00:00 2001
From: drebs <drebs@leap.se>
Date: Thu, 19 May 2016 22:04:48 -0300
Subject: [refactor] reorganize scripts dir

---
 scripts/build_debian_package.sh           |  32 ---------
 scripts/compile_design_docs.py            | 111 ------------------------------
 scripts/develop_mode.sh                   |   7 --
 scripts/packaging/build_debian_package.sh |  32 +++++++++
 scripts/packaging/compile_design_docs.py  | 111 ++++++++++++++++++++++++++++++
 scripts/run_tests.sh                      |   3 -
 scripts/testing/develop_mode.sh           |   7 ++
 7 files changed, 150 insertions(+), 153 deletions(-)
 delete mode 100755 scripts/build_debian_package.sh
 delete mode 100644 scripts/compile_design_docs.py
 delete mode 100755 scripts/develop_mode.sh
 create mode 100755 scripts/packaging/build_debian_package.sh
 create mode 100644 scripts/packaging/compile_design_docs.py
 delete mode 100755 scripts/run_tests.sh
 create mode 100755 scripts/testing/develop_mode.sh

(limited to 'scripts')

diff --git a/scripts/build_debian_package.sh b/scripts/build_debian_package.sh
deleted file mode 100755
index b9fb93a9..00000000
--- a/scripts/build_debian_package.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-# This script generates Soledad Debian packages.
-#
-# When invoking this script, you should pass a git repository URL and the name
-# of the branch that contains the code you wish to build the packages from.
-#
-# The script will clone the given branch from the given repo, as well as the
-# main Soledad repo in github which contains the most up-to-date debian
-# branch. It will then merge the desired branch into the debian branch and
-# build the packages.
-
-if [ $# -ne 2 ]; then
-  echo "Usage: ${0} <url> <branch>"
-  exit 1
-fi
-
-SOLEDAD_MAIN_REPO=git://github.com/leapcode/soledad.git
-
-url=$1
-branch=$2
-workdir=`mktemp -d`
-
-git clone -b ${branch} ${url} ${workdir}/soledad
-export GIT_DIR=${workdir}/soledad/.git
-export GIT_WORK_TREE=${workdir}/soledad
-git remote add leapcode ${SOLEDAD_MAIN_REPO}
-git fetch leapcode
-git checkout -b debian/experimental leapcode/debian/experimental
-git merge --no-edit ${branch}
-(cd ${workdir}/soledad && debuild -uc -us)
-echo "Packages generated in ${workdir}"
diff --git a/scripts/compile_design_docs.py b/scripts/compile_design_docs.py
deleted file mode 100644
index 7ffebb10..00000000
--- a/scripts/compile_design_docs.py
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/usr/bin/python
-
-
-# This script builds files for the design documents represented in the
-# ../common/src/soledad/common/ddocs directory structure (relative to the
-# current location of the script) into a target directory.
-
-
-import argparse
-from os import listdir
-from os.path import realpath, dirname, isdir, join, isfile, basename
-import json
-
-DDOCS_REL_PATH = ('..', 'common', 'src', 'leap', 'soledad', 'common', 'ddocs')
-
-
-def build_ddocs():
-    """
-    Build design documents.
-
-    For ease of development, couch backend design documents are stored as
-    `.js` files in  subdirectories of
-    `../common/src/leap/soledad/common/ddocs`. This function scans that
-    directory for javascript files, and builds the design documents structure.
-
-    This funciton uses the following conventions to generate design documents:
-
-      - Design documents are represented by directories in the form
-        `<prefix>/<ddoc>`, there prefix is the `src/leap/soledad/common/ddocs`
-        directory.
-      - Design document directories might contain `views`, `lists` and
-        `updates` subdirectories.
-      - Views subdirectories must contain a `map.js` file and may contain a
-        `reduce.js` file.
-      - List and updates subdirectories may contain any number of javascript
-        files (i.e. ending in `.js`) whose names will be mapped to the
-        corresponding list or update function name.
-    """
-    ddocs = {}
-
-    # design docs are represented by subdirectories of `DDOCS_REL_PATH`
-    cur_pwd = dirname(realpath(__file__))
-    ddocs_path = join(cur_pwd, *DDOCS_REL_PATH)
-    for ddoc in [f for f in listdir(ddocs_path)
-                 if isdir(join(ddocs_path, f))]:
-
-        ddocs[ddoc] = {'_id': '_design/%s' % ddoc}
-
-        for t in ['views', 'lists', 'updates']:
-            tdir = join(ddocs_path, ddoc, t)
-            if isdir(tdir):
-
-                ddocs[ddoc][t] = {}
-
-                if t == 'views':  # handle views (with map/reduce functions)
-                    for view in [f for f in listdir(tdir)
-                                 if isdir(join(tdir, f))]:
-                        # look for map.js and reduce.js
-                        mapfile = join(tdir, view, 'map.js')
-                        reducefile = join(tdir, view, 'reduce.js')
-                        mapfun = None
-                        reducefun = None
-                        try:
-                            with open(mapfile) as f:
-                                mapfun = f.read()
-                        except IOError:
-                            pass
-                        try:
-                            with open(reducefile) as f:
-                                reducefun = f.read()
-                        except IOError:
-                            pass
-                        ddocs[ddoc]['views'][view] = {}
-
-                        if mapfun is not None:
-                            ddocs[ddoc]['views'][view]['map'] = mapfun
-                        if reducefun is not None:
-                            ddocs[ddoc]['views'][view]['reduce'] = reducefun
-
-                else:  # handle lists, updates, etc
-                    for fun in [f for f in listdir(tdir)
-                                if isfile(join(tdir, f))]:
-                        funfile = join(tdir, fun)
-                        funname = basename(funfile).replace('.js', '')
-                        try:
-                            with open(funfile) as f:
-                                ddocs[ddoc][t][funname] = f.read()
-                        except IOError:
-                            pass
-    return ddocs
-
-
-if __name__ == '__main__':
-    parser = argparse.ArgumentParser()
-    parser.add_argument(
-        'target', type=str,
-        help='the target dir where to store design documents')
-    args = parser.parse_args()
-
-    # check if given target is a directory
-    if not isdir(args.target):
-        print 'Error: %s is not a directory.' % args.target
-        exit(1)
-
-    # write desifgn docs files
-    ddocs = build_ddocs()
-    for ddoc in ddocs:
-        ddoc_filename = "%s.json" % ddoc
-        with open(join(args.target, ddoc_filename), 'w') as f:
-            f.write("%s" % json.dumps(ddocs[ddoc], indent=3))
-        print "Wrote _design/%s content in %s" % (ddoc, join(args.target, ddoc_filename,))
diff --git a/scripts/develop_mode.sh b/scripts/develop_mode.sh
deleted file mode 100755
index 8d2ebaa8..00000000
--- a/scripts/develop_mode.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-cd common
-python setup.py develop
-cd ../client
-python setup.py develop
-cd ../server
-python setup.py develop
diff --git a/scripts/packaging/build_debian_package.sh b/scripts/packaging/build_debian_package.sh
new file mode 100755
index 00000000..b9fb93a9
--- /dev/null
+++ b/scripts/packaging/build_debian_package.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# This script generates Soledad Debian packages.
+#
+# When invoking this script, you should pass a git repository URL and the name
+# of the branch that contains the code you wish to build the packages from.
+#
+# The script will clone the given branch from the given repo, as well as the
+# main Soledad repo in github which contains the most up-to-date debian
+# branch. It will then merge the desired branch into the debian branch and
+# build the packages.
+
+if [ $# -ne 2 ]; then
+  echo "Usage: ${0} <url> <branch>"
+  exit 1
+fi
+
+SOLEDAD_MAIN_REPO=git://github.com/leapcode/soledad.git
+
+url=$1
+branch=$2
+workdir=`mktemp -d`
+
+git clone -b ${branch} ${url} ${workdir}/soledad
+export GIT_DIR=${workdir}/soledad/.git
+export GIT_WORK_TREE=${workdir}/soledad
+git remote add leapcode ${SOLEDAD_MAIN_REPO}
+git fetch leapcode
+git checkout -b debian/experimental leapcode/debian/experimental
+git merge --no-edit ${branch}
+(cd ${workdir}/soledad && debuild -uc -us)
+echo "Packages generated in ${workdir}"
diff --git a/scripts/packaging/compile_design_docs.py b/scripts/packaging/compile_design_docs.py
new file mode 100644
index 00000000..7ffebb10
--- /dev/null
+++ b/scripts/packaging/compile_design_docs.py
@@ -0,0 +1,111 @@
+#!/usr/bin/python
+
+
+# This script builds files for the design documents represented in the
+# ../common/src/soledad/common/ddocs directory structure (relative to the
+# current location of the script) into a target directory.
+
+
+import argparse
+from os import listdir
+from os.path import realpath, dirname, isdir, join, isfile, basename
+import json
+
+DDOCS_REL_PATH = ('..', 'common', 'src', 'leap', 'soledad', 'common', 'ddocs')
+
+
+def build_ddocs():
+    """
+    Build design documents.
+
+    For ease of development, couch backend design documents are stored as
+    `.js` files in  subdirectories of
+    `../common/src/leap/soledad/common/ddocs`. This function scans that
+    directory for javascript files, and builds the design documents structure.
+
+    This funciton uses the following conventions to generate design documents:
+
+      - Design documents are represented by directories in the form
+        `<prefix>/<ddoc>`, there prefix is the `src/leap/soledad/common/ddocs`
+        directory.
+      - Design document directories might contain `views`, `lists` and
+        `updates` subdirectories.
+      - Views subdirectories must contain a `map.js` file and may contain a
+        `reduce.js` file.
+      - List and updates subdirectories may contain any number of javascript
+        files (i.e. ending in `.js`) whose names will be mapped to the
+        corresponding list or update function name.
+    """
+    ddocs = {}
+
+    # design docs are represented by subdirectories of `DDOCS_REL_PATH`
+    cur_pwd = dirname(realpath(__file__))
+    ddocs_path = join(cur_pwd, *DDOCS_REL_PATH)
+    for ddoc in [f for f in listdir(ddocs_path)
+                 if isdir(join(ddocs_path, f))]:
+
+        ddocs[ddoc] = {'_id': '_design/%s' % ddoc}
+
+        for t in ['views', 'lists', 'updates']:
+            tdir = join(ddocs_path, ddoc, t)
+            if isdir(tdir):
+
+                ddocs[ddoc][t] = {}
+
+                if t == 'views':  # handle views (with map/reduce functions)
+                    for view in [f for f in listdir(tdir)
+                                 if isdir(join(tdir, f))]:
+                        # look for map.js and reduce.js
+                        mapfile = join(tdir, view, 'map.js')
+                        reducefile = join(tdir, view, 'reduce.js')
+                        mapfun = None
+                        reducefun = None
+                        try:
+                            with open(mapfile) as f:
+                                mapfun = f.read()
+                        except IOError:
+                            pass
+                        try:
+                            with open(reducefile) as f:
+                                reducefun = f.read()
+                        except IOError:
+                            pass
+                        ddocs[ddoc]['views'][view] = {}
+
+                        if mapfun is not None:
+                            ddocs[ddoc]['views'][view]['map'] = mapfun
+                        if reducefun is not None:
+                            ddocs[ddoc]['views'][view]['reduce'] = reducefun
+
+                else:  # handle lists, updates, etc
+                    for fun in [f for f in listdir(tdir)
+                                if isfile(join(tdir, f))]:
+                        funfile = join(tdir, fun)
+                        funname = basename(funfile).replace('.js', '')
+                        try:
+                            with open(funfile) as f:
+                                ddocs[ddoc][t][funname] = f.read()
+                        except IOError:
+                            pass
+    return ddocs
+
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser()
+    parser.add_argument(
+        'target', type=str,
+        help='the target dir where to store design documents')
+    args = parser.parse_args()
+
+    # check if given target is a directory
+    if not isdir(args.target):
+        print 'Error: %s is not a directory.' % args.target
+        exit(1)
+
+    # write desifgn docs files
+    ddocs = build_ddocs()
+    for ddoc in ddocs:
+        ddoc_filename = "%s.json" % ddoc
+        with open(join(args.target, ddoc_filename), 'w') as f:
+            f.write("%s" % json.dumps(ddocs[ddoc], indent=3))
+        print "Wrote _design/%s content in %s" % (ddoc, join(args.target, ddoc_filename,))
diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh
deleted file mode 100755
index e36466f8..00000000
--- a/scripts/run_tests.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-cd common
-python setup.py test
diff --git a/scripts/testing/develop_mode.sh b/scripts/testing/develop_mode.sh
new file mode 100755
index 00000000..8d2ebaa8
--- /dev/null
+++ b/scripts/testing/develop_mode.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+cd common
+python setup.py develop
+cd ../client
+python setup.py develop
+cd ../server
+python setup.py develop
-- 
cgit v1.2.3