bibliothecary 7.0.2 → 7.1.3

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: 1c44d6a07f7c3cdd1e6517420b6fe59f0b453201f0f4deb7e3870f206ace5a04
4
- data.tar.gz: 07ddf505184913265f608eea5b0ad8f9293b69a47bbe353606651d510b8d6158
3
+ metadata.gz: 363f07f35de59f9e70b69e78e25c47a16eaaeb88399db593af9fa8907f9057b4
4
+ data.tar.gz: e960f21a1d5df9dbe686efce3dd0968e08b60f24b20767fc861a344704e9f3f9
5
5
  SHA512:
6
- metadata.gz: 2c8693bace5bb30e27ae2cd72c130a68f8c2e8cdbb0f487b5bef59374a7ac6ad103bc10a2214f3ce2409a5c73dd861136f3e7c4b751d1a17b9ff13bb400a4ba7
7
- data.tar.gz: 6d92229299dd6c3997ab9ff2addde302baf95383660a7849afaa519bc94b519196c7a11aae08bc23c24daaf96bb689c1431f9ab07efe1e0cbcce7f4e0d91e6a5
6
+ metadata.gz: c4758b79d123881d8ead04bc325f2121388e216edffebfceadd2dae1183d8cb04999b205055d29a3b509ffee640e534dce9701a71fb97812d573a3bee0357297
7
+ data.tar.gz: 753f4495fb06a20dd2e77a41520c9db05b44442f94b261df5c2871454110636ca58efb22ccfecfb1922da8f5510e0edd6e3d5ec9384cf48494325c7489c90757
@@ -24,14 +24,20 @@ module Bibliothecary
24
24
  {
25
25
  name: dependency["name"],
26
26
  requirement: dependency["version"],
27
- type: 'runtime'
28
- }
27
+ type: "runtime"
28
+ }.tap do |result|
29
+ # Store Drupal version if Drupal, but include the original manifest version for reference
30
+ result[:original_requirement], result[:requirement] = result[:requirement], dependency.dig("source", "reference") if is_drupal_module(dependency)
31
+ end
29
32
  end + manifest.fetch('packages-dev',[]).map do |dependency|
30
33
  {
31
34
  name: dependency["name"],
32
35
  requirement: dependency["version"],
33
- type: 'development'
34
- }
36
+ type: "development"
37
+ }.tap do |result|
38
+ # Store Drupal version if Drupal, but include the original manifest version for reference
39
+ result[:original_requirement], result[:requirement] = result[:requirement], dependency.dig("source", "reference") if is_drupal_module(dependency)
40
+ end
35
41
  end
36
42
  end
37
43
 
@@ -40,6 +46,18 @@ module Bibliothecary
40
46
  map_dependencies(manifest, 'require', 'runtime') +
41
47
  map_dependencies(manifest, 'require-dev', 'development')
42
48
  end
49
+
50
+ # Drupal hosts its own Composer repository, where its "modules" are indexed and searchable. The best way to
51
+ # confirm that Drupal's repo is being used is if its in the "repositories" in composer.json
52
+ # (https://support.acquia.com/hc/en-us/articles/360048081273-Using-Composer-to-manage-dependencies-in-Drupal-8-and-9),
53
+ # but you may only have composer.lock, so we test if the type is "drupal-*" (e.g. "drupal-module" or "drupal-theme")
54
+ # The Drupal team also setup its own mapper of Composer semver -> Drupal tool-specfic versions
55
+ # (https://www.drupal.org/project/project_composer/issues/2622450),
56
+ # so we return the Drupal requirement instead of semver requirement if it's here
57
+ # (https://www.drupal.org/docs/develop/using-composer/using-composer-to-install-drupal-and-manage-dependencies#s-about-semantic-versioning)
58
+ private_class_method def self.is_drupal_module(dependency)
59
+ dependency["type"] =~ /drupal/ && dependency.dig("source", "reference")
60
+ end
43
61
  end
44
62
  end
45
63
  end
@@ -6,10 +6,16 @@ module Bibliothecary
6
6
  INSTALL_REGEXP = /install_requires\s*=\s*\[([\s\S]*?)\]/
7
7
  REQUIRE_REGEXP = /([a-zA-Z0-9]+[a-zA-Z0-9\-_\.]+)([><=\w\.,]+)?/
8
8
  REQUIREMENTS_REGEXP = /^#{REQUIRE_REGEXP}/
9
- MANIFEST_REGEXP = /.*require[^\/]*(\/)?[^\/]*\.(txt|pip)$/
9
+ MANIFEST_REGEXP = /.*require[^\/]*(\/)?[^\/]*\.(txt|pip|in)$/
10
+ PIP_COMPILE_REGEXP = /.*require.*$/
10
11
 
11
12
  def self.mapping
12
13
  {
14
+ lambda { |p| PIP_COMPILE_REGEXP.match(p) } => {
15
+ content_matcher: :pip_compile?,
16
+ kind: 'lockfile',
17
+ parser: :parse_requirements_txt
18
+ },
13
19
  lambda { |p| MANIFEST_REGEXP.match(p) } => {
14
20
  kind: 'manifest',
15
21
  parser: :parse_requirements_txt,
@@ -174,6 +180,15 @@ module Bibliothecary
174
180
  end
175
181
  deps
176
182
  end
183
+
184
+ def self.pip_compile?(file_contents)
185
+ return file_contents.include?("This file is autogenerated by pip-compile")
186
+ rescue Exception # rubocop:disable Lint/RescueException
187
+ # We rescue exception here since native libs can throw a non-StandardError
188
+ # We don't want to throw errors during the matching phase, only during
189
+ # parsing after we match.
190
+ false
191
+ end
177
192
  end
178
193
  end
179
194
  end
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "7.0.2"
2
+ VERSION = "7.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibliothecary
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.2
4
+ version: 7.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-22 00:00:00.000000000 Z
11
+ date: 2021-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb
@@ -206,7 +206,7 @@ dependencies:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
- description:
209
+ description:
210
210
  email:
211
211
  - andrewnez@gmail.com
212
212
  executables:
@@ -274,7 +274,7 @@ homepage: https://github.com/librariesio/bibliothecary
274
274
  licenses:
275
275
  - AGPL-3.0
276
276
  metadata: {}
277
- post_install_message:
277
+ post_install_message:
278
278
  rdoc_options: []
279
279
  require_paths:
280
280
  - lib
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
290
  version: '0'
291
291
  requirements: []
292
292
  rubygems_version: 3.1.2
293
- signing_key:
293
+ signing_key:
294
294
  specification_version: 4
295
295
  summary: Find and parse manifests
296
296
  test_files: []