@@ -71,13 +71,16 @@ export class RegistryClient {
71
71
// Get additional metadata for the package
72
72
const metadata = await this . getPackageMetadata ( result . name )
73
73
74
+ // Find the actual package.json file that contains this package
75
+ const packageLocation = await this . findPackageLocation ( result . name )
76
+
74
77
updates . push ( {
75
78
name : result . name ,
76
79
currentVersion : result . current ,
77
80
newVersion : result . latest ,
78
81
updateType,
79
82
dependencyType : 'dependencies' , // Will be refined based on package.json analysis
80
- file : 'package.json' , // Will be refined based on actual file location
83
+ file : packageLocation || 'package.json' , // Use actual location or fallback
81
84
metadata,
82
85
releaseNotesUrl : this . getReleaseNotesUrl ( result . name , metadata ) ,
83
86
changelogUrl : this . getChangelogUrl ( result . name , metadata ) ,
@@ -1084,11 +1087,14 @@ export class RegistryClient {
1084
1087
*/
1085
1088
private async getWorkspaceOutdatedPackages ( ) : Promise < BunOutdatedResult [ ] > {
1086
1089
try {
1090
+ // Get both workspace names and direct package.json file scanning
1087
1091
const workspaceNames = await this . getWorkspaceNames ( )
1092
+ const packageJsonFiles = await this . findPackageJsonFiles ( )
1088
1093
const allResults : BunOutdatedResult [ ] = [ ]
1089
1094
1090
1095
this . logger . info ( `Found ${ workspaceNames . length } workspace packages to check` )
1091
1096
1097
+ // Check by workspace name (if bun supports it)
1092
1098
for ( const workspaceName of workspaceNames ) {
1093
1099
try {
1094
1100
const results = await this . runBunOutdatedForWorkspace ( workspaceName )
@@ -1099,6 +1105,60 @@ export class RegistryClient {
1099
1105
}
1100
1106
}
1101
1107
1108
+ // Also directly check packages in each package.json for better coverage
1109
+ this . logger . info ( `Checking ${ packageJsonFiles . length } package.json files directly` )
1110
+
1111
+ for ( const filePath of packageJsonFiles ) {
1112
+ if ( filePath === 'package.json' ) continue // Skip root, already checked
1113
+
1114
+ try {
1115
+ const fullPath = path . join ( this . projectPath , filePath )
1116
+ const content = fs . readFileSync ( fullPath , 'utf-8' )
1117
+ const packageData = JSON . parse ( content )
1118
+
1119
+ const allDeps = {
1120
+ ...packageData . dependencies ,
1121
+ ...packageData . devDependencies ,
1122
+ ...packageData . peerDependencies ,
1123
+ ...packageData . optionalDependencies ,
1124
+ }
1125
+
1126
+ for ( const [ packageName , currentVersion ] of Object . entries ( allDeps ) ) {
1127
+ // Skip workspace dependencies and invalid versions
1128
+ if ( typeof currentVersion !== 'string' || currentVersion . startsWith ( 'workspace:' ) ) {
1129
+ continue
1130
+ }
1131
+
1132
+ // Check if already found in workspace results
1133
+ if ( allResults . some ( r => r . name === packageName ) ) {
1134
+ continue
1135
+ }
1136
+
1137
+ try {
1138
+ const latestVersion = await this . getLatestVersion ( packageName )
1139
+ if ( latestVersion ) {
1140
+ const cleanCurrentVersion = this . cleanVersionRange ( currentVersion )
1141
+ if ( cleanCurrentVersion && Bun . semver . order ( cleanCurrentVersion , latestVersion ) < 0 ) {
1142
+ allResults . push ( {
1143
+ name : packageName ,
1144
+ current : cleanCurrentVersion ,
1145
+ update : latestVersion ,
1146
+ latest : latestVersion ,
1147
+ file : filePath , // Store which file contains this package
1148
+ } )
1149
+ }
1150
+ }
1151
+ } catch ( error ) {
1152
+ // Continue if version check fails for this package
1153
+ continue
1154
+ }
1155
+ }
1156
+ }
1157
+ catch ( error ) {
1158
+ this . logger . warn ( `Failed to check packages in ${ filePath } :` , error )
1159
+ }
1160
+ }
1161
+
1102
1162
this . logger . info ( `Found ${ allResults . length } outdated packages across workspaces` )
1103
1163
return allResults
1104
1164
}
@@ -1194,6 +1254,39 @@ export class RegistryClient {
1194
1254
return skipDirs . includes ( dirName ) || dirName . startsWith ( '.' )
1195
1255
}
1196
1256
1257
+ /**
1258
+ * Find the actual package.json file that contains a specific package
1259
+ */
1260
+ private async findPackageLocation ( packageName : string ) : Promise < string | null > {
1261
+ const packageJsonFiles = await this . findPackageJsonFiles ( )
1262
+
1263
+ for ( const filePath of packageJsonFiles ) {
1264
+ try {
1265
+ const fullPath = path . join ( this . projectPath , filePath )
1266
+ const content = fs . readFileSync ( fullPath , 'utf-8' )
1267
+ const packageData = JSON . parse ( content )
1268
+
1269
+ // Check all dependency sections
1270
+ const allDeps = {
1271
+ ...packageData . dependencies ,
1272
+ ...packageData . devDependencies ,
1273
+ ...packageData . peerDependencies ,
1274
+ ...packageData . optionalDependencies ,
1275
+ }
1276
+
1277
+ if ( allDeps [ packageName ] ) {
1278
+ return filePath
1279
+ }
1280
+ }
1281
+ catch ( error ) {
1282
+ // Continue searching if this file is malformed
1283
+ continue
1284
+ }
1285
+ }
1286
+
1287
+ return null
1288
+ }
1289
+
1197
1290
/**
1198
1291
* Run bun outdated for a specific workspace
1199
1292
*/
0 commit comments