A simplified version of the PURCHASE! sample app. Used as a starter package by the introductory-level "Build" module in the 2GP Handbook from ISV Bedrock.
This project is published as a GitHub template repository. Any GitHub user can quickly create their own copy by following these steps.
- Open the 2GP Starter Package repo on GitHub.
- Click the Use this template button at the top-right of the page.
- Select the Create a new repository option.
After creating a new repository from this template repo...
- Click the Code button.
- Copy the HTTPS URL of your repo to the clipboard.
- Use your repo's URL to run the following command in your terminal.
git clone PASTE_YOUR_REPO_URL_HERE
If you don't want to create your own copy of this repo, simply run the following command in your terminal to get started.
git clone https://github.com/sfdx-isv/2gp-starter-package.git
Once you've cloned this project to your dev environment, follow the exercises in the 2GP Handbook for ISVs to learn how to build second-generation managed packages.
Set a default Developer Hub for your project.
sf config set target-dev-hub="DevHubOrg"
View the current local and global config values.
sf config list
Create new managed package (must update namespace in sfdx-project.json
and force-app/main/default/flows/Approve_Purchase_Orders.flow-meta.xml
first).
sf package create -n "PURCHASE! Starter Package" -r "force-app" -t "Managed"
Create a package version.
sf package version create -c -x -w 10 -d "config/package-scratch-def.json" -p "PURCHASE! Starter Package"
View package version details.
sf package version report -p "PURCHASE! Starter Package@0.1.0-1" --verbose
Promote the package version you just created.
sf package version promote -p "PURCHASE! Starter Package@0.1.0-1"
Create a Subscriber Test scratch org.
sf org create scratch -a "SubscriberTestScratchOrg" -f "config/subscriber-scratch-def.json"
Install a package version in the Subscriber Test scratch org.
sf package install -p "PURCHASE! Starter Package@0.1.0-1" -w 10 -s "AllUsers" -o "SubscriberTestScratchOrg"
Assign the PURCHASE_User
permission set to the default user in the Subscriber Test scratch org.
sf org assign permset -n "PURCHASE_User" -o "SubscriberTestScratchOrg"
Open the Subscriber Test scratch org directly into Setup.
If you normally use Chrome, add the -b "firefox"
. If you normally use Firefox, add -b "chrome"
instead.
This way it's easy to know you're operating in your scratch org because it's a different browser than you normally use.
sf org open -o "SubscriberTestScratchOrg" -p "/lightning/setup/SetupOneHome/home" -b "firefox"
Create a Package Development scratch org as your project's default org.
sf org create scratch -d -a "PackageDevOrg" -f "config/package-scratch-def.json"
Deploy package source to the default (Package Development) scratch org.
sf project deploy start
Assign the PURCHASE_User
permission set to the default (Package Development) scratch org user.
Note this is optional. It is not needed if you're only making declarative changes.
sf org assign permset -n "PURCHASE_User"
Open the default (Package Development) scratch org.
If you normally use Chrome, add the -b "firefox"
. If you normally use Firefox, add -b "chrome"
instead.
This way it's easy to know you're operating in your scratch org because it's a different browser than you normally use.
sf org open -b "firefox"
Retrieve changes from the default (Package Development) scratch org.
sf project retrieve start
Delete Subscriber Test scratch org
sf org delete scratch -p -o "SubscriberTestScratchOrg"
Delete Package Development scratch org
sf org delete scratch -p -o "PackageDevOrg"