teapot 3.6.1 → 3.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 742147841aebb1df987a75d2ffefcb764d9d42f6faf5492bdd273c62a8e195ce
4
- data.tar.gz: 11c7a76cfe57be54d9a5864b2e0d7eb821ab780c4128df78ca09e555599c7dca
3
+ metadata.gz: 6fb45edfbd49bfea6e78038ec74bd4473be5a2f716edd0391907acf66d5a740c
4
+ data.tar.gz: 61012b133dc05dbd9fd5e240964313f387592361e08394c2602c024606f65d48
5
5
  SHA512:
6
- metadata.gz: '001587e6eca1be37e6697b2b603208afe8d5685b14a8364603325d9aa24af9c2af3a12effec6bf0f9513731cffd05d7ec76125333d3fa3fd9a76e9cf66467749'
7
- data.tar.gz: 503bd6ed1aba820ce830b5e856468b9d990b179e2f2da32c7d1985a314f1e6ff48a54d8a0883a1352b7dd30380e51c951e2fdbf234d716926033700208f88b3a
6
+ metadata.gz: d1dfddcdc2485c1911367892d4be722a74c2aa2a5f2cc0943ad9b914896ec648b1276d8582cf4225f2ff864c8f8c7a5a9f1fff134c10bb1407abaae7c8ee933c
7
+ data.tar.gz: 39c8e42658208e0499fd22b0951e75218725622bcf83690b3290f230f1e5e7c710a6f0db1776036bd2b51b4108fc3ee9eef9b1ac8e65566385ba1677449204dd
checksums.yaml.gz.sig CHANGED
Binary file
@@ -20,6 +20,7 @@ module Teapot
20
20
  options do
21
21
  option "-j/-l/--limit <n>", "Limit the build to <n> concurrent processes.", type: Integer
22
22
  option "-c/--continuous", "Run the build graph continually (experimental)."
23
+ option "--show-dependencies", "Show task dependencies for debugging."
23
24
  end
24
25
 
25
26
  many :targets, "Build these targets, or use them to help the dependency resolution process."
@@ -40,8 +41,8 @@ module Teapot
40
41
  chain = selection.chain
41
42
  environment = context.configuration.environment
42
43
 
43
- controller = ::Build::Controller.new(limit: @options[:limit]) do |controller|
44
- controller.add_chain(chain, self.argv, environment)
44
+ controller = ::Build::Controller.build(limit: @options[:limit]) do |builder|
45
+ builder.add_chain(chain, self.argv, environment)
45
46
  end
46
47
 
47
48
  walker = nil
@@ -49,7 +50,7 @@ module Teapot
49
50
  # We need to catch interrupt here, and exit with the correct exit code:
50
51
  begin
51
52
  controller.run do |walker|
52
- # show_dependencies(walker)
53
+ show_dependencies(walker) if @options[:show_dependencies]
53
54
 
54
55
  # Only run once is asked:
55
56
  unless @options[:continuous]
@@ -3,56 +3,174 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2017-2026, by Samuel Williams.
5
5
 
6
+ require "samovar"
6
7
  require_relative "selection"
7
- require "graphviz"
8
+ require "build/controller"
8
9
 
9
10
  module Teapot
10
11
  module Command
11
- # A command to visualize the dependency graph.
12
- class Visualize < Selection
13
- self.description = "Generate a picture of the dependency graph."
12
+ # A command to visualize dependency graphs.
13
+ class Visualize < Samovar::Command
14
+ self.description = "Generate visualizations of package and target dependencies."
14
15
 
