Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/AlmaCdkConstructLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -99,8 +98,6 @@ function buildAwsCdkConstructLibraryOptions(
publishToGo: golang
? buildPublishToGoOptions(validatedOptions.repositoryUrl)
: undefined,
// CDK
constructsVersion: CONSTRUCTS_VERSION,
// Git & dev
gitignore: [...DEFAULT_GITIGNORE_PATTERNS],
tsconfigDev: {
Expand Down
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/schemas/almaCdkConstructLibraryOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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),
})
Expand Down
19 changes: 19 additions & 0 deletions test/schemas/almaCdkConstructLibraryOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
almaCdkConstructLibraryOptionsSchema,
branchOptionsSchema,
CDK_DEFAULT_VERSION,
CONSTRUCTS_DEFAULT_VERSION,
} from '../../src/schemas/almaCdkConstructLibraryOptions';

const validBaseOptions = {
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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,
Expand Down
Loading