diff --git a/packages/accurapp-scripts/bin/scripts.js b/packages/accurapp-scripts/bin/scripts.js index 536fa534..258c4f7d 100755 --- a/packages/accurapp-scripts/bin/scripts.js +++ b/packages/accurapp-scripts/bin/scripts.js @@ -4,7 +4,7 @@ if (parseFloat(process.versions.node) < 6.5) throw new Error('Sorry, Node 6.5+ i // warn if any accurapp package is outdated const latestVersion = require('latest-version') const semver = require('semver') -const { outdatedDepsBox } = require('../scripts/_utils') +const { createOutdatedMessage, yellowBox } = require('../scripts/_utils') const currentDeps = [ require('../package.json'), @@ -18,7 +18,8 @@ Promise.all(currentDeps.map((dep) => latestVersion(dep.name))) const outdatedDeps = currentDeps.filter((dep, i) => semver.lt(dep.version, updatedDeps[i].version)) if (outdatedDeps.length > 0) { - console.log(outdatedDepsBox(outdatedDeps, updatedDeps)) + const message = createOutdatedMessage(outdatedDeps, updatedDeps) + console.log(yellowBox(message)) } }) diff --git a/packages/accurapp-scripts/scripts/_utils.js b/packages/accurapp-scripts/scripts/_utils.js index bbb4c241..2a628d0f 100644 --- a/packages/accurapp-scripts/scripts/_utils.js +++ b/packages/accurapp-scripts/scripts/_utils.js @@ -22,23 +22,26 @@ function coloredBanner(text, colors = ['blue', 'red']) { return `\n${colored}` } -function outdatedDepsBox(outdatedDeps, updatedDeps) { +function yellowBox(message) { + const boxenOptions = { + padding: 1, + align: 'center', + borderColor: 'yellow', + } + + return boxen(message, boxenOptions) +} + +function createOutdatedMessage(outdatedDeps, updatedDeps) { const outdatedMessages = outdatedDeps.map((dep, i) => `${chalk.blue(dep.name)} ${chalk.gray(dep.version)} → ${chalk.green(updatedDeps[i].version)}` ) - const message = ` + return ` ${chalk.yellow('Hey, an update for accurapp is available!')} ${outdatedMessages.join('\n')} ${chalk.yellow('Run')} ${chalk.cyan('yarn upgrade-interactive')} ${chalk.yellow('to update')} ` - const boxenOptions = { - padding: 1, - align: 'center', - borderColor: 'yellow', - } - - return boxen(message, boxenOptions) } function indent(text, prepend = ' ', firstLinePrepend = prepend) { @@ -108,7 +111,8 @@ module.exports = { log, noop, coloredBanner, - outdatedDepsBox, + yellowBox, + createOutdatedMessage, indent, listLine, readWebpackConfig,