@codedrifters/constructs 0.0.73 → 0.0.74

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { NodejsFunction, NodejsFunctionProps } from 'aws-cdk-lib/aws-lambda-nodejs';
1
+ import { NodejsFunction, NodejsFunctionProps, ICommandHooks } from 'aws-cdk-lib/aws-lambda-nodejs';
2
2
  import { Construct } from 'constructs';
3
3
  import { Bucket, BucketProps } from 'aws-cdk-lib/aws-s3';
4
4
  import { StackProps } from 'aws-cdk-lib';
@@ -45,6 +45,19 @@ declare const mirrorPnpmWorkspacePolicy: (params: {
45
45
  readonly entry: string;
46
46
  readonly workspaceSearchFrom?: string;
47
47
  }) => MirrorPnpmWorkspacePolicyResult;
48
+ /**
49
+ * Build an `ICommandHooks` implementation that copies an
50
+ * entry-adjacent `.npmrc` into the bundling input directory before
51
+ * `pnpm install` runs. Composes with any caller-supplied hooks so
52
+ * existing `beforeBundling` / `beforeInstall` / `afterBundling`
53
+ * commands are preserved.
54
+ *
55
+ * Exported for unit testing; the construct wires this automatically.
56
+ */
57
+ declare const buildNpmrcCopyCommandHooks: (params: {
58
+ readonly npmrcPath: string;
59
+ readonly existingHooks?: ICommandHooks;
60
+ }) => ICommandHooks;
48
61
  /**
49
62
  * A `NodejsFunction` wrapper that mirrors the workspace's pnpm policy
50
63
  * (currently `minimumReleaseAge` and `minimumReleaseAgeExclude`) into
@@ -52,9 +65,13 @@ declare const mirrorPnpmWorkspacePolicy: (params: {
52
65
  *
53
66
  * CDK's bundler runs `pnpm install` in an isolated temp directory
54
67
  * outside the workspace, which means `pnpm-workspace.yaml` settings
55
- * do not apply there. Mirroring the policy into an entry-adjacent
56
- * `.npmrc` (which CDK copies into the bundling input directory)
57
- * lets the inner `pnpm install` honour the same freshness rules.
68
+ * do not apply there. CDK does **not** copy arbitrary entry-adjacent
69
+ * files into the bundling input directory, so the construct also
70
+ * wires a `bundling.commandHooks.beforeInstall` hook that copies the
71
+ * rendered `.npmrc` into the bundling input directory immediately
72
+ * before `pnpm install` runs. Caller-supplied `commandHooks` are
73
+ * preserved — the copy command is appended to whatever the caller
74
+ * already returns from `beforeInstall`.
58
75
  *
59
76
  * See the `pnpm-workspace-nodejs-function` documentation page for
60
77
  * full details on what gets mirrored, merge behaviour against an
@@ -235,4 +252,4 @@ declare class StaticHosting extends Construct {
235
252
  constructor(scope: Construct, id: string, props?: StaticHostingProps);
236
253
  }
237
254
 
238
- export { type MirrorPnpmWorkspacePolicyResult, PnpmWorkspaceNodejsFunction, type PnpmWorkspaceNodejsFunctionProps, type PnpmWorkspacePolicy, PrivateBucket, type PrivateBucketProps, StaticContent, type StaticContentProps, type StaticDomainProps, StaticHosting, type StaticHostingProps, findPnpmWorkspaceFile, mergeNpmrc, mirrorPnpmWorkspacePolicy, parseNpmrc, readPnpmWorkspacePolicy, renderNpmrcLines };
255
+ export { type MirrorPnpmWorkspacePolicyResult, PnpmWorkspaceNodejsFunction, type PnpmWorkspaceNodejsFunctionProps, type PnpmWorkspacePolicy, PrivateBucket, type PrivateBucketProps, StaticContent, type StaticContentProps, type StaticDomainProps, StaticHosting, type StaticHostingProps, buildNpmrcCopyCommandHooks, findPnpmWorkspaceFile, mergeNpmrc, mirrorPnpmWorkspacePolicy, parseNpmrc, readPnpmWorkspacePolicy, renderNpmrcLines };
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NodejsFunction, NodejsFunctionProps } from 'aws-cdk-lib/aws-lambda-nodejs';
1
+ import { NodejsFunction, NodejsFunctionProps, ICommandHooks } from 'aws-cdk-lib/aws-lambda-nodejs';
2
2
  import { Construct } from 'constructs';
3
3
  import { Bucket, BucketProps } from 'aws-cdk-lib/aws-s3';
4
4
  import { StackProps } from 'aws-cdk-lib';
@@ -55,6 +55,19 @@ declare const mirrorPnpmWorkspacePolicy: (params: {
55
55
  readonly entry: string;
56
56
  readonly workspaceSearchFrom?: string;
57
57
  }) => MirrorPnpmWorkspacePolicyResult;
58
+ /**
59
+ * Build an `ICommandHooks` implementation that copies an
60
+ * entry-adjacent `.npmrc` into the bundling input directory before
61
+ * `pnpm install` runs. Composes with any caller-supplied hooks so
62
+ * existing `beforeBundling` / `beforeInstall` / `afterBundling`
63
+ * commands are preserved.
64
+ *
65
+ * Exported for unit testing; the construct wires this automatically.
66
+ */
67
+ declare const buildNpmrcCopyCommandHooks: (params: {
68
+ readonly npmrcPath: string;
69
+ readonly existingHooks?: ICommandHooks;
70
+ }) => ICommandHooks;
58
71
  /**
59
72
  * A `NodejsFunction` wrapper that mirrors the workspace's pnpm policy
60
73
  * (currently `minimumReleaseAge` and `minimumReleaseAgeExclude`) into
@@ -62,9 +75,13 @@ declare const mirrorPnpmWorkspacePolicy: (params: {
62
75
  *
63
76
  * CDK's bundler runs `pnpm install` in an isolated temp directory
64
77
  * outside the workspace, which means `pnpm-workspace.yaml` settings
65
- * do not apply there. Mirroring the policy into an entry-adjacent
66
- * `.npmrc` (which CDK copies into the bundling input directory)
67
- * lets the inner `pnpm install` honour the same freshness rules.
78
+ * do not apply there. CDK does **not** copy arbitrary entry-adjacent
79
+ * files into the bundling input directory, so the construct also
80
+ * wires a `bundling.commandHooks.beforeInstall` hook that copies the
81
+ * rendered `.npmrc` into the bundling input directory immediately
82
+ * before `pnpm install` runs. Caller-supplied `commandHooks` are
83
+ * preserved — the copy command is appended to whatever the caller
84
+ * already returns from `beforeInstall`.
68
85
  *
69
86
  * See the `pnpm-workspace-nodejs-function` documentation page for
70
87
  * full details on what gets mirrored, merge behaviour against an
@@ -245,5 +262,5 @@ declare class StaticHosting extends Construct {
245
262
  constructor(scope: Construct, id: string, props?: StaticHostingProps);
246
263
  }
247
264
 
248
- export { PnpmWorkspaceNodejsFunction, PrivateBucket, StaticContent, StaticHosting, findPnpmWorkspaceFile, mergeNpmrc, mirrorPnpmWorkspacePolicy, parseNpmrc, readPnpmWorkspacePolicy, renderNpmrcLines };
265
+ export { PnpmWorkspaceNodejsFunction, PrivateBucket, StaticContent, StaticHosting, buildNpmrcCopyCommandHooks, findPnpmWorkspaceFile, mergeNpmrc, mirrorPnpmWorkspacePolicy, parseNpmrc, readPnpmWorkspacePolicy, renderNpmrcLines };
249
266
  export type { MirrorPnpmWorkspacePolicyResult, PnpmWorkspaceNodejsFunctionProps, PnpmWorkspacePolicy, PrivateBucketProps, StaticContentProps, StaticDomainProps, StaticHostingProps };
package/lib/index.js CHANGED
@@ -179,6 +179,7 @@ __export(src_exports, {
179
179
  PrivateBucket: () => PrivateBucket,
180
180
  StaticContent: () => StaticContent,
181
181
  StaticHosting: () => StaticHosting,
182
+ buildNpmrcCopyCommandHooks: () => buildNpmrcCopyCommandHooks,
182
183
  findPnpmWorkspaceFile: () => findPnpmWorkspaceFile,
183
184
  mergeNpmrc: () => mergeNpmrc,
184
185
  mirrorPnpmWorkspacePolicy: () => mirrorPnpmWorkspacePolicy,
@@ -337,10 +338,27 @@ var mirrorPnpmWorkspacePolicy = (params) => {
337
338
  fs2.writeFileSync(npmrcPath, merged);
338
339
  return { npmrcPath };
339
340
  };
341
+ var buildNpmrcCopyCommandHooks = (params) => {
342
+ const { npmrcPath, existingHooks } = params;
343
+ return {
344
+ beforeBundling(inputDir, outputDir) {
345
+ return existingHooks?.beforeBundling(inputDir, outputDir) ?? [];
346
+ },
347
+ beforeInstall(inputDir, outputDir) {
348
+ const callerCommands = existingHooks?.beforeInstall(inputDir, outputDir) ?? [];
349
+ const copyCommand = `cp ${npmrcPath} ${inputDir}/.npmrc`;
350
+ return [...callerCommands, copyCommand];
351
+ },
352
+ afterBundling(inputDir, outputDir) {
353
+ return existingHooks?.afterBundling(inputDir, outputDir) ?? [];
354
+ }
355
+ };
356
+ };
340
357
  var PnpmWorkspaceNodejsFunction = class extends import_aws_lambda_nodejs.NodejsFunction {
341
358
  constructor(scope, id, props) {
359
+ let mirrorResult;
342
360
  if (!props.disablePnpmPolicyMirror && props.entry) {
343
- mirrorPnpmWorkspacePolicy({
361
+ mirrorResult = mirrorPnpmWorkspacePolicy({
344
362
  entry: props.entry,
345
363
  workspaceSearchFrom: props.workspaceSearchFrom
346
364
  });
@@ -348,7 +366,19 @@ var PnpmWorkspaceNodejsFunction = class extends import_aws_lambda_nodejs.NodejsF
348
366
  const { disablePnpmPolicyMirror, workspaceSearchFrom, ...rest } = props;
349
367
  void disablePnpmPolicyMirror;
350
368
  void workspaceSearchFrom;
351
- super(scope, id, rest);
369
+ const npmrcPath = mirrorResult?.npmrcPath;
370
+ const shouldWireHook = npmrcPath !== void 0 && fs2.existsSync(npmrcPath);
371
+ const propsWithHook = shouldWireHook ? {
372
+ ...rest,
373
+ bundling: {
374
+ ...rest.bundling,
375
+ commandHooks: buildNpmrcCopyCommandHooks({
376
+ npmrcPath,
377
+ existingHooks: rest.bundling?.commandHooks
378
+ })
379
+ }
380
+ } : rest;
381
+ super(scope, id, propsWithHook);
352
382
  }
353
383
  };
354
384
 
@@ -558,6 +588,7 @@ var StaticHosting = class extends import_constructs2.Construct {
558
588
  PrivateBucket,
559
589
  StaticContent,
560
590
  StaticHosting,
591
+ buildNpmrcCopyCommandHooks,
561
592
  findPnpmWorkspaceFile,
562
593
  mergeNpmrc,
563
594
  mirrorPnpmWorkspacePolicy,
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../utils/src/aws/aws-types.ts","../../utils/src/git/git-utils.ts","../../utils/src/string/string-utils.ts","../../utils/src/index.ts","../src/index.ts","../src/lambda/pnpm-workspace-nodejs-function.ts","../src/lambda/pnpm-workspace-parser.ts","../src/s3/private-bucket.ts","../src/static-hosting/static-content.ts","../src/static-hosting/static-hosting.ts"],"sourcesContent":["/**\n * Stage Types\n *\n * What stage of deployment is this? Dev, staging, or prod?\n */\nexport const AWS_STAGE_TYPE = {\n /**\n * Development environment, typically used for testing and development.\n */\n DEV: \"dev\",\n\n /**\n * Staging environment, used for pre-production testing.\n */\n STAGE: \"stage\",\n\n /**\n * Production environment, used for live deployments.\n */\n PROD: \"prod\",\n} as const;\n\n/**\n * Above const as a type.\n */\nexport type AwsStageType = (typeof AWS_STAGE_TYPE)[keyof typeof AWS_STAGE_TYPE];\n\n/**\n * Deployment target role: whether an (account, region) is the primary or\n * secondary deployment target (e.g. primary vs replica region).\n */\nexport const DEPLOYMENT_TARGET_ROLE = {\n /**\n * Account and region that represents the primary region for this service.\n * For example, the base DynamoDB Region for global tables.\n */\n PRIMARY: \"primary\",\n /**\n * Account and region that represents a secondary region for this service.\n * For example, a replica region for a global DynamoDB table.\n */\n SECONDARY: \"secondary\",\n} as const;\n\n/**\n * Type for deployment target role values.\n */\nexport type DeploymentTargetRoleType =\n (typeof DEPLOYMENT_TARGET_ROLE)[keyof typeof DEPLOYMENT_TARGET_ROLE];\n\n/**\n * Environment types (primary/secondary).\n *\n * @deprecated Use {@link DEPLOYMENT_TARGET_ROLE} instead. This constant is maintained for backward compatibility.\n */\nexport const AWS_ENVIRONMENT_TYPE = DEPLOYMENT_TARGET_ROLE;\n\n/**\n * Type for environment type values.\n *\n * @deprecated Use {@link DeploymentTargetRoleType} instead. This type is maintained for backward compatibility.\n */\nexport type AwsEnvironmentType = DeploymentTargetRoleType;\n","import { execSync } from \"node:child_process\";\n\n/**\n * Returns the current full git branch name\n *\n * ie: feature/1234 returns feature/1234\n *\n */\nexport const findGitBranch = (): string => {\n return execSync(\"git rev-parse --abbrev-ref HEAD\")\n .toString(\"utf8\")\n .replace(/[\\n\\r\\s]+$/, \"\");\n};\n\nexport const findGitRepoName = (): string => {\n /**\n * When running in github actions this will be populated.\n */\n if (process.env.GITHUB_REPOSITORY) {\n return process.env.GITHUB_REPOSITORY;\n }\n\n /**\n * locally, we need to extract the repo name from the git config.\n */\n const remote = execSync(\"git config --get remote.origin.url\")\n .toString(\"utf8\")\n .replace(/[\\n\\r\\s]+$/, \"\")\n .trim();\n\n const match = remote.match(/[:\\/]([^/]+\\/[^/]+?)(?:\\.git)?$/);\n const repoName = match ? match[1] : \"error-repo-name\";\n\n return repoName;\n};\n","import * as crypto from \"node:crypto\";\n\n/**\n *\n * @param inString - string to hash\n * @param trimLength - trim to this length (defaults to 999 chars)\n * @returns Hex-encoded sha256 digest, truncated to `trimLength` characters.\n */\nexport const hashString = (inString: string, trimLength: number = 999) => {\n return crypto\n .createHash(\"sha256\")\n .update(inString)\n .digest(\"hex\")\n .substring(0, trimLength);\n};\n\n/**\n *\n * @param inputString - string to truncate\n * @param maxLength - max length of this string\n * @returns trimmed string\n */\nexport const trimStringLength = (inputString: string, maxLength: number) => {\n return inputString.length < maxLength\n ? inputString\n : inputString.substring(0, maxLength);\n};\n","export * from \"./aws/aws-types\";\nexport * from \"./git/git-utils\";\nexport * from \"./string/string-utils\";\n","export * from \"./lambda\";\nexport * from \"./s3\";\nexport * from \"./static-hosting\";\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n NodejsFunction,\n NodejsFunctionProps,\n} from \"aws-cdk-lib/aws-lambda-nodejs\";\nimport { Construct } from \"constructs\";\nimport {\n findPnpmWorkspaceFile,\n mergeNpmrc,\n readPnpmWorkspacePolicy,\n renderNpmrcLines,\n} from \"./pnpm-workspace-parser\";\n\n/**\n * Props for `PnpmWorkspaceNodejsFunction`. Extends\n * `NodejsFunctionProps` so the wrapper is a drop-in for any existing\n * `NodejsFunction` call site.\n */\nexport interface PnpmWorkspaceNodejsFunctionProps extends NodejsFunctionProps {\n /**\n * Directory to begin the upward search for `pnpm-workspace.yaml`.\n * Defaults to the directory of the resolved entry path.\n */\n readonly workspaceSearchFrom?: string;\n\n /**\n * Skip the policy-mirror step entirely. Useful for tests or when the\n * caller wants the pure `NodejsFunction` behavior.\n *\n * @default false\n */\n readonly disablePnpmPolicyMirror?: boolean;\n}\n\n/**\n * Result of `mirrorPnpmWorkspacePolicy` — describes what the policy\n * mirror did for one entry.\n */\nexport interface MirrorPnpmWorkspacePolicyResult {\n /** Resolved `.npmrc` path if a write happened, otherwise undefined. */\n readonly npmrcPath?: string;\n /** Reason the mirror was a no-op, if it was. */\n readonly skippedReason?:\n | \"missing-entry\"\n | \"missing-workspace-file\"\n | \"empty-policy\"\n | \"no-change\";\n}\n\n/**\n * Mirror the workspace pnpm policy into an `.npmrc` adjacent to the\n * Lambda entry. Pure side-effect helper used by\n * `PnpmWorkspaceNodejsFunction`; exported so consumers can drive it\n * from other call sites if desired.\n */\nexport const mirrorPnpmWorkspacePolicy = (params: {\n readonly entry: string;\n readonly workspaceSearchFrom?: string;\n}): MirrorPnpmWorkspacePolicyResult => {\n const { entry, workspaceSearchFrom } = params;\n if (!fs.existsSync(entry)) {\n return { skippedReason: \"missing-entry\" };\n }\n\n const entryDir = path.dirname(path.resolve(entry));\n const searchFrom = workspaceSearchFrom\n ? path.resolve(workspaceSearchFrom)\n : entryDir;\n\n const workspaceFile = findPnpmWorkspaceFile(searchFrom);\n if (!workspaceFile) {\n return { skippedReason: \"missing-workspace-file\" };\n }\n\n const policy = readPnpmWorkspacePolicy(workspaceFile);\n const lines = renderNpmrcLines(policy);\n if (lines.length === 0) {\n return { skippedReason: \"empty-policy\" };\n }\n\n const npmrcPath = path.join(entryDir, \".npmrc\");\n const existing = fs.existsSync(npmrcPath)\n ? fs.readFileSync(npmrcPath, \"utf8\")\n : undefined;\n const merged = mergeNpmrc(existing, lines);\n\n if (merged === existing) {\n return { npmrcPath, skippedReason: \"no-change\" };\n }\n\n fs.writeFileSync(npmrcPath, merged);\n return { npmrcPath };\n};\n\n/**\n * A `NodejsFunction` wrapper that mirrors the workspace's pnpm policy\n * (currently `minimumReleaseAge` and `minimumReleaseAgeExclude`) into\n * an `.npmrc` adjacent to the Lambda entry before bundling.\n *\n * CDK's bundler runs `pnpm install` in an isolated temp directory\n * outside the workspace, which means `pnpm-workspace.yaml` settings\n * do not apply there. Mirroring the policy into an entry-adjacent\n * `.npmrc` (which CDK copies into the bundling input directory)\n * lets the inner `pnpm install` honour the same freshness rules.\n *\n * See the `pnpm-workspace-nodejs-function` documentation page for\n * full details on what gets mirrored, merge behaviour against an\n * existing `.npmrc`, and when to disable the mirror.\n */\nexport class PnpmWorkspaceNodejsFunction extends NodejsFunction {\n constructor(\n scope: Construct,\n id: string,\n props: PnpmWorkspaceNodejsFunctionProps,\n ) {\n if (!props.disablePnpmPolicyMirror && props.entry) {\n mirrorPnpmWorkspacePolicy({\n entry: props.entry,\n workspaceSearchFrom: props.workspaceSearchFrom,\n });\n }\n\n const { disablePnpmPolicyMirror, workspaceSearchFrom, ...rest } = props;\n void disablePnpmPolicyMirror;\n void workspaceSearchFrom;\n super(scope, id, rest);\n }\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as yaml from \"js-yaml\";\n\n/**\n * Subset of `pnpm-workspace.yaml` fields that map to `.npmrc` keys\n * pnpm honours when running install in a non-workspace directory.\n */\nexport interface PnpmWorkspacePolicy {\n /** `minimumReleaseAge` (minutes) — equivalent to `.npmrc` `minimum-release-age`. */\n readonly minimumReleaseAge?: number;\n /**\n * `minimumReleaseAgeExclude` — equivalent to `.npmrc`\n * `minimum-release-age-exclude` (comma-separated when serialised).\n */\n readonly minimumReleaseAgeExclude?: ReadonlyArray<string>;\n}\n\n/**\n * Walk up from `startDir` until a `pnpm-workspace.yaml` file is found\n * and return its absolute path. Returns `undefined` when the filesystem\n * root is reached without finding one.\n */\nexport const findPnpmWorkspaceFile = (startDir: string): string | undefined => {\n let current = path.resolve(startDir);\n while (true) {\n const candidate = path.join(current, \"pnpm-workspace.yaml\");\n if (fs.existsSync(candidate)) {\n return candidate;\n }\n const parent = path.dirname(current);\n if (parent === current) {\n return undefined;\n }\n current = parent;\n }\n};\n\n/**\n * Read the policy subset (`minimumReleaseAge` and\n * `minimumReleaseAgeExclude`) from a `pnpm-workspace.yaml` file.\n *\n * Returns an empty object when the file is missing, unreadable, or\n * contains neither key. Throws when the file is present but YAML\n * parsing fails — the caller is expected to surface a clear error.\n */\nexport const readPnpmWorkspacePolicy = (\n workspaceFile: string,\n): PnpmWorkspacePolicy => {\n if (!fs.existsSync(workspaceFile)) {\n return {};\n }\n\n const raw = fs.readFileSync(workspaceFile, \"utf8\");\n const parsed = yaml.load(raw);\n\n if (!parsed || typeof parsed !== \"object\") {\n return {};\n }\n\n const obj = parsed as Record<string, unknown>;\n const policy: {\n -readonly [K in keyof PnpmWorkspacePolicy]: PnpmWorkspacePolicy[K];\n } = {};\n\n const age = obj.minimumReleaseAge;\n if (typeof age === \"number\" && Number.isFinite(age)) {\n policy.minimumReleaseAge = age;\n }\n\n const exclude = obj.minimumReleaseAgeExclude;\n if (Array.isArray(exclude)) {\n const cleaned = exclude.filter(\n (entry): entry is string => typeof entry === \"string\" && entry.length > 0,\n );\n if (cleaned.length > 0) {\n policy.minimumReleaseAgeExclude = cleaned;\n }\n }\n\n return policy;\n};\n\n/**\n * Render an `.npmrc` body that pnpm will honour when installing in\n * a directory outside the workspace tree. The keys emitted here are\n * the `.npmrc` equivalents of the `pnpm-workspace.yaml` fields in\n * {@link PnpmWorkspacePolicy} — pnpm reads `minimum-release-age` and\n * `minimum-release-age-exclude` from `.npmrc`, not from the workspace\n * file, when the install runs outside the workspace.\n *\n * Returns an empty string when the policy carries no relevant fields.\n */\nexport const renderNpmrcLines = (\n policy: PnpmWorkspacePolicy,\n): ReadonlyArray<string> => {\n const lines: Array<string> = [];\n\n if (typeof policy.minimumReleaseAge === \"number\") {\n lines.push(`minimum-release-age=${policy.minimumReleaseAge}`);\n }\n\n const exclude = policy.minimumReleaseAgeExclude ?? [];\n if (exclude.length > 0) {\n lines.push(`minimum-release-age-exclude=${exclude.join(\",\")}`);\n }\n\n return lines;\n};\n\n/**\n * Parse the body of an existing `.npmrc` file into a map of trimmed\n * key/value pairs. Lines that are blank or start with `#` are dropped.\n * Lines without an `=` are dropped.\n */\nexport const parseNpmrc = (body: string): Map<string, string> => {\n const map = new Map<string, string>();\n for (const rawLine of body.split(/\\r?\\n/)) {\n const line = rawLine.trim();\n if (line.length === 0 || line.startsWith(\"#\")) {\n continue;\n }\n const eq = line.indexOf(\"=\");\n if (eq < 0) {\n continue;\n }\n const key = line.slice(0, eq).trim();\n const value = line.slice(eq + 1).trim();\n if (key.length > 0) {\n map.set(key, value);\n }\n }\n return map;\n};\n\n/**\n * Merge a set of policy-derived `.npmrc` lines into an existing\n * `.npmrc` body. Our keys overwrite matching keys in the existing\n * body; all other keys are preserved. Returns the new `.npmrc` body\n * (always terminated by a trailing newline when non-empty).\n */\nexport const mergeNpmrc = (\n existing: string | undefined,\n ourLines: ReadonlyArray<string>,\n): string => {\n if (ourLines.length === 0) {\n return existing ?? \"\";\n }\n\n const ourMap = new Map<string, string>();\n for (const line of ourLines) {\n const eq = line.indexOf(\"=\");\n if (eq < 0) {\n continue;\n }\n ourMap.set(line.slice(0, eq).trim(), line.slice(eq + 1).trim());\n }\n\n const existingMap = parseNpmrc(existing ?? \"\");\n for (const [key, value] of ourMap) {\n existingMap.set(key, value);\n }\n\n const orderedKeys: Array<string> = [];\n const seen = new Set<string>();\n\n // Preserve the original line order for any pre-existing keys.\n for (const rawLine of (existing ?? \"\").split(/\\r?\\n/)) {\n const line = rawLine.trim();\n if (line.length === 0 || line.startsWith(\"#\")) {\n continue;\n }\n const eq = line.indexOf(\"=\");\n if (eq < 0) {\n continue;\n }\n const key = line.slice(0, eq).trim();\n if (key.length > 0 && existingMap.has(key) && !seen.has(key)) {\n orderedKeys.push(key);\n seen.add(key);\n }\n }\n\n // Append any keys we added that weren't already present.\n for (const key of ourMap.keys()) {\n if (!seen.has(key)) {\n orderedKeys.push(key);\n seen.add(key);\n }\n }\n\n const body = orderedKeys\n .map((key) => `${key}=${existingMap.get(key)}`)\n .join(\"\\n\");\n\n return body.length === 0 ? \"\" : `${body}\\n`;\n};\n","import { RemovalPolicy } from \"aws-cdk-lib\";\nimport {\n BlockPublicAccess,\n Bucket,\n BucketProps,\n ObjectOwnership,\n} from \"aws-cdk-lib/aws-s3\";\nimport { Construct } from \"constructs\";\n\nexport interface PrivateBucketProps extends BucketProps {}\n\nexport class PrivateBucket extends Bucket {\n constructor(scope: Construct, id: string, props: PrivateBucketProps = {}) {\n const defaultProps = {\n removalPolicy: props.removalPolicy ?? RemovalPolicy.RETAIN,\n autoDeleteObjects: props.removalPolicy === RemovalPolicy.DESTROY,\n };\n\n const requiredProps = {\n publicReadAccess: false,\n blockPublicAccess: BlockPublicAccess.BLOCK_ALL,\n enforceSSL: true,\n objectOwnership: ObjectOwnership.BUCKET_OWNER_ENFORCED,\n };\n\n super(scope, id, { ...defaultProps, ...props, ...requiredProps });\n }\n}\n","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { findGitBranch } from \"@codedrifters/utils\";\nimport { Bucket } from \"aws-cdk-lib/aws-s3\";\nimport { BucketDeployment, Source } from \"aws-cdk-lib/aws-s3-deployment\";\nimport { StringParameter } from \"aws-cdk-lib/aws-ssm\";\nimport { paramCase } from \"change-case\";\nimport { Construct } from \"constructs\";\n\n/*******************************************************************************\n *\n * STATIC CONTENT UPLOADER\n *\n * This construct uploads a directory of content from a local location into S3.\n *\n * To support PR and branch specific builds, each S3 bucket can store content\n * for multiple domains and builds, using the following format:\n *\n * S3-bucket/domain/*\n *\n * A bucket used to store content for stage.openhi.org might have the\n * following directory structure (all in the same bucket).\n *\n * `/stage.openhi.org/*` serves content to stage.openhi.org\n * `/feature-7.stage.openhi.org/*` serves content to feature-7.stage.openhi.org\n * `/pr-123.stage.openhi.org/*` serves content to pr-123.stage.openhi.org\n *\n ******************************************************************************/\n\nexport interface StaticContentProps {\n /**\n * Parameter name to use when storing the static hosting bucket's ARN.\n * This is needed in other later steps when deploying hosted content to S3.\n */\n readonly bucketArnParamName?: string;\n\n /**\n * Absolute path to directory containing content for the website.\n */\n readonly contentSourceDirectory: string;\n\n /**\n * Directory to place content into. Should start with a slash.\n * Example: '/widget'\n */\n readonly contentDestinationDirectory: string;\n\n /**\n * The sub domain prefix (ie: images)\n *\n * @default git branch name\n */\n readonly subDomain?: string;\n\n /**\n * The full domain (ie: staging.codedrifters.com)\n */\n readonly fullDomain: string;\n}\n\nexport class StaticContent extends Construct {\n constructor(scope: Construct, id: string, props: StaticContentProps) {\n super(scope, id);\n\n /***************************************************************************\n *\n * Initial Setup\n *\n * Set some defaults, build domain information.\n *\n **************************************************************************/\n\n const {\n bucketArnParamName,\n contentSourceDirectory,\n contentDestinationDirectory,\n subDomain,\n fullDomain,\n } = {\n bucketArnParamName: \"/STATIC_WEBSITE/BUCKET_ARN\",\n subDomain: findGitBranch(),\n ...props,\n };\n\n /***************************************************************************\n *\n * Import and build some values from Param Store during deployment.\n *\n **************************************************************************/\n\n const keyPrefix = [paramCase(subDomain), fullDomain].join(\".\");\n\n const bucketArn = StringParameter.valueForStringParameter(\n this,\n bucketArnParamName,\n );\n const bucket = Bucket.fromBucketArn(this, \"bucket\", bucketArn);\n\n /***************************************************************************\n *\n * Gather the sources we'll be deploying. We need to have an empty source\n * for tests since it will change all the time and bork up the test\n * snapshots if we don't.\n *\n **************************************************************************/\n\n const isTestEnv = process.env.VITEST === \"true\";\n const sources = isTestEnv ? [] : [Source.asset(contentSourceDirectory)];\n\n new BucketDeployment(this, \"deploy\", {\n sources,\n destinationBucket: bucket,\n retainOnDelete: false,\n destinationKeyPrefix: `${keyPrefix}${contentDestinationDirectory}`,\n });\n }\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { Duration, StackProps } from \"aws-cdk-lib\";\nimport {\n Certificate,\n CertificateValidation,\n} from \"aws-cdk-lib/aws-certificatemanager\";\nimport {\n AccessLevel,\n AllowedMethods,\n CacheCookieBehavior,\n CacheHeaderBehavior,\n CachePolicy,\n CacheQueryStringBehavior,\n Distribution,\n LambdaEdgeEventType,\n S3OriginAccessControl,\n Signing,\n ViewerProtocolPolicy,\n} from \"aws-cdk-lib/aws-cloudfront\";\nimport { S3BucketOrigin } from \"aws-cdk-lib/aws-cloudfront-origins\";\nimport { Runtime } from \"aws-cdk-lib/aws-lambda\";\nimport { NodejsFunction } from \"aws-cdk-lib/aws-lambda-nodejs\";\nimport { LogGroup, RetentionDays } from \"aws-cdk-lib/aws-logs\";\nimport {\n ARecord,\n HostedZone,\n HostedZoneAttributes,\n IHostedZone,\n RecordTarget,\n} from \"aws-cdk-lib/aws-route53\";\nimport { CloudFrontTarget } from \"aws-cdk-lib/aws-route53-targets\";\nimport { StringParameter } from \"aws-cdk-lib/aws-ssm\";\nimport { Construct } from \"constructs\";\nimport type { HostingMode } from \"./static-hosting.viewer-request-handler\";\nimport { PrivateBucket, PrivateBucketProps } from \"../s3/private-bucket\";\n\nexport interface StaticDomainProps {\n /**\n * The base domain (ie: codedrifters.com)\n */\n readonly baseDomain: string;\n\n /**\n * Hosted zone ID for the base domain.\n */\n readonly hostedZoneAttributes: HostedZoneAttributes;\n}\n\nexport interface StaticHostingProps extends StackProps {\n /**\n * Short description used in various places for traceability.\n */\n readonly description?: string;\n\n /**\n * Values used to connect a domain name to the cloudfront distribution. If not\n * supplied, cloudfront doesn't use a custom domain.\n */\n readonly staticDomainProps?: StaticDomainProps;\n\n /**\n * Parameter name to use when storing the static hosting bucket's ARN.\n * This is needed in other later steps when deploying hosted content to S3.\n */\n readonly bucketArnParamName?: string;\n\n /**\n * Parameter name to use when storing the CloudFront Distribution Domain Name.\n */\n readonly distributionDomainParamName?: string;\n\n /**\n * Parameter name to use when storing the CloudFront Distribution ID.\n */\n readonly distributionIDParamName?: string;\n\n /**\n * Props to pass to the private S3 bucket.\n */\n readonly privateBucketProps?: PrivateBucketProps;\n\n /**\n * Selects how path-like URIs are rewritten by the viewer-request\n * `Lambda@Edge` handler.\n *\n * - `spa` (default): path-like URIs rewrite to `/index.html` so a\n * single-page app can serve its one root index and let the client-side\n * router handle the path.\n * - `static`: path-like URIs append `/index.html` (e.g. `/docs` →\n * `/docs/index.html`) so multi-page static sites can serve distinct\n * HTML per path.\n *\n * Multi-tenant domain-folder prepending runs after the rewrite in both\n * modes and is unaffected by this prop.\n *\n * @default \"spa\"\n */\n readonly hostingMode?: HostingMode;\n}\n\nexport class StaticHosting extends Construct {\n /**\n * Full domain name used as basis for hosting.\n */\n public readonly fullDomain: string;\n\n constructor(scope: Construct, id: string, props: StaticHostingProps = {}) {\n super(scope, id);\n\n /***************************************************************************\n *\n * Initial Setup\n *\n * Set some defaults, build domain information.\n *\n **************************************************************************/\n\n const {\n bucketArnParamName,\n distributionDomainParamName,\n distributionIDParamName,\n staticDomainProps,\n privateBucketProps,\n hostingMode,\n } = {\n bucketArnParamName: \"/STATIC_WEBSITE/BUCKET_ARN\",\n distributionDomainParamName: \"/STATIC_WEBSITE/DISTRIBUTION_DOMAIN\",\n distributionIDParamName: \"/STATIC_WEBSITE/DISTRIBUTION_ID\",\n hostingMode: \"spa\" as HostingMode,\n ...props,\n };\n\n const { baseDomain, hostedZoneAttributes } = staticDomainProps ?? {};\n\n /***************************************************************************\n *\n * PRIVATE BUCKET\n *\n * A bucket to store the files within.\n * Save ARN for later deploys.\n *\n **************************************************************************/\n\n const bucket = new PrivateBucket(\n this,\n \"static-hosting-bucket\",\n privateBucketProps,\n );\n\n /***************************************************************************\n *\n * DNS & Wildcard Certificate\n *\n * If a zone Id as passed in, find the hosted zone and create a wildcard\n * certificate for the domain.\n *\n **************************************************************************/\n\n let zone: IHostedZone | undefined;\n let certificate: Certificate | undefined;\n\n if (hostedZoneAttributes && baseDomain) {\n zone = HostedZone.fromHostedZoneAttributes(\n this,\n \"zone\",\n hostedZoneAttributes,\n );\n certificate = new Certificate(this, \"wildcard-certificate\", {\n domainName: `*.${baseDomain}`,\n subjectAlternativeNames: [baseDomain],\n validation: CertificateValidation.fromDnsMultiZone({\n [`*.${baseDomain}`]: zone,\n [baseDomain]: zone,\n }),\n });\n }\n\n /******************************************************************************\n *\n * `LAMBDA@EDGE` FUNCTION\n *\n * This handles rewriting the path from domain name.\n *\n *****************************************************************************/\n\n // Explicit entry required: when omitted, NodejsFunction infers the path from the\n // call site (the built lib/index.js), so it looks for index.viewer-request-handler.js\n // in the package. That file is only emitted if we add it as a separate tsup entry.\n // Use .js when present (built package); fall back to .ts for tests running from source.\n const handlerJs = path.join(\n __dirname,\n \"static-hosting.viewer-request-handler.js\",\n );\n const handlerTs = path.join(\n __dirname,\n \"static-hosting.viewer-request-handler.ts\",\n );\n const handlerEntry = fs.existsSync(handlerJs) ? handlerJs : handlerTs;\n\n const handler = new NodejsFunction(this, \"viewer-request-handler\", {\n entry: handlerEntry,\n handler: hostingMode === \"static\" ? \"staticHandler\" : \"spaHandler\",\n memorySize: 128,\n runtime: Runtime.NODEJS_24_X,\n logGroup: new LogGroup(this, \"viewer-request-handler-log-group\", {\n retention: RetentionDays.ONE_MONTH,\n }),\n });\n\n /******************************************************************************\n *\n * CLOUDFRONT CONFIG\n *\n * Setup a CloudFront Distribution for the bucket.\n *\n *****************************************************************************/\n\n const cachePolicy = new CachePolicy(this, \"cloudfront-policy\", {\n comment: \"Relatively conservative TTL policy.\",\n maxTtl: Duration.seconds(300),\n minTtl: Duration.seconds(0),\n defaultTtl: Duration.seconds(60),\n headerBehavior: CacheHeaderBehavior.none(),\n queryStringBehavior: CacheQueryStringBehavior.none(),\n cookieBehavior: CacheCookieBehavior.none(),\n enableAcceptEncodingGzip: true,\n enableAcceptEncodingBrotli: true,\n });\n\n const oac = new S3OriginAccessControl(this, \"MyOAC\", {\n signing: Signing.SIGV4_NO_OVERRIDE,\n });\n const origin = S3BucketOrigin.withOriginAccessControl(bucket, {\n originAccessControl: oac,\n originAccessLevels: [AccessLevel.READ],\n });\n\n const distribution = new Distribution(this, \"cloudfront-distribution\", {\n comment: `Distribution for ${props.description ?? id}`,\n\n /**\n * Only if domain was supplied\n */\n ...(certificate && baseDomain\n ? {\n certificate,\n domainNames: [baseDomain, `*.${baseDomain}`],\n }\n : {}),\n\n defaultBehavior: {\n origin,\n viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,\n cachePolicy,\n allowedMethods: AllowedMethods.ALLOW_GET_HEAD_OPTIONS,\n edgeLambdas: [\n {\n functionVersion: handler.currentVersion,\n eventType: LambdaEdgeEventType.VIEWER_REQUEST,\n },\n ],\n },\n defaultRootObject: \"index.html\",\n });\n\n /**\n * We finally have enough information to set the full domain.\n */\n this.fullDomain =\n certificate && baseDomain ? baseDomain : distribution.domainName;\n\n /***************************************************************************\n *\n * DNS ENTRY\n *\n * Link cloudfront to both the root fulldomain and all possible subdomains.\n *\n **************************************************************************/\n\n if (zone) {\n new ARecord(this, \"root-dns-entry\", {\n zone,\n recordName: baseDomain ? baseDomain : \"\",\n target: RecordTarget.fromAlias(new CloudFrontTarget(distribution)),\n });\n\n new ARecord(this, \"wc-dns-entry\", {\n zone,\n recordName: baseDomain ? `*.${baseDomain}` : \"*\",\n target: RecordTarget.fromAlias(new CloudFrontTarget(distribution)),\n });\n }\n\n /***************************************************************************\n *\n * EXPORTS\n *\n * Used by content uploader later.\n *\n **************************************************************************/\n\n new StringParameter(this, \"dist-domain\", {\n description: `GENERATED DO NOT CHANGE - CloudFront Distribution Details (${props.description ?? id}).`,\n parameterName: distributionDomainParamName,\n stringValue: distribution.domainName,\n });\n\n new StringParameter(this, \"dist-id\", {\n description: `GENERATED DO NOT CHANGE - CloudFront Distribution Details (${props.description ?? id}).`,\n parameterName: distributionIDParamName,\n stringValue: distribution.distributionId,\n });\n\n new StringParameter(this, \"bucket-arn\", {\n description: `GENERATED DO NOT CHANGE - S3 Bucket ARN for (${props.description ?? id}).`,\n parameterName: bucketArnParamName,\n stringValue: bucket.bucketArn,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKa,IAAAA,SAAA,iBAAiB;;;;MAI5B,KAAK;;;;MAKL,OAAO;;;;MAKP,MAAM;;AAYK,IAAAA,SAAA,yBAAyB;;;;;MAKpC,SAAS;;;;;MAKT,WAAW;;AAcA,IAAAA,SAAA,uBAAuBA,SAAA;;;;;;;;;;ACvDpC,QAAA,uBAAA,QAAA,eAAA;AAQO,QAAMC,iBAAgB,MAAa;AACx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,GAAI,eAAe,aACf;AAAA,QACE;AAAA,QACA,aAAa,CAAC,YAAY,KAAK,UAAU,EAAE;AAAA,MAC7C,IACA,CAAC;AAAA,MAEL,iBAAiB;AAAA,QACf;AAAA,QACA,sBAAsB,2CAAqB;AAAA,QAC3C;AAAA,QACA,gBAAgB,qCAAe;AAAA,QAC/B,aAAa;AAAA,UACX;AAAA,YACE,iBAAiB,QAAQ;AAAA,YACzB,WAAW,0CAAoB;AAAA,UACjC;AAAA,QACF;AAAA,MACF;AAAA,MACA,mBAAmB;AAAA,IACrB,CAAC;AAKD,SAAK,aACH,eAAe,aAAa,aAAa,aAAa;AAUxD,QAAI,MAAM;AACR,UAAI,2BAAQ,MAAM,kBAAkB;AAAA,QAClC;AAAA,QACA,YAAY,aAAa,aAAa;AAAA,QACtC,QAAQ,gCAAa,UAAU,IAAI,4CAAiB,YAAY,CAAC;AAAA,MACnE,CAAC;AAED,UAAI,2BAAQ,MAAM,gBAAgB;AAAA,QAChC;AAAA,QACA,YAAY,aAAa,KAAK,UAAU,KAAK;AAAA,QAC7C,QAAQ,gCAAa,UAAU,IAAI,4CAAiB,YAAY,CAAC;AAAA,MACnE,CAAC;AAAA,IACH;AAUA,QAAI,gCAAgB,MAAM,eAAe;AAAA,MACvC,aAAa,8DAA8D,MAAM,eAAe,EAAE;AAAA,MAClG,eAAe;AAAA,MACf,aAAa,aAAa;AAAA,IAC5B,CAAC;AAED,QAAI,gCAAgB,MAAM,WAAW;AAAA,MACnC,aAAa,8DAA8D,MAAM,eAAe,EAAE;AAAA,MAClG,eAAe;AAAA,MACf,aAAa,aAAa;AAAA,IAC5B,CAAC;AAED,QAAI,gCAAgB,MAAM,cAAc;AAAA,MACtC,aAAa,gDAAgD,MAAM,eAAe,EAAE;AAAA,MACpF,eAAe;AAAA,MACf,aAAa,OAAO;AAAA,IACtB,CAAC;AAAA,EACH;AACF;","names":["exports","findGitBranch","exports","exports","exports","fs","path","import_aws_s3","fs","path","import_aws_cdk_lib","import_aws_lambda_nodejs","import_aws_ssm","import_constructs"]}
1
+ {"version":3,"sources":["../../utils/src/aws/aws-types.ts","../../utils/src/git/git-utils.ts","../../utils/src/string/string-utils.ts","../../utils/src/index.ts","../src/index.ts","../src/lambda/pnpm-workspace-nodejs-function.ts","../src/lambda/pnpm-workspace-parser.ts","../src/s3/private-bucket.ts","../src/static-hosting/static-content.ts","../src/static-hosting/static-hosting.ts"],"sourcesContent":["/**\n * Stage Types\n *\n * What stage of deployment is this? Dev, staging, or prod?\n */\nexport const AWS_STAGE_TYPE = {\n /**\n * Development environment, typically used for testing and development.\n */\n DEV: \"dev\",\n\n /**\n * Staging environment, used for pre-production testing.\n */\n STAGE: \"stage\",\n\n /**\n * Production environment, used for live deployments.\n */\n PROD: \"prod\",\n} as const;\n\n/**\n * Above const as a type.\n */\nexport type AwsStageType = (typeof AWS_STAGE_TYPE)[keyof typeof AWS_STAGE_TYPE];\n\n/**\n * Deployment target role: whether an (account, region) is the primary or\n * secondary deployment target (e.g. primary vs replica region).\n */\nexport const DEPLOYMENT_TARGET_ROLE = {\n /**\n * Account and region that represents the primary region for this service.\n * For example, the base DynamoDB Region for global tables.\n */\n PRIMARY: \"primary\",\n /**\n * Account and region that represents a secondary region for this service.\n * For example, a replica region for a global DynamoDB table.\n */\n SECONDARY: \"secondary\",\n} as const;\n\n/**\n * Type for deployment target role values.\n */\nexport type DeploymentTargetRoleType =\n (typeof DEPLOYMENT_TARGET_ROLE)[keyof typeof DEPLOYMENT_TARGET_ROLE];\n\n/**\n * Environment types (primary/secondary).\n *\n * @deprecated Use {@link DEPLOYMENT_TARGET_ROLE} instead. This constant is maintained for backward compatibility.\n */\nexport const AWS_ENVIRONMENT_TYPE = DEPLOYMENT_TARGET_ROLE;\n\n/**\n * Type for environment type values.\n *\n * @deprecated Use {@link DeploymentTargetRoleType} instead. This type is maintained for backward compatibility.\n */\nexport type AwsEnvironmentType = DeploymentTargetRoleType;\n","import { execSync } from \"node:child_process\";\n\n/**\n * Returns the current full git branch name\n *\n * ie: feature/1234 returns feature/1234\n *\n */\nexport const findGitBranch = (): string => {\n return execSync(\"git rev-parse --abbrev-ref HEAD\")\n .toString(\"utf8\")\n .replace(/[\\n\\r\\s]+$/, \"\");\n};\n\nexport const findGitRepoName = (): string => {\n /**\n * When running in github actions this will be populated.\n */\n if (process.env.GITHUB_REPOSITORY) {\n return process.env.GITHUB_REPOSITORY;\n }\n\n /**\n * locally, we need to extract the repo name from the git config.\n */\n const remote = execSync(\"git config --get remote.origin.url\")\n .toString(\"utf8\")\n .replace(/[\\n\\r\\s]+$/, \"\")\n .trim();\n\n const match = remote.match(/[:\\/]([^/]+\\/[^/]+?)(?:\\.git)?$/);\n const repoName = match ? match[1] : \"error-repo-name\";\n\n return repoName;\n};\n","import * as crypto from \"node:crypto\";\n\n/**\n *\n * @param inString - string to hash\n * @param trimLength - trim to this length (defaults to 999 chars)\n * @returns Hex-encoded sha256 digest, truncated to `trimLength` characters.\n */\nexport const hashString = (inString: string, trimLength: number = 999) => {\n return crypto\n .createHash(\"sha256\")\n .update(inString)\n .digest(\"hex\")\n .substring(0, trimLength);\n};\n\n/**\n *\n * @param inputString - string to truncate\n * @param maxLength - max length of this string\n * @returns trimmed string\n */\nexport const trimStringLength = (inputString: string, maxLength: number) => {\n return inputString.length < maxLength\n ? inputString\n : inputString.substring(0, maxLength);\n};\n","export * from \"./aws/aws-types\";\nexport * from \"./git/git-utils\";\nexport * from \"./string/string-utils\";\n","export * from \"./lambda\";\nexport * from \"./s3\";\nexport * from \"./static-hosting\";\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n ICommandHooks,\n NodejsFunction,\n NodejsFunctionProps,\n} from \"aws-cdk-lib/aws-lambda-nodejs\";\nimport { Construct } from \"constructs\";\nimport {\n findPnpmWorkspaceFile,\n mergeNpmrc,\n readPnpmWorkspacePolicy,\n renderNpmrcLines,\n} from \"./pnpm-workspace-parser\";\n\n/**\n * Props for `PnpmWorkspaceNodejsFunction`. Extends\n * `NodejsFunctionProps` so the wrapper is a drop-in for any existing\n * `NodejsFunction` call site.\n */\nexport interface PnpmWorkspaceNodejsFunctionProps extends NodejsFunctionProps {\n /**\n * Directory to begin the upward search for `pnpm-workspace.yaml`.\n * Defaults to the directory of the resolved entry path.\n */\n readonly workspaceSearchFrom?: string;\n\n /**\n * Skip the policy-mirror step entirely. Useful for tests or when the\n * caller wants the pure `NodejsFunction` behavior.\n *\n * @default false\n */\n readonly disablePnpmPolicyMirror?: boolean;\n}\n\n/**\n * Result of `mirrorPnpmWorkspacePolicy` — describes what the policy\n * mirror did for one entry.\n */\nexport interface MirrorPnpmWorkspacePolicyResult {\n /** Resolved `.npmrc` path if a write happened, otherwise undefined. */\n readonly npmrcPath?: string;\n /** Reason the mirror was a no-op, if it was. */\n readonly skippedReason?:\n | \"missing-entry\"\n | \"missing-workspace-file\"\n | \"empty-policy\"\n | \"no-change\";\n}\n\n/**\n * Mirror the workspace pnpm policy into an `.npmrc` adjacent to the\n * Lambda entry. Pure side-effect helper used by\n * `PnpmWorkspaceNodejsFunction`; exported so consumers can drive it\n * from other call sites if desired.\n */\nexport const mirrorPnpmWorkspacePolicy = (params: {\n readonly entry: string;\n readonly workspaceSearchFrom?: string;\n}): MirrorPnpmWorkspacePolicyResult => {\n const { entry, workspaceSearchFrom } = params;\n if (!fs.existsSync(entry)) {\n return { skippedReason: \"missing-entry\" };\n }\n\n const entryDir = path.dirname(path.resolve(entry));\n const searchFrom = workspaceSearchFrom\n ? path.resolve(workspaceSearchFrom)\n : entryDir;\n\n const workspaceFile = findPnpmWorkspaceFile(searchFrom);\n if (!workspaceFile) {\n return { skippedReason: \"missing-workspace-file\" };\n }\n\n const policy = readPnpmWorkspacePolicy(workspaceFile);\n const lines = renderNpmrcLines(policy);\n if (lines.length === 0) {\n return { skippedReason: \"empty-policy\" };\n }\n\n const npmrcPath = path.join(entryDir, \".npmrc\");\n const existing = fs.existsSync(npmrcPath)\n ? fs.readFileSync(npmrcPath, \"utf8\")\n : undefined;\n const merged = mergeNpmrc(existing, lines);\n\n if (merged === existing) {\n return { npmrcPath, skippedReason: \"no-change\" };\n }\n\n fs.writeFileSync(npmrcPath, merged);\n return { npmrcPath };\n};\n\n/**\n * Build an `ICommandHooks` implementation that copies an\n * entry-adjacent `.npmrc` into the bundling input directory before\n * `pnpm install` runs. Composes with any caller-supplied hooks so\n * existing `beforeBundling` / `beforeInstall` / `afterBundling`\n * commands are preserved.\n *\n * Exported for unit testing; the construct wires this automatically.\n */\nexport const buildNpmrcCopyCommandHooks = (params: {\n readonly npmrcPath: string;\n readonly existingHooks?: ICommandHooks;\n}): ICommandHooks => {\n const { npmrcPath, existingHooks } = params;\n return {\n beforeBundling(inputDir: string, outputDir: string): string[] {\n return existingHooks?.beforeBundling(inputDir, outputDir) ?? [];\n },\n beforeInstall(inputDir: string, outputDir: string): string[] {\n const callerCommands =\n existingHooks?.beforeInstall(inputDir, outputDir) ?? [];\n const copyCommand = `cp ${npmrcPath} ${inputDir}/.npmrc`;\n return [...callerCommands, copyCommand];\n },\n afterBundling(inputDir: string, outputDir: string): string[] {\n return existingHooks?.afterBundling(inputDir, outputDir) ?? [];\n },\n };\n};\n\n/**\n * A `NodejsFunction` wrapper that mirrors the workspace's pnpm policy\n * (currently `minimumReleaseAge` and `minimumReleaseAgeExclude`) into\n * an `.npmrc` adjacent to the Lambda entry before bundling.\n *\n * CDK's bundler runs `pnpm install` in an isolated temp directory\n * outside the workspace, which means `pnpm-workspace.yaml` settings\n * do not apply there. CDK does **not** copy arbitrary entry-adjacent\n * files into the bundling input directory, so the construct also\n * wires a `bundling.commandHooks.beforeInstall` hook that copies the\n * rendered `.npmrc` into the bundling input directory immediately\n * before `pnpm install` runs. Caller-supplied `commandHooks` are\n * preserved — the copy command is appended to whatever the caller\n * already returns from `beforeInstall`.\n *\n * See the `pnpm-workspace-nodejs-function` documentation page for\n * full details on what gets mirrored, merge behaviour against an\n * existing `.npmrc`, and when to disable the mirror.\n */\nexport class PnpmWorkspaceNodejsFunction extends NodejsFunction {\n constructor(\n scope: Construct,\n id: string,\n props: PnpmWorkspaceNodejsFunctionProps,\n ) {\n let mirrorResult: MirrorPnpmWorkspacePolicyResult | undefined;\n if (!props.disablePnpmPolicyMirror && props.entry) {\n mirrorResult = mirrorPnpmWorkspacePolicy({\n entry: props.entry,\n workspaceSearchFrom: props.workspaceSearchFrom,\n });\n }\n\n const { disablePnpmPolicyMirror, workspaceSearchFrom, ...rest } = props;\n void disablePnpmPolicyMirror;\n void workspaceSearchFrom;\n\n // Wire the beforeInstall hook only when the mirror produced (or\n // confirmed) an .npmrc file on disk. Other skippedReason values\n // (`missing-entry`, `missing-workspace-file`, `empty-policy`) mean\n // there is nothing to copy; falling through to plain NodejsFunction\n // behavior is correct in those cases.\n const npmrcPath = mirrorResult?.npmrcPath;\n const shouldWireHook = npmrcPath !== undefined && fs.existsSync(npmrcPath);\n\n const propsWithHook: NodejsFunctionProps = shouldWireHook\n ? {\n ...rest,\n bundling: {\n ...rest.bundling,\n commandHooks: buildNpmrcCopyCommandHooks({\n npmrcPath,\n existingHooks: rest.bundling?.commandHooks,\n }),\n },\n }\n : rest;\n\n super(scope, id, propsWithHook);\n }\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as yaml from \"js-yaml\";\n\n/**\n * Subset of `pnpm-workspace.yaml` fields that map to `.npmrc` keys\n * pnpm honours when running install in a non-workspace directory.\n */\nexport interface PnpmWorkspacePolicy {\n /** `minimumReleaseAge` (minutes) — equivalent to `.npmrc` `minimum-release-age`. */\n readonly minimumReleaseAge?: number;\n /**\n * `minimumReleaseAgeExclude` — equivalent to `.npmrc`\n * `minimum-release-age-exclude` (comma-separated when serialised).\n */\n readonly minimumReleaseAgeExclude?: ReadonlyArray<string>;\n}\n\n/**\n * Walk up from `startDir` until a `pnpm-workspace.yaml` file is found\n * and return its absolute path. Returns `undefined` when the filesystem\n * root is reached without finding one.\n */\nexport const findPnpmWorkspaceFile = (startDir: string): string | undefined => {\n let current = path.resolve(startDir);\n while (true) {\n const candidate = path.join(current, \"pnpm-workspace.yaml\");\n if (fs.existsSync(candidate)) {\n return candidate;\n }\n const parent = path.dirname(current);\n if (parent === current) {\n return undefined;\n }\n current = parent;\n }\n};\n\n/**\n * Read the policy subset (`minimumReleaseAge` and\n * `minimumReleaseAgeExclude`) from a `pnpm-workspace.yaml` file.\n *\n * Returns an empty object when the file is missing, unreadable, or\n * contains neither key. Throws when the file is present but YAML\n * parsing fails — the caller is expected to surface a clear error.\n */\nexport const readPnpmWorkspacePolicy = (\n workspaceFile: string,\n): PnpmWorkspacePolicy => {\n if (!fs.existsSync(workspaceFile)) {\n return {};\n }\n\n const raw = fs.readFileSync(workspaceFile, \"utf8\");\n const parsed = yaml.load(raw);\n\n if (!parsed || typeof parsed !== \"object\") {\n return {};\n }\n\n const obj = parsed as Record<string, unknown>;\n const policy: {\n -readonly [K in keyof PnpmWorkspacePolicy]: PnpmWorkspacePolicy[K];\n } = {};\n\n const age = obj.minimumReleaseAge;\n if (typeof age === \"number\" && Number.isFinite(age)) {\n policy.minimumReleaseAge = age;\n }\n\n const exclude = obj.minimumReleaseAgeExclude;\n if (Array.isArray(exclude)) {\n const cleaned = exclude.filter(\n (entry): entry is string => typeof entry === \"string\" && entry.length > 0,\n );\n if (cleaned.length > 0) {\n policy.minimumReleaseAgeExclude = cleaned;\n }\n }\n\n return policy;\n};\n\n/**\n * Render an `.npmrc` body that pnpm will honour when installing in\n * a directory outside the workspace tree. The keys emitted here are\n * the `.npmrc` equivalents of the `pnpm-workspace.yaml` fields in\n * {@link PnpmWorkspacePolicy} — pnpm reads `minimum-release-age` and\n * `minimum-release-age-exclude` from `.npmrc`, not from the workspace\n * file, when the install runs outside the workspace.\n *\n * Returns an empty string when the policy carries no relevant fields.\n */\nexport const renderNpmrcLines = (\n policy: PnpmWorkspacePolicy,\n): ReadonlyArray<string> => {\n const lines: Array<string> = [];\n\n if (typeof policy.minimumReleaseAge === \"number\") {\n lines.push(`minimum-release-age=${policy.minimumReleaseAge}`);\n }\n\n const exclude = policy.minimumReleaseAgeExclude ?? [];\n if (exclude.length > 0) {\n lines.push(`minimum-release-age-exclude=${exclude.join(\",\")}`);\n }\n\n return lines;\n};\n\n/**\n * Parse the body of an existing `.npmrc` file into a map of trimmed\n * key/value pairs. Lines that are blank or start with `#` are dropped.\n * Lines without an `=` are dropped.\n */\nexport const parseNpmrc = (body: string): Map<string, string> => {\n const map = new Map<string, string>();\n for (const rawLine of body.split(/\\r?\\n/)) {\n const line = rawLine.trim();\n if (line.length === 0 || line.startsWith(\"#\")) {\n continue;\n }\n const eq = line.indexOf(\"=\");\n if (eq < 0) {\n continue;\n }\n const key = line.slice(0, eq).trim();\n const value = line.slice(eq + 1).trim();\n if (key.length > 0) {\n map.set(key, value);\n }\n }\n return map;\n};\n\n/**\n * Merge a set of policy-derived `.npmrc` lines into an existing\n * `.npmrc` body. Our keys overwrite matching keys in the existing\n * body; all other keys are preserved. Returns the new `.npmrc` body\n * (always terminated by a trailing newline when non-empty).\n */\nexport const mergeNpmrc = (\n existing: string | undefined,\n ourLines: ReadonlyArray<string>,\n): string => {\n if (ourLines.length === 0) {\n return existing ?? \"\";\n }\n\n const ourMap = new Map<string, string>();\n for (const line of ourLines) {\n const eq = line.indexOf(\"=\");\n if (eq < 0) {\n continue;\n }\n ourMap.set(line.slice(0, eq).trim(), line.slice(eq + 1).trim());\n }\n\n const existingMap = parseNpmrc(existing ?? \"\");\n for (const [key, value] of ourMap) {\n existingMap.set(key, value);\n }\n\n const orderedKeys: Array<string> = [];\n const seen = new Set<string>();\n\n // Preserve the original line order for any pre-existing keys.\n for (const rawLine of (existing ?? \"\").split(/\\r?\\n/)) {\n const line = rawLine.trim();\n if (line.length === 0 || line.startsWith(\"#\")) {\n continue;\n }\n const eq = line.indexOf(\"=\");\n if (eq < 0) {\n continue;\n }\n const key = line.slice(0, eq).trim();\n if (key.length > 0 && existingMap.has(key) && !seen.has(key)) {\n orderedKeys.push(key);\n seen.add(key);\n }\n }\n\n // Append any keys we added that weren't already present.\n for (const key of ourMap.keys()) {\n if (!seen.has(key)) {\n orderedKeys.push(key);\n seen.add(key);\n }\n }\n\n const body = orderedKeys\n .map((key) => `${key}=${existingMap.get(key)}`)\n .join(\"\\n\");\n\n return body.length === 0 ? \"\" : `${body}\\n`;\n};\n","import { RemovalPolicy } from \"aws-cdk-lib\";\nimport {\n BlockPublicAccess,\n Bucket,\n BucketProps,\n ObjectOwnership,\n} from \"aws-cdk-lib/aws-s3\";\nimport { Construct } from \"constructs\";\n\nexport interface PrivateBucketProps extends BucketProps {}\n\nexport class PrivateBucket extends Bucket {\n constructor(scope: Construct, id: string, props: PrivateBucketProps = {}) {\n const defaultProps = {\n removalPolicy: props.removalPolicy ?? RemovalPolicy.RETAIN,\n autoDeleteObjects: props.removalPolicy === RemovalPolicy.DESTROY,\n };\n\n const requiredProps = {\n publicReadAccess: false,\n blockPublicAccess: BlockPublicAccess.BLOCK_ALL,\n enforceSSL: true,\n objectOwnership: ObjectOwnership.BUCKET_OWNER_ENFORCED,\n };\n\n super(scope, id, { ...defaultProps, ...props, ...requiredProps });\n }\n}\n","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { findGitBranch } from \"@codedrifters/utils\";\nimport { Bucket } from \"aws-cdk-lib/aws-s3\";\nimport { BucketDeployment, Source } from \"aws-cdk-lib/aws-s3-deployment\";\nimport { StringParameter } from \"aws-cdk-lib/aws-ssm\";\nimport { paramCase } from \"change-case\";\nimport { Construct } from \"constructs\";\n\n/*******************************************************************************\n *\n * STATIC CONTENT UPLOADER\n *\n * This construct uploads a directory of content from a local location into S3.\n *\n * To support PR and branch specific builds, each S3 bucket can store content\n * for multiple domains and builds, using the following format:\n *\n * S3-bucket/domain/*\n *\n * A bucket used to store content for stage.openhi.org might have the\n * following directory structure (all in the same bucket).\n *\n * `/stage.openhi.org/*` serves content to stage.openhi.org\n * `/feature-7.stage.openhi.org/*` serves content to feature-7.stage.openhi.org\n * `/pr-123.stage.openhi.org/*` serves content to pr-123.stage.openhi.org\n *\n ******************************************************************************/\n\nexport interface StaticContentProps {\n /**\n * Parameter name to use when storing the static hosting bucket's ARN.\n * This is needed in other later steps when deploying hosted content to S3.\n */\n readonly bucketArnParamName?: string;\n\n /**\n * Absolute path to directory containing content for the website.\n */\n readonly contentSourceDirectory: string;\n\n /**\n * Directory to place content into. Should start with a slash.\n * Example: '/widget'\n */\n readonly contentDestinationDirectory: string;\n\n /**\n * The sub domain prefix (ie: images)\n *\n * @default git branch name\n */\n readonly subDomain?: string;\n\n /**\n * The full domain (ie: staging.codedrifters.com)\n */\n readonly fullDomain: string;\n}\n\nexport class StaticContent extends Construct {\n constructor(scope: Construct, id: string, props: StaticContentProps) {\n super(scope, id);\n\n /***************************************************************************\n *\n * Initial Setup\n *\n * Set some defaults, build domain information.\n *\n **************************************************************************/\n\n const {\n bucketArnParamName,\n contentSourceDirectory,\n contentDestinationDirectory,\n subDomain,\n fullDomain,\n } = {\n bucketArnParamName: \"/STATIC_WEBSITE/BUCKET_ARN\",\n subDomain: findGitBranch(),\n ...props,\n };\n\n /***************************************************************************\n *\n * Import and build some values from Param Store during deployment.\n *\n **************************************************************************/\n\n const keyPrefix = [paramCase(subDomain), fullDomain].join(\".\");\n\n const bucketArn = StringParameter.valueForStringParameter(\n this,\n bucketArnParamName,\n );\n const bucket = Bucket.fromBucketArn(this, \"bucket\", bucketArn);\n\n /***************************************************************************\n *\n * Gather the sources we'll be deploying. We need to have an empty source\n * for tests since it will change all the time and bork up the test\n * snapshots if we don't.\n *\n **************************************************************************/\n\n const isTestEnv = process.env.VITEST === \"true\";\n const sources = isTestEnv ? [] : [Source.asset(contentSourceDirectory)];\n\n new BucketDeployment(this, \"deploy\", {\n sources,\n destinationBucket: bucket,\n retainOnDelete: false,\n destinationKeyPrefix: `${keyPrefix}${contentDestinationDirectory}`,\n });\n }\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { Duration, StackProps } from \"aws-cdk-lib\";\nimport {\n Certificate,\n CertificateValidation,\n} from \"aws-cdk-lib/aws-certificatemanager\";\nimport {\n AccessLevel,\n AllowedMethods,\n CacheCookieBehavior,\n CacheHeaderBehavior,\n CachePolicy,\n CacheQueryStringBehavior,\n Distribution,\n LambdaEdgeEventType,\n S3OriginAccessControl,\n Signing,\n ViewerProtocolPolicy,\n} from \"aws-cdk-lib/aws-cloudfront\";\nimport { S3BucketOrigin } from \"aws-cdk-lib/aws-cloudfront-origins\";\nimport { Runtime } from \"aws-cdk-lib/aws-lambda\";\nimport { NodejsFunction } from \"aws-cdk-lib/aws-lambda-nodejs\";\nimport { LogGroup, RetentionDays } from \"aws-cdk-lib/aws-logs\";\nimport {\n ARecord,\n HostedZone,\n HostedZoneAttributes,\n IHostedZone,\n RecordTarget,\n} from \"aws-cdk-lib/aws-route53\";\nimport { CloudFrontTarget } from \"aws-cdk-lib/aws-route53-targets\";\nimport { StringParameter } from \"aws-cdk-lib/aws-ssm\";\nimport { Construct } from \"constructs\";\nimport type { HostingMode } from \"./static-hosting.viewer-request-handler\";\nimport { PrivateBucket, PrivateBucketProps } from \"../s3/private-bucket\";\n\nexport interface StaticDomainProps {\n /**\n * The base domain (ie: codedrifters.com)\n */\n readonly baseDomain: string;\n\n /**\n * Hosted zone ID for the base domain.\n */\n readonly hostedZoneAttributes: HostedZoneAttributes;\n}\n\nexport interface StaticHostingProps extends StackProps {\n /**\n * Short description used in various places for traceability.\n */\n readonly description?: string;\n\n /**\n * Values used to connect a domain name to the cloudfront distribution. If not\n * supplied, cloudfront doesn't use a custom domain.\n */\n readonly staticDomainProps?: StaticDomainProps;\n\n /**\n * Parameter name to use when storing the static hosting bucket's ARN.\n * This is needed in other later steps when deploying hosted content to S3.\n */\n readonly bucketArnParamName?: string;\n\n /**\n * Parameter name to use when storing the CloudFront Distribution Domain Name.\n */\n readonly distributionDomainParamName?: string;\n\n /**\n * Parameter name to use when storing the CloudFront Distribution ID.\n */\n readonly distributionIDParamName?: string;\n\n /**\n * Props to pass to the private S3 bucket.\n */\n readonly privateBucketProps?: PrivateBucketProps;\n\n /**\n * Selects how path-like URIs are rewritten by the viewer-request\n * `Lambda@Edge` handler.\n *\n * - `spa` (default): path-like URIs rewrite to `/index.html` so a\n * single-page app can serve its one root index and let the client-side\n * router handle the path.\n * - `static`: path-like URIs append `/index.html` (e.g. `/docs` →\n * `/docs/index.html`) so multi-page static sites can serve distinct\n * HTML per path.\n *\n * Multi-tenant domain-folder prepending runs after the rewrite in both\n * modes and is unaffected by this prop.\n *\n * @default \"spa\"\n */\n readonly hostingMode?: HostingMode;\n}\n\nexport class StaticHosting extends Construct {\n /**\n * Full domain name used as basis for hosting.\n */\n public readonly fullDomain: string;\n\n constructor(scope: Construct, id: string, props: StaticHostingProps = {}) {\n super(scope, id);\n\n /***************************************************************************\n *\n * Initial Setup\n *\n * Set some defaults, build domain information.\n *\n **************************************************************************/\n\n const {\n bucketArnParamName,\n distributionDomainParamName,\n distributionIDParamName,\n staticDomainProps,\n privateBucketProps,\n hostingMode,\n } = {\n bucketArnParamName: \"/STATIC_WEBSITE/BUCKET_ARN\",\n distributionDomainParamName: \"/STATIC_WEBSITE/DISTRIBUTION_DOMAIN\",\n distributionIDParamName: \"/STATIC_WEBSITE/DISTRIBUTION_ID\",\n hostingMode: \"spa\" as HostingMode,\n ...props,\n };\n\n const { baseDomain, hostedZoneAttributes } = staticDomainProps ?? {};\n\n /***************************************************************************\n *\n * PRIVATE BUCKET\n *\n * A bucket to store the files within.\n * Save ARN for later deploys.\n *\n **************************************************************************/\n\n const bucket = new PrivateBucket(\n this,\n \"static-hosting-bucket\",\n privateBucketProps,\n );\n\n /***************************************************************************\n *\n * DNS & Wildcard Certificate\n *\n * If a zone Id as passed in, find the hosted zone and create a wildcard\n * certificate for the domain.\n *\n **************************************************************************/\n\n let zone: IHostedZone | undefined;\n let certificate: Certificate | undefined;\n\n if (hostedZoneAttributes && baseDomain) {\n zone = HostedZone.fromHostedZoneAttributes(\n this,\n \"zone\",\n hostedZoneAttributes,\n );\n certificate = new Certificate(this, \"wildcard-certificate\", {\n domainName: `*.${baseDomain}`,\n subjectAlternativeNames: [baseDomain],\n validation: CertificateValidation.fromDnsMultiZone({\n [`*.${baseDomain}`]: zone,\n [baseDomain]: zone,\n }),\n });\n }\n\n /******************************************************************************\n *\n * `LAMBDA@EDGE` FUNCTION\n *\n * This handles rewriting the path from domain name.\n *\n *****************************************************************************/\n\n // Explicit entry required: when omitted, NodejsFunction infers the path from the\n // call site (the built lib/index.js), so it looks for index.viewer-request-handler.js\n // in the package. That file is only emitted if we add it as a separate tsup entry.\n // Use .js when present (built package); fall back to .ts for tests running from source.\n const handlerJs = path.join(\n __dirname,\n \"static-hosting.viewer-request-handler.js\",\n );\n const handlerTs = path.join(\n __dirname,\n \"static-hosting.viewer-request-handler.ts\",\n );\n const handlerEntry = fs.existsSync(handlerJs) ? handlerJs : handlerTs;\n\n const handler = new NodejsFunction(this, \"viewer-request-handler\", {\n entry: handlerEntry,\n handler: hostingMode === \"static\" ? \"staticHandler\" : \"spaHandler\",\n memorySize: 128,\n runtime: Runtime.NODEJS_24_X,\n logGroup: new LogGroup(this, \"viewer-request-handler-log-group\", {\n retention: RetentionDays.ONE_MONTH,\n }),\n });\n\n /******************************************************************************\n *\n * CLOUDFRONT CONFIG\n *\n * Setup a CloudFront Distribution for the bucket.\n *\n *****************************************************************************/\n\n const cachePolicy = new CachePolicy(this, \"cloudfront-policy\", {\n comment: \"Relatively conservative TTL policy.\",\n maxTtl: Duration.seconds(300),\n minTtl: Duration.seconds(0),\n defaultTtl: Duration.seconds(60),\n headerBehavior: CacheHeaderBehavior.none(),\n queryStringBehavior: CacheQueryStringBehavior.none(),\n cookieBehavior: CacheCookieBehavior.none(),\n enableAcceptEncodingGzip: true,\n enableAcceptEncodingBrotli: true,\n });\n\n const oac = new S3OriginAccessControl(this, \"MyOAC\", {\n signing: Signing.SIGV4_NO_OVERRIDE,\n });\n const origin = S3BucketOrigin.withOriginAccessControl(bucket, {\n originAccessControl: oac,\n originAccessLevels: [AccessLevel.READ],\n });\n\n const distribution = new Distribution(this, \"cloudfront-distribution\", {\n comment: `Distribution for ${props.description ?? id}`,\n\n /**\n * Only if domain was supplied\n */\n ...(certificate && baseDomain\n ? {\n certificate,\n domainNames: [baseDomain, `*.${baseDomain}`],\n }\n : {}),\n\n defaultBehavior: {\n origin,\n viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,\n cachePolicy,\n allowedMethods: AllowedMethods.ALLOW_GET_HEAD_OPTIONS,\n edgeLambdas: [\n {\n functionVersion: handler.currentVersion,\n eventType: LambdaEdgeEventType.VIEWER_REQUEST,\n },\n ],\n },\n defaultRootObject: \"index.html\",\n });\n\n /**\n * We finally have enough information to set the full domain.\n */\n this.fullDomain =\n certificate && baseDomain ? baseDomain : distribution.domainName;\n\n /***************************************************************************\n *\n * DNS ENTRY\n *\n * Link cloudfront to both the root fulldomain and all possible subdomains.\n *\n **************************************************************************/\n\n if (zone) {\n new ARecord(this, \"root-dns-entry\", {\n zone,\n recordName: baseDomain ? baseDomain : \"\",\n target: RecordTarget.fromAlias(new CloudFrontTarget(distribution)),\n });\n\n new ARecord(this, \"wc-dns-entry\", {\n zone,\n recordName: baseDomain ? `*.${baseDomain}` : \"*\",\n target: RecordTarget.fromAlias(new CloudFrontTarget(distribution)),\n });\n }\n\n /***************************************************************************\n *\n * EXPORTS\n *\n * Used by content uploader later.\n *\n **************************************************************************/\n\n new StringParameter(this, \"dist-domain\", {\n description: `GENERATED DO NOT CHANGE - CloudFront Distribution Details (${props.description ?? id}).`,\n parameterName: distributionDomainParamName,\n stringValue: distribution.domainName,\n });\n\n new StringParameter(this, \"dist-id\", {\n description: `GENERATED DO NOT CHANGE - CloudFront Distribution Details (${props.description ?? id}).`,\n parameterName: distributionIDParamName,\n stringValue: distribution.distributionId,\n });\n\n new StringParameter(this, \"bucket-arn\", {\n description: `GENERATED DO NOT CHANGE - S3 Bucket ARN for (${props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AAA,MAEL,iBAAiB;AAAA,QACf;AAAA,QACA,sBAAsB,2CAAqB;AAAA,QAC3C;AAAA,QACA,gBAAgB,qCAAe;AAAA,QAC/B,aAAa;AAAA,UACX;AAAA,YACE,iBAAiB,QAAQ;AAAA,YACzB,WAAW,0CAAoB;AAAA,UACjC;AAAA,QACF;AAAA,MACF;AAAA,MACA,mBAAmB;AAAA,IACrB,CAAC;AAKD,SAAK,aACH,eAAe,aAAa,aAAa,aAAa;AAUxD,QAAI,MAAM;AACR,UAAI,2BAAQ,MAAM,kBAAkB;AAAA,QAClC;AAAA,QACA,YAAY,aAAa,aAAa;AAAA,QACtC,QAAQ,gCAAa,UAAU,IAAI,4CAAiB,YAAY,CAAC;AAAA,MACnE,CAAC;AAED,UAAI,2BAAQ,MAAM,gBAAgB;AAAA,QAChC;AAAA,QACA,YAAY,aAAa,KAAK,UAAU,KAAK;AAAA,QAC7C,QAAQ,gCAAa,UAAU,IAAI,4CAAiB,YAAY,CAAC;AAAA,MACnE,CAAC;AAAA,IACH;AAUA,QAAI,gCAAgB,MAAM,eAAe;AAAA,MACvC,aAAa,8DAA8D,MAAM,eAAe,EAAE;AAAA,MAClG,eAAe;AAAA,MACf,aAAa,aAAa;AAAA,IAC5B,CAAC;AAED,QAAI,gCAAgB,MAAM,WAAW;AAAA,MACnC,aAAa,8DAA8D,MAAM,eAAe,EAAE;AAAA,MAClG,eAAe;AAAA,MACf,aAAa,aAAa;AAAA,IAC5B,CAAC;AAED,QAAI,gCAAgB,MAAM,cAAc;AAAA,MACtC,aAAa,gDAAgD,MAAM,eAAe,EAAE;AAAA,MACpF,eAAe;AAAA,MACf,aAAa,OAAO;AAAA,IACtB,CAAC;AAAA,EACH;AACF;","names":["exports","findGitBranch","exports","exports","exports","fs","path","import_aws_s3","fs","path","import_aws_cdk_lib","import_aws_lambda_nodejs","import_aws_ssm","import_constructs"]}
package/lib/index.mjs CHANGED
@@ -297,10 +297,27 @@ var mirrorPnpmWorkspacePolicy = (params) => {
297
297
  fs2.writeFileSync(npmrcPath, merged);
298
298
  return { npmrcPath };
299
299
  };
300
+ var buildNpmrcCopyCommandHooks = (params) => {
301
+ const { npmrcPath, existingHooks } = params;
302
+ return {
303
+ beforeBundling(inputDir, outputDir) {
304
+ return existingHooks?.beforeBundling(inputDir, outputDir) ?? [];
305
+ },
306
+ beforeInstall(inputDir, outputDir) {
307
+ const callerCommands = existingHooks?.beforeInstall(inputDir, outputDir) ?? [];
308
+ const copyCommand = `cp ${npmrcPath} ${inputDir}/.npmrc`;
309
+ return [...callerCommands, copyCommand];
310
+ },
311
+ afterBundling(inputDir, outputDir) {
312
+ return existingHooks?.afterBundling(inputDir, outputDir) ?? [];
313
+ }
314
+ };
315
+ };
300
316
  var PnpmWorkspaceNodejsFunction = class extends NodejsFunction {
301
317
  constructor(scope, id, props) {
318
+ let mirrorResult;
302
319
  if (!props.disablePnpmPolicyMirror && props.entry) {
303
- mirrorPnpmWorkspacePolicy({
320
+ mirrorResult = mirrorPnpmWorkspacePolicy({
304
321
  entry: props.entry,
305
322
  workspaceSearchFrom: props.workspaceSearchFrom
306
323
  });
@@ -308,7 +325,19 @@ var PnpmWorkspaceNodejsFunction = class extends NodejsFunction {
308
325
  const { disablePnpmPolicyMirror, workspaceSearchFrom, ...rest } = props;
309
326
  void disablePnpmPolicyMirror;
310
327
  void workspaceSearchFrom;
311
- super(scope, id, rest);
328
+ const npmrcPath = mirrorResult?.npmrcPath;
329
+ const shouldWireHook = npmrcPath !== void 0 && fs2.existsSync(npmrcPath);
330
+ const propsWithHook = shouldWireHook ? {
331
+ ...rest,
332
+ bundling: {
333
+ ...rest.bundling,
334
+ commandHooks: buildNpmrcCopyCommandHooks({
335
+ npmrcPath,
336
+ existingHooks: rest.bundling?.commandHooks
337
+ })
338
+ }
339
+ } : rest;
340
+ super(scope, id, propsWithHook);
312
341
  }
313
342
  };
314
343
 
@@ -540,6 +569,7 @@ export {
540
569
  PrivateBucket,
541
570
  StaticContent,
542
571
  StaticHosting,
572
+ buildNpmrcCopyCommandHooks,
543
573
  findPnpmWorkspaceFile,
544
574
  mergeNpmrc,
545
575
  mirrorPnpmWorkspacePolicy,
package/lib/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../utils/src/aws/aws-types.ts","../../utils/src/git/git-utils.ts","../../utils/src/string/string-utils.ts","../../utils/src/index.ts","../src/lambda/pnpm-workspace-nodejs-function.ts","../src/lambda/pnpm-workspace-parser.ts","../src/s3/private-bucket.ts","../src/static-hosting/static-content.ts","../src/static-hosting/static-hosting.ts"],"sourcesContent":["/**\n * Stage Types\n *\n * What stage of deployment is this? Dev, staging, or prod?\n */\nexport const AWS_STAGE_TYPE = {\n /**\n * Development environment, typically used for testing and development.\n */\n DEV: \"dev\",\n\n /**\n * Staging environment, used for pre-production testing.\n */\n STAGE: \"stage\",\n\n /**\n * Production environment, used for live deployments.\n */\n PROD: \"prod\",\n} as const;\n\n/**\n * Above const as a type.\n */\nexport type AwsStageType = (typeof AWS_STAGE_TYPE)[keyof typeof AWS_STAGE_TYPE];\n\n/**\n * Deployment target role: whether an (account, region) is the primary or\n * secondary deployment target (e.g. primary vs replica region).\n */\nexport const DEPLOYMENT_TARGET_ROLE = {\n /**\n * Account and region that represents the primary region for this service.\n * For example, the base DynamoDB Region for global tables.\n */\n PRIMARY: \"primary\",\n /**\n * Account and region that represents a secondary region for this service.\n * For example, a replica region for a global DynamoDB table.\n */\n SECONDARY: \"secondary\",\n} as const;\n\n/**\n * Type for deployment target role values.\n */\nexport type DeploymentTargetRoleType =\n (typeof DEPLOYMENT_TARGET_ROLE)[keyof typeof DEPLOYMENT_TARGET_ROLE];\n\n/**\n * Environment types (primary/secondary).\n *\n * @deprecated Use {@link DEPLOYMENT_TARGET_ROLE} instead. This constant is maintained for backward compatibility.\n */\nexport const AWS_ENVIRONMENT_TYPE = DEPLOYMENT_TARGET_ROLE;\n\n/**\n * Type for environment type values.\n *\n * @deprecated Use {@link DeploymentTargetRoleType} instead. This type is maintained for backward compatibility.\n */\nexport type AwsEnvironmentType = DeploymentTargetRoleType;\n","import { execSync } from \"node:child_process\";\n\n/**\n * Returns the current full git branch name\n *\n * ie: feature/1234 returns feature/1234\n *\n */\nexport const findGitBranch = (): string => {\n return execSync(\"git rev-parse --abbrev-ref HEAD\")\n .toString(\"utf8\")\n .replace(/[\\n\\r\\s]+$/, \"\");\n};\n\nexport const findGitRepoName = (): string => {\n /**\n * When running in github actions this will be populated.\n */\n if (process.env.GITHUB_REPOSITORY) {\n return process.env.GITHUB_REPOSITORY;\n }\n\n /**\n * locally, we need to extract the repo name from the git config.\n */\n const remote = execSync(\"git config --get remote.origin.url\")\n .toString(\"utf8\")\n .replace(/[\\n\\r\\s]+$/, \"\")\n .trim();\n\n const match = remote.match(/[:\\/]([^/]+\\/[^/]+?)(?:\\.git)?$/);\n const repoName = match ? match[1] : \"error-repo-name\";\n\n return repoName;\n};\n","import * as crypto from \"node:crypto\";\n\n/**\n *\n * @param inString - string to hash\n * @param trimLength - trim to this length (defaults to 999 chars)\n * @returns Hex-encoded sha256 digest, truncated to `trimLength` characters.\n */\nexport const hashString = (inString: string, trimLength: number = 999) => {\n return crypto\n .createHash(\"sha256\")\n .update(inString)\n .digest(\"hex\")\n .substring(0, trimLength);\n};\n\n/**\n *\n * @param inputString - string to truncate\n * @param maxLength - max length of this string\n * @returns trimmed string\n */\nexport const trimStringLength = (inputString: string, maxLength: number) => {\n return inputString.length < maxLength\n ? inputString\n : inputString.substring(0, maxLength);\n};\n","export * from \"./aws/aws-types\";\nexport * from \"./git/git-utils\";\nexport * from \"./string/string-utils\";\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n NodejsFunction,\n NodejsFunctionProps,\n} from \"aws-cdk-lib/aws-lambda-nodejs\";\nimport { Construct } from \"constructs\";\nimport {\n findPnpmWorkspaceFile,\n mergeNpmrc,\n readPnpmWorkspacePolicy,\n renderNpmrcLines,\n} from \"./pnpm-workspace-parser\";\n\n/**\n * Props for `PnpmWorkspaceNodejsFunction`. Extends\n * `NodejsFunctionProps` so the wrapper is a drop-in for any existing\n * `NodejsFunction` call site.\n */\nexport interface PnpmWorkspaceNodejsFunctionProps extends NodejsFunctionProps {\n /**\n * Directory to begin the upward search for `pnpm-workspace.yaml`.\n * Defaults to the directory of the resolved entry path.\n */\n readonly workspaceSearchFrom?: string;\n\n /**\n * Skip the policy-mirror step entirely. Useful for tests or when the\n * caller wants the pure `NodejsFunction` behavior.\n *\n * @default false\n */\n readonly disablePnpmPolicyMirror?: boolean;\n}\n\n/**\n * Result of `mirrorPnpmWorkspacePolicy` — describes what the policy\n * mirror did for one entry.\n */\nexport interface MirrorPnpmWorkspacePolicyResult {\n /** Resolved `.npmrc` path if a write happened, otherwise undefined. */\n readonly npmrcPath?: string;\n /** Reason the mirror was a no-op, if it was. */\n readonly skippedReason?:\n | \"missing-entry\"\n | \"missing-workspace-file\"\n | \"empty-policy\"\n | \"no-change\";\n}\n\n/**\n * Mirror the workspace pnpm policy into an `.npmrc` adjacent to the\n * Lambda entry. Pure side-effect helper used by\n * `PnpmWorkspaceNodejsFunction`; exported so consumers can drive it\n * from other call sites if desired.\n */\nexport const mirrorPnpmWorkspacePolicy = (params: {\n readonly entry: string;\n readonly workspaceSearchFrom?: string;\n}): MirrorPnpmWorkspacePolicyResult => {\n const { entry, workspaceSearchFrom } = params;\n if (!fs.existsSync(entry)) {\n return { skippedReason: \"missing-entry\" };\n }\n\n const entryDir = path.dirname(path.resolve(entry));\n const searchFrom = workspaceSearchFrom\n ? path.resolve(workspaceSearchFrom)\n : entryDir;\n\n const workspaceFile = findPnpmWorkspaceFile(searchFrom);\n if (!workspaceFile) {\n return { skippedReason: \"missing-workspace-file\" };\n }\n\n const policy = readPnpmWorkspacePolicy(workspaceFile);\n const lines = renderNpmrcLines(policy);\n if (lines.length === 0) {\n return { skippedReason: \"empty-policy\" };\n }\n\n const npmrcPath = path.join(entryDir, \".npmrc\");\n const existing = fs.existsSync(npmrcPath)\n ? fs.readFileSync(npmrcPath, \"utf8\")\n : undefined;\n const merged = mergeNpmrc(existing, lines);\n\n if (merged === existing) {\n return { npmrcPath, skippedReason: \"no-change\" };\n }\n\n fs.writeFileSync(npmrcPath, merged);\n return { npmrcPath };\n};\n\n/**\n * A `NodejsFunction` wrapper that mirrors the workspace's pnpm policy\n * (currently `minimumReleaseAge` and `minimumReleaseAgeExclude`) into\n * an `.npmrc` adjacent to the Lambda entry before bundling.\n *\n * CDK's bundler runs `pnpm install` in an isolated temp directory\n * outside the workspace, which means `pnpm-workspace.yaml` settings\n * do not apply there. Mirroring the policy into an entry-adjacent\n * `.npmrc` (which CDK copies into the bundling input directory)\n * lets the inner `pnpm install` honour the same freshness rules.\n *\n * See the `pnpm-workspace-nodejs-function` documentation page for\n * full details on what gets mirrored, merge behaviour against an\n * existing `.npmrc`, and when to disable the mirror.\n */\nexport class PnpmWorkspaceNodejsFunction extends NodejsFunction {\n constructor(\n scope: Construct,\n id: string,\n props: PnpmWorkspaceNodejsFunctionProps,\n ) {\n if (!props.disablePnpmPolicyMirror && props.entry) {\n mirrorPnpmWorkspacePolicy({\n entry: props.entry,\n workspaceSearchFrom: props.workspaceSearchFrom,\n });\n }\n\n const { disablePnpmPolicyMirror, workspaceSearchFrom, ...rest } = props;\n void disablePnpmPolicyMirror;\n void workspaceSearchFrom;\n super(scope, id, rest);\n }\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as yaml from \"js-yaml\";\n\n/**\n * Subset of `pnpm-workspace.yaml` fields that map to `.npmrc` keys\n * pnpm honours when running install in a non-workspace directory.\n */\nexport interface PnpmWorkspacePolicy {\n /** `minimumReleaseAge` (minutes) — equivalent to `.npmrc` `minimum-release-age`. */\n readonly minimumReleaseAge?: number;\n /**\n * `minimumReleaseAgeExclude` — equivalent to `.npmrc`\n * `minimum-release-age-exclude` (comma-separated when serialised).\n */\n readonly minimumReleaseAgeExclude?: ReadonlyArray<string>;\n}\n\n/**\n * Walk up from `startDir` until a `pnpm-workspace.yaml` file is found\n * and return its absolute path. Returns `undefined` when the filesystem\n * root is reached without finding one.\n */\nexport const findPnpmWorkspaceFile = (startDir: string): string | undefined => {\n let current = path.resolve(startDir);\n while (true) {\n const candidate = path.join(current, \"pnpm-workspace.yaml\");\n if (fs.existsSync(candidate)) {\n return candidate;\n }\n const parent = path.dirname(current);\n if (parent === current) {\n return undefined;\n }\n current = parent;\n }\n};\n\n/**\n * Read the policy subset (`minimumReleaseAge` and\n * `minimumReleaseAgeExclude`) from a `pnpm-workspace.yaml` file.\n *\n * Returns an empty object when the file is missing, unreadable, or\n * contains neither key. Throws when the file is present but YAML\n * parsing fails — the caller is expected to surface a clear error.\n */\nexport const readPnpmWorkspacePolicy = (\n workspaceFile: string,\n): PnpmWorkspacePolicy => {\n if (!fs.existsSync(workspaceFile)) {\n return {};\n }\n\n const raw = fs.readFileSync(workspaceFile, \"utf8\");\n const parsed = yaml.load(raw);\n\n if (!parsed || typeof parsed !== \"object\") {\n return {};\n }\n\n const obj = parsed as Record<string, unknown>;\n const policy: {\n -readonly [K in keyof PnpmWorkspacePolicy]: PnpmWorkspacePolicy[K];\n } = {};\n\n const age = obj.minimumReleaseAge;\n if (typeof age === \"number\" && Number.isFinite(age)) {\n policy.minimumReleaseAge = age;\n }\n\n const exclude = obj.minimumReleaseAgeExclude;\n if (Array.isArray(exclude)) {\n const cleaned = exclude.filter(\n (entry): entry is string => typeof entry === \"string\" && entry.length > 0,\n );\n if (cleaned.length > 0) {\n policy.minimumReleaseAgeExclude = cleaned;\n }\n }\n\n return policy;\n};\n\n/**\n * Render an `.npmrc` body that pnpm will honour when installing in\n * a directory outside the workspace tree. The keys emitted here are\n * the `.npmrc` equivalents of the `pnpm-workspace.yaml` fields in\n * {@link PnpmWorkspacePolicy} — pnpm reads `minimum-release-age` and\n * `minimum-release-age-exclude` from `.npmrc`, not from the workspace\n * file, when the install runs outside the workspace.\n *\n * Returns an empty string when the policy carries no relevant fields.\n */\nexport const renderNpmrcLines = (\n policy: PnpmWorkspacePolicy,\n): ReadonlyArray<string> => {\n const lines: Array<string> = [];\n\n if (typeof policy.minimumReleaseAge === \"number\") {\n lines.push(`minimum-release-age=${policy.minimumReleaseAge}`);\n }\n\n const exclude = policy.minimumReleaseAgeExclude ?? [];\n if (exclude.length > 0) {\n lines.push(`minimum-release-age-exclude=${exclude.join(\",\")}`);\n }\n\n return lines;\n};\n\n/**\n * Parse the body of an existing `.npmrc` file into a map of trimmed\n * key/value pairs. Lines that are blank or start with `#` are dropped.\n * Lines without an `=` are dropped.\n */\nexport const parseNpmrc = (body: string): Map<string, string> => {\n const map = new Map<string, string>();\n for (const rawLine of body.split(/\\r?\\n/)) {\n const line = rawLine.trim();\n if (line.length === 0 || line.startsWith(\"#\")) {\n continue;\n }\n const eq = line.indexOf(\"=\");\n if (eq < 0) {\n continue;\n }\n const key = line.slice(0, eq).trim();\n const value = line.slice(eq + 1).trim();\n if (key.length > 0) {\n map.set(key, value);\n }\n }\n return map;\n};\n\n/**\n * Merge a set of policy-derived `.npmrc` lines into an existing\n * `.npmrc` body. Our keys overwrite matching keys in the existing\n * body; all other keys are preserved. Returns the new `.npmrc` body\n * (always terminated by a trailing newline when non-empty).\n */\nexport const mergeNpmrc = (\n existing: string | undefined,\n ourLines: ReadonlyArray<string>,\n): string => {\n if (ourLines.length === 0) {\n return existing ?? \"\";\n }\n\n const ourMap = new Map<string, string>();\n for (const line of ourLines) {\n const eq = line.indexOf(\"=\");\n if (eq < 0) {\n continue;\n }\n ourMap.set(line.slice(0, eq).trim(), line.slice(eq + 1).trim());\n }\n\n const existingMap = parseNpmrc(existing ?? \"\");\n for (const [key, value] of ourMap) {\n existingMap.set(key, value);\n }\n\n const orderedKeys: Array<string> = [];\n const seen = new Set<string>();\n\n // Preserve the original line order for any pre-existing keys.\n for (const rawLine of (existing ?? \"\").split(/\\r?\\n/)) {\n const line = rawLine.trim();\n if (line.length === 0 || line.startsWith(\"#\")) {\n continue;\n }\n const eq = line.indexOf(\"=\");\n if (eq < 0) {\n continue;\n }\n const key = line.slice(0, eq).trim();\n if (key.length > 0 && existingMap.has(key) && !seen.has(key)) {\n orderedKeys.push(key);\n seen.add(key);\n }\n }\n\n // Append any keys we added that weren't already present.\n for (const key of ourMap.keys()) {\n if (!seen.has(key)) {\n orderedKeys.push(key);\n seen.add(key);\n }\n }\n\n const body = orderedKeys\n .map((key) => `${key}=${existingMap.get(key)}`)\n .join(\"\\n\");\n\n return body.length === 0 ? \"\" : `${body}\\n`;\n};\n","import { RemovalPolicy } from \"aws-cdk-lib\";\nimport {\n BlockPublicAccess,\n Bucket,\n BucketProps,\n ObjectOwnership,\n} from \"aws-cdk-lib/aws-s3\";\nimport { Construct } from \"constructs\";\n\nexport interface PrivateBucketProps extends BucketProps {}\n\nexport class PrivateBucket extends Bucket {\n constructor(scope: Construct, id: string, props: PrivateBucketProps = {}) {\n const defaultProps = {\n removalPolicy: props.removalPolicy ?? RemovalPolicy.RETAIN,\n autoDeleteObjects: props.removalPolicy === RemovalPolicy.DESTROY,\n };\n\n const requiredProps = {\n publicReadAccess: false,\n blockPublicAccess: BlockPublicAccess.BLOCK_ALL,\n enforceSSL: true,\n objectOwnership: ObjectOwnership.BUCKET_OWNER_ENFORCED,\n };\n\n super(scope, id, { ...defaultProps, ...props, ...requiredProps });\n }\n}\n","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { findGitBranch } from \"@codedrifters/utils\";\nimport { Bucket } from \"aws-cdk-lib/aws-s3\";\nimport { BucketDeployment, Source } from \"aws-cdk-lib/aws-s3-deployment\";\nimport { StringParameter } from \"aws-cdk-lib/aws-ssm\";\nimport { paramCase } from \"change-case\";\nimport { Construct } from \"constructs\";\n\n/*******************************************************************************\n *\n * STATIC CONTENT UPLOADER\n *\n * This construct uploads a directory of content from a local location into S3.\n *\n * To support PR and branch specific builds, each S3 bucket can store content\n * for multiple domains and builds, using the following format:\n *\n * S3-bucket/domain/*\n *\n * A bucket used to store content for stage.openhi.org might have the\n * following directory structure (all in the same bucket).\n *\n * `/stage.openhi.org/*` serves content to stage.openhi.org\n * `/feature-7.stage.openhi.org/*` serves content to feature-7.stage.openhi.org\n * `/pr-123.stage.openhi.org/*` serves content to pr-123.stage.openhi.org\n *\n ******************************************************************************/\n\nexport interface StaticContentProps {\n /**\n * Parameter name to use when storing the static hosting bucket's ARN.\n * This is needed in other later steps when deploying hosted content to S3.\n */\n readonly bucketArnParamName?: string;\n\n /**\n * Absolute path to directory containing content for the website.\n */\n readonly contentSourceDirectory: string;\n\n /**\n * Directory to place content into. Should start with a slash.\n * Example: '/widget'\n */\n readonly contentDestinationDirectory: string;\n\n /**\n * The sub domain prefix (ie: images)\n *\n * @default git branch name\n */\n readonly subDomain?: string;\n\n /**\n * The full domain (ie: staging.codedrifters.com)\n */\n readonly fullDomain: string;\n}\n\nexport class StaticContent extends Construct {\n constructor(scope: Construct, id: string, props: StaticContentProps) {\n super(scope, id);\n\n /***************************************************************************\n *\n * Initial Setup\n *\n * Set some defaults, build domain information.\n *\n **************************************************************************/\n\n const {\n bucketArnParamName,\n contentSourceDirectory,\n contentDestinationDirectory,\n subDomain,\n fullDomain,\n } = {\n bucketArnParamName: \"/STATIC_WEBSITE/BUCKET_ARN\",\n subDomain: findGitBranch(),\n ...props,\n };\n\n /***************************************************************************\n *\n * Import and build some values from Param Store during deployment.\n *\n **************************************************************************/\n\n const keyPrefix = [paramCase(subDomain), fullDomain].join(\".\");\n\n const bucketArn = StringParameter.valueForStringParameter(\n this,\n bucketArnParamName,\n );\n const bucket = Bucket.fromBucketArn(this, \"bucket\", bucketArn);\n\n /***************************************************************************\n *\n * Gather the sources we'll be deploying. We need to have an empty source\n * for tests since it will change all the time and bork up the test\n * snapshots if we don't.\n *\n **************************************************************************/\n\n const isTestEnv = process.env.VITEST === \"true\";\n const sources = isTestEnv ? [] : [Source.asset(contentSourceDirectory)];\n\n new BucketDeployment(this, \"deploy\", {\n sources,\n destinationBucket: bucket,\n retainOnDelete: false,\n destinationKeyPrefix: `${keyPrefix}${contentDestinationDirectory}`,\n });\n }\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { Duration, StackProps } from \"aws-cdk-lib\";\nimport {\n Certificate,\n CertificateValidation,\n} from \"aws-cdk-lib/aws-certificatemanager\";\nimport {\n AccessLevel,\n AllowedMethods,\n CacheCookieBehavior,\n CacheHeaderBehavior,\n CachePolicy,\n CacheQueryStringBehavior,\n Distribution,\n LambdaEdgeEventType,\n S3OriginAccessControl,\n Signing,\n ViewerProtocolPolicy,\n} from \"aws-cdk-lib/aws-cloudfront\";\nimport { S3BucketOrigin } from \"aws-cdk-lib/aws-cloudfront-origins\";\nimport { Runtime } from \"aws-cdk-lib/aws-lambda\";\nimport { NodejsFunction } from \"aws-cdk-lib/aws-lambda-nodejs\";\nimport { LogGroup, RetentionDays } from \"aws-cdk-lib/aws-logs\";\nimport {\n ARecord,\n HostedZone,\n HostedZoneAttributes,\n IHostedZone,\n RecordTarget,\n} from \"aws-cdk-lib/aws-route53\";\nimport { CloudFrontTarget } from \"aws-cdk-lib/aws-route53-targets\";\nimport { StringParameter } from \"aws-cdk-lib/aws-ssm\";\nimport { Construct } from \"constructs\";\nimport type { HostingMode } from \"./static-hosting.viewer-request-handler\";\nimport { PrivateBucket, PrivateBucketProps } from \"../s3/private-bucket\";\n\nexport interface StaticDomainProps {\n /**\n * The base domain (ie: codedrifters.com)\n */\n readonly baseDomain: string;\n\n /**\n * Hosted zone ID for the base domain.\n */\n readonly hostedZoneAttributes: HostedZoneAttributes;\n}\n\nexport interface StaticHostingProps extends StackProps {\n /**\n * Short description used in various places for traceability.\n */\n readonly description?: string;\n\n /**\n * Values used to connect a domain name to the cloudfront distribution. If not\n * supplied, cloudfront doesn't use a custom domain.\n */\n readonly staticDomainProps?: StaticDomainProps;\n\n /**\n * Parameter name to use when storing the static hosting bucket's ARN.\n * This is needed in other later steps when deploying hosted content to S3.\n */\n readonly bucketArnParamName?: string;\n\n /**\n * Parameter name to use when storing the CloudFront Distribution Domain Name.\n */\n readonly distributionDomainParamName?: string;\n\n /**\n * Parameter name to use when storing the CloudFront Distribution ID.\n */\n readonly distributionIDParamName?: string;\n\n /**\n * Props to pass to the private S3 bucket.\n */\n readonly privateBucketProps?: PrivateBucketProps;\n\n /**\n * Selects how path-like URIs are rewritten by the viewer-request\n * `Lambda@Edge` handler.\n *\n * - `spa` (default): path-like URIs rewrite to `/index.html` so a\n * single-page app can serve its one root index and let the client-side\n * router handle the path.\n * - `static`: path-like URIs append `/index.html` (e.g. `/docs` →\n * `/docs/index.html`) so multi-page static sites can serve distinct\n * HTML per path.\n *\n * Multi-tenant domain-folder prepending runs after the rewrite in both\n * modes and is unaffected by this prop.\n *\n * @default \"spa\"\n */\n readonly hostingMode?: HostingMode;\n}\n\nexport class StaticHosting extends Construct {\n /**\n * Full domain name used as basis for hosting.\n */\n public readonly fullDomain: string;\n\n constructor(scope: Construct, id: string, props: StaticHostingProps = {}) {\n super(scope, id);\n\n /***************************************************************************\n *\n * Initial Setup\n *\n * Set some defaults, build domain information.\n *\n **************************************************************************/\n\n const {\n bucketArnParamName,\n distributionDomainParamName,\n distributionIDParamName,\n staticDomainProps,\n privateBucketProps,\n hostingMode,\n } = {\n bucketArnParamName: \"/STATIC_WEBSITE/BUCKET_ARN\",\n distributionDomainParamName: \"/STATIC_WEBSITE/DISTRIBUTION_DOMAIN\",\n distributionIDParamName: \"/STATIC_WEBSITE/DISTRIBUTION_ID\",\n hostingMode: \"spa\" as HostingMode,\n ...props,\n };\n\n const { baseDomain, hostedZoneAttributes } = staticDomainProps ?? {};\n\n /***************************************************************************\n *\n * PRIVATE BUCKET\n *\n * A bucket to store the files within.\n * Save ARN for later deploys.\n *\n **************************************************************************/\n\n const bucket = new PrivateBucket(\n this,\n \"static-hosting-bucket\",\n privateBucketProps,\n );\n\n /***************************************************************************\n *\n * DNS & Wildcard Certificate\n *\n * If a zone Id as passed in, find the hosted zone and create a wildcard\n * certificate for the domain.\n *\n **************************************************************************/\n\n let zone: IHostedZone | undefined;\n let certificate: Certificate | undefined;\n\n if (hostedZoneAttributes && baseDomain) {\n zone = HostedZone.fromHostedZoneAttributes(\n this,\n \"zone\",\n hostedZoneAttributes,\n );\n certificate = new Certificate(this, \"wildcard-certificate\", {\n domainName: `*.${baseDomain}`,\n subjectAlternativeNames: [baseDomain],\n validation: CertificateValidation.fromDnsMultiZone({\n [`*.${baseDomain}`]: zone,\n [baseDomain]: zone,\n }),\n });\n }\n\n /******************************************************************************\n *\n * `LAMBDA@EDGE` FUNCTION\n *\n * This handles rewriting the path from domain name.\n *\n *****************************************************************************/\n\n // Explicit entry required: when omitted, NodejsFunction infers the path from the\n // call site (the built lib/index.js), so it looks for index.viewer-request-handler.js\n // in the package. That file is only emitted if we add it as a separate tsup entry.\n // Use .js when present (built package); fall back to .ts for tests running from source.\n const handlerJs = path.join(\n __dirname,\n \"static-hosting.viewer-request-handler.js\",\n );\n const handlerTs = path.join(\n __dirname,\n \"static-hosting.viewer-request-handler.ts\",\n );\n const handlerEntry = fs.existsSync(handlerJs) ? handlerJs : handlerTs;\n\n const handler = new NodejsFunction(this, \"viewer-request-handler\", {\n entry: handlerEntry,\n handler: hostingMode === \"static\" ? \"staticHandler\" : \"spaHandler\",\n memorySize: 128,\n runtime: Runtime.NODEJS_24_X,\n logGroup: new LogGroup(this, \"viewer-request-handler-log-group\", {\n retention: RetentionDays.ONE_MONTH,\n }),\n });\n\n /******************************************************************************\n *\n * CLOUDFRONT CONFIG\n *\n * Setup a CloudFront Distribution for the bucket.\n *\n *****************************************************************************/\n\n const cachePolicy = new CachePolicy(this, \"cloudfront-policy\", {\n comment: \"Relatively conservative TTL policy.\",\n maxTtl: Duration.seconds(300),\n minTtl: Duration.seconds(0),\n defaultTtl: Duration.seconds(60),\n headerBehavior: CacheHeaderBehavior.none(),\n queryStringBehavior: CacheQueryStringBehavior.none(),\n cookieBehavior: CacheCookieBehavior.none(),\n enableAcceptEncodingGzip: true,\n enableAcceptEncodingBrotli: true,\n });\n\n const oac = new S3OriginAccessControl(this, \"MyOAC\", {\n signing: Signing.SIGV4_NO_OVERRIDE,\n });\n const origin = S3BucketOrigin.withOriginAccessControl(bucket, {\n originAccessControl: oac,\n originAccessLevels: [AccessLevel.READ],\n });\n\n const distribution = new Distribution(this, \"cloudfront-distribution\", {\n comment: `Distribution for ${props.description ?? id}`,\n\n /**\n * Only if domain was supplied\n */\n ...(certificate && baseDomain\n ? {\n certificate,\n domainNames: [baseDomain, `*.${baseDomain}`],\n }\n : {}),\n\n defaultBehavior: {\n origin,\n viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,\n cachePolicy,\n allowedMethods: AllowedMethods.ALLOW_GET_HEAD_OPTIONS,\n edgeLambdas: [\n {\n functionVersion: handler.currentVersion,\n eventType: LambdaEdgeEventType.VIEWER_REQUEST,\n },\n ],\n },\n defaultRootObject: \"index.html\",\n });\n\n /**\n * We finally have enough information to set the full domain.\n */\n this.fullDomain =\n certificate && baseDomain ? baseDomain : distribution.domainName;\n\n /***************************************************************************\n *\n * DNS ENTRY\n *\n * Link cloudfront to both the root fulldomain and all possible subdomains.\n *\n **************************************************************************/\n\n if (zone) {\n new ARecord(this, \"root-dns-entry\", {\n zone,\n recordName: baseDomain ? baseDomain : \"\",\n target: RecordTarget.fromAlias(new CloudFrontTarget(distribution)),\n });\n\n new ARecord(this, \"wc-dns-entry\", {\n zone,\n recordName: baseDomain ? `*.${baseDomain}` : \"*\",\n target: RecordTarget.fromAlias(new CloudFrontTarget(distribution)),\n });\n }\n\n /***************************************************************************\n *\n * EXPORTS\n *\n * Used by content uploader later.\n *\n **************************************************************************/\n\n new StringParameter(this, \"dist-domain\", {\n description: `GENERATED DO NOT CHANGE - CloudFront Distribution Details (${props.description ?? id}).`,\n parameterName: distributionDomainParamName,\n stringValue: distribution.domainName,\n });\n\n new StringParameter(this, \"dist-id\", {\n description: `GENERATED DO NOT CHANGE - CloudFront Distribution Details (${props.description ?? id}).`,\n parameterName: distributionIDParamName,\n stringValue: distribution.distributionId,\n });\n\n new StringParameter(this, \"bucket-arn\", {\n description: `GENERATED DO NOT CHANGE - S3 Bucket ARN for (${props.description ?? id}).`,\n parameterName: bucketArnParamName,\n stringValue: bucket.bucketArn,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;AAKa,YAAA,iBAAiB;;;;MAI5B,KAAK;;;;MAKL,OAAO;;;;MAKP,MAAM;;AAYK,YAAA,yBAAyB;;;;;MAKpC,SAAS;;;;;MAKT,WAAW;;AAcA,YAAA,uBAAuB,QAAA;;;;;;;;;;ACvDpC,QAAA,uBAAA,UAAA,eAAA;AAQO,QAAMA,iBAAgB,MAAa;AACxC,cAAO,GAAA,qBAAA,UAAS,iCAAiC,EAC9C,SAAS,MAAM,EACf,QAAQ,cAAc,EAAE;IAC7B;AAJa,YAAA,gBAAaA;AAMnB,QAAM,kBAAkB,MAAa;AAI1C,UAAI,QAAQ,IAAI,mBAAmB;AACjC,eAAO,QAAQ,IAAI;MACrB;AAKA,YAAM,UAAS,GAAA,qBAAA,UAAS,oCAAoC,EACzD,SAAS,MAAM,EACf,QAAQ,cAAc,EAAE,EACxB,KAAI;AAEP,YAAM,QAAQ,OAAO,MAAM,iCAAiC;AAC5D,YAAM,WAAW,QAAQ,MAAM,CAAC,IAAI;AAEpC,aAAO;IACT;AApBa,YAAA,kBAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACd5B,QAAA,SAAA,aAAA,UAAA,QAAA,CAAA;AAQO,QAAM,aAAa,CAAC,UAAkB,aAAqB,QAAO;AACvE,aAAO,OACJ,WAAW,QAAQ,EACnB,OAAO,QAAQ,EACf,OAAO,KAAK,EACZ,UAAU,GAAG,UAAU;IAC5B;AANa,YAAA,aAAU;AAchB,QAAM,mBAAmB,CAAC,aAAqB,cAAqB;AACzE,aAAO,YAAY,SAAS,YACxB,cACA,YAAY,UAAU,GAAG,SAAS;IACxC;AAJa,YAAA,mBAAgB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QACA,YAAY,aAAa,KAAK,UAAU,KAAK;AAAA,QAC7C,QAAQ,aAAa,UAAU,IAAI,iBAAiB,YAAY,CAAC;AAAA,MACnE,CAAC;AAAA,IACH;AAUA,QAAIC,iBAAgB,MAAM,eAAe;AAAA,MACvC,aAAa,8DAA8D,MAAM,eAAe,EAAE;AAAA,MAClG,eAAe;AAAA,MACf,aAAa,aAAa;AAAA,IAC5B,CAAC;AAED,QAAIA,iBAAgB,MAAM,WAAW;AAAA,MACnC,aAAa,8DAA8D,MAAM,eAAe,EAAE;AAAA,MAClG,eAAe;AAAA,MACf,aAAa,aAAa;AAAA,IAC5B,CAAC;AAED,QAAIA,iBAAgB,MAAM,cAAc;AAAA,MACtC,aAAa,gDAAgD,MAAM,eAAe,EAAE;AAAA,MACpF,eAAe;AAAA,MACf,aAAa,OAAO;AAAA,IACtB,CAAC;AAAA,EACH;AACF;","names":["findGitBranch","fs","path","Bucket","fs","path","NodejsFunction","StringParameter","Construct","Construct","NodejsFunction","StringParameter"]}
1
+ {"version":3,"sources":["../../utils/src/aws/aws-types.ts","../../utils/src/git/git-utils.ts","../../utils/src/string/string-utils.ts","../../utils/src/index.ts","../src/lambda/pnpm-workspace-nodejs-function.ts","../src/lambda/pnpm-workspace-parser.ts","../src/s3/private-bucket.ts","../src/static-hosting/static-content.ts","../src/static-hosting/static-hosting.ts"],"sourcesContent":["/**\n * Stage Types\n *\n * What stage of deployment is this? Dev, staging, or prod?\n */\nexport const AWS_STAGE_TYPE = {\n /**\n * Development environment, typically used for testing and development.\n */\n DEV: \"dev\",\n\n /**\n * Staging environment, used for pre-production testing.\n */\n STAGE: \"stage\",\n\n /**\n * Production environment, used for live deployments.\n */\n PROD: \"prod\",\n} as const;\n\n/**\n * Above const as a type.\n */\nexport type AwsStageType = (typeof AWS_STAGE_TYPE)[keyof typeof AWS_STAGE_TYPE];\n\n/**\n * Deployment target role: whether an (account, region) is the primary or\n * secondary deployment target (e.g. primary vs replica region).\n */\nexport const DEPLOYMENT_TARGET_ROLE = {\n /**\n * Account and region that represents the primary region for this service.\n * For example, the base DynamoDB Region for global tables.\n */\n PRIMARY: \"primary\",\n /**\n * Account and region that represents a secondary region for this service.\n * For example, a replica region for a global DynamoDB table.\n */\n SECONDARY: \"secondary\",\n} as const;\n\n/**\n * Type for deployment target role values.\n */\nexport type DeploymentTargetRoleType =\n (typeof DEPLOYMENT_TARGET_ROLE)[keyof typeof DEPLOYMENT_TARGET_ROLE];\n\n/**\n * Environment types (primary/secondary).\n *\n * @deprecated Use {@link DEPLOYMENT_TARGET_ROLE} instead. This constant is maintained for backward compatibility.\n */\nexport const AWS_ENVIRONMENT_TYPE = DEPLOYMENT_TARGET_ROLE;\n\n/**\n * Type for environment type values.\n *\n * @deprecated Use {@link DeploymentTargetRoleType} instead. This type is maintained for backward compatibility.\n */\nexport type AwsEnvironmentType = DeploymentTargetRoleType;\n","import { execSync } from \"node:child_process\";\n\n/**\n * Returns the current full git branch name\n *\n * ie: feature/1234 returns feature/1234\n *\n */\nexport const findGitBranch = (): string => {\n return execSync(\"git rev-parse --abbrev-ref HEAD\")\n .toString(\"utf8\")\n .replace(/[\\n\\r\\s]+$/, \"\");\n};\n\nexport const findGitRepoName = (): string => {\n /**\n * When running in github actions this will be populated.\n */\n if (process.env.GITHUB_REPOSITORY) {\n return process.env.GITHUB_REPOSITORY;\n }\n\n /**\n * locally, we need to extract the repo name from the git config.\n */\n const remote = execSync(\"git config --get remote.origin.url\")\n .toString(\"utf8\")\n .replace(/[\\n\\r\\s]+$/, \"\")\n .trim();\n\n const match = remote.match(/[:\\/]([^/]+\\/[^/]+?)(?:\\.git)?$/);\n const repoName = match ? match[1] : \"error-repo-name\";\n\n return repoName;\n};\n","import * as crypto from \"node:crypto\";\n\n/**\n *\n * @param inString - string to hash\n * @param trimLength - trim to this length (defaults to 999 chars)\n * @returns Hex-encoded sha256 digest, truncated to `trimLength` characters.\n */\nexport const hashString = (inString: string, trimLength: number = 999) => {\n return crypto\n .createHash(\"sha256\")\n .update(inString)\n .digest(\"hex\")\n .substring(0, trimLength);\n};\n\n/**\n *\n * @param inputString - string to truncate\n * @param maxLength - max length of this string\n * @returns trimmed string\n */\nexport const trimStringLength = (inputString: string, maxLength: number) => {\n return inputString.length < maxLength\n ? inputString\n : inputString.substring(0, maxLength);\n};\n","export * from \"./aws/aws-types\";\nexport * from \"./git/git-utils\";\nexport * from \"./string/string-utils\";\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n ICommandHooks,\n NodejsFunction,\n NodejsFunctionProps,\n} from \"aws-cdk-lib/aws-lambda-nodejs\";\nimport { Construct } from \"constructs\";\nimport {\n findPnpmWorkspaceFile,\n mergeNpmrc,\n readPnpmWorkspacePolicy,\n renderNpmrcLines,\n} from \"./pnpm-workspace-parser\";\n\n/**\n * Props for `PnpmWorkspaceNodejsFunction`. Extends\n * `NodejsFunctionProps` so the wrapper is a drop-in for any existing\n * `NodejsFunction` call site.\n */\nexport interface PnpmWorkspaceNodejsFunctionProps extends NodejsFunctionProps {\n /**\n * Directory to begin the upward search for `pnpm-workspace.yaml`.\n * Defaults to the directory of the resolved entry path.\n */\n readonly workspaceSearchFrom?: string;\n\n /**\n * Skip the policy-mirror step entirely. Useful for tests or when the\n * caller wants the pure `NodejsFunction` behavior.\n *\n * @default false\n */\n readonly disablePnpmPolicyMirror?: boolean;\n}\n\n/**\n * Result of `mirrorPnpmWorkspacePolicy` — describes what the policy\n * mirror did for one entry.\n */\nexport interface MirrorPnpmWorkspacePolicyResult {\n /** Resolved `.npmrc` path if a write happened, otherwise undefined. */\n readonly npmrcPath?: string;\n /** Reason the mirror was a no-op, if it was. */\n readonly skippedReason?:\n | \"missing-entry\"\n | \"missing-workspace-file\"\n | \"empty-policy\"\n | \"no-change\";\n}\n\n/**\n * Mirror the workspace pnpm policy into an `.npmrc` adjacent to the\n * Lambda entry. Pure side-effect helper used by\n * `PnpmWorkspaceNodejsFunction`; exported so consumers can drive it\n * from other call sites if desired.\n */\nexport const mirrorPnpmWorkspacePolicy = (params: {\n readonly entry: string;\n readonly workspaceSearchFrom?: string;\n}): MirrorPnpmWorkspacePolicyResult => {\n const { entry, workspaceSearchFrom } = params;\n if (!fs.existsSync(entry)) {\n return { skippedReason: \"missing-entry\" };\n }\n\n const entryDir = path.dirname(path.resolve(entry));\n const searchFrom = workspaceSearchFrom\n ? path.resolve(workspaceSearchFrom)\n : entryDir;\n\n const workspaceFile = findPnpmWorkspaceFile(searchFrom);\n if (!workspaceFile) {\n return { skippedReason: \"missing-workspace-file\" };\n }\n\n const policy = readPnpmWorkspacePolicy(workspaceFile);\n const lines = renderNpmrcLines(policy);\n if (lines.length === 0) {\n return { skippedReason: \"empty-policy\" };\n }\n\n const npmrcPath = path.join(entryDir, \".npmrc\");\n const existing = fs.existsSync(npmrcPath)\n ? fs.readFileSync(npmrcPath, \"utf8\")\n : undefined;\n const merged = mergeNpmrc(existing, lines);\n\n if (merged === existing) {\n return { npmrcPath, skippedReason: \"no-change\" };\n }\n\n fs.writeFileSync(npmrcPath, merged);\n return { npmrcPath };\n};\n\n/**\n * Build an `ICommandHooks` implementation that copies an\n * entry-adjacent `.npmrc` into the bundling input directory before\n * `pnpm install` runs. Composes with any caller-supplied hooks so\n * existing `beforeBundling` / `beforeInstall` / `afterBundling`\n * commands are preserved.\n *\n * Exported for unit testing; the construct wires this automatically.\n */\nexport const buildNpmrcCopyCommandHooks = (params: {\n readonly npmrcPath: string;\n readonly existingHooks?: ICommandHooks;\n}): ICommandHooks => {\n const { npmrcPath, existingHooks } = params;\n return {\n beforeBundling(inputDir: string, outputDir: string): string[] {\n return existingHooks?.beforeBundling(inputDir, outputDir) ?? [];\n },\n beforeInstall(inputDir: string, outputDir: string): string[] {\n const callerCommands =\n existingHooks?.beforeInstall(inputDir, outputDir) ?? [];\n const copyCommand = `cp ${npmrcPath} ${inputDir}/.npmrc`;\n return [...callerCommands, copyCommand];\n },\n afterBundling(inputDir: string, outputDir: string): string[] {\n return existingHooks?.afterBundling(inputDir, outputDir) ?? [];\n },\n };\n};\n\n/**\n * A `NodejsFunction` wrapper that mirrors the workspace's pnpm policy\n * (currently `minimumReleaseAge` and `minimumReleaseAgeExclude`) into\n * an `.npmrc` adjacent to the Lambda entry before bundling.\n *\n * CDK's bundler runs `pnpm install` in an isolated temp directory\n * outside the workspace, which means `pnpm-workspace.yaml` settings\n * do not apply there. CDK does **not** copy arbitrary entry-adjacent\n * files into the bundling input directory, so the construct also\n * wires a `bundling.commandHooks.beforeInstall` hook that copies the\n * rendered `.npmrc` into the bundling input directory immediately\n * before `pnpm install` runs. Caller-supplied `commandHooks` are\n * preserved — the copy command is appended to whatever the caller\n * already returns from `beforeInstall`.\n *\n * See the `pnpm-workspace-nodejs-function` documentation page for\n * full details on what gets mirrored, merge behaviour against an\n * existing `.npmrc`, and when to disable the mirror.\n */\nexport class PnpmWorkspaceNodejsFunction extends NodejsFunction {\n constructor(\n scope: Construct,\n id: string,\n props: PnpmWorkspaceNodejsFunctionProps,\n ) {\n let mirrorResult: MirrorPnpmWorkspacePolicyResult | undefined;\n if (!props.disablePnpmPolicyMirror && props.entry) {\n mirrorResult = mirrorPnpmWorkspacePolicy({\n entry: props.entry,\n workspaceSearchFrom: props.workspaceSearchFrom,\n });\n }\n\n const { disablePnpmPolicyMirror, workspaceSearchFrom, ...rest } = props;\n void disablePnpmPolicyMirror;\n void workspaceSearchFrom;\n\n // Wire the beforeInstall hook only when the mirror produced (or\n // confirmed) an .npmrc file on disk. Other skippedReason values\n // (`missing-entry`, `missing-workspace-file`, `empty-policy`) mean\n // there is nothing to copy; falling through to plain NodejsFunction\n // behavior is correct in those cases.\n const npmrcPath = mirrorResult?.npmrcPath;\n const shouldWireHook = npmrcPath !== undefined && fs.existsSync(npmrcPath);\n\n const propsWithHook: NodejsFunctionProps = shouldWireHook\n ? {\n ...rest,\n bundling: {\n ...rest.bundling,\n commandHooks: buildNpmrcCopyCommandHooks({\n npmrcPath,\n existingHooks: rest.bundling?.commandHooks,\n }),\n },\n }\n : rest;\n\n super(scope, id, propsWithHook);\n }\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as yaml from \"js-yaml\";\n\n/**\n * Subset of `pnpm-workspace.yaml` fields that map to `.npmrc` keys\n * pnpm honours when running install in a non-workspace directory.\n */\nexport interface PnpmWorkspacePolicy {\n /** `minimumReleaseAge` (minutes) — equivalent to `.npmrc` `minimum-release-age`. */\n readonly minimumReleaseAge?: number;\n /**\n * `minimumReleaseAgeExclude` — equivalent to `.npmrc`\n * `minimum-release-age-exclude` (comma-separated when serialised).\n */\n readonly minimumReleaseAgeExclude?: ReadonlyArray<string>;\n}\n\n/**\n * Walk up from `startDir` until a `pnpm-workspace.yaml` file is found\n * and return its absolute path. Returns `undefined` when the filesystem\n * root is reached without finding one.\n */\nexport const findPnpmWorkspaceFile = (startDir: string): string | undefined => {\n let current = path.resolve(startDir);\n while (true) {\n const candidate = path.join(current, \"pnpm-workspace.yaml\");\n if (fs.existsSync(candidate)) {\n return candidate;\n }\n const parent = path.dirname(current);\n if (parent === current) {\n return undefined;\n }\n current = parent;\n }\n};\n\n/**\n * Read the policy subset (`minimumReleaseAge` and\n * `minimumReleaseAgeExclude`) from a `pnpm-workspace.yaml` file.\n *\n * Returns an empty object when the file is missing, unreadable, or\n * contains neither key. Throws when the file is present but YAML\n * parsing fails — the caller is expected to surface a clear error.\n */\nexport const readPnpmWorkspacePolicy = (\n workspaceFile: string,\n): PnpmWorkspacePolicy => {\n if (!fs.existsSync(workspaceFile)) {\n return {};\n }\n\n const raw = fs.readFileSync(workspaceFile, \"utf8\");\n const parsed = yaml.load(raw);\n\n if (!parsed || typeof parsed !== \"object\") {\n return {};\n }\n\n const obj = parsed as Record<string, unknown>;\n const policy: {\n -readonly [K in keyof PnpmWorkspacePolicy]: PnpmWorkspacePolicy[K];\n } = {};\n\n const age = obj.minimumReleaseAge;\n if (typeof age === \"number\" && Number.isFinite(age)) {\n policy.minimumReleaseAge = age;\n }\n\n const exclude = obj.minimumReleaseAgeExclude;\n if (Array.isArray(exclude)) {\n const cleaned = exclude.filter(\n (entry): entry is string => typeof entry === \"string\" && entry.length > 0,\n );\n if (cleaned.length > 0) {\n policy.minimumReleaseAgeExclude = cleaned;\n }\n }\n\n return policy;\n};\n\n/**\n * Render an `.npmrc` body that pnpm will honour when installing in\n * a directory outside the workspace tree. The keys emitted here are\n * the `.npmrc` equivalents of the `pnpm-workspace.yaml` fields in\n * {@link PnpmWorkspacePolicy} — pnpm reads `minimum-release-age` and\n * `minimum-release-age-exclude` from `.npmrc`, not from the workspace\n * file, when the install runs outside the workspace.\n *\n * Returns an empty string when the policy carries no relevant fields.\n */\nexport const renderNpmrcLines = (\n policy: PnpmWorkspacePolicy,\n): ReadonlyArray<string> => {\n const lines: Array<string> = [];\n\n if (typeof policy.minimumReleaseAge === \"number\") {\n lines.push(`minimum-release-age=${policy.minimumReleaseAge}`);\n }\n\n const exclude = policy.minimumReleaseAgeExclude ?? [];\n if (exclude.length > 0) {\n lines.push(`minimum-release-age-exclude=${exclude.join(\",\")}`);\n }\n\n return lines;\n};\n\n/**\n * Parse the body of an existing `.npmrc` file into a map of trimmed\n * key/value pairs. Lines that are blank or start with `#` are dropped.\n * Lines without an `=` are dropped.\n */\nexport const parseNpmrc = (body: string): Map<string, string> => {\n const map = new Map<string, string>();\n for (const rawLine of body.split(/\\r?\\n/)) {\n const line = rawLine.trim();\n if (line.length === 0 || line.startsWith(\"#\")) {\n continue;\n }\n const eq = line.indexOf(\"=\");\n if (eq < 0) {\n continue;\n }\n const key = line.slice(0, eq).trim();\n const value = line.slice(eq + 1).trim();\n if (key.length > 0) {\n map.set(key, value);\n }\n }\n return map;\n};\n\n/**\n * Merge a set of policy-derived `.npmrc` lines into an existing\n * `.npmrc` body. Our keys overwrite matching keys in the existing\n * body; all other keys are preserved. Returns the new `.npmrc` body\n * (always terminated by a trailing newline when non-empty).\n */\nexport const mergeNpmrc = (\n existing: string | undefined,\n ourLines: ReadonlyArray<string>,\n): string => {\n if (ourLines.length === 0) {\n return existing ?? \"\";\n }\n\n const ourMap = new Map<string, string>();\n for (const line of ourLines) {\n const eq = line.indexOf(\"=\");\n if (eq < 0) {\n continue;\n }\n ourMap.set(line.slice(0, eq).trim(), line.slice(eq + 1).trim());\n }\n\n const existingMap = parseNpmrc(existing ?? \"\");\n for (const [key, value] of ourMap) {\n existingMap.set(key, value);\n }\n\n const orderedKeys: Array<string> = [];\n const seen = new Set<string>();\n\n // Preserve the original line order for any pre-existing keys.\n for (const rawLine of (existing ?? \"\").split(/\\r?\\n/)) {\n const line = rawLine.trim();\n if (line.length === 0 || line.startsWith(\"#\")) {\n continue;\n }\n const eq = line.indexOf(\"=\");\n if (eq < 0) {\n continue;\n }\n const key = line.slice(0, eq).trim();\n if (key.length > 0 && existingMap.has(key) && !seen.has(key)) {\n orderedKeys.push(key);\n seen.add(key);\n }\n }\n\n // Append any keys we added that weren't already present.\n for (const key of ourMap.keys()) {\n if (!seen.has(key)) {\n orderedKeys.push(key);\n seen.add(key);\n }\n }\n\n const body = orderedKeys\n .map((key) => `${key}=${existingMap.get(key)}`)\n .join(\"\\n\");\n\n return body.length === 0 ? \"\" : `${body}\\n`;\n};\n","import { RemovalPolicy } from \"aws-cdk-lib\";\nimport {\n BlockPublicAccess,\n Bucket,\n BucketProps,\n ObjectOwnership,\n} from \"aws-cdk-lib/aws-s3\";\nimport { Construct } from \"constructs\";\n\nexport interface PrivateBucketProps extends BucketProps {}\n\nexport class PrivateBucket extends Bucket {\n constructor(scope: Construct, id: string, props: PrivateBucketProps = {}) {\n const defaultProps = {\n removalPolicy: props.removalPolicy ?? RemovalPolicy.RETAIN,\n autoDeleteObjects: props.removalPolicy === RemovalPolicy.DESTROY,\n };\n\n const requiredProps = {\n publicReadAccess: false,\n blockPublicAccess: BlockPublicAccess.BLOCK_ALL,\n enforceSSL: true,\n objectOwnership: ObjectOwnership.BUCKET_OWNER_ENFORCED,\n };\n\n super(scope, id, { ...defaultProps, ...props, ...requiredProps });\n }\n}\n","// eslint-disable-next-line import/no-extraneous-dependencies\nimport { findGitBranch } from \"@codedrifters/utils\";\nimport { Bucket } from \"aws-cdk-lib/aws-s3\";\nimport { BucketDeployment, Source } from \"aws-cdk-lib/aws-s3-deployment\";\nimport { StringParameter } from \"aws-cdk-lib/aws-ssm\";\nimport { paramCase } from \"change-case\";\nimport { Construct } from \"constructs\";\n\n/*******************************************************************************\n *\n * STATIC CONTENT UPLOADER\n *\n * This construct uploads a directory of content from a local location into S3.\n *\n * To support PR and branch specific builds, each S3 bucket can store content\n * for multiple domains and builds, using the following format:\n *\n * S3-bucket/domain/*\n *\n * A bucket used to store content for stage.openhi.org might have the\n * following directory structure (all in the same bucket).\n *\n * `/stage.openhi.org/*` serves content to stage.openhi.org\n * `/feature-7.stage.openhi.org/*` serves content to feature-7.stage.openhi.org\n * `/pr-123.stage.openhi.org/*` serves content to pr-123.stage.openhi.org\n *\n ******************************************************************************/\n\nexport interface StaticContentProps {\n /**\n * Parameter name to use when storing the static hosting bucket's ARN.\n * This is needed in other later steps when deploying hosted content to S3.\n */\n readonly bucketArnParamName?: string;\n\n /**\n * Absolute path to directory containing content for the website.\n */\n readonly contentSourceDirectory: string;\n\n /**\n * Directory to place content into. Should start with a slash.\n * Example: '/widget'\n */\n readonly contentDestinationDirectory: string;\n\n /**\n * The sub domain prefix (ie: images)\n *\n * @default git branch name\n */\n readonly subDomain?: string;\n\n /**\n * The full domain (ie: staging.codedrifters.com)\n */\n readonly fullDomain: string;\n}\n\nexport class StaticContent extends Construct {\n constructor(scope: Construct, id: string, props: StaticContentProps) {\n super(scope, id);\n\n /***************************************************************************\n *\n * Initial Setup\n *\n * Set some defaults, build domain information.\n *\n **************************************************************************/\n\n const {\n bucketArnParamName,\n contentSourceDirectory,\n contentDestinationDirectory,\n subDomain,\n fullDomain,\n } = {\n bucketArnParamName: \"/STATIC_WEBSITE/BUCKET_ARN\",\n subDomain: findGitBranch(),\n ...props,\n };\n\n /***************************************************************************\n *\n * Import and build some values from Param Store during deployment.\n *\n **************************************************************************/\n\n const keyPrefix = [paramCase(subDomain), fullDomain].join(\".\");\n\n const bucketArn = StringParameter.valueForStringParameter(\n this,\n bucketArnParamName,\n );\n const bucket = Bucket.fromBucketArn(this, \"bucket\", bucketArn);\n\n /***************************************************************************\n *\n * Gather the sources we'll be deploying. We need to have an empty source\n * for tests since it will change all the time and bork up the test\n * snapshots if we don't.\n *\n **************************************************************************/\n\n const isTestEnv = process.env.VITEST === \"true\";\n const sources = isTestEnv ? [] : [Source.asset(contentSourceDirectory)];\n\n new BucketDeployment(this, \"deploy\", {\n sources,\n destinationBucket: bucket,\n retainOnDelete: false,\n destinationKeyPrefix: `${keyPrefix}${contentDestinationDirectory}`,\n });\n }\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { Duration, StackProps } from \"aws-cdk-lib\";\nimport {\n Certificate,\n CertificateValidation,\n} from \"aws-cdk-lib/aws-certificatemanager\";\nimport {\n AccessLevel,\n AllowedMethods,\n CacheCookieBehavior,\n CacheHeaderBehavior,\n CachePolicy,\n CacheQueryStringBehavior,\n Distribution,\n LambdaEdgeEventType,\n S3OriginAccessControl,\n Signing,\n ViewerProtocolPolicy,\n} from \"aws-cdk-lib/aws-cloudfront\";\nimport { S3BucketOrigin } from \"aws-cdk-lib/aws-cloudfront-origins\";\nimport { Runtime } from \"aws-cdk-lib/aws-lambda\";\nimport { NodejsFunction } from \"aws-cdk-lib/aws-lambda-nodejs\";\nimport { LogGroup, RetentionDays } from \"aws-cdk-lib/aws-logs\";\nimport {\n ARecord,\n HostedZone,\n HostedZoneAttributes,\n IHostedZone,\n RecordTarget,\n} from \"aws-cdk-lib/aws-route53\";\nimport { CloudFrontTarget } from \"aws-cdk-lib/aws-route53-targets\";\nimport { StringParameter } from \"aws-cdk-lib/aws-ssm\";\nimport { Construct } from \"constructs\";\nimport type { HostingMode } from \"./static-hosting.viewer-request-handler\";\nimport { PrivateBucket, PrivateBucketProps } from \"../s3/private-bucket\";\n\nexport interface StaticDomainProps {\n /**\n * The base domain (ie: codedrifters.com)\n */\n readonly baseDomain: string;\n\n /**\n * Hosted zone ID for the base domain.\n */\n readonly hostedZoneAttributes: HostedZoneAttributes;\n}\n\nexport interface StaticHostingProps extends StackProps {\n /**\n * Short description used in various places for traceability.\n */\n readonly description?: string;\n\n /**\n * Values used to connect a domain name to the cloudfront distribution. If not\n * supplied, cloudfront doesn't use a custom domain.\n */\n readonly staticDomainProps?: StaticDomainProps;\n\n /**\n * Parameter name to use when storing the static hosting bucket's ARN.\n * This is needed in other later steps when deploying hosted content to S3.\n */\n readonly bucketArnParamName?: string;\n\n /**\n * Parameter name to use when storing the CloudFront Distribution Domain Name.\n */\n readonly distributionDomainParamName?: string;\n\n /**\n * Parameter name to use when storing the CloudFront Distribution ID.\n */\n readonly distributionIDParamName?: string;\n\n /**\n * Props to pass to the private S3 bucket.\n */\n readonly privateBucketProps?: PrivateBucketProps;\n\n /**\n * Selects how path-like URIs are rewritten by the viewer-request\n * `Lambda@Edge` handler.\n *\n * - `spa` (default): path-like URIs rewrite to `/index.html` so a\n * single-page app can serve its one root index and let the client-side\n * router handle the path.\n * - `static`: path-like URIs append `/index.html` (e.g. `/docs` →\n * `/docs/index.html`) so multi-page static sites can serve distinct\n * HTML per path.\n *\n * Multi-tenant domain-folder prepending runs after the rewrite in both\n * modes and is unaffected by this prop.\n *\n * @default \"spa\"\n */\n readonly hostingMode?: HostingMode;\n}\n\nexport class StaticHosting extends Construct {\n /**\n * Full domain name used as basis for hosting.\n */\n public readonly fullDomain: string;\n\n constructor(scope: Construct, id: string, props: StaticHostingProps = {}) {\n super(scope, id);\n\n /***************************************************************************\n *\n * Initial Setup\n *\n * Set some defaults, build domain information.\n *\n **************************************************************************/\n\n const {\n bucketArnParamName,\n distributionDomainParamName,\n distributionIDParamName,\n staticDomainProps,\n privateBucketProps,\n hostingMode,\n } = {\n bucketArnParamName: \"/STATIC_WEBSITE/BUCKET_ARN\",\n distributionDomainParamName: \"/STATIC_WEBSITE/DISTRIBUTION_DOMAIN\",\n distributionIDParamName: \"/STATIC_WEBSITE/DISTRIBUTION_ID\",\n hostingMode: \"spa\" as HostingMode,\n ...props,\n };\n\n const { baseDomain, hostedZoneAttributes } = staticDomainProps ?? {};\n\n /***************************************************************************\n *\n * PRIVATE BUCKET\n *\n * A bucket to store the files within.\n * Save ARN for later deploys.\n *\n **************************************************************************/\n\n const bucket = new PrivateBucket(\n this,\n \"static-hosting-bucket\",\n privateBucketProps,\n );\n\n /***************************************************************************\n *\n * DNS & Wildcard Certificate\n *\n * If a zone Id as passed in, find the hosted zone and create a wildcard\n * certificate for the domain.\n *\n **************************************************************************/\n\n let zone: IHostedZone | undefined;\n let certificate: Certificate | undefined;\n\n if (hostedZoneAttributes && baseDomain) {\n zone = HostedZone.fromHostedZoneAttributes(\n this,\n \"zone\",\n hostedZoneAttributes,\n );\n certificate = new Certificate(this, \"wildcard-certificate\", {\n domainName: `*.${baseDomain}`,\n subjectAlternativeNames: [baseDomain],\n validation: CertificateValidation.fromDnsMultiZone({\n [`*.${baseDomain}`]: zone,\n [baseDomain]: zone,\n }),\n });\n }\n\n /******************************************************************************\n *\n * `LAMBDA@EDGE` FUNCTION\n *\n * This handles rewriting the path from domain name.\n *\n *****************************************************************************/\n\n // Explicit entry required: when omitted, NodejsFunction infers the path from the\n // call site (the built lib/index.js), so it looks for index.viewer-request-handler.js\n // in the package. That file is only emitted if we add it as a separate tsup entry.\n // Use .js when present (built package); fall back to .ts for tests running from source.\n const handlerJs = path.join(\n __dirname,\n \"static-hosting.viewer-request-handler.js\",\n );\n const handlerTs = path.join(\n __dirname,\n \"static-hosting.viewer-request-handler.ts\",\n );\n const handlerEntry = fs.existsSync(handlerJs) ? handlerJs : handlerTs;\n\n const handler = new NodejsFunction(this, \"viewer-request-handler\", {\n entry: handlerEntry,\n handler: hostingMode === \"static\" ? \"staticHandler\" : \"spaHandler\",\n memorySize: 128,\n runtime: Runtime.NODEJS_24_X,\n logGroup: new LogGroup(this, \"viewer-request-handler-log-group\", {\n retention: RetentionDays.ONE_MONTH,\n }),\n });\n\n /******************************************************************************\n *\n * CLOUDFRONT CONFIG\n *\n * Setup a CloudFront Distribution for the bucket.\n *\n *****************************************************************************/\n\n const cachePolicy = new CachePolicy(this, \"cloudfront-policy\", {\n comment: \"Relatively conservative TTL policy.\",\n maxTtl: Duration.seconds(300),\n minTtl: Duration.seconds(0),\n defaultTtl: Duration.seconds(60),\n headerBehavior: CacheHeaderBehavior.none(),\n queryStringBehavior: CacheQueryStringBehavior.none(),\n cookieBehavior: CacheCookieBehavior.none(),\n enableAcceptEncodingGzip: true,\n enableAcceptEncodingBrotli: true,\n });\n\n const oac = new S3OriginAccessControl(this, \"MyOAC\", {\n signing: Signing.SIGV4_NO_OVERRIDE,\n });\n const origin = S3BucketOrigin.withOriginAccessControl(bucket, {\n originAccessControl: oac,\n originAccessLevels: [AccessLevel.READ],\n });\n\n const distribution = new Distribution(this, \"cloudfront-distribution\", {\n comment: `Distribution for ${props.description ?? id}`,\n\n /**\n * Only if domain was supplied\n */\n ...(certificate && baseDomain\n ? {\n certificate,\n domainNames: [baseDomain, `*.${baseDomain}`],\n }\n : {}),\n\n defaultBehavior: {\n origin,\n viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,\n cachePolicy,\n allowedMethods: AllowedMethods.ALLOW_GET_HEAD_OPTIONS,\n edgeLambdas: [\n {\n functionVersion: handler.currentVersion,\n eventType: LambdaEdgeEventType.VIEWER_REQUEST,\n },\n ],\n },\n defaultRootObject: \"index.html\",\n });\n\n /**\n * We finally have enough information to set the full domain.\n */\n this.fullDomain =\n certificate && baseDomain ? baseDomain : distribution.domainName;\n\n /***************************************************************************\n *\n * DNS ENTRY\n *\n * Link cloudfront to both the root fulldomain and all possible subdomains.\n *\n **************************************************************************/\n\n if (zone) {\n new ARecord(this, \"root-dns-entry\", {\n zone,\n recordName: baseDomain ? baseDomain : \"\",\n target: RecordTarget.fromAlias(new CloudFrontTarget(distribution)),\n });\n\n new ARecord(this, \"wc-dns-entry\", {\n zone,\n recordName: baseDomain ? `*.${baseDomain}` : \"*\",\n target: RecordTarget.fromAlias(new CloudFrontTarget(distribution)),\n });\n }\n\n /***************************************************************************\n *\n * EXPORTS\n *\n * Used by content uploader later.\n *\n **************************************************************************/\n\n new StringParameter(this, \"dist-domain\", {\n description: `GENERATED DO NOT CHANGE - CloudFront Distribution Details (${props.description ?? id}).`,\n parameterName: distributionDomainParamName,\n stringValue: distribution.domainName,\n });\n\n new StringParameter(this, \"dist-id\", {\n description: `GENERATED DO NOT CHANGE - CloudFront Distribution Details (${props.description ?? id}).`,\n parameterName: distributionIDParamName,\n stringValue: distribution.distributionId,\n });\n\n new StringParameter(this, \"bucket-arn\", {\n description: `GENERATED DO NOT CHANGE - S3 Bucket ARN for (${props.description ?? id}).`,\n parameterName: bucketArnParamName,\n stringValue: bucket.bucketArn,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;AAKa,YAAA,iBAAiB;;;;MAI5B,KAAK;;;;MAKL,OAAO;;;;MAKP,MAAM;;AAYK,YAAA,yBAAyB;;;;;MAKpC,SAAS;;;;;MAKT,WAAW;;AAcA,YAAA,uBAAuB,QAAA;;;;;;;;;;ACvDpC,QAAA,uBAAA,UAAA,eAAA;AAQO,QAAMA,iBAAgB,MAAa;AACxC,cAAO,GAAA,qBAAA,UAAS,iCAAiC,EAC9C,SAAS,MAAM,EACf,QAAQ,cAAc,EAAE;IAC7B;AAJa,YAAA,gBAAaA;AAMnB,QAAM,kBAAkB,MAAa;AAI1C,UAAI,QAAQ,IAAI,mBAAmB;AACjC,eAAO,QAAQ,IAAI;MACrB;AAKA,YAAM,UAAS,GAAA,qBAAA,UAAS,oCAAoC,EACzD,SAAS,MAAM,EACf,QAAQ,cAAc,EAAE,EACxB,KAAI;AAEP,YAAM,QAAQ,OAAO,MAAM,iCAAiC;AAC5D,YAAM,WAAW,QAAQ,MAAM,CAAC,IAA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,aAAa,UAAU,IAAI,iBAAiB,YAAY,CAAC;AAAA,MACnE,CAAC;AAAA,IACH;AAUA,QAAIC,iBAAgB,MAAM,eAAe;AAAA,MACvC,aAAa,8DAA8D,MAAM,eAAe,EAAE;AAAA,MAClG,eAAe;AAAA,MACf,aAAa,aAAa;AAAA,IAC5B,CAAC;AAED,QAAIA,iBAAgB,MAAM,WAAW;AAAA,MACnC,aAAa,8DAA8D,MAAM,eAAe,EAAE;AAAA,MAClG,eAAe;AAAA,MACf,aAAa,aAAa;AAAA,IAC5B,CAAC;AAED,QAAIA,iBAAgB,MAAM,cAAc;AAAA,MACtC,aAAa,gDAAgD,MAAM,eAAe,EAAE;AAAA,MACpF,eAAe;AAAA,MACf,aAAa,OAAO;AAAA,IACtB,CAAC;AAAA,EACH;AACF;","names":["findGitBranch","fs","path","Bucket","fs","path","NodejsFunction","StringParameter","Construct","Construct","NodejsFunction","StringParameter"]}
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "main": "lib/index.js",
55
55
  "license": "MIT",
56
- "version": "0.0.73",
56
+ "version": "0.0.74",
57
57
  "types": "lib/index.d.ts",
58
58
  "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"pnpm exec projen\".",
59
59
  "scripts": {