metanorma-cli 1.4.5pre → 1.4.7
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/command.rb +3 -0
- data/lib/metanorma/cli/commands/config.rb +11 -6
- data/lib/metanorma/cli/commands/site.rb +2 -0
- data/lib/metanorma/cli/generator.rb +1 -1
- 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 +2 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 886c6f46f714e3fe30086f8570b1bae549f42c028889e2e46d1f1facd3d3840d
|
4
|
+
data.tar.gz: 4ae5e0f3c8ae9b009b48799a2967e4091ccd7667f0ea8ea1c75e4dbce062a1ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87cbe1f86d90fe2a5365c237f2a40a47427d21cc7cceb21aefa3e668ead2444e9300916c4a83a713d266b09fd99da3b9f07a890dfcc746f69f0fbc6bb8f4b9c9
|
7
|
+
data.tar.gz: 194a33c9672808f1a1f5bf4689c48b56235e6e961c36fbd86ab24ab7a675dcc70a4fe034c3856c7dfe953a8bce1e2dd5705aea9dd560ffdfa77b357e4abd31f7
|
@@ -10,6 +10,9 @@ require "metanorma"
|
|
10
10
|
module Metanorma
|
11
11
|
module Cli
|
12
12
|
class Command < ThorWithConfig
|
13
|
+
class_option :no_progress, aliases: "-s", type: :boolean, default: true,
|
14
|
+
desc: "Don't show progress for long running tasks (like download)"
|
15
|
+
|
13
16
|
desc "new NAME", "Create new Metanorma document"
|
14
17
|
option :type, aliases: "-t", required: true, desc: "Document type"
|
15
18
|
option :doctype, aliases: "-d", required: true, desc: "Metanorma doctype"
|
@@ -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))
|
@@ -39,7 +39,7 @@ module Metanorma
|
|
39
39
|
# ooption, and in that case it will use that template.
|
40
40
|
#
|
41
41
|
def self.run(name, type:, doctype:, **options)
|
42
|
-
new(name, options.merge(type: type, doctype: doctype)).run
|
42
|
+
new(name, **options.merge(type: type, doctype: doctype)).run
|
43
43
|
end
|
44
44
|
|
45
45
|
private
|
@@ -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 no_progress].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"
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
36
36
|
# need for dev because locally compiled metanorma-iso does not have css
|
37
37
|
spec.add_development_dependency "sassc"
|
38
|
+
spec.add_development_dependency "rubocop", "~> 1.5.2"
|
38
39
|
|
39
40
|
spec.add_runtime_dependency "thor", "~> 1.0"
|
40
41
|
spec.add_runtime_dependency "metanorma-iso", "~> 1.7.0"
|
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.7
|
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-30 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
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 1.5.2
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.5.2
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: thor
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -494,9 +508,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
494
508
|
version: 2.4.0
|
495
509
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
496
510
|
requirements:
|
497
|
-
- - "
|
511
|
+
- - ">="
|
498
512
|
- !ruby/object:Gem::Version
|
499
|
-
version:
|
513
|
+
version: '0'
|
500
514
|
requirements: []
|
501
515
|
rubygems_version: 3.1.4
|
502
516
|
signing_key:
|