Class: Pindo::Command::Deploy::Bundleid

Inherits:
Pindo::Command::Deploy show all
Includes:
Pindo::Command::DeployOptions
Defined in:
lib/pindo/command/deploy/bundleid.rb

Constant Summary

Constants inherited from Pindo::Command

Pindo::Command::DEFAULT_OPTIONS, Pindo::Command::DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes included from Pindo::Command::DeployOptions

#additional_args, #apple_id, #args_adhoc_flag, #args_appconfig, #args_appconfig_dir, #args_appconfig_fullname, #args_apple_id, #args_appstore_flag, #args_array, #args_bundle_id, #args_dev_flag, #args_macos_flag, #args_repo_name, #argv_temp, #bundle_id, #bundle_id_extension, #bundle_id_extensionad, #bundle_id_extensionporn, #bundle_id_imessage, #bundle_id_keyboard, #bundle_id_pushcontent, #bundle_id_pushservice, #bundle_id_siri, #bundle_id_siriui, #bundle_id_watchapp, #bundle_id_watchapp_extension, #bundle_id_widget, #config_json, #deploy_acount_id, #deploy_group_id, #deploy_icloud_id, #deploy_identifier, #deploy_identifier_extension, #deploy_identifier_extensionad, #deploy_identifier_extensionporn, #deploy_identifier_imessage, #deploy_identifier_keyboard, #deploy_identifier_pushcontent, #deploy_identifier_pushservice, #deploy_identifier_siri, #deploy_identifier_siriui, #deploy_identifier_watchapp, #deploy_identifier_watchapp_extension, #deploy_identifier_widget, #deploy_repo_name, #group_id, #icloud_id, #newconfuse_flag, #oldconfuse_flag

Attributes inherited from Pindo::Command

#args_help_flag

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Pindo::Command::DeployOptions

#check_config_version, #get_build_type_args, #get_bundle_id_map, #get_confuse_type_args, #init_deploy_params, #init_develop_params, #print_params_info, #validate!

Methods inherited from Pindo::Command

run, #validate!

Methods included from Funlog::Mixin

#pindo_log_instance

Methods included from Pindoconfig::Mixin

#pindo_single_config

Methods included from Githelper

#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag

Methods included from Executable

capture_command, #executable, execute_command, which, which!

Constructor Details

#initialize(argv) ⇒ Bundleid

Returns a new instance of Bundleid.



30
31
32
33
# File 'lib/pindo/command/deploy/bundleid.rb', line 30

def initialize(argv)
  @args_sign_flag = argv.flag?('sign', false)
  super
end

Class Method Details

.optionsObject



24
25
26
27
28
# File 'lib/pindo/command/deploy/bundleid.rb', line 24

def self.options
  [
      ['--sign', 'sign flags'],
  ].concat(super)
end

Instance Method Details

#build_settings_for(settings_key:, options_key:) ⇒ Object



213
214
215
216
217
218
219
220
# File 'lib/pindo/command/deploy/bundleid.rb', line 213

def build_settings_for(settings_key:, options_key:)
  return [{
   key: settings_key,
   options: [ {
       key: options_key
     } ]
  }]
end

#create_bundleid(bundle_id: nil, app_group: nil, setting_array: []) ⇒ Object



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
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
192
# File 'lib/pindo/command/deploy/bundleid.rb', line 110

def create_bundleid(bundle_id:nil, app_group:nil, setting_array:[])

  if !bundle_id.nil?

    app = Spaceship::Portal.app.find(bundle_id)
    puts 
    if app.nil?
      puts "Create bundle id #{bundle_id} in apple developer center..."                
      app = Spaceship::Portal.app.create!(bundle_id: bundle_id, name: bundle_id.gsub('.', ''))
    else
      puts "Find bundle id #{bundle_id} in apple developer center..."
    end   


    bundle_id_obj = Spaceship::ConnectAPI::BundleId.find(bundle_id)

    if !bundle_id_obj.nil?
        #GAME_CENTER
        if !setting_array.nil? && setting_array.to_s.include?("game_center")
          puts "Enable  #{bundle_id}  game_center on"
          bundle_id_obj.update_capability("GAME_CENTER", enabled: true)
        else
          puts "Enable  #{bundle_id}  game_center off"
          bundle_id_obj.update_capability("GAME_CENTER", enabled: false)
        end
    end

    if setting_array.nil? || setting_array.length == 0
      return nil
    end


    if !app.nil? && setting_array.to_s.include?("push_notification")
      puts "Enable  #{bundle_id}  push on"
      app.update_service(Spaceship::Portal.app_service.push_notification.on)
    else
      app.update_service(Spaceship::Portal.app_service.push_notification.off)
      puts "Enable  #{bundle_id}  push off"
    end

    if !app.nil? && setting_array.to_s.include?("siri")
      puts "Enable  #{bundle_id}  siri on"
      app.update_service(Spaceship::Portal.app_service.siri_kit.on)
    else
      app.update_service(Spaceship::Portal.app_service.siri_kit.off)
      puts "Enable  #{bundle_id}  siri off"
    end

  
    if !bundle_id_obj.nil? && setting_array.to_s.include?("apple_signin")
      puts "Enable  #{bundle_id}  Sign with Apple on "
      settings = build_settings_for(settings_key: "APPLE_ID_AUTH_APP_CONSENT", options_key: "PRIMARY_APP_CONSENT")
      bundle_id_obj.update_capability("APPLE_ID_AUTH", enabled: true, settings: settings)
    else
      # app.update_service(Spaceship::Portal.app_service.push_notification.on)
        puts "Enable  #{bundle_id}  Sign with Apple off "
        bundle_id_obj.update_capability("APPLE_ID_AUTH", enabled: false)
    end

    
    if !app_group.nil? && setting_array.to_s.include?("app_group")
      puts "Enable #{bundle_id}  group on"
      app.update_service(Spaceship::Portal.app_service.app_group.on)
      app.associate_groups([app_group])
    else
      puts "Enable  #{bundle_id} group off"
      app.update_service(Spaceship::Portal.app_service.app_group.off)
    end

    if !@app_iclound.nil? && setting_array.to_s.include?("iclound")
      puts "Enable #{bundle_id}  icloud on"
      app.update_service(Spaceship::Portal.app_service.cloud.on)
      app.update_service(Spaceship::Portal.app_service.cloud_kit.cloud_kit)
      app.associate_cloud_containers([@app_iclound])
    else
      puts "Enable #{bundle_id}  icloud off"
      app.update_service(Spaceship::Portal.app_service.cloud.off)
    end

    return app
  end
  return nil
