app_archetype 1.2.7 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -1
  3. data/Gemfile.lock +103 -74
  4. data/README.md +166 -29
  5. data/app_archetype.gemspec +22 -19
  6. data/bin/app_archetype +20 -0
  7. data/bin/archetype +1 -1
  8. data/lib/app_archetype/cli.rb +171 -139
  9. data/lib/app_archetype/commands/delete_template.rb +58 -0
  10. data/lib/app_archetype/commands/find_templates.rb +66 -0
  11. data/lib/app_archetype/commands/list_templates.rb +49 -0
  12. data/lib/app_archetype/commands/new_template.rb +42 -0
  13. data/lib/app_archetype/commands/open_manifest.rb +48 -0
  14. data/lib/app_archetype/commands/print_path.rb +20 -0
  15. data/lib/app_archetype/commands/print_template_variables.rb +67 -0
  16. data/lib/app_archetype/commands/print_version.rb +19 -0
  17. data/lib/app_archetype/commands/render_template.rb +178 -0
  18. data/lib/app_archetype/commands.rb +13 -0
  19. data/lib/app_archetype/generators.rb +4 -3
  20. data/lib/app_archetype/template/manifest.rb +17 -1
  21. data/lib/app_archetype/template_manager.rb +13 -6
  22. data/lib/app_archetype/version.rb +1 -1
  23. data/lib/app_archetype.rb +40 -23
  24. data/scripts/create_new_command +32 -0
  25. data/scripts/generators/command/manifest.json +15 -0
  26. data/scripts/generators/command/template/lib/app_archetype/commands/{{command_name.snake_case}}.rb.hbs +17 -0
  27. data/spec/app_archetype/cli/presenters_spec.rb +99 -99
  28. data/spec/app_archetype/cli/prompts_spec.rb +291 -291
  29. data/spec/app_archetype/cli_spec.rb +296 -65
  30. data/spec/app_archetype/commands/delete_template_spec.rb +132 -0
  31. data/spec/app_archetype/commands/find_templates_spec.rb +130 -0
  32. data/spec/app_archetype/commands/list_templates_spec.rb +55 -0
  33. data/spec/app_archetype/commands/new_template_spec.rb +84 -0
  34. data/spec/app_archetype/commands/open_manifest_spec.rb +113 -0
  35. data/spec/app_archetype/commands/print_path_spec.rb +22 -0
  36. data/spec/app_archetype/commands/print_template_variables_spec.rb +158 -0
  37. data/spec/app_archetype/commands/print_version_spec.rb +21 -0
  38. data/spec/app_archetype/commands/render_template_spec.rb +479 -0
  39. data/spec/app_archetype/generators_spec.rb +1 -1
  40. data/spec/app_archetype/template/manifest_spec.rb +31 -1
  41. data/spec/app_archetype/template_manager_spec.rb +32 -0
  42. data/spec/app_archetype_spec.rb +65 -0
  43. metadata +155 -80
  44. data/lib/app_archetype/cli/presenters.rb +0 -106
  45. data/lib/app_archetype/cli/prompts.rb +0 -152
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a184068cc296173ae1e20fbee823755d7252f8e81769a84eb74391f1a807833f
4
- data.tar.gz: e55ba3af28733f3bd2bd6fbae199b40096449b8b147d0b5aa256d245bb58b85b
3
+ metadata.gz: d8f0a1666491db66d69457e5f830d57f77faf585cb9a750a0eb08a7497326f20
4
+ data.tar.gz: d714cd05d486cc787c4a256419b1e167297142fc0dfdc768dfe5ece279461548
5
5
  SHA512:
