power_stencil 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/plugins.md +48 -1
- data/etc/base_commands_definition.yml +14 -1
- data/etc/meta_templates/plugin_seed/psplugin_{entity}.gemspec +3 -1
- data/etc/templates/plugin_definition/psplugin_{entity}.gemspec +3 -1
- data/lib/power_stencil/command_processors/plugin.rb +12 -2
- data/lib/power_stencil/plugins/base.rb +16 -9
- data/lib/power_stencil/plugins/capabilities.rb +1 -4
- data/lib/power_stencil/plugins/command_line.rb +1 -4
- data/lib/power_stencil/plugins/config.rb +1 -5
- 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 +9 -16
- data/lib/power_stencil/project/config.rb +3 -2
- data/lib/power_stencil/project/paths.rb +5 -25
- data/lib/power_stencil/project/plugins.rb +14 -18
- data/lib/power_stencil/utils/gem_utils.rb +22 -2
- data/lib/power_stencil/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 314848bb5c64481d2a9f56872d51ccb805038409
|
4
|
+
data.tar.gz: 608468d222257ddb0063b935d939c75fd592b254
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b73846ac1152992200f86cb5ae4e2f181c6d32b54fad1659ca90dea6ed6c05e0bf1252aea851ee67f315a6e624bedc2e9c05f47f92fd78a7f9913cc7a6811350
|
7
|
+
data.tar.gz: aaffc74c41eee5dfc69151ba61a6a982bf13680f1968fd353a2bf1d311a4f0d93f66a2495b8ad02f5dac6460ff568eec84756a422681c8641e3d3b9ae60923df
|
data/doc/plugins.md
CHANGED
@@ -15,6 +15,7 @@ Plugins
|
|
15
15
|
- [Providing entity types and templates](#providing-entity-types-and-templates)
|
16
16
|
- [Providing custom build process](#providing-custom-build-process)
|
17
17
|
- [Plugin capabilities and structure](#plugin-capabilities-and-structure)
|
18
|
+
- [Using plugins available as gems](#using-plugins-available-as-gems)
|
18
19
|
- [Conclusion](#conclusion)
|
19
20
|
|
20
21
|
<!-- /TOC -->
|
@@ -426,12 +427,58 @@ MinimalPlugin::Minimal:
|
|
426
427
|
|
427
428
|
All of this to demonstrate that a plugin can be almost anything, even something very minimalistic, but nevertheless you should keep on using the `power_stencil plugin --create` command and benefit from the structure it brings, as well as the possibility to become a stand-alone plugin gem...
|
428
429
|
|
430
|
+
# Using plugins available as gems
|
431
|
+
|
432
|
+
Any plugin you have created using the `power_stencil plugin --create` command is directly eligible to become a gem.
|
433
|
+
|
434
|
+
**If you release a plugin you created within a project as a gem (by doing `bundle exec rake release` from within the plugin directory, like for any standard gem :+1:), you can then re-use your plugin from any other `PowerStencil` project !**
|
435
|
+
|
436
|
+
All you have to do for that is to declare it in the `.ps_project/versioned-config.yaml` config file by adding an array `:project_plugins`:
|
437
|
+
|
438
|
+
```yaml
|
439
|
+
...
|
440
|
+
:project_plugins:
|
441
|
+
- my_awesome_plugin1
|
442
|
+
- my_awesome_plugin2
|
443
|
+
- my_awesome_plugin3
|
444
|
+
...
|
445
|
+
```
|
446
|
+
|
447
|
+
Now if you try to run power_stencil you may face an error if the gem is not locally installed:
|
448
|
+
|
449
|
+
```
|
450
|
+
▶ power_stencil info
|
451
|
+
--------------------------------------------------------------------------------
|
452
|
+
PROJECT REPORT
|
453
|
+
--------------------------------------------------------------------------------
|
454
|
+
General information:
|
455
|
+
Program aborted with message: 'Cannot find plugin 'my_awesome_plugin1'. Try 'power_stencil plugin --install''.
|
456
|
+
Use --debug option for more detail (see --help).
|
457
|
+
|
458
|
+
```
|
459
|
+
Here you have the choice to either manually install each of your plugins manually by using the regular gem program:
|
460
|
+
|
461
|
+
$ gem install my_awesome_plugin1 my_awesome_plugin2 my_awesome_plugin3
|
462
|
+
|
463
|
+
But `PowerStencil` provides a convenient command to install/update your plugins:
|
464
|
+
|
465
|
+
```
|
466
|
+
$ power_stencil plugin --install
|
467
|
+
Fetching: my_awesome_plugin1-0.1.0.gem (100%)
|
468
|
+
Fetching: my_awesome_plugin2-0.1.1.gem (100%)
|
469
|
+
Fetching: my_awesome_plugin3-1.2.3.gem (100%)
|
470
|
+
Installed plugin 'my_awesome_plugin1' (version: 0.1.0)
|
471
|
+
Installed plugin 'my_awesome_plugin2' (version: 0.1.1)
|
472
|
+
Installed plugin 'my_awesome_plugin3' (version: 1.2.3)
|
473
|
+
```
|
474
|
+
|
475
|
+
**:star2: ::+1: You can now verify using `power_stencil info` or `power_stencil plugin --list`, that the plugins have been installed and that any feature they provide is now available to your project.**
|
429
476
|
|
430
477
|
# Conclusion
|
431
478
|
|
432
479
|
The documentation for plugins is not fully complete, so you are encouraged to read the code. Some official plugins are under development, and the documentation will be improved along their development...
|
433
480
|
|
434
|
-
**:warning: As opposed to the rest of `PowerStencil`, the functionnality is nevertheless not completely frozen. This will be the case once `PowerStencil` turns 1.0.0.**
|
481
|
+
**:warning: As opposed to the rest of `PowerStencil`, the functionnality is nevertheless not completely frozen. This will be the case once `PowerStencil` turns 1.0.0.** but plugins are close to their final release, and anything above version 0.6 is already really usable.
|
435
482
|
|
436
483
|
|
437
484
|
[:back:][Documentation root]
|
@@ -104,13 +104,26 @@
|
|
104
104
|
:options:
|
105
105
|
create:
|
106
106
|
:type: bool
|
107
|
-
:summary:
|
107
|
+
:summary: Scaffolds a fully working plugin skeleton.
|
108
108
|
:long_aliases:
|
109
109
|
- new
|
110
110
|
- scaffold
|
111
|
+
:incompatibilities:
|
112
|
+
- list
|
113
|
+
- install
|
111
114
|
list:
|
112
115
|
:type: bool
|
113
116
|
:summary: List currently used plugins in this project.
|
117
|
+
:incompatibilities:
|
118
|
+
- create
|
119
|
+
- install
|
120
|
+
install:
|
121
|
+
:type: bool
|
122
|
+
:summary: Install gem plugins.
|
123
|
+
:incompatibilities:
|
124
|
+
- create
|
125
|
+
- list
|
126
|
+
|
114
127
|
get:
|
115
128
|
:banner: |
|
116
129
|
Query entities from repository.
|
@@ -18,8 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
19
|
if spec.respond_to?(:metadata)
|
20
20
|
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# This metadata is mandatory for PowerStencil !!
|
22
|
+
spec.metadata['plugin_name'] = '<%= plugin_name %>'
|
21
23
|
else
|
22
|
-
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes
|
24
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes and PowerStencil plugin mechanism !'
|
23
25
|
end
|
24
26
|
|
25
27
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -18,8 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
19
|
if spec.respond_to?(:metadata)
|
20
20
|
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# This metadata is mandatory for PowerStencil !!
|
22
|
+
spec.metadata['plugin_name'] = '<%= plugin_name %>'
|
21
23
|
else
|
22
|
-
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes
|
24
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes and PowerStencil plugin mechanism !'
|
23
25
|
end
|
24
26
|
|
25
27
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -8,6 +8,16 @@ module PowerStencil
|
|
8
8
|
include PowerStencil::Project::Proxy
|
9
9
|
|
10
10
|
def execute
|
11
|
+
|
12
|
+
if config[:install]
|
13
|
+
config[:project_plugins].each do |plugin_definition|
|
14
|
+
gem_name, gem_req = PowerStencil::Plugins::Base.plugin_definition_to_name_and_req plugin_definition
|
15
|
+
specs = PowerStencil::Plugins::Base.install_gem gem_name, gem_req
|
16
|
+
spec = specs.first
|
17
|
+
puts "Installed plugin '#{spec.name}' (version: #{spec.version})"
|
18
|
+
end
|
19
|
+
return
|
20
|
+
end
|
11
21
|
|
12
22
|
if config[:list]
|
13
23
|
if project.plugins.empty?
|
@@ -33,8 +43,8 @@ module PowerStencil
|
|
33
43
|
end
|
34
44
|
config.command_line_layer.extra_parameters.each do |plugin_name|
|
35
45
|
begin
|
36
|
-
target_path = File.join project.
|
37
|
-
project.
|
46
|
+
target_path = File.join project.project_local_plugin_path(plugin_name)
|
47
|
+
project.create_new_local_plugin_tree plugin_name, target_path
|
38
48
|
puts "Generated new plugin '#{plugin_name}'"
|
39
49
|
rescue => e
|
40
50
|
msg = "Could not create plugin '#{plugin_name}' because '#{e.message}'"
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'power_stencil/plugins/paths'
|
1
2
|
require 'power_stencil/plugins/type'
|
2
3
|
require 'power_stencil/plugins/config'
|
3
4
|
require 'power_stencil/plugins/command_line'
|
@@ -19,6 +20,7 @@ module PowerStencil
|
|
19
20
|
|
20
21
|
include Climatic::Proxy
|
21
22
|
include PowerStencil::Plugins::Type
|
23
|
+
include PowerStencil::Plugins::Paths
|
22
24
|
include PowerStencil::Plugins::Config
|
23
25
|
include PowerStencil::Plugins::CommandLine
|
24
26
|
include PowerStencil::Plugins::Require
|
@@ -28,27 +30,32 @@ module PowerStencil
|
|
28
30
|
include PowerStencil::Plugins::Build
|
29
31
|
include PowerStencil::Plugins::Dsl
|
30
32
|
|
31
|
-
attr_reader :name, :version, :entry_point_path
|
33
|
+
attr_reader :name, :version, :entry_point_path, :gem_spec
|
32
34
|
|
33
|
-
def initialize(name, project, type
|
35
|
+
def initialize(name, project, type: :local, gem_req: nil)
|
34
36
|
@name = name
|
35
37
|
@project = project
|
36
38
|
@version = PowerStencil::Utils::SemanticVersion.new '0.0.0-not-specified'
|
37
39
|
raise PowerStencil::Error, "Invalid plugin type (#{type}) for plugin '#{name}'" unless PLUGIN_TYPES.include? type
|
38
40
|
@type = type
|
41
|
+
case type
|
42
|
+
when :gem
|
43
|
+
logger.debug "Plugin '#{name}' is provided as a Gem."
|
44
|
+
@gem_spec = PowerStencil::Plugins::Base.find_locally_installed_gem_spec name, gem_req
|
45
|
+
raise PowerStencil::Error, "Cannot find plugin '#{name}'. Try 'power_stencil plugin --install'" if gem_spec.nil?
|
46
|
+
raise PowerStencil::Error, "Invalid plugin '#{name}' ! Missing metadata 'plugin_name' in spec !" if gem_spec.metadata['plugin_name'].nil?
|
47
|
+
@name = gem_spec.metadata['plugin_name']
|
48
|
+
logger.debug "Plugin real name is '#{name}'."
|
49
|
+
when :local
|
50
|
+
logger.debug "Plugin '#{name}' is provided locally by the project."
|
51
|
+
end
|
52
|
+
|
39
53
|
logger.debug "Loading plugin '#{name}'..."
|
40
54
|
setup_plugin
|
41
55
|
logger.info "Plugin '#{name}' successfully available"
|
42
56
|
logger.debug "Plugin '#{name}' has following capabilities: #{capabilities.inspect}"
|
43
57
|
end
|
44
58
|
|
45
|
-
def path
|
46
|
-
case type
|
47
|
-
when :local
|
48
|
-
project.project_plugin_path(name)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
59
|
def plugin_module
|
53
60
|
Object.const_get plugin_definition[:plugin_module]
|
54
61
|
end
|
@@ -9,10 +9,6 @@ module PowerStencil
|
|
9
9
|
|
10
10
|
attr_reader :plugin_definition
|
11
11
|
|
12
|
-
def plugin_capabilities_definition_file
|
13
|
-
project.plugin_capabilities_definition_file self.name
|
14
|
-
end
|
15
|
-
|
16
12
|
def capabilities
|
17
13
|
@capabilities ||= CAPABILITIES.dup.zip([false] * CAPABILITIES.size).to_h
|
18
14
|
end
|
@@ -24,6 +20,7 @@ module PowerStencil
|
|
24
20
|
unless File.exists? yaml_file and File.file? yaml_file and File.readable? yaml_file
|
25
21
|
raise PowerStencil::Error, "Plugin '#{self.name}' has no definition file !"
|
26
22
|
end
|
23
|
+
logger.debug "Loading plugin '#{self.name}' capabilities..."
|
27
24
|
@plugin_definition = yaml_file_to_hash yaml_file
|
28
25
|
%i(processors entity_definitions templates build dsl).each do |capability|
|
29
26
|
unless plugin_definition[capability].nil? or plugin_definition[capability].empty?
|
@@ -5,9 +5,6 @@ module PowerStencil
|
|
5
5
|
|
6
6
|
attr_reader :plugin_command_line_modifier
|
7
7
|
|
8
|
-
def plugin_commands_line_definition_file
|
9
|
-
project.plugin_commands_line_definition_file self.name
|
10
|
-
end
|
11
8
|
|
12
9
|
def register_processors
|
13
10
|
plugin_definition[:processors].each do |processors_name, processor|
|
@@ -20,7 +17,7 @@ module PowerStencil
|
|
20
17
|
private
|
21
18
|
|
22
19
|
def load_yaml_command_definition
|
23
|
-
yaml_file =
|
20
|
+
yaml_file = plugin_command_line_definition_file
|
24
21
|
if File.exists? yaml_file and File.file? yaml_file and File.readable? yaml_file
|
25
22
|
logger.info "Adding extra command line definition for '#{name}' plugin..."
|
26
23
|
@plugin_command_line_modifier = project.yaml_file_to_hash yaml_file
|
@@ -3,17 +3,13 @@ module PowerStencil
|
|
3
3
|
|
4
4
|
module Config
|
5
5
|
|
6
|
-
def plugin_config_specific_file
|
7
|
-
project.plugin_config_specific_file self.name
|
8
|
-
end
|
9
|
-
|
10
6
|
private
|
11
7
|
|
12
8
|
def load_plugin_specific_config
|
13
9
|
yaml_file = plugin_config_specific_file
|
14
10
|
if File.exists? yaml_file and File.file? yaml_file and File.readable? yaml_file
|
15
11
|
logger.info "Found plugin specific config in plugin '#{self.name}'. Attempting to load..."
|
16
|
-
project.add_plugin_config self
|
12
|
+
project.add_plugin_config self
|
17
13
|
capabilities[:config] = true
|
18
14
|
end
|
19
15
|
rescue => e
|
@@ -5,50 +5,29 @@ module PowerStencil
|
|
5
5
|
|
6
6
|
module Gem
|
7
7
|
|
8
|
+
include PowerStencil::Utils::GemUtils
|
9
|
+
|
8
10
|
NO_DOC = %w(--no-document).freeze
|
9
11
|
|
10
|
-
def gem_locally_installed?(plugin_name, plugin_requirements)
|
11
|
-
get_spec(plugin_name, plugin_requirements).nil? ? false : true
|
12
|
-
end
|
13
12
|
|
13
|
+
def is_available_gem?(gem_name)
|
14
14
|
|
15
|
-
def install_gem(plugin_name, plugin_requirements)
|
16
|
-
cmd = ::Gem::Commands::InstallCommand.new
|
17
|
-
opts = [plugin_name]
|
18
|
-
opts << plugin_requirements unless plugin_requirements.empty?
|
19
|
-
opts.concat NO_DOC
|
20
|
-
cmd.handle_options opts
|
21
|
-
PowerStencil.logger.debug "Installing plugin '#{plugin_name}'..."
|
22
|
-
cmd.execute
|
23
|
-
PowerStencil.logger.debug "Plugin '#{plugin_name}' successfully installed."
|
24
|
-
rescue ::Gem::SystemExitException => e
|
25
|
-
PowerStencil.logger.warn PowerStencil::Error.report_error(e)
|
26
15
|
end
|
27
16
|
|
17
|
+
def install_gem(plugin_name, plugin_requirements)
|
18
|
+
::Gem.install plugin_name, plugin_requirements
|
19
|
+
end
|
28
20
|
|
29
21
|
|
30
|
-
private
|
31
|
-
|
32
|
-
def get_spec(plugin_name, plugin_requirements)
|
33
|
-
candidates = ::Gem::Specification.find_all_by_name plugin_name
|
34
|
-
if candidates.empty?
|
35
|
-
PowerStencil.logger.debug "Could not find required plugin '#{plugin_name}'"
|
36
|
-
return nil
|
37
|
-
end
|
38
|
-
|
39
|
-
req = if plugin_requirements.nil? or plugin_requirements.empty?
|
40
|
-
::Gem::Requirement::DefaultRequirement
|
41
|
-
else
|
42
|
-
::Gem::Requirement.create plugin_requirements
|
43
|
-
end
|
44
|
-
|
45
|
-
selected = candidates.select {|candidate| req.satisfied_by? candidate.version}.sort {|a, b| a.version <=> b.version}
|
46
|
-
if candidates.empty?
|
47
|
-
PowerStencil.logger.debug "Could not find required plugin '#{plugin_name}'"
|
48
|
-
return nil
|
49
|
-
end
|
50
|
-
selected.last
|
51
22
|
|
23
|
+
def find_locally_installed_gem_spec(gem_name, gem_requirements = ::Gem::Requirement.default)
|
24
|
+
# Normal method to find gem_spec doesn't work in the context of bundler !!
|
25
|
+
# candidates = ::Gem::Specification.find_all_by_name gem_name
|
26
|
+
candidates = find_gemspec_manually(gem_name)
|
27
|
+
.select {|candidate| gem_requirements.satisfied_by? candidate.version}
|
28
|
+
.sort {|a, b| a.version <=> b.version}
|
29
|
+
PowerStencil.logger.error "Could not find required plugin '#{gem_name}'" if candidates.empty?
|
30
|
+
candidates.last
|
52
31
|
end
|
53
32
|
|
54
33
|
end
|
@@ -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,15 @@ module PowerStencil
|
|
15
14
|
end
|
16
15
|
|
17
16
|
def require_entry_point
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
securely_require entry_point_path unless plugin_definition[:plugin_module].nil?
|
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
|
+
logger.warn "As plugin '#{name}' code is invalid, removing '#{plugin_root_path}' from LOAD_PATH"
|
25
|
+
$LOAD_PATH.delete plugin_root_path
|
33
26
|
end
|
34
27
|
end
|
35
28
|
|
@@ -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
|
@@ -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,36 +32,30 @@ 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
|
-
candidates = Dir.entries(
|
61
|
-
.select { |e| File.directory? File.join(
|
55
|
+
candidates = Dir.entries(project_local_plugins_path)
|
56
|
+
.select { |e| File.directory? File.join(project_local_plugins_path, e) }
|
62
57
|
.reject { |d| %w(. ..).include? d }
|
63
|
-
|
58
|
+
|
64
59
|
candidates.each do |candidate|
|
65
60
|
begin
|
66
61
|
raise PowerStencil::Error, "Plugin '#{candidate}' already exists !" unless plugins[candidate].nil?
|
@@ -70,6 +65,7 @@ module PowerStencil
|
|
70
65
|
PowerStencil.logger.error "Discarding invalid plugin '#{candidate}'."
|
71
66
|
end
|
72
67
|
end
|
68
|
+
|
73
69
|
end
|
74
70
|
|
75
71
|
end
|
@@ -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
|
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.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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -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
|
@@ -274,7 +275,7 @@ metadata:
|
|
274
275
|
documentation_uri: https://gitlab.com/tools4devops/power_stencil/blob/master/README.md
|
275
276
|
source_code_uri: https://gitlab.com/tools4devops/power_stencil
|
276
277
|
homepage_uri: https://powerstencil.brizone.org/
|
277
|
-
post_install_message: "\nThank you for installing PowerStencil 0.
|
278
|
+
post_install_message: "\nThank you for installing PowerStencil 0.6.0 !\nFrom the command
|
278
279
|
line you can run `power_stencil --help`\nIf your shell is not completing the command:\n
|
279
280
|
\ If you use rbenv: `rbenv rehash`\n If you use zsh : `rehash`\n\nOfficial Website
|
280
281
|
\ : https://powerstencil.brizone.org/\nFull documentation here : https://gitlab.com/tools4devops/power_stencil/blob/master/README.md\nFeel
|