gct 0.3.96 → 0.4.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: fc724b7284f83afb5c5b2d1bc1e4056179d5b88e45d39dd375942649f8ad760b
4
- data.tar.gz: be50780a0fc37a2bc3fcb5bcf2c403cb8addf005f67ebd2d03ef1d5a28883809
3
+ metadata.gz: 8eacd230eb51e7c03f69df817172a1684c61a016b476ee9bede1a4490751084c
4
+ data.tar.gz: 4f9525f907f827cbe90806a0fc11b42c64bc4cdefda2f6982da2e2ce6d117e1d
5
5
  SHA512:
6
- metadata.gz: 32c305352fa1248ca6587ca5e8e1ef7a2d7bd56bfcf30390e4b769a492f1ef17bffa13df9c3b0c4f3b87bca52ebfaba2b739ccc4b2962a2e4696842943e7479c
7
- data.tar.gz: 0011f8848cb83ace7603b49cbbc713b905213fbf4a9c837cf5ccfb41419d054423fb62ff7b7e97bad919f85fc2c2685e01cf9fa7c35e3dd346a7f92f3acb8134
6
+ metadata.gz: d93d45b1ffee87733b11bc2f70fc4c35fb510c99bece66196d87b49dadb98f7a9648bb2a407cc78e98223ffbeafb1523f120ff8fec7b4ca127e9eb461a6dad24
7
+ data.tar.gz: 606a302705d5305cb8d5260d489d551794ffedabea91b7da81bc7ea66cc31042d2dad835a6fd6edccc82369b45d7e4ba5de55a35fceb3b520d29468a73a36115
@@ -38,7 +38,19 @@ module Gct
38
38
 
39
39
  def run
40
40
  FileBase.root_err
41
- analyze_dependencies
41
+ puts "开始分析podfile文件".green
42
+ puts ""
43
+ exist_dep = FileBase.exist_dependency
44
+ if exist_dep
45
+ tmp_podspecs
46
+ priority_map = FileBase.yaml_dependency_read
47
+ create_tag_by_priority(priority_map)
48
+ else
49
+ untagged_specs = analyze_dependencies
50
+ priority_map = priority_rank(untagged_specs)
51
+ generate_dependency_file(priority_map)
52
+ create_tag_by_priority(priority_map)
53
+ end
42
54
  end
43
55
 
44
56
  def check_branch(branch)
@@ -48,10 +60,9 @@ module Gct
48
60
 
49
61
  def podfile
50
62
  # if check_branch_can_be_update('zeus')
51
- if check_branch('ft/tag') # TODO: Test branch
63
+ # if check_branch('ft/tag') # TODO: Test branch
52
64
  contents = file_contents(@project_id, @file, @branch)
53
65
  contents.force_encoding('UTF-8')
54
- puts contents
55
66
  temp_local_file = TempLocalFile.new(contents, @file)
56
67
  temp_local_file.write
57
68
  full_path = temp_local_file.full_path
@@ -60,25 +71,30 @@ module Gct
60
71
  podfile = Pod::Podfile.from_ruby(full_path, contents)
61
72
  podfile
62
73
  end
63
- end
74
+ # end
64
75
  end
65
76
 
66
- def analyze_dependencies
77
+ def tmp_podspecs
67
78
  untagged_git_dependencies = podfile.dependencies.select { |dependency| dependency.external? && dependency.external_source[:tag].nil? && dependency.external_source[:branch] == Constant.DefaultTagBranch}
68
79
 
69
- untagged_specs = Parallel.map(untagged_git_dependencies, in_threads: 1) do |dep|
80
+ spec_files = Parallel.map(untagged_git_dependencies, in_threads: 1) do |dep|
70
81
  file_name = "#{dep.name}.podspec"
71
82
  podspec_contents = file_contents("#{Constant.NameSpace}#{dep.name}", file_name, Constant.DefaultTagBranch)
72
83
  temp_local_spec_file = TempLocalFile.new(podspec_contents, file_name)
73
84
  temp_local_spec_file.write
74
- spec_file = temp_local_spec_file.full_path
85
+ temp_local_spec_file.full_path
86
+ end
87
+ spec_files
88
+ end
75
89
 
