Skip to content

Commit

Permalink
add feedback from luca
Browse files Browse the repository at this point in the history
  • Loading branch information
msambol committed Dec 22, 2023
1 parent 03c1447 commit b42cb06
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
11 changes: 6 additions & 5 deletions packages/@aws-cdk-testing/cli-integ/lib/with-cli-no-stacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { withTimeout } from './with-timeout';
/**
* Higher order function to execute a block with a CliLib Integration CDK app fixture
*/
export function withCliLibIntegrationCdkApp<A extends TestContext & AwsContext>(block: (context: CliLibIntegrationTestFixture) => Promise<void>) {
export function withCliLibNoStacksIntegrationCdkApp<A extends TestContext & AwsContext>
(block: (context:CliLibNoStacksIntegrationTestFixture) => Promise<void>) {
return async (context: A) => {
const randy = context.randomString;
const stackNamePrefix = `cdktest-${randy}`;
Expand All @@ -20,7 +21,7 @@ export function withCliLibIntegrationCdkApp<A extends TestContext & AwsContext>(
context.log(` Region: ${context.aws.region}\n`);

await cloneDirectory(path.join(RESOURCES_DIR, 'cdk-apps', 'no-stack-app'), integTestDir, context.output);
const fixture = new CliLibIntegrationTestFixture(
const fixture = new CliLibNoStacksIntegrationTestFixture(
integTestDir,
stackNamePrefix,
context.output,
Expand Down Expand Up @@ -94,11 +95,11 @@ function errorCausedByGoPkg(error: string) {
/**
* SAM Integration test fixture for CDK - SAM integration test cases
*/
export function withCliLibFixture(block: (context: CliLibIntegrationTestFixture) => Promise<void>) {
return withAws(withTimeout(DEFAULT_TEST_TIMEOUT_S, withCliLibIntegrationCdkApp(block)));
export function withCliLibNoStacksFixture(block: (context: CliLibNoStacksIntegrationTestFixture) => Promise<void>) {
return withAws(withTimeout(DEFAULT_TEST_TIMEOUT_S, withCliLibNoStacksIntegrationCdkApp(block)));
}

export class CliLibIntegrationTestFixture extends TestFixture {
export class CliLibNoStacksIntegrationTestFixture extends TestFixture {
/**
*
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { integTest, withCliLibFixture } from '../../lib';
import { integTest, withCliLibFixture, withCliLibNoStacksFixture } from '../../lib';

jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime

Expand Down Expand Up @@ -47,7 +47,7 @@ integTest('cli-lib deploy', withCliLibFixture(async (fixture) => {
}
}));

integTest('cli-lib deploy no stack', withCliLibFixture(async (fixture) => {
integTest('cli-lib deploy no stack', withCliLibNoStacksFixture(async (fixture) => {
const stackName = fixture.fullStackName('no-stack-1');

try {
Expand Down
5 changes: 2 additions & 3 deletions packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface SelectStacksOptions {
defaultBehavior: DefaultSelection;

/**
* Ignore the error message if the app contains no stacks.
* Whether to deploy if the app contains no stacks.
*
* @default false
*/
Expand Down Expand Up @@ -109,9 +109,8 @@ export class CloudAssembly {
if (stacks.length === 0) {
if (options.ignoreNoStacks) {
return new StackCollection(this, []);
} else {
throw new Error('This app contains no stacks');
}
throw new Error('This app contains no stacks');
}

if (allTopLevel) {
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/deploy-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export interface DeployStackOptions {
readonly assetParallelism?: boolean;

/**
* Ignore the error message if the app contains no stacks.
* Whether to deploy if the app contains no stacks.
*
* @default false
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export interface DeployStackOptions {
readonly assetParallelism?: boolean;

/**
* Ignore the error message if the app contains no stacks.
* Whether to deploy if the app contains no stacks.
*
* @default false
*/
Expand Down
10 changes: 5 additions & 5 deletions packages/aws-cdk/lib/cdk-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ export class CdkToolkit {
}

const startSynthTime = new Date().getTime();
// eslint-disable-next-line max-len
const stackCollection = await this.selectStacksForDeploy(options.selector, options.exclusively, options.cacheCloudAssembly, options.ignoreNoStacks);
const stackCollection = await this.selectStacksForDeploy(options.selector, options.exclusively,
options.cacheCloudAssembly, options.ignoreNoStacks);
const elapsedSynthTime = new Date().getTime() - startSynthTime;
print('\n✨ Synthesis time: %ss\n', formatTime(elapsedSynthTime));

Expand Down Expand Up @@ -731,8 +731,8 @@ export class CdkToolkit {
return stacks;
}

// eslint-disable-next-line max-len
private async selectStacksForDeploy(selector: StackSelector, exclusively?: boolean, cacheCloudAssembly?: boolean, ignoreNoStacks?: boolean): Promise<StackCollection> {
private async selectStacksForDeploy(selector: StackSelector, exclusively?: boolean,
cacheCloudAssembly?: boolean, ignoreNoStacks?: boolean): Promise<StackCollection> {
const assembly = await this.assembly(cacheCloudAssembly);
const stacks = await assembly.selectStacks(selector, {
extend: exclusively ? ExtendedStackSelection.None : ExtendedStackSelection.Upstream,
Expand Down Expand Up @@ -1140,7 +1140,7 @@ export interface DeployOptions extends CfnDeployOptions, WatchOptions {
readonly assetBuildTime?: AssetBuildTime;

/**
* Ignore the error message if the app contains no stacks.
* Whether to deploy if the app contains no stacks.
*
* @default false
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async function parseCommandLineArguments(args: string[]) {
.option('concurrency', { type: 'number', desc: 'Maximum number of simultaneous deployments (dependency permitting) to execute.', default: 1, requiresArg: true })
.option('asset-parallelism', { type: 'boolean', desc: 'Whether to build/publish assets in parallel' })
.option('asset-prebuild', { type: 'boolean', desc: 'Whether to build all assets before deploying the first stack (useful for failing Docker builds)', default: true })
.option('ignore-no-stacks', { type: 'boolean', desc: 'Ignore the error message if the app contains no stacks', default: false }),
.option('ignore-no-stacks', { type: 'boolean', desc: 'Whether to deploy if the app contains no stacks', default: false }),
)
.command('import [STACK]', 'Import existing resource(s) into the given STACK', (yargs: Argv) => yargs
.option('execute', { type: 'boolean', desc: 'Whether to execute ChangeSet (--no-execute will NOT execute the ChangeSet)', default: true })
Expand Down

0 comments on commit b42cb06

Please sign in to comment.