Sha256: 2e079b2e6f41a46ac3a8821472dd19bc5bf0c853b7745f0f467ae84f475d4bc0

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Script
  module Layers
    module Infrastructure
      class PushPackageRepository
        def create_push_package(script, script_content, compiled_type)
          build_file_path = file_path(script.name, compiled_type)
          write_to_path(build_file_path, script_content)

          Domain::PushPackage.new(
            build_file_path,
            script,
            script_content,
            compiled_type,
          )
        end

        def get_push_package(script, compiled_type)
          build_file_path = file_path(script.name, compiled_type)

          raise Domain::PushPackageNotFoundError unless File.exist?(build_file_path)

          script_content = File.read(build_file_path)

          Domain::PushPackage.new(
            build_file_path,
            script,
            script_content,
            compiled_type,
          )
        end

        private

        def write_to_path(path, content)
          FileUtils.mkdir_p(File.dirname(path))
          File.write(path, content)
        end

        def file_path(script_name, compiled_type)
          "#{ScriptProject.current.directory}/build/#{script_name}.#{compiled_type}"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shopify-cli-0.9.1 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-0.9.0 lib/project_types/script/layers/infrastructure/push_package_repository.rb