Skip to content

Commit 1bdbcf8

Browse files
committed
improve update notification; fix getting scan client
1 parent 331ced0 commit 1bdbcf8

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

cycode/cli/apps/auth/auth_common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
def get_authorization_info(ctx: 'Context') -> Optional[AuthInfo]:
1414
printer = ctx.obj.get('console_printer')
1515

16-
client_id, client_secret = CredentialsManager().get_credentials()
16+
client_id, client_secret = ctx.obj.get('client_id'), ctx.obj.get('client_secret')
17+
if not client_id or not client_secret:
18+
client_id, client_secret = CredentialsManager().get_credentials()
19+
1720
if not client_id or not client_secret:
1821
return None
1922

cycode/cli/utils/get_api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _get_cycode_client(
2828
def get_scan_cycode_client(ctx: 'typer.Context') -> 'ScanClient':
2929
client_id = ctx.obj.get('client_id')
3030
client_secret = ctx.obj.get('client_secret')
31-
hide_response_log = not ctx.obj['show_secret']
31+
hide_response_log = not ctx.obj.get('show_secret', False)
3232
return _get_cycode_client(create_scan_client, client_id, client_secret, hide_response_log)
3333

3434

cycode/cli/utils/version_checker.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def get_latest_version(self) -> Optional[str]:
8686
8787
"""
8888
try:
89-
response = self.get(f'{self.PYPI_PACKAGE_NAME}/json', timeout=self.PYPI_REQUEST_TIMEOUT)
89+
response = self.get(
90+
f'{self.PYPI_PACKAGE_NAME}/json', timeout=self.PYPI_REQUEST_TIMEOUT, hide_response_content_log=True
91+
)
9092
data = response.json()
9193
return data.get('info', {}).get('version')
9294
except Exception:
@@ -203,10 +205,10 @@ def check_and_notify_update(self, current_version: str, use_cache: bool = True)
203205
should_update = bool(latest_version)
204206
if should_update:
205207
update_message = (
206-
'\nNew version of cycode available! '
207-
f'[yellow]{current_version}[/] → [bright_blue]{latest_version}[/]\n'
208+
'\nNew release of Cycode CLI is available: '
209+
f'[red]{current_version}[/] -> [green]{latest_version}[/]\n'
208210
f'Changelog: [bright_blue]{self.GIT_CHANGELOG_URL_PREFIX}{latest_version}[/]\n'
209-
f'Run [green]pip install --upgrade cycode[/] to update\n'
211+
f'To update, run: [green]pip install --upgrade cycode[/]\n'
210212
)
211213
console.print(update_message)
212214

tests/cli/commands/test_check_latest_version_on_close.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from tests.conftest import CLI_ENV_VARS
1111

1212
_NEW_LATEST_VERSION = '999.0.0' # Simulate a newer version available
13-
_UPDATE_MESSAGE_PART = 'new version of cycode available'
13+
_UPDATE_MESSAGE_PART = 'new release of cycode cli is available'
1414

1515

1616
@patch.object(VersionChecker, 'check_for_update')

0 commit comments

Comments
 (0)