ormdev 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1dcbd975dcf2f884342e1967c149a2069b6e8b1dcedbccaa82dbcf53237860b0
4
- data.tar.gz: 5dc15e05f7e8664faca371cceb5ee5dc5b38e1028d51859cf21057aede9f83e9
3
+ metadata.gz: 27324a958a9f1f17ed9fb67551d4feec4d1afead11c973c07fde615274a4b656
4
+ data.tar.gz: 97aa2fbe11290e69ffa83089955c04f1400db87149233c013ebda71a03aae349
5
5
  SHA512:
6
- metadata.gz: ca1345de733b3d9fe6138c78f943a900504f86a5d0b7148f67edb63bd07bd26e866002cb43ed05037da107d08060dc0a108c8b7a5e607ee7c4d57a931b4c69fb
7
- data.tar.gz: ea319e99aea4571e03813bf39dfd6648c48a655d7e9cc12395f20bca30a64a38bc0d1d731b002a65a3972da7f6abe90e9a80d0f2e013eb4954a1c8bdb91cf39d
6
+ metadata.gz: a8cbcf9a055f8ac0baf8065986dbc231d83aef0418d757191d56627b7824950df2b3e22ed9230d9eab96797e77bf713ea2d9c7ed74278a4fb4a59d67786c34e0
7
+ data.tar.gz: 77e989221ccba398e69d6b5970b35f77c5ebb852bed5d425395ebf4a7a6de422de32a2fad6dd17b66e70721fd3df48b07d8e8a7b73f08b6c402a9784a8e2c340
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ormdev (0.0.7)
4
+ ormdev (0.0.8)
5
5
  claide (~> 1.0, >= 1.0.2)
6
6
  cocoapods (~> 1.5, >= 1.5.3)
7
7
  rubyzip (~> 1.2, >= 1.2.2)
@@ -42,7 +42,7 @@ module OrmDev
42
42
  def run
43
43
  create = OrmDev::CreateHelper.new(@name, @fast, @prefix, @template_url)
44
44
  create.setup(@skip)
45
- OrmDev::LogUtil.info "【create】Success!!! "
45
+ OrmDev::LogUtil.info "【创建插件工程】Success!!!, `cd #{@name}` \n `ormdev run ` "
46
46
  end
47
47
  end
48
48
  end
@@ -17,12 +17,14 @@ module OrmDev
17
17
 
18
18
  def self.options
19
19
  [
20
+ ['--source', '依赖库源码更新'],
20
21
  ].concat(super)
21
22
  end
22
23
 
23
24
  def initialize(argv)
24
25
  @podspec_file = argv.shift_argument
25
26
  @podspec_files = Pathname.pwd.children.select { |pn| pn.extname == '.podspec' }
27
+ @source = argv.flag?('source', false)
26
28
  super
27
29
  end
28
30
 
@@ -42,7 +44,10 @@ module OrmDev
42
44
  super
43
45
  OrmDev::LogUtil.info '[插件管理] 验证Pod'.green
44
46
  @spec = Pod::Specification.from_file(@podspec_path)
45
- pod_lint_command = 'pod lib lint --sources=orm,master --allow-warnings --verbose --use-libraries'
47
+ ORM::SHUtil.run_command("pod cache clean #{@spec.name} --all",'清除Pod缓存',false)
48
+ pod_lint_command = ''
49
+ pod_lint_command << "#{@spec.name}_Lib=1" unless @source
50
+ pod_lint_command << ' pod lib lint --sources=orm,master --allow-warnings --use-libraries --verbose'
46
51
  OrmDev::SHUtil.run_command(pod_lint_command,'更验证Pod',false)
47
52
  end
48
53
  end
@@ -1,6 +1,6 @@
1
1
  require 'cocoapods'
2
2
 
3
- require_relative '../source/core/run_helper'
3
+ require_relative '../source/util/http_util'
4
4
 
5
5
  module OrmDev
6
6
  class Command
