@@ -4,15 +4,14 @@ const boilerplateUpdate = require('boilerplate-update');
44const getStartAndEndCommands = require ( './get-start-and-end-commands' ) ;
55const parseBlueprintPackage = require ( './parse-blueprint-package' ) ;
66const saveBlueprint = require ( './save-blueprint' ) ;
7- const loadDefaultBlueprintFromDisk = require ( './load-default-blueprint-from-disk' ) ;
8- const loadSafeBlueprint = require ( './load-safe-blueprint' ) ;
97const loadSafeBlueprintFile = require ( './load-safe-blueprint-file' ) ;
108const { getBlueprintRelativeFilePath } = require ( './get-blueprint-file-path' ) ;
119const findBlueprint = require ( './find-blueprint' ) ;
1210const getBaseBlueprint = require ( './get-base-blueprint' ) ;
1311const getBlueprintFilePath = require ( './get-blueprint-file-path' ) ;
1412const resolvePackage = require ( './resolve-package' ) ;
1513const { defaultTo } = require ( './constants' ) ;
14+ const chooseBlueprintUpdates = require ( './choose-blueprint-updates' ) ;
1615
1716module . exports = async function reset ( {
1817 blueprint : _blueprint ,
@@ -25,67 +24,73 @@ module.exports = async function reset({
2524 // We must rely on a lookup before the run.
2625 let emberCliUpdateJsonPath = await getBlueprintFilePath ( cwd ) ;
2726
28- let packageName ;
29- let name ;
30- let location ;
31- let url ;
27+ let emberCliUpdateJson = await loadSafeBlueprintFile ( emberCliUpdateJsonPath ) ;
28+
29+ let { blueprints } = emberCliUpdateJson ;
30+
31+ if ( ! blueprints . length ) {
32+ throw new Error ( 'No blueprints found.' ) ;
33+ }
34+
35+ let blueprint ;
36+ let packageInfo ;
37+
3238 if ( _blueprint ) {
3339 let parsedPackage = await parseBlueprintPackage ( {
3440 cwd,
3541 blueprint : _blueprint
3642 } ) ;
37- packageName = parsedPackage . name ;
38- name = parsedPackage . name ;
39- location = parsedPackage . location ;
40- url = parsedPackage . url ;
41- } else {
42- let defaultBlueprint = await loadDefaultBlueprintFromDisk ( cwd ) ;
43- packageName = defaultBlueprint . packageName ;
44- name = defaultBlueprint . name ;
45- }
46-
47- let packageInfo = await resolvePackage ( {
48- name : packageName ,
49- url,
50- range : to
51- } ) ;
43+ let url = parsedPackage . url ;
5244
53- packageName = packageInfo . name ;
54- if ( ! name ) {
55- name = packageInfo . name ;
56- }
57- let version = packageInfo . version ;
58- let path = packageInfo . path ;
45+ packageInfo = await resolvePackage ( {
46+ name : parsedPackage . name ,
47+ url,
48+ range : to
49+ } ) ;
5950
60- let emberCliUpdateJson = await loadSafeBlueprintFile ( emberCliUpdateJsonPath ) ;
51+ let packageName = packageInfo . name ;
52+ let name = packageInfo . name ;
6153
62- let blueprint ;
54+ let existingBlueprint = findBlueprint ( emberCliUpdateJson , packageName , name ) ;
55+ if ( ! existingBlueprint ) {
56+ throw new Error ( 'Blueprint not found.' ) ;
57+ }
6358
64- let existingBlueprint = findBlueprint ( emberCliUpdateJson , packageName , name ) ;
65- if ( existingBlueprint ) {
6659 blueprint = existingBlueprint ;
6760 } else {
68- blueprint = {
69- packageName,
70- name,
71- location
72- } ;
73- }
61+ let {
62+ blueprint : _blueprint
63+ } = await chooseBlueprintUpdates ( {
64+ cwd,
65+ emberCliUpdateJson,
66+ reset : true
67+ } ) ;
68+
69+ blueprint = _blueprint ;
7470
75- blueprint = loadSafeBlueprint ( blueprint ) ;
71+ let parsedPackage = await parseBlueprintPackage ( {
72+ cwd,
73+ blueprint : blueprint . location || blueprint . packageName
74+ } ) ;
75+ let url = parsedPackage . url ;
7676
77- blueprint . version = version ;
78- blueprint . path = path ;
77+ packageInfo = await resolvePackage ( {
78+ name : blueprint . packageName ,
79+ url,
80+ range : to
81+ } ) ;
82+ }
7983
80- let baseBlueprint = await getBaseBlueprint ( {
81- cwd,
82- blueprints : emberCliUpdateJson . blueprints ,
83- blueprint
84- } ) ;
84+ blueprint . version = packageInfo . version ;
85+ blueprint . path = packageInfo . path ;
8586
86- if ( ! baseBlueprint ) {
87- // for non-existing default blueprints
88- blueprint . isBaseBlueprint = true ;
87+ let baseBlueprint ;
88+ if ( ! blueprint . isBaseBlueprint ) {
89+ baseBlueprint = await getBaseBlueprint ( {
90+ cwd,
91+ blueprints,
92+ blueprint
93+ } ) ;
8994 }
9095
9196 let {
0 commit comments