kookeeper 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE.md +20 -0
  3. data/.gitignore +50 -0
  4. data/.travis.yml +19 -0
  5. data/CODE_OF_CONDUCT.md +46 -0
  6. data/CONTRIBUTING.md +70 -0
  7. data/Gemfile +10 -0
  8. data/Gemfile.lock +125 -0
  9. data/LICENSE +21 -0
  10. data/README.md +113 -0
  11. data/Rakefile +2 -0
  12. data/big_keeper.gemspec +49 -0
  13. data/bin/big +14 -0
  14. data/bin/setup +8 -0
  15. data/docs/en-US/FEATURE.md +0 -0
  16. data/docs/en-US/README.md +54 -0
  17. data/docs/zh-CN/BIGKEEPER_FILE.md +84 -0
  18. data/docs/zh-CN/FEATURE&HOTFIX.md +88 -0
  19. data/docs/zh-CN/IMAGE.md +0 -0
  20. data/docs/zh-CN/PODFILE.md +43 -0
  21. data/docs/zh-CN/README.md +113 -0
  22. data/docs/zh-CN/RECOMMEND.md +22 -0
  23. data/docs/zh-CN/RELEASE.md +60 -0
  24. data/docs/zh-CN/SPEC.md +39 -0
  25. data/lib/big_keeper/command/client.rb +50 -0
  26. data/lib/big_keeper/command/feature&hotfix/delete.rb +40 -0
  27. data/lib/big_keeper/command/feature&hotfix/finish.rb +54 -0
  28. data/lib/big_keeper/command/feature&hotfix/list.rb +63 -0
  29. data/lib/big_keeper/command/feature&hotfix/publish.rb +56 -0
  30. data/lib/big_keeper/command/feature&hotfix/pull.rb +26 -0
  31. data/lib/big_keeper/command/feature&hotfix/push.rb +27 -0
  32. data/lib/big_keeper/command/feature&hotfix/rebase.rb +32 -0
  33. data/lib/big_keeper/command/feature&hotfix/start.rb +74 -0
  34. data/lib/big_keeper/command/feature&hotfix/switch.rb +46 -0
  35. data/lib/big_keeper/command/feature&hotfix/update.rb +66 -0
  36. data/lib/big_keeper/command/feature&hotfix.rb +167 -0
  37. data/lib/big_keeper/command/image/image.rb +0 -0
  38. data/lib/big_keeper/command/image.rb +28 -0
  39. data/lib/big_keeper/command/init.rb +36 -0
  40. data/lib/big_keeper/command/pod/podfile.rb +72 -0
  41. data/lib/big_keeper/command/pod.rb +55 -0
  42. data/lib/big_keeper/command/release/finish.rb +36 -0
  43. data/lib/big_keeper/command/release/home.rb +92 -0
  44. data/lib/big_keeper/command/release/module.rb +65 -0
  45. data/lib/big_keeper/command/release/publish.rb +4 -0
  46. data/lib/big_keeper/command/release/start.rb +78 -0
  47. data/lib/big_keeper/command/release.rb +100 -0
  48. data/lib/big_keeper/command/spec/add.rb +9 -0
  49. data/lib/big_keeper/command/spec/analyze.rb +88 -0
  50. data/lib/big_keeper/command/spec/delete.rb +9 -0
  51. data/lib/big_keeper/command/spec/list.rb +19 -0
  52. data/lib/big_keeper/command/spec/search.rb +9 -0
  53. data/lib/big_keeper/command/spec/sync.rb +12 -0
  54. data/lib/big_keeper/command/spec.rb +78 -0
  55. data/lib/big_keeper/dependency/dep_gradle_operator.rb +74 -0
  56. data/lib/big_keeper/dependency/dep_operator.rb +48 -0
  57. data/lib/big_keeper/dependency/dep_pod_operator.rb +130 -0
  58. data/lib/big_keeper/dependency/dep_service.rb +14 -0
  59. data/lib/big_keeper/dependency/dep_type.rb +33 -0
  60. data/lib/big_keeper/model/gitflow_type.rb +43 -0
  61. data/lib/big_keeper/model/library_model.rb +116 -0
  62. data/lib/big_keeper/model/operate_type.rb +30 -0
  63. data/lib/big_keeper/model/podfile_model.rb +33 -0
  64. data/lib/big_keeper/service/git_service.rb +211 -0
  65. data/lib/big_keeper/service/module_service.rb +224 -0
  66. data/lib/big_keeper/service/stash_service.rb +45 -0
  67. data/lib/big_keeper/util/bigkeeper_parser.rb +260 -0
  68. data/lib/big_keeper/util/cache_operator.rb +118 -0
  69. data/lib/big_keeper/util/code_operator.rb +37 -0
  70. data/lib/big_keeper/util/command_line_util.rb +9 -0
  71. data/lib/big_keeper/util/file_operator.rb +33 -0
  72. data/lib/big_keeper/util/git_operator.rb +242 -0
  73. data/lib/big_keeper/util/gitflow_operator.rb +51 -0
  74. data/lib/big_keeper/util/gradle_content_generator.rb +26 -0
  75. data/lib/big_keeper/util/gradle_file_operator.rb +339 -0
  76. data/lib/big_keeper/util/gradle_module_operator.rb +70 -0
  77. data/lib/big_keeper/util/info_plist_operator.rb +46 -0
  78. data/lib/big_keeper/util/leancloud_logger.rb +84 -0
  79. data/lib/big_keeper/util/list_generator.rb +101 -0
  80. data/lib/big_keeper/util/lockfile_parser.rb +143 -0
  81. data/lib/big_keeper/util/logger.rb +47 -0
  82. data/lib/big_keeper/util/pod_operator.rb +70 -0
  83. data/lib/big_keeper/util/podfile_detector.rb +102 -0
  84. data/lib/big_keeper/util/podfile_module.rb +63 -0
  85. data/lib/big_keeper/util/podfile_operator.rb +125 -0
  86. data/lib/big_keeper/util/verify_operator.rb +17 -0
  87. data/lib/big_keeper/util/version_config_operator.rb +29 -0
  88. data/lib/big_keeper/util/xcode_operator.rb +15 -0
  89. data/lib/big_keeper/version.rb +3 -0
  90. data/lib/big_keeper.rb +81 -0
  91. data/resources/banner.png +0 -0
  92. data/resources/command.png +0 -0
  93. data/resources/keynote/big-keeper-readme-analyze.key +0 -0
  94. data/resources/keynote/big-keeper-readme-example.key +0 -0
  95. data/resources/keynote/big-keeper-readme-feature.key +0 -0
  96. data/resources/keynote/big-keeper-readme-release.key +0 -0
  97. data/resources/readme/big-keeper-readme.001.png +0 -0
  98. data/resources/template/Bigkeeper +23 -0
  99. metadata +354 -0
