fix: [ENG-2221] correctly format sf tokens ls#224
Merged
Conversation
Changed Files
|
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Fixed column width mismatch in sf tokens ls table output that caused display formatting issues.
Key changes:
- Fixed table column widths from
[40, 15, 25, 25]to[40, 15, 25]to match the 3 actual columns (Token ID, Name, Expires) - Refactored to use centralized
formatDatehelper fromsrc/helpers/format-date.tsinstead of local inline function - Removed unused
getCommandBase()helper andsrc/helpers/command.tsfile, hardcoding "sf" command throughout - Changed Token ID display color from
graytocyanfor better visual distinction - Cleaned up
@ts-ignorecomment that's no longer needed
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The changes are straightforward bug fixes and refactoring: (1) corrects a clear table formatting bug where column widths didn't match column count, (2) consolidates date formatting logic using existing helper, (3) removes unused code. All changes align with existing patterns in the codebase. The date conversion from
formatDate(token.expires_at)toformatDate(new Date(token.expires_at))is consistent with howformatDateis used elsewhere in the codebase. - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| src/helpers/command.ts | 5/5 | File deleted - getCommandBase function removed as it's no longer needed |
| src/helpers/errors.ts | 5/5 | Simplified by removing getCommandBase dependency and hardcoding "sf" command |
| src/lib/tokens.ts | 5/5 | Fixed table column width mismatch (3 columns but 4 widths specified), improved formatting, consolidated date formatting |
Sequence Diagram
sequenceDiagram
participant User
participant CLI as CLI (tokens.ts)
participant API as SF Compute API
participant Helper as formatDate Helper
User->>CLI: sf tokens list
CLI->>CLI: Check if logged in
alt Not logged in
CLI->>User: logLoginMessageAndQuit()
end
CLI->>CLI: Show loading spinner
CLI->>API: GET /tokens (with Bearer token)
alt Unauthorized (401)
API-->>CLI: 401 Error
CLI->>User: logSessionTokenExpiredAndQuit()
end
alt Success
API-->>CLI: Token list data
CLI->>CLI: Stop spinner
alt No tokens
CLI->>User: Display empty table
CLI->>User: Show "sf tokens create" hint
else Has tokens
loop For each token
CLI->>Helper: formatDate(new Date(expires_at))
Helper-->>CLI: Formatted date string
CLI->>CLI: Build table row [ID, Name, Expires]
end
CLI->>User: Display table (3 columns, widths: [40, 15, 25])
end
end
3 files reviewed, no comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before:

After:
