cocoapods-binary-artifactory-cache 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.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cocoapods-binary-artifactory-cache/cache/all.rb +9 -0
  3. data/lib/cocoapods-binary-artifactory-cache/cache/validation_result.rb +73 -0
  4. data/lib/cocoapods-binary-artifactory-cache/cache/validator.rb +20 -0
  5. data/lib/cocoapods-binary-artifactory-cache/cache/validator_accumulated.rb +4 -0
  6. data/lib/cocoapods-binary-artifactory-cache/cache/validator_base.rb +112 -0
  7. data/lib/cocoapods-binary-artifactory-cache/cache/validator_dependencies_graph.rb +25 -0
  8. data/lib/cocoapods-binary-artifactory-cache/cache/validator_dev_pods.rb +30 -0
  9. data/lib/cocoapods-binary-artifactory-cache/cache/validator_exclusion.rb +14 -0
  10. data/lib/cocoapods-binary-artifactory-cache/cache/validator_non_dev_pods.rb +13 -0
  11. data/lib/cocoapods-binary-artifactory-cache/cache/validator_with_podfile.rb +9 -0
  12. data/lib/cocoapods-binary-artifactory-cache/dependencies_graph/dependencies_graph.rb +108 -0
  13. data/lib/cocoapods-binary-artifactory-cache/dependencies_graph/graph_visualizer.rb +65 -0
  14. data/lib/cocoapods-binary-artifactory-cache/diagnosis/base.rb +13 -0
  15. data/lib/cocoapods-binary-artifactory-cache/diagnosis/diagnosis.rb +24 -0
  16. data/lib/cocoapods-binary-artifactory-cache/diagnosis/integration.rb +23 -0
  17. data/lib/cocoapods-binary-artifactory-cache/env.rb +32 -0
  18. data/lib/cocoapods-binary-artifactory-cache/helper/benchmark_show.rb +11 -0
  19. data/lib/cocoapods-binary-artifactory-cache/helper/checksum.rb +18 -0
  20. data/lib/cocoapods-binary-artifactory-cache/helper/json.rb +37 -0
  21. data/lib/cocoapods-binary-artifactory-cache/helper/lockfile.rb +90 -0
  22. data/lib/cocoapods-binary-artifactory-cache/helper/path_utils.rb +8 -0
  23. data/lib/cocoapods-binary-artifactory-cache/helper/podspec.rb +20 -0
  24. data/lib/cocoapods-binary-artifactory-cache/hooks/post_install.rb +23 -0
  25. data/lib/cocoapods-binary-artifactory-cache/hooks/pre_install.rb +121 -0
  26. data/lib/cocoapods-binary-artifactory-cache/main.rb +21 -0
  27. data/lib/cocoapods-binary-artifactory-cache/pod-binary/LICENSE.txt +22 -0
  28. data/lib/cocoapods-binary-artifactory-cache/pod-binary/helper/build.rb +37 -0
  29. data/lib/cocoapods-binary-artifactory-cache/pod-binary/helper/detected_prebuilt_pods/installer.rb +25 -0
  30. data/lib/cocoapods-binary-artifactory-cache/pod-binary/helper/detected_prebuilt_pods/target_definition.rb +29 -0
  31. data/lib/cocoapods-binary-artifactory-cache/pod-binary/helper/names.rb +27 -0
  32. data/lib/cocoapods-binary-artifactory-cache/pod-binary/helper/podfile_options.rb +2 -0
  33. data/lib/cocoapods-binary-artifactory-cache/pod-binary/helper/prebuild_sandbox.rb +71 -0
  34. data/lib/cocoapods-binary-artifactory-cache/pod-binary/helper/sandbox.rb +9 -0
  35. data/lib/cocoapods-binary-artifactory-cache/pod-binary/helper/target_checker.rb +42 -0
  36. data/lib/cocoapods-binary-artifactory-cache/pod-binary/integration/alter_specs.rb +150 -0
  37. data/lib/cocoapods-binary-artifactory-cache/pod-binary/integration/patch/embed_framework_script.rb +36 -0
  38. data/lib/cocoapods-binary-artifactory-cache/pod-binary/integration/patch/resolve_dependencies.rb +20 -0
  39. data/lib/cocoapods-binary-artifactory-cache/pod-binary/integration/patch/sandbox_analyzer_state.rb +29 -0
  40. data/lib/cocoapods-binary-artifactory-cache/pod-binary/integration/patch/source_installation.rb +55 -0
  41. data/lib/cocoapods-binary-artifactory-cache/pod-binary/integration/source_installer.rb +114 -0
  42. data/lib/cocoapods-binary-artifactory-cache/pod-binary/integration/validation.rb +20 -0
  43. data/lib/cocoapods-binary-artifactory-cache/pod-binary/integration.rb +11 -0
  44. data/lib/cocoapods-binary-artifactory-cache/pod-binary/prebuild.rb +166 -0
  45. data/lib/cocoapods-binary-artifactory-cache/pod-binary/prebuild_dsl.rb +10 -0
  46. data/lib/cocoapods-binary-artifactory-cache/pod-binary/prebuild_hook.rb +10 -0
  47. data/lib/cocoapods-binary-artifactory-cache/pod-rome/LICENSE.txt +22 -0
  48. data/lib/cocoapods-binary-artifactory-cache/pod-rome/xcodebuild_command.rb +261 -0
  49. data/lib/cocoapods-binary-artifactory-cache/pod-rome/xcodebuild_raw.rb +64 -0
  50. data/lib/cocoapods-binary-artifactory-cache/prebuild_output/metadata.rb +63 -0
  51. data/lib/cocoapods-binary-artifactory-cache/prebuild_output/output.rb +44 -0
  52. data/lib/cocoapods-binary-artifactory-cache/state_store.rb +21 -0
  53. data/lib/cocoapods-binary-artifactory-cache/ui.rb +9 -0
  54. data/lib/cocoapods-binary-artifactory-cache.rb +2 -0
  55. data/lib/cocoapods_plugin.rb +5 -0
  56. data/lib/command/binary.rb +36 -0
  57. data/lib/command/config.rb +228 -0
  58. data/lib/command/executor/base.rb +23 -0
  59. data/lib/command/executor/fetcher.rb +89 -0
  60. data/lib/command/executor/prebuilder.rb +77 -0
  61. data/lib/command/executor/visualizer.rb +23 -0
  62. data/lib/command/fetch.rb +40 -0
  63. data/lib/command/helper/zip.rb +25 -0
  64. data/lib/command/prebuild.rb +51 -0
  65. data/lib/command/visualize.rb +34 -0
  66. metadata +207 -0