6
- metadata.gz: ac59aafa81c87a4695b747647d4e2d72c9fd81eecd945f7d0df61f7e41a1a6d6ed79d0c59f8a3f7a3251350cf72b4f6068a7a05db889c1041aa8373e3adc7fab
7
- data.tar.gz: 528690c3f93bfcf647ffca0b9f1199a1fd89e4cf8d742b145073b5f814017644f3ef70ca0081e66851c4186354d7946c60836ef3bb631893a303def868642374
6
+ metadata.gz: 6a10f3de3742cd199a96a0598846173df71c7db0260d8a909fd33e064ee445d6679fdab94053806c6f723f3335f1f42bb9c440ddc521470e0ea89f9de1b53105
7
+ data.tar.gz: ddaf7ce312ed066a51a3419a4459c478c0baa8f430789f189578ce96658cf16b3a8677c6c6b5667e874555ee769b9240430eee7000e370181616c62e57f5c2f6
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  AllCops:
3
- TargetRubyVersion: 2.4
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.7)
5
- cli-format (~> 0.2)
6
- highline (~> 2.0)
7
- json (~> 2.3)
8
- json-schema (~> 2.8)
9
- jsonnet (~> 0.3.0)
10
- logger (~> 1.4.2)
11
- os (~> 1.1)
12
- ostruct (~> 0.3)
13
- ruby-handlebars (~> 0.4)
14
- thor (~> 1.0)
4
+ app_archetype (1.4.1)
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.7.0)
28
+ addressable (2.8.0)
26
29
  public_suffix (>= 2.0.2, < 5.0)
27
- ast (2.4.1)
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.9.0)
33
- cli-format (0.2.0)
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.4.4)
44
- docile (1.3.2)
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,76 +56,77 @@ 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.8.10)
61
+ i18n (1.9.1)
58
62
  concurrent-ruby (~> 1.0)
59
63
  ice_nine (0.11.2)
60
- json (2.5.1)
64
+ json (2.6.1)
61
65
  json-schema (2.8.1)
62
66
  addressable (>= 2.4)
63
- jsonnet (0.3.0)
67
+ jsonnet (0.4.0)
64
68
  mini_portile2 (>= 2.2.0)
65
69
  kwalify (0.7.2)
66
70
  launchy (2.5.0)
67
71
  addressable (~> 2.7)
68
- logger (1.4.3)
72
+ logger (1.5.0)
69
73
  method_source (1.0.0)
70
- mini_portile2 (2.6.1)
71
- minitest (5.14.4)
72
- os (1.1.1)
73
- ostruct (0.4.0)
74
- parallel (1.19.2)
75
- parser (2.7.1.5)
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.13.1)
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.0.0)
88
- rake (13.0.1)
89
- reek (6.0.1)
92
+ rainbow (3.1.1)
93
+ rake (13.0.6)
94
+ reek (6.1.0)
90
95
  kwalify (~> 0.7.0)
91
- parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
92
- psych (~> 3.1.0)
96
+ parser (~> 3.1.0)
93
97
  rainbow (>= 2.0, < 4.0)
94
- regexp_parser (1.8.1)
95
- rexml (3.2.4)
96
- rspec (3.9.0)
97
- rspec-core (~> 3.9.0)
98
- rspec-expectations (~> 3.9.0)
99
- rspec-mocks (~> 3.9.0)
100
- rspec-core (3.9.3)
101
- rspec-support (~> 3.9.3)
102
- rspec-expectations (3.9.2)
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.9.0)
105
- rspec-mocks (3.9.1)
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.9.0)
108
- rspec-support (3.9.3)
109
- rubocop (0.92.0)
111
+ rspec-support (~> 3.10.0)
112
+ rspec-support (3.10.3)
113
+ rubocop (1.25.1)
110
114
  parallel (~> 1.10)
111
- parser (>= 2.7.1.5)
115
+ parser (>= 3.1.0.0)
112
116
  rainbow (>= 2.2.2, < 4.0)
113
- regexp_parser (>= 1.7)
117
+ regexp_parser (>= 1.8, < 3.0)
114
118
  rexml
115
- rubocop-ast (>= 0.5.0)
119
+ rubocop-ast (>= 1.15.1, < 2.0)
116
120
  ruby-progressbar (~> 1.7)