90
+ def analyze_dependencies
91
+ untagged_specs = tmp_podspecs.map do |spec_file|
76
92
  # 创建podspec对象
77
93
  spec = Pod::Specification.from_file(spec_file)
78
94
  gct_spec = Specification.new()
79
95
  gct_spec.name = spec.name
80
96
  gct_spec.priority = 1000
81
- gct_spec.status = SpecPublishStatus::CREATED
97
+ gct_spec.status = SpecPublishStatus::WAITING
82
98
  gct_spec.tag = "0"
83
99
  dependencySpecs = Array.new()
84
100
  if spec.subspecs.length == 0
@@ -86,7 +102,7 @@ module Gct
86
102
  sub_spec = Specification.new()
87
103
  sub_spec.name = dep.root_name
88
104
  sub_spec.priority = 1000
89
- sub_spec.status = SpecPublishStatus::CREATED
105
+ sub_spec.status = SpecPublishStatus::WAITING
90
106
  sub_spec.tag = "0"
91
107
  sub_spec
92
108
  end
@@ -97,7 +113,7 @@ module Gct
97
113
  sub_spec = Specification.new()
98
114
  sub_spec.name = dep.root_name
99
115
  sub_spec.priority = 1000
100
- sub_spec.status = SpecPublishStatus::CREATED
116
+ sub_spec.status = SpecPublishStatus::WAITING
101
117
  sub_spec.tag = "0"
102
118
  sub_spec
103
119
  end
@@ -108,8 +124,7 @@ module Gct
108
124
  gct_spec.dependencySpecs = dependencySpecs
109
125
  gct_spec
110
126
  end
111
-
112
- priority_rank(untagged_specs)
127
+ untagged_specs
113
128
  end
114
129
 
115
130
  def eqlBetweenHash(hash1, hash2)
@@ -133,12 +148,10 @@ module Gct
133
148
  temp_spec_map[spec.name] = spec
134
149
  end
135
150
  temp_spec_map_copy = Hash.new()
136
- count = 1
137
151
 
138
152
  while !(eqlBetweenHash(temp_spec_map, temp_spec_map_copy)) do
139
153
  # 深拷贝
140
154
  temp_spec_map_copy = Marshal.load(Marshal.dump(temp_spec_map))
141
- puts "--- times == #{count} ---"
142
155
  specs.map do |spec|
143
156
  temp_spec = temp_spec_map[spec.name]
144
157
  spec.dependencySpecs.map do |subspec|
@@ -150,11 +163,70 @@ module Gct
150
163
  end
151
164
  end
152
165
  end
153
- count += 1
154
- temp_spec_map.each { |key, value|
155
- puts "#{key} => #{value.priority}"
156
- }
157
166
  end
