Module: Pindo::Appselect

Instance Method Summary collapse

Instance Method Details

#all_deploy_bundle_nameObject



80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/pindo/module/appselect.rb', line 80

def all_deploy_bundle_name
  bundle_names = []
  begin
    config = Pindoconfig.instance.pindo_common_config_json
    if config && config['android_deploy_bundle_array']
      bundle_names = config['android_deploy_bundle_array']
    end
  rescue => e
    raise Informative,  "注意: android_deploy_bundle_array 配置不存在或无法加载"
  end
  return bundle_names
end

#all_dev_bundle_nameObject

Android Bundle Name 相关函数



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/pindo/module/appselect.rb', line 67

def all_dev_bundle_name
  bundle_names = []
  begin
    config = Pindoconfig.instance.pindo_common_config_json
    if config && config['android_dev_bundle_array']
      bundle_names = config['android_dev_bundle_array']
    end
  rescue => e
    raise Informative, "注意: android_dev_bundle_array 配置不存在或无法加载"
  end
  return bundle_names
end

#all_dev_bundleidObject



36
37
38
39
40
41
42
43
44
# File 'lib/pindo/module/appselect.rb', line 36

def all_dev_bundleid
    setting_file = File.join(pindo_single_config.pindo_env_configdir,'bundleid_config.json')
    setting_json = load_setting(setting_file:setting_file)
    sub_json = []
    if !setting_json.nil? && !setting_json['all_dev_bundleid'].nil?
      sub_json = setting_json['all_dev_bundleid']
    end
    return sub_json
end

#all_itc_bundleidObject



94
95
96
97
98
99
100
101
# File 'lib/pindo/module/appselect.rb', line 94

def all_itc_bundleid
  all_bundleid = []
  all_bundleid = all_bundleid | all_dev_bundleid 
  all_bundleid = all_bundleid | all_release_bundleid
  all_bundleid = all_bundleid | all_tool_bundleid 

  return all_bundleid
end

#all_release_bundleidObject



56
57
58
59
60
61
62
63
64
# File 'lib/pindo/module/appselect.rb', line 56

def all_release_bundleid
  setting_file = File.join(pindo_single_config.pindo_env_configdir,'bundleid_config.json')
  setting_json = load_setting(setting_file:setting_file)
  sub_json = []
  if !setting_json.nil? && !setting_json['all_release_bundleid'].nil?
    sub_json = setting_json['all_release_bundleid']
  end
  return sub_json
end

#all_tool_bundleidObject



46
47
48
49
50
51
52
53
54
# File 'lib/pindo/module/appselect.rb', line 46

def all_tool_bundleid
  setting_file = File.join(pindo_single_config.pindo_env_configdir,'bundleid_config.json')
  setting_json = load_setting(setting_file:setting_file)
  sub_json = []
  if !setting_json.nil? && !setting_json['all_tool_bundleid'].nil?
    sub_json = setting_json['all_tool_bundleid']
  end
  return sub_json
end

#deploy_build_setting_jsonObject



29
30
31
32
33
34
# File 'lib/pindo/module/appselect.rb', line 29

def deploy_build_setting_json
    setting_file = File.join(pindo_single_config.pindo_env_configdir,'deploy_build_setting.json')
    setting_json = load_setting(setting_file:setting_file)

    return setting_json
end

#dev_build_setting_jsonObject



23
24
25
26
27
# File 'lib/pindo/module/appselect.rb', line 23

def dev_build_setting_json
  setting_file = File.join(pindo_single_config.pindo_env_configdir,'dev_build_setting.json')
  setting_json = load_setting(setting_file:setting_file)
  return setting_json
end

#get_deploy_repo_with_modul_name(module_name: nil) ⇒ Object



324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/pindo/module/appselect.rb', line 324

def get_deploy_repo_with_modul_name(module_name:nil)
  
  sub_setting_json = deploy_build_setting_json()
  repo_name = nil

  begin 
    repo_name = sub_setting_json[module_name]['git_repo_name']
  rescue => err 
    raise Informative, "config.json app_type is error!!!"
  end   

  return repo_name
