Skip to content
Open
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
4 changes: 4 additions & 0 deletions messages/bundle_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Number of minutes to wait for the installation to complete.

Display extended installation detail.

# flags.installation-key.summary

Installation key for key-protected bundle.

# requestInProgress

Installing bundle.
Expand Down
4 changes: 4 additions & 0 deletions messages/bundle_version_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Version number of the package bundle version to be created; overrides the sfdx-p

Description of the package bundle version.

# flags.installation-key.summary

Installation key for key-protected bundle.

# bundleVersionCreateWaitingStatus

Waiting for bundle version creation to complete. %s minutes remaining. Current status: %s
Expand Down
5 changes: 5 additions & 0 deletions src/commands/package/bundle/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export class PackageBundlesInstall extends SfCommand<BundleSObjects.PkgBundleVer
startsWith: '00D',
required: true,
}),
'installation-key': Flags.string({
char: 'k',
summary: messages.getMessage('flags.installation-key.summary'),
}),
wait: Flags.integer({
char: 'w',
summary: messages.getMessage('flags.wait.summary'),
Expand All @@ -75,6 +79,7 @@ export class PackageBundlesInstall extends SfCommand<BundleSObjects.PkgBundleVer
project: this.project!,
PackageBundleVersion: flags.bundle,
DevelopmentOrganization: flags['dev-hub-org'],
InstallationKey: flags['installation-key'],
};

// Set up lifecycle events for progress tracking
Expand Down
5 changes: 5 additions & 0 deletions src/commands/package/bundle/version/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export class PackageBundlesCreate extends SfCommand<BundleSObjects.PackageBundle
summary: messages.getMessage('flags.definition-file.summary'),
required: true,
}),
'installation-key': Flags.string({
char: 'k',
summary: messages.getMessage('flags.installation-key.summary'),
}),
'target-dev-hub': requiredHubFlag,
'api-version': orgApiVersionFlagWithDeprecations,
wait: Flags.integer({
Expand Down Expand Up @@ -91,6 +95,7 @@ export class PackageBundlesCreate extends SfCommand<BundleSObjects.PackageBundle
MajorVersion: majorVersion,
MinorVersion: minorVersion,
Ancestor: '',
InstallationKey: flags['installation-key'],
};

Lifecycle.getInstance().on(
Expand Down
27 changes: 27 additions & 0 deletions test/commands/bundle/bundleInstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,33 @@ describe('package:bundle:install - tests', () => {
expect(logStub.args[0]).to.deep.equal(['Successfully installed bundle version 1Q83i000000fxw1AAA to test@org.org']);
});

it('should install a package bundle version with installation key', async () => {
installStub = $$.SANDBOX.stub(PackageBundleInstall, 'installBundle');
installStub.resolves(pkgBundleInstallSuccessResult);

const cmd = new PackageBundlesInstall(
['-b', 'TestBundle@1.0', '--target-org', 'test@org.org', '--dev-hub-org', '00D3i000000TNHYCA4', '-k', 'mySecretKey123'],
config
);
stubSpinner(cmd);
const res = await cmd.run();
expect(res).to.deep.equal({
Id: '08c3i000000fylgAAA',
InstallStatus: 'Success',
PackageBundleVersionId: '1Q83i000000fxw1AAA',
DevelopmentOrganization: '00D3i000000TNHYCA4',
ValidationError: '',
CreatedDate: '2022-11-03 09:46',
CreatedById: '0053i000001ZIyGAAW',
Error: [],
});
expect(warnStub.callCount).to.equal(0);
expect(logStub.callCount).to.equal(1);
expect(logStub.args[0]).to.deep.equal(['Successfully installed bundle version 1Q83i000000fxw1AAA to test@org.org']);
// Verify that the installBundle function was called with the installation key
expect(installStub.firstCall.args[2]).to.have.property('InstallationKey', 'mySecretKey123');
});

it('should handle queued status', async () => {
installStub = $$.SANDBOX.stub(PackageBundleInstall, 'installBundle');
installStub.resolves(pkgBundleInstallQueuedResult);
Expand Down
31 changes: 31 additions & 0 deletions test/commands/bundle/packageBundleVersionCreate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,37 @@ describe('package:bundle:version:create - tests', () => {
expect(logStub.args[0]).to.deep.equal(['Successfully created bundle version with ID 05i3i000000fxw1AAA']);
});

it('should create a new package bundle version with installation key', async () => {
createStub = $$.SANDBOX.stub(PackageBundleVersion, 'create');
createStub.resolves(pkgBundleVersionCreateSuccessResult);

const cmd = new PackageBundlesCreate(
['-b', 'TestBundle', '-p', 'path/to/definition.json', '-k', 'mySecretKey123', '--target-dev-hub', 'test@hub.org'],
config
);
stubSpinner(cmd);
const res = await cmd.run();
expect(res).to.deep.equal({
Id: '08c3i000000fylgAAA',
RequestStatus: 'Success',
PackageBundleId: '0Ho3i000000TNHYCA4',
PackageBundleVersionId: '05i3i000000fxw1AAA',
VersionName: 'TestBundle@1.0',
MajorVersion: '1',
MinorVersion: '0',
BundleVersionComponents: '[{"packageId": "0Ho3i000000TNHYCA4", "versionNumber": "1.0.0"}]',
Error: [],
CreatedDate: '2022-11-03 09:46',
CreatedById: '0053i000001ZIyGAAW',
Ancestor: null,
});
expect(warnStub.callCount).to.equal(0);
expect(logStub.callCount).to.equal(1);
expect(logStub.args[0]).to.deep.equal(['Successfully created bundle version with ID 05i3i000000fxw1AAA']);
// Verify that the create function was called with the installation key
expect(createStub.firstCall.args[0]).to.have.property('InstallationKey', 'mySecretKey123');
});

it('should handle queued status', async () => {
createStub = $$.SANDBOX.stub(PackageBundleVersion, 'create');
createStub.resolves(pkgBundleVersionCreateQueuedResult);
Expand Down
Loading