Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added core update function #123

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 1 addition & 1 deletion src/viur_cli/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def migrate(self):
try:
result = os.popen('pip list --format=json').read()
core_version = [x for x in json.loads(result) if x["name"] == "viur-core"][0]["version"]
self["default"]["core"] = core_version
self["core"] = core_version

except:
self["default"]["core"] = "submodule"
Expand Down
38 changes: 32 additions & 6 deletions src/viur_cli/package.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import shutil
import subprocess
import zipfile
import click
import requests
Expand Down Expand Up @@ -84,9 +85,9 @@ def get_version_info(software: str, version: str) -> tuple[str, str]:

@cli.command()
@click.argument('operation', type=click.Choice(['update', 'install']))
@click.argument('component', type=click.Choice(['vi', 'admin', 'scriptor', 'all']))
@click.argument('profile', default='default')
@click.argument('component', type=click.Choice(['vi', 'admin', 'scriptor', 'core', 'all']))
@click.argument("version", default="latest")
@click.argument('profile', default='default')
def package(operation, component, profile, version):
"""
Performs installements and updates of ViUR Ecosystem packages
Expand All @@ -95,14 +96,21 @@ def package(operation, component, profile, version):
operations_links = {
'vi': vi,
'admin': admin,
'scriptor': scriptor
'scriptor': scriptor,
'core': core,
}

def perform_operation(component, version):
if operation == 'install':
operations_links[component](version, target=component, profile=profile)
else:
operations_links[component](version="latest", target=component, profile=profile)
if component == 'core':
operations_links[component](version)
else:
operations_links[component](version, target=component, profile=profile)
elif operation == 'update':
if component == 'core':
operations_links[component](version)
else:
operations_links[component](version="latest", target=component, profile=profile)

match component:
case 'vi':
Expand All @@ -111,11 +119,15 @@ def perform_operation(component, version):
perform_operation('admin', version)
case 'scriptor':
perform_operation('scriptor', version)
case 'core':
perform_operation('core', version)

case 'all':
if operation == 'update':
for build in conf["builds"]:
if build in operations_links:
perform_operation(build, "latest")
perform_operation("core", "latest")
else:
# We want to force the User to use the new Admin, so Vi can only be installed explicitly!!
for build in ["admin", "scriptor"]:
Expand Down Expand Up @@ -246,3 +258,17 @@ def step_label(step: int) -> str:
elif element == 5:
tmp_zip_file.unlink()
bar.label = "updated successful"

def core(version):
command = 'pipenv install viur-core'
if config["core"] == "submodule":
echo_fatal("Your ViUR Core is installed as Git Submodule, "
"please remove the installation and install it as Pipenv package")
if version not in ["latest", "*"]:
command += f'=="{version}"'
config['core'] = version
else:
config['core'] = "*"
process = subprocess.check_output(command, shell=True).decode('utf-8')
echo_info(process)

Grashalmbeisser marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 2 additions & 6 deletions src/viur_cli/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import re
from .conf import config
from . import cli, echo_error, echo_positive, echo_info, utils
from . import cli, echo_error, echo_info, utils


@cli.command(context_settings={"ignore_unknown_options": True})
Expand All @@ -26,14 +26,10 @@ def update(action, profile, additional_args):
- Additional arguments can be used to customize the update process if supported by the action.

"""
conf = config.get_profile(profile)

if action == "requirements":
create_req(True, profile)




def create_req(yes, profile, confirm_value=True):
"""
Load project's pipenv and build a requirements.txt.
Expand All @@ -53,7 +49,7 @@ def create_req(yes, profile, confirm_value=True):
"""
conf = config.get_profile(profile)
dist_folder = conf["distribution_folder"]
if conf["core"] != "submodule":
if config["core"] != "submodule":
if yes or click.confirm(
text=f"Do you want to regenerate the requirements.txt located in the {dist_folder}?",
default=confirm_value):
Expand Down