167
+ dependency_map = Hash.new()
168
+ priority_map = Hash.new()
169
+ temp_spec_map.each do |key, value|
170
+ dependency_map[key] = {"priority" => value.priority, "tag" => value.tag, "status" => value.status}
171
+ end
172
+ priority = 1000
173
+ while priority <= 1000 do
174
+ tmp_hash = Hash.new()
175
+ dependency_map.each do |key, value|
176
+ if (value["priority"] == priority)
177
+ tmp_hash.store(key, {"tag" => value["tag"], "status" => value["status"]})
178
+ dependency_map.delete(value)
179
+ end
180
+ end
181
+ if (tmp_hash.keys.count == 0)
182
+ priority = 1001
183
+ else
184
+ priority_map[priority.to_s] = tmp_hash
185
+ priority -= 1
186
+ end
187
+ end
188
+ priority_map
189
+ end
190
+
191
+ def generate_dependency_file(priority_map)
192
+ yaml_path = "#{Generator::GctFile.temp_folder_path}/#{Constant.DependencyName}"
193
+ FileBase.yaml_write_map(yaml_path, priority_map)
194
+ end
195
+
196
+ # 按优先级打tag, 触发第一个优先级,其他的上一优先级打完之后自动触发
197
+ def create_tag_by_priority(priority_map)
198
+ priority = get_current_need_tag_priority
199
+ value = priority_map[priority.to_s]
200
+ raise "没有需要打tag的库".red if value.keys.count == 0
201
+ value.each do |key, val|
202
+ if val["status"].eql?(SpecPublishStatus::WAITING) || val["status"].eql?(SpecPublishStatus::CANCELED) || val["status"].eql?(SpecPublishStatus::FAILED)
203
+ status = SpecPublishStatus::PENDING
204
+ val["status"] = status
205
+ system "gct update dependency #{key} status #{status}"
206
+ system "gct update tag #{key} --auto-tag"
207
+ end
208
+ end
209
+ end
210
+
211
+ # 当前优先级是否已打完
212
+ def get_current_need_tag_priority
213
+ priority = 1000
214
+ content_map = FileBase.yaml_dependency_read
215
+ priority_map = content_map[priority.to_s]
216
+ is_all_done = true
217
+ while is_all_done do
218
+ priority_map.each do |k, v|
219
+ if !v["status"].eql?(SpecPublishStatus::SUCCESS)
220
+ is_all_done = false
221
+ break
222
+ end
223
+ end
224
+ if is_all_done
225
+ priority -= 1
226
+ priority_map = content_map[priority.to_s]
227
+ end
228
+ end
229
+ priority
158
230
  end
159
231
  end
160
232
  end
@@ -5,12 +5,15 @@ stages:
5
5
  push_pod:
6
6
  stage: push
7
7
  script:
8
- - gct robot start
8
+ - gct robot start --test
9
9
  - echo "开始lint 和 push podspec"
10
+ - gct update dependency $CI_PROJECT_NAME "status" "发布中"
10
11
  - gct clean lint $CI_PROJECT_NAME
11
12
  - gct repo update
12
13
  - gct repo push
13
- - gct robot finish true
14
+ - gct robot finish true --test
15
+ - gct update dependency $CI_PROJECT_NAME "tag" $CI_COMMIT_REF_NAME
16
+ - gct update next
14
17
  only:
15
18
  - tags
16
19
  tags:
@@ -19,7 +22,8 @@ push_pod:
19
22
  on_failure:
20
23
  stage: failure
21
24
  script:
22
- - gct robot finish false
25
+ - gct robot finish false --test
26
+ - gct update dependency $CI_PROJECT_NAME "status" "发布失败"
23
27
  when: on_failure
24
28
  only:
25
29
  - tags
@@ -1,5 +1,7 @@
1
1
  require 'gct/command/robot/start'
2
2
  require 'gct/command/robot/finish'
3
+ require 'net/https'
4
+ require 'json'
3
5
 
4
6
  module Gct
5
7
  class Command
@@ -9,6 +11,43 @@ module Gct
9
11
  self.description = <<-DESC
10
12
  发送jenkins和gitlab机器人消息
11
13
  DESC
14
+
15
+ def self.options
16
+ [
17
+ ['--test', '测试机器人,测试webhook'],
18
+ ].concat(super)
19
+ end
20
+
21
+ def initialize(argv)
22
+ @test = argv.flag?('test', false)
23
+ super
24
+ end
25
+
26
+ def robot_send(content)
27
+ if @test
28
+ webhook = FileBase.get_config("gitlab-robot-webhook-test")
29
+ else
30
+ webhook = FileBase.get_config("gitlab-robot-webhook")
31
+ end
32
+ raise "请先设置webhook --> gct config set gitlab-robot-webhook WEBHOOK_URL" if webhook.nil? || webhook.empty?
33
+ url = URI(webhook)
34
+
35
+ http = Net::HTTP.new(url.host, url.port)
36
+ if url.scheme == "https"
37
+ http.use_ssl = true
38
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
39
+ end
40
+
41
+ data = {
42
+ "msgtype": "markdown",
43
+ "markdown": {
44
+ "content": "#{content}"
45
+ }
46
+ }.to_json
47
+
48
+ header = {'content-type':'application/json'}
49
+ response = http.post(url, data, header)
50
+ end
12
51
  end
13
52
  end
14
53
  end
