Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this boolean actually doing anything? I don't see it referenced in your PR besides the unit test

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used within logic that's in the sf-plugins-core. When the parameter is true, then during the command initialization we attempt to resolve an sf project directory from the current working directory. If it doesn't exist then an error is thrown. This does bring up that the point that the unit test is not particularly useful.

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