end

#get_deploy_setting_repo(tagname: nil) ⇒ Object



302
303
304
305
# File 'lib/pindo/module/appselect.rb', line 302

def get_deploy_setting_repo(tagname:nil)
  sub_setting_json = deploy_build_setting_json()
  return sub_setting_json[tagname]['git_repo_name']
end

#get_dev_setting_repo(tagname: nil) ⇒ Object



307
308
309
310
# File 'lib/pindo/module/appselect.rb', line 307

def get_dev_setting_repo(tagname:nil)
  sub_setting_json = dev_build_setting_json()
  return sub_setting_json[tagname]['git_repo_name']
end

#get_selected_deploy_bundle_nameObject



274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/pindo/module/appselect.rb', line 274

def get_selected_deploy_bundle_name()
  all_bundle_names = all_deploy_bundle_name()

  if all_bundle_names.nil? || all_bundle_names.empty?
    puts "\n未配置任何发布环境的Android Bundle Name"
    return nil
  end

  cli = HighLine.new
  menu_choice = "None"
  puts
  cli.choose do |menu|
    menu.header = "可用的Android Bundle Name如下:"
    menu.prompt = "请选择使用的Bundle Name,请输入选项(1/2/3...):"
    for bundle_name in all_bundle_names do
      menu.choice(bundle_name) do |details|
        menu_choice = "#{details}"
      end
    end
  end

  puts
  puts "选择的Bundle Name是: #{menu_choice}"
  puts

  return menu_choice
end

#get_selected_deploy_bundleidObject



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/pindo/module/appselect.rb', line 193

def get_selected_deploy_bundleid()

  all_bundleid = all_release_bundleid()
  
  cli = HighLine.new
  menu_choice="None"
  puts 
  cli.choose do |menu|                                  # you can also use constants like :blue

      menu.header = "可用的Bundle Id如下:"
      menu.prompt = "请选择使用的Bundle Id,请输入选项(1/2/3...):"
      if !all_bundleid.nil? && all_bundleid.length > 0
        for bunld_id in all_bundleid do
          menu.choice(bunld_id) do |details|
            menu_choice="#{details}"
          end
        end
      end
  end

  puts
  puts "选择的bundle id是: #{menu_choice}"
  puts
  return menu_choice;
  
end

#get_selected_dev_bundle_nameObject



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/pindo/module/appselect.rb', line 220

def get_selected_dev_bundle_name()
  # 检查环境变量
  env_bundle_name = ENV['PINDO_BUNDLE_NAME']
  if env_bundle_name && !env_bundle_name.empty?
    puts "\n使用环境变量指定的Bundle Name: #{env_bundle_name}"
    puts
    # 保存到缓存
    require_relative '../base/pindocontext'
    context = Pindo::PindoContext.instance
    context.set_selection(Pindo::PindoContext::SelectionKey::ANDROID_BUNDLE_NAME, env_bundle_name)
    return env_bundle_name
  end

  # 检查缓存
  require_relative '../base/pindocontext'
  context = Pindo::PindoContext.instance
  cached_bundle_name = context.get_selection(Pindo::PindoContext::SelectionKey::ANDROID_BUNDLE_NAME)

  if cached_bundle_name
    puts "\n使用之前选择的Bundle Name: #{cached_bundle_name}"
    puts
    return cached_bundle_name
  end

  all_bundle_names = all_dev_bundle_name()

  if all_bundle_names.nil? || all_bundle_names.empty?
    puts "\n未配置任何开发环境的Android Bundle Name"
    return nil
  end

  cli = HighLine.new
  menu_choice = "None"
  puts
  cli.choose do |menu|
    menu.header = "可用的Android Bundle Name如下:"
    menu.prompt = "请选择使用的Bundle Name,请输入选项(1/2/3...):"
    for bundle_name in all_bundle_names do
      menu.choice(bundle_name) do |details|
        menu_choice = "#{details}"
      end
    end
  end

  puts
  puts "选择的Bundle Name是: #{menu_choice}"
  puts

  # 保存选择到缓存
  context.set_selection(Pindo::PindoContext::SelectionKey::ANDROID_BUNDLE_NAME, menu_choice)

  return menu_choice
