Bugfixes
This commit is contained in:
@@ -24,7 +24,7 @@ class HelpService(CommandABC):
|
||||
['help (h|H)', 'Lists available command and their short descriptions.'],
|
||||
['install (i|I)', 'With argument installs packages to project, without argument installs project dependencies.'],
|
||||
['new (n|N)', 'Creates new CPL project.'],
|
||||
['publish (p|P)', 'Prepares files for publish into an output directory named dist/ at the given output path and executes setup_template.py. Must be executed from within a workspace directory.'],
|
||||
['publish (p|P)', 'Prepares files for publish into an output directory named dist/ at the given output path and executes setup.py. Must be executed from within a library workspace directory.'],
|
||||
['start (s|S)', 'Starts CPL project, restarting on file changes'],
|
||||
['uninstall (ui|UI)', 'Uninstalls packages from project.'],
|
||||
['update (u|u)', 'Update CPL and project dependencies.'],
|
||||
|
@@ -97,6 +97,7 @@ class NewService(CommandABC):
|
||||
|
||||
def _create_build_settings(self):
|
||||
self._build_dict = {
|
||||
BuildSettingsNameEnum.project_type.value: self._command,
|
||||
BuildSettingsNameEnum.source_path.value: 'src',
|
||||
BuildSettingsNameEnum.output_path.value: 'dist',
|
||||
BuildSettingsNameEnum.main.value: 'main',
|
||||
@@ -244,7 +245,7 @@ class NewService(CommandABC):
|
||||
"""
|
||||
if len(args) == 0:
|
||||
self._help('Usage: cpl new <schematic> [options]')
|
||||
exit()
|
||||
return
|
||||
|
||||
self._command = args[0]
|
||||
if self._command == 'console':
|
||||
@@ -252,4 +253,4 @@ class NewService(CommandABC):
|
||||
|
||||
else:
|
||||
self._help('Usage: cpl new <schematic> [options]')
|
||||
exit()
|
||||
return
|
||||
|
@@ -5,6 +5,7 @@ from cpl.configuration.configuration_model_abc import ConfigurationModelABC
|
||||
from cpl.console.console import Console
|
||||
from cpl.console.foreground_color_enum import ForegroundColorEnum
|
||||
from cpl_cli.configuration.build_settings_name_enum import BuildSettingsNameEnum
|
||||
from cpl_cli.configuration.project_type_enum import ProjectTypeEnum
|
||||
|
||||
|
||||
class BuildSettings(ConfigurationModelABC):
|
||||
@@ -12,6 +13,7 @@ class BuildSettings(ConfigurationModelABC):
|
||||
def __init__(self):
|
||||
ConfigurationModelABC.__init__(self)
|
||||
|
||||
self._project_type: Optional[ProjectTypeEnum] = None
|
||||
self._source_path: Optional[str] = None
|
||||
self._output_path: Optional[str] = None
|
||||
self._main: Optional[str] = None
|
||||
@@ -21,6 +23,10 @@ class BuildSettings(ConfigurationModelABC):
|
||||
self._excluded: Optional[list[str]] = None
|
||||
self._package_data: Optional[dict[str, list[str]]] = None
|
||||
|
||||
@property
|
||||
def project_type(self):
|
||||
return self._project_type
|
||||
|
||||
@property
|
||||
def source_path(self) -> str:
|
||||
return self._source_path
|
||||
@@ -55,6 +61,7 @@ class BuildSettings(ConfigurationModelABC):
|
||||
|
||||
def from_dict(self, settings: dict):
|
||||
try:
|
||||
self._project_type = settings[BuildSettingsNameEnum.project_type.value]
|
||||
self._source_path = settings[BuildSettingsNameEnum.source_path.value]
|
||||
self._output_path = settings[BuildSettingsNameEnum.output_path.value]
|
||||
self._include_package_data = bool(settings[BuildSettingsNameEnum.include_package_data.value])
|
||||
|
@@ -3,6 +3,7 @@ from enum import Enum
|
||||
|
||||
class BuildSettingsNameEnum(Enum):
|
||||
|
||||
project_type = 'ProjectType'
|
||||
source_path = 'SourcePath'
|
||||
output_path = 'OutputPath'
|
||||
main = 'Main'
|
||||
|
7
src/cpl_cli/configuration/project_type_enum.py
Normal file
7
src/cpl_cli/configuration/project_type_enum.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class ProjectTypeEnum(Enum):
|
||||
|
||||
console = 'console'
|
||||
library = 'library'
|
@@ -34,6 +34,7 @@ class SettingsHelper:
|
||||
@staticmethod
|
||||
def get_build_settings_dict(build: BuildSettings) -> dict:
|
||||
return {
|
||||
BuildSettingsNameEnum.project_type.value: build.project_type,
|
||||
BuildSettingsNameEnum.source_path.value: build.source_path,
|
||||
BuildSettingsNameEnum.output_path.value: build.output_path,
|
||||
BuildSettingsNameEnum.main.value: build.main,
|
||||
|
@@ -12,6 +12,7 @@ from cpl.console.console import Console
|
||||
from cpl.environment.application_environment_abc import ApplicationEnvironmentABC
|
||||
from cpl_cli.configuration.build_settings import BuildSettings
|
||||
from cpl_cli.configuration.project_settings import ProjectSettings
|
||||
from cpl_cli.configuration.project_type_enum import ProjectTypeEnum
|
||||
from cpl_cli.publish.publisher_abc import PublisherABC
|
||||
from cpl_cli.templates.build.init_template import InitTemplate
|
||||
from cpl_cli.templates.publish.setup_template import SetupTemplate
|
||||
@@ -287,14 +288,13 @@ class PublisherService(PublisherABC):
|
||||
os.remove(setup_file)
|
||||
|
||||
main = None
|
||||
main_not_found = False
|
||||
try:
|
||||
main = importlib.import_module(self._build_settings.main)
|
||||
except Exception as e:
|
||||
Console.error('Could not find entry point', str(e))
|
||||
main_not_found = True
|
||||
return
|
||||
|
||||
if (main is None or not hasattr(main, 'main')) and not main_not_found:
|
||||
if main is None or not hasattr(main, 'main'):
|
||||
Console.error('Could not find entry point')
|
||||
return
|
||||
|
||||
@@ -388,6 +388,10 @@ class PublisherService(PublisherABC):
|
||||
4. Remove all included source from dist_path/publish
|
||||
:return:
|
||||
"""
|
||||
if self._build_settings.project_type != ProjectTypeEnum.library.value:
|
||||
Console.error(f'Project must be a {ProjectTypeEnum.library.value} for publishing.')
|
||||
return
|
||||
|
||||
self._output_path = os.path.join(self._output_path, 'publish')
|
||||
|
||||
Console.write_line('Build:')
|
||||
|
Reference in New Issue
Block a user