Class: Pod::Command::Stable

Inherits:
Pod::Command show all
Extended by:
Executable
Defined in:
lib/cocoapods-bb-PodAssistant/command/stable/stable.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Stable

Returns a new instance of Stable.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cocoapods-bb-PodAssistant/command/stable/stable.rb', line 43

def initialize(argv)
  @names = argv.arguments! unless argv.arguments.empty?
  @help = argv.flag?('help')
  @init = argv.flag?('init')
  @sync = argv.flag?('sync')
  # install操作
  @install = argv.flag?('install')
  @update = argv.flag?('update')
  # update组件数据支持多个使用`,`或者`空格`隔开
  update_pods = argv.option('update-pod','')
  if !update_pods.empty?
    if update_pods.include?(' ')
      @update_pods = update_pods.split(' ') unless update_pods.nil?
    else update_pods.include?(',')
      @update_pods = update_pods.split(',') unless update_pods.nil?
    end
  end
  super
end

Class Method Details

.optionsObject



33
34
35
36
37
38
39
40
41
# File 'lib/cocoapods-bb-PodAssistant/command/stable/stable.rb', line 33

def self.options
  [
    ['--init', '初始化项目yml配置,根据当前项目Podfile.lock生成'],
    ['--sync', '同步远端yml配置,更新项目yml配置'],
    ['--install', '命令同执行`pod install操作`'],
    ['--update', '命令同执行`pod update操作`'],
    ['--update-pod', '命令同执行`pod update <组件>操作`,更新yml配置组件版本信息,多个组件使用`,`或者`空格`隔开,注意⚠️  使用`空格`需要使用双引号'],
  ].concat(super)
end

Instance Method Details

#runObject

Main ########################################



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/cocoapods-bb-PodAssistant/command/stable/stable.rb', line 82

def run
  # begin
    source_manager = BB::SourceManager.new(@businessSpec)
    if @init
      puts "[PodAssistant] 开始配置生成当前项目yml文件".yellow
      # 生成本地yml配置
      source_manager.generate_localStable
      puts "[PodAssistant] `pod stable --init` complete!".green
    elsif @install
      puts "[PodAssistant] 执行 $ pod install".yellow
      system "pod install"
      puts "[PodAssistant] `pod stable --install` complete!".green
    elsif @update
      puts "[PodAssistant] 执行 $ pod update".yellow
      system "pod update"
      puts "[PodAssistant] `pod stable --update` complete!".green
    elsif @update_pods
      # 更新单个组件
      puts "更新pod组件#{@update_pods} count:#{@update_pods.count}".yellow
      source_manager.update_podmodules(@update_pods)
      podnames = @update_pods.join(" ")
      puts "[PodAssistant] 执行 $ pod update #{podnames}".yellow
      system "pod update #{podnames}"
      source_manager.update_local_stable_from_podmodules(@update_pods)
      podnames = @update_pods.join(",")
      puts "[PodAssistant] `pod stable --update-pod=#{podnames}` complete!".green
    elsif @sync
      puts "开始合并远端lock数据".yellow
      ll_load_stable
      #2、clone origin lock spec to cache dir 
      ll_cloneStable
      #3、fetch newest code
      ll_fetch_stale_git
      # 数据合并
      source_manager.merge_stable_data
      puts "[PodAssistant] `pod stable` complete!".green
    else
      puts "[PodAssistant] `pod stable` 帮助文档请查看👇".yellow
      banner! 
    end
  # rescue => exception
  #   puts "[pod stable] error(已捕获): #{exception}".red
  # end
  
end

#stable!(source, options = {}) ⇒ Object

help load podfile option



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cocoapods-bb-PodAssistant/command/stable/stable.rb', line 68

def stable!(source, options = {})
  @ll_stable_source = source
  if options.has_key?(:specs) 
    @businessSpec = options[:specs]
    puts "当前业务使用源=>#{@businessSpec}"
  end
  @ll_stable_tag = options[:tag] if options.has_key?(:tag) 
  @ll_stable_branch = options[:branch] if options.has_key?(:branch)
  @cache = BB::Cache.new()
  configGitPath(@cache.cachePath)
end

#validate!Object



62
63
64
65
# File 'lib/cocoapods-bb-PodAssistant/command/stable/stable.rb', line 62

def validate!
  super
  banner! if @help
end