Feat: start using invoke

This commit is contained in:
Bertrand Benjamin 2020-07-01 14:54:16 +02:00
parent 4c5168e0ac
commit c28db4d91a

View File

@ -17,15 +17,26 @@ LOCAL_SETTINGS = get_settings_from_file(SETTINGS_FILE_BASE)
SETTINGS.update(LOCAL_SETTINGS)
CONFIG = {
'current_path': os.getcwd(),
'settings_base': SETTINGS_FILE_BASE,
'settings_publish': 'publishconf.py',
'year_subfolder': '',
# Output path. Can be absolute or relative to tasks.py. Default: 'output'
'deploy_path': SETTINGS['OUTPUT_PATH'],
'fake_path': '../output/',
# Remote server configuration
'ssh_user': 'sshcontent',
'ssh_host': 'Embrevade',
'ssh_port': '22',
'ssh_path': '/var/www',
'ssh_path': '/home/sshcontent/opytex.org/www/',
# Rsync config
'rsync_exclude': '--exclude "pymath" --exclude "opytex" --exclude "enseignements"',
# Port for `serve`
'port': 8000,
}
@ -40,6 +51,7 @@ def clean(c):
@task
def build(c):
"""Build local version of site"""
c.run('lessc {current_path}/theme/static/stylesheet/style.less {current_path}/theme/static/stylesheet/style.min.css -x'.format(**CONFIG))
c.run('pelican -s {settings_base}'.format(**CONFIG))
@task
@ -107,9 +119,18 @@ def publish(c):
"""Publish to production via rsync"""
c.run('pelican -s {settings_publish}'.format(**CONFIG))
c.run(
'rsync --delete --exclude ".DS_Store" -pthrvz -c '
'-e "ssh -p {ssh_port}" '
'{} {ssh_user}@{ssh_host}:{ssh_path}'.format(
'rsync --delete {rsync_exclude} -pthrvz -c '
'-e "ssh " '
'{} {ssh_host}:{ssh_path}'.format(
CONFIG['deploy_path'].rstrip('/') + '/',
**CONFIG))
@task(
pre=[build]
)
def fake(c):
""" Mimic a push to server """
print('{fake_path}{year_subfolder}'.format(**CONFIG))
os.makedirs('{fake_path}{year_subfolder}'.format(**CONFIG), exist_ok=True)
c.run('rsync -P -rvzc --delete {rsync_exclude} {deploy_path}/ {fake_path}{year_subfolder} --cvs-exclude'.format(**CONFIG))