appifier 0.1.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 +7 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +30 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +26 -0
- data/Rakefile +35 -0
- data/VERSION +1 -0
- data/appifier.gemspec +39 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/settings.yml +8 -0
- data/exe/appifier +9 -0
- data/lib/appifier/actors/generator.rb +105 -0
- data/lib/appifier/actors/init.rb +1 -0
- data/lib/appifier/actors/retriever.rb +38 -0
- data/lib/appifier/cli/configuration.rb +18 -0
- data/lib/appifier/cli/templates.rb +14 -0
- data/lib/appifier/cli.rb +67 -0
- data/lib/appifier/helpers/archives.rb +40 -0
- data/lib/appifier/helpers/gem.rb +35 -0
- data/lib/appifier/helpers/init.rb +1 -0
- data/lib/appifier/helpers/user.rb +38 -0
- data/lib/appifier/setup.rb +16 -0
- data/lib/appifier/version.rb +4 -0
- data/lib/appifier.rb +50 -0
- data/samples/dummy.tgz +0 -0
- data/samples/skeleton/%%APPNAME.downcase%%/.rspec +0 -0
- data/samples/skeleton/%%APPNAME.downcase%%/Rakefile +0 -0
- data/samples/skeleton/%%APPNAME.downcase%%/config.ru +0 -0
- data/samples/skeleton/%%APPNAME.downcase%%/exe/%%APPNAME.downcase%% +0 -0
- data/samples/skeleton/%%APPNAME.downcase%%/lib/%%APPNAME.downcase%%.rb +0 -0
- data/samples/skeleton/%%APPNAME.downcase%%/spec/%%APPNAME.downcase%%_spec.rb +0 -0
- metadata +221 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f84489d520ea8b155b2b509e2cffbb77fd2bed0a1a7c526f496687196e751bb8
|
4
|
+
data.tar.gz: e44f047a7a1185ef8fa48abcf91a5124f2770ace0d0a6f51ceb166187a93752d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e97e31f134e240f3ac3237b858d01b09a145e7881d89a44fa990787f61d345906189643d68368e5bab7176efdfe18a397a0365c62fbee9201b813045ab8b862e
|
7
|
+
data.tar.gz: 4edce23e19c9c350d17ea21b07988daa50daf116495fc6e491b2c63b8a775cebc04c3906903aedfc8feb50d6fe890619b0cadb120617306d503864a9ed319f9b
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
SuggestExtensions: false
|
4
|
+
Exclude:
|
5
|
+
- 'spec/template_spec.rb'
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
# definitive :
|
10
|
+
Style/ClassVars:
|
11
|
+
Enabled: false
|
12
|
+
Gemspec/RequireMFA:
|
13
|
+
Enabled: false
|
14
|
+
Security/YAMLLoad:
|
15
|
+
Enabled: false
|
16
|
+
Style/MutableConstant:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
# to study :
|
20
|
+
|
21
|
+
Metrics/ClassLength:
|
22
|
+
Enabled: false
|
23
|
+
Metrics/AbcSize:
|
24
|
+
Enabled: false
|
25
|
+
Metrics/CyclomaticComplexity:
|
26
|
+
Enabled: false
|
27
|
+
Metrics/MethodLength:
|
28
|
+
Enabled: false
|
29
|
+
Metrics/PerceivedComplexity:
|
30
|
+
Enabled: false
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Pierre Alphonse
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Appifier
|
2
|
+
|
3
|
+
Appifier : Applications templating and management tools
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install appifier
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Appifier : Manage your applications templates, build, deploy, publish any type of application (CLI, web, etc...) in any languages with any facilities.
|
12
|
+
|
13
|
+
## Development
|
14
|
+
|
15
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
16
|
+
|
17
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
18
|
+
|
19
|
+
## Contributing
|
20
|
+
|
21
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Ultragreen/appifier.
|
22
|
+
|
23
|
+
|
24
|
+
## License
|
25
|
+
|
26
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "version"
|
4
|
+
require 'rake/version_task'
|
5
|
+
require 'code_statistics'
|
6
|
+
require 'yard'
|
7
|
+
require 'yard/rake/yardoc_task.rb'
|
8
|
+
require 'rubocop/rake_task'
|
9
|
+
require "carioca/rake/manage"
|
10
|
+
|
11
|
+
RuboCop::RakeTask.new
|
12
|
+
|
13
|
+
|
14
|
+
Rake::VersionTask.new
|
15
|
+
|
16
|
+
RSpec::Core::RakeTask.new(:spec)
|
17
|
+
|
18
|
+
|
19
|
+
task :default => :spec
|
20
|
+
|
21
|
+
YARD::Rake::YardocTask.new do |t|
|
22
|
+
t.files = [ 'lib/**/*.rb', '-', 'doc/**/*','spec/**/*_spec.rb']
|
23
|
+
t.options += ['-o', "yardoc"]
|
24
|
+
end
|
25
|
+
|
26
|
+
YARD::Config.load_plugin('yard-rspec')
|
27
|
+
|
28
|
+
namespace :yardoc do
|
29
|
+
task :clobber do
|
30
|
+
rm_r "yardoc" rescue nil
|
31
|
+
rm_r ".yardoc" rescue nil
|
32
|
+
rm_r "pkg" rescue nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
task :clobber => "yardoc:clobber"
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/appifier.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
Gem::Specification.new do |spec|
|
3
|
+
spec.name = "appifier"
|
4
|
+
spec.version = `cat VERSION`.chomp
|
5
|
+
spec.authors = ["Camille Paquet", "Romain GEORGES"]
|
6
|
+
spec.email = ["gems@ultragreen.net"]
|
7
|
+
|
8
|
+
spec.summary = "Appifier : Applications templating and management tools "
|
9
|
+
spec.description = "Appifier : Applications templating and management tools "
|
10
|
+
spec.homepage = "https://github.com/Ultragreen/appifier"
|
11
|
+
spec.license = "MIT"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
13
|
+
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
15
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
16
|
+
spec.metadata['changelog_uri'] = spec.homepage
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'rubocop', '~> 1.32'
|
30
|
+
spec.add_development_dependency "roodi", "~> 5.0"
|
31
|
+
spec.add_development_dependency 'code_statistics', '~> 0.2.13'
|
32
|
+
spec.add_development_dependency "yard", "~> 0.9.27"
|
33
|
+
spec.add_development_dependency "yard-rspec", "~> 0.1"
|
34
|
+
spec.add_development_dependency 'version', '~> 1.1'
|
35
|
+
spec.metadata['rubygems_mfa_required'] = 'false'
|
36
|
+
spec.add_dependency "carioca", "~> 2.0"
|
37
|
+
spec.add_dependency "thor", "~> 1.2"
|
38
|
+
|
39
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "appifier"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/config/settings.yml
ADDED
data/exe/appifier
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
|
2
|
+
module Appifier
|
3
|
+
|
4
|
+
module Actors
|
5
|
+
class Generator
|
6
|
+
|
7
|
+
attr_reader :src_paths
|
8
|
+
attr_reader :src_files
|
9
|
+
attr_reader :src_folders
|
10
|
+
attr_reader :target_folders
|
11
|
+
attr_reader :target_files
|
12
|
+
|
13
|
+
|
14
|
+
def initialize(src_root: , target_root:)
|
15
|
+
@src_root = src_root
|
16
|
+
@target_root = target_root
|
17
|
+
@target_folders = []
|
18
|
+
@target_files = []
|
19
|
+
@data = {appname: 'test'}
|
20
|
+
@src_paths = Dir.glob("#{@src_root}/**/*", File::FNM_DOTMATCH)
|
21
|
+
@src_paths.delete_if {|file| file =~ /\/\.$/}
|
22
|
+
@src_folders = @src_paths.select{|item| File::directory? item }
|
23
|
+
@src_files = @src_paths.select{|item| File::file? item }
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def generate(dry_run: false, force: false )
|
28
|
+
puts 'Running in dry_run' if dry_run
|
29
|
+
calculate
|
30
|
+
if check_folder_already_exist and !force
|
31
|
+
puts 'Folders and files already exist'
|
32
|
+
return false
|
33
|
+
end
|
34
|
+
FileUtils.rm_rf("#{@target_root}/#{@target_folders.first}") if force
|
35
|
+
puts 'Generate folders'
|
36
|
+
generate_folders dry_run: dry_run
|
37
|
+
puts 'Generate files'
|
38
|
+
generate_files dry_run: dry_run
|
39
|
+
end
|
40
|
+
|
41
|
+
def calculate
|
42
|
+
calculate_target type: :folder
|
43
|
+
calculate_target type: :file
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def check_folder_already_exist
|
49
|
+
File.directory?("#{@target_root}/#{@target_folders.first}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def generate_folders(dry_run:)
|
53
|
+
puts "Target path to create in #{@target_root} :"
|
54
|
+
@target_folders.each do |path|
|
55
|
+
action = (dry_run)? '[SKIPPED]' : '[OK]'
|
56
|
+
FileUtils.mkdir_p "#{@target_root}/#{path}", noop: dry_run
|
57
|
+
puts "#{action} #{path}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def generate_files(dry_run:)
|
62
|
+
puts "Target files to create in #{@target_root} :"
|
63
|
+
@src_files.each_with_index do |path, index|
|
64
|
+
if dry_run
|
65
|
+
result = "[SKIPPED]"
|
66
|
+
else
|
67
|
+
begin
|
68
|
+
template = Template::new strict:false,
|
69
|
+
list_token: @data.keys,
|
70
|
+
template_file: path
|
71
|
+
template.map(@data)
|
72
|
+
content = template.output
|
73
|
+
File.open("#{@target_root}/#{@target_files[index]}", 'w') { |file| file.write(content) }
|
74
|
+
result = "[OK]"
|
75
|
+
rescue InvalidTokenList, NotAToken, NoTemplateFile
|
76
|
+
result = "[KO]"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
puts "#{result} #{@target_files[index]}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def calculate_target(type:)
|
85
|
+
if type == :folder then
|
86
|
+
target = @target_folders
|
87
|
+
src = @src_folders
|
88
|
+
else
|
89
|
+
target = @target_files
|
90
|
+
src = @src_files
|
91
|
+
end
|
92
|
+
src.each do |folder|
|
93
|
+
template = Template::new strict:false,
|
94
|
+
list_token: @data.keys,
|
95
|
+
template_content: folder.delete_prefix("#{@src_root}/" )
|
96
|
+
template.map(@data)
|
97
|
+
output = template.output
|
98
|
+
target.push output unless target.include? output
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.dirname(__FILE__) + '/*.rb'].each {|file| require file unless File.basename(file) == 'init.rb'}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Appifier
|
2
|
+
|
3
|
+
module Actors
|
4
|
+
|
5
|
+
module Retrivers
|
6
|
+
class Git
|
7
|
+
def self.get(origin:, destination:)
|
8
|
+
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Archive
|
13
|
+
def self.get(origin:, destination:)
|
14
|
+
untar_gz archive: origin, destination: destination
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
class Retriever
|
21
|
+
|
22
|
+
TYPE = {:archive => Appifier::Actors::Retrivers::Archive, :git => Appifier::Actors::Retrivers::Git}
|
23
|
+
|
24
|
+
def initialize(type: :archive, origin:, destination: File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH ))
|
25
|
+
@origin = origin
|
26
|
+
@type = type
|
27
|
+
@destination = destination
|
28
|
+
puts "retrieving template from #{origin}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def get
|
32
|
+
TYPE[@type].get origin: @origin , destination: @destination
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Appifier
|
2
|
+
module CLI
|
3
|
+
module Subcommands
|
4
|
+
class Configuration < ::Thor
|
5
|
+
# Thor method : running of Appifier sanitycheck
|
6
|
+
desc "sanitycheck", "Verify installation of Appifier for user"
|
7
|
+
def sanitycheck
|
8
|
+
end
|
9
|
+
|
10
|
+
# Thor method : Getting the current Appifier version
|
11
|
+
desc "version", "Display current Appifier version"
|
12
|
+
def version
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/appifier/cli.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'appifier'
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
Dir[File.dirname(__FILE__) + '/cli/*.rb'].each {|file| require file }
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
module Appifier
|
10
|
+
|
11
|
+
module CLI
|
12
|
+
|
13
|
+
# The CLI Command structure for Thor
|
14
|
+
class Command < Thor
|
15
|
+
|
16
|
+
# callback for managing ARGV errors
|
17
|
+
def self.exit_on_failure?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
desc "templates SUBCOMMAND ...ARGS", "Managing apps templates"
|
24
|
+
subcommand "templates", Subcommands::Templates
|
25
|
+
|
26
|
+
|
27
|
+
desc "configuration SUBCOMMAND ...ARGS", "Configuration commands for Appifier"
|
28
|
+
subcommand "configuration", Subcommands::Configuration
|
29
|
+
|
30
|
+
|
31
|
+
# Thor method : running of Appifier generate
|
32
|
+
desc "generate TEMPLATE [TARGET]", "Generate application from bundled template"
|
33
|
+
long_desc <<-LONGDESC
|
34
|
+
Generate application from bundled template\n
|
35
|
+
with --simulate, only simulate folders and files installed
|
36
|
+
with --force, force regeneration of application, remove old files [DANGER]
|
37
|
+
LONGDESC
|
38
|
+
option :simulate, :type => :boolean, :aliases => "-s"
|
39
|
+
option :force, :type => :boolean, :aliases => "-F"
|
40
|
+
def generate(template,target='.')
|
41
|
+
source = "#{File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)}/#{template}"
|
42
|
+
if File::exist?(source)
|
43
|
+
generator = Appifier::Actors::Generator::new src_root: source, target_root: File.expand_path(target)
|
44
|
+
generator.generate dry_run: options[:simulate], force: options[:force]
|
45
|
+
else
|
46
|
+
puts "Application template not found"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
# Thor method : running of Appifier reteive
|
52
|
+
desc "retrieve ORIGIN", "Retrieve an application template in user templates bundle"
|
53
|
+
long_desc <<-LONGDESC
|
54
|
+
Retrieve an application template in user templates bundle\n
|
55
|
+
with --type [RETRIEVER], precise retrieving type ex,builtin [:git,:archive]
|
56
|
+
LONGDESC
|
57
|
+
option :type, :type => :string, :aliases => "-t", default: 'git'
|
58
|
+
def retrieve(origin)
|
59
|
+
type = options[:type].to_sym
|
60
|
+
retriever = Appifier::Actors::Retriever::new type: type, origin: origin
|
61
|
+
retriever.get
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rubygems/package'
|
2
|
+
require 'zlib'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
module Appifier
|
6
|
+
module Helpers
|
7
|
+
module Archives
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
def untar_gz(archive:, destination: )
|
12
|
+
source = open archive
|
13
|
+
::Gem::Package::TarReader.new( Zlib::GzipReader.new source ) do |tar|
|
14
|
+
dest = nil
|
15
|
+
tar.each do |entry|
|
16
|
+
if entry.full_name == '././@LongLink'
|
17
|
+
dest = File.join destination, entry.read.strip
|
18
|
+
next
|
19
|
+
end
|
20
|
+
dest ||= File.join destination, entry.full_name
|
21
|
+
if entry.directory?
|
22
|
+
File.delete dest if File.file? dest
|
23
|
+
FileUtils.mkdir_p dest, :mode => entry.header.mode, :verbose => false
|
24
|
+
elsif entry.file?
|
25
|
+
FileUtils.rm_rf dest if File.directory? dest
|
26
|
+
File.open dest, "wb" do |f|
|
27
|
+
f.print entry.read
|
28
|
+
end
|
29
|
+
FileUtils.chmod entry.header.mode, dest, :verbose => false
|
30
|
+
elsif entry.header.typeflag == '2' #Symlink!
|
31
|
+
File.symlink entry.header.linkname, dest
|
32
|
+
end
|
33
|
+
dest = nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Appifier
|
2
|
+
module Helpers
|
3
|
+
module Gem
|
4
|
+
# facility to find a file in gem path
|
5
|
+
# @param [String] _gem a Gem name
|
6
|
+
# @param [String] _file a file relative path in the gem
|
7
|
+
# @return [String] the path of the file, if found.
|
8
|
+
# @return [False] if not found
|
9
|
+
def search_file_in_gem(_gem,_file)
|
10
|
+
if ::Gem::Specification.respond_to?(:find_by_name)
|
11
|
+
begin
|
12
|
+
spec = ::Gem::Specification.find_by_name(_gem)
|
13
|
+
rescue LoadError
|
14
|
+
spec = nil
|
15
|
+
end
|
16
|
+
else
|
17
|
+
spec = ::Gem.searcher.find(_gem)
|
18
|
+
end
|
19
|
+
if spec then
|
20
|
+
if ::Gem::Specification.respond_to?(:find_by_name)
|
21
|
+
res = spec.lib_dirs_glob.split('/')
|
22
|
+
else
|
23
|
+
res = ::Gem.searcher.lib_dirs_for(spec).split('/')
|
24
|
+
end
|
25
|
+
res.pop
|
26
|
+
services_path = res.join('/').concat("/#{_file}")
|
27
|
+
return services_path if File::exist?(services_path)
|
28
|
+
return false
|
29
|
+
else
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.dirname(__FILE__) + '/*.rb'].each {|file| require file unless File.basename(file) == 'init.rb'}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Appifier
|
2
|
+
module Helpers
|
3
|
+
module User
|
4
|
+
|
5
|
+
# return the 'root' name
|
6
|
+
# @return [String] name
|
7
|
+
def user_root
|
8
|
+
return Etc.getpwuid(0).name
|
9
|
+
end
|
10
|
+
|
11
|
+
# return the current user name
|
12
|
+
# @return [String] name
|
13
|
+
def current_user
|
14
|
+
return Etc.getpwuid(Process.uid).name
|
15
|
+
end
|
16
|
+
|
17
|
+
# return the 'root' group name : root or wheel
|
18
|
+
# @return [String] name
|
19
|
+
def group_root
|
20
|
+
return Etc.getgrgid(0).name
|
21
|
+
end
|
22
|
+
|
23
|
+
# facility to verifying if the active process run as root
|
24
|
+
# @return [Bool] status
|
25
|
+
def is_root?
|
26
|
+
case (Process.uid)
|
27
|
+
when 0
|
28
|
+
return true
|
29
|
+
else
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Appifier
|
2
|
+
class Configuration
|
3
|
+
def self.setup(force: false)
|
4
|
+
|
5
|
+
if File::exist? File.expand_path(Appifier::DEFAULT_CONFIG_PATH) and !force
|
6
|
+
puts 'Appifier already configured'
|
7
|
+
else
|
8
|
+
config_file = search_file_in_gem('appifier','config/settings.yml')
|
9
|
+
path = File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)
|
10
|
+
FileUtils::mkdir_p File.expand_path(path) unless File::exist? File.expand_path(path)
|
11
|
+
FileUtils::cp config_file, File.expand_path(Appifier::DEFAULT_PATH)
|
12
|
+
puts '[OK] Building config folder and initialize settings'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/appifier.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require "appifier/version"
|
2
|
+
require 'appifier/helpers/init'
|
3
|
+
|
4
|
+
include Appifier::Helpers::User
|
5
|
+
include Appifier::Helpers::Gem
|
6
|
+
include Appifier::Helpers::Archives
|
7
|
+
|
8
|
+
require 'appifier/setup'
|
9
|
+
require 'appifier/actors/init'
|
10
|
+
require 'carioca'
|
11
|
+
|
12
|
+
require 'thot'
|
13
|
+
require 'fileutils'
|
14
|
+
require 'etc'
|
15
|
+
|
16
|
+
include Thot
|
17
|
+
|
18
|
+
module Appifier
|
19
|
+
DEFAULT_PATH = "~/.appifier"
|
20
|
+
DEFAULT_TEMPLATES_PATH = "#{DEFAULT_PATH}/templates"
|
21
|
+
DEFAULT_CONFIG_PATH = "#{DEFAULT_PATH}/settings.yml"
|
22
|
+
end
|
23
|
+
|
24
|
+
unless File::exist? File.expand_path(Appifier::DEFAULT_CONFIG_PATH)
|
25
|
+
puts "[W] Appifier not initialized for user #{current_user}, running setup"
|
26
|
+
Appifier::Configuration.setup
|
27
|
+
end
|
28
|
+
|
29
|
+
Carioca::Registry.configure do |spec|
|
30
|
+
spec.init_from_file = false
|
31
|
+
spec.debug = true if ENV['DEBUG']
|
32
|
+
spec.log_file = '/tmp/appifier.log'
|
33
|
+
spec.config_file = './config/settings.yml'
|
34
|
+
spec.config_root = :appifier
|
35
|
+
spec.environment = :production
|
36
|
+
spec.default_locale = :fr
|
37
|
+
spec.locales_load_path << Dir[File.expand_path('./config/locales') + '/*.yml']
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
module Appifier
|
42
|
+
|
43
|
+
class Application < Carioca::Container
|
44
|
+
inject service: :configuration
|
45
|
+
inject service: :i18n
|
46
|
+
logger.info(to_s) { 'Running Appifier' }
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/samples/dummy.tgz
ADDED
Binary file
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: appifier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Camille Paquet
|
8
|
+
- Romain GEORGES
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2022-10-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '12.0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '12.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '3.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '3.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rubocop
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.32'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.32'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: roodi
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '5.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '5.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: code_statistics
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.2.13
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.2.13
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: yard
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.9.27
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 0.9.27
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: yard-rspec
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0.1'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.1'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: version
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '1.1'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '1.1'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: carioca
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '2.0'
|
133
|
+
type: :runtime
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '2.0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: thor
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '1.2'
|
147
|
+
type: :runtime
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '1.2'
|
154
|
+
description: 'Appifier : Applications templating and management tools '
|
155
|
+
email:
|
156
|
+
- gems@ultragreen.net
|
157
|
+
executables:
|
158
|
+
- appifier
|
159
|
+
extensions: []
|
160
|
+
extra_rdoc_files: []
|
161
|
+
files:
|
162
|
+
- ".gitignore"
|
163
|
+
- ".rubocop.yml"
|
164
|
+
- Gemfile
|
165
|
+
- LICENSE.txt
|
166
|
+
- README.md
|
167
|
+
- Rakefile
|
168
|
+
- VERSION
|
169
|
+
- appifier.gemspec
|
170
|
+
- bin/console
|
171
|
+
- bin/setup
|
172
|
+
- config/settings.yml
|
173
|
+
- exe/appifier
|
174
|
+
- lib/appifier.rb
|
175
|
+
- lib/appifier/actors/generator.rb
|
176
|
+
- lib/appifier/actors/init.rb
|
177
|
+
- lib/appifier/actors/retriever.rb
|
178
|
+
- lib/appifier/cli.rb
|
179
|
+
- lib/appifier/cli/configuration.rb
|
180
|
+
- lib/appifier/cli/templates.rb
|
181
|
+
- lib/appifier/helpers/archives.rb
|
182
|
+
- lib/appifier/helpers/gem.rb
|
183
|
+
- lib/appifier/helpers/init.rb
|
184
|
+
- lib/appifier/helpers/user.rb
|
185
|
+
- lib/appifier/setup.rb
|
186
|
+
- lib/appifier/version.rb
|
187
|
+
- samples/dummy.tgz
|
188
|
+
- samples/skeleton/%%APPNAME.downcase%%/.rspec
|
189
|
+
- samples/skeleton/%%APPNAME.downcase%%/Rakefile
|
190
|
+
- samples/skeleton/%%APPNAME.downcase%%/config.ru
|
191
|
+
- samples/skeleton/%%APPNAME.downcase%%/exe/%%APPNAME.downcase%%
|
192
|
+
- samples/skeleton/%%APPNAME.downcase%%/lib/%%APPNAME.downcase%%.rb
|
193
|
+
- samples/skeleton/%%APPNAME.downcase%%/spec/%%APPNAME.downcase%%_spec.rb
|
194
|
+
homepage: https://github.com/Ultragreen/appifier
|
195
|
+
licenses:
|
196
|
+
- MIT
|
197
|
+
metadata:
|
198
|
+
homepage_uri: https://github.com/Ultragreen/appifier
|
199
|
+
source_code_uri: https://github.com/Ultragreen/appifier
|
200
|
+
changelog_uri: https://github.com/Ultragreen/appifier
|
201
|
+
rubygems_mfa_required: 'false'
|
202
|
+
post_install_message:
|
203
|
+
rdoc_options: []
|
204
|
+
require_paths:
|
205
|
+
- lib
|
206
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: 2.6.0
|
211
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
requirements: []
|
217
|
+
rubygems_version: 3.1.2
|
218
|
+
signing_key:
|
219
|
+
specification_version: 4
|
220
|
+
summary: 'Appifier : Applications templating and management tools'
|
221
|
+
test_files: []
|