Fixed update & install commands #113 #115

Merged
edraft merged 1 commits from 2022.10.10-#113 into 2022.10 2022-09-19 21:48:57 +02:00
6 changed files with 58 additions and 20 deletions

View File

@ -112,7 +112,7 @@
"de": "cpl deploy-exp $ARGS",
"deploy-exp-cli": "cpl publish-cli; cpl upload-exp-cli",
"deploy-exp-core": "cpl publish-core; cpl upload-exp-core",
"deploy-exp-discord": "cpl publish-discord; #pl upload-exp-discord",
"deploy-exp-discord": "cpl publish-discord; cpl upload-exp-discord",
"deploy-exp-query": "cpl publish-query; cpl upload-exp-query",
"deploy-exp-translation": "cpl publish-translation; cpl upload-exp-translation",

View File

@ -76,23 +76,33 @@ class InstallService(CommandABC):
Console.spinner(
f'Installing: {dependency}',
Pip.install if not self._is_virtual else self._wait, dependency if not self._is_virtual else 2,
source=self._cli_settings.pip_path if 'cpl-' in dependency else None,
'--upgrade',
source=self._cli_settings.pip_path,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
text_foreground_color=ForegroundColorEnum.green,
spinner_foreground_color=ForegroundColorEnum.cyan
)
local_package = Pip.get_package(dependency)
if local_package is None:
Error.warn(f'Installation of package {dependency} failed!')
return
for dependency in self._project_settings.dev_dependencies:
Console.spinner(
f'Installing dev: {dependency}',
Pip.install if not self._is_virtual else self._wait, dependency if not self._is_virtual else 2,
source=self._cli_settings.pip_path if 'cpl-' in dependency else None,
'--upgrade',
source=self._cli_settings.pip_path,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
text_foreground_color=ForegroundColorEnum.green,
spinner_foreground_color=ForegroundColorEnum.cyan
)
local_package = Pip.get_package(dependency)
if local_package is None:
Error.warn(f'Installation of package {dependency} failed!')
return
if not self._is_virtual:
Pip.reset_executable()
@ -154,7 +164,7 @@ class InstallService(CommandABC):
Console.spinner(
f'Installing: {package}' if not self._is_dev else f'Installing dev: {package}',
Pip.install if not self._is_virtual else self._wait, package if not self._is_virtual else 2,
source=self._cli_settings.pip_path if 'cpl-' in package or 'cpl_' in package else None,
source=self._cli_settings.pip_path,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
text_foreground_color=ForegroundColorEnum.green,
@ -221,6 +231,18 @@ class InstallService(CommandABC):
args.remove('simulate')
Console.write_line('Running in simulation mode:')
if 'cpl-prod' in args:
args.remove('cpl-prod')
self._cli_settings.from_dict({'PipPath': 'https://pip.sh-edraft.de'})
if 'cpl-exp' in args:
args.remove('cpl-exp')
self._cli_settings.from_dict({'PipPath': 'https://pip-exp.sh-edraft.de'})
if 'cpl-dev' in args:
args.remove('cpl-dev')
self._cli_settings.from_dict({'PipPath': 'https://pip-dev.sh-edraft.de'})
VenvHelper.init_venv(self._is_virtual, self._env, self._project_settings)
if len(args) == 0:

View File

@ -76,7 +76,7 @@ class UpdateService(CommandABC):
'--upgrade',
'--upgrade-strategy',
'eager',
source=self._cli_settings.pip_path if 'cpl-' in name else None,
source=self._cli_settings.pip_path,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
@ -169,6 +169,18 @@ class UpdateService(CommandABC):
Console.write_line('Running in simulation mode:')
self._is_simulation = True
if 'cpl-prod' in args:
args.remove('cpl-prod')
self._cli_settings.from_dict({'PipPath': 'https://pip.sh-edraft.de'})
if 'cpl-exp' in args:
args.remove('cpl-exp')
self._cli_settings.from_dict({'PipPath': 'https://pip-exp.sh-edraft.de'})
if 'cpl-dev' in args:
args.remove('cpl-dev')
self._cli_settings.from_dict({'PipPath': 'https://pip-dev.sh-edraft.de'})
VenvHelper.init_venv(False, self._env, self._project_settings)
self._check_project_dependencies()

View File

@ -42,7 +42,10 @@ class StartupArgumentExtension(StartupExtensionABC):
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'install', ['i', 'I'], InstallService, True, validators=[ProjectValidator]) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'dev', ['d', 'D']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'virtual', ['v', 'V']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S'])
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'cpl-prod', ['cp', 'CP']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'cpl-exp', ['ce', 'CE']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'cpl-dev', ['cd', 'CD'])
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'new', ['n', 'N'], NewService, True) \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'console', ['c', 'C'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'library', ['l', 'L'], ' ') \
@ -63,7 +66,10 @@ class StartupArgumentExtension(StartupExtensionABC):
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'virtual', ['v', 'V']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S'])
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'update', ['u', 'U'], UpdateService, True, validators=[ProjectValidator]) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S'])
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'cpl-prod', ['cp', 'CP']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'cpl-exp', ['ce', 'CE']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'cpl-dev', ['cd', 'CD'])
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'version', ['v', 'V'], VersionService, True)
config.for_each_argument(lambda a: a.add_console_argument(ArgumentTypeEnum.Flag, '--', 'help', ['h', 'H']))

View File

@ -65,7 +65,7 @@ class Pip:
"""
result = None
with suppress(Exception):
args = [cls._executable, "-m", "pip", "show", package]
args = [cls._executable, "-m", "pip", "freeze"]
result = subprocess.check_output(
args,
@ -75,17 +75,11 @@ class Pip:
if result is None:
return None
new_package: list[str] = str(result, 'utf-8').lower().split('\n')
new_version = ''
for p in str(result.decode()).split('\n'):
if p == package:
return p
for atr in new_package:
if 'version' in atr:
new_version = atr.split(': ')[1]
if new_version != '':
return f'{package}=={new_version}'
return package
return None
@classmethod
def get_outdated(cls) -> bytes:

View File

@ -16,9 +16,13 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"cpl_core==2022.6.1"
"cpl-core==2022.10rc2",
"cpl-translation==2022.7.0.post2",
"cpl-query==2022.7.0"
],
"DevDependencies": [
"cpl-cli==2022.10.rc2"
],
"DevDependencies": [],
"PythonVersion": ">=3.10",
"PythonPath": {
"linux": "../../venv/bin/python",