From 19357aff6c0403af76030b3edfe1bc97f30d2cd0 Mon Sep 17 00:00:00 2001 From: Mradul Agrawal Date: Tue, 11 Jun 2024 15:42:38 -0700 Subject: [PATCH] feat: async validation for package version create --- README.md | 12 +++++++++++- command-snapshot.json | 2 ++ messages/package_version_create.md | 18 ++++++++++++++++++ schemas/package-version-create.json | 3 ++- src/commands/package/version/create.ts | 25 +++++++++++++++++++++++-- 5 files changed, 56 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 22464168..941c3d18 100644 --- a/README.md +++ b/README.md @@ -518,7 +518,7 @@ Create a package version in the Dev Hub org. ``` USAGE $ sf package version create -v [--json] [--flags-dir ] [--api-version ] [-b ] [-c | - --skip-validation] [-f ] [-k ] [-x] [-p ] [-d ] [--post-install-script ] + --skip-validation | --async-validation] [-f ] [-k ] [-x] [-p ] [-d ] [--post-install-script ] [--post-install-url ] [--releasenotes-url ] [--skip-ancestor-check] [-t ] [--uninstall-script ] [-e ] [-a ] [-n ] [-w ] [--language ] [--verbose] @@ -554,6 +554,7 @@ FLAGS that isn’t the highest released package version. --skip-validation Skip validation during package version creation; you can’t promote unvalidated package versions. + --async-validation Return a new package version before completing package validations. --uninstall-script= Uninstall script name; applies to managed packages only. --verbose Display verbose command output. @@ -602,6 +603,9 @@ EXAMPLES $ sf package version create --path common --installation-key password123 --skip-validation + Create a package version and perform package validations asynchronously: + $ sf package version create --path common --installation-key password123 --async-validation + FLAG DESCRIPTIONS -c, --code-coverage @@ -652,6 +656,12 @@ FLAG DESCRIPTIONS versions. Skipping validation can suppress important errors that can surface at a later stage. You can specify skip validation or code coverage, but not both. Code coverage is calculated during validation. + --async-validation Return a new package version before completing package validations. + + Specifying async validation returns the package version earlier in the process, allowing you to install and test + the new version right away. If your development team is using continuous integration (CI) scripts, async validation + can reduce your overall CI run time. + --uninstall-script= Uninstall script name; applies to managed packages only. The uninstall script is an Apex class within this package that is run in the installing org after uninstallations of diff --git a/command-snapshot.json b/command-snapshot.json index ec872615..91947cc8 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -229,6 +229,7 @@ "releasenotesurl", "skipancestorcheck", "skipvalidation", + "asyncvalidation", "target-hub-org", "targetdevhubusername", "uninstallscript", @@ -258,6 +259,7 @@ "releasenotes-url", "skip-ancestor-check", "skip-validation", + "async-validation", "tag", "target-dev-hub", "uninstall-script", diff --git a/messages/package_version_create.md b/messages/package_version_create.md index 3f837ff9..d951c062 100644 --- a/messages/package_version_create.md +++ b/messages/package_version_create.md @@ -33,6 +33,10 @@ We don’t calculate code coverage for org-dependent unlocked packages, or for p <%= config.bin %> <%= command.id %> --path common --installation-key password123 --skip-validation +- Create a package version and perform package validations asynchronously: + + <%= config.bin %> <%= command.id %> --path common --installation-key password123 --async-validation + # flags.package.summary ID (starts with 0Ho) or alias of the package to create a version of. @@ -129,6 +133,14 @@ Skips validation of dependencies, package ancestors, and metadata during package Skipping validation suppresses errors that usually surface during package version creation. Instead, these errors surface at a later stage, such as installation or post-installation. If you encounter errors that are difficult to debug, retry package version creation without the --skip-validation parameter. +# flags.async-validation.summary + +Return a new package version before completing package validations. + +# flags.async-validation.description + +Specifying async validation returns the package version earlier in the process, allowing you to install and test the new version right away. If your development team is using continuous integration (CI) scripts, async validation can reduce your overall CI run time. + # flags.skip-ancestor-check.summary Overrides ancestry requirements, which allows you to specify a package ancestor that isn’t the highest released package version. @@ -199,6 +211,12 @@ Version create. %d minutes remaining until timeout. Create version status: %s +# packageVersionCreatePerformingValidations + +The validations for this package version are in progress, but you can now begin testing this package version. +To determine whether all package validations completed successfully, run sf package version create report and review the Async Validation Status. +Async validated package versions can be promoted only if all validations completed successfully. + # packageVersionCreateFinalStatus Create version status: %s diff --git a/schemas/package-version-create.json b/schemas/package-version-create.json index 0e762ba5..4cb32315 100644 --- a/schemas/package-version-create.json +++ b/schemas/package-version-create.json @@ -68,7 +68,8 @@ "VerifyingFeaturesAndSettings", "VerifyingDependencies", "VerifyingMetadata", - "FinalizingPackageVersion" + "FinalizingPackageVersion", + "PerformingValidations" ] } } diff --git a/src/commands/package/version/create.ts b/src/commands/package/version/create.ts index f61bf38d..5ab2952c 100644 --- a/src/commands/package/version/create.ts +++ b/src/commands/package/version/create.ts @@ -121,7 +121,15 @@ export class PackageVersionCreateCommand extends SfCommand { - if (data.Status !== Package2VersionStatus.success && data.Status !== Package2VersionStatus.error) { + if (data.Status !== Package2VersionStatus.success && data.Status !== Package2VersionStatus.error && data.Status !== Package2VersionStatus.performingValidations + ) { const status = messages.getMessage('packageVersionCreateWaitingStatus', [ data.remainingWaitTime.minutes, data.Status, @@ -251,6 +260,18 @@ export class PackageVersionCreateCommand extends SfCommand `${os.EOL}(${i + 1}) ${e}`).join(''), ]); + case Package2VersionStatus.performingValidations: + this.log(messages.getMessage('packageVersionCreatePerformingValidations')); + this.log( + messages.getMessage(Package2VersionStatus.success, [ + result.Id, + result.SubscriberPackageVersionId, + INSTALL_URL_BASE.toString(), + result.SubscriberPackageVersionId, + this.config.bin, + ]) + ); + break; case Package2VersionStatus.success: this.log( messages.getMessage(result.Status, [