stackfu 0.1.1 → 0.1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/Gemfile +4 -0
  2. data/Manifest +36 -4
  3. data/Rakefile +1 -1
  4. data/autotest/discover.rb +1 -0
  5. data/firewall/config/01-controls.yml +5 -0
  6. data/firewall/config/02-requirements.yml +4 -0
  7. data/firewall/config/03-executions.yml +6 -0
  8. data/firewall/config/03-scripts.yml +6 -0
  9. data/firewall/config/04-validations.yml +4 -0
  10. data/firewall/executables/configure_ufw.sh.erb +9 -0
  11. data/firewall/executables/install_ufw.sh.erb +7 -0
  12. data/firewall/script/configure_ufw.sh.erb +9 -0
  13. data/firewall/script/install_ufw.sh.erb +7 -0
  14. data/firewall/script.yml +8 -0
  15. data/lib/stackfu/api_hooks.rb +2 -2
  16. data/lib/stackfu/app.rb +5 -5
  17. data/lib/stackfu/commands/command.rb +7 -3
  18. data/lib/stackfu/commands/config_command.rb +1 -1
  19. data/lib/stackfu/commands/deploy_command.rb +53 -61
  20. data/lib/stackfu/commands/dump_command.rb +46 -40
  21. data/lib/stackfu/commands/generate_command.rb +10 -12
  22. data/lib/stackfu/commands/help_command.rb +1 -1
  23. data/lib/stackfu/commands/list_command.rb +76 -22
  24. data/lib/stackfu/commands/publish_command.rb +35 -18
  25. data/lib/stackfu/commands/server_command.rb +124 -124
  26. data/lib/stackfu/date_helper.rb +111 -0
  27. data/lib/stackfu.rb +4 -2
  28. data/spec/fixtures/scripts/all.json +11 -0
  29. data/spec/fixtures/scripts/create.json +10 -0
  30. data/spec/fixtures/scripts/delete.json +10 -0
  31. data/spec/fixtures/scripts/firewall.json +12 -0
  32. data/spec/fixtures/scripts/none.json +12 -0
  33. data/spec/fixtures/scripts/not_found.json +11 -0
  34. data/spec/fixtures/scripts/script_not_found.json +11 -0
  35. data/spec/fixtures/servers/all.json +12 -0
  36. data/spec/fixtures/servers/cannot_deploy.json +0 -0
  37. data/spec/fixtures/servers/deploy.json +290 -0
  38. data/spec/fixtures/servers/none.json +12 -0
  39. data/spec/fixtures/servers/not_found.json +11 -0
  40. data/spec/fixtures/servers/webbynode/deploy.json +12 -0
  41. data/spec/fixtures/servers/webbynode.json +12 -0
  42. data/spec/spec_helper.rb +191 -0
  43. data/spec/stackfu/api_hooks_spec.rb +7 -0
  44. data/spec/stackfu/commands/deploy_command_spec.rb +65 -0
  45. data/spec/stackfu/commands/dump_command_spec.rb +47 -0
  46. data/spec/stackfu/commands/generate_command_spec.rb +90 -0
  47. data/spec/stackfu/commands/list_command_spec.rb +53 -0
  48. data/spec/stackfu/commands/publish_command_spec.rb +67 -0
  49. data/stackfu.gemspec +4 -4
  50. data/templates/02-requirements.yml.erb +8 -10
  51. data/templates/{03-scripts.yml.erb → 03-executions.yml.erb} +3 -3
  52. data/templates/04-validations.yml.erb +1 -2
  53. data/templates/stack.yml.erb +4 -13
  54. data/test/support/fixtures.rb +1 -1
  55. data/test/unit/commands/test_server_command.rb +259 -259
  56. metadata +42 -7
  57. data/test/stack.yml +0 -26
  58. /data/stackfu-installer/config/{03-scripts.yml → 03-executions.yml} +0 -0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :gemcutter
2
+
3
+ gem 'webmock', '~>1.3.4'
4
+ gem 'rspec', '2.0.0.beta.19'
data/Manifest CHANGED
@@ -1,9 +1,21 @@
1
1
  CHANGELOG
