gct 0.3.0 → 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: 234020953df6dd3d1f9a2844c5fdd7b06129f901aac392e6d8a1695add614678
4
- data.tar.gz: 25d52ea8b3467f69db9865169d033fa042f46136b32dd25681e8ee16555ecc43
3
+ metadata.gz: c4c7ac5d299bdcd12bcf268d4f7d703d3cc928ec1bdf68a6a7607eb88776bfa1
4
+ data.tar.gz: ec3a3e19a4934758f25b7782b18033a6b5ae7b4011fe7f72a9a0600c6e31ca52
5
5
  SHA512:
6
- metadata.gz: 6f2b677246254294754e4b8b25c15ba44df16e87abb513adeb9515463fc72f6bb523360d14608d7aebb83110511b31cf28357e4a731bc64df7b9f520a40985e3
7
- data.tar.gz: 12ecd76daed4b90b7ef2d29da084d7658fc33fed7282e486f3519db0962e78cfff6422c684cb7960f9a8eff50e6c57f0044e452ae15691e0a83f3122ccbebff6
6
+ metadata.gz: 8ee1ec1276911016661047a4e3b85a78e51fbc8fee6d08531075bd26c43d598e4cf066a33712e9af51e9c6a317b5621e76d964a4c931a131f4952295696b4a2d
7
+ data.tar.gz: 3a10b473568f55e49de457f50f367010db7742eaf2ecde4684703a66835cbc7a7d10b1dcf8f33c41721a286c660b0aa9c682018e8db0585d4043f5b43f57ff3e
data/lib/gct.rb CHANGED
@@ -1,7 +1,16 @@
1
1
 
2
2
  module Gct
3
- require "gct/version"
3
+ require "gct/gct_version"
4
4
  require "gct/constant"
5
- autoload :Command, 'gct/command'
5
+ require "gct/specification"
6
+ require "gct/temp_local_file"
7
+ require "gct/temp_remote_file"
8
+ require "gct/file_base"
9
+
10
+ autoload :Command, 'gct/command'
11
+
12
+ module Generator
13
+ require "gct/generator/gct_file"
14
+ end
6
15
 
7
16
  end
@@ -2,6 +2,7 @@ require 'colored2'
2
2
  require 'claide'
3
3
  require 'molinillo/errors'
4
4
  require 'xcodeproj'
5
+ require 'gitlab'
5
6
 
6
7
  module Molinillo
7
8
  class ResolverError
@@ -16,14 +17,15 @@ module Gct
16
17
 
17
18
  class Command < CLAide::Command
18
19
  require 'gct/command/create'
19
- # require 'gct/command/init'
20
- # require 'gct/command/config'
21
- require 'gct/command/analyze'
20
+ require 'gct/command/init'
21
+ require 'gct/command/config'
22
+ # require 'gct/command/analyze'
22
23
  require 'gct/command/op'
23
24
  require 'gct/command/build'
24
25
  require 'gct/command/spec'
25
26
  require 'gct/command/repo'
26
- require 'gct/command/tag'
27
+ require 'gct/command/setup'
28
+ require 'gct/command/update'
27
29
 
28
30
  self.abstract_command = true
29
31
  self.command = 'gct'
@@ -49,5 +51,56 @@ module Gct
49
51
  String.send(:define_method, :colorize) { |string, _| string }
50
52
  end
51
53
  end
54
+
55
+ def file_contents(project_id, file, branch)
56
+ file_contents ||= Gitlab.file_contents(project_id, file, branch)
57
+ rescue Gitlab::Error::NotFound => error
58
+ raise error.message
59
+ end
60
+
61
+ def config_gitlab
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
73
+ end
74
+ end
75
+
76
+ def get_project
77
+ proj = nil
78
+ Dir.entries(Dir.pwd).each do |subfile|
79
+ if subfile.include? '.xcodeproj'
80
+ proj = subfile
81
+ end
82
+ end
83
+ if proj.nil?
84
+ puts '没有找到.xcodeproj文件'.red if proj.nil?
85
+ nil
86
+ else
87
+ project_path = File.join(Dir.pwd, "./" + proj)
88
+ project = Xcodeproj::Project.open(project_path)
89
+ project
90
+ end
91
+ end
92
+
93
+ def auto_add_tag(tag)
94
+ tag_points = tag.to_s.split('.')
95
+ index = tag_points.length - 1
96
+ need_add_point = tag_points[index].to_i + 1
97
+ tag_points[index] = need_add_point == 10 ? 0 : need_add_point
98
+ while need_add_point == 10 && index > 0
99
+ index = index - 1
100
+ need_add_point = tag_points[index].to_i + 1
101
+ tag_points[index] = need_add_point == 10 && index != 0 ? 0 : need_add_point
102
+ end
103
+ tag_points.join('.')
104
+ end
52
105
  end