@@ -1,5 +1,4 @@
1
- require 'net/https'
2
- require 'json'
1
+
3
2
 
4
3
  module Gct
5
4
  class Command
@@ -35,36 +34,15 @@ module Gct
35
34
  def run
36
35
  puts @build_status.class
37
36
  puts "build_status == #{@build_status}"
38
- if @build_status.eql?('false')
37
+ if @build_status.eql?("false")
39
38
  build_text = "<font color=\"comment\">CI运行失败</font>,请相关人员注意"
40
- elsif @build_status.eql?('true')
39
+ elsif @build_status.eql?("true")
41
40
  build_text = "<font color=\"info\">CI运行成功</font>"
42
41
  end
43
- ci_text = "[点击跳转](#{@ci_url})"
44
-
45
- if @test
46
- webhook = FileBase.get_config("gitlab-robot-webhook-test")
47
- elsif
48
- webhook = FileBase.get_config("gitlab-robot-webhook")
49
- end
50
- raise "请先设置webhook --> gct config set gitlab-robot-webhook WEBHOOK_URL" if webhook.nil? || webhook.empty?
51
- url = URI(webhook)
52
-
53
- http = Net::HTTP.new(url.host, url.port)
54
- if url.scheme == "https"
55
- http.use_ssl = true
56
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
57
- end
58
-
59
- data = {
60
- "msgtype": "markdown",
61
- "markdown": {
62
- "content": "**#{@project_name} #{build_text}**\n\n\n>触发人:#{@user_name}\n\n>tag:#{@tag}\n\n>commitid:#{@commit_sha}\n\n>流水线地址:#{ci_text}"
63
- }
64
- }.to_json
65
-
66
- header = {'content-type':'application/json'}
67
- response = http.post(url, data, header)
42
+ ci_text = "[点击跳转](#{@ci_url})"
43
+
44
+ content = "**#{@project_name} #{build_text}**\n\n\n>触发人:#{@user_name}\n\n>tag:#{@tag}\n\n>commitid:#{@commit_sha}\n\n>流水线地址:#{ci_text}"
45
+ robot_send(content)
68
46
  end
69
47
  end
70
48
  end
@@ -28,30 +28,9 @@ module Gct
28
28
  end
29
29
 
30
30
  def run
31
- if @test
32
- webhook = FileBase.get_config("gitlab-robot-webhook-test")
33
- elsif
34
- webhook = FileBase.get_config("gitlab-robot-webhook")
35
- end
36
- raise "请先设置webhook --> gct config set gitlab-robot-webhook WEBHOOK_URL" if webhook.nil? || webhook.empty?
37
- url = URI(webhook)
38
-
39
- http = Net::HTTP.new(url.host, url.port)
40
- if url.scheme == "https"
41
- http.use_ssl = true
42
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
43
- end
44
-
45
31
  message = " <font color=\"info\">#{@tag}</font> 开始打tag"
46
- data = {
47
- "msgtype": "markdown",
48
- "markdown": {
49
- "content": "**#{@project_name}** #{message}"
50
- }
51
- }.to_json
52
-
53
- header = {'content-type':'application/json'}
54
- response = http.post(url, data, header)
32
+ content = "**#{@project_name}** #{message}"
33
+ robot_send(content)
55
34
  end
56
35
  end
57
36
  end
@@ -15,9 +15,18 @@ module Gct
15
15
  create_root_folder
16
16
  create_temp_folder
17
17
  create_config_file
18
+ create_backup_folder
18
19
  puts "setup success!".green
19
20
  end
20
21
 
22
+ def create_backup_folder
23
+ backup_path = Generator::GctFile.backup_folder_path
24
+ if !File.exist?(backup_path)
25
+ system "mkdir #{backup_path}", exception: true
26
+ puts "#{backup_path} 创建成功!".green
27
+ end
28
+ end
29
+
21
30
  def create_root_folder
22
31
  gct_path = Generator::GctFile.root_folder_path
23
32
  if !File.exist?(gct_path)
