pod-builder 2.0.0.beta.19 → 2.0.0.beta.21

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/Example/{Frameworks → PodBuilder}/.gitignore +0 -0
  4. data/Example/{Frameworks → PodBuilder}/.pod_builder/pod_builder +0 -0
  5. data/Example/{Frameworks → PodBuilder}/PodBuilder.json +0 -0
  6. data/Example/{Frameworks → PodBuilder}/Podfile +0 -0
  7. data/Example/{Frameworks → PodBuilder}/Podfile.restore +0 -0
  8. data/Example/Podfile +27 -29
  9. data/Example/Podfile.lock +42 -42
  10. data/README.md +13 -13
  11. data/exe/pod_builder +27 -16
  12. data/lib/pod_builder/command/build.rb +28 -159
  13. data/lib/pod_builder/command/build_all.rb +2 -2
  14. data/lib/pod_builder/command/clean.rb +34 -53
  15. data/lib/pod_builder/command/clear_lldbinit.rb +6 -2
  16. data/lib/pod_builder/command/deintegrate.rb +27 -6
  17. data/lib/pod_builder/command/generate_lfs.rb +1 -1
  18. data/lib/pod_builder/command/generate_podspec.rb +3 -2
  19. data/lib/pod_builder/command/info.rb +1 -1
  20. data/lib/pod_builder/command/init.rb +37 -14
  21. data/lib/pod_builder/command/install_sources.rb +20 -13
  22. data/lib/pod_builder/command/none.rb +2 -2
  23. data/lib/pod_builder/command/restore_all.rb +4 -4
  24. data/lib/pod_builder/command/switch.rb +56 -14
  25. data/lib/pod_builder/command/sync_podfile.rb +3 -2
  26. data/lib/pod_builder/command/update.rb +5 -6
  27. data/lib/pod_builder/command/update_lldbinit.rb +10 -8
  28. data/lib/pod_builder/configuration.rb +27 -7
  29. data/lib/pod_builder/core.rb +35 -9
  30. data/lib/pod_builder/info.rb +11 -11
  31. data/lib/pod_builder/install.rb +178 -184
  32. data/lib/pod_builder/licenses.rb +4 -4
  33. data/lib/pod_builder/podfile.rb +226 -85
  34. data/lib/pod_builder/podfile/post_actions.rb +9 -14
  35. data/lib/pod_builder/podfile_cp.rb +93 -0
  36. data/lib/pod_builder/podfile_item.rb +41 -20
  37. data/lib/pod_builder/podspec.rb +33 -16
  38. data/lib/pod_builder/rome/post_install.rb +121 -129
  39. data/lib/pod_builder/rome/pre_install.rb +1 -1
  40. data/lib/pod_builder/templates/build_podfile.template +2 -2
  41. data/lib/pod_builder/version.rb +1 -1
  42. metadata +8 -7
@@ -4,7 +4,11 @@ require 'digest'
4
4
  module PodBuilder
5
5
  module Command
6
6
  class ClearLldbInit
7
- def self.call(options)
7
+ def self.call
8
+ Configuration.check_inited
9
+ if Configuration.build_using_repo_paths
10
+ raise "\n\nlldb shenanigans not supported when 'build_using_repo_paths' is enabled".red
11
+ end
8
12
 
9
13
  argument_pods = ARGV.dup
10
14
 
@@ -34,7 +38,7 @@ module PodBuilder
34
38
 
35
39
  File.write(lldbinit_path, lldbinit_lines.join())
36
40
 
37
- if options.nil? == false
41
+ if OPTIONS.nil? == false
38
42
  puts "\n\n🎉 done!\n".green
39
43
  end
40
44
  return 0
@@ -3,11 +3,11 @@ require 'pod_builder/core'
3
3
  module PodBuilder
4
4
  module Command
5
5
  class Deintegrate
6
- def self.call(options)
6
+ def self.call
7
7
  raise "\n\nPodBuilder not initialized!\n".red if !Configuration.exists
8
8
 
9
- prebuilt_podfile = File.join(Configuration.base_path, "Podfile")
10
- restored_podfile = File.join(PodBuilder::project_path, "Podfile")
9
+ prebuilt_podfile = PodBuilder::basepath("Podfile")
10
+ restored_podfile = PodBuilder::project_path("Podfile")
11
11
 
