power_stencil 0.5.0 → 0.6.3
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/doc/builds.md +10 -1
- data/doc/entities.md +51 -42
- data/doc/plugins.md +59 -6
- data/doc/templates.md +1 -0
- data/etc/base_commands_definition.yml +14 -1
- data/etc/meta_templates/plugin_seed/etc/plugin_capabilities.yaml +2 -1
- data/etc/meta_templates/plugin_seed/psplugin_{entity}.gemspec +3 -1
- data/etc/templates/plugin_definition/etc/plugin_capabilities.yaml +2 -1
- data/etc/templates/plugin_definition/psplugin_{entity}.gemspec +3 -1
- data/lib/power_stencil/command_processors/build.rb +16 -3
- data/lib/power_stencil/command_processors/check.rb +12 -0
- data/lib/power_stencil/command_processors/create.rb +1 -1
- data/lib/power_stencil/command_processors/delete.rb +5 -5
- data/lib/power_stencil/command_processors/init.rb +2 -2
- data/lib/power_stencil/command_processors/plugin.rb +15 -5
- data/lib/power_stencil/command_processors/root.rb +1 -1
- data/lib/power_stencil/engine/build_handling.rb +1 -2
- data/lib/power_stencil/engine/directory_processor.rb +6 -1
- data/lib/power_stencil/engine/entities_definitions.rb +16 -7
- data/lib/power_stencil/engine/project_engine.rb +12 -5
- data/lib/power_stencil/initializer.rb +4 -7
- data/lib/power_stencil/plugins/base.rb +19 -9
- data/lib/power_stencil/plugins/capabilities.rb +10 -8
- data/lib/power_stencil/plugins/command_line.rb +1 -4
- data/lib/power_stencil/plugins/config.rb +1 -5
- data/lib/power_stencil/plugins/dsl.rb +24 -5
- data/lib/power_stencil/plugins/entity_definitions.rb +15 -0
- data/lib/power_stencil/plugins/gem.rb +14 -35
- data/lib/power_stencil/plugins/paths.rb +38 -0
- data/lib/power_stencil/plugins/require.rb +10 -16
- data/lib/power_stencil/plugins/templates.rb +1 -1
- data/lib/power_stencil/project/base.rb +12 -0
- data/lib/power_stencil/project/config.rb +3 -2
- data/lib/power_stencil/project/info.rb +14 -1
- data/lib/power_stencil/project/paths.rb +5 -25
- data/lib/power_stencil/project/plugins.rb +17 -22
- data/lib/power_stencil/system_entity_definitions/all.rb +1 -0
- data/lib/power_stencil/system_entity_definitions/entity_override.rb +1 -0
- data/lib/power_stencil/system_entity_definitions/entity_project_common.rb +1 -1
- data/lib/power_stencil/system_entity_definitions/project_entity.rb +1 -0
- data/lib/power_stencil/system_entity_definitions/simple_exec.rb +1 -1
- data/lib/power_stencil/system_entity_definitions/source_provider.rb +15 -0
- data/lib/power_stencil/utils/gem_utils.rb +22 -2
- data/lib/power_stencil/version.rb +1 -1
- data/power_stencil.gemspec +1 -1
- metadata +7 -5
@@ -0,0 +1,38 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module Plugins
|
3
|
+
|
4
|
+
module Paths
|
5
|
+
|
6
|
+
def plugin_path
|
7
|
+
case self.type
|
8
|
+
when :local
|
9
|
+
project.project_local_plugin_path self.name
|
10
|
+
when :gem
|
11
|
+
gem_spec.gem_dir
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def plugin_command_line_definition_file
|
16
|
+
File.join plugin_path, 'etc', 'command_line.yaml'
|
17
|
+
end
|
18
|
+
|
19
|
+
def plugin_capabilities_definition_file
|
20
|
+
File.join plugin_path, 'etc', 'plugin_capabilities.yaml'
|
21
|
+
end
|
22
|
+
|
23
|
+
def plugin_config_specific_file
|
24
|
+
File.join plugin_path, 'etc', 'plugin_config.yaml'
|
25
|
+
end
|
26
|
+
|
27
|
+
def plugin_processors_dir
|
28
|
+
File.join plugin_path, 'lib', plugin_name, 'processors'
|
29
|
+
end
|
30
|
+
|
31
|
+
def plugin_entities_definitions_dir
|
32
|
+
File.join plugin_path, 'etc', plugin_name, 'entities_definitions'
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -6,7 +6,6 @@ module PowerStencil
|
|
6
6
|
POST_BUILD_HOOK = :post_build_hook
|
7
7
|
|
8
8
|
include PowerStencil::Utils::SecureRequire
|
9
|
-
include PowerStencil::Utils::GemUtils
|
10
9
|
|
11
10
|
private
|
12
11
|
|
@@ -15,21 +14,16 @@ module PowerStencil
|
|
15
14
|
end
|
16
15
|
|
17
16
|
def require_entry_point
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
rescue LoadError => e
|
29
|
-
logger.warn "As plugin '#{name}' code is invalid, removing '#{plugin_root_path}' from LOAD_PATH"
|
30
|
-
$LOAD_PATH.delete plugin_root_path
|
31
|
-
end
|
32
|
-
|
17
|
+
@entry_point_path = File.join plugin_path, 'lib', "#{name.underscore}.rb"
|
18
|
+
logger.debug "Plugin '#{name}' entry point: '#{entry_point_path}'"
|
19
|
+
plugin_root_path = File.dirname(entry_point_path)
|
20
|
+
begin
|
21
|
+
$LOAD_PATH << plugin_root_path
|
22
|
+
securely_require entry_point_path unless plugin_definition[:plugin_module].nil?
|
23
|
+
rescue LoadError => e
|
24
|
+
@entry_point_path = nil
|
25
|
+
logger.warn "As plugin '#{name}' code is invalid, removing '#{plugin_root_path}' from LOAD_PATH"
|
26
|
+
$LOAD_PATH.delete plugin_root_path
|
33
27
|
end
|
34
28
|
end
|
35
29
|
|
@@ -7,7 +7,7 @@ module PowerStencil
|
|
7
7
|
return unless capabilities[:templates]
|
8
8
|
logger.info "Loading '#{self.name}' plugin templates..."
|
9
9
|
plugin_definition[:templates].each do |templates_path|
|
10
|
-
plugin_templates_path = File.join self.
|
10
|
+
plugin_templates_path = File.join self.plugin_path, templates_path
|
11
11
|
Dir.entries(plugin_templates_path).reject { |e| %w(. ..).include? e }.each do |entry|
|
12
12
|
template_path = File.join(plugin_templates_path, entry)
|
13
13
|
if Dir.exist? template_path
|
@@ -34,6 +34,10 @@ module PowerStencil
|
|
34
34
|
|
35
35
|
attr_reader :engine, :entity_engine
|
36
36
|
|
37
|
+
def name
|
38
|
+
File.dirname project_config_root
|
39
|
+
end
|
40
|
+
|
37
41
|
def initialize(search_from_path: Dir.pwd)
|
38
42
|
initialize_paths search_from_path
|
39
43
|
load_project_specific_config
|
@@ -41,11 +45,19 @@ module PowerStencil
|
|
41
45
|
bootstrap_plugins
|
42
46
|
build_engines
|
43
47
|
register_system_templates
|
48
|
+
register_plugins_templates
|
44
49
|
register_project_templates
|
45
50
|
end
|
46
51
|
|
47
52
|
private
|
48
53
|
|
54
|
+
def register_plugins_templates
|
55
|
+
plugins.each do |_, plugin|
|
56
|
+
plugin.register_plugin_templates
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
49
61
|
def register_project_templates
|
50
62
|
dir = project_templates_path
|
51
63
|
if Dir.exist? dir and File.readable? dir
|
@@ -21,8 +21,9 @@ module PowerStencil
|
|
21
21
|
end
|
22
22
|
|
23
23
|
|
24
|
-
def add_plugin_config(
|
25
|
-
|
24
|
+
def add_plugin_config(plugin)
|
25
|
+
plugin_name = plugin.name
|
26
|
+
yaml_file = plugin.plugin_config_specific_file
|
26
27
|
priority = if priority.nil?
|
27
28
|
PLUGIN_CONFIG_PRIORITY_MIN
|
28
29
|
else
|
@@ -60,7 +60,20 @@ module PowerStencil
|
|
60
60
|
.sort{ |a,b| a.first <=> b.first }
|
61
61
|
.each do |type, klass|
|
62
62
|
msg = "Type '#{type}' --> #{klass}"
|
63
|
-
|
63
|
+
|
64
|
+
source_provider = klass.entity_type_source_provider
|
65
|
+
source_provider_display = if source_provider == PowerStencil
|
66
|
+
"'#{source_provider.name}'"
|
67
|
+
elsif source_provider == self
|
68
|
+
"project '#{source_provider.name}'"
|
69
|
+
elsif source_provider.is_a? PowerStencil::Plugins::Base
|
70
|
+
"plugin '#{source_provider.name}'"
|
71
|
+
else
|
72
|
+
raise PowerStencil::Error, "Unidentified source provider for #{klass} !"
|
73
|
+
end
|
74
|
+
|
75
|
+
msg << " (provided by #{source_provider_display})"
|
76
|
+
msg << " template-template path: '#{entity_type_templates[type]}'" unless entity_type_templates[type].nil?
|
64
77
|
report << msg
|
65
78
|
end
|
66
79
|
report
|
@@ -35,10 +35,14 @@ module PowerStencil
|
|
35
35
|
File.join PowerStencil::Project::Paths.system_templates_path, entity_type.to_s
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def project_local_plugins_path
|
39
39
|
File.join project_config_root, PowerStencil.config[:project_plugins_directory_name]
|
40
40
|
end
|
41
41
|
|
42
|
+
def project_local_plugin_path(plugin_name)
|
43
|
+
File.join project_local_plugins_path, plugin_name
|
44
|
+
end
|
45
|
+
|
42
46
|
def project_templates_path
|
43
47
|
File.join project_config_root, PowerStencil.config[:project_templates_directory_name]
|
44
48
|
end
|
@@ -47,30 +51,6 @@ module PowerStencil
|
|
47
51
|
File.join project_config_root, PowerStencil.config[:project_entity_definitions_directory_name]
|
48
52
|
end
|
49
53
|
|
50
|
-
def project_plugin_path(plugin_name)
|
51
|
-
File.join project_plugins_path, plugin_name
|
52
|
-
end
|
53
|
-
|
54
|
-
def plugin_capabilities_definition_file(plugin_name)
|
55
|
-
File.join project_plugin_path(plugin_name), 'etc', 'plugin_capabilities.yaml'
|
56
|
-
end
|
57
|
-
|
58
|
-
def plugin_commands_line_definition_file(plugin_name)
|
59
|
-
File.join project_plugin_path(plugin_name), 'etc', 'command_line.yaml'
|
60
|
-
end
|
61
|
-
|
62
|
-
def plugin_config_specific_file(plugin_name)
|
63
|
-
File.join project_plugin_path(plugin_name), 'etc', 'plugin_config.yaml'
|
64
|
-
end
|
65
|
-
|
66
|
-
def plugin_processors_dir(plugin_name)
|
67
|
-
File.join project_plugin_path(plugin_name), 'lib', plugin_name, 'processors'
|
68
|
-
end
|
69
|
-
|
70
|
-
def plugin_entities_definitions_dir(plugin_name)
|
71
|
-
File.join project_plugin_path(plugin_name), 'etc', plugin_name, 'entities_definitions'
|
72
|
-
end
|
73
|
-
|
74
54
|
def project_entity_path(entity)
|
75
55
|
File.join project_entities_path, entity.type.to_s, "#{entity.name}.yaml"
|
76
56
|
end
|
@@ -7,7 +7,7 @@ module PowerStencil
|
|
7
7
|
@plugins ||= {}
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def create_new_local_plugin_tree(plugin_name, new_plugin_path, overwrite_files: false)
|
11
11
|
raise PowerStencil::Error, "Plugin '#{plugin_name}' already exists !" if plugins.keys.include? plugin_name
|
12
12
|
raise PowerStencil::Error, "Invalid plugin name '#{plugin_name}'" if (plugin_name.underscore =~ /^[_[:lower:]][_[:alnum:]]*$/).nil?
|
13
13
|
entity_engine.dsl = PowerStencil::Dsl::PluginGeneration
|
@@ -21,6 +21,7 @@ module PowerStencil
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def bootstrap_plugins
|
24
|
+
@plugins = {}
|
24
25
|
initialize_gem_plugins
|
25
26
|
initialize_local_plugins
|
26
27
|
command_line_manager.definition_hash_to_commands
|
@@ -31,45 +32,39 @@ module PowerStencil
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
|
-
|
35
35
|
def initialize_gem_plugins
|
36
|
-
# PowerStencil::logger.warn 'Gem plugins not yet supported ! Skipping...'
|
37
36
|
if config[:project_plugins].empty?
|
38
|
-
PowerStencil.logger.info
|
37
|
+
PowerStencil.logger.info 'No gem plugin found in project'
|
39
38
|
return
|
40
39
|
end
|
41
40
|
config[:project_plugins].each do |plugin_definition|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
unless PowerStencil::Plugins::Base.gem_locally_installed? plugin_name, plugin_requirements
|
49
|
-
PowerStencil::Plugins::Base.install_gem plugin_name, plugin_requirements
|
50
|
-
end
|
41
|
+
|
42
|
+
(gem_name, gem_req) = PowerStencil::Plugins::Base.plugin_definition_to_name_and_req plugin_definition
|
43
|
+
raise PowerStencil::Error, "Plugin '#{gem_name}' already exists !" unless plugins[gem_name].nil?
|
44
|
+
|
45
|
+
plugins[gem_name] = PowerStencil::Plugins::Base.new(gem_name, self, type: :gem, gem_req: gem_req)
|
51
46
|
end
|
52
47
|
end
|
53
48
|
|
54
49
|
def initialize_local_plugins
|
55
|
-
unless File.directory?
|
56
|
-
PowerStencil.logger.info "No local plugin found in '#{
|
50
|
+
unless File.directory? project_local_plugins_path
|
51
|
+
PowerStencil.logger.info "No local plugin found in '#{project_local_plugins_path}'"
|
57
52
|
return
|
58
53
|
end
|
59
54
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
candidates.each do |candidate|
|
55
|
+
Dir.entries(project_local_plugins_path)
|
56
|
+
.select { |e| File.directory? File.join(project_local_plugins_path, e) }
|
57
|
+
.reject { |d| %w(. ..).include? d }
|
58
|
+
.each do |candidate|
|
65
59
|
begin
|
66
60
|
raise PowerStencil::Error, "Plugin '#{candidate}' already exists !" unless plugins[candidate].nil?
|
67
61
|
plugins[candidate] = PowerStencil::Plugins::Base.new(candidate, self)
|
68
62
|
rescue PowerStencil::Error => pse
|
69
|
-
|
70
|
-
|
63
|
+
logger.puts_and_logs pse.message, logs_as: :error
|
64
|
+
logger.puts_and_logs "Discarding invalid plugin '#{candidate}'.", logs_as: :error
|
71
65
|
end
|
72
66
|
end
|
67
|
+
|
73
68
|
end
|
74
69
|
|
75
70
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require 'power_stencil/system_entity_definitions/non_persistent'
|
5
5
|
require 'power_stencil/system_entity_definitions/has_associated_files'
|
6
|
+
require 'power_stencil/system_entity_definitions/source_provider'
|
6
7
|
require 'power_stencil/system_entity_definitions/buildable'
|
7
8
|
require 'power_stencil/system_entity_definitions/entity_project_common'
|
8
9
|
|
@@ -3,7 +3,7 @@ module PowerStencil
|
|
3
3
|
|
4
4
|
module EntityProjectCommon
|
5
5
|
|
6
|
-
|
6
|
+
def save(uri = source_uri, raise_error: true, force_save: false, force_files_generation: false )
|
7
7
|
super(source_uri, raise_error: raise_error, force_save: force_save)
|
8
8
|
unless PowerStencil.project.entity_type_templates[type].nil?
|
9
9
|
PowerStencil.project.generate_entity_dir_for_entity self, force: force_files_generation
|
@@ -3,6 +3,7 @@ module PowerStencil
|
|
3
3
|
|
4
4
|
class ProjectEntity < UniverseCompiler::Entity::Base
|
5
5
|
|
6
|
+
extend PowerStencil::SystemEntityDefinitions::SourceProvider
|
6
7
|
extend PowerStencil::SystemEntityDefinitions::Buildable
|
7
8
|
include PowerStencil::SystemEntityDefinitions::EntityProjectCommon
|
8
9
|
|
@@ -3,8 +3,28 @@ module PowerStencil
|
|
3
3
|
|
4
4
|
module GemUtils
|
5
5
|
|
6
|
-
def
|
7
|
-
|
6
|
+
def plugin_definition_to_name_and_req(plugin_definition)
|
7
|
+
md = plugin_definition.match /^\s*([^\s]+)\s*,?\s*(.+)?\s*$/
|
8
|
+
if md.nil?
|
9
|
+
raise PowerStencil::Error, "Invalid plugin_definition '#{plugin_definition}'"
|
10
|
+
end
|
11
|
+
gem_name = md[1]
|
12
|
+
gem_req = if md[2].nil? or md[2].empty?
|
13
|
+
::Gem::Requirement.default
|
14
|
+
else
|
15
|
+
::Gem::Requirement.create md[2]
|
16
|
+
end
|
17
|
+
[gem_name, gem_req]
|
18
|
+
end
|
19
|
+
|
20
|
+
def find_gemspec_manually(gem_name)
|
21
|
+
gem_spec_files = []
|
22
|
+
::Gem::Specification.dirs.each do |dir|
|
23
|
+
Dir.glob(File.join(dir, "#{gem_name}-*.*.*.gemspec")) do |file|
|
24
|
+
gem_spec_files << file
|
25
|
+
end
|
26
|
+
end
|
27
|
+
gem_spec_files.map { |file| ::Gem::Specification.load file }
|
8
28
|
end
|
9
29
|
|
10
30
|
end
|
data/power_stencil.gemspec
CHANGED
@@ -25,7 +25,7 @@ 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.30'
|
29
29
|
spec.add_dependency 'dir_glob_ignore', '~> 0.3'
|
30
30
|
spec.add_dependency 'universe_compiler', '~> 0.5.1'
|
31
31
|
spec.add_dependency 'pry'
|
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.6.3
|
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-
|
11
|
+
date: 2019-10-29 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.30
|
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.30
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: dir_glob_ignore
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -233,6 +233,7 @@ files:
|
|
233
233
|
- lib/power_stencil/plugins/dsl.rb
|
234
234
|
- lib/power_stencil/plugins/entity_definitions.rb
|
235
235
|
- lib/power_stencil/plugins/gem.rb
|
236
|
+
- lib/power_stencil/plugins/paths.rb
|
236
237
|
- lib/power_stencil/plugins/require.rb
|
237
238
|
- lib/power_stencil/plugins/templates.rb
|
238
239
|
- lib/power_stencil/plugins/type.rb
|
@@ -256,6 +257,7 @@ files:
|
|
256
257
|
- lib/power_stencil/system_entity_definitions/project_config.rb
|
257
258
|
- lib/power_stencil/system_entity_definitions/project_entity.rb
|
258
259
|
- lib/power_stencil/system_entity_definitions/simple_exec.rb
|
260
|
+
- lib/power_stencil/system_entity_definitions/source_provider.rb
|
259
261
|
- lib/power_stencil/utils/directory_processor.rb
|
260
262
|
- lib/power_stencil/utils/file_edit.rb
|
261
263
|
- lib/power_stencil/utils/file_helper.rb
|
@@ -274,7 +276,7 @@ metadata:
|
|
274
276
|
documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
|
275
277
|
source_code_uri: https://gitlab.com/tools4devops/power_stencil
|
276
278
|
homepage_uri: https://powerstencil.brizone.org/
|
277
|
-
post_install_message: "\nThank you for installing PowerStencil 0.
|
279
|
+
post_install_message: "\nThank you for installing PowerStencil 0.6.3 !\nFrom the command
|
278
280
|
line you can run `power_stencil --help`\nIf your shell is not completing the command:\n
|
279
281
|
\ If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial Website
|
280
282
|
\ : https://powerstencil.brizone.org/\nFull documentation here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel
|