mina 1.0.0.beta1 → 1.0.0.beta2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61bbe65d547133bc4fbf5c86b88a12712df3159a
4
- data.tar.gz: c2d6052fe399a14279d085bf6068836fe2f2450b
3
+ metadata.gz: 696d8732964b3912c892dae9fda5ff475a1cf885
4
+ data.tar.gz: 0e0ba9b78f5322a511ae0f94f11a0beda81978a8
5
5
  SHA512:
6
- metadata.gz: 3bfb24cc3833279268394ca49947ac92f6781c01b398fdbb1a39732aea7ec1d88b6ed560a2b64f030bdca9a11a81327253baf4504473f8de2d0e47020da17435
7
- data.tar.gz: 2a3775aa8aca0c828e3ec108746f0a34ef73534f01b5f7c63d1ce9ec9144288df938a6567b50b9b8476ee6612cfd692bc4aa5c745e3a43b6fa1ba5231fb8543c
6
+ metadata.gz: e89217c1dea4ec89f16f4d89d3d5cc92b31abfbb4bcd2b57189367b59e4772bf70b21e7ea8131ff358835a2a94a716c4b2d6c8a44632be5b28977b9957f6d20c
7
+ data.tar.gz: 862407b6be4421eb0825647b66035abdb5ebd0d4228352f0ffd2d8ed4ada5c9fa12d947b2aebc3bd7878d919715c161af5dfd3a1cc159f290b4cb5e6cff9d47a
data/.gitignore CHANGED
@@ -7,3 +7,4 @@ Gemfile.lock
7
7
  pkg/
8
8
  support/helpers.md
9
9
  support/modules.md
10
+ coverage/
data/.rubocop.yml CHANGED
@@ -209,7 +209,7 @@ Metrics/AbcSize:
209
209
  Description: >-
210
210
  A calculated magnitude based on number of assignments,
211
211
  branches, and conditions.
212
- Reference: 'http://c2.com/cgi/wiki?AbcMetric'
212
+ Reference: 'https://c2.com/cgi/wiki?AbcMetric'
213
213
  Enabled: false
214
214
  Max: 20
215
215
 
@@ -358,7 +358,7 @@ Rails/ScopeArgs:
358
358
  Rails/TimeZone:
359
359
  Description: 'Checks the correct usage of time zone aware methods.'
360
360
  StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
361
- Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
361
+ Reference: 'https://danilenko.org/2012/7/6/rails_timezones'
362
362
  Enabled: false
363
363
 
364
364
  Rails/Validation:
@@ -644,7 +644,7 @@ Style/FormatString:
644
644
  Style/GlobalVars:
645
645
  Description: 'Do not introduce global variables.'
646
646
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
647
- Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
647
+ Reference: 'https://www.zenspider.com/Languages/Ruby/QuickRef.html'
648
648
  Enabled: false
649
649
 
650
650
  Style/GuardClause:
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in capistrano.gemspec
3
+ # Specify your gem's dependencies in mina.gemspec
4
4
  gemspec
