power_stencil 0.4.15 → 0.4.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39ef892e57acf1b138606b8ce494324a76759eac
4
- data.tar.gz: 811c9bbb835afa1f137c76d74a5261a01486fd6e
3
+ metadata.gz: e2582b92f3e64dba5535548383200c900db71ea5
4
+ data.tar.gz: 52cd784e7160cf2d580c86a06999e6bab6c8b0d1
5
5
  SHA512:
6
- metadata.gz: 8d7d187f50b36b965576bc4dd538bacd401a8b62df1968c9f7cbc13ccfc3e6027c842dcc6e82be8753cd62e093c7d1c28d4e0f87c8247324cfa99d0e45a3aa70
7
- data.tar.gz: 091f7d4bf28c89f292e33a78a1176b72678c8464c1dc0e517b6be47b42908fefd9a4fdabeec3af905871acecb72172b8a0a6395d67973ea3588c426c57acab42
6
+ metadata.gz: 8df322c9851a1126691cea6a7c9b2fb66dad309845b63073625ad392319c0d9221eb98f73401a5cbfe4b04bfd654d87c9dc83e281477317b82071938f33bb802
7
+ data.tar.gz: 3a141b9153a9d25ef54eaa8a581b64585961a9954508f8cd75631c399e7f73914af2d4e0f1b673ae16c4a7728f033b924210a28d4d3065ea64d25744439c5246
data/README.md CHANGED
@@ -112,13 +112,14 @@ PowerStencil is the Swiss-army knife templating workflow for developers and ops.
112
112
  --------------------------------------------------------------------------------
113
113
  * init: Initializes a PowerStencil repository ...
114
114
  * info: Generic information about the repository ...
115
- * new-plugin: Generates the skeleton for a plugin ...
115
+ * plugin: Manipulates plugins ...
116
116
  * get: Query entities from repository ...
117
117
  * shell: Opens a shell to interact with entities ...
118
118
  * check: Check repository entities consistency ...
119
119
  * create: Creates entities in the repository ...
120
120
  * edit: Edit entities from repository ...
121
121
  * delete: Delete entities from repository ...
122
+ * describe: Detailed information about entity types ...
122
123
  * build: Builds entities ...
123
124
  ```
124
125
 
@@ -244,6 +244,8 @@ PowerStencil::SystemEntityDefinitions::ProcessDescriptor:
244
244
  ```
245
245
  It creates a `process_descriptor` entity (which is referenced from the `simple_exec` entity as the `post_process` field). So you can edit this process descriptor and define there whatever executable you want to be called.
246
246
 
247
+ :information_source: If you are using Windows you may want to rename `main.sh` to `main.bat` and edit the `process_descriptor/simple_exec_example.process` to change the process to `main.bat`.
248
+
247
249
  This should already cover 95% of everything needed.
248
250
 
249
251
  If you want to do something more custom after the build process completed, this is where you will have to do a [plugin][plugins].
@@ -52,7 +52,7 @@ The normal process would be to begin with a plugin within the project and once y
52
52
  The is a command provided for that, that will create a whole plugin skeleton.
53
53
 
54
54
  ```shell
55
- $ power_stencil new-plugin myplugin
55
+ $ power_stencil plugin --create myplugin
56
56
  Generated new plugin 'myplugin'
57
57
 
58
58
  $ ll .ps_project/plugins/myplugin
@@ -96,7 +96,35 @@ If you do a `power_stencil info` you see a new part appeared in the report
96
96
  ```
97
97
  Each of the lines correspond to what is called a _plugin capability_.
98
98
 
99
- Obviously by default the plugin does nothing, but it defined some placeholders. For example in the ouput here above it says `command_line: true`. What could it mean ?
99
+ You can get the same information by issuing:
100
+
101
+ $ power_stencil plugin --list
102
+
103
+ ```
104
+ 1 plugin found to be used in this project.
105
+ - myplugin (in '/tmp/tst project/.ps_project/plugins/myplugin/lib/myplugin.rb')
106
+ ```
107
+
108
+ Or with the capabilities information:
109
+
110
+ $ power_stencil plugin --list -v
111
+
112
+ ```
113
+ 1 plugin found to be used in this project.
114
+ - myplugin (in '/tmp/tst project/.ps_project/plugins/myplugin/lib/myplugin.rb')
115
+ command_line: true
116
+ local_config: true
117
+ processors: true
118
+ build: false
119
+ dsl: false
120
+ entity_definitions: true
121
+ code: true
122
+ version: true
123
+ templates: true
124
+ ```
125
+
126
+
127
+ Obviously by default the plugin does nothing useful, yet it defined some placeholders. For example in the output here above it says `command_line: true`. What could it mean ?
100
128
 
