diff --git a/gulpfile.js b/gulpfile.js index e63f722..6c6c620 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,23 +1,30 @@ // 1. LIBRARIES try { -var gulp = require('gulp'), - plugins = require('gulp-load-plugins')(), - del = require('del'), - runSequence = require('run-sequence'), - browsersync = require('browser-sync').create(), - clip = require('gulp-clip-empty-files'), - path = require('path'), - argv = require('yargs').argv, - merge = require('merge-stream'), - extend = require('node.extend'), - util = require('./lib/util'), - scssToLess = require('./lib/scssToLess'), - rtlcss = require('./lib/rtlcss'), - validate = require('jsonschema').validate, - schema = require('./lib/defaultSchema'), - fs = require("fs"), - mkdirp = require('mkdirp'), - chalk = require('chalk'); + // required hack to make updateNotifier work as intended in a gulpfile + delete process.env.npm_config_username; + delete process.env.npm_package_name; + delete process.env.npm_config_heading; + + var gulp = require('gulp'), + plugins = require('gulp-load-plugins')(), + del = require('del'), + runSequence = require('run-sequence'), + browsersync = require('browser-sync').create(), + clip = require('gulp-clip-empty-files'), + path = require('path'), + argv = require('yargs').argv, + merge = require('merge-stream'), + extend = require('node.extend'), + util = require('./lib/util'), + scssToLess = require('./lib/scssToLess'), + rtlcss = require('./lib/rtlcss'), + validate = require('jsonschema').validate, + schema = require('./lib/defaultSchema'), + fs = require("fs"), + mkdirp = require('mkdirp'); + + const chalk = require('chalk'); + const updateNotifier = require('update-notifier'); } catch (e) { console.error('Your installation is missing dependencies. Please execute "npm install" again.'); process.exit(); @@ -339,5 +346,6 @@ gulp.task('default', function() { console.log(chalk.cyan.bold("Now open up your favorite code editor and modify any file within:")); console.log(dirs); console.log(chalk.cyan.bold("All files belonging in the directories above are made available to use in APEX")); + util.isUpToDate(); }); }); diff --git a/lib/util.js b/lib/util.js index 4ddeacf..b19e286 100644 --- a/lib/util.js +++ b/lib/util.js @@ -12,5 +12,24 @@ module.exports = { } catch (e) { return false; } + }, + + // verifies if APEX Front-End Boost is up to date with the latest version + isUpToDate: function() { + const chalk = require('chalk'); + const updateNotifier = require('update-notifier'); + const pkg = require('../package.json'); + + // Checks for available update and returns an instance + const notifier = updateNotifier({pkg}); + + // Notify using the built-in convenience method + if (notifier.update) { + notifier.notify({ + defer: false, + message: chalk.bold('APEX Front-End Boost') + ' update available ' + chalk.dim(notifier.update.current) + chalk.reset(' → ') + + chalk.green(notifier.update.latest) + ' \nRun:\n' + chalk.cyan.bold('git fetch origin') + '\n' + chalk.cyan.bold('git reset--hard origin/master') + '\n' + chalk.cyan.bold('npm install') + }); + } } }; diff --git a/package.json b/package.json index 5fd2eea..d2142ad 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "apex-frontend-boost", - "author": "OraOpenSource", "version": "2.1.3", + "author": "OraOpenSource", "description": "Enhance your productivity with a complete Front-End Stack for Oracle APEX development", "license": "MIT", "keywords": [ @@ -58,6 +58,7 @@ "rtlcss": "2.0.x", "run-sequence": "1.2.x", "through2": "2.0.x", - "yargs": "4.8.x" + "update-notifier": "1.0.x", + "yargs": "5.0.x" } }