Skip to content
Merged
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
8 changes: 5 additions & 3 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@
"installationkeybypass",
"patchversion",
"target-hub-org",
"targetdevhubusername"
"targetdevhubusername",
"codecoverage"
],
"flagChars": ["a", "f", "k", "m", "p", "s", "v", "w", "x"],
"flagChars": ["a", "f", "k", "m", "p", "s", "v", "w", "x", "c"],
"flags": [
"api-version",
"build-instance",
Expand All @@ -83,7 +84,8 @@
"seed-metadata",
"target-dev-hub",
"verbose",
"wait"
"wait",
"code-coverage"
],
"plugin": "@salesforce/plugin-packaging"
},
Expand Down
12 changes: 11 additions & 1 deletion messages/package_convert.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ To retrieve details about a package version create request, including status and

To protect the contents of your package and to prevent unauthorized installation of your package, specify the --installation-key flag.

To promote a package version to released, you must use the --code-coverage parameter. The package must also meet the code coverage requirements.

To list package version creation requests in the org, run "<%= config.bin %> package version create list".

# examples
Expand Down Expand Up @@ -66,7 +68,7 @@ Display verbose command output.

# in-progress

Request in progress. Will wait a total of %s more seconds before timing out. Current Status='%s'.
Request in progress. Will wait a total of %s more seconds before timing out. Current Status='%s'.

# flags.seed-metadata.summary

Expand All @@ -83,3 +85,11 @@ Specific released patch version to be converted.
# flags.patch-version.description

Specify a released patch version as major.minor.patch to convert to a second-generation managed package version.

# flags.code-coverage.summary

Calculate and store the code coverage percentage by running the packaged Apex tests included in this package version.

# flags.code-coverage.description

Before you can promote and release a managed package version, the Apex code must meet a minimum 75% code coverage requirement.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@oclif/core": "^4",
"@salesforce/core": "^8.12.0",
"@salesforce/kit": "^3.2.3",
"@salesforce/packaging": "^4.6.0",
"@salesforce/packaging": "^4.7.0",
"@salesforce/sf-plugins-core": "^12.2.2",
"chalk": "^5.4.1"
},
Expand Down
7 changes: 7 additions & 0 deletions src/commands/package/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ export class PackageConvert extends SfCommand<PackageVersionCreateRequestResult>
deprecateAliases: true,
aliases: ['patchversion'],
}),
'code-coverage': Flags.boolean({
char: 'c',
summary: messages.getMessage('flags.code-coverage.summary'),
description: messages.getMessage('flags.code-coverage.description'),
default: false,
}),
};

public async run(): Promise<PackageVersionCreateRequestResult> {
Expand Down Expand Up @@ -131,6 +137,7 @@ export class PackageConvert extends SfCommand<PackageVersionCreateRequestResult>
buildInstance: flags['build-instance'] as string,
seedMetadata: flags['seed-metadata'] as string,
patchversion: flags['patch-version'] as string,
codecoverage: flags['code-coverage'] as boolean,
},
project
);
Expand Down
16 changes: 13 additions & 3 deletions test/commands/package/packageConvert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
import { expect } from 'chai';
import { MockTestOrgData, TestContext } from '@salesforce/core/testSetup';
import { Config } from '@oclif/core';
import { Package, PackageVersionCreateRequestResult, PackagingSObjects } from '@salesforce/packaging';
import {
Package,
PackageVersionCreateRequestResult,
PackagingSObjects,
type ConvertPackageOptions,
} from '@salesforce/packaging';
import sinon from 'sinon';
import { PackageConvert } from '../../../src/commands/package/convert.js';
import Package2VersionStatus = PackagingSObjects.Package2VersionStatus;
Expand Down Expand Up @@ -80,8 +85,10 @@ describe('package:convert', () => {
);
stubSpinner(cmd);
const result = await cmd.run();

expect(spinnerStartStub.called).to.be.true;
// Check that codecoverage was passed as false
const callArgs = convertStub.getCall(0).args[2] as ConvertPackageOptions;
expect(callArgs.codecoverage).to.equal(false);
expect(result).to.deep.equal(pvc);
});
it('starts package version create request (success)', async () => {
Expand Down Expand Up @@ -109,11 +116,14 @@ describe('package:convert', () => {
convertStub.restore();
convertStub = $$.SANDBOX.stub(Package, 'convert').resolves(pvc);
const cmd = new PackageConvert(
['-p', CONVERTED_FROM_PACKAGE_ID, '--installation-key', INSTALL_KEY, '-v', 'test@user.com'],
['-p', CONVERTED_FROM_PACKAGE_ID, '--installation-key', INSTALL_KEY, '-v', 'test@user.com', '-c'],
config
);
stubSpinner(cmd);
const result = await cmd.run();
// Check that codecoverage was passed as true
const callArgs = convertStub.getCall(0).args[2] as ConvertPackageOptions;
expect(callArgs.codecoverage).to.equal(true);
expect(result).to.deep.equal(pvc);
});
it('starts package version create request (error)', async () => {
Expand Down
Loading