2021.4.1 #11
@ -15,7 +15,7 @@ class Help(CommandABC):
|
|||||||
['help (h|H)', 'Lists available command and their short descriptions.'],
|
['help (h|H)', 'Lists available command and their short descriptions.'],
|
||||||
['new (n|N)', 'Creates new CPL project.'],
|
['new (n|N)', 'Creates new CPL project.'],
|
||||||
['start (s|S)', 'Starts CPL project, restarting on file changes'],
|
['start (s|S)', 'Starts CPL project, restarting on file changes'],
|
||||||
['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 workspace directory.'],
|
['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.'],
|
||||||
['update (u|u)', 'Update CPL and project dependencies.'],
|
['update (u|u)', 'Update CPL and project dependencies.'],
|
||||||
['version (v|V)', 'Outputs CPL CLI version.']
|
['version (v|V)', 'Outputs CPL CLI version.']
|
||||||
]
|
]
|
||||||
|
@ -104,9 +104,10 @@ class New(CommandABC):
|
|||||||
if result.lower() == 'y':
|
if result.lower() == 'y':
|
||||||
self._use_startup = True
|
self._use_startup = True
|
||||||
|
|
||||||
# result = Console.read('Do you want to use service providing? (y/n) ')
|
# else:
|
||||||
# if result.lower() == 'y':
|
# result = Console.read('Do you want to use service providing? (y/n) ')
|
||||||
# self._use_service_providing = True
|
# if result.lower() == 'y':
|
||||||
|
# self._use_service_providing = True
|
||||||
|
|
||||||
def _build_project_dir(self, project_path: str):
|
def _build_project_dir(self, project_path: str):
|
||||||
if not os.path.isdir(project_path):
|
if not os.path.isdir(project_path):
|
||||||
|
@ -11,8 +11,8 @@ from cpl.console.console import Console
|
|||||||
from cpl_cli.configuration.build_settings import BuildSettings
|
from cpl_cli.configuration.build_settings import BuildSettings
|
||||||
from cpl_cli.configuration.project_settings import ProjectSettings
|
from cpl_cli.configuration.project_settings import ProjectSettings
|
||||||
from cpl_cli.publish.publisher_abc import PublisherABC
|
from cpl_cli.publish.publisher_abc import PublisherABC
|
||||||
from cpl_cli.templates.build.init import Init
|
from cpl_cli.templates.build.init_template import InitTemplate
|
||||||
from cpl_cli.templates.publish.setup import Setup
|
from cpl_cli.templates.publish.setup_template import SetupTemplate
|
||||||
|
|
||||||
|
|
||||||
class Publisher(PublisherABC):
|
class Publisher(PublisherABC):
|
||||||
@ -146,7 +146,7 @@ class Publisher(PublisherABC):
|
|||||||
if len(module_py_lines) > 0:
|
if len(module_py_lines) > 0:
|
||||||
imports = '\n'.join(module_py_lines)
|
imports = '\n'.join(module_py_lines)
|
||||||
|
|
||||||
template_content = stringTemplate(Init.get_init_py()).substitute(
|
template_content = stringTemplate(InitTemplate.get_init_py()).substitute(
|
||||||
Name=self._project_settings.name,
|
Name=self._project_settings.name,
|
||||||
Description=self._project_settings.description,
|
Description=self._project_settings.description,
|
||||||
LongDescription=self._project_settings.long_description,
|
LongDescription=self._project_settings.long_description,
|
||||||
@ -224,7 +224,7 @@ class Publisher(PublisherABC):
|
|||||||
return paths
|
return paths
|
||||||
|
|
||||||
def _create_setup(self):
|
def _create_setup(self):
|
||||||
setup_file = os.path.join(self._output_path, 'setup.py')
|
setup_file = os.path.join(self._output_path, 'setup_template.py')
|
||||||
if os.path.isfile(setup_file):
|
if os.path.isfile(setup_file):
|
||||||
os.remove(setup_file)
|
os.remove(setup_file)
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ class Publisher(PublisherABC):
|
|||||||
return
|
return
|
||||||
|
|
||||||
with open(setup_file, 'w+') as setup_py:
|
with open(setup_file, 'w+') as setup_py:
|
||||||
setup_string = stringTemplate(Setup.get_setup_py()).substitute(
|
setup_string = stringTemplate(SetupTemplate.get_setup_py()).substitute(
|
||||||
Name=self._project_settings.name,
|
Name=self._project_settings.name,
|
||||||
Version=self._project_settings.version.to_str(),
|
Version=self._project_settings.version.to_str(),
|
||||||
Packages=setuptools.find_packages(where=self._output_path, exclude=self._build_settings.excluded),
|
Packages=setuptools.find_packages(where=self._output_path, exclude=self._build_settings.excluded),
|
||||||
@ -262,9 +262,9 @@ class Publisher(PublisherABC):
|
|||||||
setup_py.close()
|
setup_py.close()
|
||||||
|
|
||||||
def _run_setup(self):
|
def _run_setup(self):
|
||||||
setup_py = os.path.join(self._output_path, 'setup.py')
|
setup_py = os.path.join(self._output_path, 'setup_template.py')
|
||||||
if not os.path.isfile(setup_py):
|
if not os.path.isfile(setup_py):
|
||||||
Console.error(__name__, f'setup.py not found in {self._output_path}')
|
Console.error(__name__, f'setup_template.py not found in {self._output_path}')
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -277,7 +277,7 @@ class Publisher(PublisherABC):
|
|||||||
])
|
])
|
||||||
os.remove(setup_py)
|
os.remove(setup_py)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Console.error('Executing setup.py failed', str(e))
|
Console.error('Executing setup_template.py failed', str(e))
|
||||||
|
|
||||||
def include(self, path: str):
|
def include(self, path: str):
|
||||||
self._build_settings.included.append(path)
|
self._build_settings.included.append(path)
|
||||||
@ -301,7 +301,7 @@ class Publisher(PublisherABC):
|
|||||||
Console.spinner('Building application:', self._dist_files)
|
Console.spinner('Building application:', self._dist_files)
|
||||||
|
|
||||||
Console.write_line('\nPublish:')
|
Console.write_line('\nPublish:')
|
||||||
Console.spinner('Generating setup.py:', self._create_setup)
|
Console.spinner('Generating setup_template.py:', self._create_setup)
|
||||||
Console.write_line('Running setup.py:\n')
|
Console.write_line('Running setup_template.py:\n')
|
||||||
self._run_setup()
|
self._run_setup()
|
||||||
Console.spinner('Cleaning dist path:', self._clean_dist_files)
|
Console.spinner('Cleaning dist path:', self._clean_dist_files)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
|
||||||
class Init:
|
class InitTemplate:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_init_py() -> str:
|
def get_init_py() -> str:
|
@ -1,7 +1,7 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
|
|
||||||
class Setup:
|
class SetupTemplate:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_setup_py() -> str:
|
def get_setup_py() -> str:
|
Loading…
Reference in New Issue
Block a user