power_stencil 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +194 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/update_plugin_template +79 -0
- data/doc/builds.md +267 -0
- data/doc/entities.md +964 -0
- data/doc/example_use_cases.md +59 -0
- data/doc/images/power-stencil-architecture.svg +151 -0
- data/doc/images/power-stencil-entity-build.svg +481 -0
- data/doc/images/power-stencil-entity-creation.svg +375 -0
- data/doc/images/power-stencil-project-overview.svg +2534 -0
- data/doc/images/power-stencil-simple-flow.svg +265 -0
- data/doc/plugins.md +169 -0
- data/doc/templates.md +332 -0
- data/etc/base_commands_definition.yml +259 -0
- data/etc/meta_templates/plugin_seed/etc/command_line.yaml +12 -0
- data/etc/meta_templates/plugin_seed/etc/plugin_config.yaml +4 -0
- data/etc/meta_templates/plugin_seed/etc/templates/.git_keep +0 -0
- data/etc/meta_templates/plugin_seed/lib/{entity}.rb.erb +34 -0
- data/etc/meta_templates/plugin_seed/lib/{entity}/entity_definitions/{entity}_entity.rb.erb +11 -0
- data/etc/meta_templates/plugin_seed/lib/{entity}/plugin_helper.rb.erb +17 -0
- data/etc/meta_templates/plugin_seed/lib/{entity}/version.rb.erb +3 -0
- data/etc/meta_templates/plugin_seed/lib/{entity}/{entity}_processor.rb.erb +19 -0
- data/etc/meta_templates/plugin_seed/psplugin_{entity}.gemspec +36 -0
- data/etc/power_stencil.yaml +92 -0
- data/etc/templates/plugin_definition/.gitignore +11 -0
- data/etc/templates/plugin_definition/.rspec +3 -0
- data/etc/templates/plugin_definition/.travis.yml +5 -0
- data/etc/templates/plugin_definition/CODE_OF_CONDUCT.md +74 -0
- data/etc/templates/plugin_definition/Gemfile +6 -0
- data/etc/templates/plugin_definition/LICENSE.txt +21 -0
- data/etc/templates/plugin_definition/README.md +43 -0
- data/etc/templates/plugin_definition/Rakefile +6 -0
- data/etc/templates/plugin_definition/bin/console +14 -0
- data/etc/templates/plugin_definition/bin/setup +8 -0
- data/etc/templates/plugin_definition/etc/command_line.yaml +12 -0
- data/etc/templates/plugin_definition/etc/plugin_config.yaml +4 -0
- data/etc/templates/plugin_definition/etc/templates/.git_keep +1 -0
- data/etc/templates/plugin_definition/lib/{entity}.rb.erb +34 -0
- data/etc/templates/plugin_definition/lib/{entity}/entity_definitions/{entity}_entity.rb.erb +11 -0
- data/etc/templates/plugin_definition/lib/{entity}/plugin_helper.rb.erb +17 -0
- data/etc/templates/plugin_definition/lib/{entity}/version.rb.erb +3 -0
- data/etc/templates/plugin_definition/lib/{entity}/{entity}_processor.rb.erb +19 -0
- data/etc/templates/plugin_definition/psplugin_{entity}.gemspec +36 -0
- data/etc/templates/plugin_definition/spec/spec_helper.rb +14 -0
- data/etc/templates/plugin_definition/spec/{entity}_spec.rb +9 -0
- data/etc/templates/project/.copy_ignore +2 -0
- data/etc/templates/project/.gitignore.erb +6 -0
- data/etc/templates/project/.ps_project/entities/.gitkeep +0 -0
- data/etc/templates/project/.ps_project/entities/README.md +11 -0
- data/etc/templates/project/.ps_project/entity_definitions/.gitkeep +0 -0
- data/etc/templates/project/.ps_project/entity_definitions/README.md +15 -0
- data/etc/templates/project/.ps_project/personal-config.yaml +8 -0
- data/etc/templates/project/.ps_project/plugins/.gitkeep +0 -0
- data/etc/templates/project/.ps_project/templates-templates/.gitkeep +0 -0
- data/etc/templates/project/.ps_project/templates-templates/README.md +13 -0
- data/etc/templates/project/.ps_project/user_entities/.gitkeep +0 -0
- data/etc/templates/project/.ps_project/user_entities/README.md +12 -0
- data/etc/templates/project/.ps_project/versioned-config.yaml +6 -0
- data/etc/templates/simple_exec/main.sh +4 -0
- data/exe/power_stencil +28 -0
- data/lib/power_stencil.rb +53 -0
- data/lib/power_stencil/command_processors/build.rb +43 -0
- data/lib/power_stencil/command_processors/check.rb +35 -0
- data/lib/power_stencil/command_processors/create.rb +70 -0
- data/lib/power_stencil/command_processors/delete.rb +38 -0
- data/lib/power_stencil/command_processors/edit.rb +35 -0
- data/lib/power_stencil/command_processors/entity_helper.rb +105 -0
- data/lib/power_stencil/command_processors/get.rb +22 -0
- data/lib/power_stencil/command_processors/info.rb +41 -0
- data/lib/power_stencil/command_processors/init.rb +47 -0
- data/lib/power_stencil/command_processors/new_plugin.rb +31 -0
- data/lib/power_stencil/command_processors/root.rb +27 -0
- data/lib/power_stencil/command_processors/shell.rb +37 -0
- data/lib/power_stencil/command_processors/trace_helper.rb +20 -0
- data/lib/power_stencil/dsl/base.rb +24 -0
- data/lib/power_stencil/dsl/entities.rb +46 -0
- data/lib/power_stencil/dsl/plugin_generation.rb +17 -0
- data/lib/power_stencil/engine/base.rb +50 -0
- data/lib/power_stencil/engine/build_handling.rb +77 -0
- data/lib/power_stencil/engine/directory_processor.rb +111 -0
- data/lib/power_stencil/engine/entities_definitions.rb +42 -0
- data/lib/power_stencil/engine/entities_handling.rb +76 -0
- data/lib/power_stencil/engine/entity_engine.rb +20 -0
- data/lib/power_stencil/engine/init_engine.rb +18 -0
- data/lib/power_stencil/engine/project_engine.rb +75 -0
- data/lib/power_stencil/engine/renderers/erb.rb +21 -0
- data/lib/power_stencil/error.rb +20 -0
- data/lib/power_stencil/initializer.rb +87 -0
- data/lib/power_stencil/plugins/base.rb +54 -0
- data/lib/power_stencil/plugins/capabilities.rb +30 -0
- data/lib/power_stencil/plugins/command_line.rb +27 -0
- data/lib/power_stencil/plugins/config.rb +32 -0
- data/lib/power_stencil/plugins/dependencies.rb +32 -0
- data/lib/power_stencil/plugins/gem.rb +57 -0
- data/lib/power_stencil/plugins/require.rb +77 -0
- data/lib/power_stencil/plugins/templates.rb +21 -0
- data/lib/power_stencil/project/base.rb +79 -0
- data/lib/power_stencil/project/config.rb +54 -0
- data/lib/power_stencil/project/create.rb +30 -0
- data/lib/power_stencil/project/info.rb +72 -0
- data/lib/power_stencil/project/paths.rb +119 -0
- data/lib/power_stencil/project/plugins.rb +89 -0
- data/lib/power_stencil/project/proxy.rb +13 -0
- data/lib/power_stencil/project/templates.rb +56 -0
- data/lib/power_stencil/project/versioning.rb +29 -0
- data/lib/power_stencil/system_entity_definitions/all.rb +14 -0
- data/lib/power_stencil/system_entity_definitions/buildable.rb +23 -0
- data/lib/power_stencil/system_entity_definitions/entity_override.rb +8 -0
- data/lib/power_stencil/system_entity_definitions/entity_project_common.rb +33 -0
- data/lib/power_stencil/system_entity_definitions/has_associated_files.rb +13 -0
- data/lib/power_stencil/system_entity_definitions/non_persistent.rb +14 -0
- data/lib/power_stencil/system_entity_definitions/plugin.rb +17 -0
- data/lib/power_stencil/system_entity_definitions/process_descriptor.rb +15 -0
- data/lib/power_stencil/system_entity_definitions/project_config.rb +24 -0
- data/lib/power_stencil/system_entity_definitions/project_entity.rb +16 -0
- data/lib/power_stencil/system_entity_definitions/simple_exec.rb +47 -0
- data/lib/power_stencil/utils/directory_processor.rb +54 -0
- data/lib/power_stencil/utils/file_edit.rb +87 -0
- data/lib/power_stencil/utils/file_helper.rb +56 -0
- data/lib/power_stencil/utils/gem_utils.rb +13 -0
- data/lib/power_stencil/utils/secure_require.rb +26 -0
- data/lib/power_stencil/utils/semantic_version.rb +128 -0
- data/lib/power_stencil/version.rb +3 -0
- data/power_stencil.gemspec +32 -0
- metadata +287 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module PowerStencil
|
4
|
+
module Project
|
5
|
+
|
6
|
+
module Create
|
7
|
+
|
8
|
+
include Climatic::Proxy
|
9
|
+
|
10
|
+
def create_project_tree(path, config_directory_name = PowerStencil.config[:default_config_directory_name])
|
11
|
+
path = File.expand_path path
|
12
|
+
config_path = File.join path, config_directory_name
|
13
|
+
if Dir.exists? config_path
|
14
|
+
raise PowerStencil::Error, "The directory '#{path}' already contains a PowerStencil project !" unless config[:force]
|
15
|
+
end
|
16
|
+
logger.info "Creating project in '#{path}'..."
|
17
|
+
render_project_template_in(path)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def render_project_template_in(new_project_config_path)
|
23
|
+
engine = PowerStencil::Engine::InitEngine.new
|
24
|
+
engine.render_source PowerStencil::Project::Paths.project_system_template_path, new_project_config_path
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module Project
|
3
|
+
|
4
|
+
module Info
|
5
|
+
|
6
|
+
def paths_report
|
7
|
+
report = []
|
8
|
+
report << "Project root path: '#{project_root}'"
|
9
|
+
report << "Project configuration path: '#{project_config_root}'"
|
10
|
+
report << if File.exist? project_personal_config_file
|
11
|
+
"Local user configuration file: '#{project_personal_config_file}'"
|
12
|
+
else
|
13
|
+
'No personal project config file found'
|
14
|
+
end
|
15
|
+
report << if File.exist? project_versioned_config_file
|
16
|
+
"Project (versioned) configuration file: '#{project_versioned_config_file}'"
|
17
|
+
else
|
18
|
+
'No versioned project config file found'
|
19
|
+
end
|
20
|
+
report << "Project entities: '#{project_entities_path}'"
|
21
|
+
report << "User (unversioned) entities: '#{user_entities_path}'"
|
22
|
+
txt = "Project specific entity definitions: '#{project_entity_definitions_path}'"
|
23
|
+
txt << ' (missing)' unless Dir.exist? project_entity_definitions_path
|
24
|
+
report << txt
|
25
|
+
end
|
26
|
+
|
27
|
+
def general_report
|
28
|
+
report = []
|
29
|
+
report << "Project required version: #{config[:min_power_stencil_version]}" unless config[:min_power_stencil_version].nil?
|
30
|
+
report << "PowerStencil version: #{PowerStencil::VERSION}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def plugin_report(plugin_name, plugin)
|
34
|
+
report = []
|
35
|
+
# report << "Plugin '#{plugin_name}'"
|
36
|
+
plugin.capabilities.each {|name, status| report << "#{name.to_s}: #{status}"}
|
37
|
+
report
|
38
|
+
end
|
39
|
+
|
40
|
+
def entities_report
|
41
|
+
report = []
|
42
|
+
used_types = {}
|
43
|
+
report << "Contains #{engine.root_universe.get_entities.count} entities."
|
44
|
+
engine.root_universe.get_entities
|
45
|
+
.sort{ |a,b| a.type <=> b.type }
|
46
|
+
.each do |entity|
|
47
|
+
used_types[entity.type] ||= 0
|
48
|
+
used_types[entity.type] += 1
|
49
|
+
end
|
50
|
+
used_types.each do |type, count|
|
51
|
+
report << " #{type}: #{count}"
|
52
|
+
end
|
53
|
+
report
|
54
|
+
end
|
55
|
+
|
56
|
+
def entity_types_report
|
57
|
+
report = []
|
58
|
+
PowerStencil::Engine::EntitiesHandling.all_types
|
59
|
+
.select { |type, _| type.is_a? Symbol}
|
60
|
+
.sort{ |a,b| a.first <=> b.first }
|
61
|
+
.each do |type, klass|
|
62
|
+
msg = "Type '#{type}' --> #{klass}"
|
63
|
+
msg << " (template-template path: '#{entity_type_templates[type]}')" unless entity_type_templates[type].nil?
|
64
|
+
report << msg
|
65
|
+
end
|
66
|
+
report
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module Project
|
3
|
+
|
4
|
+
module Paths
|
5
|
+
|
6
|
+
include PowerStencil::Utils::FileHelper
|
7
|
+
|
8
|
+
attr_reader :project_config_root, :started_from
|
9
|
+
|
10
|
+
def self.system_templates_path
|
11
|
+
File.expand_path File.join('..', '..', '..', '..', 'etc', 'templates'), __FILE__
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.project_system_template_path
|
15
|
+
File.join system_templates_path, 'project'
|
16
|
+
end
|
17
|
+
|
18
|
+
def build_run_path(seed)
|
19
|
+
File.join build_root_path, timestamped_uniq_dir(seed, Time.now)
|
20
|
+
end
|
21
|
+
|
22
|
+
def build_root_path
|
23
|
+
File.join project_root, PowerStencil.config[:project_build_root_directory_name]
|
24
|
+
end
|
25
|
+
|
26
|
+
def template_path(entity_type)
|
27
|
+
File.join PowerStencil::Project::Paths.system_templates_path, entity_type.to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
def project_plugins_path
|
31
|
+
File.join project_config_root, PowerStencil.config[:project_plugins_directory_name]
|
32
|
+
end
|
33
|
+
|
34
|
+
def project_templates_path
|
35
|
+
File.join project_config_root, PowerStencil.config[:project_templates_directory_name]
|
36
|
+
end
|
37
|
+
|
38
|
+
def project_entity_definitions_path
|
39
|
+
File.join project_config_root, PowerStencil.config[:project_entity_definitions_directory_name]
|
40
|
+
end
|
41
|
+
|
42
|
+
def project_plugin_path(plugin_name)
|
43
|
+
File.join project_plugins_path, plugin_name
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def plugin_commands_line_definition_file(plugin_name)
|
48
|
+
File.join project_plugin_path(plugin_name), 'etc', 'command_line.yaml'
|
49
|
+
end
|
50
|
+
|
51
|
+
def plugin_config_specific_file(plugin_name)
|
52
|
+
File.join project_plugin_path(plugin_name), 'etc', 'plugin_config.yaml'
|
53
|
+
end
|
54
|
+
|
55
|
+
def plugin_processors_dir(plugin_name)
|
56
|
+
File.join project_plugin_path(plugin_name), 'lib', plugin_name, 'processors'
|
57
|
+
end
|
58
|
+
|
59
|
+
def plugin_entities_definitions_dir(plugin_name)
|
60
|
+
File.join project_plugin_path(plugin_name), 'etc', plugin_name, 'entities_definitions'
|
61
|
+
end
|
62
|
+
|
63
|
+
def project_entity_path(entity)
|
64
|
+
File.join project_entities_path, entity.type.to_s, "#{entity.name}.yaml"
|
65
|
+
end
|
66
|
+
|
67
|
+
def user_entity_path(entity)
|
68
|
+
File.join user_entities_path, entity.type.to_s, "#{entity.name}.yaml"
|
69
|
+
end
|
70
|
+
|
71
|
+
def project_entities_path
|
72
|
+
File.join project_config_root, PowerStencil.config[:project_entities_directory_name]
|
73
|
+
end
|
74
|
+
|
75
|
+
def user_entities_path
|
76
|
+
File.join project_config_root, PowerStencil.config[:user_entities_directory_name]
|
77
|
+
end
|
78
|
+
|
79
|
+
def project_root_setup?
|
80
|
+
not project_config_root.nil?
|
81
|
+
end
|
82
|
+
|
83
|
+
def project_root
|
84
|
+
File.expand_path '..', project_config_root
|
85
|
+
end
|
86
|
+
|
87
|
+
def project_versioned_config_file
|
88
|
+
File.join project_config_root, PowerStencil.config[:versioned_project_config_file_name]
|
89
|
+
end
|
90
|
+
|
91
|
+
def project_personal_config_file
|
92
|
+
File.join project_config_root, PowerStencil.config[:unversioned_user_project_config_file_name]
|
93
|
+
end
|
94
|
+
|
95
|
+
def config_directory_name
|
96
|
+
@config_directory_name ||= PowerStencil.config[:default_config_directory_name]
|
97
|
+
end
|
98
|
+
|
99
|
+
def config_directory_name=(new_name)
|
100
|
+
@config_directory_name = new_name
|
101
|
+
initialize_paths started_from unless started_from.nil?
|
102
|
+
end
|
103
|
+
|
104
|
+
def initialize_paths(from_path)
|
105
|
+
from_path = File.expand_path from_path
|
106
|
+
@project_config_root = find_project_root from_path
|
107
|
+
raise PowerStencil::Error, "Cannot find a project in '#{from_path}' !" unless project_root_setup?
|
108
|
+
@started_from = project_config_root.nil? ? nil : from_path
|
109
|
+
project_root
|
110
|
+
end
|
111
|
+
|
112
|
+
def find_project_root(from_path)
|
113
|
+
find_recursively_in_path config_directory_name, from_path
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module Project
|
3
|
+
|
4
|
+
module Plugins
|
5
|
+
|
6
|
+
def plugins
|
7
|
+
@plugins ||= {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_plugin_tree(plugin_name, new_plugin_path, overwrite_files: false)
|
11
|
+
raise PowerStencil::Error, "Plugin '#{plugin_name}' already exists !" if plugins.keys.include? plugin_name
|
12
|
+
raise PowerStencil::Error, "Invalid plugin name '#{plugin_name}'" if (plugin_name.underscore =~ /^[_[:lower:]][_[:alnum:]]*$/).nil?
|
13
|
+
entity_engine.dsl = PowerStencil::Dsl::PluginGeneration
|
14
|
+
entity_engine.render_source entity_type_templates[:plugin_definition],
|
15
|
+
new_plugin_path,
|
16
|
+
overwrite_files: overwrite_files,
|
17
|
+
main_entry_point: plugin_name
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def bootstrap_plugins
|
24
|
+
initialize_gem_plugins
|
25
|
+
initialize_local_plugins
|
26
|
+
check_plugins_dependencies
|
27
|
+
command_line_manager.definition_hash_to_commands
|
28
|
+
plugins.each do |plugin_name, plugin|
|
29
|
+
if plugin.capabilities[:processors]
|
30
|
+
plugin.plugin_module.send PowerStencil::Plugins::Require::SETUP_PROCESSOR_CALLBACK
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def check_plugins_dependencies
|
36
|
+
plugins.each do |plugin_name, plugin|
|
37
|
+
begin
|
38
|
+
plugin.check_plugin_dependencies
|
39
|
+
rescue PowerStencil::Error => pse
|
40
|
+
PowerStencil.logger.debug pse.message
|
41
|
+
PowerStencil.logger.warn "Discarding invalid plugin '#{plugin_name}'."
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize_gem_plugins
|
47
|
+
# PowerStencil::logger.warn 'Gem plugins not yet supported ! Skipping...'
|
48
|
+
if config[:project_plugins].empty?
|
49
|
+
PowerStencil.logger.info "No gem plugin found in '#{project_plugins_path}'"
|
50
|
+
return
|
51
|
+
end
|
52
|
+
config[:project_plugins].each do |plugin_definition|
|
53
|
+
plugin_name, plugin_requirements = case plugin_definition
|
54
|
+
when String
|
55
|
+
[plugin_definition, '']
|
56
|
+
when Hash
|
57
|
+
[plugin_definition.keys.first, plugin_definition.values.first]
|
58
|
+
end
|
59
|
+
unless PowerStencil::Plugins::Base.gem_locally_installed? plugin_name, plugin_requirements
|
60
|
+
PowerStencil::Plugins::Base.install_gem plugin_name, plugin_requirements
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def initialize_local_plugins
|
66
|
+
unless File.directory? project_plugins_path
|
67
|
+
PowerStencil.logger.info "No local plugin found in '#{project_plugins_path}'"
|
68
|
+
return
|
69
|
+
end
|
70
|
+
|
71
|
+
candidates = Dir.entries(project_plugins_path)
|
72
|
+
.select { |e| File.directory? File.join(project_plugins_path, e) }
|
73
|
+
.reject { |d| %w(. ..).include? d }
|
74
|
+
@plugins = {}
|
75
|
+
candidates.each do |candidate|
|
76
|
+
begin
|
77
|
+
raise PowerStencil::Error, "Plugin '#{candidate}' already exists !" unless plugins[candidate].nil?
|
78
|
+
plugins[candidate] = PowerStencil::Plugins::Base.new(candidate, self)
|
79
|
+
rescue PowerStencil::Error => pse
|
80
|
+
PowerStencil.logger.debug pse.message
|
81
|
+
PowerStencil.logger.warn "Discarding invalid plugin '#{candidate}'."
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module Project
|
3
|
+
|
4
|
+
module Templates
|
5
|
+
|
6
|
+
def setup_templates_for_entities
|
7
|
+
plugins.each do |plugin_name, plugin|
|
8
|
+
logger.debug "Checking if plugin '#{plugin_name}' declares some templates..."
|
9
|
+
plugin.register_plugin_templates
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def entity_type_templates
|
14
|
+
@entity_type_templates ||= {}
|
15
|
+
end
|
16
|
+
|
17
|
+
def register_template_path_for_type(entity_type, path)
|
18
|
+
if entity_type_templates.include? entity_type
|
19
|
+
logger.warn "There is already a template-template path registered for entity type '#{entity_type}': '#{entity_type_templates[entity_type]}'."
|
20
|
+
end
|
21
|
+
raise PowerStencil::Error, "There is no template in path: '#{path}'" unless Dir.exist? path and File.readable? path
|
22
|
+
raise PowerStencil::Error, "Trying to register a template for non existing type '#{entity_type}'" unless engine.available_entity_types.include? entity_type
|
23
|
+
logger.debug "Registering '#{path}' as template for type '#{entity_type}'."
|
24
|
+
entity_type_templates[entity_type] = path
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_entity_dir_for_entity(entity, force: false)
|
28
|
+
unless entity_type_templates[entity.type].nil?
|
29
|
+
logger.debug "Generating entity dir for entity '#{entity.as_path}'"
|
30
|
+
target_path = File.join project_root, entity.type.to_s, entity.name.to_s
|
31
|
+
render_entity_template_in entity, target_path, force: force
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete_entity_dir_for_entity(entity, force: false)
|
36
|
+
return unless force
|
37
|
+
unless entity_type_templates[entity.type].nil?
|
38
|
+
logger.debug "Deleting entity files for entity '#{entity.as_path}'"
|
39
|
+
target_path = File.join project_root, entity.type.to_s, entity.name.to_s
|
40
|
+
FileUtils.rmtree target_path unless target_path.nil? or target_path.empty?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def render_entity_template_in(entity, entity_dir_path, force: false)
|
47
|
+
entity_engine.render_source entity_type_templates[entity.type],
|
48
|
+
entity_dir_path,
|
49
|
+
overwrite_files: force,
|
50
|
+
main_entry_point: entity.name
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module Project
|
3
|
+
|
4
|
+
module Versioning
|
5
|
+
|
6
|
+
def check_project_version
|
7
|
+
return if project_version_valid?
|
8
|
+
raise PowerStencil::Error, msg
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def project_version_valid?
|
14
|
+
unless config[:min_power_stencil_version].nil?
|
15
|
+
framework_version = PowerStencil::Utils::SemanticVersion.new PowerStencil::VERSION
|
16
|
+
is_valid = framework_version >= config[:min_power_stencil_version]
|
17
|
+
if is_valid
|
18
|
+
logger.debug "PowerStencil version (v: #{framework_version}) is advanced enough to handle project required version (v: #{config[:min_power_stencil_version]})"
|
19
|
+
end
|
20
|
+
return is_valid
|
21
|
+
end
|
22
|
+
logger.debug 'Project does not require any specific PowerStencil version'
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file is required by the engine but not from the gem
|
2
|
+
# So it is safe to declare files in the order you need.
|
3
|
+
|
4
|
+
require 'power_stencil/system_entity_definitions/non_persistent'
|
5
|
+
require 'power_stencil/system_entity_definitions/has_associated_files'
|
6
|
+
require 'power_stencil/system_entity_definitions/buildable'
|
7
|
+
require 'power_stencil/system_entity_definitions/entity_project_common'
|
8
|
+
|
9
|
+
require 'power_stencil/system_entity_definitions/project_entity'
|
10
|
+
require 'power_stencil/system_entity_definitions/project_config'
|
11
|
+
require 'power_stencil/system_entity_definitions/plugin'
|
12
|
+
require 'power_stencil/system_entity_definitions/process_descriptor'
|
13
|
+
require 'power_stencil/system_entity_definitions/simple_exec'
|
14
|
+
require 'power_stencil/system_entity_definitions/entity_override'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module SystemEntityDefinitions
|
3
|
+
|
4
|
+
module Buildable
|
5
|
+
|
6
|
+
def buildable
|
7
|
+
buildable_by ''
|
8
|
+
end
|
9
|
+
|
10
|
+
def buildable_by(plugin_name = nil)
|
11
|
+
return @build_plugin_name if plugin_name.nil?
|
12
|
+
@build_plugin_name = plugin_name
|
13
|
+
self.include PowerStencil::SystemEntityDefinitions::HasAssociatedFiles
|
14
|
+
end
|
15
|
+
|
16
|
+
def buildable?
|
17
|
+
not @build_plugin_name.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|