101
129
  Let's try to see to help:
102
130
 
@@ -122,7 +150,7 @@ PowerStencil is the Swiss-army knife templating workflow for developers and ops.
122
150
  --------------------------------------------------------------------------------
123
151
  * init: Initializes a PowerStencil repository ...
124
152
  * info: Generic information about the repository ...
125
- * new-plugin: Generates the skeleton for a plugin ...
153
+ * plugin: Manipulates plugins ...
126
154
  * get: Query entities from repository ...
127
155
  * shell: Opens a shell to interact with entities ...
128
156
  * check: Check repository entities consistency ...
@@ -146,7 +146,32 @@ Here are the main methods:
146
146
  - `build_target` will return the entity that you are currently building.
147
147
  - `project_config` is a shortcut to the project entity. You could actually retrieve it using the `entity(:project_config, 'Project Config')` method.
148
148
 
149
- And of course you have access like in `power_stencil shell` to any class brought by `PowerStencil`, you could create entities there, destroy some, **but you should not do it**, as it would be very weird to do that during the process of detemplating !
149
+ And of course you have access like in `power_stencil shell` to any class brought by `PowerStencil`, you could create entities there, destroy some, **but you should not do it**, as doing this during the process of detemplating could lead to strange behaviours !
150
+
151
+ Nevertheless you can of course use entities data and methods within your templates. Any data can be directly accessed using [entity field] mechanism. But entities may bring as well methods you may want to use within your templates. How can we know what can be done with an entity **without reading the code** ? The answer is `power_stencil describe`...
152
+
153
+ :information_source: If you do `power_stencil describe` on any entity type, you will get a comprehensive report of what you can do with this or this entity type (by default all entity types are displayed).
154
+
155
+ Here is a (not so interesting) example:
156
+
157
+ ```
158
+ $ power_stencil describe simple_exec
159
+ --------------------------------------------------------------------------------
160
+ => simple_exec (class: PowerStencil::SystemEntityDefinitions::SimpleExec)
161
+ - PARENT ENTITY TYPE: base_entity
162
+ - FIELDS:
163
+ - description
164
+ - post_process:
165
+ - has_one: process_descriptor
166
+ - not_null: true
167
+ - METHODS:
168
+ - delete
169
+ - valid?
170
+ - save
171
+ ```
172
+
173
+ This should be self explanatory, there is another part that could be displayed in case you defined complex relation using the [reverse methods] mechanism...
174
+
150
175
 
151
176
  # Where do I create templates ?
152
177
 
@@ -324,7 +349,8 @@ Flawless victory !!
324
349
  [plugins]: plugins.md "Plugins in PowerStencil"
325
350
  [example use cases]: example_use_cases.md "Example uses cases using PowerStencil"
326
351
  [buildable]: entities.md#buildable-and-buildable_by "How to make an entity buildable ?"
327
-
352
+ [entity field]: entities.md#field "How to access basic entity data"
353
+ [reverse methods]: entities.md#has_one "Check reverse methods"
328
354
  <!-- Code links -->
329
355
 
330
356
 
@@ -93,14 +93,24 @@
93
93
  info [options]
94
94
 
95
95
  Displays information about the repository.
96
- new-plugin:
96
+ plugin:
97
97
  :banner: |
98
- Generates the skeleton for a plugin.
98
+ Manipulates plugins.
99
99
 
100
100
  Usage:
101
- new-plugin [options]
101
+ plugin [options]
102
102
 
103
- Generates a fully working although useless plugin skeleton.
103
+ Manipulates plugins.
104
+ :options:
105
+ create:
106
+ :type: bool
107
+ :summary: Generates a fully working although useless plugin skeleton.
108
+ :long_aliases:
109
+ - new
110
+ - scaffold
111
+ list:
112
+ :type: bool
113
+ :summary: List currently used plugins in this project.
104
114
  get:
