bundlewrap/bundles/hedgedoc/items.py

101 lines
2.3 KiB
Python
Raw Permalink Normal View History

2023-06-04 21:17:55 +00:00
from semver import compare
2021-09-11 17:47:28 +00:00
repo.libs.tools.require_bundle(node, 'nodejs')
git_deploy = {
'/opt/hedgedoc': {
'rev': node.metadata.get('hedgedoc/version'),
'repo': 'https://github.com/hedgedoc/hedgedoc.git',
'needs': {
'directory:/opt/hedgedoc',
},
'triggers': {
'action:hedgedoc_yarn',
'svc_systemd:hedgedoc:restart',
},
},
}
files = {
'/opt/hedgedoc/config.json': {
'content_type': 'mako',
2021-09-11 17:47:28 +00:00
'needs': {
'git_deploy:/opt/hedgedoc',
},
'triggers': {
'svc_systemd:hedgedoc:restart',
},
},
'/etc/systemd/system/hedgedoc.service': {
'triggers': {
'action:systemd-reload',
'svc_systemd:hedgedoc:restart',
},
}
}
directories = {
'/opt/hedgedoc': {},
'/var/opt/hedgedoc': {
'owner': 'hedgedoc',
'group': 'hedgedoc',
},
'/opt/hedgedoc/.yarn': {
'owner': 'hedgedoc',
'group': 'hedgedoc',
2021-09-14 18:22:04 +00:00
'needs': {
'git_deploy:/opt/hedgedoc',
},
2021-09-11 17:47:28 +00:00
},
}
2023-06-04 21:17:55 +00:00
if compare(node.metadata.get('hedgedoc/version'), '1.9.7') <= 0:
command = ' && '.join([
'cd /opt/hedgedoc',
2023-08-24 17:12:57 +00:00
'yarn workspaces focus --production',
2023-06-04 21:17:55 +00:00
'yarn install --ignore-scripts',
'yarn build',
])
elif compare(node.metadata.get('hedgedoc/version'), '1.9.9') >= 0:
command = ' && '.join([
'cd /opt/hedgedoc',
'bin/setup',
'yarn install --immutable',
'yarn build',
])
2021-09-11 17:47:28 +00:00
actions = {
'hedgedoc_yarn': {
'command': ' && '.join([
'cd /opt/hedgedoc',
2023-08-24 17:12:57 +00:00
'yarn install --immutable',
'yarn build',
2021-09-11 17:47:28 +00:00
]),
'needs': {
'action:nodejs_install_yarn',
2021-09-11 17:47:28 +00:00
'file:/opt/hedgedoc/config.json',
'git_deploy:/opt/hedgedoc',
'pkg_apt:nodejs',
},
'triggered': True,
},
}
svc_systemd = {
'hedgedoc': {
'needs': {
'file:/opt/hedgedoc/config.json',
'directory:/var/opt/hedgedoc',
'directory:/opt/hedgedoc/.yarn',
'action:hedgedoc_yarn',
'postgres_db:hedgedoc',
},
},
}
users = {
'hedgedoc': {
'home': '/opt/hedgedoc',
},
}