power_stencil 0.5.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +2 -0
  3. data/README.md +3 -7
  4. data/doc/builds.md +10 -1
  5. data/doc/entities.md +59 -50
  6. data/doc/images/power-stencil-entity-creation.svg +247 -114
  7. data/doc/plugins.md +49 -1
  8. data/doc/templates.md +23 -18
  9. data/etc/base_commands_definition.yml +28 -1
  10. data/etc/meta_templates/plugin_seed/psplugin_{entity}.gemspec +3 -1
  11. data/etc/power_stencil.yaml +7 -1
  12. data/etc/templates/plugin_definition/psplugin_{entity}.gemspec +3 -1
  13. data/etc/templates/project/.zzzgitignore.erb +8 -3
  14. data/lib/power_stencil.rb +1 -0
  15. data/lib/power_stencil/command_processors/build.rb +16 -3
  16. data/lib/power_stencil/command_processors/check.rb +12 -0
  17. data/lib/power_stencil/command_processors/create.rb +6 -5
  18. data/lib/power_stencil/command_processors/delete.rb +23 -15
  19. data/lib/power_stencil/command_processors/edit.rb +4 -2
  20. data/lib/power_stencil/command_processors/init.rb +2 -2
  21. data/lib/power_stencil/command_processors/plugin.rb +20 -6
  22. data/lib/power_stencil/command_processors/root.rb +1 -1
  23. data/lib/power_stencil/command_processors/shell.rb +10 -3
  24. data/lib/power_stencil/dsl/entities.rb +0 -16
  25. data/lib/power_stencil/engine/build_handling.rb +1 -2
  26. data/lib/power_stencil/engine/directory_processor.rb +6 -1
  27. data/lib/power_stencil/engine/entities_definitions.rb +16 -7
  28. data/lib/power_stencil/engine/entities_handling.rb +1 -1
  29. data/lib/power_stencil/engine/project_engine.rb +6 -10
  30. data/lib/power_stencil/initializer.rb +4 -7
  31. data/lib/power_stencil/plugins/base.rb +18 -9
  32. data/lib/power_stencil/plugins/capabilities.rb +10 -8
  33. data/lib/power_stencil/plugins/command_line.rb +1 -4
  34. data/lib/power_stencil/plugins/config.rb +1 -5
  35. data/lib/power_stencil/plugins/entity_definitions.rb +15 -0
  36. data/lib/power_stencil/plugins/gem.rb +14 -35
  37. data/lib/power_stencil/plugins/paths.rb +38 -0
  38. data/lib/power_stencil/plugins/require.rb +10 -16
  39. data/lib/power_stencil/plugins/templates.rb +3 -3
  40. data/lib/power_stencil/project/base.rb +24 -9
  41. data/lib/power_stencil/project/config.rb +3 -2
  42. data/lib/power_stencil/project/create.rb +23 -2
  43. data/lib/power_stencil/project/git.rb +75 -0
  44. data/lib/power_stencil/project/info.rb +14 -1
  45. data/lib/power_stencil/project/paths.rb +22 -26
  46. data/lib/power_stencil/project/plugins.rb +18 -23
  47. data/lib/power_stencil/project/templates.rb +15 -22
  48. data/lib/power_stencil/system_entity_definitions/all.rb +2 -1
  49. data/lib/power_stencil/system_entity_definitions/buildable.rb +1 -1
  50. data/lib/power_stencil/system_entity_definitions/entity_override.rb +6 -0
  51. data/lib/power_stencil/system_entity_definitions/entity_project_common.rb +13 -5
  52. data/lib/power_stencil/system_entity_definitions/{has_associated_files.rb → entity_templates.rb} +2 -2
  53. data/lib/power_stencil/system_entity_definitions/project_config.rb +1 -1
  54. data/lib/power_stencil/system_entity_definitions/project_entity.rb +7 -0
  55. data/lib/power_stencil/system_entity_definitions/simple_exec.rb +3 -3
  56. data/lib/power_stencil/system_entity_definitions/source_provider.rb +15 -0
  57. data/lib/power_stencil/utils/gem_utils.rb +22 -2
  58. data/lib/power_stencil/version.rb +1 -1
  59. data/power_stencil.gemspec +2 -1
  60. metadata +23 -6