end

#create_group_id(group_id: nil) ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/pindo/command/deploy/bundleid.rb', line 195

def create_group_id(group_id:nil)

  if !group_id.nil?

    app_group = Spaceship::Portal.app_group.find(group_id)

    if app_group.nil?
      puts "Create group_id id #{group_id} in apple developer center..."
      app_group = Spaceship::Portal.app_group.create!(group_id: group_id, name: group_id.gsub('.', ''))
    else
      puts "Group_id id #{group_id} is existed in apple developer center !!!"
    end   
    return app_group
  end

  return nil
end

#create_icloud_id(icloud_id: nil) ⇒ Object



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/pindo/command/deploy/bundleid.rb', line 222

def create_icloud_id(icloud_id:nil)

  if !icloud_id.nil?

    puts "icloud_id +++++ #{icloud_id}"
    app_iclound = Spaceship::Portal.cloud_container.find(icloud_id)

    if app_iclound.nil?
      puts "Create icloud_id id #{icloud_id} in apple developer center..."
      app_iclound = Spaceship::Portal.cloud_container.create!(identifier: icloud_id,name: icloud_id.gsub('.', ''))
    else
      puts "icloud_id id #{icloud_id} is existed in apple developer center !!!"
    end   
    return app_iclound
  end
  return nil

end

#runObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
# File 'lib/pindo/command/deploy/bundleid.rb', line 35

def run

  puts @apple_id
  puts "Login #{@apple_id}..."


  Spaceship.(@apple_id.to_s)
  Spaceship.select_team

  # Spaceship::Portal.login(@apple_id.to_s)
  # Spaceship::Portal.select_team

  app_group = nil
  if !@deploy_group_id.nil?
    app_group = create_group_id(group_id:@deploy_group_id) 
    @app_group = app_group 
  end



  parms = ["push_notification", "app_group"]

  if !@config_json.nil? && !@deploy_icloud_id.nil?
    @app_iclound = create_icloud_id(icloud_id:@deploy_icloud_id)
    parms << "iclound"
  end

  app = create_bundleid(bundle_id:@bundle_id, app_group:app_group, setting_array:parms)

  if !app.nil? && !@bundle_id_pushcontent.nil?
    create_bundleid(bundle_id:@bundle_id_pushcontent, app_group:app_group, setting_array:["push_notification"])
  end

  if !app.nil? && !@bundle_id_pushservice.nil?
    create_bundleid(bundle_id:@bundle_id_pushservice, app_group:app_group, setting_array:["push_notification"])
  end

  if !app.nil? && !@deploy_identifier_keyboard.nil?
    create_bundleid(bundle_id:@deploy_identifier_keyboard, app_group:app_group, setting_array:["app_group"])
  end

  if !app.nil? && !@deploy_identifier_imessage.nil?
    create_bundleid(bundle_id:@deploy_identifier_imessage, app_group:app_group, setting_array:["app_group"])
  end

  if !app.nil? && !@deploy_identifier_siri.nil?
    create_bundleid(bundle_id:@deploy_identifier_siri, app_group:app_group, setting_array:["app_group", "siri"])
  end

  if !app.nil? && !@deploy_identifier_siriui.nil?
    create_bundleid(bundle_id:@deploy_identifier_siriui, app_group:app_group, setting_array:["app_group", "siri"])
  end

  if !app.nil? && !@deploy_identifier_widget.nil?
    create_bundleid(bundle_id:@deploy_identifier_widget, app_group:app_group, setting_array:["app_group"])
  end

  if !app.nil? && !@deploy_identifier_extension.nil?
    create_bundleid(bundle_id:@deploy_identifier_extension, app_group:app_group, setting_array:["app_group"])
  end

  if !app.nil? && !@deploy_identifier_extensionad.nil?
    create_bundleid(bundle_id:@deploy_identifier_extensionad, app_group:app_group, setting_array:["app_group"])
  end

  if !app.nil? && !@deploy_identifier_watchapp.nil?
    create_bundleid(bundle_id:@deploy_identifier_watchapp, app_group:nil, setting_array:["push_notification"])
  end

  if !app.nil? && !@deploy_identifier_watchapp_extemsion.nil?
    create_bundleid(bundle_id:@deploy_identifier_watchapp_extemsion, app_group:nil, setting_array:["push_notification"])
  end

end