shkeeper 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.idea/.gitignore +8 -0
- data/.idea/bigkeeper.iml +68 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/CONTRIBUTING.md +70 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +145 -0
- data/LICENSE +21 -0
- data/README.md +113 -0
- data/big_keeper.gemspec +50 -0
- data/bin/big +14 -0
- data/bin/koo +14 -0
- data/bin/setup +8 -0
- data/bin/sh +14 -0
- data/docs/en-US/FEATURE.md +0 -0
- data/docs/en-US/README.md +54 -0
- data/docs/zh-CN/BIGKEEPER_FILE.md +84 -0
- data/docs/zh-CN/FEATURE&HOTFIX.md +88 -0
- data/docs/zh-CN/IMAGE.md +0 -0
- data/docs/zh-CN/PODFILE.md +43 -0
- data/docs/zh-CN/README.md +113 -0
- data/docs/zh-CN/RECOMMEND.md +22 -0
- data/docs/zh-CN/RELEASE.md +60 -0
- data/docs/zh-CN/SPEC.md +39 -0
- data/lib/big_keeper/command/feature&hotfix/delete.rb +40 -0
- data/lib/big_keeper/command/feature&hotfix/finish.rb +57 -0
- data/lib/big_keeper/command/feature&hotfix/list.rb +63 -0
- data/lib/big_keeper/command/feature&hotfix/publish.rb +56 -0
- data/lib/big_keeper/command/feature&hotfix/pull.rb +26 -0
- data/lib/big_keeper/command/feature&hotfix/push.rb +27 -0
- data/lib/big_keeper/command/feature&hotfix/rebase.rb +32 -0
- data/lib/big_keeper/command/feature&hotfix/start.rb +94 -0
- data/lib/big_keeper/command/feature&hotfix/switch.rb +48 -0
- data/lib/big_keeper/command/feature&hotfix/update.rb +74 -0
- data/lib/big_keeper/command/feature&hotfix.rb +169 -0
- data/lib/big_keeper/command/image/image.rb +0 -0
- data/lib/big_keeper/command/image.rb +28 -0
- data/lib/big_keeper/command/pod/podfile.rb +69 -0
- data/lib/big_keeper/command/pod.rb +42 -0
- data/lib/big_keeper/command/release/home.rb +91 -0
- data/lib/big_keeper/command/release/module.rb +61 -0
- data/lib/big_keeper/command/release.rb +75 -0
- data/lib/big_keeper/command/spec/add.rb +9 -0
- data/lib/big_keeper/command/spec/analyze.rb +88 -0
- data/lib/big_keeper/command/spec/delete.rb +9 -0
- data/lib/big_keeper/command/spec/list.rb +19 -0
- data/lib/big_keeper/command/spec/search.rb +9 -0
- data/lib/big_keeper/command/spec/sync.rb +12 -0
- data/lib/big_keeper/command/spec.rb +78 -0
- data/lib/big_keeper/dependency/dep_gradle_operator.rb +56 -0
- data/lib/big_keeper/dependency/dep_operator.rb +32 -0
- data/lib/big_keeper/dependency/dep_pod_operator.rb +131 -0
- data/lib/big_keeper/dependency/dep_service.rb +14 -0
- data/lib/big_keeper/dependency/dep_type.rb +33 -0
- data/lib/big_keeper/model/gitflow_type.rb +43 -0
- data/lib/big_keeper/model/library_model.rb +116 -0
- data/lib/big_keeper/model/operate_type.rb +27 -0
- data/lib/big_keeper/model/podfile_model.rb +33 -0
- data/lib/big_keeper/service/git_service.rb +261 -0
- data/lib/big_keeper/service/module_service.rb +161 -0
- data/lib/big_keeper/service/stash_service.rb +58 -0
- data/lib/big_keeper/util/bigkeeper_parser.rb +244 -0
- data/lib/big_keeper/util/cache_operator.rb +149 -0
- data/lib/big_keeper/util/code_operator.rb +37 -0
- data/lib/big_keeper/util/file_operator.rb +33 -0
- data/lib/big_keeper/util/git_operator.rb +226 -0
- data/lib/big_keeper/util/gitflow_operator.rb +51 -0
- data/lib/big_keeper/util/gradle_operator.rb +209 -0
- data/lib/big_keeper/util/info_plist_operator.rb +46 -0
- data/lib/big_keeper/util/leancloud_logger.rb +72 -0
- data/lib/big_keeper/util/list_generator.rb +101 -0
- data/lib/big_keeper/util/logger.rb +46 -0
- data/lib/big_keeper/util/pod_operator.rb +71 -0
- data/lib/big_keeper/util/podfile_detector.rb +137 -0
- data/lib/big_keeper/util/podfile_module.rb +63 -0
- data/lib/big_keeper/util/podfile_operator.rb +117 -0
- data/lib/big_keeper/util/verify_operator.rb +17 -0
- data/lib/big_keeper/util/xcode_operator.rb +15 -0
- data/lib/big_keeper/version.rb +3 -0
- data/lib/big_keeper.rb +71 -0
- data/resources/banner.png +0 -0
- data/resources/command.png +0 -0
- data/resources/keynote/big-keeper-readme-analyze.key +0 -0
- data/resources/keynote/big-keeper-readme-example.key +0 -0
- data/resources/keynote/big-keeper-readme-feature.key +0 -0
- data/resources/keynote/big-keeper-readme-release.key +0 -0
- data/resources/readme/big-keeper-readme.001.png +0 -0
- metadata +345 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require 'big_keeper/util/podfile_operator'
|
3
|
+
require 'big_keeper/util/gitflow_operator'
|
4
|
+
require 'big_keeper/dependency/dep_type'
|
5
|
+
require 'big_keeper/util/info_plist_operator'
|
6
|
+
require 'big_keeper/util/logger'
|
7
|
+
require 'big_keeper/util/xcode_operator'
|
8
|
+
|
9
|
+
module BigKeeper
|
10
|
+
def self.release_home_start(path, version, user)
|
11
|
+
BigkeeperParser.parse("#{path}/Bigkeeper")
|
12
|
+
|
13
|
+
version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
|
14
|
+
modules = BigkeeperParser.module_names
|
15
|
+
|
16
|
+
#stash
|
17
|
+
StashService.new.stash_all(path, GitOperator.new.current_branch(path), user, modules)
|
18
|
+
|
19
|
+
# delete cache
|
20
|
+
CacheOperator.new(path).clean()
|
21
|
+
# cache Podfile
|
22
|
+
CacheOperator.new(path).save('Podfile')
|
23
|
+
|
24
|
+
# check
|
25
|
+
GitOperator.new.check_diff(path, "develop", "master")
|
26
|
+
|
27
|
+
#checkout release branch
|
28
|
+
Logger.highlight(%Q(Start to checkout Branch release/#{version}))
|
29
|
+
if GitOperator.new.current_branch(path) != "release/#{version}"
|
30
|
+
if GitOperator.new.has_branch(path, "release/#{version}")
|
31
|
+
GitOperator.new.checkout(path, "release/#{version}")
|
32
|
+
else
|
33
|
+
GitflowOperator.new.start(path, version, GitflowType::RELEASE)
|
34
|
+
GitOperator.new.push_to_remote(path, "release/#{version}")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Logger.highlight(%Q(Start to release/#{version}))
|
39
|
+
# step 2 replace_modules
|
40
|
+
PodfileOperator.new.replace_all_module_release(path,
|
41
|
+
user,
|
42
|
+
modules,
|
43
|
+
ModuleOperateType::RELEASE)
|
44
|
+
|
45
|
+
# step 3 change Info.plist value
|
46
|
+
InfoPlistOperator.new.change_version_build(path, version)
|
47
|
+
|
48
|
+
GitService.new.verify_push(path, "Change version to #{version}", "release/#{version}", 'Home')
|
49
|
+
DepService.dep_operator(path, user).install(true)
|
50
|
+
XcodeOperator.open_workspace(path)
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.release_home_finish(path, version)
|
54
|
+
BigkeeperParser.parse("#{path}/Bigkeeper")
|
55
|
+
version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
|
56
|
+
Logger.highlight("Start finish release home for #{version}")
|
57
|
+
|
58
|
+
if GitOperator.new.has_branch(path, "release/#{version}")
|
59
|
+
if GitOperator.new.current_branch(path) != "release/#{version}"
|
60
|
+
GitOperator.new.checkout(path, "release/#{version}")
|
61
|
+
end
|
62
|
+
|
63
|
+
GitService.new.verify_push(path, "finish release branch", "release/#{version}", 'Home')
|
64
|
+
|
65
|
+
# master
|
66
|
+
GitOperator.new.checkout(path, "master")
|
67
|
+
GitOperator.new.merge(path, "release/#{version}")
|
68
|
+
GitService.new.verify_push(path, "release V#{version}", "master", 'Home')
|
69
|
+
|
70
|
+
GitOperator.new.tag(path, version)
|
71
|
+
|
72
|
+
# release branch
|
73
|
+
GitOperator.new.checkout(path, "release/#{version}")
|
74
|
+
CacheOperator.new(path).load('Podfile')
|
75
|
+
CacheOperator.new(path).clean()
|
76
|
+
GitOperator.new.commit(path, "reset #{version} Podfile")
|
77
|
+
GitService.new.verify_push(path, "reset #{version} Podfile", "release/#{version}", 'Home')
|
78
|
+
|
79
|
+
# develop
|
80
|
+
GitOperator.new.checkout(path, "develop")
|
81
|
+
GitOperator.new.merge(path, "release/#{version}")
|
82
|
+
GitService.new.verify_push(path, "merge release/#{version} to develop", "develop", 'Home')
|
83
|
+
GitOperator.new.check_diff(path, "develop", "master")
|
84
|
+
|
85
|
+
Logger.highlight("Finish release home for #{version}")
|
86
|
+
else
|
87
|
+
raise Logger.error("There is no release/#{version} branch, please use release home start first.")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require 'big_keeper/util/podfile_operator'
|
3
|
+
require 'big_keeper/util/gitflow_operator'
|
4
|
+
require 'big_keeper/dependency/dep_type'
|
5
|
+
require 'big_keeper/util/info_plist_operator'
|
6
|
+
require 'big_keeper/util/git_operator'
|
7
|
+
require 'big_keeper/util/logger'
|
8
|
+
require 'big_keeper/util/pod_operator'
|
9
|
+
|
10
|
+
module BigKeeper
|
11
|
+
def self.release_module_start(path, version, user, module_name, ignore)
|
12
|
+
BigkeeperParser.parse("#{path}/Bigkeeper")
|
13
|
+
module_path = BigkeeperParser.module_full_path(path, user, module_name)
|
14
|
+
|
15
|
+
# stash
|
16
|
+
StashService.new.stash(module_path, GitOperator.new.current_branch(module_path), module_name)
|
17
|
+
|
18
|
+
#check
|
19
|
+
if ignore != true
|
20
|
+
GitOperator.new.check_merge(module_path, "feature/#{version}")
|
21
|
+
GitOperator.new.check_diff(module_path, "develop", "master")
|
22
|
+
Logger.highlight(%Q(#{module_name} release check finish))
|
23
|
+
end
|
24
|
+
|
25
|
+
# checkout to develop branch
|
26
|
+
Logger.highlight(%Q(Start checkout #{module_name} to Branch develop))
|
27
|
+
GitService.new.verify_checkout_pull(module_path, "develop")
|
28
|
+
|
29
|
+
Logger.highlight(%Q(#{module_name} release start finish))
|
30
|
+
end
|
31
|
+
|
32
|
+
## release finish
|
33
|
+
def self.release_module_finish(path, version, user, module_name, spec)
|
34
|
+
BigkeeperParser.parse("#{path}/Bigkeeper")
|
35
|
+
module_path = BigkeeperParser.module_full_path(path, user, module_name)
|
36
|
+
|
37
|
+
# check commit
|
38
|
+
Logger.error("current branch has unpush files") if GitOperator.new.has_changes(module_path)
|
39
|
+
|
40
|
+
#修改 podspec 文件
|
41
|
+
# TO DO: - advanced to use Regular Expression
|
42
|
+
has_change = PodfileOperator.new.podspec_change(%Q(#{module_path}/#{module_name}.podspec), version, module_name)
|
43
|
+
GitService.new.verify_push(module_path, "Change version number", "develop", "#{module_name}") if has_change == true
|
44
|
+
|
45
|
+
# check out master
|
46
|
+
Logger.highlight("'#{module_name}' checkout branch to master...")
|
47
|
+
GitService.new.verify_checkout_pull(module_path, "master")
|
48
|
+
|
49
|
+
Logger.highlight(%Q(Merge develop to master))
|
50
|
+
# merge develop to master
|
51
|
+
GitOperator.new.merge(module_path, "develop")
|
52
|
+
GitOperator.new.push_to_remote(module_path, "master")
|
53
|
+
|
54
|
+
GitOperator.new.tag(module_path, version)
|
55
|
+
# pod repo push
|
56
|
+
if spec == true
|
57
|
+
PodOperator.pod_repo_push(module_path, module_name, BigkeeperParser.source_spec_path(module_name), version)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'big_keeper/command/release/home'
|
2
|
+
require 'big_keeper/command/release/module'
|
3
|
+
require 'big_keeper/util/leancloud_logger'
|
4
|
+
|
5
|
+
module BigKeeper
|
6
|
+
def self.release_command
|
7
|
+
desc 'Gitflow release operations'
|
8
|
+
command :release do |c|
|
9
|
+
|
10
|
+
c.desc 'Release home project operations'
|
11
|
+
c.command :home do |home|
|
12
|
+
home.desc 'Start release home project'
|
13
|
+
home.command :start do |start|
|
14
|
+
start.action do |global_options, options, args|
|
15
|
+
path = File.expand_path(global_options[:path])
|
16
|
+
version = global_options[:ver]
|
17
|
+
user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
|
18
|
+
LeanCloudLogger.instance.set_command("release/home/start")
|
19
|
+
|
20
|
+
help_now!('user name is required') if user and user.empty?
|
21
|
+
raise Logger.error("release version is required") if version == nil
|
22
|
+
release_home_start(path, version, user)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
home.desc 'Finish release home project'
|
27
|
+
home.command :finish do |finish|
|
28
|
+
finish.action do |global_options, options, args|
|
29
|
+
path = File.expand_path(global_options[:path])
|
30
|
+
version = global_options[:ver]
|
31
|
+
LeanCloudLogger.instance.set_command("release/home/finish")
|
32
|
+
|
33
|
+
raise Logger.error("release version is required") if version == nil
|
34
|
+
release_home_finish(path, version)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
c.desc 'release module'
|
40
|
+
c.switch [:i,:ignore]
|
41
|
+
c.command :module do |m|
|
42
|
+
m.desc 'Start release module project'
|
43
|
+
m.command :start do |start|
|
44
|
+
start.action do |global_options, options, args|
|
45
|
+
path = File.expand_path(global_options[:path])
|
46
|
+
version = global_options[:ver]
|
47
|
+
user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
|
48
|
+
LeanCloudLogger.instance.set_command("release/module/start")
|
49
|
+
|
50
|
+
help_now!('module name is required') if args.length != 1
|
51
|
+
raise Logger.error("release version is required") if version == nil
|
52
|
+
module_name = args[0]
|
53
|
+
release_module_start(path, version, user, module_name, options[:ignore])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
m.desc 'finish release module project'
|
58
|
+
m.switch [:s,:spec]
|
59
|
+
m.command :finish do |finish|
|
60
|
+
finish.action do |global_options, options, args|
|
61
|
+
path = File.expand_path(global_options[:path])
|
62
|
+
version = global_options[:ver]
|
63
|
+
user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
|
64
|
+
LeanCloudLogger.instance.set_command("release/module/finish")
|
65
|
+
|
66
|
+
help_now!('module name is required') if args.length != 1
|
67
|
+
raise Logger.error("release version is required") if version == nil
|
68
|
+
module_name = args[0]
|
69
|
+
release_module_finish(path, version, user, module_name, options[:spec])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'big_keeper/util/bigkeeper_parser'
|
2
|
+
require 'big_keeper/dependency/dep_type'
|
3
|
+
require 'big_keeper/util/logger'
|
4
|
+
require 'big_keeper/model/library_model'
|
5
|
+
|
6
|
+
module BigKeeper
|
7
|
+
def self.spec_analyze(path,is_all,find_module_names)
|
8
|
+
# Parse Bigkeeper file
|
9
|
+
BigkeeperParser.parse("#{path}/Bigkeeper")
|
10
|
+
|
11
|
+
is_default = !is_all&&find_module_names.size==0
|
12
|
+
if is_all && find_module_names.size>0
|
13
|
+
Logger.error("parameter conflict: [--all] | [module_names]")
|
14
|
+
return
|
15
|
+
end
|
16
|
+
Logger.highlight('Start spec analyze...')
|
17
|
+
Logger.default(Time.now.to_s)
|
18
|
+
|
19
|
+
# Parse Bigkeeper file
|
20
|
+
# BigkeeperParser.parse("#{path}/Bigkeeper")
|
21
|
+
# module_names = BigkeeperParser.module_names
|
22
|
+
|
23
|
+
# find modules
|
24
|
+
Logger.highlight('Get all modules...')
|
25
|
+
module_names = []
|
26
|
+
pod_path = path+"/Pods/"
|
27
|
+
dir = Dir.open(pod_path)
|
28
|
+
dir.each do |dir_name|
|
29
|
+
if !dir_name.include?(".") && dir_name != "Headers" && dir_name != "Local Podspecs" && dir_name != "Target Support Files"
|
30
|
+
module_names[module_names.size]=dir_name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
for input_moudle_name in find_module_names do
|
35
|
+
if !module_names.include?(input_moudle_name)
|
36
|
+
Logger.error("["+input_moudle_name+"] not exist.")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# setup modules
|
41
|
+
module_list = []
|
42
|
+
module_keyword_map = Hash.new
|
43
|
+
file_count = 0
|
44
|
+
for module_name in module_names do
|
45
|
+
library = LibraryModel.new(module_name)
|
46
|
+
library.get_all_public_file(path)
|
47
|
+
module_list[module_list.size]=library
|
48
|
+
module_keyword_map[module_name]=library.keyword_list
|
49
|
+
if is_all || find_module_names.include?(library.name)
|
50
|
+
file_count = file_count + library.file_list.size
|
51
|
+
end
|
52
|
+
end
|
53
|
+
# analyze modules spec
|
54
|
+
|
55
|
+
Logger.highlight('Analyze modules...')
|
56
|
+
Logger.default(Time.now.to_s)
|
57
|
+
file_index = 0
|
58
|
+
for library in module_list do
|
59
|
+
if is_all || find_module_names.include?(library.name)
|
60
|
+
Logger.default('Analyzing ' + library.name)
|
61
|
+
file_index = file_index + library.file_list.size
|
62
|
+
library.spec_dependece_library(module_keyword_map.clone)#(Hash.new(module_keyword_map)).to_hash)
|
63
|
+
progress = (file_index*100.0)/file_count
|
64
|
+
progress = format("%.02f", progress).to_f
|
65
|
+
Logger.default('progress >>>> ' + String(progress) + '% [' + library.name + ' done] ')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
Logger.highlight('Analyze complete.')
|
69
|
+
Logger.default(Time.now.to_s)
|
70
|
+
|
71
|
+
# log spec info
|
72
|
+
for library in module_list do
|
73
|
+
if is_all || find_module_names.include?(library.name)
|
74
|
+
Logger.highlight("\n-"+library.name+":")
|
75
|
+
for spec_library in library.spec_library do
|
76
|
+
puts " -"+spec_library
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# save cache to file
|
82
|
+
if is_all
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module BigKeeper
|
5
|
+
def self.spec_list(path, user, options)
|
6
|
+
BigkeeperParser.parse("#{path}/Bigkeeper")
|
7
|
+
|
8
|
+
module_dic = BigkeeperParser.parse_modules
|
9
|
+
module_list = Array.new
|
10
|
+
module_dic.keys.each do | key |
|
11
|
+
dic = Hash["module_name" => key,
|
12
|
+
"git" => module_dic[key][:git],
|
13
|
+
"pulls" => module_dic[key][:pulls]]
|
14
|
+
module_list << dic
|
15
|
+
end
|
16
|
+
json = JSON.pretty_generate(module_list)
|
17
|
+
puts json
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'big_keeper/util/bigkeeper_parser'
|
2
|
+
require 'big_keeper/dependency/dep_type'
|
3
|
+
require 'big_keeper/util/logger'
|
4
|
+
|
5
|
+
module BigKeeper
|
6
|
+
def self.spec_sync(path, version, user, module_name)
|
7
|
+
# Parse Bigkeeper file
|
8
|
+
BigkeeperParser.parse("#{path}/Bigkeeper")
|
9
|
+
|
10
|
+
Logger.default('Coming soon.')
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'big_keeper/command/spec/analyze'
|
2
|
+
require 'big_keeper/command/spec/list'
|
3
|
+
require 'big_keeper/command/spec/add'
|
4
|
+
require 'big_keeper/command/spec/delete'
|
5
|
+
require 'big_keeper/command/spec/search'
|
6
|
+
require 'big_keeper/command/spec/sync'
|
7
|
+
require 'big_keeper/util/leancloud_logger'
|
8
|
+
|
9
|
+
module BigKeeper
|
10
|
+
|
11
|
+
def self.spec_command
|
12
|
+
desc 'Spec operations'
|
13
|
+
|
14
|
+
command :spec do |spec|
|
15
|
+
spec.switch [:a,:all]
|
16
|
+
spec.desc 'Analyze spec dependency infomation.'
|
17
|
+
spec.command :analyze do |analyze|
|
18
|
+
analyze.action do |global_options, options, args|
|
19
|
+
LeanCloudLogger.instance.set_command("spec/analyze")
|
20
|
+
|
21
|
+
path = File.expand_path(global_options[:path])
|
22
|
+
is_all = options[:all]
|
23
|
+
module_names = args
|
24
|
+
spec_analyze(path, is_all, module_names)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
spec.desc 'List all the specs.'
|
29
|
+
spec.command :list do | list |
|
30
|
+
list.action do |global_options, options, args|
|
31
|
+
LeanCloudLogger.instance.set_command("spec/list")
|
32
|
+
|
33
|
+
path = File.expand_path(global_options[:path])
|
34
|
+
version = global_options[:ver]
|
35
|
+
user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
|
36
|
+
|
37
|
+
spec_list(path, user, options)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
spec.desc 'Sync Module dependency from Home.'
|
42
|
+
spec.command :sync do | sync|
|
43
|
+
sync.action do |global_options, options, args|
|
44
|
+
LeanCloudLogger.instance.set_command("spec/sync")
|
45
|
+
|
46
|
+
path = File.expand_path(global_options[:path])
|
47
|
+
version = global_options[:ver]
|
48
|
+
user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
|
49
|
+
module_name = args
|
50
|
+
|
51
|
+
spec_sync(path, version, user, module_name)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
spec.desc 'Add a spec (Coming soon).'
|
56
|
+
spec.command :add do |add|
|
57
|
+
add.action do
|
58
|
+
spec_add()
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
spec.desc 'Delete a spec (Coming soon).'
|
63
|
+
spec.command :delete do |delete|
|
64
|
+
delete.action do
|
65
|
+
spec_delete()
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
spec.desc 'Search a spec with name (Coming soon).'
|
70
|
+
spec.command :search do |search|
|
71
|
+
search.action do
|
72
|
+
spec_search()
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'big_keeper/dependency/dep_operator'
|
2
|
+
require 'big_keeper/util/gradle_operator'
|
3
|
+
|
4
|
+
module BigKeeper
|
5
|
+
# Operator for podfile
|
6
|
+
class DepGradleOperator < DepOperator
|
7
|
+
|
8
|
+
def backup
|
9
|
+
GradleOperator.new(@path).backup
|
10
|
+
modules = ModuleCacheOperator.new(@path).all_path_modules
|
11
|
+
modules.each do |module_name|
|
12
|
+
module_full_path = BigkeeperParser.module_full_path(@path, @user, module_name)
|
13
|
+
GradleOperator.new(module_full_path).backup
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def recover
|
18
|
+
GradleOperator.new(@path).recover(true, false)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update_module_config(module_name, module_operate_type)
|
22
|
+
module_full_path = BigkeeperParser.module_full_path(@path, @user, module_name)
|
23
|
+
|
24
|
+
# get modules
|
25
|
+
if ModuleOperateType::ADD == module_operate_type
|
26
|
+
GradleOperator.new(module_full_path).backup
|
27
|
+
|
28
|
+
add_modules = ModuleCacheOperator.new(@path).add_path_modules
|
29
|
+
GradleOperator.new(module_full_path).update_build_config(module_name, add_modules, ModuleOperateType::ADD)
|
30
|
+
GradleOperator.new(module_full_path).update_settings_config(module_name, add_modules, ModuleOperateType::ADD, @user)
|
31
|
+
|
32
|
+
del_modules = ModuleCacheOperator.new(@path).del_path_modules
|
33
|
+
GradleOperator.new(module_full_path).update_build_config(module_name, del_modules, ModuleOperateType::DELETE)
|
34
|
+
GradleOperator.new(module_full_path).update_settings_config(module_name, del_modules, ModuleOperateType::DELETE, @user)
|
35
|
+
elsif ModuleOperateType::DELETE == module_operate_type
|
36
|
+
GradleOperator.new(module_full_path).recover(true, true)
|
37
|
+
elsif ModuleOperateType::FINISH == module_operate_type
|
38
|
+
modules = ModuleCacheOperator.new(@path).all_path_modules
|
39
|
+
GradleOperator.new(module_full_path).update_build_config(module_name, modules, ModuleOperateType::FINISH)
|
40
|
+
elsif ModuleOperateType::PUBLISH == module_operate_type
|
41
|
+
modules = ModuleCacheOperator.new(@path).all_git_modules
|
42
|
+
GradleOperator.new(module_full_path).update_build_config(module_name, modules, ModuleOperateType::PUBLISH)
|
43
|
+
GradleOperator.new(module_full_path).recover(true, false)
|
44
|
+
end
|
45
|
+
|
46
|
+
GradleOperator.new(@path).update_build_config('', [module_name], module_operate_type)
|
47
|
+
GradleOperator.new(@path).update_settings_config('', [module_name], module_operate_type, @user)
|
48
|
+
end
|
49
|
+
|
50
|
+
def install(should_update)
|
51
|
+
end
|
52
|
+
|
53
|
+
def open
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module BigKeeper
|
2
|
+
# Operator for podfile
|
3
|
+
class DepOperator
|
4
|
+
@path
|
5
|
+
@user
|
6
|
+
|
7
|
+
def initialize(path, user)
|
8
|
+
@path = path
|
9
|
+
@user = user
|
10
|
+
end
|
11
|
+
|
12
|
+
def backup
|
13
|
+
raise "You should override this method in subclass."
|
14
|
+
end
|
15
|
+
|
16
|
+
def recover
|
17
|
+
raise "You should override this method in subclass."
|
18
|
+
end
|
19
|
+
|
20
|
+
def update_module_config(module_name, module_operate_type)
|
21
|
+
raise "You should override this method in subclass."
|
22
|
+
end
|
23
|
+
|
24
|
+
def install(should_update)
|
25
|
+
raise "You should override this method in subclass."
|
26
|
+
end
|
27
|
+
|
28
|
+
def open
|
29
|
+
raise "You should override this method in subclass."
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'big_keeper/dependency/dep_operator'
|
2
|
+
|
3
|
+
require 'big_keeper/util/pod_operator'
|
4
|
+
require 'big_keeper/util/xcode_operator'
|
5
|
+
require 'big_keeper/util/cache_operator'
|
6
|
+
require 'big_keeper/util/file_operator'
|
7
|
+
|
8
|
+
module BigKeeper
|
9
|
+
# Operator for podfile
|
10
|
+
class DepPodOperator < DepOperator
|
11
|
+
def backup
|
12
|
+
CacheOperator.new(@path).save('Podfile')
|
13
|
+
end
|
14
|
+
|
15
|
+
def recover
|
16
|
+
cache_operator = CacheOperator.new(@path)
|
17
|
+
cache_operator.load('Podfile')
|
18
|
+
cache_operator.clean
|
19
|
+
end
|
20
|
+
|
21
|
+
def update_module_config(module_name, module_operate_type)
|
22
|
+
file = "#{@path}/Podfile"
|
23
|
+
temp_file = Tempfile.new('.Podfile.tmp')
|
24
|
+
|
25
|
+
begin
|
26
|
+
File.open(file, 'r') do |file|
|
27
|
+
file.each_line do |line|
|
28
|
+
temp_file.puts generate_module_config(line, module_name, module_operate_type)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
temp_file.close
|
32
|
+
FileUtils.mv(temp_file.path, file)
|
33
|
+
ensure
|
34
|
+
temp_file.close
|
35
|
+
temp_file.unlink
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def install(should_update)
|
40
|
+
PodOperator.pod_install(@path, should_update)
|
41
|
+
end
|
42
|
+
|
43
|
+
def open
|
44
|
+
XcodeOperator.open_workspace(@path)
|
45
|
+
end
|
46
|
+
|
47
|
+
def generate_module_config(line, module_name, module_operate_type)
|
48
|
+
line.sub(/(\s*)pod(\s*)('|")#{module_name}('|")([\s\S]*)/){
|
49
|
+
if ModuleOperateType::ADD == module_operate_type
|
50
|
+
module_path = BigkeeperParser.module_path(@user, module_name)
|
51
|
+
"#{$1}pod '#{module_name}', :path => '#{module_path}'"
|
52
|
+
elsif ModuleOperateType::DELETE == module_operate_type
|
53
|
+
origin_config_of_module = origin_config_of_module(module_name)
|
54
|
+
if origin_config_of_module.empty?
|
55
|
+
line
|
56
|
+
else
|
57
|
+
origin_config_of_module
|
58
|
+
end
|
59
|
+
elsif ModuleOperateType::FINISH == module_operate_type
|
60
|
+
module_git = BigkeeperParser.module_git(module_name)
|
61
|
+
#branch_name = GitOperator.new.current_branch(@path)
|
62
|
+
branch_name = ModuleCacheOperator.new(@path).branch_name
|
63
|
+
"#{$1}pod '#{module_name}', :git => '#{module_git}', :branch => '#{branch_name}'"
|
64
|
+
elsif ModuleOperateType::PUBLISH == module_operate_type
|
65
|
+
module_git = BigkeeperParser.module_git(module_name)
|
66
|
+
branch_name = GitOperator.new.current_branch(@path)
|
67
|
+
base_branch_name = GitflowType.base_branch(GitService.new.current_branch_type(@path))
|
68
|
+
"#{$1}pod '#{module_name}', :git => '#{module_git}', :branch => '#{base_branch_name}'"
|
69
|
+
elsif ModuleOperateType::RELEASE == module_operate_type
|
70
|
+
module_git = BigkeeperParser.module_git(module_name)
|
71
|
+
lastest_tag, is_spec = find_lastest_tag(module_name)
|
72
|
+
if is_spec == true
|
73
|
+
Logger.default("#{module_name} lastest tag is #{lastest_tag}, this tag has published.")
|
74
|
+
"#{$1}pod '#{module_name}', '#{lastest_tag}'"
|
75
|
+
else
|
76
|
+
Logger.default("#{module_name} lastest tag is #{lastest_tag}, this tag not publish.")
|
77
|
+
"#{$1}pod '#{module_name}', :git => '#{module_git}', :tag => '#{lastest_tag}'"
|
78
|
+
end
|
79
|
+
else
|
80
|
+
line
|
81
|
+
end
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
def origin_config_of_module(module_name)
|
86
|
+
origin_config = ''
|
87
|
+
|
88
|
+
File.open("#{@path}/.bigkeeper/Podfile", 'r') do |file|
|
89
|
+
file.each_line do |line|
|
90
|
+
if line =~ /(\s*)pod(\s*)('|")#{module_name}('|")([\s\S]*)/
|
91
|
+
origin_config = line
|
92
|
+
break
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
origin_config.chop
|
98
|
+
end
|
99
|
+
|
100
|
+
def find_lastest_tag(module_name)
|
101
|
+
username = FileOperator.new.current_username
|
102
|
+
tags_repos_pwd = Array.new
|
103
|
+
tags_spec_list = Array.new
|
104
|
+
tags_module_list = Array.new
|
105
|
+
|
106
|
+
IO.popen("find /Users/#{username}/.cocoapods/repos -type d -name #{module_name}") do |io|
|
107
|
+
io.each do |line|
|
108
|
+
tags_repos_pwd.push(line) if line.include? "#{module_name}"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
for pwd in tags_repos_pwd do
|
112
|
+
path = pwd.chomp
|
113
|
+
IO.popen("cd '#{path}'; ls") do |io|
|
114
|
+
io.each do |line|
|
115
|
+
tags_spec_list.push(line)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
tags_module_list = GitOperator.new.tag_list(BigkeeperParser.module_full_path(@path, @user, module_name))
|
121
|
+
last_tag = tags_module_list[tags_module_list.length - 1]
|
122
|
+
if tags_module_list.include?(last_tag) && tags_spec_list.include?(last_tag)
|
123
|
+
return [last_tag.chomp, true]
|
124
|
+
else
|
125
|
+
return [last_tag.chomp, false]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
private :generate_module_config, :origin_config_of_module, :find_lastest_tag
|
130
|
+
end
|
131
|
+
end
|