bookbindery 8.5.0 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/bookbinder.gemspec +1 -1
  3. data/lib/bookbinder/cli.rb +36 -55
  4. data/lib/bookbinder/commands/bind.rb +3 -19
  5. data/lib/bookbinder/commands/collection.rb +33 -73
  6. data/lib/bookbinder/commands/components/command_options.rb +3 -22
  7. data/lib/bookbinder/commands/generate.rb +0 -11
  8. data/lib/bookbinder/commands/imprint.rb +3 -10
  9. data/lib/bookbinder/commands/punch.rb +0 -11
  10. data/lib/bookbinder/commands/update_local_doc_repos.rb +1 -9
  11. data/lib/bookbinder/commands/watch.rb +1 -10
  12. data/lib/bookbinder/config/fetcher.rb +2 -18
  13. data/lib/bookbinder/preprocessing/dita_html_preprocessor.rb +3 -6
  14. data/lib/bookbinder/preprocessing/dita_pdf_preprocessor.rb +3 -5
  15. data/lib/bookbinder/terminal.rb +0 -1
  16. metadata +3 -31
  17. data/lib/bookbinder/cf_command_runner.rb +0 -123
  18. data/lib/bookbinder/command_runner.rb +0 -23
  19. data/lib/bookbinder/command_validator.rb +0 -51
  20. data/lib/bookbinder/commands/build_and_push_tarball.rb +0 -38
  21. data/lib/bookbinder/commands/chain.rb +0 -11
  22. data/lib/bookbinder/commands/help.rb +0 -70
  23. data/lib/bookbinder/commands/naming.rb +0 -29
  24. data/lib/bookbinder/commands/push_from_local.rb +0 -132
  25. data/lib/bookbinder/commands/push_to_prod.rb +0 -66
  26. data/lib/bookbinder/commands/run_publish_ci.rb +0 -37
  27. data/lib/bookbinder/commands/version.rb +0 -29
  28. data/lib/bookbinder/config/aws_credentials.rb +0 -21
  29. data/lib/bookbinder/config/cf_credentials.rb +0 -62
  30. data/lib/bookbinder/config/remote_yaml_credential_provider.rb +0 -22
  31. data/lib/bookbinder/deploy/app_fetcher.rb +0 -36
  32. data/lib/bookbinder/deploy/archive.rb +0 -102
  33. data/lib/bookbinder/deploy/artifact.rb +0 -26
  34. data/lib/bookbinder/deploy/blue_green_app.rb +0 -29
  35. data/lib/bookbinder/deploy/cf_routes.rb +0 -32
  36. data/lib/bookbinder/deploy/deployment.rb +0 -55
  37. data/lib/bookbinder/deploy/distributor.rb +0 -76
  38. data/lib/bookbinder/deploy/failure.rb +0 -15
  39. data/lib/bookbinder/deploy/pusher.rb +0 -34
  40. data/lib/bookbinder/deploy/success.rb +0 -16
  41. data/lib/bookbinder/deprecated_logger.rb +0 -33
  42. data/lib/bookbinder/errors/cli_error.rb +0 -6
  43. data/lib/bookbinder/legacy/cli.rb +0 -71
  44. data/lib/bookbinder/preprocessing/dita_preprocessor.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 339d708a52273a3e142c40918a6be2022f0fb4e9
4
- data.tar.gz: 0b8b092004e2580d7ca90e71610886018d21c303
3
+ metadata.gz: 11c7ab2f100519423aa8e8b3d7f209bb53f800ff
4
+ data.tar.gz: 8b95f5075fb79af6b8e9dbe4f21ffccdcd84e30d
5
5
  SHA512:
6
- metadata.gz: 23bb176375b82fa847e9792eb94cbb51b377a6eeefec08eae31345b9049550db0d70d6f6ec2da5a046c5b23943a55645cb3c7e66cd7edf2fe39ef5eef92a0e0e
7
- data.tar.gz: 14da519c15b02a8f18e6b2b949dbac0310792c6d86c4c2ad55fae62f35af667b1bc689b1f0cc1a8564229186f23119767390e347c8b3b1e7d4ecc15456d42566
6
+ metadata.gz: b8ce590ae60e8ac526c04ac42f62c8235dfc4ea05ff762735dc7339c694272aabab6602aac95be592ee7291ac9247ff24cfc9f362133cb61068adbac2699b9da
7
+ data.tar.gz: 0862ee6272e546779e1b1332d4b6071211611f157f3a2acff2a096abb9cdabf4d58f526077ba079ddc922a912f0ec90ca540eb59f5e9105c77477cc9d6c95124
@@ -2,7 +2,7 @@ require 'base64'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'bookbindery'
5
- s.version = '8.5.0'
5
+ s.version = '9.0.0'
6
6
  s.summary = 'Markdown to Rackup application documentation generator'