105
115
  :banner: |
106
116
  Query entities from repository.
@@ -179,6 +189,13 @@
179
189
  :options:
180
190
  regexp:
181
191
  <<: *REGEXPOPT
192
+ invalid-only:
193
+ :type: boolean
194
+ :summary: Show invalid entities only.
195
+ :long_aliases:
196
+ - invalid
197
+ :short_aliases:
198
+ - i
182
199
  create:
183
200
  :banner: |
184
201
  Creates entities in the repository.
@@ -191,7 +208,7 @@
191
208
  :options:
192
209
  property:
193
210
  :type: array
194
- :summary: Specifiies a first-level property for the entity
211
+ :summary: Specifies a first-level property for the entity
195
212
  :short_aliases:
196
213
  - p
197
214
  edit:
@@ -220,7 +237,7 @@
220
237
 
221
238
  Usage:
222
239
 
223
- edit [object_type[[/ ]object_name]] [options]
240
+ edit [entity_type[[/ ]entity_name]] [options]
224
241
 
225
242
  Edits repository entities. Parameters are used the same way as in 'get'.
226
243
  :options:
@@ -236,7 +253,7 @@
236
253
 
237
254
  Usage:
238
255
 
239
- delete [object_type[[/ ]object_name]] [options]
256
+ delete [entity_type[[/ ]entity_name]] [options]
240
257
 
241
258
  Deletes repository entities. Parameters are used the same way as in 'get'.
242
259
  :options:
@@ -244,6 +261,16 @@
244
261
  delete-files:
245
262
  :type: bool
246
263
  :summary: Will also remove files related to the entity.
264
+ describe:
265
+ :banner: |
266
+ Detailed information about entity types.
267
+
268
+ Usage:
269
+
270
+ describe [entity_type]* [options]
271
+
272
+ Displays information about core properties of given entity types.
273
+ By default will describe all entity types.
247
274
  build:
248
275
  :banner: |
249
276
  Builds entities.
@@ -268,4 +295,17 @@
268
295
  parallelized:
269
296
  :type: bool
270
297
  :summary: Parallelizes builds if possible
271
-
298
+ tag-build:
299
+ :type: string
300
+ :summary: Tags the build with a specific name
301
+ :long_aliases:
302
+ - tag
303
+ :short_aliases:
304
+ - t
305
+ target-path:
306
+ :type: string
307
+ :summary: Build into specified directory
308
+ :long_aliases:
309
+ - path
310
+ :short_aliases:
311
+ - p
@@ -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
+ # Last build link name
37
+ :project_build_last_stable_path: last_build
38
+ # Previous build link name
39
+ :project_build_previous_stable_path: previous_build
36
40
 
37
41
 
38
42
  # DSL CUSTOMIZATIONS
@@ -42,11 +46,11 @@
42
46
  :shell_dsl:
43
47
  :prompt_level_1: 'PowerStencil DSL> '
44
48
  :prompt_level_2: 'PowerStencil DSL --> '
45
- :session_greetings: |
49
+ :session_greetings: |+
46
50
  -------------------------------------------------------------------------------
47
51
  Welcome to the PowerStencil shell session
48
52
  In this shell you have access to anything the templating engine has access to.
49
- You can view, edit, save entities.
53
+ On top of this, you can view, edit, save and delete entities.
50
54
 
51
55
  - Retrieve and manipulate entities using the `entities` hash.
52
56
  - Persist your changes using the `save` method on each entity.
@@ -59,8 +63,6 @@
59
63
  Type `exit` to end your session.
60
64
  -------------------------------------------------------------------------------
61
65
 
62
-
63
-
64
66
  # TEMPLATING ENGINE
65
67
 
66
68
  # Map to define which kind of template engine for which type of file. Be careful if you
@@ -71,7 +73,8 @@
71
73
 
72
74
  # Files matching particular patterns can be changed on the fly
73
75
  :file_renaming_patterns:
