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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f20d5801d3a2c887f01fa3fb3ab8775153d78b27d760ac2c6b148dac749a4945
4
- data.tar.gz: 9295c01a6eab70749c2a0367a99d29f90ac3e7dafd65c49315ac521820362506
3
+ metadata.gz: 283b8eacee628f3be4e587040bd604bdbb669b8f0139e5f5a8963690f2f7605a
4
+ data.tar.gz: 9d2303cefa7684784a9505df8692cd0bbce74951f53ec28bd520d1f8c61c5041
5
5
  SHA512:
6
- metadata.gz: 31b95e54526b884b83e19e6b870b99b148114b99692b92e4c01ea092a9068d4e779d708beba850fd60471bf44821ffcf859a00e094573e7ea8e2b70b46a341f9
7
- data.tar.gz: 68637d5bd35140a9dc851176e9e22ae341c8c1029d451f63dfc0d076d5ea103f50b6f743d2c98743d121277b59cbb335933e6f98f74484509c1fe74bd02ed33b
6
+ metadata.gz: 2abcf466629177011a6d4847e3646cb033cdb34fdf40c9792ea9844678f5de0fdcd2f930cb12ad9e132300aa88ab33d59762caac39322d784af06fc768b6d51d
7
+ data.tar.gz: 4304ff0ee17be410ce5970dd917726e51a1013dfb7e9c7553df0848c4c780f9a4dbbaa4fee0f2eac33907732e37865188cfc0afbd36caa9506828d0d1ceed149
@@ -0,0 +1,4 @@
1
+ module SfCli
2
+ class CommandExecError < StandardError
3
+ end
4
+ end
@@ -1,4 +1,5 @@
1
1
  require 'sf_cli'
2
+ require 'byebug'
2
3
  require 'sf_cli/sf/model'
3
4
  require 'sf_cli/sf/model/query_condition'
4
5
  require 'sf_cli/sf/model/sf_command_connection'
@@ -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
- puts json if varbose
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
@@ -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: :null_stderr, raw_output: raw_output, format: format)
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
 
@@ -1,4 +1,4 @@
1
- require_relative '../core/base'
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::Base
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
- json = exec(__method__, flags: flags, redirection: :null_stderr)
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: json['result']['id'],
38
- access_token: json['result']['accessToken'],
39
- alias: json['result']['alias'],
40
- instance_url: json['result']['instanceUrl'],
41
- user_name: json['result']['username'],
42
- api_version: json['result']['apiVersion'],
43
- status: json['result']['connectedStatus']
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
@@ -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
- json = exec(__method__, flags: flags, redirection: :null_stderr)
56
+ output = org_exec(__method__, flags: flags, redirection: :null_stderr, raw_output: raw_output)
56
57
 
57
- others = json['result']['other'].map{|config| OrgConfig.new(**config)}
58
- sandboxes = json['result']['sandboxes'].map{|config| OrgConfig.new(**config)}
59
- non_scratch_orgs = json['result']['nonScratchOrgs'].map{|config| OrgConfig.new(**config)}
60
- devhubs = json['result']['devHubs'].map{|config| OrgConfig.new(**config)}
61
- scratch_orgs = json['result']['scratchOrgs'].map{|config| OrgConfig.new(**config)}
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
- json = exec(action, flags: flags, redirection: :null_stderr)
24
+ output = org_exec(action, flags: flags, redirection: :null_stderr, raw_output: raw_output)
24
25
 
25
- Limits.new(json['result'])
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
- json = exec(action, flags: flags, redirection: :null_stderr)
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(json['result'])
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
- json = exec(action, flags: flags, redirection: :null_stderr)
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(json['result']['metadataObjects']),
28
- organization_namespace: json['result']['organizationNamespace'],
29
- partial_save_allowed: json['result']['partialSaveAllowed'],
30
- test_required: json['result']['testRequired']
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
- json = exec(__method__, flags: flags, switches: switches, redirection: :null_stderr)
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: json['result']['outputDir'],
29
- files: json['result']['created'],
30
- raw_output: json['result']['rawOutput'],
31
- warnings: json['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
- json = exec(action, flags: flags, redirection: :null_stderr)
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
- json['result']['path']
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
- json = exec(action, flags: flags, switches: switches, redirection: :null_stderr)
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: json['result']['done'],
56
- file_properties: json['result']['fileProperties'].map{|fp| create_file_property(fp)},
57
- id: json['result']['id'],
58
- status: json['result']['status'],
59
- success: json['result']['success'],
60
- messages: json['result']['messages'],
61
- files: json['result']['files'].map{|f| create_retrieved_file(f)}
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
 
@@ -1,3 +1,3 @@
1
1
  module SfCli
2
- VERSION = '1.2.2'
2
+ VERSION = '1.2.3'
3
3
  end
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.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-10-15 00:00:00.000000000 Z
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
- homepage_url: https://github.com/tmkw/sf_cli
74
+ homepage_uri: https://github.com/tmkw/sf_cli
73
75
  post_install_message:
74
76
  rdoc_options: []
75
77
  require_paths: