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,22 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module CommandProcessors
|
3
|
+
|
4
|
+
class Get
|
5
|
+
|
6
|
+
include Climatic::Script::UnimplementedProcessor
|
7
|
+
include Climatic::Proxy
|
8
|
+
include PowerStencil::Project::Proxy
|
9
|
+
include PowerStencil::CommandProcessors::EntityHelper
|
10
|
+
|
11
|
+
def execute
|
12
|
+
targets = targets_from_criteria analyse_extra_params, project.engine.root_universe
|
13
|
+
targets.each do |target|
|
14
|
+
display_entity target
|
15
|
+
puts
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module CommandProcessors
|
3
|
+
|
4
|
+
class Info
|
5
|
+
|
6
|
+
include Climatic::Script::UnimplementedProcessor
|
7
|
+
include Climatic::Proxy
|
8
|
+
include PowerStencil::Project::Proxy
|
9
|
+
|
10
|
+
def execute
|
11
|
+
puts '-' * 80
|
12
|
+
puts 'PROJECT REPORT'
|
13
|
+
puts '-' * 80
|
14
|
+
puts ' General information:'
|
15
|
+
puts(project.general_report.map { |p| ' - %s' % [p] })
|
16
|
+
puts '-' * 80
|
17
|
+
puts ' Paths:'
|
18
|
+
puts(project.paths_report.map { |p| ' - %s' % [p] })
|
19
|
+
unless project.plugins.empty?
|
20
|
+
puts '-' * 80
|
21
|
+
puts ' Plugins:'
|
22
|
+
project.plugins.each do |plugin_name, plugin|
|
23
|
+
if plugin.has_dependencies?
|
24
|
+
puts " --> Plugin '#{plugin_name}' depends on plugin#{plugin.declared_dependencies.size > 1 ? 's' : ''}: '#{plugin.declared_dependencies.join ', '}'"
|
25
|
+
end
|
26
|
+
puts " --> Plugin '#{plugin_name}' has following capabilities:"
|
27
|
+
puts(project.plugin_report(plugin_name, plugin).map { |p| ' - %s' % [p] })
|
28
|
+
end
|
29
|
+
end
|
30
|
+
puts '-' * 80
|
31
|
+
puts ' Entities:'
|
32
|
+
puts(project.entities_report.map { |p| ' - %s' % [p] })
|
33
|
+
puts '-' * 80
|
34
|
+
puts ' Available entity types:'
|
35
|
+
puts(project.entity_types_report.map { |p| ' - %s' % [p] })
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'power_stencil/engine/init_engine'
|
2
|
+
|
3
|
+
module PowerStencil
|
4
|
+
module CommandProcessors
|
5
|
+
|
6
|
+
class Init
|
7
|
+
|
8
|
+
include Climatic::Proxy
|
9
|
+
include PowerStencil::CommandProcessors::TraceHelper
|
10
|
+
|
11
|
+
def check_params(params)
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
setup_project_path
|
17
|
+
log_startup_context
|
18
|
+
puts_and_logs "Creating new project structure in '#{config[:'project-path']}'"
|
19
|
+
PowerStencil::Project::Base.create_project_tree config[:'project-path']
|
20
|
+
puts_and_logs 'Done.'
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def setup_project_path
|
26
|
+
if config[:'project-path']
|
27
|
+
unless config.command_line_layer.extra_parameters.empty?
|
28
|
+
raise PowerStencil::Error, 'You can specify the project path only once !'
|
29
|
+
end
|
30
|
+
else
|
31
|
+
if config.command_line_layer.extra_parameters.size > 1
|
32
|
+
raise PowerStencil::Error, 'You can specify the project path only once !'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
config[:'project-path'] = if config[:'project-path']
|
36
|
+
File.expand_path config[:'project-path']
|
37
|
+
elsif config.command_line_layer.extra_parameters.size == 1
|
38
|
+
File.expand_path config.command_line_layer.extra_parameters.first
|
39
|
+
else
|
40
|
+
File.expand_path Dir.pwd
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module CommandProcessors
|
3
|
+
|
4
|
+
class NewPlugin
|
5
|
+
|
6
|
+
include Climatic::Script::UnimplementedProcessor
|
7
|
+
include Climatic::Proxy
|
8
|
+
include PowerStencil::Project::Proxy
|
9
|
+
|
10
|
+
def execute
|
11
|
+
if config.command_line_layer.extra_parameters.empty?
|
12
|
+
raise PowerStencil::Error, 'Please specify a plugin name!'
|
13
|
+
end
|
14
|
+
config.command_line_layer.extra_parameters.each do |plugin_name|
|
15
|
+
begin
|
16
|
+
target_path = File.join project.project_plugin_path(plugin_name)
|
17
|
+
project.create_plugin_tree plugin_name, target_path
|
18
|
+
puts "Generated new plugin '#{plugin_name}'"
|
19
|
+
rescue => e
|
20
|
+
msg = "Could not create plugin '#{plugin_name}' because '#{e.message}'"
|
21
|
+
puts msg
|
22
|
+
logger.error "Could not create plugin '#{plugin_name}' because '#{e.message}'"
|
23
|
+
logger.debug PowerStencil::Error.report_error(e)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module CommandProcessors
|
3
|
+
|
4
|
+
class Root
|
5
|
+
|
6
|
+
include Climatic::Script::UnimplementedProcessor
|
7
|
+
include Climatic::Proxy
|
8
|
+
|
9
|
+
def execute
|
10
|
+
if config[:version]
|
11
|
+
if config[:verbose]
|
12
|
+
puts "PowerStencil framework v: #{PowerStencil::VERSION}"
|
13
|
+
else
|
14
|
+
puts PowerStencil::VERSION
|
15
|
+
end
|
16
|
+
return
|
17
|
+
end
|
18
|
+
unless config.command_line_layer.extra_parameters.empty?
|
19
|
+
raise PowerStencil::Error, "Invalid command '#{config.command_line_layer.extra_parameters.first}'"
|
20
|
+
end
|
21
|
+
puts_and_logs 'No action specified. Exiting...'
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
module PowerStencil
|
3
|
+
module CommandProcessors
|
4
|
+
|
5
|
+
class Shell
|
6
|
+
|
7
|
+
include Climatic::Script::UnimplementedProcessor
|
8
|
+
include Climatic::Proxy
|
9
|
+
include PowerStencil::Project::Proxy
|
10
|
+
|
11
|
+
def execute
|
12
|
+
|
13
|
+
working_universe = if config[:compiled]
|
14
|
+
project.engine.root_universe.compile scenario: config[:scenario]
|
15
|
+
else
|
16
|
+
project.engine.root_universe
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
context = project.engine.running_context working_universe
|
21
|
+
|
22
|
+
require 'pry'
|
23
|
+
|
24
|
+
Pry.hooks.add_hook(:before_session, "startup_message") do
|
25
|
+
puts config[:shell_dsl][:session_greetings]
|
26
|
+
end
|
27
|
+
|
28
|
+
Pry.start context,
|
29
|
+
prompt: [proc { config[:shell_dsl][:prompt_level_1] }, proc { config[:shell_dsl][:prompt_level_2] }],
|
30
|
+
quiet: true
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module CommandProcessors
|
3
|
+
|
4
|
+
module TraceHelper
|
5
|
+
|
6
|
+
def log_startup_context
|
7
|
+
logger.debug 'Command line manager cmd_line_args: %s' % [command_line_manager.cmd_line_args.inspect]
|
8
|
+
logger.debug 'Selected command name: %s' % [command_line_manager.command.name]
|
9
|
+
logger.debug 'Selected command cmd_line_args: %s' % [command_line_manager.command.cmd_line_args.inspect]
|
10
|
+
logger.debug 'Selected command params_hash: %s' % [command_line_manager.command.params_hash.inspect]
|
11
|
+
logger.debug 'Selected processor: %s' % [command_line_manager.processor.inspect]
|
12
|
+
logger.debug 'Config is: %s' % [config[].inspect]
|
13
|
+
logger.debug 'Logger is: %s' % [logger.inspect]
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'power_stencil/dsl/entities'
|
2
|
+
|
3
|
+
module PowerStencil
|
4
|
+
module Dsl
|
5
|
+
|
6
|
+
class Base
|
7
|
+
|
8
|
+
include PowerStencil::Project::Proxy
|
9
|
+
include PowerStencil::Dsl::Entities
|
10
|
+
|
11
|
+
attr_accessor :main_entry_point
|
12
|
+
|
13
|
+
def initialize(universe)
|
14
|
+
@universe = universe
|
15
|
+
end
|
16
|
+
|
17
|
+
def project_config
|
18
|
+
project.config
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module Dsl
|
3
|
+
|
4
|
+
module Entities
|
5
|
+
|
6
|
+
def available_entity_types(force_rescan: false)
|
7
|
+
PowerStencil.project.engine.available_entity_types force_rescan: force_rescan
|
8
|
+
end
|
9
|
+
|
10
|
+
def build_target
|
11
|
+
type, name = main_entry_point.split('/')
|
12
|
+
e = entity type, name
|
13
|
+
e.nil? ? entity(type.to_sym, name) : e
|
14
|
+
end
|
15
|
+
|
16
|
+
def entity(type, name)
|
17
|
+
PowerStencil.project.engine.entity type, name, @universe
|
18
|
+
end
|
19
|
+
|
20
|
+
def entities(criterion: nil, value: nil, &filter_block)
|
21
|
+
PowerStencil.project.engine.entities @universe, criterion: criterion, value: value, &filter_block
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete_entity(entity, delete_files: false)
|
25
|
+
PowerStencil.project.engine.delete_entity @universe, entity.type, entity.name, delete_files: delete_files
|
26
|
+
end
|
27
|
+
|
28
|
+
def method_missing(method_name, *arguments, &block)
|
29
|
+
if method_name.to_s =~ /^user_new_(.*)/
|
30
|
+
PowerStencil.project.engine.new_entity @universe, $1, fields: Hash[*arguments], user: true, &block
|
31
|
+
elsif method_name.to_s =~ /^new_(.*)$/
|
32
|
+
PowerStencil.project.engine.new_entity @universe, $1, fields: Hash[*arguments], &block
|
33
|
+
else
|
34
|
+
PowerStencil.logger.warn "Invalid DSL method: '#{method_name}'"
|
35
|
+
super
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def respond_to_missing?(method_name, include_private = false)
|
40
|
+
method_name.to_s.start_with?('new_') || super
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'power_stencil/engine/entities_definitions'
|
2
|
+
require 'power_stencil/engine/directory_processor'
|
3
|
+
|
4
|
+
require 'power_stencil/engine/renderers/erb'
|
5
|
+
require 'power_stencil/dsl/base'
|
6
|
+
require 'power_stencil/dsl/plugin_generation'
|
7
|
+
|
8
|
+
module PowerStencil
|
9
|
+
module Engine
|
10
|
+
|
11
|
+
class Base
|
12
|
+
|
13
|
+
UNIVERSE_BASENAME = 'Project entities'.freeze
|
14
|
+
|
15
|
+
include Climatic::Proxy
|
16
|
+
include PowerStencil::Engine::EntitiesDefinition
|
17
|
+
include PowerStencil::Engine::DirectoryProcessor
|
18
|
+
|
19
|
+
include PowerStencil::Engine::Renderers::Erb
|
20
|
+
|
21
|
+
attr_accessor :dsl
|
22
|
+
attr_reader :root_universe
|
23
|
+
|
24
|
+
def initialize(universe = UniverseCompiler::Universe::Base.new(unique_name))
|
25
|
+
@root_universe = universe
|
26
|
+
@dsl = PowerStencil::Dsl::Base
|
27
|
+
end
|
28
|
+
|
29
|
+
def running_context(universe = root_universe, main_entry_point: nil)
|
30
|
+
context = dsl.new universe
|
31
|
+
context.main_entry_point = main_entry_point
|
32
|
+
context.instance_eval do
|
33
|
+
binding
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def load_system_entities
|
40
|
+
root_universe << PowerStencil::SystemEntityDefinitions::ProjectConfig.new(fields: PowerStencil.config[])
|
41
|
+
end
|
42
|
+
|
43
|
+
def unique_name
|
44
|
+
'%s (%f)' % [UNIVERSE_BASENAME, Time.now.to_f]
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module PowerStencil
|
2
|
+
module Engine
|
3
|
+
|
4
|
+
module BuildHandling
|
5
|
+
|
6
|
+
include Climatic::Utils::SafeExec
|
7
|
+
|
8
|
+
attr_reader :last_build_report
|
9
|
+
|
10
|
+
def build(entities_to_build, fail_on_error: false, parallelized: false)
|
11
|
+
logger.debug 'Starting build process...'
|
12
|
+
raise PowerStencil::Error, 'Parallel builds are not yet supported !' if parallelized
|
13
|
+
|
14
|
+
build_target_seed = entities_to_build.map(&:as_path).map do |entity_full_name|
|
15
|
+
entity_full_name.tr '/', '_'
|
16
|
+
end .join '_'
|
17
|
+
build_target_path = project.build_run_path build_target_seed
|
18
|
+
|
19
|
+
@last_build_report = {}
|
20
|
+
|
21
|
+
entities_to_build.each do |entity_to_build|
|
22
|
+
begin
|
23
|
+
entity_build_report = []
|
24
|
+
unless entity_to_build.buildable?
|
25
|
+
msg = "Entity '#{entity_to_build.as_path}' is not buildable !"
|
26
|
+
entity_build_report << msg
|
27
|
+
raise PowerStencil::Error, msg
|
28
|
+
end
|
29
|
+
build_entity_target_path = File.join build_target_path, entity_to_build.as_path.tr('/', '_')
|
30
|
+
puts_and_logs "De-templating files for '#{entity_to_build.as_path}' into '#{build_entity_target_path}'"
|
31
|
+
build_entity entity_to_build, build_entity_target_path
|
32
|
+
entity_build_report << 'Ok'
|
33
|
+
rescue => e
|
34
|
+
logger.error "Failed building '#{entity_to_build.as_path}' because '#{e.message}' !"
|
35
|
+
entity_build_report << e.message
|
36
|
+
if fail_on_error
|
37
|
+
raise e
|
38
|
+
else
|
39
|
+
logger.debug PowerStencil::Error.report_error e
|
40
|
+
end
|
41
|
+
ensure
|
42
|
+
last_build_report[entity_to_build.as_path] = entity_build_report
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def build_entity(entity_to_build, target_path)
|
50
|
+
logger.info "Building #{entity_to_build.as_path} in '#{target_path}'"
|
51
|
+
render_source entity_to_build.templates_path, target_path, main_entry_point: entity_to_build.as_path
|
52
|
+
logger.info "Detemplatized filed generated in '#{target_path}'"
|
53
|
+
target_plugin_name = entity_to_build.buildable_by
|
54
|
+
if target_plugin_name.empty?
|
55
|
+
post_build_hook entity_to_build, target_path
|
56
|
+
else
|
57
|
+
target_plugin = project.plugins[target_plugin_name]
|
58
|
+
raise PowerStencil::Error, "Could not find plugin '#{target_plugin_name}' !" if target_plugin.nil?
|
59
|
+
raise PowerStencil::Error, "Plugin '#{target_plugin_name}' has no build capability !" unless target_plugin.capabilities[:build]
|
60
|
+
target_plugin.plugin_module.send PowerStencil::Plugins::Require::POST_BUILD_HOOK, entity_to_build, target_path
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def post_build_hook(entity_to_build, files_path)
|
65
|
+
case entity_to_build.type
|
66
|
+
when :simple_exec
|
67
|
+
script_to_execute = File.expand_path File.join(files_path, entity_to_build.post_process.process)
|
68
|
+
exec_options = {message: "Running '#{script_to_execute}'"}
|
69
|
+
exec_options[:show_output] = true if config[:verbose]
|
70
|
+
safely_exec_command script_to_execute, exec_options
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|