Module: Pindo::SwarkHelper

Included in:
Command::Deploy::Cert, Command::Deploy::Configproj
Defined in:
lib/pindo/module/build/swarkhelper.rb

Instance Method Summary collapse

Instance Method Details

#add_swark_authorize_jsonObject



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
# File 'lib/pindo/module/build/swarkhelper.rb', line 61

def add_swark_authorize_json
  if @build_type == "appstore" && @config_json['project_info']['xcode_build_type'] && @config_json["project_info"]["xcode_build_type"].include?("swark")
          
    app_config_dir = clong_buildconfig_repo(repo_name: @deploy_repo_name)
    swark_authorize_file = File.join(app_config_dir, "swark_authorize.json")
    if File.exist?(swark_authorize_file)
        swark_authorize_json=JSON.parse(File.read(swark_authorize_file))
        if swark_authorize_json && swark_authorize_json['swark_authorize_status']
            puts "swark already authorize success !!! "
        else
            swark_authorize_json = swark_authorize_json || {}
            swark_authorize_json['swark_authorize_teamid'] = @team_id_vaule
            swark_authorize_json['swark_authorize_bundleid'] = @bundle_id
            swark_authorize_json['swark_authorize_status'] = false
            File.open(swark_authorize_file, "w") do |f|
              f.write(JSON.pretty_generate(swark_authorize_json))
            end
            git_addpush_repo(path:app_config_dir, message:"add swark authorize json")
        end
    else
      swark_authorize_json = swark_authorize_json || {}
      swark_authorize_json['swark_authorize_teamid'] = @team_id_vaule
      swark_authorize_json['swark_authorize_bundleid'] = @bundle_id
      swark_authorize_json['swark_authorize_status'] = false
      File.open(swark_authorize_file, "w") do |f|
        f.write(JSON.pretty_generate(swark_authorize_json))
      end
      git_addpush_repo(path:app_config_dir, message:"add swark authorize json")
    end
    
  end
end

#add_swark_entitlement(entitlements_plist_path: nil, bundle_id_dict: nil) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/pindo/module/build/swarkhelper.rb', line 47

def add_swark_entitlement(entitlements_plist_path:nil, bundle_id_dict:nil)
  if @config_json['project_info']['xcode_build_type'] && @config_json["project_info"]["xcode_build_type"].include?("swark")
    if File.exist?(entitlements_plist_path)
      entitlements_plist_dict = Xcodeproj::Plist.read_from_path(entitlements_plist_path)

      key_value = @team_id_vaule 
      key_value = key_value + "." +  @bundle_id
      entitlements_plist_dict['keychain-access-groups'] = [key_value]

      Xcodeproj::Plist.write_to_path(entitlements_plist_dict, entitlements_plist_path)
    end
  end
end

#check_swark_authorize(config_json: nil, buid_type: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pindo/module/build/swarkhelper.rb', line 10

def check_swark_authorize(config_json:nil, buid_type:nil)
    if !config_json.nil? && config_json['project_info']['xcode_build_type'] && config_json["project_info"]["xcode_build_type"].include?("swark")

        app_config_dir = File.join(File::expand_path(pindo_single_config.pindo_dir), @deploy_identifier)
        swark_authorize_file = File.join(app_config_dir, "swark_authorize.json")
        if File.exist?(swark_authorize_file)
            swark_authorize_json=JSON.parse(File.read(swark_authorize_file))
            unless swark_authorize_json && swark_authorize_json['swark_authorize_status']
                show_swark_authorize_error(swark_authorize_json:swark_authorize_json , buid_type:buid_type)
            end
        end
    end
end

#show_swark_authorize_error(swark_authorize_json: nil, buid_type: nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pindo/module/build/swarkhelper.rb', line 24

def show_swark_authorize_error(swark_authorize_json:nil, buid_type:nil)

    puts  "++++ +++ Need authorize !!! ++++"
    puts  "+++ Need authorize !!! ++++"
    puts  "+++ Need authorize !!! +++++"
    puts  " =========================="
    puts

    puts "方法一:"
    command = "     1. swark authorize "
    command = command + swark_authorize_json["swark_authorize_teamid"] + "." + swark_authorize_json["swark_authorize_bundleid"]
    puts  command
    command = "     2. 修改swark_authorize.json 中的 swark_authorize_status = true 并且提交"
    puts

    puts "方法二:"
    puts "      pindo deploy quswark"
    if buid_type.downcase.to_s.include?("appstore")
        raise Informative, "Need  swark authorize !!!"
    end
end