@@ -4,6 +4,7 @@ const checkForBlueprintUpdates = require('./check-for-blueprint-updates');
44const inquirer = require ( 'inquirer' ) ;
55const loadSafeBlueprint = require ( './load-safe-blueprint' ) ;
66const { defaultTo } = require ( './constants' ) ;
7+ const semver = require ( 'semver' ) ;
78
89/**
910 * Format the string that is displayed when user is prompted for a blueprint
@@ -34,10 +35,10 @@ async function chooseBlueprint({ choicesByName, message }) {
3435 *
3536 * @param {string } cwd - Used in `checkForBlueprintUpdates` in order to generate url or path to it if on local disk
3637 * @param {object } emberCliUpdateJson - Use the `blueprints` property from this
37- * @param {boolean } reset - Optional
38- * @param {boolean } compare - Optional
39- * @param {boolean } codemods - Optional
40- * @param {string } to - Optional (could be undefined).
38+ * @param {boolean } [ reset]
39+ * @param {boolean } [ compare]
40+ * @param {boolean } [ codemods]
41+ * @param {string } [to] - Optional (could be undefined).
4142 * @returns {Promise<{blueprint: (*|{}), areAllUpToDate, to: string}> }
4243 */
4344async function chooseBlueprintUpdates ( {
@@ -50,28 +51,28 @@ async function chooseBlueprintUpdates({
5051} ) {
5152 let existingBlueprint ;
5253 let areAllUpToDate ;
53-
5454 let { blueprints } = emberCliUpdateJson ;
5555
5656 if ( reset || compare || codemods ) {
5757 let choicesByName = blueprints . reduce ( ( choices , blueprint ) => {
5858 let name = blueprint . packageName ;
59+
5960 choices [ name ] = {
6061 blueprint,
6162 choice : {
6263 name
6364 }
6465 } ;
66+
6567 return choices ;
6668 } , { } ) ;
6769
68- let message ;
70+ let message = 'Which blueprint would you like to run codemods for?' ;
71+
6972 if ( reset ) {
7073 message = 'Which blueprint would you like to reset?' ;
7174 } else if ( compare ) {
7275 message = 'Which blueprint would you like to compare?' ;
73- } else {
74- message = 'Which blueprint would you like to run codemods for?' ;
7576 }
7677
7778 existingBlueprint = (
@@ -83,30 +84,37 @@ async function chooseBlueprintUpdates({
8384 } else {
8485 let blueprintUpdates = await checkForBlueprintUpdates ( {
8586 cwd,
86- blueprints
87+ blueprints,
8788 } ) ;
8889
8990 areAllUpToDate = blueprintUpdates . every (
9091 blueprintUpdate => blueprintUpdate . isUpToDate
9192 ) ;
9293
93- if ( areAllUpToDate ) {
94+ if ( ! to && areAllUpToDate ) {
9495 // eslint-disable-next-line no-console
95- console . log ( `${ blueprintUpdates . map ( formatBlueprintLine ) . join ( `
96- ` ) }
97-
98- All blueprints are up-to-date!` ) ;
96+ console . log ( `${ blueprintUpdates . map ( formatBlueprintLine ) . join ( '\n' ) } \n\nAll blueprints are up-to-date!` ) ;
9997 } else {
98+ areAllUpToDate = false ;
99+
100+ for ( let update of blueprintUpdates ) {
101+ if ( update . blueprint . isBaseBlueprint && ! ! to && semver . gt ( to , update . latestVersion ) ) {
102+ update . isUpToDate = false ;
103+ update . latestVersion = to ;
104+ }
105+ }
106+
100107 let choicesByName = blueprintUpdates . reduce (
101108 ( choices , blueprintUpdate ) => {
102109 let name = formatBlueprintLine ( blueprintUpdate ) ;
110+
103111 choices [ name ] = {
104112 blueprintUpdate,
105113 choice : {
106114 name,
107- disabled : blueprintUpdate . isUpToDate
108115 }
109116 } ;
117+
110118 return choices ;
111119 } ,
112120 { }
0 commit comments