data/Readme.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Code Climate](https://codeclimate.com/repos/5774207165982076ca005984/badges/6877153919d603250738/gpa.svg)](https://codeclimate.com/repos/5774207165982076ca005984/feed)
4
4
  [![Test Coverage](https://codeclimate.com/repos/5774207165982076ca005984/badges/6877153919d603250738/coverage.svg)](https://codeclimate.com/repos/5774207165982076ca005984/coverage)
5
5
  [![Build Status](https://semaphoreci.com/api/v1/d4be4st/mina/branches/master/shields_badge.svg)](https://semaphoreci.com/d4be4st/mina)
6
- [![Gem Version](https://badge.fury.io/rb/mina.svg)](http://badge.fury.io/rb/mina)
6
+ [![Gem Version](https://badge.fury.io/rb/mina.svg)](https://badge.fury.io/rb/mina)
7
7
 
8
8
  Really fast deployer and server automation tool.
9
9
 
@@ -33,6 +33,8 @@ For migrating your current 0.3.x deploy scripts, please look at the [migrating g
33
33
 
34
34
  For FAQ please visit the [faq](docs/faq.md)
35
35
 
36
+ If you are missing some plugins check the [3rd party plugins doc](docs/3rd_party_plugins.md)
37
+
36
38
  For other documentation please visit the [docs](docs)
37
39
 
38
40
  Acknowledgements
@@ -40,7 +42,7 @@ Acknowledgements
40
42
 
41
43
  © 2012-2015, Nadarei.
42
44
  2015-2016, Infinum.
43
- Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
45
+ Released under the [MIT License](https://www.opensource.org/licenses/mit-license.php).
44
46
 
45
47
  Mina is authored [Rico Sta. Cruz][rsc] and [Michael Galero][mg] with help from its [contributors][c] and their startup, [Nadarei][nd].
46
48
  It is maintained by [Stjepan Hadjić][sh] and [Gabrijel Škoro][gs] and sponsored by [Infinum][inf].
@@ -57,24 +59,24 @@ Gabrijel:
57
59
 
58
60
  Rico:
59
61
 
60
- * [My website](http://ricostacruz.com) (ricostacruz.com)
61
- * [Github](http://github.com/rstacruz) (@rstacruz)
62
- * [Twitter](http://twitter.com/rstacruz) (@rstacruz)
62
+ * [My website](https://ricostacruz.com) (ricostacruz.com)
63
+ * [Github](https://github.com/rstacruz) (@rstacruz)
64
+ * [Twitter](https://twitter.com/rstacruz) (@rstacruz)
63
65
 
64
66
  Michael:
65
67
 
66
68
  * [My website][mg] (michaelgalero.com)
67
- * [Github](http://github.com/mikong) (@mikong)
69
+ * [Github](https://github.com/mikong) (@mikong)
68
70
 
69
71
  Nadrei:
70
72
 
71
- * [Nadarei](http://nadarei.co) (nadarei.co)
72
- * [Github](http://github.com/nadarei) (@nadarei)
73
+ * [Nadarei](https://nadarei.co) (nadarei.co)
74
+ * [Github](https://github.com/nadarei) (@nadarei)
73
75
 
74
- [rsc]: http://ricostacruz.com
75
- [mg]: http://devblog.michaelgalero.com/
76
- [c]: http://github.com/mina-deploy/mina/graphs/contributors
77
- [nd]: http://nadarei.co
76
+ [rsc]: https://ricostacruz.com
77
+ [mg]: https://devblog.michaelgalero.com/
78
+ [c]: https://github.com/mina-deploy/mina/graphs/contributors
79
+ [nd]: https://nadarei.co
78
80
  [sh]: https://github.com/d4be4st
79
81
  [gs]: https://github.com/gabskoro
80
82
  [inf]: https://infinum.co
data/data/deploy.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'mina/bundler'
2
1
  require 'mina/rails'
3
2
  require 'mina/git'
4
3
  # require 'mina/rbenv' # for rbenv support. (https://rbenv.org)
data/data/deploy.sh.erb CHANGED
@@ -1,8 +1,8 @@
1
1
  <%
2
- default = commands.fetch(:default).map { |s| indent 2, s }.join(" &&\n")
3
- build = commands.fetch(:build).map { |s| indent 2, s }.join(" &&\n")
4
- launch = commands.fetch(:launch).map { |s| indent 2, s }.join(" &&\n")
5
- clean = commands.fetch(:clean).map { |s| indent 2, s }.join(" &&\n")
2
+ default = commands.delete(:default).map { |s| indent 2, s }.join(" &&\n")
3
+ build = commands.delete(:build).map { |s| indent 2, s }.join(" &&\n")
4
+ launch = commands.delete(:launch).map { |s| indent 2, s }.join(" &&\n")
5
+ clean = commands.delete(:clean).map { |s| indent 2, s }.join(" &&\n")
6
6
  %>
7
7
  #!/usr/bin/env bash
8
8
 
@@ -33,7 +33,8 @@ fi
33
33
  # Determine $previous_path and other variables
34
34
  [ -h "<%= fetch(:current_path) %>" ] && [ -d "<%= fetch(:current_path) %>" ] && previous_path=$(cd "<%= fetch(:current_path) %>" >/dev/null && pwd -LP)
35
35
  build_path="./tmp/build-`date +%s`$RANDOM"
36
- version=$((`cat "<%= fetch(:deploy_to) %>/last_version" 2>/dev/null`+1))
36
+
37
+ version="<%= next_version %>"
37
38
  release_path="<%= fetch(:releases_path) %>/$version"
38
39
 
39
40
  # Sanity check
@@ -88,8 +89,7 @@ fi
88
89
  # === Complete & unlock
89
90
  (
90
91
  rm -f "<%= fetch(:lock_file) %>"
91
- echo "$version" > "./last_version"
92
- echo "-----> Done. Deployed v$version"
92
+ echo "-----> Done. Deployed version $version"
93
93
  ) ||
94
94
 
95
95
  # ============================
@@ -0,0 +1,31 @@
1
+ 3rd party modules
2
+ ------
3
+
4
+ * [mina-blue_green](https://github.com/reedlaw/mina-blue_green)
5
+ * [mina-cakephp](https://github.com/mobvox/mina-cakephp)
6
+ * [mina-clockwork](https://github.com/907th/mina-clockwork)
7
+ * [mina-data_sync](https://github.com/d4be4st/mina-data_sync)
8
+ * [mina-delayed_job](https://github.com/d4be4st/mina-delayed_job)
9
+ * [mina-faye](https://github.com/NingenUA/mina-faye)
10
+ * [mina-foreman](https://github.com/mina-deploy/mina-foreman)
11
+ * [mina-ftp](https://github.com/stas/mina-ftp)
12
+ * [mina-hipchat](https://github.com/apertureless/mina-hipchat)
13
+ * [mina-hooks](https://github.com/elskwid/mina-hooks)
14
+ * [mina-mercurial](https://github.com/rainlabs/mina-mercurial)
15
+ * [mina-multistage](https://github.com/endoze/mina-multistage)
16
+ * [mina-newrelic](https://github.com/navinpeiris/mina-newrelic)
17
+ * [mina-nginx](https://github.com/hbin/mina-nginx)
18
+ * [mina-npm](https://github.com/mina-deploy/mina-npm)
19
+ * [mina-puma](https://github.com/sandelius/mina-puma)
20
+ * [mina-rbenv-addons](https://github.com/stas/mina-rbenv-addons)
21
+ * [mina-rollbar](https://github.com/code-lever/mina-rollbar)
22
+ * [mina-rsync](https://github.com/moll/mina-rsync)
23
+ * [mina-s3](https://github.com/stas/mina-s3)
24
+ * [mina-scp](https://github.com/adie/mina-scp)
25
+ * [mina-secrets](https://github.com/infinum/mina-secrets)
26
+ * [mina-sidekiq](https://github.com/Mic92/mina-sidekiq)
27
+ * [mina-slack](https://github.com/TAKAyukiatkwsk/mina-slack)
28
+ * [mina-stack](https://github.com/div/mina-stack)
29
+ * [mina-tail](https://github.com/modomoto/mina-tail)
30
+ * [mina-unicorn](https://github.com/openteam/mina-unicorn)
31
+ * [mina-whenever](https://github.com/mina-deploy/mina-whenever)
data/docs/Readme.md CHANGED
@@ -6,3 +6,4 @@
6
6
  * [Writing your own tasks](writing_your_own_tasks.md)
7
7
  * [Command line options](command_line_options.md)
8
8
  * [FAQ](faq.md)
9
+ * [3rd party plugins](3rd_party_plugins.md)
@@ -20,7 +20,7 @@ Beside normal rake options mina added some of its own:
20
20
 
21
21
  ### Tasks
22
22
 
23
- There are many tasks available. See the [tasks reference](http://mina-deploy.github.io/mina/tasks/), or
23
+ There are many tasks available. See the [tasks reference](https://mina-deploy.github.io/mina/tasks/), or
24
24
  type `mina -T`.
25
25
 
26
26
  ### Variables
data/docs/deploying.md CHANGED
@@ -8,7 +8,7 @@ Mina provides the `deploy` command which runs your commands on remote backend.
8
8
  set :domain, 'flipstack.com'
9
9
  set :user, 'flipstack'
10
10
  set :deploy_to, '/var/www/flipstack.com'
11
- set :repository, 'http://github.com/flipstack/flipstack.git'
11
+ set :repository, 'https://github.com/flipstack/flipstack.git'
12
12
 
13
13
  task :deploy do
14
14
  deploy do
data/docs/faq.md CHANGED
@@ -1 +1,12 @@
1
+ Frequently Asked Questions
2
+ --------------------
3
+
4
+ * `command not found: bundle`
5
+
6
+ You need to setup your server correctly [getting_started.md#step-0-configure-server], then install bundler.
7
+
8
+ gem install bundler
9
+
10
+
11
+
1
12
  # WIP
@@ -3,6 +3,15 @@ Setting up a project
3
3
 
4
4
  Let's deploy a project using Mina.
5
5
 
6
+ ### Step 0: Configure server
7
+
8
+ Your server needs to be properly configured for mina to work. Requirements for mina 1.0 to work:
9
+ - SSH public/private key pair set up
10
+ - deploy user to have access to folders where you want to install the application
11
+ - installed git
12
+ - installed ruby (some ruby manager recommended rbenv/rvm/chruby)
13
+ - installed bundler
14
+
6
15
  ### Step 1: Create a config/deploy.rb
7
16
 
8
17
  In your project, type `mina init` to create a sample of this file.
data/docs/migrating.md CHANGED
@@ -26,5 +26,14 @@ Migrating from 0.3.x to 1.0
26
26
 
27
27
  # Deploy variables
28
28
 
29
+ * `shared_paths` -> separate into `shared_dirs` & `shared_files`
30
+
29
31
  All `*_path` variables (`:current_path`, `:shared_path`, ...) now include `:deploy_to`
30
32
  * `#{fetch(:deploy_to)}/#{fetch(:current_path)}` -> `fetch(:current_path)`
33
+
34
+ # Using new mina on old projects
35
+
36
+ * run `mina setup`
37
+ * if you do not want for bundle to install gems copy `current/vendor/bundle` to `/shared/vender/bundle`
38
+ * if you do not want to precompile assets copy `current/public/assets` to `shared/public/assets`
39
+ * if you want to precompile you will need to run deploy with `force_asset_precompile=true`
@@ -1,5 +1,7 @@
1
1
  module Mina
2
2
  class Application < Rake::Application
3
+ include Configuration::DSL
4
+
3
5
  def initialize
4
6
  super
5
7
  @rakefiles = ['config/deploy.rb', minafile]
@@ -48,7 +50,7 @@ module Mina
48
50
  ['--verbose', '-v',
49
51
  'Print more info',
50
52
  lambda do |_value|
51
- Mina::Configuration.instance.set(:verbose, true)
53
+ set(:verbose, true)
52
54
  end
53
55
  ]
54
56
  end
@@ -57,7 +59,7 @@ module Mina
57
59
  ['--simulate', '-s',
58
60
  'Do a simulate run without executing actions',
59
61
  lambda do |_value|
60
- Mina::Configuration.instance.set(:simulate, true)
62
+ set(:simulate, true)
61
63
  end
62
64
  ]
63
65
  end
@@ -66,7 +68,7 @@ module Mina
66
68
  ['--debug-configuration-variables', '-d',
67
69
  'Display the defined config variables before runnig the tasks.',
68
70
  lambda do |_value|
69
- Mina::Configuration.instance.set(:debug_configuration_variables, true)
71
+ set(:debug_configuration_variables, true)
70
72
  end
71
73
  ]
72
74
  end
@@ -1,12 +1,10 @@
1
1
  module Mina
2
2
  module Backend
3
3
  class Local
4
- attr_reader :commands, :configuration
5
- extend Forwardable
6
- def_delegators :configuration, :fetch, :set?
4
+ include Configuration::DSL
5
+ attr_reader :commands
7
6
 
8
7
  def initialize(commands)
9
- @configuration = Mina::Configuration.instance
10
8
  @commands = commands
11
9
  end
12
10
 
@@ -1,13 +1,10 @@
1
1
  module Mina
2
2
  module Backend
3
3
  class Remote
4
- attr_reader :commands, :configuration
5
-
6
- extend Forwardable
7
- def_delegators :configuration, :fetch, :set?
4
+ attr_reader :commands
5
+ include Configuration::DSL
8
6
 
9
7
  def initialize(commands)
10
- @configuration = Mina::Configuration.instance
11
8
  @commands = commands
12
9
  end
13
10
 
@@ -23,8 +20,6 @@ module Mina
23
20
  end
24
21
  end
25
22
 
26
- private
27
-
28
23
  def ssh
29
24
  fail 'No domain set' unless set?(:domain)
30
25
  args = fetch(:domain)
data/lib/mina/commands.rb CHANGED
@@ -2,10 +2,10 @@ module Mina
2
2
  class Commands
3
3
  extend Forwardable
4
4
  include Helpers::Internal
5
+ include Configuration::DSL
5
6
 
6
7
  attr_reader :queue
7
8
  attr_accessor :stage
8
- def_delegators :queue, :find, :fetch, :process
9
9
 
10
10
  def initialize(stage = :default)
11
11
  @stage = stage
@@ -19,27 +19,29 @@ module Mina
19
19
 
20
20
  def comment(code, indent: nil)
21
21
  if indent
22
- queue[stage] << indent(indent, "echo '-----> #{code}'")
22
+ queue[stage] << indent(indent, %(echo "-----> #{code}"))
23
23
  else
24
- queue[stage] << "echo '-----> #{code}'"
24
+ queue[stage] << %(echo "-----> #{code}")
25
25
  end
26
26
  end
27
27
 
28
- def fetch(stage)
28
+ def delete(stage)
29
29
  queue.delete(stage) || []
30
30
  end
31
31
 
32
32
  def process(path = nil)
33
33
  if path
34
- queue[stage].unshift("echo '$ cd #{path}'") if Mina::Configuration.instance.fetch(:verbose)
34
+ queue[stage].unshift("echo '$ cd #{path}'") if fetch(:verbose)
35
35
  "(cd #{path} && #{queue[stage].join(' && ')})"
36
36
  else
37
- fetch(stage).join("\n")
37
+ queue[stage].join("\n")
38
38
  end
39
39
  end
40
40
 
41
41
  def run(backend)
42
- Mina::Runner.new(process, backend).run
42
+ report_time do
43
+ Mina::Runner.new(process, backend).run
44
+ end
43
45
  end
44
46
  end
45
47
  end
@@ -2,6 +2,16 @@ module Mina
2
2
  class Configuration
3
3
  include Singleton
4
4
 
5
+ module DSL
6
+ def self.included(base)
7
+ [:set, :fetch, :remove, :set?, :ensure!, :reset!].each do |method|
8
+ base.send :define_method, method do |*args, &block|
9
+ Configuration.instance.send(method, *args, &block)
10
+ end
11
+ end
12
+ end
13
+ end
14
+
5
15
  attr_reader :variables
6
16
 
7
17
  def initialize
@@ -1,6 +1,8 @@
1
1
  module Mina
2
2
  module Helpers
3
3
  module Internal
4
+ extend Configuration::DSL
5
+
4
6
  def deploy_script
5
7
  yield
6
8
  erb Mina.root_path(fetch(:deploy_script))
@@ -13,7 +15,7 @@ module Mina
13
15
  end
14
16
 
15
17
  def echo_cmd(code, ignore_verbose = false)
16
- if Mina::Configuration.instance.fetch(:verbose) && !ignore_verbose
18
+ if fetch(:verbose) && !ignore_verbose
17
19
  "echo #{Shellwords.escape('$ ' + code)} &&\n#{code}"
18
20
  else
19
21
  code
@@ -23,6 +25,24 @@ module Mina
23
25
  def indent(count, str)
24
26
  str.gsub(/^/, ' ' * count)
25
27
  end
28
+
29
+ def report_time
30
+ time_start = Time.now
31
+ output = yield
32
+ puts "Elapsed time: %.2f seconds" % [Time.now - time_start]
33
+ output
34
+ end
35
+
36
+ def next_version
37
+ case fetch(:version_scheme)
38
+ when :datetime
39
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
40
+ when :sequence
41
+ "$((`ls -1 #{fetch(:releases_path)} | sort -n | tail -n 1`+1))"
42
+ else
43
+ fail 'Unrecognizes version scheme. Use :datetime or :sequence'
44
+ end
45
+ end
26
46
  end
27
47
  end
28
48
  end
data/lib/mina/runner.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Mina
2
2
  class Runner
3
3
  attr_reader :commands, :backend
4
+ include Configuration::DSL
4
5
 
5
6
  def initialize(commands, backend)
6
7
  fail 'You must specify execution mode' if execution_mode.nil?
@@ -15,10 +16,10 @@ module Mina
15
16
 
16
17
  def execution_mode
17
18
  @execution_mode ||=
18
- if Mina::Configuration.instance.fetch(:simulate)
19
+ if fetch(:simulate)
19
20
  :printer
20
21
  else
21
- Mina::Configuration.instance.fetch(:execution_mode)
22
+ fetch(:execution_mode)
22
23
  end
23
24
  end
24
25
 
data/lib/mina/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mina
2
- VERSION = '1.0.0.beta1'.freeze
2
+ VERSION = '1.0.0.beta2'.freeze
3
3
  end
@@ -0,0 +1,15 @@
1
+ #if windows os
2
+ require 'rbconfig'
3
+ is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
4
+ if is_windows
5
+ module Shellwords
6
+ def shellescape(str)
7
+ '"' + str.gsub(/\\(?=\\*\")/, "\\\\\\").gsub(/\"/, "\\\"").gsub(/\\$/, "\\\\\\").gsub("%", "%%") + '"'
8
+ end
9
+
10
+ module_function :shellescape
11
+ class << self
12
+ alias escape shellescape
13
+ end
14
+ end
15
+ end
data/lib/mina.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rake'
2
2
  Rake.application.options.trace = true
3
3
 
4
- require 'pry'
4
+ # require 'pry'
5
5
  # require 'awesome_print'
6
6
 
7
7
  require 'forwardable'
@@ -22,14 +22,10 @@ require 'mina/runner/exec'
22
22
  require 'mina/runner/printer'
23
23
  require 'mina/backend/local'
24
24
  require 'mina/backend/remote'
25
+ require 'mina/windows_patches'
25
26
  require 'mina/application'
26
27
 
27
28
  module Mina
28
- # Error = Class.new(Exception)
29
- # class Failed < Error
30
- # attr_accessor :exitstatus
31
- # end
32
- #
33
29
  def self.root_path(*args)
34
30
  File.join File.expand_path('../../', __FILE__), *args
35
31
  end
data/mina.gemspec CHANGED
@@ -19,12 +19,12 @@ Gem::Specification.new do |spec|
19
19
  spec.files = `git ls-files`.strip.split("\n")
20
20
  spec.executables = Dir['bin/*'].map { |f| File.basename(f) }
21
21
  spec.licenses = ['MIT']
22
- spec.require_paths = ['lib']
22
+ spec.require_paths = ['lib', 'tasks']
23
23
 
24
24
  spec.add_dependency 'rake'
25
25
  spec.add_dependency 'open4', '~> 1.3.4'
26
26
  spec.add_development_dependency 'rspec', '~> 3.0.0'
27
- spec.add_development_dependency 'pry', '~> 0.9.0'
27
+ spec.add_development_dependency 'pry-byebug'
28
28
  spec.add_development_dependency 'awesome_print'
29
29
  spec.add_development_dependency 'codeclimate-test-reporter'
30
30
  end
@@ -37,21 +37,21 @@ describe Mina::Commands do
37
37
  it 'adds a comment to the queue' do
38
38
  commands.comment('ls -al')
39
39
 
40
- expect(commands.queue[:default]).to include("echo '-----> ls -al'")
40
+ expect(commands.queue[:default]).to include('echo "-----> ls -al"')
41
41
  end
42
42
 
43
43
  it 'indents a comment' do
44
44
  commands.comment('ls -al', indent: 4)
45
45
 
46
- expect(commands.queue[:default]).to include(" echo '-----> ls -al'")
46
+ expect(commands.queue[:default]).to include(' echo "-----> ls -al"')
47
47
  end
48
48
  end
49
49
 
50
- describe '#fetch' do
50
+ describe '#delete' do
51
51
  it 'returns a stage and deletes it from commands' do
52
52
  commands.command('ls -al')
53
53
 
54
- expect(commands.fetch(:default)).to include('ls -al')
54
+ expect(commands.delete(:default)).to include('ls -al')
55
55
  expect(commands.queue[:default]).to be_empty
56
56
  end
57
57
  end
@@ -49,4 +49,15 @@ describe Mina::Configuration do
49
49
  expect { config.ensure!(:key) }.to raise_error(StandardError)
50
50
  end
51
51
  end
52
+
53
+ describe Mina::Configuration::DSL do
54
+ let(:host_class) { Class.new { include Mina::Configuration::DSL } }
55
+ let(:host) { host_class.new }
56
+
57
+ [:fetch, :set].each do |method|
58
+ it "should respond to #{method}" do
59
+ expect(host).to respond_to(method)
60
+ end
61
+ end
62
+ end
52
63
  end
@@ -9,7 +9,10 @@ describe Mina::Helpers::Internal do
9
9
  let(:helper) { DummyInternalHelper.new }
10
10
 
11
11
  describe '#deploy_script' do
12
- before { Mina::Configuration.instance.set(:deploy_script, 'data/deploy.sh.erb') }
12
+ before do
13
+ Mina::Configuration.instance.set(:deploy_script, 'data/deploy.sh.erb')
14
+ Mina::Configuration.instance.set(:version_scheme, :sequence)
15
+ end
13
16
 
14
17
  it 'returns whole script' do
15
18
  expect(helper.deploy_script {}).to_not be_empty
@@ -17,6 +20,8 @@ describe Mina::Helpers::Internal do
17
20
  end
18
21
 
19
22
  describe '#erb' do
23
+ before { Mina::Configuration.instance.set(:version_scheme, :sequence) }
24
+
20
25
  it 'returns whole script' do
21
26
  expect(helper.erb('data/deploy.sh.erb')).to_not be_empty
22
27
  end
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,15 @@
1
+ require 'codeclimate-test-reporter'
2
+ require 'simplecov'
3
+
4
+ CodeClimate::TestReporter.start
5
+ SimpleCov.start
6
+
1
7
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
8
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
9
 
4
10
  require 'mina'
5
11
  require 'rspec'
6
- require 'codeclimate-test-reporter'
7
- CodeClimate::TestReporter.start
12
+ require 'pry'
8
13
 
9
14
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
10
15
 
@@ -2,7 +2,7 @@ require 'mina/default'
2
2
 
3
3
  set :bundle_bin, 'bundle'
4
4
  set :bundle_path, 'vendor/bundle'
5
- set :bundle_withouts, 'development:test'
5
+ set :bundle_withouts, 'development test'
6
6
  set :bundle_options, -> { "--without #{fetch(:bundle_withouts)} --path '#{fetch(:bundle_path)}' --deployment" }
7
7
  set :shared_dirs, fetch(:shared_dirs, []).push(fetch(:bundle_path))
8
8
 
@@ -12,4 +12,10 @@ namespace :bundle do
12
12
  comment 'Installing gem dependencies using Bundler'
13
13
  command "#{fetch(:bundle_bin)} install #{fetch(:bundle_options)}"
14
14
  end
15
+
16
+ desc 'Cleans up unused gems in your bundler directory'
17
+ task :clean do
18
+ comment 'Cleans up unsed gems'
19
+ command "#{fetch(:bundle_bin)} clean #{fetch(:bundle_options)}"
20
+ end
15
21
  end
@@ -15,6 +15,19 @@ task debug_configuration_variables: :environment do
15
15
  end
16
16
  end
17
17
 
18
+ desc 'Adds current repo host to the known hosts'
19
+ task :ssh_keyscan do
20
+ ensure!(:repository)
21
+ repo_host = fetch(:repository).split(%r{@|://}).last.split(%r{:|\/}).first
22
+ repo_port = /:([0-9]+)/.match(fetch(:repository)) && /:([0-9]+)/.match(fetch(:repository))[1] || '22'
23
+
24
+ command %[
25
+ if ! ssh-keygen -H -F #{repo_host} &>/dev/null; then
26
+ ssh-keyscan -t rsa -p #{repo_port} -H #{repo_host} >> ~/.ssh/known_hosts
27
+ fi
28
+ ]
29
+ end
30
+
18
31
  desc 'Runs a command in the server.'
19
32
  task :run, [:command] => [:environment] do |_, args|
20
33
  ensure!(:deploy_to)
@@ -32,5 +45,5 @@ end
32
45
 
33
46
  desc 'Open an ssh session to the server and cd to deploy_to folder'
34
47
  task ssh: :environment do
35
- exec ssh_command + " 'cd #{deploy_to} && exec \$SHELL'"
48
+ exec Mina::Backend::Remote.new(nil).ssh + " 'cd #{fetch(:deploy_to)} && exec \$SHELL'"
36
49
  end
data/tasks/mina/deploy.rb CHANGED
@@ -6,6 +6,7 @@ set :current_path, -> { "#{fetch(:deploy_to)}/current" }
6
6
  set :lock_file, 'deploy.lock'
7
7
  set :deploy_script, 'data/deploy.sh.erb'
8
8
  set :keep_releases, 5
9
+ set :version_scheme, :datetime
9
10
  set :execution_mode, :pretty
10
11
 
11
12
  namespace :deploy do
@@ -37,29 +38,27 @@ namespace :deploy do
37
38
 
38
39
  comment "Cleaning up old releases (keeping #{fetch(:keep_releases)})"
39
40
  in_path "#{fetch(:releases_path)}" do
40
- command 'count=`ls -1 | sort -rn | wc -l`'
41
+ command 'count=`ls -A1 | sort -rn | wc -l`'
41
42
  command "remove=$((count > #{fetch(:keep_releases)} ? $count - #{fetch(:keep_releases)} : 0))"
42
- command 'ls -1 | sort -rn | tail -n $remove | xargs rm -rf {}'
43
+ command 'ls -A1 | sort -rn | tail -n $remove | xargs rm -rf {}'
43
44
  end
44
45
  end
45
46
  end
46
47
 
47
- # TODO: Test this
48
- # desc 'Rollbacks the latest release'
49
- # task rollback: :environment do
50
- # comment "Rolling back to previous release for instance: #{fetch(:domain)}"
51
- #
52
- # # Delete existing sym link and create a new symlink pointing to the previous release
53
- # comment 'Creating new symlink from the previous release: '
54
- # command "ls -Art '#{fetch(:releases_path)}' | sort | tail -n 2 | head -n 1"
55
- # command "ls -Art '#{fetch(:releases_path)}' | sort | tail -n 2 | head -n 1 | xargs -I active ln -nfs '#{fetch(:releases_path)}/active' '#{fetch(:current_path)}'"
56
- #
57
- # # Remove latest release folder (current release)
58
- # comment 'Deleting current release: '
59
- # command "ls -Art '#{fetch(:releases_path)}' | sort | tail -n 1"
60
- # command "ls -Art '#{fetch(:releases_path)}' | sort | tail -n 1 | xargs -I active rm -rf '#{fetch(:releases_path)}/active'"
61
- # end
62
- # end
48
+ desc 'Rollbacks the latest release'
49
+ task rollback: :environment do
50
+ comment "Rolling back to previous release"
51
+
52
+ in_path "#{fetch(:releases_path)}" do
53
+ # TODO: add check if there are more than 1 release
54
+ command "rollback_release=`ls -1A | sort -n | tail -n 2 | head -n 1`"
55
+ comment 'Rollbacking to release: $rollback_release'
56
+ command "ln -nfs #{fetch(:releases_path)}/$rollback_release #{fetch(:current_path)}"
57
+ command "current_release=`ls -1A | sort -n | tail -n 1`"
58
+ comment 'Deleting current release: $current_release'
59
+ command "rm -rf #{fetch(:releases_path)}/$current_release"
60
+ end
61
+ end
63
62
 
64
63
  desc 'Sets up a site.'
65
64
  task setup: :environment do
@@ -82,4 +81,6 @@ task setup: :environment do
82
81
  end
83
82
 
84
83
  command "tree '#{fetch(:deploy_to)}' || ls -al '#{fetch(:deploy_to)}'"
84
+
85
+ invoke :ssh_keyscan
85
86
  end
data/tasks/mina/git.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'mina/default'
2
2
 
3
3
  set :branch, 'master'
4
+ set :remove_git_dir, true
4
5
 
5
6
  namespace :git do
6
7
  desc 'Clones the Git repository to the release path.'
@@ -26,7 +27,9 @@ namespace :git do
26
27
  comment 'Using this git commit'
27
28
  command 'git rev-parse HEAD > .mina_git_revision'
28
29
  command "git --no-pager log --format='%aN (%h):%n> %s' -n 1"
29
- command 'rm -rf .git'
30
+ if fetch(:remove_git_dir)
31
+ command 'rm -rf .git'
32
+ end
30
33
  end
31
34
 
32
35
  task revision: :environment do
@@ -4,7 +4,7 @@ task :init do
4
4
  config_file = Rake.application.rakefile
5
5
 
6
6
  unless File.exist?(config_file)
7
- print_str "! You already have #{config_file}."
7
+ puts "! You already have #{config_file}."
8
8
  exit 8
9
9
  end
10
10
 
@@ -13,6 +13,6 @@ task :init do
13
13
  FileUtils.mkdir_p './config'
14
14
  FileUtils.cp Mina.root_path('data/deploy.rb'), outfile
15
15
 
16
- print_str "-----> Created #{outfile}"
17
- print_str "Edit this file, then run `#{name} setup` after."
16
+ puts "-----> Created #{outfile}"
17
+ puts "Edit this file, then run `#{name} setup` after."
18
18
  end
data/tasks/mina/rails.rb CHANGED
@@ -6,7 +6,8 @@ set :bundle_prefix, -> { "RAILS_ENV='#{fetch(:rails_env)}' #{fetch(:bundle_bin)}
6
6
  set :rake, -> { "#{fetch(:bundle_prefix)} rake" }
7
7
  set :rails, -> { "#{fetch(:bundle_prefix)} rails" }
8
8
  set :compiled_asset_path, 'public/assets'
9
- set :asset_paths, ['vendor/assets/', 'app/assets/']
9
+ set :asset_dirs, ['vendor/assets/', 'app/assets/']
10
+ set :migration_dirs, ['db/migrate']
10
11
 
11
12
  set :shared_dirs, fetch(:shared_dirs, []).push('log', 'tmp/cache', fetch(:compiled_asset_path))
12
13
 
@@ -34,7 +35,7 @@ namespace :rails do
34
35
  command "#{fetch(:rake)} db:migrate"
35
36
  else
36
37
  command check_for_changes_script(
37
- at: ['db/migrate'],
38
+ at: fetch(:migration_dirs),
38
39
  skip: "echo '-----> DB migrations unchanged; skipping DB migration'",
39
40
  changed: %(
40
41
  echo '-----> Migrating database'
@@ -63,7 +64,7 @@ namespace :rails do
63
64
  command "#{fetch(:rake)} assets:precompile"
64
65
  else
65
66
  command check_for_changes_script(
66
- at: fetch(:asset_paths),
67
+ at: fetch(:asset_dirs),
67
68
  skip: 'echo "-----> Skipping asset precompilation"',
68
69
  changed: %(
69
70
  echo "-----> Precompiling asset files"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta1
4
+ version: 1.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stjepan Hadjić
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-06-30 00:00:00.000000000 Z
14
+ date: 2016-07-30 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
@@ -56,19 +56,19 @@ dependencies:
56
56
  - !ruby/object:Gem::Version
57
57
  version: 3.0.0
58
58
  - !ruby/object:Gem::Dependency
59
- name: pry
59
+ name: pry-byebug
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - "~>"
62
+ - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: 0.9.0
64
+ version: '0'
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - "~>"
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: 0.9.0
71
+ version: '0'
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: awesome_print
74
74
  requirement: !ruby/object:Gem::Requirement
@@ -120,6 +120,7 @@ files:
120
120
  - bin/mina
121
121
  - data/deploy.rb
122
122
  - data/deploy.sh.erb
123
+ - docs/3rd_party_plugins.md
123
124
  - docs/Readme.md
124
125
  - docs/command_line_options.md
125
126
  - docs/deploying.md
@@ -143,6 +144,7 @@ files:
143
144
  - lib/mina/runner/printer.rb
144
145
  - lib/mina/runner/system.rb
145
146
  - lib/mina/version.rb
147
+ - lib/mina/windows_patches.rb
146
148
  - mina.gemspec
147
149
  - spec/lib/mina/application_spec.rb
148
150
  - spec/lib/mina/backend/local_spec.rb
@@ -174,6 +176,7 @@ post_install_message:
174
176
  rdoc_options: []
175
177
  require_paths:
176
178
  - lib
179
+ - tasks
177
180
  required_ruby_version: !ruby/object:Gem::Requirement
178
181
  requirements:
179
182
  - - ">="