thktool 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/config.rb +68 -0
- data/lib/modify_until.rb +13 -6
- data/lib/package_framework.rb +3 -3
- data/lib/thktool/version.rb +1 -1
- data/lib/thktool.rb +18 -5
- data/lib/thktool_config.yml +19 -0
- metadata +3 -2
- data/lib/const.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe27fc871efd61f401ad7e5276fdbb27f93648319f96f4f9d16f6ee163d81f63
|
4
|
+
data.tar.gz: 7d39318e334e965a85beb9c83859a0d671ca0515d96acb0e80c05d9342044ceb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb9f7187a18fed63cc7faa0a2a4b4b878939a8a7de10d573d1f7ab081b8083f55ae0b32a8c5b0507b65d85ff9dfbdc324ca1664a6deb01f309dde0fea530e4cc
|
7
|
+
data.tar.gz: '051793aa1e6fcca4fa510619b6d9089fa77a61c16a5b07cdc51f7e5fdc4bf8196d3bfdb04a4f94db0d358e04b0d4422888353484b94d0d4f87f73266439c73c0'
|
data/lib/config.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
class Config
|
2
|
+
def initialize
|
3
|
+
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.create_config_file_if_need
|
7
|
+
yaml = nil
|
8
|
+
if File.exist?(Config.config_file)
|
9
|
+
yaml = YAML.load_file(Config.config_file)
|
10
|
+
Config.load_yaml(yaml)
|
11
|
+
else
|
12
|
+
yaml = YAML.load_file('lib/thktool_config.yml')
|
13
|
+
File.open(Config.config_file,"w") { |f| YAML.dump(yaml,f) }
|
14
|
+
end
|
15
|
+
yaml
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.config_file
|
19
|
+
self.Home + "/thktool_config.yml"
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.load_yaml(yaml)
|
23
|
+
@@source_repo_path = yaml['SOURCE_REPO_PATH'].trans_home_path!
|
24
|
+
@@source_spec_path = yaml['SOURCE_SPEC_PATH'].trans_home_path!
|
25
|
+
@@bin_repo_path = yaml['BIN_REPO_PATH'].trans_home_path!
|
26
|
+
@@bin_spec_path = yaml['BIN_SPEC_PATH'].trans_home_path!
|
27
|
+
@@source_repo_url = yaml['SOURCE_REPO_URL']
|
28
|
+
@@bin_repo_url = yaml['BIN_REPO_URL']
|
29
|
+
@@package_enable = yaml['PACKAGE_ENABLE']
|
30
|
+
@@package_source_repo = yaml['PACKAGE_SOURCE_REPO']
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.Home
|
34
|
+
('/Users/'+`whoami`).chomp
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.Source_Repo_Path
|
38
|
+
@@source_repo_path
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.Source_Spec_Path
|
42
|
+
@@source_spec_path
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.Bin_Repo_Path
|
46
|
+
@@bin_repo_path
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.Bin_Spec_Path
|
50
|
+
@@bin_spec_path
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.Source_Repo_Url
|
54
|
+
@@source_repo_url
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.Bin_Repo_Url
|
58
|
+
@@bin_repo_url
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.Package_Enable
|
62
|
+
@@package_enable == 1
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.Package_Source_repo
|
66
|
+
@@package_source_repo
|
67
|
+
end
|
68
|
+
end
|
data/lib/modify_until.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'config'
|
2
2
|
require 'Pathname'
|
3
3
|
|
4
4
|
class ModifyUntil
|
@@ -29,7 +29,7 @@ class ModifyUntil
|
|
29
29
|
p 'start modify file ...' + file
|
30
30
|
|
31
31
|
IO.write(file, File.open(file) do |f|
|
32
|
-
f.read.gsub(/:commit => (.*)/, ":commit => \"#{commit}\"")
|
32
|
+
f.read.gsub(/:commit => "(.*)"/, ":commit => \"#{commit}\"")
|
33
33
|
end
|
34
34
|
)
|
35
35
|
end
|
@@ -37,7 +37,7 @@ class ModifyUntil
|
|
37
37
|
|
38
38
|
# 开始修改源码仓库
|
39
39
|
def self.modify_src_commit(src,commit)
|
40
|
-
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 =
|
55
|
-
bin_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 =
|
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
|
data/lib/package_framework.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'config'
|
2
2
|
|
3
3
|
class PackageFramework
|
4
4
|
|
5
5
|
def self.package(podspec)
|
6
|
-
Dir.chdir(
|
7
|
-
spec_source =
|
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
|
data/lib/thktool/version.rb
CHANGED
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
|
-
#
|
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(
|
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(
|
47
|
+
GitUntil.git_push(Config.Bin_Repo_Path,"binary repo change : #{te.fwk}")
|
35
48
|
# 获取二进制仓库最后一次提交commit
|
36
|
-
last_commit_id = GitUntil.last_commit_id(
|
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(
|
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.
|
4
|
+
version: 0.1.3
|
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/
|
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
|