forked from pact-foundation/docs.pact.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pact_broker.rb
executable file
·33 lines (28 loc) · 1.15 KB
/
pact_broker.rb
1
2
3
4
5
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
#!/usr/bin/env ruby
require_relative 'support'
SOURCE_REPO = 'pact-foundation/pact_broker'
DESTINATION_DIR = relative_path_to('docs/pact_broker')
TRANSFORM_PATH = -> (path) {
if path.end_with?("CONFIGURATION.md")
DESTINATION_DIR / "configuration" / "settings.md"
elsif path.start_with?("docs/api/")
File.join(DESTINATION_DIR, path.downcase.gsub("docs/api/", "api/"))
else
File.join(DESTINATION_DIR, path.downcase)
end
}
INCLUDE = [
->(path) { %w{CHANGELOG.md docs/CONFIGURATION.md}.include?(path) || path.start_with?("docs/api/") }
]
IGNORE = []
CUSTOM_ACTIONS = [
[->(path) { path != 'CHANGELOG.md'}, ->(md_file_contents) { md_file_contents.extract_title } ],
["README.md", ->(md_file_contents) { md_file_contents.fields[:title] = "README"; md_file_contents.fields[:slug] = "./readme" } ],
["docs/CONFIGURATION.md", ->(md_file_contents) { md_file_contents.fields[:title] = "Settings" } ],
["CHANGELOG.md", -> (md_file_contents) {
md_file_contents.fields[:title] = "Changelog"
md_file_contents.find_and_replace(/^###\s/, "\n### ")
}]
]
FileUtils.mkdir_p DESTINATION_DIR
sync(SOURCE_REPO, INCLUDE, IGNORE, TRANSFORM_PATH, CUSTOM_ACTIONS)