bibliothecary 12.1.10 → 12.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: dfc52a5290fe4f0518906698b7dc69cf16b2a7747a130796162d8b8c431b6d9b
4
- data.tar.gz: a68f8983ff54598396bf82d02a844ca867bd29a62044bede38ba13354d0a3386
3
+ metadata.gz: 2789d542e6457ea4e069d4dc2ff4237d8cccc9c8ea018d9418a943188e461316
4
+ data.tar.gz: 0f5ba9b30929a30690d7d68f41106b1bb36bc41e5703243279de828ee5d0987e
5
5
  SHA512:
6
- metadata.gz: '08a5bd08b3864366e22eb1baf58b1a35bd819997fc59a51adf412b6e5090b3d7534f045f8793ac79315be49aa151bb1d18b5dba33d53b0a9c5cbe72c7909c190'
7
- data.tar.gz: c0574ce28cb9bcb5b3e03bab3e69859eb0e679fb809a0750d5bf7c3ba3efcf2585f61c65dbebf0c2d94edf3cd9b86b14bfea153c242a91a4b057443887c965c2
6
+ metadata.gz: d889c20a78d617d51f10206e826a7bfcc17ba7723e78c867708fc28e7c8e4592c9c8633187eadb151f9418896cc29705bc2f361d2d26ba71450af0480f4b85b2
7
+ data.tar.gz: 1b327cb0a9c53b6b711600defd2f6c43bb7740beaa7f381b7e67dcecc17da9effbedc85511685e69f08be4140b35887886a0d01a52f60f8731c5265fe96dd4f4
data/CHANGELOG.md CHANGED
@@ -13,10 +13,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
13
 
14
14
  ### Removed
15
15
 
16
- ## [12.1.10] - 2025-05-23
16
+ ## [12.3.0] - 2025-06-06
17
+
18
+ ### Added
19
+
20
+ - Nuget support for <Reference> tag in \*.csproj manifests.
21
+
22
+ ## [12.2.0] - 2025-05-30
17
23
 
18
24
  ### Added
19
25
 
26
+ - Maven parser support for maven-dependency-tree.dot file.
27
+
28
+ ## [12.1.10] - 2025-05-23
29
+
20
30
  ### Changed
21
31
 
22
32
  - Normalize package names in Poetry manifests, storing the original in
@@ -24,50 +34,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
24
34
  names in its lockfile according to PyPa's rules, but doesn't provide the original name.
25
35
  Storing the original_name will provide a connection from manifest to lockfile.
26
36
 
27
- ### Removed
28
-
29
37
  ## [12.1.9] - 2025-05-16
30
38
 
31
- ### Added
32
-
33
39
  ### Changed
34
40
 
35
41
  - Fix 12.1.8 Poetry regression that ignored deps with no category or group.
36
42
 
37
- ### Removed
38
-
39
43
  ## [12.1.8] - 2025-05-16
40
44
 
41
45
  ### Added
42
46
 
43
47
  - Support multiple requirements for a single package in poetry.lock.
44
48
 
45
- ### Changed
46
-
47
- ### Removed
48
-
49
49
  ## [12.1.7] - 2025-04-29
50
50
 
51
- ### Added
52
-
53
51
  ### Changed
54
52
 
55
53
  - Include "source" field in Dependency objects from pub files.
56
54
  - Include "source" field in Dependency objects from pnpm-lock.yaml files.
57
55
 
58
- ### Removed
59
-
60
56
  ## [12.1.6] - 2025-04-29
61
57
 
62
- ### Added
63
-
64
58
  ### Changed
65
59
 
66
60
  - Use JSON.parser.parse() in bun.lock parser to work around overriden JSON.parse() method.
67
61
  - Don't raise an error in pnpm-lock.yaml v9 parser if devDependencies isn't found.
68
62
 
69
- ### Removed
70
-
71
63
  ## [12.1.5] - 2025-03-17
72
64
 
73
65
  ### Added
@@ -75,10 +67,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
75
67
  - Adds alias support for PNPM lockfiles.
76
68
  - Add support for bun.lock files
77
69
 
78
- ### Changed
79
-
80
- ### Removed
81
-
82
70
  ## [12.1.4] - 2025-03-14
83
71
 
84
72
  ### Added
@@ -86,10 +74,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
86
74
  - Add support for PNPM lockfiles (lockfile versions 5, 6, and 9).
87
75
  - Add 'parser_options' arg to Bilbiothecary::Runner constructor.
88
76
 
