app_archetype 1.2.8 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +36 -9
- data/README.md +150 -28
- data/app_archetype.gemspec +3 -0
- data/bin/app_archetype +20 -0
- data/bin/archetype +1 -1
- data/lib/app_archetype/cli.rb +171 -139
- data/lib/app_archetype/commands/delete_template.rb +58 -0
- data/lib/app_archetype/commands/find_templates.rb +66 -0
- data/lib/app_archetype/commands/list_templates.rb +49 -0
- data/lib/app_archetype/commands/new_template.rb +42 -0
- data/lib/app_archetype/commands/open_manifest.rb +48 -0
- data/lib/app_archetype/commands/print_path.rb +20 -0
- data/lib/app_archetype/commands/print_template_variables.rb +67 -0
- data/lib/app_archetype/commands/print_version.rb +19 -0
- data/lib/app_archetype/commands/render_template.rb +178 -0
- data/lib/app_archetype/commands.rb +13 -0
- data/lib/app_archetype/generators.rb +1 -1
- data/lib/app_archetype/template_manager.rb +9 -0
- data/lib/app_archetype/version.rb +1 -1
- data/lib/app_archetype.rb +40 -23
- data/scripts/create_new_command +32 -0
- data/scripts/generators/command/manifest.json +15 -0
- data/scripts/generators/command/template/lib/app_archetype/commands/{{command_name.snake_case}}.rb.hbs +17 -0
- data/spec/app_archetype/cli/presenters_spec.rb +99 -99
- data/spec/app_archetype/cli/prompts_spec.rb +291 -291
- data/spec/app_archetype/cli_spec.rb +427 -65
- data/spec/app_archetype/commands/delete_template_spec.rb +132 -0
- data/spec/app_archetype/commands/find_templates_spec.rb +130 -0
- data/spec/app_archetype/commands/list_templates_spec.rb +55 -0
- data/spec/app_archetype/commands/new_template_spec.rb +84 -0
- data/spec/app_archetype/commands/open_manifest_spec.rb +113 -0
- data/spec/app_archetype/commands/print_path_spec.rb +22 -0
- data/spec/app_archetype/commands/print_template_variables_spec.rb +158 -0
- data/spec/app_archetype/commands/print_version_spec.rb +21 -0
- data/spec/app_archetype/commands/render_template_spec.rb +479 -0
- data/spec/app_archetype/generators_spec.rb +1 -1
- data/spec/app_archetype/template_manager_spec.rb +32 -0
- data/spec/app_archetype_spec.rb +65 -0
- metadata +79 -4
- data/lib/app_archetype/cli/presenters.rb +0 -106
- data/lib/app_archetype/cli/prompts.rb +0 -152
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_archetype
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Bigger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07
|
11
|
+
date: 2021-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cli-format
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashie
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: highline
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +164,34 @@ dependencies:
|
|
150
164
|
- - "~>"
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '1.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: tty-prompt
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.23.1
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 0.23.1
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: tty-table
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 0.12.0
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 0.12.0
|
153
195
|
- !ruby/object:Gem::Dependency
|
154
196
|
name: bump
|
155
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -280,6 +322,7 @@ description:
|
|
280
322
|
email:
|
281
323
|
- andrew.bigger@gmail.com
|
282
324
|
executables:
|
325
|
+
- app_archetype
|
283
326
|
- archetype
|
284
327
|
extensions: []
|
285
328
|
extra_rdoc_files: []
|
@@ -296,11 +339,20 @@ files:
|
|
296
339
|
- README.md
|
297
340
|
- Rakefile
|
298
341
|
- app_archetype.gemspec
|
342
|
+
- bin/app_archetype
|
299
343
|
- bin/archetype
|
300
344
|
- lib/app_archetype.rb
|
301
345
|
- lib/app_archetype/cli.rb
|
302
|
-
- lib/app_archetype/
|
303
|
-
- lib/app_archetype/
|
346
|
+
- lib/app_archetype/commands.rb
|
347
|
+
- lib/app_archetype/commands/delete_template.rb
|
348
|
+
- lib/app_archetype/commands/find_templates.rb
|
349
|
+
- lib/app_archetype/commands/list_templates.rb
|
350
|
+
- lib/app_archetype/commands/new_template.rb
|
351
|
+
- lib/app_archetype/commands/open_manifest.rb
|
352
|
+
- lib/app_archetype/commands/print_path.rb
|
353
|
+
- lib/app_archetype/commands/print_template_variables.rb
|
354
|
+
- lib/app_archetype/commands/print_version.rb
|
355
|
+
- lib/app_archetype/commands/render_template.rb
|
304
356
|
- lib/app_archetype/generators.rb
|
305
357
|
- lib/app_archetype/logger.rb
|
306
358
|
- lib/app_archetype/renderer.rb
|
@@ -314,9 +366,21 @@ files:
|
|
314
366
|
- lib/app_archetype/template_manager.rb
|
315
367
|
- lib/app_archetype/version.rb
|
316
368
|
- lib/core_ext/string.rb
|
369
|
+
- scripts/create_new_command
|
370
|
+
- scripts/generators/command/manifest.json
|
371
|
+
- scripts/generators/command/template/lib/app_archetype/commands/{{command_name.snake_case}}.rb.hbs
|
317
372
|
- spec/app_archetype/cli/presenters_spec.rb
|
318
373
|
- spec/app_archetype/cli/prompts_spec.rb
|
319
374
|
- spec/app_archetype/cli_spec.rb
|
375
|
+
- spec/app_archetype/commands/delete_template_spec.rb
|
376
|
+
- spec/app_archetype/commands/find_templates_spec.rb
|
377
|
+
- spec/app_archetype/commands/list_templates_spec.rb
|
378
|
+
- spec/app_archetype/commands/new_template_spec.rb
|
379
|
+
- spec/app_archetype/commands/open_manifest_spec.rb
|
380
|
+
- spec/app_archetype/commands/print_path_spec.rb
|
381
|
+
- spec/app_archetype/commands/print_template_variables_spec.rb
|
382
|
+
- spec/app_archetype/commands/print_version_spec.rb
|
383
|
+
- spec/app_archetype/commands/render_template_spec.rb
|
320
384
|
- spec/app_archetype/generators_spec.rb
|
321
385
|
- spec/app_archetype/logger_spec.rb
|
322
386
|
- spec/app_archetype/renderer_spec.rb
|
@@ -327,6 +391,7 @@ files:
|
|
327
391
|
- spec/app_archetype/template/variable_manager_spec.rb
|
328
392
|
- spec/app_archetype/template/variable_spec.rb
|
329
393
|
- spec/app_archetype/template_manager_spec.rb
|
394
|
+
- spec/app_archetype_spec.rb
|
330
395
|
- spec/core_ext/string_spec.rb
|
331
396
|
- spec/spec_helper.rb
|
332
397
|
homepage: https://github.com/andrewbigger/app_archetype
|
@@ -356,6 +421,15 @@ test_files:
|
|
356
421
|
- spec/app_archetype/cli/presenters_spec.rb
|
357
422
|
- spec/app_archetype/cli/prompts_spec.rb
|
358
423
|
- spec/app_archetype/cli_spec.rb
|
424
|
+
- spec/app_archetype/commands/delete_template_spec.rb
|
425
|
+
- spec/app_archetype/commands/find_templates_spec.rb
|
426
|
+
- spec/app_archetype/commands/list_templates_spec.rb
|
427
|
+
- spec/app_archetype/commands/new_template_spec.rb
|
428
|
+
- spec/app_archetype/commands/open_manifest_spec.rb
|
429
|
+
- spec/app_archetype/commands/print_path_spec.rb
|
430
|
+
- spec/app_archetype/commands/print_template_variables_spec.rb
|
431
|
+
- spec/app_archetype/commands/print_version_spec.rb
|
432
|
+
- spec/app_archetype/commands/render_template_spec.rb
|
359
433
|
- spec/app_archetype/generators_spec.rb
|
360
434
|
- spec/app_archetype/logger_spec.rb
|
361
435
|
- spec/app_archetype/renderer_spec.rb
|
@@ -366,5 +440,6 @@ test_files:
|
|
366
440
|
- spec/app_archetype/template/variable_manager_spec.rb
|
367
441
|
- spec/app_archetype/template/variable_spec.rb
|
368
442
|
- spec/app_archetype/template_manager_spec.rb
|
443
|
+
- spec/app_archetype_spec.rb
|
369
444
|
- spec/core_ext/string_spec.rb
|
370
445
|
- spec/spec_helper.rb
|
@@ -1,106 +0,0 @@
|
|
1
|
-
require 'cli-format'
|
2
|
-
|
3
|
-
module AppArchetype
|
4
|
-
class CLI < ::Thor
|
5
|
-
# CLI output presenters
|
6
|
-
module Presenters
|
7
|
-
##
|
8
|
-
# Output table header
|
9
|
-
#
|
10
|
-
RESULT_HEADER = %w[NAME VERSION].freeze
|
11
|
-
|
12
|
-
##
|
13
|
-
# Variable table header
|
14
|
-
#
|
15
|
-
VARIABLE_HEADER = %w[NAME DESCRIPTION DEFAULT].freeze
|
16
|
-
|
17
|
-
##
|
18
|
-
# Validation result table header
|
19
|
-
#
|
20
|
-
VALIDATION_HEADER = %w[ERROR].freeze
|
21
|
-
|
22
|
-
class <<self
|
23
|
-
##
|
24
|
-
# Creates a presenter for given data
|
25
|
-
#
|
26
|
-
# Accepts header row data and has configurable format.
|
27
|
-
#
|
28
|
-
# Header must be array of string
|
29
|
-
#
|
30
|
-
# Data is array of arrays where the inner array is a row.
|
31
|
-
#
|
32
|
-
# Format by default is a table, although can be 'csv'
|
33
|
-
# or 'json'.
|
34
|
-
#
|
35
|
-
# @param header [Array]
|
36
|
-
# @param data [Array]
|
37
|
-
# @param format [String]
|
38
|
-
#
|
39
|
-
# @return [CliFormat::Presenter]
|
40
|
-
#
|
41
|
-
def table(header: [], data: [], format: 'table')
|
42
|
-
has_header = header.any?
|
43
|
-
opts = { header: has_header, format: format }
|
44
|
-
|
45
|
-
presenter = CliFormat::Presenter.new(opts)
|
46
|
-
presenter.header = header if has_header
|
47
|
-
|
48
|
-
data.each { |row| presenter.rows << row }
|
49
|
-
|
50
|
-
presenter
|
51
|
-
end
|
52
|
-
|
53
|
-
##
|
54
|
-
# Builds a table of manifest information
|
55
|
-
#
|
56
|
-
# @param [Array] manifests
|
57
|
-
#
|
58
|
-
def manifest_list(manifests)
|
59
|
-
table(
|
60
|
-
header: RESULT_HEADER,
|
61
|
-
data: manifests.map do |manifest|
|
62
|
-
[
|
63
|
-
manifest.name,
|
64
|
-
manifest.version
|
65
|
-
]
|
66
|
-
end
|
67
|
-
).show
|
68
|
-
end
|
69
|
-
|
70
|
-
##
|
71
|
-
# Builds a table of variable information
|
72
|
-
#
|
73
|
-
# @param [Array] variables
|
74
|
-
#
|
75
|
-
def variable_list(variables)
|
76
|
-
table(
|
77
|
-
header: VARIABLE_HEADER,
|
78
|
-
data: variables.map do |variable|
|
79
|
-
[
|
80
|
-
variable.name,
|
81
|
-
variable.description,
|
82
|
-
variable.default
|
83
|
-
]
|
84
|
-
end
|
85
|
-
).show
|
86
|
-
end
|
87
|
-
|
88
|
-
##
|
89
|
-
# Builds a table for manifest validation results
|
90
|
-
#
|
91
|
-
# @param [Array] results
|
92
|
-
#
|
93
|
-
def validation_result(results)
|
94
|
-
table(
|
95
|
-
header: VALIDATION_HEADER,
|
96
|
-
data: results.map do |result|
|
97
|
-
[
|
98
|
-
result
|
99
|
-
]
|
100
|
-
end
|
101
|
-
).show
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
@@ -1,152 +0,0 @@
|
|
1
|
-
require 'highline'
|
2
|
-
|
3
|
-
module AppArchetype
|
4
|
-
class CLI < ::Thor
|
5
|
-
# CLI output presenters
|
6
|
-
module Prompts
|
7
|
-
##
|
8
|
-
# Variable prompt question. Asked when evaluating template
|
9
|
-
# variables
|
10
|
-
#
|
11
|
-
# @param [AppArchetype::Template::Variable] variable
|
12
|
-
#
|
13
|
-
# @return [Proc]
|
14
|
-
#
|
15
|
-
VAR_PROMPT_MESSAGE = lambda do |variable|
|
16
|
-
"\nEnter value for `#{variable.name}` variable\n\n"\
|
17
|
-
"DESCRIPTION: #{variable.description}\n"\
|
18
|
-
"TYPE: #{variable.type}\n"\
|
19
|
-
"DEFAULT: #{variable.default}"
|
20
|
-
end
|
21
|
-
|
22
|
-
class <<self
|
23
|
-
##
|
24
|
-
# Prompt returns a TTY prompt object for asking the user
|
25
|
-
# questions.
|
26
|
-
#
|
27
|
-
# @return [HighLine]
|
28
|
-
def prompt
|
29
|
-
HighLine.new
|
30
|
-
end
|
31
|
-
|
32
|
-
##
|
33
|
-
# A yes/no prompt for asking the user a yes or no question.
|
34
|
-
#
|
35
|
-
# @return [Boolean]
|
36
|
-
#
|
37
|
-
def yes?(message)
|
38
|
-
prompt.ask("#{message} [Y/n]", String) { |input| input.strip == 'Y' }
|
39
|
-
end
|
40
|
-
|
41
|
-
##
|
42
|
-
# Prompt for requesting user input.
|
43
|
-
#
|
44
|
-
# A default can be provided in the event the user does not
|
45
|
-
# provide an answer.
|
46
|
-
#
|
47
|
-
# Validator also performs type conversion by default it is
|
48
|
-
# a string
|
49
|
-
#
|
50
|
-
# @param message [String]
|
51
|
-
# @param default [Object]
|
52
|
-
# @param validator [Object|Lambda]
|
53
|
-
#
|
54
|
-
# @return [Object]
|
55
|
-
#
|
56
|
-
def ask(message, validator: String, default: nil)
|
57
|
-
resp = prompt.ask(message, validator)
|
58
|
-
return default if !default.nil? && resp.to_s.empty?
|
59
|
-
|
60
|
-
resp
|
61
|
-
end
|
62
|
-
|
63
|
-
##
|
64
|
-
# Y/N prompt to ensure user is sure they wish to delete
|
65
|
-
# the selected template
|
66
|
-
#
|
67
|
-
# @param [AppArchetype::Template::Manifest] manifest
|
68
|
-
#
|
69
|
-
# @return [Boolean]
|
70
|
-
def delete_template(manifest)
|
71
|
-
yes?(
|
72
|
-
"Are you sure you want to delete `#{manifest.name}`?"
|
73
|
-
)
|
74
|
-
end
|
75
|
-
|
76
|
-
##
|
77
|
-
# Returns a variable prompt based on the type of variable
|
78
|
-
# required. Once prompt has been executed, the response is
|
79
|
-
# returned to the caller.
|
80
|
-
#
|
81
|
-
# When the value is set in the manifest, the set value is
|
82
|
-
# returned without a prompt.
|
83
|
-
#
|
84
|
-
# For boolean and integer variables, the relevant prompt
|
85
|
-
# function is called.
|
86
|
-
#
|
87
|
-
# By default the string variable prompt will be used.
|
88
|
-
#
|
89
|
-
# @param [AppArchetype::Template::Variable] var
|
90
|
-
#
|
91
|
-
# @return [Object]
|
92
|
-
#
|
93
|
-
def variable_prompt_for(var)
|
94
|
-
return var.value if var.value?
|
95
|
-
return boolean_variable_prompt(var) if var.type == 'boolean'
|
96
|
-
return integer_variable_prompt(var) if var.type == 'integer'
|
97
|
-
|
98
|
-
string_variable_prompt(var)
|
99
|
-
end
|
100
|
-
|
101
|
-
##
|
102
|
-
# Prompt for boolean variable. This quizzes the user as to
|
103
|
-
# whether they want the variable set or not. The response
|
104
|
-
# is returned to the caller.
|
105
|
-
#
|
106
|
-
# @param [AppArchetype::Template::Variable] variable
|
107
|
-
#
|
108
|
-
# @return [Boolean]
|
109
|
-
#
|
110
|
-
def boolean_variable_prompt(variable)
|
111
|
-
yes?(
|
112
|
-
VAR_PROMPT_MESSAGE.call(variable)
|
113
|
-
)
|
114
|
-
end
|
115
|
-
|
116
|
-
##
|
117
|
-
# Prompt for integer. This quizzes the user for their
|
118
|
-
# choice and then attempts to convert it to an integer.
|
119
|
-
#
|
120
|
-
# In the event a non integer value is entered, a
|
121
|
-
# RuntimeError is thrown.
|
122
|
-
#
|
123
|
-
# @param [AppArchetype::Template::Variable] variable
|
124
|
-
#
|
125
|
-
# @return [Integer]
|
126
|
-
#
|
127
|
-
def integer_variable_prompt(variable)
|
128
|
-
ask(
|
129
|
-
VAR_PROMPT_MESSAGE.call(variable),
|
130
|
-
default: variable.default,
|
131
|
-
validator: Integer
|
132
|
-
)
|
133
|
-
end
|
134
|
-
|
135
|
-
##
|
136
|
-
# Prompt for a string. Asks user for input and returns
|
137
|
-
# it.
|
138
|
-
#
|
139
|
-
# @param [AppArchetype::Template::Variable] variable
|
140
|
-
#
|
141
|
-
# @return [String]
|
142
|
-
#
|
143
|
-
def string_variable_prompt(variable)
|
144
|
-
ask(
|
145
|
-
VAR_PROMPT_MESSAGE.call(variable),
|
146
|
-
default: variable.default
|
147
|
-
)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|