dependabot-composer 0.238.0 → 0.240.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: 1b8037a1e1283d33035f449b4c622fea79ea2a08545cd79155baf6f8dbdb4e79
4
- data.tar.gz: 1fe6a98682abde302f7c33dba4e7772c4f919b022e7fd8dc02d236ecaac3abf5
3
+ metadata.gz: 8bc4696ba6e7198423b6beb9781cb0af1bad9fd020dd85686af7ebf3a82ca62e
4
+ data.tar.gz: 7fb74904f6ce723a5ccefeeeb7c19bbdf394be8fd85cdbf14aa2ae6ed96f7534
5
5
  SHA512:
6
- metadata.gz: f93a2b0223c2a611541d89ac0c13dae8608c9af250a28c3132a8b5c629af37d33fa2ca3eb9abe6d7753bddb65768e198f71c2128cdc4317565ee75d299390b16
7
- data.tar.gz: 88dedd07728d42dc6e92617a2ccf6f4c791ae190e9528c66b3c392c2ad31363cfb210e506b2aa56dccd74212e20aba30a83c5a7ff0f848175687668bd6cb08d7
6
+ metadata.gz: 1b4c9e8fb979078e33fb5887fd9e09fd24e00f47ff89af6e9256427acbe03b964c2d6b234f021209e3e3588d8123c3020aa169280431325c16323562e1274b2a
7
+ data.tar.gz: 31d01dfb299ebfdd3fbd8f1657452c448c67ba7548945aa83288fcabb9ac547fd4764985f2761d88d0ce497f44cff364e57f69f976d69da6a8ca37acc9f2379a
data/helpers/v1/build CHANGED
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  set -e
4
4
 
data/helpers/v2/build CHANGED
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  set -e
4
4
 
@@ -37,6 +37,7 @@ module Dependabot
37
37
  fetched_files << composer_json
38
38
  fetched_files << composer_lock if composer_lock
39
39
  fetched_files << auth_json if auth_json
40
+ fetched_files += artifact_dependencies
40
41
  fetched_files += path_dependencies
41
42
  fetched_files
42
43
  end
@@ -60,6 +61,41 @@ module Dependabot
60
61
  @auth_json = fetch_support_file("auth.json")
61
62
  end
62
63
 
64
+ def artifact_dependencies
65
+ return @artifact_dependencies if defined?(@artifact_dependencies)
66
+
67
+ # Find zip files in the artifact sources and download them.
68
+ @artifact_dependencies =
69
+ artifact_sources.map do |url|
70
+ repo_contents(dir: url)
71
+ .select { |file| file.type == "file" && file.name.end_with?(".zip") }
72
+ .map { |file| File.join(url, file.name) }
73
+ .map do |zip_file|
74
+ DependencyFile.new(
75
+ name: zip_file,
76
+ content: _fetch_file_content(zip_file),
77
+ directory: directory,
78
+ type: "file"
79
+ )
80
+ end
81
+ end.flatten
82
+
83
+ # Add .gitkeep to all directories in case they are empty. Composer isn't ok with empty directories.
84
+ @artifact_dependencies += artifact_sources.map do |url|
85
+ DependencyFile.new(
86
+ name: File.join(url, ".gitkeep"),
87
+ content: "",
88
+ directory: directory,
89
+ type: "file"
90
+ )
91
+ end
92
+
93
+ # Don't try to update these files, only used by composer for package resolution.
94
+ @artifact_dependencies.each { |f| f.support_file = true }
95
+
96
+ @artifact_dependencies
97
+ end
98
+
63
99
  def path_dependencies
64
100
  @path_dependencies ||=
65
101
  begin
@@ -90,8 +126,16 @@ module Dependabot
90
126
  end
91
127
  end
92
128
 
129
+ def artifact_sources
130
+ sources.select { |details| details["type"] == "artifact" }.map { |details| details["url"] }
131
+ end
132
+
93
133
  def path_sources
94
- @path_sources ||=
134
+ sources.select { |details| details["type"] == "path" }.map { |details| details["url"] }
135
+ end
136
+
137
+ def sources
138
+ @sources ||=
95
139
  begin
96
140
  repos = parsed_composer_json.fetch("repositories", [])
97
141
  if repos.is_a?(Hash) || repos.is_a?(Array)
@@ -99,8 +143,7 @@ module Dependabot
99
143
  repos = repos.select { |r| r.is_a?(Hash) }
100
144
 
101
145
  repos
102
- .select { |details| details["type"] == "path" }
103
- .map { |details| details["url"] }
146
+ .select { |details| details["type"] == "path" || details["type"] == "artifact" }
104
147
  else
105
148
  []
106
149
  end
@@ -242,6 +242,12 @@ module Dependabot
242
242
  end
243
243
 
244
244
  def write_temporary_dependency_files
245
+ artifact_dependencies.each do |file|
246
+ path = file.name
247
+ FileUtils.mkdir_p(Pathname.new(path).dirname)
248
+ File.write(file.name, file.content)
249
+ end
250
+
245
251
  path_dependencies.each do |file|
246
252
  path = file.name
247
253
  FileUtils.mkdir_p(Pathname.new(path).dirname)
@@ -509,6 +515,11 @@ module Dependabot
509
515
  @auth_json ||= dependency_files.find { |f| f.name == "auth.json" }
