qcloudhive 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/.idea/.rakeTasks +7 -0
  3. data/.idea/Hive.iml +54 -0
  4. data/.idea/dictionaries/dongzhao.xml +7 -0
  5. data/.idea/misc.xml +4 -0
  6. data/.idea/modules.xml +8 -0
  7. data/.idea/vcs.xml +6 -0
  8. data/.idea/workspace.xml +699 -0
  9. data/CODE_OF_CONDUCT.md +74 -0
  10. data/Documents/Images/93A5AC58-17D5-4D3F-B5A8-E509CF429BD0.png +0 -0
  11. data/Documents/Images/C702C824-11B1-47A8-BB15-9F6F14F2B649.png +0 -0
  12. data/Gem/qcloudhive/.idea/misc.xml +4 -0
  13. data/Gem/qcloudhive/.idea/modules.xml +8 -0
  14. data/Gem/qcloudhive/.idea/qcloudhive.iml +8 -0
  15. data/Gem/qcloudhive/.idea/workspace.xml +383 -0
  16. data/Gemfile +4 -0
  17. data/Gemfile.lock +122 -0
  18. data/LICENSE.txt +21 -0
  19. data/README.md +273 -0
  20. data/Rakefile +5 -0
  21. data/bin/console +14 -0
  22. data/bin/setup +8 -0
  23. data/exe/Hive +302 -0
  24. data/lib/qcloudhive.rb +16 -0
  25. data/lib/qcloudhive/config.rb +176 -0
  26. data/lib/qcloudhive/feature.rb +92 -0
  27. data/lib/qcloudhive/framework.rb +192 -0
  28. data/lib/qcloudhive/git_helper.rb +75 -0
  29. data/lib/qcloudhive/gitlab.rb +69 -0
  30. data/lib/qcloudhive/manifest.rb +346 -0
  31. data/lib/qcloudhive/module.rb +228 -0
  32. data/lib/qcloudhive/pod_helper.rb +119 -0
  33. data/lib/qcloudhive/product.rb +32 -0
  34. data/lib/qcloudhive/project.rb +108 -0
  35. data/lib/qcloudhive/repo.rb +177 -0
  36. data/lib/qcloudhive/spec_helper.rb +45 -0
  37. data/lib/qcloudhive/utils.rb +46 -0
  38. data/lib/qcloudhive/version.rb +3 -0
  39. data/lib/qcloudhive/xcodeproj.rb +163 -0
  40. data/qcloudhive.gemspec +43 -0
  41. data/resources/shellscriptes/HiveApp.sh +156 -0
  42. data/resources/shellscriptes/HiveFramework +158 -0
  43. data/resources/shellscriptes/build_framework.sh +76 -0
  44. data/resources/templates/AppDefaultTemplate/.gitignore +41 -0
  45. data/resources/templates/AppDefaultTemplate/AppDefaultTemplate.xcodeproj/project.pbxproj +290 -0
  46. data/resources/templates/AppDefaultTemplate/AppDefaultTemplate.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  47. data/resources/templates/AppDefaultTemplate/AppDefaultTemplate/Info.plist +24 -0
  48. data/resources/templates/AppDefaultTemplate/Podfile +9 -0
  49. data/resources/templates/HiveAppTemplate/.gitignore +41 -0
  50. data/resources/templates/HiveAppTemplate/HiveAppTemplate.xcodeproj/project.pbxproj +539 -0
  51. data/resources/templates/HiveAppTemplate/HiveAppTemplate.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  52. data/resources/templates/HiveAppTemplate/HiveAppTemplate/AppDelegate.h +17 -0
  53. data/resources/templates/HiveAppTemplate/HiveAppTemplate/AppDelegate.m +51 -0
  54. data/resources/templates/HiveAppTemplate/HiveAppTemplate/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
  55. data/resources/templates/HiveAppTemplate/HiveAppTemplate/Base.lproj/LaunchScreen.storyboard +27 -0
  56. data/resources/templates/HiveAppTemplate/HiveAppTemplate/Base.lproj/Main.storyboard +26 -0
  57. data/resources/templates/HiveAppTemplate/HiveAppTemplate/Info.plist +45 -0
  58. data/resources/templates/HiveAppTemplate/HiveAppTemplate/ViewController.h +15 -0
  59. data/resources/templates/HiveAppTemplate/HiveAppTemplate/ViewController.m +29 -0
  60. data/resources/templates/HiveAppTemplate/HiveAppTemplate/main.m +16 -0
  61. data/resources/templates/HiveAppTemplate/HiveAppTemplateTests/HiveAppTemplateTests.m +39 -0
  62. data/resources/templates/HiveAppTemplate/HiveAppTemplateTests/Info.plist +22 -0
  63. data/resources/templates/HiveAppTemplate/HiveAppTemplateUITests/HiveAppTemplateUITests.m +40 -0
  64. data/resources/templates/HiveAppTemplate/HiveAppTemplateUITests/Info.plist +22 -0
  65. data/resources/templates/HiveAppTemplate/Podfile +20 -0
  66. data/resources/templates/commonConf.sh +9 -0
  67. data/resources/templates/manifests/build.rb +8 -0
  68. data/resources/templates/manifests/default.xml +12 -0
  69. data/resources/templates/template.podspec +37 -0
  70. metadata +321 -0
