We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
webpack-stats.json does not get built on Travis CI
```console
E           OSError: Error reading /home/travis/build/ddionrails/ddionrails/webpack-stats.json. Are you sure webpack has generated the file and the path is correct?
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pavement.py`
Content:
```
1 """
2 Pavement file
3 """
4 import os
5 import shutil
6 import socket
7 import sys
8 
9 import django
10 from django.conf import settings
11 from django.core import management
12 from paver.easy import task
13 
14 sys.path.append(".")
15 
16 hostname = socket.gethostname()
17 
18 if hostname == "hewing":
19     local_settings = "hewing"
20 elif hostname == "paneldata":
21     local_settings = "production"
22 else:
23     local_settings = "development"
24 
25 print("[INFO] Using %s settings." % local_settings)
26 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.%s" % local_settings)
27 
28 
29 ### Helper functions ###
30 
31 
32 def info(text):
33     print("\n[INFO] %s" % text)
34 
35 
36 def run(script):
37     for line in script.strip().split("\n"):
38         print("\n[SYSTEM] %s" % line.strip())
39     os.system(script)
40 
41 
42 def init_development_db():
43     """Init development database."""
44     django.setup()
45     run("rm -f db/db.sqlite3")
46     management.call_command("migrate")
47 
48 
49 def elastic_server():
50     return "%s:%s/%s" % (settings.INDEX_HOST, settings.INDEX_PORT, settings.INDEX_NAME)
51 
52 
53 ### Tasks ###
54 
55 
56 @task
57 def which_system():
58     print("[INFO] System repo:  ", settings.SYSTEM_REPO_URL)
59     print("[INFO] Import branch:", settings.IMPORT_BRANCH)
60 
61 
62 @task
63 def rqworker():
64     """Start Redis worker."""
65     django.setup()
66     management.call_command("rqworker")
67 
68 
69 @task
70 def install_elastic():
71     """Install Elasticsearch."""
72     run(
73         """
74         rm -rf db/elasticsearch
75         wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.2/elasticsearch-2.4.2.tar.gz
76         tar xzvf elasticsearch*.tar.gz
77         rm elasticsearch*.tar.gz
78         mv elasticsearch* db/elasticsearch
79     """
80     )
81 
82 
83 @task
84 def elastic():
85     """Start Elasticsearch as a foreground process."""
86     run("./db/elasticsearch/bin/elasticsearch")
87 
88 
89 @task
90 def delete_index():
91     "Delete the index."
92     run("curl -XDELETE '%s'" % elastic_server())
93     print()
94 
95 
96 @task
97 def create_index():
98     "Create the index from the elastic/mapping.json file."
99     run("curl -s -XPOST '%s' -d@elastic/mapping.json" % elastic_server())
100     print()
101 
102 
103 @task
104 def reset_index():
105     """Delete index, update mapping, create index."""
106     delete_index()
107     run("yaml2json elastic/mapping.yaml > elastic/mapping.json")
108     create_index()
109 
110 
111 @task
112 def docu():
113     """Run the docu make script (no delete)."""
114     run("cd ../docs; make html")
115 
116 
117 @task
118 def full_docu():
119     """Completely rebuild the docu."""
120     run("cd ../docs; rm -r _build; make html")
121 
122 
123 @task
124 def fire_docu():
125     """Open docu in Firefox."""
126     run("firefox ../docs/_build/html/index.html")
127 
128 
129 @task
130 def chrome_docu():
131     """Open docu in Google Chrome."""
132     run("google-chrome ../docs/_build/html/index.html")
133 
134 
135 @task
136 def server():
137     """Start development server."""
138     django.setup()
139     management.call_command("runserver_plus")
140 
141 
142 @task
143 def setup_virtualenv():
144     """Setup virtualenv in: ~/.envs/ddionrails2/"""
145     run(
146         """
147         mkdir -p ~/.envs
148         virtualenv -p /usr/bin/python3.4 ~/.envs/ddionrails2
149         source ~/.envs/ddionrails2/bin/activate
150         pip install -r requirements.txt
151     """
152     )
153 
154 
155 @task
156 def freeze_requirements():
157     """Freeze requirements."""
158     run("pip freeze > requirements.txt")
159 
160 
161 @task
162 def test_env():
163     """Rebuild the database and delete all repositories."""
164     django.setup()
165     run(
166         """
167         rm db/db.sqlite3
168         ./manage.py migrate
169         rm -rf static/repositories/*
170         touch static/repositories/.gitkeep
171         chmod 666 db/db.sqlite3
172     """
173     )
174     delete_index()
175     create_index()
176 
177 
178 @task
179 def test_su():
180     """Create superuser "admin" with password "testtest"."""
181     from django.contrib.auth.models import User
182 
183     django.setup()
184     User.objects.create_superuser("admin", "admin@example.com", "testtest")
185 
186 
187 @task
188 def import_system():
189     """Run scripts: system."""
190     django.setup()
191     run("./manage.py runscript scripts.system --settings=settings.%s" % local_settings)
192 
193 
194 @task
195 def import_all_studies():
196     """Run scripts: import."""
197     django.setup()
198     run("./manage.py runscript scripts.import_studies --settings=settings.%s" % local_settings)
199 
200 
201 @task
202 def copy_secrets_file():
203     """ Copy the secrets.json.example and rename it to secrets.json """
204     shutil.copyfile("secrets.json.example", "secrets.json")
205 
206 
207 @task
208 def full_test():
209     """Rebuild the test environment and import data."""
210     copy_secrets_file()
211     django.setup()
212     test_env()
213     if local_settings == "development":
214         test_su()
215     import_system()
216     import_all_studies()
217 
218 
219 @task
220 def clean_cache():
221     run("py3clean .")
222 
223 
224 @task
225 def reset_migrations():
226     """Reset all migrations."""
227     django.setup()
228     clean_cache()
229     run(
230         """
231             rm */migrations/0*
232             ./manage.py makemigrations
233         """
234     )
235 
236 
237 @task
238 def full_push():
239     """Merge development branch into master and push all branches."""
240     run(
241         """
242             git checkout master
243             git merge development
244             git checkout development
245             git push --all
246         """
247     )
248 
249 
250 @task
251 def erd():
252     """Create and open ERD file"""
253     django.setup()
254     run(
255         """
256             ./manage.py graph_models -a > local/erd.dot
257             cd local
258             dot erd.dot -T pdf > erd.pdf
259             evince erd.pdf
260         """
261     )
262 
263 
264 @task
265 def shell():
266     """Use django-extensions shell_plus."""
267     django.setup()
268     management.call_command("shell_plus")
269 
270 
271 @task
272 def migrate():
273     """Make and run migrations."""
274     django.setup()
275     management.call_command("makemigrations")
276     management.call_command("migrate")
277 
278 
279 @task
280 def rq_test():
281     """Test the RQ worker."""
282     django.setup()
283     run("""./manage.py runscript scripts.rq_test""")
284 
285 
286 @task
287 def zip_elastic():
288     """Create a ZIP file of the elastic directory"""
289     run(
290         """
291             cd db
292             rm elastic.zip
293             zip -r elastic.zip elasticsearch/
294         """
295     )
296 
297 
298 @task
299 def elastic_search_javascript_library():
300     """ Build the search library for ddionrails """
301     # TODO: This is a workaround. The library should be bundled with webpack directly.
302     # see: https://v5.angular.io/guide/webpack
303     # see: https://www.twilio.com/blog/2018/03/building-an-app-from-scratch-with-angular-and-webpack.html
304     run(
305         """
306             cd ./node_modules/ddionrails-elasticsearch
307             npm install --save-dev
308             ./node_modules/.bin/ng build --prod
309         """
310     )
311 
312 
313 @task
314 def webpack():
315     """ Create webpack bundles """
316     run("""./node_modules/.bin/webpack --config webpack.config.js""")
317 
318 
319 @task
320 def setup_frontend():
321     """ Setup all frontend dependencies """
322     run("""npm install --save-dev""")
323     elastic_search_javascript_library()
324     webpack()
325 
326 
327 @task
328 def setup_pipenv():
329     run("""pipenv install --dev""")
330 
331 
332 @task
333 def init():
334     setup_pipenv()
335     setup_frontend()
336 
337 
338 @task
339 def test():
340     """ Test the project without selenium tests """
341     os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.testing")
342     django.setup()
343     run("""pytest -v -m "not functional" """)
344 
345 
346 @task
347 def system_test():
348     """ Test the project with selenium tests """
349     os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.testing")
350     django.setup()
351     run("""pytest -v -m functional """)
352
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pavement.py b/pavement.py
--- a/pavement.py
+++ b/pavement.py
@@ -304,7 +304,7 @@
     run(
         """
             cd ./node_modules/ddionrails-elasticsearch
-            npm install --save-dev
+            npm install
             ./node_modules/.bin/ng build --prod
         """
     )
@@ -319,7 +319,7 @@
 @task
 def setup_frontend():
     """ Setup all frontend dependencies """
-    run("""npm install --save-dev""")
+    run("""npm install""")
     elastic_search_javascript_library()
     webpack()

{"golden_diff": "diff --git a/pavement.py b/pavement.py\n--- a/pavement.py\n+++ b/pavement.py\n@@ -304,7 +304,7 @@\n     run(\n         \"\"\"\n             cd ./node_modules/ddionrails-elasticsearch\n-            npm install --save-dev\n+            npm install\n             ./node_modules/.bin/ng build --prod\n         \"\"\"\n     )\n@@ -319,7 +319,7 @@\n @task\n def setup_frontend():\n     \"\"\" Setup all frontend dependencies \"\"\"\n-    run(\"\"\"npm install --save-dev\"\"\")\n+    run(\"\"\"npm install\"\"\")\n     elastic_search_javascript_library()\n     webpack()\n", "issue": "webpack-stats.json does not get built on Travis CI\n```console\r\nE           OSError: Error reading /home/travis/build/ddionrails/ddionrails/webpack-stats.json. Are you sure webpack has generated the file and the path is correct?\r\n```\n", "before_files": [{"content": "\"\"\"\nPavement file\n\"\"\"\nimport os\nimport shutil\nimport socket\nimport sys\n\nimport django\nfrom django.conf import settings\nfrom django.core import management\nfrom paver.easy import task\n\nsys.path.append(\".\")\n\nhostname = socket.gethostname()\n\nif hostname == \"hewing\":\n    local_settings = \"hewing\"\nelif hostname == \"paneldata\":\n    local_settings = \"production\"\nelse:\n    local_settings = \"development\"\n\nprint(\"[INFO] Using %s settings.\" % local_settings)\nos.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"settings.%s\" % local_settings)\n\n\n### Helper functions ###\n\n\ndef info(text):\n    print(\"\\n[INFO] %s\" % text)\n\n\ndef run(script):\n    for line in script.strip().split(\"\\n\"):\n        print(\"\\n[SYSTEM] %s\" % line.strip())\n    os.system(script)\n\n\ndef init_development_db():\n    \"\"\"Init development database.\"\"\"\n    django.setup()\n    run(\"rm -f db/db.sqlite3\")\n    management.call_command(\"migrate\")\n\n\ndef elastic_server():\n    return \"%s:%s/%s\" % (settings.INDEX_HOST, settings.INDEX_PORT, settings.INDEX_NAME)\n\n\n### Tasks ###\n\n\n@task\ndef which_system():\n    print(\"[INFO] System repo:  \", settings.SYSTEM_REPO_URL)\n    print(\"[INFO] Import branch:\", settings.IMPORT_BRANCH)\n\n\n@task\ndef rqworker():\n    \"\"\"Start Redis worker.\"\"\"\n    django.setup()\n    management.call_command(\"rqworker\")\n\n\n@task\ndef install_elastic():\n    \"\"\"Install Elasticsearch.\"\"\"\n    run(\n        \"\"\"\n        rm -rf db/elasticsearch\n        wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.2/elasticsearch-2.4.2.tar.gz\n        tar xzvf elasticsearch*.tar.gz\n        rm elasticsearch*.tar.gz\n        mv elasticsearch* db/elasticsearch\n    \"\"\"\n    )\n\n\n@task\ndef elastic():\n    \"\"\"Start Elasticsearch as a foreground process.\"\"\"\n    run(\"./db/elasticsearch/bin/elasticsearch\")\n\n\n@task\ndef delete_index():\n    \"Delete the index.\"\n    run(\"curl -XDELETE '%s'\" % elastic_server())\n    print()\n\n\n@task\ndef create_index():\n    \"Create the index from the elastic/mapping.json file.\"\n    run(\"curl -s -XPOST '%s' -d@elastic/mapping.json\" % elastic_server())\n    print()\n\n\n@task\ndef reset_index():\n    \"\"\"Delete index, update mapping, create index.\"\"\"\n    delete_index()\n    run(\"yaml2json elastic/mapping.yaml > elastic/mapping.json\")\n    create_index()\n\n\n@task\ndef docu():\n    \"\"\"Run the docu make script (no delete).\"\"\"\n    run(\"cd ../docs; make html\")\n\n\n@task\ndef full_docu():\n    \"\"\"Completely rebuild the docu.\"\"\"\n    run(\"cd ../docs; rm -r _build; make html\")\n\n\n@task\ndef fire_docu():\n    \"\"\"Open docu in Firefox.\"\"\"\n    run(\"firefox ../docs/_build/html/index.html\")\n\n\n@task\ndef chrome_docu():\n    \"\"\"Open docu in Google Chrome.\"\"\"\n    run(\"google-chrome ../docs/_build/html/index.html\")\n\n\n@task\ndef server():\n    \"\"\"Start development server.\"\"\"\n    django.setup()\n    management.call_command(\"runserver_plus\")\n\n\n@task\ndef setup_virtualenv():\n    \"\"\"Setup virtualenv in: ~/.envs/ddionrails2/\"\"\"\n    run(\n        \"\"\"\n        mkdir -p ~/.envs\n        virtualenv -p /usr/bin/python3.4 ~/.envs/ddionrails2\n        source ~/.envs/ddionrails2/bin/activate\n        pip install -r requirements.txt\n    \"\"\"\n    )\n\n\n@task\ndef freeze_requirements():\n    \"\"\"Freeze requirements.\"\"\"\n    run(\"pip freeze > requirements.txt\")\n\n\n@task\ndef test_env():\n    \"\"\"Rebuild the database and delete all repositories.\"\"\"\n    django.setup()\n    run(\n        \"\"\"\n        rm db/db.sqlite3\n        ./manage.py migrate\n        rm -rf static/repositories/*\n        touch static/repositories/.gitkeep\n        chmod 666 db/db.sqlite3\n    \"\"\"\n    )\n    delete_index()\n    create_index()\n\n\n@task\ndef test_su():\n    \"\"\"Create superuser \"admin\" with password \"testtest\".\"\"\"\n    from django.contrib.auth.models import User\n\n    django.setup()\n    User.objects.create_superuser(\"admin\", \"admin@example.com\", \"testtest\")\n\n\n@task\ndef import_system():\n    \"\"\"Run scripts: system.\"\"\"\n    django.setup()\n    run(\"./manage.py runscript scripts.system --settings=settings.%s\" % local_settings)\n\n\n@task\ndef import_all_studies():\n    \"\"\"Run scripts: import.\"\"\"\n    django.setup()\n    run(\"./manage.py runscript scripts.import_studies --settings=settings.%s\" % local_settings)\n\n\n@task\ndef copy_secrets_file():\n    \"\"\" Copy the secrets.json.example and rename it to secrets.json \"\"\"\n    shutil.copyfile(\"secrets.json.example\", \"secrets.json\")\n\n\n@task\ndef full_test():\n    \"\"\"Rebuild the test environment and import data.\"\"\"\n    copy_secrets_file()\n    django.setup()\n    test_env()\n    if local_settings == \"development\":\n        test_su()\n    import_system()\n    import_all_studies()\n\n\n@task\ndef clean_cache():\n    run(\"py3clean .\")\n\n\n@task\ndef reset_migrations():\n    \"\"\"Reset all migrations.\"\"\"\n    django.setup()\n    clean_cache()\n    run(\n        \"\"\"\n            rm */migrations/0*\n            ./manage.py makemigrations\n        \"\"\"\n    )\n\n\n@task\ndef full_push():\n    \"\"\"Merge development branch into master and push all branches.\"\"\"\n    run(\n        \"\"\"\n            git checkout master\n            git merge development\n            git checkout development\n            git push --all\n        \"\"\"\n    )\n\n\n@task\ndef erd():\n    \"\"\"Create and open ERD file\"\"\"\n    django.setup()\n    run(\n        \"\"\"\n            ./manage.py graph_models -a > local/erd.dot\n            cd local\n            dot erd.dot -T pdf > erd.pdf\n            evince erd.pdf\n        \"\"\"\n    )\n\n\n@task\ndef shell():\n    \"\"\"Use django-extensions shell_plus.\"\"\"\n    django.setup()\n    management.call_command(\"shell_plus\")\n\n\n@task\ndef migrate():\n    \"\"\"Make and run migrations.\"\"\"\n    django.setup()\n    management.call_command(\"makemigrations\")\n    management.call_command(\"migrate\")\n\n\n@task\ndef rq_test():\n    \"\"\"Test the RQ worker.\"\"\"\n    django.setup()\n    run(\"\"\"./manage.py runscript scripts.rq_test\"\"\")\n\n\n@task\ndef zip_elastic():\n    \"\"\"Create a ZIP file of the elastic directory\"\"\"\n    run(\n        \"\"\"\n            cd db\n            rm elastic.zip\n            zip -r elastic.zip elasticsearch/\n        \"\"\"\n    )\n\n\n@task\ndef elastic_search_javascript_library():\n    \"\"\" Build the search library for ddionrails \"\"\"\n    # TODO: This is a workaround. The library should be bundled with webpack directly.\n    # see: https://v5.angular.io/guide/webpack\n    # see: https://www.twilio.com/blog/2018/03/building-an-app-from-scratch-with-angular-and-webpack.html\n    run(\n        \"\"\"\n            cd ./node_modules/ddionrails-elasticsearch\n            npm install --save-dev\n            ./node_modules/.bin/ng build --prod\n        \"\"\"\n    )\n\n\n@task\ndef webpack():\n    \"\"\" Create webpack bundles \"\"\"\n    run(\"\"\"./node_modules/.bin/webpack --config webpack.config.js\"\"\")\n\n\n@task\ndef setup_frontend():\n    \"\"\" Setup all frontend dependencies \"\"\"\n    run(\"\"\"npm install --save-dev\"\"\")\n    elastic_search_javascript_library()\n    webpack()\n\n\n@task\ndef setup_pipenv():\n    run(\"\"\"pipenv install --dev\"\"\")\n\n\n@task\ndef init():\n    setup_pipenv()\n    setup_frontend()\n\n\n@task\ndef test():\n    \"\"\" Test the project without selenium tests \"\"\"\n    os.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"settings.testing\")\n    django.setup()\n    run(\"\"\"pytest -v -m \"not functional\" \"\"\")\n\n\n@task\ndef system_test():\n    \"\"\" Test the project with selenium tests \"\"\"\n    os.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"settings.testing\")\n    django.setup()\n    run(\"\"\"pytest -v -m functional \"\"\")\n", "path": "pavement.py"}], "after_files": [{"content": "\"\"\"\nPavement file\n\"\"\"\nimport os\nimport shutil\nimport socket\nimport sys\n\nimport django\nfrom django.conf import settings\nfrom django.core import management\nfrom paver.easy import task\n\nsys.path.append(\".\")\n\nhostname = socket.gethostname()\n\nif hostname == \"hewing\":\n    local_settings = \"hewing\"\nelif hostname == \"paneldata\":\n    local_settings = \"production\"\nelse:\n    local_settings = \"development\"\n\nprint(\"[INFO] Using %s settings.\" % local_settings)\nos.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"settings.%s\" % local_settings)\n\n\n### Helper functions ###\n\n\ndef info(text):\n    print(\"\\n[INFO] %s\" % text)\n\n\ndef run(script):\n    for line in script.strip().split(\"\\n\"):\n        print(\"\\n[SYSTEM] %s\" % line.strip())\n    os.system(script)\n\n\ndef init_development_db():\n    \"\"\"Init development database.\"\"\"\n    django.setup()\n    run(\"rm -f db/db.sqlite3\")\n    management.call_command(\"migrate\")\n\n\ndef elastic_server():\n    return \"%s:%s/%s\" % (settings.INDEX_HOST, settings.INDEX_PORT, settings.INDEX_NAME)\n\n\n### Tasks ###\n\n\n@task\ndef which_system():\n    print(\"[INFO] System repo:  \", settings.SYSTEM_REPO_URL)\n    print(\"[INFO] Import branch:\", settings.IMPORT_BRANCH)\n\n\n@task\ndef rqworker():\n    \"\"\"Start Redis worker.\"\"\"\n    django.setup()\n    management.call_command(\"rqworker\")\n\n\n@task\ndef install_elastic():\n    \"\"\"Install Elasticsearch.\"\"\"\n    run(\n        \"\"\"\n        rm -rf db/elasticsearch\n        wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.2/elasticsearch-2.4.2.tar.gz\n        tar xzvf elasticsearch*.tar.gz\n        rm elasticsearch*.tar.gz\n        mv elasticsearch* db/elasticsearch\n    \"\"\"\n    )\n\n\n@task\ndef elastic():\n    \"\"\"Start Elasticsearch as a foreground process.\"\"\"\n    run(\"./db/elasticsearch/bin/elasticsearch\")\n\n\n@task\ndef delete_index():\n    \"Delete the index.\"\n    run(\"curl -XDELETE '%s'\" % elastic_server())\n    print()\n\n\n@task\ndef create_index():\n    \"Create the index from the elastic/mapping.json file.\"\n    run(\"curl -s -XPOST '%s' -d@elastic/mapping.json\" % elastic_server())\n    print()\n\n\n@task\ndef reset_index():\n    \"\"\"Delete index, update mapping, create index.\"\"\"\n    delete_index()\n    run(\"yaml2json elastic/mapping.yaml > elastic/mapping.json\")\n    create_index()\n\n\n@task\ndef docu():\n    \"\"\"Run the docu make script (no delete).\"\"\"\n    run(\"cd ../docs; make html\")\n\n\n@task\ndef full_docu():\n    \"\"\"Completely rebuild the docu.\"\"\"\n    run(\"cd ../docs; rm -r _build; make html\")\n\n\n@task\ndef fire_docu():\n    \"\"\"Open docu in Firefox.\"\"\"\n    run(\"firefox ../docs/_build/html/index.html\")\n\n\n@task\ndef chrome_docu():\n    \"\"\"Open docu in Google Chrome.\"\"\"\n    run(\"google-chrome ../docs/_build/html/index.html\")\n\n\n@task\ndef server():\n    \"\"\"Start development server.\"\"\"\n    django.setup()\n    management.call_command(\"runserver_plus\")\n\n\n@task\ndef setup_virtualenv():\n    \"\"\"Setup virtualenv in: ~/.envs/ddionrails2/\"\"\"\n    run(\n        \"\"\"\n        mkdir -p ~/.envs\n        virtualenv -p /usr/bin/python3.4 ~/.envs/ddionrails2\n        source ~/.envs/ddionrails2/bin/activate\n        pip install -r requirements.txt\n    \"\"\"\n    )\n\n\n@task\ndef freeze_requirements():\n    \"\"\"Freeze requirements.\"\"\"\n    run(\"pip freeze > requirements.txt\")\n\n\n@task\ndef test_env():\n    \"\"\"Rebuild the database and delete all repositories.\"\"\"\n    django.setup()\n    run(\n        \"\"\"\n        rm db/db.sqlite3\n        ./manage.py migrate\n        rm -rf static/repositories/*\n        touch static/repositories/.gitkeep\n        chmod 666 db/db.sqlite3\n    \"\"\"\n    )\n    delete_index()\n    create_index()\n\n\n@task\ndef test_su():\n    \"\"\"Create superuser \"admin\" with password \"testtest\".\"\"\"\n    from django.contrib.auth.models import User\n\n    django.setup()\n    User.objects.create_superuser(\"admin\", \"admin@example.com\", \"testtest\")\n\n\n@task\ndef import_system():\n    \"\"\"Run scripts: system.\"\"\"\n    django.setup()\n    run(\"./manage.py runscript scripts.system --settings=settings.%s\" % local_settings)\n\n\n@task\ndef import_all_studies():\n    \"\"\"Run scripts: import.\"\"\"\n    django.setup()\n    run(\"./manage.py runscript scripts.import_studies --settings=settings.%s\" % local_settings)\n\n\n@task\ndef copy_secrets_file():\n    \"\"\" Copy the secrets.json.example and rename it to secrets.json \"\"\"\n    shutil.copyfile(\"secrets.json.example\", \"secrets.json\")\n\n\n@task\ndef full_test():\n    \"\"\"Rebuild the test environment and import data.\"\"\"\n    copy_secrets_file()\n    django.setup()\n    test_env()\n    if local_settings == \"development\":\n        test_su()\n    import_system()\n    import_all_studies()\n\n\n@task\ndef clean_cache():\n    run(\"py3clean .\")\n\n\n@task\ndef reset_migrations():\n    \"\"\"Reset all migrations.\"\"\"\n    django.setup()\n    clean_cache()\n    run(\n        \"\"\"\n            rm */migrations/0*\n            ./manage.py makemigrations\n        \"\"\"\n    )\n\n\n@task\ndef full_push():\n    \"\"\"Merge development branch into master and push all branches.\"\"\"\n    run(\n        \"\"\"\n            git checkout master\n            git merge development\n            git checkout development\n            git push --all\n        \"\"\"\n    )\n\n\n@task\ndef erd():\n    \"\"\"Create and open ERD file\"\"\"\n    django.setup()\n    run(\n        \"\"\"\n            ./manage.py graph_models -a > local/erd.dot\n            cd local\n            dot erd.dot -T pdf > erd.pdf\n            evince erd.pdf\n        \"\"\"\n    )\n\n\n@task\ndef shell():\n    \"\"\"Use django-extensions shell_plus.\"\"\"\n    django.setup()\n    management.call_command(\"shell_plus\")\n\n\n@task\ndef migrate():\n    \"\"\"Make and run migrations.\"\"\"\n    django.setup()\n    management.call_command(\"makemigrations\")\n    management.call_command(\"migrate\")\n\n\n@task\ndef rq_test():\n    \"\"\"Test the RQ worker.\"\"\"\n    django.setup()\n    run(\"\"\"./manage.py runscript scripts.rq_test\"\"\")\n\n\n@task\ndef zip_elastic():\n    \"\"\"Create a ZIP file of the elastic directory\"\"\"\n    run(\n        \"\"\"\n            cd db\n            rm elastic.zip\n            zip -r elastic.zip elasticsearch/\n        \"\"\"\n    )\n\n\n@task\ndef elastic_search_javascript_library():\n    \"\"\" Build the search library for ddionrails \"\"\"\n    # TODO: This is a workaround. The library should be bundled with webpack directly.\n    # see: https://v5.angular.io/guide/webpack\n    # see: https://www.twilio.com/blog/2018/03/building-an-app-from-scratch-with-angular-and-webpack.html\n    run(\n        \"\"\"\n            cd ./node_modules/ddionrails-elasticsearch\n            npm install\n            ./node_modules/.bin/ng build --prod\n        \"\"\"\n    )\n\n\n@task\ndef webpack():\n    \"\"\" Create webpack bundles \"\"\"\n    run(\"\"\"./node_modules/.bin/webpack --config webpack.config.js\"\"\")\n\n\n@task\ndef setup_frontend():\n    \"\"\" Setup all frontend dependencies \"\"\"\n    run(\"\"\"npm install\"\"\")\n    elastic_search_javascript_library()\n    webpack()\n\n\n@task\ndef setup_pipenv():\n    run(\"\"\"pipenv install --dev\"\"\")\n\n\n@task\ndef init():\n    setup_pipenv()\n    setup_frontend()\n\n\n@task\ndef test():\n    \"\"\" Test the project without selenium tests \"\"\"\n    os.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"settings.testing\")\n    django.setup()\n    run(\"\"\"pytest -v -m \"not functional\" \"\"\")\n\n\n@task\ndef system_test():\n    \"\"\" Test the project with selenium tests \"\"\"\n    os.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"settings.testing\")\n    django.setup()\n    run(\"\"\"pytest -v -m functional \"\"\")\n", "path": "pavement.py"}]}