510
516
  end
511
517
 
518
+ def artifact_dependencies
519
+ @artifact_dependencies ||=
520
+ dependency_files.select { |f| f.name.end_with?(".zip", ".gitkeep") }
521
+ end
522
+
512
523
  def path_dependencies
513
524
  @path_dependencies ||=
514
525
  dependency_files.select { |f| f.name.end_with?("/composer.json") }
@@ -1,11 +1,16 @@
1
1
  # typed: true
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "sorbet-runtime"
5
+
6
+ require "dependabot/requirement"
4
7
  require "dependabot/utils"
5
8
 
6
9
  module Dependabot
7
10
  module Composer
8
- class Requirement < Gem::Requirement
11
+ class Requirement < Dependabot::Requirement
12
+ extend T::Sig
13
+
9
14
  AND_SEPARATOR = /(?<=[a-zA-Z0-9*])(?<!\sas)[\s,]+(?![\s,]*[|-]|as)/
10
15
  OR_SEPARATOR = /(?<=[a-zA-Z0-9*])[\s,]*\|\|?\s*/
11
16
 
@@ -18,8 +23,9 @@ module Dependabot
18
23
 
19
24
  # Returns an array of requirements. At least one requirement from the
20
25
  # returned array must be satisfied for a version to be valid.
26
+ sig { override.params(requirement_string: T.nilable(String)).returns(T::Array[Requirement]) }
21
27
  def self.requirements_array(requirement_string)
22
- requirement_string.strip.split(OR_SEPARATOR).map do |req_string|
28
+ T.must(requirement_string).strip.split(OR_SEPARATOR).map do |req_string|
23
29
  new(req_string)
24
30
  end
25
31
  end
@@ -91,10 +91,18 @@ module Dependabot
91
91
  def write_temporary_dependency_files(unlock_requirement: true)
92
92
  write_dependency_file(unlock_requirement: unlock_requirement)
93
93
  write_path_dependency_files
94
+ write_zipped_path_dependency_files
94
95
  write_lockfile
95
96
  write_auth_file
96
97
  end
97
98
 
99
+ def write_zipped_path_dependency_files
100
+ zipped_path_dependency_files.each do |file|
101
+ FileUtils.mkdir_p(Pathname.new(file.name).dirname)
102
+ File.write(file.name, file.content)
103
+ end
104
+ end
105
+
98
106
  def write_dependency_file(unlock_requirement:)
99
107
  File.write(
100
108
  "composer.json",
@@ -197,6 +205,7 @@ module Dependabot
197
205
  end
198
206
 
199
207
  # rubocop:disable Metrics/PerceivedComplexity
208
+ # rubocop:disable Metrics/AbcSize
200
209
  def updated_version_requirement_string
201
210
  lower_bound =
202
211
  if requirements_to_unlock == :none
@@ -210,7 +219,7 @@ module Dependabot
210
219
  .select { |req_string| req_string.match?(VERSION_REGEX) }
211
220
  .map { |req_string| req_string.match(VERSION_REGEX) }
212
221
  .select { |version| requirement_valid?(">= #{version}") }
213
- .max_by { |version| Composer::Version.new(version) }
222
+ .max_by { |version| Composer::Version.new(version.to_s) }
214
223
 
215
224
  ">= #{version_for_requirement || 0}"
216
225
  end
@@ -231,6 +240,7 @@ module Dependabot
231
240
  lower_bound + ", <= #{latest_allowable_version}"
232
241
  end
233
242
  # rubocop:enable Metrics/PerceivedComplexity
243
+ # rubocop:enable Metrics/AbcSize
234
244
 
235
245
  # TODO: Extract error handling and share between the lockfile updater
236
246
  #
@@ -471,6 +481,11 @@ module Dependabot
471
481
  dependency_files.select { |f| f.name.end_with?("/composer.json") }
472
482
  end
473
483
 
484
+ def zipped_path_dependency_files
485
+ @zipped_path_dependency_files ||=
486
+ dependency_files.select { |f| f.name.end_with?(".zip", ".gitkeep") }
487
+ end
488
+
474
489
  def lockfile
475
490
  @lockfile ||=
476
491
  dependency_files.find { |f| f.name == "composer.lock" }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-composer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.238.0
4
+ version: 0.240.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-07 00:00:00.000000000 Z
11
+ date: 2024-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.238.0
19
+ version: 0.240.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.238.0
26
+ version: 0.240.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.57.2
117
+ version: 1.58.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.57.2
124
+ version: 1.58.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rubocop-performance
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -206,6 +206,20 @@ dependencies:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
208
  version: '3.18'
209
+ - !ruby/object:Gem::Dependency
210
+ name: webrick
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '1.7'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '1.7'
209
223
  description: Dependabot-Composer provides support for bumping PHP (composer) libraries
210
224
  via Dependabot. If you want support for multiple package managers, you probably
211
225
  want the meta-gem dependabot-omnibus.
@@ -258,7 +272,7 @@ licenses:
258
272
  - Nonstandard
259
273
  metadata:
260
274
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
261
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.238.0
275
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.240.0
262
276
  post_install_message:
263
277
  rdoc_options: []
264
278
  require_paths: