metanorma-cli 1.4.5 → 1.4.6pre
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/lib/metanorma/cli/commands/config.rb +11 -6
- data/lib/metanorma/cli/commands/site.rb +2 -0
- data/lib/metanorma/cli/site_generator.rb +14 -3
- data/lib/metanorma/cli/thor_with_config.rb +5 -4
- data/lib/metanorma/cli/version.rb +1 -1
- data/metanorma-cli.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f816a508f6849109c1993d57abe21d440e0ba7a5a9889ac3b94af22cece3460
|
4
|
+
data.tar.gz: 9cd0d1d840404896b0fc84b7538fc92cf0c871cad618e29229af4323682b24a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c52209957baded4b395c2294eaf2d1101dd25733d53847f8c9aaedb9cf99cf707a7d2327a0803732a90b61bf1d902126cd788543af78685cdf6487618ab5288
|
7
|
+
data.tar.gz: 725c5b172877a8819bea002e1ac4d7a5403d17e338c272a03ef306060562ac0dda09b89e1714fab9d49c6a613d7c5d155a63169d07d32e506f2cf53eb8ca66ff
|
@@ -10,9 +10,9 @@ module Metanorma
|
|
10
10
|
|
11
11
|
desc "get NAME", "Get config value"
|
12
12
|
def get(name = nil)
|
13
|
-
config, config_path = load_config(options
|
13
|
+
config, config_path = load_config(options[:global], create_default_config: false)
|
14
14
|
|
15
|
-
if name.nil?
|
15
|
+
if name.nil? && File.exists?(config_path)
|
16
16
|
UI.say File.read(config_path, encoding: "utf-8")
|
17
17
|
else
|
18
18
|
UI.say(config.dig(*dig_path(name)) || "nil")
|
@@ -21,7 +21,7 @@ module Metanorma
|
|
21
21
|
|
22
22
|
desc "set NAME VALUE", "Set config value"
|
23
23
|
def set(name, value = nil)
|
24
|
-
config, config_path = load_config(options
|
24
|
+
config, config_path = load_config(options[:global])
|
25
25
|
|
26
26
|
value = try_convert_to_bool(value)
|
27
27
|
ypath = dig_path(name)
|
@@ -32,7 +32,7 @@ module Metanorma
|
|
32
32
|
|
33
33
|
desc "unset [name]", "Set config [value] for [name]"
|
34
34
|
def unset(name)
|
35
|
-
config, config_path = load_config(options
|
35
|
+
config, config_path = load_config(options[:global])
|
36
36
|
|
37
37
|
ypath = dig_path(name)
|
38
38
|
deep_unset(config, *ypath)
|
@@ -75,9 +75,14 @@ module Metanorma
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
def load_config(global_config)
|
78
|
+
def load_config(global_config, create_default_config: true)
|
79
79
|
config_path = Metanorma::Cli.config_path(global_config)
|
80
|
-
|
80
|
+
|
81
|
+
unless File.exists?(config_path) || create_default_config
|
82
|
+
config_path = Metanorma::Cli.config_path(true)
|
83
|
+
end
|
84
|
+
|
85
|
+
save_default_config(config_path)
|
81
86
|
|
82
87
|
[::YAML::load_file(config_path).symbolize_all_keys || {}, config_path]
|
83
88
|
end
|
@@ -18,6 +18,8 @@ module Metanorma
|
|
18
18
|
"presented (WARNING: do know what you are agreeing with!)"
|
19
19
|
option :no_install_fonts, type: :boolean, desc: "Skip the font installation process"
|
20
20
|
option :continue_without_fonts, type: :boolean, desc: "Continue processing even when fonts are missing"
|
21
|
+
option :stylesheet, alias: "-s", desc: "Stylesheet file path for rendering HTML page"
|
22
|
+
option :template_dir, alias: "-t", desc: "Liquid template directory to render site design"
|
21
23
|
|
22
24
|
def generate(source_path = Dir.pwd)
|
23
25
|
Cli::SiteGenerator.generate(source_path, options, filter_compile_options(options))
|
@@ -10,7 +10,11 @@ module Metanorma
|
|
10
10
|
@site_path = options.fetch(:output_dir, "site").to_s
|
11
11
|
@asset_folder = options.fetch(:asset_folder, "documents").to_s
|
12
12
|
@collection_name = options.fetch(:collection_name, "documents.xml")
|
13
|
+
|
13
14
|
@manifest_file = find_realpath(options.fetch(:config, default_config))
|
15
|
+
@template_dir = options.fetch(:template_dir, template_data("path"))
|
16
|
+
@stylesheet = options.fetch(:stylesheet, template_data("stylesheet"))
|
17
|
+
|
14
18
|
@compile_options = compile_options
|
15
19
|
ensure_site_asset_directory!
|
16
20
|
end
|
@@ -31,8 +35,8 @@ module Metanorma
|
|
31
35
|
|
32
36
|
private
|
33
37
|
|
34
|
-
attr_reader :source, :asset_folder, :asset_directory
|
35
|
-
attr_reader :
|
38
|
+
attr_reader :source, :asset_folder, :asset_directory, :site_path
|
39
|
+
attr_reader :manifest_file, :collection_name, :stylesheet, :template_dir
|
36
40
|
|
37
41
|
def find_realpath(source_path)
|
38
42
|
Pathname.new(source_path.to_s).realpath if source_path
|
@@ -80,10 +84,15 @@ module Metanorma
|
|
80
84
|
def convert_to_html_page(collection, page_name)
|
81
85
|
UI.info("Generating html site in #{site_path} ...")
|
82
86
|
|
83
|
-
Relaton::Cli::XMLConvertor.to_html(collection)
|
87
|
+
Relaton::Cli::XMLConvertor.to_html(collection, stylesheet, template_dir)
|
84
88
|
File.rename(Pathname.new(collection).sub_ext(".html").to_s, page_name)
|
85
89
|
end
|
86
90
|
|
91
|
+
def template_data(node)
|
92
|
+
template_node = manifest[:template]
|
93
|
+
template_node&.fetch(node.to_s, nil)
|
94
|
+
end
|
95
|
+
|
87
96
|
def manifest
|
88
97
|
@manifest ||= config_from_manifest || {
|
89
98
|
files: [], collection_name: "", collection_organization: ""
|
@@ -109,6 +118,8 @@ module Metanorma
|
|
109
118
|
collection_organization: extract_config_data(
|
110
119
|
manifest["metanorma"]["collection"], "organization"
|
111
120
|
),
|
121
|
+
|
122
|
+
template: extract_config_data(manifest["metanorma"], "template"),
|
112
123
|
}
|
113
124
|
rescue NoMethodError
|
114
125
|
raise Errors::InvalidManifestFileError.new("Invalid manifest file")
|
@@ -7,15 +7,16 @@ module Metanorma
|
|
7
7
|
class ThorWithConfig < Thor
|
8
8
|
no_commands do
|
9
9
|
def options
|
10
|
-
@options_cache
|
11
10
|
original_options = super.to_hash.symbolize_all_keys
|
12
|
-
|
11
|
+
Thor::CoreExt::HashWithIndifferentAccess.new(
|
12
|
+
Metanorma::Cli::Commands::Config.load_configs(original_options)
|
13
|
+
)
|
13
14
|
end
|
14
15
|
|
15
16
|
def filter_compile_options(options)
|
16
17
|
options.select do |k, _|
|
17
|
-
%
|
18
|
-
end
|
18
|
+
%w[agree_to_terms no_install_fonts continue_without_fonts].include?(k)
|
19
|
+
end.symbolize_all_keys
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
data/metanorma-cli.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.required_ruby_version = '>= 2.4.0'
|
26
26
|
|
27
27
|
spec.add_development_dependency "pry"
|
28
|
-
spec.add_development_dependency "rake", "~>
|
28
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
30
|
spec.add_development_dependency "byebug", "~> 10.0"
|
31
31
|
spec.add_development_dependency "rspec-command", "~> 1.0.3"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.6pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -494,9 +494,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
494
494
|
version: 2.4.0
|
495
495
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
496
496
|
requirements:
|
497
|
-
- - "
|
497
|
+
- - ">"
|
498
498
|
- !ruby/object:Gem::Version
|
499
|
-
version:
|
499
|
+
version: 1.3.1
|
500
500
|
requirements: []
|
501
501
|
rubygems_version: 3.1.4
|
502
502
|
signing_key:
|