ocean_package 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df5f1fd000b7d02b3625d23d9c84b75bde227f1675739c743cd8c1147905ce4f
4
- data.tar.gz: e59dfeff667bb1d68c95f3cd2c03da8f9d5a10a2b3894b763c8c41763460d820
3
+ metadata.gz: 9b372a1a30d54bb10b757aecbf207cea5f235f7144e0a7e020f8b24f73ba48fc
4
+ data.tar.gz: b95ed7d2ba0abeb4aa9f6c02f2e39e60270526e631ee24a536f2ce6f4520bd0f
5
5
  SHA512:
6
- metadata.gz: 2e3db7f612b4b0639f58caa093769306c43a3b99874d735948dd192b98578f64816c6768d620cc2f6d08ff9af24c6b9e7fe7e124b3ccbc3c8c2cea1b4eeb8675
7
- data.tar.gz: 727f0b9332fff05106eff0d660646408b74f2ceea3d905f93344921897e50e42ce3a5f239229c1a9bac1e8e084db3c5740d2695257ec4e36397d340e0366e592
6
+ metadata.gz: 6dfc40afd770778ea67c6424e63b549a43240b843b4d738c186cff7730852f64af6baa7e5fdb726e7add2993f4e86ec058e1d9e39747155007c38fc418441cdd
7
+ data.tar.gz: dddfa48f512062b1f6ed3e331a9f9da28fad466bb4d7af4a687a84199f69eb471ec60e9dbea45293a1b3ac262da3a245d17280c1b04e9dd3a9909086d5810dc3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ocean_package (0.10.0)
4
+ ocean_package (0.11.0)
5
5
  CFPropertyList
6
6
  dingbot
7
7
  faraday
data/README.md CHANGED
@@ -39,8 +39,11 @@ sudo gem install multipart-post
39
39
 
40
40
  ## Usage
41
41
 
42
+ > 打包 - 上传到 fir 或 蒲公英平台 - 发送消息到钉钉群
43
+
44
+
42
45
  ```
43
- oceanpackage --workspace-path=/Users/ocean/Desktop/code/iOS/MyApp.xcworkspace --scheme=MyApp --configuration=Debug --archive-path=/Users/ocean/Documents/myipas --export-options-plist=/Users/ocean/Desktop/code/iOS/Company/MyApp/AdHocExportOptions.plist --company-name=MyCompany --fir-token=fir平台的token --pgy-api-key=蒲公英平台的apikey --change-log=测试一下 --oss-bucket-name=bucket名称 --oss-bucket-path=bucket路径 --oss-endpoint=oss的endpoint --ding-token=钉钉群机器人token --at-mobiles=需要@的人手机号
46
+ oceanpackage --workspace-path=/Users/ocean/Desktop/code/iOS/MyApp.xcworkspace --scheme=MyApp --configuration=Debug --archive-path=/Users/ocean/Documents/myipas --export-options-plist=/Users/ocean/Desktop/code/iOS/Company/MyApp/AdHocExportOptions.plist --company-name=MyCompany --fir-token=fir平台的token --pgy-api-key=蒲公英平台的apikey --change-log=测试一下 --oss-bucket-name=bucket名称 --oss-bucket-path=bucket路径 --oss-endpoint=oss的endpoint --ding-token=钉钉群机器人token --at-mobiles=需要@的人手机号 --extra-export-params="-allowProvisioningUpdates,IPHONEOS_DEPLOYMENT_TARGET=11.0"
44
47
  ```
45
48
 
46
49
  - `--workspace-path`: `.xcworkspace` 文件路径
@@ -57,7 +60,25 @@ oceanpackage --workspace-path=/Users/ocean/Desktop/code/iOS/MyApp.xcworkspace --
57
60
  - `--oss-endpoint`: `oss` 的 `endpoint`
58
61
  - `--ding-token`: 钉钉群机器人的`token`
59
62
  - `--at-mobiles`: 钉钉群需要 @ 的人手机号,多个用 `,` 拼接
63
+ - `--extra-export-params`: 打包的额外参数,多个用 `,` 拼接,例如 `"-allowProvisioningUpdates,IPHONEOS_DEPLOYMENT_TARGET=11.0"`
64
+ - `--open-finder`: 打包完成是否打开对应的文件目录,`--no-open-finder`表示`false`, `--open-finder` 表示 `true`
65
+
60
66
 
67
+ > 指定 ipa 文件
68
+
69
+ - 上传到蒲公英平台命令格式如下:
70
+
71
+ ```
72
+ oceanpackage --configuration=Debug --ipa-file-path=/Users/ocean/Documents/myipas/test.ipa --company-name=company2 --pgy-api-key=蒲公英平台apikey --change-log=测试一下 --oss-bucket-name=bucket名称 --oss-bucket-path=bucket路径 --oss-endpoint=oss的endpoint --ding-token=钉钉群机器人token --at-mobiles=需要@的人手机号
73
+ ```
74
+
75
+ > 只用到上传ipa
76
+
77
+ ```
78
+ oceanpackage --ipa-file-path=${ipa_file_path} \
79
+ --pgy-api-key=${pgy_api_key} \
80
+ --change-log="${update_desc}" \
81
+ ```
61
82
 
62
83
  ## Development
63
84
 
data/lib/ocean_package.rb CHANGED
@@ -5,6 +5,7 @@ require 'semantic_logger'
5
5
  require 'multipart_post'
6
6
  require 'net/http/post/multipart'
7
7
  require 'json'
8
+ require 'find'
8
9
 
9
10
  # 注意:这里使用 require_relative 来引用文件
10
11
  require_relative 'ocean_package/version'
@@ -58,10 +58,13 @@ module OceanPackage
58
58
  extra_export_params = argv.option("extra-export-params", "")
