hem 1.0.1.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +10 -0
  3. data/.gitignore +3 -0
  4. data/.rspec +2 -0
  5. data/CHANGELOG.md +125 -0
  6. data/DoD.md +5 -0
  7. data/Gemfile +4 -0
  8. data/Gemfile.lock +71 -0
  9. data/Guardfile +14 -0
  10. data/Hemfile +43 -0
  11. data/LICENSE +21 -0
  12. data/README.md +42 -0
  13. data/Rakefile +23 -0
  14. data/bin/hem +64 -0
  15. data/features/deps.feature +43 -0
  16. data/features/hem/basic.feature +43 -0
  17. data/features/hem/help.feature +16 -0
  18. data/features/hem/subcommands.feature +15 -0
  19. data/features/seed/plant.feature +64 -0
  20. data/features/step_definitions/env.rb +6 -0
  21. data/features/step_definitions/seed.rb +11 -0
  22. data/features/support/env.rb +6 -0
  23. data/hem.gemspec +47 -0
  24. data/lib/hem/asset_applicator.rb +33 -0
  25. data/lib/hem/asset_applicators/files.rb +5 -0
  26. data/lib/hem/asset_applicators/sqldump.rb +38 -0
  27. data/lib/hem/cli.rb +252 -0
  28. data/lib/hem/config/file.rb +22 -0
  29. data/lib/hem/config.rb +5 -0
  30. data/lib/hem/error_handlers/debug.rb +12 -0
  31. data/lib/hem/error_handlers/exit_code_map.rb +17 -0
  32. data/lib/hem/error_handlers/friendly.rb +58 -0
  33. data/lib/hem/errors.rb +89 -0
  34. data/lib/hem/help_formatter.rb +118 -0
  35. data/lib/hem/helper/file_locator.rb +44 -0
  36. data/lib/hem/helper/github.rb +10 -0
  37. data/lib/hem/helper/http_download.rb +41 -0
  38. data/lib/hem/helper/shell.rb +101 -0
  39. data/lib/hem/helper/vm_command.rb +30 -0
  40. data/lib/hem/lib/github/api.rb +48 -0
  41. data/lib/hem/lib/github/client.rb +52 -0
  42. data/lib/hem/lib/host_check/deps.rb +39 -0
  43. data/lib/hem/lib/host_check/git.rb +76 -0
  44. data/lib/hem/lib/host_check/ruby.rb +53 -0
  45. data/lib/hem/lib/host_check/vagrant.rb +45 -0
  46. data/lib/hem/lib/host_check.rb +34 -0
  47. data/lib/hem/lib/s3/local/file.rb +40 -0
  48. data/lib/hem/lib/s3/local/iohandler.rb +36 -0
  49. data/lib/hem/lib/s3/remote/file.rb +57 -0
  50. data/lib/hem/lib/s3/remote/iohandler.rb +38 -0
  51. data/lib/hem/lib/s3/sync.rb +134 -0
  52. data/lib/hem/lib/seed/project.rb +71 -0
  53. data/lib/hem/lib/seed/replacer.rb +56 -0
  54. data/lib/hem/lib/seed/seed.rb +111 -0
  55. data/lib/hem/lib/self_signed_cert_generator.rb +38 -0
  56. data/lib/hem/lib/vm/command.rb +131 -0
  57. data/lib/hem/lib/vm/inspector.rb +73 -0
  58. data/lib/hem/logging.rb +20 -0
  59. data/lib/hem/metadata.rb +42 -0
  60. data/lib/hem/null.rb +31 -0
  61. data/lib/hem/patches/deepstruct.rb +21 -0
  62. data/lib/hem/patches/rake.rb +101 -0
  63. data/lib/hem/patches/rubygems.rb +6 -0
  64. data/lib/hem/patches/slop.rb +69 -0
  65. data/lib/hem/paths.rb +96 -0
  66. data/lib/hem/tasks/assets.rb +92 -0
  67. data/lib/hem/tasks/config.rb +15 -0
  68. data/lib/hem/tasks/deps.rb +103 -0
  69. data/lib/hem/tasks/exec.rb +3 -0
  70. data/lib/hem/tasks/magento.rb +281 -0
  71. data/lib/hem/tasks/ops.rb +6 -0
  72. data/lib/hem/tasks/pr.rb +45 -0
  73. data/lib/hem/tasks/seed.rb +61 -0
  74. data/lib/hem/tasks/self.rb +45 -0
  75. data/lib/hem/tasks/shell_init.rb +25 -0
  76. data/lib/hem/tasks/system/completions.rb +76 -0
  77. data/lib/hem/tasks/system.rb +18 -0
  78. data/lib/hem/tasks/tools.rb +17 -0
  79. data/lib/hem/tasks/vm.rb +140 -0
  80. data/lib/hem/ui.rb +182 -0
  81. data/lib/hem/util.rb +76 -0
  82. data/lib/hem/version.rb +3 -0
  83. data/lib/hem.rb +72 -0
  84. data/lib/hobo/tasks/magento.rb +3 -0
  85. data/spec/hem/asset_applicator_spec.rb +30 -0
  86. data/spec/hem/cli_spec.rb +166 -0
  87. data/spec/hem/config/file_spec.rb +55 -0
  88. data/spec/hem/error_handlers/debug_spec.rb +43 -0
  89. data/spec/hem/error_handlers/friendly_spec.rb +97 -0
  90. data/spec/hem/error_spec.rb +0 -0
  91. data/spec/hem/help_formatter_spec.rb +162 -0
  92. data/spec/hem/helpers/file_locator_spec.rb +11 -0
  93. data/spec/hem/helpers/github_spec.rb +31 -0
  94. data/spec/hem/helpers/shell_spec.rb +22 -0
  95. data/spec/hem/helpers/vm_command_spec.rb +96 -0
  96. data/spec/hem/lib/github/api_spec.rb +92 -0
  97. data/spec/hem/lib/s3/sync_spec.rb +16 -0
  98. data/spec/hem/lib/seed/project_spec.rb +80 -0
  99. data/spec/hem/lib/seed/replacer_spec.rb +45 -0
  100. data/spec/hem/lib/seed/seed_spec.rb +127 -0
  101. data/spec/hem/logging_spec.rb +27 -0
  102. data/spec/hem/metadata_spec.rb +55 -0
  103. data/spec/hem/null_spec.rb +30 -0
  104. data/spec/hem/patches/rake_spec.rb +230 -0
  105. data/spec/hem/paths_spec.rb +75 -0
  106. data/spec/hem/ui_spec.rb +189 -0
  107. data/spec/hem/util_spec.rb +74 -0
  108. data/spec/spec_helper.rb +12 -0
  109. data/ssl/ca-bundle-s3.crt +3554 -0
  110. data/test_files/vagrant_fail/vagrant +2 -0
  111. metadata +339 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: de1021c2b7f5bfe996e119f41ee6c7b2eac65839
