lib/ormdev/command/publish.rb in ormdev-0.0.7 vs lib/ormdev/command/publish.rb in ormdev-0.0.8

- old
+ new

@@ -1,8 +1,8 @@ require 'cocoapods' -require_relative '../source/core/run_helper' +require_relative '../source/util/http_util' module OrmDev class Command class Publish < Command self.summary = '发布插件' @@ -15,16 +15,26 @@ CLAide::Argument.new('PATH', false) ] 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 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 def validate! super @@ -35,17 +45,21 @@ 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 def run super OrmDev::LogUtil.info '[插件发布] '.green - installer = OrmDev::RunHelper.new(@podspec_path) - installer.setup() - OrmDev::LogUtil.info "Success!!! Please run command:\n orm ipa \#{platform}" + info = OrmDev::HTTPUtil.send_pulish_plugin_http(@account, @password, @push_type, @podspec_path, @zip, @changelog) + OrmDev::LogUtil.info "插件发布完成!!! #{info}" end end end end \ No newline at end of file