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 1515 "package" : " pkg --targets node8.3.0-linux-x64,node8.3.0-win-x64,node8.3.0-macos-x64 -o exoframe index.js"
1616 },
1717 "dependencies" : {
18+ "boxen" : " ^1.2.1" ,
1819 "chalk" : " ^2.1.0" ,
1920 "cli-table" : " ^0.3.1" ,
2021 "got" : " ^7.1.0" ,
2627 "opn" : " ^5.1.0" ,
2728 "ora" : " ^1.3.0" ,
2829 "tar-fs" : " ^1.15.3" ,
30+ "update-notifier" : " ^2.2.0" ,
2931 "yargs" : " ^8.0.2"
3032 },
3133 "devDependencies" : {
Original file line number Diff line number Diff line change 11// npm packages
22const yargs = require ( 'yargs' ) ;
33
4+ // our packages
5+ const checkUpdate = require ( './util/checkUpdate' ) ;
6+
47// version
58const pkg = require ( '../package.json' ) ;
69
10+ // check for updates on start
11+ checkUpdate ( pkg ) ;
12+
713// our packages
814const login = require ( './commands/login' ) ;
915const 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