Skip to content

Commit

Permalink
1、修复自动更新submodule导致submodule回滚的问题
Browse files Browse the repository at this point in the history
2、增加打开Example的功能
  • Loading branch information
吴锡苗 committed Nov 22, 2019
1 parent df5b26f commit e4a42a9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/cocoapods/dev/env/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Cocoapods
module Dev
module Env
VERSION = "0.9.1"
VERSION = "0.9.2"
end
end
end
34 changes: 27 additions & 7 deletions lib/cocoapods_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
podfile = installer.podfile
#puts installer.instance_variables
# forbidden submodule not cloned
`
git submodule update --init --recursive
`
# 会引起submodule HEAD回滚,不靠谱,先注释掉
# `
# git submodule update --init --recursive
# `
end

Pod::HooksManager.register('cocoapods-dev-env', :post_install) do |installer|
Expand All @@ -25,6 +26,19 @@ def self.keyword
class Podfile
class TargetDefinition

def searchAndOpenLocalExample(path)
currentDir = Dir.pwd
Dir.chdir(path)
Dir.chdir("Example")
`pod install`
projPaths = Dir::glob("*.xcworkspace")
if projPaths.count > 0
`open -a Terminal ./`
`open #{projPaths[0]}`
end
Dir.chdir(currentDir)
end

def checkAndRemoveSubmodule(path)
currentDir = Dir.pwd
Dir.chdir(path)
Expand Down Expand Up @@ -97,8 +111,8 @@ def addGitTagAndPush(tag, pod_name)
end

def inputNeedJumpForReson(str)
puts str
puts '是(Y), 否(N)'
puts str.green
puts '是(Y), 任意其他输入或直接回车跳过'.green
input = STDIN.gets
if input[0,1] == "Y"
return true
Expand Down Expand Up @@ -168,16 +182,22 @@ def parse_pod_dev_env(name, requirements)
UI.puts "add submodule for #{pod_name.green}".yellow
# TODO 这个命令要想办法展示实际报错信息
`git submodule add --force -b #{branch} #{git} #{path}`

if inputNeedJumpForReson("本地库#{pod_name} 开发模式加载完成,是否自动打开Example工程")
searchAndOpenLocalExample(path)
end
if !checkTagIsEqualToHead(tag, path) && !checkTagIsEqualToHead("#{tag}_beta", path)
raise "💔 #{pod_name.yellow} branch:#{branch.yellow} 与 tag:#{tag.yellow}[_beta] 内容不同步,请自行确认所用分支和tag后重新执行 pod install"
end
else
if inputNeedJumpForReson("本地库#{pod_name} 处于开发模式,是否自动打开Example工程")
searchAndOpenLocalExample(path)
end
end
options[:path] = path
if requirements.length >= 2
requirements.delete_at(0)
end
UI.message "enabled #{"dev".green}-mode for #{pod_name.green}"
UI.message "pod #{pod_name.green} enabled #{"dev".green}-mode 🍺"
elsif dev_env == 'beta'
# Beta模式,使用tag引用远端git库的代码
tag = "#{tag}_beta"
Expand Down

0 comments on commit e4a42a9

Please sign in to comment.