sf_cli 1.0.0 → 1.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +1 -1
- data/bin/sf_cli +33 -4
- data/lib/sf_cli/console/commands.rb +18 -2
- data/lib/sf_cli/sf/org/core.rb +6 -0
- data/lib/sf_cli/sf/org/display.rb +2 -2
- data/lib/sf_cli/sf/org/list.rb +10 -10
- data/lib/sf_cli/sf/org/list_limits.rb +56 -0
- data/lib/sf_cli/sf/org/list_metadata.rb +91 -0
- data/lib/sf_cli/sf/org/list_metadata_types.rb +85 -0
- data/lib/sf_cli/sf/org/login.rb +16 -13
- data/lib/sf_cli/sf/project/core.rb +2 -1
- data/lib/sf_cli/sf/project/generate.rb +3 -3
- data/lib/sf_cli/sf/project/retrieve_start.rb +92 -0
- data/lib/sf_cli/version.rb +3 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fc80bbeed8177decb912d239a2c8746be03041bab2b21de5277fa329c632d93
|
4
|
+
data.tar.gz: 9ed9c621df404fbbe850c6ef4ca68fe09cd931d6da71081b864f8ed684aff8c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15ccdd8cfb03aa62bc4ee5726f218598ae6326c6708cd3c8fd8e8ba01ba0ed6bb0d02deedf0889dc3aa90bfb026ac89b288352152bc8fce19ae5580acbfc8361
|
7
|
+
data.tar.gz: d80b59be4dd3b8b14d419b69cc04173407b129a52025621c87d46f309bdf150980cbe2b446502f7e632e44835d158bb84c7ead153baf8be45f3f656b96c59c37
|
data/README.rdoc
CHANGED
@@ -79,4 +79,4 @@ There are some other console commands:
|
|
79
79
|
> query "SELECT Id, Name, ... FROM BazBar__c" # just same as `sf data query` with human readable format
|
80
80
|
> apex "System.debug('abc');" # execute Apex code instantly
|
81
81
|
|
82
|
-
Type
|
82
|
+
Type *help* to know all console commands
|
data/bin/sf_cli
CHANGED
@@ -1,7 +1,36 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'optparse'
|
4
|
+
require 'sf_cli'
|
5
|
+
require 'sf_cli/version'
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
7
|
+
def generate_project(project_name, params)
|
8
|
+
base_dir = Dir.pwd
|
9
|
+
target_org = params[:"target-org"]
|
10
|
+
retrieve_source = params[:retrieve]
|
11
|
+
|
12
|
+
sf.project.generate project_name, manifest: true
|
13
|
+
|
14
|
+
Dir.chdir project_name
|
15
|
+
|
16
|
+
sf.project.generate_manifest from_org: target_org, output_dir: 'manifest' if target_org
|
17
|
+
sf.project.retrieve_start manifest: 'manifest/package.xml', target_org: target_org if retrieve_source
|
18
|
+
ensure
|
19
|
+
Dir.chdir base_dir
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
params = {}
|
24
|
+
opt = OptionParser.new
|
25
|
+
Version = SfCli::VERSION
|
26
|
+
|
27
|
+
opt.on('-i', '--irb', 'Start irb session that integrates sf_cli and object model library.') { system 'irb -r sf_cli/console' }
|
28
|
+
opt.on('-g OBJECT', '--generate', 'Generate OBJECT. As of now, only project is available as OBJECT.')
|
29
|
+
opt.on('-o TARGET_ORG', '--target-org', 'Username or alias of the target org. When specified with "-g model", the manifest file is created based on the org')
|
30
|
+
opt.on('-r', '--retrieve', 'Retrieve source files.When specified with "-g model", source files is loaded according to the manifest file.')
|
31
|
+
|
32
|
+
opt.parse!(ARGV, into: params)
|
33
|
+
|
34
|
+
if params[:generate] == 'project'
|
35
|
+
generate_project(ARGV[0], params)
|
36
|
+
end
|
@@ -54,6 +54,12 @@ module SfCli
|
|
54
54
|
conf.inspect_mode = true
|
55
55
|
end
|
56
56
|
|
57
|
+
def orgs
|
58
|
+
conf.inspect_mode = false
|
59
|
+
system 'sf org list'
|
60
|
+
conf.inspect_mode = true
|
61
|
+
end
|
62
|
+
|
57
63
|
alias :gen :generate
|
58
64
|
alias :conn :connection
|
59
65
|
|
@@ -66,6 +72,7 @@ module SfCli
|
|
66
72
|
query --- Query by SOQL with human readable format
|
67
73
|
apex --- run Apex code
|
68
74
|
conn --- show current connection setting
|
75
|
+
orgs --- show the list of org
|
69
76
|
|
70
77
|
Syntax:
|
71
78
|
[use]
|
@@ -74,6 +81,9 @@ module SfCli
|
|
74
81
|
parameters:
|
75
82
|
targat-org --- Username or alias of the org you are going to use. If you are not sure about them, check by `sf org list`.
|
76
83
|
|
84
|
+
example:
|
85
|
+
use :your_org_alias
|
86
|
+
|
77
87
|
[gen]
|
78
88
|
gen object-name, object-name, ...
|
79
89
|
generate object-name, object-name, ...
|
@@ -88,13 +98,16 @@ module SfCli
|
|
88
98
|
query SOQL
|
89
99
|
|
90
100
|
parameters:
|
91
|
-
SOQL --- soql
|
101
|
+
SOQL --- soql.You must quote it like "SELECT ...."
|
102
|
+
|
103
|
+
example:
|
104
|
+
query "SELECT Id, Name FROM Account LIMIT 3"
|
92
105
|
|
93
106
|
[apex]
|
94
107
|
apex apex_code
|
95
108
|
|
96
109
|
parameters:
|
97
|
-
apex code --- Apex code you want to execute
|
110
|
+
apex code --- Apex code you want to execute.You must quote the code.
|
98
111
|
|
99
112
|
example:
|
100
113
|
apex "System.debug('abc');"
|
@@ -102,6 +115,9 @@ module SfCli
|
|
102
115
|
[conn]
|
103
116
|
conn
|
104
117
|
connection
|
118
|
+
|
119
|
+
[orgs]
|
120
|
+
orgs
|
105
121
|
HELP
|
106
122
|
conf.inspect_mode = true
|
107
123
|
end
|
data/lib/sf_cli/sf/org/core.rb
CHANGED
@@ -2,6 +2,9 @@ require_relative '../core/base'
|
|
2
2
|
require_relative './login'
|
3
3
|
require_relative './display'
|
4
4
|
require_relative './list'
|
5
|
+
require_relative './list_metadata_types'
|
6
|
+
require_relative './list_metadata'
|
7
|
+
require_relative './list_limits'
|
5
8
|
|
6
9
|
module SfCli
|
7
10
|
module Sf
|
@@ -17,6 +20,9 @@ module SfCli
|
|
17
20
|
include Login
|
18
21
|
include Display
|
19
22
|
include List
|
23
|
+
include ListMetadataTypes
|
24
|
+
include ListMetadata
|
25
|
+
include ListLimits
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -8,8 +8,8 @@ module SfCli::Sf::Org
|
|
8
8
|
|
9
9
|
#
|
10
10
|
# Returns the org's connection information
|
11
|
-
# @param target_org
|
12
|
-
# @param api_version [Numeric]
|
11
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
12
|
+
# @param api_version [Numeric] override the api version used for api requests made by this command
|
13
13
|
#
|
14
14
|
# @note this function returns the org information including security sensitive things such as access token, username and so on.
|
15
15
|
# @return [ConnectionInfo] the org's connection information
|
data/lib/sf_cli/sf/org/list.rb
CHANGED
@@ -32,21 +32,21 @@ 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
|
-
# @return [
|
35
|
+
# @return [Array] the org configulations
|
36
36
|
#
|
37
37
|
# @example
|
38
|
-
#
|
38
|
+
# org_configs = sf.org.list # returns a list of OrgConfig
|
39
39
|
#
|
40
|
-
#
|
41
|
-
#
|
40
|
+
# org_configs.first.accesstoken # returns the access token
|
41
|
+
# org_configs.first.instance_url # returns the org's url
|
42
42
|
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
43
|
+
# org_configs.first.conncected? # check the connection status
|
44
|
+
# org_configs.first.devhub? # check if the org is devhub or not
|
45
|
+
# org_configs.first.scratch? # check if the org is scratch or not
|
46
|
+
# org_configs.first.default? # check if the org is default or not
|
47
|
+
# org_configs.first.default_devhub? # check if the org is devhub default or not
|
48
48
|
#
|
49
|
-
#
|
49
|
+
# @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
50
|
#
|
51
51
|
def list
|
52
52
|
flags = {
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module SfCli::Sf::Org
|
2
|
+
module ListLimits
|
3
|
+
#
|
4
|
+
# Returns the metadata types that are enabled for your org.
|
5
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
6
|
+
# @param api_version [Numeric] override the api version used for api requests made by this command
|
7
|
+
#
|
8
|
+
# @return [Limits] the list of limit information
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# limits = sf.org.list_limits
|
12
|
+
# limits.names #=> ["ActiveScratchOrgs","AnalyticsExternalDataSizeMB", ...]
|
13
|
+
# limits.find :ActiveScratchOrgs #=> <Limit: name="ActiveScratchOrgs", remaining=3, max=3>
|
14
|
+
#
|
15
|
+
# @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
|
+
def list_limits(target_org: nil, api_version: nil)
|
18
|
+
flags = {
|
19
|
+
:"target-org" => target_org,
|
20
|
+
:"api-version" => api_version,
|
21
|
+
}
|
22
|
+
action = __method__.to_s.tr('_', ' ')
|
23
|
+
json = exec(action, flags: flags, redirection: :null_stderr)
|
24
|
+
|
25
|
+
Limits.new(json['result'])
|
26
|
+
end
|
27
|
+
|
28
|
+
Limit = Data.define(:name, :remaining, :max)
|
29
|
+
|
30
|
+
class Limits
|
31
|
+
include Enumerable
|
32
|
+
|
33
|
+
def initialize(list)
|
34
|
+
@list = list.map {|limit| Limit.new(**limit)}
|
35
|
+
end
|
36
|
+
|
37
|
+
def each(&block)
|
38
|
+
list.each(&block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def names
|
42
|
+
list.map(&:name)
|
43
|
+
end
|
44
|
+
|
45
|
+
def find(name)
|
46
|
+
list.find{|m| m.name == name.to_s}
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def list
|
52
|
+
@list
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module SfCli::Sf::Org
|
2
|
+
module ListMetadata
|
3
|
+
#
|
4
|
+
# Returns the metadata types that are enabled for your org.
|
5
|
+
# @param metadata [Symbol,String] name of metadata type
|
6
|
+
# @param folder [Symbol,String] folder associated with the component such as Report, EmailTemplate, Dashboard and Document
|
7
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
8
|
+
# @param api_version [Numeric] override the api version used for api requests made by this command
|
9
|
+
# @param output_file [String] pathname of the file in which to write the results
|
10
|
+
#
|
11
|
+
# @return [MetadataList] the list of metadata, which contains its name, its source file path and so on
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# list = sf.org.list_metadata :ApexClass
|
15
|
+
# list.names #=> ["CommunitiesLandingController","SiteLoginControllerTest", ...]
|
16
|
+
# list.find :MyProfilePageController #=> <Metadata: full_name="MyProfilePageController" ...>
|
17
|
+
#
|
18
|
+
# @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
|
+
def list_metadata(metadata, folder: nil, target_org: nil, api_version: nil, output_file: nil)
|
21
|
+
flags = {
|
22
|
+
:"metadata-type" => metadata,
|
23
|
+
:"folder" => folder,
|
24
|
+
:"target-org" => target_org,
|
25
|
+
:"api-version" => api_version,
|
26
|
+
:"output-file" => output_file,
|
27
|
+
}
|
28
|
+
action = __method__.to_s.tr('_', ' ')
|
29
|
+
json = exec(action, flags: flags, redirection: :null_stderr)
|
30
|
+
|
31
|
+
MetadataList.new(json['result'])
|
32
|
+
end
|
33
|
+
|
34
|
+
Metadata = Data.define(
|
35
|
+
:created_by_id,
|
36
|
+
:created_by_name,
|
37
|
+
:created_date,
|
38
|
+
:file_name,
|
39
|
+
:full_name,
|
40
|
+
:id,
|
41
|
+
:last_modified_by_id,
|
42
|
+
:last_modified_by_name,
|
43
|
+
:last_modified_date,
|
44
|
+
:manageable_state,
|
45
|
+
:type) do
|
46
|
+
def name
|
47
|
+
full_name
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class MetadataList
|
52
|
+
include Enumerable
|
53
|
+
|
54
|
+
def initialize(metadata_list)
|
55
|
+
@list = metadata_list.map do |m|
|
56
|
+
Metadata.new(
|
57
|
+
created_by_id: m['createdById'],
|
58
|
+
created_by_name: m['createdByName'],
|
59
|
+
created_date: m['createdDate'],
|
60
|
+
file_name: m['fileName'],
|
61
|
+
full_name: m['fullName'],
|
62
|
+
id: m['id'],
|
63
|
+
last_modified_by_id: m['lastModifiedById'],
|
64
|
+
last_modified_by_name: m['lastModifiedByName'],
|
65
|
+
last_modified_date: m['lastModifiedDate'],
|
66
|
+
manageable_state: m['manageableState'],
|
67
|
+
type: m['type']
|
68
|
+
)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def each(&block)
|
73
|
+
list.each(&block)
|
74
|
+
end
|
75
|
+
|
76
|
+
def names
|
77
|
+
list.map(&:name)
|
78
|
+
end
|
79
|
+
|
80
|
+
def find(name)
|
81
|
+
list.find{|m| m.name == name.to_s}
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def list
|
87
|
+
@list
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module SfCli::Sf::Org
|
2
|
+
module ListMetadataTypes
|
3
|
+
#
|
4
|
+
# Returns the metadata types that are enabled for your org.
|
5
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
6
|
+
# @param api_version [Numeric] override the api version used for api requests made by this command
|
7
|
+
# @param output_file [String] pathname of the file in which to write the results
|
8
|
+
#
|
9
|
+
# @return [Result] the command's output
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# result = sf.org.list_metadata_types target_org: :dev
|
13
|
+
# result.metadata_objects.names #=> ["InstalledPackage","CustomLabels", ...]
|
14
|
+
#
|
15
|
+
# @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
|
+
def list_metadata_types(target_org: nil, api_version: nil, output_file: nil)
|
18
|
+
flags = {
|
19
|
+
:"target-org" => target_org,
|
20
|
+
:"api-version" => api_version,
|
21
|
+
:"output-file" => output_file,
|
22
|
+
}
|
23
|
+
action = __method__.to_s.tr('_', '-').sub('-', ' ')
|
24
|
+
json = exec(action, flags: flags, redirection: :null_stderr)
|
25
|
+
|
26
|
+
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']
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
MetadataObject = Data.define(:directory_name, :in_folder, :meta_file, :suffix, :xml_name, :child_xml_names) do
|
35
|
+
def name
|
36
|
+
xml_name
|
37
|
+
end
|
38
|
+
|
39
|
+
def in_folder?
|
40
|
+
in_folder
|
41
|
+
end
|
42
|
+
|
43
|
+
def meta_file?
|
44
|
+
meta_file
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Result = Data.define(:metadata_objects, :organization_namespace, :partial_save_allowed, :test_required)
|
49
|
+
|
50
|
+
class MetadataObjects
|
51
|
+
include Enumerable
|
52
|
+
|
53
|
+
def initialize(metadata_objects)
|
54
|
+
@metadata_objects = metadata_objects.map do |mo|
|
55
|
+
MetadataObject.new(
|
56
|
+
directory_name: mo['directoryName'],
|
57
|
+
in_folder: mo['inFolder'],
|
58
|
+
meta_file: mo['metaFile'],
|
59
|
+
suffix: mo['suffix'],
|
60
|
+
xml_name: mo['xmlName'],
|
61
|
+
child_xml_names: mo['childXmlNames']
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def each(&block)
|
67
|
+
metadata_objects.each(&block)
|
68
|
+
end
|
69
|
+
|
70
|
+
def names
|
71
|
+
metadata_objects.map(&:name)
|
72
|
+
end
|
73
|
+
|
74
|
+
def find(name)
|
75
|
+
metadata_objects.find{|mo| mo.name == name.to_s}
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def metadata_objects
|
81
|
+
@metadata_objects
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/sf_cli/sf/org/login.rb
CHANGED
@@ -21,28 +21,31 @@ module SfCli::Sf::Org
|
|
21
21
|
exec(action, flags: flags)
|
22
22
|
end
|
23
23
|
|
24
|
+
# @note This method doesn't support user interactive mode, so *SF_ACCESS_TOKEN* environment variable must be set before calling this method.
|
24
25
|
# Login to the org by access token.
|
25
|
-
#
|
26
|
+
#
|
27
|
+
# If you don't set *SF_ACCESS_TOKEN* in the code, you have to set it outside of the script:
|
28
|
+
#
|
29
|
+
# In Unix/mac
|
30
|
+
# $ SF_ACCESS_TOKEN='xxxxxxxxxx'
|
31
|
+
# $ ruby app_using_sfcli.rb
|
32
|
+
# OR
|
33
|
+
# $ SF_ACCESS_TOKEN='xxxxxxxxxx' ruby app_using_sfcli.rb
|
34
|
+
#
|
35
|
+
# In Windows
|
36
|
+
# > set SF_ACCESS_TOKEN=xxxxxxxxxx
|
37
|
+
# > ruby app_using_sfcli.rb
|
26
38
|
#
|
27
39
|
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
28
40
|
# @param instance_url [String] URL of the instance that the org lives on.
|
29
41
|
#
|
30
42
|
# @example
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
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
|
+
# ENV['SF_ACCESS_TOKEN'] = 'xxxxxxxxxx'
|
44
|
+
# sf.org.login_access_token instance_url: 'https://hoge.bar.baz.salesforce.com'
|
43
45
|
#
|
44
46
|
# @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
|
45
47
|
#
|
48
|
+
#
|
46
49
|
def login_access_token(instance_url:, target_org: nil)
|
47
50
|
flags = {
|
48
51
|
:"instance-url" => instance_url,
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative '../core/base'
|
2
2
|
require_relative './generate'
|
3
3
|
require_relative './generate_manifest'
|
4
|
+
require_relative './retrieve_start'
|
4
5
|
|
5
6
|
module SfCli
|
6
7
|
module Sf
|
@@ -9,13 +10,13 @@ module SfCli
|
|
9
10
|
#
|
10
11
|
# @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
12
|
#
|
12
|
-
# @private :nodoc: just for developers
|
13
13
|
module Project
|
14
14
|
# @private :nodoc: just for developers
|
15
15
|
class Core
|
16
16
|
include ::SfCli::Sf::Core::Base
|
17
17
|
include Generate
|
18
18
|
include GenerateManifest
|
19
|
+
include RetrieveStart
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module SfCli::Sf::Project
|
2
2
|
module Generate
|
3
|
-
|
3
|
+
Result = Struct.new(:output_dir, :files, :raw_output, :warnings)
|
4
4
|
|
5
5
|
#
|
6
6
|
# Generate a Salesforce project
|
@@ -9,7 +9,7 @@ module SfCli::Sf::Project
|
|
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
11
|
#
|
12
|
-
# @return [
|
12
|
+
# @return [Result] the retsult of project generation
|
13
13
|
#
|
14
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
15
|
#
|
@@ -24,7 +24,7 @@ module SfCli::Sf::Project
|
|
24
24
|
}
|
25
25
|
json = exec(__method__, flags: flags, switches: switches, redirection: :null_stderr)
|
26
26
|
|
27
|
-
|
27
|
+
Result.new(
|
28
28
|
output_dir: json['result']['outputDir'],
|
29
29
|
files: json['result']['created'],
|
30
30
|
raw_output: json['result']['rawOutput'],
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module SfCli::Sf::Project
|
2
|
+
module RetrieveStart
|
3
|
+
Result = Data.define(:done, :file_properties, :id, :status, :success, :messages, :files) do
|
4
|
+
def success?
|
5
|
+
success
|
6
|
+
end
|
7
|
+
end
|
8
|
+
FileProperty = Data.define(:created_by_id, :created_by_name, :created_date, :file_name, :full_name, :id,
|
9
|
+
:last_modified_by_id, :last_modified_by_name, :last_modified_date, :manageable_state, :type)
|
10
|
+
RetrievedFile = Data.define(:full_name, :type, :state, :file_path)
|
11
|
+
|
12
|
+
# Retrieve metadata from an org to your local project.
|
13
|
+
# @param manifest [String] path of the manifest file(package.xml) that specifies the components to retrieve
|
14
|
+
# @param metadata [Array] metadata names that specifies the components to retrieve
|
15
|
+
# @param source_dir [String] file or directory path to retrieve from the org.
|
16
|
+
# @param package_name [Array] package names to retrieve
|
17
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
18
|
+
# @param output_dir [String] directory root for the retrieved source files
|
19
|
+
# @param api_version [Numeric] override the api version used for api requests made by this command
|
20
|
+
# @param wait [Integer] number of minutes to wait for command to complete
|
21
|
+
# @param ignore_conflicts [Boolean] ignore conflicts and retrieve and save files to your local filesystem
|
22
|
+
# @param single_package [Boolean] indicates that the zip file points to a directory structure for a single package
|
23
|
+
# @param unzip [Boolian] number of minutes to wait for command to complete
|
24
|
+
# @param target_metadata_dir [String] indicates that the zip file points to a directory structure for a single package
|
25
|
+
# @param zip_file_name [String] file name to use for the retrieved zip file
|
26
|
+
#
|
27
|
+
# @return [Result] the retsult of the command
|
28
|
+
#
|
29
|
+
# @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
|
+
def retrieve_start(metadata: nil, manifest: nil, source_dir: nil, package_name: nil, target_org: nil, output_dir: nil,
|
32
|
+
api_version: nil, wait: nil, target_metadata_dir: nil, zip_file_name: nil, ignore_conflicts: false, single_package: false, unzip: false)
|
33
|
+
|
34
|
+
flags = {
|
35
|
+
:manifest => manifest,
|
36
|
+
:metadata => metadata&.join(' '),
|
37
|
+
:"source-dir" => source_dir,
|
38
|
+
:"package-name" => package_name&.join(' '),
|
39
|
+
:"target-org" => target_org,
|
40
|
+
:"output-dir" => output_dir,
|
41
|
+
:"api-version" => api_version,
|
42
|
+
:"wait" => wait,
|
43
|
+
:"target-metadata-dir" => target_metadata_dir,
|
44
|
+
:"zip-file-name" => zip_file_name,
|
45
|
+
}
|
46
|
+
switches = {
|
47
|
+
:"ignore-conflicts" => ignore_conflicts,
|
48
|
+
:"single-package" => single_package,
|
49
|
+
:"unzip" => unzip,
|
50
|
+
}
|
51
|
+
action = __method__.to_s.tr('_', ' ')
|
52
|
+
json = exec(action, flags: flags, switches: switches, redirection: :null_stderr)
|
53
|
+
|
54
|
+
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)}
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def create_file_property(hash)
|
68
|
+
FileProperty.new(
|
69
|
+
created_by_id: hash['createdById'],
|
70
|
+
created_by_name: hash['createdByName'],
|
71
|
+
created_date: hash['createdDate'],
|
72
|
+
file_name: hash['fileName'],
|
73
|
+
full_name: hash['fullName'],
|
74
|
+
id: hash['id'],
|
75
|
+
last_modified_by_id: hash['lastModifiedById'],
|
76
|
+
last_modified_by_name: hash['lastModifiedByName'],
|
77
|
+
last_modified_date: hash['lastModifiedDate'],
|
78
|
+
manageable_state: hash['manageableState'],
|
79
|
+
type: hash['type']
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_retrieved_file(hash)
|
84
|
+
RetrievedFile.new(
|
85
|
+
full_name: hash['fullName'],
|
86
|
+
type: hash['type'],
|
87
|
+
state: hash['state'],
|
88
|
+
file_path: hash['filePath']
|
89
|
+
)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
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.0.
|
4
|
+
version: 1.2.0.beta1
|
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-10-01 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.
|
@@ -54,14 +54,19 @@ files:
|
|
54
54
|
- lib/sf_cli/sf/org/core.rb
|
55
55
|
- lib/sf_cli/sf/org/display.rb
|
56
56
|
- lib/sf_cli/sf/org/list.rb
|
57
|
+
- lib/sf_cli/sf/org/list_limits.rb
|
58
|
+
- lib/sf_cli/sf/org/list_metadata.rb
|
59
|
+
- lib/sf_cli/sf/org/list_metadata_types.rb
|
57
60
|
- lib/sf_cli/sf/org/login.rb
|
58
61
|
- lib/sf_cli/sf/project/core.rb
|
59
62
|
- lib/sf_cli/sf/project/generate.rb
|
60
63
|
- lib/sf_cli/sf/project/generate_manifest.rb
|
64
|
+
- lib/sf_cli/sf/project/retrieve_start.rb
|
61
65
|
- lib/sf_cli/sf/sobject/core.rb
|
62
66
|
- lib/sf_cli/sf/sobject/describe.rb
|
63
67
|
- lib/sf_cli/sf/sobject/list.rb
|
64
68
|
- lib/sf_cli/sf/sobject/schema.rb
|
69
|
+
- lib/sf_cli/version.rb
|
65
70
|
homepage: https://github.com/tmkw/sf_cli
|
66
71
|
licenses:
|
67
72
|
- MIT
|