-
Notifications
You must be signed in to change notification settings - Fork 365
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
feat: default to XDG spec for global config #1530
Conversation
when ~/.netlify/config.json is not present use $XDG_CONFIG_HOME/netlify/config.json, which falls back to ~/.config/netlify/config.json if $XDG_CONFIG_HOME is not set
const globalConfigDefaults = { | ||
/* disable stats from being sent to Netlify */ | ||
telemetryDisabled: false, | ||
/* cliId */ | ||
cliId: uuidv4(), | ||
} | ||
|
||
const legacyConfigPath = getPathInHome(['config.json']) |
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.
We could look for the folder instead in case there are other files in ~/.netlify
Hi @evans, Thanks a lot for this feature! However, this not apply to Windows users. For them, I believe using a library like
This can be easily handled with the |
To add to @ehmicky comment, would it make sense to change the file
|
@ehmicky @erezrokah I have some embarrassing news. I've started a new job and won't have the time to devote to open source outside of that scope, so I won't be pushing this PR forward. In terms of your comments, I agree with the decision to make the retrieval of the config a function and I wish that I could make the time/brainspace to make the changes. If you have bandwidth, feel free to take the branch over. If not, feel free to close the PR. In any case, thank you for your reviews and work on the Netlify CLI! I'm rooting for you and look forward to the developer wins you bring 💪 |
Congrats on the new job and thank you for following up. Since the PR and the issue make sense we'll try to push it forward. |
@evans Thanks for stirring us in the right direction with this, we'll take it from there. Congratulations on the new job! |
- Summary
Thank you for making tools with slick dx(love the branch previews)! I was looking into #526 as a first issue 🎉 , which requests the XDG specification for the global netlify configuration. In other words use to
~/.config/netlify ...
instead of~/.netlify/config.json
.This PR suggests using
~/.netlify/config.json
if it exists. Otherwise configureconfigstore
to place the config in~/.config/netlify/config.json
or$XDG_CONFIG_HOME/netlify/config.json
. I'm not fully happy with this plan, so I'm open to suggestions.If
config.json
is retrieved in more places than the netlify cli(source), then I'm happy to add that to this PR if possible! Also if the~/.netlify
folder is used for more files, I recommend closing this PR and discussing the feasibility on #526 . I also worry about documentation, testing, and code style. Please let me know if there's something I missed.Closes #526
My understanding of netlify configurations(not necessary to look at)
To frame the problem, there are three different configurations that I've come across: `netlify.toml`, `.netlify/config.json`, and `.netlify/state.json`. As I understand, their functions are:netlify.toml
: build settings(ex: usenpm run
vsjekyll build
), deploy settings, and env variables~/.netlify/config.json
: global netlify state, such as userId and auth tokens.netlify/state.json
: local netlify state, such as siteIdTheir path resolution:
netlify.toml
: provided through flag or source~/.netlify/config.json
: set to{os.homedir()}/.netlify/config.json
using configstore'sconfigPath
source.netlify/state.json
: searched for up fromcwd
like node module resolution(source)
- Test plan
I can add a test that uses
mock-fs
, though we may run into issues with mock-fs not playing nice with tests using node'sfs
(tschaub/mock-fs#103) and I vaguely remember having difficulty across os's.cli/src/lib/exec-fetcher.test.js
Lines 16 to 18 in e031d8e
I've run locally, though I don't consider that worth much for maintainability, so I'd love suggestions here!
- Description for the changelog
feat: default to XDG spec for global config when
~/.netlify/config.json
doesn't exist.- A picture of a cute animal (not mandatory but encouraged)
༼ つ ◕_◕ ༽つ