Skip to content

Commit acb52d5

Browse files
committed
test: add npm ci regression test for #3158
1 parent bddb2c8 commit acb52d5

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

shared-scripts.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,48 @@ function _verifyAmplifyBackendCompatability {
194194
# Build and test the backend
195195
npm run build && npm run test
196196

197+
# Verify bundled dependency completeness (regression test for #3158)
198+
# Check that bundledDependencies includes all transitive deps of bundled packages
199+
echo "Verifying bundled dependency completeness..."
200+
node -e "
201+
const path = require('path');
202+
const fs = require('fs');
203+
204+
const constructs = [
205+
'node_modules/@aws-amplify/data-construct',
206+
'node_modules/@aws-amplify/graphql-api-construct'
207+
];
208+
const exclude = new Set(['aws-cdk-lib', 'constructs', '@aws-cdk/toolkit-lib']);
209+
210+
let missing = [];
211+
for (const constructPath of constructs) {
212+
if (!fs.existsSync(constructPath)) continue;
213+
const pkg = JSON.parse(fs.readFileSync(path.join(constructPath, 'package.json'), 'utf8'));
214+
const bundled = new Set(pkg.bundledDependencies || []);
215+
const nm = path.join(constructPath, 'node_modules');
216+
if (!fs.existsSync(nm)) continue;
217+
218+
for (const dep of bundled) {
219+
const depPkgPath = path.join(nm, dep, 'package.json');
220+
if (!fs.existsSync(depPkgPath)) continue;
221+
const depJson = JSON.parse(fs.readFileSync(depPkgPath, 'utf8'));
222+
for (const transitive of Object.keys(depJson.dependencies || {})) {
223+
if (!bundled.has(transitive) && !exclude.has(transitive)) {
224+
missing.push(pkg.name + ': ' + dep + ' requires ' + transitive + ' (not bundled)');
225+
}
226+
}
227+
}
228+
}
229+
230+
if (missing.length > 0) {
231+
console.error('ERROR: Missing bundled transitive dependencies:');
232+
missing.forEach(m => console.error(' ' + m));
233+
process.exit(1);
234+
} else {
235+
console.log('All bundled transitive dependencies are present.');
236+
}
237+
"
238+
197239
echo "Amplify Backend Compatibility verification complete."
198240
}
199241
function _setupNodeVersion {

0 commit comments

Comments
 (0)