diff --git a/src/commands/package/convert.ts b/src/commands/package/convert.ts index 0629c6b6..11911273 100644 --- a/src/commands/package/convert.ts +++ b/src/commands/package/convert.ts @@ -13,6 +13,7 @@ import { PackageEvents, PackageVersionCreateEventData, PackageVersionCreateRequestResult, + PackagingSObjects, } from '@salesforce/packaging'; import { camelCaseToTitleCase, Duration } from '@salesforce/kit'; import { requiredHubFlag } from '../../utils/hubFlag'; @@ -128,10 +129,10 @@ export class PackageConvert extends SfCommand ); switch (result.Status) { - case 'Error': + case PackagingSObjects['Package2VersionStatus'].error: this.spinner.stop(); throw new SfError(result.Error?.join('\n') ?? pvcMessages.getMessage('unknownError')); - case 'Success': { + case PackagingSObjects['Package2VersionStatus'].success: { const successMessage = pvcMessages.getMessage(result.Status, [ result.Id, result.SubscriberPackageVersionId, diff --git a/src/commands/package/version/create.ts b/src/commands/package/version/create.ts index 442b677e..c05bcb85 100644 --- a/src/commands/package/version/create.ts +++ b/src/commands/package/version/create.ts @@ -243,11 +243,11 @@ export class PackageVersionCreateCommand extends SfCommand `${os.EOL}(${i + 1}) ${e}`).join(''), ]); - case 'Success': + case Package2VersionStatus.success: this.log( messages.getMessage(result.Status, [ result.Id, diff --git a/test/commands/package/packageVersion.nut.ts b/test/commands/package/packageVersion.nut.ts index 035d417b..68a70f06 100644 --- a/test/commands/package/packageVersion.nut.ts +++ b/test/commands/package/packageVersion.nut.ts @@ -114,14 +114,15 @@ describe('package:version:*', () => { const project = await SfProject.resolve(); const projectJson = project.getSfProjectJson(); const contents = projectJson.getContents(); - const packageDir = contents.packageDirectories.find((pkgDir) => pkgDir.package === pkgName); - if (packageDir) { - packageDir.package = packageId; - } else { + if (!contents.packageDirectories.some((pkgDir) => pkgDir.package === packageId)) { expect.fail('packageDirectory not found'); } - projectJson.setContents(contents); - projectJson.writeSync(contents); + const newPackageDirs = contents.packageDirectories.map((pkgDir) => + pkgDir.package === pkgName ? { ...pkgDir, package: packageId } : pkgDir + ); + + projectJson.set('packageDirectories', newPackageDirs); + projectJson.writeSync(); execCmd(`package:version:create --package ${packageId} -x --json`, { ensureExitCode: 0 }); }); });