gct 0.3.4 → 0.3.5

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: c2208b729536833b256e4a434a5c381771f3cc240126f099e48d52fd8ca53028
4
- data.tar.gz: 3d0b9850f3612accee8d2d82b4fa27de812df4f57a285d9628109ca79cd27267
3
+ metadata.gz: c4c7ac5d299bdcd12bcf268d4f7d703d3cc928ec1bdf68a6a7607eb88776bfa1
4
+ data.tar.gz: ec3a3e19a4934758f25b7782b18033a6b5ae7b4011fe7f72a9a0600c6e31ca52
5
5
  SHA512:
6
- metadata.gz: e72dadc08c468c15410133874ab90cdf2728f519b423204ccd8550f7a046e7caa9831d97fcc6e2aa2db2cc3b1430936bc435edccc5afbf6f4993af261749321e
7
- data.tar.gz: ec2ddf310939d2a1b3cac6915243355933a84a0be21fb871005f18757111353fc5bb6c974aecd22ff879e83b101c663467e6c60df60ea154e0fe7a21f0d0139c
6
+ metadata.gz: 8ee1ec1276911016661047a4e3b85a78e51fbc8fee6d08531075bd26c43d598e4cf066a33712e9af51e9c6a317b5621e76d964a4c931a131f4952295696b4a2d
7
+ data.tar.gz: 3a10b473568f55e49de457f50f367010db7742eaf2ecde4684703a66835cbc7a7d10b1dcf8f33c41721a286c660b0aa9c682018e8db0585d4043f5b43f57ff3e
@@ -50,8 +50,6 @@ module Gct
50
50
  Colored2.disable!
51
51
  String.send(:define_method, :colorize) { |string, _| string }
52
52
  end
53
-
54
- config_gitlab
55
53
  end
56
54
 
57
55
  def file_contents(project_id, file, branch)
@@ -61,11 +59,17 @@ module Gct
61
59
  end
62
60
 
63
61
  def config_gitlab
64
- token = Config.get_config("token")
65
- raise "请先配置token!gct config set token GITLAB_PERSON_TOKEN".red if token.nil?
66
- Gitlab.configure do |config|
67
- config.endpoint = 'https://gi-dev.ccrgt.com/api/v4'
68
- config.private_token = token
62
+ if FileBase.exist_root
63
+ token = FileBase.get_config("token")
64
+ if token
65
+ raise "请先配置token!gct config set token GITLAB_PERSON_TOKEN".red if token.nil?
66
+ Gitlab.configure do |config|
67
+ config.endpoint = 'https://gi-dev.ccrgt.com/api/v4'
68
+ config.private_token = token
69
+ end
70
+ else
71
+ raise "请先运行命令:gct set token xxx,参考文档:http://febase.crgt.xyz/docs/app_ios/base".red
72
+ end
69
73
  end
70
74
  end
71
75
 
@@ -20,6 +20,7 @@ module Gct
20
20
  @project_id = argv.shift_argument
21
21
  @file = argv.shift_argument
22
22
  @branch = argv.shift_argument
23
+ config_gitlab
23
24
  super
24
25
  end
25
26
 
@@ -4,39 +4,12 @@ require 'gct/command/config/get'
4
4
  module Gct
5
5
  class Command
6
6
  class Config < Command
7
+ self.abstract_command = true
7
8
  self.summary = 'gct 配置'
8
9
  self.description = <<-DESC
9
10
  配置全局链接等
10
11
  DESC
11
-
12
- def initialize(argv)
13
- @list = argv.flag?('list', false)
14
- super
15
- end
16
-
17
- def run
18
- # get_all_config if @list
19
- end
20
-
21
- def self.options
22
- [
23
- ['--list', '打印config所有信息'],
24
- ].concat(super)
25
- end
26
-
27
- def self.get_config(key)
28
- file_base = FileBase.new(config_path)
29
- file_base.yaml_read(key)
30
- end
31
-
32
- def self.set_config(key, value)
33
- file_base = FileBase.new(config_path)
34
- file_base.yaml_write(key, value)
35
- end
36
-
37
- def self.config_path
38
- "#{Generator::GctFile.config_file_path}"
39
- end
12
+
40
13
  end
41
14
  end
42
15
  end
@@ -23,7 +23,7 @@ module Gct
23
23
  end
24
24
 
25
25
  def run
