power_stencil 0.5.1 → 0.7.0
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/.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 +49 -1
- data/doc/templates.md +23 -18
- data/etc/base_commands_definition.yml +28 -1
- data/etc/meta_templates/plugin_seed/psplugin_{entity}.gemspec +3 -1
- data/etc/power_stencil.yaml +7 -1
- data/etc/templates/plugin_definition/psplugin_{entity}.gemspec +3 -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 +20 -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 +18 -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/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 +3 -3
- data/lib/power_stencil/project/base.rb +24 -9
- data/lib/power_stencil/project/config.rb +3 -2
- 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 -26
- data/lib/power_stencil/project/plugins.rb +18 -23
- 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/utils/gem_utils.rb +22 -2
- data/lib/power_stencil/version.rb +1 -1
- data/power_stencil.gemspec +2 -1
- metadata +23 -6
@@ -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)
|
@@ -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,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.0
|
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:
|
@@ -233,12 +247,14 @@ files:
|
|
233
247
|
- lib/power_stencil/plugins/dsl.rb
|
234
248
|
- lib/power_stencil/plugins/entity_definitions.rb
|
235
249
|
- lib/power_stencil/plugins/gem.rb
|
250
|
+
- lib/power_stencil/plugins/paths.rb
|
236
251
|
- lib/power_stencil/plugins/require.rb
|
237
252
|
- lib/power_stencil/plugins/templates.rb
|
238
253
|
- lib/power_stencil/plugins/type.rb
|
239
254
|
- lib/power_stencil/project/base.rb
|
240
255
|
- lib/power_stencil/project/config.rb
|
241
256
|
- lib/power_stencil/project/create.rb
|
257
|
+
- lib/power_stencil/project/git.rb
|
242
258
|
- lib/power_stencil/project/info.rb
|
243
259
|
- lib/power_stencil/project/paths.rb
|
244
260
|
- lib/power_stencil/project/plugins.rb
|
@@ -249,13 +265,14 @@ files:
|
|
249
265
|
- lib/power_stencil/system_entity_definitions/buildable.rb
|
250
266
|
- lib/power_stencil/system_entity_definitions/entity_override.rb
|
251
267
|
- lib/power_stencil/system_entity_definitions/entity_project_common.rb
|
252
|
-
- lib/power_stencil/system_entity_definitions/
|
268
|
+
- lib/power_stencil/system_entity_definitions/entity_templates.rb
|
253
269
|
- lib/power_stencil/system_entity_definitions/non_persistent.rb
|
254
270
|
- lib/power_stencil/system_entity_definitions/plugin.rb
|
255
271
|
- lib/power_stencil/system_entity_definitions/process_descriptor.rb
|
256
272
|
- lib/power_stencil/system_entity_definitions/project_config.rb
|
257
273
|
- lib/power_stencil/system_entity_definitions/project_entity.rb
|
258
274
|
- lib/power_stencil/system_entity_definitions/simple_exec.rb
|
275
|
+
- lib/power_stencil/system_entity_definitions/source_provider.rb
|
259
276
|
- lib/power_stencil/utils/directory_processor.rb
|
260
277
|
- lib/power_stencil/utils/file_edit.rb
|
261
278
|
- lib/power_stencil/utils/file_helper.rb
|
@@ -274,7 +291,7 @@ metadata:
|
|
274
291
|
documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
|
275
292
|
source_code_uri: https://gitlab.com/tools4devops/power_stencil
|
276
293
|
homepage_uri: https://powerstencil.brizone.org/
|
277
|
-
post_install_message: "\nThank you for installing PowerStencil 0.
|
294
|
+
post_install_message: "\nThank you for installing PowerStencil 0.7.0 !\nFrom the command
|
278
295
|
line you can run `power_stencil --help`\nIf your shell is not completing the command:\n
|
279
296
|
\ If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial Website
|
280
297
|
\ : https://powerstencil.brizone.org/\nFull documentation here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel
|