12
12
  FileUtils.cp(prebuilt_podfile, restored_podfile)
13
13
 
@@ -32,9 +32,14 @@ module PodBuilder
32
32
  end
33
33
 
34
34
  FileUtils.rm_f(restored_podfile)
35
- File.write(restored_podfile, podfile_lines.join)
36
- Podfile.update_path_entires(restored_podfile, false)
37
- Podfile.update_project_entries(restored_podfile, false)
35
+
36
+ podfile_content = podfile_lines.join
37
+
38
+ podfile_content = Podfile.update_path_entries(podfile_content, Deintegrate.method(:podfile_path_transform))
39
+ podfile_content = Podfile.update_project_entries(podfile_content, Deintegrate.method(:podfile_path_transform))
40
+ podfile_content = Podfile.update_require_entries(podfile_content, Deintegrate.method(:podfile_path_transform))
41
+
42
+ File.write(restored_podfile, podfile_content)
38
43
 
39
44
  PodBuilder::safe_rm_rf(Configuration.base_path)
40
45
 
@@ -54,6 +59,22 @@ module PodBuilder
54
59
 
55
60
  private
56
61
 
62
+ def self.podfile_path_transform(path)
63
+ use_absolute_paths = false
64
+ podfile_path = PodBuilder::project_path("Podfile")
65
+ original_basepath = PodBuilder::basepath
66
+
67
+ podfile_base_path = Pathname.new(File.dirname(podfile_path))
68
+
69
+ original_path = Pathname.new(File.join(original_basepath, path))
70
+ replace_path = original_path.relative_path_from(podfile_base_path)
71
+ if use_absolute_paths
72
+ replace_path = replace_path.expand_path(podfile_base_path)
73
+ end
74
+
75
+ return replace_path
76
+ end
77
+
57
78
  def self.update_gemfile
58
79
  gemfile_path = File.join(PodBuilder::home, "Gemfile")
59
80
  unless File.exist?(gemfile_path)
@@ -3,7 +3,7 @@ require 'pod_builder/core'
3
3
  module PodBuilder
4
4
  module Command
5
5
  class GenerateLFS
6
- def self.call(options)
6
+ def self.call
7
7
  Configuration.check_inited
8
8
 
9
9
  unless Configuration.lfs_update_gitattributes
@@ -3,13 +3,14 @@ require 'pod_builder/core'
3
3
  module PodBuilder
4
4
  module Command
5
5
  class GeneratePodspec
6
- def self.call(options)
6
+ def self.call
7
7
  Configuration.check_inited
8
8
  PodBuilder::prepare_basepath
9
9
 
10
10
  installer, analyzer = Analyze.installer_at(PodBuilder::basepath, false)
11
+ all_buildable_items = Analyze.podfile_items(installer, analyzer)
11
12
 
12
- Podspec::generate(analyzer)
13
+ Podspec::generate(all_buildable_items, analyzer)
13
14
 
14
15
  puts "\n\n🎉 done!\n".green
15
16
  return 0
@@ -4,7 +4,7 @@ require 'json'
4
4
  module PodBuilder
5
5
  module Command
6
6
  class Info
7
- def self.call(options)
7
+ def self.call
8
8
  Configuration.check_inited
9
9
 
10
10
  info = PodBuilder::Info.generate_info()
@@ -3,24 +3,24 @@ require 'pod_builder/core'
3
3
  module PodBuilder
4
4
  module Command
5
5
  class Init
6
- def self.call(options)
6
+ def self.call
7
7
  raise "\n\nAlready initialized\n".red if Configuration.exists
8
8
 
9
9
  xcworkspace = Dir.glob("*.xcworkspace")
10
- raise "\n\nNo xcworkspace found in current folder\n" if xcworkspace.count == 0
11
- raise "\n\nToo many xcworkspaces found in current folder\n#{xcworkspace}\n" if xcworkspace.count > 1
10
+ raise "\n\nNo xcworkspace found in current folder\n".red if xcworkspace.count == 0
11
+ raise "\n\nToo many xcworkspaces found in current folder\n#{xcworkspace}\n".red if xcworkspace.count > 1
12
12
 
