Skip to content
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

refactor: cache project context in toolbox to avoid passing it everywhere #115

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

km1chno
Copy link
Collaborator

@km1chno km1chno commented Sep 19, 2024

Resolves #43

@km1chno km1chno self-assigned this Sep 19, 2024
@km1chno km1chno marked this pull request as draft September 19, 2024 13:09
@km1chno km1chno changed the title @km1chno/refactor better project context refactor: cache project context in toolbox to avoid passing it everywhere Sep 19, 2024
@km1chno km1chno marked this pull request as ready for review September 30, 2024 08:01
toolbox.interactive.surveyStep(
'Created snapshot of project state before execution.'
)

context.selectedOptions = await getSelectedOptions(toolbox)
toolbox.context.selectedOptions = await getSelectedOptions(toolbox)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer a setter here and possibly in other places getter instead of just toolbox.context.variable -> so noone is tempted to write (override) something

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 was never really happy with the fact that we kept selectedOptions in context, I now created new small extension ConfigExtension which manages the cli configuration - my idea is that it will be the information about what recipes should be generated for what branches, what vendor etc.

For now our config is very simple, it's just a subset of available recipes. So basically I extracted the layer obtaining this information (from flags in case of --preset provided and otherwise from survey) to ConfigExtension

Now you have to use toolbox.config.selectedRecipes() instead of toolbox.context.selectedOptions, so also no way to accidentally override the config

13f45f2

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.

Figure out what to do with project context
2 participants