Noovolari / leapp

Leapp is the DevTool to access your cloud
https://www.leapp.cloud/
Mozilla Public License 2.0
1.62k stars 147 forks source link

Follow XDG Base Directory Specificatoin #556

Open bigodel opened 7 months ago

bigodel commented 7 months ago

The problem

Since version 1.7.45, AWS CLI allows the user to specify the location of the configuration and credentials files through environment variables. I'd like for Leapp to follow this convention as well.

The solution

I think this wouldn't be hard to implement, we'd just need to use a library like xdg-basedir in either the implementation of INativeService or in AwsCoreService. I could try and get a PR, but I don't know if I can make it in a timely manner, plus I'm not really a Node developer.

Additional context

There is a caveat for macOS. As it says on the first line of the linked Node library, macOS doesn't really follow XDG by default, and instead puts stuff under ~/Library. We could get the values for macOS with the suggested library, env-paths, but I'd argue that supporting XDG on macOS is highly desirable as well, as many would rather use that (specially those, like me, who juggle dotfiles between a Mac and a Linux machine). It might not be trivial to do that since there is no default way to set XDG_* variables system-wide on login for Mac (on Linux, your Xorg session will source your ~/.profile or whatever equivalent of it you have when you first login into the system, and only then. On macOS, that gets sourced, by default, by every new terminal window you spawn, as if you're logging in every time you open a terminal).

I suppose this would only be an issue for the GUI app. The CLI should pick up the variables if the user set them correctly.