2
+ Gemfile
2
3
  Manifest
3
4
  README
4
5
  README.md
5
6
  Rakefile
7
+ autotest/discover.rb
6
8
  bin/stackfu
9
+ firewall/config/01-controls.yml
10
+ firewall/config/02-requirements.yml
11
+ firewall/config/03-executions.yml
12
+ firewall/config/03-scripts.yml
13
+ firewall/config/04-validations.yml
14
+ firewall/executables/configure_ufw.sh.erb
15
+ firewall/executables/install_ufw.sh.erb
16
+ firewall/script.yml
17
+ firewall/script/configure_ufw.sh.erb
18
+ firewall/script/install_ufw.sh.erb
7
19
  lib/stackfu.rb
8
20
  lib/stackfu/api_hooks.rb
9
21
  lib/stackfu/app.rb
@@ -16,12 +28,34 @@ lib/stackfu/commands/help_command.rb
16
28
  lib/stackfu/commands/list_command.rb
17
29
  lib/stackfu/commands/publish_command.rb
18
30
  lib/stackfu/commands/server_command.rb
31
+ lib/stackfu/date_helper.rb
19
32
  lib/stackfu/helpers/providers_credentials.rb
20
33
  lib/stackfu/helpers/rendering.rb
21
34
  lib/stackfu/operating_systems.rb
35
+ spec/fixtures/scripts/all.json
36
+ spec/fixtures/scripts/create.json
37
+ spec/fixtures/scripts/delete.json
38
+ spec/fixtures/scripts/firewall.json
39
+ spec/fixtures/scripts/none.json
40
+ spec/fixtures/scripts/not_found.json
41
+ spec/fixtures/scripts/script_not_found.json
42
+ spec/fixtures/servers/all.json
43
+ spec/fixtures/servers/cannot_deploy.json
44
+ spec/fixtures/servers/deploy.json
45
+ spec/fixtures/servers/none.json
46
+ spec/fixtures/servers/not_found.json
47
+ spec/fixtures/servers/webbynode.json
48
+ spec/fixtures/servers/webbynode/deploy.json
49
+ spec/spec_helper.rb
50
+ spec/stackfu/api_hooks_spec.rb
51
+ spec/stackfu/commands/deploy_command_spec.rb
52
+ spec/stackfu/commands/dump_command_spec.rb
53
+ spec/stackfu/commands/generate_command_spec.rb
54
+ spec/stackfu/commands/list_command_spec.rb
55
+ spec/stackfu/commands/publish_command_spec.rb
22
56
  stackfu-installer/config/01-controls.yml
23
57
  stackfu-installer/config/02-requirements.yml
24
- stackfu-installer/config/03-scripts.yml
58
+ stackfu-installer/config/03-executions.yml
25
59
  stackfu-installer/config/04-validations.yml
26
60
  stackfu-installer/script/dotfiles_installation.sh.erb
27
61
  stackfu-installer/script/github_credentials_setup.sh.erb
@@ -31,10 +65,9 @@ stackfu-installer/script/resque_installation.sh.erb
31
65
  stackfu-installer/script/ruby_environment.sh.erb
32
66
  stackfu-installer/script/stackfu.sh.erb
33
67
  stackfu-installer/stack.yml
34
- stackfu.gemspec
35
68
  templates/01-controls.yml.erb
36
69
  templates/02-requirements.yml.erb
37
- templates/03-scripts.yml.erb
70
+ templates/03-executions.yml.erb
38
71
  templates/04-validations.yml.erb
39
72
  templates/script.sh.erb
40
73
  templates/stack.yml.erb
@@ -97,7 +130,6 @@ test/fixtures/stacks_with_controls
97
130
  test/fixtures/users
98
131
  test/fixtures/users_no_credentials
99
132
  test/fixtures/users_update
100
- test/stack.yml
101
133
  test/support/custom_matchers.rb
102
134
  test/support/fixtures.rb
103
135
  test/support/io_stub.rb
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/testtask'
4
4
 
5
5
  require 'echoe'
6
6
 
7
- Echoe.new('stackfu', '0.1.1') do |p|
7
+ Echoe.new('stackfu', '0.1.2.1') do |p|
8
8
  p.description = "StackFu Backend"
9
9
  p.url = "http://stackfu.com/cli"
10
10
  p.author = "Felipe Coury"
@@ -0,0 +1 @@
1
+ Autotest.add_discovery { "rspec2" }
@@ -0,0 +1,5 @@
1
+ ---
2
+ controls:
3
+ - label: Ports
4
+ name: Ports
5
+ type: Textbox
@@ -0,0 +1,4 @@
1
+ ---
2
+ requirements:
3
+ - data: apt-get
4
+ type: ExecutableExists
@@ -0,0 +1,6 @@
1
+ ---
2
+ executions:
3
+ - file: install_ufw
4
+ description: Install Ufw
5
+ - file: configure_ufw
6
+ description: Configure Ufw
@@ -0,0 +1,6 @@
1
+ ---
2
+ scripts:
3
+ - file: install_ufw
4
+ description: Install Ufw
5
+ - file: configure_ufw
6
+ description: Configure Ufw
@@ -0,0 +1,4 @@
1
+ ---
2
+ validations:
3
+ - data: ufw
4
+ type: ExecutableExists
@@ -0,0 +1,9 @@
1
+ #
2
+ # install_ufw.sh
3
+ # Tue Dec 01 15:06:48 -0200 2009
4
+ #
5
+
6
+ ufw default deny
7
+ <% ports.split(",").each do |port| %>
8
+ ufw allow <%= port %>
9
+ <% end %>
@@ -0,0 +1,7 @@
1
+ #
2
+ # configure_ufw.sh
3
+ # Tue Dec 01 15:06:48 -0200 2009
4
+ #
5
+
6
+ apt-get update
7
+ apt-get install -y ufw
@@ -0,0 +1,9 @@
1
+ #
2
+ # install_ufw.sh
3
+ # Tue Dec 01 15:06:48 -0200 2009
4
+ #
5
+
6
+ ufw default deny
7
+ <% ports.split(",").each do |port| %>
8
+ ufw allow <%= port %>
9
+ <% end %>
@@ -0,0 +1,7 @@
1
+ #
2
+ # configure_ufw.sh
3
+ # Tue Dec 01 15:06:48 -0200 2009
4
+ #
5
+
6
+ apt-get update
7
+ apt-get install -y ufw
@@ -0,0 +1,8 @@
1
+ ---
2
+ name: firewall
3
+ type: script
4
+ description: |-
5
+ Set up a firewall for your server to improve security.
6
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit.
7
+ Praesent eget erat libero, id malesuada tortor.
8
+ Donec pharetra sapien et nulla ultricies ac pharetra neque vulputate.
@@ -7,12 +7,12 @@ module StackFu
7
7
  class Server < Resource; end
8
8
  class User < Resource; end
9
9
  class Stack < Resource; end
10
- class Plugin < Resource; end
10
+ class Script < Resource; end
11
11
  class Provider < Resource; end
12
12
  class Deployment < Resource; end
13
13
 
14
14
  def initialize_api(config)
15
- [Server, User, Stack, Plugin, Provider, Deployment].each do |model_class|
15
+ [Server, User, Stack, Script, Provider, Deployment].each do |model_class|
16
16
  model_class.user = $config[:token]
17
17
  model_class.password = "X"
18
18
  model_class.site = StackFu::API
data/lib/stackfu/app.rb CHANGED
@@ -19,7 +19,7 @@ module StackFu
19
19
  def execute
20
20
  begin
21
21
  command = @args.delete_at(0)
22
- cmd = Command.create(command, @args)
22
+ cmd = Commands::Command.create(command, @args)
23
23
  cmd.run
24
24
  rescue Errno::ECONNREFUSED
25
25
  error "Could not connect to StackFu server.",
@@ -36,13 +36,13 @@ module StackFu
36
36
  "Please report this problem at support@stackfu.com or try again in a few minutes."
37
37
  raise if $dev
38
38
 
39
- rescue Exceptions::UnknownCommand
39
+ rescue Commands::Exceptions::UnknownCommand
40
40
  error "Command #{command} does not exist", "Try using 'stackfu help' for a summary of available commands."
41
41
 
42
- rescue Exceptions::InvalidCommand
42
+ rescue Commands::Exceptions::InvalidCommand
43
43
  error "Command #{command} is invalid", $!.message
44
44
 
45
- rescue Exceptions::InvalidSubcommand
45
+ rescue Commands::Exceptions::InvalidSubcommand
46
46
  error "Invalid usage for command #{command}", $!.message
47
47
  end
48
48
  end
@@ -54,7 +54,7 @@ module StackFu
54
54
  puts ""
55
55
  puts "To get you up to speed, we need you to provide us a couple of configuration settings that will follow."
56
56
  puts
57
- ConfigCommand.new.run
57
+ Commands::ConfigCommand.new.run
58
58
  true
59
59
  end
60
60
 
@@ -1,4 +1,4 @@
1
- module StackFu
1
+ module StackFu::Commands
2
2
  class Command
3
3
  include StackFu::OperatingSystems
4
4
  include StackFu::Rendering
@@ -15,7 +15,7 @@ module StackFu
15
15
  end
16
16
 
17
17
  def command_for(command)
18
- StackFu.const_get("#{command.camelize}Command")
18
+ StackFu::Commands.const_get("#{command.camelize}Command")
19
19
  rescue NameError
20
20
  raise Exceptions::UnknownCommand
21
21
  end
@@ -97,7 +97,10 @@ module StackFu
97
97
  end
98
98
 
99
99
  def parse_options(args)
100
- @subcommand = args.pop unless args.last =~ /^-(.*)/
100
+ if self.class.subcommand_options and !self.class.subcommand_options.empty?
101
+ @subcommand = args.pop unless args.last =~ /^-(.*)/
102
+ end
103
+
101
104
  @subcommand ||= "default"
102
105
  @parameters = []
103
106
  @options = {}
@@ -121,6 +124,7 @@ module StackFu
121
124
  end
122
125
  end
123
126
 
127
+
124
128
  @subcommand = self.class.send(:resolve, @subcommand)
125
129
  end
126
130
  end
@@ -1,4 +1,4 @@
1
- module StackFu
1
+ module StackFu::Commands
2
2
  class ConfigCommand < Command
3
3
  include StackFu::ApiHooks
4
4
  include StackFu::ProvidersCredentials
@@ -1,27 +1,17 @@
1
- module StackFu
1
+ module StackFu::Commands
2
2
  class DeployCommand < Command
3
- include ApiHooks
3
+ include StackFu::ApiHooks
4
4
 
5
- error_messages :missing_subcommand => "You have to tell what you want to deploy (a stack or a plugin) and to which server."
5
+ # error_messages :missing_subcommand => "You have to tell what you want to deploy and to which server."
6
+ # subcommand :script, :required_parameters => [:plugin_name, :server]
6
7
 
7
- subcommand :plugin, :required_parameters => [:plugin_name, :server]
8
- subcommand :stack, :required_parameters => [:stack_name, :server]
9
-
10
- def plugin(parameters, options)
11
- execute "plugin", parameters, options, false do |target|
8
+ def default(parameters, options)
9
+ execute "script", parameters, options, false do |target|
12
10
  puts "*** Preparing: #{target.name.foreground(:yellow).bright}"
13
11
  puts " #{target.description}"
14
12
  puts ""
15
13
  end
16
14
  end
17
-
18
- def stack(parameters, options)
19
- execute "stack", parameters, options, true do |target|
20
- puts "*** Deploying: #{target.name.foreground(:yellow).bright} (based on #{os_name(target.operating_system.to_sym).foreground(:yellow)})"
21
- puts " #{target.description}"
22
- puts ""
23
- end
24
- end
25
15
 
26
16
  private
27
17
 
@@ -30,26 +20,44 @@ module StackFu
30
20
  server_name = parameters[1]
31
21
 
32
22
  target_class = StackFu::ApiHooks.const_get(target.capitalize)
33
-
34
- targets = target_class.find(:all, :params => { target.to_sym => { :name => target_name } })
35
- unless targets.any?
23
+ begin
24
+ target = target_class.find(target_name)
25
+ rescue ActiveResource::ResourceNotFound
26
+ error "#{target.capitalize} '#{target_name}' was not found"
27
+ return
28
+ end
29
+
30
+ begin
31
+ target = target_class.find(target_name)
32
+ rescue ActiveResource::ResourceNotFound
33
+ error "#{target.capitalize} '#{target_name}' was not found"
34
+ return
35
+ end
36
+
37
+ unless target
36
38
  error "#{target.capitalize} '#{target_name}' was not found"
37
39
  return
38
40
  end
39
41
 
40
- server = Server.find(:all, :params => { :server => { :hostname => server_name } })
41
- unless server.any?
42
- error "Server '#{server_name}' was not found.",
43
- "You can add servers 'stackfu server add' or list your current servers with 'stackfu servers'."
42
+ begin
43
+ server = Server.find(server_name)
44
+ rescue ActiveResource::ResourceNotFound
45
+ error "Server '#{server_name}' was not found"
44
46
  return
45
47
  end
46
48
 
47
- return targets.first, server
49
+ return target, server
48
50
  end
49
51
 
50
52
  def execute(target_name, parameters, options, stack)
53
+ if parameters.size < 2
54
+ puts "You have to tell which script you want to deploy and to which server."
55
+ puts "Usage: stackfu deploy [script] [server]"
56
+ return
57
+ end
58
+
51
59
  target, server = extract_settings(target_name)
52
- return unless target
60
+ return unless target and server
53
61
 
54
62
  yield target
55
63
 
@@ -78,31 +86,15 @@ module StackFu
78
86
  puts ""
79
87
  end
80
88
 
81
- continue = if stack
82
- warning "This will destroy current contents of your server. Are you sure?\n"
83
- else
84
- agree "Continue with plugin installation?\n"
85
- end
86
-
87
- unless continue
89
+ unless agree "Continue with script installation?\n"
88
90
  puts "Aborted."
89
91
  return false
90
92
  end
91
-
92
- item = target if stack
93
- hash = { :stack => item, :server_id => server.first.id, :params => params }
94
-
95
- unless stack
96
- hash[:plugin_ids] = [target.id]
97
- end
98
93
 
99
- deployment = Deployment.new(hash)
94
+ server_id = server.id
95
+ server.id = server.slug
96
+ deployment = server.post(:deploy, {}, { :id => server_id, :script_id => target.slug, :params => params }.to_json)
100
97
 
101
- unless deployment.save
102
- error "There was a problem submitting your deployment: #{deployment.errors.full_messages.to_s}"
103
- return
104
- end
105
-
106
98
  if options[:"no-follow"]
107
99
  puts "Your deployment have been submitted"
108
100
  return
@@ -110,22 +102,22 @@ module StackFu
110
102
 
111
103
  verbose = options[:verbose]
112
104
 
113
- from = nil
114
- while true
115
- opts = {:formatted => "true", :from => from}
116
- opts.merge!(:verbose => "true") if verbose
117
-
118
- status = spinner {
119
- Deployment.find(deployment.id).get(:logs, opts)
120
- }
121
-
122
- if status["id"]
123
- show_log status["log"]
124
- from = status["id"]
125
- end
126
-
127
- break if status["state"] == "finished" or status["state"] == "failed"
128
- end
105
+ # from = nil
106
+ # while true
107
+ # opts = {:formatted => "true", :from => from}
108
+ # opts.merge!(:verbose => "true") if verbose
109
+ #
110
+ # status = spinner {
111
+ # Deployment.find(deployment.id).get(:logs, opts)
112
+ # }
113
+ #
114
+ # if status["id"]
115
+ # show_log status["log"]
116
+ # from = status["id"]
117
+ # end
118
+ #
119
+ # break if status["state"] == "finished" or status["state"] == "failed"
120
+ # end
129
121
 
