power_stencil 0.4.12 → 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: 1f0cd3595adda0996cd964ee0a4a8f7c07ebb27e
4
- data.tar.gz: 0b60844a7c8bcae8b410a0a0db76137f80cc04c5
3
+ metadata.gz: 090721c55ffc99653d0be5a9b923c45c175cd538
4
+ data.tar.gz: 80ba7636a39ceed4f6403cef1170206ca33ee8d4
5
5
  SHA512:
6
- metadata.gz: 8de37294748189b813890f137b72bd0f42eb179038ec790a12a4df0c4005c0f498e3fd7b62f40f8bc96a2845a78a0dcf4175d38d1b41f4aa77531dfc3fa92ce2
7
- data.tar.gz: a76e25e2d10d5c314a1da7fd3918a9da1bdb9fda88a886c2074736c2d69a30a4f1b534826441e966040ae744f0f3b797a3c32d00edcc8b357ce58cde625111d5
6
+ metadata.gz: 601aa0ba6a72326dc3dab22ecc0304ac26c33046dd0f208c1bd2e045d0767c4624a69027389dc76b2dc154f38eb55750e7229fffcbaee853aa891b77368d2e08
7
+ data.tar.gz: 87f465b799e7802715383c226e8acd57c4eb0cc50ff336b7666eb22802b876662554b43d0e482a2f0fc84b15f4323e047484dc19543413dd47463024c2bb99d8
data/README.md CHANGED
@@ -75,10 +75,12 @@ Then you can install the `PowerStencil` gem by issuing the usual:
75
75
 
76
76
  $ gem install power_stencil
77
77
 
78
- If you want to create graphviz graphs, you probably may want to install it for your system. If you are using an _apt-based_ system like Ubuntu or Debian it may probably be as simple as:
78
+ If you want to create [Graphviz] graphs, you probably may want to install it for your system. If you are using an _apt-based_ system like Ubuntu or Debian it may probably be as simple as:
79
79
 
80
80
  $ sudo apt install graphviz
81
81
 
82
+ If you use Windows, install [Graphviz] using the stable version for Windows and add the `bin` directory to the `%PATH%`.
83
+
82
84
  # Usage
83
85
 
84
86
  ## Help
@@ -246,4 +248,5 @@ Everyone interacting in the PowerStencil project’s codebases, issue trackers,
246
248
  [Haml]: http://haml.info/ "The templating engine for XML-like documents"
247
249
  [Ruby]: https://www.ruby-lang.org "The powerful Ruby language"
248
250
  [Rails]: https://rubyonrails.org/ "The Ruby on Rails framework"
249
- [PowerStencil site]: https://powerstencil.brizone.org "Official PowerStencil website"
251
+ [PowerStencil site]: https://powerstencil.brizone.org "Official PowerStencil website"
252
+ [Graphviz]: https://www.graphviz.org/ "Graph Visualization Software"
@@ -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].
@@ -984,4 +984,4 @@ Now you know an entity type is just a regular Ruby class. As such you could add
984
984
  [Ruby On Rails]: https://rubyonrails.org/ "One of the best Web framework"
985
985
  [universe_compiler]: https://gitlab.com/tools4devops/universe_compiler "The underlying engine to manage entities and compilation !"
986
986
  [`universe_compiler` advanced relations documentation]: https://gitlab.com/tools4devops/universe_compiler#advanced-relations "Advanced relational features"
