qcloudhive 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/Hive.iml +54 -0
- data/.idea/dictionaries/dongzhao.xml +7 -0
- data/.idea/misc.xml +4 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/.idea/workspace.xml +699 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Documents/Images/93A5AC58-17D5-4D3F-B5A8-E509CF429BD0.png +0 -0
- data/Documents/Images/C702C824-11B1-47A8-BB15-9F6F14F2B649.png +0 -0
- data/Gem/qcloudhive/.idea/misc.xml +4 -0
- data/Gem/qcloudhive/.idea/modules.xml +8 -0
- data/Gem/qcloudhive/.idea/qcloudhive.iml +8 -0
- data/Gem/qcloudhive/.idea/workspace.xml +383 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +122 -0
- data/LICENSE.txt +21 -0
- data/README.md +273 -0
- data/Rakefile +5 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/Hive +302 -0
- data/lib/qcloudhive.rb +16 -0
- data/lib/qcloudhive/config.rb +176 -0
- data/lib/qcloudhive/feature.rb +92 -0
- data/lib/qcloudhive/framework.rb +192 -0
- data/lib/qcloudhive/git_helper.rb +75 -0
- data/lib/qcloudhive/gitlab.rb +69 -0
- data/lib/qcloudhive/manifest.rb +346 -0
- data/lib/qcloudhive/module.rb +228 -0
- data/lib/qcloudhive/pod_helper.rb +119 -0
- data/lib/qcloudhive/product.rb +32 -0
- data/lib/qcloudhive/project.rb +108 -0
- data/lib/qcloudhive/repo.rb +177 -0
- data/lib/qcloudhive/spec_helper.rb +45 -0
- data/lib/qcloudhive/utils.rb +46 -0
- data/lib/qcloudhive/version.rb +3 -0
- data/lib/qcloudhive/xcodeproj.rb +163 -0
- data/qcloudhive.gemspec +43 -0
- data/resources/shellscriptes/HiveApp.sh +156 -0
- data/resources/shellscriptes/HiveFramework +158 -0
- data/resources/shellscriptes/build_framework.sh +76 -0
- data/resources/templates/AppDefaultTemplate/.gitignore +41 -0
- data/resources/templates/AppDefaultTemplate/AppDefaultTemplate.xcodeproj/project.pbxproj +290 -0
- data/resources/templates/AppDefaultTemplate/AppDefaultTemplate.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/resources/templates/AppDefaultTemplate/AppDefaultTemplate/Info.plist +24 -0
- data/resources/templates/AppDefaultTemplate/Podfile +9 -0
- data/resources/templates/HiveAppTemplate/.gitignore +41 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplate.xcodeproj/project.pbxproj +539 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplate.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplate/AppDelegate.h +17 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplate/AppDelegate.m +51 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplate/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplate/Base.lproj/LaunchScreen.storyboard +27 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplate/Base.lproj/Main.storyboard +26 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplate/Info.plist +45 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplate/ViewController.h +15 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplate/ViewController.m +29 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplate/main.m +16 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplateTests/HiveAppTemplateTests.m +39 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplateTests/Info.plist +22 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplateUITests/HiveAppTemplateUITests.m +40 -0
- data/resources/templates/HiveAppTemplate/HiveAppTemplateUITests/Info.plist +22 -0
- data/resources/templates/HiveAppTemplate/Podfile +20 -0
- data/resources/templates/commonConf.sh +9 -0
- data/resources/templates/manifests/build.rb +8 -0
- data/resources/templates/manifests/default.xml +12 -0
- data/resources/templates/template.podspec +37 -0
- metadata +321 -0
@@ -0,0 +1,228 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
require 'uri'
|
3
|
+
require 'cocoapods'
|
4
|
+
require 'git'
|
5
|
+
require 'rake'
|
6
|
+
require 'optparse'
|
7
|
+
require 'pathname'
|
8
|
+
require_relative 'project.rb'
|
9
|
+
require_relative "manifest.rb"
|
10
|
+
require 'fileutils'
|
11
|
+
require_relative 'utils.rb'
|
12
|
+
require_relative 'gitlab.rb'
|
13
|
+
require_relative 'pod_helper.rb'
|
14
|
+
|
15
|
+
module QCloudHive
|
16
|
+
module HiveModule
|
17
|
+
def HiveModule.add(cmd, opts)
|
18
|
+
name = GetOptValue(cmd, opts, :c_name)
|
19
|
+
rootPath = Config.projectRootDirectory
|
20
|
+
pwd = Dir.pwd
|
21
|
+
projectPath = opts[:i_path]
|
22
|
+
if projectPath == nil
|
23
|
+
if pwd.start_with? rootPath
|
24
|
+
projectPath = pwd[rootPath.length..-1]
|
25
|
+
L.warn "您没有给定具体的目录 将使用当前目录#{projectPath}"
|
26
|
+
else
|
27
|
+
Error "您没有给定具体的目录,并且当前不在Hive工程中!!!!"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
addModuleByName(name, projectPath)
|
31
|
+
end
|
32
|
+
|
33
|
+
def HiveModule.addModuleByName(name, projectPath)
|
34
|
+
L.debug "#{Config.manifest}"
|
35
|
+
if Config.manifest.existModule?(name)
|
36
|
+
L.warn "#{name} 已经在项目中,请不要重复添加"
|
37
|
+
end
|
38
|
+
if CodeOA.exist?(name)
|
39
|
+
gitProject = CodeOA.existProjectByName?(name)
|
40
|
+
if CodeOA.empty?(gitProject)
|
41
|
+
addModuleByCreate(name, projectPath)
|
42
|
+
return
|
43
|
+
end
|
44
|
+
Config.manifest.addModule(gitProject.http_url_to_repo, projectPath)
|
45
|
+
Config.manifest.flushStorage
|
46
|
+
L.debug "模块已经在git.code.oa.com上存在"
|
47
|
+
puts "已经添加模块#{name}"
|
48
|
+
podspec = HivePod.search(name)
|
49
|
+
if podspec == nil
|
50
|
+
L.warn"#{name} 已经存在于git.code.oa.com上,但是没有发布到cocoapods私有仓库,无法解析其依赖关系,将不进行依赖添加"
|
51
|
+
else
|
52
|
+
dependencies = podspec.specification.dependencies
|
53
|
+
L.debug "#{name}依赖以下库 #{dependencies}"
|
54
|
+
dependencies.each { |dependency|
|
55
|
+
addModuleByName(dependency.name, projectPath)
|
56
|
+
}
|
57
|
+
end
|
58
|
+
else
|
59
|
+
L.warn "#{name} 不再git.code.oa.com上面"
|
60
|
+
addModuleByCreate(name, projectPath)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
def HiveModule.addModuleByCreate(name, projectPath)
|
64
|
+
gitProject = createModuleByName(name, projectPath)
|
65
|
+
Config.manifest.addModule(gitProject.http_url_to_repo, projectPath)
|
66
|
+
Config.manifest.flushStorage
|
67
|
+
end
|
68
|
+
|
69
|
+
def HiveModule.createLocalModule(name, path)
|
70
|
+
aimPodspecPath = "#{path}/#{name}.podspec"
|
71
|
+
podspecTempPath = Config.templatesPath+"template.podspec"
|
72
|
+
if Pathname(aimPodspecPath).exist?
|
73
|
+
L.info "#{aimPodspecPath} exsit"
|
74
|
+
return
|
75
|
+
end
|
76
|
+
tempFile= File.new(podspecTempPath, "r")
|
77
|
+
if not Pathname(path).exist?
|
78
|
+
FileUtils.mkdir_p(path)
|
79
|
+
end
|
80
|
+
|
81
|
+
if tempFile
|
82
|
+
content = tempFile.read
|
83
|
+
content = content.gsub(/<POD_NAME>/,"#{name}")
|
84
|
+
File.open(aimPodspecPath, "w") { |f|
|
85
|
+
f.write content
|
86
|
+
}
|
87
|
+
classPath = "#{path}/Pod/Classes"
|
88
|
+
FileUtils.mkdir_p(classPath)
|
89
|
+
File.open(classPath+"/replace.m", "w") { |f|
|
90
|
+
f.write "//replace me !!!"
|
91
|
+
}
|
92
|
+
File.open("#{path}/README.md", "w") { |f|
|
93
|
+
f.write "README"
|
94
|
+
}
|
95
|
+
g = Git.init(path)
|
96
|
+
g.add(:all=>true)
|
97
|
+
g.commit_all("mudule init")
|
98
|
+
else
|
99
|
+
Error "模版文件不存在 #{podspecTempPath}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
def HiveModule.createModuleByName(name, projectPath)
|
105
|
+
if File.exist?(name)
|
106
|
+
L.warn "#{name} 已经存在于当前目录下,生成新模块将会覆盖他"
|
107
|
+
end
|
108
|
+
g = Git.init(name)
|
109
|
+
oaProject = CodeOA.createProject(name)
|
110
|
+
originRemote = nil
|
111
|
+
g.remotes.each { |r|
|
112
|
+
if r.name == "origin"
|
113
|
+
originRemote = r
|
114
|
+
end
|
115
|
+
}
|
116
|
+
if originRemote != nil
|
117
|
+
if originRemote.url == oaProject.http_url_to_repo
|
118
|
+
L.warn "当前Git仓库已经有 remote origin 为 #{oaProject.http_url_to_repo}"
|
119
|
+
else
|
120
|
+
Error "当前仓库已经有remote 但是不是#{oaProject.http_url_to_repo}"
|
121
|
+
end
|
122
|
+
else
|
123
|
+
g.add_remote("origin",oaProject.http_url_to_repo)
|
124
|
+
end
|
125
|
+
createLocalModule(name, name)
|
126
|
+
g.push
|
127
|
+
return oaProject
|
128
|
+
end
|
129
|
+
|
130
|
+
def HiveModule.release(cmd, opts)
|
131
|
+
rootPath = Dir.pwd
|
132
|
+
path = Pathname(rootPath)
|
133
|
+
podspec = nil
|
134
|
+
path.entries.each { |entry|
|
135
|
+
if (entry.extname == '.podspec' )
|
136
|
+
podspec = entry
|
137
|
+
end
|
138
|
+
}
|
139
|
+
if podspec == nil
|
140
|
+
puts "当前目录下没有Podspec文件,请在有Podspec文件的目录下进行该操作"
|
141
|
+
exit(1)
|
142
|
+
end
|
143
|
+
spec = Pod::Specification.from_file(podspec)
|
144
|
+
version = spec.version.version
|
145
|
+
git = Git.open(rootPath)
|
146
|
+
|
147
|
+
versionExsit = false
|
148
|
+
|
149
|
+
git.tags.each { |t|
|
150
|
+
if t.name == version
|
151
|
+
versionExsit = true
|
152
|
+
break
|
153
|
+
end
|
154
|
+
}
|
155
|
+
|
156
|
+
if versionExsit
|
157
|
+
git.delete_tag(version)
|
158
|
+
git.push("origin", ":refs/tags/"+version)
|
159
|
+
end
|
160
|
+
git.add_tag(version)
|
161
|
+
git.push("origin",version)
|
162
|
+
specStorage = "oa-qcloud-terminal-qcloudpodspecs "
|
163
|
+
Rake::sh " pod repo push #{specStorage} #{podspec} --allow-warnings"
|
164
|
+
Rake::sh "cd ~/.cocoapods/repos/#{specStorage} \n"+
|
165
|
+
'''
|
166
|
+
git add .
|
167
|
+
''' +
|
168
|
+
"git commit -m #{podspec}" +
|
169
|
+
'''
|
170
|
+
git pull
|
171
|
+
git push
|
172
|
+
'''
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
def HiveModule.tryRmGit?(gitPath)
|
177
|
+
git = Git.open(gitPath)
|
178
|
+
L.info "git is #{git}"
|
179
|
+
if git == nil
|
180
|
+
puts "您给的目录不是一个Git目录#{path}"
|
181
|
+
exit(1)
|
182
|
+
end
|
183
|
+
remoteUrl = nil
|
184
|
+
git.remotes.each { |r|
|
185
|
+
if r.name == "origin"
|
186
|
+
remoteUrl = r.url
|
187
|
+
end
|
188
|
+
}
|
189
|
+
if remoteUrl == nil
|
190
|
+
puts "您输入的Git目录没有设置远端地址#{path},您可能没没有提交的修改,暂不执行删除操作"
|
191
|
+
exit(1)
|
192
|
+
end
|
193
|
+
if git.status.changed.count > 0
|
194
|
+
puts "您输入的Git目录存在未提交的修改,暂不执行删除操作"
|
195
|
+
exit(1)
|
196
|
+
end
|
197
|
+
if git.status.deleted.count > 0
|
198
|
+
puts "您输入的Git目录存在未提交的修改,暂不执行删除操作"
|
199
|
+
exit(1)
|
200
|
+
end
|
201
|
+
if git.status.added.count > 0
|
202
|
+
puts "您输入的Git目录存在未提交的修改,暂不执行删除操作"
|
203
|
+
exit(1)
|
204
|
+
end
|
205
|
+
if git.status.untracked.count > 0
|
206
|
+
puts "您输入的Git目录存在未提交的修改,暂不执行删除操作"
|
207
|
+
exit(1)
|
208
|
+
end
|
209
|
+
return true
|
210
|
+
end
|
211
|
+
def HiveModule.dislink(cmd, opts)
|
212
|
+
name = GetOptValue(cmd, opts, :i_name)
|
213
|
+
manifestProjcet = Config.manifest.moduleByName(name)
|
214
|
+
if manifestProjcet == nil
|
215
|
+
Error "您要dislink的模块#{name}不在改项目中"
|
216
|
+
end
|
217
|
+
realetivePath = manifestProjcet.path
|
218
|
+
gitPath = Pathname(Config.projectRootDirectory).join(realetivePath).to_path
|
219
|
+
if File.exist?(gitPath)
|
220
|
+
tryRmGit?(gitPath)
|
221
|
+
end
|
222
|
+
Config.manifest.deleteModuleByName(name)
|
223
|
+
Config.manifest.flushStorage
|
224
|
+
FileUtils.rm_rf(gitPath)
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
228
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require "cocoapods"
|
2
|
+
require 'pathname'
|
3
|
+
require_relative 'spec_helper.rb'
|
4
|
+
require_relative 'xcodeproj.rb'
|
5
|
+
module QCloudHive
|
6
|
+
|
7
|
+
module HivePod
|
8
|
+
class << self
|
9
|
+
@@podspecs = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def HivePod.sources()
|
13
|
+
Pod::Config::instance.sources_manager.aggregate.sources
|
14
|
+
end
|
15
|
+
|
16
|
+
def HivePod.configPostInstaller(installer)
|
17
|
+
installer.pods_project.targets.each do |target|
|
18
|
+
target.build_configurations.each do |config|
|
19
|
+
config.build_settings['ENABLE_BITCODE'] = Config.bitcodeEnable ? "YES" : "NO"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def HivePod.search(name)
|
25
|
+
sources.each { |source|
|
26
|
+
podspec = source.search(name)
|
27
|
+
if podspec != nil
|
28
|
+
return podspec
|
29
|
+
end
|
30
|
+
}
|
31
|
+
return nil
|
32
|
+
end
|
33
|
+
|
34
|
+
def HivePod.findPodspecs(path)
|
35
|
+
podspecs = []
|
36
|
+
path = Pathname(path)
|
37
|
+
path.entries.each { |entry|
|
38
|
+
if (entry.extname == '.podspec' || entry.to_s.end_with?('.podspec.json'))
|
39
|
+
if path.basename.to_path == "Local Podspecs"
|
40
|
+
next
|
41
|
+
end
|
42
|
+
podspecs.push(path.join(entry))
|
43
|
+
end
|
44
|
+
}
|
45
|
+
if podspecs.count != 0
|
46
|
+
return podspecs
|
47
|
+
else
|
48
|
+
path.entries.each { |entry|
|
49
|
+
next if entry.to_path == "."
|
50
|
+
next if entry.to_path == ".."
|
51
|
+
next if entry.to_path == ".git"
|
52
|
+
next if entry.to_path == ".repo"
|
53
|
+
if File.directory?(path.join(entry))
|
54
|
+
subpath = path.join(entry)
|
55
|
+
ps = findPodspecs(subpath)
|
56
|
+
podspecs = podspecs + ps
|
57
|
+
end
|
58
|
+
}
|
59
|
+
end
|
60
|
+
return podspecs
|
61
|
+
end
|
62
|
+
def HivePod.podspecs
|
63
|
+
if @@podspecs.nil?
|
64
|
+
podspecs = findPodspecs(Config.projectRootDirectory)
|
65
|
+
if not podspecs.nil?
|
66
|
+
@@podspecs = podspecs.map { |specPath|
|
67
|
+
name = nil
|
68
|
+
basenamestr = specPath.basename.to_s
|
69
|
+
extenname = specPath.extname
|
70
|
+
if extenname == ".json"
|
71
|
+
extenname = ".podspec.json"
|
72
|
+
end
|
73
|
+
if extenname.length>0 && basenamestr.end_with?(extenname)
|
74
|
+
name = basenamestr[0,basenamestr.length - extenname.length]
|
75
|
+
end
|
76
|
+
HiveSpec.new(name, specPath)
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
return @@podspecs
|
81
|
+
end
|
82
|
+
|
83
|
+
def HivePod.installDependencies(target, podfilePath)
|
84
|
+
Config.setup()
|
85
|
+
Config.loadShareConfig
|
86
|
+
L.info("target is nil #{target}")
|
87
|
+
if target.nil? or target == "nil"
|
88
|
+
return
|
89
|
+
end
|
90
|
+
Config.setup
|
91
|
+
xcodeProject = QCloudHive.xcodeprojectByPath(Pathname.new(podfilePath).parent.to_s)
|
92
|
+
if xcodeProject.nil?
|
93
|
+
ERROR "该Podfile文件没有对应的Xcode工程 #{podfilePath}"
|
94
|
+
end
|
95
|
+
if xcodeProject.hiveSpecModules.nil?
|
96
|
+
puts "nil!!!"
|
97
|
+
end
|
98
|
+
xcodeProject.hiveSpecModules.each { |spec|
|
99
|
+
# local spec
|
100
|
+
if not spec.path.nil?
|
101
|
+
relativePath = Pathname.new(spec.path).dirname.relative_path_from(Pathname.new(podfilePath).parent)
|
102
|
+
target.store_pod(spec.name,:path=>relativePath.to_s)
|
103
|
+
elsif Config.buildFromCommit && (not spec.commit.nil?)
|
104
|
+
target.store_pod(spec.name,:git=>spec.sourceURL, :commit=>spec.commit)
|
105
|
+
else
|
106
|
+
target.store_pod(spec.name,:git=>spec.sourceURL, :branch=>spec.branch)
|
107
|
+
end
|
108
|
+
}
|
109
|
+
xcodeProject.saveHiveModulesConfig
|
110
|
+
L.info("Config #{Config}")
|
111
|
+
L.info("Config use frameworks #{Config.useFrameworks}")
|
112
|
+
if Config.useFrameworks
|
113
|
+
target.use_frameworks!
|
114
|
+
L.info("Target use frameworks")
|
115
|
+
end
|
116
|
+
L.info "save projects"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative "utils.rb"
|
2
|
+
require_relative "config.rb"
|
3
|
+
|
4
|
+
module QCloudHive
|
5
|
+
def QCloudHive.CreateAPP(cmd, opts)
|
6
|
+
name = opts[:c_name]
|
7
|
+
if name == nil
|
8
|
+
puts "ERROR! no name, please input one"
|
9
|
+
puts cmd.help
|
10
|
+
exit(1)
|
11
|
+
end
|
12
|
+
Rake::sh "#{Config.scriptesDirectory}HiveApp.sh #{name}"
|
13
|
+
Rake::sh "cd #{name} \n" +
|
14
|
+
"pod install \n" +
|
15
|
+
"open #{name}.xcworkspace"
|
16
|
+
|
17
|
+
|
18
|
+
url = opts[:c_url]
|
19
|
+
if url == nil
|
20
|
+
puts "您没有设置URL,将不会进行Git 远端仓库配置"
|
21
|
+
else
|
22
|
+
Rake::sh "cd #{name} \n" +
|
23
|
+
'''
|
24
|
+
git init
|
25
|
+
git add .
|
26
|
+
git commit -m "init"
|
27
|
+
''' + "git remote add origin #{url} \n " +
|
28
|
+
" git push -u origin master \n"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'optparse'
|
3
|
+
require 'pathname'
|
4
|
+
require "rake"
|
5
|
+
require 'git'
|
6
|
+
require_relative "manifest.rb"
|
7
|
+
require_relative 'gitlab.rb'
|
8
|
+
|
9
|
+
module QCloudHive
|
10
|
+
module Project
|
11
|
+
def Project.init(cmd , opts)
|
12
|
+
L.debug "#{opts}"
|
13
|
+
name = GetOptValue(cmd, opts, "name")
|
14
|
+
project = CodeOA.createProject(name)
|
15
|
+
if CodeOA.empty?(project) == true
|
16
|
+
puts "工程#{name}已经在CodeOA上存在,但是没有任何提交记录,还是个空工程,将对其进行初始化"
|
17
|
+
Project.initLocalProject(project)
|
18
|
+
else
|
19
|
+
if File.exist?(name)
|
20
|
+
Error "ERROR! the project local dirctory exist, can not cover it. please check"
|
21
|
+
end
|
22
|
+
workingPath = Pathname.new(name).to_path+"/"
|
23
|
+
if Dir.mkdir(workingPath) !=0
|
24
|
+
Error "创建目录#{name}失败"
|
25
|
+
end
|
26
|
+
Project.repoInit(workingPath, project.http_url_to_repo)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
def Project.repoInit(workingPath, url)
|
30
|
+
|
31
|
+
Rake::sh "cd #{workingPath} && repo init -u #{url} \n repo sync"
|
32
|
+
manifestPath = workingPath + ".repo/manifests/default.xml"
|
33
|
+
L.debug "#{manifestPath}"
|
34
|
+
if File.exist?(manifestPath) == false
|
35
|
+
Error "初始化失败,没有manifest配置文件"
|
36
|
+
end
|
37
|
+
manifest = Manifest.new(manifestPath)
|
38
|
+
Rake::sh "cd #{workingPath} && repo start #{manifest.default.revision} --all"
|
39
|
+
end
|
40
|
+
def Project.initLocalProject(project)
|
41
|
+
name = project.name
|
42
|
+
if File.exist?(name)
|
43
|
+
Error "ERROR! the project local dirctory exist, can not cover it. please check"
|
44
|
+
end
|
45
|
+
workingPath = Pathname.new(name).to_path+"/"
|
46
|
+
if Dir.mkdir(workingPath) !=0
|
47
|
+
Error "创建目录#{name}失败"
|
48
|
+
end
|
49
|
+
L.debug "#{project}"
|
50
|
+
git = Git.init(workingPath)
|
51
|
+
git.add_remote("origin",project.http_url_to_repo)
|
52
|
+
DZCopyFile(Config.templateManifestPath+".", workingPath, true)
|
53
|
+
git.add(:all=>true)
|
54
|
+
git.commit_all("project init")
|
55
|
+
git.push
|
56
|
+
Rake::sh("rm -rf #{workingPath}")
|
57
|
+
if Dir.mkdir(workingPath) !=0
|
58
|
+
Error "创建目录#{name}失败"
|
59
|
+
end
|
60
|
+
Project.repoInit(workingPath, project.http_url_to_repo)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
def QCloudHive.addCMD(origin , cmd)
|
67
|
+
return origin + "\n" + cmd + "\n"
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
def InitEmptyProject(cmd, opts)
|
72
|
+
name = opts[:i_name]
|
73
|
+
url = opts[:i_url]
|
74
|
+
if name == nil
|
75
|
+
puts "ERROR! no project name, please input one"
|
76
|
+
puts cmd.help
|
77
|
+
exit(1)
|
78
|
+
end
|
79
|
+
if url == nil
|
80
|
+
puts "ERROR! no git url"
|
81
|
+
puts cmd.help
|
82
|
+
exit(1)
|
83
|
+
end
|
84
|
+
if File.exist?(name)
|
85
|
+
puts "ERROR! the project exist, can not cover it. please check"
|
86
|
+
exit(1)
|
87
|
+
end
|
88
|
+
|
89
|
+
emptyProjectPath = CURRENT_PATH+name+"/"
|
90
|
+
templatePath = CDM_RES_PATH + "manifests/"
|
91
|
+
DZCopyFile(templatePath, emptyProjectPath, true)
|
92
|
+
Rake::sh "cd #{emptyProjectPath} \n" +'''
|
93
|
+
git init .
|
94
|
+
git add .
|
95
|
+
git commit -m "init project"
|
96
|
+
''' + "git remote add origin #{url} \n " +
|
97
|
+
" git push -u origin master \n" +
|
98
|
+
"cd .. \n" +
|
99
|
+
"rm -rf #{name}\n" +
|
100
|
+
"mkdir #{name}\n" +
|
101
|
+
"cd #{name}\n" +
|
102
|
+
'''
|
103
|
+
echo "产品初始化完成,将使用下述命令从您常用的源码目录,checkout该项目:"
|
104
|
+
''' + "repo init -u #{url}"
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|