diff --git a/lib/commands/update.js b/lib/commands/update.js index fe9c60560..0c4785d68 100644 --- a/lib/commands/update.js +++ b/lib/commands/update.js @@ -76,15 +76,7 @@ class UpdateCommand extends Command { }, { title: 'Updating to a major version', task: majorUpdate, - // CASE: Skip if you are already on ^2 or you update from v1 to v1. - enabled: () => { - if (semver.major(instance.version) === 2 || - semver.major(context.version) === 1) { - return false; - } - - return true; - } + enabled: () => semver.major(context.version) > semver.major(instance.version) }, { title: 'Stopping Ghost', enabled: () => isRunning, @@ -103,14 +95,7 @@ class UpdateCommand extends Command { // CASE: We have moved the execution of knex-migrator into Ghost 2.0.0. // If you are already on v2 or you update from v1 to v2, then skip the task. // We compare the major versions, otherwise pre-releases won't match. - enabled: () => { - if (semver.major(instance.version) === 2 || - semver.major(context.version) === 2) { - return false; - } - - return true; - } + enabled: () => semver.major(context.version) < 2 }, { title: 'Restarting Ghost', enabled: () => argv.restart, @@ -182,17 +167,12 @@ class UpdateCommand extends Command { const semver = require('semver'); return fs.readdir(path.join(process.cwd(), 'versions')).then((versions) => { - versions = versions.filter(semver.valid); + versions = versions.filter(semver.valid).sort(semver.compare); if (versions.length <= 5) { task.skip(); return; } - // eslint-disable-next-line arrow-body-style - versions.sort((a, b) => { - return semver.lt(a, b) ? -1 : 1; - }); - const promises = versions.slice(0, -5) .map(version => fs.remove(path.join(process.cwd(), 'versions', version))); diff --git a/lib/process-manager.js b/lib/process-manager.js index 9c2fbafc6..1c80c7c7e 100644 --- a/lib/process-manager.js +++ b/lib/process-manager.js @@ -69,7 +69,7 @@ class ProcessManager { stopOnError: true, port: this.instance.config.get('server.port'), host: this.instance.config.get('server.host', 'localhost'), - useNetServer: semver.major(this.instance.version) === 2 + useNetServer: semver.major(this.instance.version) >= 2 }, options || {}); try { diff --git a/lib/tasks/migrator.js b/lib/tasks/migrator.js index d232eec7e..7682f6672 100644 --- a/lib/tasks/migrator.js +++ b/lib/tasks/migrator.js @@ -91,7 +91,7 @@ module.exports.rollback = function runRollback(context) { // Ghost 2.0.0 uses the new knex-migrator version. We have to ensure you can still use CLI 1.9 with an older blog, because // we haven't restricted a CLI version range in Ghost (we only used cli: > X.X.X) - if (semver.major(version) === 2) { + if (semver.major(version) >= 2) { args = ['--force', '--v', previousVersion, '--mgpath', currentDir]; } else { args = ['--force', '--mgpath', currentDir];