Class: Extension::Tasks::ConvertServerConfig

Inherits:
Object
  • Object
show all
Includes:
SmartProperties
Defined in:
lib/project_types/extension/tasks/convert_server_config.rb

Constant Summary collapse

DEFAULT_BUILD_DIR =
"build"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(*args) ⇒ Object



23
24
25
# File 'lib/project_types/extension/tasks/convert_server_config.rb', line 23

def self.call(*args)
  new(*args).call
end

Instance Method Details

#callObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/project_types/extension/tasks/convert_server_config.rb', line 27

def call
  context.abort(context.message("tasks.errors.parse_error")) if hash.nil?

  renderer = Models::ServerConfig::DevelopmentRenderer.find(type)
  extension = Models::ServerConfig::Extension.new(
    uuid: registration_uuid,
    type: type,
    user: Models::ServerConfig::User.new,
    development: Models::ServerConfig::Development.new(
      build_dir: hash.dig("development", "build_dir") || DEFAULT_BUILD_DIR,
      renderer: renderer,
      entries: Models::ServerConfig::DevelopmentEntries.new(
        main: hash.dig("development", "entries", "main") || determine_default_entry_main(project_directory),
      )
    ),
    extension_points: hash.dig("extension_points"),
    capabilities: Models::ServerConfig::Capabilities.new(
      network_access: hash.dig("capabilities", "network_access") || false
    ),
    version: renderer ? version(renderer.name, context) : nil,
    title: title,
    metafields: metafields
  )

  unless resource_url.nil?
    extension.development.resource = Models::ServerConfig::DevelopmentResource.new(url: resource_url)
  end
  server_config = Models::ServerConfig::Root.new(
    extensions: [extension],
    port: port,
    public_url: tunnel_url,
    store: store
  )

  unless api_key.nil?
    server_config.app = Models::ServerConfig::App.new(api_key: api_key)
  end

  server_config
end

#version(renderer, context) ⇒ Object



68
69
70
# File 'lib/project_types/extension/tasks/convert_server_config.rb', line 68

def version(renderer, context)
  Tasks::FindPackageFromJson.call(renderer, context: context).version
end