15
- options do
16
- option "-o/--output-path <path>", "The output path for the visualization.", default: "dependency.svg"
17
- option "-d/--dependency-name <name>", "Show the partial chain for the given named dependency."
18
- end
19
-
20
- # Get the dependency names to visualize.
21
- # @returns [Array(String)] The dependency names.
22
- def dependency_names
23
- @targets || []
24
- end
25
-
26
- # Get the specific dependency name to visualize.
27
- # @returns [String | Nil] The dependency name.
28
- def dependency_name
29
- @options[:dependency_name]
16
+ # Visualize package-level dependencies.
17
+ class Packages < Selection
18
+ self.description = "Visualize package-level dependencies from configuration.require."
19
+
20
+ options do
21
+ option "-o/--output-path <path>", "The output path for the visualization."
22
+ option "-d/--dependency-name <name>", "Show the partial chain for the given named dependency."
23
+ end
24
+
25
+ # Get the specific dependency name to visualize.
26
+ # @returns [String | Nil] The dependency name.
27
+ def dependency_name
28
+ @options[:dependency_name]
29
+ end
30
+
31
+ # Process and generate the package dependency visualization.
32
+ # @parameter selection [Select] The selection to visualize.
33
+ # @returns [String] The generated Mermaid diagram.
34
+ def process(selection)
35
+ chain = selection.chain
36
+
37
+ if dependency_name
38
+ provider = selection.dependencies[dependency_name]
39
+ chain = chain.partial(provider)
40
+ end
41
+
42
+ visualization = ::Build::Dependency::Visualization.new
43
+ diagram = visualization.generate(chain)
44
+
45
+ if output_path = @options[:output_path]
46
+ File.write(output_path, diagram)
47
+ else
48
+ $stdout.puts diagram
49
+ end
50
+
51
+ return diagram
52
+ end
30
53
  end
31
54
 
32
- # Process and generate the visualization.
33
- # @parameter selection [Select] The selection to visualize.
34
- # @returns [Graphviz::Graph] The generated graph.
35
- def process(selection)
36
- context = selection.context
37
- chain = selection.chain
55
+ # Visualize target-level dependencies.
56
+ class Targets < Selection
57
+ self.description = "Visualize target-level dependencies from target.depends."
38
58
 
39
- if dependency_name
40
- provider = selection.dependencies[dependency_name]
59
+ options do
60
+ option "-o/--output-path <path>", "The output path for the visualization."
61
+ end
62
+
63
+ # Process and generate the target dependency visualization.
64
+ # @parameter selection [Select] The selection to visualize.
65
+ # @returns [String] The generated Mermaid diagram.
66
+ def process(selection)
67
+ lines = ["flowchart LR"]
68
+ lines << ""
69
+
70
+ # Build the graph from all targets in the selection
71
+ # The selection contains all targets loaded from packages
72
+ selection.targets.each do |name, target|
73
+ target.dependencies.each do |dependency|
74
+ dependency_name = dependency.name.to_s
75
+
76
+ # Create edge from target to its dependency
77
+ if dependency.private?
78
+ lines << " #{sanitize_id(name)}[#{name}] -.-> #{sanitize_id(dependency_name)}[#{dependency_name}]"
79
+ else
80
+ lines << " #{sanitize_id(name)}[#{name}] --> #{sanitize_id(dependency_name)}[#{dependency_name}]"
81
+ end
82
+ end
83
+ end
84
+
85
+ diagram = lines.join("\n")
41
86
 
42
- chain = chain.partial(provider)
87
+ if output_path = @options[:output_path]
88
+ File.write(output_path, diagram)
89
+ else
90
+ $stdout.puts diagram
91
+ end
92
+
93
+ return diagram
43
94
  end
44
95
 
45
- visualization = ::Build::Dependency::Visualization.new
96
+ private
46
97
 
47
- graph = visualization.generate(chain)
98
+ # Convert a name to a valid Mermaid node ID.
99
+ # @parameter name [String] The name to sanitize.
100
+ # @returns [String] A sanitized identifier safe for use in Mermaid diagrams.
101
+ def sanitize_id(name)
102
+ name.to_s.gsub(/[^a-zA-Z0-9_]/, "_")
103
+ end
104
+ end
105
+
106
+ # Visualize file-level dependencies from the build graph.
107
+ class Files < Selection
108
+ self.description = "Visualize file-level dependencies by walking the build graph."
48
109
 
49
- if output_path = @options[:output_path]
50
- Graphviz.output(graph, path: output_path, format: :svg)
51
- else
52
- $stdout.puts graph.to_dot
110
+ options do
111
+ option "-o/--output-path <path>", "The output path for the visualization."
53
112
  end
54
113
 
