Skip to content

Commit

Permalink
Remove special meaning and duplication of bundling stacks ['*']
Browse files Browse the repository at this point in the history
...in favor of defaulting to bundling for all stacks when a pattern
isn't supplied.
  • Loading branch information
stevehodgkiss committed Jul 20, 2022
1 parent 5556b60 commit a9a48a0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/core/lib/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1166,9 +1166,9 @@ export class Stack extends Construct implements ITaggable {
* Indicates whether the stack requires bundling or not
*/
public get bundlingRequired() {
const bundlingStacks: string[] = this.node.tryGetContext(cxapi.BUNDLING_STACKS) ?? ['*'];
const bundlingStacks: string[] | undefined = this.node.tryGetContext(cxapi.BUNDLING_STACKS);

if (bundlingStacks.length === 1 && bundlingStacks[0] === '*') {
if (!bundlingStacks) {
return true; // bundle all stacks if a stack pattern isn't supplied on the CLI
}

Expand Down
6 changes: 4 additions & 2 deletions packages/aws-cdk/lib/api/cxapp/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ export async function execProgram(aws: SdkProvider, config: Configuration): Prom
context[cxapi.DISABLE_ASSET_STAGING_CONTEXT] = true;
}

const bundlingStacks = config.settings.get(['bundlingStacks']) ?? ['*'];
context[cxapi.BUNDLING_STACKS] = bundlingStacks;
const bundlingStacks = config.settings.get(['bundlingStacks']);
if (bundlingStacks) {
context[cxapi.BUNDLING_STACKS] = bundlingStacks;
}

debug('context:', context);
env[cxapi.CONTEXT_ENV] = JSON.stringify(context);
Expand Down
10 changes: 4 additions & 6 deletions packages/aws-cdk/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,11 @@ export class Settings {
const tags = this.parseStringTagsListToObject(expectStringList(argv.tags));

// Determine bundling stacks
let bundlingStacks: string[];
let bundlingStacks: string[] | undefined;
if (BUNDLING_COMMANDS.includes(argv._[0])) {
// If we deploy, diff, synth or watch a list of stacks exclusively we skip
// bundling for all other stacks.
bundlingStacks = argv.exclusively
? argv.STACKS ?? ['*']
: ['*'];
// If we deploy, diff, synth or watch a list of stacks exclusively we skip
// bundling for all other stacks.
bundlingStacks = argv.exclusively ? argv.STACKS : undefined;
} else { // Skip bundling for all stacks
bundlingStacks = [];
}
Expand Down
10 changes: 5 additions & 5 deletions packages/aws-cdk/test/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,24 @@ test('bundling stacks defaults to an empty list', () => {
expect(settings.get(['bundlingStacks'])).toEqual([]);
});

test('bundling stacks defaults to * for deploy', () => {
test('bundling stacks defaults to undefined for deploy', () => {
// GIVEN
const settings = Settings.fromCommandLineArguments({
_: [Command.DEPLOY],
});

// THEN
expect(settings.get(['bundlingStacks'])).toEqual(['*']);
expect(settings.get(['bundlingStacks'])).toEqual(undefined);
});

test('bundling stacks defaults to * for watch', () => {
test('bundling stacks defaults to undefined for watch', () => {
// GIVEN
const settings = Settings.fromCommandLineArguments({
_: [Command.WATCH],
});

// THEN
expect(settings.get(['bundlingStacks'])).toEqual(['*']);
expect(settings.get(['bundlingStacks'])).toEqual(undefined);
});

test('bundling stacks with deploy exclusively', () => {
Expand Down Expand Up @@ -154,4 +154,4 @@ test('providing a build arg', () => {

// THEN
expect(settings.get(['build'])).toEqual('mvn package');
});
});

0 comments on commit a9a48a0

Please sign in to comment.