Org Check is an easy-to-install and easy-to-use Salesforce application and sf plugin in order to quickly analyze your org and its technical debt.
This guide will walk you through setting up a developer environment allowing you to deploy Org Check as your own unlocked package.
This page is also a good start if you want to participate in the project and propose your own PR to the team!
Before you begin, ensure you have installed the following elements:
First, clone the Org Check project repository from GitHub:
git clone https://github.com/SalesforceLabs/OrgCheck.git
cd OrgCheck
Install dependencies from the repository root:
yarn install
You need two developer orgs:
Pre-requisite: Enable Unlocked Packages and Second-Generation Managed Packages
Build the Org Check API package first (produces packages/orgcheck-api/dist/orgcheck.js):
yarn workspace @orgcheck/api build
Build the Salesforce static resource package:
yarn workspace @orgcheck/salesforce-app build
Build the sf CLI plugin package:
yarn workspace @orgcheck/sfdx-plugin build
Note: Org Check uses a monorepo. The Salesforce app is in
packages/orgcheck-salesforce-app. The Org Check API (JavaScript/TypeScript) is inpackages/orgcheck-api. Run Salesforce CLI commands frompackages/orgcheck-salesforce-appor adjust paths accordingly.
Create a fresh sfdx-project.json file with your namespace in packages/orgcheck-salesforce-app:
{
"packageDirectories": [
{
"path": "force-app",
"default": true
}
],
"namespace": "<yournamespace>",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "64.0"
}
Replace <namespace> with your actual namespace.
Pre-requisite:
sf plugins install @salesforce/plugin-packagingCreate an Unlocked package based on OrgCheck using the Salesforce CLI (recommended for debugging). Run frompackages/orgcheck-salesforce-app:
cd packages/orgcheck-salesforce-app && sf package create --name "Org Check Unlocked" --package-type Unlocked --path force-app --target-dev-hub <devhubalias>
Alternatively, you can also create and test the OrgCheck App as a Managed package:
sf package create --name "Org Check" --package-type Managed --path force-app --target-dev-hub <devhubalias>
From the @orgcheck/salesforce-app package, run the build script to generate the static resource at force-app/main/default/staticresources/OrgCheck_SR.resource:
yarn workspace @orgcheck/salesforce-app build
Or from the salesforce-app directory:
cd packages/orgcheck-salesforce-app && node ./build/static-resource/build-static-resource.js
Create a package version with the generated Package Id:
sf package version create --package "Org Check" --installation-key-bypass --wait 10 --target-dev-hub <devhubalias>
Note the Subscriber Package Version Id from the output.
If you want to use a scratch org, create it using:
sf org create scratch --definition-file orgs/dev.json --alias <scratchorgalias> --target-dev-hub <devhubalias> --wait 10
Deploy the package to your org using the Subscriber Package Version Id.
sf package install --package <subscriberpackageversionid> --target-org <scratchorgalias> --wait 10
Alternatively, you can use the corresponding alias of the version id, which has been generated for you (on step 7) in the sfdx-project.json under the section packageAliases.
sf package install --package <namespace>@1.2.3.4 --target-org <scratchorgalias> --wait 10
From the repo root, you can test the plugin commands:
sf plugins link ./packages/orgcheck-sfdx-plugin
sf check apex-classes --target-org <scratchorgalias>
sf check hardcoded-urls --target-org <scratchorgalias>
sf check global-view --target-org <scratchorgalias>
To debug, go to Setup in Salesforce:
OrgCheck_App_VFP.If you encounter any issues, check the following:
sfdx-project.json.You should now have a fully working unlocked package of Org Check, using your own namespace. For further assistance, refer to the official documentation or reach out to the community. Happy coding!