@@ -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 = (
@@ -90,22 +91,35 @@ async function chooseBlueprintUpdates({
9091 blueprintUpdate => blueprintUpdate . isUpToDate
9192 ) ;
9293
93- if ( areAllUpToDate ) {
94- console . log ( `${ blueprintUpdates . map ( formatBlueprintLine ) . join ( `
95- ` ) }
96-
97- All blueprints are up-to-date!` ) ;
94+ if ( ! to && areAllUpToDate ) {
95+ console . log (
96+ `${ blueprintUpdates . map ( formatBlueprintLine ) . join ( '\n' ) } \n\nAll blueprints are up-to-date!`
97+ ) ;
9898 } else {
99+ areAllUpToDate = false ;
100+
101+ for ( let update of blueprintUpdates ) {
102+ if (
103+ update . blueprint . isBaseBlueprint &&
104+ ! ! to &&
105+ semver . gt ( to , update . latestVersion )
106+ ) {
107+ update . isUpToDate = false ;
108+ update . latestVersion = to ;
109+ }
110+ }
111+
99112 let choicesByName = blueprintUpdates . reduce (
100113 ( choices , blueprintUpdate ) => {
101114 let name = formatBlueprintLine ( blueprintUpdate ) ;
115+
102116 choices [ name ] = {
103117 blueprintUpdate,
104118 choice : {
105- name,
106- disabled : blueprintUpdate . isUpToDate
119+ name
107120 }
108121 } ;
122+
109123 return choices ;
110124 } ,
111125 { }
0 commit comments