74
- # Specific .gitignore file for Windows
76
+ # Specific .gitignore hack for `power_stencil init` as .gitignore should be processed
77
+ # *after* .ps_project
75
78
  ^(.+)\.zzzgitignore\.erb$: '\1.gitignore'
76
79
  # Erb files
77
80
  ^(.+)\.erb$: '\1'
@@ -5,7 +5,7 @@ PowerStencil plugins
5
5
  In this directory, you can define project specific local plugins.
6
6
  You should create them using the `PowerStencil` command-line.
7
7
 
8
- $ power_stencil new-plugin myplugin
8
+ $ power_stencil plugin --create myplugin
9
9
 
10
10
  __It is strongly advised to keep this directory under source control__
11
11
 
@@ -7,6 +7,7 @@ $DO_NOT_AUTOSTART_CLIMATIC=true
7
7
  require 'climatic'
8
8
 
9
9
  require 'power_stencil/error'
10
+ require 'power_stencil/utils/os'
10
11
  require 'power_stencil/utils/semantic_version'
11
12
  require 'power_stencil/utils/file_helper'
12
13
  require 'power_stencil/utils/directory_processor'
@@ -29,8 +30,9 @@ require 'power_stencil/command_processors/create'
29
30
  require 'power_stencil/command_processors/edit'
30
31
  require 'power_stencil/command_processors/delete'
31
32
  require 'power_stencil/command_processors/shell'
32
- require 'power_stencil/command_processors/new_plugin'
33
+ require 'power_stencil/command_processors/plugin'
33
34
  require 'power_stencil/command_processors/build'
35
+ require 'power_stencil/command_processors/describe'
34
36
 
35
37
 
36
38
  module PowerStencil
@@ -25,6 +25,11 @@ module PowerStencil
25
25
  raise PowerStencil::Error, 'Please specify something to build'
26
26
  end
27
27
 
28
+ if config[:'build-tag']
29
+ raise PowerStencil::Error, "Invalid tag name '#{config[:'build-tag']}'" if config[:'build-tag'].include? '/'
30
+ raise PowerStencil::Error, "Cannot tag a build under Windows" if PowerStencil::Utils::Os.windows?
31
+ end
32
+
28
33
  targets = targets_from_criteria analyse_extra_params, project.engine.root_universe
29
34
  raise PowerStencil::Error, 'No valid entity specified' if targets.empty?
30
35
  project.engine.build targets, fail_on_error: config[:'fail-on-error'], parallelized: config[:parallelized]
@@ -9,23 +9,25 @@ module PowerStencil
9
9
  include PowerStencil::CommandProcessors::EntityHelper
10
10
 
11
11
  def execute
12
- puts 'RAW ENTITIES'
13
12
  targets = targets_from_criteria analyse_extra_params, project.engine.root_universe
14
- targets.sort {|a,b| a.as_path <=> b.as_path }
15
- .map do |entity|
13
+ sorted_targets = targets.sort {|a,b| a.as_path <=> b.as_path }
14
+ if config[:'invalid-only']
15
+ sorted_targets.reject! &:valid?
16
+ if sorted_targets.empty?
17
+ puts 'No invalid entity found in this repository.'
18
+ return
19
+ else
20
+ puts 'Showing invalid entities only:'
21
+ end
22
+ end
23
+ sorted_targets.map do |entity|
16
24
  entity_info = [" '#{entity.as_path}':"]
17
25
  entity_info << " - Storage path : '#{entity.source_uri}'"
18
26
  entity_info << " - Templates path : '#{entity.templates_path}'" if entity.respond_to? :templates_path
19
27
  entity_info << " - Status : #{entity.valid? ? 'Valid' : 'INVALID !'} "
20
28
  entity_info << " - Buildable : #{entity.buildable?}"
21
29
  entity_info
22
- end .each { |l| puts l }
23
-
24
-
25
- #
26
- # targets.map do |entity|
27
- # " - '#{entity.as_path}': '#{entity.source_uri}'"
28
- # end .sort.each { |l| puts l }
30
+ end .each { |entity_info| puts entity_info }
29
31
  end
30
32
 
31
33
 