7
7
  s.description = 'A command line utility to be run in Book repositories to stitch together their constituent Markdown repos into a static-HTML-serving application'
8
8
  s.authors = ['Mike Grafton', 'Lucas Marks', 'Gavin Morgan', 'Nikhil Gajwani', 'Dan Wendorf', 'Brenda Chan', 'Matthew Boedicker', 'Andrew Bruce', 'Frank Kotsianas', 'Elena Sharma', 'Christa Hartsock', 'Michael Trestman', 'Alpha Chen', 'Sarah McAlear', 'Gregg Van Hove']
@@ -1,11 +1,16 @@
1
1
  require 'thor'
2
- require 'ansi/code'
3
2
 
4
3
  require_relative 'ingest/git_accessor'
5
- require_relative 'legacy/cli'
4
+ require_relative 'streams/colorized_stream'
5
+ require_relative 'colorizer'
6
+ require_relative 'commands/collection'
6
7
 
7
8
  module Bookbinder
8
9
  class CLI < Thor
10
+ def self.exit_on_failure?
11
+ true
12
+ end
13
+
9
14
  map '--version' => :version
10
15
  map '--help' => :help
11
16
 
@@ -22,95 +27,71 @@ module Bookbinder
22
27
 
23
28
  desc 'generate <book_name>', 'Generate a skeleton book that can be bound with "bookbinder bind"'
24
29
  def generate(book_name)
25
- run_legacy_cli('generate', book_name)
26
- end
27
-
28
- desc 'build_and_push_tarball', 'Create a tarball from the final_app directory and push to the S3 bucket specified in your credentials.yml'
29
- def build_and_push_tarball
30
- print_deploy_deprecation_message
31
- run_legacy_cli('build_and_push_tarball')
30
+ code = legacy_commands.generate(book_name)
31
+ raise Thor::Error, '' if code != 0
32
32
  end
33
33
 
34
34
  desc 'bind <local|remote> [--verbose] [--dita-flags=\"<dita-option>=<value>\"]', 'Bind the sections specified in config.yml from <local> or <remote> into the final_app directory'
35
35
  option :verbose, type: :boolean
36
36
  option 'dita-flags'
37
37
  def bind(source)
38
- args = ['bind', source]
39
- args << '--verbose' if options[:verbose]
40
- args << "--dita-flags=\\\"#{options['dita-flags']}\\\""
41
- run_legacy_cli(*args)
42
- end
43
-
44
- desc 'push_local_to <environment>', 'Push the contents of final_app to the specified environment using the credentials.yml'
45
- def push_local_to(environment)
46
- print_deploy_deprecation_message
47
- run_legacy_cli('push_local_to', environment)
48
- end
49
-
50
- desc 'push_to_prod [build_#]', 'Push latest or <build_#> from your S3 bucket to the production host specified in credentials.yml'
51
- def push_to_prod(build_num=nil)
52
- print_deploy_deprecation_message
53
- args = ['push_to_prod', build_num].compact
54
- run_legacy_cli(*args)
55
- end
56
-
57
- desc 'run_publish_ci', 'Run publish, push_local_to staging, and build_and_push_tarball for CI purposes'
58
- def run_publish_ci
59
- print_deploy_deprecation_message
60
- run_legacy_cli('run_publish_ci')
38
+ code = legacy_commands.bind(source, options[:verbose], options['dita-flags'])
39
+ raise Thor::Error, '' if code != 0
61
40
  end
62
41
 
63
42
  desc 'punch <git tag>', 'Apply the specified <git tag> to your book, sections, and layout repo'
64
43
  def punch(git_tag)
65
- run_legacy_cli('punch', git_tag)
44
+ code = legacy_commands.punch(git_tag)
45
+ raise Thor::Error, '' if code != 0
66
46
  end
67
47
 
68
48
  desc 'update_local_doc_repos', 'Run `git pull` on all sections that exist at the same directory level as your book directory'
69
49
  def update_local_doc_repos
70
- run_legacy_cli('update_local_doc_repos')
50
+ code = legacy_commands.update_local_doc_repos
51
+ raise Thor::Error, '' if code != 0
71
52
  end
72
53
 
73
54
  desc 'watch', 'Bind and serve a local book, watching for changes'
74
55
  def watch
