@@ -23,12 +23,34 @@ const findBlueprint = require('./find-blueprint');
2323const getBaseBlueprint = require ( './get-base-blueprint' ) ;
2424const chooseBlueprintUpdates = require ( './choose-blueprint-updates' ) ;
2525const getBlueprintFilePath = require ( './get-blueprint-file-path' ) ;
26+ const resolvePackage = require ( './resolve-package' ) ;
2627
2728const {
2829 'to' : { default : toDefault } ,
2930 'codemods-url' : { default : codemodsUrlDefault }
3031} = require ( './args' ) ;
3132
33+ async function _resolvePackage ( blueprint , url , range ) {
34+ if ( blueprint . version && ! url ) {
35+ return ;
36+ }
37+
38+ let {
39+ version,
40+ path
41+ } = await resolvePackage ( {
42+ name : blueprint . packageName ,
43+ url,
44+ range
45+ } ) ;
46+
47+ blueprint . version = version ;
48+
49+ if ( path ) {
50+ blueprint . path = path ;
51+ }
52+ }
53+
3254module . exports = async function emberCliUpdate ( {
3355 blueprint : _blueprint ,
3456 from,
@@ -173,29 +195,13 @@ module.exports = async function emberCliUpdate({
173195 }
174196
175197 endBlueprint = { ...blueprint } ;
198+ delete endBlueprint . version ;
176199
177200 if ( isCustomBlueprint ) {
178- if ( packageUrl ) {
179- let [
180- startDownloadedPackage ,
181- endDownloadedPackage
182- ] = await Promise . all ( [
183- startBlueprint ? downloadPackage ( startBlueprint . packageName , packageUrl , startBlueprint . version ) : null ,
184- downloadPackage ( endBlueprint . packageName , packageUrl , to )
185- ] ) ;
186-
187- if ( startBlueprint ) {
188- startBlueprint . path = startDownloadedPackage . path ;
189- startBlueprint . version = startDownloadedPackage . version ;
190- }
191-
192- endBlueprint . path = endDownloadedPackage . path ;
193- endBlueprint . version = endDownloadedPackage . version ;
194- } else {
195- let versions = await getVersions ( endBlueprint . packageName ) ;
196- let getTagVersion = _getTagVersion ( versions , endBlueprint . packageName ) ;
197- endBlueprint . version = await getTagVersion ( to ) ;
198- }
201+ await Promise . all ( [
202+ startBlueprint ? _resolvePackage ( startBlueprint , packageUrl , startBlueprint . version ) : null ,
203+ _resolvePackage ( endBlueprint , packageUrl , to )
204+ ] ) ;
199205 } else {
200206 let packageName = getPackageName ( projectOptions ) ;
201207 let packageVersion = getPackageVersion ( packageJson , packageName ) ;
0 commit comments