@@ -15,6 +15,7 @@ Plugins
15
15
  - [Providing entity types and templates](#providing-entity-types-and-templates)
16
16
  - [Providing custom build process](#providing-custom-build-process)
17
17
  - [Plugin capabilities and structure](#plugin-capabilities-and-structure)
18
+ - [Using plugins available as gems](#using-plugins-available-as-gems)
18
19
  - [Conclusion](#conclusion)
19
20
 
20
21
  <!-- /TOC -->
@@ -205,6 +206,7 @@ we can check using `power_stencil check myplugin_entity/test`:
205
206
  $ power_stencil check myplugin_entity/test
206
207
  'myplugin_entity/test':
207
208
  - Storage path : '/tmp/demo/.ps_project/entities/myplugin_entity/test.yaml'
209
+ - Provided by : plugin 'myplugin'
208
210
  - Templates path : '/tmp/demo/myplugin_entity/test'
209
211
  - Status : Valid
210
212
  - Buildable : true
@@ -426,12 +428,58 @@ MinimalPlugin::Minimal:
426
428
 
427
429
  All of this to demonstrate that a plugin can be almost anything, even something very minimalistic, but nevertheless you should keep on using the `power_stencil plugin --create` command and benefit from the structure it brings, as well as the possibility to become a stand-alone plugin gem...
428
430
 
431
+ # Using plugins available as gems
432
+
433
+ Any plugin you have created using the `power_stencil plugin --create` command is directly eligible to become a gem.
434
+
435
+ **If you release a plugin you created within a project as a gem (by doing `bundle exec rake release` from within the plugin directory, like for any standard gem :+1:), you can then re-use your plugin from any other `PowerStencil` project !**
436
+
437
+ All you have to do for that is to declare it in the `.ps_project/versioned-config.yaml` config file by adding an array `:project_plugins`:
438
+
439
+ ```yaml
440
+ ...
441
+ :project_plugins:
442
+ - my_awesome_plugin1
443
+ - my_awesome_plugin2
444
+ - my_awesome_plugin3
445
+ ...
446
+ ```
447
+
448
+ Now if you try to run power_stencil you may face an error if the gem is not locally installed:
449
+
450
+ ```
451
+ ▶ power_stencil info
452
+ --------------------------------------------------------------------------------
453
+ PROJECT REPORT
454
+ --------------------------------------------------------------------------------
455
+ General information:
456
+ Program aborted with message: 'Cannot find plugin 'my_awesome_plugin1'. Try 'power_stencil plugin --install''.
457
+ Use --debug option for more detail (see --help).
458
+
459
+ ```
460
+ Here you have the choice to either manually install each of your plugins manually by using the regular gem program:
461
+
462
+ $ gem install my_awesome_plugin1 my_awesome_plugin2 my_awesome_plugin3
463
+
464
+ But `PowerStencil` provides a convenient command to install/update your plugins:
465
+
466
+ ```
467
+ $ power_stencil plugin --install
468
+ Fetching: my_awesome_plugin1-0.1.0.gem (100%)
469
+ Fetching: my_awesome_plugin2-0.1.1.gem (100%)
470
+ Fetching: my_awesome_plugin3-1.2.3.gem (100%)
471
+ Installed plugin 'my_awesome_plugin1' (version: 0.1.0)
472
+ Installed plugin 'my_awesome_plugin2' (version: 0.1.1)
473
+ Installed plugin 'my_awesome_plugin3' (version: 1.2.3)
474
+ ```
475
+
476
+ **:star2: ::+1: You can now verify using `power_stencil info` or `power_stencil plugin --list`, that the plugins have been installed and that any feature they provide is now available to your project.**
429
477
 
430
478
  # Conclusion
431
479
 
432
480
  The documentation for plugins is not fully complete, so you are encouraged to read the code. Some official plugins are under development, and the documentation will be improved along their development...
433
481
 
434
- **:warning: As opposed to the rest of `PowerStencil`, the functionnality is nevertheless not completely frozen. This will be the case once `PowerStencil` turns 1.0.0.** Yet now _local_ plugins are almost in their final stage. Gem plugins will soon be released and then `PowerStencil` will turn 1.0.0.
482
+ **:warning: As opposed to the rest of `PowerStencil`, the functionnality is nevertheless not completely frozen. This will be the case once `PowerStencil` turns 1.0.0.** but plugins are close to their final release, and anything above version 0.6 is already really usable.
435
483
 
436
484
 
437
485
  [:back:][Documentation root]
@@ -27,7 +27,7 @@ The default templating engine being [ERB], your templates should be written usin
27
27
 
28
28
  Templates are always associated to some [buildable entities][buildable].
29
29
 
30
- When a [buildable entity][buildable] has some templates associated, they will be located in a directory `<entity_type>/<entity_name>/`. For some entity types, when you will create a new entity of this type, some default templates will be created in that directory (this is the case of the `simple_exec` entity type as you will see in the next paragraph). This is what is called `templates-templates`.
30
+ When a [buildable entity][buildable] has some templates associated, they will be initially generated in a directory `templates/<entity_type>/<entity_name>/` (unless they are [unversioned]). For some entity types, when you will create a new entity of this type, some default templates will be created in that directory (this is the case of the `simple_exec` entity type as you will see in the next paragraph) from some kind of "_meta-templates_". This is what is called `templates-templates` in `PowerStencil`.
31
31
 
32
32
  In this document, you will learn how to create your own templates, as well as your own templates-templates.
33
33
 
@@ -37,19 +37,21 @@ In the basic entity types, the only one providing default templates is the `simp
37
37
 
38
38
  ```shell
39
39
  $ power_stencil create simple_exec/demo_templates
40
- Created 'simple_exec/demo_templates'
40
+ Creating 'simple_exec/demo_templates'...
41
+ Generated templates in '/tmp/tst3/templates/simple_exec/demo_templates'.
41
42
 
42
43
  $ power_stencil check simple_exec/demo_templates
43
44
  RAW ENTITIES
44
45
  'simple_exec/demo_templates':
45
46
  - Storage path : '/tmp/tst3/.ps_project/entities/simple_exec/demo_templates.yaml'
46
- - Templates path : '/tmp/tst3/simple_exec/demo_templates'
47
+ - Provided by : 'PowerStencil core'
48
+ - Templates path : '/tmp/tst3/templates/simple_exec/demo_templates'
47
49
  - Status : Valid
48
50
  - Buildable : true
49
51
  ```
50
52
  As you can see the output of `power_stencil check` shows more information than entities we created so far. First we see that this entity is `buildable`, and we'll detail that in the [builds] document, but for the moment what we will focus on the `Templates path` information.
51
53
 
52
- And it's true if we have a look in the `simple_exec/demo_templates/` directory from the root of the project, a file appeared there:
54
+ And it's true if we have a look in the `templates/simple_exec/demo_templates/` directory from the root of the project, a file appeared there:
53
55
 
54
56
  ```shell
55
57
  $ ls -l simple_exec/demo_templates
@@ -78,14 +80,14 @@ End of process 15572
78
80
 
79
81
  What can we see there ?
80
82
 
81
- The first line is the most interesting one for us. It says "De-templating ... into ...", and it's true that a brand new directory named `build` appeared at the root of the project. Again we won't focus too much on the name of the sub-directory as we will see that in the [builds], but if we have a look in the generated directory we see the same content as what we had in `simple_exec/demo_templates`...
83
+ The first line is the most interesting one for us. It says "De-templating ... into ...", and it's true that a brand new directory named `build` appeared at the root of the project. Again we won't focus too much on the name of the sub-directory as we will see that in the [builds], but if we have a look in the generated directory we see the same content as what we had in `templates/simple_exec/demo_templates`...
82
84
  And by the way the generated script seems to have been run, as we can see in the output.
83
85
 
84
86
  :warning: If bash is not installed on your system, the output will obviously be different as `PowerStencil` won't be able to run the script, yet all the files should have been generated correctly.
85
87
 
86
- Ok is it possible, that everything inside `simple_exec/demo_templates` is actually considered as templates ? **The answer is yes !!**
88
+ Ok is it possible, that everything inside `templates/simple_exec/demo_templates` is actually considered as templates ? **The answer is yes !!**
87
89
 
88
- Let prove it and replace the content of `simple_exec/demo_templates/main.sh` by the following:
90
+ Let prove it and replace the content of `templates/simple_exec/demo_templates/main.sh` by the following:
89
91
 
90
92
  ```shell
91
93
  #!/usr/bin/env bash
@@ -122,7 +124,7 @@ echo "It was done in the scope of 'demo_templates' (which is of the type 'simple
122
124
 
123
125
  The content has been "de-templated"... :+1: sooo cool !
124
126
 
125
- :information_source: Here the template directory of the `simple_exec/demo_templates` was containing only on file (the bash script), but **any file in any sub-directory of that directory would have been considered as a template** (yet there are some mechanism to control and limit which files have to be processed, like for example imagine there would be images, or zip files, probably you don't want them to be processed. All of this will be covered in the [builds] document).
127
+ :information_source: Here the template directory of the `simple_exec/demo_templates` entity was containing only on file (the bash script), but **any file in any sub-directory of that directory would have been considered as a template** (yet there are some mechanism to control and limit which files have to be processed, like for example imagine there would be images, or zip files, probably you don't want them to be processed. All of this will be covered in the [builds] document).
126
128
 
127
129
  # What can I do within templates ?
128
130
 
@@ -175,7 +177,7 @@ This should be self explanatory, there is another part that could be displayed i
175
177
 
176
178
  # Where do I create templates ?
177
179
 
178
- **When an entity is [buildable] you can find its templates in the `<entity_type>/<entity_name>` from the root of the project.**
180
+ **When an entity is [buildable] you can find its templates in the `templates/<entity_type>/<entity_name>` from the root of the project.**
179
181
 
180
182
  But by default, that directory is not created, and if no templates is created at this place for a [buildable] entity, the build will fail saying it didn't find any template...
181
183
 
@@ -188,7 +190,7 @@ $ power_stencil info
188
190
  .
189
191
  .
190
192
  .
191
- - Type 'simple_exec' --> PowerStencil::SystemEntityDefinitions::SimpleExec (template-template path: '/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/power_stencil-0.2.18/etc/templates/simple_exec')
193
+ - Type 'simple_exec' --> PowerStencil::SystemEntityDefinitions::SimpleExec (provided by 'PowerStencil core') template-template path: '/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/power_stencil-0.6.3/etc/templates/simple_exec'
192
194
  ```
193
195
 
194
196
  `simple_exec` is an entity type coming with `PowerStencil`, and you can see that it takes its _template-template_ from within the `PowerStencil` gem itself !
@@ -199,7 +201,7 @@ To summarize about templates and _templates-templates_:
199
201
 
200
202
  ![entity-creation-flow]
201
203
 
202
- :information_source: There is actually a third place where you could find entity types and _templates-templates_, this is within [plugins], but we will cover that in the [plugins] part...
204
+ :information_source: As you can see, there is actually a third place where you could find entity types and _templates-templates_, this is within [plugins], but we will cover that in the [plugins] part...
203
205
 
204
206
  # Creating templates-templates of your own
205
207
 
@@ -230,20 +232,21 @@ Let's now create an entity of this type:
230
232
 
231
233
  ```shell
232
234
  $ power_stencil create custom_buildable_entity/test1
233
- Created 'custom_buildable_entity/test1'
235
+ Creating 'custom_buildable_entity/test1'...
236
+ Generated templates in '/tmp/tst3/templates/custom_buildable_entity/test1'.
234
237
 
235
- $ ll custom_buildable_entity/test1
238
+ $ ll templates/custom_buildable_entity/test1
236
239
  total 12
237
240
  drwxrwxr-x 2 laurent laurent 4096 août 26 13:40 ./
238
241
  drwxrwxr-x 3 laurent laurent 4096 août 26 13:40 ../
239
242
  -rw-rw-r-- 1 laurent laurent 26 août 26 13:40 a_useless_text_file.txt
240
243
  ```
241
- Everything, seems ok. The entity `custom_buildable_entity/test1` has been created and there is now a new folder at the root of the project named `custom_buildable_entity/test1` and which content is a text file named `a_useless_text_file.txt`... So far so good.
244
+ Everything, seems ok. The entity `custom_buildable_entity/test1` has been created and there is now a new folder named `templates/custom_buildable_entity/test1` and which content is a text file named `a_useless_text_file.txt`... So far so good.
242
245
 
243
246
  And what is the content of this file ?
244
247
 
245
248
  ```shell
246
- $ cat custom_buildable_entity/test1/a_useless_text_file.txt
249
+ $ cat templates/custom_buildable_entity/test1/a_useless_text_file.txt
247
250
  This text has been generated on the 2019-08-26 13:50:35 +0200
248
251
 
249
252
  Lorem ipsum dolor sit amet, consectetur adipiscing elit,
@@ -308,15 +311,16 @@ Et voilà, let's verify:
308
311
 
309
312
  ```shell
310
313
  $ power_stencil create custom_buildable_entity/test2
311
- Created 'custom_buildable_entity/test2'
314
+ Creating 'custom_buildable_entity/test2'...
315
+ Generated templates in '/tmp/tst3/templates/custom_buildable_entity/test2'.
312
316
 
313
- $ ls -la custom_buildable_entity/test2
317
+ $ ls -la templates/custom_buildable_entity/test2
314
318
  total 12
315
319
  drwxrwxr-x 2 laurent laurent 4096 août 26 18:37 .
316
320
  drwxrwxr-x 4 laurent laurent 4096 août 26 18:37 ..
317
321
  -rw-rw-r-- 1 laurent laurent 148 août 26 18:37 a_useless_text_file.txt
318
322
 
319
- $ cat custom_buildable_entity/test2/a_useless_text_file.txt
323
+ $ cat templates/custom_buildable_entity/test2/a_useless_text_file.txt
320
324
  This text has been generated on the <%= Time.now %>
321
325
 
322
326
  Lorem ipsum dolor sit amet, consectetur adipiscing elit,
@@ -351,6 +355,7 @@ Flawless victory !!
351
355
  [buildable]: entities.md#buildable-and-buildable_by "How to make an entity buildable ?"
352
356
  [entity field]: entities.md#field "How to access basic entity data"
353
357
  [reverse methods]: entities.md#has_one "Check reverse methods"
358
+ [unversioned]: entities.md#local-unversioned-entities "Unversioned/developer entities"
354
359
  <!-- Code links -->
355
360
 
356
361
 
@@ -85,6 +85,12 @@
85
85
  :summary: Forces creation in an already existing directory.
86
86
  :short_aliases:
87
87
  - f
88
+ no-git:
89
+ :type: bool
90
+ :summary: Do not initiate a git repo when creating a new project.
91
+ :long_aliases:
92
+ - ng
93
+ - nogit
88
94
  info:
89
95
  :banner: |
90
96
  Generic information about the repository.
@@ -104,13 +110,34 @@
104
110
  :options:
105
111
  create:
106
112
  :type: bool
107
- :summary: Generates a fully working although useless plugin skeleton.
113
+ :summary: Scaffolds a fully working plugin skeleton.
108
114
  :long_aliases:
109
115
  - new
110
116
  - scaffold
117
+ :incompatibilities:
118
+ - list
119
+ - install
111
120
  list:
112
121
  :type: bool
113
122
  :summary: List currently used plugins in this project.
123
+ :incompatibilities:
124
+ - create
125
+ - install
126
+ install:
127
+ :type: bool
128
+ :summary: Install gem plugins.
129
+ :incompatibilities:
130
+ - create
131
+ - list
132
+ no-git:
133
+ :type: bool
134
+ :summary: Do not include the newly created plugin into the repository.
135
+ :long_aliases:
136
+ - ng
137
+ - nogit
138
+ :dependencies:
139
+ - create
140
+
114
141
  get:
115
142
  :banner: |
116
143
  Query entities from repository.
@@ -18,8 +18,10 @@ Gem::Specification.new do |spec|
18
18
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
19
  if spec.respond_to?(:metadata)
20
20
  spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # This metadata is mandatory for PowerStencil !!
22
+ spec.metadata['plugin_name'] = '<%= plugin_name %>'
21
23
  else
22
- raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
24
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes and PowerStencil plugin mechanism !'
23
25
  end
24
26
 
25
27
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -23,7 +23,7 @@
23
23
  :unversioned_user_project_config_file_name: personal-config.yaml
24
24
  # Entity definitions specific to the project
25
25
  :project_entity_definitions_directory_name: entity_definitions
26
- # Templates specific to the project
26
+ # Templates templates specific to the project
27
27
  :project_templates_directory_name: templates-templates
28
28
  # Directory name where entities are stored
29
29
  :project_entities_directory_name: entities
@@ -33,6 +33,10 @@
33
33
  :project_plugins_directory_name: plugins
34
34
  # Root directory where builds are generated
35
35
  :project_build_root_directory_name: build
36
+ # Versioned entities templates directory
37
+ :versioned_entities_templates_directory_name: templates
38
+ # Unversioned entities templates directory
39
+ :unversioned_user_entities_templates_directory_name: unversioned-templates
36
40
  # Last build link name
37
41
  :project_build_last_stable_path: last_build
38
42
  # Previous build link name
@@ -108,4 +112,6 @@
108
112
  :log-level: 2
109
113
  # Maximum number of retries when editing a file
110
114
  :max_file_edit_retry_times: 3
115
+ # Integration with git
116
+ :no-git: false
111
117
 
@@ -18,8 +18,10 @@ Gem::Specification.new do |spec|
18
18
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
19
  if spec.respond_to?(:metadata)
20
20
  spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # This metadata is mandatory for PowerStencil !!
22
+ spec.metadata['plugin_name'] = '<%= plugin_name %>'
21
23
  else
22
- raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
24
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes and PowerStencil plugin mechanism !'
23
25
  end
24
26
 
25
27
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -1,6 +1,11 @@
1
1
  # Ignore power stencil generated files
2
- <%= File.join '', project_config[:project_build_root_directory_name] %>
2
+ <%= File.join '', project_config[:project_build_root_directory_name] %>
3
+
3
4
  # Ignore power stencil local entities created by developer
4
- <%= File.join '', project_config[:default_config_directory_name], project_config[:user_entities_directory_name] %>
5
+ <%= File.join '', project_config[:default_config_directory_name], project_config[:user_entities_directory_name] %>
6
+
7
+ # Ignore power stencil local entities templates created by developer
8
+ <%= File.join '', project_config[:unversioned_user_entities_templates_directory_name] %>
9
+
5
10
  # Ignore power stencil local developer's config
6
- <%= File.join '', project_config[:default_config_directory_name], project_config[:unversioned_user_project_config_file_name] %>
11
+ <%= File.join '', project_config[:default_config_directory_name], project_config[:unversioned_user_project_config_file_name] %>
@@ -1,6 +1,7 @@
1
1
  require 'power_stencil/version'
2
2
 
3
3
  require 'universe_compiler'
4
+ require 'git'
4
5
  require 'dir_glob_ignore'
5
6
 
6
7
  $DO_NOT_AUTOSTART_CLIMATIC=true
@@ -15,8 +15,21 @@ module PowerStencil
15
15
  if config[:'supported-builds']
16
16
  project.engine.available_entities_hash.select do |_, klass|
17
17
  klass.respond_to?(:buildable?) and klass.buildable?
18
- end .each do |entity_type, _|
19
- puts " - '#{entity_type}'"
18
+ end .each do |entity_type, entity_class|
19
+ builder = entity_class.buildable_by.empty? ? "'#{PowerStencil.name}'" : "plugin '#{entity_class.buildable_by}'"
20
+
21
+ source_provider = entity_class.entity_type_source_provider
22
+ source_provider_display = if source_provider == PowerStencil
23
+ "'#{source_provider.name}'"
24
+ elsif source_provider == project
25
+ "project '#{source_provider.name}'"
26
+ elsif source_provider.is_a? PowerStencil::Plugins::Base
27
+ "plugin '#{source_provider.name}'"
28
+ else
29
+ raise PowerStencil::Error, "Unidentified source provider for #{entity_class} !"
30
+ end
31
+
32
+ puts " - '#{entity_type}' (buildable by #{builder} and provided by #{source_provider_display})."
20
33
  end
21
34
  return
22
35
  end
@@ -37,7 +50,7 @@ module PowerStencil
37
50
  if entity_report == ['Ok']
38
51
  puts " - '#{entity_full_name}' has been correctly built"
39
52
  else
40
- puts " - Failed to build '#{entity_full_name}' because ", entity_report
53
+ puts_and_logs " - Failed to build '#{entity_full_name}' because #{entity_report.join}", logs_as: :error, check_verbose: false
41
54
  end
42
55
  end
43
56
 
@@ -23,6 +23,18 @@ module PowerStencil
23
23
  sorted_targets.map do |entity|
24
24
  entity_info = [" '#{entity.as_path}':"]
25
25
  entity_info << " - Storage path : '#{entity.source_uri}'"
26
+
27
+ source_provider = entity.class.entity_type_source_provider
28
+ source_provider_display = if source_provider == PowerStencil
29
+ "'#{source_provider.name}'"
30
+ elsif source_provider == project
31
+ "project '#{source_provider.name}'"
32
+ elsif source_provider.is_a? PowerStencil::Plugins::Base
33
+ "plugin '#{source_provider.name}'"
34
+ else
35
+ raise PowerStencil::Error, "Unidentified source provider for #{entity.class} !"
36
+ end
37
+ entity_info << " - Provided by : #{source_provider_display}"
26
38
  entity_info << " - Templates path : '#{entity.templates_path}'" if entity.respond_to? :templates_path
27
39
  entity_info << " - Status : #{entity.valid? ? 'Valid' : 'INVALID !'} "
28
40
  entity_info << " - Buildable : #{entity.buildable?}"
@@ -12,7 +12,7 @@ module PowerStencil
12
12
  def execute
13
13
  analyse_extra_params.each do |search_criterion|
14
14
  begin
15
- puts_and_logs "Creating new entity '#{search_criterion.as_path}'"
15
+ puts_and_logs "Creating new entity '#{search_criterion.as_path}'...", check_verbose: false
16
16
  entity_as_hash = {name: search_criterion.name}
17
17
  unless config[:property].nil?
18
18
  config[:property].each do |property_def|
@@ -36,11 +36,12 @@ module PowerStencil
36
36
  end
37
37
 
38
38
  new_entity.valid? raise_error: true
39
- new_entity.save
40
-
41
- puts "Created '#{new_entity.as_path}'"
39
+ project.track_action_with_git("Created '#{new_entity.as_path}' (and potential dependencies).") do
40
+ new_entity.save
41
+ end
42
+ puts_and_logs "Generated templates in '#{new_entity.templates_path}'.", check_verbose: false if new_entity.buildable?
42
43
  rescue => e
43
- puts "Failed to create '#{search_criterion.as_path}' with message '#{e.message}'."
44
+ puts_and_logs "Failed to create '#{search_criterion.as_path}' with message '#{e.message}'.", logs_as: :error, check_verbose: false
44
45
  logger.debug PowerStencil::Error.report_error(e)
45
46
  end
46
47
  end
@@ -9,24 +9,32 @@ module PowerStencil
9
9
  include PowerStencil::CommandProcessors::EntityHelper
10
10
 
11
11
  def execute
12
- analyse_extra_params.each do |search_criterion|
12
+ targets = targets_from_criteria analyse_extra_params, project.engine.root_universe
13
+ targets.each do |target|
13
14
  begin
14
- unless project.engine.entity *search_criterion.to_a, project.engine.root_universe
15
- puts "Skipping '#{search_criterion.as_path}'. Entity not found."
16
- next
17
- end
18
- puts_and_logs "Deleting entity '#{search_criterion.as_path}'"
19
- if project.engine.delete_entity project.engine.root_universe,
20
- *search_criterion.to_a,
21
- delete_files: config[:'delete-files']
22
- msg = "Deleted '#{search_criterion.as_path}'"
23
- msg << ' and associated files.' if config[:'delete-files']
24
- puts msg
25
- else
26
- puts 'Cancelled by user input.'
15
+ # unless project.engine.entity *target.to_a, project.engine.root_universe
16
+ # puts_and_logs "Skipping '#{target.as_path}'. Entity not found.", check_verbose: false
17
+ # next
18
+ # end
19
+ puts_and_logs "Deleting entity '#{target.as_path}'", check_verbose: false
20
+
21
+ msg = "Deleted entity '#{target.as_path}' (and potential dependencies)"
22
+ msg << ' including templates.' if config[:'delete-files']
23
+ msg << '.'
24
+ project.track_action_with_git(msg) do
25
+ if project.engine.delete_entity project.engine.root_universe,
26
+ target.type,
27
+ target.name,
28
+ delete_files: config[:'delete-files']
29
+ msg = "Deleted '#{target.as_path}'"
30
+ msg << ' and template files.' if config[:'delete-files']
31
+ puts_and_logs msg, check_verbose: false
32
+ else
33
+ puts_and_logs 'Cancelled by user input.', check_verbose: false
34
+ end
27
35
  end
28
36
  rescue => e
29
- puts "Failed to delete '#{search_criterion.as_path}' with message '#{e.message}'."
37
+ puts_and_logs "Failed to delete '#{target.as_path}' with message '#{e.message}'.", logs_as: :error, check_verbose: false
30
38
  logger.debug PowerStencil::Error.report_error(e)
31
39
  end
32
40
  end