@@ -3,18 +3,25 @@ import { coerce, gte, minVersion } from 'semver'
33import { name as pkgName , version as pkgVersion } from '../../constants'
44import { scriptsEntries } from './scripts'
55
6- function isWorkspace ( version ?: string ) {
7- if ( typeof version === 'string' ) {
8- return version . startsWith ( 'workspace:' )
9- }
10- return false
11- }
6+ const NON_OVERRIDABLE_PREFIXES = [ 'workspace:' , 'catalog:' ]
127
138function parseVersion ( input : unknown ) {
149 if ( typeof input !== 'string' || input . trim ( ) . length === 0 ) {
1510 return null
1611 }
17- return minVersion ( input ) ?? coerce ( input )
12+ try {
13+ return minVersion ( input ) ?? coerce ( input )
14+ }
15+ catch {
16+ return null
17+ }
18+ }
19+
20+ function hasNonOverridablePrefix ( version ?: string ) {
21+ if ( typeof version !== 'string' ) {
22+ return false
23+ }
24+ return NON_OVERRIDABLE_PREFIXES . some ( prefix => version . startsWith ( prefix ) )
1825}
1926
2027function shouldAssignVersion ( currentVersion : unknown , nextVersion : string ) {
@@ -65,7 +72,7 @@ export function setPkgJson(
6572 }
6673
6774 const targetVersion = targetDeps [ depName ]
68- if ( isWorkspace ( targetVersion ) ) {
75+ if ( hasNonOverridablePrefix ( targetVersion ) ) {
6976 continue
7077 }
7178 if ( shouldAssignVersion ( targetVersion , depVersion ) ) {
@@ -84,13 +91,13 @@ export function setPkgJson(
8491 if ( depName === pkgName ) {
8592 const nextVersion = `^${ pkgVersion } `
8693 const targetVersion = targetDevDeps [ depName ]
87- if ( ! isWorkspace ( targetVersion ) && shouldAssignVersion ( targetVersion , nextVersion ) ) {
94+ if ( ! hasNonOverridablePrefix ( targetVersion ) && shouldAssignVersion ( targetVersion , nextVersion ) ) {
8895 targetDevDeps [ depName ] = nextVersion
8996 }
9097 }
9198 else {
9299 const targetVersion = targetDevDeps [ depName ]
93- if ( isWorkspace ( targetVersion ) ) {
100+ if ( hasNonOverridablePrefix ( targetVersion ) ) {
94101 continue
95102 }
96103 if ( shouldAssignVersion ( targetVersion , depVersion ) ) {
0 commit comments