Skip to content

Commit f4ce9d9

Browse files
committed
fix(cli): cannot set progress via app or user configuration
1 parent f1ef615 commit f4ce9d9

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

packages/aws-cdk/lib/cli/cdk-toolkit.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ export class CdkToolkit {
287287
return this.watch(options);
288288
}
289289

290+
// set progress from options, this includes user and app config
291+
if (options.progress) {
292+
this.ioHost.stackProgress = options.progress;
293+
}
294+
290295
const startSynthTime = new Date().getTime();
291296
const stackCollection = await this.selectStacksForDeploy(
292297
options.selector,
@@ -753,6 +758,11 @@ export class CdkToolkit {
753758
public async import(options: ImportOptions) {
754759
const stacks = await this.selectStacksForDeploy(options.selector, true, true, false);
755760

761+
// set progress from options, this includes user and app config
762+
if (options.progress) {
763+
this.ioHost.stackProgress = options.progress;
764+
}
765+
756766
if (stacks.stackCount > 1) {
757767
throw new ToolkitError(
758768
`Stack selection is ambiguous, please choose a specific stack for import [${stacks.stackArtifacts.map((x) => x.id).join(', ')}]`,

packages/aws-cdk/test/cli/cdk-toolkit.test.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ import {
9797
restoreSdkMocksToDefault,
9898
} from '../util/mock-sdk';
9999
import { asIoHelper } from '../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/private';
100+
import { StackActivityProgress } from '../../lib/commands/deploy';
100101

101102
markTesting();
102103

@@ -615,7 +616,6 @@ describe('deploy', () => {
615616
expect(mockSynthesize).not.toHaveBeenCalled();
616617
});
617618

618-
619619
describe('readCurrentTemplate', () => {
620620
let template: any;
621621
let mockCloudExecutable: MockCloudExecutable;
@@ -1009,6 +1009,36 @@ describe('deploy', () => {
10091009
);
10101010
});
10111011
});
1012+
1013+
test('can set progress via options', async () => {
1014+
const ioHost = CliIoHost.instance();
1015+
1016+
// Ensure environment allows StackActivityProgress.BAR
1017+
ioHost.stackProgress = StackActivityProgress.BAR;
1018+
ioHost.isTTY = true;
1019+
ioHost.isCI = false;
1020+
expect(ioHost.stackProgress).toBe('bar');
1021+
1022+
const toolkit = new CdkToolkit({
1023+
ioHost,
1024+
cloudExecutable,
1025+
configuration: cloudExecutable.configuration,
1026+
sdkProvider: cloudExecutable.sdkProvider,
1027+
deployments: new FakeCloudFormation({}),
1028+
});
1029+
1030+
// check this hasn't changed yet
1031+
expect(ioHost.stackProgress).toBe('bar');
1032+
1033+
await toolkit.deploy({
1034+
progress: StackActivityProgress.EVENTS,
1035+
selector: { patterns: ["**"] },
1036+
hotswap: HotswapMode.FALL_BACK
1037+
});
1038+
1039+
// now expect it to be updated
1040+
expect(ioHost.stackProgress).toBe('events');
1041+
});
10121042
});
10131043

10141044
describe('destroy', () => {

0 commit comments

Comments
 (0)