lib/pod/command/gd.rb in cocoapods-gd-0.0.1 vs lib/pod/command/gd.rb in cocoapods-gd-0.0.2

- old
+ new

@@ -9,11 +9,11 @@ ] def self.options [ ['--spec-sources=private,https://github.com/CocoaPods/Specs.git', '指定source源'], - ['--upload', '是否上传,默认上传'], + ['--upload', '是否上传,默认不上传'], ['--upload-spec-name', '上传仓库必要参数,二进制源对应的spec版本仓库名称'], ['--upload-git-sources', '上传仓库必要参数,二进制源对应的git源码仓库名称'], ['--upload-local-path', '上传仓库必要参数,git源码仓库映射的本地路径'], ] end @@ -34,27 +34,23 @@ @spec_sources = argv.option('spec-sources', 'https://gitlab.gaodun.com/iOSLibs/CocoaPods.git').split(',') # 'https://github.com/CocoaPods/Specs.git' @spec_sources.push('https://gitlab.gaodun.com/iOSLibs/Specs.git') # 是否上传 - @upload = argv.option('upload') + @upload = argv.flag?('upload') # 上传二进制源仓库名称 @upload_spec_name = argv.option('upload-spec-name') # 上传二进制源仓库地址 @upload_git_sources = argv.option('upload-git-sources') # 二进制源本地仓库地址 @upload_local_path = argv.option('upload-local-path') - if @upload.nil? - @upload = 1 - end - if @upload_spec_name.nil? - @upload_spec_name = "frameworks-specs" + @upload_spec_name = "lizuba-frameworks-specs" end if @upload_git_sources.nil? @upload_git_sources = "https://gitlab.gaodun.com/iOSLibs/Frameworks/raw/master" end if @upload_local_path.nil? @@ -78,25 +74,34 @@ return end target_dir, work_dir = create_working_directory return if target_dir.nil? build_gd + build_path="#{Dir.pwd}/build" if File.exist?("#{build_path}") FileUtils.rm_rf('build/') end + podspec_path="#{Dir.pwd}/replaced.podspec" + if File.exist?("#{podspec_path}") + FileUtils.rm_rf("#{podspec_path}") + end + json_path="#{Dir.pwd}/replaced.podspec.json" + if File.exist?("#{json_path}") + FileUtils.rm_rf("#{json_path}") + end `mv "#{work_dir}" "#{target_dir}"` Dir.chdir(@source_dir) - if @upload == 1 - uploader = Uploader.new(@spec, @upload_spec_name, @upload_local_path, @spec_sources) + if @upload == true + uploader = GDUploader.new(@spec, @upload_spec_name, @upload_local_path, @spec_sources) end end private - def build_in_sandbox(platform) + def gd_build_in_sandbox(platform) config.installation_root = Pathname.new(Dir.pwd) config.sandbox_root = 'Pods' static_sandbox = build_static_sandbox(@dynamic) static_installer = install_pod(platform.name, static_sandbox) @@ -105,24 +110,24 @@ dynamic_sandbox = build_dynamic_sandbox(static_sandbox, static_installer) install_dynamic_pod(dynamic_sandbox, static_sandbox, static_installer, platform) end begin - perform_build(platform, static_sandbox, dynamic_sandbox, static_installer) + gd_perform_build(platform, static_sandbox, dynamic_sandbox, static_installer) ensure # in case the build fails; see Builder#xcodebuild. Pathname.new(config.sandbox_root).rmtree FileUtils.rm_f('Podfile.lock') end end def build_gd - builder = SpecBuilder.new(@spec, @source, @embedded, @dynamic, @upload_git_sources) + builder = GDSpecBuilder.new(@spec, @source, @embedded, @dynamic, @upload_git_sources) newspec = builder.spec_metadata @spec.available_platforms.each do |platform| if platform.name == :ios - build_in_sandbox(platform) + gd_build_in_sandbox(platform) newspec += builder.spec_platform(platform) end end newspec += builder.spec_close @@ -151,10 +156,10 @@ Dir.chdir(work_dir) [target_dir, work_dir] end - def perform_build(platform, static_sandbox, dynamic_sandbox, static_installer) + def gd_perform_build(platform, static_sandbox, dynamic_sandbox, static_installer) static_sandbox_root = config.sandbox_root.to_s if @dynamic static_sandbox_root = "#{static_sandbox_root}/#{static_sandbox.root.to_s.split('/').last}" dynamic_sandbox_root = "#{config.sandbox_root}/#{dynamic_sandbox.root.to_s.split('/').last}" end