@@ -0,0 +1,19 @@
1
+ module PowerStencil
2
+ module CommandProcessors
3
+
4
+ class Describe
5
+
6
+ include Climatic::Script::UnimplementedProcessor
7
+ include Climatic::Proxy
8
+ include PowerStencil::Project::Proxy
9
+ include PowerStencil::CommandProcessors::EntityHelper
10
+
11
+ def execute
12
+ targets = extra_params_to_entity_types
13
+ describe_entity_types targets
14
+ end
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -9,6 +9,49 @@ module PowerStencil
9
9
  end
10
10
  end
11
11
 
12
+ def describe_entity_types(entity_types)
13
+ report = {}
14
+ project.engine.available_entity_types.each { |entity_type| report = build_entity_type_report entity_type, report }
15
+ scoped_classes = report.keys
16
+
17
+ report.select{|klass, _| entity_types.include? klass.entity_type}
18
+ .sort_by {|klass, _| klass.entity_type.to_s}
19
+ .each do |klass, info|
20
+ puts '-' * 80
21
+ puts "=> #{klass.entity_type} (class: #{klass.name})"
22
+ puts " - PARENT ENTITY TYPE: #{klass.superclass.entity_type}" if scoped_classes.include? klass.superclass
23
+ unless info[:fields].empty?
24
+ puts ' - FIELDS:'
25
+ info[:fields].each do |field_name, constraints|
26
+ if constraints.empty?
27
+ puts " - #{field_name}"
28
+ else
29
+ puts " - #{field_name}:"
30
+ constraints.each do |name, value|
31
+ puts " - #{name}: #{value}"
32
+ end
33
+ end
34
+ end
35
+ end
36
+ unless info[:methods].empty?
37
+ puts ' - METHODS:'
38
+ info[:methods].each do |method_name, _|
39
+ puts " - #{method_name}"
40
+ end
41
+ end
42
+ unless info[:special_methods].empty?
43
+ puts ' - SPECIAL METHODS:'
44
+ info[:special_methods].each do |method_name, method_info|
45
+ puts " - #{method_name} (reverse method defined from relation '#{method_info[:source_field]}' in entity type '#{method_info[:source_entity]}')"
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+
53
+
54
+
12
55
  def display_entity(entity)
13
56
  puts_and_logs "# Entity '#{entity.name}' (#{entity.type})"
14
57
  if config[:'names-only']
@@ -66,6 +109,20 @@ module PowerStencil
66
109
  end
67
110
  end
68
111
 
112
+ def extra_params_to_entity_types(params = config.command_line_layer.extra_parameters)
113
+ known_entity_types = project.engine.available_entity_types
114
+ return known_entity_types if params.empty?
115
+
116
+ params.map do |possible_entity_type|
117
+ possible_entity_type = possible_entity_type.to_sym
118
+ raise PowerStencil::Error, "Invalid entity type '#{possible_entity_type}' !" unless known_entity_types.include? possible_entity_type
119
+ possible_entity_type
120
+ end
121
+ end
122
+
123
+
124
+
125
+
69
126
  def extra_params_to_entity_search_criteria(params)
70
127
  criteria = []
71
128
  next_entity_reference = EntitySearchReference.new
@@ -101,6 +158,34 @@ module PowerStencil
101
158
  private
102
159
 
103
160
 
161
+ def build_entity_type_report(entity_type, report = {})
162
+ klass = project.engine.available_entities_hash[entity_type]
163
+ report[klass] ||= {fields: {}, methods: {}, special_methods: {}}
164
+ entity_type_info = report[klass]
165
+
166
+ # Fields
167
+ klass.fields_constraints.each do |field_name, constraints|
168
+ next if constraints[:reverse_method]
169
+ entity_type_info[:fields][field_name] = {}
170
+ constraints.each do |constraint_name, constraints_value|
171
+ entity_type_info[:fields][field_name][constraint_name] = constraints_value
172
+ end
173
+ end
174
+ # Methods
175
+ klass.public_instance_methods(false).select do |method_name|
176
+ klass.method_defined? method_name
177
+ end .each do |method_name|
178
+ entity_type_info[:methods][method_name] = klass
179
+ end
180
+ # Special methods
181
+ klass.fields_constraints.each do |method_name, constraints|
182
+ next unless constraints[:reverse_method]
183
+ entity_type_info[:special_methods][method_name] = constraints[:reverse_method]
184
+ end
185
+
186
+ report
187
+ end
188
+
104
189
  def analyse_extra_params(extra_params = config.command_line_layer.extra_parameters, default: [''])
