[SalesForce] Lightning component deployment

I have created few lightning component in my GSO ORG and now I want to deploy it to my another ORG

I created a below mentioned package . It is retrieving the lightning components and creating a folder name 'Aura'under the SRC folder in my project(event, bundle etc… are inside that folder). However, when I am trying it to deploy to server, it is giving me this error: 'Unable to Deploy, no deployable resource found'. any Idea how to deploy lightning components?

Package I created for retrieving the lightning components:

<types>
        <members>*</members>
        <name>AuraDefinitionBundle</name>
    </types>

Best Answer

You can retrieve and deploy all types of Lightning metadata, including Components, Applications, Interfaces, and Events, from/to any org using the Force.com Migration Tool, by deploying/retrieving the AuraDefinitionBundle metadata type.

I have gotten this to work using the API v35 version of the Force.com Migration Tool --- I don't know whether it works with earlier versions of the tool, but judging by the Lightning_FAQ incorrectly saying that this is not possible when in fact it is, I'd guess that this only works in v33 or higher since Spring 15 (v33) was when Lightning Components went GA.

I have tested deploys to Developer Edition orgs with AND without namespaces, which further makes me think that the Lightning FAQ needs to be updated.

RETRIEVE

I did a simple "retrieve unpackaged" routine using the following SF Ant retrieve task:

  <sf:retrieve username="${sf.username}" password="${sf.password}" 
      retrieveTarget="retrieveUnpackaged" unpackaged="unpackaged/package.xml"/>

With package.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>*</members>
        <name>AuraDefinitionBundle</name>
    </types>
</Package>

This dumps retrieved output into a specified folder, putting all Aura bundles within an aura folder. Each bundle --- whether it is a Lightning Application, Component, etc. --- will be displayed within a separate child folder within the aura folder, with the name of the Bundle. Within each bundle's folder, the individual component pieces of each bundle are retrieved. For instance, if you've got a Lightning Component called "example", you might have the following child files within retrieveUnpackaged/aura/example:

  • example.cmp (COMPONENT XML)
  • example.cmp-meta.xml (META file for Bundle)
  • example.css (CSS)
  • example.design (DESIGN)
  • example.svg (SVG)
  • exampleController.js (CONTROLLER)
  • exampleHelper.js (HELPER)
  • exampleRenderer.js (RENDERER)

aura retrieve file structure

For other types of Bundles, e.g. Lightning Applications, the -meta.xml file will be attached to whatever the Bundle's principal file is, e.g. for a Lightning App named "test" there will be a "test.app-meta.xml` file in the directory.

DEPLOY

To deploy this code to another org, I did a "deploy unpackaged" routine using the following SF Ant deploy task:

  <sf:deploy username="${sf.username}" password="${sf.password}" 
      deployRoot="retrieveUnpackaged"/>

Where retrieveUnpackaged is the name of the directory that the sf:retrieve task dumped its output into, which contains the aura folder as well as the following package.xml file (again, this is generated automatically by the retrieve task, so no need to modify this at all, I'm only showing it here for illustrative purposes):

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>page</members>
        <members>example</members>
        <name>AuraDefinitionBundle</name>
    </types>
    <version>35.0</version>
</Package>