@codedrifters/configulator 0.0.457 → 0.0.458

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.mjs CHANGED
@@ -37668,9 +37668,9 @@ var CDK_DEPLOY_DEFAULTS_BY_STAGE = {
37668
37668
  }
37669
37669
  };
37670
37670
  var CDK_SYNTH_DEFAULTS_BY_STAGE = {
37671
- dev: { quiet: true },
37672
- stage: { quiet: true },
37673
- prod: { quiet: true }
37671
+ dev: {},
37672
+ stage: {},
37673
+ prod: {}
37674
37674
  };
37675
37675
  var CDK_WATCH_DEFAULTS_BY_STAGE = {
37676
37676
  dev: { progress: "events" },
@@ -38396,6 +38396,11 @@ var TURBO_RUN_DRY_RUN = {
38396
38396
  };
38397
38397
 
38398
38398
  // src/aws/aws-deployment-config.ts
38399
+ var SYNTH_STAGE_RANK = {
38400
+ [import_utils9.AWS_STAGE_TYPE.DEV]: 0,
38401
+ [import_utils9.AWS_STAGE_TYPE.STAGE]: 1,
38402
+ [import_utils9.AWS_STAGE_TYPE.PROD]: 2
38403
+ };
38399
38404
  var AwsDeploymentConfig = class _AwsDeploymentConfig extends Component12 {
38400
38405
  constructor(project) {
38401
38406
  super(project);
@@ -38411,15 +38416,55 @@ var AwsDeploymentConfig = class _AwsDeploymentConfig extends Component12 {
38411
38416
  * - Change the output location for easier workflows.
38412
38417
  *
38413
38418
  ****************************************************************************/
38419
+ /**
38420
+ * Resolve the synth options for the project-wide `synth` / `synth:silent`
38421
+ * tasks.
38422
+ *
38423
+ * `cdk synth` produces one cloud assembly that every target deploys from, so
38424
+ * there is no single target to resolve against. Each registered target's
38425
+ * resolved options are folded together lowest-stage-first, so a higher stage
38426
+ * wins scalar collisions and arrays/records union across targets. Sorting
38427
+ * makes the result independent of the order targets were declared in. With a
38428
+ * single target this is exactly `synthOptionsFor(target)`; with none it is
38429
+ * empty.
38430
+ */
38431
+ this.resolveSynthOptions = () => {
38432
+ const ordered = [...this.awsDeploymentTargets].sort(
38433
+ (a, b) => SYNTH_STAGE_RANK[a.awsStageType] - SYNTH_STAGE_RANK[b.awsStageType] || a.account.localeCompare(b.account) || a.region.localeCompare(b.region)
38434
+ );
38435
+ return mergeCdkOptions(
38436
+ ...ordered.map((target) => this.cdkCli.synthOptionsFor(target))
38437
+ );
38438
+ };
38439
+ /**
38440
+ * (Re)build the project-wide synth tasks.
38441
+ *
38442
+ * Idempotent — it resets both tasks before rebuilding them, so it is safe to
38443
+ * run once from the constructor (keeping the tasks well-formed for a project
38444
+ * with no targets) and again from `preSynthesize`, once every target has
38445
+ * registered itself and the override chain can actually be resolved.
38446
+ *
38447
+ * `--output` is pinned at the call site because it is a property of the
38448
+ * project layout, and `--quiet` is pinned on `synth:silent` because it is
38449
+ * what makes that task silent. Every other flag flows through the chain.
38450
+ */
38414
38451
  this.configureSynthTask = () => {
38452
+ const synthOpts = this.resolveSynthOptions();
38415
38453
  this.project.tasks.tryFind("synth")?.reset(`rm -rf ${this.cdkOut}`);
38416
- this.project.tasks.tryFind("synth")?.exec(`cdk ${renderCdkSynth({ output: this.cdkOut })}`, {
38454
+ this.project.tasks.tryFind("synth")?.exec(`cdk ${renderCdkSynth({ ...synthOpts, output: this.cdkOut })}`, {
38417
38455
  env: this.env
38418
38456
  });
38419
38457
  this.project.tasks.tryFind("synth:silent")?.reset(`rm -rf ${this.cdkOut}`);
38420
- this.project.tasks.tryFind("synth:silent")?.exec(`cdk ${renderCdkSynth({ output: this.cdkOut, quiet: true })}`, {
38421
- env: this.env
38422
- });
38458
+ this.project.tasks.tryFind("synth:silent")?.exec(
38459
+ `cdk ${renderCdkSynth({
38460
+ ...synthOpts,
38461
+ output: this.cdkOut,
38462
+ quiet: true
38463
+ })}`,
38464
+ {
38465
+ env: this.env
38466
+ }
38467
+ );
38423
38468
  };
38424
38469
  this.cdkCli = CdkCli.of(project) || new CdkCli(project);
38425
38470
  this.env = {
@@ -38509,6 +38554,7 @@ var AwsDeploymentConfig = class _AwsDeploymentConfig extends Component12 {
38509
38554
  }
38510
38555
  preSynthesize() {
38511
38556
  super.preSynthesize();
38557
+ this.configureSynthTask();
38512
38558
  if (TurboRepo.of(this.project)) {
38513
38559
  const turbo = TurboRepo.of(this.project);
38514
38560
  turbo.postCompileTask?.outputs.push(join(this.cdkOut, "**"));
@@ -38639,6 +38685,41 @@ var AwsDeploymentTarget = class _AwsDeploymentTarget extends Component13 {
38639
38685
  );
38640
38686
  }
38641
38687
  };
38688
+ /*****************************************************************************
38689
+ *
38690
+ * Bootstrap Tasks
38691
+ *
38692
+ * Unlike deploy / watch / destroy, this family is generated for **every**
38693
+ * target rather than only those with `localDeployment` enabled. Bootstrapping
38694
+ * provisions the CDK toolkit stack for one account/region pair, and a
38695
+ * CI-only target needs that done before its first deployment just as much as
38696
+ * a local one — gating on `localDeployment` would also make the built-in
38697
+ * `prod` default (`--termination-protection`) unreachable, since prod targets
38698
+ * default to `localDeployment: false`.
38699
+ *
38700
+ * The tasks are never invoked automatically; running one is always a
38701
+ * deliberate, elevated-credentials operation.
38702
+ *
38703
+ ****************************************************************************/
38704
+ this.configureBootstrapTask = () => {
38705
+ const taskName = [
38706
+ "bootstrap",
38707
+ this.awsStageType,
38708
+ this.account,
38709
+ this.region
38710
+ ].join(":");
38711
+ const bootstrapTask = this.project.tasks.addTask(taskName, {
38712
+ env: this.awsDeploymentConfig.env
38713
+ });
38714
+ const bootstrapOpts = this.awsDeploymentConfig.cdkCli.bootstrapOptionsFor(this);
38715
+ bootstrapTask.exec(
38716
+ `cdk ${renderCdkBootstrap({
38717
+ ...bootstrapOpts,
38718
+ profile: this.localDeploymentConfig?.profile,
38719
+ stackPatterns: [`aws://${this.account}/${this.region}`]
38720
+ })}`
38721
+ );
38722
+ };
38642
38723
  this.account = options.account;
38643
38724
  this.region = options.region;
38644
38725
  this.cdkOptions = options.cdkOptions;
@@ -38682,6 +38763,7 @@ var AwsDeploymentTarget = class _AwsDeploymentTarget extends Component13 {
38682
38763
  this.configureDeployTask();
38683
38764
  this.configureWatchTask();
38684
38765
  this.configureDestroyTask();
38766
+ this.configureBootstrapTask();
38685
38767
  }
38686
38768
  /**
38687
38769
  * Static method to discovert targets in a project.