Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clone sfdx-project.json deps to avoid writing back to the file #117

Merged
merged 7 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@
"publishConfig": {
"access": "public"
}
}
}
3 changes: 2 additions & 1 deletion src/package/packageVersionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ComponentSetBuilder, ConvertResult, MetadataConverter } from '@salesfor
import SettingsGenerator from '@salesforce/core/lib/org/scratchOrgSettingsGenerator';
import * as xml2js from 'xml2js';
import { PackageDirDependency } from '@salesforce/core/lib/sfProject';
import { cloneJson } from '@salesforce/kit';
import * as pkgUtils from '../utils/packageUtils';
import {
MDFolderForArtifactOptions,
Expand Down Expand Up @@ -371,7 +372,7 @@ export class PackageVersionCreate {

// All dependencies for the packaging dir should be resolved to an 04t id to be passed to the server.
// (see _retrieveSubscriberPackageVersionId for details)
const dependencies = packageDescriptorJson.dependencies;
const dependencies = packageDescriptorJson.dependencies ? cloneJson(packageDescriptorJson.dependencies) : [];

// branch can be set via options or descriptor; option takes precedence
this.options.branch = this.options.branch ?? packageDescriptorJson.branch;
Expand Down
21 changes: 21 additions & 0 deletions test/package/packageVersionCreate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,33 @@ describe('Package Version Create', () => {
project = SfProject.getInstance();
await project.getSfProjectJson().write({
packageDirectories: [
{
path: 'pkg',
package: 'dep',
versionName: 'ver 0.1',
versionNumber: '0.1.0.NEXT',
default: false,
name: 'pkg',
},
{
path: 'force-app',
package: 'TEST',
versionName: 'ver 0.1',
versionNumber: '0.1.0.NEXT',
default: true,
ancestorId: 'TEST2',
dependencies: [
{
package: '[email protected]',
},
],
},
],
packageAliases: {
TEST: packageId,
TEST2: '05i3i000000Gmj6XXX',
DEP: '05i3i000000Gmj6XXX',
'[email protected]': '04t3i000002eyYXXXX',
},
});
await fs.promises.mkdir(path.join(project.getPath(), 'force-app'));
Expand Down Expand Up @@ -117,6 +132,12 @@ describe('Package Version Create', () => {
'SubscriberPackageVersionId',
'Tag'
);

expect(project.getSfProjectJson().getContents().packageDirectories[1].dependencies).to.deep.equal([
{
package: '[email protected]',
},
]);
});

it('should create the package version create request with codecoverage=true', async () => {
Expand Down