This is a framework which abstracts the JSforce metadata
deploy functions. Essentially you can run a few commands
per the below example.
Note: Currently this is not maintained as I am not working on any Salesforce system. Also there is a really nice project called dmc which I found out about later after implementing this and it is aiming to do a lot of what I wanted so you should check it out
'use strict'// Require the modulevar Force = ;// You MUST provide these 4. If you dont it will check the for env// variables, SF_USERNAME, SF_PASSWORD, SF_TOKEN and SF_HOSTlet options =username: 'email@example.com'password: 'somepassword'token: 'DSAddjsaddsadasda' // Annoying thing that salesforce sends youhost: 'login.salesforce.com' // Or set some other domain// Create the force object with the optionslet force = options;// Initialises a .force project folderforce;// Pulls from from the org using some previously initialised settingforce;// Pushes the current src folder (or whatever you set it to) to the orgforce;// Obliterates the .force folder and whatever src folder, take careforce;
Additionally you can set a number of options, if you take a look at the example in the repo, but it looks basically like this. Note that most of these are set for you and so are totally optional!
// Optionally create some options, the only ones you NEED to set are these// first 4 connection related settings and they default to env variableslet options =username: 'firstname.lastname@example.org'password: 'somepassword'token: 'DSAddjsaddsadasda' // Annoying thing that salesforce sends youhost: 'login.salesforce.com' // Or set some other domain// apiVersion: '34.0', // Kind of not used but its availablepollTimeout:60000 // Time in ms for jsforce retrieve / deploypollInterval:1000 // Time between polls in ms for jsforce// Logging optionslogging:level: 'debug' // For winstonexitOnError: true// Project specific optionsproject:src: './src' // Where the files will go (do not leave a trailing /)pullOnInit: false // Set this true if you want to pull after initialisingcreateMetaXml: true // True if you want missing -meta.xml to be createddeleteSrcOnReset: true // Set to false if you dont want the src folder to be reset// You can set the whole package.xml, this is the default(which is set for you)package:types:members: '*' name: 'ApexClass'members: '*' name: 'ApexComponent'members: '*' name: 'ApexPage'members: '*' name: 'ApexTrigger'members: '*' name: 'StaticResource'version: version || '34.0' // if you change THIS version it will be used
Primarily this is used at the moment in conjunction with
grunt-sf-jedi which exposes these functions
Clearly at the moment the project is fresh alpha, however, upcoming features are the following (in probable order):
- Correct change tracking, push only locally changed files
- Watch task / function
- [Deleted] file tracking from git
- Destructive push / single truth source
- Command line interface
Just a free tip here, the salesforce 'token' trolled me a bit since it wasn't sent in any email automatically. So, if you cant find the 'Reset My Security Token' option anywhere in 'Setup' try the following url. Of course you will need to change to your domain for the url
Full credit to the guy in this stackoverflow question.