Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/commands/package/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -37,6 +37,7 @@ export class PackageConvert extends SfCommand<PackageVersionCreateRequestResult>
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,
Expand Down Expand Up @@ -128,13 +129,7 @@ export class PackageConvert extends SfCommand<PackageVersionCreateRequestResult>
} 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']),
Expand All @@ -148,7 +143,7 @@ export class PackageConvert extends SfCommand<PackageVersionCreateRequestResult>
patchversion: flags['patch-version'] as string,
codecoverage: flags['code-coverage'] as boolean,
},
project
this.project
);

switch (result.Status) {
Expand Down
4 changes: 4 additions & 0 deletions test/commands/package/packageConvert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading