Skip to content

Commit

Permalink
fix: add spinner and fix perserve file location msg
Browse files Browse the repository at this point in the history
@W-11644909@
  • Loading branch information
peternhale committed Aug 26, 2022
1 parent ab11694 commit 7d732ae
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
10 changes: 9 additions & 1 deletion messages/package_version_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,12 @@ The %s value "%s" from the command line or sfdx-project.json is not in the corre

# requestInProgress

Request in progress. Sleeping %s seconds. Will wait a total of %s more seconds before timing out. Current Status=%s.
Version create.

# packageVersionCreateWaitingStatus

%d minutes remaining until timeout. Create version status: %s

# packageVersionCreateFinalStatus

Create version status: %s
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@salesforce/command": "^5.2.6",
"@salesforce/core": "^3.26.2",
"@salesforce/kit": "^1.6.0",
"@salesforce/packaging": "^0.0.25",
"@salesforce/packaging": "^0.0.27",
"tslib": "^2",
"chalk": "^4.1.2"
},
Expand Down
17 changes: 12 additions & 5 deletions src/commands/force/package/beta/version/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,18 @@ export class PackageVersionCreateCommand extends SfdxCommand {
// eslint-disable-next-line @typescript-eslint/require-await
Lifecycle.getInstance().on('in-progress', async (data: PackageVersionCreateReportProgress) => {
if (data.Status !== Package2VersionStatus.success && data.Status !== Package2VersionStatus.error) {
this.ux.log(
messages.getMessage('requestInProgress', [frequency.seconds, data.remainingWaitTime.seconds, data.Status])
this.ux.setSpinnerStatus(
messages.getMessage('packageVersionCreateWaitingStatus', [data.remainingWaitTime.minutes, data.Status])
);
}
});
Lifecycle.getInstance().on(
'packageVersionCreate:preserveFiles',
// eslint-disable-next-line @typescript-eslint/require-await
async (data: { location: string; message: string }) => {
this.ux.log(messages.getMessage('tempFileLocation', [data.location]));
}
);

// resolve the package id from the --package flag, first checking if it's an alias, then using the flag (an id), and then looking for the package name from the --path flag
let packageName: string;
Expand All @@ -179,18 +186,18 @@ export class PackageVersionCreateCommand extends SfdxCommand {
const packageId = getPackageIdFromAlias(packageName, this.project);

const pv = new PackageVersion({ project: this.project, connection: this.hubOrg.getConnection() });
this.ux.startSpinner(messages.getMessage('requestInProgress'));
const result = await pv.create(
{ ...this.flags, ...{ packageId } },
{
timeout: this.flags.wait as Duration,
frequency,
}
);

this.ux.stopSpinner(messages.getMessage('packageVersionCreateFinalStatus', [result.Status]));
switch (result.Status) {
case 'Error':
this.ux.log(messages.getMessage('unknownError', [result.Error.join('\n')]));
break;
throw messages.createError('unknownError', [result.Error.join('\n')]);
case 'Success':
this.ux.log(
messages.getMessage(result.Status, [
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1150,10 +1150,10 @@
shx "^0.3.3"
tslib "^2.2.0"

"@salesforce/packaging@^0.0.25":
version "0.0.25"
resolved "https://registry.yarnpkg.com/@salesforce/packaging/-/packaging-0.0.25.tgz#6004d86c46a13076dd8bc3e4404205d1add1cf5f"
integrity sha512-SQ8NuoTjXZ3Qnja1e2xODDdX32181AGZo+KhcedJQozKO1a09/wkbkNJqxAI/db4+TEJUM4nlT6D73cpY1SywA==
"@salesforce/packaging@^0.0.27":
version "0.0.27"
resolved "https://registry.yarnpkg.com/@salesforce/packaging/-/packaging-0.0.27.tgz#4db9480024288a26f2549e4f3b7a7ddc20e62808"
integrity sha512-1hMGLD32zH/VCEik5wLVPXqQ7y6NHwvTsC5uKurCdvqjLjP3NuJQaSTXInaP3uXSttgmsy+XIsDlmp4f3aLtpw==
dependencies:
"@salesforce/core" "^3.26.2"
"@salesforce/kit" "^1.6.0"
Expand Down

0 comments on commit 7d732ae

Please sign in to comment.