danger-spm_version_updates 0.0.1 → 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 +3 -1
- data/danger-spm_version_updates.gemspec +3 -0
- data/lib/spm_version_updates/gem_version.rb +1 -1
- data/lib/spm_version_updates/plugin.rb +23 -20
- data/spec/spm_version_updates_spec.rb +5 -13
- metadata +31 -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) }
|
|
@@ -20,6 +21,8 @@ Gem::Specification.new do |spec|
|
|
|
20
21
|
spec.require_paths = ["lib"]
|
|
21
22
|
|
|
22
23
|
spec.add_runtime_dependency("danger-plugin-api", "~> 1.0")
|
|
24
|
+
spec.add_runtime_dependency("semantic", "~> 1.6")
|
|
25
|
+
spec.add_runtime_dependency("xcodeproj", "~> 1.23")
|
|
23
26
|
|
|
24
27
|
# General ruby development
|
|
25
28
|
spec.add_development_dependency("bundler", "~> 2.0")
|
|
@@ -4,53 +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
|
-
def initialize(dangerfile)
|
|
32
|
-
super(dangerfile)
|
|
33
|
-
@check_when_exact = false
|
|
34
|
-
@quiet_above_maximum = false
|
|
35
|
-
@ignore_repos = []
|
|
36
|
-
end
|
|
37
|
-
|
|
38
33
|
# A method that you can call from your Dangerfile
|
|
39
|
-
# @
|
|
40
|
-
|
|
34
|
+
# @param [String] xcodeproj_path
|
|
35
|
+
# The path to your Xcode project
|
|
36
|
+
# @return [void]
|
|
37
|
+
def check_for_updates(xcodeproj_path)
|
|
41
38
|
raise(XcodeprojPathMustBeSet) if xcodeproj_path.nil?
|
|
42
39
|
|
|
43
40
|
project = Xcodeproj::Project.open(xcodeproj_path)
|
|
44
41
|
remote_packages = filter_remote_packages(project)
|
|
45
42
|
|
|
46
|
-
resolved_path = find_packages_resolved
|
|
43
|
+
resolved_path = find_packages_resolved(xcodeproj_path)
|
|
47
44
|
raise(CouldNotFindResolvedFile) unless File.exist?(resolved_path)
|
|
48
45
|
|
|
49
46
|
resolved_versions = JSON.load_file!(resolved_path)["pins"]
|
|
50
47
|
.to_h { |pin| [pin["location"], pin["state"]["version"] || pin["state"]["revision"]] }
|
|
51
48
|
|
|
52
49
|
remote_packages.each { |repository_url, requirement|
|
|
53
|
-
next if ignore_repos
|
|
50
|
+
next if ignore_repos&.include?(repository_url)
|
|
54
51
|
|
|
55
52
|
name = repo_name(repository_url)
|
|
56
53
|
resolved_version = resolved_versions[repository_url]
|
|
@@ -83,6 +80,8 @@ Newer version of #{name}: #{available_versions.first} (but this package is set t
|
|
|
83
80
|
}
|
|
84
81
|
end
|
|
85
82
|
|
|
83
|
+
# Extract a readable name for the repo given the url, generally org/repo
|
|
84
|
+
# @return [String]
|
|
86
85
|
def repo_name(repo_url)
|
|
87
86
|
match = repo_url.match(%r{([\w-]+/[\w-]+)(.git)?$})
|
|
88
87
|
|
|
@@ -93,6 +92,8 @@ Newer version of #{name}: #{available_versions.first} (but this package is set t
|
|
|
93
92
|
end
|
|
94
93
|
end
|
|
95
94
|
|
|
95
|
+
# Find the configured SPM dependencies in the xcodeproj
|
|
96
|
+
# @return [Hash<String, Hash>]
|
|
96
97
|
def filter_remote_packages(project)
|
|
97
98
|
project.objects.select { |obj|
|
|
98
99
|
obj.kind_of?(Xcodeproj::Project::Object::XCRemoteSwiftPackageReference) &&
|
|
@@ -101,7 +102,9 @@ Newer version of #{name}: #{available_versions.first} (but this package is set t
|
|
|
101
102
|
.to_h { |package| [package.repositoryURL, package.requirement] }
|
|
102
103
|
end
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
# Find the Packages.resolved file
|
|
106
|
+
# @return [String]
|
|
107
|
+
def find_packages_resolved(xcodeproj_path)
|
|
105
108
|
if Dir.exist?(xcodeproj_path.sub("xcodeproj", "xcworkspace"))
|
|
106
109
|
File.join(xcodeproj_path.sub("xcodeproj", "xcworkspace"), "xcshareddata", "swiftpm", "Package.resolved")
|
|
107
110
|
else
|
|
@@ -117,7 +120,7 @@ Newer version of #{name}: #{available_versions.first} (but this package is set t
|
|
|
117
120
|
warn("Newer version of #{name}: #{available_versions.first}")
|
|
118
121
|
else
|
|
119
122
|
newest_meeting_reqs = available_versions.find { |version|
|
|
120
|
-
version < max_version
|
|
123
|
+
version < max_version && report_pre_releases ? true : version.pre.nil?
|
|
121
124
|
}
|
|
122
125
|
warn("Newer version of #{name}: #{newest_meeting_reqs} ") unless newest_meeting_reqs.to_s == resolved_version
|
|
123
126
|
warn(
|
|
@@ -134,7 +137,7 @@ Newest version of #{name}: #{available_versions.first} (but this package is conf
|
|
|
134
137
|
warn("Newer version of #{name}: #{available_versions.first}")
|
|
135
138
|
else
|
|
136
139
|
newest_meeting_reqs = available_versions.find { |version|
|
|
137
|
-
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?
|
|
138
141
|
}
|
|
139
142
|
warn("Newer version of #{name}: #{newest_meeting_reqs}") unless newest_meeting_reqs == resolved_version
|
|
140
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
|
|
@@ -24,6 +24,34 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: semantic
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.6'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
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'
|
|
27
55
|
- !ruby/object:Gem::Dependency
|
|
28
56
|
name: bundler
|
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -233,7 +261,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
233
261
|
requirements:
|
|
234
262
|
- - ">="
|
|
235
263
|
- !ruby/object:Gem::Version
|
|
236
|
-
version: '
|
|
264
|
+
version: '2.7'
|
|
237
265
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
266
|
requirements:
|
|
239
267
|
- - ">="
|