cocoapods-podfile-generator 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +59 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +116 -0
- data/LICENSE +22 -0
- data/README.md +75 -0
- data/Rakefile +13 -0
- data/cocoapods-podfile-generator.gemspec +23 -0
- data/lib/cocoapods-podfile-generator/command/podfile.rb +241 -0
- data/lib/cocoapods-podfile-generator/command.rb +1 -0
- data/lib/cocoapods-podfile-generator/podfilegeneratorinformative.rb +2 -0
- data/lib/cocoapods-podfile-generator/version.rb +30 -0
- data/lib/cocoapods-podfile-generator.rb +1 -0
- data/lib/cocoapods_plugin.rb +1 -0
- data/spec/Bad_Pods_Format.txt +1 -0
- data/spec/Non_Existing_Pod.txt +1 -0
- data/spec/Pods.txt +3 -0
- data/spec/TextFile +3 -0
- data/spec/command/podfile_spec.rb +281 -0
- data/spec/spec_helper.rb +50 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e755f39a3f85aa1939356efc8f8ed5bd14bcb4c3fa03b50a5f388f6ff61a3fec
|
4
|
+
data.tar.gz: a3c6bd4721ef66736404016df8f4c7a325f443cc64b3e883ceae676ed09a460c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bf82c015f0f19be08f39e10435d4aedc1625e742f07138c6705fdf6a5975cf8072acc3883a18047ad6ad6d73e80a43fc2c547f476a7f40796dc812ef3e95deeb
|
7
|
+
data.tar.gz: 354d971e3fba40d903479c4c08b9ee8fe2d8d8e47e1ebfcef04db31f83becaa9cc6acae44b1cc59590932a437fb34d748402c20480a271e36ca2e9288a451b0d
|
data/.gitignore
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
57
|
+
|
58
|
+
spec/test
|
59
|
+
.DS_Store
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cocoapods-podfile-generator (0.4.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
CFPropertyList (3.0.5)
|
10
|
+
rexml
|
11
|
+
activesupport (6.1.7)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
17
|
+
addressable (2.8.1)
|
18
|
+
public_suffix (>= 2.0.2, < 6.0)
|
19
|
+
algoliasearch (1.27.5)
|
20
|
+
httpclient (~> 2.8, >= 2.8.3)
|
21
|
+
json (>= 1.5.1)
|
22
|
+
atomos (0.1.3)
|
23
|
+
bacon (1.2.0)
|
24
|
+
claide (1.1.0)
|
25
|
+
cocoapods (1.11.3)
|
26
|
+
addressable (~> 2.8)
|
27
|
+
claide (>= 1.0.2, < 2.0)
|
28
|
+
cocoapods-core (= 1.11.3)
|
29
|
+
cocoapods-deintegrate (>= 1.0.3, < 2.0)
|
30
|
+
cocoapods-downloader (>= 1.4.0, < 2.0)
|
31
|
+
cocoapods-plugins (>= 1.0.0, < 2.0)
|
32
|
+
cocoapods-search (>= 1.0.0, < 2.0)
|
33
|
+
cocoapods-trunk (>= 1.4.0, < 2.0)
|
34
|
+
cocoapods-try (>= 1.1.0, < 2.0)
|
35
|
+
colored2 (~> 3.1)
|
36
|
+
escape (~> 0.0.4)
|
37
|
+
fourflusher (>= 2.3.0, < 3.0)
|
38
|
+
gh_inspector (~> 1.0)
|
39
|
+
molinillo (~> 0.8.0)
|
40
|
+
nap (~> 1.0)
|
41
|
+
ruby-macho (>= 1.0, < 3.0)
|
42
|
+
xcodeproj (>= 1.21.0, < 2.0)
|
43
|
+
cocoapods-core (1.11.3)
|
44
|
+
activesupport (>= 5.0, < 7)
|
45
|
+
addressable (~> 2.8)
|
46
|
+
algoliasearch (~> 1.0)
|
47
|
+
concurrent-ruby (~> 1.1)
|
48
|
+
fuzzy_match (~> 2.0.4)
|
49
|
+
nap (~> 1.0)
|
50
|
+
netrc (~> 0.11)
|
51
|
+
public_suffix (~> 4.0)
|
52
|
+
typhoeus (~> 1.0)
|
53
|
+
cocoapods-deintegrate (1.0.5)
|
54
|
+
cocoapods-downloader (1.6.3)
|
55
|
+
cocoapods-plugins (1.0.0)
|
56
|
+
nap
|
57
|
+
cocoapods-search (1.0.1)
|
58
|
+
cocoapods-trunk (1.6.0)
|
59
|
+
nap (>= 0.8, < 2.0)
|
60
|
+
netrc (~> 0.11)
|
61
|
+
cocoapods-try (1.2.0)
|
62
|
+
colored2 (3.1.2)
|
63
|
+
concurrent-ruby (1.1.10)
|
64
|
+
escape (0.0.4)
|
65
|
+
ethon (0.15.0)
|
66
|
+
ffi (>= 1.15.0)
|
67
|
+
ffi (1.15.5)
|
68
|
+
fourflusher (2.3.1)
|
69
|
+
fuzzy_match (2.0.4)
|
70
|
+
gh_inspector (1.1.3)
|
71
|
+
httpclient (2.8.3)
|
72
|
+
i18n (1.12.0)
|
73
|
+
concurrent-ruby (~> 1.0)
|
74
|
+
json (2.6.2)
|
75
|
+
minitest (5.16.3)
|
76
|
+
mocha (1.16.0)
|
77
|
+
mocha-on-bacon (0.2.3)
|
78
|
+
mocha (>= 0.13.0)
|
79
|
+
molinillo (0.8.0)
|
80
|
+
nanaimo (0.3.0)
|
81
|
+
nap (1.1.0)
|
82
|
+
netrc (0.11.0)
|
83
|
+
prettybacon (0.0.2)
|
84
|
+
bacon (~> 1.2)
|
85
|
+
public_suffix (4.0.7)
|
86
|
+
rake (13.0.6)
|
87
|
+
rexml (3.2.5)
|
88
|
+
ruby-macho (2.5.1)
|
89
|
+
typhoeus (1.4.0)
|
90
|
+
ethon (>= 0.9.0)
|
91
|
+
tzinfo (2.0.5)
|
92
|
+
concurrent-ruby (~> 1.0)
|
93
|
+
xcodeproj (1.22.0)
|
94
|
+
CFPropertyList (>= 2.3.3, < 4.0)
|
95
|
+
atomos (~> 0.1.3)
|
96
|
+
claide (>= 1.0.2, < 2.0)
|
97
|
+
colored2 (~> 3.1)
|
98
|
+
nanaimo (~> 0.3.0)
|
99
|
+
rexml (~> 3.2.4)
|
100
|
+
zeitwerk (2.6.1)
|
101
|
+
|
102
|
+
PLATFORMS
|
103
|
+
ruby
|
104
|
+
|
105
|
+
DEPENDENCIES
|
106
|
+
bacon
|
107
|
+
bundler (~> 1.3)
|
108
|
+
cocoapods
|
109
|
+
cocoapods-podfile-generator!
|
110
|
+
mocha
|
111
|
+
mocha-on-bacon
|
112
|
+
prettybacon
|
113
|
+
rake
|
114
|
+
|
115
|
+
BUNDLED WITH
|
116
|
+
1.17.2
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2022 Israel Soto <israel.spgh@gmail.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# cocoapods-podfile-generator
|
2
|
+
|
3
|
+
A Cocoapods plugin that helps you generate a Podfile file with the pods provided.
|
4
|
+
|
5
|
+
The plugin has the following features that will try to make your life easier for creating a Podfile:
|
6
|
+
|
7
|
+
* Generate a target per each platform supported by the pods provided. You can control which platforms to support
|
8
|
+
* Calculate the best minimum supported version for each platform
|
9
|
+
* Generate the Podfile just with the pods provided or it can add for you the subspecs or dependecies needed for each pod provided
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
$ gem install cocoapods-podfile-generator
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
$ pod podfile [POD_NAME:POD_VERSION ...]
|
18
|
+
|
19
|
+
You can pass some flags and options to generate some different tastes for the Podfile:
|
20
|
+
|
21
|
+
| Option name | Description |
|
22
|
+
|---|---|
|
23
|
+
| `--regex` | Interpret the pod names as a regular expression |
|
24
|
+
| `--include-dependencies` | Include each pod's dependencies name in the Podfile. |
|
25
|
+
| `--include-default-subspecs` | Include the `default_subspecs` values in the Podfile if any. |
|
26
|
+
| `--include-all-subspecs` | Include all the subspecs in the Podfile if any. |
|
27
|
+
| `--include-analyze` | Let cocoapods resolve the necessary dependencies for the provided pods and include them in the Podfile. |
|
28
|
+
| `--text-file` | A text file containing the pods to add to the Podfile. Each row within the file should have the format: <POD_NAME>:<POD_VERSION>. Example: `--text-file=path/to/file.txt` |
|
29
|
+
| `--platforms` | Platforms to consider. If not set, all platforms supported by the pods will be used. A target will be generated per platform. Example: `--platforms=ios,tvos` |
|
30
|
+
| `--output` | Path where the Podfile will be saved. If not set, the Podfile will be saved where the command is running. Example: `--output=path/to/save/Podfile_name` |
|
31
|
+
|
32
|
+
## Example
|
33
|
+
|
34
|
+
Running the following command:
|
35
|
+
|
36
|
+
$ pod podfile Firebase:10.0.0 FBSDKShareKit:15.0.0 --include-default-subspecs --include-dependencies
|
37
|
+
|
38
|
+
will generate the following output:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
install! 'cocoapods', integrate_targets: false
|
42
|
+
use_frameworks!
|
43
|
+
|
44
|
+
target 'Target_for_ios' do
|
45
|
+
platform :ios, '12.0'
|
46
|
+
pod 'Firebase', '10.0.0'
|
47
|
+
pod 'FBSDKShareKit', '15.0.0'
|
48
|
+
pod 'Firebase/Core', '10.0.0'
|
49
|
+
pod 'FBSDKCoreKit', '15.0.0'
|
50
|
+
pod 'Firebase/CoreOnly', '10.0.0'
|
51
|
+
pod 'FirebaseAnalytics', '10.0.0'
|
52
|
+
end
|
53
|
+
|
54
|
+
target 'Target_for_osx' do
|
55
|
+
platform :osx, '10.13'
|
56
|
+
pod 'Firebase', '10.0.0'
|
57
|
+
pod 'Firebase/Core', '10.0.0'
|
58
|
+
pod 'Firebase/CoreOnly', '10.0.0'
|
59
|
+
pod 'FirebaseAnalytics', '10.0.0'
|
60
|
+
end
|
61
|
+
|
62
|
+
target 'Target_for_tvos' do
|
63
|
+
platform :tvos, '12.0'
|
64
|
+
pod 'Firebase', '10.0.0'
|
65
|
+
pod 'FBSDKShareKit', '15.0.0'
|
66
|
+
pod 'Firebase/Core', '10.0.0'
|
67
|
+
pod 'FBSDKCoreKit', '15.0.0'
|
68
|
+
pod 'Firebase/CoreOnly', '10.0.0'
|
69
|
+
pod 'FirebaseAnalytics', '10.0.0'
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
## Known limitations
|
74
|
+
|
75
|
+
* Does not support versions with optimistic operator (~>)
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cocoapods-podfile-generator/version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cocoapods-podfile-generator'
|
8
|
+
spec.version = CocoapodsPodfileGenerator::VERSION
|
9
|
+
spec.authors = ['Israel Soto']
|
10
|
+
spec.email = ['israel.spgh@gmail.com']
|
11
|
+
spec.summary = CocoapodsPodfileGenerator::SUMMARY
|
12
|
+
spec.description = CocoapodsPodfileGenerator::DESCRIPTION
|
13
|
+
spec.homepage = 'https://github.com/EXAMPLE/cocoapods-podfile-generator'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
end
|
@@ -0,0 +1,241 @@
|
|
1
|
+
require 'cocoapods-podfile-generator/podfilegeneratorinformative'
|
2
|
+
require 'cocoapods-podfile-generator/version.rb'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
# This is an example of a cocoapods plugin adding a top-level subcommand
|
7
|
+
# to the 'pod' command.
|
8
|
+
#
|
9
|
+
# You can also create subcommands of existing or new commands. Say you
|
10
|
+
# wanted to add a subcommand to `list` to show newly deprecated pods,
|
11
|
+
# (e.g. `pod list deprecated`), there are a few things that would need
|
12
|
+
# to change.
|
13
|
+
#
|
14
|
+
# - move this file to `lib/pod/command/list/deprecated.rb` and update
|
15
|
+
# the class to exist in the the Pod::Command::List namespace
|
16
|
+
# - change this class to extend from `List` instead of `Command`. This
|
17
|
+
# tells the plugin system that it is a subcommand of `list`.
|
18
|
+
# - edit `lib/cocoapods_plugins.rb` to require this file
|
19
|
+
#
|
20
|
+
# @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
|
21
|
+
# in the `plugins.json` file, once your plugin is released.
|
22
|
+
#
|
23
|
+
class Podfile < Command
|
24
|
+
require 'pathname'
|
25
|
+
|
26
|
+
self.summary = CocoapodsPodfileGenerator::SUMMARY
|
27
|
+
self.description = CocoapodsPodfileGenerator::DESCRIPTION
|
28
|
+
|
29
|
+
self.arguments = [
|
30
|
+
CLAide::Argument.new(CocoapodsPodfileGenerator::POD_ARGUMENT_NAME, false, true)
|
31
|
+
]
|
32
|
+
|
33
|
+
def self.options
|
34
|
+
[
|
35
|
+
["--#{CocoapodsPodfileGenerator::REGEX_FLAG_NAME}", "Interpret the pod names as a regular expression"],
|
36
|
+
["--#{CocoapodsPodfileGenerator::INCLUDE_DEPENDENCIES_FLAG_NAME}", "Include each pod's dependencies name in the Podfile."],
|
37
|
+
["--#{CocoapodsPodfileGenerator::INCLUDE_DEFAULT_SUBSPECS_FLAG_NAME}", "Include the `default_subspecs` values in the Podfile if any."],
|
38
|
+
["--#{CocoapodsPodfileGenerator::INCLUDE_ALL_SUBSPECS_FLAG_NAME}", "Include all the subspecs in the Podfile if any."],
|
39
|
+
["--#{CocoapodsPodfileGenerator::INCLUDE_ANALYZE_FLAG_NAME}", "Let cocoapods resolve the necessary dependencies for the provided pods and include them in the Podfile."],
|
40
|
+
["--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}", "A text file containing the pods to add to the Podfile. Each row within the file should have the format: <POD_NAME>:<POD_VERSION>. Example: --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=path/to/file.txt"],
|
41
|
+
["--#{CocoapodsPodfileGenerator::PLATFORMS_OPTION_NAME}", "Platforms to consider. If not set, all platforms supported by the pods will be used. A target will be generated per platform. Example: --#{CocoapodsPodfileGenerator::PLATFORMS_OPTION_NAME}=ios,tvos"],
|
42
|
+
["--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}", "Path where the Podfile will be saved. If not set, the Podfile will be saved where the command is running. Example: --#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=path/to/save/Podfile_name"],
|
43
|
+
].concat(super)
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize(argv)
|
47
|
+
# Let's get all the command line arguments.
|
48
|
+
@pods = {}
|
49
|
+
@pods_args = argv.arguments!
|
50
|
+
@use_regex = argv.flag?(CocoapodsPodfileGenerator::REGEX_FLAG_NAME)
|
51
|
+
@include_dependencies = argv.flag?(CocoapodsPodfileGenerator::INCLUDE_DEPENDENCIES_FLAG_NAME)
|
52
|
+
@include_default_subspecs = argv.flag?(CocoapodsPodfileGenerator::INCLUDE_DEFAULT_SUBSPECS_FLAG_NAME)
|
53
|
+
@include_all_subspecs = argv.flag?(CocoapodsPodfileGenerator::INCLUDE_ALL_SUBSPECS_FLAG_NAME)
|
54
|
+
@include_analyze = argv.flag?(CocoapodsPodfileGenerator::INCLUDE_ANALYZE_FLAG_NAME)
|
55
|
+
@pods_text_file = argv.option(CocoapodsPodfileGenerator::FILE_OPTION_NAME)
|
56
|
+
@platforms = argv.option(CocoapodsPodfileGenerator::PLATFORMS_OPTION_NAME, "").split(",")
|
57
|
+
@podfile_output_path = argv.option(CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME, "#{Dir.pwd}/Podfile")
|
58
|
+
super
|
59
|
+
end
|
60
|
+
|
61
|
+
def validate!
|
62
|
+
super
|
63
|
+
help! "You must give a Pod argument or pass a path to a text file to parse the Pods." if @pods_args.empty? && @pods_text_file.nil?
|
64
|
+
|
65
|
+
# Parse each argument passed if any
|
66
|
+
begin
|
67
|
+
@pods_args.each { |pod| @pods.merge!(parse_line(pod)) } if not @pods_args.empty?
|
68
|
+
rescue PodfileGeneratorInformative => e
|
69
|
+
help! "There was a problem parsing the argument #{e.message}."
|
70
|
+
end
|
71
|
+
|
72
|
+
# Parse each line of the text file if there's a file
|
73
|
+
if @pods_text_file
|
74
|
+
pods_text_file = Pathname.new(@pods_text_file)
|
75
|
+
help! "The file was not found at #{@pods_text_file} to parse the pod lines." if not pods_text_file.exist?
|
76
|
+
help! "The file at #{@pods_text_file} should have a .txt extension." if not pods_text_file.extname == ".txt"
|
77
|
+
|
78
|
+
begin
|
79
|
+
pods_text_file.each_line { |line| @pods.merge!(parse_line(line)) }
|
80
|
+
rescue PodfileGeneratorInformative => e
|
81
|
+
help! "There was a problem parsing the line #{e.message} at file #{@pods_text_file}."
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Validate that each Pod with its specified versions exist by using the `pod spec which` command.
|
86
|
+
@pods.each do |pod_name, pod_version|
|
87
|
+
# Arguments needed for the command.
|
88
|
+
args = [pod_name]
|
89
|
+
args += ["--#{CocoapodsPodfileGenerator::REGEX_FLAG_NAME}"] if @use_regex
|
90
|
+
|
91
|
+
begin
|
92
|
+
which_spec = Pod::Command::Spec::Which.new CLAide::ARGV.new(args + ["--version=#{pod_version}"])
|
93
|
+
which_spec.run
|
94
|
+
rescue Pod::Informative => e
|
95
|
+
raise PodfileGeneratorInformative, "There was a problem trying to locate the pod #{pod_name} (#{pod_version})\n" +
|
96
|
+
"Original error message: #{e.message}"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def run
|
102
|
+
# As we already validate the arguments provided, it's safe to get the podspecs.
|
103
|
+
specs = @pods.keys.map { |pod_name| get_specification(pod_name.to_s, @pods[pod_name]) }
|
104
|
+
resolve_platforms_if_needed(specs)
|
105
|
+
|
106
|
+
if @include_dependencies || @include_analyze
|
107
|
+
specs_by_platform = resolve_dependencies(specs)
|
108
|
+
else
|
109
|
+
specs_by_platform = get_specs_by_platform(specs)
|
110
|
+
end
|
111
|
+
|
112
|
+
generate_podfile_file(specs_by_platform, @podfile_output_path)
|
113
|
+
end
|
114
|
+
|
115
|
+
private
|
116
|
+
|
117
|
+
# Parse a string line to a hash.
|
118
|
+
def parse_line(line)
|
119
|
+
line = line.strip
|
120
|
+
raise PodfileGeneratorInformative, line if not line =~ /^.+:.+$/
|
121
|
+
pod_name, pod_version = line.split(":")
|
122
|
+
Hash[pod_name.to_sym, pod_version]
|
123
|
+
end
|
124
|
+
|
125
|
+
# Gets the podspec for an specific version
|
126
|
+
def get_specification(pod_name, pod_version)
|
127
|
+
query = @use_regex ? pod_name : Regexp.escape(pod_name)
|
128
|
+
set = config.sources_manager.search_by_name(query).first
|
129
|
+
spec_path = set.specification_paths_for_version(Pod::Version.new(pod_version)).first
|
130
|
+
spec = Pod::Specification.from_file(spec_path)
|
131
|
+
|
132
|
+
# Remove the default subspecs value to consider all exisiting subspecs within a spec
|
133
|
+
spec.default_subspecs = [] if @include_all_subspecs || spec.default_subspecs == :none
|
134
|
+
spec
|
135
|
+
end
|
136
|
+
|
137
|
+
def resolve_platforms_if_needed(specs)
|
138
|
+
# Get all the supported platforms without the OS version if no platforms are specified
|
139
|
+
@platforms = specs
|
140
|
+
.map { |spec| spec.available_platforms.map(&:name) }
|
141
|
+
.flatten
|
142
|
+
.uniq if @platforms.empty?
|
143
|
+
@platforms.map! { |platform| Pod::Platform.new(platform) }
|
144
|
+
end
|
145
|
+
|
146
|
+
# Analyze and resolve all the specs needed for this spec.
|
147
|
+
def resolve_dependencies(specs)
|
148
|
+
specs_by_platform = get_specs_by_platform(specs)
|
149
|
+
|
150
|
+
podfile = podfile(specs_by_platform)
|
151
|
+
resolved_specs = Pod::Installer::Analyzer.new(config.sandbox, podfile).analyze.specs_by_target
|
152
|
+
|
153
|
+
# After an analyze, we get every specs needed to make this Podfile work,
|
154
|
+
# Let's filter the specs according to the user needs.
|
155
|
+
@platforms.each do |platform|
|
156
|
+
key = resolved_specs.keys.find { |key| key.name.end_with?(platform.name.to_s) }
|
157
|
+
next if key.nil?
|
158
|
+
|
159
|
+
if @include_analyze
|
160
|
+
specs_by_platform[platform.name] = resolved_specs[key]
|
161
|
+
else
|
162
|
+
dependecies_names = specs_by_platform[platform.name].map { |spec| spec.dependencies(platform).map(&:name) }.flatten.uniq
|
163
|
+
specs_by_platform[platform.name] += resolved_specs[key].select { |spec| dependecies_names.include?(spec.name) }
|
164
|
+
|
165
|
+
# Let's remove any duplicated specs
|
166
|
+
specs_by_platform[platform.name].uniq!(&:name)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
specs_by_platform
|
171
|
+
end
|
172
|
+
|
173
|
+
def get_specs_by_platform(specs)
|
174
|
+
specs_by_platform = {}
|
175
|
+
@platforms.each do |platform|
|
176
|
+
specs_by_platform[platform.name] = specs.select { |spec| spec.supported_on_platform?(platform) }
|
177
|
+
|
178
|
+
next if !@include_all_subspecs && !@include_default_subspecs
|
179
|
+
|
180
|
+
# Include the subspecs of all the specs if any
|
181
|
+
if @include_all_subspecs
|
182
|
+
specs.each do |spec|
|
183
|
+
specs_by_platform[platform.name] += spec.recursive_subspecs.reject(&:non_library_specification?).select { |subspec| subspec.supported_on_platform?(platform) }
|
184
|
+
end
|
185
|
+
elsif @include_default_subspecs
|
186
|
+
specs.each do |spec|
|
187
|
+
spec.default_subspecs.each do |subspec_name|
|
188
|
+
specs_by_platform[platform.name].push(spec.subspec_by_name("#{spec.name}/#{subspec_name}"))
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
# Let's remove any duplicated specs
|
194
|
+
specs_by_platform[platform.name].uniq!(&:name)
|
195
|
+
end
|
196
|
+
specs_by_platform
|
197
|
+
end
|
198
|
+
|
199
|
+
def podfile(specs_by_platform)
|
200
|
+
ps = @platforms
|
201
|
+
|
202
|
+
Pod::Podfile.new do
|
203
|
+
install! 'cocoapods', integrate_targets: false
|
204
|
+
use_frameworks!
|
205
|
+
|
206
|
+
ps.each do |p|
|
207
|
+
next if specs_by_platform[p.name].empty?
|
208
|
+
|
209
|
+
platform_version = specs_by_platform[p.name].map { |spec| Pod::Version.new(spec.deployment_target(p.name) || "0") }.max
|
210
|
+
|
211
|
+
target "Target_for_#{p.name}" do
|
212
|
+
platform p.name, platform_version
|
213
|
+
specs_by_platform[p.name].each { |spec| pod spec.name, spec.version }
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def generate_podfile_file(specs_by_platform, path)
|
220
|
+
podfile = "install! 'cocoapods', integrate_targets: false\n"
|
221
|
+
podfile += "use_frameworks!\n"
|
222
|
+
|
223
|
+
@platforms.each do |platform|
|
224
|
+
next if specs_by_platform[platform.name].empty?
|
225
|
+
|
226
|
+
platform_version = specs_by_platform[platform.name].map { |spec| Pod::Version.new(spec.deployment_target(platform.name) || "0") }
|
227
|
+
platform_version = platform_version.max
|
228
|
+
|
229
|
+
podfile += "\ntarget 'Target_for_#{platform.name}' do\n"
|
230
|
+
podfile += "\tplatform :#{platform.name}, '#{platform_version}'\n"
|
231
|
+
specs_by_platform[platform.name].each { |spec| podfile += "\tpod '#{spec.name}', '#{spec.version}'\n" }
|
232
|
+
podfile += "end\n"
|
233
|
+
end
|
234
|
+
|
235
|
+
podfile_pathname = Pathname.new(path)
|
236
|
+
podfile_pathname.dirname.mkpath
|
237
|
+
podfile_pathname.write(podfile)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-podfile-generator/command/podfile'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module CocoapodsPodfileGenerator
|
2
|
+
VERSION = "0.4.1"
|
3
|
+
SUMMARY = "A Cocoapods plugin to generate a Podfile file with the pods provided."
|
4
|
+
DESCRIPTION = <<-DESC
|
5
|
+
A Cocoapods plugin that helps you generate a Podfile file with the pods provided.
|
6
|
+
|
7
|
+
The plugin has the following features that will try to make your life easier when creating a Podfile:
|
8
|
+
|
9
|
+
* Generate a target per each platform supported by the pods provided. You can control which platforms to support
|
10
|
+
|
11
|
+
* Calculate the best minimum supported version for each platform
|
12
|
+
|
13
|
+
* Generate the Podfile just with the pods provided or it can add for you the subspecs or dependecies needed for each pod provided
|
14
|
+
DESC
|
15
|
+
|
16
|
+
# CLAide Arguments
|
17
|
+
POD_ARGUMENT_NAME = "POD_NAME:POD_VERSION"
|
18
|
+
|
19
|
+
# CLAide Flags
|
20
|
+
REGEX_FLAG_NAME = "regex"
|
21
|
+
INCLUDE_DEPENDENCIES_FLAG_NAME = "include-dependencies"
|
22
|
+
INCLUDE_DEFAULT_SUBSPECS_FLAG_NAME = "include-default-subspecs"
|
23
|
+
INCLUDE_ALL_SUBSPECS_FLAG_NAME = "include-all-subspecs"
|
24
|
+
INCLUDE_ANALYZE_FLAG_NAME = "include-analyze"
|
25
|
+
|
26
|
+
# CLAide Options
|
27
|
+
FILE_OPTION_NAME = "file"
|
28
|
+
PLATFORMS_OPTION_NAME = "platforms"
|
29
|
+
OUTPUT_OPTION_NAME = "output"
|
30
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-podfile-generator/version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'cocoapods-podfile-generator/command'
|
@@ -0,0 +1 @@
|
|
1
|
+
FBSDKShareKit:
|
@@ -0,0 +1 @@
|
|
1
|
+
NonExistingPod:10.0.0
|
data/spec/Pods.txt
ADDED
data/spec/TextFile
ADDED
@@ -0,0 +1,281 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
require 'cocoapods-podfile-generator/version.rb'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
PODS = {
|
6
|
+
"Firebase": "10.0.0",
|
7
|
+
"FBSDKCoreKit": "15.0.0",
|
8
|
+
}
|
9
|
+
|
10
|
+
describe Command::Podfile do
|
11
|
+
describe 'CLAide' do
|
12
|
+
it 'registers it self' do
|
13
|
+
Command.parse(%w{ podfile }).should.be.instance_of Command::Podfile
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "Validate the command" do
|
17
|
+
it "is well-formed" do
|
18
|
+
lambda { Command.parse(%W{ podfile #{PODS.keys.first}:#{PODS.values.first} }).validate! }
|
19
|
+
.should.not.raise()
|
20
|
+
end
|
21
|
+
|
22
|
+
it "parses multiple Pod arguments" do
|
23
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
24
|
+
lambda { Command.parse(["podfile", *pod_args]).validate! }
|
25
|
+
.should.not.raise()
|
26
|
+
end
|
27
|
+
|
28
|
+
it "fails when no pods are given" do
|
29
|
+
lambda { Command.parse(%W{ podfile }).validate! }
|
30
|
+
.should.raise(CLAide::Help)
|
31
|
+
.message.should.match(/You must give a Pod argument/)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "fails when a bad Pod argument is given" do
|
35
|
+
lambda { Command.parse(%W{ podfile #{PODS.keys.first}:#{PODS.values.first} #{PODS.keys.last}: }).validate! }
|
36
|
+
.should.raise(CLAide::Help)
|
37
|
+
.message.should.match(/There was a problem parsing the argument/)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "fails when a Pod as an argument does not exist" do
|
41
|
+
lambda { Command.parse(%W{ podfile NonExistingPod:10.0.0 }).validate! }
|
42
|
+
.should.raise(PodfileGeneratorInformative)
|
43
|
+
.message.should.match(/There was a problem/)
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "Validate text files" do
|
47
|
+
it "fails when the text file given does not exist" do
|
48
|
+
lambda { Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Non_existing_file.txt }).validate! }
|
49
|
+
.should.raise(CLAide::Help)
|
50
|
+
.message.should.match(/The file was not found/)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "parses a text file correctly" do
|
54
|
+
lambda { Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt }).validate! }
|
55
|
+
.should.not.raise()
|
56
|
+
end
|
57
|
+
|
58
|
+
it "fails when there's a bad line to parse in a text file" do
|
59
|
+
lambda { Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Bad_Pods_Format.txt }).validate! }
|
60
|
+
.should.raise(CLAide::Help)
|
61
|
+
.message.should.match(/There was a problem parsing/)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "fails when a text file does not have the .txt extension" do
|
65
|
+
lambda { Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/TextFile }).validate! }
|
66
|
+
.should.raise(CLAide::Help)
|
67
|
+
.message.should.match(/should have a .txt extension./)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "fails when a Pod in a text file does not exist" do
|
71
|
+
lambda { Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Non_Existing_Pod.txt }).validate! }
|
72
|
+
.should.raise(PodfileGeneratorInformative)
|
73
|
+
.message.should.match(/There was a problem/)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "Test using only Pods as args" do
|
79
|
+
require 'pathname'
|
80
|
+
|
81
|
+
before do
|
82
|
+
@default_podfile_pathname = Pathname.new("Podfile")
|
83
|
+
@default_podfile_pathname.delete if @default_podfile_pathname.exist?
|
84
|
+
@podfile_pathname = Pathname.new("spec/test/Podfile")
|
85
|
+
@podfile_pathname.delete if @podfile_pathname.exist?
|
86
|
+
end
|
87
|
+
|
88
|
+
it "generates the Podfile with one argument at the default path" do
|
89
|
+
podfile = Command.parse(%W{ podfile #{PODS.keys.first}:#{PODS.values.first} })
|
90
|
+
podfile.validate!
|
91
|
+
podfile.run
|
92
|
+
@default_podfile_pathname.exist?.should.be.true?
|
93
|
+
@default_podfile_pathname.empty?.should.be.false?
|
94
|
+
end
|
95
|
+
|
96
|
+
it "generates the Podfile with multiple arguments at the default path" do
|
97
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
98
|
+
podfile = Command.parse(["podfile", *pod_args])
|
99
|
+
podfile.validate!
|
100
|
+
podfile.run
|
101
|
+
@default_podfile_pathname.exist?.should.be.true?
|
102
|
+
@default_podfile_pathname.empty?.should.be.false?
|
103
|
+
end
|
104
|
+
|
105
|
+
it "generates the Podfile with one argument at a custom path" do
|
106
|
+
podfile = Command.parse(%W{ podfile #{PODS.keys.first}:#{PODS.values.first} --#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname} })
|
107
|
+
podfile.validate!
|
108
|
+
podfile.run
|
109
|
+
@podfile_pathname.exist?.should.be.true?
|
110
|
+
@podfile_pathname.empty?.should.be.false?
|
111
|
+
end
|
112
|
+
|
113
|
+
it "generates the Podfile with multiple arguments at a custom path" do
|
114
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
115
|
+
podfile = Command.parse(["podfile", *pod_args, "--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"])
|
116
|
+
podfile.validate!
|
117
|
+
podfile.run
|
118
|
+
@podfile_pathname.exist?.should.be.true?
|
119
|
+
@podfile_pathname.empty?.should.be.false?
|
120
|
+
end
|
121
|
+
|
122
|
+
it "generates the Podfile from a text file at the default path" do
|
123
|
+
podfile = Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt })
|
124
|
+
podfile.validate!
|
125
|
+
podfile.run
|
126
|
+
@default_podfile_pathname.exist?.should.be.true?
|
127
|
+
@default_podfile_pathname.empty?.should.be.false?
|
128
|
+
end
|
129
|
+
|
130
|
+
it "generates the Podfile from a text file at a custom path" do
|
131
|
+
podfile = Command.parse(%W{ podfile --#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt --#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname} })
|
132
|
+
podfile.validate!
|
133
|
+
podfile.run
|
134
|
+
@podfile_pathname.exist?.should.be.true?
|
135
|
+
@podfile_pathname.empty?.should.be.false?
|
136
|
+
end
|
137
|
+
|
138
|
+
it "generates the Podfile from multiple arguments and a text file at the default path" do
|
139
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
140
|
+
podfile = Command.parse([
|
141
|
+
"podfile",
|
142
|
+
*pod_args,
|
143
|
+
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt"
|
144
|
+
])
|
145
|
+
podfile.validate!
|
146
|
+
podfile.run
|
147
|
+
@default_podfile_pathname.exist?.should.be.true?
|
148
|
+
@default_podfile_pathname.empty?.should.be.false?
|
149
|
+
end
|
150
|
+
|
151
|
+
it "generates the Podfile from multiple arguments and a text file at a custom path" do
|
152
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
153
|
+
podfile = Command.parse([
|
154
|
+
"podfile",
|
155
|
+
*pod_args,
|
156
|
+
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt",
|
157
|
+
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"
|
158
|
+
])
|
159
|
+
podfile.validate!
|
160
|
+
podfile.run
|
161
|
+
@podfile_pathname.exist?.should.be.true?
|
162
|
+
@podfile_pathname.empty?.should.be.false?
|
163
|
+
end
|
164
|
+
|
165
|
+
it "generates the Podfile including the default subspecs" do
|
166
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
167
|
+
podfile = Command.parse([
|
168
|
+
"podfile",
|
169
|
+
*pod_args,
|
170
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_DEFAULT_SUBSPECS_FLAG_NAME}",
|
171
|
+
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt",
|
172
|
+
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"
|
173
|
+
])
|
174
|
+
podfile.validate!
|
175
|
+
podfile.run
|
176
|
+
@podfile_pathname.exist?.should.be.true?
|
177
|
+
@podfile_pathname.empty?.should.be.false?
|
178
|
+
end
|
179
|
+
|
180
|
+
it "generates the Podfile including all the subspecs" do
|
181
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
182
|
+
podfile = Command.parse([
|
183
|
+
"podfile",
|
184
|
+
*pod_args,
|
185
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_ALL_SUBSPECS_FLAG_NAME}",
|
186
|
+
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt",
|
187
|
+
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"
|
188
|
+
])
|
189
|
+
podfile.validate!
|
190
|
+
podfile.run
|
191
|
+
@podfile_pathname.exist?.should.be.true?
|
192
|
+
@podfile_pathname.empty?.should.be.false?
|
193
|
+
end
|
194
|
+
|
195
|
+
it "generates the Podfile including all the subspecs even if the include default and all the subspecs flags are passed" do
|
196
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
197
|
+
podfile = Command.parse([
|
198
|
+
"podfile",
|
199
|
+
*pod_args,
|
200
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_DEFAULT_SUBSPECS_FLAG_NAME}",
|
201
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_ALL_SUBSPECS_FLAG_NAME}",
|
202
|
+
"--#{CocoapodsPodfileGenerator::FILE_OPTION_NAME}=./spec/Pods.txt",
|
203
|
+
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"])
|
204
|
+
podfile.validate!
|
205
|
+
podfile.run
|
206
|
+
@podfile_pathname.exist?.should.be.true?
|
207
|
+
@podfile_pathname.empty?.should.be.false?
|
208
|
+
end
|
209
|
+
|
210
|
+
it "generates the Podfile including the specs dependencies" do
|
211
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
212
|
+
podfile = Command.parse([
|
213
|
+
"podfile",
|
214
|
+
*pod_args,
|
215
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_DEPENDENCIES_FLAG_NAME}",
|
216
|
+
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"])
|
217
|
+
podfile.validate!
|
218
|
+
podfile.run
|
219
|
+
@podfile_pathname.exist?.should.be.true?
|
220
|
+
@podfile_pathname.empty?.should.be.false?
|
221
|
+
end
|
222
|
+
|
223
|
+
it "generates the Podfile including the subspecs dependencies" do
|
224
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
225
|
+
podfile = Command.parse([
|
226
|
+
"podfile",
|
227
|
+
*pod_args,
|
228
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_DEPENDENCIES_FLAG_NAME}",
|
229
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_DEFAULT_SUBSPECS_FLAG_NAME}",
|
230
|
+
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"])
|
231
|
+
podfile.validate!
|
232
|
+
podfile.run
|
233
|
+
@podfile_pathname.exist?.should.be.true?
|
234
|
+
@podfile_pathname.empty?.should.be.false?
|
235
|
+
end
|
236
|
+
|
237
|
+
it "generates the Podfile including the dependencies got by the analysis made by cocoapods" do
|
238
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
239
|
+
podfile = Command.parse([
|
240
|
+
"podfile",
|
241
|
+
*pod_args,
|
242
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_ANALYZE_FLAG_NAME}",
|
243
|
+
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"])
|
244
|
+
podfile.validate!
|
245
|
+
podfile.run
|
246
|
+
@podfile_pathname.exist?.should.be.true?
|
247
|
+
@podfile_pathname.empty?.should.be.false?
|
248
|
+
end
|
249
|
+
|
250
|
+
it "generates the Podfile including all the subspecs and the dependencies got by the analysis made by cocoapods" do
|
251
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
252
|
+
podfile = Command.parse([
|
253
|
+
"podfile",
|
254
|
+
*pod_args,
|
255
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_ALL_SUBSPECS_FLAG_NAME}",
|
256
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_ANALYZE_FLAG_NAME}",
|
257
|
+
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"])
|
258
|
+
podfile.validate!
|
259
|
+
podfile.run
|
260
|
+
@podfile_pathname.exist?.should.be.true?
|
261
|
+
@podfile_pathname.empty?.should.be.false?
|
262
|
+
end
|
263
|
+
|
264
|
+
it "generates the Podfile including all the subspecs and the dependencies got by the analysis made by cocoapods just for iOS and tvOS platform" do
|
265
|
+
pod_args = PODS.keys.map { |key| "#{key}:#{PODS[key]}" }
|
266
|
+
podfile = Command.parse([
|
267
|
+
"podfile",
|
268
|
+
*pod_args,
|
269
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_ALL_SUBSPECS_FLAG_NAME}",
|
270
|
+
"--#{CocoapodsPodfileGenerator::INCLUDE_ANALYZE_FLAG_NAME}",
|
271
|
+
"--#{CocoapodsPodfileGenerator::PLATFORMS_OPTION_NAME}=ios,tvos",
|
272
|
+
"--#{CocoapodsPodfileGenerator::OUTPUT_OPTION_NAME}=#{@podfile_pathname}"])
|
273
|
+
podfile.validate!
|
274
|
+
podfile.run
|
275
|
+
@podfile_pathname.exist?.should.be.true?
|
276
|
+
@podfile_pathname.empty?.should.be.false?
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
3
|
+
$:.unshift((ROOT + 'lib').to_s)
|
4
|
+
$:.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'bacon'
|
8
|
+
require 'mocha-on-bacon'
|
9
|
+
require 'pretty_bacon'
|
10
|
+
require 'pathname'
|
11
|
+
require 'cocoapods'
|
12
|
+
|
13
|
+
Mocha::Configuration.prevent(:stubbing_non_existent_method)
|
14
|
+
|
15
|
+
require 'cocoapods_plugin'
|
16
|
+
|
17
|
+
#-----------------------------------------------------------------------------#
|
18
|
+
|
19
|
+
module Pod
|
20
|
+
|
21
|
+
# Disable the wrapping so the output is deterministic in the tests.
|
22
|
+
#
|
23
|
+
UI.disable_wrap = true
|
24
|
+
|
25
|
+
# Redirects the messages to an internal store.
|
26
|
+
#
|
27
|
+
module UI
|
28
|
+
@output = ''
|
29
|
+
@warnings = ''
|
30
|
+
|
31
|
+
class << self
|
32
|
+
attr_accessor :output
|
33
|
+
attr_accessor :warnings
|
34
|
+
|
35
|
+
def puts(message = '')
|
36
|
+
@output << "#{message}\n"
|
37
|
+
end
|
38
|
+
|
39
|
+
def warn(message = '', actions = [])
|
40
|
+
@warnings << "#{message}\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
def print(message)
|
44
|
+
@output << message
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#-----------------------------------------------------------------------------#
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cocoapods-podfile-generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Israel Soto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-01-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: " A Cocoapods plugin that helps you generate a Podfile file with the
|
42
|
+
pods provided. \n \n The plugin has the following features that will try to
|
43
|
+
make your life easier when creating a Podfile:\n \n * Generate a target per
|
44
|
+
each platform supported by the pods provided. You can control which platforms to
|
45
|
+
support\n\n * Calculate the best minimum supported version for each platform\n
|
46
|
+
\ \n * Generate the Podfile just with the pods provided or it can add for you
|
47
|
+
the subspecs or dependecies needed for each pod provided\n"
|
48
|
+
email:
|
49
|
+
- israel.spgh@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- ".gitignore"
|
55
|
+
- Gemfile
|
56
|
+
- Gemfile.lock
|
57
|
+
- LICENSE
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- cocoapods-podfile-generator.gemspec
|
61
|
+
- lib/cocoapods-podfile-generator.rb
|
62
|
+
- lib/cocoapods-podfile-generator/command.rb
|
63
|
+
- lib/cocoapods-podfile-generator/command/podfile.rb
|
64
|
+
- lib/cocoapods-podfile-generator/podfilegeneratorinformative.rb
|
65
|
+
- lib/cocoapods-podfile-generator/version.rb
|
66
|
+
- lib/cocoapods_plugin.rb
|
67
|
+
- spec/Bad_Pods_Format.txt
|
68
|
+
- spec/Non_Existing_Pod.txt
|
69
|
+
- spec/Pods.txt
|
70
|
+
- spec/TextFile
|
71
|
+
- spec/command/podfile_spec.rb
|
72
|
+
- spec/spec_helper.rb
|
73
|
+
homepage: https://github.com/EXAMPLE/cocoapods-podfile-generator
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubygems_version: 3.3.26
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: A Cocoapods plugin to generate a Podfile file with the pods provided.
|
96
|
+
test_files:
|
97
|
+
- spec/Bad_Pods_Format.txt
|
98
|
+
- spec/Non_Existing_Pod.txt
|
99
|
+
- spec/Pods.txt
|
100
|
+
- spec/TextFile
|
101
|
+
- spec/command/podfile_spec.rb
|
102
|
+
- spec/spec_helper.rb
|