130
122
  end
131
123
 
@@ -1,33 +1,41 @@
1
- module StackFu
1
+ module StackFu::Commands
2
2
  class DumpCommand < Command
3
- include ApiHooks
3
+ include StackFu::ApiHooks
4
4
 
5
- error_messages :missing_subcommand => "You have to tell what you want to dump: a stack or a plugin"
6
- subcommand :plugin, :required_parameters => [:plugin_name]
7
-
8
- def plugin(parameters, options)
9
- stack_name = parameters[0]
10
- stack = spinner { Plugin.find(stack_name) }
5
+ def default(parameters, options)
6
+ script_name = parameters[0]
7
+
8
+ unless script_name
9
+ puts "You have to tell which script you want to dump."
10
+ return
11
+ end
12
+
13
+ script = spinner {
14
+ begin
15
+ Script.find(script_name)
16
+ rescue ActiveResource::ResourceNotFound
17
+ end
18
+ }
11
19
 
12
- if stack
13
- if directory?(stack_name)
14
- unless agree("There is already a folder called '#{stack_name}'. Do you want to overwrite its contents?")
20
+ if script
21
+ if directory?(script_name)
22
+ unless agree("There is already a folder called '#{script_name}'. Do you want to overwrite its contents?")
15
23
  puts "Aborted."
16
24
  return false
17
25
  end
18
26
  end
19
27
 
