Module: Strata::CLI::Utils::Archive

Defined in:
lib/strata/cli/utils/archive.rb

Class Method Summary collapse

Class Method Details

.build_archive(files, project_path, inlined_files = {}) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/strata/cli/utils/archive.rb', line 90

def build_archive(files, project_path, inlined_files = {})
  archive_file = archive_path

  File.open(archive_file, "wb") do |file|
    Zlib::GzipWriter.open(file) do |gz|
      Gem::Package::TarWriter.new(gz) do |tar|
        files.each do |file_path|
          add_file_to_tar(tar, file_path, project_path, inlined_files)
        end
      end
    end
  end

  archive_file
end

.create(project_path, files_to_include: nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/strata/cli/utils/archive.rb', line 19

def create(project_path, files_to_include: nil)
  if files_to_include
    # Use provided file list, but ensure they exist and are yml files
    files = files_to_include.select do |file_path|
      File.file?(file_path) && file_path.end_with?(".yml", ".yaml")
    end
    # Ensure required files are included if they exist
    files = ensure_required_files(files, project_path)
  else
    # Collect all yml files if no list provided
    files = collect_yml_files(project_path)
  end
  files = exclude_secrets(files)
  inlined_files = process_imports(files, project_path)
  build_archive(files, project_path, inlined_files)
end