Class: OrmDev::Command::Publish

Inherits:
OrmDev::Command show all
Defined in:
lib/ormdev/command/publish.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Publish

Returns a new instance of Publish.



28
29
30
31
32
33
34
35
36
37
# File 'lib/ormdev/command/publish.rb', line 28

def initialize(argv)
  @podspec_file = argv.shift_argument
  @podspec_files = Pathname.pwd.children.select { |pn| pn.extname == '.podspec' }
  @account = argv.option('account')
  @password = argv.option('password')
  @changelog = argv.option('changelog', '')
  @push_type = argv.option('push-type').to_i
  @zip = argv.option('zip')
  super
end

Class Method Details

.optionsObject



18
19
20
21
22
23
24
25
26
# File 'lib/ormdev/command/publish.rb', line 18

def self.options
  [
      ['--account=XXX', '发布第三方插件的账户名'],
      ['--password=XXX', '发布第三方插件的密码'],
      ['--changelog=xxxx', '更新说明'],
      ['--zip=xxx', '插件SDK本地地址,当push-type = 0,是必传'],
      ['--push-type=[0,1,2]', '发布类型:0、替换+push+录入;1、push+录入;2、直接录入'],
  ].concat(super)
end

Instance Method Details

#runObject



57
58
59
60
61
62
63
# File 'lib/ormdev/command/publish.rb', line 57

def run
  super
  OrmDev::LogUtil.info '[插件发布] '.green
  info = OrmDev::HTTPUtil.send_pulish_plugin_http(@account, @password, @push_type, @podspec_path, @zip, @changelog)
  OrmDev::LogUtil.info "插件上传完成!!! #{info}"
  OrmDev::LogUtil.link(info['previewUrl'], '前往查看发布结果:')
end

#validate!Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ormdev/command/publish.rb', line 39

def validate!
  super
  # raise Pod::Informative, "No `Cimfile' found in the project directory." unless @cipfile_path.exist?
  if @podspec_file
    help! "podspec file at #{@podspec_file} does not exist" unless File.exist? @podspec_file
    @podspec_path = @podspec_file
  else
    raise Pod::Informative, 'No podspec file found, please specify one' unless @podspec_files.length > 0
    raise Pod::Informative, 'Multiple podspec file found, please specify one' unless @podspec_files.length == 1
    @podspec_path = @podspec_files.first
  end
  help! '发布类型传值错误' if @push_type < 0 || @push_type > 2
  if @push_type == 0 then
    help! '插件zip包地址不能为空' if @zip.nil?
    help! "插件zip包地址( #{@zip} )不存在" unless File.exist? @zip
  end
end