4
+ data.tar.gz: b79fb7a3564ca815336a89c0a5fc2f7d66d078a3
5
+ SHA512:
6
+ metadata.gz: e4bc3b8bf466cb07c699f9f81f04d4419b03a81c4b04d4e3d1b3a8a4f272fa2b8cf07d66f5a5d5f2d3c116d2ec5ae9d735a4821b12711821bd0858f776ba90b3
7
+ data.tar.gz: 1b2a337cd6ba8eb3c7a68cfc6b86e43d2595c24690bb9a552c95442276e556ad7129f7d97eb7473fab9763780b263972e3d4d591d7820e22e176b88187a8dcb7
data/.editorconfig ADDED
@@ -0,0 +1,10 @@
1
+ ; EditorConfig is awesome: http://EditorConfig.org
2
+ root = true ; top-most EditorConfig file
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/
2
+ coverage/
3
+ tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/CHANGELOG.md ADDED
@@ -0,0 +1,125 @@
1
+ ## 0.0.16 (unreleased)
2
+
3
+ FEATURES:
4
+ * core: Project renamed to "Hem" to avoid confusion with other hobo projects
5
+
6
+ IMPROVEMENTS:
7
+
8
+ * tasks/magento: Set magento secure url to use https
9
+ * tasks/seed: Change the project seed prompt to list available seeds as choices.
10
+ * tasks/seed: Add support for specifying full git repository urls in seed names
11
+ * core/ui: Ability to use noecho with Hobo.ui.ask for password input
12
+
13
+ BUG FIXES:
14
+ * tasks/magento & tasks/assets: Ensure absolute project path is used for magento patches & asset tasks
15
+ * core/cli: Fixes Hobofile eval such that `Hobofile` appears in backtrace instead of `main`
16
+
17
+ ## 0.0.15 (5 September 2014)
18
+
19
+ FEATURES:
20
+
21
+ * tasks/magento: **New hobo task: `hobo magento patches apply`** - Applies official and critical magento patches
22
+ * tasks/seed: custom key-value data can be supplied to project configuration for `hobo seed plant` via `--data` or `-d`
23
+ * core/ui: new Hobo.ui.ask_choice method to give a numbered list of options to choose
24
+
25
+ BUG FIXES:
26
+
27
+ * core/gem_isolation: fix for bundler 1.6.5+ compatibility issue
28
+
29
+ ## 0.0.14 (20 August 2014)
30
+
31
+ BUG FIXES:
32
+
33
+ * tasks/seed: fix typo with home path detection
34
+ * tasks/deps: fix inverted check for disable_host_run in deps:composer
35
+
36
+ ## 0.0.13 (31 July 2014)
37
+
38
+ BUG FIXES:
39
+
40
+ * tasks/deps: fixes spacing bug on new vagrant plugin psuedo syntax
41
+
42
+ ## 0.0.12 (yanked)
43
+
44
+ FEATURES:
45
+
46
+ * tasks/ops: new ops task to generate self signed certs
47
+ * tasks/seed: integrate self signed certs in to seed plant
48
+ * tasks/deps: implemented new psuedo syntax for vagrant plugins to avoid require_plugin warnings
49
+
50
+ IMPROVEMENTS:
51
+
52
+ * tasks/vm: changed vm:stop to use halt instead of suspend
53
+ * tasks/seed: better detection of local paths for seed argument
54
+
55
+ BUG FIXES:
56
+
57
+ * core: minor fixes and enhancements
58
+
59
+ ## 0.0.11 (16 June 2014)
60
+
61
+ FEATURES:
62
+
63
+ * tasks/assets: dry run / confirmation of destructive sync
64
+ * tasks/deps: deps:composer now has option to disable host run of composer at the project level
65
+
66
+ IMPROVEMENTS:
67
+
68
+ * tasks/assets: rewritten mysql asset applicator to better handle error cases
69
+ * core/gem_isolation: refactored in to own module
70
+
71
+ BUG FIXES:
72
+
73
+ * tasks/assets: raise error when we encounter AWS error as VM will not start cleanly
74
+
75
+ ## 0.0.10 (23 May 2014)
76
+
77
+ FEATURES:
78
+
79
+ * core/gem_isolation: Initial implementation
80
+ * tasks/self: repl task to debug adhoc issues in the context of hobo
81
+
82
+ ## 0.0.9 (3 April 2014)
83
+
84
+ FEATURES:
85
+
86
+ * tasks/assets: new asset applicator feature to automatically load assets where possible
87
+ * core/host_checks: latest hobo version check and auto-upgrade prompt
88
+ * tasks/magento: magento specific tasks implemented
89
+
90
+ IMPROVEMENTS:
91
+
92
+ * tasks/assets: restructured asset sync code to multiple files
93
+ * core/util: centralized aws credential retrieval and windows host detection
94
+
95
+ ## 0.0.8 (7 March 2014)
96
+
97
+ FEATURES:
98
+
99
+ * core/debug: implemented debug tee (writes debug to stdout and /tmp/hobo_debug.log)
100
+ * core/cli: implemented argv passthrough
101
+ * tasks/config: new feature to set configuration in ~/.hobo/config.yaml
102
+ * helpers/http_download: new feature to download files from http w/ progressbar support
103
+
104
+ IMPROVEMENTS:
105
+
106
+ * tasks/assets: improved asset sync handler
107
+ * core/host_checks: much improved host check feedback
108
+ * helpers/vm_shell: rewritten to support project mount detection and pull config from vagrant
109
+ * core/errors: refactored error handler support to create consistent error return codes without duplication
110
+
111
+ ## 0.0.7 (18 February 2014)
112
+
113
+ FEATURES:
114
+
115
+ * tasks/seed: introduced submodule support for seeds (specifically magento)
116
+
117
+ IMPROVEMENTS:
118
+
119
+ * tasks/assets: error handling improvements
120
+ * core/errors: friendly formatter now appends backtrace information to error log
121
+
122
+ BUG FIXES:
123
+
124
+ * helpers/shell: fix carridge return handling
125
+ * core/config: fix deepstruct unwrap issue
data/DoD.md ADDED
@@ -0,0 +1,5 @@
1
+ This is the project definition of done.
2
+
3
+ - [ ] It
4
+ - [ ] Contains
5
+ - [ ] Checkboxes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Use hem.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hem (1.0.0.beta1)
5
+ aws-sdk (~> 2.0.24)
6
+ deepstruct (~> 0.0.5)
7
+ highline (~> 1.6.20)
8
+ net-ssh-simple (~> 1.6.3)
9
+ octokit (~> 3.0)
10
+ pry (~> 0.9.12)
11
+ rake (~> 10.1.1)
12
+ ruby-progressbar (~> 1.4.1)
13
+ semantic (~> 1.3.0)
14
+ slop (~> 3.4.7)
15
+ teerb (~> 0.0.1)
16
+
17
+ GEM
18
+ remote: https://rubygems.org/
19
+ specs:
20
+ addressable (2.3.8)
21
+ aws-sdk (2.0.48)
22
+ aws-sdk-resources (= 2.0.48)
23
+ aws-sdk-core (2.0.48)
24
+ builder (~> 3.0)
25
+ jmespath (~> 1.0)
26
+ multi_json (~> 1.0)
27
+ aws-sdk-resources (2.0.48)
28
+ aws-sdk-core (= 2.0.48)
29
+ blockenspiel (0.4.5)
30
+ builder (3.2.2)
31
+ coderay (1.1.0)
32
+ deepstruct (0.0.7)
33
+ faraday (0.9.2)
34
+ multipart-post (>= 1.2, < 3)
35
+ hashie (3.4.3)
36
+ highline (1.6.21)
37
+ jmespath (1.1.3)
38
+ method_source (0.8.2)
39
+ multi_json (1.11.2)
40
+ multipart-post (2.0.0)
41
+ net-scp (1.2.1)
42
+ net-ssh (>= 2.6.5)
43
+ net-ssh (3.0.1)
44
+ net-ssh-simple (1.6.12)
45
+ blockenspiel (= 0.4.5)
46
+ hashie (= 3.4.3)
47
+ net-scp (= 1.2.1)
48
+ net-ssh (= 3.0.1)
49
+ octokit (3.8.0)
50
+ sawyer (~> 0.6.0, >= 0.5.3)
51
+ pry (0.9.12.6)
52
+ coderay (~> 1.0)
53
+ method_source (~> 0.8)
54
+ slop (~> 3.4)
55
+ rake (10.1.1)
56
+ ruby-progressbar (1.4.2)
57
+ sawyer (0.6.0)
58
+ addressable (~> 2.3.5)
59
+ faraday (~> 0.8, < 0.10)
60
+ semantic (1.3.1)
61
+ slop (3.4.7)
62
+ teerb (0.0.1)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ hem!
69
+
70
+ BUNDLED WITH
71
+ 1.10.6
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
10
+ guard 'cucumber' do
11
+ watch(%r{^features/.+\.feature$})
12
+ watch(%r{^features/support/.+$}) { 'features' }
13
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
14
+ end
data/Hemfile ADDED
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ desc "lala"
4
+ task "top-level" do
5
+ Hem.ui.info "top level"
6
+ end
7
+
8
+ namespace :test do
9
+ desc "Does non-interactive things"
10
+ task 'non-interactive' do
11
+ Hem.ui.info Hem.ui.ask "A question", default: "Used defaults"
12
+ end
13
+
14
+ desc 'Performs interactive requests without echo'
15
+ task 'no-echo' do
16
+ Hem.ui.info Hem.ui.ask 'A question', echo: false
17
+ end
18
+
19
+ task "subcommand" do
20
+ Hem.ui.info "Subcommand test"
21
+ end
22
+
23
+ desc "description"
24
+ long_desc "long description"
25
+ option "-o", "--option", "Option description"
26
+ hidden true
27
+ task "metadata", [ :arg ] do
28
+ Hem.ui.info "metadata"
29
+ end
30
+
31
+ option "--testing=", "description"
32
+ task 'option-test' do |task|
33
+ Hem.ui.info task.opts[:testing]
34
+ end
35
+
36
+ task 'argument-test', [ :test ] do |task, args|
37
+ Hem.ui.info args[:test]
38
+ end
39
+
40
+ task 'unparsed' do |task|
41
+ Hem.ui.info task.opts[:_unparsed]
42
+ end
43
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 The Inviqa Group Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Hem (gem)
2
+ Hem is small rake based tool designed to assist with day to day tasks for developers.
3
+ Some highlights of functionality include:
4
+
5
+ - Fetch common tools
6
+ - Start most project VMs including setting up dependencies
7
+ - Utilize project seeds to kickstart a new project
8
+
9
+ Many more features are planned including assisting with host machine configuration, automatically pulling assets for the VM and providing commonly rewritten tasks as general utility libraries for use in Hemfiles.
10
+
11
+ # Installing & using
12
+
13
+ Full instructions for installing and using hem are available in the [User guide](https://github.com/inviqa/hem/wiki/User-guide). For information on the task DSL, see the [DSL guide](https://github.com/inviqa/hem/wiki/Hemfile-DSL).
14
+
15
+ Please ensure that you run the following command after installing and that it does not raise any issues:
16
+
17
+ ```
18
+ hem system check
19
+ ```
20
+
21
+ # Getting help
22
+
23
+ If you need any help with hem or you encounter any issues, please join the #hem slack channel.
24
+
25
+ # Contributing
26
+ If you wish to contribute to hem:
27
+ - Clone this repository
28
+ - Execute bundle install
29
+ - Create a feature branch with descriptive name (i.e. feature/magento-tasks)
30
+ - Make changes
31
+ - Build and install the gem: rake build && rake install
32
+ - Push feature branch back to this repo
33
+ - Submit a PR with details of changes
34
+
35
+ You can run tests using Guard by executing "guard" in a terminal in the project folder. Guard will re-run tests where it knows how but otherwise run cucumber tests with "cucumber" (in the guard terminal) and rspec tests with "rspec" (in the guard terminal).
36
+
37
+ # Available seeds
38
+ Currently available seeds are `default`, `magento` and `symfony`.
39
+ ```
40
+ hem seed plant <my-symfony-project-name> --seed=symfony
41
+ ```
42
+ The easiest way is to look for more custom seeds is just to search gihub. https://github.com/inviqa?query=hem-seed
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ ENV['HEM_BUILD'] = '1'
5
+
6
+ desc "Build and install"
7
+ task :build_install => [:build, :install]
8
+
9
+ desc "Install dev deps"
10
+ task :install_dev_deps do
11
+ sh 'rm -rf .bundle/config'
12
+ sh 'HEM_ENV=dev bundle install'
13
+ end
14
+
15
+ namespace :test do
16
+ task :specs => [ 'install_dev_deps' ] do
17
+ sh 'HEM_ENV=dev bundle exec rspec'
18
+ end
19
+
20
+ task :acceptance => [ 'install_dev_deps' ] do
21
+ sh 'HEM_ENV=dev bundle exec cucumber'
22
+ end
23
+ end
data/bin/hem ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Hack to allow testing with Aruba (for now)
4
+ $:.push File.expand_path(File.join("..", "..", "lib"), __FILE__)
5
+
6
+ def init_hem
7
+ require 'hem'
8
+
9
+ # Default main classes
10
+ error_handler = Hem::ErrorHandlers::Friendly.new
11
+ Hem.ui = Hem::Ui.new
12
+ Hem.logger = Logger.new(STDOUT)
13
+ Hem.logger.level = Logger::WARN
14
+
15
+ # Low level / early arg parsing
16
+ # Anything that can alter ui / logger / cli should be here
17
+ # Early termination args should also go here
18
+ slop = Slop.parse! do
19
+ on '--debug', 'Enable debugging' do
20
+ require 'teerb'
21
+ require 'tmpdir'
22
+ error_handler = Hem::ErrorHandlers::Debug.new
23
+ debug_log = File.open(File.join(Dir.tmpdir, 'hem_debug.log'), 'w+')
24
+ Hem.logger = Logger.new(TeeRb::IODelegate.new(STDOUT, debug_log))
25
+ Hem.logger.level = Logger::DEBUG
26
+ end
27
+
28
+ on '--ansi', 'Enable / disable ansi output', :invertable => true do
29
+ Hem.ui.use_color self.to_hash[:ansi]
30
+ end
31
+
32
+ on '--log-level=', 'Set log level' do
33
+ level = self.to_hash[:'log-level'].upcase
34
+ Hem.logger.level = Logger.const_get(level) if [ 'DEBUG', 'INFO' ].include? level
35
+ end
36
+
37
+ on '--non-interactive', 'Run non-interactively. Defaults will be automatically used where possible.'
38
+ on '--skip-host-checks', 'Skip host checks'
39
+ end
40
+
41
+ Hem.logger.formatter = proc do |severity, datetime, progname, msg|
42
+ "#{datetime.strftime("%Y-%m-%d %H:%M:%S")}: #{severity}: #{msg}\n"
43
+ end
44
+
45
+ opts = slop.to_hash
46
+ Hem.ui.interactive = !(opts[:'non-interactive'] == true)
47
+
48
+ begin
49
+ Hem.cli = Hem::Cli.new(slop: slop)
50
+ Hem.cli.start
51
+ rescue Exception => error
52
+ exit error_handler.handle(error)
53
+ end
54
+ end
55
+
56
+ Gem.configuration.verbose = false
57
+
58
+ require 'hem/patches/rubygems'
59
+
60
+ # Suppress Net/SSH/Simple warning on windows
61
+ $SUPPRESS_32BIT_WARNING=1
62
+ $HEM_ARGV = ARGV
63
+
64
+ init_hem
@@ -0,0 +1,43 @@
1
+ Feature: Dependencies
2
+
3
+ Scenario: deps:gems should install Gemfile dependencies
4
+ Given a file named "Gemfile" with:
5
+ """
6
+ source 'https://rubygems.org'
7
+ gem 'bundler'
8
+ """
9
+ And an empty file named "Hemfile"
10
+ When I run `hem deps gems`
11
+ Then the output should contain "Using bundler"
12
+ And a file named "Gemfile.lock" should exist
13
+
14
+ Scenario: deps:composer should install composer dependencies
15
+ Given a file named "composer.json" with:
16
+ """
17
+ {
18
+ "require": {
19
+ "whatthejeff/fab": "*"
20
+ }
21
+ }
22
+ """
23
+ And an empty file named "Hemfile"
24
+ When I run `hem deps composer`
25
+ Then the output should contain "Installing whatthejeff/fab"
26
+ And a file named "composer.lock" should exist
27
+
28
+ Scenario: deps:chef should install chef dependencies
29
+ Given a file named "Cheffile" with:
30
+ """
31
+ site 'http://community.opscode.com/api/v1'
32
+ cookbook 'apache2'
33
+ """
34
+ And an empty file named "Hemfile"
35
+ And a file named "Gemfile" with:
36
+ """
37
+ source 'https://rubygems.org'
38
+ gem 'librarian-chef'
39
+ """
40
+ When I run `bundle install`
41
+ And I run `hem deps chef`
42
+ Then the output should contain "apache2"
43
+ And a file named "Cheffile.lock" should exist
@@ -0,0 +1,43 @@
1
+ Feature: Basics
2
+ Scenario: No arguments should show help
3
+ When I run `hem`
4
+ Then the output should contain "Usage:"
5
+
6
+ Scenario: -v should show version
7
+ When I run `hem -v`
8
+ Then the output should contain "Hem version"
9
+
10
+ Scenario: --version should show version
11
+ When I run `hem --version`
12
+ Then the output should contain "Hem version"
13
+
14
+ Scenario: An invalid command should fail gracefully
15
+ When I run `hem jibberjabber`
16
+ Then the output should contain "Invalid command or option"
17
+ And the exit status should be 4
18
+
19
+ Scenario: An invalid option should fail gracefully
20
+ When I run `hem --jibberjabber`
21
+ Then the output should contain "Invalid command or option"
22
+ And the exit status should be 4
23
+
24
+ Scenario: --debug should display backtraces
25
+ When I run `hem jibberjabber --debug`
26
+ Then the output should contain "Hem::InvalidCommandOrOpt"
27
+
28
+ Scenario: --no-ansi should disable ansi output
29
+ When I run `hem --no-ansi`
30
+ Then the output should not contain "33m"
31
+
32
+ Scenario: --non-interactive should cause default options to be used
33
+ When I run `hem test non-interactive --non-interactive`
34
+ Then the output should contain "Used defaults"
35
+
36
+ Scenario: --all should list all tasks
37
+ When I run `hem --all`
38
+ Then the output should contain "hem-debug"
39
+
40
+ Scenario: --skip-host-checks should skip host checks
41
+ Given "test_files/vagrant_fail/" is appended to the PATH environment variable
42
+ When I run `hem --skip-host-checks`
43
+ Then the output should not contain "Hem has detected a problem"
@@ -0,0 +1,16 @@
1
+ Feature: Hem help
2
+ Scenario: --help should show help
3
+ When I run `hem --help`
4
+ Then the output should contain "Usage:"
5
+ And the output should contain "Global options:"
6
+ And the output should contain "Commands:"
7
+
8
+ Scenario: --h should show help
9
+ When I run `hem --help`
10
+ Then the output should contain "Usage:"
11
+ And the output should contain "Global options:"
12
+ And the output should contain "Commands:"
13
+
14
+ Scenario: --ansi should show invertable help
15
+ When I run `hem --help`
16
+ Then the output should contain "(Disable with --no-ansi)"
@@ -0,0 +1,15 @@
1
+ Feature: Subcommands
2
+
3
+ Scenario: Subcommand with --help should show command help
4
+ When I run `hem test non-interactive --help`
5
+ Then the output should contain "hem test non-interactive [options]"
6
+
7
+ Scenario: Namespace should show subcommands
8
+ When I run `hem test`
9
+ Then the output should contain "non-interactive"
10
+ And the output should contain "Does non-interactive things"
11
+
12
+ Scenario: Subcommand should execute
13
+ When I run `hem test non-interactive` interactively
14
+ And I type "Testing"
15
+ Then the output should contain "Testing"
@@ -0,0 +1,64 @@
1
+ Feature: Plant
2
+
3
+ Scenario: Plant without name should fail gracefully
4
+ When I run `hem seed plant`
5
+ Then the output should contain "Not enough arguments for seed:plant"
6
+
7
+ Scenario: Plant with name should prompt for repository and seed
8
+ Given there is a seed called "testing" with:
9
+ """
10
+ test
11
+ """
12
+ And I run `hem seed plant seed_plant_0` interactively
13
+ And I type "git://test_repo"
14
+ And I type "./testing"
15
+ And I run `sleep 0.5`
16
+ And I run `git --git-dir=seed_plant_0/.git remote show origin -n`
17
+ Then the output should contain "git://test_repo"
18
+ And the file "seed_plant_0/test" should contain "test"
19
+
20
+ Scenario: Plant with name and --git-url should prompt for seed
21
+ Given there is a seed called "testing" with:
22
+ """
23
+ test
24
+ """
25
+ When I run `hem seed plant seed_plant_0 --git-url=git://test_repo` interactively
26
+ And I type "./testing"
27
+ And I run `sleep 0.5`
28
+ And I run `git --git-dir=seed_plant_0/.git remote show origin -n`
29
+ Then the output should contain "git://test_repo"
30
+ And the file "seed_plant_0/test" should contain "test"
31
+
32
+ Scenario: Plant with name, --git-url and --seed should not prompt
33
+ Given there is a seed called "testing" with:
34
+ """
35
+ test
36
+ """
37
+ When I run `hem seed plant seed_plant_0 --git-url=git://test_repo --seed=./testing`
38
+ And I run `sleep 0.5`
39
+ And I run `git --git-dir=seed_plant_0/.git remote show origin -n`
40
+ Then the output should contain "git://test_repo"
41
+ And the file "seed_plant_0/test" should contain "test"
42
+
43
+ Scenario: Plant should replace placeholders
44
+ Given there is a seed called "testing" with:
45
+ """
46
+ NAME:{{name}}
47
+ SEED:{{seed.name}}
48
+ """
49
+ When I run `hem seed plant seed_plant_0 --git-url=git://test_repo --seed=./testing`
50
+ Then the file "seed_plant_0/test" should contain "NAME:seed_plant_0"
51
+ And the file "seed_plant_0/test" should contain "SEED:testing"
52
+
53
+ Scenario: Plant should fail gracefully with invalid seed
54
+ When I run `hem seed plant seed_plant_0 --git-url=git://test_repo --seed=./not-exist`
55
+ Then the output should contain "The following external command appears to have failed"
56
+
57
+ Scenario: Plant should fail gracefully if target directory exists
58
+ Given there is a seed called "testing" with:
59
+ """
60
+ test
61
+ """
62
+ And an empty file named "seed_plant_0"
63
+ When I run `hem seed plant seed_plant_0 --git-url=git://test_repo --seed=./not-exist`
64
+ Then the output should contain "seed_plant_0 already exists"
@@ -0,0 +1,6 @@
1
+ require 'fileutils'
2
+
3
+ Given(/^"(.*?)" is appended to the (.*) environment variable$/) do |value, env|
4
+ set_env(env, (ENV[env] || "") + ":" + value)
5
+ puts ENV[env]
6
+ end
@@ -0,0 +1,11 @@
1
+ require 'fileutils'
2
+
3
+ Given(/^there is a seed called "(.*?)" with:$/) do |seed, contents|
4
+ create_dir(seed)
5
+ cd(seed)
6
+ write_file("test", contents)
7
+ run_simple(unescape("git init"))
8
+ run_simple(unescape("git add *"))
9
+ run_simple(unescape("git commit -m 'init'"))
10
+ cd('..')
11
+ end
@@ -0,0 +1,6 @@
1
+ require 'aruba/cucumber'
2
+
3
+ Before do
4
+ # bundler / composer features need this
5
+ @aruba_timeout_seconds = 120
6
+ end