metanorma-cli 1.4.1 → 1.4.5pre
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/README.adoc +1 -3
- data/lib/metanorma/cli.rb +20 -1
- data/lib/metanorma/cli/command.rb +35 -19
- data/lib/metanorma/cli/commands/config.rb +118 -0
- data/lib/metanorma/cli/commands/site.rb +11 -6
- data/lib/metanorma/cli/commands/template_repo.rb +2 -1
- data/lib/metanorma/cli/site_generator.rb +26 -9
- data/lib/metanorma/cli/stringify_all_keys.rb +51 -0
- data/lib/metanorma/cli/template_repo.rb +7 -4
- data/lib/metanorma/cli/thor_with_config.rb +23 -0
- data/lib/metanorma/cli/version.rb +1 -1
- data/metanorma-cli.gemspec +4 -4
- metadata +16 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be9f8d3c8fe6b39720b94f1a66ab0d9ba8819ca8d55a9c35e740d0f5cd15c54a
|
4
|
+
data.tar.gz: e4059fc02804c6dc2c068dcc85216539d366faad7f272e871587a18fbbbfe9e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41044c1c94174a31dd644a1adeb0ac59258b6164226390a72a76beee87e7a0e9957283b0ba55ba5fbfc6158bfac9f0cb7333fed42660d350d0048296d44b57ac
|
7
|
+
data.tar.gz: 6631bd425364be1280a5ec4e14e338b4840ae847e4d77ade51ee018fb97684c9f922900fe487c6db350d866ba8788cd838922a0fde57b20717447c9a17e96977
|
data/README.adoc
CHANGED
@@ -183,8 +183,6 @@ are `ietf`, `iso`, `gb`, `csd`, `csand`, `m3d` and `rsd`.
|
|
183
183
|
|
184
184
|
=== Compile a document collection (`metanorma collection`)
|
185
185
|
|
186
|
-
(_This is placeholder for more complete documentation later._)
|
187
|
-
|
188
186
|
This functionality compiles collections of Metanorma documents. It compiles
|
189
187
|
the individual documents comprising the collection; then it compiles a document
|
190
188
|
acting as a container for those collections. See
|
@@ -198,7 +196,7 @@ which contains:
|
|
198
196
|
* Metadata about the collection
|
199
197
|
* A manifest listing the documents contained in the collection, in nested hierarchy
|
200
198
|
* Content to put at the beginning of the collection container
|
201
|
-
* Content to put at the
|
199
|
+
* Content to put at the ending of the collection container
|
202
200
|
|
203
201
|
Documents within a collection
|
204
202
|
may cross-reference each other using the syntax
|
data/lib/metanorma/cli.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "metanorma"
|
2
4
|
require "metanorma/cli/version"
|
3
5
|
require "metanorma/cli/errors"
|
@@ -23,6 +25,9 @@ module Metanorma
|
|
23
25
|
"metanorma-itu",
|
24
26
|
]
|
25
27
|
|
28
|
+
CONFIG_DIRNAME = ".metanorma"
|
29
|
+
CONFIG_FILENAME = "config.yml"
|
30
|
+
|
26
31
|
PRIVATE_SUPPORTED_GEMS = ["metanorma-ribose", "metanorma-mpfa"]
|
27
32
|
|
28
33
|
def self.load_flavors(flavor_names = SUPPORTED_GEMS + PRIVATE_SUPPORTED_GEMS)
|
@@ -79,7 +84,21 @@ module Metanorma
|
|
79
84
|
end
|
80
85
|
|
81
86
|
def self.home_directory
|
82
|
-
Pathname.new(Dir.home).join(
|
87
|
+
Pathname.new(Dir.home).join(CONFIG_DIRNAME)
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.global_config_path
|
91
|
+
home_directory.join(CONFIG_FILENAME)
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.local_config_path
|
95
|
+
Pathname.new(Dir.pwd).join(CONFIG_DIRNAME, CONFIG_FILENAME)
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.config_path(global = false)
|
99
|
+
return global_config_path if global
|
100
|
+
|
101
|
+
local_config_path
|
83
102
|
end
|
84
103
|
|
85
104
|
def self.writable_templates_path?
|
@@ -1,14 +1,15 @@
|
|
1
|
-
require "thor"
|
2
1
|
require "metanorma/cli/compiler"
|
3
2
|
require "metanorma/cli/generator"
|
4
3
|
require "metanorma/cli/git_template"
|
4
|
+
require "metanorma/cli/thor_with_config"
|
5
|
+
require "metanorma/cli/commands/config"
|
5
6
|
require "metanorma/cli/commands/template_repo"
|
6
7
|
require "metanorma/cli/commands/site"
|
7
8
|
require "metanorma"
|
8
9
|
|
9
10
|
module Metanorma
|
10
11
|
module Cli
|
11
|
-
class Command <
|
12
|
+
class Command < ThorWithConfig
|
12
13
|
desc "new NAME", "Create new Metanorma document"
|
13
14
|
option :type, aliases: "-t", required: true, desc: "Document type"
|
14
15
|
option :doctype, aliases: "-d", required: true, desc: "Metanorma doctype"
|
@@ -16,7 +17,7 @@ module Metanorma
|
|
16
17
|
option :template, aliases: "-l", desc: "Git hosted remote or local FS template skeleton"
|
17
18
|
|
18
19
|
def new(name)
|
19
|
-
create_new_document(name, options
|
20
|
+
create_new_document(name, options)
|
20
21
|
end
|
21
22
|
|
22
23
|
desc "compile FILENAME", "Compile to a metanorma document"
|
@@ -30,18 +31,16 @@ module Metanorma
|
|
30
31
|
option :relaton, aliases: "-R", desc: "Export Relaton XML for document to nominated filename"
|
31
32
|
option :extract, aliases: "-e", desc: "Export sourcecode fragments from this document to nominated directory"
|
32
33
|
option :version, aliases: "-v", desc: "Print version of code (accompanied with -t)"
|
33
|
-
option
|
34
|
-
|
35
|
-
|
36
|
-
option :
|
37
|
-
option :
|
34
|
+
option :output_dir, aliases: "-o", desc: "Directory to save compiled files"
|
35
|
+
option :agree_to_terms, type: :boolean, desc: "Agree / Disagree with all third-party licensing terms "\
|
36
|
+
"presented (WARNING: do know what you are agreeing with!)"
|
37
|
+
option :no_install_fonts, type: :boolean, desc: "Skip the font installation process"
|
38
|
+
option :continue_without_fonts, type: :boolean, desc: "Continue processing even when fonts are missing"
|
38
39
|
|
39
40
|
def compile(file_name = nil)
|
40
41
|
if file_name && !options[:version]
|
41
|
-
|
42
|
-
|
43
|
-
errs.each { |e| Util.log e, :error }
|
44
|
-
exit(1) if errs.any?
|
42
|
+
documents = select_wildcard_documents(file_name) || [file_name]
|
43
|
+
documents.each { |document| compile_document(document, options.dup) }
|
45
44
|
|
46
45
|
elsif options[:version]
|
47
46
|
invoke(:version, [], type: options[:type], format: options[:format])
|
@@ -56,18 +55,18 @@ module Metanorma
|
|
56
55
|
|
57
56
|
desc "collection FILENAME", "Render HTML pages from XML/YAML colection"
|
58
57
|
option :format, aliases: "-x", type: :string, desc: "Formats to generate"
|
59
|
-
option
|
58
|
+
option :output_folder, aliases: "-w", required: true, desc: "Directory to save compiled files"
|
60
59
|
option :coverpage, aliases: "-c", desc: "Liquid template"
|
61
|
-
option :
|
62
|
-
|
63
|
-
option :
|
60
|
+
option :agree_to_terms, type: :boolean, desc: "Agree / Disagree with all third-party licensing terms "\
|
61
|
+
"presented (WARNING: do know what you are agreeing with!)"
|
62
|
+
option :no_install_fonts, type: :boolean, desc: "Skip the font installation process"
|
63
|
+
option :continue_without_fonts, type: :boolean, desc: "Continue processing even when fonts are missing"
|
64
64
|
|
65
65
|
def collection(filename = nil)
|
66
66
|
if filename
|
67
|
-
opts = options
|
67
|
+
opts = options
|
68
68
|
opts[:format] &&= opts[:format].split(",").map &:to_sym
|
69
|
-
opts[:
|
70
|
-
opts[:compile] = opts.select { |k, v| ["agree-to-terms", "no-install-fonts", "continue-without-fonts"].include?(k)}.map { |k, v| [k.to_sym, v] }.to_h
|
69
|
+
opts[:compile] = filter_compile_options(opts)
|
71
70
|
coll = Metanorma::Collection.parse filename
|
72
71
|
coll.render opts
|
73
72
|
else UI.say("Need to specify a file to process")
|
@@ -111,6 +110,9 @@ module Metanorma
|
|
111
110
|
desc "site", "Manage site for metanorma collections"
|
112
111
|
subcommand :site, Metanorma::Cli::Commands::Site
|
113
112
|
|
113
|
+
desc "config", "Manage configuration file"
|
114
|
+
subcommand :config, Metanorma::Cli::Commands::Config
|
115
|
+
|
114
116
|
private
|
115
117
|
|
116
118
|
def single_type_extensions(type)
|
@@ -194,6 +196,20 @@ module Metanorma
|
|
194
196
|
|
195
197
|
UI.table(["Type", "Input", "Supported output format"], table_data)
|
196
198
|
end
|
199
|
+
|
200
|
+
def select_wildcard_documents(filename)
|
201
|
+
if filename.include?("*")
|
202
|
+
Dir.glob(Pathname.new(filename))
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def compile_document(filename, options)
|
207
|
+
Metanorma::Cli.load_flavors
|
208
|
+
errors = Metanorma::Cli::Compiler.compile(filename, options)
|
209
|
+
errors.each { |error| Util.log(error, :error) }
|
210
|
+
|
211
|
+
exit(1) if errors.any?
|
212
|
+
end
|
197
213
|
end
|
198
214
|
end
|
199
215
|
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "metanorma/cli/stringify_all_keys"
|
4
|
+
|
5
|
+
module Metanorma
|
6
|
+
module Cli
|
7
|
+
module Commands
|
8
|
+
class Config < Thor
|
9
|
+
class_option :global, aliases: "-g", type: :boolean, default: false, desc: "Use global config"
|
10
|
+
|
11
|
+
desc "get NAME", "Get config value"
|
12
|
+
def get(name = nil)
|
13
|
+
config, config_path = load_config(options.global)
|
14
|
+
|
15
|
+
if name.nil?
|
16
|
+
UI.say File.read(config_path, encoding: "utf-8")
|
17
|
+
else
|
18
|
+
UI.say(config.dig(*dig_path(name)) || "nil")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "set NAME VALUE", "Set config value"
|
23
|
+
def set(name, value = nil)
|
24
|
+
config, config_path = load_config(options.global)
|
25
|
+
|
26
|
+
value = try_convert_to_bool(value)
|
27
|
+
ypath = dig_path(name)
|
28
|
+
deep_set(config, value, *ypath)
|
29
|
+
|
30
|
+
save_config(config, config_path)
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "unset [name]", "Set config [value] for [name]"
|
34
|
+
def unset(name)
|
35
|
+
config, config_path = load_config(options.global)
|
36
|
+
|
37
|
+
ypath = dig_path(name)
|
38
|
+
deep_unset(config, *ypath)
|
39
|
+
|
40
|
+
save_config(config, config_path)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.exit_on_failure?() true end
|
44
|
+
|
45
|
+
# priority:
|
46
|
+
# IDEAL: thor defaults -> global conf -> local conf -> env vars -> passed arguments
|
47
|
+
# ACTUAL: all arguments -> global conf -> local conf
|
48
|
+
# - thor doesn't provide to differentiate default values against passed args
|
49
|
+
# - thor doesn't allow to get all args available for current command
|
50
|
+
def self.load_configs(options, configs = [Metanorma::Cli.global_config_path, Metanorma::Cli.local_config_path])
|
51
|
+
result = options.dup
|
52
|
+
configs.each do |config_path|
|
53
|
+
next unless File.exists?(config_path)
|
54
|
+
|
55
|
+
config_values = ::YAML::load_file(config_path).symbolize_all_keys[:cli] || {}
|
56
|
+
result.merge!(config_values)
|
57
|
+
end
|
58
|
+
|
59
|
+
result
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def save_config(config, path)
|
65
|
+
shash = config.stringify_all_keys
|
66
|
+
File.write(path, shash.to_yaml, encoding: "utf-8")
|
67
|
+
end
|
68
|
+
|
69
|
+
def save_default_config(config_path)
|
70
|
+
unless config_path.exist?
|
71
|
+
unless config_path.dirname.exist?
|
72
|
+
FileUtils.mkdir_p(config_path.dirname)
|
73
|
+
end
|
74
|
+
save_config({ cli: nil }, config_path)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def load_config(global_config)
|
79
|
+
config_path = Metanorma::Cli.config_path(global_config)
|
80
|
+
save_default_config(config_path) unless File.exists?(config_path)
|
81
|
+
|
82
|
+
[::YAML::load_file(config_path).symbolize_all_keys || {}, config_path]
|
83
|
+
end
|
84
|
+
|
85
|
+
def dig_path(str)
|
86
|
+
str.split(".").map(&:to_sym)
|
87
|
+
end
|
88
|
+
|
89
|
+
def deep_set(hash, value, *keys)
|
90
|
+
keys[0...-1].reduce(hash) do |acc, h|
|
91
|
+
tmp = acc.public_send(:[], h)
|
92
|
+
if tmp.nil?
|
93
|
+
acc[h] = tmp = Hash.new
|
94
|
+
end
|
95
|
+
tmp
|
96
|
+
end.public_send(:[]=, keys.last, value)
|
97
|
+
end
|
98
|
+
|
99
|
+
def deep_unset(hash, *keys)
|
100
|
+
keys[0...-1].reduce(hash) do |acc, h|
|
101
|
+
acc.public_send(:[], h)
|
102
|
+
end.delete(keys.last)
|
103
|
+
end
|
104
|
+
|
105
|
+
def try_convert_to_bool(value)
|
106
|
+
case value
|
107
|
+
when "true"
|
108
|
+
true
|
109
|
+
when "false"
|
110
|
+
false
|
111
|
+
else
|
112
|
+
value
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -1,21 +1,26 @@
|
|
1
1
|
require "pathname"
|
2
2
|
require "metanorma/cli/site_generator"
|
3
|
+
require "metanorma/cli/thor_with_config"
|
3
4
|
|
4
5
|
module Metanorma
|
5
6
|
module Cli
|
6
7
|
module Commands
|
7
|
-
class Site <
|
8
|
-
desc "generate SOURCE_PATH", "
|
9
|
-
option :config, aliases: "-c", desc: "
|
8
|
+
class Site < ThorWithConfig
|
9
|
+
desc "generate [SOURCE_PATH]", "Generate site from collection"
|
10
|
+
option :config, aliases: "-c", desc: "Metanorma configuration file"
|
10
11
|
option(
|
11
12
|
:output_dir,
|
12
13
|
aliases: "-o",
|
13
14
|
default: Pathname.new(Dir.pwd).join("site").to_s,
|
14
|
-
desc: "Output directory for
|
15
|
+
desc: "Output directory for generated site"
|
15
16
|
)
|
17
|
+
option :agree_to_terms, type: :boolean, desc: "Agree / Disagree with all third-party licensing terms "\
|
18
|
+
"presented (WARNING: do know what you are agreeing with!)"
|
19
|
+
option :no_install_fonts, type: :boolean, desc: "Skip the font installation process"
|
20
|
+
option :continue_without_fonts, type: :boolean, desc: "Continue processing even when fonts are missing"
|
16
21
|
|
17
|
-
def generate(source_path)
|
18
|
-
Cli::SiteGenerator.generate(source_path, options
|
22
|
+
def generate(source_path = Dir.pwd)
|
23
|
+
Cli::SiteGenerator.generate(source_path, options, filter_compile_options(options))
|
19
24
|
UI.say("Site has been generated at #{options[:output_dir]}")
|
20
25
|
rescue Cli::Errors::InvalidManifestFileError
|
21
26
|
UI.error("Invalid data in: #{options[:config]}")
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require "metanorma/cli/template_repo"
|
2
|
+
require "metanorma/cli/thor_with_config"
|
2
3
|
|
3
4
|
module Metanorma
|
4
5
|
module Cli
|
5
6
|
module Commands
|
6
|
-
class TemplateRepo <
|
7
|
+
class TemplateRepo < ThorWithConfig
|
7
8
|
desc "add NAME SOURCE", "Add new metanorma templates repository"
|
8
9
|
option :overwrite, aliases: "-y", type: :boolean, desc: "Overwrite existing template"
|
9
10
|
|
@@ -5,18 +5,18 @@ require "fileutils"
|
|
5
5
|
module Metanorma
|
6
6
|
module Cli
|
7
7
|
class SiteGenerator
|
8
|
-
def initialize(source, options = {})
|
8
|
+
def initialize(source, options = {}, compile_options = {})
|
9
9
|
@source = find_realpath(source)
|
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
|
@manifest_file = find_realpath(options.fetch(:config, default_config))
|
14
|
-
|
14
|
+
@compile_options = compile_options
|
15
15
|
ensure_site_asset_directory!
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.generate(source, options = {})
|
19
|
-
new(source, options).generate
|
18
|
+
def self.generate(source, options = {}, compile_options = {})
|
19
|
+
new(source, options, compile_options).generate
|
20
20
|
end
|
21
21
|
|
22
22
|
def generate
|
@@ -70,9 +70,11 @@ module Metanorma
|
|
70
70
|
def compile(source)
|
71
71
|
UI.info("Compiling #{source} ...")
|
72
72
|
|
73
|
-
|
74
|
-
|
73
|
+
options = @compile_options.merge(
|
74
|
+
format: :asciidoc, output_dir: build_asset_output_directory(source)
|
75
75
|
)
|
76
|
+
|
77
|
+
Metanorma::Cli::Compiler.compile(source.to_s, options)
|
76
78
|
end
|
77
79
|
|
78
80
|
def convert_to_html_page(collection, page_name)
|
@@ -101,11 +103,11 @@ module Metanorma
|
|
101
103
|
) || [],
|
102
104
|
|
103
105
|
collection_name: extract_config_data(
|
104
|
-
manifest["
|
106
|
+
manifest["metanorma"]["collection"], "name"
|
105
107
|
),
|
106
108
|
|
107
109
|
collection_organization: extract_config_data(
|
108
|
-
manifest["
|
110
|
+
manifest["metanorma"]["collection"], "organization"
|
109
111
|
),
|
110
112
|
}
|
111
113
|
rescue NoMethodError
|
@@ -127,7 +129,22 @@ module Metanorma
|
|
127
129
|
asset_path = [site_path, asset_folder].join("/")
|
128
130
|
@asset_directory = Pathname.new(Dir.pwd).join(asset_path)
|
129
131
|
|
130
|
-
|
132
|
+
create_directory_if_not_present!(@asset_directory)
|
133
|
+
end
|
134
|
+
|
135
|
+
def create_directory_if_not_present!(directory)
|
136
|
+
FileUtils.mkdir_p(directory) unless directory.exist?
|
137
|
+
end
|
138
|
+
|
139
|
+
def build_asset_output_directory(source)
|
140
|
+
sub_directory = Pathname.new(source.gsub(@source.to_s, "")).dirname.to_s
|
141
|
+
sub_directory.gsub!("/sources", "")
|
142
|
+
sub_directory.slice!(0)
|
143
|
+
|
144
|
+
output_directory = asset_directory.join(sub_directory)
|
145
|
+
create_directory_if_not_present!(output_directory)
|
146
|
+
|
147
|
+
output_directory
|
131
148
|
end
|
132
149
|
end
|
133
150
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class Array
|
2
|
+
def stringify_all_keys
|
3
|
+
map do |v|
|
4
|
+
case v
|
5
|
+
when Hash, Array
|
6
|
+
v.stringify_all_keys
|
7
|
+
else
|
8
|
+
v
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def symbolize_all_keys
|
14
|
+
map do |v|
|
15
|
+
case v
|
16
|
+
when Hash, Array
|
17
|
+
v.symbolize_all_keys
|
18
|
+
else
|
19
|
+
v
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Hash
|
26
|
+
def stringify_all_keys
|
27
|
+
result = {}
|
28
|
+
each do |k, v|
|
29
|
+
result[k.to_s] = case v
|
30
|
+
when Hash, Array
|
31
|
+
v.stringify_all_keys
|
32
|
+
else
|
33
|
+
v
|
34
|
+
end
|
35
|
+
end
|
36
|
+
result
|
37
|
+
end
|
38
|
+
|
39
|
+
def symbolize_all_keys
|
40
|
+
result = {}
|
41
|
+
each do |k, v|
|
42
|
+
result[k.to_sym] = case v
|
43
|
+
when Hash, Array
|
44
|
+
v.symbolize_all_keys
|
45
|
+
else
|
46
|
+
v
|
47
|
+
end
|
48
|
+
end
|
49
|
+
result
|
50
|
+
end
|
51
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require "yaml"
|
2
2
|
|
3
|
+
require "metanorma/cli/stringify_all_keys"
|
4
|
+
|
3
5
|
module Metanorma
|
4
6
|
module Cli
|
5
7
|
class TemplateRepo
|
@@ -27,11 +29,11 @@ module Metanorma
|
|
27
29
|
attr_reader :name, :source, :type, :overwrite
|
28
30
|
|
29
31
|
def templates
|
30
|
-
@templates ||= YAML.
|
32
|
+
@templates ||= YAML.load_file(template_config_file).symbolize_all_keys
|
31
33
|
end
|
32
34
|
|
33
35
|
def template_config_file
|
34
|
-
@template_config_file ||= Cli.
|
36
|
+
@template_config_file ||= Cli.config_path(true)
|
35
37
|
end
|
36
38
|
|
37
39
|
def create_template_config
|
@@ -40,12 +42,13 @@ module Metanorma
|
|
40
42
|
FileUtils.mkdir_p(template_config_file.dirname)
|
41
43
|
end
|
42
44
|
|
43
|
-
write_to_template_config(
|
45
|
+
write_to_template_config(templates: [])
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
49
|
def write_to_template_config(templates)
|
48
|
-
|
50
|
+
shash = templates.stringify_all_keys
|
51
|
+
File.write(template_config_file, shash.to_yaml)
|
49
52
|
end
|
50
53
|
|
51
54
|
def add_new_template(name, source, type)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
require_relative "stringify_all_keys"
|
4
|
+
|
5
|
+
module Metanorma
|
6
|
+
module Cli
|
7
|
+
class ThorWithConfig < Thor
|
8
|
+
no_commands do
|
9
|
+
def options
|
10
|
+
@options_cache
|
11
|
+
original_options = super.to_hash.symbolize_all_keys
|
12
|
+
@options_cache = Metanorma::Cli::Commands::Config.load_configs(original_options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def filter_compile_options(options)
|
16
|
+
options.select do |k, _|
|
17
|
+
%i[agree_to_terms no_install_fonts continue_without_fonts].include?(k)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/metanorma-cli.gemspec
CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_development_dependency "sassc"
|
38
38
|
|
39
39
|
spec.add_runtime_dependency "thor", "~> 1.0"
|
40
|
-
spec.add_runtime_dependency "metanorma-iso", "~> 1.
|
40
|
+
spec.add_runtime_dependency "metanorma-iso", "~> 1.7.0"
|
41
41
|
spec.add_runtime_dependency "metanorma-ietf", "~> 2.2.0"
|
42
42
|
#spec.add_runtime_dependency "metanorma-gb", "~> 1.5.0"
|
43
43
|
spec.add_runtime_dependency "metanorma-iec", "~> 1.2.0"
|
@@ -46,15 +46,15 @@ Gem::Specification.new do |spec|
|
|
46
46
|
#spec.add_runtime_dependency 'metanorma-ribose', "~> 1.6.0"
|
47
47
|
spec.add_runtime_dependency "metanorma-m3aawg", "~> 1.6.0"
|
48
48
|
spec.add_runtime_dependency "metanorma-bipm", "~> 1.0.0"
|
49
|
-
spec.add_runtime_dependency "metanorma-generic", "~> 1.
|
50
|
-
spec.add_runtime_dependency "metanorma-standoc", "~> 1.
|
49
|
+
spec.add_runtime_dependency "metanorma-generic", "~> 1.9.0"
|
50
|
+
spec.add_runtime_dependency "metanorma-standoc", "~> 1.8.0"
|
51
51
|
#spec.add_runtime_dependency 'metanorma-mpfa', "~> 0.5.0"
|
52
52
|
spec.add_runtime_dependency "metanorma-un", "~> 0.5.0"
|
53
53
|
spec.add_runtime_dependency "metanorma-ogc", "~> 1.2.0"
|
54
54
|
spec.add_runtime_dependency "metanorma-nist", "~> 1.2.0"
|
55
55
|
spec.add_runtime_dependency "metanorma-itu", "~> 1.2.0"
|
56
56
|
spec.add_runtime_dependency "metanorma-iho", "~> 0.2.0"
|
57
|
-
spec.add_runtime_dependency "isodoc", ">= 1.
|
57
|
+
spec.add_runtime_dependency "isodoc", ">= 1.5.0"
|
58
58
|
spec.add_runtime_dependency "metanorma", "~> 1.2.0"
|
59
59
|
spec.add_runtime_dependency "git", "~> 1.5"
|
60
60
|
spec.add_runtime_dependency "relaton-cli", ">= 0.8.2"
|
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.5pre
|
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-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1.
|
173
|
+
version: 1.7.0
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 1.
|
180
|
+
version: 1.7.0
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: metanorma-ietf
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -268,28 +268,28 @@ dependencies:
|
|
268
268
|
requirements:
|
269
269
|
- - "~>"
|
270
270
|
- !ruby/object:Gem::Version
|
271
|
-
version: 1.
|
271
|
+
version: 1.9.0
|
272
272
|
type: :runtime
|
273
273
|
prerelease: false
|
274
274
|
version_requirements: !ruby/object:Gem::Requirement
|
275
275
|
requirements:
|
276
276
|
- - "~>"
|
277
277
|
- !ruby/object:Gem::Version
|
278
|
-
version: 1.
|
278
|
+
version: 1.9.0
|
279
279
|
- !ruby/object:Gem::Dependency
|
280
280
|
name: metanorma-standoc
|
281
281
|
requirement: !ruby/object:Gem::Requirement
|
282
282
|
requirements:
|
283
283
|
- - "~>"
|
284
284
|
- !ruby/object:Gem::Version
|
285
|
-
version: 1.
|
285
|
+
version: 1.8.0
|
286
286
|
type: :runtime
|
287
287
|
prerelease: false
|
288
288
|
version_requirements: !ruby/object:Gem::Requirement
|
289
289
|
requirements:
|
290
290
|
- - "~>"
|
291
291
|
- !ruby/object:Gem::Version
|
292
|
-
version: 1.
|
292
|
+
version: 1.8.0
|
293
293
|
- !ruby/object:Gem::Dependency
|
294
294
|
name: metanorma-un
|
295
295
|
requirement: !ruby/object:Gem::Requirement
|
@@ -366,14 +366,14 @@ dependencies:
|
|
366
366
|
requirements:
|
367
367
|
- - ">="
|
368
368
|
- !ruby/object:Gem::Version
|
369
|
-
version: 1.
|
369
|
+
version: 1.5.0
|
370
370
|
type: :runtime
|
371
371
|
prerelease: false
|
372
372
|
version_requirements: !ruby/object:Gem::Requirement
|
373
373
|
requirements:
|
374
374
|
- - ">="
|
375
375
|
- !ruby/object:Gem::Version
|
376
|
-
version: 1.
|
376
|
+
version: 1.5.0
|
377
377
|
- !ruby/object:Gem::Dependency
|
378
378
|
name: metanorma
|
379
379
|
requirement: !ruby/object:Gem::Requirement
|
@@ -461,6 +461,7 @@ files:
|
|
461
461
|
- lib/metanorma-cli.rb
|
462
462
|
- lib/metanorma/cli.rb
|
463
463
|
- lib/metanorma/cli/command.rb
|
464
|
+
- lib/metanorma/cli/commands/config.rb
|
464
465
|
- lib/metanorma/cli/commands/site.rb
|
465
466
|
- lib/metanorma/cli/commands/template_repo.rb
|
466
467
|
- lib/metanorma/cli/compiler.rb
|
@@ -468,7 +469,9 @@ files:
|
|
468
469
|
- lib/metanorma/cli/generator.rb
|
469
470
|
- lib/metanorma/cli/git_template.rb
|
470
471
|
- lib/metanorma/cli/site_generator.rb
|
472
|
+
- lib/metanorma/cli/stringify_all_keys.rb
|
471
473
|
- lib/metanorma/cli/template_repo.rb
|
474
|
+
- lib/metanorma/cli/thor_with_config.rb
|
472
475
|
- lib/metanorma/cli/ui.rb
|
473
476
|
- lib/metanorma/cli/version.rb
|
474
477
|
- metanorma-cli.gemspec
|
@@ -491,11 +494,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
491
494
|
version: 2.4.0
|
492
495
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
493
496
|
requirements:
|
494
|
-
- - "
|
497
|
+
- - ">"
|
495
498
|
- !ruby/object:Gem::Version
|
496
|
-
version:
|
499
|
+
version: 1.3.1
|
497
500
|
requirements: []
|
498
|
-
rubygems_version: 3.
|
501
|
+
rubygems_version: 3.1.4
|
499
502
|
signing_key:
|
500
503
|
specification_version: 4
|
501
504
|
summary: Metanorma is the standard of standards; the metanorma gem allows you to create
|