Skip to content

Conversation

@cwarden
Copy link
Member

@cwarden cwarden commented Nov 28, 2025

Update force login scratch with new flags for features, products, editions, and settings to configure the scratch org.

New flags:

  • --feature - Enable individual scratch org features (PersonAccounts, ContactsToMultipleAccounts, FinancialServicesUser, StateAndCountryPicklist, Communities)
  • --product - Product shortcuts that enable multiple features/settings at once (fsc, communities)
  • --edition - Specify scratch org edition (Developer, Enterprise, Group, Professional, and Partner variants)
  • --quantity - Override default quantity for features like FinancialServicesUser
  • --setting - Deploy settings after org creation (enableEnhancedNotes, enableQuote, networksEnabled)

Products:

  • fsc - Financial Services Cloud (enables PersonAccounts, ContactsToMultipleAccounts, FinancialServicesUser)
  • communities - Experience Cloud (enables Communities feature and networksEnabled setting)

Enable fine-grained control over scratch org features during creation by
adding three new flags to the `login scratch` command:

--feature: Specify individual features to enable (repeatable). Valid values
are PersonAccounts, ContactsToMultipleAccounts, and FinancialServicesUser.
Uses enumflag for validation with case-insensitive matching and automatic
display of valid options in help text.

--product: Specify product shortcuts that expand to multiple features
(repeatable). Currently supports "fsc" (Financial Services Cloud) which
enables PersonAccounts, ContactsToMultipleAccounts, and FinancialServicesUser.

--quantity: Override default quantities for features that require them using
key=value syntax (e.g., FinancialServicesUser=5). Features requiring
quantities automatically receive a default of 10, enabling a streamlined UX
where users can simply specify `--product fsc` without explicit quantities.

Implementation details:
- Added enumflag/v2 dependency for type-safe flag validation
- Created ScratchFeature and ScratchProduct enum types with ID mappings
- Updated expandProductsToFeatures() to handle product expansion, feature
  deduplication, and automatic quantity assignment
- Modified ForceScratchCreateLoginAndSave() and related functions in lib/auth.go
  and lib/scratch.go to accept and process feature parameters
- Added comprehensive unit tests covering all feature/product/quantity combinations

Example usage:
  force login scratch --product fsc
  force login scratch --feature PersonAccounts --feature FinancialServicesUser
  force login scratch --product fsc --quantity FinancialServicesUser=20
Add StateAndCountryPicklist as a new scratch org feature option, enabling
State and Country Picklists for standard address fields in scratch orgs.

Reorganize help text to provide better discoverability of available features
and products. Move the growing list of valid feature and product values from
inline flag descriptions to the command's Long description, where each option
can be documented with a descriptive explanation.

Changes:
- Add StateAndCountryPicklist to ScratchFeature enum and ID mapping
- Update flag descriptions to reference "see command help for available features/products"
- Add Long description to scratchCmd with:
  - Complete list of available features with explanations
  - Complete list of available products with explanations
  - Usage examples demonstrating common scenarios
- Add unit tests for StateAndCountryPicklist feature:
  - Test standalone usage of StateAndCountryPicklist
  - Test mixed features including StateAndCountryPicklist

The new help format scales better as more features are added, keeping flag
descriptions concise while providing comprehensive documentation via --help.
The enumflag validation still shows all valid values in error messages when
invalid options are provided.

Example output:
  force login scratch --feature StateAndCountryPicklist
  force login scratch --feature PersonAccounts --feature StateAndCountryPicklist
Enable specification of scratch org edition during creation by adding a new
--edition flag to the `login scratch` command. Supports all standard and
partner Salesforce editions with case-insensitive validation and automatic
display of valid options.

Available editions (in UpperCamelCase format):
- Developer (default), Enterprise, Group, Professional
- PartnerDeveloper, PartnerEnterprise, PartnerGroup, PartnerProfessional

Implementation details:
- Created ScratchEdition enum type with all 8 edition options
- Used enumflag for type-safe validation and automatic help text generation
- Updated scratch org creation chain:
  - Modified scratchLogin() to accept edition parameter
  - Updated ForceScratchCreateLoginAndSave() signature in lib/auth.go
  - Added CreateScratchOrgWithUserFeaturesAndEdition() in lib/scratch.go
  - Maintained backward compatibility by defaulting to "Developer" edition
- Enhanced help documentation:
  - Added "Available Editions" section with descriptions
  - Included edition usage in examples
  - Kept flag description concise by referencing command help
- Added unit test to verify all edition IDs are properly defined
- Validation automatically shows all valid values in error messages

The edition parameter is passed through to the ScratchOrgInfo object creation,
allowing users to create scratch orgs with appropriate license and feature
sets for their testing needs.

Example usage:
  force login scratch --edition Enterprise --product fsc
  force login scratch --edition PartnerProfessional
  force login scratch --edition group  # case-insensitive
Enable configuration of scratch org settings through a new --setting flag that
deploys settings metadata after org creation. Unlike features which are passed
during org creation, settings must be deployed as metadata to the scratch org
after it has been created and logged into.

Available settings:
- enableEnhancedNotes: Enables Enhanced Notes and Tasks on Enhanced Notes
Add Communities as a scratch org feature and networksEnabled as a
deployable setting. Also add communities product shortcut that enables
both the Communities feature and networksEnabled setting in one command.
@cwarden cwarden merged commit 1d47c99 into ForceCLI:master Nov 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant