@@ -29,7 +29,15 @@ module.exports = function resolveVersion(version, activeVersion, v1 = false, for
29
29
}
30
30
31
31
return yarn ( [ 'info' , 'ghost' , 'versions' , '--json' ] ) . then ( ( result ) => {
32
- let comparator = ! force && activeVersion ? `>${ activeVersion } ` : MIN_RELEASE ;
32
+ let comparator ;
33
+
34
+ if ( ! force && activeVersion ) {
35
+ comparator = `>${ activeVersion } ` ;
36
+ } else if ( force && activeVersion ) {
37
+ comparator = `>=${ activeVersion } ` ;
38
+ } else {
39
+ comparator = MIN_RELEASE ;
40
+ }
33
41
34
42
if ( v1 ) {
35
43
comparator += ' <2.0.0' ;
@@ -55,23 +63,17 @@ module.exports = function resolveVersion(version, activeVersion, v1 = false, for
55
63
56
64
let versionToReturn = version || versions . pop ( ) ;
57
65
58
- if ( v1 && activeVersion && semver . satisfies ( activeVersion , '^2.0.0' ) ) {
59
- return Promise . reject ( new errors . CliError ( {
60
- message : 'You can\'t downgrade from v2 to v1 using these options.' ,
61
- help : 'Please run "ghost update --rollback".'
62
- } ) ) ;
63
- }
64
-
65
66
// CASE: you haven't passed `--v1` and you are not about to install a fresh blog
66
67
if ( ! v1 && activeVersion ) {
67
68
const majorVersionJump = semver . major ( activeVersion ) !== semver . major ( versionToReturn ) ;
68
69
69
- // CASE: use latest v1 release
70
- if ( majorVersionJump && force ) {
70
+ // CASE 1: you want to force update and you are not on the latest v1 version
71
+ // CASE 2: you don't use force and you are not on the latest v1 version
72
+ if ( majorVersionJump && force && versions . length > 1 ) {
71
73
while ( ! semver . satisfies ( versionToReturn , '^1.0.0' ) ) {
72
74
versionToReturn = versions . pop ( ) ;
73
75
}
74
- } else if ( majorVersionJump && versions . length ) {
76
+ } else if ( majorVersionJump && ! force && versions . length ) {
75
77
return Promise . reject ( new errors . CliError ( {
76
78
message : 'You are about to migrate to Ghost 2.0. Your blog is not on the latest Ghost 1.0 version.' ,
77
79
help : 'Please run "ghost update --v1".'
0 commit comments