kensa 1.2.0rc2 → 1.2.0rc3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/kensa +10 -1
- data/lib/heroku/kensa/client.rb +59 -1
- data/lib/heroku/kensa/version.rb +1 -1
- data/test.rb +1 -0
- data/test/create_test.rb +12 -0
- metadata +28 -25
data/bin/kensa
CHANGED
@@ -24,6 +24,7 @@ ARGV.options do |o|
|
|
24
24
|
o.on("-h", "--help") { command = "help" }
|
25
25
|
o.on("-p plan", "--plan") { |plan| options[:plan] = plan }
|
26
26
|
o.on("-v", "--version") { options[:command] = "version" }
|
27
|
+
o.on("-t template", "--template") { |t| options[:template] = t }
|
27
28
|
o.parse!
|
28
29
|
end
|
29
30
|
|
@@ -33,6 +34,8 @@ begin
|
|
33
34
|
args = ARGV.dup
|
34
35
|
ARGV.clear
|
35
36
|
Client.new(args, options).run!
|
37
|
+
rescue Client::CommandFailed => e
|
38
|
+
puts "We're sorry, but #{e.message} "
|
36
39
|
rescue Client::CommandInvalid
|
37
40
|
abort File.read(__FILE__).split('__END__').last
|
38
41
|
end
|
@@ -63,10 +66,17 @@ OPTIONS
|
|
63
66
|
--post
|
64
67
|
Use HTTP POST for single sign-on instead of GET
|
65
68
|
|
69
|
+
-t, --template name
|
70
|
+
Desired template to clone for create command from:
|
71
|
+
git://github.com/heroku/kensa-template-<name>
|
72
|
+
try sinatra, clojure, or node
|
73
|
+
|
66
74
|
COMMANDS
|
67
75
|
|
68
76
|
init Creates a skeleton manifest
|
69
77
|
|
78
|
+
create <name> Creates a skeleton application from --template
|
79
|
+
|
70
80
|
test <type> Simulate call from Heroku (provision or deprovision)
|
71
81
|
|
72
82
|
run <command> Provisions a resource and runs command in returned ENV
|
@@ -93,4 +103,3 @@ TEST TYPES
|
|
93
103
|
|
94
104
|
manifest
|
95
105
|
Confirm that the manifest is valid. Automatically runs before all tests.
|
96
|
-
|
data/lib/heroku/kensa/client.rb
CHANGED
@@ -3,9 +3,47 @@ require 'term/ansicolor'
|
|
3
3
|
require 'launchy'
|
4
4
|
|
5
5
|
module Heroku
|
6
|
+
class Git
|
7
|
+
class << self
|
8
|
+
def verify_create(app_name, template)
|
9
|
+
raise CommandInvalid.new("template #{clone_url(template)} does not exist") unless template_exists?(template)
|
10
|
+
raise CommandInvalid.new("Need git to clone repository") unless git_installed?
|
11
|
+
end
|
12
|
+
|
13
|
+
def template_exists?(template)
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def git_installed?
|
18
|
+
`git` rescue false
|
19
|
+
end
|
20
|
+
|
21
|
+
def clone(app_name, template)
|
22
|
+
verify_create(app_name, template)
|
23
|
+
cmd = "git clone #{clone_url(template)} #{app_name}"
|
24
|
+
puts cmd
|
25
|
+
`#{cmd}`
|
26
|
+
raise Exception.new("couldn't clone the repository from #{clone_url(template)}") unless File.directory?("#{app_name}")
|
27
|
+
puts "Created #{app_name} from #{template} template"
|
28
|
+
end
|
29
|
+
|
30
|
+
def clone_url(name)
|
31
|
+
prefix = ENV['REPO_PREFIX'] || "heroku"
|
32
|
+
if name.include? "://" #its a full url
|
33
|
+
return name
|
34
|
+
elsif name.include? "/" #its a non-heroku repo
|
35
|
+
name = "#{prefix}/#{name}"
|
36
|
+
else #its one of ours
|
37
|
+
name = "#{prefix}/kensa-create-#{name}"
|
38
|
+
end
|
39
|
+
|
40
|
+
"git://github.com/#{name}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
6
45
|
module Kensa
|
7
46
|
class Client
|
8
|
-
|
9
47
|
def initialize(args, options)
|
10
48
|
@args = args
|
11
49
|
@options = options
|
@@ -15,7 +53,10 @@ module Heroku
|
|
15
53
|
@options[:filename]
|
16
54
|
end
|
17
55
|
|
56
|
+
#you fucked up
|
18
57
|
class CommandInvalid < Exception; end
|
58
|
+
#we fucked up
|
59
|
+
class CommandFailed < Exception; end
|
19
60
|
|
20
61
|
def run!
|
21
62
|
command = @args.shift || @options[:command]
|
@@ -28,6 +69,23 @@ module Heroku
|
|
28
69
|
Screen.new.message "Initialized new addon manifest in #{filename}\n"
|
29
70
|
end
|
30
71
|
|
72
|
+
def create
|
73
|
+
app_name = @args.shift
|
74
|
+
template = @options[:template]
|
75
|
+
raise CommandInvalid.new("Need git to supply a template") unless template
|
76
|
+
raise CommandInvalid.new("Need git to supply an application name") unless app_name
|
77
|
+
|
78
|
+
begin
|
79
|
+
Git.clone(app_name, template)
|
80
|
+
rescue Exception => e
|
81
|
+
raise CommandFailed.new("error cloning #{Git.clone_url(template)} into #{app_name}")
|
82
|
+
end
|
83
|
+
|
84
|
+
Dir.chdir("./#{app_name}")
|
85
|
+
`./after_clone #{app_name}` if File.exist?('./after_clone')
|
86
|
+
end
|
87
|
+
|
88
|
+
|
31
89
|
def test
|
32
90
|
case check = @args.shift
|
33
91
|
when "manifest"
|
data/lib/heroku/kensa/version.rb
CHANGED
data/test.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
puts ARGV
|
data/test/create_test.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kensa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.0rc3
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -17,7 +17,7 @@ date: 2011-10-17 00:00:00.000000000Z
|
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: json
|
20
|
-
requirement: &
|
20
|
+
requirement: &70298725075380 !ruby/object:Gem::Requirement
|
21
21
|
none: false
|
22
22
|
requirements:
|
23
23
|
- - ! '>='
|
@@ -25,10 +25,10 @@ dependencies:
|
|
25
25
|
version: '0'
|
26
26
|
type: :development
|
27
27
|
prerelease: false
|
28
|
-
version_requirements: *
|
28
|
+
version_requirements: *70298725075380
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: sinatra
|
31
|
-
requirement: &
|
31
|
+
requirement: &70298725074800 !ruby/object:Gem::Requirement
|
32
32
|
none: false
|
33
33
|
requirements:
|
34
34
|
- - ~>
|
@@ -36,10 +36,10 @@ dependencies:
|
|
36
36
|
version: 1.2.6
|
37
37
|
type: :development
|
38
38
|
prerelease: false
|
39
|
-
version_requirements: *
|
39
|
+
version_requirements: *70298725074800
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: timecop
|
42
|
-
requirement: &
|
42
|
+
requirement: &70298725074220 !ruby/object:Gem::Requirement
|
43
43
|
none: false
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
@@ -47,10 +47,10 @@ dependencies:
|
|
47
47
|
version: 0.3.5
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
|
-
version_requirements: *
|
50
|
+
version_requirements: *70298725074220
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
52
|
name: rr
|
53
|
-
requirement: &
|
53
|
+
requirement: &70298725073680 !ruby/object:Gem::Requirement
|
54
54
|
none: false
|
55
55
|
requirements:
|
56
56
|
- - ~>
|
@@ -58,10 +58,10 @@ dependencies:
|
|
58
58
|
version: 1.0.4
|
59
59
|
type: :development
|
60
60
|
prerelease: false
|
61
|
-
version_requirements: *
|
61
|
+
version_requirements: *70298725073680
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: artifice
|
64
|
-
requirement: &
|
64
|
+
requirement: &70298725073100 !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
@@ -69,10 +69,10 @@ dependencies:
|
|
69
69
|
version: '0.6'
|
70
70
|
type: :development
|
71
71
|
prerelease: false
|
72
|
-
version_requirements: *
|
72
|
+
version_requirements: *70298725073100
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: haml
|
75
|
-
requirement: &
|
75
|
+
requirement: &70298725072560 !ruby/object:Gem::Requirement
|
76
76
|
none: false
|
77
77
|
requirements:
|
78
78
|
- - ~>
|
@@ -80,10 +80,10 @@ dependencies:
|
|
80
80
|
version: 3.1.3
|
81
81
|
type: :development
|
82
82
|
prerelease: false
|
83
|
-
version_requirements: *
|
83
|
+
version_requirements: *70298725072560
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: test-unit
|
86
|
-
requirement: &
|
86
|
+
requirement: &70298725071980 !ruby/object:Gem::Requirement
|
87
87
|
none: false
|
88
88
|
requirements:
|
89
89
|
- - ~>
|
@@ -91,10 +91,10 @@ dependencies:
|
|
91
91
|
version: 1.2.3
|
92
92
|
type: :runtime
|
93
93
|
prerelease: false
|
94
|
-
version_requirements: *
|
94
|
+
version_requirements: *70298725071980
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: rest-client
|
97
|
-
requirement: &
|
97
|
+
requirement: &70298725071440 !ruby/object:Gem::Requirement
|
98
98
|
none: false
|
99
99
|
requirements:
|
100
100
|
- - ~>
|
@@ -102,10 +102,10 @@ dependencies:
|
|
102
102
|
version: 1.6.7
|
103
103
|
type: :runtime
|
104
104
|
prerelease: false
|
105
|
-
version_requirements: *
|
105
|
+
version_requirements: *70298725071440
|
106
106
|
- !ruby/object:Gem::Dependency
|
107
107
|
name: yajl-ruby
|
108
|
-
requirement: &
|
108
|
+
requirement: &70298725070860 !ruby/object:Gem::Requirement
|
109
109
|
none: false
|
110
110
|
requirements:
|
111
111
|
- - ~>
|
@@ -113,10 +113,10 @@ dependencies:
|
|
113
113
|
version: 0.8.3
|
114
114
|
type: :runtime
|
115
115
|
prerelease: false
|
116
|
-
version_requirements: *
|
116
|
+
version_requirements: *70298725070860
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: term-ansicolor
|
119
|
-
requirement: &
|
119
|
+
requirement: &70298725070320 !ruby/object:Gem::Requirement
|
120
120
|
none: false
|
121
121
|
requirements:
|
122
122
|
- - ~>
|
@@ -124,10 +124,10 @@ dependencies:
|
|
124
124
|
version: 1.0.6
|
125
125
|
type: :runtime
|
126
126
|
prerelease: false
|
127
|
-
version_requirements: *
|
127
|
+
version_requirements: *70298725070320
|
128
128
|
- !ruby/object:Gem::Dependency
|
129
129
|
name: launchy
|
130
|
-
requirement: &
|
130
|
+
requirement: &70298725004540 !ruby/object:Gem::Requirement
|
131
131
|
none: false
|
132
132
|
requirements:
|
133
133
|
- - ~>
|
@@ -135,10 +135,10 @@ dependencies:
|
|
135
135
|
version: 2.0.5
|
136
136
|
type: :runtime
|
137
137
|
prerelease: false
|
138
|
-
version_requirements: *
|
138
|
+
version_requirements: *70298725004540
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: mechanize
|
141
|
-
requirement: &
|
141
|
+
requirement: &70298725003960 !ruby/object:Gem::Requirement
|
142
142
|
none: false
|
143
143
|
requirements:
|
144
144
|
- - ~>
|
@@ -146,7 +146,7 @@ dependencies:
|
|
146
146
|
version: 1.0.0
|
147
147
|
type: :runtime
|
148
148
|
prerelease: false
|
149
|
-
version_requirements: *
|
149
|
+
version_requirements: *70298725003960
|
150
150
|
description: Kensa is a command-line tool to help add-on providers integrating their
|
151
151
|
services with Heroku. It manages manifest files, and provides a TDD-like approach
|
152
152
|
for programmers to test and develop their APIs.
|
@@ -171,6 +171,8 @@ files:
|
|
171
171
|
- lib/heroku/kensa/sso.rb
|
172
172
|
- lib/heroku/kensa/version.rb
|
173
173
|
- set-env.sh
|
174
|
+
- test.rb
|
175
|
+
- test/create_test.rb
|
174
176
|
- test/deprovision_test.rb
|
175
177
|
- test/helper.rb
|
176
178
|
- test/lib/dependencies.rb
|
@@ -210,6 +212,7 @@ signing_key:
|
|
210
212
|
specification_version: 3
|
211
213
|
summary: Tool to help Heroku add-on providers integrating their services
|
212
214
|
test_files:
|
215
|
+
- test/create_test.rb
|
213
216
|
- test/deprovision_test.rb
|
214
217
|
- test/helper.rb
|
215
218
|
- test/lib/dependencies.rb
|