-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #584 from LouisBoudreau/cocoapods
Add Cocoapods source
- Loading branch information
Showing
14 changed files
with
594 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# CocoaPods | ||
|
||
The cocoapods source will detect dependencies when `Podfile` and `Podfile.lock` are found at an app's `source_path`. | ||
|
||
It uses the `pod` CLI commands to enumerate dependencies and gather metadata on each package. | ||
|
||
### Evaluating dependencies from a specific target | ||
|
||
The `cocoapods.targets` property is used to specify which targets to analyze dependencies from. By default, dependencies from all targets will be analyzed. | ||
|
||
```yml | ||
cocoapods: | ||
targets: | ||
- ios | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# frozen_string_literal: true | ||
require "json" | ||
require "pathname" | ||
require "uri" | ||
require "cocoapods-core" | ||
|
||
module Licensed | ||
module Sources | ||
class Cocoapods < Source | ||
def enabled? | ||
return unless Licensed::Shell.tool_available?("pod") | ||
|
||
config.pwd.join("Podfile").exist? && config.pwd.join("Podfile.lock").exist? | ||
end | ||
|
||
def enumerate_dependencies | ||
pods.map do |pod| | ||
name = pod.name | ||
path = dependency_path(pod.root_name) | ||
version = lockfile.version(name).version | ||
|
||
Dependency.new( | ||
path: path, | ||
name: name, | ||
version: version, | ||
metadata: { "type" => Cocoapods.type } | ||
) | ||
end | ||
end | ||
|
||
private | ||
|
||
def pods | ||
return lockfile.dependencies if targets.nil? | ||
|
||
targets_to_validate = podfile.target_definition_list.filter { |t| targets.include?(t.label) } | ||
if targets_to_validate.any? | ||
targets_to_validate.map(&:dependencies).flatten | ||
else | ||
raise Licensed::Sources::Source::Error, "Unable to find any target in the Podfile matching the ones provided in the config." | ||
end | ||
end | ||
|
||
def targets | ||
@targets ||= config.dig("cocoapods", "targets")&.map { |t| "Pods-#{t}" } | ||
end | ||
|
||
def lockfile | ||
@lockfile ||= Pod::Lockfile.from_file(config.pwd.join("Podfile.lock")) | ||
end | ||
|
||
def podfile | ||
@podfile ||= Pod::Podfile.from_file(config.pwd.join("Podfile")) | ||
end | ||
|
||
def dependency_path(name) | ||
config.pwd.join("Pods/#{name}") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ -z "$(which pod)" ]; then | ||
echo "A local pod installation is required for cocoapods development." >&2 | ||
exit 127 | ||
fi | ||
|
||
# setup test fixtures | ||
BASE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" | ||
cd $BASE_PATH/test/fixtures/cocoapods | ||
|
||
if [ "$1" == "-f" ]; then | ||
pod install --clean-install | ||
fi | ||
|
||
pod install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Uncomment the next line to define a global platform for your project | ||
platform :ios, '13.0' | ||
|
||
target 'ios' do | ||
# Comment the next line if you don't want to use dynamic frameworks | ||
use_frameworks! | ||
|
||
pod "Alamofire", "5.4.3" | ||
pod "MaterialComponents/Buttons", "124.2.0" | ||
pod "MaterialComponents/Cards", "124.2.0" | ||
pod "Chatto", git: "https://github.com/badoo/Chatto", tag: "4.1.0" | ||
|
||
target 'iosTests' do | ||
inherit! :search_paths | ||
|
||
pod "lottie-ios", "3.3.0" | ||
end | ||
end |
Oops, something went wrong.