Class: Pindo::Command::Appstore::Tag

Inherits:
Pindo::Command::Appstore show all
Defined in:
lib/pindo/command/appstore/tag.rb

Constant Summary

Constants inherited from Pindo::Command

DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes inherited from Pindo::Command

#args_help_flag

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pindo::Command

command_name, #initialize_options, run, use_cache?

Methods included from Funlog::Mixin

#pindo_log_instance

Methods included from Pindoconfig::Mixin

#pindo_single_config

Methods included from HelpValidator

#validate!

Constructor Details

#initialize(argv) ⇒ Tag

Returns a new instance of Tag.



35
36
37
38
39
# File 'lib/pindo/command/appstore/tag.rb', line 35

def initialize(argv)
    @options = initialize_options(argv)
    @delete_tag_name = @options[:delete]
    super
end

Class Method Details

.option_itemsObject



27
28
29
# File 'lib/pindo/command/appstore/tag.rb', line 27

def self.option_items
  @option_items ||= Pindo::Options::AppStoreOptions.select(:delete)
end

.optionsObject



31
32
33
# File 'lib/pindo/command/appstore/tag.rb', line 31

def self.options
  option_items.map(&:to_claide_option).concat(super)
end

Instance Method Details

#runObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/pindo/command/appstore/tag.rb', line 41

def run

    project_dir = Dir.pwd
    config_file = File.join(project_dir, "config.json")

    # 加载配置
    config_parser = Pindo::IosConfigParser.instance
    config_parser.load_config(config_file: config_file)
    config_json = config_parser.config_json
    bundle_id = config_parser.bundle_id

    if config_json.nil? || config_json.empty?
        raise Informative, "配置未加载,请检查配置文件: #{config_file}"
    end

    if bundle_id.nil? || bundle_id.empty?
        raise Informative, "无法从配置文件中获取 Bundle ID"
    end

    # 创建临时对象来调用模块方法
    tag_helper = Object.new
    tag_helper.extend(Pindo::XcodeAppConfig)

    # 调用封装的方法
    success = tag_helper.create_release_tag(
        project_dir: project_dir,
        config_json: config_json,
        bundle_id: bundle_id,
        delete_tag_name: @delete_tag_name
    )

    unless success
        raise Informative, "创建 tag 失败,请检查日志"
    end
end