danger-spm_version_updates 0.2.0 → 2.0.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.
data/Guardfile DELETED
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # A guardfile for making Danger Plugins
4
- # For more info see https://github.com/guard/guard#readme
5
-
6
- # To run, use `bundle exec guard`.
7
-
8
- guard :rspec, cmd: "bundle exec rspec" do
9
- require "guard/rspec/dsl"
10
- dsl = Guard::RSpec::Dsl.new(self)
11
-
12
- # RSpec files
13
- rspec = dsl.rspec
14
- watch(rspec.spec_helper) { rspec.spec_dir }
15
- watch(rspec.spec_support) { rspec.spec_dir }
16
- watch(rspec.spec_files)
17
-
18
- # Ruby files
19
- ruby = dsl.ruby
20
- dsl.watch_spec_files_for(ruby.lib_files)
21
- end
data/Rakefile DELETED
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "reek/rake/task"
5
- require "rspec/core/rake_task"
6
- require "rubocop/rake_task"
7
-
8
- RSpec::Core::RakeTask.new(:specs)
9
-
10
- task default: :specs
11
-
12
- desc "Run all test and lint tasks"
13
- task :spec do
14
- Rake::Task["specs"].invoke
15
- Rake::Task["rubocop"].invoke
16
- Rake::Task["spec_docs"].invoke
17
- end
18
-
19
- desc "Run RuboCop on the lib/specs directory"
20
- RuboCop::RakeTask.new(:rubocop) { |task|
21
- task.requires << "rubocop-rspec"
22
- task.requires << "rubocop-rake"
23
- task.requires << "rubocop-performance"
24
- task.patterns = ["lib/**/*.rb", "spec/**/*.rb"]
25
- }
26
-
27
- desc "Run Reek on the lib/specs directory"
28
- Reek::Rake::Task.new(:reek) { |task|
29
- task.source_files = FileList["lib/**/*.rb", "spec/**/*.rb"]
30
- }
31
-
32
- desc "Ensure that the plugin passes `danger plugins lint`"
33
- task :spec_docs do
34
- sh "bundle exec danger plugins lint"
35
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SpmVersionUpdates
4
- VERSION = "0.2.0"
5
- end
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Git
4
- # Removes protocol and trailing .git from a repo URL
5
- # @param [String] repo_url
6
- # The URL of the repository
7
- # @return [String]
8
- def self.trim_repo_url(repo_url)
9
- repo_url.split("://").last.gsub(/\.git$/, "")
10
- end
11
-
12
- # Extract a readable name for the repo given the url, generally org/repo
13
- # @return [String]
14
- def self.repo_name(repo_url)
15
- match = repo_url.match(%r{([\w-]+/[\w-]+)(.git)?$})
16
-
17
- if match
18
- match[1] || match[0]
19
- else
20
- repo_url
21
- end
22
- end
23
-
24
- # Call git to list tags
25
- # @param [String] repo_url
26
- # The URL of the dependency's repository
27
- # @return [Array<Semantic::Version>]
28
- def self.version_tags(repo_url)
29
- versions = `git ls-remote -t #{repo_url}`
30
- .split("\n")
31
- .map { |line| line.split("/tags/").last }
32
- .filter_map { |line|
33
- begin
34
- Semantic::Version.new(line)
35
- rescue ArgumentError
36
- nil
37
- end
38
- }
39
- versions.sort!
40
- versions.reverse!
41
- versions
42
- end
43
-
44
- # Call git to find the last commit on a branch
45
- # @param [String] repo_url
46
- # The URL of the dependency's repository
47
- # @param [String] branch_name
48
- # The name of the branch on which to find the last commit
49
- # @return [String]
50
- def self.branch_last_commit(repo_url, branch_name)
51
- `git ls-remote -h #{repo_url}`
52
- .split("\n")
53
- .find { |line| line.split("\trefs/heads/")[1] == branch_name }
54
- .split("\trefs/heads/")[0]
55
- end
56
- end
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "xcodeproj"
4
-
5
- module Xcode
6
- # Find the configured SPM dependencies in the xcodeproj
7
- # @param [String] xcodeproj_path
8
- # The path of the Xcode project
9
- # @return [Hash<String, Hash>]
10
- def self.get_packages(xcodeproj_path)
11
- raise(XcodeprojPathMustBeSet) if xcodeproj_path.nil? || xcodeproj_path.empty?
12
-
13
- project = Xcodeproj::Project.open(xcodeproj_path)
14
- project.objects.select { |obj|
15
- obj.kind_of?(Xcodeproj::Project::Object::XCRemoteSwiftPackageReference) &&
16
- obj.requirement["kind"] != "commit"
17
- }
18
- .to_h { |package|
19
- [Git.trim_repo_url(package.repositoryURL), package.requirement]
20
- }
21
- end
22
-
23
- # Extracts resolved versions from Package.resolved relative to an Xcode project
24
- # @param [String] xcodeproj_path
25
- # The path to your Xcode project
26
- # @raise [CouldNotFindResolvedFile] if no Package.resolved files were found
27
- # @return [Hash<String, String>]
28
- def self.get_resolved_versions(xcodeproj_path)
29
- resolved_paths = find_packages_resolved_file(xcodeproj_path)
30
- raise(CouldNotFindResolvedFile) if resolved_paths.empty?
31
-
32
- resolved_versions = resolved_paths.map { |resolved_path|
33
- contents = JSON.load_file!(resolved_path)
34
- pins = contents["pins"] || contents["object"]["pins"]
35
- pins.to_h { |pin|
36
- [
37
- Git.trim_repo_url(pin["location"] || pin["repositoryURL"]),
38
- pin["state"]["version"] || pin["state"]["revision"],
39
- ]
40
- }
41
- }
42
- resolved_versions.reduce(:merge!)
43
- end
44
-
45
- # Find the Packages.resolved file
46
- # @return [Array<String>]
47
- def self.find_packages_resolved_file(xcodeproj_path)
48
- locations = []
49
- # First check the workspace for a resolved file
50
- workspace = xcodeproj_path.sub("xcodeproj", "xcworkspace")
51
- if Dir.exist?(workspace)
52
- path = File.join(workspace, "xcshareddata", "swiftpm", "Package.resolved")
53
- locations << path if File.exist?(path)
54
- end
55
-
56
- # Then check the project for a resolved file
57
- path = File.join(xcodeproj_path, "project.xcworkspace", "xcshareddata", "swiftpm", "Package.resolved")
58
- locations << path if File.exist?(path)
59
-
60
- $stderr.puts("Searching for resolved packages in: #{locations}")
61
- locations
62
- end
63
-
64
- private_class_method :find_packages_resolved_file
65
-
66
- class XcodeprojPathMustBeSet < StandardError
67
- end
68
-
69
- class CouldNotFindResolvedFile < StandardError
70
- end
71
- end