sf_cli 1.1.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/bin/sf_cli +33 -4
- 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 +4 -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/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
|
@@ -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.
|
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.
|
@@ -61,10 +61,12 @@ files:
|
|
61
61
|
- lib/sf_cli/sf/project/core.rb
|
62
62
|
- lib/sf_cli/sf/project/generate.rb
|
63
63
|
- lib/sf_cli/sf/project/generate_manifest.rb
|
64
|
+
- lib/sf_cli/sf/project/retrieve_start.rb
|
64
65
|
- lib/sf_cli/sf/sobject/core.rb
|
65
66
|
- lib/sf_cli/sf/sobject/describe.rb
|
66
67
|
- lib/sf_cli/sf/sobject/list.rb
|
67
68
|
- lib/sf_cli/sf/sobject/schema.rb
|
69
|
+
- lib/sf_cli/version.rb
|
68
70
|
homepage: https://github.com/tmkw/sf_cli
|
69
71
|
licenses:
|
70
72
|
- MIT
|