cocoapods 0.36.0.beta.1 → 0.36.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +67 -5
- data/bin/pod +11 -10
- data/bin/sandbox-pod +1 -1
- data/lib/cocoapods.rb +1 -1
- data/lib/cocoapods/command/lib.rb +0 -1
- data/lib/cocoapods/command/outdated.rb +1 -3
- data/lib/cocoapods/command/repo.rb +5 -267
- data/lib/cocoapods/command/repo/add.rb +53 -0
- data/lib/cocoapods/command/repo/lint.rb +73 -0
- data/lib/cocoapods/command/repo/list.rb +95 -0
- data/lib/cocoapods/command/repo/remove.rb +36 -0
- data/lib/cocoapods/command/repo/update.rb +27 -0
- data/lib/cocoapods/command/setup.rb +1 -1
- data/lib/cocoapods/command/spec.rb +5 -546
- data/lib/cocoapods/command/spec/cat.rb +51 -0
- data/lib/cocoapods/command/spec/create.rb +279 -0
- data/lib/cocoapods/command/spec/edit.rb +87 -0
- data/lib/cocoapods/command/spec/lint.rb +105 -0
- data/lib/cocoapods/command/spec/which.rb +43 -0
- data/lib/cocoapods/downloader.rb +0 -2
- data/lib/cocoapods/external_sources/podspec_source.rb +13 -3
- data/lib/cocoapods/gem_version.rb +1 -1
- data/lib/cocoapods/generator/copy_resources_script.rb +22 -11
- data/lib/cocoapods/generator/embed_frameworks_script.rb +3 -0
- data/lib/cocoapods/generator/header.rb +3 -3
- data/lib/cocoapods/generator/target_environment_header.rb +1 -1
- data/lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb +7 -7
- data/lib/cocoapods/generator/xcconfig/public_pod_xcconfig.rb +1 -1
- data/lib/cocoapods/hooks_manager.rb +4 -4
- data/lib/cocoapods/installer.rb +17 -4
- data/lib/cocoapods/installer/analyzer.rb +19 -12
- data/lib/cocoapods/installer/pod_source_installer.rb +1 -1
- data/lib/cocoapods/installer/target_installer.rb +1 -1
- data/lib/cocoapods/installer/target_installer/aggregate_target_installer.rb +9 -8
- data/lib/cocoapods/installer/user_project_integrator/target_integrator.rb +2 -2
- data/lib/cocoapods/sandbox.rb +0 -2
- data/lib/cocoapods/sandbox/headers_store.rb +1 -1
- data/lib/cocoapods/sources_manager.rb +8 -7
- data/lib/cocoapods/target.rb +1 -1
- data/lib/cocoapods/target/aggregate_target.rb +1 -0
- data/lib/cocoapods/target/pod_target.rb +1 -1
- data/lib/cocoapods/user_interface/error_report.rb +10 -0
- data/lib/cocoapods/validator.rb +15 -4
- metadata +17 -6
@@ -0,0 +1,51 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class Spec < Command
|
4
|
+
class Cat < Spec
|
5
|
+
self.summary = 'Prints a spec file.'
|
6
|
+
|
7
|
+
self.description = <<-DESC
|
8
|
+
Prints the content of the podspec(s) whose name matches `QUERY` to standard output.
|
9
|
+
DESC
|
10
|
+
|
11
|
+
self.arguments = [
|
12
|
+
CLAide::Argument.new('QUERY', false),
|
13
|
+
]
|
14
|
+
|
15
|
+
def self.options
|
16
|
+
[
|
17
|
+
['--regex', 'Interpret the `QUERY` as a regular expression'],
|
18
|
+
['--show-all', 'Pick from all versions of the given podspec'],
|
19
|
+
].concat(super)
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(argv)
|
23
|
+
@use_regex = argv.flag?('regex')
|
24
|
+
@show_all = argv.flag?('show-all')
|
25
|
+
@query = argv.shift_argument
|
26
|
+
@query = @query.gsub('.podspec', '') unless @query.nil?
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def validate!
|
31
|
+
super
|
32
|
+
help! 'A podspec name is required.' unless @query
|
33
|
+
validate_regex!(@query) if @use_regex
|
34
|
+
end
|
35
|
+
|
36
|
+
def run
|
37
|
+
query = @use_regex ? @query : Regexp.escape(@query)
|
38
|
+
filepath = if @show_all
|
39
|
+
specs = get_path_of_spec(query, @show_all).split(/\n/)
|
40
|
+
index = choose_from_array(specs, "Which spec would you like to print [1-#{ specs.count }]? ")
|
41
|
+
specs[index]
|
42
|
+
else
|
43
|
+
get_path_of_spec(query)
|
44
|
+
end
|
45
|
+
|
46
|
+
UI.puts File.read(filepath)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,279 @@
|
|
1
|
+
|
2
|
+
module Pod
|
3
|
+
class Command
|
4
|
+
class Spec < Command
|
5
|
+
class Create < Spec
|
6
|
+
self.summary = 'Create spec file stub.'
|
7
|
+
|
8
|
+
self.description = <<-DESC
|
9
|
+
Creates a PodSpec, in the current working dir, called `NAME.podspec'.
|
10
|
+
If a GitHub url is passed the spec is prepopulated.
|
11
|
+
DESC
|
12
|
+
|
13
|
+
self.arguments = [
|
14
|
+
CLAide::Argument.new(%w(NAME https://github.com/USER/REPO), false),
|
15
|
+
]
|
16
|
+
|
17
|
+
def initialize(argv)
|
18
|
+
@name_or_url, @url = argv.shift_argument, argv.shift_argument
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
def validate!
|
23
|
+
super
|
24
|
+
help! 'A pod name or repo URL is required.' unless @name_or_url
|
25
|
+
end
|
26
|
+
|
27
|
+
def run
|
28
|
+
if repo_id_match = (@url || @name_or_url).match(%r{github.com/([^/\.]*\/[^/\.]*)\.*})
|
29
|
+
repo_id = repo_id_match[1]
|
30
|
+
data = github_data_for_template(repo_id)
|
31
|
+
data[:name] = @name_or_url if @url
|
32
|
+
UI.puts semantic_versioning_notice(repo_id, data[:name]) if data[:version] == '0.0.1'
|
33
|
+
else
|
34
|
+
data = default_data_for_template(@name_or_url)
|
35
|
+
end
|
36
|
+
|
37
|
+
spec = spec_template(data)
|
38
|
+
(Pathname.pwd + "#{data[:name]}.podspec").open('w') { |f| f << spec }
|
39
|
+
UI.puts "\nSpecification created at #{data[:name]}.podspec".green
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
#--------------------------------------#
|
45
|
+
|
46
|
+
# Templates and GitHub information retrieval for spec create
|
47
|
+
#
|
48
|
+
# @todo It would be nice to have a template class that accepts options
|
49
|
+
# and uses the default ones if not provided.
|
50
|
+
# @todo The template is outdated.
|
51
|
+
|
52
|
+
def default_data_for_template(name)
|
53
|
+
data = {}
|
54
|
+
data[:name] = name
|
55
|
+
data[:version] = '0.0.1'
|
56
|
+
data[:summary] = "A short description of #{name}."
|
57
|
+
data[:homepage] = "http://EXAMPLE/#{name}"
|
58
|
+
data[:author_name] = `git config --get user.name`.strip
|
59
|
+
data[:author_email] = `git config --get user.email`.strip
|
60
|
+
data[:source_url] = "http://EXAMPLE/#{name}.git"
|
61
|
+
data[:ref_type] = ':tag'
|
62
|
+
data[:ref] = '0.0.1'
|
63
|
+
data
|
64
|
+
end
|
65
|
+
|
66
|
+
def github_data_for_template(repo_id)
|
67
|
+
repo = GitHub.repo(repo_id)
|
68
|
+
raise Informative, "Unable to fetch data for `#{repo_id}`" unless repo
|
69
|
+
user = GitHub.user(repo['owner']['login'])
|
70
|
+
raise Informative, "Unable to fetch data for `#{repo['owner']['login']}`" unless user
|
71
|
+
data = {}
|
72
|
+
|
73
|
+
data[:name] = repo['name']
|
74
|
+
data[:summary] = (repo['description'] || '').gsub(/["]/, '\"')
|
75
|
+
data[:homepage] = (repo['homepage'] && !repo['homepage'].empty?) ? repo['homepage'] : repo['html_url']
|
76
|
+
data[:author_name] = user['name'] || user['login']
|
77
|
+
data[:author_email] = user['email'] || 'email@address.com'
|
78
|
+
data[:source_url] = repo['clone_url']
|
79
|
+
|
80
|
+
data.merge suggested_ref_and_version(repo)
|
81
|
+
end
|
82
|
+
|
83
|
+
def suggested_ref_and_version(repo)
|
84
|
+
tags = GitHub.tags(repo['html_url']).map { |tag| tag['name'] }
|
85
|
+
versions_tags = {}
|
86
|
+
tags.each do |tag|
|
87
|
+
clean_tag = tag.gsub(/^v(er)? ?/, '')
|
88
|
+
versions_tags[Gem::Version.new(clean_tag)] = tag if Gem::Version.correct?(clean_tag)
|
89
|
+
end
|
90
|
+
version = versions_tags.keys.sort.last || '0.0.1'
|
91
|
+
data = { :version => version }
|
92
|
+
if version == '0.0.1'
|
93
|
+
branches = GitHub.branches(repo['html_url'])
|
94
|
+
master_name = repo['master_branch'] || 'master'
|
95
|
+
master = branches.find { |branch| branch['name'] == master_name }
|
96
|
+
raise Informative, "Unable to find any commits on the master branch for the repository `#{repo['html_url']}`" unless master
|
97
|
+
data[:ref_type] = ':commit'
|
98
|
+
data[:ref] = master['commit']['sha']
|
99
|
+
else
|
100
|
+
data[:ref_type] = ':tag'
|
101
|
+
data[:ref] = versions_tags[version]
|
102
|
+
end
|
103
|
+
data
|
104
|
+
end
|
105
|
+
|
106
|
+
def spec_template(data)
|
107
|
+
<<-SPEC
|
108
|
+
#
|
109
|
+
# Be sure to run `pod spec lint #{data[:name]}.podspec' to ensure this is a
|
110
|
+
# valid spec and to remove all comments including this before submitting the spec.
|
111
|
+
#
|
112
|
+
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
|
113
|
+
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
|
114
|
+
#
|
115
|
+
|
116
|
+
Pod::Spec.new do |s|
|
117
|
+
|
118
|
+
# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
|
119
|
+
#
|
120
|
+
# These will help people to find your library, and whilst it
|
121
|
+
# can feel like a chore to fill in it's definitely to your advantage. The
|
122
|
+
# summary should be tweet-length, and the description more in depth.
|
123
|
+
#
|
124
|
+
|
125
|
+
s.name = "#{data[:name]}"
|
126
|
+
s.version = "#{data[:version]}"
|
127
|
+
s.summary = "#{data[:summary]}"
|
128
|
+
|
129
|
+
s.description = <<-DESC
|
130
|
+
A longer description of #{data[:name]} in Markdown format.
|
131
|
+
|
132
|
+
* Think: Why did you write this? What is the focus? What does it do?
|
133
|
+
* CocoaPods will be using this to generate tags, and improve search results.
|
134
|
+
* Try to keep it short, snappy and to the point.
|
135
|
+
* Finally, don't worry about the indent, CocoaPods strips it!
|
136
|
+
DESC
|
137
|
+
|
138
|
+
s.homepage = "#{data[:homepage]}"
|
139
|
+
# s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
|
140
|
+
|
141
|
+
|
142
|
+
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
|
143
|
+
#
|
144
|
+
# Licensing your code is important. See http://choosealicense.com for more info.
|
145
|
+
# CocoaPods will detect a license file if there is a named LICENSE*
|
146
|
+
# Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
|
147
|
+
#
|
148
|
+
|
149
|
+
s.license = "MIT (example)"
|
150
|
+
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
|
151
|
+
|
152
|
+
|
153
|
+
# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
|
154
|
+
#
|
155
|
+
# Specify the authors of the library, with email addresses. Email addresses
|
156
|
+
# of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
|
157
|
+
# accepts just a name if you'd rather not provide an email address.
|
158
|
+
#
|
159
|
+
# Specify a social_media_url where others can refer to, for example a twitter
|
160
|
+
# profile URL.
|
161
|
+
#
|
162
|
+
|
163
|
+
s.author = { "#{data[:author_name]}" => "#{data[:author_email]}" }
|
164
|
+
# Or just: s.author = "#{data[:author_name]}"
|
165
|
+
# s.authors = { "#{data[:author_name]}" => "#{data[:author_email]}" }
|
166
|
+
# s.social_media_url = "http://twitter.com/#{data[:author_name]}"
|
167
|
+
|
168
|
+
# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
|
169
|
+
#
|
170
|
+
# If this Pod runs only on iOS or OS X, then specify the platform and
|
171
|
+
# the deployment target. You can optionally include the target after the platform.
|
172
|
+
#
|
173
|
+
|
174
|
+
# s.platform = :ios
|
175
|
+
# s.platform = :ios, "5.0"
|
176
|
+
|
177
|
+
# When using multiple platforms
|
178
|
+
# s.ios.deployment_target = "5.0"
|
179
|
+
# s.osx.deployment_target = "10.7"
|
180
|
+
|
181
|
+
|
182
|
+
# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
|
183
|
+
#
|
184
|
+
# Specify the location from where the source should be retrieved.
|
185
|
+
# Supports git, hg, bzr, svn and HTTP.
|
186
|
+
#
|
187
|
+
|
188
|
+
s.source = { :git => "#{data[:source_url]}", #{data[:ref_type]} => "#{data[:ref]}" }
|
189
|
+
|
190
|
+
|
191
|
+
# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
|
192
|
+
#
|
193
|
+
# CocoaPods is smart about how it includes source code. For source files
|
194
|
+
# giving a folder will include any swift, h, m, mm, c & cpp files.
|
195
|
+
# For header files it will include any header in the folder.
|
196
|
+
# Not including the public_header_files will make all headers public.
|
197
|
+
#
|
198
|
+
|
199
|
+
s.source_files = "Classes", "Classes/**/*.{h,m}"
|
200
|
+
s.exclude_files = "Classes/Exclude"
|
201
|
+
|
202
|
+
# s.public_header_files = "Classes/**/*.h"
|
203
|
+
|
204
|
+
|
205
|
+
# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
|
206
|
+
#
|
207
|
+
# A list of resources included with the Pod. These are copied into the
|
208
|
+
# target bundle with a build phase script. Anything else will be cleaned.
|
209
|
+
# You can preserve files from being cleaned, please don't preserve
|
210
|
+
# non-essential files like tests, examples and documentation.
|
211
|
+
#
|
212
|
+
|
213
|
+
# s.resource = "icon.png"
|
214
|
+
# s.resources = "Resources/*.png"
|
215
|
+
|
216
|
+
# s.preserve_paths = "FilesToSave", "MoreFilesToSave"
|
217
|
+
|
218
|
+
|
219
|
+
# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
|
220
|
+
#
|
221
|
+
# Link your library with frameworks, or libraries. Libraries do not include
|
222
|
+
# the lib prefix of their name.
|
223
|
+
#
|
224
|
+
|
225
|
+
# s.framework = "SomeFramework"
|
226
|
+
# s.frameworks = "SomeFramework", "AnotherFramework"
|
227
|
+
|
228
|
+
# s.library = "iconv"
|
229
|
+
# s.libraries = "iconv", "xml2"
|
230
|
+
|
231
|
+
|
232
|
+
# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
|
233
|
+
#
|
234
|
+
# If your library depends on compiler flags you can set them in the xcconfig hash
|
235
|
+
# where they will only apply to your library. If you depend on other Podspecs
|
236
|
+
# you can include multiple dependencies to ensure it works.
|
237
|
+
|
238
|
+
# s.requires_arc = true
|
239
|
+
|
240
|
+
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
|
241
|
+
# s.dependency "JSONKit", "~> 1.4"
|
242
|
+
|
243
|
+
end
|
244
|
+
SPEC
|
245
|
+
end
|
246
|
+
|
247
|
+
def semantic_versioning_notice(repo_id, repo)
|
248
|
+
<<-EOS
|
249
|
+
|
250
|
+
#{'――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'.reversed}
|
251
|
+
|
252
|
+
I’ve recently added [#{repo}](https://github.com/CocoaPods/Specs/tree/master/#{repo}) to the [CocoaPods](https://github.com/CocoaPods/CocoaPods) package manager repo.
|
253
|
+
|
254
|
+
CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.
|
255
|
+
|
256
|
+
However, #{repo} doesn't have any version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.
|
257
|
+
|
258
|
+
[Semantic version](http://semver.org) tags (instead of plain commit hashes/revisions) allow for [resolution of cross-dependencies](https://github.com/CocoaPods/Specs/wiki/Cross-dependencies-resolution-example).
|
259
|
+
|
260
|
+
In case you didn’t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:
|
261
|
+
|
262
|
+
```
|
263
|
+
$ git tag -a 1.0.0 -m "Tag release 1.0.0"
|
264
|
+
$ git push --tags
|
265
|
+
```
|
266
|
+
|
267
|
+
#{'――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'.reversed}
|
268
|
+
|
269
|
+
#{'[!] This repo does not appear to have semantic version tags.'.yellow}
|
270
|
+
|
271
|
+
After commiting the specification, consider opening a ticket with the template displayed above:
|
272
|
+
- link: https://github.com/#{repo_id}/issues/new
|
273
|
+
- title: Please add semantic version tags
|
274
|
+
EOS
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class Spec < Command
|
4
|
+
class Edit < Spec
|
5
|
+
self.summary = 'Edit a spec file.'
|
6
|
+
|
7
|
+
self.description = <<-DESC
|
8
|
+
Opens the podspec matching `QUERY` to be edited.
|
9
|
+
DESC
|
10
|
+
|
11
|
+
self.arguments = [
|
12
|
+
CLAide::Argument.new('QUERY', false),
|
13
|
+
]
|
14
|
+
|
15
|
+
def self.options
|
16
|
+
[
|
17
|
+
['--regex', 'Interpret the `QUERY` as a regular expression'],
|
18
|
+
['--show-all', 'Pick from all versions of the given podspec'],
|
19
|
+
].concat(super)
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(argv)
|
23
|
+
@use_regex = argv.flag?('regex')
|
24
|
+
@show_all = argv.flag?('show-all')
|
25
|
+
@query = argv.shift_argument
|
26
|
+
@query = @query.gsub('.podspec', '') unless @query.nil?
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def validate!
|
31
|
+
super
|
32
|
+
help! 'A podspec name is required.' unless @query
|
33
|
+
validate_regex!(@query) if @use_regex
|
34
|
+
end
|
35
|
+
|
36
|
+
def run
|
37
|
+
query = @use_regex ? @query : Regexp.escape(@query)
|
38
|
+
if @show_all
|
39
|
+
specs = get_path_of_spec(query, @show_all).split(/\n/)
|
40
|
+
message = "Which spec would you like to edit [1-#{specs.count}]? "
|
41
|
+
index = choose_from_array(specs, message)
|
42
|
+
filepath = specs[index]
|
43
|
+
else
|
44
|
+
filepath = get_path_of_spec(query)
|
45
|
+
end
|
46
|
+
|
47
|
+
exec_editor(filepath.to_s) if File.exist? filepath
|
48
|
+
raise Informative, "#{ filepath } doesn't exist."
|
49
|
+
end
|
50
|
+
|
51
|
+
# Thank you homebrew
|
52
|
+
def which(cmd)
|
53
|
+
dir = ENV['PATH'].split(':').find { |p| File.executable? File.join(p, cmd) }
|
54
|
+
Pathname.new(File.join(dir, cmd)) unless dir.nil?
|
55
|
+
end
|
56
|
+
|
57
|
+
def which_editor
|
58
|
+
editor = ENV['EDITOR']
|
59
|
+
# If an editor wasn't set, try to pick a sane default
|
60
|
+
return editor unless editor.nil?
|
61
|
+
|
62
|
+
# Find Sublime Text 2
|
63
|
+
return 'subl' if which 'subl'
|
64
|
+
# Find Textmate
|
65
|
+
return 'mate' if which 'mate'
|
66
|
+
# Find # BBEdit / TextWrangler
|
67
|
+
return 'edit' if which 'edit'
|
68
|
+
# Default to vim
|
69
|
+
return 'vim' if which 'vim'
|
70
|
+
|
71
|
+
raise Informative, "Failed to open editor. Set your 'EDITOR' environment variable."
|
72
|
+
end
|
73
|
+
|
74
|
+
def exec_editor(*args)
|
75
|
+
return if args.to_s.empty?
|
76
|
+
safe_exec(which_editor, *args)
|
77
|
+
end
|
78
|
+
|
79
|
+
def safe_exec(cmd, *args)
|
80
|
+
# This buys us proper argument quoting and evaluation
|
81
|
+
# of environment variables in the cmd parameter.
|
82
|
+
exec('/bin/sh', '-i', '-c', cmd + ' "$@"', '--', *args)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class Spec < Command
|
4
|
+
class Lint < Spec
|
5
|
+
self.summary = 'Validates a spec file.'
|
6
|
+
|
7
|
+
self.description = <<-DESC
|
8
|
+
Validates `NAME.podspec`. If a `DIRECTORY` is provided, it validates
|
9
|
+
the podspec files found, including subfolders. In case
|
10
|
+
the argument is omitted, it defaults to the current working dir.
|
11
|
+
DESC
|
12
|
+
|
13
|
+
self.arguments = [
|
14
|
+
CLAide::Argument.new(%w(NAME.podspec DIRECTORY http://PATH/NAME.podspec), false, true),
|
15
|
+
]
|
16
|
+
|
17
|
+
def self.options
|
18
|
+
[['--quick', 'Lint skips checks that would require to download and build the spec'],
|
19
|
+
['--allow-warnings', 'Lint validates even if warnings are present'],
|
20
|
+
['--subspec=NAME', 'Lint validates only the given subspec'],
|
21
|
+
['--no-subspecs', 'Lint skips validation of subspecs'],
|
22
|
+
['--no-clean', 'Lint leaves the build directory intact for inspection'],
|
23
|
+
['--use-frameworks', 'Lint uses frameworks to install the spec'],
|
24
|
+
['--sources=https://github.com/artsy/Specs', 'The sources from which to pull dependant pods ' \
|
25
|
+
'(defaults to https://github.com/CocoaPods/Specs.git). '\
|
26
|
+
'Multiple sources must be comma-delimited.']].concat(super)
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(argv)
|
30
|
+
@quick = argv.flag?('quick')
|
31
|
+
@allow_warnings = argv.flag?('allow-warnings')
|
32
|
+
@clean = argv.flag?('clean', true)
|
33
|
+
@subspecs = argv.flag?('subspecs', true)
|
34
|
+
@only_subspec = argv.option('subspec')
|
35
|
+
@use_frameworks = argv.flag?('use-frameworks')
|
36
|
+
@source_urls = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
|
37
|
+
@podspecs_paths = argv.arguments!
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
def run
|
42
|
+
UI.puts
|
43
|
+
invalid_count = 0
|
44
|
+
podspecs_to_lint.each do |podspec|
|
45
|
+
validator = Validator.new(podspec, @source_urls)
|
46
|
+
validator.quick = @quick
|
47
|
+
validator.no_clean = !@clean
|
48
|
+
validator.allow_warnings = @allow_warnings
|
49
|
+
validator.no_subspecs = !@subspecs || @only_subspec
|
50
|
+
validator.only_subspec = @only_subspec
|
51
|
+
validator.use_frameworks = @use_frameworks
|
52
|
+
validator.validate
|
53
|
+
invalid_count += 1 unless validator.validated?
|
54
|
+
|
55
|
+
unless @clean
|
56
|
+
UI.puts "Pods project available at `#{validator.validation_dir}/Pods/Pods.xcodeproj` for inspection."
|
57
|
+
UI.puts
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
count = podspecs_to_lint.count
|
62
|
+
UI.puts "Analyzed #{count} #{'podspec'.pluralize(count)}.\n\n"
|
63
|
+
if invalid_count == 0
|
64
|
+
lint_passed_message = count == 1 ? "#{podspecs_to_lint.first.basename} passed validation." : 'All the specs passed validation.'
|
65
|
+
UI.puts lint_passed_message.green << "\n\n"
|
66
|
+
else
|
67
|
+
raise Informative, count == 1 ? 'The spec did not pass validation.' : "#{invalid_count} out of #{count} specs failed validation."
|
68
|
+
end
|
69
|
+
podspecs_tmp_dir.rmtree if podspecs_tmp_dir.exist?
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def podspecs_to_lint
|
75
|
+
@podspecs_to_lint ||= begin
|
76
|
+
files = []
|
77
|
+
@podspecs_paths << '.' if @podspecs_paths.empty?
|
78
|
+
@podspecs_paths.each do |path|
|
79
|
+
if path =~ %r{https?://}
|
80
|
+
require 'open-uri'
|
81
|
+
output_path = podspecs_tmp_dir + File.basename(path)
|
82
|
+
output_path.dirname.mkpath
|
83
|
+
open(path) do |io|
|
84
|
+
output_path.open('w') { |f| f << io.read }
|
85
|
+
end
|
86
|
+
files << output_path
|
87
|
+
elsif (pathname = Pathname.new(path)).directory?
|
88
|
+
files += Pathname.glob(pathname + '**/*.podspec{.json,}')
|
89
|
+
raise Informative, 'No specs found in the current directory.' if files.empty?
|
90
|
+
else
|
91
|
+
files << (pathname = Pathname.new(path))
|
92
|
+
raise Informative, "Unable to find a spec named `#{path}'." unless pathname.exist? && path.include?('.podspec')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
files
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def podspecs_tmp_dir
|
100
|
+
Pathname(File.join(Pathname.new('/tmp').realpath, '/CocoaPods/Lint_podspec'))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|