105
190
  params_to_check = if extra_params.empty? then
106
191
  config[:regexp] = true
@@ -0,0 +1,56 @@
1
+ module PowerStencil
2
+ module CommandProcessors
3
+
4
+ class Plugin
5
+
6
+ include Climatic::Script::UnimplementedProcessor
7
+ include Climatic::Proxy
8
+ include PowerStencil::Project::Proxy
9
+
10
+ def execute
11
+
12
+ if config[:list]
13
+ if project.plugins.empty?
14
+ puts 'No plugin used in this project.'
15
+ else
16
+ puts "#{project.plugins.size} plugin#{project.plugins.size == 1 ? '' : 's'} found to be used in this project."
17
+ end
18
+ project.plugins.each do |plugin_name, plugin_def|
19
+ puts " - #{plugin_name} (in '#{plugin_def.entry_point_path}')"
20
+ if config[:verbose]
21
+ plugin_def.capabilities.each do |name, value|
22
+ puts " #{name}: #{value}"
23
+ end
24
+ end
25
+ end
26
+ return
27
+ end
28
+
29
+
30
+ if config[:create]
31
+ if config.command_line_layer.extra_parameters.empty?
32
+ raise PowerStencil::Error, 'Please specify at least one plugin name !'
33
+ end
34
+ config.command_line_layer.extra_parameters.each do |plugin_name|
35
+ begin
36
+ target_path = File.join project.project_plugin_path(plugin_name)
37
+ project.create_plugin_tree plugin_name, target_path
38
+ puts "Generated new plugin '#{plugin_name}'"
39
+ rescue => e
40
+ msg = "Could not create plugin '#{plugin_name}' because '#{e.message}'"
41
+ puts msg
42
+ logger.error "Could not create plugin '#{plugin_name}' because '#{e.message}'"
43
+ logger.debug PowerStencil::Error.report_error(e)
44
+ end
45
+ end
46
+ return
47
+ end
48
+
49
+ raise PowerStencil::Error, 'You should specify an option'
50
+
51
+ end
52
+
53
+ end
54
+
55
+ end
56
+ end
@@ -26,7 +26,16 @@ module PowerStencil
26
26
  entity_build_report << msg
27
27
  raise PowerStencil::Error, msg
28
28
  end
29
- build_entity_target_path = File.join build_target_path, entity_to_build.as_path.tr('/', '_')
29
+ build_entity_target_path = if config[:'target-path']
30
+ specified_target_path = File.expand_path config[:'target-path']
31
+ if File.exists? specified_target_path
32
+ raise PowerStencil::Error, "Specified target path '#{specified_target_path}' already exists ! Aborting..."
33
+ end
34
+ specified_target_path
35
+ else
36
+ File.join build_target_path, entity_to_build.as_path.tr('/', '_')
37
+ end
38
+
30
39
  puts_and_logs "De-templating files for '#{entity_to_build.as_path}' into '#{build_entity_target_path}'"
31
40
  build_entity entity_to_build, build_entity_target_path
32
41
  entity_build_report << 'Ok'
@@ -46,10 +55,51 @@ module PowerStencil
46
55
 
47
56
  private
48
57
 
58
+ def manage_build_links(last_build_path)
59
+ if PowerStencil::Utils::Os.windows?
60
+ logger.info 'Cannot create link to last build folder under Windows !'
61
+ return
62
+ end
63
+ last_build_link_path = project.last_build_stable_link_path
64
+ previous_build_link_path = project.previous_build_stable_link_path
65
+ current_last_build_link_target_path = (File.symlink? last_build_link_path) ? File.readlink(last_build_link_path) : nil
66
+
67
+ safely_remove_link previous_build_link_path
68
+ unless current_last_build_link_target_path.nil?
69
+ File.symlink current_last_build_link_target_path, previous_build_link_path unless File.exists? previous_build_link_path
70
+ end
71
+
72
+ safely_remove_link last_build_link_path
73
+ File.symlink last_build_path, last_build_link_path unless File.exists? last_build_link_path
74
+
75
+ if config[:'tag-build']
76
+ build_tag_path = File.join project.build_root_path, config[:'tag-build']
77
+ safely_remove_link build_tag_path
78
+ File.symlink last_build_path, build_tag_path unless File.exists? build_tag_path
79
+ end
80
+ end
81
+
82
+
83
+ def safely_remove_link(link)
84
+ if File.exists? link
85
+ if File.symlink? link
86
+ File.unlink link
87
+ else
88
+ logger.warn "Warning '#{link}' is not a symlink !!"
89
+ return false
90
+ end
91
+ else
92
+ logger.debug "No file/link to delete ('#{link}')"
93
+ end
94
+ true
95
+ end
96
+
97
+
49
98
  def build_entity(entity_to_build, target_path)
