Module: ShopifyCLI::Core::Monorail

Defined in:
lib/shopify_cli/core/monorail.rb

Constant Summary collapse

ENDPOINT_URI =
URI.parse("https://monorail-edge.shopifysvc.com/v1/produce")
INVOCATIONS_SCHEMA =
"app_cli_command/5.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.metadataObject

Returns the value of attribute metadata.



16
17
18
# File 'lib/shopify_cli/core/monorail.rb', line 16

def 
  @metadata
end

Class Method Details

.full_command(command, args, resolved_command:) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/shopify_cli/core/monorail.rb', line 39

def full_command(command, args, resolved_command:)
  resolved_command = resolved_command.dup
  if command
    subcommand, subcommand_name = command.subcommand_registry.lookup_command(args.first)
    resolved_command << subcommand_name if subcommand
    if subcommand&.subcommand_registry
      resolved_command = full_command(subcommand, args.drop(1), resolved_command: resolved_command)
    end
  end
  resolved_command
end

.log(name, args, &block) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/shopify_cli/core/monorail.rb', line 18

def log(name, args, &block) # rubocop:disable Lint/UnusedMethodArgument
  command, command_name = Commands::Registry.lookup_command(name)
  full_command = self.full_command(command, args, resolved_command: [command_name])

  start_time = now_in_milliseconds
  err = nil

  begin
    yield
  rescue Exception => e # rubocop:disable Lint/RescueException
    err = e
    raise
  ensure
    # If there's an error, we don't prompt from here and we let the exception
    # reporter do that.
    if report?(prompt: err.nil?)
      send_event(start_time, full_command, args - full_command, err&.message)
    end
  end
end