179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
# File 'lib/cnvrg/project.rb', line 179
def self.link(owner, project_name, docker = false, git = false, bucket: nil)
ignore_exits = File.exist? ".cnvrgignore"
list_dirs = [".cnvrg"
]
list_files = [
".cnvrg/config.yml"
]
if !ignore_exits
list_files <<
".cnvrgignore"
end
cnvrgreadme = Helpers.readme_content
cnvrgignore = Helpers.cnvrgignore_content
begin
response = Cnvrg::API.request("cli/create_project", 'POST', {title: project_name, owner: owner, is_docker: docker, bucket: bucket})
Cnvrg::CLI.is_response_success(response)
response = JSON.parse response["result"]
project_slug = response["slug"]
config = {project_name: project_name,
project_slug: project_slug,
owner: owner,
git: git}
FileUtils.mkdir_p list_dirs
FileUtils.touch list_files
File.open(".cnvrg/config.yml", "w+") {|f| f.write config.to_yaml}
File.open(".cnvrgignore", "w+") {|f| f.write cnvrgignore} unless ignore_exits
if !File.exist? "README" and !File.exist? "README.md"
FileUtils.touch ["README.md"]
File.open("README.md", "w+") {|f| f.write cnvrgreadme}
end
rescue => e
puts e
return false
end
return true
end
|