graphwerk 1.2.1 → 1.3.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: 14fe65bc2ddbecc3e621774f3ce56173f837ef84c8967e66238b4e1914f86134
4
- data.tar.gz: c5a2218164c40cce1fa5c9131e581754fdd7797b1ae3e96d024b25701f249c0a
3
+ metadata.gz: 4740933529aec75ed8570637a356ed28477b4490fe7276980dc26a58ae87c563
4
+ data.tar.gz: 2ccabcdeaaedd6fce1488658fb3642459db87ff72e8dcd6768c33032a684fa70
5
5
  SHA512:
6
- metadata.gz: 84160d2620769c3347b418a4a583b1b9226f564eb7d1cb4159e985ed4451fa98da6d020f353058fe0615a103d1860156215ffae6c9c9c185df0c7ce5a2185827
7
- data.tar.gz: 18a3046303f1c74d48bb87638ba43a978fdaa7189543154da95a4565d5b2ba80e389aa002e0b6610e3d0c4f7b90f4ab4b193b3bc1f2e427466fc9779db5f727f
6
+ metadata.gz: 46ca8349efe1370511c43b1375184646295dcaea7ff5b16d9ea24b5b165afa1aad20feb5c0055fa5179ce00f47299e1429799be8fcc08b4a1e5c40863819fa5a
7
+ data.tar.gz: bca7bc7aa9393eedd5122ce7c6e4e836eb06a458dbca2751a2b51d11cd63ea7540baecf3449369e0ae08bcbfa25a05075480328e33bca7736905216aea100e24
@@ -1,5 +1,7 @@
1
1
  ---
2
2
  name: Continuous Integration
3
+ env:
4
+ SLACK_CHANNEL_ID: C0317P7C9C2
3
5
  on:
4
6
  push:
5
7
  branches-ignore:
@@ -38,9 +40,9 @@ jobs:
38
40
  || github.ref == 'refs/heads/stable')
39
41
  uses: pullreminders/slack-action@a5a262c896a1cc80dcbae59ba95513e2dfb21439
40
42
  env:
41
- SLACK_BOT_TOKEN: "${{ secrets.SLACK_BOT_TOKEN }}"
43
+ SLACK_BOT_TOKEN: "${{ secrets.BELLROY_SLACK_TOKEN }}"
42
44
  with:
43
- args: '{\"channel\":\"C33574SJJ\",\"text\":\"* ${{ github.repository }} BUILD
45
+ args: '{\"channel\":\"{{ env.SLACK_CHANNEL_ID }}\",\"text\":\"* ${{ github.repository }} BUILD
44
46
  FAILURE*\", \"attachments\": [{ \"fallback\": \"Failure summary\", \"color\":
45
47
  \"#ff0000\", \"fields\": [{\"title\": \"Branch\", \"value\":\"${{ steps.extract_branch.outputs.branch
46
48
  }}\"}, {\"title\": \"Who broke it\", \"value\":\"${{ github.actor }}\"},
data/.gitignore CHANGED
@@ -13,7 +13,6 @@
13
13
  # rspec failure tracking
14
14
  .rspec_status
15
15
 
16
- /shell.nix
17
16
  /tags
18
17
 
19
18
  *.log
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 1.3.0
2
+
3
+ * Draw package_todo.yml dependencies
4
+ * Add configuration option to hide todo edges on the graph
5
+
1
6
  1.2.1
2
7
 
