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
2 changes: 1 addition & 1 deletion messages/package.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Can't retrieve package metadata. To use this feature, you must first assign your

# downloadDeveloperPackageZipHasNoData

Can't retrieve package metadata. We're unable to retrieve metadata for the package version you specified. Retrieving package metadata is available to converted 2GP package versions only. If the package you specified is a converted 2GP package, try creating a new package version, and then retry retrieving the package metadata for the new package version. If your package is a 1GP, start by converting the package to 2GP, and then retry retrieving metadata from the converted 2GP package version.
Can't retrieve package metadata. Package metadata is only generated for converted 2GP package versions and versions created with the --generate-pkg-zip flag. To resolve, create a new package version and retry. For native 2GP packages, include the --generate-pkg-zip flag when creating the version. For 1GP packages, first convert them to 2GP.

# packagingNotEnabledOnOrg

Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/packagingInterfacesAndType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ export type PackageVersionCreateRequest = {
CalculateCodeCoverage: boolean;
SkipValidation: boolean;
AsyncValidation?: boolean;
IsDevUsePkgZipRequested?: boolean;
CalcTransitiveDependencies?: boolean;
};

Expand Down Expand Up @@ -388,6 +389,7 @@ export type PackageVersionCreateOptions = {
skipancestorcheck: boolean;
skipvalidation: boolean;
asyncvalidation: boolean;
generatepkgzip?: boolean;
sourceorg: string;
tag: string;
uninstallscript: string;
Expand Down
1 change: 1 addition & 0 deletions src/package/packageVersionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ export class PackageVersionCreate {
CalculateCodeCoverage: this.options.codecoverage ?? false,
SkipValidation: this.options.skipvalidation ?? false,
AsyncValidation: this.options.asyncvalidation ?? false,
IsDevUsePkgZipRequested: this.options.generatepkgzip ?? false,
Language: this.options.language, // note: the createRequest's Language corresponds to the AllPackageVersion's language
CalcTransitiveDependencies: this.packageObject.calculateTransitiveDependencies ?? false,
};
Expand Down
62 changes: 62 additions & 0 deletions test/package/packageVersionCreate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,20 @@ describe('Package Version Create', () => {
expect(result).to.have.all.keys(expectedKeys);
});

it('should create the package version create request with generatepkgzip', async () => {
const pvc = new PackageVersionCreate({
connection,
project,
generatepkgzip: true,
packageId,
});
stubConvert();

const result = await pvc.createPackageVersion();
expect(packageCreateStub.firstCall.args[1].IsDevUsePkgZipRequested).to.equal(true);
expect(result).to.have.all.keys(expectedKeys);
});

it('should create the package version create request with installationkey', async () => {
const pvc = new PackageVersionCreate({
connection,
Expand Down Expand Up @@ -456,6 +470,54 @@ describe('Package Version Create', () => {
expect(package2DescriptorJson).to.have.string('B2BBuyerPsl');
});

it('should set apexTestAccess permission sets in package2descriptor.json when codecoverage is enabled and specified in sfdx-project.json', async () => {
project.getSfProjectJson().set('packageDirectories', [
{
path: 'force-app',
package: 'TEST',
versionName: 'ver 0.1',
versionNumber: '0.1.0.NEXT',
default: true,
apexTestAccess: {
permissionSets: ['Test_Permission_Set', 'Another_Test_PermSet'],
permissionSetLicenses: ['TestPsl', 'AnotherTestPsl'],
},
},
]);

await project.getSfProjectJson().write();

const validationSpy = $$.SANDBOX.spy(project.getSfProjectJson(), 'schemaValidate');
const pvc = new PackageVersionCreate({
connection,
project,
validateschema: true,
packageId,
skipancestorcheck: true,
codecoverage: true, // Enable code coverage to process apexTestAccess
});
stubConvert();

const writeFileSpy = $$.SANDBOX.spy(fs.promises, 'writeFile');

const result = await pvc.createPackageVersion();
expect(validationSpy.callCount).to.equal(1);
expect(result).to.have.all.keys(expectedKeys);

const package2DescriptorJson = writeFileSpy.firstCall.args[1]; // package2-descriptor.json contents

// Verify that apexTestAccess was converted to permissionSetNames and permissionSetLicenseDeveloperNames
expect(package2DescriptorJson).to.have.string('permissionSetNames');
expect(package2DescriptorJson).to.have.string('permissionSetLicenseDeveloperNames');
expect(package2DescriptorJson).to.have.string('Test_Permission_Set');
expect(package2DescriptorJson).to.have.string('Another_Test_PermSet');
expect(package2DescriptorJson).to.have.string('TestPsl');
expect(package2DescriptorJson).to.have.string('AnotherTestPsl');

// Verify that apexTestAccess was removed from the descriptor (it's a client-only property)
expect(package2DescriptorJson).to.not.have.string('apexTestAccess');
});

it('should validate options when package type = unlocked (scripts) - postinstall script', async () => {
packageTypeQuery.restore();
// @ts-ignore
Expand Down