-
Notifications
You must be signed in to change notification settings - Fork 5
Overall refactor to file structures and types, functions, constants usage #28
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
Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
CatalogConfigurationReaderonly includes config reading, caching, config object validation feature - Created
utils/directory withdefault.ts,validation.ts,resolution.ts,functions.tsdefault.ts: Fallback to default alias groupvalidation.ts: Validate if catalog dependencies are using catalog protocols (if possible)resolution.ts: Resolve catalog dependency & Find all alias groups that contain specific dependencyfuntions.ts: General utility functions
Key changes
src/index.ts, extracted utility functions into dedicated files.get-catalog-protocol-usability.ts.configuration.tsinto multiple files for better separation of concerns.src/constants.tsandsrc/types.ts.findAllAccessibleGroupsand replaced withfindDependency.getCatalogDependenciesWithoutProtocol->getUnusedCatalogDependencies)Minor changes
typecheckscript..prettierrcfor consistent formatting.Descriptortypes instead of raw string types when possible.Test result