Sha256: a9b6bad1902dc92f6bd0bbfe6e2d1aaec9fc03e115bfe5871b405264b58af6eb

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Script
  module Layers
    module Domain
      class ScriptProject
        include SmartProperties

        UUID_ENV_KEY = "UUID"

        property! :id, accepts: String
        property :env, accepts: ShopifyCLI::Resources::EnvFile

        property! :extension_point_type, accepts: String
        property! :script_name, accepts: String
        property! :language, accepts: String

        property :script_config, accepts: ScriptConfig

        def initialize(*)
          super

          ShopifyCLI::Core::Monorail.metadata = {
            "script_name" => script_name,
            "extension_point_type" => extension_point_type,
            "language" => language,
          }
        end

        def api_key
          env&.api_key
        end

        def api_secret
          env&.secret
        end

        def uuid
          uuid_defined? && !raw_uuid.empty? ? raw_uuid : nil
        end

        def uuid_defined?
          !raw_uuid.nil?
        end

        def env_valid?
          api_key && api_secret && uuid_defined?
        end

        private

        def raw_uuid
          env&.extra&.[](UUID_ENV_KEY)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shopify-cli-2.10.0 lib/project_types/script/layers/domain/script_project.rb
shopify-cli-2.9.0 lib/project_types/script/layers/domain/script_project.rb
shopify-cli-2.8.0 lib/project_types/script/layers/domain/script_project.rb
shopify-cli-2.7.4 lib/project_types/script/layers/domain/script_project.rb
shopify-cli-2.7.3 lib/project_types/script/layers/domain/script_project.rb