sf_cli 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{rdoc/README.rdoc → README.rdoc} +24 -38
- data/lib/sf_cli/console/commands.rb +36 -0
- data/lib/sf_cli/console.rb +5 -0
- data/lib/sf_cli/sf/apex/core.rb +5 -6
- data/lib/sf_cli/sf/apex/run.rb +13 -10
- data/lib/sf_cli/sf/core/base.rb +1 -0
- data/lib/sf_cli/sf/data/bulk_result_v2.rb +2 -3
- data/lib/sf_cli/sf/data/core.rb +5 -6
- data/lib/sf_cli/sf/data/create_record.rb +6 -8
- data/lib/sf_cli/sf/data/delete_bulk.rb +9 -10
- data/lib/sf_cli/sf/data/delete_record.rb +8 -9
- data/lib/sf_cli/sf/data/delete_resume.rb +7 -9
- data/lib/sf_cli/sf/data/get_record.rb +11 -13
- data/lib/sf_cli/sf/data/helper_methods.rb +1 -0
- data/lib/sf_cli/sf/data/query.rb +20 -27
- data/lib/sf_cli/sf/data/query_helper.rb +3 -0
- data/lib/sf_cli/sf/data/resume.rb +6 -6
- data/lib/sf_cli/sf/data/search.rb +9 -10
- data/lib/sf_cli/sf/data/update_record.rb +11 -14
- data/lib/sf_cli/sf/data/upsert_bulk.rb +9 -12
- data/lib/sf_cli/sf/data/upsert_resume.rb +7 -10
- data/lib/sf_cli/sf/main.rb +7 -3
- data/lib/sf_cli/sf/model/base_methods.rb +1 -0
- data/lib/sf_cli/sf/model/class_definition.rb +1 -0
- data/lib/sf_cli/sf/model/dml_methods.rb +1 -0
- data/lib/sf_cli/sf/model/generator.rb +2 -1
- data/lib/sf_cli/sf/model/query_condition.rb +1 -0
- data/lib/sf_cli/sf/model/query_methods.rb +1 -0
- data/lib/sf_cli/sf/model/sf_command_connection.rb +24 -5
- data/lib/sf_cli/sf/model.rb +6 -4
- data/lib/sf_cli/sf/org/core.rb +6 -6
- data/lib/sf_cli/sf/org/display.rb +7 -6
- data/lib/sf_cli/sf/org/list.rb +12 -13
- data/lib/sf_cli/sf/org/login.rb +22 -28
- data/lib/sf_cli/sf/project/core.rb +10 -72
- data/lib/sf_cli/sf/project/generate.rb +35 -0
- data/lib/sf_cli/sf/project/generate_manifest.rb +31 -0
- data/lib/sf_cli/sf/sobject/core.rb +10 -47
- data/lib/sf_cli/sf/sobject/describe.rb +29 -0
- data/lib/sf_cli/sf/sobject/list.rb +18 -0
- data/lib/sf_cli.rb +5 -12
- metadata +10 -9
- data/CHANGELOG.md +0 -57
- data/lib/sf_cli/sf/console.rb +0 -33
- data/rdoc/ObjectModel.rdoc +0 -83
@@ -1,23 +1,20 @@
|
|
1
1
|
module SfCli::Sf::Data
|
2
2
|
module UpdateRecord
|
3
3
|
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# *target_org* --- an alias of paticular org, or username can be used<br>
|
15
|
-
#
|
16
|
-
# ==== examples
|
4
|
+
# Update a object record.
|
5
|
+
# @param object_type [Symbol,String] object type(ex. Account)
|
6
|
+
# @param record_id [String] ID of the object
|
7
|
+
# @param where [Hash] field values to identify a record
|
8
|
+
# @param values [Hash] field values for update
|
9
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
10
|
+
#
|
11
|
+
# @return [String] ID of the record updated
|
12
|
+
#
|
13
|
+
# @example
|
17
14
|
# sf.data.update_record :Account, record_id: 'xxxxxxx', values: {Name: 'New Account Name'}
|
18
15
|
# sf.data.update_record :Hoge__c, where: {Name: 'Jonny B.Good', Country: 'USA'}, values: {Phone: 'xxxxx', bar: 2000}
|
19
16
|
#
|
20
|
-
#
|
17
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_update_record_unified command reference
|
21
18
|
#
|
22
19
|
def update_record(object_type, record_id: nil, where: nil, values: nil, target_org: nil)
|
23
20
|
where_conditions = field_value_pairs(where)
|
@@ -2,19 +2,16 @@ require_relative './bulk_result_v2'
|
|
2
2
|
|
3
3
|
module SfCli::Sf::Data
|
4
4
|
module UpsertBulk
|
5
|
-
#
|
5
|
+
# Update records using Bulk API 2.0
|
6
|
+
# @param file [String] path of a CSV file to update records
|
7
|
+
# @param sobject [Symbol,String] object type(ex. Account)
|
8
|
+
# @param external_id [String] name of the external ID field.Otherwise it must be Id
|
9
|
+
# @param timeout [Integer] max minutes to wait for the job complete the task
|
10
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
6
11
|
#
|
7
|
-
#
|
12
|
+
# @return [JobInfo, BulkResultV2] the job result, whose type is changed by situation
|
8
13
|
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# *external_id* --- Name of the external ID field, or the Id field<br>
|
12
|
-
#
|
13
|
-
# *timeout* --- max minutes to wait for the job complete the task.<br>
|
14
|
-
#
|
15
|
-
# *target_org* --- an alias of paticular org, or username can be used<br>
|
16
|
-
#
|
17
|
-
# ======
|
14
|
+
# @example
|
18
15
|
# # start a upsert job
|
19
16
|
# jobinfo = sf.data.upsert_bulk sobject: :TestCustomObject__c, file: 'upsert.csv' # this returns immediately
|
20
17
|
# jobinfo.id # => "750J4000003g1OaIAI" it's job ID
|
@@ -25,7 +22,7 @@ module SfCli::Sf::Data
|
|
25
22
|
# # Or, you can wait for the job completion with one try.
|
26
23
|
# result = sf.data.upsert_bulk sobject: :TestCustomObject__c, file: 'upsert.csv', timeout: 5 # wait within 5 minutes
|
27
24
|
#
|
28
|
-
#
|
25
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_upsert_bulk_unified command reference
|
29
26
|
#
|
30
27
|
def upsert_bulk(file:, sobject:, external_id:, timeout: nil, target_org: nil)
|
31
28
|
flags = {
|
@@ -2,15 +2,14 @@ require_relative './bulk_result_v2'
|
|
2
2
|
|
3
3
|
module SfCli::Sf::Data
|
4
4
|
module UpsertResume
|
5
|
-
#
|
5
|
+
# Resume a bulk upsert job you previously started with Bulk API 2.0 and return a bulk result object.
|
6
|
+
# @param job_id [String] job ID you want to resume
|
7
|
+
# @param timeout [Integer] max minutes to wait for the job complete the task
|
8
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
6
9
|
#
|
7
|
-
#
|
10
|
+
# @return [JobInfo, BulkResultV2] the job result, whose type is changed by situation
|
8
11
|
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# *target_org* --- an alias of paticular org, or username can be used<br>
|
12
|
-
#
|
13
|
-
# ======
|
12
|
+
# @example
|
14
13
|
# # start a upsert job
|
15
14
|
# jobinfo = sf.data.upsert_bulk sobject: :TestCustomObject__c, file: 'upsert.csv' # this returns immediately
|
16
15
|
# jobinfo.id # => "750J4000003g1OaIAI" it's job ID
|
@@ -22,9 +21,7 @@ module SfCli::Sf::Data
|
|
22
21
|
#
|
23
22
|
# puts 'yey!' if result.job_info.completed? # the job has completed
|
24
23
|
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
# For more command details, see {the command reference}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_upsert_resume_unified]
|
24
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_upsert_resume_unified command reference
|
28
25
|
#
|
29
26
|
def upsert_resume(job_id:, timeout: nil, target_org: nil)
|
30
27
|
flags = {
|
data/lib/sf_cli/sf/main.rb
CHANGED
@@ -3,14 +3,15 @@ require 'json'
|
|
3
3
|
|
4
4
|
module SfCli
|
5
5
|
module Sf
|
6
|
-
|
7
|
-
# The entry class of sf command. It is returned by sf method.
|
6
|
+
|
7
|
+
# The entry class of sf command. It is returned by the sf method.
|
8
8
|
# With including Singleton module, the instance of this class is guaranteed as singleton.
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# @example
|
11
11
|
# sf # returns a instance of SfCli::Sf
|
12
12
|
# sf.org.display # you can follow the similar syntax to the original command by using method chain.
|
13
13
|
#
|
14
|
+
# @private :nodoc: just for developers
|
14
15
|
class Main
|
15
16
|
include Singleton
|
16
17
|
|
@@ -21,6 +22,9 @@ module SfCli
|
|
21
22
|
attr_reader category.downcase.to_sym
|
22
23
|
end
|
23
24
|
|
25
|
+
# Generate each sub command object such as org, data and sobject
|
26
|
+
# so that it can chain like `sf.org.display`.
|
27
|
+
#
|
24
28
|
def initialize
|
25
29
|
OPERATION_CATEGORIES.each do |category|
|
26
30
|
instance_variable_set(:"@#{category.downcase}", Object.const_get(%|::SfCli::Sf::#{category}::Core|).new)
|
@@ -3,8 +3,9 @@ require_relative './class_definition'
|
|
3
3
|
module SfCli
|
4
4
|
module Sf
|
5
5
|
module Model
|
6
|
+
# @private :nodoc: just for developers
|
6
7
|
class Generator
|
7
|
-
attr_reader :
|
8
|
+
attr_reader :connection
|
8
9
|
|
9
10
|
def initialize(connection)
|
10
11
|
@connection = connection
|
@@ -5,9 +5,18 @@ require_relative '../org/core'
|
|
5
5
|
module SfCli
|
6
6
|
module Sf
|
7
7
|
module Model
|
8
|
+
#
|
9
|
+
# Connection object to access Salesforce based on Sf command
|
10
|
+
#
|
8
11
|
class SfCommandConnection
|
9
|
-
attr_reader :
|
12
|
+
attr_reader :target_org, :instance_url
|
10
13
|
|
14
|
+
# @private :nodoc: just for developers
|
15
|
+
attr_reader :sf_data, :sf_org, :sf_sobject
|
16
|
+
|
17
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
18
|
+
# @param instance_url [String] URL of the instance that the org lives on.
|
19
|
+
#
|
11
20
|
def initialize(target_org: nil, instance_url: nil)
|
12
21
|
@sf_org = ::SfCli::Sf::Org::Core.new
|
13
22
|
@sf_data = ::SfCli::Sf::Data::Core.new
|
@@ -24,10 +33,20 @@ module SfCli
|
|
24
33
|
end
|
25
34
|
end
|
26
35
|
|
36
|
+
# Sf command style query interface for Model module
|
37
|
+
#
|
38
|
+
# For query details, see {SfCli::Sf::Data::Query sf data query}
|
39
|
+
#
|
40
|
+
def exec_query(soql, format: nil, bulk: false, timeout: nil, model_class: nil)
|
41
|
+
sf_data.query(soql, target_org: target_org, format: format, bulk: bulk, timeout: timeout, model_class: model_class)
|
42
|
+
end
|
43
|
+
|
44
|
+
# @private :nodoc: just for developers
|
27
45
|
def find(object_type, id, klass)
|
28
46
|
sf_data.get_record object_type, record_id: id, target_org: target_org, model_class: klass
|
29
47
|
end
|
30
48
|
|
49
|
+
# @private :nodoc: just for developers
|
31
50
|
def create(object_type, values, klass = nil)
|
32
51
|
id = sf_data.create_record object_type, values: values, target_org: target_org
|
33
52
|
return id if klass.nil?
|
@@ -35,22 +54,22 @@ module SfCli
|
|
35
54
|
find(object_type, id, klass)
|
36
55
|
end
|
37
56
|
|
57
|
+
# @private :nodoc: just for developers
|
38
58
|
def update(object_type, id, values)
|
39
59
|
sf_data.update_record object_type, record_id: id, where: nil, values: values, target_org: target_org
|
40
60
|
end
|
41
61
|
|
62
|
+
# @private :nodoc: just for developers
|
42
63
|
def delete(object_type, id)
|
43
64
|
sf_data.delete_record object_type, record_id: id, where: nil, target_org: target_org
|
44
65
|
end
|
45
66
|
|
67
|
+
# @private :nodoc: just for developers
|
46
68
|
def query(soql, klass)
|
47
69
|
sf_data.query soql, target_org: target_org, model_class: klass
|
48
70
|
end
|
49
71
|
|
50
|
-
|
51
|
-
sf_data.query(soql, target_org: target_org, format: format, bulk: bulk, timeout: timeout, model_class: model_class)
|
52
|
-
end
|
53
|
-
|
72
|
+
# @private :nodoc: just for developers
|
54
73
|
def describe(object_type)
|
55
74
|
sf_sobject.describe(object_type, target_org: target_org)
|
56
75
|
end
|
data/lib/sf_cli/sf/model.rb
CHANGED
@@ -3,20 +3,22 @@ require_relative 'model/generator'
|
|
3
3
|
module SfCli
|
4
4
|
module Sf
|
5
5
|
#
|
6
|
-
#
|
7
|
-
# The module for \Object \Model definition and generation
|
8
|
-
#
|
9
|
-
# see the section {"Object Model support"}[link://files/README_rdoc.html#label-Object+Model+support+-28experimental-2C+since+0.0.4-29] in README.
|
6
|
+
# The module for object model definition and generation
|
10
7
|
#
|
11
8
|
module Model
|
9
|
+
# The connection object to access Salesforce
|
12
10
|
def self.connection
|
13
11
|
@@connection
|
14
12
|
end
|
15
13
|
|
14
|
+
# set the connection
|
16
15
|
def self.set_connection(conn)
|
17
16
|
@@connection = conn
|
18
17
|
end
|
19
18
|
|
19
|
+
# generate object models
|
20
|
+
# @param object_names [Array] a list of object name
|
21
|
+
#
|
20
22
|
def self.generate(object_names)
|
21
23
|
generator = Generator.new(connection)
|
22
24
|
|
data/lib/sf_cli/sf/org/core.rb
CHANGED
@@ -5,13 +5,13 @@ require_relative './list'
|
|
5
5
|
|
6
6
|
module SfCli
|
7
7
|
module Sf
|
8
|
+
#
|
9
|
+
# Org Commands
|
10
|
+
#
|
11
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm command reference
|
12
|
+
#
|
8
13
|
module Org
|
9
|
-
#
|
10
|
-
# ==== description
|
11
|
-
# The class representing *sf* *org*.
|
12
|
-
#
|
13
|
-
# https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm
|
14
|
-
#
|
14
|
+
# @private :nodoc: just for developers
|
15
15
|
class Core
|
16
16
|
include ::SfCli::Sf::Core::Base
|
17
17
|
include Login
|
@@ -3,13 +3,14 @@ module SfCli::Sf::Org
|
|
3
3
|
ConnectionInfo = Struct.new(:id, :access_token, :alias, :instance_url, :user_name, :api_version, :status)
|
4
4
|
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# Returns the org's connection information
|
7
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
7
8
|
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# ======
|
11
|
-
# # example (in irb):
|
9
|
+
# @note this function returns the org information including security sensitive things such as access token, username and so on.
|
10
|
+
# @return [ConnectionInfo] the org's connection information
|
12
11
|
#
|
12
|
+
# @example
|
13
|
+
# (in irb):
|
13
14
|
# > sf.org.display
|
14
15
|
# =>
|
15
16
|
# #<struct SfCli::Sf::Org::Display::ConnectionInfo
|
@@ -21,7 +22,7 @@ module SfCli::Sf::Org
|
|
21
22
|
# api_version="61.0",
|
22
23
|
# status="Connected">
|
23
24
|
#
|
24
|
-
#
|
25
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm#cli_reference_org_display_unified command reference
|
25
26
|
#
|
26
27
|
def display(target_org: nil)
|
27
28
|
flags = {:"target-org" => target_org}
|
data/lib/sf_cli/sf/org/list.rb
CHANGED
@@ -29,23 +29,22 @@ module SfCli::Sf::Org
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
#
|
32
|
+
# List orgs you’ve created or authenticated to
|
33
33
|
#
|
34
|
-
#
|
35
|
-
#
|
34
|
+
# @note this function returns org information including security sensitive things such as access token, username and so on.
|
35
|
+
# @return [OrgConfig] the org configulation
|
36
36
|
#
|
37
|
-
#
|
37
|
+
# @example
|
38
|
+
# org_config_list = sf.org.list # returns a list of OrgConfig
|
38
39
|
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
# - sandbox?
|
42
|
-
# - scratch?
|
43
|
-
# - default?
|
44
|
-
# - default_devhub?
|
40
|
+
# org_config.first.accesstoken # returns the access token
|
41
|
+
# org_config.first.instance_url # returns the org's url
|
45
42
|
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
# org_config.first.
|
43
|
+
# org_config.first.conncected? # check the connection status
|
44
|
+
# org_config.first.devhub? # check if the org is devhub or not
|
45
|
+
# org_config.first.scratch? # check if the org is scratch or not
|
46
|
+
# org_config.first.default? # check if the org is default or not
|
47
|
+
# org_config.first.default_devhub? # check if the org is devhub default or not
|
49
48
|
#
|
50
49
|
# For more command details, see {the command reference}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm#cli_reference_org_list_unified]
|
51
50
|
#
|
data/lib/sf_cli/sf/org/login.rb
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
module SfCli::Sf::Org
|
2
2
|
module Login
|
3
|
-
#
|
3
|
+
# Login to the org by the browser.
|
4
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
5
|
+
# @param instance_url [String] URL of the instance that the org lives on.
|
6
|
+
# @param browser [Symbol,String] browser in which to open the org.
|
4
7
|
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# *instance_url* --- URL of the instance that the org lives on.
|
8
|
-
#
|
9
|
-
# *browser* --- browser in which to open the org.
|
10
|
-
#
|
11
|
-
# == examples:
|
8
|
+
# @example
|
12
9
|
# sf.org.login_web
|
13
10
|
# sf.org.login_web target_org: :dev
|
14
11
|
#
|
15
|
-
#
|
12
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm#cli_reference_org_login_web_unified command reference
|
16
13
|
#
|
17
14
|
def login_web(target_org: nil, instance_url: nil, browser: nil)
|
18
15
|
flags = {
|
@@ -24,30 +21,27 @@ module SfCli::Sf::Org
|
|
24
21
|
exec(action, flags: flags)
|
25
22
|
end
|
26
23
|
|
27
|
-
#
|
28
|
-
#
|
29
|
-
# NOTE: this method doesn't support user interactive mode, so *SF_ACCESS_TOKEN* environment variable must be set before call this method.
|
24
|
+
# Login to the org by access token.
|
25
|
+
# @note This method doesn't support user interactive mode, so *SF_ACCESS_TOKEN* environment variable must be set before call this method.
|
30
26
|
#
|
31
|
-
#
|
27
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
28
|
+
# @param instance_url [String] URL of the instance that the org lives on.
|
32
29
|
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
# ======
|
30
|
+
# @example
|
36
31
|
# ENV['SF_ACCESS_TOKEN'] = 'xxxxxxxxxx'
|
37
32
|
# sf.org.login_access_token instance_url: https://hoge.bar.baz.salesforce.com
|
38
33
|
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
# For more command details, see {the command reference}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm#cli_reference_org_login_access-token_unified]
|
34
|
+
# How to set env variable outside of Ruby::
|
35
|
+
# In Unix/mac::
|
36
|
+
# $ SF_ACCESS_TOKEN='xxxxxxxxxx'
|
37
|
+
# $ ruby app_using_sfcli.rb
|
38
|
+
# OR
|
39
|
+
# $ SF_ACCESS_TOKEN='xxxxxxxxxx' ruby app_using_sfcli.rb
|
40
|
+
# In Windows::
|
41
|
+
# $ set SF_ACCESS_TOKEN=xxxxxxxxxx
|
42
|
+
# $ ruby app_using_sfcli.rb
|
43
|
+
#
|
44
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm#cli_reference_org_login_access-token_unified command reference
|
51
45
|
#
|
52
46
|
def login_access_token(instance_url:, target_org: nil)
|
53
47
|
flags = {
|
@@ -1,82 +1,20 @@
|
|
1
1
|
require_relative '../core/base'
|
2
|
+
require_relative './generate'
|
3
|
+
require_relative './generate_manifest'
|
2
4
|
|
3
5
|
module SfCli
|
4
6
|
module Sf
|
7
|
+
#
|
8
|
+
# Project Commands
|
9
|
+
#
|
10
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm command reference
|
11
|
+
#
|
5
12
|
module Project
|
6
|
-
#
|
7
|
-
# The class representing *sf* *project*
|
8
|
-
#
|
9
|
-
# command reference: https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm
|
10
|
-
#
|
13
|
+
# @private :nodoc: just for developers
|
11
14
|
class Core
|
12
15
|
include ::SfCli::Sf::Core::Base
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
#
|
17
|
-
# generate a Salesforce project
|
18
|
-
#
|
19
|
-
# *name* --- project name<br>
|
20
|
-
#
|
21
|
-
# *template* --- project template name<br>
|
22
|
-
#
|
23
|
-
# *output_dir* --- output directory<br>
|
24
|
-
#
|
25
|
-
# *manifest* --- switch to create manifest file in the project directory (manifest/package.xml). default: false
|
26
|
-
#
|
27
|
-
# For more command details, see the {reference document}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm#cli_reference_project_generate_unified]
|
28
|
-
#
|
29
|
-
def generate(name, manifest: false, template: nil, output_dir: nil)
|
30
|
-
flags = {
|
31
|
-
:name => name,
|
32
|
-
:template => template,
|
33
|
-
:"output-dir" => output_dir,
|
34
|
-
}
|
35
|
-
switches = {
|
36
|
-
manifest: manifest,
|
37
|
-
}
|
38
|
-
json = exec(__method__, flags: flags, switches: switches, redirection: :null_stderr)
|
39
|
-
|
40
|
-
GenerateResult.new(
|
41
|
-
output_dir: json['result']['outputDir'],
|
42
|
-
files: json['result']['created'],
|
43
|
-
raw_output: json['result']['rawOutput'],
|
44
|
-
warnings: json['warnings']
|
45
|
-
)
|
46
|
-
end
|
47
|
-
|
48
|
-
# generate the manifest file of a Salesforce project
|
49
|
-
#
|
50
|
-
# *metadata* --- an array that consists of metadata type like CustomObject, Layout and so on. (default: [])<br>
|
51
|
-
#
|
52
|
-
# *api_verson* --- api version (default: nil)<br>
|
53
|
-
#
|
54
|
-
# *output_dir* --- manifest's output directory in the project directory. You can use relative path from the project root (default: nil)<br>
|
55
|
-
#
|
56
|
-
# *from_org* --- username or alias of the org that contains the metadata components from which to build a manifest (default: nil)<br>
|
57
|
-
#
|
58
|
-
# *source_dir* --- paths to the local source files to include in the manifest (default: nil)
|
59
|
-
#
|
60
|
-
# ======
|
61
|
-
# sf.project.generate_manifest metadata: %w[CustomObject Layout] # creates a package.xml, which is initialized with CustomObject and Layout
|
62
|
-
# sf.project.generate_manifest from_org: <org_name> # creates a package.xml, which is initialized with all metadata types in the org
|
63
|
-
#
|
64
|
-
# For more command details, see the {reference document}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm#cli_reference_project_generate_manifest_unified]
|
65
|
-
#
|
66
|
-
def generate_manifest(name: nil, output_dir: nil, api_version: nil, metadata: [], from_org: nil, source_dir: nil)
|
67
|
-
flags = {
|
68
|
-
:name => name,
|
69
|
-
:"metadata" => (metadata.empty? ? nil : metadata.join(' ')),
|
70
|
-
:"from-org" => from_org,
|
71
|
-
:"source-dir" => source_dir,
|
72
|
-
:"output-dir" => output_dir,
|
73
|
-
:"api-version" => api_version,
|
74
|
-
}
|
75
|
-
action = __method__.to_s.tr('_', ' ')
|
76
|
-
json = exec(action, flags: flags, redirection: :null_stderr)
|
77
|
-
|
78
|
-
json['result']['path']
|
79
|
-
end
|
16
|
+
include Generate
|
17
|
+
include GenerateManifest
|
80
18
|
end
|
81
19
|
end
|
82
20
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module SfCli::Sf::Project
|
2
|
+
module Generate
|
3
|
+
GenerateResult = Struct.new(:output_dir, :files, :raw_output, :warnings)
|
4
|
+
|
5
|
+
#
|
6
|
+
# Generate a Salesforce project
|
7
|
+
# @param name [Symbol,String] project name
|
8
|
+
# @param template [Symbol,String] project template name
|
9
|
+
# @param output_dir [String] output directory
|
10
|
+
# @param manifest [Boolian] switch to create manifest file in the project directory (manifest/package.xml)
|
11
|
+
#
|
12
|
+
# @return [GenerateResult] the retsult of project generation
|
13
|
+
#
|
14
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm#cli_reference_project_generate_unified command reference
|
15
|
+
#
|
16
|
+
def generate(name, manifest: false, template: nil, output_dir: nil)
|
17
|
+
flags = {
|
18
|
+
:name => name,
|
19
|
+
:template => template,
|
20
|
+
:"output-dir" => output_dir,
|
21
|
+
}
|
22
|
+
switches = {
|
23
|
+
manifest: manifest,
|
24
|
+
}
|
25
|
+
json = exec(__method__, flags: flags, switches: switches, redirection: :null_stderr)
|
26
|
+
|
27
|
+
GenerateResult.new(
|
28
|
+
output_dir: json['result']['outputDir'],
|
29
|
+
files: json['result']['created'],
|
30
|
+
raw_output: json['result']['rawOutput'],
|
31
|
+
warnings: json['warnings']
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module SfCli::Sf::Project
|
2
|
+
module GenerateManifest
|
3
|
+
# Generate the manifest file of a Salesforce DX project
|
4
|
+
# @param metadata [Array] an array that consists of metadata type like CustomObject, Layout and so on. (default: [])
|
5
|
+
# @param api_version [Integer] API version (default: nil)
|
6
|
+
# @param output_dir [String] manifest's output directory in the project directory. You can use relative path from the project root (default: nil)
|
7
|
+
# @param from_org [String] username or alias of the org that contains the metadata components from which to build a manifest (default: nil)
|
8
|
+
# @param source_dir [String] paths to the local source files to include in the manifest (default: nil)
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# sf.project.generate_manifest metadata: %w[CustomObject Layout] # creates a package.xml, which is initialized with CustomObject and Layout
|
12
|
+
# sf.project.generate_manifest from_org: org_name # creates a package.xml, which is initialized with all metadata types in the org
|
13
|
+
#
|
14
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm#cli_reference_project_generate_manifest_unified command reference
|
15
|
+
#
|
16
|
+
def generate_manifest(name: nil, output_dir: nil, api_version: nil, metadata: [], from_org: nil, source_dir: nil)
|
17
|
+
flags = {
|
18
|
+
:name => name,
|
19
|
+
:"metadata" => (metadata.empty? ? nil : metadata.join(' ')),
|
20
|
+
:"from-org" => from_org,
|
21
|
+
:"source-dir" => source_dir,
|
22
|
+
:"output-dir" => output_dir,
|
23
|
+
:"api-version" => api_version,
|
24
|
+
}
|
25
|
+
action = __method__.to_s.tr('_', ' ')
|
26
|
+
json = exec(action, flags: flags, redirection: :null_stderr)
|
27
|
+
|
28
|
+
json['result']['path']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|