4

I am having difficulty understanding the 2GP workflow. I have read through the documentation and have watched a number of videos but it is still not clicking for me. I was hoping to have someone point me in the right direction, I have a few questions that I would love answers to or documentation on.

  1. Do I have to create a scratch org to be able to use 2GP?
  2. Or can I create my changes in the SF developer org, test, and push to production org, pull down prod changes to VSCode and run the sfdx cli commands to push to a beta package?
  3. If I can do it this way, how do I connect to the beta package if I don't have a partner community login? I assume I would have to connect the same way I would have to connect to a GitHub repo and I would be able to view it in some platform like GitHub has.
  4. Does force:package:version:promote take your package from beta to production? I have to assume that "released status" means released to the public but I don't like to assume.
  5. If I can't just work out of the developer org and VSCode - how do I get my code changes from a GitHub repo to the beta app and then beta to production?

The main things that are tripping me up are not having a partner community login and managing the beta vs production app and publishing updates.

Just incase you need my current situation: I have a github repo with a few reports, a few apex classes, and a few triggers. I have a live app on the AppExchange that I want to update. It was created with the sfdx command line tool. I need to update the app with the new reports. The person who published the app is not longer able to manage the updates so I am taking it over for them.

1 Answer 1

4

Do I have to create a scratch org to be able to use 2GP?

Yes, 2GP packages are completely developed in scratch orgs.

Or can I create my changes in the SF developer org, test, and push to production org, pull down prod changes to VSCode and run the sfdx cli commands to push to a beta package?

2GPs do not use a "production org". A developer edition org reserves the namespace for the 2GP but is never used otherwise and contains no metadata. If you are developing a package in a developer edition org with a namespace, you may be in fact working with a 1GP, which uses a packaging org.

If I can do it this way, how do I connect to the beta package if I don't have a partner community login? I assume I would have to connect the same way I would have to connect to a GitHub repo and I would be able to view it in some platform like GitHub has.

The partner community hosts the Publishing Console for the AppExchange. That is a step you would take after you create a new released version of your managed package and wish to add it to your AppExchange listing or submit it for Security Review. You don't need to connect to the Partner Community or the Publishing Console during the development process.

Does force:package:version:promote take your package from beta to production? I have to assume that "released status" means released to the public but I don't like to assume.

Yes, but moving to released status is about the package version itself, and does not change your AppExchange listing or perform an upgrade of any customers. You move to released status when your development reaches a conclusion on a new version; this allows the package version to be installed in a production org and makes it possible for you to submit for Security Review and/or update your AppExchange listing.

If I can't just work out of the developer org and VSCode - how do I get my code changes from a GitHub repo to the beta app and then beta to production?

You're thinking about this as if "beta" and "production" are persistent environments you deploy to. That's not how packaging works. If you're working in source control (GitHub) with a second-generation package, you use the sfdx force:package:version:create command to create a new beta package from your repository, then promote that version when you're ready to release it with sfdx force:package:version:promote.

When you're working in a scratch org, you use the sfdx force:source:push and sfdx force:source:pull commands to move metadata between source control and the scratch org.


Clarification on terminology:

  • A Developer Edition is a type of org, which is often used as the packaging org for 1GP managed packages.
  • The Dev Hub is an org that manages your scratch orgs. The Dev Hub and the packaging org (for 1GP) or namespace org (for 2GP) are not the same org.
  • A package is not an org. A package is an artifact that can be installed in an org.
  • 1GP managed packages are created from the metadata in a packaging org.
  • 2GP managed packages are created from metadata stored in source control (not an org).
  • Packages can be in "beta" or "released" state. When a package is in released state, it can be installed in production orgs and published to the AppExchange. Beta packages are for testing.
  • "Promoting" a 2GP package version changes the state of that version from beta to released. It doesn't publish it to the AppExchange or upgrade and customer orgs.
  • Creating a release package version is a prerequisite to listing on the AppExchange and/or submitting for Security Review, but that is a separate operation.
10
  • Thank you @DavidReed. If I pull down from GH, connect my devhub username, create a new scratch org, promote the scratch org - where is it being promoted to? Am I able to physically see it somewhere?
    – Olivia
    Jul 20, 2021 at 18:40
  • You don't promote scratch orgs, you promote package versions.
    – David Reed
    Jul 20, 2021 at 18:41
  • okay, so if I merge my scratch org with my (what I assume is the same as a "master branch") developer hub...is my developer hub the new package version? and if I promote this package, where does it go? the partner community?
    – Olivia
    Jul 20, 2021 at 21:51
  • I've edited my answer to try to clarify some terminology.
    – David Reed
    Jul 20, 2021 at 22:20
  • Thank you David. I am starting to get a way better understanding. To clarify my understanding, what I am hearing is that everything is done via the cli for 2GP...so I would pull down the repo from GH, connect it to my DevHub, make a scratch org, make my changes in the scratch org, and then run sfdx force:package:version:create to create a new package. I can install this beta package somehow (still need to look that up), and then when ready I will promote the package which will set the package to "released" which allows it to be installed by people on the AppExchange. Does this sound right?
    – Olivia
    Jul 21, 2021 at 16:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .