Merge branch 'cleanup/major'
Conflicts: README.md
This commit is contained in:
commit
6e7ce4d72d
29 changed files with 360 additions and 233 deletions
3
.document
Normal file
3
.document
Normal file
|
@ -0,0 +1,3 @@
|
|||
LICENSE.md
|
||||
README.md
|
||||
lib/**/*.rb
|
26
.gitignore
vendored
26
.gitignore
vendored
|
@ -1,8 +1,18 @@
|
|||
# Ignore bundler lock file
|
||||
/Gemfile.lock
|
||||
|
||||
# Ignore pkg folder
|
||||
/pkg
|
||||
|
||||
# Ignore coverage folder
|
||||
/coverage
|
||||
*.gem
|
||||
*.rbc
|
||||
.bundle
|
||||
.config
|
||||
.yardoc
|
||||
Gemfile.lock
|
||||
InstalledFiles
|
||||
_yardoc
|
||||
coverage
|
||||
doc/
|
||||
lib/bundler/man
|
||||
pkg
|
||||
rdoc
|
||||
spec/reports
|
||||
test/tmp
|
||||
test/version_tmp
|
||||
tmp
|
||||
bin
|
24
.rubocop.yml
Normal file
24
.rubocop.yml
Normal file
|
@ -0,0 +1,24 @@
|
|||
AllCops:
|
||||
Include:
|
||||
- Rakefile
|
||||
- Gemfile
|
||||
Exclude:
|
||||
- script/**/*
|
||||
- vendor/**/*
|
||||
- bin/**/*
|
||||
LineLength:
|
||||
Enabled: false
|
||||
MethodLength:
|
||||
Enabled: false
|
||||
ClassLength:
|
||||
Enabled: false
|
||||
Documentation:
|
||||
Enabled: false
|
||||
Encoding:
|
||||
Enabled: false
|
||||
Blocks:
|
||||
Enabled: false
|
||||
AlignParameters:
|
||||
Enabled: false
|
||||
HashSyntax:
|
||||
EnforcedStyle: ruby19
|
24
.travis.yml
Normal file
24
.travis.yml
Normal file
|
@ -0,0 +1,24 @@
|
|||
language: ruby
|
||||
cache: bundler
|
||||
bundler_args: --without development
|
||||
rvm:
|
||||
- ruby-head
|
||||
- ruby
|
||||
- jruby-head
|
||||
- jruby
|
||||
- 2.1.0
|
||||
- 2.0.0
|
||||
- 1.9.3
|
||||
- rbx-2
|
||||
matrix:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- rvm: ruby-head
|
||||
- rvm: ruby
|
||||
- rvm: jruby-head
|
||||
- rvm: jruby
|
||||
- rvm: rbx-2
|
||||
notifications:
|
||||
email: false
|
||||
env:
|
||||
- CODECLIMATE_REPO_TOKEN=5eee8e8624962f963a52a1d2313dc7407e3b8006291e3704346c786642cc073b
|
6
.yardopts
Normal file
6
.yardopts
Normal file
|
@ -0,0 +1,6 @@
|
|||
--markup markdown
|
||||
-
|
||||
CHANGELOG.md
|
||||
CONTRIBUTING.md
|
||||
LICENSE.md
|
||||
README.md
|
44
CONTRIBUTING.md
Normal file
44
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,44 @@
|
|||
## Contributing
|
||||
In the spirit of [free software][free-sw], **everyone** is encouraged to help
|
||||
improve this project.
|
||||
|
||||
[free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
|
||||
|
||||
Here are some ways *you* can contribute:
|
||||
|
||||
* by using alpha, beta, and prerelease versions
|
||||
* by reporting bugs
|
||||
* by suggesting new features
|
||||
* by writing or editing documentation
|
||||
* by writing specifications
|
||||
* by writing code (**no patch is too small**: fix typos, add comments, clean up
|
||||
inconsistent whitespace)
|
||||
* by refactoring code
|
||||
* by closing [issues][]
|
||||
* by reviewing patches
|
||||
|
||||
[issues]: https://github.com/karlfreeman/middleman-deploy/issues
|
||||
|
||||
## Submitting an Issue
|
||||
We use the [GitHub issue tracker][issues] to track bugs and features. Before
|
||||
submitting a bug report or feature request, check to make sure it hasn't
|
||||
already been submitted. When submitting a bug report, please include a [Gist][]
|
||||
that includes a stack trace and any details that may be necessary to reproduce
|
||||
the bug, including your gem version, Ruby version, and operating system.
|
||||
Ideally, a bug report should include a pull request with failing specs.
|
||||
|
||||
[gist]: https://gist.github.com/
|
||||
|
||||
## Submitting a Pull Request
|
||||
1. [Fork the repository.][fork]
|
||||
2. [Create a topic branch.][branch]
|
||||
3. Add specs for your unimplemented feature or bug fix.
|
||||
4. Run `bundle exec rake cucumber`. If your specs pass, return to step 3.
|
||||
5. Implement your feature or bug fix.
|
||||
6. Run `bundle exec rake cucumber`. If your specs fail, return to step 5.
|
||||
7. Add, commit, and push your changes.
|
||||
9. [Submit a pull request.][pr]
|
||||
|
||||
[fork]: http://help.github.com/fork-a-repo/
|
||||
[branch]: http://learn.github.com/p/branching.html
|
||||
[pr]: http://help.github.com/send-pull-requests/
|
18
Gemfile
18
Gemfile
|
@ -1,19 +1,11 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
# Specify your gem's dependencies in middleman-deploy.gemspec
|
||||
gemspec
|
||||
|
||||
group :development do
|
||||
gem "rake"
|
||||
gem "rdoc"
|
||||
gem "yard"
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem "compass"
|
||||
gem "cucumber"
|
||||
gem "fivemat"
|
||||
gem "aruba"
|
||||
gem "rspec"
|
||||
gem "simplecov"
|
||||
gem 'rake', '~> 10.0'
|
||||
gem 'cucumber', '~> 1.3'
|
||||
gem 'aruba', '~> 0.5'
|
||||
gem 'fivemat'
|
||||
gem 'codeclimate-test-reporter'
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
Copyright (c) 2012 Tom Vaughan <thomas.david.vaughan@gmail.com>
|
||||
Copyright (c) 2012-2014 Tom Vaughan, Karl Freeman
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
@ -8,13 +10,13 @@ distribute, sublicense, and/or sell copies of the Software, and to
|
|||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
114
README.md
114
README.md
|
@ -1,18 +1,13 @@
|
|||
# middleman-deploy [![Gem Version](https://badge.fury.io/rb/middleman-deploy.png)](http://badge.fury.io/rb/middleman-deploy)
|
||||
# Middleman Deploy
|
||||
|
||||
Deploys a [middleman](http://middlemanapp.com/) built site via **rsync**,
|
||||
**ftp**, **sftp**, or **git** (e.g. gh-pages on github).
|
||||
Deploy your [Middleman](http://middlemanapp.com/) build via **rsync**, **ftp**, **sftp**, or **git** (e.g. [gh-pages on github](https://help.github.com/articles/creating-project-pages-manually)).
|
||||
|
||||
## Installation
|
||||
|
||||
Add this to the Gemfile of the repository of your middleman site:
|
||||
|
||||
```ruby
|
||||
gem "middleman-deploy"
|
||||
gem 'middleman-deploy', '~> 2.5'
|
||||
```
|
||||
|
||||
and run `bundle install`.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
|
@ -20,23 +15,11 @@ $ middleman build [--clean]
|
|||
$ middleman deploy [--build-before]
|
||||
```
|
||||
|
||||
To automatically run `middleman build` during `middleman deploy`, turn on the
|
||||
`build_before` option while activating the deploy extension:
|
||||
|
||||
```ruby
|
||||
activate :deploy do |deploy|
|
||||
# ...
|
||||
deploy.build_before = true # default: false
|
||||
end
|
||||
```
|
||||
|
||||
## Possible Configurations
|
||||
|
||||
Middleman-deploy can deploy a site via rsync, ftp, sftp, or git.
|
||||
Middleman-deploy can deploy a site via rsync, ftp, sftp, or git. Checkout [the wiki](https://github.com/tvaughan/middleman-deploy/wiki/_pages) for advanced set-up options.
|
||||
|
||||
Checkout [the wiki](https://github.com/tvaughan/middleman-deploy/wiki/_pages) for advanced set-up options.
|
||||
|
||||
### rsync
|
||||
### Rsync
|
||||
|
||||
Make sure that `rsync` is installed, and activate the extension by adding the
|
||||
following to `config.rb`:
|
||||
|
@ -44,13 +27,13 @@ following to `config.rb`:
|
|||
```ruby
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :rsync
|
||||
deploy.host = "www.example.com"
|
||||
deploy.path = "/srv/www/site"
|
||||
deploy.host = 'www.example.com'
|
||||
deploy.path = '/srv/www/site'
|
||||
# Optional Settings
|
||||
# deploy.user = "tvaughan" # no default
|
||||
# deploy.user = 'tvaughan' # no default
|
||||
# deploy.port = 5309 # ssh port, default: 22
|
||||
# deploy.clean = true # remove orphaned files on remote host, default: false
|
||||
# deploy.flags = "-rltgoDvzO --no-p --del" # add custom flags, default: -avz
|
||||
# deploy.flags = '-rltgoDvzO --no-p --del' # add custom flags, default: -avz
|
||||
end
|
||||
```
|
||||
|
||||
|
@ -63,10 +46,10 @@ following to `config.rb`:
|
|||
activate :deploy do |deploy|
|
||||
deploy.method = :git
|
||||
# Optional Settings
|
||||
# deploy.remote = "custom-remote" # remote name or git url, default: origin
|
||||
# deploy.branch = "custom-branch" # default: gh-pages
|
||||
# deploy.remote = 'custom-remote' # remote name or git url, default: origin
|
||||
# deploy.branch = 'custom-branch' # default: gh-pages
|
||||
# deploy.strategy = :submodule # commit strategy: can be :force_push or :submodule, default: :force_push
|
||||
# deploy.commit_message = "custom-message" # commit message (can be empty), default: Automated commit at `timestamp` by middleman-deploy `version`
|
||||
# deploy.commit_message = 'custom-message' # commit message (can be empty), default: Automated commit at `timestamp` by middleman-deploy `version`
|
||||
end
|
||||
```
|
||||
|
||||
|
@ -88,10 +71,10 @@ Activate the extension by adding the following to `config.rb`:
|
|||
```ruby
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :ftp
|
||||
deploy.host = "ftp.example.com"
|
||||
deploy.path = "/srv/www/site"
|
||||
deploy.user = "tvaughan"
|
||||
deploy.password = "secret"
|
||||
deploy.host = 'ftp.example.com'
|
||||
deploy.path = '/srv/www/site'
|
||||
deploy.user = 'tvaughan'
|
||||
deploy.password = 'secret'
|
||||
end
|
||||
```
|
||||
|
||||
|
@ -102,12 +85,24 @@ Activate the extension by adding the following to `config.rb`:
|
|||
```ruby
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :sftp
|
||||
deploy.host = "sftp.example.com"
|
||||
deploy.host = 'sftp.example.com'
|
||||
deploy.port = 22
|
||||
deploy.path = "/srv/www/site"
|
||||
deploy.path = '/srv/www/site'
|
||||
# Optional Settings
|
||||
# deploy.user = "tvaughan" # no default
|
||||
# deploy.password = "secret" # no default
|
||||
# deploy.user = 'tvaughan' # no default
|
||||
# deploy.password = 'secret' # no default
|
||||
end
|
||||
```
|
||||
|
||||
### Run Automatically
|
||||
|
||||
To automatically run `middleman build` during `middleman deploy`, turn on the
|
||||
`build_before` option while activating the deploy extension:
|
||||
|
||||
```ruby
|
||||
activate :deploy do |deploy|
|
||||
# ...
|
||||
deploy.build_before = true # default: false
|
||||
end
|
||||
```
|
||||
|
||||
|
@ -121,14 +116,14 @@ case ENV['TARGET'].to_s.downcase
|
|||
when 'production'
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :rsync
|
||||
deploy.host = "www.example.com"
|
||||
deploy.path = "/srv/www/production-site"
|
||||
deploy.host = 'www.example.com'
|
||||
deploy.path = '/srv/www/production-site'
|
||||
end
|
||||
else
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :rsync
|
||||
deploy.host = "staging.example.com"
|
||||
deploy.path = "/srv/www/staging-site"
|
||||
deploy.host = 'staging.example.com'
|
||||
deploy.path = '/srv/www/staging-site'
|
||||
end
|
||||
end
|
||||
```
|
||||
|
@ -166,13 +161,38 @@ end
|
|||
sense. `deploy` was added to the `after_build` hook simply because it
|
||||
was available.
|
||||
|
||||
## Badges
|
||||
|
||||
[![Gem Version](http://img.shields.io/gem/v/middleman-deploy.svg)][gem]
|
||||
[![Build Status](http://img.shields.io/travis/karlfreeman/middleman-deploy.svg)][travis]
|
||||
[![Code Quality](http://img.shields.io/codeclimate/github/karlfreeman/middleman-deploy.svg)][codeclimate]
|
||||
[![Code Coverage](http://img.shields.io/codeclimate/coverage/github/karlfreeman/middleman-deploy.svg)][codeclimate]
|
||||
[![Gittip](http://img.shields.io/gittip/karlfreeman.svg)][gittip]
|
||||
|
||||
## Supported Ruby Versions
|
||||
|
||||
This library aims to support and is [tested against][travis] the following Ruby
|
||||
implementations:
|
||||
|
||||
- Ruby 2.1.0
|
||||
- Ruby 2.0.0
|
||||
- Ruby 1.9.3
|
||||
- [JRuby][jruby]
|
||||
- [Rubinius][rubinius]
|
||||
|
||||
## Thanks!
|
||||
|
||||
A **BIG** thanks to
|
||||
[everyone who has contributed](https://github.com/tvaughan/middleman-deploy/graphs/contributors)!
|
||||
Almost all pull requests are accepted.
|
||||
A **BIG** thanks to [everyone who has contributed](https://github.com/tvaughan/middleman-deploy/graphs/contributors)! Almost all pull requests are accepted.
|
||||
|
||||
## Other
|
||||
# Credits
|
||||
|
||||
Inspired by the rsync task in
|
||||
[Octopress](https://github.com/imathis/octopress).
|
||||
Inspiration:
|
||||
|
||||
- The rsync task in [Octopress](https://github.com/imathis/octopress)
|
||||
|
||||
[gem]: https://rubygems.org/gems/middleman-deploy
|
||||
[travis]: http://travis-ci.org/karlfreeman/middleman-deploy
|
||||
[codeclimate]: https://codeclimate.com/github/karlfreeman/middleman-deploy
|
||||
[gittip]: https://www.gittip.com/karlfreeman
|
||||
[jruby]: http://www.jruby.org
|
||||
[rubinius]: http://rubini.us
|
||||
|
|
21
Rakefile
21
Rakefile
|
@ -1,14 +1,25 @@
|
|||
require 'bundler'
|
||||
Bundler.setup
|
||||
Bundler::GemHelper.install_tasks
|
||||
|
||||
require 'cucumber/rake/task'
|
||||
|
||||
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
||||
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
|
||||
exempt_tags = ['--tags ~@wip']
|
||||
t.cucumber_opts = "--color #{exempt_tags.join(' ')} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
|
||||
end
|
||||
|
||||
require 'rake/clean'
|
||||
begin
|
||||
require 'yard'
|
||||
YARD::Rake::YardocTask.new
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
task :test => ["cucumber"]
|
||||
begin
|
||||
require 'rubocop/rake_task'
|
||||
desc 'Run rubocop'
|
||||
Rubocop::RakeTask.new(:rubocop)
|
||||
rescue LoadError
|
||||
end
|
||||
|
||||
task :default => :test
|
||||
task default: :cucumber
|
||||
task test: :cucumber
|
||||
|
|
56
USAGE
56
USAGE
|
@ -1,56 +0,0 @@
|
|||
You should follow one of the four examples below to setup the deploy
|
||||
extension in config.rb.
|
||||
|
||||
# To deploy the build directory to a remote host via rsync:
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :rsync
|
||||
# host and path *must* be set
|
||||
deploy.host = "www.example.com"
|
||||
deploy.path = "/srv/www/site"
|
||||
# user is optional (no default)
|
||||
deploy.user = "tvaughan"
|
||||
# port is optional (default is 22)
|
||||
deploy.port = 5309
|
||||
# clean is optional (default is false)
|
||||
deploy.clean = true
|
||||
# flags is optional (default is -avze)
|
||||
deploy.flags = "-rltgoDvzO --no-p --del -e"
|
||||
end
|
||||
|
||||
# To deploy to a remote branch via git (e.g. gh-pages on github):
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :git
|
||||
# remote is optional (default is "origin")
|
||||
# run `git remote -v` to see a list of possible remotes
|
||||
deploy.remote = "some-other-remote-name"
|
||||
|
||||
# branch is optional (default is "gh-pages")
|
||||
# run `git branch -a` to see a list of possible branches
|
||||
deploy.branch = "some-other-branch-name"
|
||||
|
||||
# strategy is optional (default is :force_push)
|
||||
deploy.strategy = :submodule
|
||||
end
|
||||
|
||||
# To deploy the build directory to a remote host via ftp:
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :ftp
|
||||
# host, user, passwword and path *must* be set
|
||||
deploy.host = "ftp.example.com"
|
||||
deploy.path = "/srv/www/site"
|
||||
deploy.user = "tvaughan"
|
||||
deploy.password = "secret"
|
||||
end
|
||||
|
||||
# To deploy the build directory to a remote host via sftp:
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :sftp
|
||||
# host, user, passwword and path *must* be set
|
||||
deploy.host = "sftp.example.com"
|
||||
deploy.port = 22
|
||||
deploy.path = "/srv/www/site"
|
||||
# user is optional (no default)
|
||||
deploy.user = "tvaughan"
|
||||
# password is optional (no default)
|
||||
deploy.password = "secret"
|
||||
end
|
|
@ -1,6 +1,8 @@
|
|||
require "simplecov"
|
||||
SimpleCov.start
|
||||
PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
|
||||
require "middleman-core"
|
||||
require "middleman-core/step_definitions"
|
||||
require 'middleman-core'
|
||||
require 'middleman-core/step_definitions'
|
||||
|
||||
require 'codeclimate-test-reporter'
|
||||
CodeClimate::TestReporter.start
|
||||
|
||||
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-deploy')
|
||||
|
|
6
features/test.feature
Normal file
6
features/test.feature
Normal file
|
@ -0,0 +1,6 @@
|
|||
Feature: test
|
||||
|
||||
Scenario: whilst testing
|
||||
Given the Server is running at "test-app"
|
||||
When I go to "/index.html"
|
||||
Then I should see "<h1>Test</h1>"
|
0
fixtures/test-app/config.rb
Normal file
0
fixtures/test-app/config.rb
Normal file
1
fixtures/test-app/source/index.html.erb
Normal file
1
fixtures/test-app/source/index.html.erb
Normal file
|
@ -0,0 +1 @@
|
|||
<h1>Test</h1>
|
|
@ -1,8 +1,8 @@
|
|||
require "middleman-core"
|
||||
require 'middleman-core'
|
||||
|
||||
require "middleman-deploy/commands"
|
||||
require 'middleman-deploy/commands'
|
||||
|
||||
::Middleman::Extensions.register(:deploy) do
|
||||
require "middleman-deploy/extension"
|
||||
require 'middleman-deploy/extension'
|
||||
::Middleman::Deploy
|
||||
end
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
require "middleman-core/cli"
|
||||
require 'middleman-core/cli'
|
||||
|
||||
require "middleman-deploy/extension"
|
||||
require "middleman-deploy/methods"
|
||||
require "middleman-deploy/strategies"
|
||||
require "middleman-deploy/pkg-info"
|
||||
require 'middleman-deploy/pkg-info'
|
||||
require 'middleman-deploy/extension'
|
||||
require 'middleman-deploy/methods'
|
||||
require 'middleman-deploy/strategies'
|
||||
|
||||
module Middleman
|
||||
module Cli
|
||||
|
||||
# This class provides a "deploy" command for the middleman CLI.
|
||||
class Deploy < Thor
|
||||
include Thor::Actions
|
||||
|
@ -21,11 +20,11 @@ module Middleman
|
|||
true
|
||||
end
|
||||
|
||||
desc "deploy [options]", Middleman::Deploy::TAGLINE
|
||||
method_option "build_before",
|
||||
:type => :boolean,
|
||||
:aliases => "-b",
|
||||
:desc => "Run `middleman build` before the deploy step"
|
||||
desc 'deploy [options]', Middleman::Deploy::TAGLINE
|
||||
method_option 'build_before',
|
||||
type: :boolean,
|
||||
aliases: '-b',
|
||||
desc: 'Run `middleman build` before the deploy step'
|
||||
def deploy
|
||||
build_before(options)
|
||||
process
|
||||
|
@ -33,7 +32,7 @@ module Middleman
|
|||
|
||||
protected
|
||||
|
||||
def build_before(options={})
|
||||
def build_before(options = {})
|
||||
build_enabled = options.fetch('build_before', self.deploy_options.build_before)
|
||||
|
||||
if build_enabled
|
||||
|
@ -43,10 +42,7 @@ module Middleman
|
|||
end
|
||||
|
||||
def print_usage_and_die(message)
|
||||
usage_path = File.join(File.dirname(__FILE__), '..', '..', 'USAGE')
|
||||
usage_message = File.read(usage_path)
|
||||
|
||||
raise Error, "ERROR: #{message}\n#{usage_message}"
|
||||
raise Error, "ERROR: #{message}\n#{Middleman::Deploy::README}"
|
||||
end
|
||||
|
||||
def process
|
||||
|
@ -65,11 +61,11 @@ module Middleman
|
|||
begin
|
||||
options = ::Middleman::Application.server.inst.options
|
||||
rescue NoMethodError
|
||||
print_usage_and_die "You need to activate the deploy extension in config.rb."
|
||||
print_usage_and_die 'You need to activate the deploy extension in config.rb.'
|
||||
end
|
||||
|
||||
unless options.method
|
||||
print_usage_and_die "The deploy extension requires you to set a method."
|
||||
print_usage_and_die 'The deploy extension requires you to set a method.'
|
||||
end
|
||||
|
||||
case options.method
|
||||
|
@ -79,7 +75,7 @@ module Middleman
|
|||
end
|
||||
when :ftp
|
||||
unless options.host && options.user && options.password && options.path
|
||||
print_usage_and_die "The ftp deploy method requires host, path, user, and password to be set."
|
||||
print_usage_and_die 'The ftp deploy method requires host, path, user, and password to be set.'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -88,6 +84,6 @@ module Middleman
|
|||
end
|
||||
|
||||
# Alias "d" to "deploy"
|
||||
Base.map({ "d" => "deploy" })
|
||||
Base.map('d' => 'deploy')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
# Require core library
|
||||
require "middleman-core"
|
||||
require 'middleman-core'
|
||||
|
||||
# Extension namespace
|
||||
module Middleman
|
||||
module Deploy
|
||||
|
||||
class Options < Struct.new(:whatisthis, :method, :host, :port, :user, :password, :path, :clean, :remote, :branch, :strategy, :build_before, :flags, :commit_message); end
|
||||
class Options < Struct.new(:method, :host, :port, :user, :password, :path, :clean, :remote, :branch, :strategy, :build_before, :flags, :commit_message); end
|
||||
|
||||
class << self
|
||||
|
||||
def options
|
||||
@@options
|
||||
end
|
||||
|
||||
def registered(app, options_hash={}, &block)
|
||||
def registered(app, options_hash = {}, &block)
|
||||
options = Options.new(options_hash)
|
||||
yield options if block_given?
|
||||
|
||||
|
@ -22,9 +20,9 @@ module Middleman
|
|||
options.clean ||= false
|
||||
|
||||
# Default options for the git method.
|
||||
options.remote ||= "origin"
|
||||
options.branch ||= "gh-pages"
|
||||
options.strategy ||= :force_push
|
||||
options.remote ||= 'origin'
|
||||
options.branch ||= 'gh-pages'
|
||||
options.strategy ||= :force_push
|
||||
options.commit_message ||= nil
|
||||
|
||||
options.build_before ||= false
|
||||
|
@ -34,8 +32,7 @@ module Middleman
|
|||
app.send :include, Helpers
|
||||
end
|
||||
|
||||
alias :included :registered
|
||||
|
||||
alias_method :included, :registered
|
||||
end
|
||||
|
||||
module Helpers
|
||||
|
@ -43,6 +40,5 @@ module Middleman
|
|||
::Middleman::Deploy.options
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ module Middleman
|
|||
class Base
|
||||
attr_reader :options, :server_instance
|
||||
|
||||
def initialize(server_instance, options={})
|
||||
def initialize(server_instance, options = {})
|
||||
@options = options
|
||||
@server_instance = server_instance
|
||||
end
|
||||
|
@ -12,7 +12,6 @@ module Middleman
|
|||
def process
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,10 +5,9 @@ module Middleman
|
|||
module Deploy
|
||||
module Methods
|
||||
class Ftp < Base
|
||||
|
||||
attr_reader :host, :port, :pass, :path, :user
|
||||
|
||||
def initialize(server_instance, options={})
|
||||
def initialize(server_instance, options = {})
|
||||
super(server_instance, options)
|
||||
|
||||
@host = self.options.host
|
||||
|
@ -27,7 +26,7 @@ module Middleman
|
|||
filtered_files.each do |filename|
|
||||
if File.directory?(filename)
|
||||
upload_directory(ftp, filename)
|
||||
else
|
||||
else
|
||||
upload_binary(ftp, filename)
|
||||
end
|
||||
end
|
||||
|
@ -36,7 +35,7 @@ module Middleman
|
|||
ftp.close
|
||||
end
|
||||
|
||||
protected
|
||||
protected
|
||||
|
||||
def filtered_files
|
||||
files = Dir.glob('**/*', File::FNM_DOTMATCH)
|
||||
|
@ -46,7 +45,7 @@ module Middleman
|
|||
|
||||
def handle_exception(exception, ftp, filename)
|
||||
reply = exception.message
|
||||
err_code = reply[0,3].to_i
|
||||
err_code = reply[0, 3].to_i
|
||||
|
||||
if err_code == 550
|
||||
if File.binary?(filename)
|
||||
|
@ -83,8 +82,6 @@ module Middleman
|
|||
rescue
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,6 @@ module Middleman
|
|||
module Deploy
|
||||
module Methods
|
||||
class Git < Base
|
||||
|
||||
def process
|
||||
puts "## Deploying via git to remote=\"#{self.options.remote}\" and branch=\"#{self.options.branch}\""
|
||||
|
||||
|
@ -12,7 +11,6 @@ module Middleman
|
|||
|
||||
strategy_instance.process
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,10 +2,9 @@ module Middleman
|
|||
module Deploy
|
||||
module Methods
|
||||
class Rsync < Base
|
||||
|
||||
attr_reader :clean, :flags, :host, :path, :port, :user
|
||||
|
||||
def initialize(server_instance, options={})
|
||||
def initialize(server_instance, options = {})
|
||||
super(server_instance, options)
|
||||
|
||||
@clean = self.options.clean
|
||||
|
@ -25,13 +24,12 @@ module Middleman
|
|||
command = "rsync #{flags} '-e ssh -p #{self.port}' #{self.server_instance.build_dir}/ #{dest_url}"
|
||||
|
||||
if self.clean
|
||||
command += " --delete"
|
||||
command += ' --delete'
|
||||
end
|
||||
|
||||
puts "## Deploying via rsync to #{dest_url} port=#{self.port}"
|
||||
exec command
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,12 +5,11 @@ module Middleman
|
|||
module Deploy
|
||||
module Methods
|
||||
class Sftp < Ftp
|
||||
|
||||
def process
|
||||
puts "## Deploying via sftp to #{self.user}@#{self.host}:#{path}"
|
||||
|
||||
# `nil` is a valid value for user and/or pass.
|
||||
Net::SFTP.start(self.host, self.user, :password => self.pass, :port => self.port) do |sftp|
|
||||
Net::SFTP.start(self.host, self.user, password: self.pass, port: self.port) do |sftp|
|
||||
sftp.mkdir(self.path)
|
||||
|
||||
Dir.chdir(self.server_instance.build_dir) do
|
||||
|
@ -25,11 +24,11 @@ module Middleman
|
|||
end
|
||||
end
|
||||
|
||||
protected
|
||||
protected
|
||||
|
||||
def handle_exception(exception,filename, file_path)
|
||||
reply = exception.message
|
||||
err_code = reply[0,3].to_i
|
||||
err_code = reply[0, 3].to_i
|
||||
|
||||
if err_code == 550
|
||||
sftp.upload(filename, file_path)
|
||||
|
@ -57,9 +56,7 @@ module Middleman
|
|||
|
||||
puts "Copied #{filename}"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,64 @@
|
|||
module Middleman
|
||||
module Deploy
|
||||
PACKAGE = "middleman-deploy"
|
||||
VERSION = "0.2.4"
|
||||
TAGLINE = "Deploy a middleman built site over rsync, ftp, sftp, or git (e.g. gh-pages on github)."
|
||||
end
|
||||
PACKAGE = 'middleman-deploy'
|
||||
VERSION = '0.2.5'
|
||||
TAGLINE = 'Deploy a middleman built site over rsync, ftp, sftp, or git (e.g. gh-pages on github).'
|
||||
README = %Q{
|
||||
You should follow one of the four examples below to setup the deploy
|
||||
extension in config.rb.
|
||||
|
||||
# To deploy the build directory to a remote host via rsync:
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :rsync
|
||||
# host and path *must* be set
|
||||
deploy.host = "www.example.com"
|
||||
deploy.path = "/srv/www/site"
|
||||
# user is optional (no default)
|
||||
deploy.user = "tvaughan"
|
||||
# port is optional (default is 22)
|
||||
deploy.port = 5309
|
||||
# clean is optional (default is false)
|
||||
deploy.clean = true
|
||||
# flags is optional (default is -avze)
|
||||
deploy.flags = "-rltgoDvzO --no-p --del -e"
|
||||
end
|
||||
|
||||
# To deploy to a remote branch via git (e.g. gh-pages on github):
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :git
|
||||
# remote is optional (default is "origin")
|
||||
# run `git remote -v` to see a list of possible remotes
|
||||
deploy.remote = "some-other-remote-name"
|
||||
|
||||
# branch is optional (default is "gh-pages")
|
||||
# run `git branch -a` to see a list of possible branches
|
||||
deploy.branch = "some-other-branch-name"
|
||||
|
||||
# strategy is optional (default is :force_push)
|
||||
deploy.strategy = :submodule
|
||||
end
|
||||
|
||||
# To deploy the build directory to a remote host via ftp:
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :ftp
|
||||
# host, user, passwword and path *must* be set
|
||||
deploy.host = "ftp.example.com"
|
||||
deploy.path = "/srv/www/site"
|
||||
deploy.user = "tvaughan"
|
||||
deploy.password = "secret"
|
||||
end
|
||||
|
||||
# To deploy the build directory to a remote host via sftp:
|
||||
activate :deploy do |deploy|
|
||||
deploy.method = :sftp
|
||||
# host, user, passwword and path *must* be set
|
||||
deploy.host = "sftp.example.com"
|
||||
deploy.port = 22
|
||||
deploy.path = "/srv/www/site"
|
||||
# user is optional (no default)
|
||||
deploy.user = "tvaughan"
|
||||
# password is optional (no default)
|
||||
deploy.password = "secret"
|
||||
end}
|
||||
end
|
||||
end
|
|
@ -16,7 +16,7 @@ module Middleman
|
|||
raise NotImplementedError
|
||||
end
|
||||
|
||||
protected
|
||||
protected
|
||||
|
||||
def add_signature_to_commit_message(base_message)
|
||||
signature = "#{Middleman::Deploy::PACKAGE} #{Middleman::Deploy::VERSION}"
|
||||
|
@ -34,14 +34,13 @@ module Middleman
|
|||
end
|
||||
end
|
||||
|
||||
def commit_branch(options='')
|
||||
def commit_branch(options = '')
|
||||
message = self.commit_message ? self.commit_message : add_signature_to_commit_message('Automated commit')
|
||||
|
||||
`git add -A`
|
||||
`git commit --allow-empty -am "#{message}"`
|
||||
`git push #{options} origin #{self.branch}`
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,6 @@ module Middleman
|
|||
module Strategies
|
||||
module Git
|
||||
class ForcePush < Base
|
||||
|
||||
def process
|
||||
Dir.chdir(self.build_dir) do
|
||||
add_remote_url
|
||||
|
@ -12,12 +11,12 @@ module Middleman
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def add_remote_url
|
||||
url = get_remote_url
|
||||
|
||||
unless File.exists?('.git')
|
||||
unless File.exist?('.git')
|
||||
`git init`
|
||||
`git remote add origin #{url}`
|
||||
else
|
||||
|
@ -46,7 +45,6 @@ module Middleman
|
|||
|
||||
url
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,6 @@ module Middleman
|
|||
module Strategies
|
||||
module Git
|
||||
class Submodule < Base
|
||||
|
||||
def process
|
||||
Dir.chdir(self.build_dir) do
|
||||
checkout_branch
|
||||
|
@ -14,7 +13,7 @@ module Middleman
|
|||
commit_submodule
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def commit_submodule
|
||||
current_branch = `git rev-parse --abbrev-ref HEAD`
|
||||
|
@ -36,7 +35,6 @@ module Middleman
|
|||
exit
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1 +1 @@
|
|||
require "middleman-deploy"
|
||||
require 'middleman-deploy'
|
||||
|
|
|
@ -1,27 +1,32 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
$:.push File.expand_path("../lib", __FILE__)
|
||||
require "middleman-deploy/pkg-info"
|
||||
# coding: utf-8
|
||||
lib = File.expand_path('../lib', __FILE__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
require 'middleman-deploy/pkg-info'
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = Middleman::Deploy::PACKAGE
|
||||
s.version = Middleman::Deploy::VERSION
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.authors = ["Tom Vaughan"]
|
||||
s.email = ["thomas.david.vaughan@gmail.com"]
|
||||
s.homepage = "http://github.com/tvaughan/middleman-deploy"
|
||||
s.summary = Middleman::Deploy::TAGLINE
|
||||
s.description = Middleman::Deploy::TAGLINE
|
||||
s.license = "MIT"
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = Middleman::Deploy::PACKAGE
|
||||
spec.version = Middleman::Deploy::VERSION
|
||||
spec.authors = ['Tom Vaughan', 'Karl Freeman']
|
||||
spec.email = ['thomas.david.vaughan@gmail.com', 'karlfreeman@gmail.com']
|
||||
spec.summary = Middleman::Deploy::TAGLINE
|
||||
spec.description = Middleman::Deploy::TAGLINE
|
||||
spec.homepage = 'https://github.com/karlfreeman/middleman-deploy'
|
||||
spec.license = 'MIT'
|
||||
|
||||
s.files = `git ls-files`.split("\n")
|
||||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
||||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
||||
s.require_paths = ["lib"]
|
||||
spec.files = `git ls-files -z`.split("\x0")
|
||||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
||||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
||||
spec.require_paths = ['lib']
|
||||
spec.required_ruby_version = '>= 1.9.3'
|
||||
|
||||
# The version of middleman-core your extension depends on
|
||||
s.add_runtime_dependency("middleman-core", [">= 3.0.0"])
|
||||
spec.add_dependency 'middleman-core', '>= 3.2'
|
||||
spec.add_dependency 'ptools'
|
||||
spec.add_dependency 'net-sftp'
|
||||
|
||||
# Additional dependencies
|
||||
s.add_runtime_dependency("ptools")
|
||||
s.add_runtime_dependency("net-sftp")
|
||||
spec.add_development_dependency 'bundler', '~> 1.5'
|
||||
spec.add_development_dependency 'rake', '~> 10.0'
|
||||
spec.add_development_dependency 'kramdown', '>= 0.14'
|
||||
spec.add_development_dependency 'rubocop', '~> 0.19'
|
||||
spec.add_development_dependency 'pry'
|
||||
spec.add_development_dependency 'yard'
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue