appifier 0.1.0 → 0.1.1
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/.rubocop.yml +56 -2
- data/Gemfile +3 -1
- data/Rakefile +27 -15
- data/VERSION +1 -1
- data/appifier.gemspec +19 -19
- data/bin/console +4 -3
- data/exe/appifier +2 -1
- data/lib/appifier/actors/generator.rb +90 -100
- data/lib/appifier/actors/init.rb +3 -1
- data/lib/appifier/actors/retriever.rb +30 -36
- data/lib/appifier/cli/configuration.rb +13 -14
- data/lib/appifier/cli/templates.rb +18 -9
- data/lib/appifier/cli.rb +46 -57
- data/lib/appifier/helpers/archives.rb +29 -31
- data/lib/appifier/helpers/gem.rb +31 -30
- data/lib/appifier/helpers/init.rb +3 -1
- data/lib/appifier/helpers/templates.rb +27 -0
- data/lib/appifier/helpers/user.rb +29 -31
- data/lib/appifier/setup.rb +8 -7
- data/lib/appifier/version.rb +2 -0
- data/lib/appifier.rb +17 -20
- metadata +26 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ebe2edb236e0e8042528bed79556182fb8dc433a3fee5968925bfec477174ca
|
4
|
+
data.tar.gz: c68af6a6f2403399df42d306e57eae491fb34ace51642958a551187629b95c3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00df49a5f7cef5ff1186cb48bc260a26e999a741e2ac892bbedbf018d42f5c7bb0fd49a1e2da8bce16fbbe9f6be3326346f245f139c782630c3c93f9c796e1c0
|
7
|
+
data.tar.gz: 45876a4b19542f2ed10c01259a7f649b3b101a169443349f599e082e78e514a1c2591069f56225b72743d78ada3a1d7d4d8ddc83aa8c5fffa5993988a3ae2e29
|
data/.rubocop.yml
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
|
2
|
+
|
1
3
|
AllCops:
|
2
4
|
NewCops: enable
|
3
5
|
SuggestExtensions: false
|
4
6
|
Exclude:
|
5
|
-
- '
|
6
|
-
|
7
|
+
- 'samples/**/*'
|
8
|
+
- 'spec/**/*'
|
7
9
|
|
8
10
|
|
9
11
|
# definitive :
|
@@ -28,3 +30,55 @@ Metrics/MethodLength:
|
|
28
30
|
Enabled: false
|
29
31
|
Metrics/PerceivedComplexity:
|
30
32
|
Enabled: false
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
# Offense count: 2
|
37
|
+
# Configuration parameters: AllowKeywordBlockArguments.
|
38
|
+
Lint/UnderscorePrefixedVariableName:
|
39
|
+
Exclude:
|
40
|
+
- 'lib/appifier/helpers/gem.rb'
|
41
|
+
|
42
|
+
# Offense count: 1
|
43
|
+
Lint/UselessAssignment:
|
44
|
+
Exclude:
|
45
|
+
- 'lib/appifier.rb'
|
46
|
+
|
47
|
+
# Offense count: 1
|
48
|
+
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
|
49
|
+
# NamePrefix: is_, has_, have_
|
50
|
+
# ForbiddenPrefixes: is_, has_, have_
|
51
|
+
# AllowedMethods: is_a?
|
52
|
+
# MethodDefinitionMacros: define_method, define_singleton_method
|
53
|
+
Naming/PredicateName:
|
54
|
+
Exclude:
|
55
|
+
|
56
|
+
- 'lib/appifier/helpers/user.rb'
|
57
|
+
|
58
|
+
# Offense count: 1
|
59
|
+
Security/Open:
|
60
|
+
Exclude:
|
61
|
+
- 'lib/appifier/helpers/archives.rb'
|
62
|
+
|
63
|
+
# Offense count: 12
|
64
|
+
# Configuration parameters: AllowedConstants.
|
65
|
+
Style/Documentation:
|
66
|
+
Exclude:
|
67
|
+
- 'spec/**/*'
|
68
|
+
- 'test/**/*'
|
69
|
+
- 'lib/appifier.rb'
|
70
|
+
- 'lib/appifier/actors/generator.rb'
|
71
|
+
- 'lib/appifier/actors/retriever.rb'
|
72
|
+
- 'lib/appifier/cli/configuration.rb'
|
73
|
+
- 'lib/appifier/cli/templates.rb'
|
74
|
+
- 'lib/appifier/helpers/archives.rb'
|
75
|
+
- 'lib/appifier/helpers/gem.rb'
|
76
|
+
- 'lib/appifier/helpers/templates.rb'
|
77
|
+
- 'lib/appifier/helpers/user.rb'
|
78
|
+
- 'lib/appifier/setup.rb'
|
79
|
+
|
80
|
+
# Offense count: 2
|
81
|
+
Style/MixinUsage:
|
82
|
+
Exclude:
|
83
|
+
- 'exe/appifier'
|
84
|
+
- 'lib/appifier.rb'
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,35 +1,47 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'version'
|
4
6
|
require 'rake/version_task'
|
5
7
|
require 'code_statistics'
|
6
8
|
require 'yard'
|
7
|
-
require 'yard/rake/yardoc_task
|
9
|
+
require 'yard/rake/yardoc_task'
|
8
10
|
require 'rubocop/rake_task'
|
9
|
-
require
|
11
|
+
require 'carioca/rake/manage'
|
10
12
|
|
11
13
|
RuboCop::RakeTask.new
|
12
14
|
|
13
|
-
|
14
15
|
Rake::VersionTask.new
|
15
16
|
|
16
17
|
RSpec::Core::RakeTask.new(:spec)
|
17
18
|
|
18
|
-
|
19
|
-
task :default => :spec
|
19
|
+
task default: :spec
|
20
20
|
|
21
21
|
YARD::Rake::YardocTask.new do |t|
|
22
|
-
|
23
|
-
|
22
|
+
t.files = ['lib/**/*.rb', '-', 'doc/**/*', 'spec/**/*_spec.rb']
|
23
|
+
t.options += ['-o', 'yardoc']
|
24
24
|
end
|
25
25
|
|
26
26
|
YARD::Config.load_plugin('yard-rspec')
|
27
27
|
|
28
28
|
namespace :yardoc do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
task :clobber do
|
30
|
+
begin
|
31
|
+
rm_r 'yardoc'
|
32
|
+
rescue StandardError
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
begin
|
36
|
+
rm_r '.yardoc'
|
37
|
+
rescue StandardError
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
begin
|
41
|
+
rm_r 'pkg'
|
42
|
+
rescue StandardError
|
43
|
+
nil
|
33
44
|
end
|
45
|
+
end
|
34
46
|
end
|
35
|
-
task :
|
47
|
+
task clobber: 'yardoc:clobber'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/appifier.gemspec
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
Gem::Specification.new do |spec|
|
3
|
-
spec.name =
|
4
|
+
spec.name = 'appifier'
|
4
5
|
spec.version = `cat VERSION`.chomp
|
5
|
-
spec.authors = [
|
6
|
-
spec.email = [
|
6
|
+
spec.authors = ['Camille Paquet', 'Romain GEORGES']
|
7
|
+
spec.email = ['gems@ultragreen.net']
|
7
8
|
|
8
|
-
spec.summary =
|
9
|
-
spec.description =
|
10
|
-
spec.homepage =
|
11
|
-
spec.license =
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
9
|
+
spec.summary = 'Appifier : Applications templating and management tools '
|
10
|
+
spec.description = 'Appifier : Applications templating and management tools '
|
11
|
+
spec.homepage = 'https://github.com/Ultragreen/appifier'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
13
14
|
|
14
|
-
spec.metadata[
|
15
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
15
16
|
spec.metadata['source_code_uri'] = spec.homepage
|
16
17
|
spec.metadata['changelog_uri'] = spec.homepage
|
17
18
|
|
18
19
|
# Specify which files should be added to the gem when it is released.
|
19
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
-
spec.files
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
22
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
23
|
end
|
23
|
-
spec.bindir =
|
24
|
+
spec.bindir = 'exe'
|
24
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
-
spec.require_paths = [
|
26
|
+
spec.require_paths = ['lib']
|
26
27
|
|
28
|
+
spec.add_development_dependency 'code_statistics', '~> 0.2.13'
|
27
29
|
spec.add_development_dependency 'rake', '~> 12.0'
|
30
|
+
spec.add_development_dependency 'roodi', '~> 5.0'
|
28
31
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
32
|
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
33
|
spec.add_development_dependency 'version', '~> 1.1'
|
34
|
+
spec.add_development_dependency 'yard', '~> 0.9.27'
|
35
|
+
spec.add_development_dependency 'yard-rspec', '~> 0.1'
|
35
36
|
spec.metadata['rubygems_mfa_required'] = 'false'
|
36
|
-
spec.add_dependency
|
37
|
-
spec.add_dependency
|
38
|
-
|
37
|
+
spec.add_dependency 'carioca', '~> 2.0'
|
38
|
+
spec.add_dependency 'thor', '~> 1.2'
|
39
39
|
end
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'appifier'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "appifier"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/exe/appifier
CHANGED
@@ -1,105 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
module Appifier
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
3
|
+
module Appifier
|
4
|
+
module Actors
|
5
|
+
class Generator
|
6
|
+
attr_reader :src_paths, :src_files, :src_folders, :target_folders, :target_files
|
7
|
+
|
8
|
+
def initialize(src_root:, target_root:)
|
9
|
+
@src_root = src_root
|
10
|
+
@target_root = target_root
|
11
|
+
@target_folders = []
|
12
|
+
@target_files = []
|
13
|
+
@data = { appname: 'test' }
|
14
|
+
@src_paths = Dir.glob("#{@src_root}/**/*", File::FNM_DOTMATCH)
|
15
|
+
@src_paths.delete_if { |file| file =~ %r{/\.$} }
|
16
|
+
@src_folders = @src_paths.select { |item| File.directory? item }
|
17
|
+
@src_files = @src_paths.select { |item| File.file? item }
|
18
|
+
end
|
19
|
+
|
20
|
+
def generate(dry_run: false, force: false)
|
21
|
+
puts 'Running in dry_run' if dry_run
|
22
|
+
calculate
|
23
|
+
if check_folder_already_exist && !force
|
24
|
+
puts 'Folders and files already exist'
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
FileUtils.rm_rf("#{@target_root}/#{@target_folders.first}") if force
|
28
|
+
puts 'Generate folders'
|
29
|
+
generate_folders dry_run: dry_run
|
30
|
+
puts 'Generate files'
|
31
|
+
generate_files dry_run: dry_run
|
32
|
+
end
|
33
|
+
|
34
|
+
def calculate
|
35
|
+
calculate_target type: :folder
|
36
|
+
calculate_target type: :file
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def check_folder_already_exist
|
42
|
+
File.directory?("#{@target_root}/#{@target_folders.first}")
|
43
|
+
end
|
44
|
+
|
45
|
+
def generate_folders(dry_run:)
|
46
|
+
puts "Target path to create in #{@target_root} :"
|
47
|
+
@target_folders.each do |path|
|
48
|
+
action = dry_run ? '[SKIPPED]' : '[OK]'
|
49
|
+
FileUtils.mkdir_p "#{@target_root}/#{path}", noop: dry_run
|
50
|
+
puts "#{action} #{path}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def generate_files(dry_run:)
|
55
|
+
puts "Target files to create in #{@target_root} :"
|
56
|
+
@src_files.each_with_index do |path, index|
|
57
|
+
if dry_run
|
58
|
+
result = '[SKIPPED]'
|
59
|
+
else
|
60
|
+
begin
|
61
|
+
template = Template.new strict: false,
|
62
|
+
list_token: @data.keys,
|
63
|
+
template_file: path
|
64
|
+
template.map(@data)
|
65
|
+
content = template.output
|
66
|
+
File.write("#{@target_root}/#{@target_files[index]}", content)
|
67
|
+
result = '[OK]'
|
68
|
+
rescue InvalidTokenList, NotAToken, NoTemplateFile
|
69
|
+
result = '[KO]'
|
101
70
|
end
|
102
|
-
|
71
|
+
end
|
72
|
+
puts "#{result} #{@target_files[index]}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def calculate_target(type:)
|
77
|
+
if type == :folder
|
78
|
+
target = @target_folders
|
79
|
+
src = @src_folders
|
80
|
+
else
|
81
|
+
target = @target_files
|
82
|
+
src = @src_files
|
83
|
+
end
|
84
|
+
src.each do |folder|
|
85
|
+
template = Template.new strict: false,
|
86
|
+
list_token: @data.keys,
|
87
|
+
template_content: folder.delete_prefix("#{@src_root}/")
|
88
|
+
template.map(@data)
|
89
|
+
output = template.output
|
90
|
+
target.push output unless target.include? output
|
103
91
|
end
|
92
|
+
end
|
104
93
|
end
|
94
|
+
end
|
105
95
|
end
|
data/lib/appifier/actors/init.rb
CHANGED
@@ -1,38 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def self.get(origin:, destination:)
|
14
|
-
untar_gz archive: origin, destination: destination
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appifier
|
4
|
+
module Actors
|
5
|
+
module Retrivers
|
6
|
+
class Git
|
7
|
+
def self.get(origin:, destination:); end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Archive
|
11
|
+
def self.get(origin:, destination:)
|
12
|
+
untar_gz archive: origin, destination: destination
|
18
13
|
end
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Retriever
|
18
|
+
TYPE = { archive: Appifier::Actors::Retrivers::Archive, git: Appifier::Actors::Retrivers::Git }
|
19
|
+
|
20
|
+
def initialize(origin:, type: :archive, destination: File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH))
|
21
|
+
@origin = origin
|
22
|
+
@type = type
|
23
|
+
@destination = destination
|
24
|
+
puts "retrieving template from #{origin}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def get
|
28
|
+
TYPE[@type].get origin: @origin, destination: @destination
|
29
|
+
end
|
37
30
|
end
|
38
|
-
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,18 +1,17 @@
|
|
1
|
-
|
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
|
1
|
+
# frozen_string_literal: true
|
9
2
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
module Appifier
|
4
|
+
module CLI
|
5
|
+
module Subcommands
|
6
|
+
class Configuration < ::Thor
|
7
|
+
# Thor method : running of Appifier sanitycheck
|
8
|
+
desc 'sanitycheck', 'Verify installation of Appifier for user'
|
9
|
+
def sanitycheck; end
|
14
10
|
|
15
|
-
|
16
|
-
|
11
|
+
# Thor method : Getting the current Appifier version
|
12
|
+
desc 'version', 'Display current Appifier version'
|
13
|
+
def version; end
|
14
|
+
end
|
17
15
|
end
|
16
|
+
end
|
18
17
|
end
|
@@ -1,14 +1,23 @@
|
|
1
|
-
|
2
|
-
module CLI
|
3
|
-
module Subcommands
|
4
|
-
class Templates < ::Thor
|
5
|
-
# Thor method : running of Appifier sanitycheck
|
6
|
-
desc "ls", "list templates avaibles in user bundle"
|
7
|
-
def ls
|
8
|
-
end
|
1
|
+
# frozen_string_literal: true
|
9
2
|
|
3
|
+
module Appifier
|
4
|
+
module CLI
|
5
|
+
module Subcommands
|
6
|
+
class Templates < ::Thor
|
7
|
+
# Thor method : list availables templates in user bundle
|
8
|
+
desc 'ls', 'list templates availables in user bundle'
|
9
|
+
def ls
|
10
|
+
puts "List of avaible templates for user : #{current_user} :"
|
11
|
+
list_bundled_templates
|
12
|
+
end
|
10
13
|
|
11
|
-
|
14
|
+
# Thor method : remove a template from user bundle
|
15
|
+
desc 'rm', 'rm templates from user bundle'
|
16
|
+
def rm(template)
|
17
|
+
puts "Removing template #{template} for user : #{current_user} :"
|
18
|
+
rm_bundled_template(template)
|
12
19
|
end
|
20
|
+
end
|
13
21
|
end
|
22
|
+
end
|
14
23
|
end
|
data/lib/appifier/cli.rb
CHANGED
@@ -1,67 +1,56 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'appifier'
|
3
4
|
require 'thor'
|
4
5
|
|
5
|
-
Dir[File.dirname(__FILE__)
|
6
|
-
|
7
|
-
|
6
|
+
Dir["#{File.dirname(__FILE__)}/cli/*.rb"].sort.each { |file| require file }
|
8
7
|
|
9
8
|
module Appifier
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
9
|
+
module CLI
|
10
|
+
# The CLI Command structure for Thor
|
11
|
+
class Command < Thor
|
12
|
+
# callback for managing ARGV errors
|
13
|
+
def self.exit_on_failure?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'templates SUBCOMMAND ...ARGS', 'Managing apps templates'
|
18
|
+
subcommand 'templates', Subcommands::Templates
|
19
|
+
|
20
|
+
desc 'configuration SUBCOMMAND ...ARGS', 'Configuration commands for Appifier'
|
21
|
+
subcommand 'configuration', Subcommands::Configuration
|
22
|
+
|
23
|
+
# Thor method : running of Appifier generate
|
24
|
+
desc 'generate TEMPLATE [TARGET]', 'Generate application from bundled template'
|
25
|
+
long_desc <<-LONGDESC
|
34
26
|
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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
27
|
+
with --simulate, only simulate folders and files installed#{' '}
|
28
|
+
with --force, force regeneration of application, remove old files [DANGER]#{' '}
|
29
|
+
LONGDESC
|
30
|
+
option :simulate, type: :boolean, aliases: '-s'
|
31
|
+
option :force, type: :boolean, aliases: '-F'
|
32
|
+
def generate(template, target = '.')
|
33
|
+
source = "#{File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)}/#{template}"
|
34
|
+
if File.exist?(source)
|
35
|
+
generator = Appifier::Actors::Generator.new src_root: source, target_root: File.expand_path(target)
|
36
|
+
generator.generate dry_run: options[:simulate], force: options[:force]
|
37
|
+
else
|
38
|
+
puts 'Application template not found'
|
39
|
+
end
|
40
|
+
end
|
50
41
|
|
51
|
-
|
52
|
-
|
53
|
-
|
42
|
+
# Thor method : running of Appifier reteive
|
43
|
+
desc 'retrieve ORIGIN', 'Retrieve an application template in user templates bundle'
|
44
|
+
long_desc <<-LONGDESC
|
54
45
|
Retrieve an application template in user templates bundle\n
|
55
46
|
with --type [RETRIEVER], precise retrieving type ex,builtin [:git,:archive]
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
|
47
|
+
LONGDESC
|
48
|
+
option :type, type: :string, aliases: '-t', default: 'git'
|
49
|
+
def retrieve(origin)
|
50
|
+
type = options[:type].to_sym
|
51
|
+
retriever = Appifier::Actors::Retriever.new type: type, origin: origin
|
52
|
+
retriever.get
|
53
|
+
end
|
66
54
|
end
|
67
|
-
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,40 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rubygems/package'
|
2
4
|
require 'zlib'
|
3
5
|
require 'open-uri'
|
4
6
|
|
5
7
|
module Appifier
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
8
|
+
module Helpers
|
9
|
+
module Archives
|
10
|
+
def untar_gz(archive:, destination:)
|
11
|
+
source = open archive
|
12
|
+
::Gem::Package::TarReader.new(Zlib::GzipReader.new(source)) do |tar|
|
13
|
+
dest = nil
|
14
|
+
tar.each do |entry|
|
15
|
+
if entry.full_name == '././@LongLink'
|
16
|
+
dest = File.join destination, entry.read.strip
|
17
|
+
next
|
36
18
|
end
|
37
|
-
|
19
|
+
dest ||= File.join destination, entry.full_name
|
20
|
+
if entry.directory?
|
21
|
+
File.delete dest if File.file? dest
|
22
|
+
FileUtils.mkdir_p dest, mode: entry.header.mode, verbose: false
|
23
|
+
elsif entry.file?
|
24
|
+
FileUtils.rm_rf dest if File.directory? dest
|
25
|
+
File.open dest, 'wb' do |f|
|
26
|
+
f.print entry.read
|
27
|
+
end
|
28
|
+
FileUtils.chmod entry.header.mode, dest, verbose: false
|
29
|
+
elsif entry.header.typeflag == '2' # Symlink!
|
30
|
+
File.symlink entry.header.linkname, dest
|
31
|
+
end
|
32
|
+
dest = nil
|
33
|
+
end
|
38
34
|
end
|
35
|
+
end
|
39
36
|
end
|
37
|
+
end
|
40
38
|
end
|
data/lib/appifier/helpers/gem.rb
CHANGED
@@ -1,35 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Appifier
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
4
|
+
module Helpers
|
5
|
+
module Gem
|
6
|
+
# facility to find a file in gem path
|
7
|
+
# @param [String] _gem a Gem name
|
8
|
+
# @param [String] _file a file relative path in the gem
|
9
|
+
# @return [String] the path of the file, if found.
|
10
|
+
# @return [False] if not found
|
11
|
+
def search_file_in_gem(_gem, _file)
|
12
|
+
if ::Gem::Specification.respond_to?(:find_by_name)
|
13
|
+
begin
|
14
|
+
spec = ::Gem::Specification.find_by_name(_gem)
|
15
|
+
rescue LoadError
|
16
|
+
spec = nil
|
17
|
+
end
|
18
|
+
else
|
19
|
+
spec = ::Gem.searcher.find(_gem)
|
20
|
+
end
|
21
|
+
if spec
|
22
|
+
res = if ::Gem::Specification.respond_to?(:find_by_name)
|
23
|
+
spec.lib_dirs_glob.split('/')
|
29
24
|
else
|
30
|
-
|
25
|
+
::Gem.searcher.lib_dirs_for(spec).split('/')
|
31
26
|
end
|
32
|
-
|
27
|
+
res.pop
|
28
|
+
services_path = res.join('/').concat("/#{_file}")
|
29
|
+
return services_path if File.exist?(services_path)
|
30
|
+
|
33
31
|
end
|
32
|
+
false
|
33
|
+
end
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appifier
|
4
|
+
module Helpers
|
5
|
+
module Templates
|
6
|
+
def list_bundled_templates
|
7
|
+
template_path = File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)
|
8
|
+
Dir.glob("#{template_path}/*").map { |item| item.delete_prefix("#{template_path}/") }.each do |template|
|
9
|
+
puts " * #{template}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def rm_bundled_template(template)
|
14
|
+
template_path = File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)
|
15
|
+
begin
|
16
|
+
if FileUtils.rm_rf "#{template_path}/#{template}"
|
17
|
+
puts "[RM] Template #{template} deleted of bundle for user #{current_user}"
|
18
|
+
else
|
19
|
+
puts "[ERROR] Template #{template} not found in bundle for user #{current_user}"
|
20
|
+
end
|
21
|
+
rescue Errno::ENOENT
|
22
|
+
puts "[ERROR] Template #{template} not found in bundle for user #{current_user}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,38 +1,36 @@
|
|
1
|
-
|
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
|
1
|
+
# frozen_string_literal: true
|
10
2
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def group_root
|
20
|
-
return Etc.getgrgid(0).name
|
21
|
-
end
|
3
|
+
module Appifier
|
4
|
+
module Helpers
|
5
|
+
module User
|
6
|
+
# return the 'root' name
|
7
|
+
# @return [String] name
|
8
|
+
def user_root
|
9
|
+
Etc.getpwuid(0).name
|
10
|
+
end
|
22
11
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
return true
|
29
|
-
else
|
30
|
-
return false
|
31
|
-
end
|
32
|
-
end
|
12
|
+
# return the current user name
|
13
|
+
# @return [String] name
|
14
|
+
def current_user
|
15
|
+
Etc.getpwuid(Process.uid).name
|
16
|
+
end
|
33
17
|
|
18
|
+
# return the 'root' group name : root or wheel
|
19
|
+
# @return [String] name
|
20
|
+
def group_root
|
21
|
+
Etc.getgrgid(0).name
|
22
|
+
end
|
34
23
|
|
24
|
+
# facility to verifying if the active process run as root
|
25
|
+
# @return [Bool] status
|
26
|
+
def is_root?
|
27
|
+
case Process.uid
|
28
|
+
when 0
|
29
|
+
true
|
30
|
+
else
|
31
|
+
false
|
35
32
|
end
|
33
|
+
end
|
36
34
|
end
|
35
|
+
end
|
37
36
|
end
|
38
|
-
|
data/lib/appifier/setup.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Appifier
|
2
4
|
class Configuration
|
3
5
|
def self.setup(force: false)
|
4
|
-
|
5
|
-
|
6
|
-
puts 'Appifier already configured'
|
6
|
+
if File.exist?(File.expand_path(Appifier::DEFAULT_CONFIG_PATH)) && !force
|
7
|
+
puts 'Appifier already configured'
|
7
8
|
else
|
8
|
-
config_file = search_file_in_gem('appifier','config/settings.yml')
|
9
|
+
config_file = search_file_in_gem('appifier', 'config/settings.yml')
|
9
10
|
path = File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)
|
10
|
-
FileUtils
|
11
|
-
FileUtils
|
11
|
+
FileUtils.mkdir_p File.expand_path(path)
|
12
|
+
FileUtils.cp config_file, File.expand_path(Appifier::DEFAULT_PATH)
|
12
13
|
puts '[OK] Building config folder and initialize settings'
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
16
|
-
end
|
17
|
+
end
|
data/lib/appifier/version.rb
CHANGED
data/lib/appifier.rb
CHANGED
@@ -1,30 +1,31 @@
|
|
1
|
-
|
2
|
-
require 'appifier/helpers/init'
|
3
|
-
|
4
|
-
include Appifier::Helpers::User
|
5
|
-
include Appifier::Helpers::Gem
|
6
|
-
include Appifier::Helpers::Archives
|
1
|
+
# frozen_string_literal: true
|
7
2
|
|
8
|
-
require 'appifier/setup'
|
9
|
-
require 'appifier/actors/init'
|
10
3
|
require 'carioca'
|
11
|
-
|
12
4
|
require 'thot'
|
13
5
|
require 'fileutils'
|
14
6
|
require 'etc'
|
15
7
|
|
16
8
|
include Thot
|
17
|
-
|
18
9
|
module Appifier
|
19
|
-
DEFAULT_PATH =
|
10
|
+
DEFAULT_PATH = '~/.appifier'
|
20
11
|
DEFAULT_TEMPLATES_PATH = "#{DEFAULT_PATH}/templates"
|
21
12
|
DEFAULT_CONFIG_PATH = "#{DEFAULT_PATH}/settings.yml"
|
22
13
|
end
|
23
14
|
|
24
|
-
|
15
|
+
require 'appifier/version'
|
16
|
+
require 'appifier/helpers/init'
|
17
|
+
|
18
|
+
Appifier::Helpers.constants.select { |c| Appifier::Helpers.const_get(c).is_a? Module }
|
19
|
+
.map { |item| item = "Appifier::Helpers::#{item}" }
|
20
|
+
.each { |mod| include Object.const_get(mod) }
|
21
|
+
|
22
|
+
require 'appifier/setup'
|
23
|
+
require 'appifier/actors/init'
|
24
|
+
|
25
|
+
unless File.exist? File.expand_path(Appifier::DEFAULT_CONFIG_PATH)
|
25
26
|
puts "[W] Appifier not initialized for user #{current_user}, running setup"
|
26
|
-
Appifier::Configuration.setup
|
27
|
-
end
|
27
|
+
Appifier::Configuration.setup
|
28
|
+
end
|
28
29
|
|
29
30
|
Carioca::Registry.configure do |spec|
|
30
31
|
spec.init_from_file = false
|
@@ -34,17 +35,13 @@ Carioca::Registry.configure do |spec|
|
|
34
35
|
spec.config_root = :appifier
|
35
36
|
spec.environment = :production
|
36
37
|
spec.default_locale = :fr
|
37
|
-
spec.locales_load_path << Dir[File.expand_path('./config/locales')
|
38
|
+
spec.locales_load_path << Dir["#{File.expand_path('./config/locales')}/*.yml"]
|
38
39
|
end
|
39
40
|
|
40
|
-
|
41
41
|
module Appifier
|
42
|
-
|
43
42
|
class Application < Carioca::Container
|
44
43
|
inject service: :configuration
|
45
44
|
inject service: :i18n
|
46
45
|
logger.info(to_s) { 'Running Appifier' }
|
47
|
-
|
48
46
|
end
|
49
|
-
|
50
|
-
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camille Paquet
|
@@ -12,117 +12,117 @@ cert_chain: []
|
|
12
12
|
date: 2022-10-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: code_statistics
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 0.2.13
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 0.2.13
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '12.0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '12.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: roodi
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '5.0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '5.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '3.0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '3.0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: rubocop
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: '1.32'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
83
|
+
version: '1.32'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: version
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
90
|
+
version: '1.1'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
97
|
+
version: '1.1'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
|
-
name: yard
|
99
|
+
name: yard
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
104
|
+
version: 0.9.27
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version:
|
111
|
+
version: 0.9.27
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
|
-
name:
|
113
|
+
name: yard-rspec
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
118
|
+
version: '0.1'
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: '
|
125
|
+
version: '0.1'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: carioca
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- lib/appifier/helpers/archives.rb
|
182
182
|
- lib/appifier/helpers/gem.rb
|
183
183
|
- lib/appifier/helpers/init.rb
|
184
|
+
- lib/appifier/helpers/templates.rb
|
184
185
|
- lib/appifier/helpers/user.rb
|
185
186
|
- lib/appifier/setup.rb
|
186
187
|
- lib/appifier/version.rb
|