55
- return graph
114
+ # Process and generate the file dependency visualization.
115
+ # @parameter selection [Select] The selection to visualize.
116
+ # @returns [String] The generated Mermaid diagram.
117
+ def process(selection)
118
+ require "build/graph/walker"
119
+ require "build/graph/visualization"
120
+
121
+ context = selection.context
122
+ chain = selection.chain
123
+ environment = context.configuration.environment
124
+
125
+ # Build the controller to get the root nodes
126
+ controller = ::Build::Controller.build(limit: 1) do |builder|
127
+ builder.add_chain(chain, [], environment)
128
+ end
129
+
130
+ # Create a process group for task execution
131
+ group = ::Process::Group.new
132
+
133
+ # Create a walker that traverses without building
134
+ walker = ::Build::Graph::Walker.new do |walker, node, parent_task = nil|
135
+ task_class = node.task_class(parent_task) || ::Build::Graph::Task
136
+ task = task_class.new(walker, node, group)
137
+
138
+ # Use traverse instead of visit to skip building:
139
+ task.traverse
140
+ end
141
+
142
+ # Populate the walker by traversing from the root nodes
143
+ walker.update(controller.nodes)
144
+
145
+ # Generate the Mermaid diagram
146
+ visualization = ::Build::Graph::Visualization.new
147
+ diagram = visualization.generate(walker)
148
+
149
+ if output_path = @options[:output_path]
150
+ File.write(output_path, diagram)
151
+ else
152
+ $stdout.puts diagram
153
+ end
154
+
155
+ return diagram
156
+ end
157
+ end
158
+
159
+ nested :command, {
160
+ "packages" => Packages,
161
+ "targets" => Targets,
162
+ "files" => Files,
163
+ }, default: "packages"
164
+
165
+ # Delegate context to parent Top command.
166
+ # @returns [Context] The project context.
167
+ def context
168
+ parent.context
169
+ end
170
+
171
+ # Execute the visualize command.
172
+ def call
173
+ @command.call
56
174
  end
57
175
  end
58
176
  end
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module Teapot
8
- VERSION = "3.6.1"
8
+ VERSION = "3.7.0"
9
9
  end
data/readme.md CHANGED
@@ -25,6 +25,10 @@ Please see the [project documentation](https://ioquatix.github.io/teapot/) for m
25
25
 
26
26
  Please see the [project releases](https://ioquatix.github.io/teapot/releases/index) for all releases.
27
27
 
28
+ ### v3.7.0
29
+
30
+ - `teapot visualize` has two new sub-commands: `packages` and `targets`. The former visualizes the dependency graph of packages, while the latter visualizes the dependency graph of targets. Both sub-commands output Mermaid diagrams, which can be rendered using Mermaid Live Editor or other Mermaid-compatible tools.
31
+
28
32
  ### v3.6.0
29
33
 
30
34
  - Update dependencies.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v3.7.0
4
+
5
+ - `teapot visualize` has two new sub-commands: `packages` and `targets`. The former visualizes the dependency graph of packages, while the latter visualizes the dependency graph of targets. Both sub-commands output Mermaid diagrams, which can be rendered using Mermaid Live Editor or other Mermaid-compatible tools.
6
+
3
7
  ## v3.6.0
4
8
 
5
9
  - Update dependencies.
data.tar.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- ��L7�D��%jl$�Ω��"ϊYҟ��Wn~Vo�:�����9rvE&i���.�Ue�\���D �
2
- ��%?�7�9Eѷx �33�� (\��K~y�!��`I6����E��\$���|f���XO��Exq���곊(�9�!��i;R�N�*��…��.)c�+:�R�s�f�/#��)���1�V[�R�t����^�\
1
+ CVfm��{˽�����b���Zq*3b!�s_ߗ���_
2
+ ]>���A�M��` a楿�S}:$�_�a*'=����+yO3$|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teapot
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.1
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.4'
47
+ version: '2.9'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.4'
54
+ version: '2.9'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: build-dependency
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.4'
61
+ version: '1.6'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.4'
68
+ version: '1.6'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: build-environment
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: build-graph
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.3'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.3'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: build-text
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -258,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
272
  - !ruby/object:Gem::Version
259
273
  version: '0'
260
274
  requirements: []
261
- rubygems_version: 4.0.6
275
+ rubygems_version: 4.0.3
262
276
  specification_version: 4
263
277
  summary: Teapot is a tool for managing cross-platform builds.
264
278
  test_files: []
metadata.gz.sig CHANGED
Binary file