require 'cocoapods' require_relative '../source/core/run_helper' module OrmDev class Command class Run < Command self.summary = '运行插件发布整个流程[检查运行环境、打包静态库、归档framework]' self.description = <<-DESC 指定'插件名.podspec'的路径`PATH`。 运行插件发布整个流程【检查运行环境、打包静态库、归档framework】。 【*】在运行前完成版本控制和'插件名.podspec'配置 【*】如果暂时未加入版本控制,命令提供临时解决方案: 1、启动Mac系统默认Apache `sudo apachectl restart`; 2、归档源码`插件名.zip`到本机`/Library/WebServer/Documents/OrmPlugins`目录下; 3、配置地址`http://localhost/插件名.zip`。 在此期间需要获取系统权限,需要输入开机密码。 DESC self.arguments = [ CLAide::Argument.new('PATH', false) ] def self.options [ ['--without-version-control', '没有版本控制'], ].concat(super) end def initialize(argv) @podspec_file = argv.shift_argument @podspec_files = Pathname.pwd.children.select { |pn| pn.extname == '.podspec' } @no_version_control = argv.flag?('without-version-control') super end 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 end def run super OrmDev::LogUtil.info '[插件发布] '.green installer = OrmDev::RunHelper.new(@podspec_path) framework_zip = installer.setup(@no_version_control) framework_zip_path= File.expand_path('./', framework_zip) OrmDev::LogUtil.info "Success!!! 静态库编译完成:#{framework_zip_path}" OrmDev::LogUtil.info " ormdev publish #{@podspec_path} --zip=#{framework_zip_path} --push-type=0".magenta end end end end