@@ -0,0 +1,228 @@
1
+ require_relative "../cocoapods-binary-artifactory-cache/helper/json"
2
+
3
+ module PodPrebuild
4
+ def self.config
5
+ PodPrebuild::Config.instance
6
+ end
7
+
8
+ class Config # rubocop:disable Metrics/ClassLength
9
+ attr_accessor :dsl_config, :cli_config
10
+
11
+ def initialize(path)
12
+ @deprecated_config = File.exist?(path) ? PodPrebuild::JSONFile.new(path).data : {}
13
+ @dsl_config = {}
14
+ @cli_config = {}
15
+ @detected_config = {}
16
+ end
17
+
18
+ def self.instance
19
+ @instance ||= new("PodBinaryCacheConfig.json")
20
+ end
21
+
22
+ def reset!
23
+ @deprecated_config = {}
24
+ @dsl_config = {}
25
+ @cli_config = {}
26
+ end
27
+
28
+ def cache_repo
29
+ @cache_repo ||= cache_repo_config["remote"]
30
+ end
31
+
32
+ def local_cache?
33
+ cache_repo.nil?
34
+ end
35
+
36
+ def cache_path
37
+ @cache_path ||= File.expand_path(cache_repo_config["local"])
38
+ end
39
+
40
+ def prebuild_sandbox_path
41
+ @dsl_config[:prebuild_sandbox_path] || @deprecated_config["prebuild_path"] || "_Prebuild"
42
+ end
43
+
44
+ def prebuild_delta_path
45
+ @dsl_config[:prebuild_delta_path] || @deprecated_config["prebuild_delta_path"] || "_Prebuild_delta/changes.json"
46
+ end
47
+
48
+ def manifest_path(in_cache: false)
49
+ root_dir(in_cache) + "/Manifest.lock"
50
+ end
51
+
52
+ def root_dir(in_cache)
53
+ in_cache ? cache_path : prebuild_sandbox_path
54
+ end
55
+
56
+ def generated_frameworks_dir(in_cache: false)
57
+ root_dir(in_cache) + "/GeneratedFrameworks"
58
+ end
59
+
60
+ def prebuilt_path(path: nil)
61
+ p = Pathname.new(path.nil? ? "_Prebuilt" : "_Prebuilt/#{path}")
62
+ p = p.sub_ext(".xcframework") if xcframework? && p.extname == ".framework"
63
+ p.to_s
64
+ end
65
+
66
+ def validate_dsl_config
67
+ inapplicable_options = @dsl_config.keys - applicable_dsl_config
68
+ return if inapplicable_options.empty?
69
+
70
+ message = <<~HEREDOC
71
+ [WARNING] The following options (in `config_cocoapods_binary_cache`) are not correct: #{inapplicable_options}.
72
+ Available options: #{applicable_dsl_config}.
73
+ Check out the following doc for more details
74
+ https://github.com/grab/cocoapods-binary-cache/blob/master/docs/configure_cocoapods_binary_cache.md
75
+ HEREDOC
76
+
77
+ Pod::UI.puts message.yellow
78
+ end
79
+
80
+ def prebuild_config
81
+ @cli_config[:prebuild_config] || @dsl_config[:prebuild_config] || "Debug"
82
+ end
83
+
84
+ def prebuild_job?
85
+ @cli_config[:prebuild_job] || @dsl_config[:prebuild_job]
86
+ end
87
+
88
+ def fetch_job?
89
+ @cli_config[:fetch_job] || @dsl_config[:fetch_job]
90
+ end
91
+
92
+ def prebuild_all_pods?
93
+ @cli_config[:prebuild_all_pods] || @dsl_config[:prebuild_all_pods]
94
+ end
95
+
96
+ def excluded_pods
97
+ ((@dsl_config[:excluded_pods] || Set.new) + (@detected_config[:excluded_pods] || Set.new)).to_set
98
+ end
99
+
100
+ def dev_pods_enabled?
101
+ @dsl_config[:dev_pods_enabled]
102
+ end
103
+
104
+ def bitcode_enabled?
105
+ @dsl_config[:bitcode_enabled]
106
+ end
107
+
108
+ def device_build_enabled?
109
+ @dsl_config[:device_build_enabled]
110
+ end
111
+
112
+ def xcframework?
113
+ @dsl_config[:xcframework]
114
+ end
115
+
116
+ def disable_dsym?
117
+ @dsl_config[:disable_dsym]
118
+ end
119
+
120
+ def dont_remove_source_code?
121
+ @dsl_config[:dont_remove_source_code]
122
+ end
123
+
124
+ def xcodebuild_log_path
125
+ @dsl_config[:xcodebuild_log_path]
126
+ end
127
+
128
+ def build_args
129
+ @dsl_config[:build_args]
130
+ end
131
+
132
+ def save_cache_validation_to
133
+ @dsl_config[:save_cache_validation_to]
134
+ end
135
+
136
+ def validate_prebuilt_settings
137
+ @dsl_config[:validate_prebuilt_settings]
138
+ end
139
+
140
+ def prebuild_code_gen
141
+ @dsl_config[:prebuild_code_gen]
142
+ end
143
+
144
+ def strict_diagnosis?
145
+ @dsl_config[:strict_diagnosis]
146
+ end
147
+
148
+ def silent_build?
149
+ @dsl_config[:silent_build]
150
+ end
151
+
152
+ def targets_to_prebuild_from_cli
153
+ @cli_config[:prebuild_targets] || []
154
+ end
155
+
156
+ def update_detected_prebuilt_pod_names!(value)
157
+ @detected_config[:prebuilt_pod_names] = value
158
+ end
159
+
160
+ def update_detected_excluded_pods!(value)
161
+ @detected_config[:excluded_pods] = value
162
+ end
163
+
164
+ def prebuilt_pod_names
165
+ @detected_config[:prebuilt_pod_names] || Set.new
166
+ end
167
+
168
+ def tracked_prebuilt_pod_names
169
+ prebuilt_pod_names - excluded_pods
170
+ end
171
+
172
+ def artifactory_login
173
+ @cli_config[:artifactory_login]
174
+ end
175
+
176
+ def artifactory_password
177
+ @cli_config[:artifactory_password]
178
+ end
179
+
180
+ private
181
+
182
+ def applicable_dsl_config
183
+ [
184
+ :cache_repo,
185
+ :prebuild_sandbox_path,
186
+ :prebuild_delta_path,
187
+ :prebuild_config,
188
+ :prebuild_job,
189
+ :fetch_job,
190
+ :prebuild_all_pods,
191
+ :excluded_pods,
192
+ :dev_pods_enabled,
193
+ :bitcode_enabled,
194
+ :device_build_enabled,
195
+ :xcframework,
196
+ :disable_dsym,
197
+ :dont_remove_source_code,
198
+ :xcodebuild_log_path,
199
+ :build_args,
200
+ :save_cache_validation_to,
201
+ :validate_prebuilt_settings,
202
+ :prebuild_code_gen,
203
+ :strict_diagnosis,
204
+ :silent_build
205
+ ]
206
+ end
207
+
208
+ def cache_repo_config
209
+ @cache_repo_config ||= begin
210
+ repo = @cli_config[:repo] || "default"
211
+ config_ = @dsl_config[:cache_repo] || {}
212
+ if config_[repo].nil?
213
+ message = <<~HEREDOC
214
+ [Deprecated] Configs in `PodBinaryCacheConfig.json` are deprecated.
215
+ Declare option `cache_repo` in `config_cocoapods_binary_cache` instead.
216
+ Check out the following doc for more details
217
+ https://github.com/grab/cocoapods-binary-cache/blob/master/docs/configure_cocoapods_binary_cache.md
218
+ HEREDOC
219
+ Pod::UI.puts message.yellow
220
+ end
221
+ config_[repo] || {
222
+ "remote" => @deprecated_config["cache_repo"] || @deprecated_config["prebuilt_cache_repo"],
223
+ "local" => @deprecated_config["cache_path"] || "~/.cocoapods-binary-cache/prebuilt-frameworks"
224
+ }
225
+ end
226
+ end
227
+ end
228
+ end
@@ -0,0 +1,23 @@
1
+ module PodPrebuild
2
+ class CommandExecutor
3
+ def initialize(options)
4
+ @config = options[:config]
5
+ prepare_cache_dir
6
+ end
7
+
8
+ def installer
9
+ @installer ||= begin
10
+ pod_config = Pod::Config.instance
11
+ Pod::Installer.new(pod_config.sandbox, pod_config.podfile, pod_config.lockfile)
12
+ end
13
+ end
14
+
15
+ def use_local_cache?
16
+ @config.cache_repo.nil?
17
+ end
18
+
19
+ def prepare_cache_dir
20
+ FileUtils.mkdir_p(@config.cache_path) if @config.cache_path
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,89 @@
1
+ require "parallel"
2
+ require_relative "base"
3
+ require_relative "../helper/zip"
4
+ require 'open-uri'
5
+
6
+ module PodPrebuild
7
+ class CacheFetcher < CommandExecutor
8
+ @resolved_targets = []
9
+
10
+ def initialize(options)
11
+ super(options)
12
+ end
13
+
14
+ def run
15
+ Pod::UI.step("Fetching cache") do
16
+ FileUtils.mkdir_p(@config.prebuild_sandbox_path)
17
+ @binary_installer = Pod::PrebuildInstaller.new(
18
+ sandbox: Pod::PrebuildSandbox.from_standard_sandbox(installer.sandbox),
19
+ podfile: installer.podfile,
20
+ lockfile: installer.lockfile,
21
+ cache_validation: nil
22
+ )
23
+
24
+ Pod::UI.title("Generate Manifest") do
25
+ @binary_installer.clean_delta_file
26
+ @binary_installer.install!
27
+ end
28
+ @resolved_targets = @binary_installer.pod_targets
29
+ fetch_remote_cache(@config.cache_repo, @config.cache_path)
30
+ unzip_cache
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def fetch_remote_cache(repo, dest_dir)
37
+ Pod::UI.puts "Fetching cache from #{repo}".green
38
+ Parallel.each(@resolved_targets, in_threads: 1) do |name|
39
+ to_dir = @config.generated_frameworks_dir(in_cache: true) + "/#{name}"
40
+ unless to_dir.nil?
41
+ FileUtils.mkdir_p(to_dir)
42
+ end
43
+ end
44
+ cache_paths = @resolved_targets.map {|target| "/#{target.name}/#{target.version}.zip"}
45
+ Parallel.each(cache_paths, in_threads: 8) do |path|
46
+ cache_path = @config.generated_frameworks_dir(in_cache: true) + path
47
+ if File.exists?(cache_path) == false || File.zero?(cache_path) == true
48
+ File.open(cache_path, "wb") do |file|
49
+ begin
50
+ file.write open(repo + path, :http_basic_authentication => [@config.artifactory_login, @config.artifactory_password]).read
51
+ Pod::UI.puts "Successful download from cache #{path}".green
52
+ rescue OpenURI::HTTPError => error
53
+ response = error.io
54
+ response.status
55
+ if response.status[0] == "404"
56
+ Pod::UI.puts "Not found in cache #{path}".yellow
57
+ else
58
+ Pod::UI.puts "Error download cache (#{response.status[0]}) #{response.status[1]}".red
59
+ end
60
+ file.close unless file.closed?
61
+ File.delete(file)
62
+ end
63
+ end
64
+ else
65
+ Pod::UI.puts "Found in local cache #{path}".green
66
+ end
67
+ end
68
+ end
69
+
70
+ def unzip_cache
71
+ Pod::UI.puts "Unzipping cache: #{@config.cache_path} -> #{@config.prebuild_sandbox_path}".green
72
+ to_remain_files = ["Manifest.lock"]
73
+ to_delete_files = @binary_installer.sandbox.root.children.reject { |file| to_remain_files.include?(File.basename(file)) }
74
+ to_delete_files.each { |file| file.rmtree if file.exist? }
75
+ if File.exist?(@config.manifest_path(in_cache: true))
76
+ FileUtils.cp(
77
+ @config.manifest_path(in_cache: true),
78
+ @config.manifest_path
79
+ )
80
+ end
81
+ zip_paths = @resolved_targets.map {|target| @config.generated_frameworks_dir(in_cache: true) + "/#{target.name}/#{target.version}.zip"}
82
+ Parallel.each(zip_paths, in_threads: 8) do |path|
83
+ if File.exists? path
84
+ ZipUtils.unzip(path, to_dir: @config.generated_frameworks_dir)
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,77 @@
1
+ require_relative "base"
2
+ require_relative "fetcher"
3
+
4
+ module PodPrebuild
5
+ class CachePrebuilder < CommandExecutor
6
+ attr_reader :repo_update, :fetcher, :pusher
7
+
8
+ def initialize(options)
9
+ super(options)
10
+ @repo_update = options[:repo_update]
11
+ end
12
+
13
+ def run
14
+ prebuild
15
+ changes = PodPrebuild::JSONFile.new(@config.prebuild_delta_path)
16
+ return if changes.empty?
17
+
18
+ sync_cache(changes)
19
+ end
20
+
21
+ private
22
+
23
+ def prebuild
24
+ Pod::UI.step("Installation") do
25
+ installer.repo_update = @repo_update
26
+ installer.install!
27
+
28
+ end
29
+ end
30
+
31
+ def sync_cache(changes)
32
+ Pod::UI.step("Syncing cache") do
33
+ FileUtils.cp(@config.manifest_path, @config.manifest_path(in_cache: true))
34
+ clean_cache(changes["deleted"])
35
+ zip_to_cache(changes["updated"])
36
+ end
37
+ end
38
+
39
+ def zip_to_cache(pods_to_update)
40
+ FileUtils.mkdir_p(@config.generated_frameworks_dir(in_cache: true))
41
+ pods_to_update.each do |pod|
42
+ Pod::UI.puts "- Update cache: #{pod}"
43
+ currentTarget = installer.pod_targets.select {|e| e.name == pod}.first
44
+
45
+ ZipUtils.zip(
46
+ "#{@config.generated_frameworks_dir}/#{pod}",
47
+ to_dir: "#{@config.generated_frameworks_dir(in_cache: true)}/#{currentTarget.name}/",
48
+ name: "#{currentTarget.version}"
49
+ )
50
+
51
+ uri = URI.parse(@config.cache_repo + "/#{currentTarget.name}/#{currentTarget.version}.zip")
52
+ file = "#{@config.generated_frameworks_dir(in_cache: true)}/#{currentTarget.name}/#{currentTarget.version}.zip"
53
+ http = Net::HTTP.new(uri.host, uri.port)
54
+ http.use_ssl = true
55
+ request = Net::HTTP::Put.new(uri.request_uri)
56
+ request.basic_auth @config.artifactory_login, @config.artifactory_password
57
+ request.body_stream = File.open(file)
58
+ request["Content-Type"] = "multipart/form-data"
59
+ request.add_field('Content-Length', File.size(file))
60
+ response=http.request(request)
61
+ if response.code == "201"
62
+ Pod::UI.puts " Successfull uploaded #{pod} (#{response.code}) to artifactory".green
63
+ else
64
+ Pod::UI.puts " Error upload #{pod} to artifactory".red
65
+ Pod::UI.puts "#{response.body}".red
66
+ end
67
+ end
68
+ end
69
+
70
+ def clean_cache(pods_to_delete)
71
+ pods_to_delete.each do |pod|
72
+ Pod::UI.puts "- Clean up cache: #{pod}"
73
+ FileUtils.rm_rf("#{@config.generated_frameworks_dir(in_cache: true)}/#{pod}.zip")
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,23 @@
1
+ require_relative "base"
2
+ require_relative "../../cocoapods-binary-artifactory-cache/dependencies_graph/dependencies_graph"
3
+
4
+ module PodPrebuild
5
+ class Visualizer < CommandExecutor
6
+ def initialize(options)
7
+ super(options)
8
+ @lockfile = options[:lockfile]
9
+ @open = options[:open]
10
+ @output_dir = options[:output_dir]
11
+ @devpod_only = options[:devpod_only]
12
+ @max_deps = options[:max_deps]
13
+ end
14
+
15
+ def run
16
+ FileUtils.mkdir_p(@output_dir)
17
+ graph = DependenciesGraph.new(lockfile: @lockfile, devpod_only: @devpod_only, max_deps: @max_deps)
18
+ output_path = "#{@output_dir}/graph.png"
19
+ graph.write_graphic_file(output_path: output_path)
20
+ system("open #{@output_path}") if @open
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,40 @@
1
+ require_relative "executor/fetcher"
2
+ require 'io/console'
3
+
4
+ module Pod
5
+ class Command
6
+ class Binary < Command
7
+ class Fetch < Binary
8
+ self.arguments = [CLAide::Argument.new("CACHE-BRANCH", false)]
9
+ def initialize(argv)
10
+ super
11
+ unless ENV['ARTIFACTORY_LOGIN'].nil? && ENV['ARTIFACTORY_PASSWORD'].nil?
12
+ update_cli_config(
13
+ :artifactory_login => ENV['CI_ARTIFACTORY_LOGIN'],
14
+ :artifactory_password => ENV['ARTIFACTORY_PASSWORD']
15
+ )
16
+ else
17
+ Pod::UI.puts "Enter Artifactory login:"
18
+ login = IO::console.gets.strip
19
+ Pod::UI.puts "Enter Artifactory password:"
20
+ password = IO::console.getpass
21
+ update_cli_config(
22
+ :artifactory_login => login,
23
+ :artifactory_password => password
24
+ )
25
+ end
26
+ update_cli_config(
27
+ :fetch_job => true
28
+ )
29
+ @fetcher = PodPrebuild::CacheFetcher.new(
30
+ config: prebuild_config,
31
+ )
32
+ end
33
+
34
+ def run
35
+ @fetcher.run
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,25 @@
1
+ module PodPrebuild
2
+ module ZipUtils
3
+ def self.zip(path, to_dir: nil, name: nil)
4
+ basename = File.basename(path)
5
+ toname = name.nil? ? basename : name
6
+ unless to_dir.nil?
7
+ FileUtils.mkdir_p(to_dir)
8
+ end
9
+
10
+ out_path = to_dir.nil? ? "#{toname}.zip" : "#{to_dir}/#{toname}.zip"
11
+ cmd = []
12
+ cmd << "cd" << File.dirname(path)
13
+ cmd << "&& zip -r --symlinks" << out_path << basename
14
+ cmd << "&& cd -"
15
+ `#{cmd.join(" ")}`
16
+ end
17
+
18
+ def self.unzip(path, to_dir: nil)
19
+ cmd = []
20
+ cmd << "unzip -nq" << path
21
+ cmd << "-d" << to_dir unless to_dir.nil?
22
+ `#{cmd.join(" ")}`
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,51 @@
1
+ require_relative "executor/prebuilder"
2
+ require_relative "../cocoapods-binary-artifactory-cache/pod-binary/prebuild_dsl"
3
+
4
+ module Pod
5
+ class Command
6
+ class Binary < Command
7
+ class Prebuild < Binary
8
+ attr_reader :prebuilder
9
+
10
+ self.arguments = [CLAide::Argument.new("CACHE-BRANCH", false)]
11
+ def self.options
12
+ [
13
+ ["--config", "Config (Debug, Test...) to prebuild"],
14
+ ["--repo-update", "Update pod repo before installing"],
15
+ ["--all", "Prebuild all binary pods regardless of cache validation"],
16
+ ["--targets", "Targets to prebuild. Use comma (,) to specify a list of targets"]
17
+ ].concat(super)
18
+ end
19
+
20
+ def initialize(argv)
21
+ super
22
+ unless ENV['ARTIFACTORY_LOGIN'].nil? && ENV['ARTIFACTORY_PASSWORD'].nil?
23
+ update_cli_config(
24
+ :artifactory_login => ENV['ARTIFACTORY_LOGIN'],
25
+ :artifactory_password => ENV['ARTIFACTORY_PASSWORD']
26
+ )
27
+ else
28
+ Pod::UI.puts "Please configure ARTIFACTORY_LOGIN and ARTIFACTORY_PASSWORD envirement to use prebuild".red
29
+ exit
30
+ end
31
+ prebuild_all_pods = argv.flag?("all")
32
+ prebuild_targets = argv.option("targets", "").split(",")
33
+ update_cli_config(
34
+ :prebuild_job => true,
35
+ :prebuild_all_pods => prebuild_all_pods,
36
+ :prebuild_config => argv.option("config")
37
+ )
38
+ update_cli_config(:prebuild_targets => prebuild_targets) unless prebuild_all_pods
39
+ @prebuilder = PodPrebuild::CachePrebuilder.new(
40
+ config: prebuild_config,
41
+ repo_update: argv.flag?("repo-update")
42
+ )
43
+ end
44
+
45
+ def run
46
+ @prebuilder.run
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,34 @@
1
+ require_relative "executor/visualizer"
2
+
3
+ module Pod
4
+ class Command
5
+ class Binary < Command
6
+ class Viz < Binary
7
+ self.arguments = [CLAide::Argument.new("OUTPUT-DIR", false)]
8
+ def self.options
9
+ [
10
+ ["--open", "Open the graph upon completion"],
11
+ ["--devpod_only", "Only include development pod"],
12
+ ["--max_deps", "Only include pod with number of dependencies <= max_deps"]
13
+ ]
14
+ end
15
+
16
+ def initialize(argv)
17
+ super
18
+ @visualizer = PodPrebuild::Visualizer.new(
19
+ config: prebuild_config,
20
+ lockfile: config.lockfile,
21
+ output_dir: argv.shift_argument || ".",
22
+ open: argv.flag?("open"),
23
+ devpod_only: argv.flag?("devpod_only"),
24
+ max_deps: argv.option("max_deps")
25
+ )
26
+ end
27
+
28
+ def run
29
+ @visualizer.run
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end