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
10 changes: 10 additions & 0 deletions packages/aws-cdk/lib/cli/cdk-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ export class CdkToolkit {
return this.watch(options);
}

// set progress from options, this includes user and app config
if (options.progress) {
this.ioHost.stackProgress = options.progress;
}

const startSynthTime = new Date().getTime();
const stackCollection = await this.selectStacksForDeploy(
options.selector,
Expand Down Expand Up @@ -760,6 +765,11 @@ export class CdkToolkit {
public async import(options: ImportOptions) {
const stacks = await this.selectStacksForDeploy(options.selector, true, true, false);

// set progress from options, this includes user and app config
if (options.progress) {
this.ioHost.stackProgress = options.progress;
}

if (stacks.stackCount > 1) {
throw new ToolkitError(
`Stack selection is ambiguous, please choose a specific stack for import [${stacks.stackArtifacts.map((x) => x.id).join(', ')}]`,
Expand Down
32 changes: 31 additions & 1 deletion packages/aws-cdk/test/cli/cdk-toolkit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import {
restoreSdkMocksToDefault,
} from '../util/mock-sdk';
import { asIoHelper } from '../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/private';
import { StackActivityProgress } from '../../lib/commands/deploy';

markTesting();

Expand Down Expand Up @@ -615,7 +616,6 @@ describe('deploy', () => {
expect(mockSynthesize).not.toHaveBeenCalled();
});


describe('readCurrentTemplate', () => {
let template: any;
let mockCloudExecutable: MockCloudExecutable;
Expand Down Expand Up @@ -1009,6 +1009,36 @@ describe('deploy', () => {
);
});
});

test('can set progress via options', async () => {
const ioHost = CliIoHost.instance();

// Ensure environment allows StackActivityProgress.BAR
ioHost.stackProgress = StackActivityProgress.BAR;
ioHost.isTTY = true;
ioHost.isCI = false;
expect(ioHost.stackProgress).toBe('bar');

const toolkit = new CdkToolkit({
ioHost,
cloudExecutable,
configuration: cloudExecutable.configuration,
sdkProvider: cloudExecutable.sdkProvider,
deployments: new FakeCloudFormation({}),
});

// check this hasn't changed yet
expect(ioHost.stackProgress).toBe('bar');

await toolkit.deploy({
progress: StackActivityProgress.EVENTS,
selector: { patterns: ["**"] },
hotswap: HotswapMode.FALL_BACK
});

// now expect it to be updated
expect(ioHost.stackProgress).toBe('events');
});
});

describe('destroy', () => {
Expand Down