@@ -0,0 +1,13 @@
1
+ require 'gct/command/tag/next'
2
+
3
+ module Gct
4
+ class Command
5
+ class Tag < Command
6
+ self.abstract_command = true
7
+ self.summary = 'tag 相关操作'
8
+ self.description = <<-DESC
9
+ tag 相关操作
10
+ DESC
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,8 @@
1
- require 'gct/command/update/tag'
1
+ require 'gct/command/update/dependency'
2
+ require 'gct/command/update/podfile'
2
3
  require 'gct/command/update/version'
4
+ require 'gct/command/update/next'
5
+ require 'gct/command/update/tag'
3
6
 
4
7
  module Gct
5
8
  class Command
@@ -0,0 +1,22 @@
1
+ module Gct
2
+ class Command
3
+ class Update < Command
4
+ class Analyze < Update
5
+ self.summary = '编译'
6
+ self.description = <<-DESC
7
+ 下一个优先级打tag
8
+ DESC
9
+
10
+ def initialize(argv)
11
+
12
+ super
13
+ end
14
+
15
+ def run
16
+
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,36 @@
1
+ module Gct
2
+ class Command
3
+ class Update < Command
4
+ class Dependency < Update
5
+
6
+ self.summary = '更新依赖文件'
7
+ self.description = <<-DESC
8
+ 更新依赖文件
9
+ DESC
10
+
11
+ self.arguments = [
12
+ # CLAide::Argument.new('PRIORITY', false),
13
+ CLAide::Argument.new('POD_NAME', false),
14
+ CLAide::Argument.new('KEY', false),
15
+ CLAide::Argument.new('VALUE', false),
16
+ ]
17
+
18
+ def initialize(argv)
19
+ # @priority = argv.shift_argument
20
+ @pod_name = argv.shift_argument
21
+ @key = argv.shift_argument
22
+ @value = argv.shift_argument
23
+ super
24
+ end
25
+
26
+ def validate!
27
+ super
28
+ end
29
+
30
+ def run
31
+ FileBase.yaml_dependency_update(@pod_name, @key, @value)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,72 @@
1
+ module Gct
2
+ class Command
3
+ class Update < Command
4
+ class Next < Update
5
+ self.summary = '编译'
6
+ self.description = <<-DESC
7
+ 下一个优先级打tag
8
+ DESC
9
+
10
+ def initialize(argv)
11
+ @project_name = ENV['CI_PROJECT_NAME']
12
+ super
13
+ end
14
+
15
+ def run
16
+ batch_tag
17
+ end
18
+
19
+ def batch_tag
20
+ value = next_specs
21
+ if val.nil?
22
+ return
23
+ end
24
+ if value.keys.count == 0
25
+ puts "tag已全部打完!!!".green
26
+ # 执行更新podfile的操作
27
+ # system "gct update podfile"
28
+ else
29
+ value.each do |key, val|
30
+ if val["status"].eql?(SpecPublishStatus::WAITING) || val["status"].eql?(SpecPublishStatus::CANCELED) || val["status"].eql?(SpecPublishStatus::FAILED)
31
+ status = SpecPublishStatus::PENDING
32
+ val["status"] = status
33
+ system "gct update dependency #{key} status #{status}"
34
+ system "gct update tag #{key} --auto-tag --update-ci"
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ def next_specs
41
+ priority = get_current_project_priority
42
+ content_map = FileBase.yaml_dependency_read
43
+ priority_map = content_map[priority.to_s]
44
+ is_all_done = true
45
+ priority_map.each do |k, v|
46
+ if !v["status"].eql?("发布成功")
47
+ is_all_done = false
48
+ break
49
+ end
50
+ end
51
+ if is_all_done
52
+ content_map[(priority - 1).to_s]
53
+ else
54
+ nil
55
+ end
56
+ end
57
+
58
+ def get_current_project_priority
59
+ content_map = FileBase.yaml_dependency_read
60
+ priority = 1000
61
+ content_map.each do |k, v|
62
+ if v.keys.include?(@project_name)
63
+ priority = k
64
+ break
65
+ end
66
+ end
67
+ priority
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,41 @@
1
+ module Gct
2
+ class Command
3
+ class Update < Command
4
+ class Podfile < Update
5
+
6
+ self.summary = '更新podfile文件'
7
+ self.description = <<-DESC
8
+ 更新podfile文件
9
+ DESC
10
+
11
+ self.arguments = [
12
+ CLAide::Argument.new('VERSION', true),
13
+ ]
14
+
15
+ def initialize(argv)
16
+ @version = argv.shift_argument
17
+ super
18
+ end
19
+
20
+ def validate!
21
+ super
22
+ end
23
+
24
+ def run
25
+
26
+ end
27
+
28
+ # 删除和备份
29
+ def remove_and_backup
30
+ d_name = Constant.DependencyName
31
+ Dir.chdir(FileBase.tmp_path) do
32
+ # 备份dependency文件到backup文件夹下
33
+ system "cp #{d_name} ../backup/#{d_name}-#{@version}"
34
+ # 删除tmp文件夹下所有文件
35
+ system "rm -rf *"
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -17,6 +17,7 @@ module Gct
17
17
  [
18
18
  ['--skip-tag', '是否忽略tag,直接触发ci'],
19
19
  ['--update-ci', '是否更新CI'],
20
+ ['--auto-tag', '自动化'],
20
21
  ].concat(super)