50
99
  logger.info "Building #{entity_to_build.as_path} in '#{target_path}'"
51
100
  render_source entity_to_build.templates_path, target_path, main_entry_point: entity_to_build.as_path
52
101
  logger.info "Detemplatized filed generated in '#{target_path}'"
102
+ manage_build_links target_path
53
103
  target_plugin_name = entity_to_build.buildable_by
54
104
  if target_plugin_name.empty?
55
105
  post_build_hook entity_to_build, target_path
@@ -67,7 +117,7 @@ module PowerStencil
67
117
  script_to_execute = File.expand_path File.join(files_path, entity_to_build.post_process.process)
68
118
  exec_options = {message: "Running '#{script_to_execute}'"}
69
119
  exec_options[:show_output] = true if config[:verbose]
70
- process_report = safely_exec_command script_to_execute, exec_options
120
+ process_report = safely_exec_command "'#{script_to_execute}'", exec_options
71
121
  unless process_report.exit_status.exitstatus == 0
72
122
  raise PowerStencil::Error, "Process `#{process_report.command}` failed and returned exit code '#{process_report.exit_status.exitstatus}'"
73
123
  end
@@ -47,8 +47,9 @@ module PowerStencil
47
47
  edit: PowerStencil::CommandProcessors::Edit,
48
48
  delete: PowerStencil::CommandProcessors::Delete,
49
49
  shell: PowerStencil::CommandProcessors::Shell,
50
- :'new-plugin' => PowerStencil::CommandProcessors::NewPlugin,
51
- build: PowerStencil::CommandProcessors::Build
50
+ plugin: PowerStencil::CommandProcessors::Plugin,
51
+ build: PowerStencil::CommandProcessors::Build,
52
+ describe: PowerStencil::CommandProcessors::Describe
52
53
  }.each do |command_name, processor|
53
54
  command_line_manager.register_processor command_line_manager.command_by_alias(command_name),
54
55
  processor.new
@@ -19,6 +19,14 @@ module PowerStencil
19
19
  File.join build_root_path, timestamped_uniq_dir(seed, Time.now)
20
20
  end
21
21
 
22
+ def last_build_stable_link_path
23
+ File.join build_root_path, PowerStencil.config[:project_build_last_stable_path]
24
+ end
25
+
26
+ def previous_build_stable_link_path
27
+ File.join build_root_path, PowerStencil.config[:project_build_previous_stable_path]
28
+ end
29
+
22
30
  def build_root_path
23
31
  File.join project_root, PowerStencil.config[:project_build_root_directory_name]
24
32
  end
@@ -5,7 +5,11 @@ module PowerStencil
5
5
 
6
6
  def check_project_version
7
7
  return if project_version_valid?
8
- raise PowerStencil::Error, msg
8
+ msg = <<~EOM
9
+ This PowerStencil project requires a version of PowerStencil >= #{config[:min_power_stencil_version]} (You are using version #{PowerStencil::VERSION}) !
10
+ You should consider upgrading by doing 'gem install power_stencil'...
11
+ EOM
12
+ raise PowerStencil::Error, msg.chomp
9
13
  end
10
14
 
11
15
  private
