Class: SfCli::Sf::Project::Core

Inherits:
Object
  • Object
show all
Includes:
Core::Base
Defined in:
lib/sf_cli/sf/project/core.rb

Overview

Defined Under Namespace

Classes: GenerateResult

Instance Attribute Summary

Attributes included from Core::Base

#varbose

Instance Method Summary collapse

Instance Method Details

#generate(name, manifest: false, template: nil, output_dir: nil) ⇒ Object

generate a Salesforce project. (equivalent to sf project generate)

name — project name
template — project template name
output_dir — output directory
manifest — switch to create manifest file in the project directory (manifest/package.xml). default: false

For more command details, see the reference document



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/sf_cli/sf/project/core.rb', line 26

def generate(name, manifest: false, template: nil, output_dir: nil)
  flags    = {
    :name         => name,
    :template     => template,
    :"output-dir" => output_dir,
  }
  switches = {
    manifest: manifest,
  }
  json = exec(__method__, flags: flags, switches: switches, redirection: :null_stderr)

  GenerateResult.new(
    output_dir: json['result']['outputDir'],
    files:      json['result']['created'],
    raw_output: json['result']['rawOutput'],
    warnings:   json['warnings']
  )
end

#generate_manifest(name: nil, output_dir: nil, api_version: nil, metadata: [], from_org: nil, source_dir: nil) ⇒ Object

generate the manifest file of a Salesforce project. (equivalent to sf project generate manifest)

metadata — an array that consists of metadata type like CustomObject, Layout and so on. (default: [])
api_verson — api version (default: nil)
output_dir — manifest’s output directory in the project directory. You can use relative path from the project root (default: nil)
from_org — username or alias of the org that contains the metadata components from which to build a manifest (default: nil)
source_dir — paths to the local source files to include in the manifest (default: nil)

examples

sf.project.generate_manifest metadata: %w[CustomObject Layout]  # creates a package.xml, which is initialized with CustomObject and Layout
sf.project.generate_manifest from_org: <org_name>               # creates a package.xml, which is initialized with all metadata types in the org

For more command details, see the reference document



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/sf_cli/sf/project/core.rb', line 59

def generate_manifest(name: nil, output_dir: nil, api_version: nil, metadata: [], from_org: nil, source_dir: nil)
  flags    = {
    :name           => name,
    :"metadata"     => (.empty? ? nil : .join(' ')),
    :"from-org"     => from_org,
    :"source-dir"   => source_dir,
    :"output-dir"   => output_dir,
    :"api-version"  => api_version,
  }
  action = __method__.to_s.tr('_', ' ')
  json = exec(action, flags: flags, redirection: :null_stderr)

  json['result']['path']
end