power_stencil 0.4.16 → 0.4.17

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: b10ddad9f41bfb08e3d0917d4226038c4f80804c
4
- data.tar.gz: 614c5bf32a33a9e55ce3b62f9a9d6a1e24db3b39
3
+ metadata.gz: 090721c55ffc99653d0be5a9b923c45c175cd538
4
+ data.tar.gz: 80ba7636a39ceed4f6403cef1170206ca33ee8d4
5
5
  SHA512:
6
- metadata.gz: 23e52fc919f98bb92b173e4b5e945028b78a6a14597646ffc6fef7f39fbafe9be0d0bae32b8ee247537144ccb7ccd3206eb8d795711003879b76557f1b925dc7
7
- data.tar.gz: f2af26ceb8859707ff7b721b2346c93fafca817c9253ac65b9b9840205f21833798bd39606f377715ed0c0ce6849656e7943b293e306ab2edca026621c774f6e
6
+ metadata.gz: 601aa0ba6a72326dc3dab22ecc0304ac26c33046dd0f208c1bd2e045d0767c4624a69027389dc76b2dc154f38eb55750e7229fffcbaee853aa891b77368d2e08
7
+ data.tar.gz: 87f465b799e7802715383c226e8acd57c4eb0cc50ff336b7666eb22802b876662554b43d0e482a2f0fc84b15f4323e047484dc19543413dd47463024c2bb99d8
data/doc/builds.md CHANGED
@@ -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].
@@ -268,4 +268,17 @@
268
268
  parallelized:
269
269
  :type: bool
270
270
  :summary: Parallelizes builds if possible
271
-
271
+ tag-build:
272
+ :type: string
273
+ :summary: Tags the build with a specific name
274
+ :long_aliases:
275
+ - tag
276
+ :short_aliases:
277
+ - t
278
+ target-path:
279
+ :type: string
280
+ :summary: Build into specified directory
281
+ :long_aliases:
282
+ - path
283
+ :short_aliases:
284
+ - 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
@@ -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]
@@ -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
@@ -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
@@ -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.16'.freeze
2
+ VERSION = '0.4.17'.freeze
3
3
  end
data/lib/power_stencil.rb CHANGED
@@ -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'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power_stencil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.16
4
+ version: 0.4.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Briais
@@ -247,6 +247,7 @@ files:
247
247
  - lib/power_stencil/utils/file_helper.rb
248
248
  - lib/power_stencil/utils/gem_utils.rb
249
249
  - lib/power_stencil/utils/graphviz.rb
250
+ - lib/power_stencil/utils/os.rb
250
251
  - lib/power_stencil/utils/secure_require.rb
251
252
  - lib/power_stencil/utils/semantic_version.rb
252
253
  - lib/power_stencil/version.rb
@@ -259,7 +260,7 @@ metadata:
259
260
  documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
260
261
  source_code_uri: https://gitlab.com/tools4devops/power_stencil
261
262
  homepage_uri: https://powerstencil.brizone.org/
262
- post_install_message: "\nThank you for installing PowerStencil 0.4.16 !\nFrom the
263
+ post_install_message: "\nThank you for installing PowerStencil 0.4.17 !\nFrom the
263
264
  command line you can run `power_stencil --help`\nIf your shell is not completing
264
265
  the command:\n If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial
265
266
  Website : https://powerstencil.brizone.org/\nFull documentation here :