class OceanPackage::Fir

Attributes

change_log[RW]

更新日志

ipa_file_path[RW]

ipa文件包路径

log_path[RW]

log文件路径

token[RW]

token

Public Class Methods

new(token, change_log = "", ipa_file_path, log_path) click to toggle source
# File lib/ocean_package/fir.rb, line 14
def initialize(token, change_log = "", ipa_file_path, log_path)
  @token = token
  @change_log = change_log
  @ipa_file_path = ipa_file_path
  @log_path = log_path
end

Public Instance Methods

check() click to toggle source

校验

# File lib/ocean_package/fir.rb, line 65
def check

  token_value = "#{@token}"
  if token_value.empty?
    Log.error("fir token is empty, please check !!!")
    return false
  end

  ipa_file_path_value = "#{@ipa_file_path}"
  if ipa_file_path_value.empty?
    Log.error("ipa file path is empty, please check !!!")
    return false
  end

  return true
end
find_qr_code_path() click to toggle source

查找下载二维码的文件路径

# File lib/ocean_package/fir.rb, line 164
def find_qr_code_path
  # 正则表达式匹配
  pattern = /.*Local qrcode file:.*/
  path = ''
  if File.exist?("#{@log_path}")
    File.open(@log_path, "r") do |f|
      f.each_line do |line|
        line_s = "#{line}"
        if line_s =~ pattern
          path = line_s.split(' ').last
          break
        end
      end
    end
  else
    Log.info("fir log path not exist !!!")
  end
  Log.info("fir qr code path value: #{path}")
  path
end
find_release_id() click to toggle source

查找 release_id

# File lib/ocean_package/fir.rb, line 109
def find_release_id
  # 正则表达式匹配
  pattern = /.*Release id is.*/
  release_id = ''
  if File.exist?("#{@log_path}")
    File.open(@log_path, "r") do |f|
      f.each_line do |line|
        line_s = "#{line}"
        if line_s =~ pattern
          release_id = line_s.split(' ').last
          break
        end
      end
    end
  else
    Log.info("fir log path not exist !!!")
  end
  Log.info("fir release id value: #{release_id}")
  release_id
end
info_cmd() click to toggle source

命令:查看 fir 信息

# File lib/ocean_package/fir.rb, line 22
def info_cmd
  'fir -v'
end
login() click to toggle source

登录

# File lib/ocean_package/fir.rb, line 83
def login
  system(info_cmd)
  res = system(login_cmd)

  Log.info("fir login result: #{res}")

  unless res == true
    Log.error("fir login fail, please check !!!")
    exit(1)
  end

end
login_cmd() click to toggle source

命令:fir 登录

# File lib/ocean_package/fir.rb, line 27
def login_cmd
  cmd = 'fir login'
  cmd += ' -T ' + @token

  Log.divider
  Log.info("fir login command: #{cmd}")
  Log.divider

  cmd
end
publish() click to toggle source

上传

# File lib/ocean_package/fir.rb, line 97
def publish
  res = system(publish_cmd)

  Log.info("fir publish result: #{res}")

  unless res == true
    Log.error("fir publish fail, please check !!!")
    exit(1)
  end
end
publish_cmd() click to toggle source

命令:上传ipa文件到fir平台

# File lib/ocean_package/fir.rb, line 39
def publish_cmd
  # @ipa_file_path @change_log @log_path 需要是字符串值!!!!!
  cmd = "fir publish"
  cmd += " "  + "'#{@ipa_file_path}'"
  cmd += " -c " + "'#{@change_log}'"
  cmd += " -Q"
  cmd += " | tee " + "'#{@log_path}'"

  Log.divider
  Log.info("fir publish command: #{cmd}")
  Log.divider

  cmd
end
run() click to toggle source

运行

# File lib/ocean_package/fir.rb, line 55
def run
  unless check
    # 后续会接入蒲公英分发平台,这里不退出程序 exit
    return
  end
  login
  publish
end