Last active
May 1, 2024 06:20
-
-
Save xixiaofinland/099ecfe6ed37c69105e255c665ab19f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Proudly supplied by Salesforce Way Site: https://salesforceway.com | |
# This cheatsheet contains the most often used sf(v2) commands to get a jumpstart. | |
# Hint. It is highly recommended to use `sf search` to search for commands, examples, parameters. | |
# More commands can be found in the official sites: | |
# https://developer.salesforce.com/docs/atlas.en-us.244.0.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_unified.htm | |
# The old "sfdx" cheatsheet is stored below: | |
# https://gist.github.com/XiXiaoFinland/e22aad45caf67df33aeafae085810570 | |
# Login a sandbox org and set the alias | |
sf org login web -r https://test.salesforce.com -a sandbox1 | |
# Login, set alias, and set "sandbox1" as the default org | |
sf org login web -r https://test.salesforce.com -a sandbox1 -s | |
# tail log and filter for lines with keyword 'testxx' | |
sf apex tail log | grep --line-buffered 'testxx' | |
# Logout | |
sfdx force:auth:logout -u sandbox1 | |
# Set "sandbox1" as the target devhub (i.e. default devhub) | |
sf config set target-dev-hub sandbox1 | |
# Set "sandbox1" as the target org (i.e. default org) | |
sf config set target-org sandbox1 | |
# Disconnect/logout from sandbox1 | |
sf org logout -o sandbox1 | |
# Disconnect/logout from all connected orgs without prompt | |
sf org logout -a -p | |
# Log into a prod or DevHub org and set the alias | |
sf org login web -a prodOrDevHub | |
# List connected orgs | |
sf org list | |
# Open a connected org by alisa | |
sf org open -o sandbox1 | |
# Set an alisa "testOrg" for an already connected org by the unique username "[email protected]" in the org | |
sf alias set testOrg [email protected] | |
# create scratch org, set alias, set as default | |
sf org create scratch -d -f config/project-scratch-def.json -a tempScratch | |
# install unlocked package (nebula logger's Id) into the "tempScracth" org | |
sf package install -w 20 -s AdminsOnly --package 04t5Y0000023SI6QAM -o tempScratch | |
# Deploy metadata, big scope, use "-h" to check parameters | |
sf project deploy start -h | |
# Run anonymous Apex | |
sf apex run -o [email protected] -f ~/anonymous.apex | |
# Create an Apex file | |
sf apex generate class -d path -n ApexFileName.cls | |
# Tail apex log | |
sf apex tail log -c | |
# generate/scaffold a project with default package.xml | |
sf project generate -n myProject -x | |
# generate package.xml from meta-data files or path ? Need to test it out | |
sf project generate manifest -h | |
# retrieve metadata files by package.xml from "sandbox1" org | |
sf project retrieve start -x path_to_xml_file -o sandbox1 | |
# two ways to retrieve specific metadata file from "sandbox1" org | |
sf project retrieve start -m ApexClass:ApexFileName -o sandbox1 | |
sf project retrieve start -d path/ApexfileName.cls -o sandbox1 | |
# two way to deploy metadata to sandbox1 org | |
sf project deploy start -m ApexClass:ApexFileName -o sandbox1 | |
sf project deploy start -d path_to_folder_or_file -o sandbox1 | |
# delete the scratch org with alias/username scratch1 | |
sf org delete scratch -o scratch1 | |
# run anonymous apex in the org "sandbox1" | |
sf apex run -f path_to_apex_file -o sandbox1 | |
# run Apex test test1 in TestClass in org "sandbox1" in sync mode | |
sf force apex test run -t TestClass.Test1 -o sandbox1 --synchronous | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment