hiiro 0.1.155 → 0.1.156

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbe44699de1ea172d5b4d18436f3aae2e7fec81e0350f66aef04646c452e259d
4
- data.tar.gz: c91fba3e8f92db14f581af937b103ef3a87c52f993fe306a64a629b2420d0aee
3
+ metadata.gz: cc18a91776e0f111e0263e6dcf4c48129a14097f9b58cb0a75f3d7917c8281a2
4
+ data.tar.gz: 02f058b4148463f1685476f7c963931a74f2a1970cd8c8fddcf1fe1605f66721
5
5
  SHA512:
6
- metadata.gz: 274b382097248a427e5300634e6928a92c2ce2135742fcd8ad9fea5c6f822f8e882445a82b3b6879c1062b5a86d19a86675b5c263d1e811fd7f3fede11b5af4f
7
- data.tar.gz: 6cc068ece0ed1b5efcad1238ab14c42115364c33af8850781ef1e8dbca4bd5af751b53a33b421e8a95d12fa5d3bdcc6725a39682dade5356591cefb0c1ed1b50
6
+ metadata.gz: d2bad5c61c106dc01c45e62e40a3c49fc247b96cbd2c7d2138d5bb8c7df2fe995ad85e48563cf9250333e4bfe62f4307efdc27ca3103086f4e2e9c0e16681958
7
+ data.tar.gz: 23bb98706770163a575aa25ee40368cd5d94856c0ed4214e2aaaa4433afa92ec691738332d973dc44e02d0fec4b6f2ceaf724eb96a29c47c126b6e26bfeef8ef
@@ -1,6 +1,8 @@
1
1
  # Example services.yml
2
2
  # Place at ~/.config/hiiro/services.yml
3
3
  #
4
+ # base_dir is always relative to the repo root (where init/start commands run)
5
+ #
4
6
  # Base env templates referenced by base_env live in:
5
7
  # ~/.config/hiiro/env_templates/
6
8
 
@@ -22,7 +24,7 @@ redis:
22
24
  # Rails API - multiple init steps, single env file with variations
23
25
  # =============================================================================
24
26
  api-rails:
25
- base_dir: ~/work/api
27
+ base_dir: apps/api
26
28
  host: localhost
27
29
  port: 3000
28
30
  init:
@@ -67,7 +69,7 @@ api-rails:
67
69
  # GraphQL service - multiple env files
68
70
  # =============================================================================
69
71
  graphql:
70
- base_dir: ~/work/graphql
72
+ base_dir: services/graphql
71
73
  host: localhost
72
74
  port: 4000
73
75
  init:
@@ -118,7 +120,7 @@ graphql:
118
120
  # Frontend - depends on graphql URL
119
121
  # =============================================================================
120
122
  frontend:
121
- base_dir: ~/work/frontend
123
+ base_dir: apps/frontend
122
124
  host: localhost
123
125
  port: 8080
124
126
  start:
@@ -149,7 +151,7 @@ frontend:
149
151
  # Worker with custom stop command
150
152
  # =============================================================================
151
153
  sidekiq:
152
- base_dir: ~/work/api
154
+ base_dir: apps/api
153
155
  host: localhost
154
156
  port: ""
155
157
  start:
@@ -172,7 +174,7 @@ sidekiq:
172
174
  # Multi-command start - seed data then launch
173
175
  # =============================================================================
174
176
  demo-server:
175
- base_dir: ~/work/demo
177
+ base_dir: apps/demo
176
178
  host: localhost
177
179
  port: 5000
178
180
  init:
@@ -50,8 +50,7 @@ class Hiiro
50
50
  svc = find_service(svc_name)
51
51
  return unless svc
52
52
 
53
- base_dir = svc[:base_dir]
54
- return unless base_dir
53
+ base_dir = resolve_base_dir(svc[:base_dir])
55
54
 
56
55
  env_file_configs = build_env_file_configs(svc)
57
56
  return if env_file_configs.empty?
@@ -86,7 +85,7 @@ class Hiiro
86
85
  first_member = members.first
87
86
  first_name = first_member['name'] || first_member[:name]
88
87
  first_svc = find_service(first_name)
89
- first_base_dir = first_svc&.[](:base_dir) || Dir.pwd
88
+ first_base_dir = resolve_base_dir(first_svc&.[](:base_dir))
90
89
 
91
90
  # Create a new window for the group
92
91
  window_target = create_tmux_window(session, group[:name], first_base_dir)
@@ -99,7 +98,7 @@ class Hiiro
99
98
  svc = find_service(member_name)
100
99
  next unless svc
101
100
 
102
- base_dir = svc[:base_dir] || Dir.pwd
101
+ base_dir = resolve_base_dir(svc[:base_dir])
103
102
 
104
103
  if idx == 0
105
104
  # First service uses the initial pane
@@ -184,13 +183,9 @@ class Hiiro
184
183
 
185
184
  # Run init commands
186
185
  if svc[:init]
186
+ base_dir = resolve_base_dir(svc[:base_dir])
187
187
  svc[:init].each do |cmd|
188
- base_dir = svc[:base_dir]
189
- if base_dir
190
- system("cd #{base_dir} && #{cmd}")
191
- else
192
- system(cmd)
193
- end
188
+ system("cd #{base_dir} && #{cmd}")
194
189
  end
195
190
  end
196
191
 
@@ -207,7 +202,7 @@ class Hiiro
207
202
  end
208
203
 
209
204
  start_cmds = Array(start_cmd)
210
- base_dir = svc[:base_dir]
205
+ base_dir = resolve_base_dir(svc[:base_dir])
211
206
  session = tmux_info[:session] || current_tmux_session
212
207
 
213
208
  # Write start commands to an executable tempfile
@@ -215,7 +210,7 @@ class Hiiro
215
210
 
216
211
  if session && !skip_window_creation
217
212
  # Create a new tmux window for this service
218
- window_target = create_tmux_window(session, svc_name, base_dir || Dir.pwd)
213
+ window_target = create_tmux_window(session, svc_name, base_dir)
219
214
  pane_id = capture_pane_id(window_target)
220
215
  elsif session && skip_window_creation
221
216
  # Pane already created by start_group
@@ -228,10 +223,8 @@ class Hiiro
228
223
 
229
224
  if pane_id
230
225
  system('tmux', 'send-keys', '-t', pane_id, script, 'Enter')
231
- elsif base_dir
232
- system("cd #{base_dir} && #{script} &")
233
226
  else
234
- system("#{script} &")
227
+ system("cd #{base_dir} && #{script} &")
235
228
  end
236
229
 
237
230
  # Record state
@@ -817,5 +810,14 @@ class Hiiro
817
810
  def symbolize_keys(hash)
818
811
  hash.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
819
812
  end
813
+
814
+ def resolve_base_dir(base_dir)
815
+ return Dir.pwd if base_dir.nil? || base_dir.to_s.empty?
816
+
817
+ git_root = `git rev-parse --show-toplevel 2>/dev/null`.chomp
818
+ root = git_root.empty? ? Dir.pwd : git_root
819
+
820
+ File.join(root, base_dir)
821
+ end
820
822
  end
821
823
  end
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.155"
2
+ VERSION = "0.1.156"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiiro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.155
4
+ version: 0.1.156
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota