@@ -252,6 +252,14 @@ jobs:
252252
253253 let maxVersion = '0.0.0';
254254 const bumpedProjects = [];
255+ const internalVersions = {};
256+
257+ // Helper to increment patch version
258+ function bumpPatch(version) {
259+ const parts = version.split('.');
260+ parts[2] = String(parseInt(parts[2], 10) + 1);
261+ return parts.join('.');
262+ }
255263
256264 // Helper to generate changelog entry
257265 function generateChangelogEntry(version, changelog) {
@@ -291,6 +299,7 @@ jobs:
291299 fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
292300 console.error('Updated ' + proj.name + ' to ' + proj.newVersion + ' (' + proj.bump + '): ' + proj.reason);
293301 bumpedProjects.push(proj.name);
302+ internalVersions[proj.name] = proj.newVersion;
294303
295304 // Track max version
296305 if (proj.newVersion.localeCompare(maxVersion, undefined, { numeric: true, sensitivity: 'base' }) > 0) {
@@ -320,6 +329,56 @@ jobs:
320329 }
321330 }
322331
332+ // Second pass: Sync internal dependencies across ALL publishable packages
333+ // If a package depends on a bumped package, update the dep version and patch-bump the dependent
334+ const { execSync } = require('child_process');
335+ let allLibs = [];
336+ try {
337+ const allPublishable = execSync('npx nx show projects -p tag:scope:publishable --type lib --json', { encoding: 'utf8' });
338+ allLibs = JSON.parse(allPublishable);
339+ } catch (e) {
340+ console.error('Warning: Could not get publishable libs for dependency sync');
341+ }
342+
343+ for (const libName of allLibs) {
344+ const pkgPath = 'libs/' + libName + '/package.json';
345+ if (!fs.existsSync(pkgPath)) continue;
346+
347+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
348+ let modified = false;
349+ let needsBump = false;
350+
351+ // Check if any dependency was bumped
352+ if (pkg.dependencies) {
353+ for (const [dep, version] of Object.entries(pkg.dependencies)) {
354+ if (internalVersions[dep] && version !== internalVersions[dep]) {
355+ pkg.dependencies[dep] = internalVersions[dep];
356+ modified = true;
357+ needsBump = true;
358+ console.error('Updated ' + libName + ' dep ' + dep + ' to ' + internalVersions[dep]);
359+ }
360+ }
361+ }
362+
363+ // If this package wasn't already bumped but has updated deps, patch bump it
364+ if (needsBump && !internalVersions[libName]) {
365+ const newVersion = bumpPatch(pkg.version);
366+ pkg.version = newVersion;
367+ internalVersions[libName] = newVersion;
368+ bumpedProjects.push(libName);
369+ console.error('Patch bumped ' + libName + ' to ' + newVersion + ' (dependency update)');
370+
371+ // Update max version
372+ if (newVersion.localeCompare(maxVersion, undefined, { numeric: true, sensitivity: 'base' }) > 0) {
373+ maxVersion = newVersion;
374+ }
375+ }
376+
377+ if (modified) {
378+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
379+ }
380+ }
381+
323382 // Update global changelog
324383 if (output.globalChangelog && bumpedProjects.length > 0) {
325384 const globalPath = 'CHANGELOG.md';
0 commit comments