2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-02-02 03:14:56 +00:00

Merge branch 'master' of https://github.com/inventree/InvenTree into feat--matrix-testing

This commit is contained in:
Matthias Mair
2026-01-19 09:05:38 +01:00
194 changed files with 82100 additions and 80171 deletions

View File

@@ -1,5 +1,6 @@
"""Tasks for automating certain actions and interacting with InvenTree from the CLI."""
import datetime
import json
import os
import pathlib
@@ -357,6 +358,26 @@ def manage_py_path():
return manage_py_dir().joinpath('manage.py')
def _frontend_info():
"""Return the path of the frontend info directory."""
return manage_py_dir().joinpath('web', 'static', 'web', '.vite')
def version_target_pth():
"""Return the path of the target version file."""
return _frontend_info().joinpath('tag.txt')
def version_sha_pth():
"""Return the path of the SHA version file."""
return _frontend_info().joinpath('sha.txt')
def version_source_pth():
"""Return the path of the source version file."""
return _frontend_info().joinpath('source.txt')
# endregion
if __name__ in ['__main__', 'tasks']:
@@ -598,14 +619,19 @@ def clean_settings(c):
success('Settings cleaned successfully')
@task(help={'mail': "mail of the user who's MFA should be disabled"})
def remove_mfa(c, mail=''):
@task(
help={
'mail': "mail of the user who's MFA should be disabled",
'username': "username of the user who's MFA should be disabled",
}
)
def remove_mfa(c, mail='', username=''):
"""Remove MFA for a user."""
if not mail:
warning('You must provide a users mail')
if not mail and not username:
warning('You must provide a users mail or username')
return
manage(c, f'remove_mfa {mail}')
manage(c, f'remove_mfa --mail {mail} --username {username}')
@task(
@@ -1664,6 +1690,31 @@ def frontend_build(c):
info('Building frontend')
yarn(c, 'yarn run build')
def write_info(path: Path, content: str):
"""Helper function to write version content to file after cleaning it if it exists."""
if path.exists():
path.unlink()
path.write_text(content, encoding='utf-8')
# Write version marker
try:
import src.backend.InvenTree.InvenTree.version as InvenTreeVersion # type: ignore[import]
if version_hash := InvenTreeVersion.inventreeCommitHash():
write_info(version_sha_pth(), version_hash)
elif version_tag := InvenTreeVersion.inventreeVersion():
write_info(version_target_pth(), version_tag)
else:
warning('No version information available to write frontend version marker')
# Write source marker
write_info(
version_source_pth(),
f'local build on {datetime.datetime.now().isoformat()}',
)
except Exception:
warning('Failed to write frontend version marker')
@task
def frontend_server(c):
@@ -1788,13 +1839,9 @@ def frontend_download(
ref = 'tag' if tag else 'commit'
if tag:
current = manage_py_dir().joinpath(
'web', 'static', 'web', '.vite', 'tag.txt'
)
current = version_target_pth()
elif sha:
current = manage_py_dir().joinpath(
'web', 'static', 'web', '.vite', 'sha.txt'
)
current = version_sha_pth()
else:
raise ValueError('Either tag or sha needs to be set')