Class: Pindo::Command::Deploy::Itcapp

Inherits:
Pindo::Command::Deploy show all
Includes:
Pindo::Command::DeployOptions
Defined in:
lib/pindo/command/deploy/itcapp.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) ⇒ Itcapp

Returns a new instance of Itcapp.



26
27
28
29
30
31
# File 'lib/pindo/command/deploy/itcapp.rb', line 26

def initialize(argv)
  @app_version = argv.option('num')
  @com_name = argv.option('com')
  puts "@app_version = #{@app_version}"
  super
end

Class Method Details

.optionsObject



19
20
21
22
23
24
# File 'lib/pindo/command/deploy/itcapp.rb', line 19

def self.options
    [
        ['--num', 'itc num version'],
        ['--com', 'itc num version'],
    ].concat(super)
end

Instance Method Details

#create_itcapp(temp_bundle_id: nil) ⇒ Object



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

def create_itcapp(temp_bundle_id:nil)

  temp_version = "1.0.0"
  if @config_json && @config_json["app_info"] && @config_json["app_info"]["app_version"]
    temp_version = @config_json["app_info"]["app_version"]
  end 

  if (@com_name.nil? || @com_name.empty?) && !@config_json.nil? && !@config_json["account_info"].nil? && !@config_json["account_info"]["acount_company_name"].nil?
    @com_name = @config_json["account_info"]["acount_company_name"].strip
  end

  app = nil
  if !temp_bundle_id.nil?
    app = Spaceship::ConnectAPI::App.find(temp_bundle_id)
    if app == nil
      app_sku_id_fixed = temp_bundle_id + ".sku"
      puts "App的默认sku id 为:    #{app_sku_id_fixed}"
      input_skuid = ask("请自定义输入App Sku ID: ") || nil
      if !input_skuid.nil? && input_skuid.length > 1
        app_sku_id_fixed = input_skuid
      end

      if @com_name.nil?
        @com_name = ask('Company Name : ') || nil
      end
      puts "App Sku ID   : #{app_sku_id_fixed}"
      puts "Company Name : #{@com_name}"
      answer = agree("请确认上面信息是否正确(Y/n):")
      unless answer
        raise Informative, "重新创建 !!!"
      end 
      app_default_name = temp_bundle_id.gsub('.', '')
      if app_default_name.length > 30
        app_default_name.slice!(30)
      end
      app = Spaceship::ConnectAPI::App.create(name: app_default_name,
                                version_string: temp_version, # initial version
                                sku: app_sku_id_fixed,
                                primary_locale: "en-US",
                                bundle_id: temp_bundle_id,
                                platforms: ["IOS"],
                                company_name:@com_name
                              )
      puts "App is created !!!"
    else
      puts "App is already exist !!!"
    end

  end
  return app
end

#modify_appconfig_appleid(temp_bundle_id: nil) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/pindo/command/deploy/itcapp.rb', line 54

def modify_appconfig_appleid(temp_bundle_id:nil)

  app = Spaceship::ConnectAPI::App.find(temp_bundle_id)
  unless app.nil?
    puts 
    puts " app.id :  #{app.id}  +++++++++",
    puts
    modify_appconfig_file(app_config_file:@args_appconfig_fullname, app_info_detail:app)
    app_config_dir = clong_buildconfig_repo(repo_name: @deploy_repo_name)
    app_config_file = File.join(app_config_dir, "config.json")
    modify_appconfig_file(app_config_file:app_config_file, app_info_detail:app)
    prepare_gitenv()
    git_addpush_repo(path:app_config_dir, message:"modify apple id ")
  end
  
end

#modify_appconfig_file(app_config_file: nil, app_info_detail: nil) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/pindo/command/deploy/itcapp.rb', line 71

def modify_appconfig_file(app_config_file:nil, app_info_detail:nil)
  config_content=JSON.parse(File.read(app_config_file))
  File.open(app_config_file, "w") do |f|
    config_content['app_info']['app_id_ios'] = app_info_detail.id
    if config_content['app_setting']["apple_app_id"]
      config_content['app_setting']["apple_app_id"] =  app_info_detail.id
    end

    if config_content['app_setting']["kGUKeyAppId"]
      config_content['app_setting']["kGUKeyAppId"] =  app_info_detail.id
    end

    f.write(JSON.pretty_generate(config_content))
  end

end

#runObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/pindo/command/deploy/itcapp.rb', line 34

def run

  Spaceship::Portal.(@apple_id.to_s)
  Spaceship::Portal.select_team
  app = Spaceship::Portal.app.find(@bundle_id)
  if app.nil?
    Bundleid::run([@args_appconfig])
    sleep(2)
  end
  puts "Create app in itc ..."
  puts @apple_id
  puts "Login #{@apple_id}..."
  Spaceship::Tunes.(@apple_id.to_s)
  Spaceship::Tunes.select_team

  create_itcapp(temp_bundle_id:@bundle_id)
  modify_appconfig_appleid(temp_bundle_id:@bundle_id)

end