Build and deployment
[redakcja.git] / deployment / base.py
1 from fabric.api import env
2 from fabric.tasks import Task
3 from fnpdjango.deploy import Command
4
5
6 class Environment(Task):
7     def __init__(self, *args, **kwargs):
8         super(Environment, self).__init__(*args, **kwargs)
9         self.npm_bin = kwargs.pop('npm_bin', 'npm')
10         self.host = kwargs.pop('host')
11         self.env_vars = kwargs
12         self.env_vars['skip_collect_static'] = True
13
14     def run(self, *args, **kwargs):
15         env.project_name = 'redakcja'
16         env.hosts = [self.host]
17         for k,v in self.env_vars.items():
18             env[k] = v
19
20         build_cmd = '../../ve/bin/python manage.py build --npm-bin=%s' % self.npm_bin
21         if 'node_bin_path' in self.env_vars:
22             build_cmd += ' --node-bin-path=%s' % self.env_vars['node_bin_path']
23
24         env.pre_collectstatic = [
25             Command([build_cmd], '')
26         ]