Skip to content

Commit

Permalink
feat: async validation for package version create
Browse files Browse the repository at this point in the history
  • Loading branch information
mradulsf committed Jun 11, 2024
1 parent 1b36ae7 commit 19357af
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ Create a package version in the Dev Hub org.
```
USAGE
$ sf package version create -v <value> [--json] [--flags-dir <value>] [--api-version <value>] [-b <value>] [-c |
--skip-validation] [-f <value>] [-k <value>] [-x] [-p <value>] [-d <value>] [--post-install-script <value>]
--skip-validation | --async-validation] [-f <value>] [-k <value>] [-x] [-p <value>] [-d <value>] [--post-install-script <value>]
[--post-install-url <value>] [--releasenotes-url <value>] [--skip-ancestor-check] [-t <value>] [--uninstall-script
<value>] [-e <value>] [-a <value>] [-n <value>] [-w <value>] [--language <value>] [--verbose]
Expand Down Expand Up @@ -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=<value> Uninstall script name; applies to managed packages only.
--verbose Display verbose command output.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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=<value> 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
Expand Down
2 changes: 2 additions & 0 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
"releasenotesurl",
"skipancestorcheck",
"skipvalidation",
"asyncvalidation",
"target-hub-org",
"targetdevhubusername",
"uninstallscript",
Expand Down Expand Up @@ -258,6 +259,7 @@
"releasenotes-url",
"skip-ancestor-check",
"skip-validation",
"async-validation",
"tag",
"target-dev-hub",
"uninstall-script",
Expand Down
18 changes: 18 additions & 0 deletions messages/package_version_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion schemas/package-version-create.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"VerifyingFeaturesAndSettings",
"VerifyingDependencies",
"VerifyingMetadata",
"FinalizingPackageVersion"
"FinalizingPackageVersion",
"PerformingValidations"
]
}
}
Expand Down
25 changes: 23 additions & 2 deletions src/commands/package/version/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,15 @@ export class PackageVersionCreateCommand extends SfCommand<PackageVersionCommand
summary: messages.getMessage('flags.skip-validation.summary'),
description: messages.getMessage('flags.skip-validation.description'),
default: false,
exclusive: ['code-coverage'],
exclusive: ['code-coverage', 'async-validation'],
}),
'async-validation': Flags.boolean({
deprecateAliases: true,
aliases: ['asyncvalidation'],
summary: messages.getMessage('flags.async-validation.summary'),
description: messages.getMessage('flags.async-validation.description'),
default: false,
exclusive: ['skip-validation'],
}),
tag: Flags.string({
char: 't',
Expand Down Expand Up @@ -193,7 +201,8 @@ export class PackageVersionCreateCommand extends SfCommand<PackageVersionCommand
// no async methods
// eslint-disable-next-line @typescript-eslint/require-await
async (data: PackageVersionCreateReportProgress) => {
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,
Expand Down Expand Up @@ -251,6 +260,18 @@ export class PackageVersionCreateCommand extends SfCommand<PackageVersionCommand
throw messages.createError('multipleErrors', [
result.Error?.map((e: string, i) => `${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, [
Expand Down

0 comments on commit 19357af

Please sign in to comment.