cocoapods-tt 0.0.1
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 +7 -0
- data/lib/cocoapods-tt/command/native/install.rb +56 -0
- data/lib/cocoapods-tt/command/native/update.rb +157 -0
- data/lib/cocoapods-tt/command/tt/make.rb +92 -0
- data/lib/cocoapods-tt/command/tt.rb +115 -0
- data/lib/cocoapods-tt/command.rb +1 -0
- data/lib/cocoapods-tt/gem_version.rb +3 -0
- data/lib/cocoapods-tt/native/command.rb +185 -0
- data/lib/cocoapods-tt/native/config.rb +366 -0
- data/lib/cocoapods-tt/native/core_overrides.rb +1 -0
- data/lib/cocoapods-tt/native/downloader/cache.rb +322 -0
- data/lib/cocoapods-tt/native/downloader/request.rb +86 -0
- data/lib/cocoapods-tt/native/downloader/response.rb +16 -0
- data/lib/cocoapods-tt/native/downloader.rb +192 -0
- data/lib/cocoapods-tt/native/executable.rb +247 -0
- data/lib/cocoapods-tt/native/external_sources/abstract_external_source.rb +205 -0
- data/lib/cocoapods-tt/native/external_sources/downloader_source.rb +30 -0
- data/lib/cocoapods-tt/native/external_sources/path_source.rb +55 -0
- data/lib/cocoapods-tt/native/external_sources/podspec_source.rb +54 -0
- data/lib/cocoapods-tt/native/external_sources.rb +57 -0
- data/lib/cocoapods-tt/native/gem_version.rb +5 -0
- data/lib/cocoapods-tt/native/generator/acknowledgements/markdown.rb +44 -0
- data/lib/cocoapods-tt/native/generator/acknowledgements/plist.rb +94 -0
- data/lib/cocoapods-tt/native/generator/acknowledgements.rb +107 -0
- data/lib/cocoapods-tt/native/generator/app_target_helper.rb +363 -0
- data/lib/cocoapods-tt/native/generator/bridge_support.rb +22 -0
- data/lib/cocoapods-tt/native/generator/constant.rb +19 -0
- data/lib/cocoapods-tt/native/generator/copy_dsyms_script.rb +56 -0
- data/lib/cocoapods-tt/native/generator/copy_resources_script.rb +223 -0
- data/lib/cocoapods-tt/native/generator/copy_xcframework_script.rb +227 -0
- data/lib/cocoapods-tt/native/generator/dummy_source.rb +31 -0
- data/lib/cocoapods-tt/native/generator/embed_frameworks_script.rb +196 -0
- data/lib/cocoapods-tt/native/generator/file_list.rb +39 -0
- data/lib/cocoapods-tt/native/generator/header.rb +103 -0
- data/lib/cocoapods-tt/native/generator/info_plist_file.rb +128 -0
- data/lib/cocoapods-tt/native/generator/module_map.rb +99 -0
- data/lib/cocoapods-tt/native/generator/prefix_header.rb +60 -0
- data/lib/cocoapods-tt/native/generator/script_phase_constants.rb +100 -0
- data/lib/cocoapods-tt/native/generator/umbrella_header.rb +46 -0
- data/lib/cocoapods-tt/native/hooks_manager.rb +132 -0
- data/lib/cocoapods-tt/native/installer/analyzer/analysis_result.rb +87 -0
- data/lib/cocoapods-tt/native/installer/analyzer/locking_dependency_analyzer.rb +103 -0
- data/lib/cocoapods-tt/native/installer/analyzer/pod_variant.rb +87 -0
- data/lib/cocoapods-tt/native/installer/analyzer/pod_variant_set.rb +175 -0
- data/lib/cocoapods-tt/native/installer/analyzer/podfile_dependency_cache.rb +55 -0
- data/lib/cocoapods-tt/native/installer/analyzer/sandbox_analyzer.rb +268 -0
- data/lib/cocoapods-tt/native/installer/analyzer/specs_state.rb +108 -0
- data/lib/cocoapods-tt/native/installer/analyzer/target_inspection_result.rb +58 -0
- data/lib/cocoapods-tt/native/installer/analyzer/target_inspector.rb +258 -0
- data/lib/cocoapods-tt/native/installer/analyzer.rb +1204 -0
- data/lib/cocoapods-tt/native/installer/base_install_hooks_context.rb +135 -0
- data/lib/cocoapods-tt/native/installer/installation_options.rb +195 -0
- data/lib/cocoapods-tt/native/installer/pod_source_installer.rb +224 -0
- data/lib/cocoapods-tt/native/installer/pod_source_preparer.rb +77 -0
- data/lib/cocoapods-tt/native/installer/podfile_validator.rb +168 -0
- data/lib/cocoapods-tt/native/installer/post_install_hooks_context.rb +9 -0
- data/lib/cocoapods-tt/native/installer/post_integrate_hooks_context.rb +9 -0
- data/lib/cocoapods-tt/native/installer/pre_install_hooks_context.rb +51 -0
- data/lib/cocoapods-tt/native/installer/pre_integrate_hooks_context.rb +9 -0
- data/lib/cocoapods-tt/native/installer/project_cache/project_cache.rb +11 -0
- data/lib/cocoapods-tt/native/installer/project_cache/project_cache_analysis_result.rb +53 -0
- data/lib/cocoapods-tt/native/installer/project_cache/project_cache_analyzer.rb +200 -0
- data/lib/cocoapods-tt/native/installer/project_cache/project_cache_version.rb +43 -0
- data/lib/cocoapods-tt/native/installer/project_cache/project_installation_cache.rb +103 -0
- data/lib/cocoapods-tt/native/installer/project_cache/project_metadata_cache.rb +73 -0
- data/lib/cocoapods-tt/native/installer/project_cache/target_cache_key.rb +176 -0
- data/lib/cocoapods-tt/native/installer/project_cache/target_metadata.rb +74 -0
- data/lib/cocoapods-tt/native/installer/sandbox_dir_cleaner.rb +105 -0
- data/lib/cocoapods-tt/native/installer/sandbox_header_paths_installer.rb +45 -0
- data/lib/cocoapods-tt/native/installer/source_provider_hooks_context.rb +34 -0
- data/lib/cocoapods-tt/native/installer/target_uuid_generator.rb +34 -0
- data/lib/cocoapods-tt/native/installer/user_project_integrator/target_integrator/xcconfig_integrator.rb +179 -0
- data/lib/cocoapods-tt/native/installer/user_project_integrator/target_integrator.rb +815 -0
- data/lib/cocoapods-tt/native/installer/user_project_integrator.rb +280 -0
- data/lib/cocoapods-tt/native/installer/xcode/multi_pods_project_generator.rb +82 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/aggregate_target_dependency_installer.rb +66 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/aggregate_target_installer.rb +192 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/app_host_installer.rb +154 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/file_references_installer.rb +329 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/pod_target_dependency_installer.rb +195 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/pod_target_installer.rb +1239 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/pod_target_integrator.rb +312 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/pods_project_writer.rb +90 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/project_generator.rb +120 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/target_installation_result.rb +140 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/target_installer.rb +257 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator/target_installer_helper.rb +110 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator.rb +291 -0
- data/lib/cocoapods-tt/native/installer/xcode/pods_project_generator_result.rb +54 -0
- data/lib/cocoapods-tt/native/installer/xcode/single_pods_project_generator.rb +38 -0
- data/lib/cocoapods-tt/native/installer/xcode/target_validator.rb +170 -0
- data/lib/cocoapods-tt/native/installer/xcode.rb +11 -0
- data/lib/cocoapods-tt/native/installer.rb +1044 -0
- data/lib/cocoapods-tt/native/native_target_extension.rb +60 -0
- data/lib/cocoapods-tt/native/open-uri.rb +33 -0
- data/lib/cocoapods-tt/native/podfile.rb +13 -0
- data/lib/cocoapods-tt/native/project.rb +544 -0
- data/lib/cocoapods-tt/native/resolver/lazy_specification.rb +88 -0
- data/lib/cocoapods-tt/native/resolver/resolver_specification.rb +41 -0
- data/lib/cocoapods-tt/native/resolver.rb +600 -0
- data/lib/cocoapods-tt/native/sandbox/file_accessor.rb +532 -0
- data/lib/cocoapods-tt/native/sandbox/headers_store.rb +163 -0
- data/lib/cocoapods-tt/native/sandbox/path_list.rb +242 -0
- data/lib/cocoapods-tt/native/sandbox/pod_dir_cleaner.rb +71 -0
- data/lib/cocoapods-tt/native/sandbox/podspec_finder.rb +23 -0
- data/lib/cocoapods-tt/native/sandbox.rb +470 -0
- data/lib/cocoapods-tt/native/sources_manager.rb +221 -0
- data/lib/cocoapods-tt/native/target/aggregate_target.rb +558 -0
- data/lib/cocoapods-tt/native/target/build_settings.rb +1385 -0
- data/lib/cocoapods-tt/native/target/pod_target.rb +1168 -0
- data/lib/cocoapods-tt/native/target.rb +378 -0
- data/lib/cocoapods-tt/native/user_interface/error_report.rb +204 -0
- data/lib/cocoapods-tt/native/user_interface/inspector_reporter.rb +102 -0
- data/lib/cocoapods-tt/native/user_interface.rb +463 -0
- data/lib/cocoapods-tt/native/validator.rb +1170 -0
- data/lib/cocoapods-tt/native/version_metadata.rb +26 -0
- data/lib/cocoapods-tt/native/xcode/framework_paths.rb +54 -0
- data/lib/cocoapods-tt/native/xcode/linkage_analyzer.rb +22 -0
- data/lib/cocoapods-tt/native/xcode/xcframework/xcframework_slice.rb +138 -0
- data/lib/cocoapods-tt/native/xcode/xcframework.rb +99 -0
- data/lib/cocoapods-tt/native/xcode.rb +7 -0
- data/lib/cocoapods-tt.rb +1 -0
- data/lib/cocoapods_plugin.rb +17 -0
- metadata +193 -0
@@ -0,0 +1,463 @@
|
|
1
|
+
require 'cocoapods/user_interface/error_report'
|
2
|
+
require 'cocoapods/user_interface/inspector_reporter'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
# Provides support for UI output. It provides support for nested sections of
|
6
|
+
# information and for a verbose mode.
|
7
|
+
#
|
8
|
+
module UserInterface
|
9
|
+
require 'colored2'
|
10
|
+
|
11
|
+
@title_colors = %w( yellow green )
|
12
|
+
@title_level = 0
|
13
|
+
@indentation_level = 2
|
14
|
+
@treat_titles_as_messages = false
|
15
|
+
@warnings = []
|
16
|
+
|
17
|
+
class << self
|
18
|
+
include Config::Mixin
|
19
|
+
|
20
|
+
attr_accessor :indentation_level
|
21
|
+
attr_accessor :title_level
|
22
|
+
attr_accessor :warnings
|
23
|
+
|
24
|
+
# @return [IO] IO object to which UI output will be directed.
|
25
|
+
#
|
26
|
+
attr_accessor :output_io
|
27
|
+
|
28
|
+
# @return [Bool] Whether the wrapping of the strings to the width of the
|
29
|
+
# terminal should be disabled.
|
30
|
+
#
|
31
|
+
attr_accessor :disable_wrap
|
32
|
+
alias_method :disable_wrap?, :disable_wrap
|
33
|
+
|
34
|
+
# Prints a title taking an optional verbose prefix and
|
35
|
+
# a relative indentation valid for the UI action in the passed
|
36
|
+
# block.
|
37
|
+
#
|
38
|
+
# In verbose mode titles are printed with a color according
|
39
|
+
# to their level. In normal mode titles are printed only if
|
40
|
+
# they have nesting level smaller than 2.
|
41
|
+
#
|
42
|
+
# @todo Refactor to title (for always visible titles like search)
|
43
|
+
# and sections (titles that represent collapsible sections).
|
44
|
+
#
|
45
|
+
# @param [String] title
|
46
|
+
# The title to print
|
47
|
+
#
|
48
|
+
# @param [String] verbose_prefix
|
49
|
+
# See #message
|
50
|
+
#
|
51
|
+
# @param [FixNum] relative_indentation
|
52
|
+
# The indentation level relative to the current,
|
53
|
+
# when the message is printed.
|
54
|
+
#
|
55
|
+
def section(title, verbose_prefix = '', relative_indentation = 0)
|
56
|
+
if config.verbose?
|
57
|
+
title(title, verbose_prefix, relative_indentation)
|
58
|
+
elsif title_level < 1
|
59
|
+
puts title
|
60
|
+
end
|
61
|
+
|
62
|
+
self.indentation_level += relative_indentation
|
63
|
+
self.title_level += 1
|
64
|
+
yield if block_given?
|
65
|
+
ensure
|
66
|
+
self.indentation_level -= relative_indentation
|
67
|
+
self.title_level -= 1
|
68
|
+
end
|
69
|
+
|
70
|
+
# In verbose mode it shows the sections and the contents.
|
71
|
+
# In normal mode it just prints the title.
|
72
|
+
#
|
73
|
+
# @return [void]
|
74
|
+
#
|
75
|
+
def titled_section(title, options = {})
|
76
|
+
relative_indentation = options[:relative_indentation] || 0
|
77
|
+
verbose_prefix = options[:verbose_prefix] || ''
|
78
|
+
if config.verbose?
|
79
|
+
title(title, verbose_prefix, relative_indentation)
|
80
|
+
else
|
81
|
+
puts title
|
82
|
+
end
|
83
|
+
|
84
|
+
self.indentation_level += relative_indentation
|
85
|
+
self.title_level += 1
|
86
|
+
yield if block_given?
|
87
|
+
ensure
|
88
|
+
self.indentation_level -= relative_indentation
|
89
|
+
self.title_level -= 1
|
90
|
+
end
|
91
|
+
|
92
|
+
# A title opposed to a section is always visible
|
93
|
+
#
|
94
|
+
# @param [String] title
|
95
|
+
# The title to print
|
96
|
+
#
|
97
|
+
# @param [String] verbose_prefix
|
98
|
+
# See #message
|
99
|
+
#
|
100
|
+
# @param [FixNum] relative_indentation
|
101
|
+
# The indentation level relative to the current,
|
102
|
+
# when the message is printed.
|
103
|
+
#
|
104
|
+
def title(title, verbose_prefix = '', relative_indentation = 2)
|
105
|
+
if @treat_titles_as_messages
|
106
|
+
message(title, verbose_prefix)
|
107
|
+
else
|
108
|
+
title = verbose_prefix + title if config.verbose?
|
109
|
+
title = "\n#{title}" if @title_level < 2
|
110
|
+
if (color = @title_colors[@title_level])
|
111
|
+
title = title.send(color)
|
112
|
+
end
|
113
|
+
puts "#{title}"
|
114
|
+
end
|
115
|
+
|
116
|
+
self.indentation_level += relative_indentation
|
117
|
+
self.title_level += 1
|
118
|
+
yield if block_given?
|
119
|
+
ensure
|
120
|
+
self.indentation_level -= relative_indentation
|
121
|
+
self.title_level -= 1
|
122
|
+
end
|
123
|
+
|
124
|
+
# Prints a verbose message taking an optional verbose prefix and
|
125
|
+
# a relative indentation valid for the UI action in the passed
|
126
|
+
# block.
|
127
|
+
#
|
128
|
+
# @todo Clean interface.
|
129
|
+
#
|
130
|
+
# @param [String] message
|
131
|
+
# The message to print.
|
132
|
+
#
|
133
|
+
# @param [String] verbose_prefix
|
134
|
+
# See #message
|
135
|
+
#
|
136
|
+
# @param [FixNum] relative_indentation
|
137
|
+
# The indentation level relative to the current,
|
138
|
+
# when the message is printed.
|
139
|
+
#
|
140
|
+
# @yield The action, this block is always executed.
|
141
|
+
#
|
142
|
+
# @return [void]
|
143
|
+
#
|
144
|
+
def message(message, verbose_prefix = '', relative_indentation = 2)
|
145
|
+
message = verbose_prefix + message if config.verbose?
|
146
|
+
puts_indented message if config.verbose?
|
147
|
+
|
148
|
+
self.indentation_level += relative_indentation
|
149
|
+
yield if block_given?
|
150
|
+
ensure
|
151
|
+
self.indentation_level -= relative_indentation
|
152
|
+
end
|
153
|
+
|
154
|
+
# Prints an info to the user. The info is always displayed.
|
155
|
+
# It respects the current indentation level only in verbose
|
156
|
+
# mode.
|
157
|
+
#
|
158
|
+
# Any title printed in the optional block is treated as a message.
|
159
|
+
#
|
160
|
+
# @param [String] message
|
161
|
+
# The message to print.
|
162
|
+
#
|
163
|
+
def info(message)
|
164
|
+
indentation = config.verbose? ? self.indentation_level : 0
|
165
|
+
indented = wrap_string(message, indentation)
|
166
|
+
puts(indented)
|
167
|
+
|
168
|
+
self.indentation_level += 2
|
169
|
+
@treat_titles_as_messages = true
|
170
|
+
yield if block_given?
|
171
|
+
ensure
|
172
|
+
@treat_titles_as_messages = false
|
173
|
+
self.indentation_level -= 2
|
174
|
+
end
|
175
|
+
|
176
|
+
# Prints an important message to the user.
|
177
|
+
#
|
178
|
+
# @param [String] message The message to print.
|
179
|
+
#
|
180
|
+
# return [void]
|
181
|
+
#
|
182
|
+
def notice(message)
|
183
|
+
puts("\n[!] #{message}".green)
|
184
|
+
end
|
185
|
+
|
186
|
+
# Returns a string containing relative location of a path from the Podfile.
|
187
|
+
# The returned path is quoted. If the argument is nil it returns the
|
188
|
+
# empty string.
|
189
|
+
#
|
190
|
+
# @param [#to_str] pathname
|
191
|
+
# The path to print.
|
192
|
+
#
|
193
|
+
def path(pathname)
|
194
|
+
if pathname
|
195
|
+
from_path = config.podfile_path.dirname if config.podfile_path
|
196
|
+
from_path ||= Pathname.pwd
|
197
|
+
path = begin
|
198
|
+
Pathname(pathname).relative_path_from(from_path)
|
199
|
+
rescue
|
200
|
+
pathname
|
201
|
+
end
|
202
|
+
"`#{path}`"
|
203
|
+
else
|
204
|
+
''
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
# Prints the textual representation of a given set.
|
209
|
+
#
|
210
|
+
# @param [Set] set
|
211
|
+
# the set that should be presented.
|
212
|
+
#
|
213
|
+
# @param [Symbol] mode
|
214
|
+
# the presentation mode, either `:normal` or `:name_and_version`.
|
215
|
+
#
|
216
|
+
def pod(set, mode = :normal)
|
217
|
+
if mode == :name_and_version
|
218
|
+
puts_indented "#{set.name} #{set.versions.first.version}"
|
219
|
+
else
|
220
|
+
pod = Specification::Set::Presenter.new(set)
|
221
|
+
title = "-> #{pod.name} (#{pod.version})"
|
222
|
+
if pod.spec.deprecated?
|
223
|
+
title += " #{pod.deprecation_description}"
|
224
|
+
colored_title = title.red
|
225
|
+
else
|
226
|
+
colored_title = title.green
|
227
|
+
end
|
228
|
+
|
229
|
+
title(colored_title, '', 1) do
|
230
|
+
puts_indented pod.summary if pod.summary
|
231
|
+
puts_indented "pod '#{pod.name}', '~> #{pod.version}'"
|
232
|
+
labeled('Homepage', pod.homepage)
|
233
|
+
labeled('Source', pod.source_url)
|
234
|
+
labeled('Versions', pod.versions_by_source)
|
235
|
+
if mode == :stats
|
236
|
+
labeled('Authors', pod.authors) if pod.authors =~ /,/
|
237
|
+
labeled('Author', pod.authors) if pod.authors !~ /,/
|
238
|
+
labeled('License', pod.license)
|
239
|
+
labeled('Platform', pod.platform)
|
240
|
+
labeled('Stars', pod.github_stargazers)
|
241
|
+
labeled('Forks', pod.github_forks)
|
242
|
+
end
|
243
|
+
labeled('Subspecs', pod.subspecs)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
# Prints a message with a label.
|
249
|
+
#
|
250
|
+
# @param [String] label
|
251
|
+
# The label to print.
|
252
|
+
#
|
253
|
+
# @param [#to_s] value
|
254
|
+
# The value to print.
|
255
|
+
#
|
256
|
+
# @param [FixNum] justification
|
257
|
+
# The justification of the label.
|
258
|
+
#
|
259
|
+
def labeled(label, value, justification = 12)
|
260
|
+
if value
|
261
|
+
title = "- #{label}:"
|
262
|
+
if value.is_a?(Array)
|
263
|
+
lines = [wrap_string(title, self.indentation_level)]
|
264
|
+
value.each do |v|
|
265
|
+
lines << wrap_string("- #{v}", self.indentation_level + 2)
|
266
|
+
end
|
267
|
+
puts lines.join("\n")
|
268
|
+
else
|
269
|
+
puts wrap_string(title.ljust(justification) + "#{value}", self.indentation_level)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
# Prints a message respecting the current indentation level and
|
275
|
+
# wrapping it to the terminal width if necessary.
|
276
|
+
#
|
277
|
+
# @param [String] message
|
278
|
+
# The message to print.
|
279
|
+
#
|
280
|
+
def puts_indented(message = '')
|
281
|
+
indented = wrap_string(message, self.indentation_level)
|
282
|
+
puts(indented)
|
283
|
+
end
|
284
|
+
|
285
|
+
# Prints the stored warnings. This method is intended to be called at the
|
286
|
+
# end of the execution of the binary.
|
287
|
+
#
|
288
|
+
# @return [void]
|
289
|
+
#
|
290
|
+
def print_warnings
|
291
|
+
STDOUT.flush
|
292
|
+
warnings.each do |warning|
|
293
|
+
next if warning[:verbose_only] && !config.verbose?
|
294
|
+
STDERR.puts("\n[!] #{warning[:message]}".yellow)
|
295
|
+
warning[:actions].each do |action|
|
296
|
+
string = "- #{action}"
|
297
|
+
string = wrap_string(string, 4)
|
298
|
+
puts(string)
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
# Presents a choice among the elements of an array to the user.
|
304
|
+
#
|
305
|
+
# @param [Array<#to_s>] array
|
306
|
+
# The list of the elements among which the user should make his
|
307
|
+
# choice.
|
308
|
+
#
|
309
|
+
# @param [String] message
|
310
|
+
# The message to display to the user.
|
311
|
+
#
|
312
|
+
# @return [Fixnum] The index of the chosen array item.
|
313
|
+
#
|
314
|
+
def choose_from_array(array, message)
|
315
|
+
array.each_with_index do |item, index|
|
316
|
+
UI.puts "#{index + 1}: #{item}"
|
317
|
+
end
|
318
|
+
|
319
|
+
UI.puts message
|
320
|
+
|
321
|
+
index = UI.gets.chomp.to_i - 1
|
322
|
+
if index < 0 || index > array.count - 1
|
323
|
+
raise Informative, "#{index + 1} is invalid [1-#{array.count}]"
|
324
|
+
else
|
325
|
+
index
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
public
|
330
|
+
|
331
|
+
# @!group Basic methods
|
332
|
+
#-----------------------------------------------------------------------#
|
333
|
+
|
334
|
+
# prints a message followed by a new line unless config is silent.
|
335
|
+
#
|
336
|
+
# @param [String] message
|
337
|
+
# The message to print.
|
338
|
+
#
|
339
|
+
def puts(message = '')
|
340
|
+
return if config.silent?
|
341
|
+
begin
|
342
|
+
(output_io || STDOUT).puts(message)
|
343
|
+
rescue Errno::EPIPE
|
344
|
+
exit 0
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
# prints a message followed by a new line unless config is silent.
|
349
|
+
#
|
350
|
+
# @param [String] message
|
351
|
+
# The message to print.
|
352
|
+
#
|
353
|
+
def print(message)
|
354
|
+
return if config.silent?
|
355
|
+
begin
|
356
|
+
(output_io || STDOUT).print(message)
|
357
|
+
rescue Errno::EPIPE
|
358
|
+
exit 0
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
# gets input from $stdin
|
363
|
+
#
|
364
|
+
def gets
|
365
|
+
$stdin.gets
|
366
|
+
end
|
367
|
+
|
368
|
+
# Stores important warning to the user optionally followed by actions
|
369
|
+
# that the user should take. To print them use {#print_warnings}.
|
370
|
+
#
|
371
|
+
# @param [String] message The message to print.
|
372
|
+
# @param [Array] actions The actions that the user should take.
|
373
|
+
# @param [Bool] verbose_only
|
374
|
+
# Restrict the appearance of the warning to verbose mode only
|
375
|
+
#
|
376
|
+
# return [void]
|
377
|
+
#
|
378
|
+
def warn(message, actions = [], verbose_only = false)
|
379
|
+
warnings << { :message => message, :actions => actions, :verbose_only => verbose_only }
|
380
|
+
end
|
381
|
+
|
382
|
+
# Pipes all output inside given block to a pager.
|
383
|
+
#
|
384
|
+
# @yield Code block in which inputs to {#puts} and {#print} methods will be printed to the piper.
|
385
|
+
#
|
386
|
+
def with_pager
|
387
|
+
prev_handler = Signal.trap('INT', 'IGNORE')
|
388
|
+
IO.popen((ENV['PAGER'] || 'less -R'), 'w') do |io|
|
389
|
+
UI.output_io = io
|
390
|
+
yield
|
391
|
+
end
|
392
|
+
ensure
|
393
|
+
Signal.trap('INT', prev_handler)
|
394
|
+
UI.output_io = nil
|
395
|
+
end
|
396
|
+
|
397
|
+
private
|
398
|
+
|
399
|
+
# @!group Helpers
|
400
|
+
#-----------------------------------------------------------------------#
|
401
|
+
|
402
|
+
# @return [String] Wraps a string taking into account the width of the
|
403
|
+
# terminal and an option indent. Adapted from
|
404
|
+
# https://macromates.com/blog/2006/wrapping-text-with-regular-expressions/
|
405
|
+
#
|
406
|
+
# @param [String] string The string to wrap
|
407
|
+
#
|
408
|
+
# @param [String] indent The string to use to indent the result.
|
409
|
+
#
|
410
|
+
# @return [String] The formatted string.
|
411
|
+
#
|
412
|
+
# @note If CocoaPods is not being run in a terminal or the width of the
|
413
|
+
# terminal is too small a width of 80 is assumed.
|
414
|
+
#
|
415
|
+
def wrap_string(string, indent = 0)
|
416
|
+
if disable_wrap
|
417
|
+
(' ' * indent) + string
|
418
|
+
else
|
419
|
+
first_space = ' ' * indent
|
420
|
+
indented = CLAide::Command::Banner::TextWrapper.wrap_with_indent(string, indent, 9999)
|
421
|
+
first_space + indented
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
UI = UserInterface
|
427
|
+
|
428
|
+
#---------------------------------------------------------------------------#
|
429
|
+
|
430
|
+
# Redirects cocoapods-core UI.
|
431
|
+
#
|
432
|
+
module CoreUI
|
433
|
+
class << self
|
434
|
+
def puts(message)
|
435
|
+
UI.puts message
|
436
|
+
end
|
437
|
+
|
438
|
+
def print(message)
|
439
|
+
UI.print(message)
|
440
|
+
end
|
441
|
+
|
442
|
+
def warn(message)
|
443
|
+
UI.warn message
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
#---------------------------------------------------------------------------#
|
450
|
+
|
451
|
+
module Xcodeproj
|
452
|
+
# Redirects xcodeproj UI.
|
453
|
+
#
|
454
|
+
module UserInterface
|
455
|
+
def self.puts(message)
|
456
|
+
::Pod::UI.puts message
|
457
|
+
end
|
458
|
+
|
459
|
+
def self.warn(message)
|
460
|
+
::Pod::UI.warn message
|
461
|
+
end
|
462
|
+
end
|
463
|
+
end
|