sf_cli 1.2.0 → 1.2.1

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: e9e80b705227bf6cc0a20eb798294a8179ac417b70ee1720626c34ede61c57f9
4
- data.tar.gz: a47fae091fde1fa337f11a3265dc27703a14642ad3dc287dfb400f41f3e0fcdb
3
+ metadata.gz: c6cc1ab1222fe6f4c19b78853eed5a06c7e7f9047146b5f59a08a888fb369a54
4
+ data.tar.gz: f73f3784ed62def6460450fc6780f13fae73ae5d64ee7652b60379d50fcbc3e5
5
5
  SHA512:
6
- metadata.gz: c4f31ede06a4efd8e9bf8e257712ffa2f5be05e0b7a06e79d7d5a056671480d06eaaaace79c5b2896ae4037ae53de46620a5337841b8e9c415397c70fffc9f59
7
- data.tar.gz: 24a8d99be40d9f0df743dbe0839dd25c31c6d3870123f50f2b806d580c588e37578a7d2341c2eb8a73f3003748e8ddc0ef44f7315467a2e8c67841e0b65189c3
6
+ metadata.gz: 80a77af9028ef5fed8b195d79356c0df6fc3b304a5eab26b8d094333d9148097cabb51b21592091815dc1ae0b768a3f1dbd35b88d01921d02986e5ee9b43add4
7
+ data.tar.gz: 1dbc012a4c8b0895f00ac1f741c1262d6b7319de72c08ef5d92f61204acdbb4f052755dd596883a989addaae35589039623d3d82ca9eace7a3ca97ae38a8e291
data/bin/sf_cli CHANGED
@@ -8,13 +8,15 @@ def generate_project(project_name, params)
8
8
  base_dir = Dir.pwd
9
9
  target_org = params[:"target-org"]
10
10
  retrieve_source = params[:retrieve]
11
+ editor = params[:editor]
11
12
 
12
13
  sf.project.generate project_name, manifest: true
13
14
 
14
15
  Dir.chdir project_name
15
16
 
16
- sf.project.generate_manifest from_org: target_org, output_dir: 'manifest' if target_org
17
+ sf.project.generate_manifest from_org: target_org, output_dir: 'manifest' if target_org
17
18
  sf.project.retrieve_start manifest: 'manifest/package.xml', target_org: target_org if retrieve_source
19
+ system 'code .' if editor
18
20
  ensure
19
21
  Dir.chdir base_dir
20
22
  end
@@ -25,11 +27,14 @@ Version = SfCli::VERSION
25
27
 
26
28
  opt.on('-i', '--irb', 'Start irb session that integrates sf_cli and object model library.') { system 'irb -r sf_cli/console' }
27
29
  opt.on('-g OBJECT', '--generate', 'Generate OBJECT. As of now, only project is available as OBJECT.')
28
- 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')
29
- opt.on('-r', '--retrieve', 'Retrieve source files.When specified with "-g model", source files is loaded according to the manifest file.')
30
+ opt.on('-o TARGET_ORG', '--target-org', 'Username or alias of the target org. When specified with "-g project", the manifest file is created based on the org')
31
+ opt.on('-r', '--retrieve', 'Retrieve source files.When specified with "-g project", source files is loaded according to the manifest file.')
32
+ opt.on('-e', '--editor', 'Open VS Code for current directory. When specified with "-g project", it opens the project directory')
30
33
 
31
34
  opt.parse!(ARGV, into: params)
32
35
 
33
36
  if params[:generate] == 'project'
34
37
  generate_project(ARGV[0], params)
38
+ elsif params[:editor]
39
+ system 'code .'
35
40
  end
@@ -1,7 +1,7 @@
1
1
  module SfCli::Sf::Org
2
2
  module ListLimits
3
3
  #
4
- # Returns the metadata types that are enabled for your org.
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
7
  #
@@ -1,7 +1,7 @@
1
1
  module SfCli::Sf::Org
2
2
  module ListMetadata
3
3
  #
