@@ -416,6 +416,22 @@ export async function findAllPackageFiles(dir: string = process.cwd(), recursive
416416 packageFiles . push ( rootPackageJsonPath )
417417 }
418418
419+ // Also check for pantry.json/pantry.jsonc in root
420+ const rootPantryJsonPath = join ( dir , 'pantry.json' )
421+ if ( existsSync ( rootPantryJsonPath ) ) {
422+ packageFiles . push ( rootPantryJsonPath )
423+ }
424+ const rootPantryJsoncPath = join ( dir , 'pantry.jsonc' )
425+ if ( existsSync ( rootPantryJsoncPath ) ) {
426+ packageFiles . push ( rootPantryJsoncPath )
427+ }
428+
429+ // Also check for package.jsonc in root
430+ const rootPackageJsoncPath = join ( dir , 'package.jsonc' )
431+ if ( existsSync ( rootPackageJsoncPath ) ) {
432+ packageFiles . push ( rootPackageJsoncPath )
433+ }
434+
419435 if ( recursive ) {
420436 // First try workspace-aware discovery
421437 const workspacePackages = await getWorkspacePackages ( dir )
@@ -436,6 +452,49 @@ export async function findAllPackageFiles(dir: string = process.cwd(), recursive
436452 }
437453 }
438454 }
455+
456+ // Also find pantry.json and pantry.jsonc files recursively
457+ const pantryJsonGlob = join ( dir , '**/pantry.json' )
458+ const pantryFiles = await glob ( pantryJsonGlob , {
459+ ignore : respectGitignore ? [ '**/node_modules/**' , '**/.git/**' ] : [ ] ,
460+ } )
461+ for ( const pantryPath of pantryFiles ) {
462+ if ( ! packageFiles . includes ( pantryPath ) ) {
463+ packageFiles . push ( pantryPath )
464+ }
465+ }
466+
467+ const pantryJsoncGlob = join ( dir , '**/pantry.jsonc' )
468+ const pantryJsoncFiles = await glob ( pantryJsoncGlob , {
469+ ignore : respectGitignore ? [ '**/node_modules/**' , '**/.git/**' ] : [ ] ,
470+ } )
471+ for ( const pantryPath of pantryJsoncFiles ) {
472+ if ( ! packageFiles . includes ( pantryPath ) ) {
473+ packageFiles . push ( pantryPath )
474+ }
475+ }
476+
477+ // Also find package.jsonc files recursively
478+ const packageJsoncGlob = join ( dir , '**/package.jsonc' )
479+ const packageJsoncFiles = await glob ( packageJsoncGlob , {
480+ ignore : respectGitignore ? [ '**/node_modules/**' , '**/.git/**' ] : [ ] ,
481+ } )
482+ for ( const packagePath of packageJsoncFiles ) {
483+ if ( ! packageFiles . includes ( packagePath ) ) {
484+ packageFiles . push ( packagePath )
485+ }
486+ }
487+
488+ // Also find build.zig.zon files recursively (Zig package manifests)
489+ const zigZonGlob = join ( dir , '**/build.zig.zon' )
490+ const zigZonFiles = await glob ( zigZonGlob , {
491+ ignore : respectGitignore ? [ '**/node_modules/**' , '**/.git/**' ] : [ ] ,
492+ } )
493+ for ( const zigPath of zigZonFiles ) {
494+ if ( ! packageFiles . includes ( zigPath ) ) {
495+ packageFiles . push ( zigPath )
496+ }
497+ }
439498 }
440499
441500 return packageFiles
@@ -473,17 +532,54 @@ export function writePackageJson(filePath: string, packageJson: PackageJson): vo
473532export function updateVersionInFile ( filePath : string , oldVersion : string , newVersion : string , forceUpdate : boolean = false , dryRun : boolean = false ) : FileInfo {
474533 try {
475534 const content = readFileSync ( filePath , 'utf-8' )
476- const isPackageJson = filePath . endsWith ( 'package.json' )
535+ const isPackageJson = filePath . endsWith ( 'package.json' ) || filePath . endsWith ( 'package.jsonc' )
536+ const isPantryJson = filePath . endsWith ( 'pantry.json' ) || filePath . endsWith ( 'pantry.jsonc' )
537+ const isJsonc = filePath . endsWith ( '.jsonc' )
538+ const isZigZon = filePath . endsWith ( 'build.zig.zon' )
477539
478540 let newContent : string = content
479541 let updated = false
480542
481- if ( isPackageJson ) {
482- const packageJson = JSON . parse ( content )
543+ if ( isZigZon ) {
544+ // Handle Zig build.zig.zon files
545+ // Format: .version = "0.0.0",
546+ const versionRegex = new RegExp (
547+ `(\\.version\\s*=\\s*")${ oldVersion . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) } ("\\s*,)` ,
548+ 'g'
549+ )
550+ if ( content . match ( versionRegex ) || forceUpdate ) {
551+ newContent = content . replace ( versionRegex , `$1${ newVersion } $2` )
552+ updated = true
553+ }
554+ }
555+ else if ( isPackageJson || isPantryJson ) {
556+ // For JSONC files, we need to strip comments before parsing
557+ let jsonContent = content
558+ if ( isJsonc ) {
559+ // Simple comment removal (handles // and /* */ comments)
560+ jsonContent = content
561+ . replace ( / \/ \* [ \s \S ] * ?\* \/ / g, '' ) // Remove /* */ comments
562+ . replace ( / \/ \/ .* / g, '' ) // Remove // comments
563+ }
564+
565+ const packageJson = JSON . parse ( jsonContent )
483566 if ( packageJson . version === oldVersion || forceUpdate ) {
484567 packageJson . version = newVersion
485- newContent = `${ JSON . stringify ( packageJson , null , 2 ) } \n`
486- updated = true
568+
569+ // For JSONC files, preserve the original formatting with comments
570+ if ( isJsonc ) {
571+ // Replace the version value while preserving comments and formatting
572+ const versionRegex = new RegExp (
573+ `(["']version["']\\s*:\\s*)["']${ oldVersion . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) } ["']` ,
574+ 'g'
575+ )
576+ newContent = content . replace ( versionRegex , `$1"${ newVersion } "` )
577+ updated = true
578+ } else {
579+ // For regular JSON, use standard formatting
580+ newContent = `${ JSON . stringify ( packageJson , null , 2 ) } \n`
581+ updated = true
582+ }
487583 }
488584 }
489585 else {
0 commit comments