sf_cli 1.2.0.beta1 → 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: 5fc80bbeed8177decb912d239a2c8746be03041bab2b21de5277fa329c632d93
4
- data.tar.gz: 9ed9c621df404fbbe850c6ef4ca68fe09cd931d6da71081b864f8ed684aff8c0
3
+ metadata.gz: c6cc1ab1222fe6f4c19b78853eed5a06c7e7f9047146b5f59a08a888fb369a54
4
+ data.tar.gz: f73f3784ed62def6460450fc6780f13fae73ae5d64ee7652b60379d50fcbc3e5
5
5
  SHA512:
6
- metadata.gz: 15ccdd8cfb03aa62bc4ee5726f218598ae6326c6708cd3c8fd8e8ba01ba0ed6bb0d02deedf0889dc3aa90bfb026ac89b288352152bc8fce19ae5580acbfc8361
7
- data.tar.gz: d80b59be4dd3b8b14d419b69cc04173407b129a52025621c87d46f309bdf150980cbe2b446502f7e632e44835d158bb84c7ead153baf8be45f3f656b96c59c37
6
+ metadata.gz: 80a77af9028ef5fed8b195d79356c0df6fc3b304a5eab26b8d094333d9148097cabb51b21592091815dc1ae0b768a3f1dbd35b88d01921d02986e5ee9b43add4
7
+ data.tar.gz: 1dbc012a4c8b0895f00ac1f741c1262d6b7319de72c08ef5d92f61204acdbb4f052755dd596883a989addaae35589039623d3d82ca9eace7a3ca97ae38a8e291
data/bin/sf_cli CHANGED
@@ -8,29 +8,33 @@ 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
21
23
 
22
-
23
24
  params = {}
24
25
  opt = OptionParser.new
25
26
  Version = SfCli::VERSION
26
27
 
27
28
  opt.on('-i', '--irb', 'Start irb session that integrates sf_cli and object model library.') { system 'irb -r sf_cli/console' }
28
29
  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.')
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')
31
33
 
32
34
  opt.parse!(ARGV, into: params)
33
35
 
34
36
  if params[:generate] == 'project'
35
37
  generate_project(ARGV[0], params)
38
+ elsif params[:editor]
39
+ system 'code .'
36
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
@@ -395,8 +411,18 @@ module SfCli
395
411
  field["permissionable"]
396
412
  end
397
413
 
414
+ PicklistValue = Data.define(:active, :default_value, :label, :valid_for, :value)
415
+
398
416
  def picklist_values
399
- field["picklistValues"]
417
+ field["picklistValues"].map do |value|
418
+ PicklistValue.new(
419
+ active: value['active'],
420
+ default_value: value['defaultValue'],
421
+ label: value['label'],
422
+ valid_for: value['validFor'],
423
+ value: value['value'],
424
+ )
425
+ end
400
426
  end
401
427
 
402
428
  def polymorphic_foreign_key?
@@ -1,3 +1,3 @@
1
1
  module SfCli
2
- VERSION = '1.2.0.beta1'
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.beta1
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,82 +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
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