89
- ### Changed
90
-
91
- ### Removed
92
-
93
77
  ## [12.1.3] - 2025-02-26
94
78
 
95
79
  ### Added
@@ -102,28 +86,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
102
86
  - Fix a PyPI parser's regex to exclude false positive "require" names.
103
87
  - Drop all sub-projects from list of deps in a Maven maven-dependency-tree.txt.
104
88
 
105
- ### Removed
106
-
107
89
  ## [12.1.2] - 2025-02-26
108
90
 
109
91
  ### Added
110
92
 
111
93
  - Add 'local' property to dependencies from Pipfile and Pipfile.lock
112
94
 
113
- ### Changed
114
-
115
- ### Removed
116
-
117
95
  ## [12.1.1] - 2025-02-21
118
96
 
119
97
  ### Added
120
98
 
121
99
  - Add test coverage for Go 1.24's new "tool" directive.
122
100
 
123
- ### Changed
124
-
125
- ### Removed
126
-
127
101
  ## [12.1.0] - 2025-01-30
128
102
 
129
103
  ### Added
@@ -135,8 +109,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
135
109
 
136
110
  - Improved Rubocop rules to make future spec changes easier via Rubocop auto-correcting formatting violations.
137
111
 
138
- ### Removed
139
-
140
112
  ## [12.0.0] - 2025-01-27
141
113
 
142
114
  ### Removed
@@ -11,6 +11,10 @@ module Bibliothecary
11
11
  class Maven
12
12
  include Bibliothecary::Analyser
13
13
 
14
+ # Matches digraph contents from the Maven dependency tree .dot file format.
15
+ MAVEN_DOT_PROJECT_REGEXP = /digraph\s+"([^\"]+)"\s+{/
16
+ MAVEN_DOT_RELATIONSHIP_REGEXP = /"([^\"]+)"\s+->\s+"([^\"]+)"/
17
+
14
18
  # e.g. "annotationProcessor - Annotation processors and their dependencies for source set 'main'."
15
19
  GRADLE_TYPE_REGEXP = /^(\w+)/
16
20
 
@@ -113,10 +117,19 @@ module Bibliothecary
113
117
  kind: "lockfile",
114
118
  parser: :parse_sbt_update_full,
115
119
  },
120
+ # maven-dependency-tree.txt is the output of `mvn dependency:tree` as a single command.
121
+ # The tree lines contain "[INFO]" prefix and uses 2-space indentation.
116
122
  match_filename("maven-dependency-tree.txt", case_insensitive: true) => {
117
123
  kind: "lockfile",
118
124
  parser: :parse_maven_tree,
119
125
  },
126
+ # maven-dependency-tree.dot is the output of this command:
127
+ # `mvn dependency:tree -DoutputType=dot -DoutputFile=maven-dependency-tree.dot`
128
+ # It doesn't have the "[INFO]" prefix, and is in graphviz .dot format.
129
+ match_filename("maven-dependency-tree.dot", case_insensitive: true) => {
130
+ kind: "lockfile",
131
+ parser: :parse_maven_tree_dot,
132
+ },
120
133
  }
121
134
  end
122
135
 
@@ -303,23 +316,24 @@ module Bibliothecary
303
316
 
304
317
  raise "found no lines with deps in maven-dependency-tree.txt" if items.empty?
305
318
 
306
- projects = {}
319
+ projects_to_exclude = {}
307
320
 
308
321
  if keep_subprojects
309
322
  # traditional behavior: we only exclude the root project, and only if we parsed multiple lines
310
323
  (root_name, root_version, _root_type) = parse_maven_tree_dependency(items.shift[1])
311
324
  unless items.empty?
312
- projects[root_name] = Set.new
313
- projects[root_name].add(root_version)
325
+ projects_to_exclude[root_name] = Set.new
326
+ projects_to_exclude[root_name].add(root_version)
314
327
  end
315
328
  end
316
329
 
317
330
  unique_items = items.map do |(depth, item)|
331
+ # new behavior: we exclude root and subprojects (depth 0 items)
318
332
  (name, version, type) = parse_maven_tree_dependency(item)
319
333
  if depth == 0 && !keep_subprojects
320
334
  # record and then remove the depth 0
321
- projects[name] ||= Set.new
322
- projects[name].add(version)
335
+ projects_to_exclude[name] ||= Set.new
336
+ projects_to_exclude[name].add(version)
323
337
  nil
324
338
  else
325
339
  [name, version, type]
@@ -328,7 +342,7 @@ module Bibliothecary
328
342
 
329
343
  unique_items