59
59
  Log.info("extra-export-params: #{extra_export_params}")
60
60
 
61
+ open_finder = argv.flag?("open-finder", false )
62
+ Log.info("open-finder: #{open_finder}")
63
+
61
64
  # 自定义ipa文件,使用该文件作为 archive path
62
65
  tmp_archive_path = has_custom_ipa_file ? File.dirname("#{ipa_file_path}") : archive_path
63
66
  Log.info("tmp_archive_path: #{tmp_archive_path}")
64
- @package = OceanPackage::Package.new(workspace_path, scheme, configuration, tmp_archive_path, company_name, export_options_plist, extra_export_params)
67
+ @package = OceanPackage::Package.new(workspace_path, scheme, configuration, tmp_archive_path, company_name, export_options_plist, extra_export_params, open_finder)
65
68
 
66
69
  fir_token = argv.option("fir-token", "")
67
70
  Log.info("fir_token: #{fir_token}")
@@ -8,7 +8,6 @@ module OceanPackage
8
8
  DEFAULT_CONFIGURATION = "Debug"
9
9
  DEFAULT_COMPANY_NAME = "YourCompanyName"
10
10
  DEFAULT_ARCHIVE_PATH = "#{Dir.home}/Documents/Ipas/"
11
-
12
11
  end
13
12
 
14
13
  end
@@ -27,7 +27,12 @@ module OceanPackage
27
27
  # 结束时间
28
28
  attr_accessor :end_time
29
29
 
30
- def initialize(workspace_path, scheme, configuration, archive_path, company_name, export_options_plist, extra_export_params)
30
+ # ipa 最大保存的数目
31
+ attr_accessor :ipa_max_retain_number
32
+ # 打包完成是否打开文件夹
33
+ attr_accessor :open_finder
34
+
35
+ def initialize(workspace_path, scheme, configuration, archive_path, company_name, export_options_plist, extra_export_params, open_finder)
31
36
  @workspace_path = workspace_path
32
37
  @scheme = scheme
33
38
  @configuration = configuration
@@ -37,6 +42,8 @@ module OceanPackage
37
42
  @export_options_plist = export_options_plist
38
43
  @extra_export_params = extra_export_params
39
44
 
45
+ @ipa_max_retain_number = 3
46
+ @open_finder = open_finder
40
47
  # 预设置开始时间
41
48
  @start_time = Time.now
42
49
  end
@@ -61,6 +68,8 @@ module OceanPackage
61
68
  @start_time = Time.now
62
69
  # 检查必须参数
63
70
  check
71
+ # 清理历史的ipa
72
+ clean_history_ipa
64
73
  # clean 项目
65
74
  clean
66
75
  # 打包项目
@@ -70,7 +79,9 @@ module OceanPackage
70
79
  @end_time = Time.now
71
80
  # 返回打包成功的 ipa 文件路径
72
81
  ipa_file_path
73
- open_ipa_file_path
82
+ if @open_finder
83
+ open_ipa_file_path
84
+ end
74
85
  end
75
86
 
76
87
  # 一些校验
@@ -109,6 +120,51 @@ module OceanPackage
109
120
 
110
121
  end
111
122
 
123
+ # **************************************
124
+ # clean history
125
+ # **************************************
126
+
127
+ def clean_history_ipa
128
+ path = final_archive_path_company_pro
129
+
130
+ sub_paths = Array.new
131
+ Dir.each_child(path) do |x|
132
+ unless "#{x}".eql?(".DS_Store")
133
+ sub_paths.push("#{x}")
134
+ end
135
+ end
136
+
137
+ if sub_paths.length > @ipa_max_retain_number
138
+ Log.divider
139
+ Log.info("clean history ipas: begin =======")
140
+
141
+ count = sub_paths.length - @ipa_max_retain_number
142
+ deleted_paths = sub_paths.first(count)
143
+
144
+ deleted_paths.each do |p|
145
+ new_path = path + p
146
+ Log.info(new_path)
147
+ delete_directory(new_path)
148
+ end
149
+
150
+ Log.info("clean history ipas: end =======")
151
+ Log.divider
152
+ end
153
+ end
154
+
155
+ def delete_directory(dirPath)
156
+ if File.directory?(dirPath)
157
+ Dir.foreach(dirPath) do |subFile|
158
+ if subFile != '.' and subFile != '..'
159
+ delete_directory(File.join(dirPath, subFile));
160
+ end
161
+ end
162
+ Dir.rmdir(dirPath)
163
+ else
164
+ File.delete(dirPath)
165
+ end
166
+ end
167
+
112
168
  # **************************************
113
169
  # clean
114
170
  # **************************************
@@ -152,8 +208,8 @@ module OceanPackage
152
208
  end
153
209
  end
154
210
 
155
- # 最终的打包路径
156
- def final_archive_path
211
+ # 最终的打包路径,包含了公司,项目名称
212
+ def final_archive_path_company_pro
157
213
  path = processed_archive_path
158
214
  unless "#{@company_name}".empty?
159
215
  path += @company_name + '/'
@@ -161,6 +217,13 @@ module OceanPackage
161
217
  unless "#{project_name}".empty?
162
218
  path += project_name + '/'
163
219
  end
220
+
221
+ path
222
+ end
223
+
224
+ # 最终的打包路径
225
+ def final_archive_path
226
+ path = final_archive_path_company_pro
164
227
  path += @date_time + '/'
165
228
 
166
229
  Log.info("final archive path: #{path}")
@@ -1,3 +1,3 @@
1
1
  module OceanPackage
2
- VERSION = "0.11.0"
2
+ VERSION = "0.12.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean_package
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ocean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-26 00:00:00.000000000 Z
11
+ date: 2021-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dingbot