muxify 0.1.6 → 0.1.7
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/README.md +28 -26
- data/bin/rails_server_with_puma_dev +53 -0
- data/lib/muxify/builder.rb +10 -2
- data/lib/muxify/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98861ef327df42548ffe35e925b221c5c16a44b5623f55a3c7384a41e55a1e3f
|
4
|
+
data.tar.gz: e8cbc88546ae7cae5610e32f1aa3349ea9b687dc682cd79c48fb9c4289024036
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9bc6c4c4351d1cc2ed64d82c5de796cda9a956c42d086e05eef2077074f2228cd0ff3952eed55e2d676effcd8f52514024acb6bf3be8e9e813c6f283026cbda
|
7
|
+
data.tar.gz: ca0f1396d5cba5b0c5265d23633dc2a7ede6ce50de492f0d3141a10e9faf3c5b71c6c83a00ba2fe22809dd542b08aef9977259570bbfa54f4632b87944e705c2
|
data/README.md
CHANGED
@@ -4,15 +4,15 @@ Sets up consistent tmux development environment for projects.
|
|
4
4
|
|
5
5
|
Why?
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
- Saves time and effort switching projects.
|
8
|
+
- Ensures consistent layout which is faster to navigate via muscle memory.
|
9
|
+
- Avoids visual and mental overhead of maintaining numerous tabs.
|
10
10
|
|
11
11
|
## Dependencies
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
- MacOS (may work on Linux)
|
14
|
+
- Ruby
|
15
|
+
- Tmux (`which tmux || brew install tmux`)
|
16
16
|
|
17
17
|
## Installation
|
18
18
|
|
@@ -41,25 +41,26 @@ $ mux my_app
|
|
41
41
|
|
42
42
|
Depending on its type, this will create the following tmux windows for a project:
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
44
|
+
- Standard (applies to all projects)
|
45
|
+
- shell (performs `git fetch` when `.git` is present)
|
46
|
+
- editor (invokes terminal editor, defaulting to `vim` when `$EDITOR` is unset)
|
47
|
+
- logs (when present, truncates then tails `log/*.log`)
|
48
|
+
- Rails (identified by presence of `bin/rails`)
|
49
|
+
- db (`rails db`)
|
50
|
+
- console (`rails console`)
|
51
|
+
- server (configures puma-dev then `rails server`; see [code](./bin/rails_server_with_puma_dev))
|
52
|
+
- NodeJS (identified by presence of `package.json` when non-Rails)
|
53
|
+
- console (`node`)
|
54
|
+
- Elixir (identified by presence of `mix.exs` when non-Phoenix)
|
55
|
+
- console (`iex -S mix`)
|
56
|
+
- server (`mix`)
|
57
|
+
- Elixir/Phoenix (identified by presence of `deps/phoenix`)
|
58
|
+
- console (`iex -S mix phoenix.server`)
|
59
|
+
- server (`mix phoenix.server`)
|
60
|
+
- Django (identified by `requirements.txt` containing `django`)
|
61
|
+
- db (`python manage.py dbshell`)
|
62
|
+
- console (`python manage.py shell`)
|
63
|
+
- server (`python manage.py runserver`)
|
63
64
|
|
64
65
|
## Customising projects
|
65
66
|
|
@@ -67,6 +68,7 @@ To add a custom tmux window for a project:
|
|
67
68
|
|
68
69
|
1. Create a file called `~/.muxifyrc`.
|
69
70
|
1. Edit it in YAML format; eg to add a tmux window to `my_app` project which is named `server` and invokes `yarn dev`:
|
71
|
+
|
70
72
|
```yaml
|
71
73
|
my_app:
|
72
74
|
windows:
|
@@ -75,7 +77,7 @@ my_app:
|
|
75
77
|
|
76
78
|
## Thanks
|
77
79
|
|
78
|
-
|
80
|
+
- https://github.com/tmuxinator/tmuxinator
|
79
81
|
|
80
82
|
## Contributing
|
81
83
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# Starts rails server with a random port and configures puma-dev
|
4
|
+
# Usage:
|
5
|
+
# rails_server_with_puma_dev [HOSTNAME]
|
6
|
+
# HOSTNAME should not include the `.test` extension.
|
7
|
+
# If HOSTNAME isn't supplied, it defaults to current directory name
|
8
|
+
# (underscores are converted to dashes).
|
9
|
+
|
10
|
+
set -euo pipefail
|
11
|
+
|
12
|
+
min_port=3000
|
13
|
+
max_port=4000
|
14
|
+
puma_dev_config_path="$HOME/.puma-dev"
|
15
|
+
|
16
|
+
find_available_port() {
|
17
|
+
netstat -aln | awk -v min_port="$min_port" -v max_port="$max_port" '
|
18
|
+
$6 == "LISTEN" {
|
19
|
+
if ($4 ~ "[.:][0-9]+$") {
|
20
|
+
split($4, a, /[:.]/);
|
21
|
+
port = a[length(a)];
|
22
|
+
p[port] = 1
|
23
|
+
}
|
24
|
+
}
|
25
|
+
END {
|
26
|
+
for (i = min_port; i < max_port && p[i]; i++) {};
|
27
|
+
if (i == max_port) { exit 1 };
|
28
|
+
print i
|
29
|
+
}
|
30
|
+
'
|
31
|
+
}
|
32
|
+
|
33
|
+
get_target_hostname() {
|
34
|
+
if (( $# == 0 )); then
|
35
|
+
echo "$(basename "$(pwd)" | tr '_' '-')"
|
36
|
+
else
|
37
|
+
echo $1
|
38
|
+
fi
|
39
|
+
}
|
40
|
+
|
41
|
+
configure_puma_dev() {
|
42
|
+
target_config_path="$puma_dev_config_path/$host"
|
43
|
+
echo "Configuring puma-dev: $host.test:$port ($target_config_path)"
|
44
|
+
echo "$port" > "$target_config_path"
|
45
|
+
puma-dev -stop
|
46
|
+
pkill -USR1 puma-dev
|
47
|
+
}
|
48
|
+
|
49
|
+
target_port="$(find_available_port)"
|
50
|
+
target_host="$(get_target_hostname "$@")"
|
51
|
+
|
52
|
+
host="$target_host" port="$target_port" configure_puma_dev
|
53
|
+
bundle exec rails server -p "$target_port"
|
data/lib/muxify/builder.rb
CHANGED
@@ -91,6 +91,7 @@ module Muxify
|
|
91
91
|
|
92
92
|
def logs
|
93
93
|
return [] if logfiles.empty?
|
94
|
+
|
94
95
|
logfiles.each(&method(:truncate_file))
|
95
96
|
[{'logs' => 'tail -f log/*.log'}]
|
96
97
|
end
|
@@ -105,6 +106,7 @@ module Muxify
|
|
105
106
|
|
106
107
|
def foreman
|
107
108
|
return [] unless foreman?
|
109
|
+
|
108
110
|
[{'foreman' => <<-SH.strip}]
|
109
111
|
ps aux | grep 'unicorn_rails master' | awk '{print $2}' | xargs kill; foreman start
|
110
112
|
SH
|
@@ -116,9 +118,11 @@ module Muxify
|
|
116
118
|
|
117
119
|
def rails
|
118
120
|
return [] unless rails?
|
121
|
+
|
119
122
|
[
|
120
123
|
{'db' => 'rails db'},
|
121
124
|
{'console' => 'rails console'},
|
125
|
+
{'server' => File.expand_path('../../bin/rails_server_with_puma_dev', __dir__)},
|
122
126
|
]
|
123
127
|
end
|
124
128
|
|
@@ -128,6 +132,7 @@ module Muxify
|
|
128
132
|
|
129
133
|
def elixir_non_phoenix
|
130
134
|
return [] unless elixir_non_phoenix?
|
135
|
+
|
131
136
|
[
|
132
137
|
{'console' => 'iex -S mix'},
|
133
138
|
{'server' => 'mix'},
|
@@ -140,6 +145,7 @@ module Muxify
|
|
140
145
|
|
141
146
|
def phoenix
|
142
147
|
return [] unless phoenix?
|
148
|
+
|
143
149
|
[
|
144
150
|
{'console' => 'iex -S mix phoenix.server'},
|
145
151
|
{'server' => 'mix phoenix.server'},
|
@@ -152,6 +158,7 @@ module Muxify
|
|
152
158
|
|
153
159
|
def nodejs
|
154
160
|
return [] unless nodejs?
|
161
|
+
|
155
162
|
[
|
156
163
|
{'console' => 'node'},
|
157
164
|
]
|
@@ -163,6 +170,7 @@ module Muxify
|
|
163
170
|
|
164
171
|
def django
|
165
172
|
return [] unless django?
|
173
|
+
|
166
174
|
[
|
167
175
|
{'db' => 'python manage.py dbshell'},
|
168
176
|
{'console' => 'python manage.py shell'},
|
@@ -172,7 +180,7 @@ module Muxify
|
|
172
180
|
|
173
181
|
def django?
|
174
182
|
python_requirements = File.join(root, 'requirements.txt')
|
175
|
-
File.
|
183
|
+
File.exist?(python_requirements) && File.read(python_requirements).include?('django')
|
176
184
|
end
|
177
185
|
|
178
186
|
def directory?(relative_path)
|
@@ -180,7 +188,7 @@ module Muxify
|
|
180
188
|
end
|
181
189
|
|
182
190
|
def exists?(relative_path)
|
183
|
-
File.
|
191
|
+
File.exist?(File.join(root, relative_path))
|
184
192
|
end
|
185
193
|
end
|
186
194
|
end
|
data/lib/muxify/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zubin Henner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- Rakefile
|
97
97
|
- bin/console
|
98
98
|
- bin/muxify
|
99
|
+
- bin/rails_server_with_puma_dev
|
99
100
|
- bin/setup
|
100
101
|
- lib/muxify.rb
|
101
102
|
- lib/muxify/builder.rb
|