hem 1.0.1.beta6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +32 -45
  3. data/Hemfile +4 -2
  4. data/README.md +4 -0
  5. data/bin/hem +5 -6
  6. data/hem.gemspec +15 -15
  7. data/lib/hem.rb +47 -45
  8. data/lib/hem/asset_applicators/files.rb +1 -1
  9. data/lib/hem/cli.rb +36 -29
  10. data/lib/hem/error_handlers/debug.rb +1 -1
  11. data/lib/hem/error_handlers/friendly.rb +3 -3
  12. data/lib/hem/errors.rb +23 -12
  13. data/lib/hem/help_formatter.rb +12 -3
  14. data/lib/hem/helper/argument_parser.rb +30 -0
  15. data/lib/hem/helper/command.rb +2 -1
  16. data/lib/hem/helper/file_locator.rb +34 -7
  17. data/lib/hem/helper/shell.rb +0 -1
  18. data/lib/hem/helper/vm_command.rb +2 -2
  19. data/lib/hem/lib/host_check/vagrant.rb +2 -3
  20. data/lib/hem/lib/s3/sync.rb +2 -2
  21. data/lib/hem/lib/seed/project.rb +10 -13
  22. data/lib/hem/lib/seed/replacer.rb +9 -31
  23. data/lib/hem/lib/seed/template.rb +21 -0
  24. data/lib/hem/lib/vm/inspector.rb +1 -1
  25. data/lib/hem/patches/deepstruct.rb +4 -0
  26. data/lib/hem/patches/rake.rb +42 -11
  27. data/lib/hem/plugins.rb +129 -0
  28. data/lib/hem/setup.rb +6 -0
  29. data/lib/hem/tasks.rb +15 -0
  30. data/lib/hem/tasks/deps.rb +13 -14
  31. data/lib/hem/tasks/exec.rb +4 -2
  32. data/lib/hem/tasks/magento.rb +13 -275
  33. data/lib/hem/tasks/mysql.rb +16 -0
  34. data/lib/hem/tasks/ops.rb +2 -1
  35. data/lib/hem/tasks/plugin.rb +16 -0
  36. data/lib/hem/tasks/redis.rb +26 -0
  37. data/lib/hem/tasks/seed.rb +4 -2
  38. data/lib/hem/tasks/self.rb +7 -6
  39. data/lib/hem/tasks/tools.rb +1 -1
  40. data/lib/hem/tasks/vm.rb +8 -16
  41. data/lib/hem/util.rb +6 -16
  42. data/lib/hem/version.rb +12 -1
  43. data/lib/hobo/tasks/magento.rb +2 -1
  44. data/spec/hem/cli_spec.rb +1 -0
  45. data/spec/hem/helpers/argument_parser_spec.rb +57 -0
  46. data/spec/hem/lib/seed/project_spec.rb +1 -0
  47. data/spec/hem/lib/seed/replacer_spec.rb +12 -13
  48. data/spec/hem/lib/seed/seed_spec.rb +1 -0
  49. metadata +50 -42
  50. data/lib/hem/lib/github/api.rb +0 -48
  51. data/lib/hem/lib/github/client.rb +0 -52
  52. data/lib/hem/tasks/pr.rb +0 -45
