Improved update command

This commit is contained in:
Sven Heidemann 2021-03-14 10:33:57 +01:00
parent e7796e0371
commit fc12d1803d

View File

@ -23,6 +23,14 @@ class UpdateService(CommandABC):
def _get_outdated() -> bytes: def _get_outdated() -> bytes:
return subprocess.check_output([sys.executable, "-m", "pip", "list", "--outdated"]) return subprocess.check_output([sys.executable, "-m", "pip", "list", "--outdated"])
def _check_project_dependencies(self):
Console.spinner(
'Collecting installed dependencies', self._update_project_dependencies,
text_foreground_color=ForegroundColorEnum.green,
spinner_foreground_color=ForegroundColorEnum.cyan
)
Console.write_line(f'Found {len(self._project_settings.dependencies)} dependencies.')
def _check_outdated(self): def _check_outdated(self):
table_str: bytes = Console.spinner( table_str: bytes = Console.spinner(
'Analyzing for available package updates', self._get_outdated, 'Analyzing for available package updates', self._get_outdated,
@ -35,7 +43,9 @@ class UpdateService(CommandABC):
for row in table: for row in table:
Console.write_line(f'\t{row}') Console.write_line(f'\t{row}')
Console.set_foreground_color(ForegroundColorEnum.yellow)
Console.write_line(f'\tUpdate with {sys.executable} -m pip install --upgrade <package>') Console.write_line(f'\tUpdate with {sys.executable} -m pip install --upgrade <package>')
Console.set_foreground_color(ForegroundColorEnum.default)
def _project_json_update_dependency(self, old_package: str, new_package: str): def _project_json_update_dependency(self, old_package: str, new_package: str):
content = '' content = ''
@ -69,14 +79,6 @@ class UpdateService(CommandABC):
self._project_json_update_dependency(package, Pip.get_package(name)) self._project_json_update_dependency(package, Pip.get_package(name))
def _check_project_dependencies(self):
Console.spinner(
'Collecting installed dependencies', self._update_project_dependencies,
text_foreground_color=ForegroundColorEnum.green,
spinner_foreground_color=ForegroundColorEnum.cyan
)
Console.write_line(f'Found {len(self._project_settings.dependencies)} dependencies.')
def run(self, args: list[str]): def run(self, args: list[str]):
# target update discord 1.5.1 to discord 1.6.0 # target update discord 1.5.1 to discord 1.6.0
self._check_project_dependencies() self._check_project_dependencies()