Sha256: 4584c57c133324b36fcdf01a99f474928804fe6091ac8d476dd8884a1c534064

Contents?: true

Size: 1.46 KB

Versions: 24

Compression:

Stored size: 1.46 KB

Contents

require "securerandom"

module Extension
  module Models
    module ServerConfig
      class Extension < Base
        include SmartProperties

        property! :uuid, accepts: String
        property! :type, accepts: String
        property! :user, accepts: ServerConfig::User
        property! :development, accepts: ServerConfig::Development
        property  :capabilities, accepts: ServerConfig::Capabilities
        property  :extension_points, accepts: Array
        property  :title, accepts: String
        property  :description, accepts: String
        property  :version, accepts: String
        property  :metafields, accepts: Array

        def self.build(uuid: "", template:, type:, root_dir:, **args)
          renderer = ServerConfig::DevelopmentRenderer.find(type)
          entry = ServerConfig::DevelopmentEntries.find(template)
          new(
            uuid: uuid.empty? ? generate_dev_uuid : uuid,
            type: type.downcase,
            user: ServerConfig::User.new,
            development: ServerConfig::Development.new(
              root_dir: root_dir,
              template: template,
              renderer: renderer,
              entries: entry
            ),
            capabilities: ServerConfig::Capabilities.new(
              network_access: false
            ),
            metafields: args.delete(:metafields)
          )
        end

        def self.generate_dev_uuid
          "dev-#{SecureRandom.uuid}"
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.35.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.34.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.33.1 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.33.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.32.1 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.32.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.31.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.30.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.29.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.28.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.27.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.26.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.25.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.24.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.23.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.22.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.21.0 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.20.1 lib/project_types/extension/models/server_config/extension.rb
shopify-cli-2.20.0 lib/project_types/extension/models/server_config/extension.rb