lib/cocoapods-flutter/native/podfile.rb in cocoapods-flutter-dt-0.0.2 vs lib/cocoapods-flutter/native/podfile.rb in cocoapods-flutter-dt-0.0.3

- old
+ new

@@ -1,8 +1,9 @@ require 'digest' require 'open-uri' require 'json' +require 'cocoapods-flutter/native/archive/archive' module Pod class Podfile module DSL # require @@ -12,22 +13,59 @@ # name flutter project name def flutter_pod(name = nil, *requirements) unless name raise StandardError, 'A dependency requires a name.' end - + # { + # :git => { + # :url => '', + # :ref => '', + # :wrapper => 'flutterw' + # } + # } flutter_project_name = name flutter_project_mode = parse_key(:mode, requirements) flutter_project_path = parse_key(:path, requirements) + flutter_project_repo = parse_key(:git, requirements) + flutter_project_repo_url = flutter_project_repo[:url] + flutter_project_repo_ref = flutter_project_repo[:ref] + flutter_command_wrapper = flutter_project_repo[:wrapper] flutter_project_version = parse_version requirements if flutter_project_mode.nil? flutter_project_mode = "release" end unless flutter_project_path.nil? - UI.info "Using local flutter project.." + UI.info "Using local flutter project..." load File.join(flutter_project_path, '.ios', 'Flutter', 'podhelper.rb') install_all_flutter_pods flutter_project_path + return + end + + unless flutter_project_repo.nil? + UI.info "Using git source..." + if flutter_project_repo_ref.nil? + flutter_project_repo_ref = 'master' + end + + if flutter_command_wrapper.nil? + flutter_command_wrapper = 'flutter' + end + + flutter_application_path = Dir.pwd + + "/.flutter" + + CommandRunner.run 'git', 'clone', flutter_project_repo_url, flutter_application_path + Dir.chdir flutter_application_path do |dir| + CommandRunner.run 'git', 'fetch', '--all', '-v' + CommandRunner.run 'git', 'reset', '--hard', 'origin/master' + CommandRunner.run 'git', 'pull' + CommandRunner.run 'git', 'checkout', flutter_project_repo_ref + archiver = Archiver.new(flutter_project_name,flutter_project_version,sources,flutter_command_wrapper,true ,"",true ,dir, "") + pods = archiver.make_flutter_pods flutter_project_mode + pods.each do |p| + pod p.name, :path => p.path + end + end return end pod "#{flutter_project_name}_#{flutter_project_mode}", flutter_project_version