@@ -23,71 +23,6 @@ const resolvePackage = require('./resolve-package');
2323const { defaultTo } = require ( './constants' ) ;
2424const normalizeBlueprintArgs = require ( './normalize-blueprint-args' ) ;
2525
26- /**
27- * Build an object of configurations based on contents of the package containing the blueprint specified
28- * by the user
29- */
30- async function setupParamPassedBlueprint (
31- selectedPackageName ,
32- selectedBlueprintName ,
33- emberCliUpdateJson ,
34- fromVersion ,
35- cwd
36- ) {
37- let blueprintArgs = normalizeBlueprintArgs ( {
38- selectedPackageName,
39- blueprintName : selectedBlueprintName
40- } ) ;
41- let parsedPackage = await parseBlueprintPackage ( {
42- cwd,
43- packageName : blueprintArgs . packageName
44- } ) ;
45- let blueprint ;
46- let packageUrl = parsedPackage . url ;
47- let packageName = parsedPackage . name ;
48-
49- if ( ! packageName ) {
50- let downloadedPackage = await downloadPackage ( null , packageUrl , defaultTo ) ;
51- packageName = downloadedPackage . name ;
52- }
53-
54- let blueprintName ;
55- if ( blueprintArgs . blueprintName !== blueprintArgs . packageName ) {
56- blueprintName = blueprintArgs . blueprintName ;
57- } else {
58- blueprintName = packageName ;
59- }
60-
61- let existingBlueprint = findBlueprint ( emberCliUpdateJson , packageName , blueprintName ) ;
62-
63- if ( existingBlueprint ) {
64- blueprint = existingBlueprint ;
65- } else {
66- blueprint = loadSafeBlueprint ( {
67- packageName,
68- name : blueprintName ,
69- location : parsedPackage . location
70- } ) ;
71-
72- if ( isDefaultBlueprint ( blueprint ) ) {
73- blueprint = await loadDefaultBlueprintFromDisk ( {
74- cwd,
75- version : fromVersion
76- } ) ;
77- }
78- }
79-
80- if ( fromVersion ) {
81- blueprint . version = fromVersion ;
82- }
83-
84- if ( ! blueprint . version ) {
85- throw new Error ( 'A custom blueprint cannot detect --from. You must supply it.' ) ;
86- }
87-
88- return blueprint ;
89- }
90-
9126/**
9227 * If `version` attribute exists in the `blueprint` object and URL is empty, skip. Otherwise resolve the details of
9328 * the blueprint
@@ -120,24 +55,14 @@ async function _resolvePackage(blueprint, url, range) {
12055 }
12156}
12257
123- /**
124- *
125- * @param cwd
126- * @param packageName - User passed package name
127- * @param _blueprint - User passed blueprint name
128- * @param from
129- * @param to
130- * @param resolveConflicts
131- * @returns {Promise<{promise: Promise<*>, resolveConflictsProcess}|{promise: Promise<void>}> }
132- */
13358module . exports = async function emberCliUpdate ( {
134- cwd = process . cwd ( ) ,
135- packageName,
136- blueprint : _blueprint ,
137- from,
138- to,
139- resolveConflicts
140- } = { } ) {
59+ cwd = process . cwd ( ) ,
60+ packageName,
61+ blueprint : _blueprint ,
62+ from,
63+ to,
64+ resolveConflicts
65+ } = { } ) {
14166 // A custom config location in package.json may be reset/init away,
14267 // so we can no longer look it up on the fly after the run.
14368 // We must rely on a lookup before the run.
@@ -151,13 +76,54 @@ module.exports = async function emberCliUpdate({
15176 let packageUrl ;
15277
15378 if ( _blueprint ) {
154- blueprint = await setupParamPassedBlueprint (
79+ let blueprintArgs = normalizeBlueprintArgs ( {
15580 packageName,
156- _blueprint ,
157- emberCliUpdateJson ,
158- from ,
159- cwd
160- ) ;
81+ blueprintName : _blueprint
82+ } ) ;
83+
84+ let parsedPackage = await parseBlueprintPackage ( {
85+ cwd,
86+ packageName : blueprintArgs . packageName
87+ } ) ;
88+ packageUrl = parsedPackage . url ;
89+
90+ packageName = parsedPackage . name ;
91+ if ( ! packageName ) {
92+ let downloadedPackage = await downloadPackage ( null , packageUrl , defaultTo ) ;
93+ packageName = downloadedPackage . name ;
94+ }
95+ let blueprintName ;
96+ if ( blueprintArgs . blueprintName !== blueprintArgs . packageName ) {
97+ blueprintName = blueprintArgs . blueprintName ;
98+ } else {
99+ blueprintName = packageName ;
100+ }
101+
102+ let existingBlueprint = findBlueprint ( emberCliUpdateJson , packageName , blueprintName ) ;
103+ if ( existingBlueprint ) {
104+ blueprint = existingBlueprint ;
105+ } else {
106+ blueprint = loadSafeBlueprint ( {
107+ packageName,
108+ name : blueprintName ,
109+ location : parsedPackage . location
110+ } ) ;
111+
112+ if ( isDefaultBlueprint ( blueprint ) ) {
113+ blueprint = await loadDefaultBlueprintFromDisk ( {
114+ cwd,
115+ version : from
116+ } ) ;
117+ }
118+ }
119+
120+ if ( from ) {
121+ blueprint . version = from ;
122+ }
123+
124+ if ( ! blueprint . version ) {
125+ throw new Error ( 'A custom blueprint cannot detect --from. You must supply it.' ) ;
126+ }
161127 } else if ( blueprints . length ) {
162128 let {
163129 areAllUpToDate,
@@ -225,9 +191,9 @@ module.exports = async function emberCliUpdate({
225191 cwd,
226192 projectOptions : ( { packageJson } ) => getProjectOptions ( packageJson , blueprint ) ,
227193 mergeOptions : async function mergeOptions ( {
228- packageJson,
229- projectOptions
230- } ) {
194+ packageJson,
195+ projectOptions
196+ } ) {
231197 let startBlueprint = { ...blueprint } ;
232198 endBlueprint = { ...blueprint } ;
233199 delete endBlueprint . version ;
0 commit comments