middleman-packager 0.1.0
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 +7 -0
- data/.gitignore +8 -0
- data/Gemfile +23 -0
- data/LICENSE +21 -0
- data/README.md +98 -0
- data/Rakefile +14 -0
- data/features/support/env.rb +6 -0
- data/lib/middleman-packager.rb +8 -0
- data/lib/middleman-packager/commands.rb +100 -0
- data/lib/middleman-packager/extension.rb +48 -0
- data/lib/middleman-packager/pkg-info.rb +7 -0
- data/lib/middleman_extension.rb +1 -0
- data/middleman-packager.gemspec +23 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9a52d8287fb8999ac8b6c736562f70dc78e59cd2
|
4
|
+
data.tar.gz: c39183e5fa18da3e80173c879ed82bd33d37e038
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1cede87adfb94840fec678b7b6e35911eada116ee6efdbc4af22499cae6a703e449f3dd26daf2268ba058bea31424e437a5aa4c84185b6ab45b93c963bc0245a
|
7
|
+
data.tar.gz: 7caf9a4d65c65a4bb25ee15984021f033a3300340307cad298f4d441b785510cc50e1f94508af3bdae68bb1446fe07824524017af0fd2efeec358cf9bd8c8510
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem "middleman-core", ">= 3.0.0"
|
4
|
+
gem "multi_json" #, "~>1.8.2"
|
5
|
+
|
6
|
+
# Specify your gem's dependencies in middleman-packager.gemspec
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
|
10
|
+
group :development do
|
11
|
+
gem "rake"
|
12
|
+
gem "rdoc"
|
13
|
+
gem "yard"
|
14
|
+
end
|
15
|
+
|
16
|
+
group :test do
|
17
|
+
gem "compass"
|
18
|
+
gem "cucumber"
|
19
|
+
gem "fivemat"
|
20
|
+
gem "aruba"
|
21
|
+
gem "rspec"
|
22
|
+
gem "simplecov"
|
23
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Spencer Rhodes <spencer at spencer dash rhodes dot com>
|
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,98 @@
|
|
1
|
+
Middleman Packager
|
2
|
+
------------------
|
3
|
+
|
4
|
+
This is a [Middleman](http://www.middlemanapp.com) extension to easily package up your build into a tgz, zip, or other file archiving mechanism.
|
5
|
+
|
6
|
+
This extension is inspired by the excellent [Middleman Deploy](https://github.com/tvaughan/middleman-deploy) extension.
|
7
|
+
|
8
|
+
## Requirements
|
9
|
+
[Middleman](http://www.middlemanapp.com) 3.0.0+
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this to your Middleman project's Gemfile
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem "middleman-packager"
|
17
|
+
```
|
18
|
+
and run
|
19
|
+
|
20
|
+
```bash
|
21
|
+
$ bundle install
|
22
|
+
```
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
Activate the extension in your `config.rb` file:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
activate :packager
|
29
|
+
```
|
30
|
+
|
31
|
+
```bash
|
32
|
+
$ middleman build [--clean]
|
33
|
+
$ middleman package [-b]
|
34
|
+
```
|
35
|
+
|
36
|
+
_-b_ : pre-build before packaging
|
37
|
+
|
38
|
+
_Note: `pack`, `archive`, and `zip` are aliases for `package`._
|
39
|
+
### Config examples
|
40
|
+
###### Block config
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
\# Use zip instead of tar+gzip
|
44
|
+
activate :packager do |pack|
|
45
|
+
pack.package_mask = "build-{ts:%Y-%m-%d}.tgz"
|
46
|
+
pack.package_cmd_mask = "zip -r {to} {from}"
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
###### Inline config
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
\# Custom filename mask
|
54
|
+
activate :packager,
|
55
|
+
:package_mask => "../packages/my_project_{ts}.tgz"</code></pre>
|
56
|
+
```
|
57
|
+
|
58
|
+
## Options
|
59
|
+
Default options:
|
60
|
+
|
61
|
+
###### `:package_source` _(default: [middleman build directory])_
|
62
|
+
|
63
|
+
The source file/folder of your package.
|
64
|
+
|
65
|
+
###### `:package_mask` _(default: "build-{ts}.tgz")_
|
66
|
+
|
67
|
+
A filename mask to use as the target archive file. Accepts relative or absolute file paths, though relative is recommended!
|
68
|
+
|
69
|
+
Use `{ts[:time_format_string]}` for the generated timestamp. Optionally, you can pass a standard [Ruby Time formatting string](http://www.ruby-doc.org/core-2.0.0/Time.html#method-i-strftime) to control the timestamp output, or leave off the `:stuff` for a general timestamp.
|
70
|
+
|
71
|
+
Examples:
|
72
|
+
```ruby
|
73
|
+
"build-{ts}.tgz" # => "build-1384121876.tgz"
|
74
|
+
"build-{ts:%Y-%m-%d}.tgz" # => "build-2013-11-10.tgz"
|
75
|
+
```
|
76
|
+
|
77
|
+
###### `:package_cmd_mask` _(default: "tar -zcf {to} {from}")_
|
78
|
+
|
79
|
+
The command and file sequence mask to use. This mask allows you to easily change your archiving tool if you don't want to use tar. _{to}_ is replaced with the compiled `:package_mask` value, and _{from}_ is replaced with the `:package_source` value. Just make sure you change the `:package_mask` option accordingly!
|
80
|
+
|
81
|
+
<!--
|
82
|
+
###### `:auto_package` _(default: false)_
|
83
|
+
|
84
|
+
Should we auto-package after running a build?
|
85
|
+
_Note: This is not yet working_
|
86
|
+
|
87
|
+
###### `:pre_build` _(default: false)_
|
88
|
+
|
89
|
+
Run a build before creating a package?
|
90
|
+
_Note: This is not yet working, though passing the `-b` parameter to the package command does work._
|
91
|
+
-->
|
92
|
+
|
93
|
+
## ToDo
|
94
|
+
|
95
|
+
- Get `:pre_build` working
|
96
|
+
- Get `:auto_package` working
|
97
|
+
- Run this in `:build` mode rather than `:development` mode (mm-server)
|
98
|
+
- Other `:development` extensions are running unnecessarily.
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
7
|
+
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'rake/clean'
|
11
|
+
|
12
|
+
task :test => ["cucumber"]
|
13
|
+
|
14
|
+
task :default => :test
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require "middleman-core/cli"
|
2
|
+
|
3
|
+
require "middleman-packager/extension"
|
4
|
+
require "middleman-packager/pkg-info"
|
5
|
+
|
6
|
+
module Middleman
|
7
|
+
module Cli
|
8
|
+
|
9
|
+
# This class provides a "package" command for the middleman CLI.
|
10
|
+
class Packager < Thor
|
11
|
+
include Thor::Actions
|
12
|
+
|
13
|
+
check_unknown_options!
|
14
|
+
|
15
|
+
namespace :package
|
16
|
+
|
17
|
+
# Tell Thor to exit with a nonzero exit code on failure
|
18
|
+
def self.exit_on_failure?
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "package [options]", Middleman::Packager::TAGLINE
|
23
|
+
method_option "build_before",
|
24
|
+
:type => :boolean,
|
25
|
+
:aliases => "-b",
|
26
|
+
:desc => "Run `middleman build` before the package step"
|
27
|
+
|
28
|
+
def package
|
29
|
+
# puts "package running"
|
30
|
+
if options.has_key? "build_before"
|
31
|
+
build_before = options.build_before
|
32
|
+
else
|
33
|
+
build_before = self.options.build_before
|
34
|
+
end
|
35
|
+
if build_before
|
36
|
+
# http://forum.middlemanapp.com/t/problem-with-the-build-task-in-an-extension
|
37
|
+
bundler = File.exist?('Gemfile')
|
38
|
+
run("#{bundler ? 'bundle exec ' : ''}middleman build") || exit(1)
|
39
|
+
end
|
40
|
+
send("package_run")
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def print_usage_and_die(message)
|
46
|
+
# raise Error, "\nERROR: " + message + "\n" + <<EOF\n EOF
|
47
|
+
raise Error, "\nERROR: " + message + "\n"
|
48
|
+
end # of print_usage_and_dir
|
49
|
+
|
50
|
+
def inst
|
51
|
+
::Middleman::Application.server.inst
|
52
|
+
end
|
53
|
+
|
54
|
+
def opts
|
55
|
+
opts = nil
|
56
|
+
|
57
|
+
begin
|
58
|
+
opts = inst.pkgopts || {}
|
59
|
+
rescue NoMethodError
|
60
|
+
print_usage_and_die "You need to activate the #{:packager.inspect} extension in config.rb."
|
61
|
+
end
|
62
|
+
|
63
|
+
if (!opts[:package_source])
|
64
|
+
print_usage_and_die "The package extension requires you to set a source file or directory."
|
65
|
+
end
|
66
|
+
|
67
|
+
opts
|
68
|
+
end
|
69
|
+
|
70
|
+
def package_run
|
71
|
+
# http://www.ruby-doc.org/core-2.0.0/Time.html#method-i-strftime
|
72
|
+
opts = self.opts
|
73
|
+
time = Time.now()
|
74
|
+
timestamp = time.to_i
|
75
|
+
if opts[:package_mask].match(/{(ts|timestamp):.+}/)
|
76
|
+
format = (opts[:package_mask].match(/{(ts|timestamp):(?<format>.+)}/))[:format]
|
77
|
+
timestamp = time.strftime(format)
|
78
|
+
end
|
79
|
+
file_name = (opts[:package_mask]).gsub(/{(ts|timestamp):?.*}/i, "#{timestamp}")
|
80
|
+
command = (opts[:package_cmd_mask])
|
81
|
+
.gsub(/\{from\}/, "#{opts[:package_source]}")
|
82
|
+
.gsub(/\{to\}/, "#{file_name}")
|
83
|
+
run(command)
|
84
|
+
if ($?.success?)
|
85
|
+
# puts "== Your build package is: #{file_name}"
|
86
|
+
else
|
87
|
+
print_usage_and_die "There was a problem creating your build package. Please check your configuration."
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
Base.map({
|
94
|
+
"pack" => "package",
|
95
|
+
"zip" => "package",
|
96
|
+
"archive" => "package"
|
97
|
+
})
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Require core library
|
2
|
+
require "middleman-core"
|
3
|
+
|
4
|
+
# Extension namespace
|
5
|
+
module Middleman
|
6
|
+
module Packager
|
7
|
+
|
8
|
+
class PkgOptions < Struct.new(:package_source, :package_mask, :package_cmd_mask, :auto_package, :build_before); end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def pkgopts
|
13
|
+
@@pkgopts
|
14
|
+
end
|
15
|
+
|
16
|
+
def registered(app, options_hash={}, &block)
|
17
|
+
# puts "registered() running"
|
18
|
+
# Default options for the rsync method.
|
19
|
+
defaults = {
|
20
|
+
# :build_before => false,
|
21
|
+
# :auto_package => false,
|
22
|
+
:package_mask => "build-{ts:%Y-%m-%d}.tgz",
|
23
|
+
:package_cmd_mask => "tar -zcf {to} {from}",
|
24
|
+
:package_source => app.config[:build_dir]
|
25
|
+
}
|
26
|
+
# TODO: Refactor this with merge!
|
27
|
+
opts = defaults.merge(options_hash)
|
28
|
+
# opts = PkgOptions.new(options_hash)
|
29
|
+
# yield opts if block_given?
|
30
|
+
|
31
|
+
@@pkgopts = opts
|
32
|
+
|
33
|
+
app.send :include, Helpers
|
34
|
+
end
|
35
|
+
|
36
|
+
alias :included :registered
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
module Helpers
|
41
|
+
def pkgopts
|
42
|
+
::Middleman::Packager.pkgopts
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "middleman-packager"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "middleman-packager/pkg-info"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = Middleman::Packager::PACKAGE
|
7
|
+
s.version = Middleman::Packager::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Spencer Rhodes"]
|
10
|
+
s.email = ["spencer at spencer dash rhodes dot com"]
|
11
|
+
s.homepage = "http://github.com/oobleck/middleman-packager"
|
12
|
+
s.summary = Middleman::Packager::TAGLINE
|
13
|
+
s.description = s.summary # Middleman::Packager::TAGLINE
|
14
|
+
s.license = "MIT"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# The version of middleman-core your extension depends on
|
22
|
+
s.add_runtime_dependency("middleman-core", [">= 3.0.0"])
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-packager
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Spencer Rhodes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: middleman-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
description: Configurable post-build archiver for Middleman builds.
|
28
|
+
email:
|
29
|
+
- spencer at spencer dash rhodes dot com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- LICENSE
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- features/support/env.rb
|
40
|
+
- lib/middleman-packager.rb
|
41
|
+
- lib/middleman-packager/commands.rb
|
42
|
+
- lib/middleman-packager/extension.rb
|
43
|
+
- lib/middleman-packager/pkg-info.rb
|
44
|
+
- lib/middleman_extension.rb
|
45
|
+
- middleman-packager.gemspec
|
46
|
+
homepage: http://github.com/oobleck/middleman-packager
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
metadata: {}
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 2.0.5
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: Configurable post-build archiver for Middleman builds.
|
70
|
+
test_files:
|
71
|
+
- features/support/env.rb
|