How can I clean my org and uninstall all packages from a particular org as quickly and simply as possible?
1 Answer
Assuming there are only 2GMP packages installed in the org, and no unmanaged components refer the package components, the following simple script can be used:
for OUTPUT in $(sfdx force:package:beta:installed:list --json | jq '.result [] .SubscriberPackageVersionId' -r)
do
sfdx force:package:uninstall -w 500 -p $OUTPUT
done
Otherwise you need to resolve dependencies first.
For the 1GMP, it is possible to try to generate a destructiveChanges.xml
with InstalledPackage metadata component.