From c557c6934309315e689cd0f23ca1c4b56a0fca93 Mon Sep 17 00:00:00 2001 From: rpanguluri Date: Mon, 30 Mar 2026 16:03:00 -0700 Subject: [PATCH 1/2] feat: fail fast logic for convert commands not run in project dir --- src/commands/package/convert.ts | 11 +++-------- test/commands/package/packageConvert.test.ts | 4 ++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/commands/package/convert.ts b/src/commands/package/convert.ts index 05093b8f..cd8c291b 100644 --- a/src/commands/package/convert.ts +++ b/src/commands/package/convert.ts @@ -37,6 +37,7 @@ export class PackageConvert extends SfCommand public static readonly examples = messages.getMessages('examples'); public static readonly deprecateAliases = true; public static readonly aliases = ['force:package:convert']; + public static readonly requiresProject = true; public static readonly flags = { loglevel, 'target-dev-hub': requiredHubFlag, @@ -128,13 +129,7 @@ export class PackageConvert extends SfCommand } else { this.spinner.start('Converting Package', 'Initializing'); } - // initialize the project instance if in a project - let project: SfProject | undefined; - try { - project = await SfProject.resolve(); - } catch (err) { - // ignore project is optional - } + const result = await Package.convert( flags.package, flags['target-dev-hub'].getConnection(flags['api-version']), @@ -148,7 +143,7 @@ export class PackageConvert extends SfCommand patchversion: flags['patch-version'] as string, codecoverage: flags['code-coverage'] as boolean, }, - project + this.project as SfProject ); switch (result.Status) { diff --git a/test/commands/package/packageConvert.test.ts b/test/commands/package/packageConvert.test.ts index dd5a1cc1..3adf8701 100644 --- a/test/commands/package/packageConvert.test.ts +++ b/test/commands/package/packageConvert.test.ts @@ -52,6 +52,10 @@ describe('package:convert', () => { $$.restore(); }); + it('should require an sfdx project', () => { + expect(PackageConvert.requiresProject).to.be.true; + }); + it('returns error for missing installationkey or installationkeybypass flag', async () => { const expectedErrorMsg = 'Exactly one of the following must be provided: --installation-key, --installation-key-bypass'; From 66e4c78b263f256a6d4880bf9ddb3d1a1b4ce3b9 Mon Sep 17 00:00:00 2001 From: rpanguluri Date: Mon, 30 Mar 2026 16:49:55 -0700 Subject: [PATCH 2/2] chore: remove uneeded type assertion --- src/commands/package/convert.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/package/convert.ts b/src/commands/package/convert.ts index cd8c291b..9fb92202 100644 --- a/src/commands/package/convert.ts +++ b/src/commands/package/convert.ts @@ -15,7 +15,7 @@ */ import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core'; -import { Lifecycle, Messages, SfError, SfProject } from '@salesforce/core'; +import { Lifecycle, Messages, SfError } from '@salesforce/core'; import { INSTALL_URL_BASE, Package, @@ -143,7 +143,7 @@ export class PackageConvert extends SfCommand patchversion: flags['patch-version'] as string, codecoverage: flags['code-coverage'] as boolean, }, - this.project as SfProject + this.project ); switch (result.Status) {