power_stencil 0.8.11 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +27 -15
- data/doc/faq.md +4 -7
- data/doc/git_integration.md +38 -12
- data/etc/meta_templates/plugin_seed/README.md +133 -0
- data/etc/meta_templates/plugin_seed/psplugin_{entity}.gemspec +20 -5
- data/etc/meta_templates/plugin_seed/spec/project_helper.rb +50 -0
- data/etc/meta_templates/plugin_seed/spec/spec_helper.rb +16 -0
- data/etc/meta_templates/plugin_seed/spec/{entity}_spec.rb +30 -0
- data/etc/power_stencil.yaml +6 -1
- data/etc/templates/plugin_definition/README.md +110 -20
- data/etc/templates/plugin_definition/psplugin_{entity}.gemspec +20 -5
- data/etc/templates/plugin_definition/spec/project_helper.rb +50 -0
- data/etc/templates/plugin_definition/spec/spec_helper.rb +4 -2
- data/etc/templates/plugin_definition/spec/{entity}_spec.rb +24 -3
- data/etc/templates/zsh_command_line_completion/_power_stencil.sh.erb +18 -8
- data/lib/power_stencil.rb +4 -0
- data/lib/power_stencil/command_processors/adm.rb +29 -1
- data/lib/power_stencil/command_processors/create.rb +1 -1
- data/lib/power_stencil/dsl/completion.rb +37 -0
- data/lib/power_stencil/dsl/plugin_generation.rb +4 -0
- data/lib/power_stencil/engine/base.rb +2 -0
- data/lib/power_stencil/engine/build_handling.rb +5 -0
- data/lib/power_stencil/engine/directory_processor.rb +20 -1
- data/lib/power_stencil/engine/entities_handling.rb +2 -2
- data/lib/power_stencil/engine/renderers/haml.rb +21 -0
- data/lib/power_stencil/initializer.rb +6 -1
- data/lib/power_stencil/plugins/command_line.rb +3 -1
- data/lib/power_stencil/project/completion.rb +3 -5
- data/lib/power_stencil/ultra_command_line/command_line_manager.rb +35 -0
- data/lib/power_stencil/ultra_command_line/option_definition.rb +5 -0
- data/lib/power_stencil/ultra_command_line/providers_manager.rb +21 -0
- data/lib/power_stencil/ultra_command_line/sub_command.rb +12 -0
- data/lib/power_stencil/utils/completion.rb +19 -9
- data/lib/power_stencil/version.rb +1 -1
- data/power_stencil.gemspec +2 -1
- metadata +34 -11
@@ -2,6 +2,7 @@ require 'power_stencil/engine/entities_definitions'
|
|
2
2
|
require 'power_stencil/engine/directory_processor'
|
3
3
|
|
4
4
|
require 'power_stencil/engine/renderers/erb'
|
5
|
+
require 'power_stencil/engine/renderers/haml'
|
5
6
|
require 'power_stencil/dsl/base'
|
6
7
|
require 'power_stencil/dsl/plugin_generation'
|
7
8
|
require 'power_stencil/dsl/completion'
|
@@ -18,6 +19,7 @@ module PowerStencil
|
|
18
19
|
include PowerStencil::Engine::DirectoryProcessor
|
19
20
|
|
20
21
|
include PowerStencil::Engine::Renderers::Erb
|
22
|
+
include PowerStencil::Engine::Renderers::Haml
|
21
23
|
|
22
24
|
attr_accessor :dsl
|
23
25
|
attr_reader :root_universe
|
@@ -95,8 +95,11 @@ module PowerStencil
|
|
95
95
|
|
96
96
|
|
97
97
|
def build_entity(entity_to_build, target_path)
|
98
|
+
initial_directory = Dir.pwd
|
98
99
|
target_plugin_name = entity_to_build.buildable_by.to_s
|
99
100
|
default_build entity_to_build, target_path
|
101
|
+
# Post processing executed from generated directory (#11)
|
102
|
+
Dir.chdir target_path
|
100
103
|
|
101
104
|
if target_plugin_name.empty?
|
102
105
|
post_build_hook entity_to_build, target_path
|
@@ -106,6 +109,8 @@ module PowerStencil
|
|
106
109
|
raise PowerStencil::Error, "Plugin '#{target_plugin_name}' has no build capability !" unless target_plugin.capabilities[:build]
|
107
110
|
target_plugin.post_build_hook entity_to_build, target_path
|
108
111
|
end
|
112
|
+
ensure
|
113
|
+
Dir.chdir initial_directory
|
109
114
|
end
|
110
115
|
|
111
116
|
def default_build(entity_to_build, target_path)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'erb'
|
3
|
+
require 'haml'
|
4
|
+
|
3
5
|
|
4
6
|
module PowerStencil
|
5
7
|
module Engine
|
@@ -30,10 +32,27 @@ module PowerStencil
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
ensure
|
33
|
-
@
|
35
|
+
@files_not_to_rename = nil
|
34
36
|
@files_not_to_render = nil
|
35
37
|
end
|
36
38
|
|
39
|
+
|
40
|
+
def render_single_template_file(source_template, destination_file, main_entry_point: nil)
|
41
|
+
compiled_universe = root_universe.compile scenario: config[:scenario]
|
42
|
+
puts_and_logs 'Entities analysis completed.'
|
43
|
+
|
44
|
+
logger.info 'Generating target file...'
|
45
|
+
|
46
|
+
process_file source_template, destination_file,
|
47
|
+
compiled_universe,
|
48
|
+
overwrite_files: true,
|
49
|
+
main_entry_point: main_entry_point
|
50
|
+
ensure
|
51
|
+
@files_not_to_rename = nil
|
52
|
+
@files_not_to_render = nil
|
53
|
+
end
|
54
|
+
|
55
|
+
|
37
56
|
private
|
38
57
|
|
39
58
|
def detemplatized_file_name(filename, replacement_text)
|
@@ -34,11 +34,11 @@ module PowerStencil
|
|
34
34
|
@available_entities_hash.keys
|
35
35
|
end
|
36
36
|
|
37
|
-
def entity(type, name, universe)
|
37
|
+
def entity(type, name, universe = self.root_universe)
|
38
38
|
universe.get_entity type, name
|
39
39
|
end
|
40
40
|
|
41
|
-
def entities(universe, criterion: nil, value: nil, &filter_block)
|
41
|
+
def entities(universe = self.root_universe, criterion: nil, value: nil, &filter_block)
|
42
42
|
universe.get_entities criterion: criterion, value: value, &filter_block
|
43
43
|
end
|
44
44
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module Engine
|
3
|
+
module Renderers
|
4
|
+
|
5
|
+
module Haml
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def render_haml_template(source, context)
|
10
|
+
logger.debug "Using HAML to render file '#{source}'"
|
11
|
+
::Haml::Engine.new(File.read source).render(context)
|
12
|
+
rescue => e
|
13
|
+
logger.debug PowerStencil::Error.report_error(e)
|
14
|
+
raise PowerStencil::Error, "Error rendering '#{source}': '#{e.message}'"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -55,14 +55,19 @@ module PowerStencil
|
|
55
55
|
describe: PowerStencil::CommandProcessors::Describe,
|
56
56
|
adm: PowerStencil::CommandProcessors::Adm
|
57
57
|
}.each do |command_name, processor|
|
58
|
-
|
58
|
+
command = command_line_manager.command_by_alias(command_name)
|
59
|
+
command_line_manager.register_processor command,
|
59
60
|
processor.new
|
61
|
+
command.add_provider self
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
63
65
|
def setup_climatic(cmd_line_args)
|
64
66
|
mngr = Climatic::ConfigLayers::CommandLineLayer.build_command_line_manager base_commands_definition_file
|
65
67
|
Climatic.bootstrap cmd_line_args: cmd_line_args, command_manager: mngr
|
68
|
+
mngr.commands.each do |command|
|
69
|
+
command.add_provider PowerStencil
|
70
|
+
end
|
66
71
|
begin
|
67
72
|
# Fix command line layer priority to allow a bigger number of plugins
|
68
73
|
config.command_line_layer.priority = 999
|
@@ -10,7 +10,9 @@ module PowerStencil
|
|
10
10
|
clm = PowerStencil.command_line_manager
|
11
11
|
plugin_definition[:processors].each do |processors_name, processor|
|
12
12
|
processor_class = Object.const_get processor
|
13
|
-
|
13
|
+
command = clm.command_by_alias(processors_name)
|
14
|
+
clm.register_processor command, processor_class.new
|
15
|
+
command.add_provider self
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
@@ -6,17 +6,15 @@ module PowerStencil
|
|
6
6
|
def query_for_completion(query_type)
|
7
7
|
case query_type
|
8
8
|
when :entities
|
9
|
-
engine.entities
|
9
|
+
engine.entities.map(&:as_path).sort
|
10
10
|
when :'entity-types'
|
11
11
|
engine.available_entity_types.sort
|
12
12
|
when :scenario
|
13
|
-
engine.entities(
|
13
|
+
engine.entities(criterion: :by_type, value: :entity_override) do |entity|
|
14
14
|
!entity.scenario.nil? and !entity.scenario.empty?
|
15
15
|
end.map(&:scenario).sort.uniq
|
16
16
|
when :buildable
|
17
|
-
engine.entities(
|
18
|
-
entity.buildable?
|
19
|
-
end.map(&:as_path).sort
|
17
|
+
engine.entities(&:buildable?).map(&:as_path).sort
|
20
18
|
else
|
21
19
|
raise PowerStencil::Error, "'#{query_type}' is not a valid query type for completion !"
|
22
20
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class UltraCommandLine::Manager::Base
|
2
|
+
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def add_provider_for(command_or_option, provider)
|
6
|
+
providers = providers_for command_or_option
|
7
|
+
providers << provider unless providers.include? provider
|
8
|
+
end
|
9
|
+
|
10
|
+
def providers_for(command_or_option)
|
11
|
+
default_command_data = {options: {}, providers: []}
|
12
|
+
case command_or_option
|
13
|
+
when UltraCommandLine::Commands::SubCommand
|
14
|
+
sc = command_or_option
|
15
|
+
internal_provider_mapping[sc.name] ||= default_command_data
|
16
|
+
internal_provider_mapping[sc.name][:providers]
|
17
|
+
when UltraCommandLine::Commands::OptionDefinition
|
18
|
+
sco = command_or_option
|
19
|
+
internal_provider_mapping[sco.sub_command.name] ||= default_command_data
|
20
|
+
internal_provider_mapping[sco.sub_command.name][:options][sco.name] ||= []
|
21
|
+
internal_provider_mapping[sco.sub_command.name][:options][sco.name]
|
22
|
+
else
|
23
|
+
raise PowerStencil::Error, "Invalid command or option"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# private
|
28
|
+
|
29
|
+
def internal_provider_mapping
|
30
|
+
@internal_provider_mapping ||= {}
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module UltraCommandLine
|
3
|
+
|
4
|
+
module ProvidersManager
|
5
|
+
|
6
|
+
def providers_manager
|
7
|
+
PowerStencil.command_line_manager.class
|
8
|
+
end
|
9
|
+
|
10
|
+
def providers
|
11
|
+
providers_manager.providers_for self
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_provider(provider)
|
15
|
+
providers_manager.add_provider_for self, provider
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -3,24 +3,34 @@ module PowerStencil
|
|
3
3
|
|
4
4
|
module Completion
|
5
5
|
|
6
|
-
|
6
|
+
class FakeIgnoreList
|
7
|
+
attr_accessor :return_value
|
8
|
+
def ignore_file?(file)
|
9
|
+
return_value
|
10
|
+
end
|
11
|
+
end
|
7
12
|
|
8
|
-
|
13
|
+
include PowerStencil::Utils::DirectoryProcessor
|
9
14
|
|
10
|
-
|
11
|
-
config.executable_gem_layer[:file_renaming_patterns] = {'(.+)_power_stencil.sh.erb' => '\1_power_stencil' }
|
15
|
+
def generate_zsh_completion(script_name, target_file, generating_project_completion)
|
12
16
|
|
13
|
-
target_dir = File.expand_path config[:completion_target][:zsh][:completion_dir]
|
14
17
|
source_dir = File.join PowerStencil::Project::Paths.system_templates_templates_path, 'zsh_command_line_completion'
|
18
|
+
source_template = File.join source_dir, '_power_stencil.sh.erb'
|
15
19
|
|
16
20
|
engine = PowerStencil::Engine::InitEngine.new
|
17
21
|
engine.dsl = PowerStencil::Dsl::Completion
|
18
22
|
engine.dsl.script_name = script_name
|
19
|
-
engine.
|
23
|
+
engine.dsl.generating_project_completion = generating_project_completion
|
24
|
+
|
25
|
+
engine.instance_eval do
|
26
|
+
@files_not_to_rename = FakeIgnoreList.new
|
27
|
+
files_not_to_rename.return_value = true
|
28
|
+
@files_not_to_render = FakeIgnoreList.new
|
29
|
+
files_not_to_render.return_value = false
|
30
|
+
end
|
31
|
+
|
32
|
+
engine.render_single_template_file source_template, target_file
|
20
33
|
|
21
|
-
puts_and_logs "zsh auto_completion has been installed in '#{File.join target_dir, "_#{script_name}"}'.", check_verbose: false
|
22
|
-
puts "You should ensure you have something like 'fpath=(#{target_dir} $fpath)' in your ~/.zshrc file..."
|
23
|
-
puts 'You may have to relog for changes to be applied.'
|
24
34
|
end
|
25
35
|
|
26
36
|
end
|
data/power_stencil.gemspec
CHANGED
@@ -25,11 +25,12 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
26
26
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
27
|
|
28
|
-
spec.add_dependency 'climatic', '~> 0.2.
|
28
|
+
spec.add_dependency 'climatic', '~> 0.2.34'
|
29
29
|
spec.add_dependency 'dir_glob_ignore', '~> 0.3'
|
30
30
|
spec.add_dependency 'universe_compiler', '~> 0.5.5'
|
31
31
|
spec.add_dependency 'pry'
|
32
32
|
spec.add_dependency 'git' , '~> 1.5.0'
|
33
|
+
spec.add_dependency 'haml', '~> 5.1.2'
|
33
34
|
|
34
35
|
source_code_uri = 'https://gitlab.com/tools4devops/power_stencil'
|
35
36
|
|
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
|
+
version: 0.9.1
|
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-11-
|
11
|
+
date: 2019-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.2.
|
61
|
+
version: 0.2.34
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.2.
|
68
|
+
version: 0.2.34
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: dir_glob_ignore
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.5.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: haml
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 5.1.2
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 5.1.2
|
125
139
|
description: PowerStencil is the Swiss-army knife templating workflow for developers
|
126
140
|
and ops.
|
127
141
|
email:
|
@@ -154,6 +168,7 @@ files:
|
|
154
168
|
- doc/plugins.md
|
155
169
|
- doc/templates.md
|
156
170
|
- etc/base_commands_definition.yml
|
171
|
+
- etc/meta_templates/plugin_seed/README.md
|
157
172
|
- etc/meta_templates/plugin_seed/etc/command_line.yaml
|
158
173
|
- etc/meta_templates/plugin_seed/etc/plugin_capabilities.yaml
|
159
174
|
- etc/meta_templates/plugin_seed/etc/plugin_config.yaml
|
@@ -168,6 +183,9 @@ files:
|
|
168
183
|
- etc/meta_templates/plugin_seed/lib/{entity}/version.rb.erb
|
169
184
|
- etc/meta_templates/plugin_seed/lib/{entity}/{entity}_processor.rb.erb
|
170
185
|
- etc/meta_templates/plugin_seed/psplugin_{entity}.gemspec
|
186
|
+
- etc/meta_templates/plugin_seed/spec/project_helper.rb
|
187
|
+
- etc/meta_templates/plugin_seed/spec/spec_helper.rb
|
188
|
+
- etc/meta_templates/plugin_seed/spec/{entity}_spec.rb
|
171
189
|
- etc/power_stencil.yaml
|
172
190
|
- etc/templates/plugin_definition/.gitignore
|
173
191
|
- etc/templates/plugin_definition/.rspec
|
@@ -193,6 +211,7 @@ files:
|
|
193
211
|
- etc/templates/plugin_definition/lib/{entity}/version.rb.erb
|
194
212
|
- etc/templates/plugin_definition/lib/{entity}/{entity}_processor.rb.erb
|
195
213
|
- etc/templates/plugin_definition/psplugin_{entity}.gemspec
|
214
|
+
- etc/templates/plugin_definition/spec/project_helper.rb
|
196
215
|
- etc/templates/plugin_definition/spec/spec_helper.rb
|
197
216
|
- etc/templates/plugin_definition/spec/{entity}_spec.rb
|
198
217
|
- etc/templates/project/.copy_ignore
|
@@ -242,6 +261,7 @@ files:
|
|
242
261
|
- lib/power_stencil/engine/init_engine.rb
|
243
262
|
- lib/power_stencil/engine/project_engine.rb
|
244
263
|
- lib/power_stencil/engine/renderers/erb.rb
|
264
|
+
- lib/power_stencil/engine/renderers/haml.rb
|
245
265
|
- lib/power_stencil/error.rb
|
246
266
|
- lib/power_stencil/initializer.rb
|
247
267
|
- lib/power_stencil/plugins/base.rb
|
@@ -279,6 +299,10 @@ files:
|
|
279
299
|
- lib/power_stencil/system_entity_definitions/project_entity.rb
|
280
300
|
- lib/power_stencil/system_entity_definitions/simple_exec.rb
|
281
301
|
- lib/power_stencil/system_entity_definitions/source_provider.rb
|
302
|
+
- lib/power_stencil/ultra_command_line/command_line_manager.rb
|
303
|
+
- lib/power_stencil/ultra_command_line/option_definition.rb
|
304
|
+
- lib/power_stencil/ultra_command_line/providers_manager.rb
|
305
|
+
- lib/power_stencil/ultra_command_line/sub_command.rb
|
282
306
|
- lib/power_stencil/utils/completion.rb
|
283
307
|
- lib/power_stencil/utils/directory_processor.rb
|
284
308
|
- lib/power_stencil/utils/file_edit.rb
|
@@ -299,13 +323,12 @@ metadata:
|
|
299
323
|
documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
|
300
324
|
source_code_uri: https://gitlab.com/tools4devops/power_stencil
|
301
325
|
homepage_uri: https://powerstencil.brizone.org/
|
302
|
-
post_install_message: "\nThank you for installing PowerStencil 0.
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
https://gitlab.com/tools4devops/power_stencil/
|
307
|
-
|
308
|
-
adm --zsh-completion' to install auto-completion for zsh.\n\n "
|
326
|
+
post_install_message: "\nThank you for installing PowerStencil 0.9.1 !\nFrom the command
|
327
|
+
line you can run `power_stencil --help`\nIf your shell is not completing the command:\n
|
328
|
+
\ If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial Website
|
329
|
+
\ : https://powerstencil.brizone.org/\nFull documentation here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel
|
330
|
+
free to report issues: https://gitlab.com/tools4devops/power_stencil/issues\n\nType
|
331
|
+
'power_stencil adm --zsh-completion' to install auto-completion for zsh.\n\n "
|
309
332
|
rdoc_options: []
|
310
333
|
require_paths:
|
311
334
|
- lib
|