Newer Version Available
Development
Create Source Files from the CLI
To add source files from the CLI, make sure that you’re working in an appropriate directory. For example, if your package directory is called force-app, create Apex classes in force-app/main/default/classes. You can organize your source as you want underneath each package directory except for documents, custom objects, and custom object translations.
As of API version 45.0, you can build Lightning components using two programming models: Lightning Web Components and Aura Components. To organize your components’ source files, your Aura components must be in the aura directory. Your Lightning web components must be in the lwc directory.
Execute one of these commands.
- apex:class:create
- apex:trigger:create
- lightning:app:create
- lightning:component:create
- lightning:event:create
- lightning:interface:create
- lightning:test:create
- visualforce:component:create
- visualforce:page:create
| Option | Description |
|---|---|
| -d, --outputdir | The directory for saving the created files. If you don’t indicate a directory, your source is added to the current folder. |
| -t, --template | Template used for the file creation. |
Edit Source Files
Use your favorite code editor to edit Apex classes, Visualforce pages and components, Lightning web components, and Aura components in your project. You can also make edits in your default scratch org and then use force:source:pull to pull those changes down to your project. For Lightning pages (FlexiPage files) that are already in your scratch org, use the shortcut to open Lightning App Builder in a scratch org from your default browser. Lightning Pages are stored in the flexipages directory.
To edit a FlexiPage in your default browser—for example, to edit the Property_Record_Page source—execute this command.
1sfdx force:source:open -f Property_Record_Page.flexipage-meta.xmlIf you want to generate a URL that loads the .flexipage-meta.xml file in Lightning App Builder but does not launch your browser, use the --urlonly flag.
1sfdx force:source:open -f Property_Record_Page.flexipage-meta.xml -r