117
- unicode-display_width (>= 1.4.0, < 2.0)
118
- rubocop-ast (0.7.1)
119
- parser (>= 2.7.1.5)
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.10.1)
123
- ruby_parser (3.15.0)
124
- sexp_processor (~> 4.9)
125
- rubycritic (4.5.2)
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.15.1)
137
- simplecov (0.19.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.0.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.7.0)
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
- yard (0.9.25)
154
- zeitwerk (2.4.2)
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 (~> 0.9)
162
- private_gem (~> 1.1)
163
- pry (~> 0.13)
164
- rake (~> 13.0)
165
- rspec (~> 3.9)
166
- rubocop (~> 0.92)
167
- rubycritic (~> 4.5)
168
- simplecov (~> 0.19)
169
- yard (~> 0.9)
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
- Add the following to your Gemfile
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
- ## Usage
49
+ ### Use in another project/script (standalone)
48
50
 
49
- ### Creating a template
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
- Templates are a collection of files in the template folder with a manifest. The structure is thus:
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
- - $ARCHETYPE_TEMPLATE_DIR
55
- | - my_template
56
- | - | - template/
57
- | - | - | - file.erb
58
- | - | - | - file2.txt
59
- | - | - manifest.json
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
- Each template must include a manifest which has instructions necessary to render the template at run time.
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
- To create a blank template run the new command with the relative (from your template directory) path to your new template. For example to create a ruby gem you might:
76
+ ```ruby
77
+ #!/usr/bin/env ruby
65
78
 
66
- ```bash
67
- archetype new ruby/gem # creates a template at $ARCHETYPE_TEMPLATE_DIR/ruby/gem
79
+ require 'app_archetype'
68
80
 
69
- # or
81
+ puts 'CREATE NEW COMMAND'
70
82
 
71
- archetype new ruby_gem # creates a template at $ARCHETYPE_TEMPLATE_DIR/ruby_gem
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
- # or
89
+ puts <<~NEXT_STEPS
90
+ ✔ Command created
74
91
 
75
- archetype new ruby/gem/on_rails # creates a template at $ARCHETYPE_TEMPLATE_DIR/ruby/gem/on_rails
92
+ TODO:
93
+ NEXT_STEPS
76
94
 
77
- # etc.
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
- A manifest has a name, version and set of variables. A sample manifest looks like this:
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 Files
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
- You can include handlebars in file names, and like template files, the variables will be used to render the filenames.
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
- Adjust the template manifest to include the variables you want, and then run:
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
@@ -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', '~> 0.2'
20
- spec.add_dependency 'highline', '~> 2.0'
21
- spec.add_dependency 'json', '~> 2.3'
22
- spec.add_dependency 'jsonnet', '~> 0.3.0'
23
- spec.add_dependency 'json-schema', '~> 2.8'
24
- spec.add_dependency 'logger', '~> 1.4.2'
25
- spec.add_dependency 'os', '~> 1.1'
26
- spec.add_dependency 'ostruct', '~> 0.3'
27
- spec.add_dependency 'ruby-handlebars', '~> 0.4'
28
- spec.add_dependency 'thor', '~> 1.0'
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', '~> 0.9'
31
- spec.add_development_dependency 'private_gem', '~> 1.1'
32
- spec.add_development_dependency 'pry', '~> 0.13'
33
- spec.add_development_dependency 'rake', '~> 13.0'
34
- spec.add_development_dependency 'rspec', '~> 3.9'
35
- spec.add_development_dependency 'rubocop', '~> 0.92'
36
- spec.add_development_dependency 'rubycritic', '~> 4.5'
37
- spec.add_development_dependency 'simplecov', '~> 0.19'
38
- spec.add_development_dependency 'yard', '~> 0.9'
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
data/bin/archetype CHANGED
@@ -14,7 +14,7 @@ end
14
14
  begin
15
15
  AppArchetype::CLI.start
16
16
  rescue StandardError => e
17
- puts "ERROR: #{e.message}"
17
+ puts "ERROR: #{e.message}"
18
18
  puts e.backtrace.join("\n")
19
19
  exit 1
20
20
  end