27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/arfor/github_module.rb', line 27
def self.create()
forge_name = ask("#{Arfor::QUESTION} Forge module name: ") do |q|
q.validate = /[\w_]+-[\w_]+/
end
description = ask("#{Arfor::QUESTION} Module description: ")
forge_name_split = forge_name.split('-')
forge_user = forge_name_split[0]
module_name = forge_name_split[1]
git_name = "puppet-#{module_name}"
git_opts = {
:description => description,
}
if system("puppet module generate --skip-interview #{forge_name}")
Dir.chdir(module_name) {
File.delete('Gemfile')
system("pdqtest init")
begin
resp = Arfor::Util::Github::create_repository(git_name, git_opts)
full_name = resp.full_name
rescue Octokit::UnprocessableEntity => e
raise "Repository creation error: #{e.message}"
end
template = File.read(File.join(File.dirname(File.expand_path(__FILE__)), README_ERB))
content = ERB.new(template, nil, '-').result(binding)
File.write(README_FILE, content)
system("git init && git remote add origin #{resp.clone_url}")
metadata = JSON.parse(File.read(PUPPET_METADATA))
metadata['source'] = resp.clone_url
metadata['project_url'] = resp.clone_url
metadata['issues_url'] = resp.issues_url
metadata['summary'] = description
File.write(PUPPET_METADATA, JSON.pretty_generate(metadata))
Dir.glob("**/*.pdqtest_old").each { |f|
File.delete(f)
}
puts "sleep for sync"
sleep(30)
system("travis enable --no-interactive")
system("git add -A && git commit -m 'initial' && git push origin master")
}
else
raise "module generation error"
end
Arfor::OK
end
|