@@ -17,12 +17,22 @@ module OrmDev
17
17
 
18
18
  def self.options
19
19
  [
20
+ ['--account=XXX', '发布第三方插件的账户名'],
21
+ ['--password=XXX', '发布第三方插件的密码'],
22
+ ['--changelog=xxxx', '更新说明'],
23
+ ['--zip=xxx', '插件SDK本地地址,当push-type = 0,是必传'],
24
+ ['--push-type=[0,1,2]', '发布类型:0、替换+push+录入;1、push+录入;2、直接录入'],
20
25
  ].concat(super)
21
26
  end
22
27
 
23
28
  def initialize(argv)
24
29
  @podspec_file = argv.shift_argument
25
30
  @podspec_files = Pathname.pwd.children.select { |pn| pn.extname == '.podspec' }
31
+ @account = argv.option('account')
32
+ @password = argv.option('password')
33
+ @changelog = argv.option('changelog', '')
34
+ @push_type = argv.option('push-type').to_i
35
+ @zip = argv.option('zip')
26
36
  super
27
37
  end
28
38
 
@@ -37,14 +47,18 @@ module OrmDev
37
47
  raise Pod::Informative, 'Multiple podspec file found, please specify one' unless @podspec_files.length == 1
38
48
  @podspec_path = @podspec_files.first
39
49
  end
50
+ help! '发布类型传值错误' if @push_type < 0 || @push_type > 2
51
+ if @push_type == 0 then
52
+ help! '插件zip包地址不能为空' if @zip.nil?
53
+ help! "插件zip包地址( #{@zip} )不存在" unless File.exist? @zip
54
+ end
40
55
  end
41
56
 
42
57
  def run
43
58
  super
44
59
  OrmDev::LogUtil.info '[插件发布] '.green
45
- installer = OrmDev::RunHelper.new(@podspec_path)
46
- installer.setup()
47
- OrmDev::LogUtil.info "Success!!! Please run command:\n orm ipa \#{platform}"
60
+ info = OrmDev::HTTPUtil.send_pulish_plugin_http(@account, @password, @push_type, @podspec_path, @zip, @changelog)
61
+ OrmDev::LogUtil.info "插件发布完成!!! #{info}"
48
62
  end
49
63
  end
50
64
  end
@@ -5,10 +5,16 @@ require_relative '../source/core/run_helper'
5
5
  module OrmDev
6
6
  class Command
7
7
  class Run < Command
8
- self.summary = '运行插件发布整个流程[检查运行环境、framwork、zip]'
8
+ self.summary = '运行插件发布整个流程[检查运行环境、打包静态库、归档framework]'
9
9
  self.description = <<-DESC
10
- 运行插件发布整个流程.
11
10
  指定'插件名.podspec'的路径`PATH`。
11
+ 运行插件发布整个流程【检查运行环境、打包静态库、归档framework】。
12
+ 【*】在运行前完成版本控制和'插件名.podspec'配置
13
+ 【*】如果暂时未加入版本控制,命令提供临时解决方案:
14
+ 1、启动Mac系统默认Apache `sudo apachectl restart`;
15
+ 2、归档源码`插件名.zip`到本机`/Library/WebServer/Documents/OrmPlugins`目录下;
16
+ 3、配置地址`http://localhost/插件名.zip`。
17
+ 在此期间需要获取系统权限,需要输入开机密码。
12
18
  DESC
13
19
 
