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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f84489d520ea8b155b2b509e2cffbb77fd2bed0a1a7c526f496687196e751bb8
4
- data.tar.gz: e44f047a7a1185ef8fa48abcf91a5124f2770ace0d0a6f51ceb166187a93752d
3
+ metadata.gz: 6ebe2edb236e0e8042528bed79556182fb8dc433a3fee5968925bfec477174ca
4
+ data.tar.gz: c68af6a6f2403399df42d306e57eae491fb34ace51642958a551187629b95c3c
5
5
  SHA512:
6
- metadata.gz: e97e31f134e240f3ac3237b858d01b09a145e7881d89a44fa990787f61d345906189643d68368e5bab7176efdfe18a397a0365c62fbee9201b813045ab8b862e
7
- data.tar.gz: 4edce23e19c9c350d17ea21b07988daa50daf116495fc6e491b2c63b8a775cebc04c3906903aedfc8feb50d6fe890619b0cadb120617306d503864a9ed319f9b
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
- - 'spec/template_spec.rb'
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
@@ -1,3 +1,5 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/Rakefile CHANGED
@@ -1,35 +1,47 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "version"
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.rb'
9
+ require 'yard/rake/yardoc_task'
8
10
  require 'rubocop/rake_task'
9
- require "carioca/rake/manage"
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
- t.files = [ 'lib/**/*.rb', '-', 'doc/**/*','spec/**/*_spec.rb']
23
- t.options += ['-o', "yardoc"]
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
- task :clobber do
30
- rm_r "yardoc" rescue nil
31
- rm_r ".yardoc" rescue nil
32
- rm_r "pkg" rescue nil
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 :clobber => "yardoc:clobber"
47
+ task clobber: 'yardoc:clobber'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
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 = "appifier"
4
+ spec.name = 'appifier'
4
5
  spec.version = `cat VERSION`.chomp
5
- spec.authors = ["Camille Paquet", "Romain GEORGES"]
6
- spec.email = ["gems@ultragreen.net"]
6
+ spec.authors = ['Camille Paquet', 'Romain GEORGES']
7
+ spec.email = ['gems@ultragreen.net']
7
8
 
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")
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["homepage_uri"] = spec.homepage
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 = Dir.chdir(File.expand_path('..', __FILE__)) do
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 = "exe"
24
+ spec.bindir = 'exe'
24
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
- spec.require_paths = ["lib"]
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 "carioca", "~> 2.0"
37
- spec.add_dependency "thor", "~> 1.2"
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 "bundler/setup"
4
- require "appifier"
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 "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/exe/appifier CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'appifier'
4
5
 
@@ -6,4 +7,4 @@ require 'appifier/cli'
6
7
 
7
8
  include Appifier::CLI
8
9
 
9
- Command.start(ARGV)
10
+ Command.start(ARGV)
@@ -1,105 +1,95 @@
1
+ # frozen_string_literal: true
1
2
 
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
-
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
@@ -1 +1,3 @@
1
- Dir[File.dirname(__FILE__) + '/*.rb'].each {|file| require file unless File.basename(file) == 'init.rb'}
1
+ # frozen_string_literal: true
2
+
3
+ Dir["#{File.dirname(__FILE__)}/*.rb"].sort.each { |file| require file unless File.basename(file) == 'init.rb' }
@@ -1,38 +1,32 @@
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
-
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
- 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
-
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
- 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
1
+ # frozen_string_literal: true
9
2
 
10
- # Thor method : Getting the current Appifier version
11
- desc "version", "Display current Appifier version"
12
- def version
13
- end
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
- end
16
- end
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
- module Appifier
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
- end
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
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  require 'appifier'
3
4
  require 'thor'
4
5
 
5
- Dir[File.dirname(__FILE__) + '/cli/*.rb'].each {|file| require file }
6
-
7
-
6
+ Dir["#{File.dirname(__FILE__)}/cli/*.rb"].sort.each { |file| require file }
8
7
 
9
8
  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
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
- 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
-
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
- # Thor method : running of Appifier reteive
52
- desc "retrieve ORIGIN", "Retrieve an application template in user templates bundle"
53
- long_desc <<-LONGDESC
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
- 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
-
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
- 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
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
@@ -1,35 +1,36 @@
1
+ # frozen_string_literal: true
2
+
1
3
  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
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
- return false
25
+ ::Gem.searcher.lib_dirs_for(spec).split('/')
31
26
  end
32
- end
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
@@ -1 +1,3 @@
1
- Dir[File.dirname(__FILE__) + '/*.rb'].each {|file| require file unless File.basename(file) == 'init.rb'}
1
+ # frozen_string_literal: true
2
+
3
+ Dir["#{File.dirname(__FILE__)}/*.rb"].sort.each { |file| require file unless File.basename(file) == 'init.rb' }
@@ -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
- 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
1
+ # frozen_string_literal: true
10
2
 
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
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
- # 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
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
-
@@ -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
- if File::exist? File.expand_path(Appifier::DEFAULT_CONFIG_PATH) and !force
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::mkdir_p File.expand_path(path) unless File::exist? File.expand_path(path)
11
- FileUtils::cp config_file, File.expand_path(Appifier::DEFAULT_PATH)
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'version'
2
4
  module Appifier
3
5
  VERSION = Version.current
data/lib/appifier.rb CHANGED
@@ -1,30 +1,31 @@
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
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 = "~/.appifier"
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
- unless File::exist? File.expand_path(Appifier::DEFAULT_CONFIG_PATH)
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') + '/*.yml']
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.0
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: rake
15
+ name: code_statistics
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '12.0'
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: '12.0'
27
+ version: 0.2.13
28
28
  - !ruby/object:Gem::Dependency
29
- name: rspec
29
+ name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '3.0'
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: '3.0'
41
+ version: '12.0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: rubocop
43
+ name: roodi
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.32'
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: '1.32'
55
+ version: '5.0'
56
56
  - !ruby/object:Gem::Dependency
57
- name: roodi
57
+ name: rspec
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '5.0'
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: '5.0'
69
+ version: '3.0'
70
70
  - !ruby/object:Gem::Dependency
71
- name: code_statistics
71
+ name: rubocop
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: 0.2.13
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: 0.2.13
83
+ version: '1.32'
84
84
  - !ruby/object:Gem::Dependency
85
- name: yard
85
+ name: version
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 0.9.27
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: 0.9.27
97
+ version: '1.1'
98
98
  - !ruby/object:Gem::Dependency
99
- name: yard-rspec
99
+ name: yard
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: '0.1'
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: '0.1'
111
+ version: 0.9.27
112
112
  - !ruby/object:Gem::Dependency
113
- name: version
113
+ name: yard-rspec
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: '1.1'
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: '1.1'
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