Module: Pindo::Appselect

Instance Method Summary collapse

Instance Method Details

#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



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

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



186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/pindo/module/appselect.rb', line 186

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



164
165
166
167
# File 'lib/pindo/module/appselect.rb', line 164

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



169
170
171
172
# File 'lib/pindo/module/appselect.rb', line 169

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_bundleidObject



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
# File 'lib/pindo/module/appselect.rb', line 137

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_bundleidObject



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
135
# File 'lib/pindo/module/appselect.rb', line 109

def get_selected_dev_bundleid()

  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
  return menu_choice;
  
end

#get_setting_bundleid_withdir(repo_dir: nil) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
# File 'lib/pindo/module/appselect.rb', line 174

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



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
# File 'lib/pindo/module/appselect.rb', line 76

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