53
106
  end
@@ -1,5 +1,6 @@
1
1
  require 'pathname'
2
2
  require 'tmpdir'
3
+ require 'parallel'
3
4
 
4
5
  module Gct
5
6
  class Command
@@ -9,7 +10,17 @@ module Gct
9
10
  分析podfile完整依赖链,并输出json文件.
10
11
  DESC
11
12
 
13
+ self.arguments = [
14
+ CLAide::Argument.new('PROJECT_ID', true),
15
+ CLAide::Argument.new('FILE', true),
16
+ CLAide::Argument.new('BRANCH', true),
17
+ ]
18
+
12
19
  def initialize(argv)
20
+ @project_id = argv.shift_argument
21
+ @file = argv.shift_argument
22
+ @branch = argv.shift_argument
23
+ config_gitlab
13
24
  super
14
25
  end
15
26
 
@@ -19,11 +30,98 @@ module Gct
19
30
  end
20
31
 
21
32
  def validate!
33
+ help! '必须输入项目名.' unless @project_id
34
+ help! '必须输入读取文件的相对路径.' unless @file
35
+ help! '必须输入读取文件的项目分支.' unless @branch
22
36
  super
23
37
  end
24
38
 
25
39
  def run
26
- system "pod dep"
40
+ analyze_dependencies
41
+ # update_podspec_version()
42
+ end
43
+
44
+ def podfile
45
+ contents = file_contents(@project_id, @file, @branch)
46
+ contents.force_encoding('UTF-8')
47
+
48
+ temp_local_file = TempLocalFile.new(contents, @file)
49
+ temp_local_file.write
50
+ full_path = temp_local_file.full_path
51
+
52
+ @podfile ||= begin
53
+ podfile = Pod::Podfile.from_ruby(full_path, contents)
54
+ podfile
55
+ end
56
+ end
57
+
58
+ def analyze_dependencies
59
+ untagged_git_dependencies = podfile.dependencies.select { |dependency| dependency.external? && dependency.external_source[:tag].nil? && dependency.external_source[:branch] == Constant.DefaultTagBranch}
60
+ puts untagged_git_dependencies
61
+ # untagged_specs = Parallel.map(untagged_git_dependencies, in_threads: 1) do |dep|
62
+ # require 'json'
63
+ # puts "#{Constant.NameSpace}#{dep.name}"
64
+ # puts "#{dep.name}.podspec"
65
+ # puts Constant.DefaultTagBranch
66
+
67
+ # contents_json = file_contents("#{Constant.NameSpace}#{dep.name}", "#{dep.name}.podspec", Constant.DefaultTagBranch)
68
+ # podspec = system contents_json
69
+ # puts podspec.class
70
+ # puts podspec
71
+ # podspec = from_string("", contents_json)
72
+ # podspec = Pod::Spec.new do |spec|
73
+
74
+ # end
75
+
76
+
77
+ # puts podspec.class.to_s
78
+ # puts podspec.to_s
79
+ # gct_spec = Specification.new()
80
+ # gct_spec.specification = podspec
81
+ # gct_spec.priority = 1000
82
+ # gct_spec.status = SpecPublishStatus::CREATED
83
+ # gct_spec.tag = "0"
84
+
85
+ # update_podspec_version(spec)
86
+ # gct_spec
87
+ # end
88
+ end
89
+
90
+ def update_podspec_version(spec)
91
+ content = file_contents("#{Constant.NameSpace}#{dep.name}", "#{spec.name}.podspec", Constant.DefaultTagBranch)
92
+ now_version = spec.version
93
+ version = auto_add_tag(now_version)
94
+ require_variable_prefix = true
95
+ version_var_name = 'version'
96
+ variable_prefix = require_variable_prefix ? /\w\./ : //
97
+ version_regex = /^(?<begin>[^#]*#{variable_prefix}#{version_var_name}\s*=\s*['"])(?<value>(?<major>[0-9]+)(\.(?<minor>[0-9]+))?(\.(?<patch>[0-9]+))?(?<appendix>(\.[0-9]+)*)?(-(?<prerelease>(.+)))?)(?<end>['"])/i
98
+ version_match = version_regex.match(content)
99
+ updated_podspec_content = content.gsub(version_regex, "#{version_match[:begin]}#{version}#{version_match[:end]}")
100
+ updated_podspec_content
101
+
102
+ edit_file(spec, updated_podspec_content, version)
103
+ mr_to_master(spec)
104
+ end
105
+
106
+
107
+
108
+ def edit_file(spec, content, version)
109
+ Gitlab.edit_file("#{Constant.NameSpace}#{dep.name}", "#{spec.name}.podspec", Constant.DefaultTagBranch, content, "@config 升级版本号:#{version}")
110
+ end
111
+
112
+ def mr_to_master(spec)
113
+ mr = Gitlab.create_merge_request("#{Constant.NameSpace}#{dep.name}", "podpesc修改", { source_branch: 'develop', target_branch: 'master' })
114
+ id = mr.iid
115
+ puts mr.to_hash
116
+ if mr.merge_status == 'cannot_be_merged'
117
+ raise "Merge有冲突,请前往 https://gi-dev.ccrgt.com/#{Constant.NameSpace}#{spec.name}/merge_requests/#{id} 解决".red
118
+ end
119
+
120
+ accept_merge_request(spec, id)
121
+ end
122
+
123
+ def accept_merge_request(spec, id)
124
+ Gitlab.accept_merge_request("#{Constant.NameSpace}#{dep.name}", id)
27
125
  end
28
126
  end
29
127
  end
@@ -24,19 +24,8 @@ module Gct
24
24
 
25
25
  def buildR
26
26
  puts "starting search R script ...".green
27
- proj = ''
28
- Dir.entries(Dir.pwd).each do |subfile|
29
- if subfile.include? '.xcodeproj'
30
- proj = subfile
31
- end
32
- end
33
-
34
- if proj == ''
35
- puts '没有找到.xcodeproj文件'.red
36
- else
37
- project_path = File.join(Dir.pwd, "./" + proj)
38
- project = Xcodeproj::Project.open(project_path)
39
-
27
+ project = get_project
28
+ if project
40
29
  objects = project.objects
41
30
  findR = false
42
31
  objects.each do |obj|
@@ -9,6 +9,7 @@ module Gct
9
9
  self.description = <<-DESC
10
10
  配置全局链接等
11
11
  DESC
12
+
12
13
  end
13
14
  end
14
15
  end
@@ -9,25 +9,21 @@ module Gct
9
9
  DESC
10
10
 
11
11
  self.arguments = [
12
- CLAide::Argument.new('NAME', true),
12
+ CLAide::Argument.new('KEY', true),
13
13
  ]
14
14
 
15
15
  def initialize(argv)
16
- @name = argv.shift_argument
16
+ @key = argv.shift_argument
17
17
  super
18
- @additional_args = argv.remainder!
19
18
  end
20
19
 
21
20
  def validate!
22
21
  super
23
- help! 'A name for the Pod is required.' unless @name
24
- help! 'The Pod name cannot contain spaces.' if @name =~ /\s/
25
- help! 'The Pod name cannot contain plusses.' if @name =~ /\+/
26
- help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.'
22
+ help! '请输入key.' unless @key
27
23
  end
28
24
 
29
25
  def run
30
- puts "获取全局配置成功".green
26
+ puts "#{FileBase.get_config(@key)}"
31
27
  end
32
28
  end
33
29
  end
@@ -8,26 +8,25 @@ module Gct
8
8
  设置gct全局配置.
9
9
  DESC
10
10
 
11
- # self.arguments = [
12
- # CLAide::Argument.new('NAME', true),
13
- # ]
11
+ self.arguments = [
12
+ CLAide::Argument.new('KEY', true),
13
+ CLAide::Argument.new('VALUE', true),
14
+ ]
14
15
 
15
16
  def initialize(argv)
16
- @name = argv.shift_argument
17
+ @key = argv.shift_argument
18
+ @value = argv.shift_argument
17
19
  super
18
- # @additional_args = argv.remainder!
19
20
  end
20
21
 
21
22
  def validate!
22
23
  super
23
- # help! 'A name for the Pod is required.' unless @name
24
- # help! 'The Pod name cannot contain spaces.' if @name =~ /\s/
25
- # help! 'The Pod name cannot contain plusses.' if @name =~ /\+/
26
- # help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.'
24
+ help! '请输入key.' unless @key
25
+ help! '请输入value.' unless @value
27
26
  end
28
27
 
29
28
  def run
30
- puts "设置全局配置成功".green
29
+ FileBase.set_config(@key, @value)
31
30
  end
32
31
  end
33
32
  end
@@ -9,25 +9,20 @@ module Gct
9
9
  DESC
10
10
 
11
11
  self.arguments = [
12
- CLAide::Argument.new('NAME', true),
13
12
  ]
14
13
 
15
14
  def initialize(argv)
16
- @name = argv.shift_argument
17
15
  super
18
- @additional_args = argv.remainder!
19
16
  end
20
17
 
21
18
  def validate!
22
19
  super
23
- help! 'A name for the Pod is required.' unless @name
24
- help! 'The Pod name cannot contain spaces.' if @name =~ /\s/
25
- help! 'The Pod name cannot contain plusses.' if @name =~ /\+/
26
- help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.'
27
20
  end
28
21
 
29
22
  def run
30
- puts "new ci".green
23
+ puts "init ci".green
24
+ cp_path = Pathname.new(__FILE__).parent + 'gitlab-ci.rb'
25
+ system "cp #{cp_path} .gitlab-ci.yml"
31
26
  end
32
27
  end
33
28
  end
@@ -0,0 +1,13 @@
1
+ stages:
2
+ - push
3
+
4
+ push_pod:
5
+ stage: push
6
+ script:
7
+ - echo "开始lint 和 push podspec"
8
+ - gct repo update
9
+ - gct repo push
10
+ only:
11
+ - master
12
+ tags:
13
+ - iOS
@@ -1,6 +1,7 @@
1
1
  require 'gct/command/op/gems'
2
2
  require 'gct/command/op/gitconf'
3
3
  require 'gct/command/op/xcache'
4
+ require 'gct/command/op/root'
4
5
 
5
6
  module Gct
6
7
  class Command
@@ -10,6 +11,7 @@ module Gct
10
11
  self.description = <<-DESC
11
12
  打开常用文件夹,并输出路径
12
13
  DESC
14
+
13
15
  end
14
16
  end
15
17
  end
@@ -0,0 +1,33 @@
1
+ module Gct
2
+ class Command
3
+ class Op < Command
4
+ class Root < Op
5
+
6
+ self.summary = '打开gct文件夹'
7
+ self.description = <<-DESC
8
+ 打开gct文件夹
9
+ DESC
10
+
11
+ self.arguments = [
12
+ ]
13
+
14
+ def initialize(argv)
15
+ super
16
+ end
17
+
18
+ def validate!
19
+ super
20
+ end
21
+
22
+ def run
23
+ openGct
24
+ end
25
+
26
+ def openGct
27
+ root_path = Generator::GctFile.root_folder_path
28
+ system "open #{root_path}"
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,46 @@
1
+ module Gct
2
+ class Command
3
+ class Setup < Command
4
+
5
+ self.summary = '设置Gct'
6
+ self.description = <<-DESC
7
+ 创建gct的全局隐藏文件,配置全局参数,缓存文件等
8
+ DESC
9
+
10
+ def initialize(argv)
11
+ super
12
+ end
13
+
14
+ def run
15
+ create_root_folder
16
+ create_temp_folder
17
+ create_config_file
18
+ puts "setup success!".green
19
+ end
20
+
21
+ def create_root_folder
22
+ gct_path = Generator::GctFile.root_folder_path
23
+ if !File.exist?(gct_path)
24
+ system "mkdir #{gct_path}", exception: true
25
+ puts "#{gct_path} 创建成功!".green
26
+ end
27
+ end
28
+
29
+ def create_temp_folder
30
+ temp_path = Generator::GctFile.temp_folder_path
31
+ if !File.exist?(temp_path)
32
+ system "mkdir #{temp_path}", exception: true
33
+ puts "#{temp_path} 创建成功!".green
34
+ end
35
+ end
36
+
37
+ def create_config_file
38
+ config_path = Generator::GctFile.config_file_path
39
+ if !File.exist?(config_path)
40
+ system "touch #{config_path}", exception: true
41
+ puts "#{config_path} 创建成功!".green
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,19 @@
1
+ require 'gct/command/update/tag'
2
+ require 'gct/command/update/version'
3
+
4
+ module Gct
5
+ class Command
6
+ class Update < Command
7
+ self.abstract_command = true
8
+ self.summary = '更新操作'
9
+ self.description = <<-DESC
10
+ 更新组件tag、主工程版本号等
11
+ DESC
12
+
13
+ def initialize(argv)
14
+ super
15
+ config_gitlab
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,7 +1,8 @@
1
1
  module Gct
2
- class Command
3
- class Tag < Command
4
-
2
+ class Command
3
+ class Update < Command
4
+ class Tag < Update
5
+
5
6
  self.summary = '添加tag'
6
7
  self.description = <<-DESC
7
8
  十进制增加tag版本
@@ -39,24 +40,12 @@ module Gct
39
40
  end
40
41
 
41
42
  def add_push_new_tag
42
- @new_tag = @tag || autoAddTag(@now_tag.to_s)
43
+ @new_tag = @tag || auto_add_tag(@now_tag.to_s)
43
44
  update_tag_podspec
44
45
  `git tag #{@new_tag}`
45
46
  `git push origin #{@new_tag} || { exit 1; }`
46
47
  end
47
-
48
- def autoAddTag(tag)
49
- tag_points = tag.to_s.split('.')
50
- index = tag_points.length - 1
51
- need_add_point = tag_points[index].to_i + 1
52
- tag_points[index] = need_add_point == 10 ? 0 : need_add_point
53
- while need_add_point == 10 && index > 0
54
- index = index - 1
55
- need_add_point = tag_points[index].to_i + 1
56
- tag_points[index] = need_add_point == 10 && index != 0 ? 0 : need_add_point
57
- end
58
- tag_points.join('.')
59
- end
60
48
  end
61
49
  end
62
- end
50
+ end
51
+ end
@@ -0,0 +1,64 @@
1
+ module Gct
2
+ class Command
3
+ class Update < Command
4
+ class Version < Update
5
+
6
+ self.summary = '更新版本号'
7
+ self.description = <<-DESC
8
+ 更新release分支的版本号
9
+ DESC
10
+
11
+ self.arguments = [
12
+ CLAide::Argument.new('NAME', false),
13
+ CLAide::Argument.new('VERSION', false),
14
+ ]
15
+
16
+ def initialize(argv)
17
+ @name = argv.shift_argument
18
+ @version = argv.shift_argument
19
+ name = @name ||= "iLife"
20
+ @project_id = "#{Constant.NameSpace}#{name}"
21
+ @file = "#{name}.xcodeproj/project.pbxproj"
22
+ super
23
+ end
24
+
25
+ def validate!
26
+ super
27
+ end
28
+
29
+ def run
30
+ @branch = current_branch
31
+ update_version
32
+ end
33
+
34
+ def update_version
35
+ if check_branch_can_be_update
36
+ content = file_contents(@project_id, @file, @branch)
37
+ version_var_name = 'MARKETING_VERSION = '
38
+ version_regex = /(?<=#{version_var_name})\w.*(?=;)/
39
+ version_match = version_regex.match(content)
40
+ version = @version ||= auto_add_tag(version_match)
41
+ updated_content = content.gsub(version_regex, version)
42
+ edit_file(updated_content, version)
43
+ else
44
+ puts "当前不是release分支".red
45
+ end
46
+ end
47
+
48
+ def edit_file(content, version)
49
+ Gitlab.edit_file(@project_id, @file, @branch, content, "@config 更新版本号:#{version}")
50
+ end
51
+
52
+ def check_branch_can_be_update
53
+ current_branch.include?('release')
54
+ end
55
+
56
+ def current_branch
57
+ branch = "#{`git branch | awk '$1 == "*" {print $2}'`}".rstrip
58
+ raise "该文件夹不是一个git仓库".red if branch.empty?
59
+ branch
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -1,6 +1,10 @@
1
1
  module Gct
2
2
  module Constant
3
3
  class << self
4
+ def GitBaseURL
5
+ "https://gi-dev.ccrgt.com/"
6
+ end
7
+
4
8
  def GitThirdURL
5
9
  "https://gi-dev.ccrgt.com/ios-thirdpart/"
6
10
  end
@@ -8,6 +12,18 @@ module Gct
8
12
  def GitURL
9
13
  "https://gi-dev.ccrgt.com/ios/"
10
14
  end
15
+
16
+ def NameSpace
17
+ "ios/"
18
+ end
19
+
20
+ def ThirdNameSpace
21
+ "ios-third/"
22
+ end
23
+
24
+ def DefaultTagBranch
25
+ "develop"
26
+ end
11
27
  end
12
28
  end
13
29
  end
@@ -0,0 +1,57 @@
1
+ module Gct
2
+ module FileBase
3
+ class << self
4
+ attr_reader :path
5
+
6
+ def initialize(path)
7
+ @path = path
8
+ end
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?
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}"
48
+ end
49
+
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
54
+ end
55
+ end
56
+ end
57
+ end
@@ -2,5 +2,5 @@ module Gct
2
2
  # freeze 冻结对象,将对象变成一个常量
3
3
  # unless 右边的代码块成立,才会运行左边的代码块
4
4
  # defined? 是用来判断本地变量是否存在,也可用来判断是否存在方法
5
- VERSION = "0.3.0".freeze unless defined? Gct::VERSION
5
+ VERSION = "0.3.5".freeze unless defined? Gct::VERSION
6
6
  end
@@ -0,0 +1,32 @@
1
+ module Gct
2
+ module Generator
3
+ class GctFile
4
+
5
+ def self.root_folder_path
6
+ "/Users/#{get_system_user_name.rstrip}/.gct"
7
+ end
8
+
9
+ def self.temp_folder_path
10
+ "/Users/#{get_system_user_name.rstrip}/.gct/tmp"
11
+ end
12
+
13
+ def self.config_file_path
14
+ "/Users/#{get_system_user_name.rstrip}/.gct/config"
15
+ end
16
+
17
+ # 获取系统用户名
18
+ def self.get_system_user_name
19
+ # windows
20
+ if RUBY_PLATFORM =~ /mswin|mingw/
21
+ query = `reg query HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer /v "Logon User Name"`
22
+ /Logon\ User\ Name\s+REG_SZ\s+(\S+)/ =~ query
23
+ "#{$1}"
24
+ # unix, cygwin, mac
25
+ else
26
+ "#{`whoami`}"
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,39 @@
1
+ module Gct
2
+ # attr_accessor get and set
3
+ # attr_reader only get
4
+ # attr_writer only set
5
+ class Specification
6
+ # Pod::Dependency
7
+ attr_accessor :specification
8
+
9
+ # 优先级
10
+ attr_accessor :priority
11
+
12
+ # tag版本
13
+ attr_accessor :tag
14
+
15
+ # 发布状态
16
+ attr_accessor :status
17
+
18
+ def initialize()
19
+ @specification = specification
20
+ @priority = priority
21
+ @status = status
22
+ @tag = tag
23
+ end
24
+ end
25
+ end
26
+
27
+ module SpecPublishStatus
28
+ CREATED = '待分析'
29
+ ANALYZING = '分析中'
30
+ PREPARING = '准备中'
31
+ PENDING = '等待中'
32
+ WAITING = '待发布'
33
+ SKIPPED = '已忽略'
34
+ MERGED = '已合并'
35
+ DEPLOYING = '发布中'
36
+ SUCCESS = '发布成功'
37
+ FAILED = '发布失败'
38
+ CANCELED = '已取消'
39
+ end
@@ -0,0 +1,42 @@
1
+ module Gct
2
+ class TempLocalFile
3
+ attr_reader :content
4
+
5
+ attr_reader :file_name
6
+
7
+ def initialize(content, file_name)
8
+ @content = content
9
+ @file_name = file_name
10
+ end
11
+
12
+ def write
13
+ begin
14
+ file = File.open(tmp_folder, "w")
15
+ file.write(@content)
16
+ rescue IOError => e
17
+ raise e.message
18
+ ensure
19
+ file.close unless file.nil?
20
+ end
21
+ end
22
+
23
+ def read
24
+ begin
25
+ file = File.open(tmp_folder, "r")
26
+ file.read
27
+ rescue IOError => e
28
+ raise e.message
29
+ ensure
30
+ file.close unless file.nil?
31
+ end
32
+ end
33
+
34
+ def full_path
35
+ tmp_folder
36
+ end
37
+
38
+ def tmp_folder
39
+ "#{Generator::GctFile.temp_folder_path}/#{file_name}"
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,44 @@
1
+ module Gct
2
+ class TempRemoteFile
3
+ attr_reader :uri
4
+
5
+ def initialize(url, content)
6
+ @uri = URI.parse(url)
7
+ @content = content
8
+ end
9
+
10
+ def file
11
+ @file ||= Tempfile.open(tmp_filename, tmp_folder, encoding: encoding) do |f|
12
+ puts f
13
+ io.rewind
14
+ f.write(io.read)
15
+ f.close
16
+ end
17
+ end
18
+
19
+ def close
20
+ @file.close
21
+ @file.unlink
22
+ end
23
+
24
+ def io
25
+ @io ||= uri.open
26
+ end
27
+
28
+ def encoding
29
+ io.rewind
30
+ io.read.encoding
31
+ end
32
+
33
+ def tmp_filename
34
+ [
35
+ Pathname.new(uri.path).basename,
36
+ Pathname.new(uri.path).extname
37
+ ]
38
+ end
39
+
40
+ def tmp_folder
41
+ Generator::GctFile.temp_folder_path
42
+ end
43
+ end
44
+ end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - jieming
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-20 00:00:00.000000000 Z
11
+ date: 2020-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
@@ -106,6 +106,34 @@ dependencies:
106
106
  - - "<"
107
107
  - !ruby/object:Gem::Version
108
108
  version: '2.0'
109
+ - !ruby/object:Gem::Dependency
110
+ name: gitlab
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ type: :runtime
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ - !ruby/object:Gem::Dependency
124
+ name: parallel
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ type: :runtime
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
109
137
  description: '"gct ios 自动化脚本工具"'
110
138
  email:
111
139
  - 307113345@qq.com
@@ -130,20 +158,30 @@ files:
130
158
  - lib/gct/command/create/third.rb
131
159
  - lib/gct/command/init.rb
132
160
  - lib/gct/command/init/ci.rb
161
+ - lib/gct/command/init/gitlab-ci.rb
133
162
  - lib/gct/command/init/unit.rb
134
163
  - lib/gct/command/op.rb
135
164
  - lib/gct/command/op/gems.rb
136
165
  - lib/gct/command/op/gitconf.rb
166
+ - lib/gct/command/op/root.rb
137
167
  - lib/gct/command/op/xcache.rb
138
168
  - lib/gct/command/repo.rb
139
169
  - lib/gct/command/repo/add.rb
140
170
  - lib/gct/command/repo/push.rb
141
171
  - lib/gct/command/repo/update.rb
172
+ - lib/gct/command/setup.rb
142
173
  - lib/gct/command/spec.rb
143
174
  - lib/gct/command/spec/lint.rb
144
- - lib/gct/command/tag.rb
175
+ - lib/gct/command/update.rb
176
+ - lib/gct/command/update/tag.rb
177
+ - lib/gct/command/update/version.rb
145
178
  - lib/gct/constant.rb
146
- - lib/gct/version.rb
179
+ - lib/gct/file_base.rb
180
+ - lib/gct/gct_version.rb
181
+ - lib/gct/generator/gct_file.rb
182
+ - lib/gct/specification.rb
183
+ - lib/gct/temp_local_file.rb
184
+ - lib/gct/temp_remote_file.rb
147
185
  homepage: https://gi-dev.ccrgt.com/ios-thirdpart/gct
148
186
  licenses: []
149
187
  metadata:
@@ -156,15 +194,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
194
  requirements:
157
195
  - - ">="
158
196
  - !ruby/object:Gem::Version
159
- version: '0'
197
+ version: 2.6.0
160
198
  required_rubygems_version: !ruby/object:Gem::Requirement
161
199
  requirements:
162
200
  - - ">="
163
201
  - !ruby/object:Gem::Version
164
202
  version: '0'
165
203
  requirements: []
166
- rubyforge_project:
167
- rubygems_version: 2.7.7
204
+ rubygems_version: 3.0.3
168
205
  signing_key:
169
206
  specification_version: 4
170
207
  summary: '"gct ios 自动化脚本工具"'