Skip to content

Commit e8c59f8

Browse files
committed
Add Publish Stubs
1 parent effb615 commit e8c59f8

File tree

6 files changed

+55
-0
lines changed

6 files changed

+55
-0
lines changed

cppython/console/entry.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,25 @@ def list_command(
112112
_: typer.Context,
113113
) -> None:
114114
"""Prints project information"""
115+
116+
117+
@app.command()
118+
def publish(
119+
context: typer.Context,
120+
) -> None:
121+
"""Publish API call
122+
123+
Args:
124+
context: The CLI configuration object
125+
126+
Raises:
127+
ValueError: If the configuration object is missing
128+
"""
129+
if (configuration := context.find_object(ConsoleConfiguration)) is None:
130+
raise ValueError('The configuration object is missing')
131+
132+
path = configuration.project_configuration.project_root / 'pyproject.toml'
133+
pyproject_data = loads(path.read_text(encoding='utf-8'))
134+
135+
project = Project(configuration.project_configuration, configuration.interface, pyproject_data)
136+
project.publish()

cppython/core/plugin_schema/provider.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,8 @@ def install(self) -> None:
8888
def update(self) -> None:
8989
"""Called when dependencies need to be updated and written to the lock file."""
9090
raise NotImplementedError
91+
92+
@abstractmethod
93+
def publish(self) -> None:
94+
"""Called when the project needs to be published."""
95+
raise NotImplementedError

cppython/plugins/conan/plugin.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,11 @@ def sync_data(self, consumer: SyncConsumer) -> SyncData:
120120
async def download_tooling(cls, directory: Path) -> None:
121121
"""Downloads the conan provider file"""
122122
cls._download_file(cls._provider_url, directory / 'conan_provider.cmake')
123+
124+
def publish(self) -> None:
125+
"""Updates the provider
126+
127+
Raises:
128+
NotImplementedError: Conan does not support publishing
129+
"""
130+
raise NotImplementedError('Conan does not support publishing')

cppython/plugins/vcpkg/plugin.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,11 @@ def update(self) -> None:
239239
except subprocess.CalledProcessError as e:
240240
logger.exception('Unable to install project dependencies: %s', e.stderr.decode() if e.stderr else str(e))
241241
raise
242+
243+
def publish(self) -> None:
244+
"""Called when the project needs to be published.
245+
246+
Raises:
247+
NotImplementedError: vcpkg does not support publishing
248+
"""
249+
raise NotImplementedError('vcpkg does not support publishing')

cppython/project.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,11 @@ def update(self) -> None:
9999
raise SystemExit('Error: An unexpected error occurred during update.') from None
100100

101101
self._data.sync()
102+
103+
def publish(self) -> None:
104+
"""Publishes the project"""
105+
try:
106+
self._data.plugins.provider.publish()
107+
except Exception as exception:
108+
self.logger.error('Unexpected error during publish: %s', str(exception))
109+
raise SystemExit('Error: An unexpected error occurred during publish.') from None

cppython/test/mock/provider.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,7 @@ def install(self) -> None:
9090
def update(self) -> None:
9191
"""Updates the provider"""
9292
pass
93+
94+
def publish(self) -> None:
95+
"""Updates the provider"""
96+
pass

0 commit comments

Comments
 (0)