26
- puts "#{@key}: #{get_config(@key)}"
26
+ puts "#{FileBase.get_config(@key)}"
27
27
  end
28
28
  end
29
29
  end
@@ -26,7 +26,7 @@ module Gct
26
26
  end
27
27
 
28
28
  def run
29
- set_config(@key, @value)
29
+ FileBase.set_config(@key, @value)
30
30
  end
31
31
  end
32
32
  end
@@ -9,6 +9,11 @@ module Gct
9
9
  self.description = <<-DESC
10
10
  更新组件tag、主工程版本号等
11
11
  DESC
12
+
13
+ def initialize(argv)
14
+ super
15
+ config_gitlab
16
+ end
12
17
  end
13
18
  end
14
19
  end
@@ -19,7 +19,6 @@ module Gct
19
19
  name = @name ||= "iLife"
20
20
  @project_id = "#{Constant.NameSpace}#{name}"
21
21
  @file = "#{name}.xcodeproj/project.pbxproj"
22
- @branch = current_branch.rstrip
23
22
  super
24
23
  end
25
24
 
@@ -28,6 +27,7 @@ module Gct
28
27
  end
29
28
 
30
29
  def run
30
+ @branch = current_branch
31
31
  update_version
32
32
  end
33
33
 
@@ -54,7 +54,9 @@ module Gct
54
54
  end
55
55
 
56
56
  def current_branch
57
- "#{`git branch | awk '$1 == "*" {print $2}'`}"
57
+ branch = "#{`git branch | awk '$1 == "*" {print $2}'`}".rstrip
58
+ raise "该文件夹不是一个git仓库".red if branch.empty?
59
+ branch
58
60
  end
59
61
  end
60
62
  end
@@ -1,29 +1,56 @@
1
1
  module Gct
2
- class FileBase
3
-
4
- attr_reader :path
2
+ module FileBase
3
+ class << self
4
+ attr_reader :path
5
5
 
6
- def initialize(path)
7
- @path = path
8
- end
6
+ def initialize(path)
7
+ @path = path
8
+ end
9
9
 
10
- def yaml_write(key, value)
11
- begin
12
- yaml_file = File.open(@path, "w")
13
- YAML::dump({key => value}, yaml_file)
14
- rescue IOError => e
15
- raise e.message
16
- ensure
17
- yaml_file.close unless yaml_file.nil?
10
+ def yaml_write(key, value)
11
+ begin
12
+ yaml_file = File.open(@path, "w")
13
+ YAML::dump({key => value}, yaml_file)
14
+ rescue IOError => e
15
+ raise e.message
16
+ ensure
17
+ yaml_file.close unless yaml_file.nil?
18
+ end
19
+ end
20
+
21
+ def yaml_read(key)
22
+ begin
23
+ yaml_file = YAML.load(File.open(@path, "r"))
24
+ if yaml_file
25
+ yaml_file[key]
26
+ end
27
+ rescue IOError => e
28
+ raise e.message
29
+ end
30
+ end
31
+
32
+ def get_config(key)
33
+ if exist_root
34
+ @path = config_path
35
+ yaml_read(key)
36
+ end
37
+ end
38
+
39
+ def set_config(key, value)
40
+ if exist_root
41
+ @path = config_path
42
+ yaml_write(key, value)
43
+ end
44
+ end
45
+
46
+ def config_path
47
+ "#{Generator::GctFile.config_file_path}"
18
48
  end
19
- end
20
49
 
21
- def yaml_read(key)
22
- begin
23
- yaml_file = YAML.load(File.open(@path, "r"))
24
- yaml_file[key]
25
- rescue IOError => e
26
- raise e.message
50
+ def exist_root
51
+ root_exist = File.exist?(Generator::GctFile.root_folder_path)
52
+ raise "请先运行命令:gct setup".red if !root_exist
53
+ root_exist
27
54
  end
28
55
  end
29
56
  end
@@ -2,5 +2,5 @@ module Gct
2
2
  # freeze 冻结对象,将对象变成一个常量
3
3
  # unless 右边的代码块成立,才会运行左边的代码块
4
4
  # defined? 是用来判断本地变量是否存在,也可用来判断是否存在方法
5
- VERSION = "0.3.4".freeze unless defined? Gct::VERSION
5
+ VERSION = "0.3.5".freeze unless defined? Gct::VERSION
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - jieming