Class: Lono::AppFile::Build
Defined Under Namespace
Classes: LambdaLayer
Instance Method Summary
collapse
#execute_zip, #zip, #zip_directory, #zip_file
Methods inherited from Base
#initialize
#initialize, #reinitialize, #template_path
#find_blueprint_root, #set_blueprint_root
Instance Method Details
#build_all ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/lono/app_file/build.rb', line 17
def build_all
clean_output
validate_files!
copy_to_output
build_layers
compress_output
end
|
#build_layers ⇒ Object
41
42
43
44
45
46
|
# File 'lib/lono/app_file/build.rb', line 41
def build_layers
layer_items = Registry.layers
layer_items.each do |item|
LambdaLayer.new(@blueprint, item).build
end
end
|
#clean_output ⇒ Object
70
71
72
|
# File 'lib/lono/app_file/build.rb', line 70
def clean_output
FileUtils.rm_rf(@output_files_path)
end
|
#compress_output ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/lono/app_file/build.rb', line 48
def compress_output
Registry.items.each do |item|
if item.type == "lambda_layer" || item.exist?
zip(item)
else
puts "WARN: #{item.src_path} does not exist. Double check that the path is correct in the s3_key call.".color(:yellow)
end
end
end
|
#context ⇒ Object
65
66
67
|
# File 'lib/lono/app_file/build.rb', line 65
def context
Lono::Template::Context.new(@options)
end
|
#copy_to_output ⇒ Object
59
60
61
62
63
|
# File 'lib/lono/app_file/build.rb', line 59
def copy_to_output
override_source_paths("#{Lono.blueprint_root}/app/files")
self.destination_root = @output_files_path
directory(".", verbose: false, context: context.get_binding)
end
|
#detect_files? ⇒ Boolean
74
75
76
77
78
79
80
81
82
|
# File 'lib/lono/app_file/build.rb', line 74
def detect_files?
app_files = Dir["#{Lono.blueprint_root}/app/files/*"]
if app_files.empty?
false
else
puts "Detected app/files for blueprint #{@blueprint}"
true
end
end
|
#initialize_variables ⇒ Object
7
8
9
|
# File 'lib/lono/app_file/build.rb', line 7
def initialize_variables
@output_files_path = "#{Lono.config.output_path}/#{@blueprint}/files"
end
|
#run ⇒ Object
11
12
13
14
15
|
# File 'lib/lono/app_file/build.rb', line 11
def run
return unless detect_files?
puts "Building app/files for blueprint #{@blueprint}"
build_all
end
|
#validate_files! ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/lono/app_file/build.rb', line 25
def validate_files!
items = Registry.items + Registry.layers
missing = items.select do |item|
!File.exist?(item.src_path)
end
missing_paths = missing.map { |item| item.src_path }.uniq
unless missing_paths.empty?
puts "ERROR: These app/files are missing were used by the s3_key method but are missing".color(:red)
missing_paths.each do |path|
puts " #{path}"
end
puts "Please double check that they exist."
exit 1
end
end
|