metanorma-cli 1.4.0 → 1.4.3
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/Gemfile +0 -1
- data/README.adoc +27 -3
- data/lib/metanorma/cli.rb +20 -1
- data/lib/metanorma/cli/command.rb +48 -10
- data/lib/metanorma/cli/commands/config.rb +118 -0
- data/lib/metanorma/cli/commands/site.rb +10 -5
- data/lib/metanorma/cli/commands/template_repo.rb +2 -1
- data/lib/metanorma/cli/site_generator.rb +16 -12
- 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/ui.rb +4 -0
- data/lib/metanorma/cli/version.rb +1 -1
- data/metanorma-cli.gemspec +4 -4
- metadata +13 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46cfadec82b49d2434f4d854b949d1a43052734dbf455d9fd5b00cf9688fc7f3
|
4
|
+
data.tar.gz: 1634372911d8c51fab3898aa79584e182098296d91f09dd2dc394340c2ea7d22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df1e3bb7f61c245b173f86094cf61e5d2ded8b5ebe34b95646a937915a0ee8215dcc97621c57ff0bd986b5342a3c184966de93171a7b97fd529dda967c9c05aa
|
7
|
+
data.tar.gz: 63f15ed135e6a7e0d9ebb556c3202189c51fdc54a5a8d6ff16a946d06fa8ebd073ceca69b6230bfc0ad79b37f23887a473b0c905c5bf8da9d6395345a7586f8a
|
data/Gemfile
CHANGED
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
|
@@ -228,6 +226,32 @@ Options:
|
|
228
226
|
-c, [--coverpage=COVERPAGE] # Cover page as Liquid template for collection (currently HTML only)
|
229
227
|
----
|
230
228
|
|
229
|
+
=== List supported doctypes (`metanorma list-doctypes`)
|
230
|
+
|
231
|
+
You want to know what are the supported doctypes and what do they support for
|
232
|
+
input and output format? Well, the `metanorma list-doctypes` can help.
|
233
|
+
|
234
|
+
|
235
|
+
[source,sh]
|
236
|
+
----
|
237
|
+
metanorma list-doctypes
|
238
|
+
----
|
239
|
+
|
240
|
+
|
241
|
+
To list out the details for a specific flavor run the following command:
|
242
|
+
|
243
|
+
[source,sh]
|
244
|
+
----
|
245
|
+
metanorma list-doctypes <flavor>
|
246
|
+
----
|
247
|
+
|
248
|
+
e.g.,
|
249
|
+
|
250
|
+
[source,sh]
|
251
|
+
----
|
252
|
+
metanorma list-doctypes iso
|
253
|
+
----
|
254
|
+
|
231
255
|
=== List supported output formats (`metanorma list-extensions`)
|
232
256
|
|
233
257
|
Need to know what output formats are supported for a given flavor?
|
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,16 +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
|
-
|
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!)"
|
36
37
|
option :no_install_fonts, type: :boolean, desc: "Skip the font installation process"
|
37
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
|
Metanorma::Cli.load_flavors
|
42
|
-
errs = Metanorma::Cli::Compiler.compile(file_name, options
|
43
|
+
errs = Metanorma::Cli::Compiler.compile(file_name, options)
|
43
44
|
errs.each { |e| Util.log e, :error }
|
44
45
|
exit(1) if errs.any?
|
45
46
|
|
@@ -56,14 +57,18 @@ module Metanorma
|
|
56
57
|
|
57
58
|
desc "collection FILENAME", "Render HTML pages from XML/YAML colection"
|
58
59
|
option :format, aliases: "-x", type: :string, desc: "Formats to generate"
|
59
|
-
option
|
60
|
+
option :output_folder, aliases: "-w", required: true, desc: "Directory to save compiled files"
|
60
61
|
option :coverpage, aliases: "-c", desc: "Liquid template"
|
62
|
+
option :agree_to_terms, type: :boolean, desc: "Agree / Disagree with all third-party licensing terms "\
|
63
|
+
"presented (WARNING: do know what you are agreeing with!)"
|
64
|
+
option :no_install_fonts, type: :boolean, desc: "Skip the font installation process"
|
65
|
+
option :continue_without_fonts, type: :boolean, desc: "Continue processing even when fonts are missing"
|
61
66
|
|
62
67
|
def collection(filename = nil)
|
63
68
|
if filename
|
64
|
-
opts = options
|
69
|
+
opts = options
|
65
70
|
opts[:format] &&= opts[:format].split(",").map &:to_sym
|
66
|
-
opts[:
|
71
|
+
opts[:compile] = filter_compile_options(opts)
|
67
72
|
coll = Metanorma::Collection.parse filename
|
68
73
|
coll.render opts
|
69
74
|
else UI.say("Need to specify a file to process")
|
@@ -90,12 +95,26 @@ module Metanorma
|
|
90
95
|
UI.say("Couldn't load #{type}, please provide a valid type!")
|
91
96
|
end
|
92
97
|
|
98
|
+
desc "list-doctypes", "List supported doctypes"
|
99
|
+
def list_doctypes(type = nil)
|
100
|
+
processors = backend_processors
|
101
|
+
|
102
|
+
if type && processors[type.to_sym]
|
103
|
+
processors = { type.to_sym => processors[type.to_sym] }
|
104
|
+
end
|
105
|
+
|
106
|
+
print_doctypes_table(processors)
|
107
|
+
end
|
108
|
+
|
93
109
|
desc "template-repo", "Manage metanorma templates repository"
|
94
110
|
subcommand :template_repo, Metanorma::Cli::Commands::TemplateRepo
|
95
111
|
|
96
112
|
desc "site", "Manage site for metanorma collections"
|
97
113
|
subcommand :site, Metanorma::Cli::Commands::Site
|
98
114
|
|
115
|
+
desc "config", "Manage configuration file"
|
116
|
+
subcommand :config, Metanorma::Cli::Commands::Config
|
117
|
+
|
99
118
|
private
|
100
119
|
|
101
120
|
def single_type_extensions(type)
|
@@ -124,6 +143,13 @@ module Metanorma
|
|
124
143
|
end
|
125
144
|
end
|
126
145
|
|
146
|
+
def backend_processors
|
147
|
+
@backend_processors ||= (
|
148
|
+
Metanorma::Cli.load_flavors
|
149
|
+
Metanorma::Registry.instance.processors
|
150
|
+
)
|
151
|
+
end
|
152
|
+
|
127
153
|
def find_backend(type)
|
128
154
|
load_flavours(type)
|
129
155
|
Metanorma::Registry.instance.find_processor(type&.to_sym)
|
@@ -160,6 +186,18 @@ module Metanorma
|
|
160
186
|
require "metanorma-#{type}"
|
161
187
|
end
|
162
188
|
end
|
189
|
+
|
190
|
+
def print_doctypes_table(processors)
|
191
|
+
table_data = processors.map do |type_sym, processor|
|
192
|
+
[
|
193
|
+
type_sym.to_s,
|
194
|
+
processor.input_format,
|
195
|
+
join_keys(processor.output_formats.keys),
|
196
|
+
]
|
197
|
+
end
|
198
|
+
|
199
|
+
UI.table(["Type", "Input", "Supported output format"], table_data)
|
200
|
+
end
|
163
201
|
end
|
164
202
|
end
|
165
203
|
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 "
|
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
22
|
def generate(source_path)
|
18
|
-
Cli::SiteGenerator.generate(source_path, options
|
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,26 +5,25 @@ 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
|
-
@manifest_file = find_realpath(options.fetch(:config, nil))
|
12
11
|
@asset_folder = options.fetch(:asset_folder, "documents").to_s
|
13
12
|
@collection_name = options.fetch(:collection_name, "documents.xml")
|
14
|
-
|
13
|
+
@manifest_file = find_realpath(options.fetch(:config, default_config))
|
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
|
23
23
|
site_directory = asset_directory.join("..")
|
24
|
+
select_source_files.each { |source| compile(source) }
|
24
25
|
|
25
26
|
Dir.chdir(site_directory) do
|
26
|
-
select_source_files.each { |source| compile(source) }
|
27
|
-
|
28
27
|
build_collection_file(collection_name)
|
29
28
|
convert_to_html_page(collection_name, "index.html")
|
30
29
|
end
|
@@ -41,6 +40,11 @@ module Metanorma
|
|
41
40
|
source_path
|
42
41
|
end
|
43
42
|
|
43
|
+
def default_config
|
44
|
+
default_file = Pathname.new(Dir.pwd).join("metanorma.yml")
|
45
|
+
default_file if File.exist?(default_file)
|
46
|
+
end
|
47
|
+
|
44
48
|
def select_source_files
|
45
49
|
files = source_from_manifest
|
46
50
|
|
@@ -66,9 +70,9 @@ module Metanorma
|
|
66
70
|
def compile(source)
|
67
71
|
UI.info("Compiling #{source} ...")
|
68
72
|
|
69
|
-
|
70
|
-
|
71
|
-
)
|
73
|
+
opts = @compile_options.merge(format: :asciidoc, output_dir: asset_directory)
|
74
|
+
|
75
|
+
Metanorma::Cli::Compiler.compile(source.to_s, opts)
|
72
76
|
end
|
73
77
|
|
74
78
|
def convert_to_html_page(collection, page_name)
|
@@ -97,11 +101,11 @@ module Metanorma
|
|
97
101
|
) || [],
|
98
102
|
|
99
103
|
collection_name: extract_config_data(
|
100
|
-
manifest["
|
104
|
+
manifest["metanorma"]["collection"], "name"
|
101
105
|
),
|
102
106
|
|
103
107
|
collection_organization: extract_config_data(
|
104
|
-
manifest["
|
108
|
+
manifest["metanorma"]["collection"], "organization"
|
105
109
|
),
|
106
110
|
}
|
107
111
|
rescue NoMethodError
|
@@ -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/lib/metanorma/cli/ui.rb
CHANGED
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-25 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
|