app_archetype 1.2.8 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -1
- data/Gemfile.lock +102 -73
- data/README.md +166 -29
- data/app_archetype.gemspec +22 -19
- 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 +4 -3
- data/lib/app_archetype/template/manifest.rb +17 -1
- data/lib/app_archetype/template_manager.rb +13 -6
- data/lib/app_archetype/version.rb +1 -1
- data/lib/app_archetype.rb +40 -23
- data/lib/core_ext/string.rb +18 -12
- 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 +296 -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/manifest_spec.rb +31 -1
- data/spec/app_archetype/template_manager_spec.rb +32 -0
- data/spec/app_archetype_spec.rb +65 -0
- metadata +155 -80
- data/lib/app_archetype/cli/presenters.rb +0 -106
- data/lib/app_archetype/cli/prompts.rb +0 -152
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd7588cabd79d1600fe22d108924c2c63ebee976846daeec841abe7a185273df
|
4
|
+
data.tar.gz: f1be9dbb4d8a13c06c964e463d0af6e928c1603776868b3fc055c6e2ac7bbdae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd50591da0153b4f89193da820dcc471e6aff6e032ca7f9504cb6478dc7abc777ccca2b3da10e59c167d8c28bc25eeeae669c82df13b61f00dd5a617094d6a25
|
7
|
+
data.tar.gz: c5ca9b24aee9cc0238bc3051173585aff37b019fa8f808dae79161342e71dfd519cf4f1edc1cdf7d92e76c79a7691bfb9a07433101249c051b92cba27114f749
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
AllCops:
|
3
|
-
TargetRubyVersion: 2.
|
3
|
+
TargetRubyVersion: 2.6
|
4
4
|
|
5
5
|
Style/FrozenStringLiteralComment:
|
6
6
|
Enabled: false
|
@@ -33,3 +33,9 @@
|
|
33
33
|
|
34
34
|
Style/IfUnlessModifier:
|
35
35
|
Enabled: false
|
36
|
+
|
37
|
+
Style/GlobalStdStream:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Style/OptionalBooleanParameter:
|
41
|
+
Enabled: false
|
data/Gemfile.lock
CHANGED
@@ -1,36 +1,39 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
app_archetype (1.2
|
5
|
-
cli-format
|
6
|
-
|
7
|
-
|
8
|
-
json
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
app_archetype (1.4.2)
|
5
|
+
cli-format
|
6
|
+
hashie
|
7
|
+
highline
|
8
|
+
json
|
9
|
+
json-schema
|
10
|
+
jsonnet
|
11
|
+
logger
|
12
|
+
os
|
13
|
+
ostruct
|
14
|
+
ruby-handlebars
|
15
|
+
thor
|
16
|
+
tty-prompt
|
17
|
+
tty-table
|
15
18
|
|
16
19
|
GEM
|
17
20
|
remote: https://rubygems.org/
|
18
21
|
specs:
|
19
|
-
activesupport (6.1.4)
|
22
|
+
activesupport (6.1.4.4)
|
20
23
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
21
24
|
i18n (>= 1.6, < 2)
|
22
25
|
minitest (>= 5.1)
|
23
26
|
tzinfo (~> 2.0)
|
24
27
|
zeitwerk (~> 2.3)
|
25
|
-
addressable (2.
|
28
|
+
addressable (2.8.0)
|
26
29
|
public_suffix (>= 2.0.2, < 5.0)
|
27
|
-
ast (2.4.
|
30
|
+
ast (2.4.2)
|
28
31
|
axiom-types (0.1.1)
|
29
32
|
descendants_tracker (~> 0.0.4)
|
30
33
|
ice_nine (~> 0.11.0)
|
31
34
|
thread_safe (~> 0.3, >= 0.3.1)
|
32
|
-
bump (0.
|
33
|
-
cli-format (0.2.
|
35
|
+
bump (0.10.0)
|
36
|
+
cli-format (0.2.1)
|
34
37
|
activesupport
|
35
38
|
text-table
|
36
39
|
zeitwerk
|
@@ -40,8 +43,8 @@ GEM
|
|
40
43
|
concurrent-ruby (1.1.9)
|
41
44
|
descendants_tracker (0.0.4)
|
42
45
|
thread_safe (~> 0.3, >= 0.3.1)
|
43
|
-
diff-lcs (1.
|
44
|
-
docile (1.
|
46
|
+
diff-lcs (1.5.0)
|
47
|
+
docile (1.4.0)
|
45
48
|
equalizer (0.0.11)
|
46
49
|
erubis (2.7.0)
|
47
50
|
flay (2.12.1)
|
@@ -53,11 +56,12 @@ GEM
|
|
53
56
|
path_expander (~> 1.0)
|
54
57
|
ruby_parser (~> 3.1, > 3.1.0)
|
55
58
|
sexp_processor (~> 4.8)
|
59
|
+
hashie (5.0.0)
|
56
60
|
highline (2.0.3)
|
57
|
-
i18n (1.
|
61
|
+
i18n (1.9.1)
|
58
62
|
concurrent-ruby (~> 1.0)
|
59
63
|
ice_nine (0.11.2)
|
60
|
-
json (2.
|
64
|
+
json (2.6.1)
|
61
65
|
json-schema (2.8.1)
|
62
66
|
addressable (>= 2.4)
|
63
67
|
jsonnet (0.4.0)
|
@@ -65,64 +69,64 @@ GEM
|
|
65
69
|
kwalify (0.7.2)
|
66
70
|
launchy (2.5.0)
|
67
71
|
addressable (~> 2.7)
|
68
|
-
logger (1.
|
72
|
+
logger (1.5.0)
|
69
73
|
method_source (1.0.0)
|
70
|
-
mini_portile2 (2.
|
71
|
-
minitest (5.
|
72
|
-
os (1.1.
|
73
|
-
ostruct (0.
|
74
|
-
parallel (1.
|
75
|
-
parser (
|
74
|
+
mini_portile2 (2.7.1)
|
75
|
+
minitest (5.15.0)
|
76
|
+
os (1.1.4)
|
77
|
+
ostruct (0.5.3)
|
78
|
+
parallel (1.21.0)
|
79
|
+
parser (3.1.0.0)
|
76
80
|
ast (~> 2.4.1)
|
77
81
|
parslet (1.8.2)
|
82
|
+
pastel (0.8.0)
|
83
|
+
tty-color (~> 0.5)
|
78
84
|
path_expander (1.1.0)
|
79
85
|
private_gem (1.1.4)
|
80
86
|
bundler (> 1.7, < 3.0)
|
81
87
|
thor
|
82
|
-
pry (0.
|
88
|
+
pry (0.14.1)
|
83
89
|
coderay (~> 1.1)
|
84
90
|
method_source (~> 1.0)
|
85
|
-
psych (3.1.0)
|
86
91
|
public_suffix (4.0.6)
|
87
|
-
rainbow (3.
|
88
|
-
rake (13.0.
|
89
|
-
reek (6.0
|
92
|
+
rainbow (3.1.1)
|
93
|
+
rake (13.0.6)
|
94
|
+
reek (6.1.0)
|
90
95
|
kwalify (~> 0.7.0)
|
91
|
-
parser (
|
92
|
-
psych (~> 3.1.0)
|
96
|
+
parser (~> 3.1.0)
|
93
97
|
rainbow (>= 2.0, < 4.0)
|
94
|
-
regexp_parser (
|
95
|
-
rexml (3.2.
|
96
|
-
rspec (3.
|
97
|
-
rspec-core (~> 3.
|
98
|
-
rspec-expectations (~> 3.
|
99
|
-
rspec-mocks (~> 3.
|
100
|
-
rspec-core (3.
|
101
|
-
rspec-support (~> 3.
|
102
|
-
rspec-expectations (3.
|
98
|
+
regexp_parser (2.2.0)
|
99
|
+
rexml (3.2.5)
|
100
|
+
rspec (3.10.0)
|
101
|
+
rspec-core (~> 3.10.0)
|
102
|
+
rspec-expectations (~> 3.10.0)
|
103
|
+
rspec-mocks (~> 3.10.0)
|
104
|
+
rspec-core (3.10.2)
|
105
|
+
rspec-support (~> 3.10.0)
|
106
|
+
rspec-expectations (3.10.2)
|
103
107
|
diff-lcs (>= 1.2.0, < 2.0)
|
104
|
-
rspec-support (~> 3.
|
105
|
-
rspec-mocks (3.
|
108
|
+
rspec-support (~> 3.10.0)
|
109
|
+
rspec-mocks (3.10.3)
|
106
110
|
diff-lcs (>= 1.2.0, < 2.0)
|
107
|
-
rspec-support (~> 3.
|
108
|
-
rspec-support (3.
|
109
|
-
rubocop (
|
111
|
+
rspec-support (~> 3.10.0)
|
112
|
+
rspec-support (3.10.3)
|
113
|
+
rubocop (1.25.1)
|
110
114
|
parallel (~> 1.10)
|
111
|
-
parser (>=
|
115
|
+
parser (>= 3.1.0.0)
|
112
116
|
rainbow (>= 2.2.2, < 4.0)
|
113
|
-
regexp_parser (>= 1.
|
117
|
+
regexp_parser (>= 1.8, < 3.0)
|
114
118
|
rexml
|
115
|
-
rubocop-ast (>=
|
119
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
116
120
|
ruby-progressbar (~> 1.7)
|
117
|
-
unicode-display_width (>= 1.4.0, <
|
118
|
-
rubocop-ast (
|
119
|
-
parser (>=
|
121
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
122
|
+
rubocop-ast (1.15.1)
|
123
|
+
parser (>= 3.0.1.1)
|
120
124
|
ruby-handlebars (0.4.0)
|
121
125
|
parslet (~> 1.6, >= 1.6.2)
|
122
|
-
ruby-progressbar (1.
|
123
|
-
ruby_parser (3.
|
124
|
-
sexp_processor (~> 4.
|
125
|
-
rubycritic (4.
|
126
|
+
ruby-progressbar (1.11.0)
|
127
|
+
ruby_parser (3.18.1)
|
128
|
+
sexp_processor (~> 4.16)
|
129
|
+
rubycritic (4.6.1)
|
126
130
|
flay (~> 2.8)
|
127
131
|
flog (~> 4.4)
|
128
132
|
launchy (>= 2.0.0)
|
@@ -133,40 +137,65 @@ GEM
|
|
133
137
|
simplecov (>= 0.17.0)
|
134
138
|
tty-which (~> 0.4.0)
|
135
139
|
virtus (~> 1.0)
|
136
|
-
sexp_processor (4.
|
137
|
-
simplecov (0.
|
140
|
+
sexp_processor (4.16.0)
|
141
|
+
simplecov (0.21.2)
|
138
142
|
docile (~> 1.1)
|
139
143
|
simplecov-html (~> 0.11)
|
144
|
+
simplecov_json_formatter (~> 0.1)
|
140
145
|
simplecov-html (0.12.3)
|
146
|
+
simplecov_json_formatter (0.1.3)
|
147
|
+
strings (0.2.1)
|
148
|
+
strings-ansi (~> 0.2)
|
149
|
+
unicode-display_width (>= 1.5, < 3.0)
|
150
|
+
unicode_utils (~> 1.4)
|
151
|
+
strings-ansi (0.2.0)
|
141
152
|
text-table (1.2.4)
|
142
|
-
thor (1.
|
153
|
+
thor (1.2.1)
|
143
154
|
thread_safe (0.3.6)
|
155
|
+
tty-color (0.6.0)
|
156
|
+
tty-cursor (0.7.1)
|
157
|
+
tty-prompt (0.23.1)
|
158
|
+
pastel (~> 0.8)
|
159
|
+
tty-reader (~> 0.8)
|
160
|
+
tty-reader (0.9.0)
|
161
|
+
tty-cursor (~> 0.7)
|
162
|
+
tty-screen (~> 0.8)
|
163
|
+
wisper (~> 2.0)
|
164
|
+
tty-screen (0.8.1)
|
165
|
+
tty-table (0.12.0)
|
166
|
+
pastel (~> 0.8)
|
167
|
+
strings (~> 0.2.0)
|
168
|
+
tty-screen (~> 0.8)
|
144
169
|
tty-which (0.4.2)
|
145
170
|
tzinfo (2.0.4)
|
146
171
|
concurrent-ruby (~> 1.0)
|
147
|
-
unicode-display_width (1.
|
172
|
+
unicode-display_width (2.1.0)
|
173
|
+
unicode_utils (1.4.0)
|
148
174
|
virtus (1.0.5)
|
149
175
|
axiom-types (~> 0.1)
|
150
176
|
coercible (~> 1.0)
|
151
177
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
152
178
|
equalizer (~> 0.0, >= 0.0.9)
|
153
|
-
|
154
|
-
|
179
|
+
webrick (1.7.0)
|
180
|
+
wisper (2.0.1)
|
181
|
+
yard (0.9.27)
|
182
|
+
webrick (~> 1.7.0)
|
183
|
+
zeitwerk (2.5.4)
|
155
184
|
|
156
185
|
PLATFORMS
|
157
186
|
ruby
|
158
187
|
|
159
188
|
DEPENDENCIES
|
160
189
|
app_archetype!
|
161
|
-
bump
|
162
|
-
private_gem
|
163
|
-
pry
|
164
|
-
rake
|
165
|
-
rspec
|
166
|
-
rubocop
|
167
|
-
rubycritic
|
168
|
-
simplecov
|
169
|
-
yard
|
190
|
+
bump
|
191
|
+
private_gem
|
192
|
+
pry
|
193
|
+
rake
|
194
|
+
rspec
|
195
|
+
rubocop
|
196
|
+
rubycritic
|
197
|
+
simplecov
|
198
|
+
yard
|
170
199
|
|
171
200
|
BUNDLED WITH
|
172
201
|
2.2.15
|
data/README.md
CHANGED
@@ -14,7 +14,9 @@ gem install app_archetype
|
|
14
14
|
|
15
15
|
For inclusion in another script or application, add this line to your application's Gemfile:
|
16
16
|
|
17
|
-
|
17
|
+
```ruby
|
18
|
+
gem 'app_archetype'
|
19
|
+
```
|
18
20
|
|
19
21
|
## Getting Started
|
20
22
|
|
@@ -44,42 +46,81 @@ echo 'export ARCHETYPE_EDITOR="vi"' >> $HOME/.zshrc # sets vim as default editor
|
|
44
46
|
echo 'export ARCHETYPE_EDITOR="vi"' >> $HOME/.bashrc # sets vim as default editor
|
45
47
|
```
|
46
48
|
|
47
|
-
|
49
|
+
### Use in another project/script (standalone)
|
48
50
|
|
49
|
-
|
51
|
+
An alternative method of usage is to create standalone ruby scripts for standalone exection (outside of the `ARCHETYPE_TEMPLATE_DIR`). As an example, the following describes a code component renderer, where a command class for a simple CLI application can be rendered automatically.
|
50
52
|
|
51
|
-
|
53
|
+
For this example you may wish to introduce a `scripts` folder to a project:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
mkdir path/to/my_project/scripts
|
57
|
+
```
|
58
|
+
|
59
|
+
And under that make an archetypes template directory:
|
52
60
|
|
53
61
|
```text
|
54
|
-
-
|
55
|
-
| -
|
56
|
-
| - | -
|
57
|
-
| - | - | -
|
58
|
-
| - | - | -
|
59
|
-
| - | -
|
62
|
+
- 📁 path/to/my_project/scripts
|
63
|
+
| - 📁 generators/
|
64
|
+
| - | - 📁 command/
|
65
|
+
| - | - | - 📁 template/
|
66
|
+
| - | - | - | - 📁 lib/
|
67
|
+
| - | - | - | - | 📁 app_archetype/
|
68
|
+
| - | - | - | - | - | 📁 commands/
|
69
|
+
| - | - | - | - | - | - | 📄 {{command_name.snake_case}}.rb.hbs
|
70
|
+
| - | - | - 📄 manifest.json
|
71
|
+
| - | 📄 create_new_command
|
60
72
|
```
|
61
73
|
|
62
|
-
|
74
|
+
A standalone generator can be written using the standalone render method exposed in the `AppArchetype` namespace. The following would be the content of the `create_new_command` script.
|
63
75
|
|
64
|
-
|
76
|
+
```ruby
|
77
|
+
#!/usr/bin/env ruby
|
65
78
|
|
66
|
-
|
67
|
-
archetype new ruby/gem # creates a template at $ARCHETYPE_TEMPLATE_DIR/ruby/gem
|
79
|
+
require 'app_archetype'
|
68
80
|
|
69
|
-
|
81
|
+
puts 'CREATE NEW COMMAND'
|
70
82
|
|
71
|
-
|
83
|
+
manifest = AppArchetype.render_template(
|
84
|
+
collection_dir: File.join(__dir__, 'generators'),
|
85
|
+
template_name: 'command',
|
86
|
+
destination_path: File.expand_path(File.join(__dir__, '..'))
|
87
|
+
)
|
72
88
|
|
73
|
-
|
89
|
+
puts <<~NEXT_STEPS
|
90
|
+
✔ Command created
|
74
91
|
|
75
|
-
|
92
|
+
TODO:
|
93
|
+
NEXT_STEPS
|
76
94
|
|
77
|
-
|
95
|
+
manifest.next_steps.each do |step|
|
96
|
+
puts step
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
100
|
+
## Usage
|
101
|
+
|
102
|
+
### Creating a template
|
103
|
+
|
104
|
+
Templates are a collection of files in the template folder with a manifest. The structure is thus:
|
105
|
+
|
106
|
+
```text
|
107
|
+
- 📁 $ARCHETYPE_TEMPLATE_DIR
|
108
|
+
| - 📁 my_template
|
109
|
+
| - | - 📁 template/
|
110
|
+
| - | - | - 📄 file.erb
|
111
|
+
| - | - | - 📄 file2.txt
|
112
|
+
| - | - 📄 manifest.json
|
113
|
+
```
|
114
|
+
|
115
|
+
To create a blank template like the one above in the `ARCHETYPE_TEMPLATE_DIR` run:
|
116
|
+
|
117
|
+
```bash
|
118
|
+
archetype new
|
78
119
|
```
|
79
120
|
|
80
121
|
#### Template Manifests
|
81
122
|
|
82
|
-
|
123
|
+
Template manifests describe what should be done with a template at render time. For more detailed documentation on the AppArchetype manifest schema see [https://docs.biggerconcept.com/app_archetype/templates/manifest/](https://docs.biggerconcept.com/app_archetype/templates/manifest/) for more detail, however as a brief overview, a manifest has a name, version and set of variables. A sample manifest looks like this:
|
83
124
|
|
84
125
|
```json
|
85
126
|
{
|
@@ -95,7 +136,11 @@ A manifest has a name, version and set of variables. A sample manifest looks lik
|
|
95
136
|
"type": "string",
|
96
137
|
"default": "bar"
|
97
138
|
}
|
98
|
-
}
|
139
|
+
},
|
140
|
+
"next_steps": [
|
141
|
+
"TODO:",
|
142
|
+
"Restart your machine"
|
143
|
+
]
|
99
144
|
}
|
100
145
|
```
|
101
146
|
|
@@ -103,6 +148,7 @@ A manifest has a name, version and set of variables. A sample manifest looks lik
|
|
103
148
|
- `version` should be the version of the template
|
104
149
|
- `metadata.app_archetype` is information about the manifest for the app archetype gem. `metadata.app_archetype.version` is required, and must be less than the version of the currently installed gem.
|
105
150
|
- `variables` is an object of variable descriptions
|
151
|
+
- `next_steps` is an array of human readable instructions on what to do after the manifest has been applied
|
106
152
|
|
107
153
|
#### Variable Descriptions
|
108
154
|
|
@@ -133,34 +179,125 @@ If plain ol' JSON isn't quite enough for you - manifests can also be expressed i
|
|
133
179
|
|
134
180
|
See [https://jsonnet.org/](https://jsonnet.org/) for more jsonnet documentation
|
135
181
|
|
136
|
-
#### Template
|
182
|
+
#### Template Folder
|
137
183
|
|
138
184
|
Templates are a collection of files within a folder. You may put any files you want in side the `/template` directory and when it comes time to use the template.
|
139
185
|
|
140
|
-
ERB templates or handlebar templates will be rendered using the variables specified in the manifest.json. Anything that's not ERB or HBS will be copied across to the destination as is.
|
186
|
+
ERB templates or handlebar templates (HBS) will be rendered using the variables specified in the manifest.json. Anything that's not ERB or HBS will be copied across to the destination as is.
|
187
|
+
|
188
|
+
You can include handlebars in file names, and like template files, the variables will be used to render the filenames. See [https://docs.biggerconcept.com/app_archetype/templates/folder/](https://docs.biggerconcept.com/app_archetype/templates/folder/) for more detailed information about template folders.
|
189
|
+
|
190
|
+
#### Variable Supporting Functions
|
191
|
+
|
192
|
+
AppArchetype exposes functions to either further parse the value of a variable or generate data as a value of a variable. The use cases are subtly different, but can be described in the following groups:
|
141
193
|
|
142
|
-
|
194
|
+
- [Generator Functions](https://docs.biggerconcept.com/app_archetype/templates/functions/generators/) useful for generating data for use within filenames and template files
|
195
|
+
- [Helper Functions](https://docs.biggerconcept.com/app_archetype/templates/functions/helpers/) useful for parsing values provided for variables.
|
196
|
+
|
197
|
+
See the supporting documentation for more specifid information about supporting functions.
|
198
|
+
|
199
|
+
### Using the CLI
|
200
|
+
|
201
|
+
When setup with a template directory and when installed into the system, app archetype has the following commands:
|
202
|
+
|
203
|
+
- `render` - Renders a template to the current location
|
204
|
+
- `list` - Prints a list of known templates to STDOUT
|
205
|
+
- `find` - Searches for a template by name
|
206
|
+
- `open` - Opens manifest of template in `ARCHETYPE_EDITOR` process
|
207
|
+
- `new` - Creates a new blank template in `ARCHETYPE_TEMPLATE_DIR`
|
208
|
+
- `delete` - Deletes template and manifest from `ARCHETYPE_TEMPLATE_DIR`
|
209
|
+
- `variables` - Prints list of known variables from a manifest
|
210
|
+
- `path` - Prints path to `ARCHETYPE_TEMPLATE_DIR` to STDOUT
|
211
|
+
- `version` - Prints gem version to STDOUT
|
212
|
+
- `help` - Provides help on any of the above commands
|
213
|
+
|
214
|
+
You will find detailed usage instructions of all commands here: [https://docs.biggerconcept.com/app_archetype/commands/](https://docs.biggerconcept.com/app_archetype/commands/)
|
143
215
|
|
144
216
|
### Rendering a Template
|
145
217
|
|
146
|
-
|
218
|
+
The [`archetype render`](https://docs.biggerconcept.com/app_archetype/commands/render/) command will render a template from the `ARCHETYPE_TEMPLATE_DIR` to the current CLI location.
|
219
|
+
|
220
|
+
It supports an optional `--name` parameter that refers to the name of the template to render, when this is not provided, the tool will present a list of known templates.
|
221
|
+
|
222
|
+
To use:
|
147
223
|
|
148
224
|
```bash
|
149
225
|
mkdir where_id_like_to_render
|
150
226
|
cd where_id_like_to_render
|
151
|
-
archetype render my_template
|
227
|
+
archetype render --name my_template
|
152
228
|
```
|
153
229
|
|
154
|
-
And the template will be rendered with the instructions in the manifest to the destinaton location as simple as that.
|
155
|
-
|
156
230
|
### Listing Templates
|
157
231
|
|
158
|
-
You can list the templates in your template directory at any time by running the list command:
|
232
|
+
You can list the templates in your template directory at any time by running the [`archetype list`](https://docs.biggerconcept.com/app_archetype/commands/list/) command:
|
159
233
|
|
160
234
|
```bash
|
161
235
|
archetype list
|
162
236
|
```
|
163
237
|
|
238
|
+
You will see a summary of known templates similar to this:
|
239
|
+
|
240
|
+
```text
|
241
|
+
NAME VERSION
|
242
|
+
go_module 2.0.1
|
243
|
+
bash_script 1.0.0
|
244
|
+
ruby_cli_gem 1.0.0
|
245
|
+
```
|
246
|
+
|
247
|
+
### Finding Templates
|
248
|
+
|
249
|
+
You can search known templates in your template directory using the [`archetype find`](https://docs.biggerconcept.com/app_archetype/commands/find/) command:
|
250
|
+
|
251
|
+
```bash
|
252
|
+
archetype find --name bash
|
253
|
+
```
|
254
|
+
|
255
|
+
You will be presented with a list of templates that include the given name:
|
256
|
+
|
257
|
+
```text
|
258
|
+
NAME VERSION
|
259
|
+
bash_script 1.0.0
|
260
|
+
```
|
261
|
+
|
262
|
+
### Opening Template Manifest
|
263
|
+
|
264
|
+
If you have your `ARCHETYPE_EDITOR` variable set in your environment. You can use the [`archetype open`](https://docs.biggerconcept.com/app_archetype/commands/open/) command to open the manifest in a new editor process (for example `vi`).
|
265
|
+
|
266
|
+
Similar to the `archetype find` command, you may provide a name option to choose the manifest:
|
267
|
+
|
268
|
+
```bash
|
269
|
+
archetype open --name bash_script
|
270
|
+
```
|
271
|
+
|
272
|
+
### Creating a new Template
|
273
|
+
|
274
|
+
The [`archetype new`](https://docs.biggerconcept.com/app_archetype/commands/new/) renders a new blank template into the `ARCHETYPE_TEMPLATE_DIR` location.
|
275
|
+
|
276
|
+
Simply run:
|
277
|
+
|
278
|
+
```bash
|
279
|
+
archetype new
|
280
|
+
```
|
281
|
+
|
282
|
+
And follow the prompts.
|
283
|
+
|
284
|
+
### Deleting an existing template
|
285
|
+
|
286
|
+
You can delete a template manifest and its files by running the [`archetype delete`](https://docs.biggerconcept.com/app_archetype/commands/delete/) command.
|
287
|
+
|
288
|
+
```bash
|
289
|
+
archetype delete --name bash_script
|
290
|
+
```
|
291
|
+
|
292
|
+
### Help and configuration
|
293
|
+
|
294
|
+
The Gem provides 2 commands to inspect its config. They are:
|
295
|
+
|
296
|
+
- [`archetype path`](https://docs.biggerconcept.com/app_archetype/commands/path/) which displays the currently configured `ARCHETYPE_TEMPLATE_DIR`
|
297
|
+
- [`archetype version`](https://docs.biggerconcept.com/app_archetype/commands/version/) which displays the current installed gem version
|
298
|
+
|
299
|
+
Additionally the [`archetype help`](https://docs.biggerconcept.com/app_archetype/commands/help/) provides more detailed usage information about all of the above mentioned commands.
|
300
|
+
|
164
301
|
## Contributing
|
165
302
|
|
166
303
|
See CONTRIBUTING.md for more information
|
data/app_archetype.gemspec
CHANGED
@@ -16,24 +16,27 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ['lib']
|
18
18
|
|
19
|
-
spec.add_dependency 'cli-format'
|
20
|
-
spec.add_dependency '
|
21
|
-
spec.add_dependency '
|
22
|
-
spec.add_dependency '
|
23
|
-
spec.add_dependency '
|
24
|
-
spec.add_dependency '
|
25
|
-
spec.add_dependency '
|
26
|
-
spec.add_dependency '
|
27
|
-
spec.add_dependency '
|
28
|
-
spec.add_dependency '
|
19
|
+
spec.add_dependency 'cli-format'
|
20
|
+
spec.add_dependency 'hashie'
|
21
|
+
spec.add_dependency 'highline'
|
22
|
+
spec.add_dependency 'json'
|
23
|
+
spec.add_dependency 'jsonnet'
|
24
|
+
spec.add_dependency 'json-schema'
|
25
|
+
spec.add_dependency 'logger'
|
26
|
+
spec.add_dependency 'os'
|
27
|
+
spec.add_dependency 'ostruct'
|
28
|
+
spec.add_dependency 'ruby-handlebars'
|
29
|
+
spec.add_dependency 'thor'
|
30
|
+
spec.add_dependency 'tty-prompt'
|
31
|
+
spec.add_dependency 'tty-table'
|
29
32
|
|
30
|
-
spec.add_development_dependency 'bump'
|
31
|
-
spec.add_development_dependency 'private_gem'
|
32
|
-
spec.add_development_dependency 'pry'
|
33
|
-
spec.add_development_dependency 'rake'
|
34
|
-
spec.add_development_dependency 'rspec'
|
35
|
-
spec.add_development_dependency 'rubocop'
|
36
|
-
spec.add_development_dependency 'rubycritic'
|
37
|
-
spec.add_development_dependency 'simplecov'
|
38
|
-
spec.add_development_dependency 'yard'
|
33
|
+
spec.add_development_dependency 'bump'
|
34
|
+
spec.add_development_dependency 'private_gem'
|
35
|
+
spec.add_development_dependency 'pry'
|
36
|
+
spec.add_development_dependency 'rake'
|
37
|
+
spec.add_development_dependency 'rspec'
|
38
|
+
spec.add_development_dependency 'rubocop'
|
39
|
+
spec.add_development_dependency 'rubycritic'
|
40
|
+
spec.add_development_dependency 'simplecov'
|
41
|
+
spec.add_development_dependency 'yard'
|
39
42
|
end
|
data/bin/app_archetype
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib_path = File.expand_path('../lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
|
5
|
+
|
6
|
+
require 'pry'
|
7
|
+
require 'app_archetype/cli'
|
8
|
+
|
9
|
+
Signal.trap('INT') do
|
10
|
+
warn("\n#{caller.join("\n")}: interrupted")
|
11
|
+
exit(1)
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
AppArchetype::CLI.start
|
16
|
+
rescue StandardError => e
|
17
|
+
puts "✖ ERROR: #{e.message}"
|
18
|
+
puts e.backtrace.join("\n")
|
19
|
+
exit 1
|
20
|
+
end
|