@codedrifters/configulator 0.0.89 → 0.0.91

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
@@ -527,14 +527,167 @@ var AwsDeploymentConfig = class _AwsDeploymentConfig extends Component3 {
527
527
  }
528
528
  };
529
529
 
530
+ // src/aws/aws-deployment-target.ts
531
+ var import_utils2 = __toESM(require_lib());
532
+ import { Component as Component4 } from "projen";
533
+ var AwsDeploymentTarget = class _AwsDeploymentTarget extends Component4 {
534
+ constructor(project, options) {
535
+ super(project);
536
+ /**
537
+ * The AWS profile to use for this deployment target.
538
+ *
539
+ * @default ['main'] when prod release type, ['feature/*'] when dev type
540
+ */
541
+ this.branches = [];
542
+ /*****************************************************************************
543
+ *
544
+ * Deploy Tasks
545
+ *
546
+ * - If local deploy, add a deploy task.
547
+ *
548
+ ****************************************************************************/
549
+ this.configureDeployTask = () => {
550
+ if (this.localDeployment) {
551
+ const taskName = [
552
+ "deploy",
553
+ this.awsStageType,
554
+ this.account,
555
+ this.region
556
+ ].join(":");
557
+ const deployTask = this.project.tasks.addTask(taskName, {
558
+ env: this.awsDeploymentConfig.env
559
+ });
560
+ deployTask.exec(
561
+ `cdk deploy --lookups=false --require-approval=never --profile=${this.localDeploymentConfig?.profile} --app=${this.awsDeploymentConfig.cdkOut} "${this.localDeploymentConfig?.stackPattern}"`
562
+ );
563
+ }
564
+ };
565
+ /*****************************************************************************
566
+ *
567
+ * Watch tasks
568
+ *
569
+ * - Configure watch task to use the branch name
570
+ * - configure watch task to use the correct synth output location.
571
+ *
572
+ ****************************************************************************/
573
+ this.configureWatchTask = () => {
574
+ if (this.localDeployment) {
575
+ const taskName = [
576
+ "watch",
577
+ this.awsStageType,
578
+ this.account,
579
+ this.region
580
+ ].join(":");
581
+ const watchTask = this.project.tasks.addTask(taskName, {
582
+ env: this.awsDeploymentConfig.env
583
+ });
584
+ const synthSilent = this.project.tasks.tryFind("synth:silent");
585
+ if (synthSilent) {
586
+ watchTask.spawn(synthSilent);
587
+ }
588
+ watchTask.exec(
589
+ `cdk deploy --lookups=false --require-approval=never --profile=${this.localDeploymentConfig?.profile} --app=${this.awsDeploymentConfig.cdkOut} "${this.localDeploymentConfig?.stackPattern}"`
590
+ );
591
+ watchTask.exec(
592
+ `cdk watch --lookups=false --require-approval=never --hotswap --profile=${this.localDeploymentConfig?.profile} "${this.localDeploymentConfig?.stackPattern}"`
593
+ );
594
+ }
595
+ };
596
+ this.account = options.account;
597
+ this.region = options.region;
598
+ this.awsStageType = options.awsStageType || import_utils2.AWS_STAGE_TYPE.DEV;
599
+ const role = options.deploymentTargetRole ?? options.awsEnvironmentType ?? import_utils2.DEPLOYMENT_TARGET_ROLE.PRIMARY;
600
+ this.deploymentTargetRole = role;
601
+ this.awsEnvironmentType = role;
602
+ this.branches = options.branches ?? (this.awsStageType === import_utils2.AWS_STAGE_TYPE.PROD ? [
603
+ {
604
+ branch: "main"
605
+ }
606
+ ] : [
607
+ {
608
+ branch: "feature/*"
609
+ }
610
+ ]);
611
+ this.localDeployment = options.localDeployment ?? this.awsStageType === import_utils2.AWS_STAGE_TYPE.DEV;
612
+ if (this.localDeployment) {
613
+ const roleName = options.localDeploymentConfig?.roleName?.toLowerCase() || "poweruseraccess";
614
+ const profile = options.localDeploymentConfig?.profile || `${roleName}-${this.awsStageType}-${this.account}-${this.region}`;
615
+ const stackPattern = options.localDeploymentConfig?.stackPattern || `${this.awsStageType}/${this.awsEnvironmentType}/*-${this.account}-${this.region}`;
616
+ this.localDeploymentConfig = {
617
+ profile,
618
+ roleName,
619
+ stackPattern,
620
+ ...options.localDeploymentConfig
621
+ };
622
+ }
623
+ this.ciDeployment = options.ciDeployment ?? false;
624
+ if (this.ciDeployment) {
625
+ const roleArn = options.ciDeploymentConfig?.roleArn || `arn:aws:iam::${this.account}:role/GitHubDeployer}`;
626
+ const stackPattern = options.ciDeploymentConfig?.stackPattern || `${this.awsStageType}/${this.awsEnvironmentType}/*-${this.account}-${this.region}`;
627
+ this.ciDeploymentConfig = {
628
+ roleArn,
629
+ stackPattern,
630
+ ...options.ciDeploymentConfig
631
+ };
632
+ }
633
+ this.awsDeploymentConfig = AwsDeploymentConfig.of(project) || new AwsDeploymentConfig(project);
634
+ this.awsDeploymentConfig.awsDeploymentTargets.push(this);
635
+ this.configureDeployTask();
636
+ this.configureWatchTask();
637
+ }
638
+ /**
639
+ * Static method to discovert targets in a project.
640
+ */
641
+ static of(project) {
642
+ const isDefined = (c) => c instanceof _AwsDeploymentTarget;
643
+ return project.components.filter(isDefined);
644
+ }
645
+ };
646
+
647
+ // src/versions.ts
648
+ var VERSION = {
649
+ /**
650
+ * CDK CLI for workflows and command line operations.
651
+ *
652
+ * CLI and lib are versioned separately, so this is the CLI version.
653
+ */
654
+ AWS_CDK_CLI_VERSION: "2.1104.0",
655
+ /**
656
+ * CDK Version to use for construct projects.
657
+ *
658
+ * CLI and lib are versioned separately, so this is the lib version.
659
+ */
660
+ AWS_CDK_LIB_VERSION: "2.237.1",
661
+ /**
662
+ * Version of the AWS Constructs library to use.
663
+ */
664
+ AWS_CONSTRUCTS_VERSION: "10.4.5",
665
+ /**
666
+ * Version of Node.js to use in CI workflows at github actions.
667
+ */
668
+ NODE_WORKFLOWS: "24",
669
+ /**
670
+ * Version of PNPM to use in workflows at github actions.
671
+ */
672
+ PNPM_VERSION: "10.28.2",
673
+ /**
674
+ * Version of Projen to use.
675
+ */
676
+ PROJEN_VERSION: "0.99.9",
677
+ /**
678
+ * What version of the turborepo library should we use?
679
+ */
680
+ TURBO_VERSION: "2.8.3"
681
+ };
682
+
530
683
  // src/jsii/jsii-faker.ts