987
- [Graphviz]: (https://www.graphviz.org/) "Graph Visualization Software"
987
+ [Graphviz]: https://www.graphviz.org/ "Graph Visualization Software"
data/doc/faq.md CHANGED
@@ -65,7 +65,9 @@ So the two main remaining contenders are JSON and YAML. Although there is no rea
65
65
 
66
66
  As such, even if I never tested, I would expect it to probably work out of the box on MacOS, BSD or other Unices supporting Ruby 2.2+.
67
67
 
68
- Regarding Windows, I stopped using spywareOS years ago so I can't really tell you. Last time I tried using Ruby on Windows (maybe 10 years ago), I did face a lot of dependency issues. Maybe things are better now, but I have no idea. As far as I understood you can now have an Ubuntu running on top of Windows 10 as a kind of blessed VM. I would probably more go this way...
68
+ ~~Regarding Windows, I stopped using spywareOS years ago so I can't really tell you. Last time I tried using Ruby on Windows (maybe 10 years ago), I did face a lot of dependency issues. Maybe things are better now, but I have no idea. As far as I understood you can now have an Ubuntu running on top of Windows 10 as a kind of blessed VM. I would probably more go this way...~~
69
+
70
+ I had the opportunity to have access to a Windows VM and tested `PowerStencil`. I had to fix a couple of issues related to the way Windows manages concurrent access to files (:rofl:) , but **since version `0.4.14`, `PowerStencil` should now fully work under Windows**, including generating files using GraphViz if it is installed and correctly set in the `%PATH%`. I used the standard Ruby for Windows with no hack.
69
71
 
70
72
 
71
73
  # What is the status of `PowerStencil` ?
@@ -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
@@ -71,6 +75,8 @@
71
75
 
72
76
  # Files matching particular patterns can be changed on the fly
73
77
  :file_renaming_patterns:
78
+ # Specific .gitignore file for Windows
79
+ ^(.+)\.zzzgitignore\.erb$: '\1.gitignore'
74
80
  # Erb files
75
81
  ^(.+)\.erb$: '\1'
76
82
 
@@ -0,0 +1,12 @@
1
+ PowerStencil plugins
2
+ ====================
3
+
4
+
5
+ In this directory, you can define project specific local plugins.
6
+ You should create them using the `PowerStencil` command-line.
7
+
8
+ $ power_stencil new-plugin myplugin
9
+
10
+ __It is strongly advised to keep this directory under source control__
11
+
12
+ This should be the PowerStencil default behaviour.
@@ -1,12 +1,10 @@
1
- PowerStencil project templates
2
- ==============================
1
+ PowerStencil project templates templates
2
+ ========================================
3
3
 
4
4
 
5
- In this directory, you can define project specific templates for entities
6
- defined locally in this project.
5
+ In this directory, you can define project specific templates for entity types defined locally in this project.
7
6
 
8
- Templates can be a whole tree structure in a directory named from the entity
9
- type of entities you defined in `entity_definitions` folder that are `buildable`.
7
+ Templates can be a whole tree structure in a directory named from the entity type of entities you defined in `entity_definitions` folder that are `buildable`.
10
8
 
11
9
  __It is strongly advised to keep this directory under source control__
12
10
 
@@ -2,3 +2,6 @@
2
2
  # Generated on the <%= Time.now %>
3
3
 
4
4
  echo "Nothing to do... Easy task..."
5
+
6
+ # Return 0 if the build succeeds
7
+ exit 0
@@ -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'
@@ -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
@@ -67,7 +117,11 @@ 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
- safely_exec_command script_to_execute, exec_options
120
+ process_report = safely_exec_command "'#{script_to_execute}'", exec_options
121
+ unless process_report.exit_status.exitstatus == 0
122
+ raise PowerStencil::Error, "Process `#{process_report.command}` failed and returned exit code '#{process_report.exit_status.exitstatus}'"
123
+ end
124
+ process_report
71
125
  end
72
126
  end
73
127
 
@@ -59,7 +59,7 @@ module PowerStencil
59
59
  unless files_not_to_rename.ignore_file? src_file
60
60
  config[:file_renaming_patterns].each do |regexp_str, replacement|
61
61
  regexp = Regexp.new regexp_str
62
- next if (dest_file =~ regexp).nil?
62
+ next if (src_file =~ regexp).nil?
63
63
  dest_file = dest_file.gsub regexp, replacement
64
64
  break
65
65
  end
@@ -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
@@ -12,7 +12,7 @@ module PowerStencil
12
12
  # Dir.glob_with_ignore_file ignore_file, base_dir, *glob_args, &block
13
13
  file_pattern = "#{source}/**/*"
14
14
  res = {}
15
- Dir.glob_with_ignore_file ignore_files_pattern, source, file_pattern, File::FNM_DOTMATCH do |original_file|
15
+ Dir.glob_with_ignore_file(ignore_files_pattern, source, file_pattern, File::FNM_DOTMATCH).sort.each do |original_file|
16
16
  logger.debug "Processing '#{original_file}'"
17
17
  res[original_file] = destination_file(original_file, source, destination)
18
18
  if block_given?
@@ -25,14 +25,21 @@ module PowerStencil
25
25
  def securely_edit_entity(entity, &modifications_validation_block)
26
26
  initial_uri = entity.source_uri
27
27
  modified_entity = nil
28
- Tempfile.create(["#{entity.type.to_s}_#{entity.name.to_s}", '.yaml']) do |tmpfile|
28
+ tmpfile = Tempfile.create(["#{entity.type.to_s}_#{entity.name.to_s}", '.yaml'])
29
+ tmpfile_path = tmpfile.path
30
+ begin
29
31
  tmpfile.puts entity.to_yaml
30
32
  tmpfile.flush
31
- securely_edit_file(tmpfile, &modifications_validation_block)
32
- modified_entity = UniverseCompiler::Entity::Persistence.load tmpfile
33
- modified_entity.source_uri = initial_uri
33
+ ensure
34
+ tmpfile.close
34
35
  end
36
+ securely_edit_file(tmpfile_path, &modifications_validation_block)
37
+ modified_entity = UniverseCompiler::Entity::Persistence.load tmpfile_path
38
+ modified_entity.source_uri = initial_uri
35
39
  return modified_entity
40
+ ensure
41
+ tmpfile.close
42
+ File.unlink tmpfile
36
43
  end
37
44
 
38
45
  def securely_edit_file(file, &modifications_validation_block)
@@ -41,7 +48,9 @@ module PowerStencil
41
48
  end
42
49
  ext = File.extname file
43
50
  base = File.basename file, ext
44
- tmp_file_path = Tempfile.new([base, ext]).path
51
+ tmp_file = Tempfile.create([base, ext])
52
+ tmp_file_path = tmp_file.path
53
+ tmp_file.close
45
54
  retry_count = 1
46
55
  begin
47
56
  FileUtils.copy file, tmp_file_path if retry_count == 1
@@ -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.12'.freeze
2
+ VERSION = '0.4.17'.freeze
3
3
  end
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.12
4
+ version: 0.4.17
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-09-28 00:00:00.000000000 Z
11
+ date: 2019-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -171,18 +171,19 @@ files:
171
171
  - etc/templates/plugin_definition/spec/spec_helper.rb
172
172
  - etc/templates/plugin_definition/spec/{entity}_spec.rb
173
173
  - etc/templates/project/.copy_ignore
174
- - etc/templates/project/.gitignore.erb
175
174
  - etc/templates/project/.ps_project/entities/.gitkeep
176
175
  - etc/templates/project/.ps_project/entities/README.md
177
176
  - etc/templates/project/.ps_project/entity_definitions/.gitkeep
178
177
  - etc/templates/project/.ps_project/entity_definitions/README.md
179
178
  - etc/templates/project/.ps_project/personal-config.yaml
180
179
  - etc/templates/project/.ps_project/plugins/.gitkeep
180
+ - etc/templates/project/.ps_project/plugins/README.md
181
181
  - etc/templates/project/.ps_project/templates-templates/.gitkeep
182
182
  - etc/templates/project/.ps_project/templates-templates/README.md
183
183
  - etc/templates/project/.ps_project/user_entities/.gitkeep
184
184
  - etc/templates/project/.ps_project/user_entities/README.md
185
185
  - etc/templates/project/.ps_project/versioned-config.yaml
186
+ - etc/templates/project/.zzzgitignore.erb
186
187
  - etc/templates/simple_exec/main.sh
187
188
  - exe/power_stencil
188
189
  - lib/power_stencil.rb
@@ -246,6 +247,7 @@ files:
246
247
  - lib/power_stencil/utils/file_helper.rb
247
248
  - lib/power_stencil/utils/gem_utils.rb
248
249
  - lib/power_stencil/utils/graphviz.rb
250
+ - lib/power_stencil/utils/os.rb
249
251
  - lib/power_stencil/utils/secure_require.rb
250
252
  - lib/power_stencil/utils/semantic_version.rb
251
253
  - lib/power_stencil/version.rb
@@ -258,7 +260,7 @@ metadata:
258
260
  documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
259
261
  source_code_uri: https://gitlab.com/tools4devops/power_stencil
260
262
  homepage_uri: https://powerstencil.brizone.org/
261
- post_install_message: "\nThank you for installing PowerStencil 0.4.12 !\nFrom the
263
+ post_install_message: "\nThank you for installing PowerStencil 0.4.17 !\nFrom the
262
264
  command line you can run `power_stencil --help`\nIf your shell is not completing
263
265
  the command:\n If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial
264
266
  Website : https://powerstencil.brizone.org/\nFull documentation here :