WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@johnduffell
Copy link
Member

@johnduffell johnduffell commented Sep 24, 2025

branched off #2907

There was feedback suggesting to use the pnpm catalog rather than writing the dependencies into the individual files.

This is a further enhancement not related to the above PR, but I thought I would produce followup PRs to show how it might be done.

Option 1 (this PR)

Rather than programmatically defining the dependencies in dependencies.ts this makes the pnpm catalog the source of truth for recommended dependencies.
buildcheck will read and validate the pnpm catalog and encourage the package.jsons to use the catalog (or include a deviation in the build.ts.)

Option 2 ( #3098 ) will instead make the pnpm-workspace.yaml file a managed file, and the dependency versions will be written there instead of the package.jsons

# Conflicts:
#	handlers/alarms-handler/package.json
#	handlers/mparticle-api/package.json
#	handlers/product-switch-api/package.json
#	handlers/salesforce-disaster-recovery-health-check/package.json
#	modules/supporter-product-data/package.json
#	package.json
#	pnpm-lock.yaml
# Conflicts:
#	handlers/alarms-handler/package.json
# Conflicts:
#	handlers/discount-api/lambda/package.json
#	pnpm-lock.yaml
@johnduffell johnduffell force-pushed the jd/split-cdk-build-generator branch from 66f63f6 to e1df36d Compare September 24, 2025 17:30
@johnduffell johnduffell force-pushed the jd/split-cdk-build-generator branch from e1df36d to 692c394 Compare September 24, 2025 18:05
…enerator-pnpm-primary

# Conflicts:
#	handlers/alarms-handler/package.json
#	pnpm-lock.yaml
Comment on lines 14 to 28
// the code won't type check if a disallowed library is present
type DisallowedLibs = readonly ['aws-sdk'];

const DISALLOWED_LIBRARY_IN_PNPM_CATALOG = Symbol('Error');
type DisallowedLibsType = {
[Key in DisallowedLibs[number]]?: unknown;
};

export function getPnpmCatalog<K extends string>(
catalog: Record<K, string> extends DisallowedLibsType
? Record<K, string> & {
// the following line is the compiler error reported when you try to add aws-sdk v2
[DISALLOWED_LIBRARY_IN_PNPM_CATALOG]: `${keyof DisallowedLibsType & keyof Record<K, string>}`;
}
: Record<K, string>,
Copy link
Member Author

@johnduffell johnduffell Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure the benefit of making it a compile error, given that we always run it when we compile it. The error is reported in a strange way
image

Comment on lines +15 to +30
// check that all the aws sdk v3 versions are identical
const awsVersions = new Set(
Object.entries(catalog)
.filter(([dep]) => dep.startsWith('@aws-sdk/'))
.map(([, version]) => version),
);
if (awsVersions.size !== 1) {
throw new Error(
'mismatched AWS versions in pnpm catalog: ' +
[...awsVersions].sort().join(', '),
);
}
// aws sdk v2 is not allowed
if ((catalog as Record<string, string>)['aws-sdk']) {
throw new Error('AWS SDK v2 is not allowed in the pnpm catalog');
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even though the pnpm catalog is not a managed file (so we can't update the content), we can still validate it when we read it in

@johnduffell johnduffell marked this pull request as ready for review September 29, 2025 13:58
Base automatically changed from jd/split-cdk-build-generator to main October 3, 2025 09:23
@Reettaphant Reettaphant added maintenance Departmental tracking: maintenance work, not a fix or a feature and removed maintenance labels Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Departmental tracking: maintenance work, not a fix or a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants