bookbindery 1.0.3 → 2.0.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 +4 -4
- data/{bin → install_bin}/bookbinder +0 -0
- data/lib/bookbinder.rb +2 -9
- data/lib/bookbinder/archive.rb +1 -1
- data/lib/bookbinder/archive_menu_configuration.rb +34 -0
- data/lib/bookbinder/book.rb +17 -17
- data/lib/bookbinder/cli.rb +25 -36
- data/lib/bookbinder/code_example.rb +5 -38
- data/lib/bookbinder/code_example_reader.rb +40 -0
- data/lib/bookbinder/colorizer.rb +14 -0
- data/lib/bookbinder/command_runner.rb +9 -16
- data/lib/bookbinder/command_validator.rb +14 -7
- data/lib/bookbinder/commands/bind.rb +321 -0
- data/lib/bookbinder/commands/build_and_push_tarball.rb +7 -6
- data/lib/bookbinder/commands/chain.rb +11 -0
- data/lib/bookbinder/commands/generate_pdf.rb +4 -3
- data/lib/bookbinder/commands/help.rb +49 -10
- data/lib/bookbinder/commands/naming.rb +9 -1
- data/lib/bookbinder/commands/push_local_to_staging.rb +4 -3
- data/lib/bookbinder/commands/push_to_prod.rb +36 -4
- data/lib/bookbinder/commands/run_publish_ci.rb +21 -24
- data/lib/bookbinder/commands/tag.rb +3 -3
- data/lib/bookbinder/commands/update_local_doc_repos.rb +5 -4
- data/lib/bookbinder/commands/version.rb +11 -8
- data/lib/bookbinder/configuration.rb +8 -3
- data/lib/bookbinder/configuration_fetcher.rb +7 -25
- data/lib/bookbinder/configuration_validator.rb +21 -0
- data/lib/bookbinder/distributor.rb +1 -1
- data/lib/bookbinder/dita_html_to_middleman_formatter.rb +37 -0
- data/lib/bookbinder/dita_section.rb +7 -0
- data/lib/bookbinder/dita_section_gatherer.rb +28 -0
- data/lib/bookbinder/git_accessor.rb +17 -0
- data/lib/bookbinder/git_client.rb +10 -7
- data/lib/bookbinder/git_hub_repository.rb +46 -41
- data/lib/bookbinder/local_dita_preprocessor.rb +27 -0
- data/lib/bookbinder/local_dita_to_html_converter.rb +49 -0
- data/lib/bookbinder/local_file_system_accessor.rb +68 -0
- data/lib/bookbinder/middleman_runner.rb +30 -17
- data/lib/bookbinder/publisher.rb +16 -80
- data/lib/bookbinder/remote_yaml_credential_provider.rb +2 -3
- data/lib/bookbinder/repositories/command_repository.rb +156 -0
- data/lib/bookbinder/repositories/section_repository.rb +31 -0
- data/lib/bookbinder/section.rb +5 -67
- data/lib/bookbinder/shell_out.rb +1 -0
- data/lib/bookbinder/sheller.rb +19 -0
- data/lib/bookbinder/sieve.rb +6 -1
- data/lib/bookbinder/terminal.rb +10 -0
- data/lib/bookbinder/user_message.rb +6 -0
- data/lib/bookbinder/user_message_presenter.rb +21 -0
- data/lib/bookbinder/yaml_loader.rb +18 -7
- data/master_middleman/archive_drop_down_menu.rb +46 -0
- data/master_middleman/bookbinder_helpers.rb +47 -40
- metadata +33 -87
- data/lib/bookbinder/commands/publish.rb +0 -138
- data/lib/bookbinder/usage_messenger.rb +0 -33
@@ -1,138 +0,0 @@
|
|
1
|
-
require_relative '../book'
|
2
|
-
require_relative '../cli_error'
|
3
|
-
require_relative '../configuration'
|
4
|
-
require_relative '../directory_helpers'
|
5
|
-
require_relative '../middleman_runner'
|
6
|
-
require_relative '../publisher'
|
7
|
-
require_relative '../spider'
|
8
|
-
require_relative 'bookbinder_command'
|
9
|
-
require_relative 'naming'
|
10
|
-
|
11
|
-
module Bookbinder
|
12
|
-
module Commands
|
13
|
-
class Publish < BookbinderCommand
|
14
|
-
VersionUnsupportedError = Class.new(StandardError)
|
15
|
-
|
16
|
-
include Bookbinder::DirectoryHelperMethods
|
17
|
-
extend Commands::Naming
|
18
|
-
|
19
|
-
def self.usage
|
20
|
-
"publish <local|github> [--verbose] \t Bind the sections specified in config.yml from <local> or <github> into the final_app directory"
|
21
|
-
end
|
22
|
-
|
23
|
-
def run(cli_arguments, git_accessor=Git)
|
24
|
-
raise CliError::InvalidArguments unless arguments_are_valid?(cli_arguments)
|
25
|
-
@git_accessor = git_accessor
|
26
|
-
|
27
|
-
final_app_dir = File.absolute_path('final_app')
|
28
|
-
bind_book(cli_arguments, final_app_dir)
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def bind_book(cli_arguments, final_app_dir)
|
34
|
-
generate_site_etc(cli_arguments, final_app_dir)
|
35
|
-
end
|
36
|
-
|
37
|
-
def generate_site_etc(cli_args, final_app_dir, target_tag=nil)
|
38
|
-
# TODO: general solution to turn all string keys to symbols
|
39
|
-
verbosity = cli_args.include?('--verbose')
|
40
|
-
location = cli_args[0]
|
41
|
-
|
42
|
-
cli_options = { verbose: verbosity, target_tag: target_tag }
|
43
|
-
output_paths = output_directory_paths(location, final_app_dir)
|
44
|
-
publish_config = publish_config(location)
|
45
|
-
spider = Spider.new(@logger, app_dir: final_app_dir)
|
46
|
-
static_site_generator = MiddlemanRunner.new(@logger)
|
47
|
-
|
48
|
-
success = Publisher.new(@logger, spider, static_site_generator).publish(cli_options, output_paths, publish_config, @git_accessor)
|
49
|
-
success ? 0 : 1
|
50
|
-
end
|
51
|
-
|
52
|
-
def output_directory_paths(location, final_app_dir)
|
53
|
-
local_repo_dir = (location == 'local') ? File.absolute_path('..') : nil
|
54
|
-
|
55
|
-
{
|
56
|
-
final_app_dir: final_app_dir,
|
57
|
-
local_repo_dir: local_repo_dir,
|
58
|
-
output_dir: File.absolute_path(output_dir_name),
|
59
|
-
master_middleman_dir: layout_repo_path(local_repo_dir)
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
def publish_config(location)
|
64
|
-
arguments = {
|
65
|
-
sections: config.sections,
|
66
|
-
book_repo: config.book_repo,
|
67
|
-
host_for_sitemap: config.public_host,
|
68
|
-
archive_menu: config.archive_menu
|
69
|
-
}
|
70
|
-
|
71
|
-
optional_arguments = {}
|
72
|
-
optional_arguments.merge!(template_variables: config.template_variables) if config.respond_to?(:template_variables)
|
73
|
-
if publishing_to_github? location
|
74
|
-
config.versions.each { |version| arguments[:sections].concat sections_from version, @git_accessor }
|
75
|
-
optional_arguments.merge!(versions: config.versions)
|
76
|
-
end
|
77
|
-
|
78
|
-
arguments.merge! optional_arguments
|
79
|
-
end
|
80
|
-
|
81
|
-
def sections_from(version, git_accessor)
|
82
|
-
config_file = File.join book_checkout(version, git_accessor), 'config.yml'
|
83
|
-
attrs = YAML.load(File.read(config_file))['sections']
|
84
|
-
raise VersionUnsupportedError.new(version) if attrs.nil?
|
85
|
-
|
86
|
-
attrs.map do |section_hash|
|
87
|
-
section_hash['repository']['ref'] = version
|
88
|
-
section_hash['directory'] = File.join(version, section_hash['directory'])
|
89
|
-
section_hash
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def book_checkout(ref, git_accessor=Git)
|
94
|
-
temp_workspace = Dir.mktmpdir('book_checkout')
|
95
|
-
book = Book.from_remote(logger: @logger,
|
96
|
-
full_name: config.book_repo,
|
97
|
-
destination_dir: temp_workspace,
|
98
|
-
ref: ref,
|
99
|
-
git_accessor: git_accessor,
|
100
|
-
)
|
101
|
-
|
102
|
-
File.join temp_workspace, book.directory
|
103
|
-
end
|
104
|
-
|
105
|
-
def layout_repo_path(local_repo_dir)
|
106
|
-
if config.has_option?('layout_repo')
|
107
|
-
if local_repo_dir
|
108
|
-
File.join(local_repo_dir, config.layout_repo.split('/').last)
|
109
|
-
else
|
110
|
-
section = {'repository' => {'name' => config.layout_repo}}
|
111
|
-
destination_dir = Dir.mktmpdir
|
112
|
-
repository = GitHubRepository.build_from_remote(@logger, section, destination_dir, 'master', @git_accessor)
|
113
|
-
if repository
|
114
|
-
File.join(destination_dir, repository.directory)
|
115
|
-
else
|
116
|
-
raise 'failed to fetch repository'
|
117
|
-
end
|
118
|
-
end
|
119
|
-
else
|
120
|
-
File.absolute_path('master_middleman')
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def arguments_are_valid?(arguments)
|
125
|
-
return false unless arguments.any?
|
126
|
-
verbose = arguments[1] && arguments[1..-1].include?('--verbose')
|
127
|
-
tag_provided = arguments[1] && (arguments[1..-1] - ['--verbose']).any?
|
128
|
-
nothing_special = arguments[1..-1].empty?
|
129
|
-
|
130
|
-
%w(local github).include?(arguments[0]) && (tag_provided || verbose || nothing_special)
|
131
|
-
end
|
132
|
-
|
133
|
-
def publishing_to_github?(publish_location)
|
134
|
-
config.has_option?('versions') && publish_location != 'local'
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Bookbinder
|
2
|
-
class UsageMessenger
|
3
|
-
|
4
|
-
def construct_for commands, flags
|
5
|
-
log_usage_header + "\n" + flag_usage_messages(flags) + command_usage_messages(commands)
|
6
|
-
end
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def flag_usage_messages(flags)
|
11
|
-
flag_usage_messages = ""
|
12
|
-
flags.each { |f| flag_usage_messages += " \t#{f.usage}\n" }
|
13
|
-
flag_usage_messages
|
14
|
-
end
|
15
|
-
|
16
|
-
def command_usage_messages(commands)
|
17
|
-
flag_command_messages = ""
|
18
|
-
commands.each do |command_class|
|
19
|
-
flag_command_messages += " \t#{command_class.usage}\n"
|
20
|
-
end
|
21
|
-
flag_command_messages
|
22
|
-
end
|
23
|
-
|
24
|
-
def log_usage_header
|
25
|
-
<<TEXT
|
26
|
-
|
27
|
-
\e[1;39;49mDocumentation\e[0m: https://github.com/pivotal-cf/docs-bookbinder
|
28
|
-
|
29
|
-
\e[1;39;49mUsage\e[0m: bookbinder <command|flag> [args]
|
30
|
-
TEXT
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|