13
13
  Configuration.project_name = File.basename(xcworkspace.first, ".*")
14
14
 
15
- options[:prebuild_path] ||= Configuration.base_path
15
+ OPTIONS[:prebuild_path] ||= Configuration.base_path
16
16
 
17
- if File.expand_path(options[:prebuild_path]) != options[:prebuild_path] # if not absolute
18
- options[:prebuild_path] = File.expand_path(PodBuilder::project_path(options[:prebuild_path]))
17
+ if File.expand_path(OPTIONS[:prebuild_path]) != OPTIONS[:prebuild_path] # if not absolute
18
+ OPTIONS[:prebuild_path] = File.expand_path(PodBuilder::project_path(OPTIONS[:prebuild_path]))
19
19
  end
20
20
 
21
- FileUtils.mkdir_p(options[:prebuild_path])
22
- FileUtils.mkdir_p("#{options[:prebuild_path]}/.pod_builder")
23
- FileUtils.touch("#{options[:prebuild_path]}/.pod_builder/pod_builder")
21
+ FileUtils.mkdir_p(OPTIONS[:prebuild_path])
22
+ FileUtils.mkdir_p("#{OPTIONS[:prebuild_path]}/.pod_builder")
23
+ FileUtils.touch("#{OPTIONS[:prebuild_path]}/.pod_builder/pod_builder")
24
24
 
25
25
  source_path_rel_path = "Sources"
26
26
  development_pods_config_rel_path = Configuration.dev_pods_configuration_filename
@@ -32,15 +32,22 @@ module PodBuilder
32
32
  source_path_rel_path,
33
33
  development_pods_config_rel_path]
34
34
 
35
- File.write("#{options[:prebuild_path]}/.gitignore", git_ignores.join("\n"))
35
+ File.write("#{OPTIONS[:prebuild_path]}/.gitignore", git_ignores.join("\n"))
36
36
 
37
37
  project_podfile_path = PodBuilder::project_path("Podfile")
38
- prebuilt_podfile_path = File.join(options[:prebuild_path], "Podfile")
38
+ prebuilt_podfile_path = File.join(OPTIONS[:prebuild_path], "Podfile")
39
39
  FileUtils.cp(project_podfile_path, prebuilt_podfile_path)
40
+
41
+ podfile_content = File.read(prebuilt_podfile_path)
40
42
 
41
- Podfile.add_install_block(prebuilt_podfile_path)
42
- Podfile.update_path_entires(prebuilt_podfile_path, false, PodBuilder::project_path(""))
43
- Podfile.update_project_entries(prebuilt_podfile_path, false, PodBuilder::project_path(""))
43
+ podfile_content = Podfile.add_install_block(podfile_content)
44
+ podfile_content = Podfile.update_path_entries(podfile_content, Init.method(:podfile_path_transform))
45
+ podfile_content = Podfile.update_project_entries(podfile_content, Init.method(:podfile_path_transform))
46
+ podfile_content = Podfile.update_require_entries(podfile_content, Init.method(:podfile_path_transform))
47
+
48
+ podfile_content = Podfile.prepare_for_react_native(podfile_content)
49
+
50
+ File.write(prebuilt_podfile_path, podfile_content)
44
51
 
45
52
  Configuration.write
46
53
 
@@ -52,6 +59,22 @@ module PodBuilder
52
59
 
53
60
  private
54
61
 
62
+ def self.podfile_path_transform(path)
63
+ use_absolute_paths = false
64
+ podfile_path = File.join(OPTIONS[:prebuild_path], "Podfile")
65
+ original_basepath = PodBuilder::project_path
66
+
67
+ podfile_base_path = Pathname.new(File.dirname(podfile_path))
68
+
69
+ original_path = Pathname.new(File.join(original_basepath, path))
70
+ replace_path = original_path.relative_path_from(podfile_base_path)
71
+ if use_absolute_paths
72
+ replace_path = replace_path.expand_path(podfile_base_path)
73
+ end
74
+
75
+ return replace_path
76
+ end
77
+
55
78
  def self.update_gemfile
56
79
  gemfile_path = File.join(PodBuilder::home, "Gemfile")
57
80
  unless File.exist?(gemfile_path)