75
- run_legacy_cli('watch')
56
+ code = legacy_commands.watch
57
+ raise Thor::Error, '' if code != 0
76
58
  end
77
59
 
78
60
  desc 'imprint <local|remote> [--verbose] [--dita-flags=\"<dita-option>=<value>\"]', 'Generate a PDF for a given book'
79
61
  option :verbose, type: :boolean
80
62
  option 'dita-flags'
81
63
  def imprint(source)
82
- args = ['imprint', source]
83
- args << '--verbose' if options[:verbose]
84
- args << "--dita-flags=\\\"#{options['dita-flags']}\\\""
85
- run_legacy_cli(*args)
64
+ code = legacy_commands.imprint(source, options[:verbose], options['dita-flags'])
65
+ raise Thor::Error, '' if code != 0
66
+ end
67
+
68
+ def method_missing(command, *args)
69
+ puts "Unknown command '#{command}'"
70
+ puts ""
71
+ help
86
72
  end
87
73
 
88
74
  private
89
75
 
90
- attr_reader :legacy_cli
76
+ attr_reader :legacy_commands
91
77
 
92
78
  def initialize(*)
93
79
  super
94
80
 
95
- @legacy_cli = Legacy::Cli.new(Ingest::GitAccessor.new)
81
+ @legacy_commands = Bookbinder::Commands::Collection.new(colorized_streams, git)
96
82
  end
97
83
 
98
- def run_legacy_cli(*args)
99
- status = legacy_cli.run(args)
100
- exit status unless status.zero?
84
+ def git
85
+ @git ||= Ingest::GitAccessor.new
101
86
  end
102
87
 
103
- def print_deploy_deprecation_message
104
- message = ANSI.red do
105
- <<-EOM
106
-
107
- DEPRECATED: In a future version Bookbinder will no longer deploy to Cloud Foundry
108
- The appropriate Concourse pipeline should be doing all deploys going forward.
109
-
110
- EOM
111
- end
112
-
113
- puts message
88
+ def colorized_streams
89
+ @streams ||= {
90
+ err: Streams::ColorizedStream.new(Colorizer::Colors.red, $stderr),
91
+ out: $stdout,
92
+ success: Streams::ColorizedStream.new(Colorizer::Colors.green, $stdout),
93
+ warn: Streams::ColorizedStream.new(Colorizer::Colors.yellow, $stdout),
94
+ }
114
95
  end
115
96
  end
116
97
  end
@@ -1,13 +1,10 @@
1
1
  require 'middleman-syntax'
2
2
 
3
3
  require_relative 'components/command_options'
4
- require_relative 'naming'
5
4
 
6
5
  module Bookbinder
7
6
  module Commands
8
7
  class Bind
