class Escalator::Combine

Attributes

arguments[RW]
command[RW]

Public Class Methods

run(command) click to toggle source
# File lib/escalator/combine.rb, line 7
def run command
  @command = command
  prepareContext
  excuteCommands
end

Private Class Methods

excuteCommands() click to toggle source
# File lib/escalator/combine.rb, line 25
def excuteCommands
  Throw.note "Begin excute commands ..."
  outputPath = command.work_path + "/_confuses"
  if File.exist? outputPath
    FileUtils.rm_rf outputPath
  end
  projectPaths = nil
  if command.commands.include? "confuse"
    projectPaths = Dir["#{command.input_path}/*/*.xcodeproj"]
    args = ["confuse"] + arguments["keywords"]
    projectPaths = projectPaths.map { |path|
      Command.run args + [
        "--project-path=#{path}",
        "--output-path=#{outputPath}"
      ]
    }
  end

  ipaPaths = nil
  if command.commands.include? "archive"
    outputPath = command.work_path + "/_packges"
    if File.exist? outputPath
      FileUtils.rm_rf outputPath
    end
    if !projectPaths
      projectPaths = Dir["#{command.input_path}/*/*.xcodeproj"]
    end
    args = ["archive", arguments["method"]]
    ipaPaths = projectPaths.map { |path|
      Command.run args + [
        "--project-path=#{path}",
        "--output-path=#{outputPath}"
      ]
    }
  end

  if command.commands.include? "resign"
    if !ipaPaths
      ipaPaths = Dir["#{command.input_path}/*/*.ipa"]
    end
    args = ["resign"] + ipaPaths + [
      "--key-id=#{arguments["key_id"]}",
      "--issuer-id=#{arguments["issuer_id"]}",
      "--keyfile-path=#{arguments["keyfile_path"]}",
      "--user-password=#{arguments["user_password"]}",
      "--bundle-identifier=#{arguments["CFBundleIdentifier"]}",
      "--short-version=#{arguments["CFBundleShortVersionString"]}",
      "--bundle-version=#{arguments["CFBundleVersion"]}"
    ]
    arg = arguments["apple_id"]
    if arg
      args << "--apple-id=#{arg}"
    end
    arg = arguments["CFBundleName"]
    if arg
      args << "--bundle-name=#{arg}"
    end
    arg = arguments["CFBundleDisplayName"]
    if arg
      args << "--display-name=#{arg}"
    end
    arg = arguments["CFBundleExecutable"]
    if arg
      args << "--executable-name=#{arg}"
    end
    arg = arguments["iconAssets_path"]
    if arg
      args << "--iconAssets-path=#{arg}"
    end
    ipaPaths = Command.run args
  end

  if command.commands.include? "upload"
    if !ipaPaths
      ipaPaths = Dir["#{command.input_path}/*/*.ipa"]
    end
    Command.run ["upload"] + ipaPaths + [
      "--key-id=#{arguments["key_id"]}",
      "--issuer-id=#{arguments["issuer_id"]}",
      "--keyfile-path=#{arguments["keyfile_path"]}",
      "--bundle-identifier=#{arguments["CFBundleIdentifier"]}"
    ]
  end

  Throw.note "==========================End!=========================="
end
prepareContext() click to toggle source
# File lib/escalator/combine.rb, line 19
def prepareContext
  Throw.note "Prepare combine context ..."
  plist = CFPropertyList::List.new :file => command.config_path
  @arguments = CFPropertyList.native_types plist.value
end