Class: Pindo::CertProcess::CustomGitCertOperator

Inherits:
BaseCertOperator show all
Defined in:
lib/pindo/module/cert/mode/custom_git_cert_operator.rb

Overview

✅/📝 场景 3、4:Custom + Git 证书操作

自定义方式管理证书,存储在自定义 Git 仓库

创建模式(📝 TODO):

  • 手动调用 Apple Developer API 创建证书

  • AES 加密证书文件

  • 推送到自定义 Git 仓库

  • 安装到本地 Keychain

获取模式(✅ 已实现):

  • 从自定义 Git 仓库拉取加密证书

  • AES 解密

  • 安装到本地 Keychain

  • 配置 Xcode 工程

Instance Method Summary collapse

Instance Method Details

#create_and_install_certs(apple_id:, bundle_id_array:, cert_type:, platform_type:, project_dir: nil) ⇒ Array<Hash>

📝 场景 4:创建 + Custom + Git(TODO)

使用自定义方式创建证书并推送到 Git 仓库

Parameters:

  • apple_id (String)

    Apple ID

  • bundle_id_array (Array<String>)

    Bundle ID 数组

  • cert_type (String)

    证书类型

  • platform_type (String)

    平台类型

  • project_dir (String, nil) (defaults to: nil)

    项目目录(可选,如果提供则配置 Xcode 工程)

Returns:

  • (Array<Hash>)

    provisioning_info_array

Raises:

  • (NotImplementedError)


38
39
40
# File 'lib/pindo/module/cert/mode/custom_git_cert_operator.rb', line 38

def create_and_install_certs(apple_id:, bundle_id_array:, cert_type:, platform_type:, project_dir: nil)
  raise NotImplementedError, "#TODO: HTTPS 下载证书尚未实现。"
end

#fetch_and_install_certs(apple_id:, bundle_id_array:, cert_type:, platform_type:, project_dir: nil) ⇒ Array<Hash>

✅ 场景 3:获取 + Custom + Git

从自定义 Git 仓库获取证书并安装

Parameters:

  • apple_id (String)

    Apple ID

  • bundle_id_array (Array<String>)

    Bundle ID 数组(未使用,保留向后兼容)

  • cert_type (String)

    证书类型

  • platform_type (String)

    平台类型

  • project_dir (String, nil) (defaults to: nil)

    项目目录(可选,如果提供则配置 Xcode 工程)

Returns:

  • (Array<Hash>)

    provisioning_info_array



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
# File 'lib/pindo/module/cert/mode/custom_git_cert_operator.rb', line 52

def fetch_and_install_certs(apple_id:, bundle_id_array:, cert_type:, platform_type:, project_dir: nil)
  Funlog.instance.fancyinfo_start("从自定义 Git 仓库获取并安装证书...")

  # 1. 验证配置并获取 config_parser
  config_parser = validate_and_get_config

  # 2. 从 Git 仓库克隆证书并获取 Git URL
  certs_dir, cert_git_url = clone_cert_repo_from_git(apple_id: apple_id)

  # 3. 安装证书到 Keychain(AES 解密 + 安装)
  install_certs(
    cert_url: cert_git_url,
    certs_dir: certs_dir,
    cert_type: cert_type,
    platform_type: platform_type
  )

  # 4. 安装 Provisioning Profiles
  provisioning_info_array = install_provisionfiles(
    cert_url: cert_git_url,
    certs_dir: certs_dir,
    bundle_id_map: config_parser.get_bundle_id_map,
    cert_type: cert_type,
    platform_type: platform_type
  )

  # 5. 验证并保存证书信息,提取 Team ID
  team_id = validate_and_save_cert_info(provisioning_info_array)

  # 6. 执行 Swark 授权检查
  perform_swark_authorization(
    cert_type: cert_type,
    team_id: team_id,
    config_parser: config_parser
  )

  # 7. 配置 Xcode 工程
  configure_xcode_for_certs(
    project_dir: project_dir,
    cert_type: cert_type,
    platform_type: platform_type,
    team_id: team_id,
    provisioning_info_array: provisioning_info_array,
    config_parser: config_parser
  )

  Funlog.instance.fancyinfo_success("自定义 Git 仓库获取证书完成!")
  provisioning_info_array
end