Class: Pindo::SwarkHelper
- Inherits:
-
Object
- Object
- Pindo::SwarkHelper
- Defined in:
- lib/pindo/module/build/swark_helper.rb
Overview
Swark 授权辅助类负责 Swark 授权检查、权限配置等操作
Class Method Summary collapse
-
.add_swark_authorize_json(build_type:, config_json:, team_id:, bundle_id:, deploy_repo_name:) ⇒ Object
添加 Swark 授权配置文件.
-
.add_swark_entitlement(entitlements_plist_path:, bundle_id_dict:, config_json:, team_id:, bundle_id:) ⇒ Object
添加 Swark 权限配置到 entitlements.
-
.check_swark_authorize(config_json:, buid_type:, deploy_identifier:) ⇒ Object
检查 Swark 授权状态.
-
.show_swark_authorize_error(swark_authorize_json:, buid_type:) ⇒ Object
显示 Swark 授权错误信息.
Class Method Details
.add_swark_authorize_json(build_type:, config_json:, team_id:, bundle_id:, deploy_repo_name:) ⇒ Object
添加 Swark 授权配置文件
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 |
# File 'lib/pindo/module/build/swark_helper.rb', line 96 def self.( build_type:, config_json:, team_id:, bundle_id:, deploy_repo_name: ) return unless build_type == "appstore" && config_json && config_json['project_info'] && config_json['project_info']['xcode_build_type'] && config_json['project_info']['xcode_build_type'].include?("swark") app_config_dir = Pindo::GitHandler.clong_buildconfig_repo(repo_name: deploy_repo_name) = File.join(app_config_dir, "swark_authorize.json") if File.exist?() = JSON.parse(File.read()) if && ['swark_authorize_status'] puts "swark already authorize success !!! " return end end # 创建或更新授权文件 = {} ['swark_authorize_teamid'] = team_id ['swark_authorize_bundleid'] = bundle_id ['swark_authorize_status'] = false File.open(, "w") do |f| f.write(JSON.pretty_generate()) end Pindo::GitHandler.git_addpush_repo(path: app_config_dir, message: "add swark authorize json") end |
.add_swark_entitlement(entitlements_plist_path:, bundle_id_dict:, config_json:, team_id:, bundle_id:) ⇒ Object
添加 Swark 权限配置到 entitlements
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/pindo/module/build/swark_helper.rb', line 68 def self.add_swark_entitlement( entitlements_plist_path:, bundle_id_dict:, config_json:, team_id:, bundle_id: ) return unless config_json && config_json['project_info'] && config_json['project_info']['xcode_build_type'] && config_json['project_info']['xcode_build_type'].include?("swark") return unless File.exist?(entitlements_plist_path) entitlements_plist_dict = Xcodeproj::Plist.read_from_path(entitlements_plist_path) key_value = team_id + "." + bundle_id entitlements_plist_dict['keychain-access-groups'] = [key_value] Xcodeproj::Plist.write_to_path(entitlements_plist_dict, entitlements_plist_path) end |
.check_swark_authorize(config_json:, buid_type:, deploy_identifier:) ⇒ Object
检查 Swark 授权状态
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pindo/module/build/swark_helper.rb', line 16 def self.(config_json:, buid_type:, deploy_identifier:) return unless config_json && config_json['project_info'] && config_json['project_info']['xcode_build_type'] && config_json['project_info']['xcode_build_type'].include?("swark") require 'pindo/config/pindoconfig' app_config_dir = File.join(File.(Pindoconfig.instance.pindo_dir), deploy_identifier) = File.join(app_config_dir, "swark_authorize.json") if File.exist?() = JSON.parse(File.read()) unless && ['swark_authorize_status'] ( swark_authorize_json: , buid_type: buid_type ) end end end |
.show_swark_authorize_error(swark_authorize_json:, buid_type:) ⇒ Object
显示 Swark 授权错误信息
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pindo/module/build/swark_helper.rb', line 40 def self.(swark_authorize_json:, buid_type:) puts "++++ +++ Need authorize !!! ++++" puts "+++ Need authorize !!! ++++" puts "+++ Need authorize !!! +++++" puts " ==========================" puts puts "方法一:" command = " 1. swark authorize " command += ["swark_authorize_teamid"] + "." + ["swark_authorize_bundleid"] puts command puts " 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 |