14
20
  self.arguments = [
@@ -17,12 +23,14 @@ module OrmDev
17
23
 
18
24
  def self.options
19
25
  [
26
+ ['--without-version-control', '没有版本控制'],
20
27
  ].concat(super)
21
28
  end
22
29
 
23
30
  def initialize(argv)
24
31
  @podspec_file = argv.shift_argument
25
32
  @podspec_files = Pathname.pwd.children.select { |pn| pn.extname == '.podspec' }
33
+ @no_version_control = argv.flag?('without-version-control')
26
34
  super
27
35
  end
28
36
 
@@ -43,8 +51,8 @@ module OrmDev
43
51
  super
44
52
  OrmDev::LogUtil.info '[插件发布] '.green
45
53
  installer = OrmDev::RunHelper.new(@podspec_path)
46
- installer.setup()
47
- OrmDev::LogUtil.info "Success!!! Please run command:\n orm ipa \#{platform}"
54
+ framework_zip = installer.setup(@no_version_control)
55
+ OrmDev::LogUtil.info "Success!!! `ormdev publish #{@podspec_path} --zip=#{framework_zip} --push-type=0`"
48
56
  end
49
57
  end
50
58
  end
@@ -6,32 +6,48 @@ require_relative '../util/sh_util'
6
6
  module OrmDev
7
7
  class RunHelper
8
8
  attr_reader :spec
9
+ attr_reader :podspec_path
9
10
 
10
11
  def initialize(path)
12
+ @podspec_path = path;
11
13
  @spec = Pod::Specification.from_file(path)
12
14
  end
13
15
 
14
- def setup()
16
+ def setup(no_version_control)
15
17
  task_start_time = Time.now
16
18
  time_info_logs = ["开始运行:#{task_start_time}"]
17
19
  start_time = task_start_time
18
20
 
19
- # check_environment
20
- # current_time = Time.new
21
- # time_info_logs << "检查运行环境:#{current_time - start_time}秒"
22
- # start_time = current_time
23
- #
24
- # pod_package_framwork
25
- # current_time = Time.new
26
- # time_info_logs << "打包静态库:#{current_time - start_time}秒"
27
- # start_time = current_time
21
+ check_environment
22
+ current_time = Time.new
23
+ time_info_logs << "检查运行环境:#{current_time - start_time}秒"
24
+ start_time = current_time
25
+
26
+ if no_version_control then
27
+ archive_zip_source
28
+ current_time = Time.new
29
+ time_info_logs << "源码没有版本控制,归档到本机WebServer:#{current_time - start_time}秒"
30
+ start_time = current_time
31
+ end
28
32
 
29
- upload_zip_framwork
33
+ pod_package_framwork
30
34
  current_time = Time.new
31
- time_info_logs << "上传静态framework:#{current_time - start_time}秒"
35
+ time_info_logs << "打包静态库:#{current_time - start_time}秒"
36
+ start_time = current_time
37
+
38
+ result = archive_zip_framwork
39
+ current_time = Time.new
40
+ time_info_logs << "压缩静态framework:#{current_time - start_time}秒"
41
+ start_time = current_time
42
+
43
+ # lint_zip_framwork
44
+ # current_time = Time.new
45
+ # time_info_logs << "验证静态framework:#{current_time - start_time}秒"
46
+ # start_time = current_time
32
47
 
33
48
  time_info_logs << "#{@spec.name}总耗时:#{Time.new - task_start_time}秒"
34
49
  puts time_info_logs
50
+ result
35
51
  end
36
52
 
37
53
  private
@@ -40,9 +56,44 @@ module OrmDev
40
56
  OrmDev::SHUtil.run_command('bundle install','检测配置运行环境',false)
41
57
  end
42
58
 
59
+ # 归档源码
60
+ def archive_zip_source
61
+ OrmDev::LogUtil.print_command '启动系统Apache服务,请求获取root权限,请输入root密码:'
62
+ OrmDev::SHUtil.run_command('sudo apachectl restart','启动系统Apache服务', true)
63
+ source_path = "#{@spec.name}.zip"
64
+ FileUtils.rm_rf(source_path) if File::exist?(source_path)
65
+ Zip::File.open(source_path, Zip::File::CREATE) do |zipfile|
66
+ [
67
+ "#{@spec.name}.podspec",
68
+ 'LICENSE',
69
+ 'README.md',
70
+ 'Dependencies',
71
+ "#{@spec.name}/Assets",
72
+ "#{@spec.name}/Classes",
73
+ ].each do |filename|
74
+ add_file_to_zip(filename, zipfile)
75
+ end
76
+ end
77
+ OrmDev::LogUtil.print_success "归档压缩完成,#{source_path}"
78
+ zip_root_path = '/Library/WebServer/Documents/OrmPlugins'
79
+ unless Dir.exist?(zip_root_path) then
80
+ OrmDev::LogUtil.print_command '创建插件根目录,请输入root密码:'
81
+ OrmDev::SHUtil.run_command("sudo mkdir -p #{zip_root_path}",'创建插件根目录', true)
82
+ OrmDev::SHUtil.run_command("sudo chown #{ENV["USER"]} #{zip_root_path}",'初始化插件根目录权限', true)
83
+ end
84
+ destination_path = File.join(zip_root_path, "#{@spec.name}.zip")
85
+ FileUtils.rm_rf(destination_path) if File.exist?(destination_path)
86
+ FileUtils.cp_r(source_path, destination_path)
87
+ FileUtils.rm_rf(source_path)
88
+ zip_http_path = "http://localhost/OrmPlugins/#{@spec.name}.zip"
89
+ # 替换配置文件
90
+ version_text = File.read(@podspec_path).sub(/^( )*orm_sdk_source(.*)\n/, " orm_sdk_source = { :http => '#{zip_http_path}'}\n")
91
+ File.open(@podspec_path, "w") { |file| file.puts version_text }
92
+ end
93
+
43
94
  # 静态化
44
95
  def pod_package_framwork
45
- pod_package_command = "#{@spec.name}_SOURCE=1 pod package #{@spec.name}.podspec --exclude-deps --no-mangle --force --spec-sources=git@gitee.com:mvn/ios.git,https://github.com/CocoaPods/Specs.git"
96
+ pod_package_command = "pod package #{@spec.name}.podspec --exclude-deps --no-mangle --force --spec-sources=git@gitee.com:mvn/ios.git,https://github.com/CocoaPods/Specs.git --verbose"
46
97
  OrmDev::SHUtil.run_command(pod_package_command,'静态化插件')
47
98
  destination_path = "#{@spec.name}/lib"
48
99
  source_path = "#{@spec.name}-#{@spec.version}"
@@ -58,8 +109,18 @@ module OrmDev
58
109
  end
59
110
  end
60
111
 
112
+ # 验证静态库
113
+ # def lint_zip_framwork
114
+ # OrmDev::LogUtil.info '[插件管理] 验证Pod'.green
115
+ # ORM::SHUtil.run_command("pod cache clean #{@spec.name} --all",'清除Pod缓存',false)
116
+ # pod_lint_command = ''
117
+ # pod_lint_command << "#{@spec.name}_Lib=1"
118
+ # pod_lint_command << ' pod lib lint --sources=orm,master --allow-warnings --use-libraries --verbose'
119
+ # OrmDev::SHUtil.run_command(pod_lint_command,'更验证Pod',true)
120
+ # end
121
+
61
122
  # 压缩上传
62
- def upload_zip_framwork
123
+ def archive_zip_framwork
63
124
  zip_path = "#{@spec.name}.zip"
64
125
  FileUtils.rm_rf(zip_path) if File::exist?(zip_path)
65
126
  Zip::File.open(zip_path, Zip::File::CREATE) do |zipfile|
@@ -73,12 +134,12 @@ module OrmDev
73
134
  add_file_to_zip(filename, zipfile)
74
135
  end
75
136
  end
76
- zip_path
77
137
  OrmDev::LogUtil.print_success "运行成功,#{zip_path}"
138
+ zip_path
78
139
  end
79
140
 
80
141
  def add_file_to_zip(file_path, zip)
81
- p file_path
142
+ return unless File::exist?(file_path)
82
143
  if File.directory?(file_path)
83
144
  Dir.foreach(file_path) do |sub_file_name|
84
145
  add_file_to_zip("#{file_path}/#{sub_file_name}", zip) unless sub_file_name == '.' or sub_file_name == '..'
@@ -0,0 +1,74 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+
4
+ module OrmDev
5
+ class HTTPUtil
6
+
7
+ API_THIRD_PLUGIN_PUBLISH = 'http://192.168.2.110:8081/soops/sword/portal?SwordControllerName=uploadPlugin'.freeze #测试地址
8
+
9
+ def self.send_pulish_plugin_http(username, password, publish_type, podspec_path, zip_path, changelog = '')
10
+ @spec = Pod::Specification.from_file(podspec_path)
11
+ cim_sdk_version = ''
12
+ @spec.dependencies.each do |dep|
13
+ if 'CIMSDK'.eql? dep.name
14
+ cim_sdk_version = plugin_version_from(dep.requirement.requirements.flatten.last.to_s)
15
+ end
16
+ end
17
+
18
+ # start upload
19
+ conn_options = {
20
+ request: {
21
+ timeout: 1000,
22
+ open_timeout: 300
23
+ }
24
+ }
25
+ pgyer_client = Faraday.new(nil, conn_options) do |c|
26
+ c.request :multipart
27
+ c.request :url_encoded
28
+ c.response :json, content_type: /\bjson$/
29
+ c.adapter :net_http
30
+ end
31
+
32
+ params = {
33
+ 'username' => username || ENV['ORMDEV_CLT_USERNAME'],
34
+ 'password' => password || ENV['ORMDEV_CLT_PASSWORD'],
35
+ 'version' => OrmDev::VERSION,
36
+ 'platform' => 1,# 0:android,1:ios
37
+ 'type' => 1,# ios:0,1,2
38
+ 'cipBaseVersion' => cim_sdk_version, #base版本号
39
+ 'desc' => changelog,
40
+ }
41
+ unless podspec_path.nil? then
42
+ params[File.basename(podspec_path)] = Faraday::UploadIO.new(podspec_path, 'application/octet-stream') if File.exist?(podspec_path)
43
+ end
44
+ unless zip_path.nil? then
45
+ params[File.basename(zip_path)] = Faraday::UploadIO.new(zip_path, 'application/octet-stream') if File.exist?(zip_path)
46
+ end
47
+ OrmDev::LogUtil.info '【发布第三方插件】Start upload ...'
48
+
49
+ api = ENV['ORMDEV_CLT_API_THIRD_PLUGIN_PUBLISH'] || API_THIRD_PLUGIN_PUBLISH
50
+ response = pgyer_client.post api, params
51
+
52
+ info = response.body
53
+ OrmDev::LogUtil.info "【第三方插件发布】#{api}"
54
+ OrmDev::LogUtil.info "【第三方插件发布】Upload complate: #{info}"
55
+ if info && info['status'] && info['status'] == '0000' then
56
+ OrmDev::LogUtil.info '发布成功'
57
+ end
58
+ info
59
+ end
60
+
61
+ private
62
+
63
+ def self.plugin_version_from(pod_version)
64
+ if pod_version.nil? then
65
+ ''
66
+ else
67
+ arr = pod_version.split('.')
68
+ arr.delete_at(arr.size - 1)
69
+ arr.join('.')
70
+ end
71
+ end
72
+
73
+ end
74
+ end
@@ -1,3 +1,3 @@
1
1
  module OrmDev
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ormdev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - devorm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-30 00:00:00.000000000 Z
11
+ date: 2018-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claide
@@ -141,6 +141,7 @@ files:
141
141
  - lib/ormdev/command/setup.rb
142
142
  - lib/ormdev/source/core/create_helper.rb
143
143
  - lib/ormdev/source/core/run_helper.rb
144
+ - lib/ormdev/source/util/http_util.rb
144
145
  - lib/ormdev/source/util/log_util.rb
145
146
  - lib/ormdev/source/util/sh_util.rb
146
147
  - lib/ormdev/version.rb