4
- # Returns the metadata types that are enabled for your org.
4
+ # List the metadata components and properties of a specified type
5
5
  # @param metadata [Symbol,String] name of metadata type
6
6
  # @param folder [Symbol,String] folder associated with the component such as Report, EmailTemplate, Dashboard and Document
7
7
  # @param target_org [Symbol,String] an alias of paticular org, or username can be used
@@ -1,6 +1,6 @@
1
1
  module SfCli::Sf::Org
2
2
  module Login
3
- # Login to the org by the browser.
3
+ # Log in to a Salesforce org using the web server flow
4
4
  # @param target_org [Symbol,String] an alias of paticular org, or username can be used
5
5
  # @param instance_url [String] URL of the instance that the org lives on.
6
6
  # @param browser [Symbol,String] browser in which to open the org.
@@ -3,7 +3,7 @@ module SfCli::Sf::Project
3
3
  Result = Struct.new(:output_dir, :files, :raw_output, :warnings)
4
4
 
5
5
  #
6
- # Generate a Salesforce project
6
+ # Generate a Salesforce DX project
7
7
  # @param name [Symbol,String] project name
8
8
  # @param template [Symbol,String] project template name
9
9
  # @param output_dir [String] output directory
@@ -1,6 +1,6 @@
1
1
  module SfCli::Sf::Project
2
2
  module GenerateManifest
3
- # Generate the manifest file of a Salesforce DX project
3
+ # Create a project manifest that lists the metadata components you want to deploy or retrieve
4
4
  # @param metadata [Array] an array that consists of metadata type like CustomObject, Layout and so on. (default: [])
5
5
  # @param api_version [Integer] API version (default: nil)
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)
@@ -2,7 +2,7 @@ require_relative './schema'
2
2
 
3
3
  module SfCli::Sf::Sobject
4
4
  module Describe
5
- # Returns a schema object containing the Salesforce object schema
5
+ # Get a Salesforce object schema
6
6
  # @param object_type [Symbol,String] object type(ex: Account)
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
@@ -1,6 +1,6 @@
1
1
  module SfCli::Sf::Sobject
2
2
  module List
3
- # Returns a list of Salesforce object name
3
+ # List all Salesforce objects of a specified category.
4
4
  # @param object_type [Symbol,String] 'all' or 'custom'
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
@@ -42,6 +42,22 @@ module SfCli
42
42
  schema
43
43
  end
44
44
 
45
+ def action_overrides
46
+ schema["actionOverrides"]
47
+ end
48
+
49
+ def activateable?
50
+ schema["activateable"]
51
+ end
52
+
53
+ def associateEntityType
54
+ schema["associateEntityType"]
55
+ end
56
+
57
+ def associateParentEntity
58
+ schema["associateParentEntity"]
59
+ end
60
+
45
61
  def compact_layoutable?
46
62
  schema["compactLayoutable"]
47
63
  end
@@ -1,3 +1,3 @@
1
1
  module SfCli
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
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.0
4
+ version: 1.2.1
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-01 00:00:00.000000000 Z
11
+ date: 2024-10-04 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.
@@ -16,10 +16,8 @@ email:
16
16
  executables:
17
17
  - sf_cli
18
18
  extensions: []
19
- extra_rdoc_files:
20
- - README.rdoc
19
+ extra_rdoc_files: []
21
20
  files:
22
- - README.rdoc
23
21
  - bin/sf_cli
24
22
  - lib/sf_cli.rb
25
23
  - lib/sf_cli/console.rb