9
- include Commands::Naming
10
-
11
8
  def initialize(base_streams,
12
9
  output_locations: nil,
13
10
  config_fetcher: nil,
@@ -33,21 +30,8 @@ module Bookbinder
33
30
  @directory_preparer = directory_preparer
34
31
  end
35
32
 
36
- def usage
37
- ["bind <local|remote> [--verbose] [--dita-flags=\\\"<dita-option>=<value>\\\"]",
38
- "Bind the sections specified in config.yml from <local> or <remote> into the final_app directory"]
39
- end
40
-
41
- def command_for?(test_command_name)
42
- %w(bind publish).include?(test_command_name)
43
- end
44
-
45
- def deprecated_command_for?(command_name)
46
- %w(publish).include?(command_name)
47
- end
48
-
49
- def run(cli_arguments)
50
- bind_options = Components::CommandOptions.new(cli_arguments, base_streams).tap(&:validate!)
33
+ def run(bind_type, verbose = false, dita_flags = nil)
34
+ bind_options = Components::CommandOptions.new([bind_type], base_streams, verbose)
51
35
  bind_config = config_fetcher.fetch_config
52
36
  cloner = cloner_factory.produce(bind_options.local_repo_dir)
53
37
 
@@ -69,7 +53,7 @@ module Bookbinder
69
53
  preprocessor.preprocess(
70
54
  sections,
71
55
  output_locations,
72
- options: bind_options.options,
56
+ options: { dita_flags: dita_flags },
73
57
  output_streams: bind_options.streams,
74
58
  config: bind_config
75
59
  )
@@ -6,7 +6,6 @@ require_relative '../commands/components/bind/directory_preparer'
6
6
  require_relative '../commands/components/imprint/directory_preparer'
7
7
  require_relative '../config/configuration_decorator'
8
8
  require_relative '../config/fetcher'
9
- require_relative '../config/remote_yaml_credential_provider'
10
9
  require_relative '../config/validator'
11
10
  require_relative '../config/yaml_loader'
12
11
  require_relative '../config/configuration'
@@ -32,64 +31,37 @@ module Bookbinder
32
31
  class Collection
33
32
  include Enumerable
34
33
 
35
- def initialize(logger, streams, version_control_system)
36
- @logger = logger
34
+ def initialize(streams, version_control_system)
37
35
  @streams = streams
38
36
  @version_control_system = version_control_system
39
37
  end
40
38
 
41
- def each(&block)
42
- list.each(&block)
39
+ def generate(*args)
40
+ Commands::Generate.new(
41
+ local_filesystem_accessor,
42
+ sheller,
43
+ Dir.pwd,
44
+ streams
45
+ ).run(*args)
43
46
  end
44
47
 
45
- def help
46
- @help ||= Commands::Help.new(
47
- logger,
48
- [version] + standard_commands
49
- )
50
- end
51
-
52
- private
53
-
54
- attr_reader :logger, :streams, :version_control_system
55
-
56
- def list
57
- standard_commands + flags
58
- end
59
-
60
- def flags
61
- @flags ||= [ version, help ]
62
- end
63
-
64
- def standard_commands
65
- @standard_commands ||= [
66
- Commands::Generate.new(
67
- local_filesystem_accessor,
68
- sheller,
69
- Dir.pwd,
70
- streams
71
- ),
72
- build_and_push_tarball,
73
- bind,
74
- push_local_to,
75
- Commands::PushToProd.new(streams, logger, configuration_fetcher(Config::Configuration), Dir.mktmpdir),
76
- Commands::RunPublishCI.new(bind, push_local_to, build_and_push_tarball),
77
- Commands::Punch.new(streams, configuration_fetcher(Config::Configuration), version_control_system),
78
- Commands::UpdateLocalDocRepos.new(
79
- streams,
80
- configuration_fetcher(Config::Configuration),
81
- version_control_system
82
- ),
83
- watch,
84
- imprint
85
- ]
48
+ def punch(*args)
49
+ Commands::Punch.new(
50
+ streams,
51
+ configuration_fetcher(Config::Configuration),
52
+ version_control_system
53
+ ).run(*args)
86
54
  end
87
55
 
88
- def version
89
- @version ||= Commands::Version.new(logger)
56
+ def update_local_doc_repos
57
+ Commands::UpdateLocalDocRepos.new(
58
+ streams,
59
+ configuration_fetcher(Config::Configuration),
60
+ version_control_system
61
+ ).run
90
62
  end
91
63
 
92
- def bind
64
+ def bind(*args)
93
65
  @bind ||= Commands::Bind.new(
94
66
  streams,
95
67
  output_locations: output_locations,
@@ -111,11 +83,7 @@ module Bookbinder
111
83
  cloner_factory: Ingest::ClonerFactory.new(streams, local_filesystem_accessor, version_control_system),
112
84
  section_repository: Ingest::SectionRepository.new,
113
85
  directory_preparer: directory_preparer
114
- )
115
- end
116
-
117
- def dita_command_creator
118
- DitaCommandCreator.new(ENV['PATH_TO_DITA_OT_LIBRARY'])
86
+ ).run(*args)
119
87
  end
120
88
 
121
89
  def watch
@@ -130,11 +98,11 @@ module Bookbinder
130
98
  cloner: local_file_system_cloner,
131
99
  section_repository: Ingest::SectionRepository.new,
132
100
  directory_preparer: directory_preparer
133
- )
101
+ ).run
134
102
  end
135
103
 
136
- def imprint
137
- Commands::Imprint.new(
104
+ def imprint(*args)
105
+ Bookbinder::Commands::Imprint.new(
138
106
  streams,
139
107
  output_locations: output_locations,
140
108
  config_fetcher: configuration_fetcher(Config::Imprint::Configuration),
@@ -142,29 +110,21 @@ module Bookbinder
142
110
  cloner_factory: Ingest::ClonerFactory.new(streams, local_filesystem_accessor, version_control_system),
143
111
  section_repository: Ingest::SectionRepository.new,
144
112
  directory_preparer: Commands::Components::Imprint::DirectoryPreparer.new(local_filesystem_accessor)
145
- )
113
+ ).run(*args)
146
114
  end
147
115
 
148
- def push_local_to
149
- @push_local_to ||= Commands::PushFromLocal.new(
150
- streams,
151
- logger,
152
- configuration_fetcher(Config::Configuration)
153
- )
154
- end
116
+ private
155
117
 
