aws / aws-pdk

The AWS PDK provides building blocks for common patterns together with development tools to manage and build your projects.
https://aws.github.io/aws-pdk/
Apache License 2.0
340 stars 70 forks source link

[BUG] Upgrading core pdk code results in reverting back to the original versions. #784

Open raurir opened 1 month ago

raurir commented 1 month ago

Describe the bug

Attempting to upgrade pdk, pdk dependencies and projen roles back to previous versions.

Expected Behavior

aws/pdk should be upgraded to latest and projen should be upgraded to latest.

Current Behavior

Relevant bits of the upgrade logs included from reproduction steps below.

  1. @aws/pdk goes from 0.23.35 to 0.23.38 then back to 0.23.35
> @demo/monorepo@0.0.0 upgrade UpgradeDemo
> pnpm exec projen upgrade

πŸ‘Ύ upgrade | pnpm dlx npm-check-updates@16 --upgrade --target=minor --peer --dep=dev,peer,prod,optional --filter=eslint-config-prettier,eslint-import-resolver-typescript,eslint-plugin-import,eslint-plugin-prettier,npm-check-updates,prettier,ts-node,typescript,@aws-cdk/aws-cognito-identitypool-alpha,aws-cdk-lib,cdk-nag
Progress: removed
Using pnpm
Upgrading UpgradeDemo/package.json
[====================] 11/11 100%
[====================] 3/3 100%

 aws-cdk-lib         2.137.0  β†’   2.142.1
 cdk-nag             2.28.92  β†’  2.28.119
 npm-check-updates  16.14.18  β†’  16.14.20

Run pnpm install to install new versions.
πŸ‘Ύ upgrade | pnpm i --no-frozen-lockfile
Scope: all 3 workspace projects
Progress: removed

dependencies:
- aws-cdk-lib 2.137.0
+ aws-cdk-lib 2.142.1
- cdk-nag 2.28.92
+ cdk-nag 2.28.119

devDependencies:
- npm-check-updates 16.14.18
+ npm-check-updates 16.14.20

Done in 4.7s
πŸ‘Ύ upgrade | pnpm update @aws/pdk @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser constructs eslint-config-prettier eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier eslint npm-check-updates nx prettier projen syncpack ts-node typescript @aws-cdk/aws-cognito-identitypool-alpha aws-cdk-lib cdk-nag
Progress: removed

dependencies:
- @aws-cdk/aws-cognito-identitypool-alpha 2.134.0-alpha.0
+ @aws-cdk/aws-cognito-identitypool-alpha 2.142.1-alpha.0

devDependencies:
- @aws/pdk 0.23.35
+ @aws/pdk 0.23.38
- @types/node 18.19.26
+ @types/node 18.19.33 (20.12.12 is available)
- syncpack 12.3.0
+ syncpack 12.3.2

Done in 2.2s
πŸ‘Ύ upgrade | pnpm exec projen
πŸ‘Ύ default | ts-node --project tsconfig.dev.json .projenrc.ts
πŸ‘Ύ Installing dependencies...
πŸ‘Ύ install | pnpm i --no-frozen-lockfile
Scope: all 3 workspace projects
Progress: removed

devDependencies:
- @aws/pdk 0.23.38
+ @aws/pdk 0.23.35 (0.23.38 is available)

Done in 4.4s
  1. projen goes from 0.79.24 to 0.81.15 back to 0.79.27

> @demo/monorepo@0.0.0 upgrade-deps UpgradeDemo
> pnpm exec projen upgrade-deps

πŸ‘Ύ upgrade-deps | pnpm exec nx run-many --target=upgrade --output-style=stream --nx-bail --projects=@demo/api,@demo/api-model

 >  NX   The following projects do not have a configuration for any of the provided targets ("upgrade")

   - @demo/api
   - @demo/api-model

 >  NX   No projects with target upgrade for 0 projects were run

 >  NX   Successfully ran target upgrade for 0 projects

πŸ‘Ύ upgrade-deps | pnpm exec npm-check-updates --deep --rejectVersion 0.0.0 -u --dep prod,dev,peer,optional,bundle --target=minor
Using pnpm
Upgrading UpgradeDemo/package.json
[====================] 20/20 100%

 constructs   ^10.0.0  β†’   ^10.3.0
 projen      ^0.79.24  β†’  ^0.81.15
Upgrading UpgradeDemo/packages/api/generated/infrastructure/typescript/package.json
[====================] 8/8 100%

 @aws/pdk     ^0.23.35  β†’   ^0.23.38
 aws-cdk-lib  ^2.137.0  β†’   ^2.142.1
 cdk-nag      ^2.28.92  β†’  ^2.28.119
 projen       ^0.79.24  β†’   ^0.81.15
Upgrading UpgradeDemo/packages/api/generated/runtime/typescript/package.json
[====================] 8/8 100%

 constructs   ^10.0.0  β†’   ^10.3.0
 projen      ^0.79.24  β†’  ^0.81.15

