5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 01:26:22 +00:00
panel/app/models/deploy_zip.rb

60 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
2019-09-16 16:15:20 +00:00
require 'zip'
# Genera un ZIP a partir del sitio ya construido
#
# TODO: Firmar con minisign
class DeployZip < Deploy
store :values, accessors: %i[], coder: JSON
# Una vez que el sitio está generado, tomar todos los archivos y
# y generar un zip accesible públicamente.
#
# rubocop:disable Metrics/MethodLength
def deploy(**)
2019-09-24 22:24:45 +00:00
FileUtils.rm_f path
time_start
Dir.chdir(destination) do
Zip::File.open(path, Zip::File::CREATE) do |z|
Dir.glob('./**/**').each do |f|
File.directory?(f) ? z.mkdir(f) : z.add(f, f)
end
end
end
time_stop
build_stats.create action: 'zip',
seconds: time_spent_in_seconds,
bytes: size
File.exist? path
end
# rubocop:enable Metrics/MethodLength
def limit
1
end
def size
File.size path
end
def destination
File.join(Rails.root, '_deploy', site.hostname)
end
def file
"#{site.hostname}.zip"
end
2022-04-06 23:07:14 +00:00
def url
"#{site.url}#{file}"
end
def path
File.join(destination, file)
end
end