-
Notifications
You must be signed in to change notification settings - Fork 626
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
Support specified config directory and XDG Base Dirs Spec #479
Conversation
Resolve Issue tmuxinator#462 - "Tmuxinator config files in a different location" Resolve Issue tmuxinator#360 - "XDG base directory support" Mentioned in Issue tmuxinator#427 - "Introduce Analytics Module" Allow `$TMUXINATOR_CONFIG` to specify a configuration directory, which will be created if it doesn't exist. This directory takes preference over honouring the XDG specification (below). If specified, this will be the only configuration location used. Honour the [XDG Base Directories Specification] (https://specifications.freedesktop.org/basedir-spec/latest/) with regards to user specific configuration files: Look for `tmuxinator` configuration files under `$XDG_CONFIG_HOME/tmuxinator`. For existing setups with no `$XDG_CONFIG_HOME` directory, continue to create new projects in `~/.tmuxinator` for backwards compatibility. If `$XDG_CONFIG_HOME/tmuxinator` exists, create new projects there. If neither `~/.tmuxinator` nor `$XDG_CONFIG_HOME/tmuxinator` exist, use `$XDG_CONFIG_HOME/tmuxinator` for new projects. When loading a project, search `$XDG_CONFIG_HOME/tmuxinator` before `~/.tmuxinator`. Document in comments and tests the existing behaviour of returning only the first project file found in a recursive search of a configuration directory. Add Config#directories: an array of the configuration director{y,ies} which exist. Update commands `implode` and `list` to operate upon this array. Rename `Config#root` -> `Config#directory` This directory is the only one used when creating new project files, and may be either `$TMUXINATOR_CONFIG`, `$XDG_CONFIG_HOME/tmuxinator` or `~/.tmuxinator`. Implementing XDG Base Dirs support with backwards compatibility means that two directories may contain project files, making the `root` nomenclature misleading as it implies a single directory. Rename `Config#project_in_root` -> `Config#global_project` See comment on `root` terminology above. `global_project` is also shorter and corresponds to the naming of `default_project` Rename `Config#project_in_local` -> `Config#local_project` Fit with the naming of both `global_project` and `default_project`
Allow existing code to work with renamed methods Deprecated methods: ignore the 1st, use the 2nd alias :root :directory alias :project_in_root :global_project alias :project_in_local :local_project
OK, ready for comments / merge. |
This looks good 👍 |
@ethagnawl @J3RN do you have any feedback on this for @HaleTom? I say LGTM. |
@adamstrickland I've reviewed these changes a few times and, barring a few small nitpicks (adding comments now), everything looks good to me. Though, I haven't had a chance to pull it down and experiment yet. |
lib/tmuxinator/config.rb
Outdated
root_dir | ||
# The directory (created if needed) in which to store new projects | ||
def directory | ||
environment = ENV["TMUXINATOR_CONFIG"] |
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.
This config get/test behavior is used in multiple places, so it might warrant its own helper method.
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.
Thanks for the thorough review, I'll get on to these in a couple of days to allow for more reviewers to have their say in the meantime.
lib/tmuxinator/config.rb
Outdated
Dir["#{Tmuxinator::Config.root}/**/*.yml"].sort.map do |path| | ||
path.gsub("#{Tmuxinator::Config.root}/", "").gsub(".yml", "") | ||
configs = [] | ||
directories.each do |directory| |
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.
Is there a good reason not to use map
here?
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 guess a brain-fart doesn't count :)
@ethagnawl I trust that this is good to go now. Thanks for the thorough review - I learned from it. |
This LGTM 👍 |
@HaleTom I had some time to experiment with this today. With the exception of one very small item (covered below), everything appears to work as intended. I noticed that the config path at the top of the project yml file always uses the old default directory (~/.tmuxinator/$PROJECT). It's possible that this is caused by some legacy config on my system and it doesn't break anything (that I'm aware of, at least) but it's probably worth addressing. Also, as a bonus, the fix will likely address #440. |
@Soliah @adamstrickland Any thoughts on the above? Shall we merge this as-is? It might be a bit self-serving, but I'd like to begin using XDG on my dev machines. |
Merging this broke the build. I'm looking into it now and will submit a patch. @HaleTom If you're available, would you mind taking a look to see if anything jumps out at you? UPDATE: |
I'm working towards diagnosing this. I got out of hospital yesterday (dengue), and am battling a |
The doco for
I'll append |
PR #506 created. I hope this is what you were after - let me know if not. |
@HaleTom Wow. I hope you're feeling better! :| Thanks for looking into this issue. Unfortunately, PR #506 doesn't look like it's going to address the problem and reintroduce the changes from your original PR. Perhaps that's because #506 wants to merge its changes into the branch: tmuxinator:revert-479-Issues-360-462? Could you try creating a new PR and selecting UPDATE:
|
Allow setting config directory and honour XDG Base Dirs Spec
Resolve Issue #462 - "Tmuxinator config files in a different location"
Resolve Issue #360 - "XDG base directory support"
Mentioned in Issue #427 - "Introduce Analytics Module"
Allow
$TMUXINATOR_CONFIG
to specify a configuration directory, whichwill be created (including its parent directories) if it doesn't exist. This
directory takes preference over honouring the XDG specification (below). If
specified, this will be the only configuration location used.
Honour the XDG Base Directories Specification
with regards to user specific configuration files: Look for
tmuxinator
configuration files under
$XDG_CONFIG_HOME/tmuxinator
.For existing setups with no
$XDG_CONFIG_HOME
directory, continue tocreate new projects in
~/.tmuxinator
for backwards compatibility.If
$XDG_CONFIG_HOME/tmuxinator
exists, create new projects there.If neither
~/.tmuxinator
nor$XDG_CONFIG_HOME/tmuxinator
exist, use$XDG_CONFIG_HOME/tmuxinator
for new projects. Create this directory(including its parents) if it does not exist.
When loading a project, search
$XDG_CONFIG_HOME/tmuxinator
before~/.tmuxinator
. Document in comments and tests the existing behaviourof returning only the first project file found in a recursive search of
a configuration directory.
Add
Config#directories
: an array of the configuration director{y,ies}which exist. Update commands
implode
andlist
to operate upon thisarray.
Add
alias
es for the 3 renamed methods below for backwardcompatibility:
Rename
Config#root
->Config#directory
This directory is the only one used when creating new project files, and
may be either
$TMUXINATOR_CONFIG
,$XDG_CONFIG_HOME/tmuxinator
or~/.tmuxinator
.Implementing XDG Base Dirs support with backwards compatibility means
that two directories may contain project files, making the
root
nomenclature misleading as it implies a single directory.
Rename
Config#project_in_root
->Config#global_project
See comment on
root
terminology above.global_project
is alsoshorter and corresponds to the naming of
default_project
Rename
Config#project_in_local
->Config#local_project
Fit with the naming of both
global_project
anddefault_project
Sort gem dependencies into alphabetical order