|
77 | 77 | npm create amplify@latest -- --yes |
78 | 78 | node $GITHUB_WORKSPACE/packages/create-blocks-app/dist/index.js --yes . |
79 | 79 |
|
| 80 | + # De-skew the sandbox typecheck against the drifting Amplify scaffold. |
| 81 | + # |
| 82 | + # `npm create amplify@latest` installs its OWN aws-cdk-lib/constructs at |
| 83 | + # whatever versions it currently ships, which drift from the versions this |
| 84 | + # repo builds against. The generated aws-blocks/index.cdk.ts resolves |
| 85 | + # aws-cdk-lib (Stack/Mixins) from THIS scaffold's tree, while the Blocks |
| 86 | + # packages — linked in as `file:` deps (symlinks) — resolve their own |
| 87 | + # constructs/aws-cdk-lib from the REPO's tree via the symlink realpath. |
| 88 | + # tsc dedups modules by package id (name@version), so when the two trees |
| 89 | + # are DIFFERENT versions it treats them as distinct declarations and the |
| 90 | + # nominally-private Construct#host member no longer matches — failing with |
| 91 | + # TS2345 "separate declarations of a private property 'host'". |
| 92 | + # |
| 93 | + # Fix: pin the scaffold's constructs/aws-cdk-lib to the repo's EXACT |
| 94 | + # installed versions (read from node_modules, not the package.json semver |
| 95 | + # range, so the ids match precisely — a range could resolve to a newer |
| 96 | + # patch and re-drift). The scaffold lists both as DIRECT devDependencies, |
| 97 | + # and npm refuses an `overrides` entry for a directly-depended package |
| 98 | + # unless the direct spec matches the override exactly (EOVERRIDE) — so pin |
| 99 | + # the direct dep specs to those same exact versions AND set the overrides |
| 100 | + # (the latter also dedupes any transitive copies), then reinstall. Matching |
| 101 | + # versions => matching package ids => tsc dedups to one declaration. |
| 102 | + - name: Pin constructs/aws-cdk-lib to the repo's versions |
| 103 | + run: | |
| 104 | + cd /tmp/amplify-interop-test |
| 105 | + node -e ' |
| 106 | + const fs = require("fs"); |
| 107 | + const ws = process.env.GITHUB_WORKSPACE; |
| 108 | + const ver = (n) => { |
| 109 | + try { return require(ws + "/node_modules/" + n + "/package.json").version; } |
| 110 | + catch { const p = require(ws + "/package.json"); return (p.devDependencies || {})[n] || (p.dependencies || {})[n]; } |
| 111 | + }; |
| 112 | + const constructsV = ver("constructs"), cdkV = ver("aws-cdk-lib"); |
| 113 | + if (!constructsV || !cdkV) throw new Error("could not determine constructs/aws-cdk-lib version from repo"); |
| 114 | + const pkg = JSON.parse(fs.readFileSync("package.json", "utf8")); |
| 115 | + const pins = { constructs: constructsV, "aws-cdk-lib": cdkV }; |
| 116 | + for (const [name, v] of Object.entries(pins)) { |
| 117 | + for (const bucket of ["dependencies", "devDependencies"]) { |
| 118 | + if (pkg[bucket] && pkg[bucket][name]) pkg[bucket][name] = v; |
| 119 | + } |
| 120 | + } |
| 121 | + pkg.overrides = { ...pkg.overrides, ...pins }; |
| 122 | + fs.writeFileSync("package.json", JSON.stringify(pkg, null, 2) + "\n"); |
| 123 | + console.log("pinned constructs=" + constructsV + " aws-cdk-lib=" + cdkV + " (direct deps + overrides)"); |
| 124 | + ' |
| 125 | + rm -rf node_modules package-lock.json |
| 126 | + npm install |
| 127 | +
|
80 | 128 | - name: Deploy sandbox |
81 | 129 | run: | |
82 | 130 | cd /tmp/amplify-interop-test |
|
0 commit comments