appifier 0.1.1 → 0.1.2
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/VERSION +1 -1
- data/appifier.gemspec +2 -1
- data/config/appifier.registry +9 -0
- data/config/settings.yml +59 -0
- data/exe/appifier +1 -1
- data/lib/appifier/actors/collector.rb +67 -0
- data/lib/appifier/actors/generator.rb +19 -17
- data/lib/appifier/actors/retriever.rb +9 -3
- data/lib/appifier/cli/templates.rb +15 -4
- data/lib/appifier/cli.rb +84 -14
- data/lib/appifier/components/Appifile.rb +35 -0
- data/lib/appifier/components/init.rb +3 -0
- data/lib/appifier/components/templates.rb +34 -0
- data/lib/appifier/helpers/datasets.rb +36 -0
- data/lib/appifier/services/finisher.rb +52 -0
- data/lib/appifier/services/init.rb +3 -0
- data/lib/appifier/setup.rb +5 -2
- data/lib/appifier.rb +24 -10
- data/samples/dummy/Appifile +12 -0
- data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/.rspec +0 -0
- data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/Rakefile +0 -0
- data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/config.ru +0 -0
- data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/exe/%%APPNAME.downcase%% +0 -0
- data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/lib/%%APPNAME.downcase%%.rb +0 -0
- data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/spec/%%APPNAME.downcase%%_spec.rb +0 -0
- data/samples/dummy.tgz +0 -0
- metadata +33 -11
- data/lib/appifier/helpers/templates.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aeea227ea8e3eaa87c58fcbd7333297f73b7e2c82f7ba51da9b8bccb4f979f05
|
4
|
+
data.tar.gz: 3121f0753db7fbc4b8d68f2acfaf141cf9ee9785f5abfc5edca2b5a645faa942
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7aceeba188e836380bd52eebdfb87839c6227f79282e2ae90fe12d1486d03c4dbb53147c61abb84d4aab172bca8e10b8d7aa419b214e0f0bb151bbd30e4a17c
|
7
|
+
data.tar.gz: 90fa233237110cfc8c815e6d3002dbc831eaf08b9979d9f0d499f9d08228768c87e519f212fde8241ee9c944f158d90cadbe9924fc4031bd8a8eaa42a6165873
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/appifier.gemspec
CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency 'yard', '~> 0.9.27'
|
35
35
|
spec.add_development_dependency 'yard-rspec', '~> 0.1'
|
36
36
|
spec.metadata['rubygems_mfa_required'] = 'false'
|
37
|
-
spec.add_dependency 'carioca', '~> 2.0'
|
37
|
+
spec.add_dependency 'carioca', '~> 2.0.9'
|
38
38
|
spec.add_dependency 'thor', '~> 1.2'
|
39
|
+
spec.add_dependency 'tty-prompt', '~> 0.23.1'
|
39
40
|
end
|
data/config/settings.yml
CHANGED
@@ -6,3 +6,62 @@
|
|
6
6
|
:test: {}
|
7
7
|
:default:
|
8
8
|
:test: 'Romain'
|
9
|
+
:exit_cases:
|
10
|
+
:not_root:
|
11
|
+
:message: This operation need to be run as root (use sudo or rvmsudo)
|
12
|
+
:code: 10
|
13
|
+
:options_incompatibility:
|
14
|
+
:message: Options incompatibility
|
15
|
+
:code: 40
|
16
|
+
:service_dependence_missing:
|
17
|
+
:message: Appifier Service dependence missing
|
18
|
+
:code: 60
|
19
|
+
:config_required:
|
20
|
+
:message: Specific configuration required
|
21
|
+
:code: 30
|
22
|
+
:setup_error:
|
23
|
+
:message: Setup terminated unsuccessfully
|
24
|
+
:code: 25
|
25
|
+
:setup_success:
|
26
|
+
:message: Setup terminated successfully
|
27
|
+
:code: 0
|
28
|
+
:sanitycheck_error:
|
29
|
+
:messagee: Sanitycheck terminated unsuccessfully
|
30
|
+
:code: 20
|
31
|
+
:sanitycheck_success:
|
32
|
+
:message: Sanitycheck terminated successfully
|
33
|
+
:code: 0
|
34
|
+
:configuration_error:
|
35
|
+
:message: Configuration Error
|
36
|
+
:code: 50
|
37
|
+
|
38
|
+
|
39
|
+
# global
|
40
|
+
:quiet_exit:
|
41
|
+
:code: 0
|
42
|
+
:error_exit:
|
43
|
+
:code: 99
|
44
|
+
:message: Operation failure
|
45
|
+
|
46
|
+
# events
|
47
|
+
:interrupt:
|
48
|
+
:message: User operation interrupted
|
49
|
+
:code: 33
|
50
|
+
|
51
|
+
# request
|
52
|
+
:not_found:
|
53
|
+
:message: Object not found
|
54
|
+
:code: 44
|
55
|
+
:already_exist:
|
56
|
+
:message: Object already exist
|
57
|
+
:code: 48
|
58
|
+
|
59
|
+
# daemon
|
60
|
+
:status_ok:
|
61
|
+
:message: Status OK
|
62
|
+
:code: 0
|
63
|
+
:status_ko:
|
64
|
+
:message: Status KO
|
65
|
+
:code: 31
|
66
|
+
|
67
|
+
|
data/exe/appifier
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "tty-prompt"
|
3
|
+
|
4
|
+
module Appifier
|
5
|
+
module Actors
|
6
|
+
class Collector
|
7
|
+
|
8
|
+
extend Carioca::Injector
|
9
|
+
inject service: :output
|
10
|
+
|
11
|
+
attr_accessor :dataset
|
12
|
+
attr_reader :template
|
13
|
+
|
14
|
+
def initialize(template: ,dataset: nil,force: false )
|
15
|
+
@force = force
|
16
|
+
@template = template
|
17
|
+
get_defined_dataset(dataset)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def collect
|
22
|
+
|
23
|
+
appifilename = "#{File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)}/#{template}/Appifile"
|
24
|
+
appifile = Appifier::Components::Appifile::new path: appifilename
|
25
|
+
prompt = TTY::Prompt.new
|
26
|
+
@dataset = {}
|
27
|
+
appifile.dataset_rules.each do |name, rule|
|
28
|
+
default = (rule[:default])? rule[:default] : ""
|
29
|
+
@dataset[name] = prompt.ask("Give #{rule[:description]} : ", default: default) do |q|
|
30
|
+
q.required true
|
31
|
+
q.validate Regexp.new(rule[:format]) if rule[:format]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
write_dataset template: @template, data: @dataset
|
35
|
+
@collected = true
|
36
|
+
output.info "Dataset recorded for #{@template}"
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def collected?
|
41
|
+
return @collected
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def get_defined_dataset(newdataset=nil)
|
46
|
+
if check_dataset_defined? template: @template then
|
47
|
+
@dataset = open_dataset template: @template
|
48
|
+
if @force
|
49
|
+
@dataset = newdataset
|
50
|
+
write_dataset template: @template, data: @dataset
|
51
|
+
else
|
52
|
+
raise "Dataset already collect for template : #{@template}"
|
53
|
+
end
|
54
|
+
@collected = true
|
55
|
+
elsif newdataset
|
56
|
+
@dataset = newdataset
|
57
|
+
write_dataset template: @template, data: @dataset
|
58
|
+
@collected = true
|
59
|
+
else
|
60
|
+
@dataset = nil
|
61
|
+
@collected = false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -5,29 +5,31 @@ module Appifier
|
|
5
5
|
class Generator
|
6
6
|
attr_reader :src_paths, :src_files, :src_folders, :target_folders, :target_files
|
7
7
|
|
8
|
-
|
8
|
+
extend Carioca::Injector
|
9
|
+
inject service: :output
|
10
|
+
|
11
|
+
|
12
|
+
def initialize(src_root:, target_root:, dataset: )
|
9
13
|
@src_root = src_root
|
10
14
|
@target_root = target_root
|
11
15
|
@target_folders = []
|
12
16
|
@target_files = []
|
13
|
-
@data =
|
17
|
+
@data = dataset
|
14
18
|
@src_paths = Dir.glob("#{@src_root}/**/*", File::FNM_DOTMATCH)
|
15
19
|
@src_paths.delete_if { |file| file =~ %r{/\.$} }
|
16
20
|
@src_folders = @src_paths.select { |item| File.directory? item }
|
17
21
|
@src_files = @src_paths.select { |item| File.file? item }
|
22
|
+
raise 'Application template not found' unless File.exist?(src_root)
|
18
23
|
end
|
19
24
|
|
20
25
|
def generate(dry_run: false, force: false)
|
21
|
-
|
26
|
+
output.info 'Running in dry_run (operation will be SKIPPED)' if dry_run
|
22
27
|
calculate
|
23
|
-
|
24
|
-
puts 'Folders and files already exist'
|
25
|
-
return false
|
26
|
-
end
|
28
|
+
raise 'Folders and files already exist' if check_folder_already_exist && !force
|
27
29
|
FileUtils.rm_rf("#{@target_root}/#{@target_folders.first}") if force
|
28
|
-
|
30
|
+
output.info 'Generate folders'
|
29
31
|
generate_folders dry_run: dry_run
|
30
|
-
|
32
|
+
output.info 'Generate files'
|
31
33
|
generate_files dry_run: dry_run
|
32
34
|
end
|
33
35
|
|
@@ -43,19 +45,19 @@ module Appifier
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def generate_folders(dry_run:)
|
46
|
-
|
48
|
+
output.info "Target path to create in #{@target_root} :"
|
47
49
|
@target_folders.each do |path|
|
48
|
-
action = dry_run ?
|
50
|
+
action = dry_run ? :skipped : :ok
|
49
51
|
FileUtils.mkdir_p "#{@target_root}/#{path}", noop: dry_run
|
50
|
-
|
52
|
+
output.send action, "#{path}"
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
56
|
def generate_files(dry_run:)
|
55
|
-
|
57
|
+
output.info "Target files to create in #{@target_root} :"
|
56
58
|
@src_files.each_with_index do |path, index|
|
57
59
|
if dry_run
|
58
|
-
result =
|
60
|
+
result = :skipped
|
59
61
|
else
|
60
62
|
begin
|
61
63
|
template = Template.new strict: false,
|
@@ -64,12 +66,12 @@ module Appifier
|
|
64
66
|
template.map(@data)
|
65
67
|
content = template.output
|
66
68
|
File.write("#{@target_root}/#{@target_files[index]}", content)
|
67
|
-
result =
|
69
|
+
result = :ok
|
68
70
|
rescue InvalidTokenList, NotAToken, NoTemplateFile
|
69
|
-
result =
|
71
|
+
result = :ko
|
70
72
|
end
|
71
73
|
end
|
72
|
-
|
74
|
+
output.send result,"#{@target_files[index]}"
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
@@ -1,27 +1,33 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: false
|
2
2
|
|
3
3
|
module Appifier
|
4
4
|
module Actors
|
5
5
|
module Retrivers
|
6
6
|
class Git
|
7
|
-
def self.get(origin:, destination:);
|
7
|
+
def self.get(origin:, destination:);
|
8
|
+
raise 'not yest implemented'
|
9
|
+
end
|
8
10
|
end
|
9
11
|
|
10
12
|
class Archive
|
11
13
|
def self.get(origin:, destination:)
|
14
|
+
raise "Archive : #{origin} not found" unless File::exist? origin
|
12
15
|
untar_gz archive: origin, destination: destination
|
13
16
|
end
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
20
|
class Retriever
|
21
|
+
extend Carioca::Injector
|
22
|
+
inject service: :output
|
23
|
+
|
18
24
|
TYPE = { archive: Appifier::Actors::Retrivers::Archive, git: Appifier::Actors::Retrivers::Git }
|
19
25
|
|
20
26
|
def initialize(origin:, type: :archive, destination: File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH))
|
21
27
|
@origin = origin
|
22
28
|
@type = type
|
23
29
|
@destination = destination
|
24
|
-
|
30
|
+
output.info "retrieving template from #{origin}"
|
25
31
|
end
|
26
32
|
|
27
33
|
def get
|
@@ -4,18 +4,29 @@ module Appifier
|
|
4
4
|
module CLI
|
5
5
|
module Subcommands
|
6
6
|
class Templates < ::Thor
|
7
|
+
|
8
|
+
def initialize(*args)
|
9
|
+
super
|
10
|
+
@output = Carioca::Registry.get.get_service name: :output
|
11
|
+
@finisher = Carioca::Registry.get.get_service name: :finisher
|
12
|
+
end
|
13
|
+
|
7
14
|
# Thor method : list availables templates in user bundle
|
8
15
|
desc 'ls', 'list templates availables in user bundle'
|
9
16
|
def ls
|
10
|
-
|
11
|
-
|
17
|
+
Appifier::Components::Templates::list
|
18
|
+
@finisher.terminate exit_case: :error_exit
|
12
19
|
end
|
13
20
|
|
14
21
|
# Thor method : remove a template from user bundle
|
15
22
|
desc 'rm', 'rm templates from user bundle'
|
16
23
|
def rm(template)
|
17
|
-
|
18
|
-
|
24
|
+
begin
|
25
|
+
Appifier::Components::Templates::rm(template)
|
26
|
+
rescue RuntimeError => e
|
27
|
+
@output.error e.message
|
28
|
+
@finisher.terminate exit_case: :error_exit
|
29
|
+
end
|
19
30
|
end
|
20
31
|
end
|
21
32
|
end
|
data/lib/appifier/cli.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: false
|
2
2
|
|
3
3
|
require 'appifier'
|
4
4
|
require 'thor'
|
@@ -8,7 +8,15 @@ Dir["#{File.dirname(__FILE__)}/cli/*.rb"].sort.each { |file| require file }
|
|
8
8
|
module Appifier
|
9
9
|
module CLI
|
10
10
|
# The CLI Command structure for Thor
|
11
|
-
class
|
11
|
+
class MainCommand < Thor
|
12
|
+
|
13
|
+
|
14
|
+
def initialize(*args)
|
15
|
+
super
|
16
|
+
@output = Carioca::Registry.get.get_service name: :output
|
17
|
+
@finisher = Carioca::Registry.get.get_service name: :finisher
|
18
|
+
end
|
19
|
+
|
12
20
|
# callback for managing ARGV errors
|
13
21
|
def self.exit_on_failure?
|
14
22
|
true
|
@@ -24,33 +32,95 @@ module Appifier
|
|
24
32
|
desc 'generate TEMPLATE [TARGET]', 'Generate application from bundled template'
|
25
33
|
long_desc <<-LONGDESC
|
26
34
|
Generate application from bundled template\n
|
27
|
-
with --simulate, only simulate folders and files installed
|
28
|
-
with --force, force regeneration of application, remove old files [DANGER]
|
35
|
+
with --simulate, only simulate folders and files installed
|
36
|
+
with --force, force regeneration of application, remove old files [DANGER]
|
29
37
|
LONGDESC
|
30
38
|
option :simulate, type: :boolean, aliases: '-s'
|
31
39
|
option :force, type: :boolean, aliases: '-F'
|
32
40
|
def generate(template, target = '.')
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
41
|
+
root = "#{File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)}/#{template}"
|
42
|
+
source = "#{root}/skeleton"
|
43
|
+
|
44
|
+
if File::exist? File::expand_path("#{DEFAULT_DATASETS_PATH}/#{template}.yml") then
|
45
|
+
dataset = open_dataset(template: template)
|
46
|
+
@output.info "Dataset file found for #{template}"
|
37
47
|
else
|
38
|
-
|
48
|
+
@output.ko "Dataset file not found for #{template}"
|
49
|
+
@finisher.terminate exit_case: :error_exit
|
50
|
+
end
|
51
|
+
|
52
|
+
begin
|
53
|
+
generator = Appifier::Actors::Generator.new src_root: source, target_root: File.expand_path(target), dataset: dataset
|
54
|
+
generator.generate dry_run: options[:simulate], force: options[:force]
|
55
|
+
@finisher.terminate exit_case: :quiet_exit
|
56
|
+
rescue RuntimeError => e
|
57
|
+
@output.error e.message
|
58
|
+
@finisher.terminate exit_case: :error_exit
|
39
59
|
end
|
40
60
|
end
|
41
61
|
|
42
|
-
# Thor method : running of Appifier
|
62
|
+
# Thor method : running of Appifier retreive
|
43
63
|
desc 'retrieve ORIGIN', 'Retrieve an application template in user templates bundle'
|
44
64
|
long_desc <<-LONGDESC
|
45
65
|
Retrieve an application template in user templates bundle\n
|
46
|
-
with --type [RETRIEVER], precise retrieving type ex,builtin [:git,:archive]
|
66
|
+
with --type [RETRIEVER], precise retrieving type ex,builtin [:git,:archive] DEFAULT : :git
|
47
67
|
LONGDESC
|
48
68
|
option :type, type: :string, aliases: '-t', default: 'git'
|
49
69
|
def retrieve(origin)
|
50
|
-
|
51
|
-
|
52
|
-
|
70
|
+
begin
|
71
|
+
type = options[:type].to_sym
|
72
|
+
retriever = Appifier::Actors::Retriever.new type: type, origin: origin
|
73
|
+
retriever.get
|
74
|
+
@finisher.terminate exit_case: :quiet_exit
|
75
|
+
rescue RuntimeError => e
|
76
|
+
@output.error e.message
|
77
|
+
@finisher.terminate exit_case: :error_exit
|
78
|
+
end
|
53
79
|
end
|
80
|
+
|
81
|
+
# Thor method : running of Appifier Dataset Collector
|
82
|
+
desc 'collect TEMPLATE', 'Collect dataset for an application template in user templates bundle'
|
83
|
+
long_desc <<-LONGDESC
|
84
|
+
Collect dataset for an application template in user templates bundle\n
|
85
|
+
with --force => force collect, and destroy previous Dataset [DANGER]
|
86
|
+
with --file FILENAME get data from à YAML File
|
87
|
+
with --stdin get data from STDIN
|
88
|
+
|
89
|
+
LONGDESC
|
90
|
+
option :force, type: :boolean, aliases: '-F'
|
91
|
+
option :stdin, type: :boolean, aliases: '-S'
|
92
|
+
option :file, type: :string, aliases: '-f'
|
93
|
+
def collect(template)
|
94
|
+
data = nil
|
95
|
+
begin
|
96
|
+
raise "Options incompatibles --file and --stdin" if options[:stdin] and options[:file]
|
97
|
+
@output.info "Force mode, rewrite dataset if exist" if options[:force]
|
98
|
+
if options[:file]
|
99
|
+
Appifier::Actors::Collector.new template: template, dataset: open_yaml(filename: options[:file]), force: options[:force]
|
100
|
+
@output.info "Getting Dataset from file : #{options[:file]} for #{template}"
|
101
|
+
elsif options[:stdin]
|
102
|
+
@output.info "Getting Dataset from STDIN for #{template}"
|
103
|
+
begin
|
104
|
+
data = STDIN.readlines.join
|
105
|
+
rescue Interrupt
|
106
|
+
@output.error "Dataset input from STDIN cancelled"
|
107
|
+
@finisher.terminate exit_case: :interrupt
|
108
|
+
end
|
109
|
+
Appifier::Actors::Collector.new template: template, dataset: YAML::load(data), force: options[:force]
|
110
|
+
else
|
111
|
+
@output.info "Beginning interactive Dataset input for #{template}"
|
112
|
+
collector = Appifier::Actors::Collector.new template: template, force: options[:force]
|
113
|
+
collector.collect
|
114
|
+
end
|
115
|
+
@finisher.terminate exit_case: :quiet_exit
|
116
|
+
rescue RuntimeError => e
|
117
|
+
@output.error e.message
|
118
|
+
@finisher.terminate exit_case: :error_exit
|
119
|
+
rescue
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
54
124
|
end
|
55
125
|
end
|
56
126
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Appifier
|
2
|
+
module Components
|
3
|
+
class Appifile
|
4
|
+
|
5
|
+
attr_reader :content
|
6
|
+
|
7
|
+
def initialize(path:)
|
8
|
+
@path = path
|
9
|
+
@content = {}
|
10
|
+
openfile
|
11
|
+
end
|
12
|
+
|
13
|
+
def dataset_rules
|
14
|
+
@content[:template][:dataset]
|
15
|
+
end
|
16
|
+
|
17
|
+
def actions
|
18
|
+
@content[:actions]
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def openfile
|
23
|
+
raise 'Appifile not foud' unless File::exist? @path
|
24
|
+
begin
|
25
|
+
@content = YAML.load_file(@path)
|
26
|
+
rescue StandardError => e
|
27
|
+
raise e.message
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appifier
|
4
|
+
module Components
|
5
|
+
class Templates
|
6
|
+
|
7
|
+
extend Carioca::Injector
|
8
|
+
inject service: :output
|
9
|
+
|
10
|
+
def self.list
|
11
|
+
output.info "List of avaible templates for user : #{current_user} :"
|
12
|
+
template_path = File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)
|
13
|
+
Dir.glob("#{template_path}/*").map { |item| item.delete_prefix("#{template_path}/") }.each do |template|
|
14
|
+
output.item "#{template}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.rm(template)
|
19
|
+
output.info "Removing template #{template} for user : #{current_user} :"
|
20
|
+
template_path = File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)
|
21
|
+
begin
|
22
|
+
if File::exist? "#{template_path}/#{template}"
|
23
|
+
FileUtils.rm_rf "#{template_path}/#{template}"
|
24
|
+
output.ok "Template #{template} deleted of bundle for user #{current_user}"
|
25
|
+
else
|
26
|
+
raise "Template #{template} not found in bundle for user #{current_user}"
|
27
|
+
end
|
28
|
+
rescue Errno::ENOENT
|
29
|
+
raise "Template #{template} not found in bundle for user #{current_user}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appifier
|
4
|
+
module Helpers
|
5
|
+
module Datasets
|
6
|
+
def open_dataset(template:)
|
7
|
+
path = File::expand_path("#{DEFAULT_DATASETS_PATH}/#{template}.yml")
|
8
|
+
raise 'Dataset not found' unless File::exist? path
|
9
|
+
begin
|
10
|
+
return YAML.load_file(path)
|
11
|
+
rescue StandardError => e
|
12
|
+
raise e.message
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def check_dataset_defined?(template:)
|
17
|
+
return File::exist? File::expand_path("#{DEFAULT_DATASETS_PATH}/#{template}.yml")
|
18
|
+
end
|
19
|
+
|
20
|
+
def write_dataset(template:, data:)
|
21
|
+
path = File::expand_path("#{DEFAULT_DATASETS_PATH}/#{template}.yml")
|
22
|
+
File.open(path, 'w') { |file| file.write(data.to_yaml) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def open_yaml(filename:)
|
26
|
+
raise 'File not found' unless File::exist? filename
|
27
|
+
begin
|
28
|
+
return YAML.load_file(filename)
|
29
|
+
rescue StandardError => e
|
30
|
+
raise e.message
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# base Splash namespace
|
4
|
+
module Appifier
|
5
|
+
|
6
|
+
module Services
|
7
|
+
# Exiter namespace
|
8
|
+
class Finisher
|
9
|
+
|
10
|
+
extend Carioca::Injector
|
11
|
+
inject service: :configuration
|
12
|
+
inject service: :logger
|
13
|
+
|
14
|
+
EXIT_MAP= configuration.settings.exit_cases
|
15
|
+
|
16
|
+
|
17
|
+
def self.terminate(return_case: nil, exit_case: nil, more: nil )
|
18
|
+
raise "Case must a return or an exit" if return_case and exit_case
|
19
|
+
do_exit( exit_case: exit_case, more: more) if exit_case
|
20
|
+
do_return(return_case: return_case, more: more) if return_case
|
21
|
+
end
|
22
|
+
|
23
|
+
# exiter wrapper
|
24
|
+
# @param [Hash] options
|
25
|
+
# @option options [Symbol] :case an exit case
|
26
|
+
# @option options [String] :more a complementary string to display
|
27
|
+
def self.do_exit(exit_case: :quiet_exit, more: nil )
|
28
|
+
|
29
|
+
mess = ""
|
30
|
+
mess = EXIT_MAP[exit_case][:message] if EXIT_MAP[exit_case].include? :message
|
31
|
+
mess << " : " unless mess.empty? or not more
|
32
|
+
mess << "#{more}" if more
|
33
|
+
if EXIT_MAP[exit_case][:code] == 0 then
|
34
|
+
logger.success mess unless mess.empty?
|
35
|
+
exit 0
|
36
|
+
else
|
37
|
+
logger.fatal mess unless mess.empty?
|
38
|
+
exit EXIT_MAP[exit_case][:code]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.do_return(return_case: :status_ok, more: nil )
|
43
|
+
|
44
|
+
data = EXIT_MAP[return_case].clone
|
45
|
+
data[:status] = (data[:code]>0)? :failure : :success
|
46
|
+
data[:more] = more if more
|
47
|
+
return data
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/appifier/setup.rb
CHANGED
@@ -8,8 +8,11 @@ module Appifier
|
|
8
8
|
else
|
9
9
|
config_file = search_file_in_gem('appifier', 'config/settings.yml')
|
10
10
|
path = File.expand_path(Appifier::DEFAULT_TEMPLATES_PATH)
|
11
|
-
|
12
|
-
|
11
|
+
[Appifier::DEFAULT_TEMPLATES_PATH, Appifier::DEFAULT_LOGS_PATH, Appifier::DEFAULT_CONFIG_PATH, Appifier::DEFAULT_DATASETS_PATH].each do |path|
|
12
|
+
FileUtils.mkdir_p File.expand_path(path)
|
13
|
+
end
|
14
|
+
File.open(File.expand_path("#{Appifier::DEFAULT_LOGS_PATH}/#{Appifier::DEFAULT_LOG_FILENAME}"), 'w') { |file| file.write("# Appifier : beginning of log file") }
|
15
|
+
FileUtils.cp config_file, File.expand_path(Appifier::DEFAULT_CONFIG_PATH)
|
13
16
|
puts '[OK] Building config folder and initialize settings'
|
14
17
|
end
|
15
18
|
end
|
data/lib/appifier.rb
CHANGED
@@ -6,19 +6,27 @@ require 'fileutils'
|
|
6
6
|
require 'etc'
|
7
7
|
|
8
8
|
include Thot
|
9
|
+
|
10
|
+
|
11
|
+
require 'appifier/version'
|
12
|
+
require 'appifier/helpers/init'
|
13
|
+
|
9
14
|
module Appifier
|
10
15
|
DEFAULT_PATH = '~/.appifier'
|
11
16
|
DEFAULT_TEMPLATES_PATH = "#{DEFAULT_PATH}/templates"
|
12
|
-
DEFAULT_CONFIG_PATH = "#{DEFAULT_PATH}/
|
17
|
+
DEFAULT_CONFIG_PATH = "#{DEFAULT_PATH}/config/"
|
18
|
+
DEFAULT_LOGS_PATH = "#{DEFAULT_PATH}/logs"
|
19
|
+
DEFAULT_DATASETS_PATH = "#{DEFAULT_PATH}/datasets"
|
20
|
+
DEFAULT_LOG_FILENAME = "appifier.log"
|
21
|
+
DEFAULT_SETTINGS_FILENAME = "settings.yml"
|
22
|
+
DEFAULT_REGISTRY = "config/appifier.registry"
|
13
23
|
end
|
14
24
|
|
15
|
-
require 'appifier/version'
|
16
|
-
require 'appifier/helpers/init'
|
17
|
-
|
18
25
|
Appifier::Helpers.constants.select { |c| Appifier::Helpers.const_get(c).is_a? Module }
|
19
26
|
.map { |item| item = "Appifier::Helpers::#{item}" }
|
20
27
|
.each { |mod| include Object.const_get(mod) }
|
21
28
|
|
29
|
+
|
22
30
|
require 'appifier/setup'
|
23
31
|
require 'appifier/actors/init'
|
24
32
|
|
@@ -28,20 +36,26 @@ unless File.exist? File.expand_path(Appifier::DEFAULT_CONFIG_PATH)
|
|
28
36
|
end
|
29
37
|
|
30
38
|
Carioca::Registry.configure do |spec|
|
31
|
-
spec.
|
39
|
+
spec.filename = "#{search_file_in_gem('appifier', Appifier::DEFAULT_REGISTRY )}"
|
40
|
+
spec.init_from_file = true
|
32
41
|
spec.debug = true if ENV['DEBUG']
|
33
|
-
spec.log_file =
|
34
|
-
spec.config_file =
|
42
|
+
spec.log_file = File.expand_path("#{Appifier::DEFAULT_LOGS_PATH}/#{Appifier::DEFAULT_LOG_FILENAME}")
|
43
|
+
spec.config_file = File.expand_path("#{Appifier::DEFAULT_CONFIG_PATH}/#{Appifier::DEFAULT_SETTINGS_FILENAME}")
|
35
44
|
spec.config_root = :appifier
|
36
45
|
spec.environment = :production
|
37
|
-
spec.
|
38
|
-
spec.
|
46
|
+
spec.output_mode = :dual
|
47
|
+
spec.output_emoji = true
|
48
|
+
spec.output_colors = true
|
39
49
|
end
|
40
50
|
|
51
|
+
require_relative 'appifier/services/init'
|
52
|
+
|
41
53
|
module Appifier
|
42
54
|
class Application < Carioca::Container
|
43
55
|
inject service: :configuration
|
44
56
|
inject service: :i18n
|
45
|
-
|
57
|
+
inject service: :terminator
|
46
58
|
end
|
47
59
|
end
|
60
|
+
|
61
|
+
require_relative 'appifier/components/init'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/samples/{skeleton → dummy/skeleton}/%%APPNAME.downcase%%/spec/%%APPNAME.downcase%%_spec.rb
RENAMED
File without changes
|
data/samples/dummy.tgz
CHANGED
Binary file
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camille Paquet
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-10-
|
12
|
+
date: 2022-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: code_statistics
|
@@ -129,14 +129,14 @@ dependencies:
|
|
129
129
|
requirements:
|
130
130
|
- - "~>"
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
132
|
+
version: 2.0.9
|
133
133
|
type: :runtime
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
139
|
+
version: 2.0.9
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: thor
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +151,20 @@ dependencies:
|
|
151
151
|
- - "~>"
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '1.2'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: tty-prompt
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 0.23.1
|
161
|
+
type: :runtime
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 0.23.1
|
154
168
|
description: 'Appifier : Applications templating and management tools '
|
155
169
|
email:
|
156
170
|
- gems@ultragreen.net
|
@@ -169,29 +183,37 @@ files:
|
|
169
183
|
- appifier.gemspec
|
170
184
|
- bin/console
|
171
185
|
- bin/setup
|
186
|
+
- config/appifier.registry
|
172
187
|
- config/settings.yml
|
173
188
|
- exe/appifier
|
174
189
|
- lib/appifier.rb
|
190
|
+
- lib/appifier/actors/collector.rb
|
175
191
|
- lib/appifier/actors/generator.rb
|
176
192
|
- lib/appifier/actors/init.rb
|
177
193
|
- lib/appifier/actors/retriever.rb
|
178
194
|
- lib/appifier/cli.rb
|
179
195
|
- lib/appifier/cli/configuration.rb
|
180
196
|
- lib/appifier/cli/templates.rb
|
197
|
+
- lib/appifier/components/Appifile.rb
|
198
|
+
- lib/appifier/components/init.rb
|
199
|
+
- lib/appifier/components/templates.rb
|
181
200
|
- lib/appifier/helpers/archives.rb
|
201
|
+
- lib/appifier/helpers/datasets.rb
|
182
202
|
- lib/appifier/helpers/gem.rb
|
183
203
|
- lib/appifier/helpers/init.rb
|
184
|
-
- lib/appifier/helpers/templates.rb
|
185
204
|
- lib/appifier/helpers/user.rb
|
205
|
+
- lib/appifier/services/finisher.rb
|
206
|
+
- lib/appifier/services/init.rb
|
186
207
|
- lib/appifier/setup.rb
|
187
208
|
- lib/appifier/version.rb
|
188
209
|
- samples/dummy.tgz
|
189
|
-
- samples/
|
190
|
-
- samples/skeleton/%%APPNAME.downcase
|
191
|
-
- samples/skeleton/%%APPNAME.downcase%%/
|
192
|
-
- samples/skeleton/%%APPNAME.downcase%%/
|
193
|
-
- samples/skeleton/%%APPNAME.downcase%%/
|
194
|
-
- samples/skeleton/%%APPNAME.downcase%%/
|
210
|
+
- samples/dummy/Appifile
|
211
|
+
- samples/dummy/skeleton/%%APPNAME.downcase%%/.rspec
|
212
|
+
- samples/dummy/skeleton/%%APPNAME.downcase%%/Rakefile
|
213
|
+
- samples/dummy/skeleton/%%APPNAME.downcase%%/config.ru
|
214
|
+
- samples/dummy/skeleton/%%APPNAME.downcase%%/exe/%%APPNAME.downcase%%
|
215
|
+
- samples/dummy/skeleton/%%APPNAME.downcase%%/lib/%%APPNAME.downcase%%.rb
|
216
|
+
- samples/dummy/skeleton/%%APPNAME.downcase%%/spec/%%APPNAME.downcase%%_spec.rb
|
195
217
|
homepage: https://github.com/Ultragreen/appifier
|
196
218
|
licenses:
|
197
219
|
- MIT
|
@@ -1,27 +0,0 @@
|
|
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
|