diff --git a/API.md b/API.md
index 351006f..6ecd178 100644
--- a/API.md
+++ b/API.md
@@ -1617,6 +1617,7 @@ const almaCdkConstructLibraryOptions: AlmaCdkConstructLibraryOptions = { ... }
| bundledDeps | string[] | *No description.* |
| cdkVersion | string | AWS CDK version for the generated library (semver or coercible, same rules as Node version fields); |
| codeCov | boolean | *No description.* |
+| constructsVersion | string | `constructs` library version for the generated project (semver or coercible, same rules as Node version fields); |
| deps | string[] | *No description.* |
| devDeps | string[] | *No description.* |
| golang | boolean | *No description.* |
@@ -1747,6 +1748,20 @@ public readonly codeCov: boolean;
---
+##### `constructsVersion`Optional
+
+```typescript
+public readonly constructsVersion: string;
+```
+
+- *Type:* string
+
+`constructs` library version for the generated project (semver or coercible, same rules as Node version fields);
+
+when omitted, defaults to the exported `CONSTRUCTS_DEFAULT_VERSION` constant.
+
+---
+
##### `deps`Optional
```typescript
diff --git a/src/AlmaCdkConstructLibrary.ts b/src/AlmaCdkConstructLibrary.ts
index 6030bd8..f942c3f 100644
--- a/src/AlmaCdkConstructLibrary.ts
+++ b/src/AlmaCdkConstructLibrary.ts
@@ -12,7 +12,6 @@ import { uniqueKeywordsCaseInsensitive } from './uniqueKeywordsCaseInsensitive';
export type { AlmaCdkConstructLibraryOptions } from './schemas/almaCdkConstructLibraryOptions';
-const CONSTRUCTS_VERSION = '10.3.0';
const JSII_VERSION = '~5.9.0';
const JEST_VERSION = '^30';
const DEFAULT_KEYWORDS = ['cdk', 'aws-cdk', 'awscdk', 'aws'] as const;
@@ -99,8 +98,6 @@ function buildAwsCdkConstructLibraryOptions(
publishToGo: golang
? buildPublishToGoOptions(validatedOptions.repositoryUrl)
: undefined,
- // CDK
- constructsVersion: CONSTRUCTS_VERSION,
// Git & dev
gitignore: [...DEFAULT_GITIGNORE_PATTERNS],
tsconfigDev: {
diff --git a/src/index.ts b/src/index.ts
index 9733de2..640d18a 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,4 +1,7 @@
-export { CDK_DEFAULT_VERSION } from './schemas/almaCdkConstructLibraryOptions';
+export {
+ CDK_DEFAULT_VERSION,
+ CONSTRUCTS_DEFAULT_VERSION,
+} from './schemas/almaCdkConstructLibraryOptions';
export {
AlmaCdkConstructLibrary,
type AlmaCdkConstructLibraryOptions,
diff --git a/src/schemas/almaCdkConstructLibraryOptions.ts b/src/schemas/almaCdkConstructLibraryOptions.ts
index 58b9790..1cba8d8 100644
--- a/src/schemas/almaCdkConstructLibraryOptions.ts
+++ b/src/schemas/almaCdkConstructLibraryOptions.ts
@@ -81,6 +81,8 @@ export interface AlmaCdkConstructLibraryOptions {
readonly sonarProjectPropertiesExtraLines?: string[];
/** AWS CDK version for the generated library (semver or coercible, same rules as Node version fields); when omitted, defaults to the exported `CDK_DEFAULT_VERSION` constant. */
readonly cdkVersion?: string;
+ /** `constructs` library version for the generated project (semver or coercible, same rules as Node version fields); when omitted, defaults to the exported `CONSTRUCTS_DEFAULT_VERSION` constant. */
+ readonly constructsVersion?: string;
readonly golang?: boolean;
readonly python?: boolean;
}
@@ -97,6 +99,8 @@ const NODEJS_WORKFLOW_VERSION = NODEJS_MAX_VERSION;
/** Default AWS CDK version passed to projen when `cdkVersion` is omitted from options. */
export const CDK_DEFAULT_VERSION = '2.220.0';
+/** Default `constructs` version passed to projen when `constructsVersion` is omitted from options. */
+export const CONSTRUCTS_DEFAULT_VERSION = '10.3.0';
/** Projen AwsCdkConstructLibrary options with validation and defaults (min/max/workflow Node versions, package name, etc.). */
// JSII cannot infer this schema shape cleanly, so we keep the runtime schema
@@ -125,6 +129,7 @@ export const almaCdkConstructLibraryOptionsSchema = z
pnpmSettings: pnpmSettingsSchema.optional(),
sonarProjectPropertiesExtraLines: z.array(z.string()).optional(),
cdkVersion: versionStringSchema.default(CDK_DEFAULT_VERSION),
+ constructsVersion: versionStringSchema.default(CONSTRUCTS_DEFAULT_VERSION),
golang: z.boolean().default(true),
python: z.boolean().default(true),
})
diff --git a/test/schemas/almaCdkConstructLibraryOptions.test.ts b/test/schemas/almaCdkConstructLibraryOptions.test.ts
index 3698ca3..af63ca6 100644
--- a/test/schemas/almaCdkConstructLibraryOptions.test.ts
+++ b/test/schemas/almaCdkConstructLibraryOptions.test.ts
@@ -3,6 +3,7 @@ import {
almaCdkConstructLibraryOptionsSchema,
branchOptionsSchema,
CDK_DEFAULT_VERSION,
+ CONSTRUCTS_DEFAULT_VERSION,
} from '../../src/schemas/almaCdkConstructLibraryOptions';
const validBaseOptions = {
@@ -70,6 +71,7 @@ describe('almaCdkConstructLibraryOptionsSchema', () => {
expect(result.workflowNodeVersion).toBe('24');
expect(result.maxNodeVersion).toBe('24');
expect(result.cdkVersion).toBe(CDK_DEFAULT_VERSION);
+ expect(result.constructsVersion).toBe(CONSTRUCTS_DEFAULT_VERSION);
});
it('applies default Node versions when omitted', () => {
@@ -107,6 +109,23 @@ describe('almaCdkConstructLibraryOptionsSchema', () => {
).toThrow();
});
+ it('accepts constructsVersion override', () => {
+ const result = almaCdkConstructLibraryOptionsSchema.parse({
+ ...validBaseOptions,
+ constructsVersion: '10.4.2',
+ });
+ expect(result.constructsVersion).toBe('10.4.2');
+ });
+
+ it('rejects invalid semver for constructsVersion', () => {
+ expect(() =>
+ almaCdkConstructLibraryOptionsSchema.parse({
+ ...validBaseOptions,
+ constructsVersion: 'not-semver',
+ }),
+ ).toThrow();
+ });
+
it('accepts custom Node versions when min <= workflow <= max', () => {
const result = almaCdkConstructLibraryOptionsSchema.parse({
...validBaseOptions,