File tree Expand file tree Collapse file tree 2 files changed +39
-5
lines changed
packages/plugin-js-packages/src/lib/runner/outdated Expand file tree Collapse file tree 2 files changed +39
-5
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,14 @@ export function outdatedResultToAuditOutput(
1818 const relevantDependencies : OutdatedResult = result . filter (
1919 dep => dep . type === dependencyGroupToLong [ depGroup ] ,
2020 ) ;
21- const outdatedDependencies = relevantDependencies . filter (
22- dep => dep . current !== dep . latest ,
23- ) ;
21+ // TODO use semver logic to compare versions
22+ const outdatedDependencies = relevantDependencies
23+ . filter ( dep => dep . current !== dep . latest )
24+ . filter (
25+ dep =>
26+ dep . current . split ( '-' ) [ 0 ] ?. toString ( ) !==
27+ dep . latest . split ( '-' ) [ 0 ] ?. toString ( ) ,
28+ ) ;
2429
2530 const outdatedStats = outdatedDependencies . reduce (
2631 ( acc , dep ) => {
@@ -114,7 +119,8 @@ export function getOutdatedLevel(
114119}
115120
116121export function splitPackageVersion ( fullVersion : string ) : PackageVersion {
117- const [ major , minor , patch ] = fullVersion . split ( '.' ) . map ( Number ) ;
122+ const semanticVersion = String ( fullVersion . split ( '-' ) [ 0 ] ) ;
123+ const [ major , minor , patch ] = semanticVersion . split ( '.' ) . map ( Number ) ;
118124
119125 if ( major == null || minor == null || patch == null ) {
120126 throw new Error ( `Invalid version description ${ fullVersion } ` ) ;
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ describe('outdatedResultToAuditOutput', () => {
8787 {
8888 name : 'nx' ,
8989 current : '15.8.1' ,
90- latest : '17.0.0' ,
90+ latest : '17.0.0-stable ' ,
9191 type : 'dependencies' ,
9292 } ,
9393 {
@@ -169,6 +169,34 @@ describe('outdatedResultToAuditOutput', () => {
169169 displayValue : 'all dependencies are up to date' ,
170170 } ) ;
171171 } ) ;
172+
173+ it ( 'should skip identical semantic versions with different label' , ( ) => {
174+ expect (
175+ outdatedResultToAuditOutput (
176+ [
177+ {
178+ name : 'cypress' ,
179+ current : '13.7.0-alpha' ,
180+ latest : '13.7.0-beta' ,
181+ type : 'devDependencies' ,
182+ } ,
183+ {
184+ name : 'nx' ,
185+ current : '17.0.0-12' ,
186+ latest : '17.0.0-15' ,
187+ type : 'devDependencies' ,
188+ } ,
189+ ] ,
190+ 'npm' ,
191+ 'dev' ,
192+ ) ,
193+ ) . toEqual < AuditOutput > ( {
194+ slug : 'npm-outdated-dev' ,
195+ score : 1 ,
196+ value : 0 ,
197+ displayValue : 'all dependencies are up to date' ,
198+ } ) ;
199+ } ) ;
172200} ) ;
173201
174202describe ( 'calculateOutdatedScore' , ( ) => {
You can’t perform that action at this time.
0 commit comments