Class: Pod::Command::OemConfig

Inherits:
Pod::Command show all
Defined in:
lib/cocoapods-hooks/command/oem_config.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ OemConfig

Returns a new instance of OemConfig.



15
16
17
18
19
# File 'lib/cocoapods-hooks/command/oem_config.rb', line 15

def initialize(argv)
  @tenantid = argv.option('tenantid')
  @branch = argv.option('branch')
  super
end

Class Method Details

.optionsObject



8
9
10
11
12
13
# File 'lib/cocoapods-hooks/command/oem_config.rb', line 8

def self.options
  [
    ['--tenantid=TENANTID', 'Specify the tenant ID'],
    ['--branch=Branch', 'Specify the branch for git clone']
  ].concat(super)
end

Instance Method Details

#runObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cocoapods-hooks/command/oem_config.rb', line 26

def run
  UI.puts "Downloading OEM configuration for tenant #{@tenantid}"
  # 执行你的业务逻辑
  if @branch == nil
      UI.puts "没有传入指定分支,默认使用 main_develop"
      @branch = 'main_develop'
  end
  # 1. 根据 tenant_id 下载相关的配置文件
  result = system("pod git-clone --tenantid=#{@tenantid} --branch=#{@branch}")
  unless result
      puts "pod git-clone command execution failed. Exiting..."
      exist 1
  end
  # 2. 修改图片的主题色
  result = system("pod change-color")
  unless result
      puts "pod change-color command execution failed. Exiting..."
      exist 1
  end
  # 3. 修改工程配置, 进行签名
  result = system("pod fastlane-sign")
  unless result
      puts "pod fastlane-sign command execution failed. Exiting..."
      exist 1
  end
end

#validate!Object



21
22
23
24
# File 'lib/cocoapods-hooks/command/oem_config.rb', line 21

def validate!
  super
  help! 'A tenant ID is required.' unless @tenantid
end