@@ -3,14 +3,18 @@ require 'pod_builder/core'
3
3
  module PodBuilder
4
4
  module Command
5
5
  class InstallSources
6
- def self.call(options)
6
+ def self.call
7
7
  Configuration.check_inited
8
+ if Configuration.build_using_repo_paths
9
+ raise "\n\nSource cannot be installed because lldb shenanigans not supported when 'build_using_repo_paths' is enabled".red
10
+ end
11
+
8
12
  PodBuilder::prepare_basepath
9
13
 
10
- install_update_repo = options.fetch(:update_repos, true)
14
+ install_update_repo = OPTIONS.fetch(:update_repos, true)
11
15
  installer, analyzer = Analyze.installer_at(PodBuilder::basepath, install_update_repo)
12
- framework_items = Analyze.podfile_items(installer, analyzer).select { |x| !x.is_prebuilt }
13
- podspec_names = framework_items.map(&:podspec_name)
16
+ podfile_items = Analyze.podfile_items(installer, analyzer).select { |x| !x.is_prebuilt }
17
+ podspec_names = podfile_items.map(&:podspec_name)
14
18
 
15
19
  base_path = PodBuilder::prebuiltpath
16
20
  framework_files = Dir.glob("#{base_path}/**/*.framework")
@@ -18,15 +22,14 @@ module PodBuilder
18
22
  framework_files.each do |path|
19
23
  rel_path = Pathname.new(path).relative_path_from(Pathname.new(base_path)).to_s
20
24
 
21
- if framework_spec = framework_items.detect { |x| x.prebuilt_rel_path == rel_path }
22
- update_repo(framework_spec)
25
+ if podfile_spec = podfile_items.detect { |x| x.prebuilt_rel_path == rel_path }
26
+ update_repo(podfile_spec)
23
27
  end
24
28
  end
25
29
 
26
- Command::Clean::clean_sources()
30
+ Command::Clean::clean_sources(podspec_names)
27
31
 
28
32
  ARGV << PodBuilder::basepath("Sources")
29
- Command::UpdateLldbInit::call(options)
30
33
 
31
34
  puts "\n\n🎉 done!\n".green
32
35
  return 0
@@ -35,6 +38,10 @@ module PodBuilder
35
38
  private
36
39
 
37
40
  def self.update_repo(spec)
41
+ if spec.path != nil || spec.podspec_path != nil
42
+ return
43
+ end
44
+
38
45
  dest_path = PodBuilder::basepath("Sources")
39
46
  FileUtils.mkdir_p(dest_path)
40
47
 
@@ -43,25 +50,25 @@ module PodBuilder
43
50
 
44
51
  repo_dir = File.join(dest_path, spec.podspec_name)
45
52
  if !File.directory?(repo_dir)
46
- raise "Failed cloning #{spec.name}" if !system("git clone #{spec.repo} #{spec.podspec_name}")
53
+ raise "\n\nFailed cloning #{spec.name}".red if !system("git clone #{spec.repo} #{spec.podspec_name}")
47
54
  end
48
55
 
49
56
  Dir.chdir(repo_dir)
50
57
  puts "Checking out #{spec.podspec_name}".yellow
51
- raise "Failed cheking out #{spec.name}" if !system(git_hard_checkout_cmd(spec))
58
+ raise "\n\nFailed cheking out #{spec.name}".red if !system(git_hard_checkout_cmd(spec))
52
59
 
53
60
  Dir.chdir(current_dir)
54
61
  end
55
62
 
56
63
  def self.git_hard_checkout_cmd(spec)
57
64
  prefix = "git fetch --all --tags --prune; git reset --hard"
58
- if @tag
65
+ if spec.tag
59
66
  return "#{prefix} tags/#{spec.tag}"
60
67
  end
61
- if @commit
68
+ if spec.commit
62
69
  return "#{prefix} #{spec.commit}"
63
70
  end
64
- if @branch
71
+ if spec.branch
65
72
  return "#{prefix} origin/#{spec.branch}"
66
73
  end
67
74
 
@@ -3,8 +3,8 @@ require 'pod_builder/core'
3
3
  module PodBuilder
4
4
  module Command
5
5
  class None