@@ -1,48 +0,0 @@
1
- module Hem
2
- module Lib
3
- module Github
4
- class Api
5
-
6
- @connected = false
7
-
8
- def initialize(opts = {})
9
- @opts = {
10
- :config_class => Hem::Config::File,
11
- :user_config => Hem.user_config,
12
- :ui => Hem.ui,
13
- :client => Hem::Lib::Github::Client.new
14
- }.merge! opts
15
- end
16
-
17
- def connect
18
- config = @opts[:user_config]
19
- config[:github] ||= {}
20
-
21
- if config[:github][:token].nil?
22
- @opts[:ui].info 'You do not have a stored Github token. Authenticate now to create one.'
23
- username = @opts[:ui].ask 'Github username'
24
- password = @opts[:ui].ask 'Github password', echo: false
25
-
26
- config[:github][:token] = @opts[:client].get_token_for_credentials(username, password)
27
-
28
- @opts[:config_class].save(Hem.user_config_file, config)
29
- else
30
- @opts[:client].authenticate_with_token(config[:github][:token])
31
- # client = Octokit::Client.new(:access_token => config.github.token)
32
- end
33
-
34
- @connected = true
35
- end
36
-
37
- def create_pull_request(repo, source_branch, target_branch, title, body)
38
- unless @connected
39
- connect
40
- end
41
-
42
- @opts[:client].create_pull_request(repo, source_branch, target_branch, title, body)
43
- end
44
-
45
- end
46
- end
47
- end
48
- end
@@ -1,52 +0,0 @@
1
- module Hem
2
- module Lib
3
- module Github
4
- class Client
5
-
6
- @client = nil
7
-
8
- def initialize(opts = {})
9
- require 'octokit'
10
- @opts = {
11
- :client_class => Octokit::Client
12
- }.merge! opts
13
- end
14
-
15
- def get_token_for_credentials(username, password)
16
- begin
17
- @client = @opts[:client_class].new(:login => username, :password => password)
18
- token_response = @client.create_authorization(:scopes => ['repo'], :note => 'Hem')
19
- return token_response.token.to_s
20
- rescue Octokit::UnprocessableEntity => e
21
- case e.errors[0][:code]
22
- when 'already_exists'
23
- raise Hem::GithubAuthenticationError.new 'You already created a token for Hem, please delete this from your Github account before continuing.'
24
- else
25
- raise Hem::Error.new e.message
26
- end
27
- rescue Exception => e
28
- raise Hem::Error.new e.message
29
- end
30
- end
31
-
32
- def authenticate_with_token(token)
33
- begin
34
- @client = @opts[:client_class].new(:access_token => token)
35
- rescue Exception => e
36
- raise Hem::Error.new e.message
37
- end
38
- end
39
-
40
- def create_pull_request(repo, source_branch, target_branch, title, body)
41
- if @client.nil?
42
- raise Hem::Error.new 'Client is not created'
43
- end
44
-
45
- response = @client.create_pull_request(repo, source_branch, target_branch, title, body)
46
- response[:html_url].to_s
47
- end
48
-
49
- end
50
- end
51
- end
52
- end
@@ -1,45 +0,0 @@
1
- desc 'Perform pull request operations'
2
- namespace :pr do
3
- desc 'Create a new pull request'
4
- task :create do
5
- source_branch = Hem.ui.ask 'Source branch', default: (Hem::Helper.shell 'git rev-parse --abbrev-ref HEAD', :capture => true)
6
- target_branch = Hem.ui.ask 'Target branch', default: 'develop'
7
-
8
- pr_content = <<-prbody
9
- # The line below this comment is the title of your pull request. Keep it short and on a single line.
10
- PR_TITLE
11
-
12
- # All text below this comment will appear as the body of the pull request.
13
- # If your project has a DoD.md in the project root, it will be automatically included.
14
- # Any line starting with a hash (comment) will be ignored
15
-
16
- PR_DOD
17
- prbody
18
-
19
- pr_content['PR_TITLE'] = Hem::Helper.shell 'git log -1 --pretty=%B', :capture => true
20
-
21
- dod_path = Hem::Helper.locate('DoD.md')
22
-
23
- if dod_path && !dod_path.empty?
24
- dod_file = File.open dod_path[0]
25
- pr_content['PR_DOD'] = dod_file.read
26
- dod_file.close
27
- else
28
- pr_content['PR_DOD'] = '# No DoD.md file found, add one to your project root.'
29
- end
30
-
31
- pr_body = Hem.ui.editor(pr_content).lines.reject{ |line| line[0] == '#' }.join
32
-
33
- pr_title = pr_body.lines.to_a[0]
34
-
35
- pr_body = pr_body.lines.to_a[1..-1].join
36
-
37
- git_parts = Hem::Helper.parse_github_url(Hem.project_config.git_url)
38
- repo = "#{git_parts[:owner]}/#{git_parts[:repo]}"
39
-
40
- api = Hem::Lib::Github::Api.new
41
- pr_url = api.create_pull_request(repo, target_branch, source_branch, pr_title, pr_body)
42
-
43
- Hem::ui.success "Pull request created: #{pr_url}"
44
- end
45
- end