hiiro 0.1.213 → 0.1.214

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: '0057308e049772c9676b39678d2ca0bc970c4bfb63fde93bb8c3ad92545537f9'
4
- data.tar.gz: 66bd247b6c02dafa378d2a081bd553b1b0d6b212f7737ee06cc71c568c334790
3
+ metadata.gz: 9de74ec0cfb202ffe27c661ee10cc51604adad8811263c88da91c4d34345cafc
4
+ data.tar.gz: 599316268a674b407da7bc2f9782a0f7157c26d08cf321a3fee449e984c7e4c7
5
5
  SHA512:
6
- metadata.gz: 8b2adcb6d32b80c3486e0018dffa7704c4440753dcd6cb8394ed8392612446d24c548c527b136c58daeaafe06a1aad520e47922904fac8b65e5f8399e8c7ec20
7
- data.tar.gz: cb8334fdb4f7951bfadae24ec5027a6219e6b1b27e3450fb887ab667344d8aeddec9e71eba566c8549a3098bc8787372e368760129cb9b9c4332d7ddb478e4e5
6
+ metadata.gz: a41c63d2b2f684c2a2cda55764b01010f15bad2b6eb642d529db3976f878c3748f0ffead82001d96dc42a9c4a4cd27026a0b9772b267de42a6b380fb7c047537
7
+ data.tar.gz: '019205a1b4fbffe74aff57973baa2ffbc76b7f43a0c8dc27f35fea280714b1b99d3df8113af61eb1bc3723af9517099853ce37ea4d1516b3aeb4cb412ae8052f'
@@ -0,0 +1,97 @@
1
+ # Example sparse_groups.yml
2
+ # Place at ~/.config/hiiro/sparse_groups.yml
3
+ #
4
+ # Sparse checkout groups let you limit which directories are checked out in a
5
+ # worktree. This keeps worktrees small and fast when you only need a subset of
6
+ # a large monorepo.
7
+ #
8
+ # Each key is a group name. Each value is a list of directory paths (relative
9
+ # to the repo root) that will be included in the sparse checkout.
10
+ #
11
+ # Usage with h task start:
12
+ # h task start my-task --sparse ruby
13
+ # h task start my-task --sparse ruby --sparse frontend
14
+ # h task start my-task -s ruby -s shared
15
+
16
+ # =============================================================================
17
+ # Single-service groups - check out only what one service needs
18
+ # =============================================================================
19
+
20
+ ruby:
21
+ - apps/api
22
+ - lib
23
+ - config
24
+ - db
25
+
26
+ frontend:
27
+ - apps/web
28
+ - apps/mobile
29
+ - packages/design-system
30
+ - packages/shared-types
31
+
32
+ graphql:
33
+ - services/graphql
34
+ - packages/shared-types
35
+
36
+ workers:
37
+ - apps/api
38
+ - workers
39
+ - lib
40
+ - config
41
+
42
+ # =============================================================================
43
+ # Shared/common groups - infrastructure or tooling used by multiple services
44
+ # =============================================================================
45
+
46
+ shared:
47
+ - lib
48
+ - config
49
+ - scripts
50
+ - .github
51
+
52
+ infra:
53
+ - terraform
54
+ - k8s
55
+ - scripts/deploy
56
+
57
+ # =============================================================================
58
+ # Compound groups - combine multiple service directories into one group.
59
+ # Use with a single --sparse flag when you know you'll touch both sides.
60
+ # =============================================================================
61
+
62
+ # Full-stack: Ruby API + GraphQL + Web frontend (no mobile, no workers)
63
+ fullstack:
64
+ - apps/api
65
+ - services/graphql
66
+ - apps/web
67
+ - packages/design-system
68
+ - packages/shared-types
69
+ - lib
70
+ - config
71
+ - db
72
+
73
+ # Backend only: API + workers + shared lib
74
+ backend:
75
+ - apps/api
76
+ - workers
77
+ - lib
78
+ - config
79
+ - db
80
+
81
+ # =============================================================================
82
+ # QUICK REFERENCE
83
+ # =============================================================================
84
+ #
85
+ # Create a new task with a sparse checkout:
86
+ # h task start my-feature --sparse ruby
87
+ # h task start my-feature -s ruby -s shared
88
+ # h task start my-feature --sparse fullstack
89
+ #
90
+ # --sparse can be repeated to combine multiple groups:
91
+ # h task start my-feature --sparse ruby --sparse infra
92
+ # -> checks out: apps/api + lib + config + db + terraform + k8s + scripts/deploy
93
+ #
94
+ # Without --sparse, a full checkout is performed (default git behavior).
95
+ #
96
+ # Directories listed in a group are passed directly to git sparse-checkout.
97
+ # All listed paths are relative to the repo root.
data/lib/hiiro/git.rb CHANGED
@@ -143,6 +143,15 @@ class Hiiro
143
143
  run_system('worktree', 'repair')