330
344
  # drop the projects and subprojects
331
- .reject { |(name, version, _type)| projects[name]&.include?(version) }
345
+ .reject { |(name, version, _type)| projects_to_exclude[name]&.include?(version) }
332
346
  .map do |(name, version, type)|
333
347
  Bibliothecary::Dependency.new(
334
348
  name: name,
@@ -339,6 +353,32 @@ module Bibliothecary
339
353
  end
340
354
  end
341
355
 
356
+ def self.parse_maven_tree_dot(file_contents, options: {})
357
+ # Project could be either the root project or a sub-module.
358
+ project = file_contents.match(MAVEN_DOT_PROJECT_REGEXP)[1]
359
+ relationships = file_contents.scan(MAVEN_DOT_RELATIONSHIP_REGEXP)
360
+
361
+ direct_names_to_versions = relationships.each.with_object({}) do |(parent, child), obj|
362
+ next unless parent == project
363
+
364
+ name, version, _type = parse_maven_tree_dependency(child)
365
+ obj[name] ||= Set.new
366
+ obj[name].add(version)
367
+ end
368
+
369
+ relationships.map do |(_parent, child)|
370
+ child_name, child_version, child_type = parse_maven_tree_dependency(child)
371
+
372
+ Dependency.new(
373
+ name: child_name,
374
+ requirement: child_version,
375
+ type: child_type,
376
+ direct: direct_names_to_versions[child_name]&.include?(child_version) || false,
377
+ source: options.fetch(:filename, nil)
378
+ )
379
+ end.uniq
380
+ end
381
+
342
382
  def self.parse_resolved_dep_line(line, options: {})
343
383
  # filter out anything that doesn't look like a
344
384
  # resolved dep line
@@ -109,26 +109,45 @@ module Bibliothecary
109
109
 
110
110
  def self.parse_csproj(file_contents, options: {})
111
111
  manifest = Ox.parse file_contents
112
+ packages = manifest
113
+ .locate("ItemGroup/PackageReference")
114
+ .select { |dep| dep.respond_to? "Include" }
115
+ .map do |dependency|
116
+ requirement = (dependency.Version if dependency.respond_to? "Version")
117
+ if requirement.is_a?(Ox::Element)
118
+ requirement = dependency.nodes.detect { |n| n.value == "Version" }&.text
119
+ end
112
120
 
113
- packages = manifest.locate("ItemGroup/PackageReference").select { |dep| dep.respond_to? "Include" }.map do |dependency|
114
- requirement = (dependency.Version if dependency.respond_to? "Version")
115
- if requirement.is_a?(Ox::Element)
116
- requirement = dependency.nodes.detect { |n| n.value == "Version" }&.text
121
+ type = if (dependency.nodes.first&.nodes&.include?("all") && dependency.nodes.first.value.include?("PrivateAssets")) || dependency.attributes[:PrivateAssets] == "All"
122
+ "development"
123
+ else
124
+ "runtime"
125
+ end
126
+
127
+ Dependency.new(
128
+ name: dependency.Include,
129
+ requirement: requirement,
130
+ type: type,
131
+ source: options.fetch(:filename, nil)
132
+ )
117
133
  end
118
134
 
119
- type = if (dependency.nodes.first&.nodes&.include?("all") && dependency.nodes.first.value.include?("PrivateAssets")) || dependency.attributes[:PrivateAssets] == "All"
120
- "development"
121
- else
122
- "runtime"
123
- end
135
+ packages += manifest
136
+ .locate("ItemGroup/Reference")
137
+ .select { |dep| dep.respond_to? "Include" }
138
+ .map do |dependency|
139
+ vals = *dependency.Include.split(",").map(&:strip)
140
+ name = vals.shift
141
+ vals = vals.to_h { |r| r.split("=", 2) }
142
+
143
+ Dependency.new(
144
+ name: name,
145
+ requirement: vals["Version"] || "*",
146
+ type: "runtime",
147
+ source: options.fetch(:filename, nil)
148
+ )
149
+ end
124
150
 
125
- Dependency.new(
126
- name: dependency.Include,
127
- requirement: requirement,
128
- type: type,
129
- source: options.fetch(:filename, nil)
130
- )
131
- end
132
151
  packages.uniq(&:name)
133
152
  rescue StandardError
134
153
  []
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bibliothecary
4
- VERSION = "12.1.10"
4
+ VERSION = "12.3.0"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibliothecary
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.1.10
4
+ version: 12.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-23 00:00:00.000000000 Z
10
+ date: 2025-06-06 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: commander