Module: Pindo::Options::BundleIdSelector
- Defined in:
- lib/pindo/options/helpers/bundleid_selector.rb
Class Method Summary collapse
-
.load_bundleid_group ⇒ Hash?
加载 all_bundleid_group 映射表.
-
.load_deploy_bundleids ⇒ Object
加载发布环境的 Bundle ID 列表.
-
.load_dev_bundleids ⇒ Object
加载开发环境的 Bundle ID 列表.
-
.pindo_env_configdir ⇒ Object
获取 pindo 环境配置目录.
-
.resolve_bundleid_by_group_name(group_name) ⇒ String?
通过 group name 查找真实 bundle ID.
-
.select_bundleid(build_type) ⇒ String?
选择 Bundle ID(根据构建类型).
-
.select_deploy_bundleid ⇒ String
选择发布环境的 Bundle ID.
-
.select_dev_bundleid ⇒ String
选择开发环境的 Bundle ID.
-
.select_from_list(bundleid_list, env_name) ⇒ Object
从列表中选择 Bundle ID.
Class Method Details
.load_bundleid_group ⇒ Hash?
加载 all_bundleid_group 映射表
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 99 def self.load_bundleid_group config_file = File.join(pindo_env_configdir, 'bundleid_config.json') unless File.exist?(config_file) puts "加载 bundleid_config.json 失败: 文件不存在 #{config_file},请运行 pindo setup 更新配置" return nil end begin config = JSON.parse(File.read(config_file)) group = config['all_bundleid_group'] unless group.is_a?(Hash) && !group.empty? puts "加载 bundleid_config.json 失败: all_bundleid_group 缺失或为空 #{config_file},请运行 pindo setup 更新配置" return nil end group rescue => e puts "加载 bundleid_config.json 失败: #{e.},请运行 pindo setup 更新配置" nil end end |
.load_deploy_bundleids ⇒ Object
加载发布环境的 Bundle ID 列表
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 80 def self.load_deploy_bundleids bundleids = [] # 从配置文件加载 config_file = File.join(pindo_env_configdir, 'bundleid_config.json') if File.exist?(config_file) begin config = JSON.parse(File.read(config_file)) bundleids |= config['all_release_bundleid'] if config['all_release_bundleid'] rescue => e puts "加载 bundleid_config.json 失败: #{e.}" end end bundleids end |
.load_dev_bundleids ⇒ Object
加载开发环境的 Bundle ID 列表
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 61 def self.load_dev_bundleids bundleids = [] # 从配置文件加载 config_file = File.join(pindo_env_configdir, 'bundleid_config.json') if File.exist?(config_file) begin config = JSON.parse(File.read(config_file)) bundleids |= config['all_dev_bundleid'] if config['all_dev_bundleid'] bundleids |= config['all_tool_bundleid'] if config['all_tool_bundleid'] rescue => e puts "加载 bundleid_config.json 失败: #{e.}" end end bundleids end |
.pindo_env_configdir ⇒ Object
获取 pindo 环境配置目录
140 141 142 143 144 145 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 140 def self.pindo_env_configdir require_relative '../../config/pindoconfig' Pindoconfig.instance.pindo_env_configdir rescue File.join(Dir.home, '.pindo', 'config') end |
.resolve_bundleid_by_group_name(group_name) ⇒ String?
通过 group name 查找真实 bundle ID
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 124 def self.resolve_bundleid_by_group_name(group_name) return nil if group_name.nil? || group_name.empty? group = load_bundleid_group return nil unless group bundle_id = group[group_name] if bundle_id.nil? || bundle_id.empty? puts "解析 Bundle ID 失败: all_bundleid_group 中未找到 #{group_name},请运行 pindo setup 更新配置" return nil end bundle_id end |
.select_bundleid(build_type) ⇒ String?
选择 Bundle ID(根据构建类型)
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 9 def self.select_bundleid(build_type) build_type_lower = build_type.to_s.downcase # 判断是否为开发环境(development/dev) if build_type_lower == 'development' || build_type_lower == 'dev' select_dev_bundleid else # adhoc、appstore、release、developer_id 都使用发布 bundle id select_deploy_bundleid end end |
.select_deploy_bundleid ⇒ String
选择发布环境的 Bundle ID
32 33 34 35 36 37 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 32 def self.select_deploy_bundleid all_bundleid = load_deploy_bundleids return nil if all_bundleid.empty? select_from_list(all_bundleid, "发布环境") end |
.select_dev_bundleid ⇒ String
选择开发环境的 Bundle ID
23 24 25 26 27 28 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 23 def self.select_dev_bundleid all_bundleid = load_dev_bundleids return nil if all_bundleid.empty? select_from_list(all_bundleid, "开发环境") end |
.select_from_list(bundleid_list, env_name) ⇒ Object
从列表中选择 Bundle ID
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/pindo/options/helpers/bundleid_selector.rb', line 42 def self.select_from_list(bundleid_list, env_name) cli = HighLine.new puts puts "可用的Bundle Id如下::" bundleid_list.each_with_index do |bundleid, index| puts "#{index + 1}. #{bundleid}" end choice = cli.ask("请选择使用的Bundle Id,请输入选项(1/2/3...):", Integer) do |q| q.in = 1..bundleid_list.size end selected = bundleid_list[choice - 1] puts "已选择 #{env_name} Bundle ID: #{selected}\n" selected end |