@codedrifters/configulator 0.0.445 → 0.0.447
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.d.mts +118 -3
- package/lib/index.d.ts +119 -4
- package/lib/index.js +123 -2
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +120 -2
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -181,6 +181,7 @@ __export(index_exports, {
|
|
|
181
181
|
AGENT_RULE_SCOPE: () => AGENT_RULE_SCOPE,
|
|
182
182
|
AGENT_TIER_ROLES: () => AGENT_TIER_ROLES,
|
|
183
183
|
AGENT_TIER_VALUES: () => AGENT_TIER_VALUES,
|
|
184
|
+
APPROVE_JOB_ID: () => APPROVE_JOB_ID,
|
|
184
185
|
AUDIT_CATEGORY_ORDER: () => AUDIT_CATEGORY_ORDER,
|
|
185
186
|
AgentConfig: () => AgentConfig,
|
|
186
187
|
ApiExtractor: () => ApiExtractor,
|
|
@@ -279,6 +280,7 @@ __export(index_exports, {
|
|
|
279
280
|
DEFAULT_UNBLOCK_COMMENT_TEMPLATE: () => DEFAULT_UNBLOCK_COMMENT_TEMPLATE,
|
|
280
281
|
DEFAULT_UNBLOCK_DEPENDENTS_ENABLED: () => DEFAULT_UNBLOCK_DEPENDENTS_ENABLED,
|
|
281
282
|
DEFAULT_UPSTREAM_CONFIGULATOR_ENABLED: () => DEFAULT_UPSTREAM_CONFIGULATOR_ENABLED,
|
|
283
|
+
DEPLOY_APPROVALS: () => DEPLOY_APPROVALS,
|
|
282
284
|
DEPLOY_GATE: () => DEPLOY_GATE,
|
|
283
285
|
DIFF_ARTIFACT_NAME: () => DIFF_ARTIFACT_NAME,
|
|
284
286
|
DIFF_NEW_STACK_MARKER: () => DIFF_NEW_STACK_MARKER,
|
|
@@ -519,6 +521,7 @@ __export(index_exports, {
|
|
|
519
521
|
researchPipelineBundle: () => researchPipelineBundle,
|
|
520
522
|
resolveAgentPaths: () => resolveAgentPaths,
|
|
521
523
|
resolveAgentTiers: () => resolveAgentTiers,
|
|
524
|
+
resolveApprovalGate: () => resolveApprovalGate,
|
|
522
525
|
resolveAstroProjectOutdir: () => resolveAstroProjectOutdir,
|
|
523
526
|
resolveAwsCdkProjectOutdir: () => resolveAwsCdkProjectOutdir,
|
|
524
527
|
resolveBuildPolicy: () => resolveBuildPolicy,
|
|
@@ -34818,7 +34821,7 @@ var VERSION = {
|
|
|
34818
34821
|
/**
|
|
34819
34822
|
* Version of Astro to pin for AstroProject scaffolding.
|
|
34820
34823
|
*/
|
|
34821
|
-
ASTRO_VERSION: "7.2.
|
|
34824
|
+
ASTRO_VERSION: "7.2.2",
|
|
34822
34825
|
/**
|
|
34823
34826
|
* CDK CLI for workflows and command line operations.
|
|
34824
34827
|
*
|
|
@@ -34830,7 +34833,7 @@ var VERSION = {
|
|
|
34830
34833
|
*
|
|
34831
34834
|
* CLI and lib are versioned separately, so this is the lib version.
|
|
34832
34835
|
*/
|
|
34833
|
-
AWS_CDK_LIB_VERSION: "2.
|
|
34836
|
+
AWS_CDK_LIB_VERSION: "2.265.0",
|
|
34834
34837
|
/**
|
|
34835
34838
|
* Version of the AWS Constructs library to use.
|
|
34836
34839
|
*/
|
|
@@ -42588,6 +42591,54 @@ var DEPLOY_GATE = {
|
|
|
42588
42591
|
*/
|
|
42589
42592
|
PLAN_APPLY: "plan-apply"
|
|
42590
42593
|
};
|
|
42594
|
+
var DEPLOY_APPROVALS = {
|
|
42595
|
+
/**
|
|
42596
|
+
* One approval per deploy job. The environment sits on every deploy job, so
|
|
42597
|
+
* each reaches its protection rules on its own — and deploy jobs chained by
|
|
42598
|
+
* `deployAfterTargets` reach them one at a time, with a full deploy between
|
|
42599
|
+
* each prompt.
|
|
42600
|
+
*/
|
|
42601
|
+
PER_TARGET: "per-target",
|
|
42602
|
+
/**
|
|
42603
|
+
* One approval for the whole run. A dedicated approval job carries the
|
|
42604
|
+
* required-reviewer rule and every deploy job waits on it, so the operator
|
|
42605
|
+
* approves once and the rest of the run proceeds unattended.
|
|
42606
|
+
*
|
|
42607
|
+
* Requires `approvalEnvironmentName`, and it must name a *different*
|
|
42608
|
+
* environment than the deploy jobs' — the deploy jobs keep their own
|
|
42609
|
+
* `environment` so their OIDC subject claims, environment-scoped secrets,
|
|
42610
|
+
* and per-stack deployment history are untouched.
|
|
42611
|
+
*/
|
|
42612
|
+
ONCE: "once"
|
|
42613
|
+
};
|
|
42614
|
+
var APPROVE_JOB_ID = "approve";
|
|
42615
|
+
var resolveApprovalGate = (gate, approvals, approvalEnvironmentName, environmentName, componentName) => {
|
|
42616
|
+
const trimmed = approvalEnvironmentName?.trim();
|
|
42617
|
+
if (approvals !== DEPLOY_APPROVALS.ONCE) {
|
|
42618
|
+
if (trimmed) {
|
|
42619
|
+
throw new Error(
|
|
42620
|
+
`${componentName} requires \`approvals\` to be "${DEPLOY_APPROVALS.ONCE}" when \`approvalEnvironmentName\` is supplied, got "${approvalEnvironmentName}" with \`approvals\` ${approvals ? `"${approvals}"` : "unset"}`
|
|
42621
|
+
);
|
|
42622
|
+
}
|
|
42623
|
+
return void 0;
|
|
42624
|
+
}
|
|
42625
|
+
if (gate !== DEPLOY_GATE.ENVIRONMENT) {
|
|
42626
|
+
throw new Error(
|
|
42627
|
+
`${componentName} requires \`gate\` to be "${DEPLOY_GATE.ENVIRONMENT}" when \`approvals\` is "${DEPLOY_APPROVALS.ONCE}", got ${gate ? `"${gate}"` : "no gate"}`
|
|
42628
|
+
);
|
|
42629
|
+
}
|
|
42630
|
+
if (!trimmed) {
|
|
42631
|
+
throw new Error(
|
|
42632
|
+
`${componentName} requires a non-empty \`approvalEnvironmentName\` when \`approvals\` is "${DEPLOY_APPROVALS.ONCE}"`
|
|
42633
|
+
);
|
|
42634
|
+
}
|
|
42635
|
+
if (trimmed === environmentName?.trim()) {
|
|
42636
|
+
throw new Error(
|
|
42637
|
+
`${componentName} requires \`approvalEnvironmentName\` to name a different environment than \`environmentName\`, got "${trimmed}" for both \u2014 a shared environment puts the reviewer rule back on every deploy job, which is the per-target prompting "${DEPLOY_APPROVALS.ONCE}" exists to remove`
|
|
42638
|
+
);
|
|
42639
|
+
}
|
|
42640
|
+
return trimmed;
|
|
42641
|
+
};
|
|
42591
42642
|
var resolveEnvironmentGate = (gate, environmentName, componentName) => {
|
|
42592
42643
|
const trimmed = environmentName?.trim();
|
|
42593
42644
|
if (gate === void 0) {
|
|
@@ -43216,6 +43267,35 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends import_projen29.Compone
|
|
|
43216
43267
|
}
|
|
43217
43268
|
return conditions.join(" || ");
|
|
43218
43269
|
};
|
|
43270
|
+
/**
|
|
43271
|
+
* Compose the single approval job's condition.
|
|
43272
|
+
*
|
|
43273
|
+
* Mirrors a deploy job's, with one difference forced by the job being shared:
|
|
43274
|
+
* the branch clause is the union of every target's, rather than one target's.
|
|
43275
|
+
* Without it a push to a branch no target deploys from would still pause for
|
|
43276
|
+
* an approval — prompting for a deployment that can never happen, and holding
|
|
43277
|
+
* the `complete` gate pending while it waits.
|
|
43278
|
+
*
|
|
43279
|
+
* A target with no branch filter deploys from every branch, so one of those
|
|
43280
|
+
* collapses the union to no clause at all.
|
|
43281
|
+
*
|
|
43282
|
+
* Deliberately no `!cancelled()`, unlike the diff report: a report is wanted
|
|
43283
|
+
* precisely when a diff failed, but an approval is not. GitHub's default —
|
|
43284
|
+
* skip a job whose `needs` failed — is what should happen here, and it
|
|
43285
|
+
* cascades to every deploy job waiting on the approval.
|
|
43286
|
+
*/
|
|
43287
|
+
this.buildApprovalCondition = (homeRepositoryCondition) => {
|
|
43288
|
+
const branchConditions = this.awsDeploymentTargets.map(
|
|
43289
|
+
(target) => this.buildBranchFilterCondition(target.branches)
|
|
43290
|
+
);
|
|
43291
|
+
const anyBranch = branchConditions.some((condition) => !condition);
|
|
43292
|
+
const branchClause = anyBranch ? void 0 : Array.from(new Set(branchConditions)).join(" || ");
|
|
43293
|
+
return "${{ " + [
|
|
43294
|
+
"!needs.build.outputs.self_mutation_happened",
|
|
43295
|
+
...homeRepositoryCondition ? [homeRepositoryCondition] : [],
|
|
43296
|
+
...branchClause ? [`(${branchClause})`] : []
|
|
43297
|
+
].join(" && ") + " }}";
|
|
43298
|
+
};
|
|
43219
43299
|
/**
|
|
43220
43300
|
* Steps for a target's deploy job.
|
|
43221
43301
|
*
|
|
@@ -43515,6 +43595,14 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends import_projen29.Compone
|
|
|
43515
43595
|
options.environmentName,
|
|
43516
43596
|
"AwsDeployWorkflow"
|
|
43517
43597
|
);
|
|
43598
|
+
this.approvals = options.approvals ?? DEPLOY_APPROVALS.PER_TARGET;
|
|
43599
|
+
this.approvalEnvironmentName = resolveApprovalGate(
|
|
43600
|
+
options.gate,
|
|
43601
|
+
options.approvals,
|
|
43602
|
+
options.approvalEnvironmentName,
|
|
43603
|
+
this.environmentName,
|
|
43604
|
+
"AwsDeployWorkflow"
|
|
43605
|
+
);
|
|
43518
43606
|
this.homeRepository = options.homeRepository;
|
|
43519
43607
|
const homeRepositoryCondition = renderHomeRepositoryCondition(
|
|
43520
43608
|
this.homeRepository,
|
|
@@ -43652,6 +43740,7 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends import_projen29.Compone
|
|
|
43652
43740
|
needs: [
|
|
43653
43741
|
"build",
|
|
43654
43742
|
...gatedOnDiff ? [DIFF_REPORT_JOB_ID] : [],
|
|
43743
|
+
...this.approvalEnvironmentName ? [APPROVE_JOB_ID] : [],
|
|
43655
43744
|
...this.deployAfterTargets.map((p) => {
|
|
43656
43745
|
return this.buildJobName(p);
|
|
43657
43746
|
})
|
|
@@ -43698,6 +43787,35 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends import_projen29.Compone
|
|
|
43698
43787
|
}))
|
|
43699
43788
|
});
|
|
43700
43789
|
}
|
|
43790
|
+
if (this.approvalEnvironmentName && this.awsDeploymentTargets.length > 0) {
|
|
43791
|
+
if (this.buildWorkflow.workflow.getJob(APPROVE_JOB_ID)) {
|
|
43792
|
+
throw new Error(
|
|
43793
|
+
`AwsDeployWorkflow cannot add a second \`approvals: "${DEPLOY_APPROVALS.ONCE}"\` gate to the workflow "${this.buildWorkflow.name}": the job id "${APPROVE_JOB_ID}" is already taken. One approval job releases every deploy job in the file, so give the components separate build workflows if they must be approved separately.`
|
|
43794
|
+
);
|
|
43795
|
+
}
|
|
43796
|
+
const gatedOnDiff = this.diffOptions.enabled;
|
|
43797
|
+
this.buildWorkflow.workflow.addJob(APPROVE_JOB_ID, {
|
|
43798
|
+
name: `Approve ${this.project.name} ${this.awsStageType} deployment`,
|
|
43799
|
+
needs: ["build", ...gatedOnDiff ? [DIFF_REPORT_JOB_ID] : []],
|
|
43800
|
+
runsOn: ["ubuntu-latest"],
|
|
43801
|
+
/**
|
|
43802
|
+
* Nothing to read and nothing to write: the job exists so GitHub holds
|
|
43803
|
+
* it at the environment's protection rules, and its only step records
|
|
43804
|
+
* that it cleared them.
|
|
43805
|
+
*/
|
|
43806
|
+
permissions: {
|
|
43807
|
+
contents: import_workflows_model7.JobPermission.NONE
|
|
43808
|
+
},
|
|
43809
|
+
environment: this.approvalEnvironmentName,
|
|
43810
|
+
if: this.buildApprovalCondition(homeRepositoryCondition),
|
|
43811
|
+
steps: [
|
|
43812
|
+
{
|
|
43813
|
+
name: "Record approval",
|
|
43814
|
+
run: `echo "Approved \u2014 releasing every ${this.awsStageType} deploy job in this run." >> "$GITHUB_STEP_SUMMARY"`
|
|
43815
|
+
}
|
|
43816
|
+
]
|
|
43817
|
+
});
|
|
43818
|
+
}
|
|
43701
43819
|
addBuildCompleteJob(this.buildWorkflow);
|
|
43702
43820
|
}
|
|
43703
43821
|
static of(project, buildWorkflow) {
|
|
@@ -44658,6 +44776,7 @@ export const collections = {
|
|
|
44658
44776
|
AGENT_RULE_SCOPE,
|
|
44659
44777
|
AGENT_TIER_ROLES,
|
|
44660
44778
|
AGENT_TIER_VALUES,
|
|
44779
|
+
APPROVE_JOB_ID,
|
|
44661
44780
|
AUDIT_CATEGORY_ORDER,
|
|
44662
44781
|
AgentConfig,
|
|
44663
44782
|
ApiExtractor,
|
|
@@ -44756,6 +44875,7 @@ export const collections = {
|
|
|
44756
44875
|
DEFAULT_UNBLOCK_COMMENT_TEMPLATE,
|
|
44757
44876
|
DEFAULT_UNBLOCK_DEPENDENTS_ENABLED,
|
|
44758
44877
|
DEFAULT_UPSTREAM_CONFIGULATOR_ENABLED,
|
|
44878
|
+
DEPLOY_APPROVALS,
|
|
44759
44879
|
DEPLOY_GATE,
|
|
44760
44880
|
DIFF_ARTIFACT_NAME,
|
|
44761
44881
|
DIFF_NEW_STACK_MARKER,
|
|
@@ -44996,6 +45116,7 @@ export const collections = {
|
|
|
44996
45116
|
researchPipelineBundle,
|
|
44997
45117
|
resolveAgentPaths,
|
|
44998
45118
|
resolveAgentTiers,
|
|
45119
|
+
resolveApprovalGate,
|
|
44999
45120
|
resolveAstroProjectOutdir,
|
|
45000
45121
|
resolveAwsCdkProjectOutdir,
|
|
45001
45122
|
resolveBuildPolicy,
|