middleman-cli 4.0.0.alpha.5 → 4.0.0.alpha.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/middleman +6 -1
- data/lib/middleman-cli.rb +9 -72
- data/lib/middleman-cli/build.rb +63 -68
- data/lib/middleman-cli/console.rb +15 -15
- data/lib/middleman-cli/extension.rb +10 -10
- data/lib/middleman-cli/init.rb +44 -34
- data/lib/middleman-cli/server.rb +44 -48
- data/lib/middleman-cli/templates/extension/lib/lib.rb +1 -1
- data/lib/middleman-core/cli.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b4d71b08b02fed014baba761ddb5021c93e3149
|
4
|
+
data.tar.gz: c5c2046bf5f453504550008aba3db227353c83c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea071324738707a762be53f986e8ecbc5d9f47bef1e9e4268010bde865dc71f4a42af782a5fc5714030399eb0be8c196d2b851df7bf4959578f2a1fab0dc31ab
|
7
|
+
data.tar.gz: 120cac0b58998fde7737ba7c5c07d6b387dd70ebcffc102cca5f3a184ca21977fc59518bdd8cb18df06aff30cf0d7455abbd4e4fd6bd0b4bf517ea9291925727
|
data/bin/middleman
CHANGED
@@ -14,5 +14,10 @@ require "middleman-cli"
|
|
14
14
|
# Change directory to the root
|
15
15
|
Dir.chdir(ENV["MM_ROOT"]) if ENV["MM_ROOT"]
|
16
16
|
|
17
|
+
# Default command is server
|
18
|
+
if ARGV[0] != 'help' && (ARGV.length < 1 || ARGV.first.include?('-'))
|
19
|
+
ARGV.unshift('server')
|
20
|
+
end
|
21
|
+
|
17
22
|
# Start the CLI
|
18
|
-
Middleman::Cli::Base.start
|
23
|
+
Middleman::Cli::Base.start(ARGV)
|
data/lib/middleman-cli.rb
CHANGED
@@ -6,81 +6,18 @@ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
|
|
6
6
|
|
7
7
|
# Require Thor since that's what the whole CLI is built around
|
8
8
|
require 'thor'
|
9
|
-
require 'thor/group'
|
10
9
|
|
11
10
|
# CLI Module
|
12
|
-
module Middleman
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
ARGV.unshift('help') if ARGV.delete('--help')
|
20
|
-
|
21
|
-
# Default command is server
|
22
|
-
if ARGV[0] != 'help' && (ARGV.length < 1 || ARGV.first.include?('-'))
|
23
|
-
ARGV.unshift('server')
|
24
|
-
end
|
25
|
-
|
26
|
-
super
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
desc 'version', 'Show version'
|
31
|
-
def version
|
32
|
-
say "Middleman #{Middleman::VERSION}"
|
33
|
-
end
|
34
|
-
|
35
|
-
desc 'help', 'Show help'
|
36
|
-
|
37
|
-
# Override the Thor help method to find help for subtasks
|
38
|
-
# @param [Symbol, String, nil] meth
|
39
|
-
# @param [Boolean] subcommand
|
40
|
-
# @return [void]
|
41
|
-
# rubocop:disable UnusedMethodArgument
|
42
|
-
def help(meth=nil, subcommand=false)
|
43
|
-
if meth && !self.respond_to?(meth)
|
44
|
-
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
45
|
-
klass.start(['-h', task].compact, shell: shell)
|
46
|
-
else
|
47
|
-
list = []
|
48
|
-
Thor::Util.thor_classes_in(Middleman::Cli).each do |thor_class|
|
49
|
-
list += thor_class.printable_tasks(false)
|
50
|
-
end
|
51
|
-
list.sort! { |a, b| a[0] <=> b[0] }
|
52
|
-
|
53
|
-
shell.say 'Tasks:'
|
54
|
-
shell.print_table(list, ident: 2, truncate: true)
|
55
|
-
shell.say %(\nSee 'middleman help <command>' for more information on specific command.)
|
56
|
-
shell.say
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# Intercept missing methods and search subtasks for them
|
61
|
-
# @param [Symbol] meth
|
62
|
-
def method_missing(meth, *args)
|
63
|
-
meth = meth.to_s
|
64
|
-
meth = self.class.map[meth] if self.class.map.key?(meth)
|
65
|
-
|
66
|
-
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
67
|
-
|
68
|
-
if klass.nil?
|
69
|
-
tasks_dir = File.join(Dir.pwd, 'tasks')
|
70
|
-
|
71
|
-
if File.exist?(tasks_dir)
|
72
|
-
Dir[File.join(tasks_dir, '**/*_task.rb')].each { |f| require f }
|
73
|
-
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
74
|
-
end
|
75
|
-
end
|
11
|
+
module Middleman::Cli
|
12
|
+
# The base task from which everything else extends
|
13
|
+
class Base < ::Thor
|
14
|
+
desc 'version', 'Show version'
|
15
|
+
def version
|
16
|
+
say "Middleman #{Middleman::VERSION}"
|
17
|
+
end
|
76
18
|
|
77
|
-
|
78
|
-
|
79
|
-
else
|
80
|
-
args.unshift(task) if task
|
81
|
-
klass.start(args, shell: shell)
|
82
|
-
end
|
83
|
-
end
|
19
|
+
def self.exit_on_failure?
|
20
|
+
true
|
84
21
|
end
|
85
22
|
end
|
86
23
|
end
|
data/lib/middleman-cli/build.rb
CHANGED
@@ -1,39 +1,36 @@
|
|
1
1
|
# CLI Module
|
2
2
|
module Middleman::Cli
|
3
3
|
# The CLI Build class
|
4
|
-
class Build < Thor
|
4
|
+
class Build < Thor::Group
|
5
5
|
include Thor::Actions
|
6
6
|
|
7
7
|
check_unknown_options!
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
type: :boolean,
|
35
|
-
default: false,
|
36
|
-
desc: 'Generate profiling report for the build'
|
9
|
+
class_option :environment,
|
10
|
+
aliases: '-e',
|
11
|
+
default: ENV['MM_ENV'] || ENV['RACK_ENV'] || 'production',
|
12
|
+
desc: 'The environment Middleman will run under'
|
13
|
+
class_option :clean,
|
14
|
+
type: :boolean,
|
15
|
+
default: true,
|
16
|
+
desc: 'Remove orphaned files from build (--no-clean to disable)'
|
17
|
+
class_option :glob,
|
18
|
+
type: :string,
|
19
|
+
aliases: '-g',
|
20
|
+
default: nil,
|
21
|
+
desc: 'Build a subset of the project'
|
22
|
+
class_option :verbose,
|
23
|
+
type: :boolean,
|
24
|
+
default: false,
|
25
|
+
desc: 'Print debug messages'
|
26
|
+
class_option :instrument,
|
27
|
+
type: :string,
|
28
|
+
default: false,
|
29
|
+
desc: 'Print instrument messages'
|
30
|
+
class_option :profile,
|
31
|
+
type: :boolean,
|
32
|
+
default: false,
|
33
|
+
desc: 'Generate profiling report for the build'
|
37
34
|
|
38
35
|
# Core build Thor command
|
39
36
|
# @return [void]
|
@@ -78,51 +75,49 @@ module Middleman::Cli
|
|
78
75
|
end
|
79
76
|
end
|
80
77
|
|
81
|
-
|
82
|
-
def self.exit_on_failure?
|
83
|
-
true
|
84
|
-
end
|
78
|
+
protected
|
85
79
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
say_status event_type, extra, :blue
|
107
|
-
end
|
80
|
+
# Handles incoming events from the builder.
|
81
|
+
# @param [Symbol] event_type The type of event.
|
82
|
+
# @param [String] contents The event contents.
|
83
|
+
# @param [String] extra The extra information.
|
84
|
+
# @return [void]
|
85
|
+
def on_event(event_type, target, extra=nil)
|
86
|
+
case event_type
|
87
|
+
when :error
|
88
|
+
say_status :error, target, :red
|
89
|
+
shell.say extra, :red if options['verbose']
|
90
|
+
when :deleted
|
91
|
+
say_status :remove, target, :green
|
92
|
+
when :created
|
93
|
+
say_status :create, target, :green
|
94
|
+
when :identical
|
95
|
+
say_status :identical, target, :blue
|
96
|
+
when :updated
|
97
|
+
say_status :updated, target, :yellow
|
98
|
+
else
|
99
|
+
say_status event_type, extra, :blue
|
108
100
|
end
|
101
|
+
end
|
109
102
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
103
|
+
# Find empty directories in the build folder and remove them.
|
104
|
+
# @return [Boolean]
|
105
|
+
def clean_directories!
|
106
|
+
all_build_files = File.join(@app.config[:build_dir], '**', '*')
|
114
107
|
|
115
|
-
|
116
|
-
|
117
|
-
|
108
|
+
empty_directories = Dir[all_build_files].select do |d|
|
109
|
+
File.directory?(d)
|
110
|
+
end
|
118
111
|
|
119
|
-
|
120
|
-
|
121
|
-
end
|
112
|
+
empty_directories.each do |d|
|
113
|
+
remove_file d, force: true if Pathname(d).children.empty?
|
122
114
|
end
|
123
115
|
end
|
124
|
-
end
|
125
116
|
|
126
|
-
|
127
|
-
|
117
|
+
# Add to CLI
|
118
|
+
Base.register(self, 'build', 'build [options]', 'Builds the static site for deployment')
|
119
|
+
|
120
|
+
# Map "b" to "build"
|
121
|
+
Base.map('b' => 'build')
|
122
|
+
end
|
128
123
|
end
|
@@ -1,25 +1,19 @@
|
|
1
1
|
# CLI Module
|
2
2
|
module Middleman::Cli
|
3
|
-
# Alias "c" to "console"
|
4
|
-
Base.map(c: 'console')
|
5
|
-
|
6
3
|
# The CLI Console class
|
7
|
-
class Console < Thor
|
4
|
+
class Console < Thor::Group
|
8
5
|
include Thor::Actions
|
9
6
|
|
10
7
|
check_unknown_options!
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
type: :boolean,
|
21
|
-
default: false,
|
22
|
-
desc: 'Print debug messages'
|
9
|
+
class_option :environment,
|
10
|
+
aliases: '-e',
|
11
|
+
default: ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development',
|
12
|
+
desc: 'The environment Middleman will run under'
|
13
|
+
class_option :verbose,
|
14
|
+
type: :boolean,
|
15
|
+
default: false,
|
16
|
+
desc: 'Print debug messages'
|
23
17
|
def console
|
24
18
|
require 'middleman-core'
|
25
19
|
require 'irb'
|
@@ -42,5 +36,11 @@ module Middleman::Cli
|
|
42
36
|
require 'irb/ext/multi-irb'
|
43
37
|
IRB.irb nil, @app
|
44
38
|
end
|
39
|
+
|
40
|
+
# Add to CLI
|
41
|
+
Base.register(self, 'console', 'console [options]', 'Start an interactive console in the context of your Middleman application')
|
42
|
+
|
43
|
+
# Map "c" to "console"
|
44
|
+
Base.map('c' => 'console')
|
45
45
|
end
|
46
46
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
# CLI Module
|
2
2
|
module Middleman::Cli
|
3
3
|
# A thor task for creating new projects
|
4
|
-
class Extension < Thor
|
4
|
+
class Extension < Thor::Group
|
5
5
|
include Thor::Actions
|
6
6
|
|
7
7
|
check_unknown_options!
|
8
8
|
|
9
|
-
namespace :extension
|
10
|
-
|
11
9
|
# Required path for the new project to be generated
|
12
10
|
argument :name, type: :string
|
13
11
|
|
@@ -17,11 +15,13 @@ module Middleman::Cli
|
|
17
15
|
File.join(File.dirname(__FILE__), 'templates')
|
18
16
|
end
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
class_option 'skip-git',
|
19
|
+
type: :boolean,
|
20
|
+
default: false,
|
21
|
+
desc: 'Skip Git ignores and keeps'
|
22
|
+
|
23
|
+
# Output a .gitignore file
|
24
|
+
class_option :git, type: :boolean, default: true
|
25
25
|
|
26
26
|
# The extension task
|
27
27
|
# @param [String] name
|
@@ -36,7 +36,7 @@ module Middleman::Cli
|
|
36
36
|
empty_directory File.join(name, 'fixtures')
|
37
37
|
end
|
38
38
|
|
39
|
-
#
|
40
|
-
|
39
|
+
# Add to CLI
|
40
|
+
Base.register(self, 'extension', 'extension [options]', 'Create a new Middleman extension')
|
41
41
|
end
|
42
42
|
end
|
data/lib/middleman-cli/init.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
# CLI Module
|
2
2
|
module Middleman::Cli
|
3
3
|
# A thor task for creating new projects
|
4
|
-
class Init < Thor
|
4
|
+
class Init < Thor::Group
|
5
5
|
include Thor::Actions
|
6
|
+
|
6
7
|
check_unknown_options!
|
7
8
|
|
8
|
-
|
9
|
+
argument :target, type: :string, default: '.'
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
desc: 'Use a project template'
|
11
|
+
class_option 'template',
|
12
|
+
aliases: '-T',
|
13
|
+
default: 'middleman/middleman-templates-default',
|
14
|
+
desc: 'Use a project template'
|
15
15
|
|
16
16
|
# Do not run bundle install
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
class_option 'skip-bundle',
|
18
|
+
type: :boolean,
|
19
|
+
aliases: '-B',
|
20
|
+
default: false,
|
21
|
+
desc: 'Skip bundle install'
|
22
22
|
|
23
23
|
# The init task
|
24
|
-
|
25
|
-
|
24
|
+
def init
|
25
|
+
require 'fileutils'
|
26
26
|
require 'tmpdir'
|
27
27
|
|
28
28
|
repo_path, repo_branch = if shortname?(options[:template])
|
@@ -37,8 +37,8 @@ module Middleman::Cli
|
|
37
37
|
data['links']['github']
|
38
38
|
data['links']['github'].split('#')
|
39
39
|
rescue ::OpenURI::HTTPError
|
40
|
-
|
41
|
-
|
40
|
+
say "Template `#{options[:template]}` not found in Middleman Directory."
|
41
|
+
say 'Did you mean to use a full `user/repo` path?'
|
42
42
|
exit
|
43
43
|
end
|
44
44
|
else
|
@@ -46,18 +46,29 @@ module Middleman::Cli
|
|
46
46
|
[repository_path(repo_name), repo_branch]
|
47
47
|
end
|
48
48
|
|
49
|
-
Dir.mktmpdir
|
50
|
-
|
49
|
+
dir = Dir.mktmpdir
|
50
|
+
|
51
|
+
begin
|
52
|
+
branch_cmd = repo_branch ? "-b #{repo_branch} " : ''
|
53
|
+
|
54
|
+
run("git clone --depth 1 #{branch_cmd}#{repo_path} #{dir}")
|
51
55
|
|
52
|
-
|
56
|
+
inside(target) do
|
57
|
+
thorfile = File.join(dir, 'Thorfile')
|
53
58
|
|
54
|
-
|
59
|
+
if File.exist?(thorfile)
|
60
|
+
::Thor::Util.load_thorfile(thorfile)
|
55
61
|
|
56
|
-
|
62
|
+
invoke 'middleman:generator'
|
63
|
+
else
|
64
|
+
source_paths << dir
|
65
|
+
directory dir, '.', exclude_pattern: /\.git\/|\.gitignore$/
|
66
|
+
end
|
57
67
|
|
58
|
-
|
59
|
-
|
60
|
-
|
68
|
+
run('bundle install') unless ENV['TEST'] || options[:'skip-bundle']
|
69
|
+
end
|
70
|
+
ensure
|
71
|
+
FileUtils.remove_entry(dir)
|
61
72
|
end
|
62
73
|
end
|
63
74
|
|
@@ -70,16 +81,15 @@ module Middleman::Cli
|
|
70
81
|
def repository_path(repo)
|
71
82
|
"git://github.com/#{repo}.git"
|
72
83
|
end
|
73
|
-
end
|
74
84
|
|
75
|
-
|
76
|
-
|
77
|
-
end
|
85
|
+
# Add to CLI
|
86
|
+
Base.register(self, 'init', 'init TARGET [options]', 'Create new project at TARGET')
|
78
87
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
88
|
+
# Map "i", "new" and "n" to "init"
|
89
|
+
Base.map(
|
90
|
+
'i' => 'init',
|
91
|
+
'new' => 'init',
|
92
|
+
'n' => 'init'
|
93
|
+
)
|
94
|
+
end
|
85
95
|
end
|
data/lib/middleman-cli/server.rb
CHANGED
@@ -1,50 +1,47 @@
|
|
1
1
|
# CLI Module
|
2
2
|
module Middleman::Cli
|
3
3
|
# Server thor task
|
4
|
-
class Server < Thor
|
4
|
+
class Server < Thor::Group
|
5
5
|
check_unknown_options!
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
aliases: '-l',
|
46
|
-
default: 0.25,
|
47
|
-
desc: 'Set file watcher latency, in seconds'
|
7
|
+
class_option :environment,
|
8
|
+
aliases: '-e',
|
9
|
+
default: ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development',
|
10
|
+
desc: 'The environment Middleman will run under'
|
11
|
+
class_option :host,
|
12
|
+
type: :string,
|
13
|
+
aliases: '-h',
|
14
|
+
default: '0.0.0.0',
|
15
|
+
desc: 'Bind to HOST address'
|
16
|
+
class_option :port,
|
17
|
+
aliases: '-p',
|
18
|
+
default: '4567',
|
19
|
+
desc: 'The port Middleman will listen on'
|
20
|
+
class_option :verbose,
|
21
|
+
type: :boolean,
|
22
|
+
default: false,
|
23
|
+
desc: 'Print debug messages'
|
24
|
+
class_option :instrument,
|
25
|
+
type: :string,
|
26
|
+
default: false,
|
27
|
+
desc: 'Print instrument messages'
|
28
|
+
class_option :disable_watcher,
|
29
|
+
type: :boolean,
|
30
|
+
default: false,
|
31
|
+
desc: 'Disable the file change and delete watcher process'
|
32
|
+
class_option :profile,
|
33
|
+
type: :boolean,
|
34
|
+
default: false,
|
35
|
+
desc: 'Generate profiling report for server startup'
|
36
|
+
class_option :force_polling,
|
37
|
+
type: :boolean,
|
38
|
+
default: false,
|
39
|
+
desc: 'Force file watcher into polling mode'
|
40
|
+
class_option :latency,
|
41
|
+
type: :numeric,
|
42
|
+
aliases: '-l',
|
43
|
+
default: 0.25,
|
44
|
+
desc: 'Set file watcher latency, in seconds'
|
48
45
|
|
49
46
|
# Start the server
|
50
47
|
def server
|
@@ -71,12 +68,11 @@ module Middleman::Cli
|
|
71
68
|
puts '== The Middleman is loading'
|
72
69
|
::Middleman::PreviewServer.start(params)
|
73
70
|
end
|
74
|
-
end
|
75
71
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
72
|
+
# Add to CLI
|
73
|
+
Base.register(self, 'server', 'server [options]', 'Start the preview server')
|
79
74
|
|
80
|
-
|
81
|
-
|
75
|
+
# Map "s" to "server"
|
76
|
+
Base.map('s' => 'server')
|
77
|
+
end
|
82
78
|
end
|
data/lib/middleman-core/cli.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# Backwards compat
|
2
|
-
require 'middleman-cli'
|
2
|
+
require 'middleman-cli'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.alpha.
|
4
|
+
version: 4.0.0.alpha.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Reynolds
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|