Salesforce DX – Push to Scratch Org

Salesforce DX – Push to Scratch Org

Salesforce DX – Push to Scratch Org

Brett M. Nelson - Tuesday, June 6, 2017

During Salesforce DX – Setup I mentioned using the readme.md at sfdx-simple. Lets take the sample code and push it to the org we created last time.  But first let's see what it has how the sample app is structured.

Structure

The repo has 3 main directories:

  1. .sfdx - the SalesforceDX config is in here and the directory and config were added when we were doing our setup.
  2. config  - this contains our workspace scratch org definition json file that we used with the sfdx force:org:create command.
  3. force-app - This folder is where all our code lives.  Production code in force-app/main/default and Test code in force-app/test/default.   This is specified in the sfdx-workspace.json in the root of the folder structure.

The dev guide says that project workspace can be set up at the in a flexible manner with the only exception being Lightning components needing to be in a directory named aura.  We'll see how flexible later :)

The repo also has the .gitignore, a .project, the LICENSE, the README.md, and the previously mentioned sfdx-workspace.json.  Let's talk about them:

The actual working files (apex, visualforce) can be seen as well.  Here is the complete file structrue:

File Structure

sfdx-simple File Structure

Push It

Let's push this code to our scratch org using the sfdx force:source:push  command and see what happens:

sfdx force:source:push Command

sfdx force:source:push Command

As you can see it sent the Apex Classes, both of them, and the Visualforce page with the meta xml files.

Now that we have something in our org we can run tests using the

sfdx force:apex:test:run command:

sfdx force:apex:test:run Command

sfdx force:apex:test:run Command

Here you can see it returns the test id along with the sfdx command to run to see the results force:apex:test:report -i 7073D000000Ib8wtes.  So lets see what our tests result was.

sfdx force:apex:test:report -i 7073D000000Ib8wtes Command

sfdx force:apex:test:report -i 7073D000000Ib8wtes Command

There you have it One test passed, YAY!

Conclusion

We now have pushed the sfdx-simple sample to our scratch org and ran some tests.  Pretty exciting so far!  Have something you would like to add?  Let me know by leaving a comment below, emailing brett@wipdeveloper.com or following and yelling at me on Twitter/BrettMN.

Tags