end

#get_selected_dev_bundleidObject



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/pindo/module/appselect.rb', line 136

def get_selected_dev_bundleid()
  # 检查环境变量
  env_bundleid = ENV['PINDO_BUNDLE_ID']
  if env_bundleid && !env_bundleid.empty?
    puts "\n使用环境变量指定的Bundle ID: #{env_bundleid}"
    puts
    # 保存到缓存
    require_relative '../base/pindocontext'
    context = Pindo::PindoContext.instance
    context.set_selection(Pindo::PindoContext::SelectionKey::BUNDLE_ID, env_bundleid)
    return env_bundleid
  end

  # 检查缓存
  require_relative '../base/pindocontext'
  context = Pindo::PindoContext.instance
  cached_bundleid = context.get_selection(Pindo::PindoContext::SelectionKey::BUNDLE_ID)

  if cached_bundleid
    puts "\n使用之前选择的Bundle ID: #{cached_bundleid}"
    puts
    return cached_bundleid
  end

  all_bundleid = []
  all_bundleid = all_bundleid | all_dev_bundleid()
  all_bundleid = all_bundleid | all_tool_bundleid()

  cli = HighLine.new
  menu_choice="None"
  puts
  cli.choose do |menu|                                  # you can also use constants like :blue
      menu.header = "可用的Bundle Id如下:"
      menu.prompt = "请选择使用的Bundle Id,请输入选项(1/2/3...):"
      if !all_bundleid.nil? && all_bundleid.length > 0
        for bunld_id in all_bundleid do
          menu.choice(bunld_id) do |details|
            menu_choice="#{details}"
          end
        end
      end
  end

  puts
  puts "选择的bundle id是: #{menu_choice}"
  puts
  if menu_choice.eql?("com.heroneverdie101.*")
    menu_choice = "com.heroneverdie101"
  end

  # 保存选择到缓存
  context.set_selection(Pindo::PindoContext::SelectionKey::BUNDLE_ID, menu_choice)

  return menu_choice;

end

#get_setting_bundleid_withdir(repo_dir: nil) ⇒ Object



312
313
314
315
316
317
318
319
320
321
322
# File 'lib/pindo/module/appselect.rb', line 312

def get_setting_bundleid_withdir(repo_dir:nil)

    bundl_id = ""
    config_json_file = File.join(repo_dir, "config.json")
    if File.exist?(config_json_file)
        config_json = JSON.parse(File.read(config_json_file))
        bundl_id = config_json["app_info"]["app_identifier"]

    end
    return bundl_id
end

#load_setting(setting_file: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pindo/module/appselect.rb', line 9

def load_setting(setting_file:nil)
  setting_json = nil
  if  setting_json.nil? && File.exist?(setting_file)  
    # begin
      setting_json = JSON.parse(File.read(setting_file))   
    # rescue => exception
    #   puts "load Pindo build setting error !!!"
    # end
  end

  return setting_json
end

#select_main_appObject



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/pindo/module/appselect.rb', line 103

def select_main_app
    
    sub_setting_json = dev_build_setting_json()

    cli = HighLine.new
    menu_choice="None"
    puts ""
    puts "如果没有想要打包的App, 可以使用 pindo dev createbuild 创建打包选项"
    puts ""
    puts "具体参考文档: https://tower.im/teams/851356/repository_documents/714/"
    puts ""
    puts "App Type:"
    puts 
    cli.choose do |menu|                                  # you can also use constants like :blue
        menu.header = "可用的Bundle Id如下:"
        menu.prompt = "请选择使用的Bundle Id,请输入选项(1/2/3...):"
        menu.index_suffix = ") "
        if !sub_setting_json.nil? 
          sub_setting_json.each do |key, items|
            menu.choice(key) do |details|
              menu_choice="#{details}"
            end
          end
        end
    end

    puts
    puts "选择的bundle id是: #{menu_choice}"
    puts

    return menu_choice;
end