Newer Version Available

This content describes an older version of this product. View Latest

Development

After you import some test data, you’ve completed the process of setting up your project. Now, you’re ready to start the development process.

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.

  • force:apex:class:create
  • force:apex:trigger:create
  • force:cmdt:create
  • force:cmdt:field:create
  • force:cmdt:record:create
  • force:lightning:app:create
  • force:lightning:component:create
  • force:lightning:event:create
  • force:lightning:interface:create
  • force:lightning:test:create
  • force:staticresource:create
  • force:visualforce:component:create
  • force:visualforce:page:create
Consider using these two helpful optional flags:
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. To add the source to an existing directory, indicate the absolute or relative path. If you don’t indicate an absolute or a relative path and the directory doesn’t exist, the CLI attempts to create it for you.
-t, --template Template used for the file creation.

If you want to know more information about a command, run it with the --help option. For example, sfdx force:apex:class:create --help.

Tip

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 from the flexipages directory.

1sfdx force:source:open -f Property_Record_Page.flexipage-meta.xml

If you want to generate a URL that loads the .flexipage-meta.xml file in Lightning App Builder but doesn’t launch your browser, use the --urlonly | -r flag.

1sfdx force:source:open -f Property_Record_Page.flexipage-meta.xml -r