@@ -0,0 +1,177 @@
1
+ require "pathname"
2
+ require 'date'
3
+ require_relative 'git_helper'
4
+ require 'terminal-table'
5
+ require_relative 'pod_helper.rb'
6
+ require "cocoapods"
7
+ require_relative "module.rb"
8
+ require_relative "spec_helper.rb"
9
+
10
+
11
+
12
+
13
+ module QCloudHive
14
+ def QCloudHive.RemapProduct(cmd, opts)
15
+ pods = HivePod.podspecs
16
+ Repo.addChildSpec("xxxx",pods[3])
17
+ end
18
+
19
+ class Repo
20
+ def Repo.push(cmd, opts)
21
+
22
+ end
23
+
24
+ def Repo.relaseCommits(name)
25
+
26
+ end
27
+ def Repo.request(cmd, opts)
28
+ git = Git.open(Dir.pwd)
29
+ if git == nil
30
+ Error("当前不是Git目录")
31
+ end
32
+ message = GetOptValue(cmd, opts, :i_message)
33
+ if git.current_branch == "master"
34
+ Error "无法将master分支合并到master分支"
35
+ end
36
+ name = QCloudHive::GITURLDecoder.new(git.remote.url).name
37
+ L.debug name
38
+ project = CodeOA.existProjectByName?(name)
39
+ if project == nil
40
+ Error "工程还没有在CodeOA上创建!!#{name}"
41
+ end
42
+ begin
43
+ L.info "#{project.id} #{git.current_branch}"
44
+ Gitlab.create_merge_request(project.id, message, :source_branch=>git.current_branch, :target_branch=>"master")
45
+ rescue => err
46
+ Error "创建失败#{err}"
47
+ end
48
+ end
49
+
50
+ def Repo.checkGitStatus(git, tableRows)
51
+ git.status.changed.each do |path, statu|
52
+ tableRows << ["", "", statu.type.red, path.red]
53
+ end
54
+ git.status.deleted.each do |path, statu|
55
+ tableRows << ["", "", statu.type.red, path.red]
56
+ end
57
+ git.status.added.each do |path, statu|
58
+ tableRows << ["","", statu.type.red, path.red]
59
+ end
60
+ git.status.untracked.each do |path, statu|
61
+ tableRows << ["", "", "U".red, path.red]
62
+ end
63
+ end
64
+ def Repo.checkStatus(cmd, opts)
65
+ projectTable = []
66
+ Config.manifest.projects.each { |p|
67
+ projectTable << ["#{p.path}".red, "Branche" ,p.gitRepo.clean? ? "clean".green : "dirty".red]
68
+ if not p.exsitServer?
69
+ projectTable << ["", "远端没有该模块,请提交" ]
70
+ else
71
+ if not p.exsitPodRepo?
72
+ projectTable << ["", "", "", "🐝🐝请提交该模块到Pod仓库"]
73
+ else
74
+
75
+ if p.needReleasePod?
76
+ projectTable << ["", "", "", "🐝🐝提交该模块的新修改到Pod仓库"]
77
+ end
78
+ end
79
+ #
80
+ projectTable << [p.moduleName]
81
+ currentBranch = p.gitRepo.branches[p.gitRepo.current_branch]
82
+ currentFreature = ProjectFeature.new(p, currentBranch)
83
+ if currentFreature.remoteBranch.nil?
84
+ projectTable << ["", currentBranch.full,"", "远端没有该分支,请及时提交到服务器 ⬆️⬆️⬆️⬆️".red]
85
+ else
86
+ compareRet = currentFreature.compareRemote
87
+ if compareRet == 1
88
+ projectTable << ["", "","" ,"本地有未同步的修改,请及时提交到服务器 ⬆️⬆️⬆️⬆️".red]
89
+ elsif compareRet == -1
90
+ projectTable << ["", "","" ,"远端有新的修改,请及时Pull⬇️⬇️⬇️".blue]
91
+ else
92
+ projectTable << ["", "","" ,""]
93
+ end
94
+ compareMaster = currentFreature.compareMaster
95
+ if compareMaster == 1
96
+ projectTable << ["", "","" ,"领先于master分支,请留意进行merge request!!!"]
97
+ elsif compareMaster == -1
98
+ projectTable << ["", "","" ,"落后于master分支有差异,请留意合并master的修改!!!"]
99
+ end
100
+ end
101
+ end
102
+ checkGitStatus(p.gitRepo, projectTable)
103
+ projectTable << :separator
104
+ }
105
+ table = Terminal::Table.new :rows => projectTable
106
+ puts table
107
+ end
108
+ def Repo.status(git)
109
+ if git.remotes.count == 0
110
+ Error "您没有设置改模块的远端地址,请设置!!!#{path}"
111
+ end
112
+ L.debug "#{git.clean?}"
113
+ changedCount = 0
114
+ git.status.each { |statu|
115
+ tag = nil
116
+ if statu.type != nil
117
+ tag = statu.type.red
118
+ elsif statu.untracked == true
119
+ tag = "U".red
120
+ end
121
+ if tag != nil
122
+ changedCount += 0
123
+ printf "%-60s %s \n", statu.path, tag
124
+ end
125
+ }
126
+ end
127
+
128
+ def Repo.clean?(git)
129
+ root = Pathname(Config.projectRootDirectory)
130
+ Config.manifest.projects.each { |p|
131
+ path = root.join(p.path)
132
+ begin
133
+ g = Git.open(path)
134
+ L.debug "#{g} #{g.clean?}"
135
+ rescue => err
136
+ puts "读取git工程失败 #{path} #{err}"
137
+ end
138
+ }
139
+ end
140
+
141
+ def Repo.fackSpec(name)
142
+
143
+ end
144
+
145
+ def Repo.fackSpecContainerPath
146
+ fackPath = Pathname(Config.projectRootDirectory).join(".fackspec")
147
+ if not fackPath.exist?
148
+ fackPath.mkdir
149
+ end
150
+ return fackPath.to_path
151
+ end
152
+
153
+ def Repo.subFackSpec(name, rebuild=true)
154
+ fackpath = fackSpecContainerPath+"/#{name}"
155
+ if rebuild == true
156
+ if Pathname(fackpath).exist?
157
+ FileUtils.rm_rf(fackpath)
158
+ end
159
+ end
160
+ HiveModule.createLocalModule(name, fackpath)
161
+ return HiveSpec.new(name, fackpath+"/#{name}.podspec")
162
+ end
163
+
164
+ def Repo.addChildSpec(parentName, subHiveSpec)
165
+ faceParentHiveSpec = subFackSpec(parentName)
166
+ spec = faceParentHiveSpec.podspec
167
+ subSpec = subHiveSpec.podspec
168
+ sourceFiles = subSpec.attributes_hash["source_files"]
169
+ if sourceFiles.is_a?(String)
170
+ sourceFiles = subHiveSpec.path.parent.join(sourceFiles).to_path
171
+ end
172
+ subSpec.source_files = sourceFiles
173
+ spec.subspec subHiveSpec.name,subSpec
174
+ faceParentHiveSpec.writeJson
175
+ end
176
+ end
177
+ end
@@ -0,0 +1,45 @@
1
+ require 'cocoapods'
2
+ module QCloudHive
3
+ class HiveSpec
4
+ attr_accessor :name
5
+ attr_accessor :path
6
+ attr_accessor :branch
7
+ attr_accessor :commit
8
+ attr_accessor :sourceURL
9
+ def initialize(name=nil, path=nil)
10
+ @name = name
11
+ @path = path
12
+ @podspec = nil
13
+ end
14
+
15
+ def podspec
16
+ if @podspec.nil?
17
+ @podspec = Pod::Specification.from_file(path)
18
+ end
19
+ return @podspec
20
+ end
21
+ def toConfig
22
+ config = "[#{name}]\n"
23
+ if not path.nil?
24
+ config += "path=#{path}\n"
25
+ end
26
+ if not commit.nil?
27
+ config += "commit=#{commit}\n"
28
+ end
29
+ if not branch.nil?
30
+ config += "branch=#{branch}\n"
31
+ end
32
+ if not sourceURL.nil?
33
+ config += "sourceURL=#{sourceURL}\n"
34
+ end
35
+ config
36
+ end
37
+
38
+ def writeJson
39
+ jsonPath = @path + ".json"
40
+ File.open("#{jsonPath}", "w") { |f|
41
+ f.write podspec.to_json
42
+ }
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,46 @@
1
+ require 'rake'
2
+ require 'uri'
3
+ require 'logger'
4
+
5
+ L = Logger.new(STDOUT)
6
+
7
+ def DZCopyFile(originPath , aimPath , dir)
8
+ fileOriginPath = originPath
9
+ argv = " "
10
+ if File.exist?(aimPath)
11
+ puts aimPath + " already exsit! Will update"
12
+ if dir
13
+ argv = " -r -f -p "
14
+ else
15
+ argv = " -f -p "
16
+ end
17
+ else
18
+ if dir
19
+ argv = " -r -p"
20
+ end
21
+ end
22
+ Rake::sh "cp "+ argv + " " + fileOriginPath + " " + aimPath
23
+ end
24
+
25
+ def GetOptValue(cmd, opts, name)
26
+ value = opts[name]
27
+ L.debug "name is #{name} value is #{value}"
28
+ if value == nil
29
+ puts "您没有输入必须输入的参数#{name}"
30
+ puts cmd.help
31
+ exit(1)
32
+ end
33
+ return value
34
+ end
35
+
36
+ def Error(msg)
37
+ puts msg
38
+ exit(1)
39
+ end
40
+
41
+ def VersionStrToNumber(str)
42
+ if str == None
43
+ return 0
44
+ end
45
+
46
+ end
@@ -0,0 +1,3 @@
1
+ module QCloudHive
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,163 @@
1
+ require 'cocoapods'
2
+ require_relative 'utils.rb'
3
+ require_relative 'config.rb'
4
+ require 'pathname'
5
+ require 'parseconfig'
6
+ require_relative 'pod_helper.rb'
7
+ require "git"
8
+
9
+
10
+ module QCloudHive
11
+ HIVE_MODULES_FILE_NAME = ".hivemodules"
12
+ class << self
13
+ @@xcodeprojectvar = nil
14
+ end
15
+ class XCodeProject
16
+ attr_accessor :path
17
+ attr_reader :hiveSpecModules
18
+ def podfile
19
+ if @podfile.nil?
20
+ @podfile = Pod::Podfile.from_file(Pathname(@path).join("Podfile").to_path)
21
+ end
22
+ @podfile
23
+ end
24
+
25
+ def hiveSpecModules
26
+ if @hiveSpecModules.nil?
27
+ hivemodules = Pathname.new(@path).join(QCloudHive::HIVE_MODULES_FILE_NAME)
28
+ configedModules = []
29
+ if hivemodules.exist?
30
+ parseConfig = ParseConfig.new(hivemodules.to_path)
31
+ configedModules += parseConfig.groups.map { |e|
32
+ spec = HiveSpec.new(e, nil)
33
+ spec.commit = parseConfig[e]["commit"]
34
+ spec.branch= parseConfig[e]["branch"]
35
+ spec.sourceURL = Config.manifest.sourceURLByModuleName(e)
36
+ localSpec = QCloudHive::HivePod.podspecs.select{|s| s.name == e}.first
37
+ if not localSpec.nil?
38
+ spec.path = localSpec.path
39
+ end
40
+ if (not spec.path.nil?) && Pathname.new(spec.path).exist?
41
+ begin
42
+ git = Git.open(Pathname.new(spec.path).parent.to_s)
43
+ if not git.nil?
44
+ spec.branch = git.current_branch
45
+ if not git.branches[git.current_branch].nil?
46
+ spec.commit = git.branches[git.current_branch].gcommit.sha
47
+ end
48
+ end
49
+ rescue => err
50
+ puts "读取git工程失败 #{path} #{err}"
51
+ end
52
+ end
53
+ spec
54
+ }
55
+ end
56
+ configedModules += QCloudHive::HivePod.podspecs.map { |s|
57
+ spec = nil
58
+ if configedModules.select { |e| e.name == s.name }.count == 0
59
+ spec = HiveSpec.new(s.name, nil)
60
+ spec.sourceURL = Config.manifest.sourceURLByModuleName(s.name)
61
+ spec.path = s.path
62
+ if (not spec.path.nil?) && Pathname.new(spec.path).exist?
63
+ begin
64
+ git = Git.open(Pathname.new(spec.path).parent.to_path)
65
+ L.debug "Create git #{git}"
66
+ rescue => err
67
+ puts "读取git工程失败 #{path} #{err}"
68
+ end
69
+ if not git.nil?
70
+ spec.branch = git.current_branch
71
+ if not git.branches[git.current_branch].nil?
72
+ spec.commit = git.branches[git.current_branch].gcommit.sha
73
+ end
74
+ end
75
+ end
76
+ else
77
+ # exist
78
+ spec = nil
79
+ end
80
+ spec
81
+ }
82
+ configedModules = configedModules.compact
83
+ @hiveSpecModules = configedModules
84
+ end
85
+ return @hiveSpecModules
86
+ end
87
+ def initialize(path)
88
+ @path = path
89
+ @podfile = nil
90
+ @hiveSpecModules = nil
91
+ end
92
+
93
+ def saveHiveModulesConfig
94
+ config = ""
95
+ hiveSpecModules.each { |e|
96
+ config += "\n#{e.toConfig}"
97
+ }
98
+ File.open(Pathname.new(@path).join(QCloudHive::HIVE_MODULES_FILE_NAME).to_s, "w") { |f|
99
+ f.write config
100
+ }
101
+ end
102
+ end
103
+ def QCloudHive.findXcodeProject(path)
104
+ dirPath = Pathname.new(path)
105
+ if not dirPath.directory?
106
+ return []
107
+ end
108
+ projects = dirPath.each_child.select{|f|
109
+ f.extname == ".xcodeproj"
110
+ }
111
+ if projects.count != 0
112
+ return [dirPath.to_path]
113
+ else
114
+ subProjects = []
115
+ dirPath.each_child { |file|
116
+ if file.basename.to_path == ".git"
117
+ next
118
+ end
119
+ if file.basename.to_path == ".repo"
120
+ next
121
+ end
122
+ subDir = dirPath.join(file)
123
+ if subDir.directory?
124
+ subProjects+=findXcodeProject(subDir)
125
+ end
126
+ }
127
+ return subProjects
128
+ end
129
+ end
130
+ def QCloudHive.xcodeprojects
131
+ if @@xcodeprojectvar.nil?
132
+ root = Config.projectRootDirectory
133
+ L.info("find xcode projects")
134
+ projects = findXcodeProject(root)
135
+ xcodePojects = []
136
+ projects.each { |xcp|
137
+ xcodePojects << XCodeProject.new(xcp)
138
+ }
139
+ @@xcodeprojectvar = xcodePojects
140
+ end
141
+ return @@xcodeprojectvar
142
+ end
143
+
144
+ def QCloudHive.xcodeprojectByPath(path)
145
+ QCloudHive.xcodeprojects.select{|p| p.path == path}.first
146
+ end
147
+
148
+ def QCloudHive.UpdateProducts(cmd, opts)
149
+ name = opts[:i_name]
150
+ Config.dumpShareConfig
151
+ if name.nil?
152
+ updateAllProducts
153
+ end
154
+
155
+ end
156
+
157
+ def QCloudHive.updateAllProducts
158
+ QCloudHive.xcodeprojects.each { |hive|
159
+ L.debug "codeproject #{hive.path}"
160
+ Rake::sh "cd #{Pathname(hive.path).to_path};pod update"
161
+ }
162
+ end
163
+ end
@@ -0,0 +1,43 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'qcloudhive/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "qcloudhive"
8
+ spec.version = QCloudHive::VERSION
9
+ spec.authors = ["stonedong"]
10
+ spec.email = ["stonedong@tencent.com"]
11
+
12
+ spec.summary = %q{腾讯云终端团队模块化开发工具}
13
+ spec.description = %q{腾讯云终端团队模块化开发工具,致力于模块化协同开发和发布SDK类产品}
14
+ spec.homepage = "http://git.code.oa.com/qcloud-terminal"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = ["Hive"]
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.14"
29
+ spec.add_development_dependency "rspec", '~> 0'
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+
32
+ spec.add_runtime_dependency "rake", "~> 10.0"
33
+ spec.add_runtime_dependency "nokogiri", '~> 0'
34
+ spec.add_runtime_dependency "git", '~> 0'
35
+ spec.add_runtime_dependency "gitlab", '~> 0'
36
+ spec.add_runtime_dependency "parseconfig", '~> 0'
37
+ spec.add_runtime_dependency "cocoapods", '~> 0'
38
+ spec.add_runtime_dependency 'colorize', '~> 0'
39
+ spec.add_runtime_dependency 'terminal-table', '~> 0'
40
+ spec.add_runtime_dependency 'json', '~> 2.0', '>= 2.0.2'
41
+ spec.add_runtime_dependency 'httparty', "~> 0.14.0"
42
+ spec.add_runtime_dependency 'versionomy', '~> 0'
43
+ end