From 17fce00e4d4eaeefb16f806149ff372bfb2c5256 Mon Sep 17 00:00:00 2001 From: rpanguluri Date: Mon, 30 Mar 2026 16:03:00 -0700 Subject: [PATCH 1/3] 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 4a6eeb7b..51a4b49c 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 83ccd8d72d83f723e85a1b2b8c47ee030aeaf27b Mon Sep 17 00:00:00 2001 From: rpanguluri Date: Mon, 30 Mar 2026 16:49:55 -0700 Subject: [PATCH 2/3] 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 51a4b49c..286c3add 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) { From e0a31ea8337bca2a843a1c3e9da2a8bf4ec55a74 Mon Sep 17 00:00:00 2001 From: rpanguluri Date: Thu, 9 Apr 2026 12:19:18 -0700 Subject: [PATCH 3/3] test: remove uneeded test --- test/commands/package/packageConvert.test.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/commands/package/packageConvert.test.ts b/test/commands/package/packageConvert.test.ts index 3adf8701..dd5a1cc1 100644 --- a/test/commands/package/packageConvert.test.ts +++ b/test/commands/package/packageConvert.test.ts @@ -52,10 +52,6 @@ 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';