Class: Pindo::Command::Ios::Cert

Inherits:
Pindo::Command::Ios show all
Includes:
Appselect
Defined in:
lib/pindo/command/ios/cert.rb

Constant Summary

Constants inherited from Pindo::Command

DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes inherited from Pindo::Command

#args_help_flag

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Appselect

#all_deploy_bundle_name, #all_dev_bundle_name, #all_dev_bundleid, #all_itc_bundleid, #all_release_bundleid, #all_tool_bundleid, #deploy_build_setting_json, #dev_build_setting_json, #get_deploy_repo_with_modul_name, #get_deploy_setting_repo, #get_dev_setting_repo, #get_selected_deploy_bundle_name, #get_selected_deploy_bundleid, #get_selected_dev_bundle_name, #get_selected_dev_bundleid, #get_setting_bundleid_withdir, #load_setting, #select_main_app

Methods inherited from Pindo::Command

command_name, #initialize_options, run, use_cache?, #validate!

Methods included from Funlog::Mixin

#pindo_log_instance

Methods included from Pindoconfig::Mixin

#pindo_single_config

Constructor Details

#initialize(argv) ⇒ Cert

Returns a new instance of Cert.



52
53
54
55
56
57
# File 'lib/pindo/command/ios/cert.rb', line 52

def initialize(argv)
  @args_adhoc_flag = argv.flag?('adhoc', false)
  @args_deploy_flag = argv.flag?('deploy', false)
  @args_macos_flag = argv.flag?('macos', false)
  super 
end

Class Method Details

.optionsObject

命令的选项列表



44
45
46
47
48
49
50
# File 'lib/pindo/command/ios/cert.rb', line 44

def self.options
  [
    ['--deploy', '使用发布bundle id(默认使用开发bundle id)'],
    ['--adhoc',  '使用adhoc证书(默认使用dev证书)'],
    ['--macos',  '使用macOS平台证书'],
  ].concat(super)
end

Instance Method Details

#runObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
# File 'lib/pindo/command/ios/cert.rb', line 60

def run

  mainapp_bundleid= nil
  if @args_deploy_flag
    mainapp_bundleid = get_selected_deploy_bundleid()
  else
    mainapp_bundleid = get_selected_dev_bundleid()
  end

  # 拉取应用配置
  require 'pindo/config/build_info_manager'
  Pindo::BuildInfoManager.share_instance.pull_appconfig_with_reponame(
    repo_name: mainapp_bundleid,
    target_dir: Dir.pwd
  )

  project_dir = Dir.pwd
  Dir.chdir(project_dir)

  # 加载配置到 IosConfigParser
  require 'pindo/config/ios_config_parser'
  config_json_file = File.join(project_dir, "config.json")
  Pindo::IosConfigParser.instance.load_config(config_file: config_json_file)

  # 处理entitlements配置
  Pindo::XcodeBuildConfig.update_entitlements_config(project_dir: project_dir)

  # 确定构建类型
  build_type = @args_adhoc_flag ? 'adhoc' : 'dev'

  # 检测平台类型
  project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
  if !project_fullname.nil?
      require 'xcodeproj'
      project_obj = Xcodeproj::Project.open(project_fullname)
      project_build_platform = project_obj.root_object.build_configuration_list.get_setting("SDKROOT")["Release"]
      if !project_build_platform.nil? && project_build_platform.eql?("macosx")
        @args_macos_flag = true
      end
  end

  platform_type = @args_macos_flag ? 'macos' : 'ios'

  # 直接调用 XcodeCertHelper 安装和配置证书
  # 配置已经加载到 IosConfigParser,不需要再传 config_file
  require 'pindo/module/cert/xcode_cert_helper'
  Pindo::XcodeCertHelper.install_and_config_certs(
    build_type: build_type,
    platform_type: platform_type,
    project_dir: project_dir
  )

  puts "✓ 证书安装和配置完成!"
end