sf_cli 1.2.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sf_cli/command_exec_error.rb +4 -0
- data/lib/sf_cli/console/commands.rb +4 -1
- data/lib/sf_cli/sf/core/base.rb +3 -5
- data/lib/sf_cli/sf/core/org_base.rb +13 -0
- data/lib/sf_cli/sf/data/query.rb +14 -3
- data/lib/sf_cli/sf/model/generator.rb +11 -0
- data/lib/sf_cli/sf/model/query_condition.rb +10 -2
- data/lib/sf_cli/sf/org/core.rb +2 -2
- data/lib/sf_cli/sf/org/display.rb +11 -9
- data/lib/sf_cli/sf/org/list.rb +10 -7
- data/lib/sf_cli/sf/org/list_limits.rb +6 -3
- data/lib/sf_cli/sf/org/list_metadata.rb +5 -3
- data/lib/sf_cli/sf/org/list_metadata_types.rb +8 -6
- data/lib/sf_cli/sf/project/generate.rb +10 -6
- data/lib/sf_cli/sf/project/generate_manifest.rb +7 -3
- data/lib/sf_cli/sf/project/retrieve_start.rb +13 -9
- data/lib/sf_cli/sf/sobject/schema.rb +44 -9
- data/lib/sf_cli/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 283b8eacee628f3be4e587040bd604bdbb669b8f0139e5f5a8963690f2f7605a
|
4
|
+
data.tar.gz: 9d2303cefa7684784a9505df8692cd0bbce74951f53ec28bd520d1f8c61c5041
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2abcf466629177011a6d4847e3646cb033cdb34fdf40c9792ea9844678f5de0fdcd2f930cb12ad9e132300aa88ab33d59762caac39322d784af06fc768b6d51d
|
7
|
+
data.tar.gz: 4304ff0ee17be410ce5970dd917726e51a1013dfb7e9c7553df0848c4c780f9a4dbbaa4fee0f2eac33907732e37865188cfc0afbd36caa9506828d0d1ceed149
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'sf_cli'
|
2
|
+
require 'byebug'
|
2
3
|
require 'sf_cli/sf/model'
|
4
|
+
require 'sf_cli/sf/model/query_condition'
|
3
5
|
require 'sf_cli/sf/model/sf_command_connection'
|
4
6
|
require 'stringio'
|
5
7
|
|
@@ -48,7 +50,8 @@ module SfCli
|
|
48
50
|
sf.apex.run target_org: target_org, file: StringIO.new(apex_code)
|
49
51
|
end
|
50
52
|
|
51
|
-
def query(
|
53
|
+
def query(_soql)
|
54
|
+
soql = _soql.is_a?(SfCli::Sf::Model::QueryMethods::QueryCondition) ? _soql.to_soql : _soql
|
52
55
|
conf.inspect_mode = false
|
53
56
|
puts sf.data.query(soql, format: :human, target_org: target_org)
|
54
57
|
conf.inspect_mode = true
|
data/lib/sf_cli/sf/core/base.rb
CHANGED
@@ -1,24 +1,22 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
|
+
require_relative '../../command_exec_error'
|
5
|
+
|
4
6
|
module SfCli
|
5
7
|
module Sf
|
6
8
|
# @private :nodoc: just for developers
|
7
9
|
module Core
|
8
10
|
module Base
|
9
|
-
attr_reader :varbose
|
10
|
-
|
11
11
|
private
|
12
12
|
|
13
13
|
def exec(action, flags: {}, switches: {}, redirection: nil, raw_output: false, format: :json) # :doc:
|
14
14
|
cmd = %|sf #{category} #{action}#{as_flag_options(flags)}#{as_switch_options(switches, format)}#{redirect redirection}|
|
15
|
-
puts cmd if varbose
|
16
15
|
|
17
16
|
return `#{cmd}` if raw_output
|
18
17
|
|
19
18
|
json = JSON.parse `#{cmd}`
|
20
|
-
|
21
|
-
raise StandardError.new(json['message']) if json['status'] != 0
|
19
|
+
raise ::SfCli::CommandExecError.new(json['message']) if json['status'] != 0
|
22
20
|
|
23
21
|
json
|
24
22
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module SfCli::Sf::Core
|
4
|
+
module OrgBase
|
5
|
+
include Base
|
6
|
+
|
7
|
+
def org_exec(action, flags: {}, switches: {}, redirection: nil, raw_output: false)
|
8
|
+
fmt = raw_output ? :human : :json
|
9
|
+
redirect_type = raw_output ? nil : :null_stderr
|
10
|
+
exec(action, flags: flags, switches: switches, redirection: redirect_type, raw_output: raw_output, format: fmt)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/sf_cli/sf/data/query.rb
CHANGED
@@ -17,6 +17,10 @@ module SfCli::Sf::Data
|
|
17
17
|
# @example
|
18
18
|
# sf.data.query 'SELECT Id, Name FROM Account LIMIT 1' # => [{Id: "abc", Name: "account name"}]
|
19
19
|
#
|
20
|
+
# accounts = sf.data.query('SELECT Id, Name From Account') do |record|
|
21
|
+
# record['Name'] += " Changed!" # can manipulate the record in block
|
22
|
+
# end
|
23
|
+
#
|
20
24
|
# Account = Struct.new(:Id, :Name)
|
21
25
|
# sf.data.query('SELECT Id, Name From Account Limit 3', model_class: Account) # returns an array of Account struct object
|
22
26
|
#
|
@@ -39,7 +43,7 @@ module SfCli::Sf::Data
|
|
39
43
|
#
|
40
44
|
# @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_query_unified command reference
|
41
45
|
#
|
42
|
-
def query(soql, target_org: nil, format: nil, bulk: false, wait: nil, api_version: nil, model_class: nil)
|
46
|
+
def query(soql, target_org: nil, format: nil, bulk: false, wait: nil, api_version: nil, model_class: nil, &block)
|
43
47
|
flags = {
|
44
48
|
:"query" => %("#{soql}"),
|
45
49
|
:"target-org" => target_org,
|
@@ -51,11 +55,18 @@ module SfCli::Sf::Data
|
|
51
55
|
bulk: bulk,
|
52
56
|
}
|
53
57
|
raw_output = format ? true : false
|
58
|
+
redirect_type = raw_output ? nil : :null_stderr
|
54
59
|
format = format&.to_sym || :json
|
55
60
|
|
56
|
-
|
61
|
+
exec_result = exec(__method__, flags: flags, switches: switches, redirection: redirect_type, raw_output: raw_output, format: format)
|
62
|
+
|
63
|
+
results = return_result(exec_result, raw_output, bulk, model_class)
|
64
|
+
|
65
|
+
return results if raw_output
|
66
|
+
|
67
|
+
results.each(&block) if block_given?
|
57
68
|
|
58
|
-
|
69
|
+
results
|
59
70
|
end
|
60
71
|
|
61
72
|
# Resume a bulk query job, which you previously started, and get records
|
@@ -12,17 +12,28 @@ module SfCli
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def generate(object_name)
|
15
|
+
return false if generated? object_name
|
16
|
+
|
15
17
|
schema = describe(object_name)
|
16
18
|
class_definition = ClassDefinition.new(schema)
|
17
19
|
|
18
20
|
instance_eval "::#{object_name} = #{class_definition}"
|
19
21
|
klass = Object.const_get object_name.to_sym
|
20
22
|
klass.connection = connection
|
23
|
+
|
24
|
+
true
|
21
25
|
end
|
22
26
|
|
23
27
|
def describe(object_name)
|
24
28
|
connection.describe object_name
|
25
29
|
end
|
30
|
+
|
31
|
+
def generated?(object_name)
|
32
|
+
Object.const_get object_name.to_sym
|
33
|
+
true
|
34
|
+
rescue NameError
|
35
|
+
false
|
36
|
+
end
|
26
37
|
end
|
27
38
|
end
|
28
39
|
end
|
@@ -40,7 +40,7 @@ module SfCli
|
|
40
40
|
def not(*expr)
|
41
41
|
return self unless valid_expr?(expr)
|
42
42
|
|
43
|
-
conditions.append %|NOT(#{to_string_expr(expr)})|
|
43
|
+
conditions.append %|(NOT(#{to_string_expr(expr)}))|
|
44
44
|
self
|
45
45
|
end
|
46
46
|
|
@@ -132,6 +132,8 @@ module SfCli
|
|
132
132
|
%|'#{expr[2]}'|
|
133
133
|
when :Time
|
134
134
|
expr[2].to_datetime
|
135
|
+
when :NilClass
|
136
|
+
:null
|
135
137
|
when :Array
|
136
138
|
candidates = expr[2].map do |o|
|
137
139
|
case o.class.name.to_sym
|
@@ -139,11 +141,13 @@ module SfCli
|
|
139
141
|
%|'#{o}'|
|
140
142
|
when :Time
|
141
143
|
o.to_datetime
|
144
|
+
when :NilClass
|
145
|
+
:null
|
142
146
|
else
|
143
147
|
o
|
144
148
|
end
|
145
149
|
end
|
146
|
-
%|
|
150
|
+
%|(#{candidates.join(', ')})|
|
147
151
|
else
|
148
152
|
expr[2]
|
149
153
|
end
|
@@ -165,6 +169,8 @@ module SfCli
|
|
165
169
|
%|#{k} = '#{v}'|
|
166
170
|
when :Time
|
167
171
|
%|#{k} = #{v.to_datetime}|
|
172
|
+
when :NilClass
|
173
|
+
%|#{k} = null|
|
168
174
|
when :Array
|
169
175
|
candidates = v.map do |o|
|
170
176
|
case o.class.name.to_sym
|
@@ -172,6 +178,8 @@ module SfCli
|
|
172
178
|
%|'#{o}'|
|
173
179
|
when :Time
|
174
180
|
%|#{o.to_datetime}|
|
181
|
+
when :NilClass
|
182
|
+
:null
|
175
183
|
else
|
176
184
|
o
|
177
185
|
end
|
data/lib/sf_cli/sf/org/core.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '../core/
|
1
|
+
require_relative '../core/org_base'
|
2
2
|
require_relative './login'
|
3
3
|
require_relative './display'
|
4
4
|
require_relative './list'
|
@@ -16,7 +16,7 @@ module SfCli
|
|
16
16
|
module Org
|
17
17
|
# @private :nodoc: just for developers
|
18
18
|
class Core
|
19
|
-
include ::SfCli::Sf::Core::
|
19
|
+
include ::SfCli::Sf::Core::OrgBase
|
20
20
|
include Login
|
21
21
|
include Display
|
22
22
|
include List
|
@@ -10,6 +10,7 @@ module SfCli::Sf::Org
|
|
10
10
|
# Returns the org's connection information
|
11
11
|
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
12
12
|
# @param api_version [Numeric] override the api version used for api requests made by this command
|
13
|
+
# @param raw_output [Boolian] return the original command's output.
|
13
14
|
#
|
14
15
|
# @note this function returns the org information including security sensitive things such as access token, username and so on.
|
15
16
|
# @return [ConnectionInfo] the org's connection information
|
@@ -29,18 +30,19 @@ module SfCli::Sf::Org
|
|
29
30
|
#
|
30
31
|
# @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
|
31
32
|
#
|
32
|
-
def display(target_org: nil, api_version: nil)
|
33
|
+
def display(target_org: nil, api_version: nil, raw_output: false)
|
33
34
|
flags = {:"target-org" => target_org, :"api-version" => api_version}
|
34
|
-
|
35
|
+
output = org_exec(__method__, flags: flags, redirection: :null_stderr, raw_output: raw_output)
|
36
|
+
return output if raw_output
|
35
37
|
|
36
38
|
ConnectionInfo.new(
|
37
|
-
id:
|
38
|
-
access_token:
|
39
|
-
alias:
|
40
|
-
instance_url:
|
41
|
-
user_name:
|
42
|
-
api_version:
|
43
|
-
status:
|
39
|
+
id: output['result']['id'],
|
40
|
+
access_token: output['result']['accessToken'],
|
41
|
+
alias: output['result']['alias'],
|
42
|
+
instance_url: output['result']['instanceUrl'],
|
43
|
+
user_name: output['result']['username'],
|
44
|
+
api_version: output['result']['apiVersion'],
|
45
|
+
status: output['result']['connectedStatus']
|
44
46
|
)
|
45
47
|
end
|
46
48
|
end
|
data/lib/sf_cli/sf/org/list.rb
CHANGED
@@ -32,6 +32,7 @@ module SfCli::Sf::Org
|
|
32
32
|
# List orgs you’ve created or authenticated to
|
33
33
|
#
|
34
34
|
# @note this function returns org information including security sensitive things such as access token, username and so on.
|
35
|
+
# @param raw_output [Boolian] return the original command's output.
|
35
36
|
# @return [Array] the org configulations
|
36
37
|
#
|
37
38
|
# @example
|
@@ -48,17 +49,19 @@ module SfCli::Sf::Org
|
|
48
49
|
#
|
49
50
|
# @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_list_unified command reference
|
50
51
|
#
|
51
|
-
def list
|
52
|
+
def list(raw_output: false)
|
52
53
|
flags = {
|
53
54
|
# reserved for later option addition
|
54
55
|
}
|
55
|
-
|
56
|
+
output = org_exec(__method__, flags: flags, redirection: :null_stderr, raw_output: raw_output)
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
return output if raw_output
|
59
|
+
|
60
|
+
others = output['result']['other'].map{|config| OrgConfig.new(**config)}
|
61
|
+
sandboxes = output['result']['sandboxes'].map{|config| OrgConfig.new(**config)}
|
62
|
+
non_scratch_orgs = output['result']['nonScratchOrgs'].map{|config| OrgConfig.new(**config)}
|
63
|
+
devhubs = output['result']['devHubs'].map{|config| OrgConfig.new(**config)}
|
64
|
+
scratch_orgs = output['result']['scratchOrgs'].map{|config| OrgConfig.new(**config)}
|
62
65
|
|
63
66
|
(others + sandboxes + non_scratch_orgs + devhubs + scratch_orgs).uniq{|config| config.alias}
|
64
67
|
end
|
@@ -4,6 +4,7 @@ module SfCli::Sf::Org
|
|
4
4
|
# List the limits in your org
|
5
5
|
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
6
6
|
# @param api_version [Numeric] override the api version used for api requests made by this command
|
7
|
+
# @param raw_output [Boolian] return the original command's output.
|
7
8
|
#
|
8
9
|
# @return [Limits] the list of limit information
|
9
10
|
#
|
@@ -14,15 +15,17 @@ module SfCli::Sf::Org
|
|
14
15
|
#
|
15
16
|
# @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_list_limits_unified command reference
|
16
17
|
#
|
17
|
-
def list_limits(target_org: nil, api_version: nil)
|
18
|
+
def list_limits(target_org: nil, api_version: nil, raw_output: false)
|
18
19
|
flags = {
|
19
20
|
:"target-org" => target_org,
|
20
21
|
:"api-version" => api_version,
|
21
22
|
}
|
22
23
|
action = __method__.to_s.tr('_', ' ')
|
23
|
-
|
24
|
+
output = org_exec(action, flags: flags, redirection: :null_stderr, raw_output: raw_output)
|
24
25
|
|
25
|
-
|
26
|
+
return output if raw_output
|
27
|
+
|
28
|
+
Limits.new(output['result'])
|
26
29
|
end
|
27
30
|
|
28
31
|
Limit = Data.define(:name, :remaining, :max)
|
@@ -7,6 +7,7 @@ module SfCli::Sf::Org
|
|
7
7
|
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
8
8
|
# @param api_version [Numeric] override the api version used for api requests made by this command
|
9
9
|
# @param output_file [String] pathname of the file in which to write the results
|
10
|
+
# @param raw_output [Boolian] return the original command's output.
|
10
11
|
#
|
11
12
|
# @return [MetadataList] the list of metadata, which contains its name, its source file path and so on
|
12
13
|
#
|
@@ -17,7 +18,7 @@ module SfCli::Sf::Org
|
|
17
18
|
#
|
18
19
|
# @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_list_metadata_unified command reference
|
19
20
|
#
|
20
|
-
def list_metadata(metadata, folder: nil, target_org: nil, api_version: nil, output_file: nil)
|
21
|
+
def list_metadata(metadata, folder: nil, target_org: nil, api_version: nil, output_file: nil, raw_output: false)
|
21
22
|
flags = {
|
22
23
|
:"metadata-type" => metadata,
|
23
24
|
:"folder" => folder,
|
@@ -26,9 +27,10 @@ module SfCli::Sf::Org
|
|
26
27
|
:"output-file" => output_file,
|
27
28
|
}
|
28
29
|
action = __method__.to_s.tr('_', ' ')
|
29
|
-
|
30
|
+
output = org_exec(action, flags: flags, redirection: :null_stderr, raw_output: raw_output)
|
31
|
+
return output if raw_output
|
30
32
|
|
31
|
-
MetadataList.new(
|
33
|
+
MetadataList.new(output['result'])
|
32
34
|
end
|
33
35
|
|
34
36
|
Metadata = Data.define(
|
@@ -5,6 +5,7 @@ module SfCli::Sf::Org
|
|
5
5
|
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
6
6
|
# @param api_version [Numeric] override the api version used for api requests made by this command
|
7
7
|
# @param output_file [String] pathname of the file in which to write the results
|
8
|
+
# @param raw_output [Boolian] return the original command's output.
|
8
9
|
#
|
9
10
|
# @return [Result] the command's output
|
10
11
|
#
|
@@ -14,20 +15,21 @@ module SfCli::Sf::Org
|
|
14
15
|
#
|
15
16
|
# @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_list_metadata-types_unified command reference
|
16
17
|
#
|
17
|
-
def list_metadata_types(target_org: nil, api_version: nil, output_file: nil)
|
18
|
+
def list_metadata_types(target_org: nil, api_version: nil, output_file: nil, raw_output: false)
|
18
19
|
flags = {
|
19
20
|
:"target-org" => target_org,
|
20
21
|
:"api-version" => api_version,
|
21
22
|
:"output-file" => output_file,
|
22
23
|
}
|
23
24
|
action = __method__.to_s.tr('_', '-').sub('-', ' ')
|
24
|
-
|
25
|
+
output = org_exec(action, flags: flags, redirection: :null_stderr, raw_output: raw_output)
|
26
|
+
return output if raw_output
|
25
27
|
|
26
28
|
Result.new(
|
27
|
-
metadata_objects: MetadataObjects.new(
|
28
|
-
organization_namespace:
|
29
|
-
partial_save_allowed:
|
30
|
-
test_required:
|
29
|
+
metadata_objects: MetadataObjects.new(output['result']['metadataObjects']),
|
30
|
+
organization_namespace: output['result']['organizationNamespace'],
|
31
|
+
partial_save_allowed: output['result']['partialSaveAllowed'],
|
32
|
+
test_required: output['result']['testRequired']
|
31
33
|
)
|
32
34
|
end
|
33
35
|
|
@@ -8,12 +8,13 @@ module SfCli::Sf::Project
|
|
8
8
|
# @param template [Symbol,String] project template name
|
9
9
|
# @param output_dir [String] output directory
|
10
10
|
# @param manifest [Boolian] switch to create manifest file in the project directory (manifest/package.xml)
|
11
|
+
# @param raw_output [Boolian] output what original command shows
|
11
12
|
#
|
12
13
|
# @return [Result] the retsult of project generation
|
13
14
|
#
|
14
15
|
# @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
|
#
|
16
|
-
def generate(name, manifest: false, template: nil, output_dir: nil)
|
17
|
+
def generate(name, manifest: false, template: nil, output_dir: nil, raw_output: false)
|
17
18
|
flags = {
|
18
19
|
:name => name,
|
19
20
|
:template => template,
|
@@ -22,13 +23,16 @@ module SfCli::Sf::Project
|
|
22
23
|
switches = {
|
23
24
|
manifest: manifest,
|
24
25
|
}
|
25
|
-
|
26
|
+
command_output_format = raw_output ? :human : :json
|
27
|
+
redirect_type = raw_output ? nil : :null_stderr
|
28
|
+
output = exec(__method__, flags: flags, switches: switches, redirection: redirect_type, raw_output: raw_output, format: command_output_format)
|
29
|
+
return output if raw_output
|
26
30
|
|
27
31
|
Result.new(
|
28
|
-
output_dir:
|
29
|
-
files:
|
30
|
-
raw_output:
|
31
|
-
warnings:
|
32
|
+
output_dir: output['result']['outputDir'],
|
33
|
+
files: output['result']['created'],
|
34
|
+
raw_output: output['result']['rawOutput'],
|
35
|
+
warnings: output['warnings']
|
32
36
|
)
|
33
37
|
end
|
34
38
|
end
|
@@ -6,6 +6,7 @@ module SfCli::Sf::Project
|
|
6
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
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
8
|
# @param source_dir [String] paths to the local source files to include in the manifest (default: nil)
|
9
|
+
# @param raw_output [Boolian] output what original command shows
|
9
10
|
#
|
10
11
|
# @example
|
11
12
|
# sf.project.generate_manifest metadata: %w[CustomObject Layout] # creates a package.xml, which is initialized with CustomObject and Layout
|
@@ -13,7 +14,7 @@ module SfCli::Sf::Project
|
|
13
14
|
#
|
14
15
|
# @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
|
#
|
16
|
-
def generate_manifest(name: nil, output_dir: nil, api_version: nil, metadata: [], from_org: nil, source_dir: nil)
|
17
|
+
def generate_manifest(name: nil, output_dir: nil, api_version: nil, metadata: [], from_org: nil, source_dir: nil, raw_output: false)
|
17
18
|
flags = {
|
18
19
|
:name => name,
|
19
20
|
:"metadata" => (metadata.empty? ? nil : metadata.join(' ')),
|
@@ -23,9 +24,12 @@ module SfCli::Sf::Project
|
|
23
24
|
:"api-version" => api_version,
|
24
25
|
}
|
25
26
|
action = __method__.to_s.tr('_', ' ')
|
26
|
-
|
27
|
+
command_output_format = raw_output ? :human : :json
|
28
|
+
redirect_type = raw_output ? nil : :null_stderr
|
29
|
+
output = exec(action, flags: flags, redirection: redirect_type, raw_output: raw_output, format: command_output_format)
|
30
|
+
return output if raw_output
|
27
31
|
|
28
|
-
|
32
|
+
output['result']['path']
|
29
33
|
end
|
30
34
|
end
|
31
35
|
end
|
@@ -23,12 +23,13 @@ module SfCli::Sf::Project
|
|
23
23
|
# @param unzip [Boolian] number of minutes to wait for command to complete
|
24
24
|
# @param target_metadata_dir [String] indicates that the zip file points to a directory structure for a single package
|
25
25
|
# @param zip_file_name [String] file name to use for the retrieved zip file
|
26
|
+
# @param raw_output [Boolian] output what original command shows
|
26
27
|
#
|
27
28
|
# @return [Result] the retsult of the command
|
28
29
|
#
|
29
30
|
# @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_retrieve_start_unified command reference
|
30
31
|
#
|
31
|
-
def retrieve_start(metadata: nil, manifest: nil, source_dir: nil, package_name: nil, target_org: nil, output_dir: nil,
|
32
|
+
def retrieve_start(metadata: nil, manifest: nil, source_dir: nil, package_name: nil, target_org: nil, output_dir: nil, raw_output: false,
|
32
33
|
api_version: nil, wait: nil, target_metadata_dir: nil, zip_file_name: nil, ignore_conflicts: false, single_package: false, unzip: false)
|
33
34
|
|
34
35
|
flags = {
|
@@ -49,16 +50,19 @@ module SfCli::Sf::Project
|
|
49
50
|
:"unzip" => unzip,
|
50
51
|
}
|
51
52
|
action = __method__.to_s.tr('_', ' ')
|
52
|
-
|
53
|
+
command_output_format = raw_output ? :human : :json
|
54
|
+
redirect_type = raw_output ? nil : :null_stderr
|
55
|
+
output = exec(action, flags: flags, switches: switches, redirection: redirect_type, raw_output: raw_output, format: command_output_format)
|
56
|
+
return output if raw_output
|
53
57
|
|
54
58
|
Result.new(
|
55
|
-
done:
|
56
|
-
file_properties:
|
57
|
-
id:
|
58
|
-
status:
|
59
|
-
success:
|
60
|
-
messages:
|
61
|
-
files:
|
59
|
+
done: output['result']['done'],
|
60
|
+
file_properties: output['result']['fileProperties'].map{|fp| create_file_property(fp)},
|
61
|
+
id: output['result']['id'],
|
62
|
+
status: output['result']['status'],
|
63
|
+
success: output['result']['success'],
|
64
|
+
messages: output['result']['messages'],
|
65
|
+
files: output['result']['files'].map{|f| create_retrieved_file(f)}
|
62
66
|
)
|
63
67
|
end
|
64
68
|
|
@@ -19,23 +19,29 @@ module SfCli
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def field_names
|
22
|
-
@field_names ||= fields.map{|f| f.name.to_sym}
|
22
|
+
@field_names ||= fields.map{|f| f.name.to_sym}.sort
|
23
23
|
end
|
24
24
|
|
25
25
|
def field_labels
|
26
|
-
@field_labels ||= fields.map{|f| f.label}
|
26
|
+
@field_labels ||= fields.map{|f| f.label}.sort
|
27
27
|
end
|
28
28
|
|
29
29
|
def children_relations
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
@children_relations ||=
|
31
|
+
schema['childRelationships']
|
32
|
+
.select{|r| r['relationshipName'].nil? == false}
|
33
|
+
.map{|r| {name: r['relationshipName'].to_sym, field: r['field'].to_sym, class_name: r['childSObject'].to_sym}}
|
33
34
|
end
|
34
35
|
|
35
36
|
def parent_relations
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
@parent_relations ||=
|
38
|
+
fields
|
39
|
+
.select{|f| !(f.relationship_name.nil? || f.reference_to.nil?) && f.reference_to.size > 0}
|
40
|
+
.map{|f| {name: f.relationship_name.to_sym, field: f.name.to_sym, class_name: f.reference_to.first.to_sym} }
|
41
|
+
end
|
42
|
+
|
43
|
+
def relations
|
44
|
+
@relations ||= Relations.new(children_relations + parent_relations)
|
39
45
|
end
|
40
46
|
|
41
47
|
def to_h
|
@@ -212,6 +218,35 @@ module SfCli
|
|
212
218
|
@schema
|
213
219
|
end
|
214
220
|
|
221
|
+
Relation = Struct.new(:name, :field, :class_name)
|
222
|
+
|
223
|
+
class Relations
|
224
|
+
include Enumerable
|
225
|
+
|
226
|
+
def initialize(relations)
|
227
|
+
@relations = relations.map{|r| Relation.new(name: r[:name], field: r[:field], class_name: r[:class_name])}
|
228
|
+
end
|
229
|
+
|
230
|
+
def each(&block)
|
231
|
+
relations.each(&block)
|
232
|
+
end
|
233
|
+
|
234
|
+
def names
|
235
|
+
map(&:name).sort
|
236
|
+
end
|
237
|
+
|
238
|
+
def find(name)
|
239
|
+
relations.find{|r| r.name == name.to_sym}
|
240
|
+
end
|
241
|
+
|
242
|
+
private
|
243
|
+
|
244
|
+
def relations
|
245
|
+
@relations
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
|
215
250
|
class Fields
|
216
251
|
include Enumerable
|
217
252
|
|
@@ -235,7 +270,7 @@ module SfCli
|
|
235
270
|
|
236
271
|
find do |field|
|
237
272
|
attr_val = field.__send__(attr_name.to_sym)
|
238
|
-
attr_val == val
|
273
|
+
attr_val == val.to_s
|
239
274
|
end
|
240
275
|
end
|
241
276
|
|
data/lib/sf_cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sf_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takanobu Maekawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A class library for introducing Salesforce CLI to Ruby scripting. Currenty
|
14
14
|
only sf command is the target of development.
|
@@ -20,11 +20,13 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- bin/sf_cli
|
22
22
|
- lib/sf_cli.rb
|
23
|
+
- lib/sf_cli/command_exec_error.rb
|
23
24
|
- lib/sf_cli/console.rb
|
24
25
|
- lib/sf_cli/console/commands.rb
|
25
26
|
- lib/sf_cli/sf/apex/core.rb
|
26
27
|
- lib/sf_cli/sf/apex/run.rb
|
27
28
|
- lib/sf_cli/sf/core/base.rb
|
29
|
+
- lib/sf_cli/sf/core/org_base.rb
|
28
30
|
- lib/sf_cli/sf/data/bulk_result_v2.rb
|
29
31
|
- lib/sf_cli/sf/data/core.rb
|
30
32
|
- lib/sf_cli/sf/data/create_record.rb
|
@@ -69,7 +71,7 @@ homepage: https://github.com/tmkw/sf_cli
|
|
69
71
|
licenses:
|
70
72
|
- MIT
|
71
73
|
metadata:
|
72
|
-
|
74
|
+
homepage_uri: https://github.com/tmkw/sf_cli
|
73
75
|
post_install_message:
|
74
76
|
rdoc_options: []
|
75
77
|
require_paths:
|