144
144
  end
145
145
 
146
+ def sparse_checkout(path, dirs, cone: true)
147
+ if cone
148
+ run_system('-C', path, 'sparse-checkout', 'init', '--cone')
149
+ else
150
+ run_system('-C', path, 'sparse-checkout', 'init')
151
+ end
152
+ run_system('-C', path, 'sparse-checkout', 'set', *dirs)
153
+ end
154
+
146
155
  # Remote convenience methods
147
156
 
148
157
  def remotes
data/lib/hiiro/tasks.rb CHANGED
@@ -75,7 +75,7 @@ class Hiiro
75
75
 
76
76
  # --- Actions ---
77
77
 
78
- def start_task(name, app_name: nil)
78
+ def start_task(name, app_name: nil, sparse_groups: [])
79
79
  existing = task_by_name(name)
80
80
  if existing
81
81
  puts "Task '#{existing.name}' already exists. Switching..."
@@ -106,6 +106,8 @@ class Hiiro
106
106
  end
107
107
  end
108
108
 
109
+ apply_sparse_checkout(target_path, sparse_groups) if sparse_groups.any?
110
+
109
111
  session_name = task_name
110
112
  task = Task.new(name: task_name, tree: subtree_name, session: session_name)
111
113
  config.save_task(task)
@@ -508,6 +510,16 @@ class Hiiro
508
510
  end
509
511
  end
510
512
 
513
+ def apply_sparse_checkout(path, group_names)
514
+ dirs = SparseGroups.dirs_for_groups(group_names)
515
+ if dirs.empty?
516
+ puts "WARNING: No directories found for sparse groups: #{group_names.join(', ')}"
517
+ return
518
+ end
519
+ puts "Applying sparse checkout (groups: #{group_names.join(', ')})..."
520
+ Hiiro::Git.new(nil, path).sparse_checkout(path, dirs)
521
+ end
522
+
511
523
  def send_cd(path)
512
524
  pane = ENV['TMUX_PANE']
513
525
  if pane
@@ -607,14 +619,33 @@ class Hiiro
607
619
  end
608
620
  end
609
621
 
622
+ class SparseGroups
623
+ FILE = File.join(Dir.home, '.config', 'hiiro', 'sparse_groups.yml')
624
+
625
+ def self.load(file: FILE)
626
+ return {} unless File.exist?(file)
627
+ YAML.safe_load_file(file) || {}
628
+ end
629
+
630
+ def self.dirs_for_groups(group_names, file: FILE)
631
+ groups = load(file: file)
632
+ group_names.flat_map { |name| Array(groups[name]) }.uniq
633
+ end
634
+ end
635
+
610
636
  module Tasks
611
637
  def self.build_hiiro(parent_hiiro, tm)
612
638
  task_hiiro = parent_hiiro.make_child do |h|
613
639
  h.add_subcmd(:list) { tm.list }
614
640
  h.add_subcmd(:ls) { tm.list }
615
641
 
616
- h.add_subcmd(:start) do |task_name, app_name=nil|
617
- tm.start_task(task_name, app_name: app_name)
642
+ h.add_subcmd(:start) do |*raw_args|
643
+ opts = Hiiro::Options.parse(raw_args) do
644
+ option(:sparse, short: :s, desc: 'Sparse checkout group (may be repeated)', multi: true)
645
+ end
646
+ task_name = opts.args[0]
647
+ app_name = opts.args[1]
648
+ tm.start_task(task_name, app_name: app_name, sparse_groups: opts.sparse)
618
649
  end
619
650
 
620
651
  h.add_subcmd(:switch) do |task_name=nil, app_name=nil|
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.213"
2
+ VERSION = "0.1.214"
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.213
4
+ version: 0.1.214
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota
@@ -129,6 +129,7 @@ files:
129
129
  - editboth
130
130
  - examples/services.sleepers.yml
131
131
  - examples/services.yml
132
+ - examples/sparse_groups.yml
132
133
  - exe/h
133
134
  - exe/hiiro
134
135
  - h-tmux-plugins.tmux