sf_cli 1.2.2 → 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 +1 -0
- 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 +2 -1
- 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/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
|
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
@@ -55,9 +55,10 @@ module SfCli::Sf::Data
|
|
55
55
|
bulk: bulk,
|
56
56
|
}
|
57
57
|
raw_output = format ? true : false
|
58
|
+
redirect_type = raw_output ? nil : :null_stderr
|
58
59
|
format = format&.to_sym || :json
|
59
60
|
|
60
|
-
exec_result = exec(__method__, flags: flags, switches: switches, redirection:
|
61
|
+
exec_result = exec(__method__, flags: flags, switches: switches, redirection: redirect_type, raw_output: raw_output, format: format)
|
61
62
|
|
62
63
|
results = return_result(exec_result, raw_output, bulk, model_class)
|
63
64
|
|
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
|
|
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:
|