@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.mjs
CHANGED
|
@@ -34424,7 +34424,7 @@ var VERSION = {
|
|
|
34424
34424
|
/**
|
|
34425
34425
|
* Version of Astro to pin for AstroProject scaffolding.
|
|
34426
34426
|
*/
|
|
34427
|
-
ASTRO_VERSION: "7.2.
|
|
34427
|
+
ASTRO_VERSION: "7.2.2",
|
|
34428
34428
|
/**
|
|
34429
34429
|
* CDK CLI for workflows and command line operations.
|
|
34430
34430
|
*
|
|
@@ -34436,7 +34436,7 @@ var VERSION = {
|
|
|
34436
34436
|
*
|
|
34437
34437
|
* CLI and lib are versioned separately, so this is the lib version.
|
|
34438
34438
|
*/
|
|
34439
|
-
AWS_CDK_LIB_VERSION: "2.
|
|
34439
|
+
AWS_CDK_LIB_VERSION: "2.265.0",
|
|
34440
34440
|
/**
|
|
34441
34441
|
* Version of the AWS Constructs library to use.
|
|
34442
34442
|
*/
|
|
@@ -42207,6 +42207,54 @@ var DEPLOY_GATE = {
|
|
|
42207
42207
|
*/
|
|
42208
42208
|
PLAN_APPLY: "plan-apply"
|
|
42209
42209
|
};
|
|
42210
|
+
var DEPLOY_APPROVALS = {
|
|
42211
|
+
/**
|
|
42212
|
+
* One approval per deploy job. The environment sits on every deploy job, so
|
|
42213
|
+
* each reaches its protection rules on its own — and deploy jobs chained by
|
|
42214
|
+
* `deployAfterTargets` reach them one at a time, with a full deploy between
|
|
42215
|
+
* each prompt.
|
|
42216
|
+
*/
|
|
42217
|
+
PER_TARGET: "per-target",
|
|
42218
|
+
/**
|
|
42219
|
+
* One approval for the whole run. A dedicated approval job carries the
|
|
42220
|
+
* required-reviewer rule and every deploy job waits on it, so the operator
|
|
42221
|
+
* approves once and the rest of the run proceeds unattended.
|
|
42222
|
+
*
|
|
42223
|
+
* Requires `approvalEnvironmentName`, and it must name a *different*
|
|
42224
|
+
* environment than the deploy jobs' — the deploy jobs keep their own
|
|
42225
|
+
* `environment` so their OIDC subject claims, environment-scoped secrets,
|
|
42226
|
+
* and per-stack deployment history are untouched.
|
|
42227
|
+
*/
|
|
42228
|
+
ONCE: "once"
|
|
42229
|
+
};
|
|
42230
|
+
var APPROVE_JOB_ID = "approve";
|
|
42231
|
+
var resolveApprovalGate = (gate, approvals, approvalEnvironmentName, environmentName, componentName) => {
|
|
42232
|
+
const trimmed = approvalEnvironmentName?.trim();
|
|
42233
|
+
if (approvals !== DEPLOY_APPROVALS.ONCE) {
|
|
42234
|
+
if (trimmed) {
|
|
42235
|
+
throw new Error(
|
|
42236
|
+
`${componentName} requires \`approvals\` to be "${DEPLOY_APPROVALS.ONCE}" when \`approvalEnvironmentName\` is supplied, got "${approvalEnvironmentName}" with \`approvals\` ${approvals ? `"${approvals}"` : "unset"}`
|
|
42237
|
+
);
|
|
42238
|
+
}
|
|
42239
|
+
return void 0;
|
|
42240
|
+
}
|
|
42241
|
+
if (gate !== DEPLOY_GATE.ENVIRONMENT) {
|
|
42242
|
+
throw new Error(
|
|
42243
|
+
`${componentName} requires \`gate\` to be "${DEPLOY_GATE.ENVIRONMENT}" when \`approvals\` is "${DEPLOY_APPROVALS.ONCE}", got ${gate ? `"${gate}"` : "no gate"}`
|
|
42244
|
+
);
|
|
42245
|
+
}
|
|
42246
|
+
if (!trimmed) {
|
|
42247
|
+
throw new Error(
|
|
42248
|
+
`${componentName} requires a non-empty \`approvalEnvironmentName\` when \`approvals\` is "${DEPLOY_APPROVALS.ONCE}"`
|
|
42249
|
+
);
|
|
42250
|
+
}
|
|
42251
|
+
if (trimmed === environmentName?.trim()) {
|
|
42252
|
+
throw new Error(
|
|
42253
|
+
`${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`
|
|
42254
|
+
);
|
|
42255
|
+
}
|
|
42256
|
+
return trimmed;
|
|
42257
|
+
};
|
|
42210
42258
|
var resolveEnvironmentGate = (gate, environmentName, componentName) => {
|
|
42211
42259
|
const trimmed = environmentName?.trim();
|
|
42212
42260
|
if (gate === void 0) {
|
|
@@ -42835,6 +42883,35 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component25 {
|
|
|
42835
42883
|
}
|
|
42836
42884
|
return conditions.join(" || ");
|
|
42837
42885
|
};
|
|
42886
|
+
/**
|
|
42887
|
+
* Compose the single approval job's condition.
|
|
42888
|
+
*
|
|
42889
|
+
* Mirrors a deploy job's, with one difference forced by the job being shared:
|
|
42890
|
+
* the branch clause is the union of every target's, rather than one target's.
|
|
42891
|
+
* Without it a push to a branch no target deploys from would still pause for
|
|
42892
|
+
* an approval — prompting for a deployment that can never happen, and holding
|
|
42893
|
+
* the `complete` gate pending while it waits.
|
|
42894
|
+
*
|
|
42895
|
+
* A target with no branch filter deploys from every branch, so one of those
|
|
42896
|
+
* collapses the union to no clause at all.
|
|
42897
|
+
*
|
|
42898
|
+
* Deliberately no `!cancelled()`, unlike the diff report: a report is wanted
|
|
42899
|
+
* precisely when a diff failed, but an approval is not. GitHub's default —
|
|
42900
|
+
* skip a job whose `needs` failed — is what should happen here, and it
|
|
42901
|
+
* cascades to every deploy job waiting on the approval.
|
|
42902
|
+
*/
|
|
42903
|
+
this.buildApprovalCondition = (homeRepositoryCondition) => {
|
|
42904
|
+
const branchConditions = this.awsDeploymentTargets.map(
|
|
42905
|
+
(target) => this.buildBranchFilterCondition(target.branches)
|
|
42906
|
+
);
|
|
42907
|
+
const anyBranch = branchConditions.some((condition) => !condition);
|
|
42908
|
+
const branchClause = anyBranch ? void 0 : Array.from(new Set(branchConditions)).join(" || ");
|
|
42909
|
+
return "${{ " + [
|
|
42910
|
+
"!needs.build.outputs.self_mutation_happened",
|
|
42911
|
+
...homeRepositoryCondition ? [homeRepositoryCondition] : [],
|
|
42912
|
+
...branchClause ? [`(${branchClause})`] : []
|
|
42913
|
+
].join(" && ") + " }}";
|
|
42914
|
+
};
|
|
42838
42915
|
/**
|
|
42839
42916
|
* Steps for a target's deploy job.
|
|
42840
42917
|
*
|
|
@@ -43134,6 +43211,14 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component25 {
|
|
|
43134
43211
|
options.environmentName,
|
|
43135
43212
|
"AwsDeployWorkflow"
|
|
43136
43213
|
);
|
|
43214
|
+
this.approvals = options.approvals ?? DEPLOY_APPROVALS.PER_TARGET;
|
|
43215
|
+
this.approvalEnvironmentName = resolveApprovalGate(
|
|
43216
|
+
options.gate,
|
|
43217
|
+
options.approvals,
|
|
43218
|
+
options.approvalEnvironmentName,
|
|
43219
|
+
this.environmentName,
|
|
43220
|
+
"AwsDeployWorkflow"
|
|
43221
|
+
);
|
|
43137
43222
|
this.homeRepository = options.homeRepository;
|
|
43138
43223
|
const homeRepositoryCondition = renderHomeRepositoryCondition(
|
|
43139
43224
|
this.homeRepository,
|
|
@@ -43271,6 +43356,7 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component25 {
|
|
|
43271
43356
|
needs: [
|
|
43272
43357
|
"build",
|
|
43273
43358
|
...gatedOnDiff ? [DIFF_REPORT_JOB_ID] : [],
|
|
43359
|
+
...this.approvalEnvironmentName ? [APPROVE_JOB_ID] : [],
|
|
43274
43360
|
...this.deployAfterTargets.map((p) => {
|
|
43275
43361
|
return this.buildJobName(p);
|
|
43276
43362
|
})
|
|
@@ -43317,6 +43403,35 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component25 {
|
|
|
43317
43403
|
}))
|
|
43318
43404
|
});
|
|
43319
43405
|
}
|
|
43406
|
+
if (this.approvalEnvironmentName && this.awsDeploymentTargets.length > 0) {
|
|
43407
|
+
if (this.buildWorkflow.workflow.getJob(APPROVE_JOB_ID)) {
|
|
43408
|
+
throw new Error(
|
|
43409
|
+
`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.`
|
|
43410
|
+
);
|
|
43411
|
+
}
|
|
43412
|
+
const gatedOnDiff = this.diffOptions.enabled;
|
|
43413
|
+
this.buildWorkflow.workflow.addJob(APPROVE_JOB_ID, {
|
|
43414
|
+
name: `Approve ${this.project.name} ${this.awsStageType} deployment`,
|
|
43415
|
+
needs: ["build", ...gatedOnDiff ? [DIFF_REPORT_JOB_ID] : []],
|
|
43416
|
+
runsOn: ["ubuntu-latest"],
|
|
43417
|
+
/**
|
|
43418
|
+
* Nothing to read and nothing to write: the job exists so GitHub holds
|
|
43419
|
+
* it at the environment's protection rules, and its only step records
|
|
43420
|
+
* that it cleared them.
|
|
43421
|
+
*/
|
|
43422
|
+
permissions: {
|
|
43423
|
+
contents: JobPermission7.NONE
|
|
43424
|
+
},
|
|
43425
|
+
environment: this.approvalEnvironmentName,
|
|
43426
|
+
if: this.buildApprovalCondition(homeRepositoryCondition),
|
|
43427
|
+
steps: [
|
|
43428
|
+
{
|
|
43429
|
+
name: "Record approval",
|
|
43430
|
+
run: `echo "Approved \u2014 releasing every ${this.awsStageType} deploy job in this run." >> "$GITHUB_STEP_SUMMARY"`
|
|
43431
|
+
}
|
|
43432
|
+
]
|
|
43433
|
+
});
|
|
43434
|
+
}
|
|
43320
43435
|
addBuildCompleteJob(this.buildWorkflow);
|
|
43321
43436
|
}
|
|
43322
43437
|
static of(project, buildWorkflow) {
|
|
@@ -44276,6 +44391,7 @@ export {
|
|
|
44276
44391
|
AGENT_RULE_SCOPE,
|
|
44277
44392
|
AGENT_TIER_ROLES,
|
|
44278
44393
|
AGENT_TIER_VALUES,
|
|
44394
|
+
APPROVE_JOB_ID,
|
|
44279
44395
|
AUDIT_CATEGORY_ORDER,
|
|
44280
44396
|
AgentConfig,
|
|
44281
44397
|
ApiExtractor,
|
|
@@ -44374,6 +44490,7 @@ export {
|
|
|
44374
44490
|
DEFAULT_UNBLOCK_COMMENT_TEMPLATE,
|
|
44375
44491
|
DEFAULT_UNBLOCK_DEPENDENTS_ENABLED,
|
|
44376
44492
|
DEFAULT_UPSTREAM_CONFIGULATOR_ENABLED,
|
|
44493
|
+
DEPLOY_APPROVALS,
|
|
44377
44494
|
DEPLOY_GATE,
|
|
44378
44495
|
DIFF_ARTIFACT_NAME,
|
|
44379
44496
|
DIFF_NEW_STACK_MARKER,
|
|
@@ -44614,6 +44731,7 @@ export {
|
|
|
44614
44731
|
researchPipelineBundle,
|
|
44615
44732
|
resolveAgentPaths,
|
|
44616
44733
|
resolveAgentTiers,
|
|
44734
|
+
resolveApprovalGate,
|
|
44617
44735
|
resolveAstroProjectOutdir,
|
|
44618
44736
|
resolveAwsCdkProjectOutdir,
|
|
44619
44737
|
resolveBuildPolicy,
|