@@ -0,0 +1,55 @@
1
+ require 'big_keeper/command/pod/podfile'
2
+ require 'big_keeper/util/leancloud_logger'
3
+
4
+ module BigKeeper
5
+
6
+ def self.pod_command
7
+ desc 'Podfile operation'
8
+ command :podfile do |podfile|
9
+ podfile.desc 'Podfile'
10
+
11
+ podfile.desc 'Detect podname should be locked.'
12
+ podfile.command :detect do |detect|
13
+ detect.action do |global_options, options, args|
14
+ LeanCloudLogger.instance.set_command("podfile/detect")
15
+
16
+ path = File.expand_path(global_options[:path])
17
+ podfile_detect(path)
18
+ end
19
+ end
20
+
21
+ podfile.desc 'Lock podname should be locked.'
22
+ podfile.command :lock do |lock|
23
+ lock.desc 'Lock pods accouding to Podfile.'
24
+ lock.command :module do |m|
25
+ m.action do |global_options, options, args|
26
+ LeanCloudLogger.instance.set_command("podfile/lock/module")
27
+
28
+ path = File.expand_path(global_options[:path])
29
+ podfile_lock(path, false)
30
+ end
31
+ end
32
+ lock.desc 'Lock pods accouding to Podfile.lock.'
33
+ lock.command :submodule do |s|
34
+ s.action do |global_options, options, args|
35
+ LeanCloudLogger.instance.set_command("podfile/lock/submodule")
36
+
37
+ path = File.expand_path(global_options[:path])
38
+ podfile_lock(path, true)
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ podfile.desc 'Update modules should be upgrade.'
45
+ podfile.command :update do |update|
46
+ update.action do |global_options, options, args|
47
+ LeanCloudLogger.instance.set_command("podfile/update")
48
+
49
+ path = File.expand_path(global_options[:path])
50
+ podfile_modules_update(path)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,36 @@
1
+ module BigKeeper
2
+ def self.release_finish(path, version, user, modules)
3
+ BigkeeperParser.parse("#{path}/Bigkeeper")
4
+ version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
5
+ modules = release_check_changed_modules(path, user) if (modules.nil? || modules.empty?)
6
+
7
+ if modules.nil? || modules.empty?
8
+ Logger.error('no module need to release')
9
+ end
10
+ if !CommandLineUtil.double_check("module #{modules} will changed version to #{version}, are you sure?")
11
+ Logger.error('release finish interrupt')
12
+ end
13
+ #stash home
14
+ StashService.new.stash(path, GitOperator.new.current_branch(path), 'home')
15
+ # delete cache
16
+ CacheOperator.new(path).clean()
17
+ # checkout develop
18
+ GitService.new.verify_checkout_pull(path, 'develop')
19
+
20
+ modules.each do |module_name|
21
+ Logger.highlight("release start module #{module_name}")
22
+ ModuleService.new.release_finish(path, user, modules, module_name, version)
23
+ end
24
+
25
+ #release home
26
+ DepService.dep_operator(path, user).release_home_finish(modules, version)
27
+
28
+ # Push home changes to remote
29
+ Logger.highlight("Push branch 'develop' for 'Home'...")
30
+ GitService.new.verify_push(
31
+ path,
32
+ "release finish for #{version}",
33
+ 'develop',
34
+ 'Home')
35
+ end
36
+ end
@@ -0,0 +1,92 @@
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
+ require 'big_keeper/model/operate_type'
9
+
10
+ module BigKeeper
11
+ def self.release_home_start(path, version, user)
12
+ BigkeeperParser.parse("#{path}/Bigkeeper")
13
+
14
+ version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
15
+ modules = BigkeeperParser.module_names
16
+
17
+ #stash
18
+ StashService.new.stash_all(path, GitOperator.new.current_branch(path), user, modules)
19
+
20
+ # delete cache
21
+ CacheOperator.new(path).clean()
22
+ # cache Podfile
23
+ CacheOperator.new(path).save('Podfile')
24
+
25
+ # check
26
+ GitOperator.new.check_diff(path, "develop", "master")
27
+
28
+ #checkout release branch
29
+ Logger.highlight(%Q(Start to checkout Branch release/#{version}))
30
+ if GitOperator.new.current_branch(path) != "release/#{version}"
31
+ if GitOperator.new.has_branch(path, "release/#{version}")
32
+ GitOperator.new.checkout(path, "release/#{version}")
33
+ else
34
+ GitflowOperator.new.start(path, version, GitflowType::RELEASE)
35
+ GitOperator.new.push_to_remote(path, "release/#{version}")
36
+ end
37
+ end
38
+
39
+ Logger.highlight(%Q(Start to release/#{version}))
40
+ # step 2 replace_modules
41
+ PodfileOperator.new.replace_all_module_release(path,
42
+ user,
43
+ modules,
44
+ ModuleOperateType::RELEASE)
45
+
46
+ # step 3 change Info.plist value
47
+ InfoPlistOperator.new.change_version_build(path, version)
48
+
49
+ GitService.new.verify_push(path, "Change version to #{version}", "release/#{version}", 'Home')
50
+ DepService.dep_operator(path, user).install(modules, OperateType::RELEASE, true)
51
+ XcodeOperator.open_workspace(path)
52
+ end
53
+
54
+ def self.release_home_finish(path, version)
55
+ BigkeeperParser.parse("#{path}/Bigkeeper")
56
+ version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
57
+ Logger.highlight("Start finish release home for #{version}")
58
+
59
+ if GitOperator.new.has_branch(path, "release/#{version}")
60
+ if GitOperator.new.current_branch(path) != "release/#{version}"
61
+ GitOperator.new.checkout(path, "release/#{version}")
62
+ end
63
+
64
+ GitService.new.verify_push(path, "finish release branch", "release/#{version}", 'Home')
65
+
66
+ # master
67
+ GitOperator.new.checkout(path, "master")
68
+ GitOperator.new.merge(path, "release/#{version}")
69
+ GitService.new.verify_push(path, "release V#{version}", "master", 'Home')
70
+
71
+ GitOperator.new.tag(path, version)
72
+
73
+ # release branch
74
+ GitOperator.new.checkout(path, "release/#{version}")
75
+ CacheOperator.new(path).load('Podfile')
76
+ CacheOperator.new(path).clean()
77
+ GitOperator.new.commit(path, "reset #{version} Podfile")
78
+ GitService.new.verify_push(path, "reset #{version} Podfile", "release/#{version}", 'Home')
79
+
80
+ # develop
81
+ GitOperator.new.checkout(path, "develop")
82
+ GitOperator.new.merge(path, "release/#{version}")
83
+ GitService.new.verify_push(path, "merge release/#{version} to develop", "develop", 'Home')
84
+ GitOperator.new.check_diff(path, "develop", "master")
85
+
86
+ Logger.highlight("Finish release home for #{version}")
87
+ else
88
+ raise Logger.error("There is no release/#{version} branch, please use release home start first.")
89
+ end
90
+ end
91
+
92
+ end
@@ -0,0 +1,65 @@
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
+
14
+ version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
15
+ module_path = BigkeeperParser.module_full_path(path, user, module_name)
16
+
17
+ # stash
18
+ StashService.new.stash(module_path, GitOperator.new.current_branch(module_path), module_name)
19
+
20
+ #check
21
+ if ignore != true
22
+ GitOperator.new.check_merge(module_path, "feature/#{version}")
23
+ GitOperator.new.check_diff(module_path, "develop", "master")
24
+ Logger.highlight(%Q(#{module_name} release check finish))
25
+ end
26
+
27
+ # checkout to develop branch
28
+ Logger.highlight(%Q(Start checkout #{module_name} to Branch develop))
29
+ GitService.new.verify_checkout_pull(module_path, "develop")
30
+
31
+ Logger.highlight(%Q(#{module_name} release start finish))
32
+ end
33
+
34
+ ## release finish
35
+ def self.release_module_finish(path, version, user, module_name, spec)
36
+ BigkeeperParser.parse("#{path}/Bigkeeper")
37
+
38
+ version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
39
+ module_path = BigkeeperParser.module_full_path(path, user, module_name)
40
+
41
+ # check commit
42
+ Logger.error("current branch has unpush files") if GitOperator.new.has_changes(module_path)
43
+
44
+ #修改 podspec 文件
45
+ # TO DO: - advanced to use Regular Expression
46
+ has_change = PodfileOperator.new.podspec_change(%Q(#{module_path}/#{module_name}.podspec), version, module_name)
47
+ GitService.new.verify_push(module_path, "Change version number", "develop", "#{module_name}") if has_change == true
48
+
49
+ # check out master
50
+ Logger.highlight("'#{module_name}' checkout branch to master...")
51
+ GitService.new.verify_checkout_pull(module_path, "master")
52
+
53
+ Logger.highlight(%Q(Merge develop to master))
54
+ # merge develop to master
55
+ GitOperator.new.merge(module_path, "develop")
56
+ GitOperator.new.push_to_remote(module_path, "master")
57
+
58
+ GitOperator.new.tag(module_path, version)
59
+ # pod repo push
60
+ if spec == true
61
+ PodOperator.pod_repo_push(module_path, module_name, BigkeeperParser.source_spec_path(module_name), version)
62
+ end
63
+ end
64
+
65
+ end
@@ -0,0 +1,4 @@
1
+ module BigKeeper
2
+ def self.publish(path, version, user)
3
+ end
4
+ end
@@ -0,0 +1,78 @@
1
+ module BigKeeper
2
+ def self.release_start(path, version, user, modules)
3
+ BigkeeperParser.parse("#{path}/Bigkeeper")
4
+ version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
5
+ modules = release_check_changed_modules(path, user) if (modules.nil? || modules.empty?)
6
+
7
+ if modules.nil? || modules.empty?
8
+ Logger.error('no module need to release')
9
+ end
10
+
11
+ if !CommandLineUtil.double_check("module #{modules} will changed version to #{version}-SNAPSHOT, are you sure?")
12
+ Logger.error('release start interrupt')
13
+ end
14
+
15
+ #stash home
16
+ StashService.new.stash(path, GitOperator.new.current_branch(path), 'home')
17
+ # delete cache
18
+ CacheOperator.new(path).clean()
19
+ # checkout develop
20
+ GitService.new.verify_checkout_pull(path, 'develop')
21
+
22
+ modules.each do |module_name|
23
+ Logger.highlight("release start module #{module_name}")
24
+ ModuleService.new.release_start(path, user, modules, module_name, version)
25
+ end
26
+
27
+ #release home
28
+ DepService.dep_operator(path, user).release_home_start(modules, version)
29
+
30
+ # Push home changes to remote
31
+ Logger.highlight("Push branch 'develop' for 'Home'...")
32
+ GitService.new.verify_push(
33
+ path,
34
+ "release start for #{version}",
35
+ 'develop',
36
+ 'Home')
37
+ end
38
+
39
+ def self.release_finish(path, version, user, modules)
40
+ BigkeeperParser.parse("#{path}/Bigkeeper")
41
+ version = BigkeeperParser.version if version == 'Version in Bigkeeper file'
42
+
43
+ #stash home
44
+ StashService.new.stash(path, GitOperator.new.current_branch(path), 'home')
45
+ # delete cache
46
+ CacheOperator.new(path).clean()
47
+ # checkout develop
48
+ GitService.new.verify_checkout_pull(path, 'develop')
49
+
50
+ modules.each do |module_name|
51
+ Logger.highlight("release start module #{module_name}")
52
+ ModuleService.new.release_finish(path, user, modules, module_name, version)
53
+ end
54
+
55
+ #release home
56
+ DepService.dep_operator(path, user).release_home_finish(modules, version)
57
+
58
+ # Push home changes to remote
59
+ Logger.highlight("Push branch 'develop' for 'Home'...")
60
+ GitService.new.verify_push(
61
+ path,
62
+ "release finish for #{version}",
63
+ 'develop',
64
+ 'Home')
65
+ end
66
+
67
+ def self.release_check_changed_modules(path, user)
68
+ changed_modules = []
69
+ BigkeeperParser.parse("#{path}/Bigkeeper")
70
+ allModules = BigkeeperParser.module_names
71
+ allModules.each do |module_name|
72
+ if ModuleService.new.release_check_changed(path, user, module_name)
73
+ changed_modules << module_name
74
+ end
75
+ end
76
+ changed_modules
77
+ end
78
+ end
@@ -0,0 +1,100 @@
1
+ require 'big_keeper/command/release/home'
2
+ require 'big_keeper/command/release/module'
3
+ require 'big_keeper/util/leancloud_logger'
4
+ require 'big_keeper/command/release/start'
5
+ require 'big_keeper/command/release/finish'
6
+ require 'big_keeper/util/command_line_util'
7
+
8
+ module BigKeeper
9
+ def self.release_command
10
+ desc 'Gitflow release operations'
11
+ command :release do |c|
12
+
13
+ c.desc 'release project start'
14
+ c.command :start do |start|
15
+ start.action do |global_options, options, args|
16
+ path = File.expand_path(global_options[:path])
17
+ version = global_options[:ver]
18
+ user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
19
+ modules = args[(0...args.length)] if args.length > 0
20
+ release_start(path, version, user, modules)
21
+ end
22
+ end
23
+
24
+ c.desc 'release project finish'
25
+ c.command :finish do |finish|
26
+ finish.action do |global_options, options, args|
27
+ path = File.expand_path(global_options[:path])
28
+ version = global_options[:ver]
29
+ user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
30
+ modules = args[(0...args.length)] if args.length > 0
31
+ release_finish(path, version, user, modules)
32
+ end
33
+ end
34
+
35
+ c.desc 'Release home project operations'
36
+ c.command :home do |home|
37
+ home.desc 'Start release home project'
38
+ home.command :start do |start|
39
+ start.action do |global_options, options, args|
40
+ path = File.expand_path(global_options[:path])
41
+ version = global_options[:ver]
42
+ user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
43
+ LeanCloudLogger.instance.set_command("release/home/start")
44
+
45
+ help_now!('user name is required') if user and user.empty?
46
+ raise Logger.error("release version is required") if version == nil
47
+ release_home_start(path, version, user)
48
+ end
49
+ end
50
+
51
+ home.desc 'Finish release home project'
52
+ home.command :finish do |finish|
53
+ finish.action do |global_options, options, args|
54
+ path = File.expand_path(global_options[:path])
55
+ version = global_options[:ver]
56
+ LeanCloudLogger.instance.set_command("release/home/finish")
57
+
58
+ raise Logger.error("release version is required") if version == nil
59
+ release_home_finish(path, version)
60
+ end
61
+ end
62
+ end
63
+
64
+ c.desc 'release module'
65
+ c.switch [:i,:ignore]
66
+ c.command :module do |m|
67
+ m.desc 'Start release module project'
68
+ m.command :start do |start|
69
+ start.action do |global_options, options, args|
70
+ path = File.expand_path(global_options[:path])
71
+ version = global_options[:ver]
72
+ user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
73
+ LeanCloudLogger.instance.set_command("release/module/start")
74
+
75
+ help_now!('module name is required') if args.length != 1
76
+ raise Logger.error("release version is required") if version == nil
77
+ module_name = args[0]
78
+ release_module_start(path, version, user, module_name, options[:ignore])
79
+ end
80
+ end
81
+
82
+ m.desc 'finish release module project'
83
+ m.switch [:s,:spec]
84
+ m.command :finish do |finish|
85
+ finish.action do |global_options, options, args|
86
+ path = File.expand_path(global_options[:path])
87
+ version = global_options[:ver]
88
+ user = global_options[:user].gsub(/[^0-9A-Za-z]/, '').downcase
89
+ LeanCloudLogger.instance.set_command("release/module/finish")
90
+
91
+ help_now!('module name is required') if args.length != 1
92
+ raise Logger.error("release version is required") if version == nil
93
+ module_name = args[0]
94
+ release_module_finish(path, version, user, module_name, options[:spec])
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,9 @@
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_add
7
+ Logger.default('Coming soon.')
8
+ end
9
+ 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,9 @@
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_delete
7
+ Logger.default('Coming soon.')
8
+ end
9
+ 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,9 @@
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_search
7
+ Logger.default('Coming soon.')
8
+ end
9
+ 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