Class: Pindo::Command::Appstore::Pem
- Inherits:
-
Pindo::Command::Appstore
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Appstore
- Pindo::Command::Appstore::Pem
- Defined in:
- lib/pindo/command/appstore/pem.rb
Constant Summary
Constants inherited from Pindo::Command
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
Attributes inherited from Pindo::Command
Class Method Summary collapse
-
.option_items ⇒ Object
定义此命令使用的参数项(类方法,避免重复定义).
-
.options ⇒ Object
命令的选项列表.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Pem
constructor
A new instance of Pem.
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from Pindo::Command
command_name, #initialize_options, run, use_cache?
Methods included from Funlog::Mixin
Methods included from Pindoconfig::Mixin
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, #git_root_directory, #is_git_directory?, #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, popen3, reader, which, which!
Constructor Details
#initialize(argv) ⇒ Pem
Returns a new instance of Pem.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/pindo/command/appstore/pem.rb', line 85 def initialize(argv) # 首先获取位置参数(向后兼容) positional_config = argv.shift_argument # 使用 Options 模块初始化参数 @options = (argv) # 优先使用选项参数,如果没有则使用位置参数,最后默认为当前目录的config.json @config_path = @options[:config] || positional_config || File.join(Dir.pwd, 'config.json') @args_dev_flag = @options[:dev] @deploy_repo_name = @options[:repo] super @additional_args = argv.remainder! end |
Class Method Details
.option_items ⇒ Object
定义此命令使用的参数项(类方法,避免重复定义)
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 |
# File 'lib/pindo/command/appstore/pem.rb', line 52 def self.option_items @option_items ||= [ Pindo::Options::OptionItem.new( key: :config, description: '指定config.json文件路径', type: String, optional: true, example: 'pindo appstore pem --config=config.json' ), Pindo::Options::OptionItem.new( key: :dev, description: '创建开发环境证书(默认为生产环境)', type: TrueClass, optional: true, default_value: false, example: 'pindo appstore pem --dev' ), Pindo::Options::OptionItem.new( key: :repo, description: '部署仓库名称(用于上传证书)', type: String, optional: true, example: 'pindo appstore pem --repo=com.example.app' ) ] end |
.options ⇒ Object
命令的选项列表
80 81 82 83 |
# File 'lib/pindo/command/appstore/pem.rb', line 80 def self. # 转换为 CLAide 格式 option_items.map { |item| item.to_claide_option }.concat(super) end |
Instance Method Details
#run ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/pindo/command/appstore/pem.rb', line 117 def run # 调用 PemHelper 执行 Push 证书创建流程 begin cert_path = Pindo::PemHelper.execute_pem_creation( config_json: @config_json, dev_flag: @args_dev_flag, deploy_repo_name: @deploy_repo_name ) puts "\n✓ Push 证书创建完成!" puts "证书路径: #{cert_path}" rescue StandardError => e puts "\n❌ Push 证书创建失败: #{e.}" raise e end end |
#validate! ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/pindo/command/appstore/pem.rb', line 101 def validate! super # 检查 config.json 文件是否存在 unless File.exist?(@config_path) help! "配置文件不存在: #{@config_path}" end # 读取并解析 config.json begin @config_json = JSON.parse(File.read(@config_path)) rescue JSON::ParserError => e help! "配置文件格式错误: #{e.}" end end |