aws-cdk 2.1111.0 → 2.1112.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -349,8 +349,8 @@ var require_helpers = __commonJS({
349
349
  var ValidationError = exports2.ValidationError = /* @__PURE__ */ __name(function ValidationError2(message2, instance, schema, path43, name, argument) {
350
350
  if (Array.isArray(path43)) {
351
351
  this.path = path43;
352
- this.property = path43.reduce(function(sum3, item) {
353
- return sum3 + makeSuffix(item);
352
+ this.property = path43.reduce(function(sum5, item) {
353
+ return sum5 + makeSuffix(item);
354
354
  }, "instance");
355
355
  } else if (path43 !== void 0) {
356
356
  this.property = path43;
@@ -451,8 +451,8 @@ var require_helpers = __commonJS({
451
451
  this.options = options;
452
452
  if (Array.isArray(path43)) {
453
453
  this.path = path43;
454
- this.propertyPath = path43.reduce(function(sum3, item) {
455
- return sum3 + makeSuffix(item);
454
+ this.propertyPath = path43.reduce(function(sum5, item) {
455
+ return sum5 + makeSuffix(item);
456
456
  }, "instance");
457
457
  } else {
458
458
  this.propertyPath = path43;
@@ -3599,7 +3599,7 @@ var require_semver2 = __commonJS({
3599
3599
  // ../@aws-cdk/cloud-assembly-schema/cli-version.json
3600
3600
  var require_cli_version = __commonJS({
3601
3601
  "../@aws-cdk/cloud-assembly-schema/cli-version.json"(exports2, module2) {
3602
- module2.exports = { version: "2.1111.0" };
3602
+ module2.exports = { version: "2.1112.0" };
3603
3603
  }
3604
3604
  });
3605
3605
 
@@ -5957,11 +5957,11 @@ var init_metadata = __esm({
5957
5957
  "../@aws-cdk/cloud-assembly-api/lib/metadata.ts"() {
5958
5958
  "use strict";
5959
5959
  PATH_METADATA_KEY = "aws:cdk:path";
5960
- SynthesisMessageLevel = /* @__PURE__ */ ((SynthesisMessageLevel3) => {
5961
- SynthesisMessageLevel3["INFO"] = "info";
5962
- SynthesisMessageLevel3["WARNING"] = "warning";
5963
- SynthesisMessageLevel3["ERROR"] = "error";
5964
- return SynthesisMessageLevel3;
5960
+ SynthesisMessageLevel = /* @__PURE__ */ ((SynthesisMessageLevel5) => {
5961
+ SynthesisMessageLevel5["INFO"] = "info";
5962
+ SynthesisMessageLevel5["WARNING"] = "warning";
5963
+ SynthesisMessageLevel5["ERROR"] = "error";
5964
+ return SynthesisMessageLevel5;
5965
5965
  })(SynthesisMessageLevel || {});
5966
5966
  }
5967
5967
  });
@@ -57629,10 +57629,10 @@ var require_headers = __commonJS({
57629
57629
  }
57630
57630
  __name(indexOf, "indexOf");
57631
57631
  function cksum(block) {
57632
- let sum3 = 8 * 32;
57633
- for (let i10 = 0; i10 < 148; i10++) sum3 += block[i10];
57634
- for (let j10 = 156; j10 < 512; j10++) sum3 += block[j10];
57635
- return sum3;
57632
+ let sum5 = 8 * 32;
57633
+ for (let i10 = 0; i10 < 148; i10++) sum5 += block[i10];
57634
+ for (let j10 = 156; j10 < 512; j10++) sum5 += block[j10];
57635
+ return sum5;
57636
57636
  }
57637
57637
  __name(cksum, "cksum");
57638
57638
  function encodeOct(val, n10) {
@@ -57669,12 +57669,12 @@ var require_headers = __commonJS({
57669
57669
  if (positive) tuple.push(byte);
57670
57670
  else tuple.push(255 - byte);
57671
57671
  }
57672
- let sum3 = 0;
57672
+ let sum5 = 0;
57673
57673
  const l10 = tuple.length;
57674
57674
  for (i10 = 0; i10 < l10; i10++) {
57675
- sum3 += tuple[i10] * Math.pow(256, i10);
57675
+ sum5 += tuple[i10] * Math.pow(256, i10);
57676
57676
  }
57677
- return positive ? sum3 : -1 * sum3;
57677
+ return positive ? sum5 : -1 * sum5;
57678
57678
  }
57679
57679
  __name(parse256, "parse256");
57680
57680
  function decodeOct(val, offset, length) {
@@ -116043,7 +116043,7 @@ ${indent}${str}`;
116043
116043
  end
116044
116044
  } = flowChars;
116045
116045
  const strings = nodes.map((n10) => n10.str);
116046
- if (hasItemWithNewLine || strings.reduce((sum3, str2) => sum3 + str2.length + 2, 2) > _Collection.maxFlowStringSingleLineLength) {
116046
+ if (hasItemWithNewLine || strings.reduce((sum5, str2) => sum5 + str2.length + 2, 2) > _Collection.maxFlowStringSingleLineLength) {
116047
116047
  str = start;
116048
116048
  for (const s10 of strings) {
116049
116049
  str += s10 ? `
@@ -121557,6 +121557,8 @@ var init_span = __esm({
121557
121557
  spanId;
121558
121558
  startTime;
121559
121559
  timingMsgTemplate;
121560
+ counters = {};
121561
+ openTimers = /* @__PURE__ */ new Set();
121560
121562
  constructor(ioHelper, definition, makeHelper) {
121561
121563
  this.definition = definition;
121562
121564
  this.ioHelper = ioHelper;
@@ -121584,6 +121586,10 @@ var init_span = __esm({
121584
121586
  }
121585
121587
  async end(x10, y4) {
121586
121588
  const duration = this.time();
121589
+ for (const t10 of this.openTimers) {
121590
+ t10.stop();
121591
+ }
121592
+ this.openTimers.clear();
121587
121593
  const endInput = parseArgs(x10, y4);
121588
121594
  const endMsg = endInput.message ?? util2.format(this.timingMsgTemplate, this.definition.name, duration.asSec);
121589
121595
  const endPayload = endInput.payload;
@@ -121591,14 +121597,30 @@ var init_span = __esm({
121591
121597
  endMsg,
121592
121598
  {
121593
121599
  duration: duration.asMs,
121600
+ ...Object.keys(this.counters).length > 0 ? { counters: this.counters } : {},
121594
121601
  ...endPayload
121595
121602
  }
121596
121603
  ));
121597
121604
  return duration;
121598
121605
  }
121606
+ incCounter(name, delta = 1) {
121607
+ this.counters[name] = (this.counters[name] ?? 0) + delta;
121608
+ }
121599
121609
  async requestResponse(msg) {
121600
121610
  return this.ioHelper.requestResponse(withSpanId(this.spanId, msg));
121601
121611
  }
121612
+ startTimer(name) {
121613
+ const start = Date.now();
121614
+ const t10 = {
121615
+ stop: /* @__PURE__ */ __name(() => {
121616
+ this.openTimers.delete(t10);
121617
+ this.incCounter(`${name}_ms`, Math.floor(Date.now() - start) / 1e3);
121618
+ this.incCounter(`${name}_cnt`, 1);
121619
+ }, "stop")
121620
+ };
121621
+ this.openTimers.add(t10);
121622
+ return t10;
121623
+ }
121602
121624
  time() {
121603
121625
  const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - this.startTime;
121604
121626
  return {
@@ -132405,7 +132427,7 @@ async function loadTree(assembly, trace3) {
132405
132427
  try {
132406
132428
  const outdir = assembly.directory;
132407
132429
  const fileName = assembly.tree()?.file;
132408
- return fileName ? fs19.readJSONSync(path19.join(outdir, fileName)).tree : {};
132430
+ return fileName ? fs19.readJSONSync(path19.join(outdir, fileName)).tree : void 0;
132409
132431
  } catch (e10) {
132410
132432
  await trace3(`Failed to get tree.json file: ${e10}. Proceeding with empty tree.`);
132411
132433
  return void 0;
@@ -137465,10 +137487,10 @@ var require_utils11 = __commonJS({
137465
137487
  return (_b = (_a3 = input.match(/\s+/g)) === null || _a3 === void 0 ? void 0 : _a3.length) !== null && _b !== void 0 ? _b : 0;
137466
137488
  }, "countSpaceSequence");
137467
137489
  exports2.countSpaceSequence = countSpaceSequence;
137468
- var distributeUnevenly = /* @__PURE__ */ __name((sum3, length) => {
137469
- const result2 = Array.from({ length }).fill(Math.floor(sum3 / length));
137490
+ var distributeUnevenly = /* @__PURE__ */ __name((sum5, length) => {
137491
+ const result2 = Array.from({ length }).fill(Math.floor(sum5 / length));
137470
137492
  return result2.map((element, index) => {
137471
- return element + (index < sum3 % length ? 1 : 0);
137493
+ return element + (index < sum5 % length ? 1 : 0);
137472
137494
  });
137473
137495
  }, "distributeUnevenly");
137474
137496
  exports2.distributeUnevenly = distributeUnevenly;
@@ -305837,12 +305859,12 @@ var require_metadata = __commonJS({
305837
305859
  Object.defineProperty(exports2, "__esModule", { value: true });
305838
305860
  exports2.SynthesisMessageLevel = exports2.PATH_METADATA_KEY = void 0;
305839
305861
  exports2.PATH_METADATA_KEY = "aws:cdk:path";
305840
- var SynthesisMessageLevel3;
305841
- (function(SynthesisMessageLevel4) {
305842
- SynthesisMessageLevel4["INFO"] = "info";
305843
- SynthesisMessageLevel4["WARNING"] = "warning";
305844
- SynthesisMessageLevel4["ERROR"] = "error";
305845
- })(SynthesisMessageLevel3 || (exports2.SynthesisMessageLevel = SynthesisMessageLevel3 = {}));
305862
+ var SynthesisMessageLevel5;
305863
+ (function(SynthesisMessageLevel6) {
305864
+ SynthesisMessageLevel6["INFO"] = "info";
305865
+ SynthesisMessageLevel6["WARNING"] = "warning";
305866
+ SynthesisMessageLevel6["ERROR"] = "error";
305867
+ })(SynthesisMessageLevel5 || (exports2.SynthesisMessageLevel = SynthesisMessageLevel5 = {}));
305846
305868
  }
305847
305869
  });
305848
305870
 
@@ -306144,7 +306166,7 @@ var require_cloudformation_artifact = __commonJS({
306144
306166
  var environment_1 = require_environment();
306145
306167
  var error_1 = require_error3();
306146
306168
  var CLOUDFORMATION_STACK_ARTIFACT_SYM2 = /* @__PURE__ */ Symbol.for("@aws-cdk/cx-api.CloudFormationStackArtifact");
306147
- var CloudFormationStackArtifact3 = class extends cloud_artifact_1.CloudArtifact {
306169
+ var CloudFormationStackArtifact4 = class extends cloud_artifact_1.CloudArtifact {
306148
306170
  static {
306149
306171
  __name(this, "CloudFormationStackArtifact");
306150
306172
  }
@@ -306214,8 +306236,8 @@ var require_cloudformation_artifact = __commonJS({
306214
306236
  return this._template;
306215
306237
  }
306216
306238
  };
306217
- exports2.CloudFormationStackArtifact = CloudFormationStackArtifact3;
306218
- Object.defineProperty(CloudFormationStackArtifact3.prototype, CLOUDFORMATION_STACK_ARTIFACT_SYM2, {
306239
+ exports2.CloudFormationStackArtifact = CloudFormationStackArtifact4;
306240
+ Object.defineProperty(CloudFormationStackArtifact4.prototype, CLOUDFORMATION_STACK_ARTIFACT_SYM2, {
306219
306241
  value: true,
306220
306242
  enumerable: false,
306221
306243
  writable: false
@@ -306999,12 +307021,12 @@ var require_legacy_moved = __commonJS({
306999
307021
  Object.defineProperty(exports2, "UNKNOWN_REGION", { enumerable: true, get: /* @__PURE__ */ __name(function() {
307000
307022
  return cloud_assembly_api_1.UNKNOWN_REGION;
307001
307023
  }, "get") });
307002
- var SynthesisMessageLevel3;
307003
- (function(SynthesisMessageLevel4) {
307004
- SynthesisMessageLevel4["INFO"] = "info";
307005
- SynthesisMessageLevel4["WARNING"] = "warning";
307006
- SynthesisMessageLevel4["ERROR"] = "error";
307007
- })(SynthesisMessageLevel3 || (exports2.SynthesisMessageLevel = SynthesisMessageLevel3 = {}));
307024
+ var SynthesisMessageLevel5;
307025
+ (function(SynthesisMessageLevel6) {
307026
+ SynthesisMessageLevel6["INFO"] = "info";
307027
+ SynthesisMessageLevel6["WARNING"] = "warning";
307028
+ SynthesisMessageLevel6["ERROR"] = "error";
307029
+ })(SynthesisMessageLevel5 || (exports2.SynthesisMessageLevel = SynthesisMessageLevel5 = {}));
307008
307030
  exports2.CloudAssembly = cloud_assembly_api_1.CloudAssembly;
307009
307031
  exports2.CloudArtifact = cloud_assembly_api_1.CloudArtifact;
307010
307032
  exports2.CloudFormationStackArtifact = cloud_assembly_api_1.CloudFormationStackArtifact;
@@ -308949,19 +308971,27 @@ function writeContextToEnv(env2, context, completeness) {
308949
308971
  }
308950
308972
  };
308951
308973
  }
308952
- async function checkContextOverflowSupport(assembly, ioHelper) {
308953
- const traceFn = /* @__PURE__ */ __name((msg) => ioHelper.defaults.trace(msg), "traceFn");
308954
- const tree = await loadTree(assembly, traceFn);
308974
+ async function checkContextOverflowSupport(tree, ioHelper) {
308955
308975
  if (!frameworkSupportsContextOverflow(tree)) {
308956
308976
  await ioHelper.notify(IO.CDK_ASSEMBLY_W0010.msg("Part of the context could not be sent to the application. Please update the AWS CDK library to the latest version."));
308957
308977
  }
308958
308978
  }
308959
- function frameworkSupportsContextOverflow(tree) {
308960
- return !some(tree, (node) => {
308979
+ function findConstructLibraryVersion(tree) {
308980
+ let ret = void 0;
308981
+ some(tree, (node) => {
308961
308982
  const fqn = node.constructInfo?.fqn;
308962
308983
  const version = node.constructInfo?.version;
308963
- return fqn === "aws-cdk-lib.App" && version !== "0.0.0" && version != null && (0, import_semver.lte)(version, "2.38.0") || fqn === "@aws-cdk/core.App";
308984
+ if (fqn?.startsWith("aws-cdk-lib.") || fqn?.startsWith("@aws-cdk/core.")) {
308985
+ ret = version;
308986
+ return true;
308987
+ }
308988
+ return false;
308964
308989
  });
308990
+ return ret !== "0.0.0" ? ret : void 0;
308991
+ }
308992
+ function frameworkSupportsContextOverflow(tree) {
308993
+ const version = findConstructLibraryVersion(tree);
308994
+ return !version || !(0, import_semver.lte)(version, "2.38.0");
308965
308995
  }
308966
308996
  async function assemblyFromDirectory(assemblyDir, ioHelper, loadOptions = {}) {
308967
308997
  try {
@@ -308971,7 +309001,8 @@ async function assemblyFromDirectory(assemblyDir, ioHelper, loadOptions = {}) {
308971
309001
  // We sort as we deploy
308972
309002
  topoSort: false
308973
309003
  });
308974
- await checkContextOverflowSupport(assembly, ioHelper);
309004
+ const tree = await loadTree(assembly, ioHelper.defaults.trace.bind(ioHelper.defaults));
309005
+ await checkContextOverflowSupport(tree, ioHelper);
308975
309006
  return assembly;
308976
309007
  } catch (err) {
308977
309008
  if (err.message.includes(cxschema8.VERSION_MISMATCH)) {
@@ -309166,6 +309197,7 @@ var init_prepare_source = __esm({
309166
309197
  };
309167
309198
  __name(writeContextToEnv, "writeContextToEnv");
309168
309199
  __name(checkContextOverflowSupport, "checkContextOverflowSupport");
309200
+ __name(findConstructLibraryVersion, "findConstructLibraryVersion");
309169
309201
  __name(frameworkSupportsContextOverflow, "frameworkSupportsContextOverflow");
309170
309202
  __name(assemblyFromDirectory, "assemblyFromDirectory");
309171
309203
  __name(settingsFromSynthOptions, "settingsFromSynthOptions");
@@ -310201,7 +310233,7 @@ var init_diff_formatter = __esm({
310201
310233
  }
310202
310234
  if (diff.differenceCount && !options.strict) {
310203
310235
  const mangledNewTemplate = JSON.parse((0, import_cloudformation_diff.mangleLikeCloudFormation)(JSON.stringify(this.newTemplate.template)));
310204
- const mangledDiff = (0, import_cloudformation_diff.fullDiff)(this.oldTemplate, mangledNewTemplate, this.changeSet);
310236
+ const mangledDiff = (0, import_cloudformation_diff.fullDiff)(oldTemplate, mangledNewTemplate, this.changeSet);
310205
310237
  filteredChangesCount = Math.max(0, diff.differenceCount - mangledDiff.differenceCount);
310206
310238
  if (filteredChangesCount > 0) {
310207
310239
  diff = mangledDiff;
@@ -311131,6 +311163,20 @@ var init_work_graph = __esm({
311131
311163
  }
311132
311164
  });
311133
311165
  }
311166
+ /**
311167
+ * Execute all stack nodes in dependency order with the given concurrency.
311168
+ *
311169
+ * Unlike `doParallel`, this method only handles stack nodes and takes a
311170
+ * simple callback. Intended for destroy where there are no asset nodes.
311171
+ */
311172
+ processStacks(concurrency, fn) {
311173
+ return this.forAllArtifacts(concurrency, async (x10) => {
311174
+ if (x10.type !== "stack") {
311175
+ return;
311176
+ }
311177
+ await fn(x10);
311178
+ });
311179
+ }
311134
311180
  /**
311135
311181
  * Return the set of unblocked nodes
311136
311182
  */
@@ -311358,11 +311404,45 @@ var init_work_graph = __esm({
311358
311404
  }
311359
311405
  });
311360
311406
 
311407
+ // ../@aws-cdk/toolkit-lib/lib/api/work-graph/build-destroy-work-graph.ts
311408
+ function buildDestroyWorkGraph(stacks, ioHelper) {
311409
+ const graph = new WorkGraph({}, ioHelper);
311410
+ const selectedIds = new Set(stacks.map((s10) => s10.id));
311411
+ for (const stack of stacks) {
311412
+ graph.addNodes({
311413
+ type: "stack",
311414
+ id: stack.id,
311415
+ dependencies: /* @__PURE__ */ new Set(),
311416
+ stack,
311417
+ deploymentState: "pending" /* PENDING */,
311418
+ priority: 0
311419
+ });
311420
+ }
311421
+ for (const stack of stacks) {
311422
+ for (const dep of stack.dependencies) {
311423
+ if (cxapi6.CloudFormationStackArtifact.isCloudFormationStackArtifact(dep) && selectedIds.has(dep.id)) {
311424
+ graph.addDependency(dep.id, stack.id);
311425
+ }
311426
+ }
311427
+ }
311428
+ return graph;
311429
+ }
311430
+ var cxapi6;
311431
+ var init_build_destroy_work_graph = __esm({
311432
+ "../@aws-cdk/toolkit-lib/lib/api/work-graph/build-destroy-work-graph.ts"() {
311433
+ "use strict";
311434
+ cxapi6 = __toESM(require_lib3());
311435
+ init_work_graph();
311436
+ init_work_graph_types();
311437
+ __name(buildDestroyWorkGraph, "buildDestroyWorkGraph");
311438
+ }
311439
+ });
311440
+
311361
311441
  // ../@aws-cdk/toolkit-lib/lib/api/work-graph/work-graph-builder.ts
311362
311442
  function stacksFromAssets(artifacts) {
311363
311443
  const ret = /* @__PURE__ */ new Map();
311364
- for (const stack of artifacts.filter((x10) => cxapi6.CloudFormationStackArtifact.isCloudFormationStackArtifact(x10))) {
311365
- const assetArtifacts = stack.dependencies.filter((x10) => cxapi6.AssetManifestArtifact.isAssetManifestArtifact(x10));
311444
+ for (const stack of artifacts.filter((x10) => cxapi7.CloudFormationStackArtifact.isCloudFormationStackArtifact(x10))) {
311445
+ const assetArtifacts = stack.dependencies.filter((x10) => cxapi7.AssetManifestArtifact.isAssetManifestArtifact(x10));
311366
311446
  for (const art of assetArtifacts) {
311367
311447
  ret.set(art, stack);
311368
311448
  }
@@ -311370,14 +311450,14 @@ function stacksFromAssets(artifacts) {
311370
311450
  return ret;
311371
311451
  }
311372
311452
  function onlyStacks(artifacts) {
311373
- return artifacts.filter((x10) => cxapi6.CloudFormationStackArtifact.isCloudFormationStackArtifact(x10));
311453
+ return artifacts.filter((x10) => cxapi7.CloudFormationStackArtifact.isCloudFormationStackArtifact(x10));
311374
311454
  }
311375
- var import_cdk_assets_lib4, cxapi6, WorkGraphBuilder;
311455
+ var import_cdk_assets_lib4, cxapi7, WorkGraphBuilder;
311376
311456
  var init_work_graph_builder = __esm({
311377
311457
  "../@aws-cdk/toolkit-lib/lib/api/work-graph/work-graph-builder.ts"() {
311378
311458
  "use strict";
311379
311459
  import_cdk_assets_lib4 = __toESM(require_lib6());
311380
- cxapi6 = __toESM(require_lib3());
311460
+ cxapi7 = __toESM(require_lib3());
311381
311461
  init_work_graph();
311382
311462
  init_work_graph_types();
311383
311463
  init_toolkit_error();
@@ -311470,9 +311550,9 @@ var init_work_graph_builder = __esm({
311470
311550
  build(artifacts) {
311471
311551
  const parentStacks = stacksFromAssets(artifacts);
311472
311552
  for (const artifact of artifacts) {
311473
- if (cxapi6.CloudFormationStackArtifact.isCloudFormationStackArtifact(artifact)) {
311553
+ if (cxapi7.CloudFormationStackArtifact.isCloudFormationStackArtifact(artifact)) {
311474
311554
  this.addStack(artifact);
311475
- } else if (cxapi6.AssetManifestArtifact.isAssetManifestArtifact(artifact)) {
311555
+ } else if (cxapi7.AssetManifestArtifact.isAssetManifestArtifact(artifact)) {
311476
311556
  const manifest = import_cdk_assets_lib4.AssetManifest.fromFile(artifact.file);
311477
311557
  for (const entry of manifest.entries) {
311478
311558
  const parentStack = parentStacks.get(artifact);
@@ -311481,8 +311561,8 @@ var init_work_graph_builder = __esm({
311481
311561
  }
311482
311562
  this.addAsset(parentStack, artifact, manifest, entry);
311483
311563
  }
311484
- } else if (cxapi6.NestedCloudAssemblyArtifact.isNestedCloudAssemblyArtifact(artifact)) {
311485
- const assembly = new cxapi6.CloudAssembly(artifact.fullPath, { topoSort: false });
311564
+ } else if (cxapi7.NestedCloudAssemblyArtifact.isNestedCloudAssemblyArtifact(artifact)) {
311565
+ const assembly = new cxapi7.CloudAssembly(artifact.fullPath, { topoSort: false });
311486
311566
  const nestedGraph = new _WorkGraphBuilder(
311487
311567
  this.ioHelper,
311488
311568
  this.prebuildAssets,
@@ -311497,10 +311577,10 @@ var init_work_graph_builder = __esm({
311497
311577
  return this.graph;
311498
311578
  }
311499
311579
  stackArtifactIds(deps) {
311500
- return deps.flatMap((d10) => cxapi6.CloudFormationStackArtifact.isCloudFormationStackArtifact(d10) ? [this.stackArtifactId(d10)] : []);
311580
+ return deps.flatMap((d10) => cxapi7.CloudFormationStackArtifact.isCloudFormationStackArtifact(d10) ? [this.stackArtifactId(d10)] : []);
311501
311581
  }
311502
311582
  stackArtifactId(artifact) {
311503
- if (!cxapi6.CloudFormationStackArtifact.isCloudFormationStackArtifact(artifact)) {
311583
+ if (!cxapi7.CloudFormationStackArtifact.isCloudFormationStackArtifact(artifact)) {
311504
311584
  throw new ToolkitError(`Can only call this on CloudFormationStackArtifact, got: ${artifact.constructor.name}`);
311505
311585
  }
311506
311586
  return `${this.idPrefix}${artifact.id}`;
@@ -311529,6 +311609,7 @@ var init_work_graph_builder = __esm({
311529
311609
  var init_work_graph2 = __esm({
311530
311610
  "../@aws-cdk/toolkit-lib/lib/api/work-graph/index.ts"() {
311531
311611
  "use strict";
311612
+ init_build_destroy_work_graph();
311532
311613
  init_work_graph();
311533
311614
  init_work_graph_builder();
311534
311615
  init_work_graph_types();
@@ -312410,6 +312491,7 @@ __export(api_exports, {
312410
312491
  addMetadataAssetsToManifest: () => addMetadataAssetsToManifest,
312411
312492
  assemblyFromDirectory: () => assemblyFromDirectory,
312412
312493
  assertIsSuccessfulDeployStackResult: () => assertIsSuccessfulDeployStackResult,
312494
+ buildDestroyWorkGraph: () => buildDestroyWorkGraph,
312413
312495
  cached: () => cached2,
312414
312496
  contextFromSettings: () => contextFromSettings,
312415
312497
  credentialsAboutToExpire: () => credentialsAboutToExpire,
@@ -312417,6 +312499,7 @@ __export(api_exports, {
312417
312499
  determineAllowCrossAccountAssetPublishing: () => determineAllowCrossAccountAssetPublishing,
312418
312500
  execInChildProcess: () => execInChildProcess,
312419
312501
  findCloudWatchLogGroups: () => findCloudWatchLogGroups,
312502
+ findConstructLibraryVersion: () => findConstructLibraryVersion,
312420
312503
  formatSdkLoggerContent: () => formatSdkLoggerContent,
312421
312504
  frameworkSupportsContextOverflow: () => frameworkSupportsContextOverflow,
312422
312505
  getBootstrapStackInfo: () => getBootstrapStackInfo,
@@ -316634,6 +316717,7 @@ async function synthAndMeasure(ioHelper, cx, selectStacks) {
316634
316717
  const synthSpan = await ioHelper.span(SPAN.SYNTH_ASSEMBLY).begin({ stacks: selectStacks });
316635
316718
  try {
316636
316719
  const ret = await assemblyFromSource(synthSpan.asHelper, cx);
316720
+ countAssemblyResults(synthSpan, ret.assembly);
316637
316721
  const synthDuration = await synthSpan.end({});
316638
316722
  return Object.assign(ret, { synthDuration });
316639
316723
  } catch (error5) {
@@ -316644,13 +316728,28 @@ async function synthAndMeasure(ioHelper, cx, selectStacks) {
316644
316728
  function zeroTime() {
316645
316729
  return { asMs: 0, asSec: 0 };
316646
316730
  }
316647
- var import_dispose_polyfill5, path32, cxapi7, import_cloud_assembly_schema5, chalk25, fs34, FILE_EVENTS, Toolkit;
316731
+ function countAssemblyResults(span, assembly) {
316732
+ const stacksRecursively = assembly.stacksRecursively;
316733
+ span.incCounter("stacks", stacksRecursively.length);
316734
+ span.incCounter("assemblies", asmCount(assembly));
316735
+ span.incCounter("errorAnns", sum3(stacksRecursively.map((s10) => s10.messages.filter((m10) => m10.level === import_cloud_assembly_api14.SynthesisMessageLevel.ERROR).length)));
316736
+ span.incCounter("warnings", sum3(stacksRecursively.map((s10) => s10.messages.filter((m10) => m10.level === import_cloud_assembly_api14.SynthesisMessageLevel.WARNING).length)));
316737
+ function asmCount(x10) {
316738
+ return 1 + x10.nestedAssemblies.reduce((acc, asm) => acc + asmCount(asm.nestedAssembly), 0);
316739
+ }
316740
+ __name(asmCount, "asmCount");
316741
+ }
316742
+ function sum3(xs) {
316743
+ return xs.reduce((a10, b10) => a10 + b10, 0);
316744
+ }
316745
+ var import_dispose_polyfill5, path32, cxapi8, import_cloud_assembly_api14, import_cloud_assembly_schema5, chalk25, fs34, FILE_EVENTS, Toolkit;
316648
316746
  var init_toolkit = __esm({
316649
316747
  "../@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts"() {
316650
316748
  "use strict";
316651
316749
  import_dispose_polyfill5 = __toESM(require_dispose_polyfill());
316652
316750
  path32 = __toESM(require("node:path"));
316653
- cxapi7 = __toESM(require_lib3());
316751
+ cxapi8 = __toESM(require_lib3());
316752
+ import_cloud_assembly_api14 = __toESM(require_lib3());
316654
316753
  import_cloud_assembly_schema5 = __toESM(require_lib2());
316655
316754
  chalk25 = __toESM(require_source());
316656
316755
  init_esm3();
@@ -317080,7 +317179,8 @@ var init_toolkit = __esm({
317080
317179
  `Stack ${stack.displayName} does not define an environment, and AWS credentials could not be obtained from standard locations or no region was configured.`
317081
317180
  );
317082
317181
  }
317083
- if (Object.keys(stack.template.Resources || {}).length === 0) {
317182
+ const resourceCount = Object.keys(stack.template.Resources || {}).length;
317183
+ if (resourceCount === 0) {
317084
317184
  const stackExists = await deployments.stackExists({ stack });
317085
317185
  if (!stackExists) {
317086
317186
  return ioHelper.notify(IO.CDK_TOOLKIT_W5021.msg(`${chalk25.bold(stack.displayName)}: stack has no resources, skipping deployment.`));
@@ -317126,6 +317226,7 @@ Do you wish to deploy these changes`;
317126
317226
  current: stackIndex,
317127
317227
  stack
317128
317228
  });
317229
+ deploySpan.incCounter("resources", resourceCount);
317129
317230
  let tags = options.tags;
317130
317231
  if (!tags || tags.length === 0) {
317131
317232
  tags = tagsForStack(stack);
@@ -317253,7 +317354,7 @@ ${deployResult.stackArn}`));
317253
317354
  const concurrency = options.concurrency || 1;
317254
317355
  const stacksAndTheirAssetManifests = stacks.flatMap((stack) => [
317255
317356
  stack,
317256
- ...stack.dependencies.filter((x10) => cxapi7.AssetManifestArtifact.isAssetManifestArtifact(x10))
317357
+ ...stack.dependencies.filter((x10) => cxapi8.AssetManifestArtifact.isAssetManifestArtifact(x10))
317257
317358
  ]);
317258
317359
  const workGraph = new WorkGraphBuilder(ioHelper, prebuildAssets).build(stacksAndTheirAssetManifests);
317259
317360
  if (!options.forceAssetPublishing) {
@@ -317603,7 +317704,7 @@ ${deployResult.stackArn}`));
317603
317704
  async _destroy(assembly, action, options) {
317604
317705
  const selectStacks = stacksOpt(options);
317605
317706
  const ioHelper = asIoHelper(this.ioHost, action);
317606
- const stacks = (await assembly.selectStacksV2(selectStacks)).reversed();
317707
+ const stacks = await assembly.selectStacksV2(selectStacks);
317607
317708
  const ret = {
317608
317709
  stacks: []
317609
317710
  };
@@ -317614,15 +317715,19 @@ ${deployResult.stackArn}`));
317614
317715
  await ioHelper.notify(IO.CDK_TOOLKIT_E7010.msg("Aborted by user"));
317615
317716
  return ret;
317616
317717
  }
317718
+ const concurrency = options.concurrency || 1;
317719
+ let destroyCount = 0;
317617
317720
  const destroySpan = await ioHelper.span(SPAN.DESTROY_ACTION).begin({
317618
317721
  stacks: stacks.stackArtifacts
317619
317722
  });
317620
317723
  try {
317621
- for (const [index, stack] of stacks.stackArtifacts.entries()) {
317724
+ const destroyStack2 = /* @__PURE__ */ __name(async (stackNode) => {
317725
+ const stack = stackNode.stack;
317726
+ destroyCount++;
317622
317727
  try {
317623
- const singleDestroySpan = await ioHelper.span(SPAN.DESTROY_STACK).begin(chalk25.green(`${chalk25.blue(stack.displayName)}: destroying... [${index + 1}/${stacks.stackCount}]`), {
317728
+ const singleDestroySpan = await ioHelper.span(SPAN.DESTROY_STACK).begin(chalk25.green(`${chalk25.blue(stack.displayName)}: destroying... [${destroyCount}/${stacks.stackCount}]`), {
317624
317729
  total: stacks.stackCount,
317625
- current: index + 1,
317730
+ current: destroyCount,
317626
317731
  stack
317627
317732
  });
317628
317733
  const deployments = await this.deploymentsForAction(action);
@@ -317648,7 +317753,9 @@ ${deployResult.stackArn}`));
317648
317753
  \u274C ${chalk25.blue(stack.displayName)}: ${action} failed ${e10}`, { error: e10 }));
317649
317754
  throw e10;
317650
317755
  }
317651
- }
317756
+ }, "destroyStack");
317757
+ const workGraph = buildDestroyWorkGraph(stacks.stackArtifacts, ioHelper);
317758
+ await workGraph.processStacks(concurrency, destroyStack2);
317652
317759
  return ret;
317653
317760
  } finally {
317654
317761
  await destroySpan.end();
@@ -317748,6 +317855,8 @@ ${deployResult.stackArn}`));
317748
317855
  __name(stacksOpt, "stacksOpt");
317749
317856
  __name(synthAndMeasure, "synthAndMeasure");
317750
317857
  __name(zeroTime, "zeroTime");
317858
+ __name(countAssemblyResults, "countAssemblyResults");
317859
+ __name(sum3, "sum");
317751
317860
  }
317752
317861
  });
317753
317862
 
@@ -321093,6 +321202,12 @@ var require_cli_type_registry = __commonJS({
321093
321202
  type: "boolean",
321094
321203
  alias: "f",
321095
321204
  desc: "Do not ask for confirmation before destroying the stacks"
321205
+ },
321206
+ concurrency: {
321207
+ type: "number",
321208
+ desc: "Maximum number of simultaneous destroys (dependency permitting) to execute.",
321209
+ default: 1,
321210
+ requiresArg: true
321096
321211
  }
321097
321212
  }
321098
321213
  },
@@ -321665,6 +321780,9 @@ function isAbortedError(error5) {
321665
321780
  }
321666
321781
  return false;
321667
321782
  }
321783
+ function mutable(x10) {
321784
+ return x10;
321785
+ }
321668
321786
  var import_crypto7, import_toolkit_lib2, ABORTED_ERROR_MESSAGE, TelemetrySession;
321669
321787
  var init_session = __esm({
321670
321788
  "lib/cli/telemetry/session.ts"() {
@@ -321738,6 +321856,43 @@ var init_session = __esm({
321738
321856
  region
321739
321857
  };
321740
321858
  }
321859
+ /**
321860
+ * Attach a language guess
321861
+ */
321862
+ attachLanguage(language) {
321863
+ if (!this._sessionInfo) {
321864
+ return;
321865
+ }
321866
+ if (language) {
321867
+ mutable(this.sessionInfo.project).language = language;
321868
+ }
321869
+ }
321870
+ /**
321871
+ * Attach our best guess at running under an agent or not
321872
+ */
321873
+ attachAgent(isAgent) {
321874
+ if (!this._sessionInfo) {
321875
+ return;
321876
+ }
321877
+ mutable(this.sessionInfo.environment).agent = isAgent;
321878
+ }
321879
+ /**
321880
+ * Attach the CDK library version
321881
+ *
321882
+ * By default the telemetry will guess at the CDK library version if it so
321883
+ * happens that the CDK project is an NPM project and the CDK CLI is executed
321884
+ * in the root of NPM project with `aws-cdk-lib` available in `node_modules`.
321885
+ * This may succeed or may fail.
321886
+ *
321887
+ * Once we have produced and loaded the cloud assembly more accurate
321888
+ * information becomes available that we can add in.
321889
+ */
321890
+ attachCdkLibVersion(libVersion) {
321891
+ if (!this._sessionInfo) {
321892
+ return;
321893
+ }
321894
+ mutable(this.sessionInfo.identifiers).cdkLibraryVersion = libVersion;
321895
+ }
321741
321896
  /**
321742
321897
  * When the command is complete, so is the CliIoHost. Ends the span of the entire CliIoHost
321743
321898
  * and notifies with an optional error message in the data.
@@ -321769,7 +321924,8 @@ var init_session = __esm({
321769
321924
  error: {
321770
321925
  name: event.error.name
321771
321926
  }
321772
- } : {}
321927
+ } : {},
321928
+ ...event.counters && Object.keys(event.counters).length > 0 ? { counters: event.counters } : {}
321773
321929
  });
321774
321930
  }
321775
321931
  get sessionInfo() {
@@ -321781,6 +321937,7 @@ var init_session = __esm({
321781
321937
  };
321782
321938
  __name(getState, "getState");
321783
321939
  __name(isAbortedError, "isAbortedError");
321940
+ __name(mutable, "mutable");
321784
321941
  }
321785
321942
  });
321786
321943
 
@@ -322010,7 +322167,8 @@ function eventFromMessage(msg) {
322010
322167
  return {
322011
322168
  eventType,
322012
322169
  duration: m10.data.duration,
322013
- error: m10.data.error
322170
+ error: m10.data.error,
322171
+ counters: m10.data.counters
322014
322172
  };
322015
322173
  }
322016
322174
  __name(eventResult, "eventResult");
@@ -322818,10 +322976,25 @@ function setsEqual(a10, b10) {
322818
322976
  }
322819
322977
  return true;
322820
322978
  }
322821
- var import_toolkit_lib9, CloudExecutable;
322979
+ function countAssemblyResults2(span, assembly) {
322980
+ const stacksRecursively = assembly.stacksRecursively;
322981
+ span.incCounter("stacks", stacksRecursively.length);
322982
+ span.incCounter("errorAnns", sum4(stacksRecursively.map((s10) => s10.messages.filter((m10) => m10.level === import_cloud_assembly_api15.SynthesisMessageLevel.ERROR).length)));
322983
+ span.incCounter("warnings", sum4(stacksRecursively.map((s10) => s10.messages.filter((m10) => m10.level === import_cloud_assembly_api15.SynthesisMessageLevel.WARNING).length)));
322984
+ span.incCounter("assemblies", asmCount(assembly));
322985
+ function asmCount(x10) {
322986
+ return 1 + x10.nestedAssemblies.reduce((acc, asm) => acc + asmCount(asm.nestedAssembly), 0);
322987
+ }
322988
+ __name(asmCount, "asmCount");
322989
+ }
322990
+ function sum4(xs) {
322991
+ return xs.reduce((a10, b10) => a10 + b10, 0);
322992
+ }
322993
+ var import_cloud_assembly_api15, import_toolkit_lib9, CloudExecutable;
322822
322994
  var init_cloud_executable = __esm({
322823
322995
  "lib/cxapp/cloud-executable.ts"() {
322824
322996
  "use strict";
322997
+ import_cloud_assembly_api15 = __toESM(require_lib3());
322825
322998
  import_toolkit_lib9 = __toESM(require_lib13());
322826
322999
  init_cloud_assembly5();
322827
323000
  init_api_private();
@@ -322880,20 +323053,26 @@ var init_cloud_executable = __esm({
322880
323053
  }
322881
323054
  previouslyMissingKeys = missingKeys;
322882
323055
  if (tryLookup) {
322883
- await this.props.ioHelper.defaults.debug("Some context information is missing. Fetching...");
322884
- const updates = await provideContextValues(
322885
- assembly.manifest.missing,
322886
- this.props.sdkProvider,
322887
- GLOBAL_PLUGIN_HOST,
322888
- this.props.ioHelper
322889
- );
322890
- for (const [key, value] of Object.entries(updates)) {
322891
- this.props.configuration.context.set(key, value);
323056
+ const lookupsTimer = synthSpan.startTimer("lookups");
323057
+ try {
323058
+ await this.props.ioHelper.defaults.debug("Some context information is missing. Fetching...");
323059
+ const updates = await provideContextValues(
323060
+ assembly.manifest.missing,
323061
+ this.props.sdkProvider,
323062
+ GLOBAL_PLUGIN_HOST,
323063
+ this.props.ioHelper
323064
+ );
323065
+ for (const [key, value] of Object.entries(updates)) {
323066
+ this.props.configuration.context.set(key, value);
323067
+ }
323068
+ await this.props.configuration.saveContext();
323069
+ } finally {
323070
+ lookupsTimer.stop();
322892
323071
  }
322893
- await this.props.configuration.saveContext();
322894
323072
  continue;
322895
323073
  }
322896
323074
  }
323075
+ countAssemblyResults2(synthSpan, assembly);
322897
323076
  return new CloudAssembly5(assembly, this.props.ioHelper);
322898
323077
  }
322899
323078
  } catch (e10) {
@@ -322911,6 +323090,8 @@ var init_cloud_executable = __esm({
322911
323090
  };
322912
323091
  __name(missingContextKeys2, "missingContextKeys");
322913
323092
  __name(setsEqual, "setsEqual");
323093
+ __name(countAssemblyResults2, "countAssemblyResults");
323094
+ __name(sum4, "sum");
322914
323095
  }
322915
323096
  });
322916
323097
 
@@ -323019,10 +323200,10 @@ async function execProgram(aws, ioHelper, config) {
323019
323200
  throw new import_toolkit_lib11.ToolkitError(`Could not create output directory ${outdir} (${error5.message})`);
323020
323201
  }
323021
323202
  await debugFn(`outdir: ${outdir}`);
323022
- env2[cxapi8.OUTDIR_ENV] = outdir;
323203
+ env2[cxapi9.OUTDIR_ENV] = outdir;
323023
323204
  const writerLock = await new RWLock(outdir).acquireWrite();
323024
- env2[cxapi8.CLI_ASM_VERSION_ENV] = cxschema11.Manifest.version();
323025
- env2[cxapi8.CLI_VERSION_ENV] = versionNumber2();
323205
+ env2[cxapi9.CLI_ASM_VERSION_ENV] = cxschema11.Manifest.version();
323206
+ env2[cxapi9.CLI_VERSION_ENV] = versionNumber2();
323026
323207
  await debugFn((0, import_util68.format)("env:", env2));
323027
323208
  const cleanupTemp = writeContextToEnv(env2, context, "add-process-env-later");
323028
323209
  try {
@@ -323065,7 +323246,7 @@ async function execProgram(aws, ioHelper, config) {
323065
323246
  }
323066
323247
  function createAssembly(appDir) {
323067
323248
  try {
323068
- return new import_cloud_assembly_api14.CloudAssembly(appDir, {
323249
+ return new import_cloud_assembly_api16.CloudAssembly(appDir, {
323069
323250
  // We sort as we deploy
323070
323251
  topoSort: false
323071
323252
  });
@@ -323080,15 +323261,15 @@ function createAssembly(appDir) {
323080
323261
  function noUndefined2(xs) {
323081
323262
  return Object.fromEntries(Object.entries(xs).filter(([_2, v10]) => v10 !== void 0));
323082
323263
  }
323083
- var childProcess, import_util68, import_cloud_assembly_api14, cxschema11, cxapi8, import_toolkit_lib11, fs40;
323264
+ var childProcess, import_util68, import_cloud_assembly_api16, cxschema11, cxapi9, import_toolkit_lib11, fs40;
323084
323265
  var init_exec2 = __esm({
323085
323266
  "lib/cxapp/exec.ts"() {
323086
323267
  "use strict";
323087
323268
  childProcess = __toESM(require("child_process"));
323088
323269
  import_util68 = require("util");
323089
- import_cloud_assembly_api14 = __toESM(require_lib3());
323270
+ import_cloud_assembly_api16 = __toESM(require_lib3());
323090
323271
  cxschema11 = __toESM(require_lib2());
323091
- cxapi8 = __toESM(require_lib12());
323272
+ cxapi9 = __toESM(require_lib12());
323092
323273
  import_toolkit_lib11 = __toESM(require_lib13());
323093
323274
  fs40 = __toESM(require_lib14());
323094
323275
  init_api();
@@ -324467,8 +324648,8 @@ function chunks(list2, chunkSize) {
324467
324648
  }
324468
324649
  function setEnvironment(account, region) {
324469
324650
  return {
324470
- account: account ?? import_cloud_assembly_api15.UNKNOWN_ACCOUNT,
324471
- region: region ?? import_cloud_assembly_api15.UNKNOWN_REGION,
324651
+ account: account ?? import_cloud_assembly_api17.UNKNOWN_ACCOUNT,
324652
+ region: region ?? import_cloud_assembly_api17.UNKNOWN_REGION,
324472
324653
  name: "cdk-migrate-env"
324473
324654
  };
324474
324655
  }
@@ -324651,13 +324832,13 @@ function deduplicateResources(resources) {
324651
324832
  }
324652
324833
  return Object.values(uniqueResources);
324653
324834
  }
324654
- var fs42, path39, import_cloud_assembly_api15, import_toolkit_lib15, cdk_from_cfn, chalk29, camelCase2, decamelize2, MIGRATE_SUPPORTED_LANGUAGES, FilterType, CfnTemplateGeneratorProvider;
324835
+ var fs42, path39, import_cloud_assembly_api17, import_toolkit_lib15, cdk_from_cfn, chalk29, camelCase2, decamelize2, MIGRATE_SUPPORTED_LANGUAGES, FilterType, CfnTemplateGeneratorProvider;
324655
324836
  var init_migrate = __esm({
324656
324837
  "lib/commands/migrate.ts"() {
324657
324838
  "use strict";
324658
324839
  fs42 = __toESM(require("fs"));
324659
324840
  path39 = __toESM(require("path"));
324660
- import_cloud_assembly_api15 = __toESM(require_lib3());
324841
+ import_cloud_assembly_api17 = __toESM(require_lib3());
324661
324842
  import_toolkit_lib15 = __toESM(require_lib13());
324662
324843
  cdk_from_cfn = __toESM(require_cdk_from_cfn());
324663
324844
  chalk29 = __toESM(require_source());
@@ -325980,13 +326161,13 @@ function stackMetadataLogger(ioHelper, verbose) {
325980
326161
  function requiresApproval(requireApproval, permissionChangeType) {
325981
326162
  return requireApproval === import_cloud_assembly_schema7.RequireApproval.ANYCHANGE || requireApproval === import_cloud_assembly_schema7.RequireApproval.BROADENING && permissionChangeType === import_toolkit_lib17.PermissionChangeType.BROADENING;
325982
326163
  }
325983
- var path41, import_util72, cxapi9, import_cloud_assembly_schema7, import_toolkit_lib17, chalk31, fs44, pLimit5, FILE_EVENTS2, InternalToolkit, CdkToolkit;
326164
+ var path41, import_util72, cxapi10, import_cloud_assembly_schema7, import_toolkit_lib17, chalk31, fs44, pLimit5, FILE_EVENTS2, InternalToolkit, CdkToolkit;
325984
326165
  var init_cdk_toolkit = __esm({
325985
326166
  "lib/cli/cdk-toolkit.ts"() {
325986
326167
  "use strict";
325987
326168
  path41 = __toESM(require("path"));
325988
326169
  import_util72 = require("util");
325989
- cxapi9 = __toESM(require_lib3());
326170
+ cxapi10 = __toESM(require_lib3());
325990
326171
  import_cloud_assembly_schema7 = __toESM(require_lib2());
325991
326172
  import_toolkit_lib17 = __toESM(require_lib13());
325992
326173
  chalk31 = __toESM(require_source());
@@ -326271,7 +326452,8 @@ var init_cdk_toolkit = __esm({
326271
326452
  `Stack ${stack.displayName} does not define an environment, and AWS credentials could not be obtained from standard locations or no region was configured.`
326272
326453
  );
326273
326454
  }
326274
- if (Object.keys(stack.template.Resources || {}).length === 0) {
326455
+ const resourceCount = Object.keys(stack.template.Resources || {}).length;
326456
+ if (resourceCount === 0) {
326275
326457
  if (!await this.props.deployments.stackExists({ stack })) {
326276
326458
  await this.ioHost.asIoHelper().defaults.warn("%s: stack has no resources, skipping deployment.", chalk31.bold(stack.displayName));
326277
326459
  } else {
@@ -326323,6 +326505,7 @@ var init_cdk_toolkit = __esm({
326323
326505
  tags = tagsForStack(stack);
326324
326506
  }
326325
326507
  const deploySpan = await this.ioHost.asIoHelper().span(CLI_PRIVATE_SPAN.DEPLOY).begin({});
326508
+ deploySpan.incCounter("resources", resourceCount);
326326
326509
  let error5;
326327
326510
  let elapsedDeployTime = 0;
326328
326511
  try {
@@ -326454,7 +326637,7 @@ var init_cdk_toolkit = __esm({
326454
326637
  }
326455
326638
  const stacksAndTheirAssetManifests = stacks.flatMap((stack) => [
326456
326639
  stack,
326457
- ...stack.dependencies.filter((x10) => cxapi9.AssetManifestArtifact.isAssetManifestArtifact(x10))
326640
+ ...stack.dependencies.filter((x10) => cxapi10.AssetManifestArtifact.isAssetManifestArtifact(x10))
326458
326641
  ]);
326459
326642
  const workGraph = new WorkGraphBuilder(
326460
326643
  asIoHelper(this.ioHost, "deploy"),
@@ -326671,7 +326854,7 @@ var init_cdk_toolkit = __esm({
326671
326854
  }
326672
326855
  async destroy(options) {
326673
326856
  const ioHelper = this.ioHost.asIoHelper();
326674
- const stacks = (await this.selectStacksForDestroy(options.selector, options.exclusively)).reversed();
326857
+ const stacks = await this.selectStacksForDestroy(options.selector, options.exclusively);
326675
326858
  if (!options.force) {
326676
326859
  const motivation = "Destroying stacks is an irreversible action";
326677
326860
  const question2 = `Are you sure you want to delete: ${chalk31.blue(stacks.stackArtifacts.map((s10) => s10.hierarchicalId).join(", "))}`;
@@ -326685,9 +326868,16 @@ var init_cdk_toolkit = __esm({
326685
326868
  return;
326686
326869
  }
326687
326870
  }
326871
+ const concurrency = options.concurrency || 1;
326688
326872
  const action = options.fromDeploy ? "deploy" : "destroy";
326689
- for (const [index, stack] of stacks.stackArtifacts.entries()) {
326690
- await ioHelper.defaults.info(chalk31.green("%s: destroying... [%s/%s]"), chalk31.blue(stack.displayName), index + 1, stacks.stackCount);
326873
+ let destroyCount = 0;
326874
+ if (concurrency > 1) {
326875
+ this.ioHost.stackProgress = "events" /* EVENTS */;
326876
+ }
326877
+ const destroyStack2 = /* @__PURE__ */ __name(async (stackNode) => {
326878
+ const stack = stackNode.stack;
326879
+ destroyCount++;
326880
+ await ioHelper.defaults.info(chalk31.green("%s: destroying... [%s/%s]"), chalk31.blue(stack.displayName), destroyCount, stacks.stackCount);
326691
326881
  try {
326692
326882
  await this.props.deployments.destroyStack({
326693
326883
  stack,
@@ -326701,7 +326891,9 @@ var init_cdk_toolkit = __esm({
326701
326891
  \u274C %s: ${action} failed`, chalk31.blue(stack.displayName), e10);
326702
326892
  throw e10;
326703
326893
  }
326704
- }
326894
+ }, "destroyStack");
326895
+ const workGraph = buildDestroyWorkGraph(stacks.stackArtifacts, ioHelper);
326896
+ await workGraph.processStacks(concurrency, destroyStack2);
326705
326897
  }
326706
326898
  async list(selectors, options = {}) {
326707
326899
  const stacks = await listStacks2(this, {
@@ -332684,6 +332876,11 @@ function parseCommandLineArguments(args) {
332684
332876
  type: "boolean",
332685
332877
  alias: "f",
332686
332878
  desc: "Do not ask for confirmation before destroying the stacks"
332879
+ }).option("concurrency", {
332880
+ default: 1,
332881
+ type: "number",
332882
+ desc: "Maximum number of simultaneous destroys (dependency permitting) to execute.",
332883
+ requiresArg: true
332687
332884
  })
332688
332885
  ).command(
332689
332886
  "diff [STACKS..]",
@@ -361137,7 +361334,7 @@ async function displayCdkEnvironmentVariables(ioHelper) {
361137
361334
  await ioHelper.defaults.info("\u2139\uFE0F CDK environment variables:");
361138
361335
  let healthy = true;
361139
361336
  for (const key of keys.sort()) {
361140
- if (key === cxapi10.CONTEXT_ENV || key === cxapi10.CONTEXT_OVERFLOW_LOCATION_ENV || key === cxapi10.OUTDIR_ENV) {
361337
+ if (key === cxapi11.CONTEXT_ENV || key === cxapi11.CONTEXT_OVERFLOW_LOCATION_ENV || key === cxapi11.OUTDIR_ENV) {
361141
361338
  await ioHelper.defaults.info(` - ${chalk36.red(key)} = ${chalk36.green(process2.env[key])} (\u26A0\uFE0F reserved for use by the CDK toolkit)`);
361142
361339
  healthy = false;
361143
361340
  } else {
@@ -361155,12 +361352,12 @@ function anonymizeAwsVariable(name, value) {
361155
361352
  }
361156
361353
  return value;
361157
361354
  }
361158
- var process2, cxapi10, chalk36, verifications;
361355
+ var process2, cxapi11, chalk36, verifications;
361159
361356
  var init_doctor = __esm({
361160
361357
  "lib/commands/doctor.ts"() {
361161
361358
  "use strict";
361162
361359
  process2 = __toESM(require("process"));
361163
- cxapi10 = __toESM(require_lib12());
361360
+ cxapi11 = __toESM(require_lib12());
361164
361361
  chalk36 = __toESM(require_source());
361165
361362
  init_display_version();
361166
361363
  init_version();
@@ -366081,6 +366278,33 @@ var init_flags = __esm({
366081
366278
  }
366082
366279
  });
366083
366280
 
366281
+ // lib/cli/util/guess-agent.ts
366282
+ function guessAgent() {
366283
+ const awsExecutionEnv = (process.env.AWS_EXECUTION_ENV ?? "").toLocaleLowerCase();
366284
+ if (awsExecutionEnv.includes("amazonq") || awsExecutionEnv.includes("kiro")) {
366285
+ return true;
366286
+ }
366287
+ if (process.env.CLAUDECODE) {
366288
+ return true;
366289
+ }
366290
+ if (Object.keys(process.env).some((x10) => x10.startsWith("CODEX_"))) {
366291
+ return true;
366292
+ }
366293
+ if (process.env.CURSOR_AGENT) {
366294
+ return true;
366295
+ }
366296
+ if (Object.keys(process.env).some((x10) => x10.startsWith("CLINE_"))) {
366297
+ return true;
366298
+ }
366299
+ return void 0;
366300
+ }
366301
+ var init_guess_agent = __esm({
366302
+ "lib/cli/util/guess-agent.ts"() {
366303
+ "use strict";
366304
+ __name(guessAgent, "guessAgent");
366305
+ }
366306
+ });
366307
+
366084
366308
  // lib/cli/cli.ts
366085
366309
  var cli_exports = {};
366086
366310
  __export(cli_exports, {
@@ -366146,6 +366370,8 @@ async function exec4(args, synthesizer) {
366146
366370
  } catch (e10) {
366147
366371
  await ioHost.asIoHelper().defaults.trace(`Telemetry instantiation failed: ${e10.message}`);
366148
366372
  }
366373
+ ioHost.telemetry?.attachLanguage(await guessLanguage(process.cwd()));
366374
+ ioHost.telemetry?.attachAgent(guessAgent());
366149
366375
  const isSafeToWriteNotices = !isCI2() || Boolean(ciSystemIsStdErrSafe());
366150
366376
  let shouldDisplayNotices;
366151
366377
  if (argv.notices !== void 0) {
@@ -366191,6 +366417,13 @@ async function exec4(args, synthesizer) {
366191
366417
  await outDirLock?.release();
366192
366418
  const { assembly, lock } = await execProgram(aws, ioHost.asIoHelper(), config);
366193
366419
  outDirLock = lock;
366420
+ const tree = await loadTree(assembly, ioHelper.defaults.trace.bind(ioHelper.defaults));
366421
+ if (tree) {
366422
+ const v10 = findConstructLibraryVersion(tree);
366423
+ if (v10) {
366424
+ ioHost.telemetry?.attachCdkLibVersion(v10);
366425
+ }
366426
+ }
366194
366427
  return assembly;
366195
366428
  }),
366196
366429
  ioHelper: ioHost.asIoHelper()
@@ -366286,7 +366519,7 @@ async function exec4(args, synthesizer) {
366286
366519
  });
366287
366520
  case "diff":
366288
366521
  ioHost.currentAction = "diff";
366289
- const enableDiffNoFail = isFeatureEnabled(configuration, cxapi11.ENABLE_DIFF_NO_FAIL_CONTEXT);
366522
+ const enableDiffNoFail = isFeatureEnabled(configuration, cxapi12.ENABLE_DIFF_NO_FAIL_CONTEXT);
366290
366523
  return cli2.diff({
366291
366524
  stackNames: args2.STACKS,
366292
366525
  exclusively: args2.exclusively,
@@ -366439,7 +366672,8 @@ async function exec4(args, synthesizer) {
366439
366672
  selector,
366440
366673
  exclusively: args2.exclusively,
366441
366674
  force: args2.force,
366442
- roleArn: args2.roleArn
366675
+ roleArn: args2.roleArn,
366676
+ concurrency: args2.concurrency
366443
366677
  });
366444
366678
  case "gc":
366445
366679
  ioHost.currentAction = "gc";
@@ -366563,7 +366797,7 @@ async function determineBootstrapVersion(ioHost, args) {
366563
366797
  return source;
366564
366798
  }
366565
366799
  function isFeatureEnabled(configuration, featureFlag) {
366566
- return configuration.context.get(featureFlag) ?? cxapi11.futureFlagDefault(featureFlag);
366800
+ return configuration.context.get(featureFlag) ?? cxapi12.futureFlagDefault(featureFlag);
366567
366801
  }
366568
366802
  function arrayFromYargs(xs) {
366569
366803
  if (xs.length === 0) {
@@ -366672,11 +366906,11 @@ function cli(args = process.argv.slice(2)) {
366672
366906
  }
366673
366907
  });
366674
366908
  }
366675
- var cxapi11, import_toolkit_lib21, chalk37;
366909
+ var cxapi12, import_toolkit_lib21, chalk37;
366676
366910
  var init_cli = __esm({
366677
366911
  "lib/cli/cli.ts"() {
366678
366912
  "use strict";
366679
- cxapi11 = __toESM(require_lib12());
366913
+ cxapi12 = __toESM(require_lib12());
366680
366914
  import_toolkit_lib21 = __toESM(require_lib13());
366681
366915
  chalk37 = __toESM(require_source());
366682
366916
  init_util7();
@@ -366708,6 +366942,7 @@ var init_cli = __esm({
366708
366942
  init_migrate();
366709
366943
  init_cxapp();
366710
366944
  init_ci();
366945
+ init_guess_agent();
366711
366946
  __name(exec4, "exec");
366712
366947
  __name(determineBootstrapVersion, "determineBootstrapVersion");
366713
366948
  __name(isFeatureEnabled, "isFeatureEnabled");