Run pnpm install to install new versions.
πŸ‘Ύ upgrade-deps | pnpm exec syncpack fix-mismatches
= Default Version Group ========================================================
    18 βœ“ already valid
    30 βœ“ fixed
βœ“ package.json
βœ“ packages/api/generated/infrastructure/typescript/package.json
βœ“ packages/api/generated/runtime/typescript/package.json
πŸ‘Ύ upgrade-deps | rm pnpm-lock.yaml
πŸ‘Ύ upgrade-deps | pnpm i
Scope: all 3 workspace projects
 WARN  5 deprecated subdependencies found: @npmcli/move-file@2.0.1, are-we-there-yet@3.0.1, gauge@4.0.4, npmlog@6.0.2, read-package-json@6.0.4
Packages: +4 -25
++++-------------------------
Progress: resolved 637, reused 629, downloaded 0, added 0, done

devDependencies:
- @aws/pdk 0.23.35
+ @aws/pdk 0.23.38
- projen 0.79.27
+ projen 0.81.15

 WARN  Issues with peer dependencies found
.
└─┬ @aws/pdk 0.23.38
  └── βœ• unmet peer projen@^0.79.24: found 0.81.15

packages/api/generated/infrastructure/typescript
└─┬ @aws/pdk 0.23.38
  └── βœ• unmet peer projen@^0.79.24: found 0.81.15

Done in 6s
πŸ‘Ύ upgrade-deps | pnpm exec projen
πŸ‘Ύ default | ts-node --project tsconfig.dev.json .projenrc.ts
πŸ‘Ύ Installing dependencies...
πŸ‘Ύ install | pnpm i --no-frozen-lockfile
Scope: all 3 workspace projects
 WARN  5 deprecated subdependencies found: @npmcli/move-file@2.0.1, are-we-there-yet@3.0.1, gauge@4.0.4, npmlog@6.0.2, read-package-json@6.0.4
Packages: +3 -2
+++--
Progress: resolved 637, reused 629, downloaded 0, added 0, done

devDependencies:
- projen 0.81.15
+ projen 0.79.27 (0.81.15 is available)

Done in 3.7s
  1. Re-synthing projen seems irrelevant, dependencies are not updated.

Reproduction Steps

Using these versions: @aws/pdk 0.23.35 & projen 0.79.24

Running the following steps does not upgrade pdk/projen:

  1. pnpm run upgrade
  2. pnpm upgrade-deps
  3. pnpm default

Possible Solution

No response

Additional Information/Context

A demo repo has been setup, hopefully it behaves the same in other environments:

https://github.com/raurir/projen-pdk-upgrade-issue/

PDK version used

0.23.35

What languages are you seeing this issue on?

Typescript

Environment details (OS name and version, etc.)

Macos 14.4

raurir commented 1 month ago

@agdimech Are you having the same issue in #710 ?

carter293 commented 3 weeks ago

I've also had this issue and can't find a solution...

agdimech commented 2 weeks ago

Hi - sorry for the delayed response.

The reason this is happening is because we actual pin the projen version as per: https://github.com/aws/aws-pdk/blob/6fc5ca16bb87fb00d61f25844ce2463c1c90980f/packages/monorepo/src/components/projen-dependency.ts#L4

So what is happening is the following:

1.) npm-check-updates runs and bumps everything to the latest version (projen is 0.82.6 as of today) 2.) syncpack ensures all subprojects use this version 3.) a synthesis occurs which picks up the default projen version which is currently pinned to ^0.79.24

To resolve this, you will need to do pin the projen version within your .projenrc as follows:

Option A: Pinned Version

const monorepo = new MonorepoTsProject({
  name: "@demo/monorepo",
  defaultReleaseBranch: "main",
  packageManager: NodePackageManager.PNPM,
  projenVersion: "^0.82.6",
  tsconfig: {
    compilerOptions: {
      lib: ["es2019", "dom"],
      skipLibCheck: true,
    },
  },
});

Option B: Latest Resolved Version

Note: this will result in the projen version being bumped each time you run a synth.

const monorepo = new MonorepoTsProject({
  name: "@demo/monorepo",
  defaultReleaseBranch: "main",
  packageManager: NodePackageManager.PNPM,
  projenVersion: "*",
  tsconfig: {
    compilerOptions: {
      lib: ["es2019", "dom"],
      skipLibCheck: true,
    },
  },
});

Let me know if this resolves your issue and again apologies for the delay (I was on vacation and then quite sick :( )

raurir commented 2 weeks ago

@agdimech Thank you!

Very Close... the dependencies updated, and almost everything builds.

Unfortunately the latest CloudscapeReactTsWebsiteProject is causing this error when building the website:

Attempted import error: 'getLogicalBoundingClientRect' is not exported from '@cloudscape-design/component-toolkit/internal' (imported as 'getLogicalBoundingClientRect').

I have logged a bug here which hopefully resolves it: https://github.com/cloudscape-design/component-toolkit/issues/66

In my demo repo I did not add a CloudscapeReactTsWebsiteProject to keep things simple :(