commit
742ba8314a
@ -15,7 +15,7 @@ __title__ = 'cpl_cli'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -19,13 +19,10 @@ class Library(ProjectTypeABC):
|
|||||||
project_file_data: dict,
|
project_file_data: dict,
|
||||||
):
|
):
|
||||||
from project_file import ProjectFile
|
from project_file import ProjectFile
|
||||||
from project_file_appsettings import ProjectFileAppsettings
|
|
||||||
from project_file_code_application import ProjectFileApplication
|
|
||||||
from project_file_code_main import ProjectFileMain
|
|
||||||
from project_file_code_startup import ProjectFileStartup
|
|
||||||
from project_file_readme import ProjectFileReadme
|
from project_file_readme import ProjectFileReadme
|
||||||
from project_file_license import ProjectFileLicense
|
from project_file_license import ProjectFileLicense
|
||||||
from schematic_init import Init
|
from schematic_init import Init
|
||||||
|
from schematic_class import Class
|
||||||
|
|
||||||
ProjectTypeABC.__init__(self, base_path, project_name, workspace, use_application_api, use_startup, use_service_providing, use_async, project_file_data)
|
ProjectTypeABC.__init__(self, base_path, project_name, workspace, use_application_api, use_startup, use_service_providing, use_async, project_file_data)
|
||||||
|
|
||||||
@ -35,15 +32,6 @@ class Library(ProjectTypeABC):
|
|||||||
if workspace is None:
|
if workspace is None:
|
||||||
self.add_template(ProjectFileLicense(''))
|
self.add_template(ProjectFileLicense(''))
|
||||||
self.add_template(ProjectFileReadme(''))
|
self.add_template(ProjectFileReadme(''))
|
||||||
self.add_template(Init('', 'init', f'{base_path}tests/'))
|
|
||||||
|
|
||||||
self.add_template(Init('', 'init', project_path))
|
self.add_template(Init('', 'init', project_path))
|
||||||
self.add_template(ProjectFileAppsettings(project_path))
|
self.add_template(Class('Class1', 'class', project_path))
|
||||||
|
|
||||||
if use_application_api:
|
|
||||||
self.add_template(ProjectFileApplication(project_path, use_application_api, use_startup, use_service_providing, use_async))
|
|
||||||
|
|
||||||
if use_startup:
|
|
||||||
self.add_template(ProjectFileStartup(project_path, use_application_api, use_startup, use_service_providing, use_async))
|
|
||||||
|
|
||||||
self.add_template(ProjectFileMain(project_name.split('/')[-1], project_path, use_application_api, use_startup, use_service_providing, use_async))
|
|
||||||
|
@ -4,8 +4,8 @@ from cpl_core.utils import String
|
|||||||
|
|
||||||
class Class(GenerateSchematicABC):
|
class Class(GenerateSchematicABC):
|
||||||
|
|
||||||
def __init__(self, name: str, path: str, schematic: str):
|
def __init__(self, name: str, schematic: str, path: str):
|
||||||
GenerateSchematicABC.__init__(self, name, path, schematic)
|
GenerateSchematicABC.__init__(self, name, schematic, path)
|
||||||
self._name = f'{String.convert_to_snake_case(name)}.py'
|
self._name = f'{String.convert_to_snake_case(name)}.py'
|
||||||
self._class_name = f'{String.first_to_upper(name)}'
|
self._class_name = f'{String.first_to_upper(name)}'
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -28,4 +28,4 @@ from .main import main
|
|||||||
from .startup import Startup
|
from .startup import Startup
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli._templates'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli._templates.build'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli._templates.publish'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.abc'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"CLI": {
|
"CLI": {
|
||||||
"PipPath": "https://pip.sh-edraft.de"
|
"PipPath": "https://pip-dev.sh-edraft.de"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.command'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -29,4 +29,4 @@ from .publish_service import PublishService
|
|||||||
from .version_service import VersionService
|
from .version_service import VersionService
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -34,6 +34,7 @@ class GenerateService(CommandABC):
|
|||||||
self._config = configuration
|
self._config = configuration
|
||||||
self._env = self._config.environment
|
self._env = self._config.environment
|
||||||
self._schematics = {}
|
self._schematics = {}
|
||||||
|
self._schematic_classes = set()
|
||||||
|
|
||||||
for package_name, version in Dependencies.get_cpl_packages():
|
for package_name, version in Dependencies.get_cpl_packages():
|
||||||
if package_name == 'cpl-cli':
|
if package_name == 'cpl-cli':
|
||||||
@ -44,16 +45,12 @@ class GenerateService(CommandABC):
|
|||||||
self._read_custom_schematics_from_path(self._env.working_directory)
|
self._read_custom_schematics_from_path(self._env.working_directory)
|
||||||
self._read_custom_schematics_from_path(self._env.runtime_directory)
|
self._read_custom_schematics_from_path(self._env.runtime_directory)
|
||||||
|
|
||||||
if len(GenerateSchematicABC.__subclasses__()) == 0:
|
if len(self._schematic_classes) == 0:
|
||||||
Console.error(f'No schematics found in template directory: .cpl')
|
Console.error(f'No schematics found in template directory: .cpl')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
known_schematics = []
|
known_schematics = []
|
||||||
for schematic in GenerateSchematicABC.__subclasses__():
|
for schematic in self._schematic_classes:
|
||||||
if schematic.__name__ in known_schematics:
|
|
||||||
Console.error(f'Duplicate of schematic {schematic.__name__} found!')
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
known_schematics.append(schematic.__name__)
|
known_schematics.append(schematic.__name__)
|
||||||
schematic.register()
|
schematic.register()
|
||||||
|
|
||||||
@ -83,6 +80,23 @@ class GenerateService(CommandABC):
|
|||||||
help_msg += f'\n {schematic}'
|
help_msg += f'\n {schematic}'
|
||||||
return help_msg
|
return help_msg
|
||||||
|
|
||||||
|
def _read_custom_schematics_from_path(self, path: str):
|
||||||
|
if not os.path.exists(os.path.join(path, '.cpl')):
|
||||||
|
return
|
||||||
|
|
||||||
|
sys.path.insert(0, os.path.join(path, '.cpl'))
|
||||||
|
for r, d, f in os.walk(os.path.join(path, '.cpl')):
|
||||||
|
for file in f:
|
||||||
|
if not file.startswith('schematic_') or not file.endswith('.py'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
exec(open(os.path.join(r, file), 'r').read())
|
||||||
|
self._schematic_classes.update(GenerateSchematicABC.__subclasses__())
|
||||||
|
except Exception as e:
|
||||||
|
Console.error(str(e), traceback.format_exc())
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _create_file(file_path: str, value: str):
|
def _create_file(file_path: str, value: str):
|
||||||
"""
|
"""
|
||||||
@ -157,23 +171,6 @@ class GenerateService(CommandABC):
|
|||||||
spinner_foreground_color=ForegroundColorEnum.cyan
|
spinner_foreground_color=ForegroundColorEnum.cyan
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _read_custom_schematics_from_path(path: str):
|
|
||||||
if not os.path.exists(os.path.join(path, '.cpl')):
|
|
||||||
return
|
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(path, '.cpl'))
|
|
||||||
for r, d, f in os.walk(os.path.join(path, '.cpl')):
|
|
||||||
for file in f:
|
|
||||||
if not file.startswith('schematic_') or not file.endswith('.py'):
|
|
||||||
continue
|
|
||||||
|
|
||||||
try:
|
|
||||||
exec(open(os.path.join(r, file), 'r').read())
|
|
||||||
except Exception as e:
|
|
||||||
Console.error(str(e), traceback.format_exc())
|
|
||||||
sys.exit(-1)
|
|
||||||
|
|
||||||
def _get_schematic_by_alias(self, schematic: str) -> str:
|
def _get_schematic_by_alias(self, schematic: str) -> str:
|
||||||
for key in self._schematics:
|
for key in self._schematics:
|
||||||
if schematic in self._schematics[key]['Aliases']:
|
if schematic in self._schematics[key]['Aliases']:
|
||||||
@ -195,9 +192,8 @@ class GenerateService(CommandABC):
|
|||||||
schematic = s
|
schematic = s
|
||||||
break
|
break
|
||||||
|
|
||||||
schematic_by_alias = self._get_schematic_by_alias(args[0])
|
if schematic is None and len(args) >= 1 and (args[0] in self._schematics or self._get_schematic_by_alias(args[0]) != args[0]):
|
||||||
if schematic is None and len(args) >= 1 and (args[0] in self._schematics or schematic_by_alias != args[0]):
|
schematic = self._get_schematic_by_alias(args[0])
|
||||||
schematic = schematic_by_alias
|
|
||||||
self._config.add_configuration(schematic, args[1])
|
self._config.add_configuration(schematic, args[1])
|
||||||
value = args[1]
|
value = args[1]
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ class NewService(CommandABC):
|
|||||||
self._build: BuildSettings = BuildSettings()
|
self._build: BuildSettings = BuildSettings()
|
||||||
self._build_dict = {}
|
self._build_dict = {}
|
||||||
|
|
||||||
|
self._project_type_classes = set()
|
||||||
|
|
||||||
self._name: str = ''
|
self._name: str = ''
|
||||||
self._rel_path: str = ''
|
self._rel_path: str = ''
|
||||||
self._project_type: ProjectTypeEnum = ProjectTypeEnum.console
|
self._project_type: ProjectTypeEnum = ProjectTypeEnum.console
|
||||||
@ -98,7 +100,7 @@ class NewService(CommandABC):
|
|||||||
],
|
],
|
||||||
ProjectSettingsNameEnum.python_version.value: f'>={sys.version.split(" ")[0]}',
|
ProjectSettingsNameEnum.python_version.value: f'>={sys.version.split(" ")[0]}',
|
||||||
ProjectSettingsNameEnum.python_path.value: {
|
ProjectSettingsNameEnum.python_path.value: {
|
||||||
sys.platform: '../../venv/bin/python' if self._use_venv else ''
|
sys.platform: '../../venv/' if self._use_venv else ''
|
||||||
},
|
},
|
||||||
ProjectSettingsNameEnum.classifiers.value: []
|
ProjectSettingsNameEnum.classifiers.value: []
|
||||||
}
|
}
|
||||||
@ -152,17 +154,22 @@ class NewService(CommandABC):
|
|||||||
|
|
||||||
return project_path
|
return project_path
|
||||||
|
|
||||||
def _get_project_information(self, is_unittest=False):
|
def _get_project_information(self, project_type: str):
|
||||||
"""
|
"""
|
||||||
Gets project information's from user
|
Gets project information's from user
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
is_unittest = project_type == 'unittest'
|
||||||
|
is_library = project_type == 'library'
|
||||||
|
if is_library:
|
||||||
|
return
|
||||||
|
|
||||||
if self._use_application_api or self._use_startup or self._use_service_providing or self._use_async or self._use_nothing:
|
if self._use_application_api or self._use_startup or self._use_service_providing or self._use_async or self._use_nothing:
|
||||||
Console.set_foreground_color(ForegroundColorEnum.default)
|
Console.set_foreground_color(ForegroundColorEnum.default)
|
||||||
Console.write_line('Skipping question due to given flags')
|
Console.write_line('Skipping question due to given flags')
|
||||||
return
|
return
|
||||||
|
|
||||||
if not is_unittest:
|
if not is_unittest and not is_library:
|
||||||
self._use_application_api = Console.read('Do you want to use application base? (y/n) ').lower() == 'y'
|
self._use_application_api = Console.read('Do you want to use application base? (y/n) ').lower() == 'y'
|
||||||
|
|
||||||
if not is_unittest and self._use_application_api:
|
if not is_unittest and self._use_application_api:
|
||||||
@ -194,8 +201,7 @@ class NewService(CommandABC):
|
|||||||
explicit_path=os.path.join(self._env.working_directory, project, self._project.python_executable.replace('../', ''))
|
explicit_path=os.path.join(self._env.working_directory, project, self._project.python_executable.replace('../', ''))
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
def _read_custom_project_types_from_path(self, path: str):
|
||||||
def _read_custom_project_types_from_path(path: str):
|
|
||||||
if not os.path.exists(os.path.join(path, '.cpl')):
|
if not os.path.exists(os.path.join(path, '.cpl')):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -207,28 +213,28 @@ class NewService(CommandABC):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
exec(open(os.path.join(r, file), 'r').read())
|
exec(open(os.path.join(r, file), 'r').read())
|
||||||
|
self._project_type_classes.update(ProjectTypeABC.__subclasses__())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Console.error(str(e), traceback.format_exc())
|
Console.error(str(e), traceback.format_exc())
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
def _create_project(self, project_type: str):
|
def _create_project(self, project_type: str):
|
||||||
for package_name in Dependencies.get_cpl_packages():
|
for package_name in Dependencies.get_cpl_packages():
|
||||||
|
if package_name == 'cpl-cli':
|
||||||
|
continue
|
||||||
package = importlib.import_module(String.convert_to_snake_case(package_name[0]))
|
package = importlib.import_module(String.convert_to_snake_case(package_name[0]))
|
||||||
self._read_custom_project_types_from_path(os.path.dirname(package.__file__))
|
self._read_custom_project_types_from_path(os.path.dirname(package.__file__))
|
||||||
|
|
||||||
self._read_custom_project_types_from_path(self._env.working_directory)
|
self._read_custom_project_types_from_path(self._env.working_directory)
|
||||||
|
self._read_custom_project_types_from_path(self._env.runtime_directory)
|
||||||
|
|
||||||
if len(ProjectTypeABC.__subclasses__()) == 0:
|
if len(self._project_type_classes) == 0:
|
||||||
Console.error(f'No project types found in template directory: .cpl')
|
Console.error(f'No project types found in template directory: .cpl')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
project_class = None
|
project_class = None
|
||||||
known_project_types = []
|
known_project_types = []
|
||||||
for p in ProjectTypeABC.__subclasses__():
|
for p in self._project_type_classes:
|
||||||
if p.__name__ in known_project_types:
|
|
||||||
Console.error(f'Duplicate of project type {p.__name__} found!')
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
known_project_types.append(p.__name__)
|
known_project_types.append(p.__name__)
|
||||||
if p.__name__.lower() != project_type and p.__name__.lower()[0] != project_type[0]:
|
if p.__name__.lower() != project_type and p.__name__.lower()[0] != project_type[0]:
|
||||||
continue
|
continue
|
||||||
@ -247,7 +253,7 @@ class NewService(CommandABC):
|
|||||||
if path is None:
|
if path is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._get_project_information()
|
self._get_project_information(project_type)
|
||||||
project_name = self._project.name
|
project_name = self._project.name
|
||||||
if self._rel_path != '':
|
if self._rel_path != '':
|
||||||
project_name = f'{self._rel_path}/{project_name}'
|
project_name = f'{self._rel_path}/{project_name}'
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.configuration'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -31,4 +31,4 @@ from .workspace_settings import WorkspaceSettings
|
|||||||
from .workspace_settings_name_enum import WorkspaceSettingsNameEnum
|
from .workspace_settings_name_enum import WorkspaceSettingsNameEnum
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -123,10 +123,14 @@ class ProjectSettings(ConfigurationModelABC):
|
|||||||
self._python_path = settings[ProjectSettingsNameEnum.python_path.value]
|
self._python_path = settings[ProjectSettingsNameEnum.python_path.value]
|
||||||
|
|
||||||
if ProjectSettingsNameEnum.python_path.value in settings and sys.platform in settings[ProjectSettingsNameEnum.python_path.value]:
|
if ProjectSettingsNameEnum.python_path.value in settings and sys.platform in settings[ProjectSettingsNameEnum.python_path.value]:
|
||||||
path = f'{settings[ProjectSettingsNameEnum.python_path.value][sys.platform]}/bin/python'
|
path = f'{settings[ProjectSettingsNameEnum.python_path.value][sys.platform]}'
|
||||||
|
|
||||||
if path == '' or path is None:
|
if path == '' or path is None:
|
||||||
Error.warn(f'{ProjectSettingsNameEnum.python_path.value} not set')
|
Error.warn(f'{ProjectSettingsNameEnum.python_path.value} not set')
|
||||||
path = sys.executable
|
path = sys.executable
|
||||||
|
else:
|
||||||
|
if not path.endswith('bin/python'):
|
||||||
|
path = os.path.join('bin/python')
|
||||||
else:
|
else:
|
||||||
path = sys.executable
|
path = sys.executable
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class VenvHelper:
|
|||||||
if is_virtual:
|
if is_virtual:
|
||||||
return
|
return
|
||||||
|
|
||||||
venv_path = os.path.abspath(os.path.join(env.working_directory, project_settings.python_executable))
|
venv_path = os.path.abspath(os.path.join(env.working_directory, project_settings.python_executable, '../../'))
|
||||||
|
|
||||||
if explicit_path is not None:
|
if explicit_path is not None:
|
||||||
venv_path = os.path.abspath(explicit_path)
|
venv_path = os.path.abspath(explicit_path)
|
||||||
@ -31,7 +31,7 @@ class VenvHelper:
|
|||||||
spinner_foreground_color=ForegroundColorEnum.cyan
|
spinner_foreground_color=ForegroundColorEnum.cyan
|
||||||
)
|
)
|
||||||
|
|
||||||
Pip.set_executable(venv_path)
|
Pip.set_executable(project_settings.python_executable)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_venv(path):
|
def create_venv(path):
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"Version": {
|
"Version": {
|
||||||
"Major": "2022",
|
"Major": "2022",
|
||||||
"Minor": "12",
|
"Minor": "12",
|
||||||
"Micro": "0"
|
"Micro": "dev144"
|
||||||
},
|
},
|
||||||
"Author": "Sven Heidemann",
|
"Author": "Sven Heidemann",
|
||||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||||
@ -16,7 +16,7 @@
|
|||||||
"LicenseName": "MIT",
|
"LicenseName": "MIT",
|
||||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
"cpl-core>=2022.12.0"
|
"cpl-core>=2022.12.dev144"
|
||||||
],
|
],
|
||||||
"DevDependencies": [],
|
"DevDependencies": [],
|
||||||
"PythonVersion": ">=3.10",
|
"PythonVersion": ">=3.10",
|
||||||
@ -42,7 +42,8 @@
|
|||||||
],
|
],
|
||||||
"PackageData": {
|
"PackageData": {
|
||||||
"cpl_cli": [
|
"cpl_cli": [
|
||||||
"*.json"
|
"*.json",
|
||||||
|
".cpl/*.py"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ProjectReferences": []
|
"ProjectReferences": []
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.helper'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.live_server'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -9,6 +9,7 @@ from cpl_cli.startup_migration_extension import StartupMigrationExtension
|
|||||||
from cpl_cli.startup_workspace_extension import StartupWorkspaceExtension
|
from cpl_cli.startup_workspace_extension import StartupWorkspaceExtension
|
||||||
from cpl_core.application.application_builder import ApplicationBuilder
|
from cpl_core.application.application_builder import ApplicationBuilder
|
||||||
from cpl_core.application.startup_extension_abc import StartupExtensionABC
|
from cpl_core.application.startup_extension_abc import StartupExtensionABC
|
||||||
|
from cpl_core.console import Console
|
||||||
|
|
||||||
|
|
||||||
def get_startup_extensions() -> list[Type[StartupExtensionABC]]:
|
def get_startup_extensions() -> list[Type[StartupExtensionABC]]:
|
||||||
@ -40,6 +41,7 @@ def main():
|
|||||||
app_builder.use_extension(extension)
|
app_builder.use_extension(extension)
|
||||||
|
|
||||||
app_builder.build().run()
|
app_builder.build().run()
|
||||||
|
Console.write_line()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.migrations'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports
|
# imports
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.migrations.base'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.migrations.service'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.publish'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -25,4 +25,4 @@ from .publisher_abc import PublisherABC
|
|||||||
from .publisher_service import PublisherService
|
from .publisher_service import PublisherService
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.source_creator'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -1,18 +1,11 @@
|
|||||||
import os
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from cpl_cli.command.custom_script_service import CustomScriptService
|
|
||||||
from cpl_cli.configuration.workspace_settings import WorkspaceSettings
|
|
||||||
from cpl_cli.migrations.base.migration_abc import MigrationABC
|
from cpl_cli.migrations.base.migration_abc import MigrationABC
|
||||||
from cpl_cli.migrations.base.migration_service_abc import MigrationServiceABC
|
from cpl_cli.migrations.base.migration_service_abc import MigrationServiceABC
|
||||||
from cpl_cli.migrations.migration_2022_10 import Migration202210
|
from cpl_cli.migrations.migration_2022_10 import Migration202210
|
||||||
from cpl_cli.migrations.service.migration_service import MigrationService
|
from cpl_cli.migrations.service.migration_service import MigrationService
|
||||||
from cpl_core.application.startup_extension_abc import StartupExtensionABC
|
from cpl_core.application.startup_extension_abc import StartupExtensionABC
|
||||||
from cpl_core.configuration.argument_type_enum import ArgumentTypeEnum
|
|
||||||
from cpl_core.configuration.configuration_abc import ConfigurationABC
|
from cpl_core.configuration.configuration_abc import ConfigurationABC
|
||||||
from cpl_core.dependency_injection.service_collection_abc import ServiceCollectionABC
|
from cpl_core.dependency_injection.service_collection_abc import ServiceCollectionABC
|
||||||
from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC
|
from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC
|
||||||
from cpl_core.utils.string import String
|
|
||||||
|
|
||||||
|
|
||||||
class StartupMigrationExtension(StartupExtensionABC):
|
class StartupMigrationExtension(StartupExtensionABC):
|
||||||
|
@ -1 +0,0 @@
|
|||||||
# imports
|
|
@ -1 +0,0 @@
|
|||||||
# imports
|
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.validators'
|
|||||||
__author__ = 'Sven Heidemann'
|
__author__ = 'Sven Heidemann'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
|
||||||
__version__ = '2022.12.0'
|
__version__ = '2022.12.dev144'
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@ -23,4 +23,4 @@ from collections import namedtuple
|
|||||||
# imports:
|
# imports:
|
||||||
|
|
||||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
version_info = VersionInfo(major='2022', minor='12', micro='0')
|
version_info = VersionInfo(major='2022', minor='12', micro='dev144')
|
||||||
|
@ -53,7 +53,11 @@
|
|||||||
"*/logs",
|
"*/logs",
|
||||||
"*/tests"
|
"*/tests"
|
||||||
],
|
],
|
||||||
"PackageData": {},
|
"PackageData": {
|
||||||
|
"cpl_core": [
|
||||||
|
".cpl/*.py"
|
||||||
|
]
|
||||||
|
},
|
||||||
"ProjectReferences": []
|
"ProjectReferences": []
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -33,7 +33,7 @@ class Pip:
|
|||||||
return
|
return
|
||||||
|
|
||||||
cls._executable = executable
|
cls._executable = executable
|
||||||
if not os.path.islink(cls._executable):
|
if not os.path.islink(cls._executable) or not os.path.isfile(executable):
|
||||||
return
|
return
|
||||||
|
|
||||||
path = os.path.dirname(os.path.dirname(cls._executable))
|
path = os.path.dirname(os.path.dirname(cls._executable))
|
||||||
@ -119,6 +119,7 @@ class Pip:
|
|||||||
if source is not None:
|
if source is not None:
|
||||||
pip_args.append(f'--extra-index-url')
|
pip_args.append(f'--extra-index-url')
|
||||||
pip_args.append(source)
|
pip_args.append(source)
|
||||||
|
|
||||||
subprocess.run(pip_args, stdout=stdout, stderr=stderr, env=cls._env)
|
subprocess.run(pip_args, stdout=stdout, stderr=stderr, env=cls._env)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -40,7 +40,11 @@
|
|||||||
"*/logs",
|
"*/logs",
|
||||||
"*/tests"
|
"*/tests"
|
||||||
],
|
],
|
||||||
"PackageData": {},
|
"PackageData": {
|
||||||
|
"cpl_discord": [
|
||||||
|
".cpl/*.py"
|
||||||
|
]
|
||||||
|
},
|
||||||
"ProjectReferences": []
|
"ProjectReferences": []
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,7 +34,10 @@
|
|||||||
"*/logs",
|
"*/logs",
|
||||||
"*/tests"
|
"*/tests"
|
||||||
],
|
],
|
||||||
"PackageData": {},
|
"PackageData": {
|
||||||
|
"cpl_query": [
|
||||||
|
".cpl/*.py"
|
||||||
|
]},
|
||||||
"ProjectReferences": []
|
"ProjectReferences": []
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,7 +40,10 @@
|
|||||||
"*/logs",
|
"*/logs",
|
||||||
"*/tests"
|
"*/tests"
|
||||||
],
|
],
|
||||||
"PackageData": {},
|
"PackageData": {
|
||||||
|
"cpl_translation": [
|
||||||
|
".cpl/*.py"
|
||||||
|
]},
|
||||||
"ProjectReferences": []
|
"ProjectReferences": []
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -56,7 +56,14 @@ class Application(ApplicationABC):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if branch.startswith('#'):
|
if suffix != '':
|
||||||
|
self._configuration.add_json_file(self._workspace.projects[self._workspace.default_project], optional=False, output=False)
|
||||||
|
ps: ProjectSettings = self._configuration.get_configuration(ProjectSettings)
|
||||||
|
|
||||||
|
version[VersionSettingsNameEnum.major.value] = ps.version.major
|
||||||
|
version[VersionSettingsNameEnum.minor.value] = ps.version.minor
|
||||||
|
version[VersionSettingsNameEnum.micro.value] = suffix
|
||||||
|
elif branch.startswith('#'):
|
||||||
self._configuration.add_json_file(self._workspace.projects[self._workspace.default_project], optional=False, output=False)
|
self._configuration.add_json_file(self._workspace.projects[self._workspace.default_project], optional=False, output=False)
|
||||||
ps: ProjectSettings = self._configuration.get_configuration(ProjectSettings)
|
ps: ProjectSettings = self._configuration.get_configuration(ProjectSettings)
|
||||||
|
|
||||||
@ -71,8 +78,6 @@ class Application(ApplicationABC):
|
|||||||
suffix = '0'
|
suffix = '0'
|
||||||
version[VersionSettingsNameEnum.micro.value] = f'{suffix}'
|
version[VersionSettingsNameEnum.micro.value] = f'{suffix}'
|
||||||
else:
|
else:
|
||||||
if not suffix.startswith('.') and suffix != '':
|
|
||||||
suffix = f'.{suffix}'
|
|
||||||
version[VersionSettingsNameEnum.micro.value] = f'{branch.split(".")[2]}{suffix}'
|
version[VersionSettingsNameEnum.micro.value] = f'{branch.split(".")[2]}{suffix}'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Console.error(f'Branch {branch} does not contain valid version')
|
Console.error(f'Branch {branch} does not contain valid version')
|
||||||
|
@ -37,11 +37,11 @@ class InstallTestCase(CommandTestCase):
|
|||||||
|
|
||||||
os.chdir(PLAYGROUND_PATH)
|
os.chdir(PLAYGROUND_PATH)
|
||||||
# create projects
|
# create projects
|
||||||
CLICommands.new('console', self._source, '--ab', '--s')
|
CLICommands.new('console', self._source, '--ab', '--s', '--venv')
|
||||||
os.chdir(os.path.join(os.getcwd(), self._source))
|
os.chdir(os.path.join(os.getcwd(), self._source))
|
||||||
|
|
||||||
def _get_installed_packages(self) -> dict:
|
def _get_installed_packages(self) -> dict:
|
||||||
reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'])
|
reqs = subprocess.check_output([os.path.join(os.getcwd(), 'venv/bin/python'), '-m', 'pip', 'freeze'])
|
||||||
return dict([tuple(r.decode().split('==')) for r in reqs.split()])
|
return dict([tuple(r.decode().split('==')) for r in reqs.split()])
|
||||||
|
|
||||||
def test_install_package(self):
|
def test_install_package(self):
|
||||||
@ -50,16 +50,20 @@ class InstallTestCase(CommandTestCase):
|
|||||||
package = f'{package_name}=={version}'
|
package = f'{package_name}=={version}'
|
||||||
CLICommands.install(package)
|
CLICommands.install(package)
|
||||||
settings = self._get_project_settings()
|
settings = self._get_project_settings()
|
||||||
self.assertNotEqual(settings, {})
|
|
||||||
self.assertIn('ProjectSettings', settings)
|
with self.subTest(msg='Project deps'):
|
||||||
self.assertIn('Dependencies', settings['ProjectSettings'])
|
self.assertNotEqual(settings, {})
|
||||||
self.assertIn(
|
self.assertIn('ProjectSettings', settings)
|
||||||
package,
|
self.assertIn('Dependencies', settings['ProjectSettings'])
|
||||||
settings['ProjectSettings']['Dependencies']
|
self.assertIn(
|
||||||
)
|
package,
|
||||||
packages = self._get_installed_packages()
|
settings['ProjectSettings']['Dependencies']
|
||||||
self.assertIn(package_name, packages)
|
)
|
||||||
self.assertEqual(version, packages[package_name])
|
|
||||||
|
with self.subTest(msg='PIP'):
|
||||||
|
packages = self._get_installed_packages()
|
||||||
|
self.assertIn(package_name, packages)
|
||||||
|
self.assertEqual(version, packages[package_name])
|
||||||
|
|
||||||
def test_dev_install_package(self):
|
def test_dev_install_package(self):
|
||||||
version = '1.7.3'
|
version = '1.7.3'
|
||||||
@ -67,21 +71,25 @@ class InstallTestCase(CommandTestCase):
|
|||||||
package = f'{package_name}=={version}'
|
package = f'{package_name}=={version}'
|
||||||
CLICommands.install(package, is_dev=True)
|
CLICommands.install(package, is_dev=True)
|
||||||
settings = self._get_project_settings()
|
settings = self._get_project_settings()
|
||||||
self.assertNotEqual(settings, {})
|
|
||||||
self.assertIn('ProjectSettings', settings)
|
with self.subTest(msg='Project deps'):
|
||||||
self.assertIn('Dependencies', settings['ProjectSettings'])
|
self.assertNotEqual(settings, {})
|
||||||
self.assertIn('DevDependencies', settings['ProjectSettings'])
|
self.assertIn('ProjectSettings', settings)
|
||||||
self.assertNotIn(
|
self.assertIn('Dependencies', settings['ProjectSettings'])
|
||||||
package,
|
self.assertIn('DevDependencies', settings['ProjectSettings'])
|
||||||
settings['ProjectSettings']['Dependencies']
|
self.assertNotIn(
|
||||||
)
|
package,
|
||||||
self.assertIn(
|
settings['ProjectSettings']['Dependencies']
|
||||||
package,
|
)
|
||||||
settings['ProjectSettings']['DevDependencies']
|
self.assertIn(
|
||||||
)
|
package,
|
||||||
packages = self._get_installed_packages()
|
settings['ProjectSettings']['DevDependencies']
|
||||||
self.assertIn(package_name, packages)
|
)
|
||||||
self.assertEqual(version, packages[package_name])
|
|
||||||
|
with self.subTest(msg='PIP'):
|
||||||
|
packages = self._get_installed_packages()
|
||||||
|
self.assertIn(package_name, packages)
|
||||||
|
self.assertEqual(version, packages[package_name])
|
||||||
|
|
||||||
def _test_install_all(self):
|
def _test_install_all(self):
|
||||||
version = '1.7.3'
|
version = '1.7.3'
|
||||||
@ -120,5 +128,3 @@ class InstallTestCase(CommandTestCase):
|
|||||||
packages = self._get_installed_packages()
|
packages = self._get_installed_packages()
|
||||||
self.assertIn(package_name, packages)
|
self.assertIn(package_name, packages)
|
||||||
self.assertEqual(version, packages[package_name])
|
self.assertEqual(version, packages[package_name])
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,14 +14,15 @@ class NewTestCase(CommandTestCase):
|
|||||||
CommandTestCase.__init__(self, method_name)
|
CommandTestCase.__init__(self, method_name)
|
||||||
|
|
||||||
def _test_project(self, project_type: str, name: str, *args, test_venv=False, without_ws=False):
|
def _test_project(self, project_type: str, name: str, *args, test_venv=False, without_ws=False):
|
||||||
CLICommands.new(project_type, name, *args)
|
CLICommands.new(project_type, name, *args, output=False)
|
||||||
workspace_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, name))
|
workspace_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, name))
|
||||||
self.assertTrue(os.path.exists(workspace_path))
|
self.assertTrue(os.path.exists(workspace_path))
|
||||||
if test_venv:
|
if test_venv:
|
||||||
self.assertTrue(os.path.exists(os.path.join(workspace_path, 'venv')))
|
with self.subTest(msg='Venv exists'):
|
||||||
self.assertTrue(os.path.exists(os.path.join(workspace_path, 'venv/bin')))
|
self.assertTrue(os.path.exists(os.path.join(workspace_path, 'venv')))
|
||||||
self.assertTrue(os.path.exists(os.path.join(workspace_path, 'venv/bin/python')))
|
self.assertTrue(os.path.exists(os.path.join(workspace_path, 'venv/bin')))
|
||||||
self.assertTrue(os.path.islink(os.path.join(workspace_path, 'venv/bin/python')))
|
self.assertTrue(os.path.exists(os.path.join(workspace_path, 'venv/bin/python')))
|
||||||
|
self.assertTrue(os.path.islink(os.path.join(workspace_path, 'venv/bin/python')))
|
||||||
|
|
||||||
base = 'src'
|
base = 'src'
|
||||||
if '--base' in args and '/' in name:
|
if '--base' in args and '/' in name:
|
||||||
@ -32,34 +33,46 @@ class NewTestCase(CommandTestCase):
|
|||||||
if without_ws:
|
if without_ws:
|
||||||
project_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, base, name, 'src/', String.convert_to_snake_case(name)))
|
project_path = os.path.abspath(os.path.join(PLAYGROUND_PATH, base, name, 'src/', String.convert_to_snake_case(name)))
|
||||||
|
|
||||||
self.assertTrue(os.path.exists(project_path))
|
with self.subTest(msg='Project json exists'):
|
||||||
self.assertTrue(os.path.exists(os.path.join(project_path, f'{name}.json')))
|
self.assertTrue(os.path.exists(project_path))
|
||||||
self.assertTrue(os.path.exists(os.path.join(project_path, f'main.py')))
|
self.assertTrue(os.path.exists(os.path.join(project_path, f'{name}.json')))
|
||||||
|
|
||||||
if '--ab' in args:
|
if project_type == 'library':
|
||||||
self.assertTrue(os.path.isfile(os.path.join(project_path, f'application.py')))
|
with self.subTest(msg='Library class1 exists'):
|
||||||
else:
|
self.assertTrue(os.path.exists(os.path.join(project_path, f'class1.py')))
|
||||||
self.assertFalse(os.path.isfile(os.path.join(project_path, f'application.py')))
|
return
|
||||||
|
|
||||||
|
with self.subTest(msg='Project main.py exists'):
|
||||||
|
self.assertTrue(os.path.exists(os.path.join(project_path, f'main.py')))
|
||||||
|
|
||||||
|
with self.subTest(msg='Application base'):
|
||||||
|
if '--ab' in args:
|
||||||
|
self.assertTrue(os.path.isfile(os.path.join(project_path, f'application.py')))
|
||||||
|
else:
|
||||||
|
self.assertFalse(os.path.isfile(os.path.join(project_path, f'application.py')))
|
||||||
|
|
||||||
# s depends on ab
|
# s depends on ab
|
||||||
if '--ab' in args and '--s' in args:
|
with self.subTest(msg='Startup'):
|
||||||
self.assertTrue(os.path.isfile(os.path.join(project_path, f'startup.py')))
|
if '--ab' in args and '--s' in args:
|
||||||
else:
|
self.assertTrue(os.path.isfile(os.path.join(project_path, f'startup.py')))
|
||||||
self.assertFalse(os.path.isfile(os.path.join(project_path, f'startup.py')))
|
else:
|
||||||
|
self.assertFalse(os.path.isfile(os.path.join(project_path, f'startup.py')))
|
||||||
|
|
||||||
if project_type == 'unittest':
|
with self.subTest(msg='Unittest'):
|
||||||
self.assertTrue(os.path.isfile(os.path.join(project_path, f'test_case.py')))
|
if project_type == 'unittest':
|
||||||
else:
|
self.assertTrue(os.path.isfile(os.path.join(project_path, f'test_case.py')))
|
||||||
self.assertFalse(os.path.isfile(os.path.join(project_path, f'test_case.py')))
|
else:
|
||||||
|
self.assertFalse(os.path.isfile(os.path.join(project_path, f'test_case.py')))
|
||||||
|
|
||||||
if project_type == 'discord-bot':
|
with self.subTest(msg='Discord'):
|
||||||
self.assertTrue(os.path.isfile(os.path.join(project_path, f'events/__init__.py')))
|
if project_type == 'discord-bot':
|
||||||
self.assertTrue(os.path.isfile(os.path.join(project_path, f'events/on_ready_event.py')))
|
self.assertTrue(os.path.isfile(os.path.join(project_path, f'events/__init__.py')))
|
||||||
self.assertTrue(os.path.isfile(os.path.join(project_path, f'commands/__init__.py')))
|
self.assertTrue(os.path.isfile(os.path.join(project_path, f'events/on_ready_event.py')))
|
||||||
self.assertTrue(os.path.isfile(os.path.join(project_path, f'commands/ping_command.py')))
|
self.assertTrue(os.path.isfile(os.path.join(project_path, f'commands/__init__.py')))
|
||||||
else:
|
self.assertTrue(os.path.isfile(os.path.join(project_path, f'commands/ping_command.py')))
|
||||||
self.assertFalse(os.path.isfile(os.path.join(project_path, f'events/on_ready_event.py')))
|
else:
|
||||||
self.assertFalse(os.path.isfile(os.path.join(project_path, f'commands/ping_command.py')))
|
self.assertFalse(os.path.isfile(os.path.join(project_path, f'events/on_ready_event.py')))
|
||||||
|
self.assertFalse(os.path.isfile(os.path.join(project_path, f'commands/ping_command.py')))
|
||||||
|
|
||||||
def _test_sub_project(self, project_type: str, name: str, workspace_name: str, *args, test_venv=False):
|
def _test_sub_project(self, project_type: str, name: str, workspace_name: str, *args, test_venv=False):
|
||||||
os.chdir(os.path.abspath(os.path.join(os.getcwd(), workspace_name)))
|
os.chdir(os.path.abspath(os.path.join(os.getcwd(), workspace_name)))
|
||||||
|
@ -10,7 +10,6 @@ from unittests_shared.cli_commands import CLICommands
|
|||||||
|
|
||||||
|
|
||||||
class PublishTestCase(CommandTestCase):
|
class PublishTestCase(CommandTestCase):
|
||||||
_skip_tear_down = True
|
|
||||||
|
|
||||||
def __init__(self, method_name: str):
|
def __init__(self, method_name: str):
|
||||||
CommandTestCase.__init__(self, method_name)
|
CommandTestCase.__init__(self, method_name)
|
||||||
|
@ -66,22 +66,30 @@ class VersionTestCase(CommandTestCase):
|
|||||||
self._get_version_output(version)
|
self._get_version_output(version)
|
||||||
reference_banner = colored(text2art(self._name), ForegroundColorEnum.yellow.value).split('\n')
|
reference_banner = colored(text2art(self._name), ForegroundColorEnum.yellow.value).split('\n')
|
||||||
reference_banner = "\n".join(reference_banner[:len(reference_banner) - 1]) + '\n'
|
reference_banner = "\n".join(reference_banner[:len(reference_banner) - 1]) + '\n'
|
||||||
self.assertEqual(reference_banner, self._block_banner)
|
|
||||||
|
with self.subTest(msg='Block banner'):
|
||||||
|
self.assertEqual(reference_banner, self._block_banner)
|
||||||
|
|
||||||
reference_version = [
|
reference_version = [
|
||||||
colored(f'{colored("Common Python library CLI: ")}{colored(cpl_cli.__version__)}'),
|
colored(f'{colored("Common Python library CLI: ")}{colored(cpl_cli.__version__)}'),
|
||||||
colored(f'{colored("Python: ")}{colored(f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")}'),
|
colored(f'{colored("Python: ")}{colored(f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")}'),
|
||||||
colored(f'OS: {colored(f"{platform.system()} {platform.processor()}")}') + '\n'
|
colored(f'OS: {colored(f"{platform.system()} {platform.processor()}")}') + '\n'
|
||||||
]
|
]
|
||||||
self.assertEqual('\n'.join(reference_version), self._block_version)
|
with self.subTest(msg='Block version'):
|
||||||
|
self.assertEqual('\n'.join(reference_version), self._block_version)
|
||||||
reference_cpl_packages = [
|
reference_cpl_packages = [
|
||||||
colored(colored(f'CPL packages:')),
|
colored(colored(f'CPL packages:')),
|
||||||
colored(f'{tabulate(cpl_packages, headers=["Name", "Version"])}') + '\n'
|
colored(f'{tabulate(cpl_packages, headers=["Name", "Version"])}') + '\n'
|
||||||
]
|
]
|
||||||
self.assertEqual('\n'.join(reference_cpl_packages), self._block_cpl_packages)
|
with self.subTest(msg='Block cpl packages'):
|
||||||
|
self.assertEqual('\n'.join(reference_cpl_packages), self._block_cpl_packages)
|
||||||
reference_packages = [
|
reference_packages = [
|
||||||
colored(colored(f'Python packages:')),
|
colored(colored(f'Python packages:')),
|
||||||
colored(f'{tabulate(packages, headers=["Name", "Version"])}'),
|
colored(f'{tabulate(packages, headers=["Name", "Version"])}'),
|
||||||
'\x1b[0m\x1b[0m\n\x1b[0m\x1b[0m\n' # fix colored codes
|
'\x1b[0m\x1b[0m\n\x1b[0m\x1b[0m\n\x1b[0m\x1b[0m\n' # fix colored codes
|
||||||
]
|
]
|
||||||
self.assertEqual('\n'.join(reference_packages), self._block_packages)
|
|
||||||
|
self.maxDiff = None
|
||||||
|
with self.subTest(msg='Block packages'):
|
||||||
|
ref_packages = '\n'.join(reference_packages)
|
||||||
|
self.assertEqual(ref_packages, self._block_packages)
|
||||||
|
Loading…
Reference in New Issue
Block a user