danger-spm_version_updates 0.0.2 → 0.0.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 +4 -4
- data/Gemfile.lock +2 -1
- data/danger-spm_version_updates.gemspec +2 -0
- data/lib/spm_version_updates/gem_version.rb +1 -1
- data/lib/spm_version_updates/plugin.rb +23 -13
- data/spec/spm_version_updates_spec.rb +5 -13
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e09f13ea3447749c8a464e7583af7df15daa485a2fd4859642686dfa099d6686
|
4
|
+
data.tar.gz: 29cdfaae73b66e0288cd94c84b14d674f9ab2d1f6c3fd30431f31ad49b1d4fdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 885f9f92765ee4dad799321b3251cf8e8961196470b3e934d6ca25067cad96356759d88b845f1ccd2adde92008cc80239e57caa5d0f4833fefe1f6f49a0c9deb
|
7
|
+
data.tar.gz: 124352559472f974630fb4a28d3fa436b7f30360a23cc21864c20939b47718047bffd08190e61676c429ee567306089c5e0c6c7dc69b451ea42185b486db7541
|
data/Gemfile.lock
CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.summary = "A Danger plugin to detect if there are any updates to your Swift Package Manager dependencies."
|
14
14
|
spec.homepage = "https://github.com/hbmartin/danger-spm_version_updates"
|
15
15
|
spec.license = "MIT"
|
16
|
+
spec.required_ruby_version = ">= 2.7"
|
16
17
|
|
17
18
|
spec.files = `git ls-files`.split($/)
|
18
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -21,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
21
22
|
|
22
23
|
spec.add_runtime_dependency("danger-plugin-api", "~> 1.0")
|
23
24
|
spec.add_runtime_dependency("semantic", "~> 1.6")
|
25
|
+
spec.add_runtime_dependency("xcodeproj", "~> 1.23")
|
24
26
|
|
25
27
|
# General ruby development
|
26
28
|
spec.add_development_dependency("bundler", "~> 2.0")
|
@@ -4,46 +4,50 @@ require "semantic"
|
|
4
4
|
require "xcodeproj"
|
5
5
|
|
6
6
|
module Danger
|
7
|
+
# A plugin for checking if there are versions upgrades available for SPM packages
|
8
|
+
#
|
7
9
|
# @example Ensure people are well warned about merging on Mondays
|
8
10
|
#
|
9
|
-
#
|
11
|
+
# spm_version_updates.check_for_updates("MyApp.xcodeproj")
|
10
12
|
#
|
11
13
|
# @see Harold Martin/danger-spm_version_updates
|
12
14
|
# @tags swift, spm, swift package manager, xcode, xcodeproj, version, updates
|
13
15
|
#
|
14
16
|
class DangerSpmVersionUpdates < Plugin
|
15
|
-
# The path to the xcodeproj file
|
16
|
-
# @return [String]
|
17
|
-
attr_accessor :xcodeproj_path
|
18
|
-
|
19
17
|
# Whether to check when dependencies are exact versions or commits, default false
|
20
18
|
# @return [Boolean]
|
21
19
|
attr_accessor :check_when_exact
|
22
20
|
|
23
|
-
# Whether to ignore
|
21
|
+
# Whether to ignore versions above the maximum version range, default true
|
24
22
|
# @return [Boolean]
|
25
23
|
attr_accessor :quiet_above_maximum
|
26
24
|
|
25
|
+
# Whether to report pre-release versions, default false
|
26
|
+
# @return [Boolean]
|
27
|
+
attr_accessor :report_pre_releases
|
28
|
+
|
27
29
|
# A list of repositories to ignore entirely, must exactly match the URL as configured in the Xcode project
|
28
30
|
# @return [Array<String>]
|
29
31
|
attr_accessor :ignore_repos
|
30
32
|
|
31
33
|
# A method that you can call from your Dangerfile
|
32
|
-
# @
|
33
|
-
|
34
|
+
# @param [String] xcodeproj_path
|
35
|
+
# The path to your Xcode project
|
36
|
+
# @return [void]
|
37
|
+
def check_for_updates(xcodeproj_path)
|
34
38
|
raise(XcodeprojPathMustBeSet) if xcodeproj_path.nil?
|
35
39
|
|
36
40
|
project = Xcodeproj::Project.open(xcodeproj_path)
|
37
41
|
remote_packages = filter_remote_packages(project)
|
38
42
|
|
39
|
-
resolved_path = find_packages_resolved
|
43
|
+
resolved_path = find_packages_resolved(xcodeproj_path)
|
40
44
|
raise(CouldNotFindResolvedFile) unless File.exist?(resolved_path)
|
41
45
|
|
42
46
|
resolved_versions = JSON.load_file!(resolved_path)["pins"]
|
43
47
|
.to_h { |pin| [pin["location"], pin["state"]["version"] || pin["state"]["revision"]] }
|
44
48
|
|
45
49
|
remote_packages.each { |repository_url, requirement|
|
46
|
-
next if ignore_repos
|
50
|
+
next if ignore_repos&.include?(repository_url)
|
47
51
|
|
48
52
|
name = repo_name(repository_url)
|
49
53
|
resolved_version = resolved_versions[repository_url]
|
@@ -76,6 +80,8 @@ Newer version of #{name}: #{available_versions.first} (but this package is set t
|
|
76
80
|
}
|
77
81
|
end
|
78
82
|
|
83
|
+
# Extract a readable name for the repo given the url, generally org/repo
|
84
|
+
# @return [String]
|
79
85
|
def repo_name(repo_url)
|
80
86
|
match = repo_url.match(%r{([\w-]+/[\w-]+)(.git)?$})
|
81
87
|
|
@@ -86,6 +92,8 @@ Newer version of #{name}: #{available_versions.first} (but this package is set t
|
|
86
92
|
end
|
87
93
|
end
|
88
94
|
|
95
|
+
# Find the configured SPM dependencies in the xcodeproj
|
96
|
+
# @return [Hash<String, Hash>]
|
89
97
|
def filter_remote_packages(project)
|
90
98
|
project.objects.select { |obj|
|
91
99
|
obj.kind_of?(Xcodeproj::Project::Object::XCRemoteSwiftPackageReference) &&
|
@@ -94,7 +102,9 @@ Newer version of #{name}: #{available_versions.first} (but this package is set t
|
|
94
102
|
.to_h { |package| [package.repositoryURL, package.requirement] }
|
95
103
|
end
|
96
104
|
|
97
|
-
|
105
|
+
# Find the Packages.resolved file
|
106
|
+
# @return [String]
|
107
|
+
def find_packages_resolved(xcodeproj_path)
|
98
108
|
if Dir.exist?(xcodeproj_path.sub("xcodeproj", "xcworkspace"))
|
99
109
|
File.join(xcodeproj_path.sub("xcodeproj", "xcworkspace"), "xcshareddata", "swiftpm", "Package.resolved")
|
100
110
|
else
|
@@ -110,7 +120,7 @@ Newer version of #{name}: #{available_versions.first} (but this package is set t
|
|
110
120
|
warn("Newer version of #{name}: #{available_versions.first}")
|
111
121
|
else
|
112
122
|
newest_meeting_reqs = available_versions.find { |version|
|
113
|
-
version < max_version
|
123
|
+
version < max_version && report_pre_releases ? true : version.pre.nil?
|
114
124
|
}
|
115
125
|
warn("Newer version of #{name}: #{newest_meeting_reqs} ") unless newest_meeting_reqs.to_s == resolved_version
|
116
126
|
warn(
|
@@ -127,7 +137,7 @@ Newest version of #{name}: #{available_versions.first} (but this package is conf
|
|
127
137
|
warn("Newer version of #{name}: #{available_versions.first}")
|
128
138
|
else
|
129
139
|
newest_meeting_reqs = available_versions.find { |version|
|
130
|
-
version.send(major_or_minor) == resolved_version.send(major_or_minor)
|
140
|
+
version.send(major_or_minor) == resolved_version.send(major_or_minor) && report_pre_releases ? true : version.pre.nil?
|
131
141
|
}
|
132
142
|
warn("Newer version of #{name}: #{newest_meeting_reqs}") unless newest_meeting_reqs == resolved_version
|
133
143
|
warn(
|
@@ -22,35 +22,27 @@ module Danger
|
|
22
22
|
allow(@my_plugin.github).to receive(:pr_json).and_return(json)
|
23
23
|
end
|
24
24
|
|
25
|
-
it "raises error if xcodeproj_path is not set" do
|
26
|
-
expect { @my_plugin.check_for_updates }
|
27
|
-
.to raise_error(Danger::XcodeprojPathMustBeSet)
|
28
|
-
end
|
29
|
-
|
30
25
|
it "Reports none without exact version matching" do
|
31
|
-
|
32
|
-
allow(Date).to receive(:today).and_return monday_date
|
26
|
+
allow(@my_plugin).to receive(:git_versions).and_return false
|
33
27
|
|
34
|
-
@my_plugin.
|
35
|
-
@my_plugin.check_for_updates
|
28
|
+
@my_plugin.check_for_updates("#{File.dirname(__FILE__)}/support/fixtures/Example.xcodeproj")
|
36
29
|
|
37
30
|
expect(@dangerfile.status_report[:warnings]).to eq([])
|
38
31
|
end
|
39
32
|
|
40
33
|
it "Reports some with exact version matching" do
|
41
34
|
# TODO: mock git calls
|
42
|
-
|
35
|
+
allow(@my_plugin).to receive(:git_versions).and_return false
|
43
36
|
|
44
|
-
@my_plugin.xcodeproj_path = "#{File.dirname(__FILE__)}/support/fixtures/Example.xcodeproj"
|
45
37
|
@my_plugin.check_when_exact = true
|
46
|
-
@my_plugin.check_for_updates
|
38
|
+
@my_plugin.check_for_updates("#{File.dirname(__FILE__)}/support/fixtures/Example.xcodeproj")
|
47
39
|
|
48
40
|
expect(@dangerfile.status_report[:warnings]).to eq(
|
49
41
|
[
|
50
42
|
"Newer version of pointfreeco/swift-snapshot-testing: 1.14.2 (but this package is set to exact version 1.13.0)\n",
|
51
43
|
"Newer version of kean/Nuke: 12.2.0-beta.2 (but this package is set to exact version 12.1.6)\n",
|
52
44
|
"Newer version of pointfreeco/swiftui-navigation: 1.0.3 (but this package is set to exact version 1.0.2)\n",
|
53
|
-
"Newer version of getsentry/sentry-cocoa: 8.
|
45
|
+
"Newer version of getsentry/sentry-cocoa: 8.15.0 (but this package is set to exact version 8.12.0)\n",
|
54
46
|
"Newer version of firebase/firebase-ios-sdk: 10.17.0 (but this package is set to exact version 10.15.0)\n",
|
55
47
|
]
|
56
48
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-spm_version_updates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harold Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: xcodeproj
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.23'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.23'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -247,7 +261,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
247
261
|
requirements:
|
248
262
|
- - ">="
|
249
263
|
- !ruby/object:Gem::Version
|
250
|
-
version: '
|
264
|
+
version: '2.7'
|
251
265
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
252
266
|
requirements:
|
253
267
|
- - ">="
|