Skip to content

Conversation

@shafeeqd959
Copy link
Contributor

@shafeeqd959 shafeeqd959 commented Mar 11, 2025

[Oclif v4 Migration] Upgrade CLI to oclif v4

Overview

This PR migrates our CLI from oclif v3 to oclif v4, updating dependencies, refactoring deprecated functionalities, and standardizing table rendering across commands. The migration ensures compatibility with oclif v4 while maintaining consistent CLI output and behavior.

Key Changes

1. Upgraded Dependencies

Updated oclif-related packages to the latest versions:

Package | Before (oclif v3) | After (oclif v4) -- | -- | -- @oclif/core | ^3.27.0 | ^4.2.7 @oclif/plugin-help | ^5.2.20 | ^6.2.25 @oclif/plugin-not-found | ^2.4.3 | ^3.2.42 eslint-config-oclif | ^4.0.0 | ^6.0.15 oclif | ^3.17.2 | ^4.17.30
Example Migration:

Before (oclif v3 using ux.table())

typescript
CopyEdit
import { ux } from '@oclif/core'; ux.table(data, columns, options);

After (oclif v4 using tty-table via cliux.table())

typescript
CopyEdit
import cliux from '../cliux'; cliux.table(headers, data, flags, options);

3. Standardized Table Rendering with cliux.table()

  • ux.table() deprecated in oclif v4

  • Introduced cliux.table(), wrapping tty-table for consistent rendering

  • Updated all CLI commands to use cliux.table()

New Table Utility Usage:
typescript
CopyEdit
import cliux from '../cliux'; const headers = [ { value: 'Project Name' }, { value: 'Project Type' }, { value: 'Environment' }, { value: 'Repository' }, { value: 'Framework Preset' }, ]; const data = [ { 'Project Name': 'Contentstack', 'Project Type': 'Web', Environment: 'Development', Repository: '', 'Framework Preset': 'React' }, ]; cliux.table(headers, data, flags, options);

4. Enhanced Table Flags Handling

  • The showHeader flag now defaults to true.

  • If --no-header is passed, headers will be hidden.

Code Change:
typescript
CopyEdit
showHeader: (flags && !flags['no-header']) // Defaults to true unless --no-header is passed

5. Refactored Table Implementations Across Plugins

Migrated the following CLI plugins to use cliux.table():

  • Auth Plugin → Updated table rendering

  • Branches Plugin → Applied cliux.table() updates

  • Config Plugin → Replaced ux.table()

  • CLI Launch Plugin → Verified table formatting

  • App CLI → Standardized table rendering

  • TSGen → Ensured table compatibility

  • Content Types Plugin → Updated table logic


Testing Instructions

Unit & Integration Tests

  • Run CLI commands and verify correct table output format.

  • Ensure --no-header flag hides headers as expected.

Manual Validation Steps

  1. Execute CLI commands that previously used ux.table().

  2. Verify table formatting in output.

  3. Compare old vs. new output for consistency.

  4. Ensure correct behavior of all table-related flags.


Impact & Risks

🚀 Benefits:

  • Maintains full compatibility with oclif v4.

  • Standardized table rendering across CLI.

  • Future-proof for easier upgrades.

⚠️ Potential Risks:

  • Formatting changes: Minor differences in table output formatting.

  • Flag behavior changes: Some flag options may need adjustments.

  • Plugin dependencies: External plugins may require additional fixes.


Next Steps

  • ✅ Validate all CLI commands post-migration.

  • ✅ Update documentation to reflect new table usage.

  • ✅ Perform end-to-end testing to identify regressions.

  • 🚀 Deploy migration changes after final review.


PR Checklist

  • Migrated all CLI table usages to cliux.table().

  • Updated dependencies to oclif v4.

  • Ensured correct handling of showHeader flag.

  • Verified table rendering across plugins.

  • Conducted unit tests and manual validations.


Final Notes

This PR finalizes our migration to oclif v4 with improved table rendering and a standardized CLI experience. 🚀

@shafeeqd959 shafeeqd959 changed the base branch from main to development March 11, 2025 10:21
@shafeeqd959 shafeeqd959 changed the title Feature/oclif v4 migration base [Oclif v4 Migration] Upgrade CLI to oclif v4 Apr 2, 2025
@shafeeqd959 shafeeqd959 marked this pull request as ready for review April 2, 2025 07:14
@shafeeqd959 shafeeqd959 requested a review from a team as a code owner April 2, 2025 07:14
aman19K
aman19K previously approved these changes Apr 2, 2025
aman19K
aman19K previously approved these changes Apr 3, 2025
@shafeeqd959 shafeeqd959 merged commit 6406fca into development Apr 3, 2025
7 of 8 checks passed
@shafeeqd959 shafeeqd959 deleted the feature/oclif-v4-migration-base branch April 3, 2025 06:54
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