21
22
  end
22
23
 
@@ -24,10 +25,13 @@ module Gct
24
25
  @update_version_branch = 'develop'
25
26
  @skip_tag = argv.flag?('skip-tag', false)
26
27
  @update_ci = argv.flag?('update-ci', false)
27
- @file = get_spec_file
28
- name = argv.shift_argument
29
- @name = name.nil? ? @spec.name : name
28
+ @auto_tag = argv.flag?('auto-tag', false)
29
+ @name = argv.shift_argument
30
30
  @tag = argv.shift_argument
31
+ @file = get_spec_file
32
+ if @name.nil?
33
+ @name = @spec.name
34
+ end
31
35
  @project_id = "#{Constant.NameSpace}#{@name}"
32
36
  super
33
37
  end
@@ -70,11 +74,19 @@ module Gct
70
74
  end
71
75
 
72
76
  def get_spec_file
77
+ spec_file = nil
78
+ if @auto_tag
79
+ raise "podspec名不能为空!!!".red if spec_file.nil? if @name.nil?
80
+ Dir.chdir(FileBase.tmp_path) do
81
+ spec_file = Pathname.glob("#{@name}.podspec").first
82
+ raise "在 #{Dir.pwd} 目录下找不到podspec文件".red if spec_file.nil?
83
+ end
84
+ else
73
85
  spec_file = Pathname.glob('*.podspec').first
74
86
  raise "在 #{Dir.pwd} 目录下找不到podspec文件".red if spec_file.nil?
75
-
76
- @spec = Pod::Specification.from_file(spec_file)
77
- spec_file
87
+ end
88
+ @spec = Pod::Specification.from_file(spec_file)
89
+ spec_file
78
90
  end
79
91
 
80
92
  def update_podspec_version
@@ -24,6 +24,10 @@ module Gct
24
24
  def DefaultTagBranch
25
25
  "develop"
26
26
  end
27
+
28
+ def DependencyName
29
+ "dependency"
30
+ end
27
31
  end
28
32
  end
29
33
  end
@@ -7,6 +7,37 @@ module Gct
7
7
  @path = path
8
8
  end
9
9
 
10
+ def yaml_dependency_read
11
+ path = dependency_path
12
+ config_map = YAML.load(File.open(path, "r"))
13
+ config_map
14
+ end
15
+
16
+ def yaml_dependency_update(pod_name, key, value)
17
+ begin
18
+ path = dependency_path
19
+ config_map = YAML.load(File.open(path, "r"))
20
+ puts config_map
21
+ config_map = Hash.new() if !config_map
22
+ config_map.each do |k, v|
23
+ v.each do |sk, sv|
24
+ if sk.eql?(pod_name)
25
+ sv[key] = value
26
+ if key.eql?("tag")
27
+ sv["status"] = SpecPublishStatus::SUCCESS
28
+ end
29
+ end
30
+ end
31
+ end
32
+ yaml_file = File.open(path, "w")
33
+ YAML::dump(config_map, yaml_file)
34
+ rescue IOError => e
35
+ raise e.message
36
+ ensure
37
+ yaml_file.close unless yaml_file.nil?
38
+ end
39
+ end
40
+
10
41
  def yaml_write(key, value)
