muxify 0.1.11 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +1 -1
- data/README.md +20 -1
- data/Rakefile +4 -5
- data/lib/muxify/builder.rb +52 -44
- data/lib/muxify/cli.rb +7 -7
- data/lib/muxify/linker.rb +3 -3
- data/lib/muxify/version.rb +1 -1
- data/lib/muxify.rb +8 -2
- data/muxify.gemspec +19 -19
- metadata +9 -10
- data/.rubocop.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99b06fb29cb0313ee692a84da4cfa068931256fd8e19325c3431e45463d4ef76
|
4
|
+
data.tar.gz: ebfe044c5cd37f1f62574fd289a2ec0038ee56ab34f2eb14a80fe0ea6c704827
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fcf84278243026a0e7c9e5b80cb31924172f1ee3300da85641c174cf768f3183de26aa4c40aacfdf793049a47b4a5f8d5bd46a3a7cdf2b54607d12431628f3e
|
7
|
+
data.tar.gz: 97a6fceaf5887c62cae38a8919bdd35d43aa59ff1b0e5af0119e3ce953b9d665247fae166b9f289d8e39e79eddb0bc3f38b5fa57683c15abd2c39e77b69f351c
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -64,7 +64,9 @@ Depending on its type, this will create the following tmux windows for a project
|
|
64
64
|
|
65
65
|
## Customising projects
|
66
66
|
|
67
|
-
|
67
|
+
Each project may have custom windows via a `.muxifyrc` file.
|
68
|
+
|
69
|
+
### Using a .muxifyrc in your home directory
|
68
70
|
|
69
71
|
1. Create a file called `~/.muxifyrc`.
|
70
72
|
1. Edit it in YAML format; eg to add a tmux window to `my_app` project which is named `server` and invokes `yarn dev`:
|
@@ -75,6 +77,23 @@ my_app:
|
|
75
77
|
server: yarn dev
|
76
78
|
```
|
77
79
|
|
80
|
+
If you want a custom window for all projects:
|
81
|
+
|
82
|
+
```yaml
|
83
|
+
windows:
|
84
|
+
echo_all_projects: "echo 'this will apply to all projects'"
|
85
|
+
```
|
86
|
+
|
87
|
+
### Using a .muxifyrc in your project directory
|
88
|
+
|
89
|
+
1. Create a file called `my_app/.muxifyrc` (given your project is in `my_app`).
|
90
|
+
1. Edit it in YAML format; eg to add a tmux window to `my_app` project which is named `server` and invokes `yarn dev`:
|
91
|
+
|
92
|
+
```yaml
|
93
|
+
windows:
|
94
|
+
server: yarn dev
|
95
|
+
```
|
96
|
+
|
78
97
|
## Thanks
|
79
98
|
|
80
99
|
- https://github.com/tmuxinator/tmuxinator
|
data/Rakefile
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "standard/rake"
|
6
6
|
|
7
|
-
RuboCop::RakeTask.new
|
8
7
|
RSpec::Core::RakeTask.new(:spec)
|
9
8
|
|
10
|
-
task default: %i[
|
9
|
+
task default: %i[standard spec]
|
data/lib/muxify/builder.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "yaml"
|
4
4
|
|
5
5
|
module Muxify
|
6
6
|
class Builder
|
7
|
-
|
8
|
-
private_constant :
|
7
|
+
DEFAULT_CUSTOM_CONFIG_PATH = File.join(ENV["HOME"], ".muxifyrc")
|
8
|
+
private_constant :DEFAULT_CUSTOM_CONFIG_PATH
|
9
9
|
|
10
|
-
def self.call(
|
11
|
-
new(
|
10
|
+
def self.call(path, **kwargs)
|
11
|
+
new(path, **kwargs).to_yaml
|
12
12
|
end
|
13
13
|
|
14
|
-
def initialize(root, name: nil
|
14
|
+
def initialize(root, name: nil)
|
15
15
|
@root = File.expand_path(root)
|
16
16
|
@name = name || File.basename(@root)
|
17
|
-
@custom_config_path = custom_config_path
|
18
17
|
end
|
19
18
|
|
20
19
|
def to_yaml
|
@@ -23,37 +22,46 @@ module Muxify
|
|
23
22
|
|
24
23
|
private
|
25
24
|
|
26
|
-
attr_reader :root, :name
|
25
|
+
attr_reader :root, :name
|
27
26
|
|
28
27
|
def config
|
29
28
|
{
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
"name" => name,
|
30
|
+
"root" => root,
|
31
|
+
"windows" => windows
|
33
32
|
}
|
34
33
|
end
|
35
34
|
|
36
35
|
def windows
|
37
|
-
Windows.new(root).all.tap do |windows|
|
36
|
+
windows = Windows.new(root).all.tap do |windows|
|
38
37
|
custom_windows.each do |name, command|
|
39
38
|
windows << {name => command}
|
40
39
|
end
|
41
40
|
end
|
41
|
+
|
42
|
+
windows
|
43
|
+
.each_with_object({}) { |window, result| result[window.keys.first] = window.values.first }
|
44
|
+
.each_with_object([]) { |(k, v), result| result << {k => v} }
|
42
45
|
end
|
43
46
|
|
44
47
|
def custom_windows
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
+
custom_config_paths.each_with_object({}) do |custom_config_path, result|
|
49
|
+
[
|
50
|
+
YAML.safe_load_file(custom_config_path)&.dig(name, "windows"),
|
51
|
+
YAML.safe_load_file(custom_config_path)&.dig("windows")
|
52
|
+
].compact.each(&result.method(:merge!))
|
53
|
+
end
|
48
54
|
end
|
49
55
|
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
56
|
+
def custom_config_paths
|
57
|
+
[
|
58
|
+
DEFAULT_CUSTOM_CONFIG_PATH,
|
59
|
+
project_custom_config_path,
|
60
|
+
].compact.uniq.select(&File.method(:exist?))
|
61
|
+
end
|
55
62
|
|
56
|
-
|
63
|
+
def project_custom_config_path
|
64
|
+
File.join(root, ".muxifyrc")
|
57
65
|
end
|
58
66
|
|
59
67
|
class Windows
|
@@ -70,7 +78,7 @@ module Muxify
|
|
70
78
|
*elixir_non_phoenix,
|
71
79
|
*phoenix,
|
72
80
|
*nodejs,
|
73
|
-
*django
|
81
|
+
*django
|
74
82
|
]
|
75
83
|
end
|
76
84
|
|
@@ -79,28 +87,28 @@ module Muxify
|
|
79
87
|
attr_reader :root
|
80
88
|
|
81
89
|
def shell
|
82
|
-
[{
|
90
|
+
[{"shell" => init_shell}]
|
83
91
|
end
|
84
92
|
|
85
93
|
def init_shell
|
86
94
|
return 'echo "Not a git repository."' unless git?
|
87
95
|
|
88
|
-
|
96
|
+
"git fetch; git status"
|
89
97
|
end
|
90
98
|
|
91
99
|
def git?
|
92
|
-
|
100
|
+
system("git rev-parse &>/dev/null")
|
93
101
|
end
|
94
102
|
|
95
103
|
def editor
|
96
|
-
[{
|
104
|
+
[{"editor" => ENV.fetch("EDITOR", "vim")}]
|
97
105
|
end
|
98
106
|
|
99
107
|
def logs
|
100
108
|
return [] if logfiles.empty?
|
101
109
|
|
102
110
|
logfiles.each(&method(:truncate_file))
|
103
|
-
[{
|
111
|
+
[{"logs" => "tail -f log/*.log"}]
|
104
112
|
end
|
105
113
|
|
106
114
|
def logfiles
|
@@ -115,67 +123,67 @@ module Muxify
|
|
115
123
|
return [] unless rails?
|
116
124
|
|
117
125
|
[
|
118
|
-
{
|
119
|
-
{
|
120
|
-
{
|
126
|
+
{"db" => "rails db"},
|
127
|
+
{"console" => "rails console"},
|
128
|
+
{"server" => File.join(Muxify.root, "bin/rails_server_with_puma_dev")},
|
121
129
|
]
|
122
130
|
end
|
123
131
|
|
124
132
|
def rails?
|
125
|
-
exists?(
|
133
|
+
exists?("bin/rails")
|
126
134
|
end
|
127
135
|
|
128
136
|
def elixir_non_phoenix
|
129
137
|
return [] unless elixir_non_phoenix?
|
130
138
|
|
131
139
|
[
|
132
|
-
{
|
133
|
-
{
|
140
|
+
{"console" => "iex -S mix"},
|
141
|
+
{"server" => "mix"}
|
134
142
|
]
|
135
143
|
end
|
136
144
|
|
137
145
|
def elixir_non_phoenix?
|
138
|
-
exists?(
|
146
|
+
exists?("mix.exs") && !phoenix?
|
139
147
|
end
|
140
148
|
|
141
149
|
def phoenix
|
142
150
|
return [] unless phoenix?
|
143
151
|
|
144
152
|
[
|
145
|
-
{
|
146
|
-
{
|
153
|
+
{"console" => "iex -S mix phx.server"},
|
154
|
+
{"server" => "mix phx.server"}
|
147
155
|
]
|
148
156
|
end
|
149
157
|
|
150
158
|
def phoenix?
|
151
|
-
directory?(
|
159
|
+
directory?("deps/phoenix")
|
152
160
|
end
|
153
161
|
|
154
162
|
def nodejs
|
155
163
|
return [] unless nodejs?
|
156
164
|
|
157
165
|
[
|
158
|
-
{
|
166
|
+
{"console" => "node"}
|
159
167
|
]
|
160
168
|
end
|
161
169
|
|
162
170
|
def nodejs?
|
163
|
-
exists?(
|
171
|
+
exists?("package.json") && !rails?
|
164
172
|
end
|
165
173
|
|
166
174
|
def django
|
167
175
|
return [] unless django?
|
168
176
|
|
169
177
|
[
|
170
|
-
{
|
171
|
-
{
|
172
|
-
{
|
178
|
+
{"db" => "python manage.py dbshell"},
|
179
|
+
{"console" => "python manage.py shell"},
|
180
|
+
{"server" => "python manage.py runserver"}
|
173
181
|
]
|
174
182
|
end
|
175
183
|
|
176
184
|
def django?
|
177
|
-
python_requirements = File.join(root,
|
178
|
-
File.exist?(python_requirements) && File.read(python_requirements).include?(
|
185
|
+
python_requirements = File.join(root, "requirements.txt")
|
186
|
+
File.exist?(python_requirements) && File.read(python_requirements).include?("django")
|
179
187
|
end
|
180
188
|
|
181
189
|
def directory?(relative_path)
|
data/lib/muxify/cli.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "thor"
|
4
|
+
require "muxify/builder"
|
5
|
+
require "muxify/linker"
|
6
6
|
|
7
7
|
module Muxify
|
8
8
|
class CLI < Thor
|
9
|
-
desc
|
9
|
+
desc "add", "Adds tmuxinator config for current (or supplied) path"
|
10
10
|
def add(root = Dir.pwd)
|
11
11
|
Muxify::Linker.call(root: root)
|
12
12
|
end
|
13
13
|
|
14
|
-
desc
|
14
|
+
desc "debug", "Prints tmuxinator config of current (or supplied) path to stdout"
|
15
15
|
def debug(root = Dir.pwd)
|
16
16
|
puts Muxify::Builder.call(root)
|
17
17
|
end
|
18
18
|
|
19
|
-
desc
|
19
|
+
desc "stop", "Kills tmux session"
|
20
20
|
def stop(name = File.basename(Dir.pwd))
|
21
21
|
Kernel.system("tmux kill-session -t #{name}")
|
22
22
|
end
|
23
23
|
|
24
|
-
desc
|
24
|
+
desc "version", "Print current version"
|
25
25
|
def version
|
26
26
|
puts Muxify::VERSION
|
27
27
|
end
|
data/lib/muxify/linker.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "fileutils"
|
4
4
|
|
5
5
|
module Muxify
|
6
6
|
class Linker
|
7
|
-
TMUXINATOR_CONFIG_PATH = File.expand_path(File.join(ENV.fetch(
|
7
|
+
TMUXINATOR_CONFIG_PATH = File.expand_path(File.join(ENV.fetch("HOME"), ".tmuxinator")).freeze
|
8
8
|
private_constant :TMUXINATOR_CONFIG_PATH
|
9
9
|
|
10
10
|
def self.call(**args)
|
@@ -17,7 +17,7 @@ module Muxify
|
|
17
17
|
|
18
18
|
def call
|
19
19
|
FileUtils.mkdir_p(TMUXINATOR_CONFIG_PATH)
|
20
|
-
File.open(config_path,
|
20
|
+
File.open(config_path, "w") { |f| f << contents }
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
data/lib/muxify/version.rb
CHANGED
data/lib/muxify.rb
CHANGED
data/muxify.gemspec
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require "muxify/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.authors
|
11
|
-
spec.email
|
8
|
+
spec.name = "muxify"
|
9
|
+
spec.version = Muxify::VERSION
|
10
|
+
spec.authors = ["Zubin Henner"]
|
11
|
+
spec.email = ["zubin@users.noreply.github.com"]
|
12
12
|
|
13
|
-
spec.summary
|
14
|
-
spec.homepage
|
13
|
+
spec.summary = "Simple tmux project config"
|
14
|
+
spec.homepage = "https://github.com/zubin/muxify"
|
15
15
|
|
16
|
-
spec.files
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
17
|
f.match(%r{^(test|spec|features)/})
|
18
18
|
end
|
19
|
-
spec.bindir
|
20
|
-
spec.executables
|
21
|
-
spec.require_paths = [
|
22
|
-
spec.required_ruby_version =
|
19
|
+
spec.bindir = "bin"
|
20
|
+
spec.executables = ["muxify"]
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
spec.required_ruby_version = ">= 3.0.0"
|
23
23
|
|
24
|
-
spec.add_dependency
|
25
|
-
spec.add_dependency
|
24
|
+
spec.add_dependency "thor"
|
25
|
+
spec.add_dependency "tmuxinator"
|
26
26
|
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
27
|
+
spec.add_development_dependency "bundler"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
spec.add_development_dependency "rspec"
|
30
|
+
spec.add_development_dependency "standard"
|
31
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muxify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zubin Henner
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: standard
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
description:
|
97
|
+
description:
|
98
98
|
email:
|
99
99
|
- zubin@users.noreply.github.com
|
100
100
|
executables:
|
@@ -104,7 +104,6 @@ extra_rdoc_files: []
|
|
104
104
|
files:
|
105
105
|
- ".gitignore"
|
106
106
|
- ".rspec"
|
107
|
-
- ".rubocop.yml"
|
108
107
|
- ".travis.yml"
|
109
108
|
- Gemfile
|
110
109
|
- README.md
|
@@ -125,7 +124,7 @@ files:
|
|
125
124
|
homepage: https://github.com/zubin/muxify
|
126
125
|
licenses: []
|
127
126
|
metadata: {}
|
128
|
-
post_install_message:
|
127
|
+
post_install_message:
|
129
128
|
rdoc_options: []
|
130
129
|
require_paths:
|
131
130
|
- lib
|
@@ -133,15 +132,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
132
|
requirements:
|
134
133
|
- - ">="
|
135
134
|
- !ruby/object:Gem::Version
|
136
|
-
version:
|
135
|
+
version: 3.0.0
|
137
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
137
|
requirements:
|
139
138
|
- - ">="
|
140
139
|
- !ruby/object:Gem::Version
|
141
140
|
version: '0'
|
142
141
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
-
signing_key:
|
142
|
+
rubygems_version: 3.3.7
|
143
|
+
signing_key:
|
145
144
|
specification_version: 4
|
146
145
|
summary: Simple tmux project config
|
147
146
|
test_files: []
|
data/.rubocop.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
Layout/SpaceInsideArrayLiteralBrackets:
|
3
|
-
EnforcedStyle: no_space
|
4
|
-
Layout/SpaceInsideHashLiteralBraces:
|
5
|
-
EnforcedStyle: no_space
|
6
|
-
Style/Documentation:
|
7
|
-
Enabled: false
|
8
|
-
Style/StringLiterals:
|
9
|
-
Enabled: false
|
10
|
-
Style/TrailingCommaInArguments:
|
11
|
-
EnforcedStyleForMultiline: comma
|
12
|
-
Style/TrailingCommaInArrayLiteral:
|
13
|
-
EnforcedStyleForMultiline: comma
|
14
|
-
Style/TrailingCommaInHashLiteral:
|
15
|
-
EnforcedStyleForMultiline: comma
|