data/README.rdoc DELETED
@@ -1,94 +0,0 @@
1
- = Salesforce CLI library for Ruby
2
- https://badge.fury.io/rb/sf_cli.png
3
-
4
- This is a class library for introducing {Salesforce CLI}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_top.htm] to Ruby scripting.<br>
5
- It is designed to be similar usability to the original command.<br>
6
- Currently only *sf* command is the target of development.
7
-
8
- [rubygems] https://rubygems.org/gems/sf_cli
9
- [official document] https://tmkw.github.io/sf_cli/
10
-
11
- == prerequisite
12
- {Salesforce CLI}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_top.htm] must be installed.<br>
13
- As of as of September in 2024, ver.2.56.7 is the development target.
14
-
15
- == install
16
- Rubygem::
17
- the simplest way:
18
- $ gem install sf_cli
19
- Bundler::
20
- in Gemfile:
21
- gem 'sf_cli'
22
- then,
23
- $ bundle install
24
- == Usage
25
- Load module
26
- require 'sf_cli'
27
-
28
- Login to org
29
- sf.org.login_web
30
-
31
- Get Salesforce Object schema
32
- sf.sobject.describe :Account
33
-
34
- Get a record
35
- sf.data.get_record :Account, record_id: 'xxxxxxx'
36
- sf.data.get_record :Account, where: {Name: 'Jonny B.Good', Country: 'USA'}
37
-
38
- Execute SOQL
39
- sf.data.query "SELECT Id, Name FROM Account LIMIT 1" # => [{Id: "abc", Name: "account name"}]
40
-
41
- Create a record
42
- sf.data.create_record :TheCustomObject__c, values: {Name: "John Smith", Age: 33}
43
-
44
- Update a record
45
- sf.data.update_record :Account, record_id: 'xxxxxxx', values: {Name: 'New Account Name'}
46
- sf.data.update_record :Hoge__c, where: {Name: 'Jonny B.Good', Country: 'USA'}, values: {Phone: 'xxxxx', bar: 2000}
47
-
48
- Delete a record
49
- sf.data.delete_record :Hoge__c, record_id: 'xxxxxxx'
50
- sf.data.delete_record :Hoge__c, where: {Name: 'Jonny B.Good', Country: 'USA'}
51
-
52
- Using Bulk API 2.0
53
- sf.data.upsert_bulk sobject: :TestCustomObject__c, file: 'upsert.csv', wait: 5 # waiting for 5 minutes at maximum
54
-
55
- Run Apex
56
- sf.apex.run file: 'path/to/file'
57
- sf.apex.run file: StringIO.new("System.debug('Hello World')")
58
- == Object Model Support
59
- With sf command:
60
- rows = sf.data.query "SELECT Id, Name FROM Contact WHERE Name = 'Akin Kristen'", model_class: Contact
61
- rows.first # <Contact: @Id="0035j00001RW3xbAAD", @Name="Akin Kristen">
62
- rows.first.Name # Akin Kristen
63
- Doing the same thing independently:
64
- contact = Contact.select(:Id, :Name).where(Name: 'Akin Kristen').take
65
- contact.Name # Akin Kristen
66
- == Developer Console
67
- Developer console integrates both sf_cli's command methods and object model librry into IRB to make scripting easier in REPL.
68
-
69
- You can directly use sf_cli's command methods:
70
- $ sf_cli -i
71
- > sf.query "SELECT Id, Name FROM Case", target_org: :your_org
72
-
73
- Object Model is also available:
74
- > use :your_org_name
75
- > gen :Account, :Contact, :User #=> generate 3 Object model classes
76
- > acc = Account.find_by Name: 'Hoge Fuga'
77
-
78
- There are some other console commands:
79
- > query "SELECT Id, Name, ... FROM BazBar__c" # just same as `sf data query` with human readable format
80
- > apex "System.debug('abc');" # execute Apex code instantly
81
-
82
- Type *help* to know all console commands
83
-
84
- == Utility
85
- sf_cli command also have other functions. As of 1.2.0, it can generate Salesforce DX project.
86
-
87
- Create a project directory and files including manifest file
88
- $ sf_cli -g project YOUR_PROJECT_NAME
89
-
90
- Same as above, but the manifest file is built based on the org
91
- $ sf_cli -g project YOUR_PROJECT_NAME -o YOUR_TARGET_ORG
92
-
93
- Build project and manifest then retreave metadata such as Apex code at once
94
- $ sf_cli -g project YOUR_PROJECT_NAME -o YOUR_TARGET_ORG -r