Skip to content

Conversation

@suhdonghwi
Copy link
Collaborator

@suhdonghwi suhdonghwi commented Nov 6, 2025

Key changes

  • Keep only plugin definition in src/index.ts, extracted utility functions into dedicated files.
  • Abstracted duplicate catalog usability validation logic into get-catalog-protocol-usability.ts.
  • Split configuration.ts into multiple files for better separation of concerns.
  • Moved constants and types not strictly related to configuration to src/constants.ts and src/types.ts.
  • Removed findAllAccessibleGroups and replaced with findDependency.
  • Rename some functions (getCatalogDependenciesWithoutProtocol -> getUnusedCatalogDependencies)

Minor changes

  • Added typecheck script.
  • Added .prettierrc for consistent formatting.
  • Use Descriptor types instead of raw string types when possible.

Test result

image

@suhdonghwi suhdonghwi requested a review from parksb November 6, 2025 09:35
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about organizing the files by key feature rather than by individual functions? We could split them into four modules:

  • configuration: Reading and parsing yarnrc file, resolving catalog descriptors
  • inheritance: Resolving inheritance chains, validating inheritance structures
  • default: fallbackDefaultAliasGroup, getDefaultAliasGroups, ...
  • validation: getGroupValidationLevel, getValidationLevel, ...

We could place these at the same level (it looks like yarn core typically uses a utils directory for this) and have index.ts reference them. This structure might make the code easier to maintain going forward.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a great idea. The only issue is that some functions (e.g. resolveInheritedRange, getValidationLevel) are methods of CatalogConfigurationReader. I'll consider separating those functions so that the Reader class focuses solely on configuration reading.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have made changes:

  • Now CatalogConfigurationReader only includes config reading, caching, config object validation feature
  • Created utils/ directory with default.ts, validation.ts, resolution.ts, functions.ts
    • default.ts: Fallback to default alias group
    • validation.ts: Validate if catalog dependencies are using catalog protocols (if possible)
    • resolution.ts: Resolve catalog dependency & Find all alias groups that contain specific dependency
    • funtions.ts: General utility functions

@suhdonghwi suhdonghwi requested a review from parksb November 7, 2025 09:57
@suhdonghwi suhdonghwi merged commit 6dda85e into main Nov 7, 2025
1 check passed
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