From 0710b25317db3761876fc586a5ef9609688537c2 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 27 Jun 2022 20:04:19 +0200 Subject: [PATCH] Added dev-dependencies to uninstall command --- src/cpl_cli/command/uninstall_service.py | 22 +++++++++++++++---- .../custom/general/src/general/general.json | 4 +--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/cpl_cli/command/uninstall_service.py b/src/cpl_cli/command/uninstall_service.py index ab83dcbd..585f728a 100644 --- a/src/cpl_cli/command/uninstall_service.py +++ b/src/cpl_cli/command/uninstall_service.py @@ -36,6 +36,8 @@ class UninstallService(CommandABC): self._is_simulating = False self._is_virtual = False + self._is_dev = False + self._project_file = f'{self._project_settings.name}.json' @property @@ -62,6 +64,10 @@ class UninstallService(CommandABC): Console.error(f'Usage: cpl uninstall ') return + if 'dev' in args: + self._is_dev = True + args.remove('dev') + if '--virtual' in args: self._is_virtual = True args.remove('--virtual') @@ -82,7 +88,11 @@ class UninstallService(CommandABC): else: pip_package = package - for dependency in self._project_settings.dependencies: + deps = self._project_settings.dependencies + if self._is_dev: + deps = self._project_settings.dev_dependencies + + for dependency in deps: if package in dependency: is_in_dependencies = True package = dependency @@ -95,7 +105,7 @@ class UninstallService(CommandABC): package = pip_package Console.spinner( - f'Uninstalling: {package}', + f'Uninstalling: {package}' if not self._is_dev else f'Uninstalling dev: {package}', Pip.uninstall if not self._is_virtual else self._wait, package if not self._is_virtual else 2, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, @@ -103,8 +113,12 @@ class UninstallService(CommandABC): spinner_foreground_color=ForegroundColorEnum.cyan ) - if package in self._project_settings.dependencies: - self._project_settings.dependencies.remove(package) + deps = self._project_settings.dependencies + if self._is_dev: + deps = self._project_settings.dev_dependencies + + if package in deps: + deps.remove(package) if not self._is_simulating: config = { ProjectSettings.__name__: SettingsHelper.get_project_settings_dict(self._project_settings), diff --git a/src/tests/custom/general/src/general/general.json b/src/tests/custom/general/src/general/general.json index 4af74368..3c53ccda 100644 --- a/src/tests/custom/general/src/general/general.json +++ b/src/tests/custom/general/src/general/general.json @@ -18,9 +18,7 @@ "Dependencies": [ "cpl_core==2022.6.1" ], - "DevDependencies": [ - "cpl-cli==2022.6.17.dev10" - ], + "DevDependencies": [], "PythonVersion": ">=3.10", "PythonPath": { "linux": "../../venv/bin/python",