From f60e6e9b6f761aa170113399bb288311a142142b Mon Sep 17 00:00:00 2001 From: Parker Scanlon <69879391+scanlonp@users.noreply.github.com> Date: Mon, 25 Mar 2024 11:37:42 -0700 Subject: [PATCH] revert: "feat(cli): warn of non-existent stacks in `cdk destroy`" (#29577) Reverts aws/aws-cdk#27921 Failing in the test pipeline on [this test](https://github.com/aws/aws-cdk/blob/07ce8ecc42782475d099b89944571375341c28d3/packages/%40aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts#L190) where it was not erroring out as it should have. [The error here](https://github.com/aws/aws-cdk/blob/07ce8ecc42782475d099b89944571375341c28d3/packages/aws-cdk/lib/api/cxapp/cloud-executable.ts#L86) is not being thrown. --- packages/aws-cdk/lib/cdk-toolkit.ts | 42 +---------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/packages/aws-cdk/lib/cdk-toolkit.ts b/packages/aws-cdk/lib/cdk-toolkit.ts index c460f72ce80c4..e2614a3710aad 100644 --- a/packages/aws-cdk/lib/cdk-toolkit.ts +++ b/packages/aws-cdk/lib/cdk-toolkit.ts @@ -4,9 +4,7 @@ import * as cxapi from '@aws-cdk/cx-api'; import * as chalk from 'chalk'; import * as chokidar from 'chokidar'; import * as fs from 'fs-extra'; -import { minimatch } from 'minimatch'; import * as promptly from 'promptly'; -import * as semver from 'semver'; import * as uuid from 'uuid'; import { DeploymentMethod } from './api'; import { SdkProvider } from './api/aws-auth'; @@ -31,7 +29,6 @@ import { validateSnsTopicArn } from './util/validate-notification-arn'; import { Concurrency, WorkGraph } from './util/work-graph'; import { WorkGraphBuilder } from './util/work-graph-builder'; import { AssetBuildNode, AssetPublishNode, StackNode } from './util/work-graph-types'; -import { versionNumber } from './version'; import { environmentsFromDescriptors, globEnvironmentsFromStacks, looksLikeGlob } from '../lib/api/cxapp/environments'; export interface CdkToolkitProps { @@ -617,9 +614,6 @@ export class CdkToolkit { stacks = stacks.reversed(); if (!options.force) { - if (stacks.stackArtifacts.length === 0) { - return; - } // eslint-disable-next-line max-len const confirmed = await promptly.confirm(`Are you sure you want to delete: ${chalk.blue(stacks.stackArtifacts.map(s => s.hierarchicalId).join(', '))} (y/n)?`); if (!confirmed) { @@ -913,43 +907,9 @@ export class CdkToolkit { extend: exclusively ? ExtendedStackSelection.None : ExtendedStackSelection.Downstream, defaultBehavior: DefaultSelection.OnlySingle, }); - const selectorWithoutPatterns: StackSelector = { - ...selector, - allTopLevel: true, - patterns: [], - }; - const stacksWithoutPatterns = await assembly.selectStacks(selectorWithoutPatterns, { - extend: exclusively ? ExtendedStackSelection.None : ExtendedStackSelection.Downstream, - defaultBehavior: DefaultSelection.OnlySingle, - }); - const patterns = selector.patterns.map(pattern => { - const notExist = !stacks.stackArtifacts.find(stack => - minimatch(stack.hierarchicalId, pattern) || (stack.id === pattern && semver.major(versionNumber()) < 2), - ); - - const closelyMatched = notExist ? stacksWithoutPatterns.stackArtifacts.map(stack => { - if (minimatch(stack.hierarchicalId.toLowerCase(), pattern.toLowerCase())) { - return stack.hierarchicalId; - } - if (stack.id.toLowerCase() === pattern.toLowerCase() && semver.major(versionNumber()) < 2) { - return stack.id; - } - return; - }).filter((stack): stack is string => stack !== undefined) : []; - return { - pattern, - notExist, - closelyMatched, - }; - }); + // No validation - patterns.forEach(pattern => { - if (pattern.notExist) { - const closelyMatched = pattern.closelyMatched.length > 0 ? ` Do you mean ${pattern.closelyMatched.join(', ')}?` : ''; - warning(`${pattern.pattern} does not exist.${closelyMatched}`); - } - }); return stacks; }