11
42
  begin
12
43
  config_map = YAML.load(File.open(@path, "r"))
@@ -21,6 +52,28 @@ module Gct
21
52
  end
22
53
  end
23
54
 
55
+ def yaml_write_map(path, content)
56
+ begin
57
+ yaml_file = File.open(path, "w")
58
+ YAML::dump(content, yaml_file)
59
+ rescue IOError => e
60
+ raise e.message
61
+ ensure
62
+ yaml_file.close unless yaml_file.nil?
63
+ end
64
+ end
65
+
66
+ def yaml_read_map(path, key)
67
+ begin
68
+ yaml_file = YAML.load(File.open(path, "r"))
69
+ if yaml_file
70
+ yaml_file[key]
71
+ end
72
+ rescue IOError => e
73
+ raise e.message
74
+ end
75
+ end
76
+
24
77
  def yaml_read(key)
25
78
  begin
26
79
  yaml_file = YAML.load(File.open(@path, "r"))
@@ -48,11 +101,24 @@ module Gct
48
101
  "#{Generator::GctFile.config_file_path}"
49
102
  end
50
103
 
104
+ def dependency_path
105
+ "#{Generator::GctFile.temp_folder_path}/#{Constant.DependencyName}"
106
+ end
107
+
108
+ def tmp_path
109
+ "#{Generator::GctFile.temp_folder_path}"
110
+ end
111
+
51
112
  def exist_root
52
113
  root_exist = File.exist?(Generator::GctFile.root_folder_path)
53
114
  root_exist
54
115
  end
55
116
 
117
+ def exist_dependency
118
+ root_exist = File.exist?(dependency_path)
119
+ root_exist
120
+ end
121
+
56
122
  def root_err
57
123
  raise "请先运行命令:gct setup".red if !exist_root
58
124
  end
@@ -2,5 +2,5 @@ module Gct
2
2
  # freeze 冻结对象,将对象变成一个常量
3
3
  # unless 右边的代码块成立,才会运行左边的代码块
4
4
  # defined? 是用来判断本地变量是否存在,也可用来判断是否存在方法
5
- VERSION = "0.3.96".freeze unless defined? Gct::VERSION
5
+ VERSION = "0.4.0".freeze unless defined? Gct::VERSION
6
6
  end
@@ -13,6 +13,10 @@ module Gct
13
13
  "#{get_system_home_path.rstrip}/.gct/config"
14
14
  end
15
15
 
16
+ def self.backup_folder_path
17
+ "#{get_system_home_path.rstrip}/.gct/backup"
18
+ end
19
+
16
20
  # 获取系统用户名
17
21
  def self.get_system_user_name
18
22
  # windows
@@ -30,10 +30,7 @@ module Gct
30
30
  end
31
31
 
32
32
  module SpecPublishStatus
33
- CREATED = '待分析'
34
- ANALYZING = '分析中'
35
- PREPARING = '准备中'
36
- PENDING = '等待中'
33
+ PENDING = '队列中'
37
34
  WAITING = '待发布'
38
35
  SKIPPED = '已忽略'
39
36
  MERGED = '已合并'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.96
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jieming
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-30 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -180,7 +180,12 @@ files:
180
180
  - lib/gct/command/setup.rb
181
181
  - lib/gct/command/spec.rb
182
182
  - lib/gct/command/spec/lint.rb
183
+ - lib/gct/command/tag.rb
183
184
  - lib/gct/command/update.rb
185
+ - lib/gct/command/update/analyze.rb
186
+ - lib/gct/command/update/dependency.rb
187
+ - lib/gct/command/update/next.rb
188
+ - lib/gct/command/update/podfile.rb
184
189
  - lib/gct/command/update/tag.rb
185
190
  - lib/gct/command/update/version.rb
186
191
  - lib/gct/constant.rb