6
- def self.call(options)
7
- unless !options.has_key?(:version)
6
+ def self.call
7
+ unless !OPTIONS.has_key?(:version)
8
8
  puts VERSION
9
9
  return 0
10
10
  end
@@ -3,9 +3,9 @@ require 'pod_builder/core'
3
3
  module PodBuilder
4
4
  module Command
5
5
  class RestoreAll
6
- def self.call(options)
6
+ def self.call
7
7
  unless Configuration.restore_enabled
8
- raise "Restore not enabled!".red
8
+ raise "\n\nRestore not enabled!".red
9
9
  end
10
10
 
11
11
  Configuration.check_inited
@@ -16,8 +16,8 @@ module PodBuilder
16
16
  File.rename(PodBuilder::basepath("Podfile.restore"), PodBuilder::basepath("Podfile"))
17
17
 
18
18
  ARGV << "*"
19
- options[:skip_prebuild_update] = true
20
- return Command::Build::call(options)
19
+ OPTIONS[:skip_prebuild_update] = true
20
+ return Command::Build::call
21
21
  rescue Exception => e
22
22
  raise e
23
23
  ensure
@@ -3,7 +3,7 @@ require 'pod_builder/core'
3
3
  module PodBuilder
4
4
  module Command
5
5
  class Switch
6
- def self.call(options)
6
+ def self.call
7
7
  Configuration.check_inited
8
8
  PodBuilder::prepare_basepath
9
9
 
@@ -17,25 +17,62 @@ module PodBuilder
17
17
  argument_pods.each do |pod|
18
18
  pod_name_to_switch = pod
19
19
  pod_name_to_switch = Podfile::resolve_pod_names_from_podfile([pod_name_to_switch]).first
20
- raise "\n\nDid not find pod '#{pod}'" if pod_name_to_switch.nil?
20
+ raise "\n\nDid not find pod '#{pod}'".red if pod_name_to_switch.nil?
21
21
 
22
22
  check_not_building_subspec(pod_name_to_switch)
23
23
 
24
24
  pod_names_to_switch.push(pod_name_to_switch)
25
25
  end