@@ -0,0 +1,15 @@
1
+ module PowerStencil
2
+ module Utils
3
+
4
+ module Os
5
+
6
+ WINDOWS_RUBY_FLAVOURS = %w(mswin32 cygwin mingw bccwin)
7
+
8
+ def self.windows?
9
+ WINDOWS_RUBY_FLAVOURS.include? RbConfig::CONFIG['host_os']
10
+ end
11
+
12
+ end
13
+
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module PowerStencil
2
- VERSION = '0.4.15'.freeze
2
+ VERSION = '0.4.20'.freeze
3
3
  end
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency 'climatic', '~> 0.2.29'
29
29
  spec.add_dependency 'dir_glob_ignore', '~> 0.3'
30
- spec.add_dependency 'universe_compiler', '~> 0.4.3'
30
+ spec.add_dependency 'universe_compiler', '~> 0.5.1'
31
31
  spec.add_dependency 'pry'
32
32
 
33
33
  source_code_uri = 'https://gitlab.com/tools4devops/power_stencil'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power_stencil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.15
4
+ version: 0.4.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Briais
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-03 00:00:00.000000000 Z
11
+ date: 2019-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.4.3
89
+ version: 0.5.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.4.3
96
+ version: 0.5.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -191,12 +191,13 @@ files:
191
191
  - lib/power_stencil/command_processors/check.rb
192
192
  - lib/power_stencil/command_processors/create.rb
193
193
  - lib/power_stencil/command_processors/delete.rb
194
+ - lib/power_stencil/command_processors/describe.rb
194
195
  - lib/power_stencil/command_processors/edit.rb
195
196
  - lib/power_stencil/command_processors/entity_helper.rb
196
197
  - lib/power_stencil/command_processors/get.rb
197
198
  - lib/power_stencil/command_processors/info.rb
198
199
  - lib/power_stencil/command_processors/init.rb
199
- - lib/power_stencil/command_processors/new_plugin.rb
200
+ - lib/power_stencil/command_processors/plugin.rb
200
201
  - lib/power_stencil/command_processors/root.rb
201
202
  - lib/power_stencil/command_processors/shell.rb
202
203
  - lib/power_stencil/command_processors/trace_helper.rb
@@ -247,6 +248,7 @@ files:
247
248
  - lib/power_stencil/utils/file_helper.rb
248
249
  - lib/power_stencil/utils/gem_utils.rb
249
250
  - lib/power_stencil/utils/graphviz.rb
251
+ - lib/power_stencil/utils/os.rb
250
252
  - lib/power_stencil/utils/secure_require.rb
251
253
  - lib/power_stencil/utils/semantic_version.rb
252
254
  - lib/power_stencil/version.rb
@@ -259,7 +261,7 @@ metadata:
259
261
  documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
260
262
  source_code_uri: https://gitlab.com/tools4devops/power_stencil
261
263
  homepage_uri: https://powerstencil.brizone.org/
262
- post_install_message: "\nThank you for installing PowerStencil 0.4.15 !\nFrom the
264
+ post_install_message: "\nThank you for installing PowerStencil 0.4.20 !\nFrom the
263
265
  command line you can run `power_stencil --help`\nIf your shell is not completing
264
266
  the command:\n If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial
265
267
  Website : https://powerstencil.brizone.org/\nFull documentation here :
@@ -1,31 +0,0 @@
1
- module PowerStencil
2
- module CommandProcessors
3
-
4
- class NewPlugin
5
-
6
- include Climatic::Script::UnimplementedProcessor
7
- include Climatic::Proxy
8
- include PowerStencil::Project::Proxy
9
-
10
- def execute
11
- if config.command_line_layer.extra_parameters.empty?
12
- raise PowerStencil::Error, 'Please specify a plugin name!'
13
- end
14
- config.command_line_layer.extra_parameters.each do |plugin_name|
15
- begin
16
- target_path = File.join project.project_plugin_path(plugin_name)
17
- project.create_plugin_tree plugin_name, target_path
18
- puts "Generated new plugin '#{plugin_name}'"
19
- rescue => e
20
- msg = "Could not create plugin '#{plugin_name}' because '#{e.message}'"
21
- puts msg
22
- logger.error "Could not create plugin '#{plugin_name}' because '#{e.message}'"
23
- logger.debug PowerStencil::Error.report_error(e)
24
- end
25
- end
26
- end
27
-
28
- end
29
-
30
- end
31
- end