diff --git a/packages/@aws-cdk-testing/cli-integ/lib/with-cli-no-stacks.ts b/packages/@aws-cdk-testing/cli-integ/lib/with-cli-no-stacks.ts index 625af386db31a..7d95eb9f1d41d 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/with-cli-no-stacks.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/with-cli-no-stacks.ts @@ -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(block: (context: CliLibIntegrationTestFixture) => Promise) { +export function withCliLibNoStacksIntegrationCdkApp +(block: (context:CliLibNoStacksIntegrationTestFixture) => Promise) { return async (context: A) => { const randy = context.randomString; const stackNamePrefix = `cdktest-${randy}`; @@ -20,7 +21,7 @@ export function withCliLibIntegrationCdkApp( 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, @@ -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) { - return withAws(withTimeout(DEFAULT_TEST_TIMEOUT_S, withCliLibIntegrationCdkApp(block))); +export function withCliLibNoStacksFixture(block: (context: CliLibNoStacksIntegrationTestFixture) => Promise) { + return withAws(withTimeout(DEFAULT_TEST_TIMEOUT_S, withCliLibNoStacksIntegrationCdkApp(block))); } -export class CliLibIntegrationTestFixture extends TestFixture { +export class CliLibNoStacksIntegrationTestFixture extends TestFixture { /** * */ diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli-lib.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli-lib.integtest.ts index 6a72987783691..c6d93177415db 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli-lib.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli-lib.integtest.ts @@ -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 @@ -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 { diff --git a/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts b/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts index 3637c61879d7e..c797e3a3492c4 100644 --- a/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts +++ b/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts @@ -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 */ @@ -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) { diff --git a/packages/aws-cdk/lib/api/deploy-stack.ts b/packages/aws-cdk/lib/api/deploy-stack.ts index 2db9ffda5d51f..c4dcf03c5b1ef 100644 --- a/packages/aws-cdk/lib/api/deploy-stack.ts +++ b/packages/aws-cdk/lib/api/deploy-stack.ts @@ -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 */ diff --git a/packages/aws-cdk/lib/api/deployments.ts b/packages/aws-cdk/lib/api/deployments.ts index ffbd72b8af244..196c3fae3a999 100644 --- a/packages/aws-cdk/lib/api/deployments.ts +++ b/packages/aws-cdk/lib/api/deployments.ts @@ -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 */ diff --git a/packages/aws-cdk/lib/cdk-toolkit.ts b/packages/aws-cdk/lib/cdk-toolkit.ts index 7f5b001a8d87e..9ef39c8a0e423 100644 --- a/packages/aws-cdk/lib/cdk-toolkit.ts +++ b/packages/aws-cdk/lib/cdk-toolkit.ts @@ -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)); @@ -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 { + private async selectStacksForDeploy(selector: StackSelector, exclusively?: boolean, + cacheCloudAssembly?: boolean, ignoreNoStacks?: boolean): Promise { const assembly = await this.assembly(cacheCloudAssembly); const stacks = await assembly.selectStacks(selector, { extend: exclusively ? ExtendedStackSelection.None : ExtendedStackSelection.Upstream, @@ -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 */ diff --git a/packages/aws-cdk/lib/cli.ts b/packages/aws-cdk/lib/cli.ts index 03ecc4480b826..c872109a423c5 100644 --- a/packages/aws-cdk/lib/cli.ts +++ b/packages/aws-cdk/lib/cli.ts @@ -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 })