Sha256: 7a049adddfb70b17707db4bb4ca086d017e5d3a78c40053a17984912282525fe

Contents?: true

Size: 1.29 KB

Versions: 13

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module Script
  module Layers
    module Infrastructure
      class PushPackageRepository
        include SmartProperties
        property! :ctx, accepts: ShopifyCli::Context

        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 ctx.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)
          ctx.mkdir_p(File.dirname(path))
          ctx.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

13 entries across 13 versions & 1 rubygems

Version Path
shopify-cli-1.5.0 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-1.4.1 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-1.4.0 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-1.3.1 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-1.3.0 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-1.2.0 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-1.1.2 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-1.1.1 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-1.1.0 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-1.0.5 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-1.0.4 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-1.0.3 lib/project_types/script/layers/infrastructure/push_package_repository.rb
shopify-cli-1.0.2 lib/project_types/script/layers/infrastructure/push_package_repository.rb