26
+
27
+ dep_pod_names_to_switch = []
28
+ if OPTIONS[:switch_all] == true
29
+ pod_names_to_switch.each do |pod|
30
+ podspec_path = PodBuilder::prebuiltpath("#{pod}/#{pod}.podspec")
31
+ unless File.exist?(podspec_path)
32
+ next
33
+ end
34
+
35
+ podspec_content = File.read(podspec_path)
36
+
37
+ regex = "p\\d\\.dependency '(.*)'"
38
+
39
+ podspec_content.each_line do |line|
40
+ matches = line.match(/#{regex}/)
41
+
42
+ if matches&.size == 2
43
+ dep_pod_names_to_switch.push(matches[1].split("/").first)
44
+ end
45
+ end
46
+ end
47
+
48
+ dep_pod_names_to_switch.uniq!
49
+ dep_pod_names_to_switch.reverse.each do |dep_name|
50
+ podspec_path = PodBuilder::prebuiltpath("#{dep_name}/#{dep_name}.podspec")
51
+ if File.exist?(podspec_path)
52
+ if pod = Podfile::resolve_pod_names_from_podfile([dep_name]).first
53
+ pod_names_to_switch.push(pod)
54
+ next
55
+ end
56
+ end
57
+
58
+ dep_pod_names_to_switch.delete(dep_name)
59
+ end
60
+ pod_names_to_switch = pod_names_to_switch.map { |t| t.split("/").first }.uniq
61
+ dep_pod_names_to_switch.reject { |t| pod_names_to_switch.include?(t) }
62
+ end
26
63
 
27
64
  pod_names_to_switch.each do |pod_name_to_switch|
28
65
  development_path = ""
29
66
  default_entries = Hash.new
30
67
 
31
- case options[:switch_mode]
68
+ case OPTIONS[:switch_mode]
32
69
  when "development"
33
- development_path = find_podspec(pod_name_to_switch)
70
+ development_path = find_podspec(pod_name_to_switch)
34
71
  when "prebuilt"
35
72
  podfile_path = PodBuilder::basepath("Podfile.restore")
36
73
  content = File.read(podfile_path)
37
74
  if !content.include?("pod '#{pod_name_to_switch}")
38
- raise "\n\n'#{pod_name_to_switch}' does not seem to be prebuit!"
75
+ raise "\n\n'#{pod_name_to_switch}' does not seem to be prebuit!".red
39
76
  end
40
77
  when "default"
41
78
  podfile_path = PodBuilder::basepath("Podfile")
@@ -57,7 +94,15 @@ module PodBuilder
57
94
  end
58
95
  end
59
96
 
60
- raise "\n\n'#{pod_name_to_switch}' not found in #{podfile_path}" if default_entries.keys.count == 0
97
+ raise "\n\n'#{pod_name_to_switch}' not found in #{podfile_path}".red if default_entries.keys.count == 0
98
+ end
99
+
100
+ if development_path.nil?
101
+ if dep_pod_names_to_switch.include?(pod_name_to_switch)
102
+ next
103
+ else
104
+ raise "\n\nCouln't find `#{pod_name_to_switch}` sources in the following specified development pod paths:\n#{Configuration.development_pods_paths.join("\n")}\n".red
105
+ end
61
106
  end
62
107
 
63
108
  podfile_path = PodBuilder::project_path("Podfile")
@@ -74,10 +119,11 @@ module PodBuilder
74
119
  matches = line.gsub("\"", "'").match(/pod '(.*?)',(.*)/)
75
120
  if matches&.size == 3
76
121
  if matches[1].split("/").first == pod_name_to_switch
77
- case options[:switch_mode]
122
+ case OPTIONS[:switch_mode]
78
123
  when "prebuilt"
79
124
  indentation = line.split("pod '").first
80
- rel_path = Pathname.new(PodBuilder::prebuiltpath).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
125
+ podspec_path = File.dirname(PodBuilder::prebuiltpath("#{pod_name_to_switch}/#{pod_name_to_switch}.podspec"))
126
+ rel_path = Pathname.new(podspec_path).relative_path_from(Pathname.new(PodBuilder::project_path)).to_s
81
127
  prebuilt_line = "#{indentation}pod '#{matches[1]}', :path => '#{rel_path}'\n"
82
128
  if line.include?("# pb<") && marker = line.split("# pb<").last
83
129
  prebuilt_line = prebuilt_line.chomp("\n") + " # pb<#{marker}"
@@ -102,10 +148,10 @@ module PodBuilder
102
148
  lines.append(default_line)
103
149
  next
104
150
  elsif
105
- raise "Line for pod '#{matches[1]}' in section '#{current_section}' not found in PodBuilder's Podfile"
151
+ raise "\n\nLine for pod '#{matches[1]}' in section '#{current_section}' not found in PodBuilder's Podfile".red
106
152
  end
107
153
  else
108
- raise "Unsupported mode '#{options[:switch_mode]}'"
154
+ raise "\n\nUnsupported mode '#{OPTIONS[:switch_mode]}'".red
109
155
  end
110
156
  end
111
157
  end
@@ -144,10 +190,6 @@ module PodBuilder
144
190
  end
145
191
  end
146
192
 
147
- if podspec_path.nil?
148
- raise "\n\nCouln't find `#{podname}` sources in the following specified development pod paths:\n#{Configuration.development_pods_paths.join("\n")}\n".red
149
- end
150
-
151
193
  return podspec_path
152
194
  end
153
195
 
@@ -3,11 +3,11 @@ require 'pod_builder/core'
3
3
  module PodBuilder
4
4
  module Command
5
5
  class SyncPodfile
6
- def self.call(options)
6
+ def self.call
7
7
  Configuration.check_inited
8
8
  PodBuilder::prepare_basepath
9
9
 
10
- install_update_repo = options.fetch(:update_repos, true)
10
+ install_update_repo = OPTIONS.fetch(:update_repos, true)
11
11
  installer, analyzer = Analyze.installer_at(PodBuilder::basepath, install_update_repo)
12
12
 
13
13
  all_buildable_items = Analyze.podfile_items(installer, analyzer)
@@ -25,6 +25,7 @@ module PodBuilder
25
25
  system("#{bundler_prefix}pod install;")
26
26
  end
27
27
 
28
+ puts "\n\n🎉 done!\n".green
28
29
  return 0
29
30
  end
30
31
  end