156
- def build_and_push_tarball
157
- @build_and_push_tarball ||= Commands::BuildAndPushTarball.new(
158
- streams,
159
- configuration_fetcher(Config::Configuration)
160
- )
118
+ attr_reader :streams, :version_control_system
119
+
120
+ def dita_command_creator
121
+ DitaCommandCreator.new(ENV['PATH_TO_DITA_OT_LIBRARY'])
161
122
  end
162
123
 
163
124
  def configuration_fetcher(config_class)
164
- Config::Fetcher.new(
165
- Config::Validator.new(local_filesystem_accessor),
125
+ Bookbinder::Config::Fetcher.new(
126
+ Bookbinder::Config::Validator.new(local_filesystem_accessor),
166
127
  config_loader,
167
- Config::RemoteYamlCredentialProvider.new(logger, version_control_system),
168
128
  config_class
169
129
  ).tap do |fetcher|
170
130
  fetcher.set_config_file_path './config.yml'
@@ -7,13 +7,10 @@ module Bookbinder
7
7
  module Commands
8
8
  module Components
9
9
  class CommandOptions
10
- def initialize(opts, base_streams)
10
+ def initialize(opts, base_streams, verbose = false)
11
11
  @opts = opts
12
12
  @base_streams = base_streams
13
- end
14
-
15
- def validate!
16
- raise CliError::InvalidArguments unless arguments_are_valid?
13
+ @verbosity = verbose
17
14
  end
18
15
 
19
16
  def bind_source
@@ -39,25 +36,9 @@ module Bookbinder
39
36
  )
40
37
  end
41
38
 
42
- def verbosity
43
- options.detect {|arg| arg == '--verbose'}
44
- end
45
-
46
39
  private
47
40
 
48
- attr_accessor :base_streams, :opts
49
-
50
- def arguments_are_valid?
51
- %w(local remote github).include?(bind_source) && flag_names.subset?(valid_options)
52
- end
53
-
54
- def valid_options
55
- %w(--verbose --ignore-section-refs --dita-flags).to_set
56
- end
57
-
58
- def flag_names
59
- options.map {|o| o.split('=').first}.to_set
60
- end
41
+ attr_accessor :base_streams, :opts, :verbosity
61
42
  end
62
43
  end
63
44
  end
@@ -3,8 +3,6 @@ require 'bundler'
3
3
  module Bookbinder
4
4
  module Commands
5
5
  class Generate
6
- include Commands::Naming
7
-
8
6
  def initialize(fs, sheller, context_dir, streams)
9
7
  @fs = fs
10
8
  @sheller = sheller
@@ -12,15 +10,6 @@ module Bookbinder
12
10
  @streams = streams
13
11
  end
14
12
 
15
- def command_for?(name)
16
- name == 'generate'
17
- end
18
-
19
- def usage
20
- ["generate <book-name>",
21
- "Generate a skeleton book that can be bound with 'bookbinder bind'"]
22
- end
23
-
24
13
  def run((name))
25
14
  path = context_dir.join(name)
26
15
  streams[:out].puts "Generating book at #{path}…"
@@ -1,11 +1,8 @@
1
1
  require_relative 'components/command_options'
2
- require_relative 'naming'
3
2
 
4
3
  module Bookbinder
5
4
  module Commands
6
5
  class Imprint
7
- include Commands::Naming
8
-
9
6
  def initialize(base_streams,
10
7
  output_locations: nil,
11
8
  config_fetcher: nil,
@@ -23,12 +20,8 @@ module Bookbinder
23
20
  @directory_preparer = directory_preparer
24
21
  end
25
22
 
26
- def usage
27
- ["imprint <local|remote> [--verbose] [--dita-flags=\\\"<dita-option>=<value>\\\"]", "Generate a PDF for a given book"]
28
- end
29
-
30
- def run(cli_arguments)
31
- options = Components::CommandOptions.new(cli_arguments, base_streams).tap(&:validate!)
23
+ def run(bind_type, verbose = false, dita_flags = nil)
24
+ options = Components::CommandOptions.new([bind_type], base_streams, verbose)
32
25
  config = config_fetcher.fetch_config
33
26
  cloner = cloner_factory.produce(options.local_repo_dir)
34
27
 
@@ -45,7 +38,7 @@ module Bookbinder
45
38
  preprocessor.preprocess(
46
39
  sections,
47
40
  output_locations,
48
- options: options.options,
41
+ options: { dita_flags: dita_flags },
49
42
  output_streams: options.streams,
50
43
  config: config
51
44
  )