File tree Expand file tree Collapse file tree 4 files changed +242
-5
lines changed Expand file tree Collapse file tree 4 files changed +242
-5
lines changed Original file line number Diff line number Diff line change 15
15
"package" : " pkg --targets node8.3.0-linux-x64,node8.3.0-win-x64,node8.3.0-macos-x64 -o exoframe index.js"
16
16
},
17
17
"dependencies" : {
18
+ "boxen" : " ^1.2.1" ,
18
19
"chalk" : " ^2.1.0" ,
19
20
"cli-table" : " ^0.3.1" ,
20
21
"got" : " ^7.1.0" ,
26
27
"opn" : " ^5.1.0" ,
27
28
"ora" : " ^1.3.0" ,
28
29
"tar-fs" : " ^1.15.3" ,
30
+ "update-notifier" : " ^2.2.0" ,
29
31
"yargs" : " ^8.0.2"
30
32
},
31
33
"devDependencies" : {
Original file line number Diff line number Diff line change 1
1
// npm packages
2
2
const yargs = require ( 'yargs' ) ;
3
3
4
+ // our packages
5
+ const checkUpdate = require ( './util/checkUpdate' ) ;
6
+
4
7
// version
5
8
const pkg = require ( '../package.json' ) ;
6
9
10
+ // check for updates on start
11
+ checkUpdate ( pkg ) ;
12
+
7
13
// our packages
8
14
const login = require ( './commands/login' ) ;
9
15
const deploy = require ( './commands/deploy' ) ;
Original file line number Diff line number Diff line change
1
+ // npm packages
2
+ const chalk = require ( 'chalk' ) ;
3
+ const boxen = require ( 'boxen' ) ;
4
+ const updateNotifier = require ( 'update-notifier' ) ;
5
+
6
+ // boxen options
7
+ const boxenOpts = {
8
+ padding : 1 ,
9
+ margin : 1 ,
10
+ align : 'center' ,
11
+ borderColor : 'yellow' ,
12
+ borderStyle : 'round' ,
13
+ } ;
14
+ // packaged script path
15
+ const pkgPath = '/snapshot/exoframe-cli/src/util' ;
16
+
17
+ // check function
18
+ module . exports = pkg => {
19
+ // Checks for available update and returns an instance
20
+ const notifier = updateNotifier ( {
21
+ pkg,
22
+ updateCheckInterval : 1000 ,
23
+ } ) ;
24
+ // show message if update is available
25
+ if ( notifier . update ) {
26
+ const { update} = notifier ;
27
+ const isPackaged = __dirname === pkgPath ;
28
+ const upNpmMsg = `Run ${ chalk . cyan ( 'npm i -g exoframe' ) } to update` ;
29
+ const upPkgMsg = `Download from ${ chalk . cyan ( 'https://github.com/exoframejs/exoframe/releases' ) } ` ;
30
+ const upmsg = isPackaged ? upPkgMsg : upNpmMsg ;
31
+ const message = `Update available ${ chalk . dim ( update . current ) } ${ chalk . reset ( ' → ' ) } ${ chalk . green (
32
+ update . latest
33
+ ) } \n${ upmsg } `;
34
+ console . log ( `\n${ boxen ( message , boxenOpts ) } ` ) ;
35
+ }
36
+ } ;
You can’t perform that action at this time.
0 commit comments