Skip to content

Conversation

@btrn11
Copy link
Collaborator

@btrn11 btrn11 commented Aug 29, 2025

@W-19441295@

What does this PR do?

What issues does this PR fix or reference?

added the nessary commands to endit the sfdx json for bundle aliases and entries
…18671326/Package-Bundle-Create-command feat: added commands for bundles
@btrn11 btrn11 requested a review from a team as a code owner August 29, 2025 15:18
@btrn11 btrn11 changed the title Bundles CLI - sfdx-core @W-19441295 Bundles CLI - sfdx-core Aug 29, 2025
@btrn11 btrn11 requested a review from WillieRuemmele August 29, 2025 15:22
src/sfProject.ts Outdated
/**
* Has at least one package bundle alias defined in the project.
*/
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/require-await
Copy link
Member

Choose a reason for hiding this comment

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

Please add a return type, remove async if it's not required

return this.packageBundleAliases;
}

public getPackageBundleIdFromAlias(alias: string): Optional<string> {
Copy link
Member

Choose a reason for hiding this comment

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

might be an equivalent type, but this actually returns string | undefined

const json = await SfProjectJson.create();
json.set('packageBundleAliases', { MyName: 'someBundle' });
await json.write();
// @ts-expect-error possibly undefined
Copy link
Member

Choose a reason for hiding this comment

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

we can remove this directive by using a ! on the type where it's undefined, or by asserting that the response is defined.

consider this because you'll see this in the consuming code otherwise

it('should add a new package bundle when no package bundles exist', () => {
$$.setConfigStubContents('SfProjectJson', {
contents: {
packageBundles: [],
Copy link
Member

Choose a reason for hiding this comment

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

would this packageBundles key exist before package bundles exist, what about the case when there's nothing new in sfdx-project.json?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added a new test case

project.getSfProjectJson().addPackageBundle({
name: 'testBundle',
versionName: 'testBundle',
versionNumber: '1.0.0.0',
Copy link
Member

Choose a reason for hiding this comment

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

could consider changing something in this one that you're adding (and asserting the new value is present), to ensure it's adding correctly

});

const project = SfProject.getInstance();
expect(project.getSfProjectJson().getPackageBundleAliases()).to.not.be.ok;
Copy link
Member

Choose a reason for hiding this comment

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

to.be.undefined

});

const project = SfProject.getInstance();
expect(project.getSfProjectJson().hasPackageBundleAliases()).to.not.be.false;
Copy link
Member

Choose a reason for hiding this comment

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

"'should return false no bundlealiases are defined'"

=>

to.not.be.false;

something isn't lining up here

});

const project = SfProject.getInstance();
expect(project.getSfProjectJson().hasPackageBundleAliases()).to.not.be.true;
Copy link
Member

Choose a reason for hiding this comment

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

same comment , why the double negatives? to.be.false?

alias1: '1Flxxxxxxxxxxxxxxx',
});
});
it('should not find id of alias by name when name not in aliases collection', () => {
Copy link
Member

Choose a reason for hiding this comment

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

"should not find id of aliias" => we're expecting the result to equal what it's defined as

src/sfProject.ts Outdated
* @param bundleEntry
*/
public addPackageBundle(bundleEntry: BundleEntry): void {
const bundles: BundleEntry[] = this.getPackageBundles();
Copy link
Member

Choose a reason for hiding this comment

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

we may be able to allow TS to infer this type : BundleEntry[] from the method returns, so try removing that and the type definition on 362 and see if it'll work

@btrn11 btrn11 requested a review from WillieRuemmele August 29, 2025 20:10
@WillieRuemmele WillieRuemmele merged commit fbcf39d into main Sep 2, 2025
127 of 133 checks passed
@WillieRuemmele WillieRuemmele deleted the packagingDistribution/packageBundles branch September 2, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

5 participants