lib/ormdev/source/util/http_util.rb in ormdev-0.1.6 vs lib/ormdev/source/util/http_util.rb in ormdev-0.1.7
- old
+ new
@@ -2,12 +2,66 @@
require 'faraday_middleware'
module OrmDev
class HTTPUtil
- API_THIRD_PLUGIN_PUBLISH = 'http://192.168.2.110:8081/soops/sword/portal?SwordControllerName=uploadPlugin'.freeze #测试地址
+ API_THIRD_PLUGIN_CHECK = 'http://112.65.142.83:7799/soops/sword/portal/checkPluginBaseInfo'.freeze #测试地址
+ API_THIRD_PLUGIN_PUBLISH = 'http://112.65.142.83:7799/soops/sword/portal?SwordControllerName=uploadPlugin'.freeze #测试地址
+ def self.send_check_plugin_http(username, password, publish_type, podspec_path, zip_path, changelog = '')
+ @spec = Pod::Specification.from_file(podspec_path)
+ cim_sdk_version = ''
+ @spec.dependencies.each do |dep|
+ if 'CIMSDK'.eql? dep.name
+ cim_sdk_version = plugin_version_from(dep.requirement.requirements.flatten.last.to_s)
+ end
+ end
+
+ # start upload
+ conn_options = {
+ request: {
+ timeout: 1000,
+ open_timeout: 300
+ }
+ }
+ pgyer_client = Faraday.new(nil, conn_options) do |c|
+ c.request :multipart
+ c.request :url_encoded
+ c.response :json, content_type: /\bjson$/
+ c.adapter :net_http
+ end
+
+ params = {
+ 'username' => username || ENV['ORMDEV_CLT_USERNAME'],
+ 'password' => password || ENV['ORMDEV_CLT_PASSWORD'],
+ 'version' => OrmDev::VERSION,
+ 'platform' => 1,# 0:android,1:ios
+ 'pluginName' => @spec.name.gsub(/^CIP/, 'cip'),
+ 'pluginVersion' => @spec.version.to_s,
+ 'pluginBaseVersion' => cim_sdk_version, #base版本号
+ }
+
+ unless podspec_path.nil? then
+ params[File.basename(podspec_path)] = Faraday::UploadIO.new(podspec_path, 'application/octet-stream') if File.exist?(podspec_path)
+ end
+ unless zip_path.nil? then
+ params[File.basename(zip_path)] = Faraday::UploadIO.new(zip_path, 'application/octet-stream') if File.exist?(zip_path)
+ end
+ OrmDev::LogUtil.info '【发布第三方插件】开始上传 ...'
+
+ api = ENV['ORMDEV_CLT_API_THIRD_PLUGIN_PUBLISH'] || API_THIRD_PLUGIN_PUBLISH
+ response = pgyer_client.post api, params
+
+ info = response.body
+ OrmDev::LogUtil.info "【第三方插件发布】#{api}"
+ OrmDev::LogUtil.info "【第三方插件发布】Upload complate: #{info}"
+ if info && info['status'] && info['status'] == '0000' then
+ OrmDev::LogUtil.info '【第三方插件发布】上传成功'
+ end
+ info
+ end
+
def self.send_pulish_plugin_http(username, password, publish_type, podspec_path, zip_path, changelog = '')
@spec = Pod::Specification.from_file(podspec_path)
cim_sdk_version = ''
@spec.dependencies.each do |dep|
if 'CIMSDK'.eql? dep.name
@@ -55,9 +109,12 @@
if info && info['status'] && info['status'] == '0000' then
OrmDev::LogUtil.info '【第三方插件发布】上传成功'
end
info
end
+
+ ORMDEV_CLT_API_THIRD_PLUGIN_CHECK
+
private
def self.plugin_version_from(pod_version)
if pod_version.nil? then
\ No newline at end of file