531
684
  import * as spec from "@jsii/spec";
532
- import { Component as Component4, JsonFile as JsonFile2 } from "projen";
685
+ import { Component as Component5, JsonFile as JsonFile2 } from "projen";
533
686
  var ProjenBaseFqn = {
534
687
  TYPESCRIPT_PROJECT: "projen.typescript.TypeScriptProject",
535
688
  TYPESCRIPT_PROJECT_OPTIONS: "projen.typescript.TypeScriptProjectOptions"
536
689
  };
537
- var JsiiFaker = class _JsiiFaker extends Component4 {
690
+ var JsiiFaker = class _JsiiFaker extends Component5 {
538
691
  constructor(project) {
539
692
  super(project);
540
693
  this.project = project;
@@ -584,7 +737,7 @@ var JsiiFaker = class _JsiiFaker extends Component4 {
584
737
 
585
738
  // src/pnpm/pnpm-workspace.ts
586
739
  import { relative as relative2 } from "path";
587
- import { Component as Component5, YamlFile } from "projen";
740
+ import { Component as Component6, YamlFile } from "projen";
588
741
  var MIMIMUM_RELEASE_AGE = {
589
742
  ZERO_DAYS: 0,
590
743
  ONE_HOUR: 60,
@@ -598,7 +751,7 @@ var MIMIMUM_RELEASE_AGE = {
598
751
  SIX_DAYS: 8640,
599
752
  ONE_WEEK: 10080
600
753
  };
601
- var PnpmWorkspace = class _PnpmWorkspace extends Component5 {
754
+ var PnpmWorkspace = class _PnpmWorkspace extends Component6 {
602
755
  /**
603
756
  * Get the pnpm workspace component of a project. If it does not exist,
604
757
  * return undefined.
@@ -674,7 +827,7 @@ import {
674
827
  import { merge as merge2 } from "ts-deepmerge";
675
828
 
676
829
  // src/tasks/reset-task.ts
677
- import { Component as Component6 } from "projen";
830
+ import { Component as Component7 } from "projen";
678
831
 
679
832
  // src/projects/typescript-project.ts
680
833
  import { typescript } from "projen";
@@ -685,44 +838,6 @@ import {
685
838
  } from "projen/lib/javascript";
686
839
  import { ReleaseTrigger } from "projen/lib/release";
687
840
  import { merge } from "ts-deepmerge";
688
-
689
- // src/versions.ts
690
- var VERSION = {
691
- /**
692
- * CDK CLI for workflows and command line operations.
693
- *
694
- * CLI and lib are versioned separately, so this is the CLI version.
695
- */
696
- AWS_CDK_CLI_VERSION: "2.1104.0",
697
- /**
698
- * CDK Version to use for construct projects.
699
- *
700
- * CLI and lib are versioned separately, so this is the lib version.
701
- */
702
- AWS_CDK_LIB_VERSION: "2.237.1",
703
- /**
704
- * Version of the AWS Constructs library to use.
705
- */
706
- AWS_CONSTRUCTS_VERSION: "10.4.5",
707
- /**
708
- * Version of Node.js to use in CI workflows at github actions.
709
- */
710
- NODE_WORKFLOWS: "24",
711
- /**
712
- * Version of PNPM to use in workflows at github actions.
713
- */
714
- PNPM_VERSION: "10.28.2",
715
- /**
716
- * Version of Projen to use.
717
- */
718
- PROJEN_VERSION: "0.99.9",
719
- /**
720
- * What version of the turborepo library should we use?
721
- */
722
- TURBO_VERSION: "2.8.3"
723
- };
724
-
725
- // src/projects/typescript-project.ts
726
841
  var TypeScriptProject = class extends typescript.TypeScriptProject {
727
842
  constructor(userOptions) {
728
843
  const pnpmVersion = userOptions.parent && userOptions.parent instanceof MonorepoProject ? userOptions.parent.pnpmVersion : VERSION.PNPM_VERSION;
@@ -860,7 +975,7 @@ var TypeScriptProject = class extends typescript.TypeScriptProject {
860
975
  };
861
976
 
862
977
  // src/tasks/reset-task.ts
863
- var ResetTask = class _ResetTask extends Component6 {
978
+ var ResetTask = class _ResetTask extends Component7 {
864
979
  constructor(project, options = {}) {
865
980
  super(project);
866
981
  this.project = project;
@@ -933,8 +1048,8 @@ var ResetTask = class _ResetTask extends Component6 {
933
1048
  };
934
1049
 
935
1050
  // src/vscode/vscode.ts
936
- import { Component as Component7, vscode } from "projen";
937
- var VSCodeConfig = class extends Component7 {
1051
+ import { Component as Component8, vscode } from "projen";
1052
+ var VSCodeConfig = class extends Component8 {
938
1053
  constructor(project) {
939
1054
  super(project);
940
1055
  const vsConfig = new vscode.VsCode(project);
@@ -1202,9 +1317,9 @@ var MonorepoProject = class extends TypeScriptAppProject {
1202
1317
 
1203
1318
  // src/typescript/typescript-config.ts
1204
1319
  import { relative as relative3 } from "path";
1205
- import { Component as Component8 } from "projen";
1320
+ import { Component as Component9 } from "projen";
1206
1321
  import { ensureRelativePathStartsWithDot } from "projen/lib/util/path";
1207
- var TypeScriptConfig = class extends Component8 {
1322
+ var TypeScriptConfig = class extends Component9 {
1208
1323
  constructor(project) {
1209
1324
  super(project);
1210
1325
  let tsPaths = {};
@@ -1231,13 +1346,13 @@ var TypeScriptConfig = class extends Component8 {
1231
1346
  };
1232
1347
 
1233
1348
  // src/workflows/aws-deploy-workflow.ts
1234
- var import_utils2 = __toESM(require_lib());
1235
- import { Component as Component9 } from "projen";
1349
+ var import_utils3 = __toESM(require_lib());
1350
+ import { Component as Component10 } from "projen";
1236
1351
  import { BuildWorkflow } from "projen/lib/build";
1237
1352
  import { GitHub } from "projen/lib/github";
1238
1353
  import { JobPermission as JobPermission2 } from "projen/lib/github/workflows-model";
1239
1354
  var PROD_DEPLOY_NAME = "prod-deploy";
1240
- var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component9 {
1355
+ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component10 {
1241
1356
  constructor(project, options = {}) {
1242
1357
  super(project);
1243
1358
  this.project = project;
@@ -1247,7 +1362,7 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component9 {
1247
1362
  * @deprecated Use deployment target role terminology elsewhere. This property is maintained for backward compatibility.
1248
1363
  * @default 'primary' (this is the only type supported currently)
1249
1364
  */
1250
- this.awsEnvironmentType = import_utils2.DEPLOYMENT_TARGET_ROLE.PRIMARY;
1365
+ this.awsEnvironmentType = import_utils3.DEPLOYMENT_TARGET_ROLE.PRIMARY;
1251
1366
  this.setupNode = () => {
1252
1367
  return [
1253
1368
  {
@@ -1356,7 +1471,7 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component9 {
1356
1471
  }
1357
1472
  const turbo = TurboRepo.of(this.rootProject);
1358
1473
  const buildWorkflowOptions = turbo?.remoteCacheOptions ? TurboRepo.buildWorkflowOptions(turbo.remoteCacheOptions) : {};
1359
- this.awsStageType = options.awsStageType ?? import_utils2.AWS_STAGE_TYPE.DEV;
1474
+ this.awsStageType = options.awsStageType ?? import_utils3.AWS_STAGE_TYPE.DEV;
1360
1475
  this.awsDeploymentTargets = options.awsDeploymentTargets ?? AwsDeploymentConfig.of(project)?.awsDeploymentTargets.filter(
1361
1476
  (target) => target.awsStageType === this.awsStageType && target.ciDeployment
1362
1477
  ) ?? [];
@@ -1480,6 +1595,7 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component9 {
1480
1595
  export {
1481
1596
  AwsDeployWorkflow,
1482
1597
  AwsDeploymentConfig,
1598
+ AwsDeploymentTarget,
1483
1599
  JsiiFaker,
1484
1600
  MIMIMUM_RELEASE_AGE,
1485
1601
  MonorepoProject,
@@ -1492,6 +1608,7 @@ export {
1492
1608
  TurboRepoTask,
1493
1609
  TypeScriptConfig,
1494
1610
  TypeScriptProject,
1611
+ VERSION,
1495
1612
  VSCodeConfig
1496
1613
  };
1497
1614
  //# sourceMappingURL=index.mjs.map