3
8
  * Add some nicer error messages when dependencies are not found
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ![graphwerk-logo](https://user-images.githubusercontent.com/2643026/95463568-cfaada80-0970-11eb-8305-aea01a0d77a9.png)
2
2
 
3
- # Graphwerk [![Gem Version](https://badge.fury.io/rb/graphwerk.svg)](https://badge.fury.io/rb/graphwerk) ![CI Badge](https://github.com/tricycle/graphwerk/workflows/RSpec%20Test%20Suite/badge.svg)
3
+ # Graphwerk [![Gem Version](https://badge.fury.io/rb/graphwerk.svg)](https://badge.fury.io/rb/graphwerk) [![Continuous Integration](https://github.com/bellroy/graphwerk/actions/workflows/ci.yml/badge.svg)](https://github.com/bellroy/graphwerk/actions/workflows/ci.yml)
4
4
 
5
5
  Graphwerk is a small Ruby gem that can generate a diagram of dependencies between packages within an application that's using Packwerk to enforce boundaries.
6
6
 
@@ -41,6 +41,7 @@ graph = Graphwerk::Builders::Graph.new(
41
41
  options: {
42
42
  layout: Graphwerk::Layout::Twopi,
43
43
  deprecated_references_color: 'yellow',
44
+ package_todo_color: 'yellow',
44
45
  graph: { overlap: true },
45
46
  node: { fillcolor: '#000000' },
46
47
  edges: { len: '3.0' }
@@ -10,6 +10,8 @@ module Graphwerk
10
10
  {
11
11
  layout: Graphwerk::Layout,
12
12
  deprecated_references_color: String,
13
+ package_todo_color: String,
14
+ hide_todo: T::Boolean,
13
15
  application: T::Hash[Symbol, Object],
14
16
  graph: T::Hash[Symbol, Object],
15
17
  node: T::Hash[Symbol, Object],
@@ -20,6 +22,8 @@ module Graphwerk
20
22
  DEFAULT_OPTIONS = T.let({
21
23
  layout: Graphwerk::Layout::Dot,
22
24
  deprecated_references_color: 'red',
25
+ package_todo_color: 'red',
26
+ hide_todo: false,
23
27
  application: {
24
28
  style: 'filled',
25
29
  fillcolor: '#333333',
@@ -90,7 +94,10 @@ module Graphwerk
90
94
  def add_package_dependencies_to_graph
91
95
  packages.each do |package|
92
96
  draw_dependencies(package)
97
+ next if @options[:hide_todo]
98
+
93
99
  draw_deprecated_references(package)
100
+ draw_package_todos(package)
94
101
  end
95
102
  end
96
103
 
@@ -122,6 +129,17 @@ module Graphwerk
122
129
  end
123
130
  end
124
131
 
132
+ sig { params(package: Presenters::Package).void }
133
+ def draw_package_todos(package)
134
+ package.package_todos.each do |todo|
135
+ @graph.add_edges(
136
+ @nodes[package.name],
137
+ @nodes[todo],
138
+ color: @options[:package_todo_color]
139
+ )
140
+ end
141
+ end
142
+
125
143
  sig { returns(T::Array[Presenters::Package]) }
126
144
  def packages
127
145
  @packages = T.let(@packages, T.nilable(T::Array[Presenters::Package]))
@@ -0,0 +1,31 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Graphwerk
5
+ class PackageTodoLoader
6
+ extend T::Sig
7
+
8
+ sig { params(package: Packwerk::Package, root_path: Pathname).void }
9
+ def initialize(package, root_path)
10
+ @package = package
11
+ @root_path = root_path
12
+ end
13
+
14
+ sig { returns(T::Array[String]) }
15
+ def load
16
+ return [] if !package_todo_file.exist?
17
+
18
+ (YAML.load_file(package_todo_file) || {}).keys
19
+ end
20
+
21
+ private
22
+
23
+ PACKAGE_TODO_FILENAME = 'package_todo.yml'
24
+
25
+ sig { returns(Pathname) }
26
+ def package_todo_file
27
+ @package_todo_file = T.let(@package_todo_file, T.nilable(Pathname))
28
+ @package_todo_file ||= @root_path.join(@package.name, PACKAGE_TODO_FILENAME)
29
+ end
30
+ end
31
+ end
@@ -29,6 +29,13 @@ module Graphwerk
29
29
  end
30
30
  end
31
31
 
32
+ sig { returns(T::Array[String]) }
33
+ def package_todos
34
+ PackageTodoLoader.new(@package, @root_path).load.map do |todo|
35
+ Name.new(todo).node_name
36
+ end
37
+ end
38
+
32
39
  ROOT_COLOR = 'black'
33
40
  COMPONENT_COLOR = 'azure4'
34
41
 
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Graphwerk
5
- VERSION = '1.2.1'
5
+ VERSION = '1.3.0'
6
6
  end
data/lib/graphwerk.rb CHANGED
@@ -9,6 +9,7 @@ require 'graphwerk/version'
9
9
  require 'graphwerk/constants'
10
10
  require 'graphwerk/layout'
11
11
  require 'graphwerk/deprecated_references_loader'
12
+ require 'graphwerk/package_todo_loader'
12
13
  require 'graphwerk/presenters/package'
13
14
  require 'graphwerk/builders/graph'
14
15
  require 'graphwerk/railtie' if defined?(Rails)
data/shell.nix ADDED
@@ -0,0 +1,20 @@
1
+ { sources ? import ./nix/sources.nix }:
2
+ let
3
+ nixpkgs = import sources.nixpkgs { };
4
+ in
5
+ nixpkgs.mkShell {
6
+ name = "bellroy-gem-env";
7
+ buildInputs = with nixpkgs; [
8
+ bundler
9
+ libnotify
10
+ niv
11
+ pkg-config
12
+ readline
13
+ ruby_2_7
14
+ zlib
15
+ ]
16
+ ++ (if stdenv.hostPlatform.isDarwin then [ libiconv darwin.apple_sdk.frameworks.CoreServices ] else [ ]);
17
+ shellHook = ''
18
+ bundle config --local path "$PWD/vendor/bundle"
19
+ '';
20
+ }
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphwerk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Giles
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 1980-01-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -164,7 +163,6 @@ dependencies:
164
163
  - - ">="
165
164
  - !ruby/object:Gem::Version
166
165
  version: '0'
167
- description:
168
166
  email:
169
167
  - samuel.giles@bellroy.com
170
168
  executables: []
@@ -172,7 +170,6 @@ extensions: []
172
170
  extra_rdoc_files: []
173
171
  files:
174
172
  - ".github/workflows/ci.yml"
175
- - ".github/workflows/rspec.yml"
176
173
  - ".gitignore"
177
174
  - ".rspec"
178
175
  - CHANGELOG.md
@@ -189,6 +186,7 @@ files:
189
186
  - lib/graphwerk/constants.rb
190
187
  - lib/graphwerk/deprecated_references_loader.rb
191
188
  - lib/graphwerk/layout.rb
189
+ - lib/graphwerk/package_todo_loader.rb
192
190
  - lib/graphwerk/presenters/package.rb
193
191
  - lib/graphwerk/railtie.rb
194
192
  - lib/graphwerk/tasks/rails.rake
@@ -196,11 +194,11 @@ files:
196
194
  - nix/sources.json
197
195
  - nix/sources.nix
198
196
  - run_ci.sh
197
+ - shell.nix
199
198
  homepage: https://github.com/tricycle/graphwerk
200
199
  licenses:
201
200
  - MIT
202
201
  metadata: {}
203
- post_install_message:
204
202
  rdoc_options: []
205
203
  require_paths:
206
204
  - lib
@@ -215,8 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
213
  - !ruby/object:Gem::Version
216
214
  version: '0'
217
215
  requirements: []
218
- rubygems_version: 3.2.16
219
- signing_key:
216
+ rubygems_version: 3.6.9
220
217
  specification_version: 4
221
218
  summary: Visualise dependencies between your application and it's Packwerk packages
222
219
  using Graphviz.
@@ -1,23 +0,0 @@
1
- name: RSpec Test Suite
2
-
3
- on: [push]
4
-
5
- jobs:
6
- build:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - name: Checkout branch
10
- uses: actions/checkout@v1
11
- - name: Set up Ruby
12
- uses: actions/setup-ruby@v1
13
- with:
14
- ruby-version: 2.6.6
15
- - name: Install latest bundler
16
- run: |
17
- command -v bundler || gem install bundler
18
- - name: Install gems
19
- run: bundle install --jobs $(nproc) --retry 3
20
- - name: Typecheck with Sorbet
21
- run: bundle exec srb tc . --ignore=/vendor
22
- - name: Run RSpec test suite
23
- run: bundle exec rspec spec