Commit 39528ee5 authored by Fabio Pelosin's avatar Fabio Pelosin

[UI] General improvements.

parent 0eadc218
......@@ -14,7 +14,7 @@ module Pod
def download
create_cache unless cache_exist?
UI.section(' > Cloning git repo', '', 3) do
UI.section(' > Cloning git repo', '', 1) do
if options[:tag]
download_tag
elsif options[:branch]
......@@ -30,7 +30,7 @@ module Pod
end
def create_cache
UI.section " > Creating cache git repo (#{cache_path})"
UI.section(" > Creating cache git repo (#{cache_path})",'',1)
cache_path.rmtree if cache_path.exist?
cache_path.mkpath
git! %Q|clone --mirror "#{url}" "#{cache_path}"|
......@@ -74,15 +74,16 @@ module Pod
end
def update_cache
UI.section " > Updating cache git repo (#{cache_path})"
Dir.chdir(cache_path) do
if git("config core.bare").chomp == "true"
git! "remote update"
else
git! "reset --hard HEAD"
git! "clean -d -x -f"
git! "pull origin master"
git! "fetch --tags"
UI.section(" > Updating cache git repo (#{cache_path})",'',1) do
Dir.chdir(cache_path) do
if git("config core.bare").chomp == "true"
git! "remote update"
else
git! "reset --hard HEAD"
git! "clean -d -x -f"
git! "pull origin master"
git! "fetch --tags"
end
end
end
end
......@@ -152,7 +153,9 @@ module Pod
end
def clone(from, to)
git! %Q|clone "#{from}" "#{to}"|
UI.section(" > Cloning to Pods folder",'',1) do
git! %Q|clone "#{from}" "#{to}"|
end
end
end
......
......@@ -141,9 +141,9 @@ module Pod
@lockfile = Lockfile.generate(@podfile, specs_by_target.values.flatten)
@lockfile.write_to_disk(config.project_lockfile)
end
end
UserProjectIntegrator.new(@podfile).integrate! if config.integrate_targets?
end
end
def run_pre_install_hooks
......
......@@ -51,7 +51,7 @@ module Pod
workspace << project_path unless workspace.include?(project_path)
end
unless workspace_path.exist? || config.silent?
puts "[!] From now on use `#{workspace_path.basename}'."
UI.notice "From now on use `#{workspace_path.basename}'."
end
workspace.save_as(workspace_path)
end
......@@ -69,20 +69,30 @@ module Pod
"#<#{self.class} for target `#{@target_definition.label}'>"
end
# Integrates the user project targets. Only the targets that do **not**
# already have the Pods library in their frameworks build phase are
# processed.
#
# @return [void]
#
def integrate!
return if targets.empty?
unless Config.instance.silent?
puts "-> Integrating `#{@target_definition.lib_name}' into #{'target'.pluralize(targets.size)} " \
"`#{targets.map(&:name).to_sentence}' of Xcode project `#{user_project_path.basename}'.".green
UI.section ("Integrating `#{@target_definition.lib_name}' into #{'target'.pluralize(targets.size)} " \
"`#{targets.map(&:name).to_sentence}' of Xcode project #{UI.path user_project_path}.") do
add_xcconfig_base_configuration
add_pods_library
add_copy_resources_script_phase
user_project.save_as(@target_definition.user_project.path)
end
add_xcconfig_base_configuration
add_pods_library
add_copy_resources_script_phase
user_project.save_as(@target_definition.user_project.path)
end
# @return [Pathname] the path of the user project.
#
# @raises If the path doesn't exits.
#
# @raises If the project is implicit and there are multiple projects.
#
def user_project_path
if path = @target_definition.user_project.path
unless path.exist?
......@@ -96,6 +106,8 @@ module Pod
end
end
# @return [Xcodeproj::Project] Returns the project of the user.
#
def user_project
@user_project ||= Xcodeproj::Project.new(user_project_path)
end
......@@ -152,13 +164,10 @@ module Pod
config.base_configuration = xcconfig
end
unless config.silent?
config_build_names_by_overriden_key.each do |key, config_build_names|
name = "#{target.attributes["name"]} [#{config_build_names.join(' - ')}]"
puts "\n[!] The target `#{name}' overrides the `#{key}' build setting defined in `#{@target_definition.xcconfig_relative_path}'.".yellow
puts " - Use the `$(inherited)' flag, or"
puts " - Remove the build settings from the target."
end
config_build_names_by_overriden_key.each do |key, config_build_names|
name = "#{target.attributes["name"]} [#{config_build_names.join(' - ')}]"
actions = [ "Use the `$(inherited)' flag, or", "Remove the build settings from the target." ]
UI.warn("The target `#{name}' overrides the `#{key}' build setting defined in `#{@target_definition.xcconfig_relative_path}'.", actions)
end
end
end
......
......@@ -6,7 +6,7 @@ module Pod
@title_colors = %w|yellow green|
@title_level = 0
@indentation_level = 0
@indentation_level = 2
@treat_titles_as_messages = false
class << self
......@@ -25,7 +25,7 @@ module Pod
# TODO: refactor to title (for always visible titles like search)
# and sections (titles that reppresent collapsible sections).
#
def section(title, verbose_prefix = '', relative_indentation = 2)
def section(title, verbose_prefix = '', relative_indentation = 0)
if config.verbose?
title(title, verbose_prefix, relative_indentation)
elsif title_level < 2
......@@ -96,6 +96,32 @@ module Pod
self.indentation_level -= 2
end
# Prints an important message to the user.
#
# @param [String] message The message to print.
#
# return [void]
#
def notice(message)
puts("\n[!] #{message}".green)
end
# Prints an important warning to the user optionally followed by actions
# that the user should take.
#
# @param [String] message The message to print.
# @param [Actions] actions The actions that the user should take.
#
# return [void]
#
def warn(message, actions)
puts("\n[!] #{message}".yellow)
actions.each do |action|
indented = wrap_string(action, " - ")
puts(indented)
end
end
# Returns a string containing relative location of a path from the Podfile.
# The returned path is quoted. If the argument is nit it returns the
# empty string.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment