metanorma-cli 1.16.9 → 1.16.10
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 +2 -0
- data/lib/metanorma/cli/flavor.rb +43 -33
- data/lib/metanorma/cli/git_template.rb +3 -0
- data/lib/metanorma/cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 826947482a6b6504d9e8b6f0270fbf9c21c7ea4aaf28987fae188a75d9785130
|
|
4
|
+
data.tar.gz: 70cdc4d3ae532c8119586898cc9b2fe2de7ebe47544131ba72b46be26c9efe67
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3566044e7574ecba68e89cde656d0fa1931b970a1898d1d9fe90ce9cf9fbafc1a5d0456f75bafb18392a399ef3c157d599d89f53e4a414c23ec882c3582ea2a3
|
|
7
|
+
data.tar.gz: 8535140d5d93309cf295523b85fe368ad81e8c967ee65d65194232a78f7593748e1018b2b6de4dd5d429238c77ac6b7ba0cdc85b7cc71eb980ffcb6387f98929
|
data/Gemfile
CHANGED
data/lib/metanorma/cli/flavor.rb
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
module Metanorma
|
|
2
2
|
module Cli
|
|
3
3
|
class Command < ThorWithConfig
|
|
4
|
+
DEPENDENCY_GEMS =
|
|
5
|
+
%w(html2doc isodoc metanorma-utils mn2pdf mn-requirements isodoc-i18n
|
|
6
|
+
metanorma-core metanorma-plugin-glossarist metanorma-plugin-lutaml
|
|
7
|
+
metanorma-taste relaton-cli pubid glossarist fontist
|
|
8
|
+
plurimath expressir xmi lutaml-model emf2svg unitsml
|
|
9
|
+
vectory ogc-gml oscal suma).freeze
|
|
10
|
+
|
|
11
|
+
EXPORT_CONFIG_FLAVOR_FILES = [
|
|
12
|
+
"metanorma/*/*.adoc",
|
|
13
|
+
"isodoc/*/html/*",
|
|
14
|
+
"isodoc/*/*.xsl",
|
|
15
|
+
"isodoc/*/*.yml",
|
|
16
|
+
"isodoc/*/*.yaml",
|
|
17
|
+
"relaton/render/*.yml",
|
|
18
|
+
"relaton/render/*.yaml",
|
|
19
|
+
].freeze
|
|
20
|
+
|
|
4
21
|
private
|
|
5
22
|
|
|
6
23
|
def print_doctypes_table(type)
|
|
@@ -104,20 +121,22 @@ module Metanorma
|
|
|
104
121
|
end
|
|
105
122
|
end
|
|
106
123
|
|
|
107
|
-
DEPENDENCY_GEMS =
|
|
108
|
-
%w(html2doc isodoc metanorma-utils mn2pdf mn-requirements isodoc-i18n
|
|
109
|
-
metanorma-core metanorma-plugin-glossarist metanorma-plugin-lutaml
|
|
110
|
-
metanorma-taste relaton-cli pubid glossarist fontist
|
|
111
|
-
plurimath lutaml expressir xmi lutaml-model emf2svg unitsml
|
|
112
|
-
vectory ogc-gml oscal suma).freeze
|
|
113
|
-
|
|
114
124
|
def dependencies_versions
|
|
115
125
|
versions = Gem.loaded_specs
|
|
116
126
|
DEPENDENCY_GEMS.sort.each do |k|
|
|
117
|
-
|
|
127
|
+
spec = versions[k] || installed_gem_spec(k) or next
|
|
128
|
+
UI.say("#{k} #{spec.version}")
|
|
118
129
|
end
|
|
119
130
|
end
|
|
120
131
|
|
|
132
|
+
# gems installed but not loaded by the version command itself
|
|
133
|
+
# (e.g. emf2svg) are still reported, from the installed specs
|
|
134
|
+
def installed_gem_spec(name)
|
|
135
|
+
Gem::Specification.find_by_name(name)
|
|
136
|
+
rescue Gem::LoadError
|
|
137
|
+
nil
|
|
138
|
+
end
|
|
139
|
+
|
|
121
140
|
def join_keys(keys)
|
|
122
141
|
[keys[0..-2].join(", "), keys.last].join(" and ")
|
|
123
142
|
end
|
|
@@ -150,16 +169,6 @@ module Metanorma
|
|
|
150
169
|
abort if errors.any?
|
|
151
170
|
end
|
|
152
171
|
|
|
153
|
-
EXPORT_CONFIG_FLAVOR_FILES = [
|
|
154
|
-
"metanorma/*/*.adoc",
|
|
155
|
-
"isodoc/*/html/*",
|
|
156
|
-
"isodoc/*/*.xsl",
|
|
157
|
-
"isodoc/*/*.yml",
|
|
158
|
-
"isodoc/*/*.yaml",
|
|
159
|
-
"relaton/render/*.yml",
|
|
160
|
-
"relaton/render/*.yaml",
|
|
161
|
-
].freeze
|
|
162
|
-
|
|
163
172
|
def export_config_flavor(type)
|
|
164
173
|
base, taste, dir = export_config_flavor_prep(type)
|
|
165
174
|
base or return
|
|
@@ -192,20 +201,23 @@ module Metanorma
|
|
|
192
201
|
end
|
|
193
202
|
|
|
194
203
|
def export_config_flavor_prep(type)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return
|
|
198
|
-
end
|
|
199
|
-
dict = flavor_dictionary
|
|
200
|
-
unless dict[type.to_sym]
|
|
201
|
-
UI.say("Couldn't load #{type}, please provide a valid type!")
|
|
202
|
-
return [nil, nil, nil]
|
|
203
|
-
end
|
|
204
|
+
dict = type && flavor_dictionary
|
|
205
|
+
(dict && dict[type.to_sym]) or
|
|
206
|
+
return export_config_flavor_invalid(type)
|
|
204
207
|
FileUtils.mkdir_p("export-config-#{type}")
|
|
205
208
|
base = dict[type.to_sym][:base_flavor]
|
|
206
209
|
[base || type, base ? type : nil, "export-config-#{type}"]
|
|
207
210
|
end
|
|
208
211
|
|
|
212
|
+
def export_config_flavor_invalid(type)
|
|
213
|
+
if type
|
|
214
|
+
UI.say("Couldn't load #{type}, please provide a valid type!")
|
|
215
|
+
else
|
|
216
|
+
UI.say("Please specify a standard type")
|
|
217
|
+
end
|
|
218
|
+
[nil, nil, nil]
|
|
219
|
+
end
|
|
220
|
+
|
|
209
221
|
def export_config_flavor_gem(base)
|
|
210
222
|
begin
|
|
211
223
|
gem_spec = Gem::Specification.find_by_name("metanorma-#{base}")
|
|
@@ -221,7 +233,7 @@ module Metanorma
|
|
|
221
233
|
UI.say("No matching configuration files found in metanorma-#{base}")
|
|
222
234
|
else
|
|
223
235
|
UI.say("Exported #{copied_files.size} configuration file(s) " \
|
|
224
|
-
|
|
236
|
+
"from metanorma-#{base} to #{dir}")
|
|
225
237
|
end
|
|
226
238
|
end
|
|
227
239
|
|
|
@@ -249,11 +261,9 @@ module Metanorma
|
|
|
249
261
|
end
|
|
250
262
|
|
|
251
263
|
def export_config_taste_copy_files(source_path, gem_data_path, dest_path)
|
|
252
|
-
copied_files = []
|
|
253
264
|
pattern = source_path.join("**", "*")
|
|
254
|
-
Pathname.glob(pattern).
|
|
255
|
-
|
|
256
|
-
dest_path)
|
|
265
|
+
copied_files = Pathname.glob(pattern).map do |source_file|
|
|
266
|
+
export_config_copy_file(source_file, gem_data_path, dest_path)
|
|
257
267
|
end
|
|
258
268
|
copied_files.compact
|
|
259
269
|
end
|
|
@@ -263,7 +273,7 @@ module Metanorma
|
|
|
263
273
|
UI.say("No files found in metanorma-taste/taste/#{taste}")
|
|
264
274
|
else
|
|
265
275
|
UI.say("Exported #{copied_files.size} taste configuration file(s) " \
|
|
266
|
-
|
|
276
|
+
"from metanorma-taste to #{dest_path}")
|
|
267
277
|
end
|
|
268
278
|
end
|
|
269
279
|
end
|
|
@@ -74,6 +74,9 @@ module Metanorma
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def clone_git_template(repo)
|
|
77
|
+
# git gem >= 5 spawns with a chdir into the target directory, which
|
|
78
|
+
# must already exist; older versions created it implicitly
|
|
79
|
+
templates_path.mkpath
|
|
77
80
|
clone = Git.clone(repo, name, path: templates_path)
|
|
78
81
|
template_path unless clone.nil?
|
|
79
82
|
end
|