@@ -10,6 +10,9 @@ import {Add} from './add.js';
10
10
import { Install } from './install.js' ;
11
11
import Lockfile from '../../lockfile/wrapper.js' ;
12
12
13
+ const tty = require ( 'tty' ) ;
14
+ const semver = require ( 'semver' ) ;
15
+
13
16
export const requireLockfile = true ;
14
17
15
18
export function setFlags ( commander : Object ) {
@@ -29,14 +32,16 @@ type InquirerResponses<K, T> = {[key: K]: Array<T>};
29
32
30
33
// Prompt user with Inquirer
31
34
async function prompt ( choices ) : Promise < Array < Dependency >> {
35
+ let pageSize ;
36
+ if ( process . stdout instanceof tty . WriteStream ) {
37
+ pageSize = process . stdout . rows - 2 ;
38
+ }
32
39
const answers : InquirerResponses < 'packages' , Dependency > = await inquirer . prompt ( [ {
33
40
name : 'packages' ,
34
41
type : 'checkbox' ,
35
42
message : 'Choose which packages to update.' ,
36
43
choices,
37
- // Couldn't make it work, I guess I'm missing something here
38
- // $FlowFixMe: https://github.com/facebook/flow/blob/f41e66e27b227235750792c34f5a80f38bde6320/lib/node.js#L1197
39
- pageSize : process . stdout . rows - 2 ,
44
+ pageSize,
40
45
validate : ( answer ) => ! ! answer . length || 'You must choose at least one package.' ,
41
46
} ] ) ;
42
47
return answers . packages ;
@@ -74,17 +79,11 @@ export async function run(
74
79
return ( { name, current, wanted, latest, hint} ) ;
75
80
} ) ) ) ;
76
81
77
- const isDepOld = ( { latest, current} ) => latest !== current ;
82
+ const isDepOld = ( { latest, current} ) => latest !== 'exotic' && semver . lt ( current , latest ) ;
78
83
const isDepExpected = ( { current, wanted} ) => current === wanted ;
84
+ const orderByExpected = ( depA , depB ) => isDepExpected ( depA ) && ! isDepExpected ( depB ) ? 1 : - 1 ;
79
85
80
- const outdatedDeps = allDeps
81
- . filter ( isDepOld )
82
- . sort ( ( depA , depB ) => {
83
- if ( isDepExpected ( depA ) && ! isDepExpected ( depB ) ) {
84
- return 1 ;
85
- }
86
- return - 1 ;
87
- } ) ;
86
+ const outdatedDeps = allDeps . filter ( isDepOld ) . sort ( orderByExpected ) ;
88
87
89
88
const getNameFromHint = ( hint ) => hint ? `${ hint } Dependencies` : 'dependencies' ;
90
89
0 commit comments