Skip to content

feat: Integrated Logger and cliErrorHandler in auth plugin #1965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2025

Conversation

aman19K
Copy link
Contributor

@aman19K aman19K commented Jun 11, 2025

NOTE:- Will do version bump before releasing this feature to avoid unnecessary version conflict.

@aman19K aman19K requested a review from Copilot June 11, 2025 05:11
@aman19K aman19K marked this pull request as ready for review June 11, 2025 05:11
@aman19K aman19K requested a review from a team as a code owner June 11, 2025 05:11
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates a unified logging and error handling approach into the auth plugin by replacing the direct use of LoggerService with log and handleAndLogError from @contentstack/cli-utilities. It also adds context details to command classes and updates various commands and utils for consistency.

  • Replaces LoggerService instances with log and handleAndLogError calls
  • Introduces contextDetails for standardized logging in BaseCommand
  • Updates various auth commands and tokens-related utility functions

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/contentstack-auth/src/utils/tokens-validation.ts Unified logging in token validation by replacing LoggerService with log and handleAndLogError
packages/contentstack-auth/src/utils/auth-handler.ts Updated logging and error handling in auth handler functions
packages/contentstack-auth/src/interfaces/index.ts Added Context interface for maintaining context details
packages/contentstack-auth/src/commands/auth/whoami.ts Changed logging calls to use log and handleAndLogError for improved consistency
packages/contentstack-auth/src/commands/auth/tokens/remove.ts Updated token removal command to use standard logging approaches
packages/contentstack-auth/src/commands/auth/tokens/index.ts Refactored tokens listing command to use unified error handling
packages/contentstack-auth/src/commands/auth/tokens/add.ts Revised token addition command with improved logging details
packages/contentstack-auth/src/commands/auth/logout.ts Updated logout command logging; note potential issue with async checks
packages/contentstack-auth/src/commands/auth/login.ts Integrated unified logging in login command
packages/contentstack-auth/src/base-command.ts Enhanced BaseCommand with contextDetails for logging purposes
packages/contentstack-auth/messages/index.json Updated message format for consistent logging messages
Comments suppressed due to low confidence (1)

packages/contentstack-auth/src/commands/auth/logout.ts:54

  • The removal of 'await' before oauthHandler.isAuthenticated() might lead to an unintended promise evaluation. Please ensure to await the async call by restoring 'await' as in: if (confirm === true && (await oauthHandler.isAuthenticated())) {.
if (confirm === true && (oauthHandler.isAuthenticated())) {

@aman19K aman19K merged commit 504614a into feat/DX-2951-v2Logger-integration Jun 11, 2025
8 checks passed
@aman19K aman19K deleted the feat/DX-3078 branch June 11, 2025 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants