thktool 0.1.2 → 0.1.4

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: '079d03122b4b4dc7976229584897cceeb10f5d7b7e1e86cf423818b8c69a4159'
4
- data.tar.gz: '09e9d7914a7048bebfe50d047f7eef301016de531890bf4f5a04a3f2245cf438'
3
+ metadata.gz: e74a964ed1bc9eefb1abd2486f1c93f5283bf5e6d8a9996cc9dea4aa04852191
4
+ data.tar.gz: 2a8557b01e1d7ab542f4d935eff0f426e3a690390851f0af818a92766c54bebf
5
5
  SHA512:
6
- metadata.gz: 2104a94ee65c23290f1d5f1fa3e56c735711217322401a1edea31eaf05388bc40f20ec276e10711e86f9c34a804155fafd6688e8e58d0fa3d8202e1948a1fdbc
7
- data.tar.gz: 3690ba607003bdc191721e5e45c87252357d83c5cbaad69a1b2276648b6c716b3fe00727d0510040ac96da2356c4cde2a1b9be7be78317498a1ad799bf9e8510
6
+ metadata.gz: a660acced5cb0a0a2f4497dd9411743756ee0532a885a1eb39564b36624d9a61068f8a52ae00c34b307c71d2b74bf0e430083ab8456dfadf63d487d06250bf2a
7
+ data.tar.gz: afb8be4cb3d7be41213e868bc4c2e90a922c828fc630814d33cc69033e7c3a37b68c3073aadc124bd69ae7eaaec8dccdedcdb6b4f6bdd61a1000970c7eeb9cc7
data/lib/config.rb ADDED
@@ -0,0 +1,70 @@
1
+ class Config
2
+ def initialize
3
+
4
+ end
5
+
6
+ def self.create_config_file_if_need
7
+ yaml = nil
8
+
9
+ if File.exist?(Config.config_file)
10
+ yaml = YAML.load_file(Config.config_file)
11
+ Config.load_yaml(yaml)
12
+ else
13
+ yml_file = File.join(File.dirname(File.expand_path(__FILE__)), 'thktool_config.yml')
14
+ yaml = YAML.load_file(yml_file)
15
+ File.open(Config.config_file,"w") { |f| YAML.dump(yaml,f) }
16
+ end
17
+ yaml
18
+ end
19
+
20
+ def self.config_file
21
+ self.Home + "/thktool_config.yml"
22
+ end
23
+
24
+ def self.load_yaml(yaml)
25
+ @@source_repo_path = yaml['SOURCE_REPO_PATH'].trans_home_path!
26
+ @@source_spec_path = yaml['SOURCE_SPEC_PATH'].trans_home_path!
27
+ @@bin_repo_path = yaml['BIN_REPO_PATH'].trans_home_path!
28
+ @@bin_spec_path = yaml['BIN_SPEC_PATH'].trans_home_path!
29
+ @@source_repo_url = yaml['SOURCE_REPO_URL']
30
+ @@bin_repo_url = yaml['BIN_REPO_URL']
31
+ @@package_enable = yaml['PACKAGE_ENABLE']
32
+ @@package_source_repo = yaml['PACKAGE_SOURCE_REPO']
33
+ end
34
+
35
+ def self.Home
36
+ ('/Users/'+`whoami`).chomp
37
+ end
38
+
39
+ def self.Source_Repo_Path
40
+ @@source_repo_path
41
+ end
42
+
43
+ def self.Source_Spec_Path
44
+ @@source_spec_path
45
+ end
46
+
47
+ def self.Bin_Repo_Path
48
+ @@bin_repo_path
49
+ end
50
+
51
+ def self.Bin_Spec_Path
52
+ @@bin_spec_path
53
+ end
54
+
55
+ def self.Source_Repo_Url
56
+ @@source_repo_url
57
+ end
58
+
59
+ def self.Bin_Repo_Url
60
+ @@bin_repo_url
61
+ end
62
+
63
+ def self.Package_Enable
64
+ @@package_enable == 1
65
+ end
66
+
67
+ def self.Package_Source_repo
68
+ @@package_source_repo
69
+ end
70
+ end
data/lib/modify_until.rb CHANGED
@@ -1,4 +1,4 @@
1
- require_relative 'const'
1
+ require_relative 'config'
2
2
  require 'Pathname'
3
3
 
4
4
  class ModifyUntil
@@ -37,7 +37,7 @@ class ModifyUntil
37
37
 
38
38
  # 开始修改源码仓库
39
39
  def self.modify_src_commit(src,commit)
40
- path = Const.Source_Spec_Path
40
+ path = Config.Source_Spec_Path
41
41
  pn = find_max_ver(path,src)
42
42
  if pn.file?
43
43
  modify_src_file_line(pn.to_s,commit)
@@ -51,8 +51,8 @@ class ModifyUntil
51
51
  def self.modify_fwk_file_line(file,src_commit,fwk_commit)
52
52
  p 'start modify file ...' + file
53
53
 
54
- src_url = Const.Source_Repo_Url
55
- bin_url = Const.Bin_Repo_Url
54
+ src_url = Config.Source_Repo_Url
55
+ bin_url = Config.Bin_Repo_Url
56
56
 
57
57
  IO.write(file, File.open(file) do |f|
58
58
  f.read.gsub(/.*s.source.*#{src_url}.*/, " s.source = \{ :git => \'#{src_url}\', :commit => \"#{src_commit}\"\}")
@@ -66,7 +66,7 @@ class ModifyUntil
66
66
  end
67
67
 
68
68
  def self.modify_fwk_commit(fwk,src_commit,fwk_commit)
69
- path = Const.Bin_Spec_Path
69
+ path = Config.Bin_Spec_Path
70
70
  pn = find_max_ver(path,fwk)
71
71
  if pn.file?
72
72
  modify_fwk_file_line(pn.to_s,src_commit,fwk_commit)
@@ -84,4 +84,11 @@ class String
84
84
  cmp = proc { |s| s.split(fieldsep).map(&:to_i) }
85
85
  cmp.call(self) <=> cmp.call(other)
86
86
  end
87
+
88
+ def trans_home_path!
89
+ real = Config.Home
90
+ if self.include? '~'
91
+ self.gsub(/~/,real)
92
+ end
93
+ end
87
94
  end
@@ -1,10 +1,10 @@
1
- require_relative 'const'
1
+ require_relative 'config'
2
2
 
3
3
  class PackageFramework
4
4
 
5
5
  def self.package(podspec)
6
- Dir.chdir(Const.Bin_Repo_Path)
7
- spec_source = ['https://github.com/CocoaPods/Specs.git','git@repo.we.com:iosfeaturelibraries/thkbusinesskitspecs.git','git@repo.we.com:ios/tspecsrepo.git']
6
+ Dir.chdir(Config.Bin_Repo_Path)
7
+ spec_source = Config.Package_Source_repo
8
8
  command = "pod packagethk #{podspec} --force --exclude-deps --no-mangle --configuration=Debug --spec-sources=#{spec_source.join(',')}"
9
9
  puts "start package ..."
10
10
  puts command
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Thktool
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/thktool.rb CHANGED
@@ -5,6 +5,8 @@ require_relative "trigger_event"
5
5
  require_relative "modify_until"
6
6
  require_relative "package_framework"
7
7
  require_relative "git_until"
8
+ require 'yaml'
9
+ require_relative "config"
8
10
 
9
11
  module Thktool
10
12
  class Error < StandardError; end
@@ -17,27 +19,38 @@ module Thktool
17
19
  p "web hook argv : "
18
20
  p ARGV
19
21
 
20
- # Tool.run(ARGV)
22
+ # 初始化配置
23
+ yml = Config.create_config_file_if_need
24
+ # 加载配置文件
25
+ Config.load_yaml(yml)
26
+
21
27
  end
22
28
 
23
29
  class Tool
24
30
  def self.run(argv)
31
+ # 初始化配置
32
+ yml = Config.create_config_file_if_need
33
+ # 加载配置文件
34
+ Config.load_yaml(yml)
35
+ # 触发器创建
25
36
  te = TriggerEvent.new(argv)
26
37
  if te.validate_object
27
38
  # 修改源码仓库对应的spec仓库
28
39
  src_podspec = ModifyUntil.modify_src_commit(te.fwk,te.commit)
29
40
  # 提交spec仓库代码
30
- GitUntil.git_push(Const.Source_Spec_Path,"source podspec repo change : #{te.fwk} commit => #{te.commit}")
41
+ GitUntil.git_push(Config.Source_Spec_Path,"source podspec repo change : #{te.fwk} commit => #{te.commit}")
42
+ # 判断是否打包
43
+ return unless Config.Package_Enable
31
44
  # 开始制作二进制包
32
45
  PackageFramework.package(src_podspec)
33
46
  # 提交二进制包到framwork仓库
34
- GitUntil.git_push(Const.Bin_Repo_Path,"binary repo change : #{te.fwk}")
47
+ GitUntil.git_push(Config.Bin_Repo_Path,"binary repo change : #{te.fwk}")
35
48
  # 获取二进制仓库最后一次提交commit
36
- last_commit_id = GitUntil.last_commit_id(Const.Bin_Repo_Path)
49
+ last_commit_id = GitUntil.last_commit_id(Config.Bin_Repo_Path)
37
50
  # 修改二进制spec仓库
38
51
  fwk_podspec = ModifyUntil.modify_fwk_commit(te.fwk,te.commit,last_commit_id)
39
52
  # 提交二进制spec仓库
40
- GitUntil.git_push(Const.Bin_Spec_Path,"binary podspec change : #{te.fwk} src commit => #{te.commit}, bin commit => #{last_commit_id}")
53
+ GitUntil.git_push(Config.Bin_Spec_Path,"binary podspec change : #{te.fwk} src commit => #{te.commit}, bin commit => #{last_commit_id}")
41
54
  end
42
55
  end
43
56
  end
@@ -0,0 +1,19 @@
1
+ SOURCE_REPO_PATH: ~/
2
+
3
+ SOURCE_SPEC_PATH: ~/thkbusinesskitspecs
4
+
5
+ BIN_REPO_PATH: ~/frameworkrepo
6
+
7
+ BIN_SPEC_PATH: ~/frameworkspec
8
+
9
+ SOURCE_REPO_URL: 'http://repo.we.com/iosfeaturelibraries/THKBusinessComponent.git'
10
+
11
+ BIN_REPO_URL: 'git@repo.we.com:iosfeaturelibraries/frameworkrepo.git'
12
+
13
+ PACKAGE_ENABLE: 1
14
+
15
+ PACKAGE_SOURCE_REPO:
16
+ - https://github.com/CocoaPods/Specs.git
17
+ - git@repo.we.com:iosfeaturelibraries/thkbusinesskitspecs.git
18
+ - git@repo.we.com:ios/tspecsrepo.git
19
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thktool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe.cheng
@@ -23,12 +23,13 @@ files:
23
23
  - README.md
24
24
  - Rakefile
25
25
  - bin/thktool
26
- - lib/const.rb
26
+ - lib/config.rb
27
27
  - lib/git_until.rb
28
28
  - lib/modify_until.rb
29
29
  - lib/package_framework.rb
30
30
  - lib/thktool.rb
31
31
  - lib/thktool/version.rb
32
+ - lib/thktool_config.yml
32
33
  - lib/trigger_event.rb
33
34
  - sig/thktool.rbs
34
35
  - thktool.gemspec
data/lib/const.rb DELETED
@@ -1,33 +0,0 @@
1
- class Const
2
- def initialize
3
-
4
- end
5
-
6
- def self.Home
7
- ('/Users/'+`whoami`).chomp
8
- end
9
-
10
- def self.Source_Repo_Path
11
- './'
12
- end
13
-
14
- def self.Source_Spec_Path
15
- self.Home + '/thkbusinesskitspecs'
16
- end
17
-
18
- def self.Bin_Repo_Path
19
- self.Home + '/frameworkrepo'
20
- end
21
-
22
- def self.Bin_Spec_Path
23
- self.Home + '/frameworkspec'
24
- end
25
-
26
- def self.Source_Repo_Url
27
- 'http://repo.we.com/iosfeaturelibraries/THKBusinessComponent.git'
28
- end
29
-
30
- def self.Bin_Repo_Url
31
- 'git@repo.we.com:iosfeaturelibraries/frameworkrepo.git'
32
- end
33
- end