diff --git a/src/commands/package/convert.ts b/src/commands/package/convert.ts index 05093b8f..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, @@ -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 ); 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';