starter 0.1.2 → 0.1.3
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.
- data/lib/starter/prompt.rb +4 -1
- data/lib/starter/tasks/github.rb +69 -35
- data/lib/starter/tasks/starter.rb +12 -0
- metadata +1 -1
data/lib/starter/prompt.rb
CHANGED
data/lib/starter/tasks/github.rb
CHANGED
@@ -4,41 +4,62 @@ desc "Create an issue on GitHub"
|
|
4
4
|
task "github:issue" => "github_repo" do
|
5
5
|
|
6
6
|
repo = $STARTER[:github_repo]
|
7
|
-
options = {}
|
8
|
-
$stdout.print "Title: "; $stdout.flush
|
9
|
-
options[:title] = $stdin.readline.strip
|
10
|
-
$stdout.print "Description: "; $stdout.flush
|
11
|
-
options[:description] = $stdin.readline.strip
|
12
7
|
labels = repo.labels.map { |label| label["name"] }.join(" ")
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
$stdout.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
8
|
+
milestones = repo.milestones
|
9
|
+
|
10
|
+
loop do
|
11
|
+
options = {}
|
12
|
+
$stdout.print "Title: "; $stdout.flush
|
13
|
+
options[:title] = $stdin.readline.strip
|
14
|
+
$stdout.print "Description: "; $stdout.flush
|
15
|
+
options[:body] = $stdin.readline.strip
|
16
|
+
$stdout.print "Labels (separate with spaces: [#{labels}]): "; $stdout.flush
|
17
|
+
options[:labels] = $stdin.readline.strip.split(" ")
|
18
|
+
if milestones.size > 0
|
19
|
+
$stdout.puts "Milestone:"
|
20
|
+
repo.milestones.each do |milestone|
|
21
|
+
$stdout.puts "#{milestone['number']} - #{milestone['title']}"
|
22
|
+
end
|
23
|
+
milestone = $stdin.readline.strip
|
24
|
+
options[:milestone] = milestone unless milestone.empty?
|
25
|
+
end
|
26
|
+
|
27
|
+
print "Issue details: "
|
28
|
+
Starter::Prompt.confirm("Create this issue?") do
|
29
|
+
result = repo.issues.create(options)
|
30
|
+
if result["errors"]
|
31
|
+
result["errors"].each do |error|
|
32
|
+
$stderr.puts "#{error['resource']}: #{error['message']}"
|
33
|
+
end
|
34
|
+
exit
|
35
|
+
elsif result["message"]
|
36
|
+
$stderr.puts "Problem creating issue:", result["message"]
|
37
|
+
exit
|
38
|
+
else
|
39
|
+
$stdout.puts "Issue ##{result['number']} created."
|
28
40
|
end
|
29
|
-
else
|
30
|
-
$stdout.puts "Issue ##{result['number']} created."
|
31
41
|
end
|
42
|
+
|
43
|
+
break unless Starter::Prompt.confirm("Create another?")
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
task "github:issues" => "github_repo" do
|
49
|
+
repo = $STARTER[:github_repo]
|
50
|
+
repo.issues.each do |issue|
|
51
|
+
line = "#%-6i %s" % issue.values_at(*%w[ number title ])
|
52
|
+
puts line
|
32
53
|
end
|
33
54
|
end
|
34
55
|
|
35
56
|
|
36
|
-
task "github_repo" => %w[ github_settings
|
57
|
+
task "github_repo" => %w[ github_settings github_auth ] do
|
37
58
|
require 'ghee'
|
38
59
|
|
39
60
|
settings = $STARTER[:settings][:github]
|
40
|
-
|
41
|
-
ghee = Ghee.
|
61
|
+
repo = settings[:repo]
|
62
|
+
ghee = Ghee.access_token(settings[:auth])
|
42
63
|
|
43
64
|
repo = ghee.repos(repo[:owner], repo[:name])
|
44
65
|
if repo["message"]
|
@@ -50,24 +71,37 @@ task "github_repo" => %w[ github_settings github_password ] do
|
|
50
71
|
|
51
72
|
end
|
52
73
|
|
53
|
-
|
54
|
-
task "github_password" => "github_settings" do
|
74
|
+
task "github_auth" => %w[ github_settings .starter ] do
|
55
75
|
require "starter/password"
|
56
|
-
|
76
|
+
require 'ghee'
|
77
|
+
settings = $STARTER[:settings][:github]
|
78
|
+
if File.exists?(".starter/gh_auth") && auth = File.read(".starter/gh_auth")
|
79
|
+
settings[:auth] = auth.chomp
|
80
|
+
else
|
57
81
|
password = Starter::Password.request("GitHub")
|
58
|
-
$STARTER[:settings][:github][:
|
82
|
+
user = $STARTER[:settings][:github][:user]
|
83
|
+
auth = Ghee.create_token(user, password, ["user", "repo"])
|
84
|
+
if auth
|
85
|
+
settings[:auth] = auth
|
86
|
+
Starter::Prompt.confirm("Write auth token to .starter?") do
|
87
|
+
File.open(".starter/gh_auth", "w") { |f| f.print(auth) }
|
88
|
+
end
|
89
|
+
else
|
90
|
+
puts "Authentication failure"
|
91
|
+
exit
|
92
|
+
end
|
59
93
|
end
|
60
94
|
end
|
61
95
|
|
62
96
|
|
63
|
-
task "read_settings" do
|
97
|
+
task "read_settings" => ".starter" do
|
64
98
|
require "yaml"
|
65
99
|
begin
|
66
|
-
$STARTER[:settings] = YAML.load_file("settings.yml")
|
100
|
+
$STARTER[:settings] = YAML.load_file(".starter/settings.yml")
|
67
101
|
rescue Errno::ENOENT
|
68
|
-
$stderr.puts "You do not appear to have a settings.yml file."
|
102
|
+
$stderr.puts "You do not appear to have a .starter/settings.yml file."
|
69
103
|
if Starter::Prompt.confirm("Create a stubbed settings file?")
|
70
|
-
File.open("settings.yml", "w") do |f|
|
104
|
+
File.open(".starter/settings.yml", "w") do |f|
|
71
105
|
settings = {
|
72
106
|
:github => {
|
73
107
|
:user => "YOURUSERNAME",
|
@@ -75,7 +109,7 @@ task "read_settings" do
|
|
75
109
|
}
|
76
110
|
}
|
77
111
|
YAML.dump(settings, f)
|
78
|
-
puts "Created settings.yml. Now go edit it
|
112
|
+
puts "Created .starter/settings.yml. Now go edit it."
|
79
113
|
end
|
80
114
|
end
|
81
115
|
exit
|
@@ -85,7 +119,7 @@ end
|
|
85
119
|
|
86
120
|
task "github_settings" => "read_settings" do
|
87
121
|
if $STARTER[:settings][:github] == nil
|
88
|
-
$stderr.puts "Looks like your settings.yml file isn't set up with a github stanza."
|
122
|
+
$stderr.puts "Looks like your .starter/settings.yml file isn't set up with a github stanza."
|
89
123
|
exit
|
90
124
|
end
|
91
125
|
end
|
@@ -18,6 +18,11 @@ task "build"
|
|
18
18
|
desc "Release the dogs that shoot bees from their mouths"
|
19
19
|
task "release" => %w[ build ]
|
20
20
|
|
21
|
+
directory ".starter"
|
22
|
+
|
23
|
+
task ".starter" do
|
24
|
+
gitignore(".starter")
|
25
|
+
end
|
21
26
|
|
22
27
|
task "determine_author" => %w[ read_git_config ] do
|
23
28
|
if author = $STARTER[:git].config["user.name"]
|
@@ -42,4 +47,11 @@ def confirm_command(command)
|
|
42
47
|
end
|
43
48
|
end
|
44
49
|
|
50
|
+
def gitignore(string)
|
51
|
+
Starter::Prompt.confirm "Append #{string} to your .gitignore?" do
|
52
|
+
File.open(".gitignore", "a") do |f|
|
53
|
+
f.puts(string)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
45
57
|
|