function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jayesh Babu A VJayesh Babu A V 

Download all the code to local system

I have been creating a lightning app for 3 months and I have completed it. I wrote all my code in the Salesforce Developer Console. So, my question is, is there any simlple way to get all those codes (aura components, controller classes, helper classes, apex classes, visualforce pages, REST classes) and download to my local computer or is there any way to upload all codes to Github or something?
Best Answer chosen by Jayesh Babu A V
ANUTEJANUTEJ (Salesforce Developers) 
so, you could use workbench to retrieve the lightning components using the above package.xml, you could follow the below path.

>> create a file in notepad and save it as package.xml in the local storage.

>> https://workbench.developerforce.com/login.php

>> from above navigation button hover on to migration then choose retrieve.

>> Choose the above-created package.xml and now click on retrieve.

You should be able to download the components as a zip file.

You could also use salesforce cli for this purpose.

Additionally, I would suggest you check this particular trailhead module, for better understanding of metadata API:

https://trailhead.salesforce.com/content/learn/modules/package-xml

 

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Jayesh,

So, to my knowledge I think you can use metadata API to get the components, you could use the below package.xml file to retrieve all the aura components:
 
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>*</members>
        <name>AuraDefinitionBundle</name>
    </types>
    <version>45.0</version>
</Package>
Link: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_auradefinitionbundle.htm

This retrieves both lightning components and lightning web components in case if you want only for lightning web components you can use the package.xml present in the below link
>> https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_lightningcomponentbundle.htm

I hope this helps, in case if this comes handy can you please choose this as the best answer so that it can be used by others in the future.

Regards,
Anutej
Jayesh Babu A VJayesh Babu A V
Salesforce Dev console doesnt have any option to create xml file. I can only create apex classes, visualforce pages, lightning components.
ANUTEJANUTEJ (Salesforce Developers) 
so, you could use workbench to retrieve the lightning components using the above package.xml, you could follow the below path.

>> create a file in notepad and save it as package.xml in the local storage.

>> https://workbench.developerforce.com/login.php

>> from above navigation button hover on to migration then choose retrieve.

>> Choose the above-created package.xml and now click on retrieve.

You should be able to download the components as a zip file.

You could also use salesforce cli for this purpose.

Additionally, I would suggest you check this particular trailhead module, for better understanding of metadata API:

https://trailhead.salesforce.com/content/learn/modules/package-xml

 
This was selected as the best answer