Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions invenio_cli/commands/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Copyright (C) 2020 CERN.
# Copyright (C) 2022 Graz University of Technology.
# Copyright (C) 2025 TUBITAK ULAKBIM
#
# Invenio-Cli is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -87,6 +88,17 @@ def update_statics_and_assets(self, force, debug=False, log_file=None):
pkg_man = self.cli_config.python_package_manager
ops = [pkg_man.run_command("invenio", "collect", "--verbose")]

js_translations_bundle_path = self.cli_config.get_js_translations_bundle_path()
ops.append(
pkg_man.run_command(
"invenio",
"i18n",
"distribute-js-translations",
"-i",
js_translations_bundle_path,
)
)

if force:
ops.append(pkg_man.run_command("invenio", "webpack", "clean", "create"))
ops.append(pkg_man.run_command("invenio", "webpack", "install"))
Expand Down
26 changes: 26 additions & 0 deletions invenio_cli/helpers/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
# Copyright (C) 2019-2020 Northwestern University.
# Copyright (C) 2021 Esteban J. G. Gabancho.
# Copyright (C) 2024 Graz University of Technology.
# Copyright (C) 2025 TUBITAK ULAKBIM
#
# Invenio-Cli is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Invenio-cli configuration file."""

import os
from configparser import ConfigParser
from pathlib import Path

Expand Down Expand Up @@ -59,6 +61,8 @@ def __init__(self, project_dir="./"):
self.private_config.read_file(cfg_file)
except FileNotFoundError:
CLIConfig._write_private_config(Path(project_dir))
# TODO: change js translations directory
os.mkdir(f"{project_dir}/js_translations")
with open(self.private_config_path) as cfg_file:
self.private_config.read_file(cfg_file)

Expand Down Expand Up @@ -97,6 +101,20 @@ def get_instance_path(self, throw=True):
elif throw:
raise InvenioCLIConfigError("Accessing unset 'instance_path'")

def get_js_translations_bundle_path(self, throw=True):
"""Returns path to translation bundle directory.

If not set yet, raises an InvenioCLIConfigError.
"""
# TODO: config name may change
path = self.private_config[CLIConfig.CLI_SECTION].get(
"js_translations_bundle_path"
)
if path:
return Path(path)
elif throw:
raise InvenioCLIConfigError("Accessing unset 'js_translations_bundle_path'")

def update_instance_path(self, new_instance_path):
"""Updates path to application instance directory."""
self.private_config[CLIConfig.CLI_SECTION]["instance_path"] = str(
Expand Down Expand Up @@ -187,6 +205,10 @@ def _write_private_config(cls, project_dir):
config_parser = ConfigParser()
config_parser[cls.CLI_SECTION] = {}
config_parser[cls.CLI_SECTION]["services_setup"] = str(False)
# TODO: change js translations directory
config_parser[cls.CLI_SECTION][
"js_translations_bundle_path"
] = f"{project_dir}/js_translations"
private_config_path = project_dir / cls.PRIVATE_CONFIG_FILENAME
with open(private_config_path, "w") as configfile:
config_parser.write(configfile)
Expand Down Expand Up @@ -224,4 +246,8 @@ def write(cls, project_dir, flavour, replay):
# Custom to machine (not version controlled)
cls._write_private_config(project_dir)

# Create js translations directory
# TODO: change js translations directory
os.mkdir(f"{project_dir}/js_translations")

return project_dir