power_stencil 0.6.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +2 -0
- data/README.md +3 -7
- data/doc/builds.md +10 -1
- data/doc/entities.md +59 -50
- data/doc/images/power-stencil-entity-creation.svg +247 -114
- data/doc/plugins.md +1 -0
- data/doc/templates.md +23 -18
- data/etc/base_commands_definition.yml +14 -0
- data/etc/power_stencil.yaml +7 -1
- data/etc/templates/project/.zzzgitignore.erb +8 -3
- data/lib/power_stencil.rb +1 -0
- 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 +6 -5
- data/lib/power_stencil/command_processors/delete.rb +23 -15
- data/lib/power_stencil/command_processors/edit.rb +4 -2
- data/lib/power_stencil/command_processors/init.rb +2 -2
- data/lib/power_stencil/command_processors/plugin.rb +21 -6
- data/lib/power_stencil/command_processors/root.rb +1 -1
- data/lib/power_stencil/command_processors/shell.rb +10 -3
- data/lib/power_stencil/dsl/entities.rb +0 -16
- 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/entities_handling.rb +1 -1
- data/lib/power_stencil/engine/project_engine.rb +6 -10
- data/lib/power_stencil/initializer.rb +4 -7
- data/lib/power_stencil/plugins/base.rb +3 -1
- data/lib/power_stencil/plugins/capabilities.rb +9 -4
- data/lib/power_stencil/plugins/entity_definitions.rb +15 -0
- data/lib/power_stencil/plugins/require.rb +1 -0
- data/lib/power_stencil/plugins/templates.rb +3 -3
- data/lib/power_stencil/project/base.rb +24 -9
- data/lib/power_stencil/project/create.rb +23 -2
- data/lib/power_stencil/project/git.rb +75 -0
- data/lib/power_stencil/project/info.rb +14 -1
- data/lib/power_stencil/project/paths.rb +22 -6
- data/lib/power_stencil/project/plugins.rb +7 -8
- data/lib/power_stencil/project/templates.rb +15 -22
- data/lib/power_stencil/system_entity_definitions/all.rb +2 -1
- data/lib/power_stencil/system_entity_definitions/buildable.rb +1 -1
- data/lib/power_stencil/system_entity_definitions/entity_override.rb +6 -0
- data/lib/power_stencil/system_entity_definitions/entity_project_common.rb +13 -5
- data/lib/power_stencil/system_entity_definitions/{has_associated_files.rb → entity_templates.rb} +2 -2
- data/lib/power_stencil/system_entity_definitions/project_config.rb +1 -1
- data/lib/power_stencil/system_entity_definitions/project_entity.rb +7 -0
- data/lib/power_stencil/system_entity_definitions/simple_exec.rb +3 -3
- data/lib/power_stencil/system_entity_definitions/source_provider.rb +15 -0
- data/lib/power_stencil/version.rb +1 -1
- data/power_stencil.gemspec +2 -1
- metadata +22 -6
@@ -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_templates[type]}'" unless entity_type_templates_templates[type].nil?
|
64
77
|
report << msg
|
65
78
|
end
|
66
79
|
report
|
@@ -7,12 +7,12 @@ module PowerStencil
|
|
7
7
|
|
8
8
|
attr_reader :project_config_root, :started_from
|
9
9
|
|
10
|
-
def self.
|
10
|
+
def self.system_templates_templates_path
|
11
11
|
File.expand_path File.join('..', '..', '..', '..', 'etc', 'templates'), __FILE__
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.
|
15
|
-
File.join
|
14
|
+
def self.project_system_template_template_path
|
15
|
+
File.join system_templates_templates_path, 'project'
|
16
16
|
end
|
17
17
|
|
18
18
|
def build_run_path(seed)
|
@@ -31,8 +31,8 @@ module PowerStencil
|
|
31
31
|
File.join project_root, PowerStencil.config[:project_build_root_directory_name]
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
File.join PowerStencil::Project::Paths.
|
34
|
+
def system_template_template_path(entity_type)
|
35
|
+
File.join PowerStencil::Project::Paths.system_templates_templates_path, entity_type.to_s
|
36
36
|
end
|
37
37
|
|
38
38
|
def project_local_plugins_path
|
@@ -43,10 +43,26 @@ module PowerStencil
|
|
43
43
|
File.join project_local_plugins_path, plugin_name
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
46
|
+
def project_templates_templates_path
|
47
47
|
File.join project_config_root, PowerStencil.config[:project_templates_directory_name]
|
48
48
|
end
|
49
49
|
|
50
|
+
def entities_template_path
|
51
|
+
File.join project_root, PowerStencil.config[:versioned_entities_templates_directory_name]
|
52
|
+
end
|
53
|
+
|
54
|
+
def user_entities_template_path
|
55
|
+
File.join project_root, PowerStencil.config[:unversioned_user_entities_templates_directory_name]
|
56
|
+
end
|
57
|
+
|
58
|
+
def entity_template_path(entity)
|
59
|
+
if entity.is_versioned_entity?
|
60
|
+
File.join entities_template_path, entity.type.to_s, entity.name
|
61
|
+
else
|
62
|
+
File.join user_entities_template_path, entity.type.to_s, entity.name
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
50
66
|
def project_entity_definitions_path
|
51
67
|
File.join project_config_root, PowerStencil.config[:project_entity_definitions_directory_name]
|
52
68
|
end
|
@@ -11,7 +11,7 @@ module PowerStencil
|
|
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
|
14
|
-
entity_engine.render_source
|
14
|
+
entity_engine.render_source entity_type_templates_templates[:plugin_definition],
|
15
15
|
new_plugin_path,
|
16
16
|
overwrite_files: overwrite_files,
|
17
17
|
main_entry_point: plugin_name
|
@@ -52,17 +52,16 @@ module PowerStencil
|
|
52
52
|
return
|
53
53
|
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
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|
|
60
59
|
begin
|
61
60
|
raise PowerStencil::Error, "Plugin '#{candidate}' already exists !" unless plugins[candidate].nil?
|
62
61
|
plugins[candidate] = PowerStencil::Plugins::Base.new(candidate, self)
|
63
62
|
rescue PowerStencil::Error => pse
|
64
|
-
|
65
|
-
|
63
|
+
logger.puts_and_logs pse.message, logs_as: :error
|
64
|
+
logger.puts_and_logs "Discarding invalid plugin '#{candidate}'.", logs_as: :error
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
@@ -3,48 +3,41 @@ module PowerStencil
|
|
3
3
|
|
4
4
|
module Templates
|
5
5
|
|
6
|
-
def
|
7
|
-
|
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 ||= {}
|
6
|
+
def entity_type_templates_templates
|
7
|
+
@entity_type_templates_templates ||= {}
|
15
8
|
end
|
16
9
|
|
17
|
-
def
|
18
|
-
if
|
19
|
-
logger.warn "There is already a template-template path registered for entity type '#{entity_type}': '#{
|
10
|
+
def register_template_template_path_for_type(entity_type, path)
|
11
|
+
if entity_type_templates_templates.include? entity_type
|
12
|
+
logger.warn "There is already a template-template path registered for entity type '#{entity_type}': '#{entity_type_templates_templates[entity_type]}'."
|
20
13
|
end
|
21
14
|
raise PowerStencil::Error, "There is no template in path: '#{path}'" unless Dir.exist? path and File.readable? path
|
22
15
|
raise PowerStencil::Error, "Trying to register a template for non existing type '#{entity_type}'" unless engine.available_entity_types.include? entity_type
|
23
16
|
logger.debug "Registering '#{path}' as template for type '#{entity_type}'."
|
24
|
-
|
17
|
+
entity_type_templates_templates[entity_type] = path
|
25
18
|
end
|
26
19
|
|
27
|
-
def
|
28
|
-
unless
|
20
|
+
def generate_template_dir_for_entity(entity, force: false)
|
21
|
+
unless entity_type_templates_templates[entity.type].nil?
|
29
22
|
logger.debug "Generating entity dir for entity '#{entity.as_path}'"
|
30
|
-
target_path =
|
31
|
-
|
23
|
+
target_path = entity.templates_path
|
24
|
+
render_entity_template_template_in entity, target_path, force: force
|
32
25
|
end
|
33
26
|
end
|
34
27
|
|
35
|
-
def
|
28
|
+
def delete_template_dir_for_entity(entity, force: false)
|
36
29
|
return unless force
|
37
|
-
unless
|
30
|
+
unless entity_type_templates_templates[entity.type].nil?
|
38
31
|
logger.debug "Deleting entity files for entity '#{entity.as_path}'"
|
39
|
-
target_path =
|
32
|
+
target_path = entity.templates_path
|
40
33
|
FileUtils.rmtree target_path unless target_path.nil? or target_path.empty?
|
41
34
|
end
|
42
35
|
end
|
43
36
|
|
44
37
|
private
|
45
38
|
|
46
|
-
def
|
47
|
-
entity_engine.render_source
|
39
|
+
def render_entity_template_template_in(entity, entity_dir_path, force: false)
|
40
|
+
entity_engine.render_source entity_type_templates_templates[entity.type],
|
48
41
|
entity_dir_path,
|
49
42
|
overwrite_files: force,
|
50
43
|
main_entry_point: entity.name
|
@@ -2,7 +2,8 @@
|
|
2
2
|
# So it is safe to declare files in the order you need.
|
3
3
|
|
4
4
|
require 'power_stencil/system_entity_definitions/non_persistent'
|
5
|
-
require 'power_stencil/system_entity_definitions/
|
5
|
+
require 'power_stencil/system_entity_definitions/entity_templates'
|
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
|
|
@@ -10,7 +10,7 @@ module PowerStencil
|
|
10
10
|
def buildable_by(plugin_name = nil)
|
11
11
|
return @build_plugin_name if plugin_name.nil?
|
12
12
|
@build_plugin_name = plugin_name
|
13
|
-
self.include PowerStencil::SystemEntityDefinitions::
|
13
|
+
self.include PowerStencil::SystemEntityDefinitions::EntityTemplates
|
14
14
|
end
|
15
15
|
|
16
16
|
def buildable?
|
@@ -1,8 +1,14 @@
|
|
1
1
|
class UniverseCompiler::Entity::Override
|
2
2
|
|
3
|
+
extend PowerStencil::SystemEntityDefinitions::SourceProvider
|
3
4
|
extend PowerStencil::SystemEntityDefinitions::Buildable
|
4
5
|
include PowerStencil::SystemEntityDefinitions::EntityProjectCommon
|
5
6
|
|
6
7
|
field :description
|
7
8
|
|
9
|
+
def initialize(fields: {}, universe: nil, user: false)
|
10
|
+
@is_versioned_entity = not(user)
|
11
|
+
super(fields: fields, universe: universe)
|
12
|
+
end
|
13
|
+
|
8
14
|
end
|
@@ -3,17 +3,25 @@ module PowerStencil
|
|
3
3
|
|
4
4
|
module EntityProjectCommon
|
5
5
|
|
6
|
-
|
6
|
+
def is_versioned_entity?
|
7
|
+
@is_versioned_entity
|
8
|
+
end
|
9
|
+
|
10
|
+
def is_user_entity?
|
11
|
+
not(@is_versioned_entity)
|
12
|
+
end
|
13
|
+
|
14
|
+
def save(uri = source_uri, raise_error: true, force_save: false, force_files_generation: false )
|
7
15
|
super(source_uri, raise_error: raise_error, force_save: force_save)
|
8
|
-
unless PowerStencil.project.
|
9
|
-
PowerStencil.project.
|
16
|
+
unless PowerStencil.project.entity_type_templates_templates[type].nil?
|
17
|
+
PowerStencil.project.generate_template_dir_for_entity self, force: force_files_generation
|
10
18
|
end
|
11
19
|
self
|
12
20
|
end
|
13
21
|
|
14
22
|
def delete(force_files_deletion: false)
|
15
|
-
unless PowerStencil.project.
|
16
|
-
PowerStencil.project.
|
23
|
+
unless PowerStencil.project.entity_type_templates_templates[type].nil?
|
24
|
+
PowerStencil.project.delete_template_dir_for_entity self, force: force_files_deletion
|
17
25
|
end
|
18
26
|
super()
|
19
27
|
self
|
data/lib/power_stencil/system_entity_definitions/{has_associated_files.rb → entity_templates.rb}
RENAMED
@@ -1,10 +1,10 @@
|
|
1
1
|
module PowerStencil
|
2
2
|
module SystemEntityDefinitions
|
3
3
|
|
4
|
-
module
|
4
|
+
module EntityTemplates
|
5
5
|
|
6
6
|
def templates_path
|
7
|
-
|
7
|
+
PowerStencil.project.entity_template_path self
|
8
8
|
end
|
9
9
|
|
10
10
|
end
|
@@ -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
|
|
@@ -10,6 +11,12 @@ module PowerStencil
|
|
10
11
|
|
11
12
|
field :description
|
12
13
|
|
14
|
+
def initialize(fields: {}, universe: nil, user: false)
|
15
|
+
@is_versioned_entity = not(user)
|
16
|
+
super(fields: fields, universe: universe)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
13
20
|
end
|
14
21
|
|
15
22
|
end
|
@@ -3,13 +3,13 @@ module PowerStencil
|
|
3
3
|
|
4
4
|
class SimpleExec < PowerStencil::SystemEntityDefinitions::ProjectEntity
|
5
5
|
|
6
|
-
include PowerStencil::SystemEntityDefinitions::
|
6
|
+
include PowerStencil::SystemEntityDefinitions::EntityTemplates
|
7
7
|
|
8
8
|
DOC = 'Describes a simple process to be called after source files have been rendered'.freeze
|
9
9
|
|
10
10
|
entity_type :simple_exec
|
11
11
|
|
12
|
-
|
12
|
+
buildable
|
13
13
|
|
14
14
|
has_one :process_descriptor, name: :post_process
|
15
15
|
not_null :post_process
|
@@ -20,7 +20,7 @@ module PowerStencil
|
|
20
20
|
self.post_process = PowerStencil.project.engine.new_entity universe, :process_descriptor, fields: {
|
21
21
|
name: "simple_exec_#{name}.process",
|
22
22
|
process: './main.sh'
|
23
|
-
}
|
23
|
+
}, user: is_user_entity?
|
24
24
|
end
|
25
25
|
end
|
26
26
|
super(raise_error: raise_error)
|
data/power_stencil.gemspec
CHANGED
@@ -25,10 +25,11 @@ 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'
|
32
|
+
spec.add_dependency 'git'
|
32
33
|
|
33
34
|
source_code_uri = 'https://gitlab.com/tools4devops/power_stencil'
|
34
35
|
|
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.7.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-10-
|
11
|
+
date: 2019-10-30 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
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: git
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: PowerStencil is the Swiss-army knife templating workflow for developers
|
112
126
|
and ops.
|
113
127
|
email:
|
@@ -240,6 +254,7 @@ files:
|
|
240
254
|
- lib/power_stencil/project/base.rb
|
241
255
|
- lib/power_stencil/project/config.rb
|
242
256
|
- lib/power_stencil/project/create.rb
|
257
|
+
- lib/power_stencil/project/git.rb
|
243
258
|
- lib/power_stencil/project/info.rb
|
244
259
|
- lib/power_stencil/project/paths.rb
|
245
260
|
- lib/power_stencil/project/plugins.rb
|
@@ -250,13 +265,14 @@ files:
|
|
250
265
|
- lib/power_stencil/system_entity_definitions/buildable.rb
|
251
266
|
- lib/power_stencil/system_entity_definitions/entity_override.rb
|
252
267
|
- lib/power_stencil/system_entity_definitions/entity_project_common.rb
|
253
|
-
- lib/power_stencil/system_entity_definitions/
|
268
|
+
- lib/power_stencil/system_entity_definitions/entity_templates.rb
|
254
269
|
- lib/power_stencil/system_entity_definitions/non_persistent.rb
|
255
270
|
- lib/power_stencil/system_entity_definitions/plugin.rb
|
256
271
|
- lib/power_stencil/system_entity_definitions/process_descriptor.rb
|
257
272
|
- lib/power_stencil/system_entity_definitions/project_config.rb
|
258
273
|
- lib/power_stencil/system_entity_definitions/project_entity.rb
|
259
274
|
- lib/power_stencil/system_entity_definitions/simple_exec.rb
|
275
|
+
- lib/power_stencil/system_entity_definitions/source_provider.rb
|
260
276
|
- lib/power_stencil/utils/directory_processor.rb
|
261
277
|
- lib/power_stencil/utils/file_edit.rb
|
262
278
|
- lib/power_stencil/utils/file_helper.rb
|
@@ -275,7 +291,7 @@ metadata:
|
|
275
291
|
documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
|
276
292
|
source_code_uri: https://gitlab.com/tools4devops/power_stencil
|
277
293
|
homepage_uri: https://powerstencil.brizone.org/
|
278
|
-
post_install_message: "\nThank you for installing PowerStencil 0.
|
294
|
+
post_install_message: "\nThank you for installing PowerStencil 0.7.1 !\nFrom the command
|
279
295
|
line you can run `power_stencil --help`\nIf your shell is not completing the command:\n
|
280
296
|
\ If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial Website
|
281
297
|
\ : https://powerstencil.brizone.org/\nFull documentation here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel
|