Class: Deploy

Inherits:
IRB::Command::Base
  • Object
show all
Defined in:
lib/alet/irb/command/deploy.rb

Instance Method Summary collapse

Instance Method Details

#deploy_component(component_type, argv, options) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/alet/irb/command/deploy.rb', line 56

def deploy_component(component_type, argv, options)
  return if argv.empty?

  type_alias = {
    'apex' => 'ApexClass',
    'trigger' => 'ApexTrigger',
    'lwc' => 'LightningComponentBundle',
  }

   =
    argv.map do |name|
       = type_alias[component_type] || component_type
      %|"#{}:#{name}"|
    end

  sf.project.deploy_start metadata: , target_org: Alet.config.org.alias, raw_output: true, **options
end

#deploy_file(argv, manifest, options) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/alet/irb/command/deploy.rb', line 48

def deploy_file(argv, manifest, options)
  if manifest
    sf.project.deploy_start manifest: manifest, target_org: Alet.config.org.alias, raw_output: true, **options
  else
    sf.project.deploy_start source_dir: argv.first, target_org: Alet.config.org.alias, raw_output: true, **options
  end
end

#execute(arg) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/alet/irb/command/deploy.rb', line 9

def execute(arg)
  pastel = Pastel.new
  argv = Shellwords.shellsplit(arg)

  opts = OptionParser.new
  opts.on('-m manifest-file', '--manifest')
  opts.on('-d', '--dryrun')
  opts.on('-l test-level', '--test-level')
  opts.on('-t test1,test2,...', '--tests')

  if argv.empty?
    puts pastel.red(t('deploy.error.no_arguments'))
    return
  end

  params = {}
  opts.parse!(argv, into: params)
  component_type = argv.shift

  options = {
    dry_run: params[:dryrun] || false,
    tests: params[:tests]&.split(','),
    test_level: params[:"test-level"]
  }

  puts component_type # for debug
  puts argv           # for debug
  puts params         # for debug
  puts options        # for debug

  if component_type == 'file'
    deploy_file(argv, params[:manifest], options)
  else
    deploy_component(component_type, argv, options)
  end
rescue => e
  puts pastel.red(e.message)
end