-
-
Notifications
You must be signed in to change notification settings - Fork 816
feat: add support for persisting user preferences using a default configuration in the REPL #2559
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
Open
Snehil-Shah
wants to merge
6
commits into
stdlib-js:develop
Choose a base branch
from
Snehil-Shah:config
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
58eb85c
feat: add persistence using a default configuration
Snehil-Shah ad0cb06
fix: validate new themes
Snehil-Shah 734560c
Merge branch 'stdlib-js:develop' into config
Snehil-Shah c1a4c1c
feat: allow resolving config from a `.js` export
Snehil-Shah 1bc2c51
feat: explicitly prompt user before saving configuration
Snehil-Shah 49b4672
refactor: replace keybinding with an input prompt
Snehil-Shah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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 am still skeptical if this is the best way to do this. For context, after resolving the options from the configuration file, I am merging it with the
defaults()
, till level 2. My main concern being, we might not always want to merge all things till level 2 (and things like the input and output stream properties might also get wrongly merged creating corrupted data), should we have a custom merger (similar to thevalidate
function)?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.
Would you be able to show in code what you are concerned about? In particular, can you provide example config which gets merged and creates "corrupted"
opts
? Would help me, as I am having trouble visualizing the potential issue.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.
the
defaults()
also hasopts.input
which is a stream object (with many nested properties at diff levels), say someone makes a custom configuration, with aninput
option to a different object, they can potentially inject and corrupt the stream object at some levels because of the merge. We do have a list ofPERSISTABLE_OPTIONS
(L94), that we are using to allow saving only those specific properties that we want to persist. Maybe we can use it to also enforce that only thePERSISTABLE_OPTIONS
can be loaded through a custom configuration. But again, this isn't future-proof, as it can be something else other than streams as well that we might later support.Currently, in the
validate
function, we manually check if the given options (at REPL instantiation) has the prop or not (for a property, saysettings
), if yes, we merge or replace the default with the given property manually for each option. So, should we do something similar to merge 1) defaults, 2) configuration, and 3) REPL options into a finalopts
object?