From 28c22384238fd2d1f027e1496275eb4ca13ad2db Mon Sep 17 00:00:00 2001 From: Christopher Charbonneau Wells Date: Thu, 26 Oct 2017 12:26:09 -0400 Subject: [PATCH] Add migrate and fake commands to gulp. --- README.md | 9 +++++++-- gulpfile.js/tasks/manage.js | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 878abcda..270503ef 100644 --- a/README.md +++ b/README.md @@ -47,12 +47,17 @@ user name and password (`admin`/`admin`). ### Fake data -From within the pipenv shell, execute: +Add some fake data to the database with the following command: ``` -python manage.py fake +gulp fake ``` +By default, ``fake`` creates one child and 31 days of random data. Use the +``--children`` and ``--days`` flags to change the default values, e.g. +``gulp fake --children 5 --days 7`` to generate five fake children and seven +days of data for each. + ### Testing :exclamation: Tests require static files to be collected, it may be necessary diff --git a/gulpfile.js/tasks/manage.js b/gulpfile.js/tasks/manage.js index 3d824b14..a3d60e4b 100644 --- a/gulpfile.js/tasks/manage.js +++ b/gulpfile.js/tasks/manage.js @@ -18,6 +18,27 @@ gulp.task('collectstatic', function(cb) { ).on('exit', cb); }); +gulp.task('fake', function(cb) { + var command = ['run', 'python', 'manage.py', 'fake']; + command = command.concat(process.argv.splice(3)); + spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb); +}); + +gulp.task('migrate', function(cb) { + spawn( + 'pipenv', + [ + 'run', + 'python', + 'manage.py', + 'migrate' + ], + { + stdio: 'inherit' + } + ).on('exit', cb); +}); + gulp.task('reset', function(cb) { spawn( 'pipenv',