xf

salesforce source code migration in terminal

npm install xf
20 downloads in the last month

xforce

Salesforce Source Code Migration in Terminal (X11, xterm, bash, sh, shell, unix)

Features:

  • Low-level - this simplifies the use of other Terminal-level software, such as vim and git
  • Cross-platform - works on any system leveraging a shell

Installation

  1. Install node.js and its package manager, npm.
  2. npm install -g xf

Table of Contents

Getting Started

You will need to generate a consumer key and a consumer secret from within Salesforce. These tokens allow xforce to access your Salesforce environment.

  1. Navigate to Your Name > Setup > Develop > Remote Access.
  2. Click New. Fill the mandatory fields with anything, then click Save.
  3. The generated tokens should be accessible on the resulting screen.

Next, in Terminal:

$ mkdir my-first-project
$ cd my-first-project
$ xf init
$ xf config client_id <your consumer key here>
$ xf config client_secret <your consumer secret here>
$ xf config username <your username here>
$ xf config password <your password here>

Configuration

Configuration settings are managed with the config command.

Required configuration

  • client_id: the consumer key generated from the Remote Access screen
  • client_secret: the consumer secret generated from the Remote Access screen
  • username: your salesforce username
  • password: your salesforce password

Optional configuration

  • version: set the version of the Salesforce API that is used. Defaults to "v27.0".
  • verbosity: set the level of logging output from the program. A verbosity of 3 or above outputs Tooling API requests and responses. The default verbosity is 1.
  • is_sandbox: this should be set to true when xforce is used with a sandbox. Defaults to false.

Operations

init

Start a new project in the current directory. This should be done first before other commands are run.

config [get | set | list]

Manage configuration parameters.

  • xf config get [key] prints the value associated with the given key
  • xf config set [key] [value] sets the given key to the given value
  • xf config list prints the full config file to the screen
  • xf get [key] is the same as xf config get [key]
  • xf set [key] [value] is the same as xf config set [key] [value]
# get the version
$ xf get version
v27.0

# use the sandbox login url
$ xf set is_sandbox true

list [expressions]

List source code files that currently exist in Salesforce, in alphabetic order.

Expressions have a name and an extension. The name can include any number of wildcard characters ("%"), and the extension can be "cls", "page", "component", "trigger", or "%".

  • xf list lists all classes, pages, components, and triggers.
  • xf list %.trigger lists all triggers.
  • xf list Site%.page Site%Controller.cls lists all pages whose names begin with "Site" and all classes whose names begin with "Site" and end with "Controller".
  • xf list SiteLogin.component prints SiteLogin.component if there is a component called SiteLogin in Salesforce, otherwise prints nothing.
  • xf list Code.% prints all classes, pages, components, and triggers with the name "Code".
  • xf list Code is the same as xf list Code.%.
  • xf list %.% and xf list % are the same as xf list.

add [local files]

Add local files to the project. A file must be added to the project before it can be pushed to the server with xf push. A file must have a proper extension ("cls", "page", "component", or "trigger") before it can be added to the project. The file must also be beneath the project directory (the directory that xf init was executed in).

# add a new page that does not exist in Salesforce to the project
$ xf add NewPage.page
added /NewPage.page

# add a page that exists in Salesforce to the project
$ xf add path/to/ExistingPage.page
added /path/to/ExistingPage.page

rm [local files]

Remove files from the project.

# remove a page from the project
$ xf rm path/to/ExistingPage.page
removed /path/to/ExistingPage.page

pull [remote files]

Pull a set of files from salesforce into the current directory. If the file already exists in the current directory, it is overwritten.

Files that have been pulled from Salesforce are not automatically added to the project.

# pull a file into the current directory
$ xf pull SiteLogin.component

# pull several files into the current directory
$ xf pull `xf list Site%Controller.cls Site%.page`

push [local files]

Push a set of files to Salesforce. These files must first be added to the project with the add command before they can be pushed to the server. It is possible to push files that do not yet exist on the server.

# push a file to the server
$ xf push NewPage.page
npm loves you