27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/cocoapods-mPaaS/command/mpaas/init.rb', line 27
def run
repo_url = @custom_repo_url || CocoapodsmPaaS::MPAAS_REPO_URL
source_line = "source \"#{repo_url}\""
LogTools.p_green Pod::MPAAS::Localization.t('mpaas.init_command.check_config_file_exists')
project_dir = Dir::pwd
meta_file_path = find_config_file(project_dir)
unless meta_file_path.length > 0 && File::exist?(meta_file_path)
config_file_name = "meta.config"
meta_file_path = File.join(project_dir, config_file_name)
unless File::exist?(meta_file_path)
help! "No config file found !!!"
else
LogTools.p "config file path : #{meta_file_path}"
end
else
LogTools.p "config file path : #{meta_file_path}"
end
LogTools.p_green Pod::MPAAS::Localization.t('mpaas.init_command.check_process_podfile')
podfile_path = File.join(project_dir, "Podfile")
LogTools.p "Podfile path: #{podfile_path}"
plugin_full = PLUGIN
if @all_targets
podfile = Pod::Podfile.from_file(podfile_path)
plugin_option = ', :targets => ['
root_targetDefinition_array = podfile.root_target_definitions
if root_targetDefinition_array && root_targetDefinition_array.size > 0
root_targetDefinition_array.each do |root_targetDefinition|
children = root_targetDefinition.children
if children
children.each_index do |index|
plugin_option += ('"' + children[index].name + '"')
if index != (children.size - 1)
plugin_option += ', '
end
end
end
end
end
plugin_option += ']'
plugin_full += plugin_option
end
io = File::open(podfile_path).readlines
override = File.new(podfile_path, "w")
override.puts("# mPaaS Pods Begin")
override.puts(plugin_full)
override.puts(source_line)
if @custom_repo_url
override.puts("mPaaS_repo_url '#{repo_url}'")
end
override.puts('mPaaS_baseline ' + '\'x.x.x\'' + ' ' + Pod::MPAAS::Localization.t('mpaas.init_command.replace_baseline_note'))
override.puts("# mPaaS Pods End")
override.puts("# ---------------------------------------------------------------------")
io.each do |line|
unless line.include?("cocoapods-mPaaS") || line.include?("mPaaS_repo_url") || line.include?(CocoapodsmPaaS::MPAAS_REPO_URL) || (@custom_repo_url && line.include?(@custom_repo_url)) || line.include?("mPaaS Pods") || line.include?("use_pod_for_mPaaS") || line.include?("mPaaS_baseline") || line.include?("# -------------------------------------------------------")
override.puts line
end
end
override.close
LogTools.p_green 'Added "plugin in current Podfile, Done"'
LogTools.p plugin_full
LogTools.p_green 'Added "source in current Podfile, Done"'
LogTools.p source_line
LogTools.p_green Pod::MPAAS::Localization.t('mpaas.init_command.configuration_complete')
end
|