Files
vue-cli/packages/@vue/cli/lib/util/clearConsole.js
Haoqun Jiang 044f5b3b7e refactor: use a version map to determine the newest dependency versions
Now that lerna independent mode is used to release new versions, we can
no longer ensure the core service/plugin versions are in sync with
@vue/cli itself. So `vue-cli-version-marker` is now used to store the
latest version map of core packages.

In order to automate this process, all the core cli packages are listed
as `devDependencies` of `vue-cli-version-marker`. This will cause a
cyclic dependency warning in lerna bootstrap, and that warning can be
safely ignored because these are just `devDependencies` which won't
affect end users.

Another gotcha is that the version of `vue-cli-version-marker` will be
bumped each time we do a release. This may break the remote version
check logic before rc.12 (due to
1ae223dfc0 (diff-ac5fc3f8b11df9fc948b8e5aa52a074e)
the background version check might never get executed since rc.12)
2018-11-12 14:24:41 +08:00

35 lines
1.2 KiB
JavaScript

const chalk = require('chalk')
const semver = require('semver')
const getVersions = require('./getVersions')
const { clearConsole } = require('@vue/cli-shared-utils')
exports.generateTitle = async function (checkUpdate) {
const { current, latest } = await getVersions()
let title = chalk.bold.blue(`Vue CLI v${current['@vue/cli']}`)
if (process.env.VUE_CLI_TEST) {
title += ' ' + chalk.blue.bold('TEST')
}
if (process.env.VUE_CLI_DEBUG) {
title += ' ' + chalk.magenta.bold('DEBUG')
}
if (checkUpdate && semver.gt(latest['@vue/cli'], current['@vue/cli'])) {
if (process.env.VUE_CLI_API_MODE) {
title += chalk.green(` 🌟️ Update available: ${latest}`)
} else {
title += chalk.green(`
┌────────────────────${``.repeat(latest['@vue/cli'].length)}──┐
│ Update available: ${latest['@vue/cli']}
└────────────────────${``.repeat(latest['@vue/cli'].length)}──┘`)
}
}
return title
}
exports.clearConsole = async function clearConsoleWithTitle (checkUpdate) {
const title = await exports.generateTitle(checkUpdate)
clearConsole(title)
}