20
- create_folder(stack_name)
21
- create_file "#{stack_name}/stack.yml", {
22
- "type" => "stack",
23
- "name" => stack.name,
24
- "description" => stack.respond_to?(:description) ? stack.description : ""
28
+ create_folder(script_name)
29
+ create_file "#{script_name}/script.yml", {
30
+ "type" => "script",
31
+ "name" => script.name,
32
+ "description" => script.respond_to?(:description) ? script.description : ""
25
33
  }.to_yaml
26
34
 
27
- create_folder "#{stack_name}/config"
35
+ create_folder "#{script_name}/config"
28
36
 
29
- if stack.respond_to?(:controls)
30
- controls = map stack.controls, "controls" do |c|
37
+ if script.respond_to?(:controls)
38
+ controls = map script.controls, "controls" do |c|
31
39
  { "name" => c.name,
32
40
  "label" => c.label,
33
41
  "type" => c._type }
@@ -36,18 +44,17 @@ module StackFu
36
44
  controls = []
37
45
  end
38
46
 
39
- if stack.respond_to?(:requirements)
40
- requirements = map stack.requirements, "requirements" do |req|
41
- { "data" => req.data,
42
- "error" => req.error,
43
- "type" => req._type }
47
+ if script.respond_to?(:requirements)
48
+ requirements = map script.requirements, "requirements" do |req|
49
+ { "data" => req.params.attributes["data"],
50
+ "type" => req._type }
44
51
  end
45
52
  else
46
53
  requirements = []
47
54
  end
48
55
 
49
- if stack.respond_to?(:executions)
50
- executions = map stack.executions, "scripts" do |exec|
56
+ if script.respond_to?(:executions)
57
+ executions = map script.executions, "executions" do |exec|
51
58
  { "description" => exec.description,
52
59
  "file" => exec.description.downcase.gsub(" ", "_") }
53
60
  end
@@ -56,29 +63,28 @@ module StackFu
56
63
  end
57
64
 
58
65
 
59
- if stack.respond_to?(:validations)
60
- validations = map stack.validations, "validations" do |val|
61
- { "data" => val.data,
62
- "error" => val.error,
63
- "type" => val._type }
66
+ if script.respond_to?(:validations)
67
+ validations = map script.validations, "validations" do |val|
68
+ { "data" => val.params.attributes["data"],
69
+ "type" => val._type }
64
70
  end
65
71
  else
66
72
  validations = []
67
73
  end
68
74
 
69
- create_file "#{stack_name}/config/01-controls.yml", controls
70
- create_file "#{stack_name}/config/02-requirements.yml", requirements
71
- create_file "#{stack_name}/config/03-scripts.yml", executions
72
- create_file "#{stack_name}/config/04-validations.yml", validations
75
+ create_file "#{script_name}/config/01-controls.yml", controls
76
+ create_file "#{script_name}/config/02-requirements.yml", requirements
77
+ create_file "#{script_name}/config/03-executions.yml", executions
78
+ create_file "#{script_name}/config/04-validations.yml", validations
73
79
 
74
- create_folder "#{stack_name}/script"
75
- stack.executions.each do |script|
76
- create_file "#{stack_name}/script/#{script.description.downcase.gsub(" ", "_")}.sh.erb", script.script
80
+ create_folder "#{script_name}/executables"
81
+ script.executions.each do |script|
82
+ create_file "#{script_name}/executables/#{script.description.downcase.gsub(" ", "_")}.sh.erb", script.body
77
83
  end
78
84
 
79
- puts "Stack #{stack_name} dumped successfully..."
85
+ puts "Script #{script_name} dumped successfully..."
80
86
  else
81
- puts "Stack '#{stack_name}' was not found"
87
+ puts "Script '#{script_name}' was not found"
82
88
  end
83
89
  end
84
90
 
@@ -1,12 +1,9 @@
1
1
  require 'erb'
2
2
  require 'ostruct'
3
3
 
4
- module StackFu
4
+ module StackFu::Commands
5
5
  class GenerateCommand < Command
6
6
  aliases :create
7
- subcommand :stack, :required_parameters => [:stack_name]
8
- subcommand :plugin, :required_parameters => [:plugin_name]
9
- error_messages :missing_subcommand => "You have to tell what you want to generate: a stack or a plugin."
10
7
 
11
8
  Types = {
12
9
  [:checkbox, :numericbox, :combobox, :password, :radio, :textbox] => :control
@@ -30,7 +27,8 @@ module StackFu
30
27
  generate("stack", parameters, options)
31
28
  end
32
29
 
33
- def generate(what, parameters, options)
30
+ def default(parameters, options)
31
+ what = 'script'
34
32
  begin
35
33
  item_name = parameters.shift
36
34
  items = {}
@@ -38,8 +36,8 @@ module StackFu
38
36
  name, type = p.split(":")
39
37
 
40
38
  case type(type)
41
- when :script
42
- (items["scripts"]||=[]) << [name, template("script.sh.erb", {
39
+ when :execution, :script
40
+ (items["executions"]||=[]) << [name, template("script.sh.erb", {
43
41
  "filename" => name,
44
42
  "description" => name.titleize
45
43
  })]
@@ -56,13 +54,13 @@ module StackFu
56
54
 
57
55
  stack = template("stack.yml.erb", {
58
56
  "name" => item_name,
59
- "description" => "Enter a description for this stack here"
57
+ "description" => "Enter a description for this script here"
60
58
  })
61
59
 
62
60
  create("#{item_name}", "#{what}.yml", stack)
63
61
 
64
62
  i = 1
65
- %w[controls requirements scripts validations].each do |item|
63
+ %w[controls requirements executions validations].each do |item|
66
64
  template_name = "0#{i}-#{item}.yml"
67
65
  create "#{item_name}/config", template_name, template("#{template_name}.erb", {
68
66
  item => items[item]
@@ -70,9 +68,9 @@ module StackFu
70
68
  i += 1
71
69
  end
72
70
 
73
- items["scripts"].try(:each) do |item|
74
- create("#{item_name}/script", "#{item.first}.sh.erb", item.last)
75
- end or create("#{item_name}/script")
71
+ items["executions"].try(:each) do |item|
72
+ create("#{item_name}/executables", "#{item.first}.sh.erb", item.last)
73
+ end or create("#{item_name}/executables")
76
74
 
77
75
  puts "#{what.titleize} #{item_name} created successfully"
78
76
  rescue Exceptions::InvalidParameter
@@ -1,4 +1,4 @@
1
- module StackFu
1
+ module StackFu::Commands
2
2
  class HelpCommand < Command
3
3
  def default(parameters, options)
4
4
  stackfu = "stackfu".foreground(:green).bright