Skip to content

Commit e6490b7

Browse files
author
Kelly Selden
committed
use loadSafeDefaultBlueprint in more places
1 parent 3602b27 commit e6490b7

9 files changed

Lines changed: 50 additions & 75 deletions

src/bootstrap.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ const loadSafeDefaultBlueprint = require('./load-safe-default-blueprint');
1212
const stageBlueprintFile = require('./stage-blueprint-file');
1313

1414
module.exports = async function bootstrap() {
15-
let defaultBlueprint = {
16-
name: 'ember-cli'
17-
};
15+
let defaultBlueprint = loadSafeDefaultBlueprint();
1816

1917
let cwd = process.cwd();
2018

src/get-start-and-end-commands.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const fs = require('fs-extra');
55
const run = require('./run');
66
const utils = require('./utils');
77
const loadSafeBlueprint = require('./load-safe-blueprint');
8+
const loadSafeDefaultBlueprint = require('./load-safe-default-blueprint');
89
const isDefaultBlueprint = require('./is-default-blueprint');
910

1011
const nodeModulesIgnore = `
@@ -197,9 +198,7 @@ module.exports.installAddonBlueprint = async function installAddonBlueprint({
197198
projectName,
198199
blueprintPath
199200
}) {
200-
let defaultBlueprint = {
201-
name: 'ember-cli'
202-
};
201+
let defaultBlueprint = loadSafeDefaultBlueprint();
203202

204203
let args = getArgs(projectName, loadSafeBlueprint(defaultBlueprint));
205204

src/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ module.exports = async function emberCliUpdate({
4141
createCustomDiff,
4242
wasRunAsExecutable
4343
}) {
44-
let defaultBlueprint = {
45-
name: 'ember-cli'
46-
};
44+
let defaultBlueprint = loadSafeDefaultBlueprint();
4745

4846
let cwd = process.cwd();
4947

src/init.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ module.exports = async function init({
2020
blueprintOptions,
2121
wasRunAsExecutable
2222
}) {
23-
let defaultBlueprint = {
24-
name: 'ember-cli'
25-
};
23+
let defaultBlueprint = loadSafeDefaultBlueprint();
2624

2725
let cwd = process.cwd();
2826

src/install.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ const downloadBlueprint = require('./download-blueprint');
66
const saveBlueprint = require('./save-blueprint');
77
const loadBlueprintFile = require('./load-blueprint-file');
88
const saveDefaultBlueprint = require('./save-default-blueprint');
9+
const loadSafeDefaultBlueprint = require('./load-safe-default-blueprint');
910

1011
const toDefault = require('./args').to.default;
1112

1213
module.exports = async function install({
1314
addon
1415
}) {
15-
let defaultBlueprint = {
16-
name: 'ember-cli'
17-
};
16+
let defaultBlueprint = loadSafeDefaultBlueprint();
1817

1918
let cwd = process.cwd();
2019

src/load-safe-default-blueprint.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
function loadSafeDefaultBlueprint(projectOptions, version) {
3+
function loadSafeDefaultBlueprint(projectOptions = [], version) {
44
let type = 'app';
55
if (projectOptions.includes('addon')) {
66
type = 'addon';
@@ -11,6 +11,7 @@ function loadSafeDefaultBlueprint(projectOptions, version) {
1111
options.push('--yarn');
1212
}
1313
if (!projectOptions.includes('welcome') || projectOptions.includes('addon')) {
14+
// Why do addons always have --no-welcome?
1415
options.push('--no-welcome');
1516
}
1617

test/integration/load-safe-default-blueprint-test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ describe(_loadSafeDefaultBlueprint, function() {
1717
return _loadSafeDefaultBlueprint(projectOptions, version);
1818
}
1919

20+
it('returns blank blueprint if no params', async function() {
21+
let blueprint = _loadSafeDefaultBlueprint();
22+
23+
expect(blueprint).to.deep.equal({
24+
name: 'ember-cli',
25+
type: 'app',
26+
version: undefined,
27+
options: [
28+
'--no-welcome'
29+
]
30+
});
31+
});
32+
2033
describe('app', function() {
2134
beforeEach(function() {
2235
projectOptions.push('app');

test/unit/get-start-and-end-commands-test.js

Lines changed: 26 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const path = require('path');
77
const _getStartAndEndCommands = require('../../src/get-start-and-end-commands');
88
const utils = require('../../src/utils');
99
const loadSafeBlueprint = require('../../src/load-safe-blueprint');
10+
const loadSafeDefaultBlueprint = require('../../src/load-safe-default-blueprint');
1011

1112
const {
1213
getArgs
@@ -23,6 +24,8 @@ const commandName = 'ember';
2324
const blueprint = 'test-blueprint';
2425
const blueprintPath = '/path/to/blueprint';
2526
const projectPath = path.normalize(`${cwd}/${projectName}`);
27+
const defaultStartBlueprint = loadSafeDefaultBlueprint([], startVersion);
28+
const defaultEndBlueprint = loadSafeDefaultBlueprint([], endVersion);
2629

2730
describe(_getStartAndEndCommands, function() {
2831
let sandbox;
@@ -51,14 +54,8 @@ describe(_getStartAndEndCommands, function() {
5154
function getStartAndEndCommands(options) {
5255
return _getStartAndEndCommands(Object.assign({
5356
packageJson: { name: projectName },
54-
startBlueprint: {
55-
name: 'ember-cli',
56-
version: startVersion
57-
},
58-
endBlueprint: {
59-
name: 'ember-cli',
60-
version: endVersion
61-
}
57+
startBlueprint: defaultStartBlueprint,
58+
endBlueprint: defaultEndBlueprint
6259
}, options));
6360
}
6461

@@ -76,17 +73,11 @@ describe(_getStartAndEndCommands, function() {
7673
packageName,
7774
commandName,
7875
startOptions: {
79-
blueprint: {
80-
name: 'ember-cli',
81-
version: startVersion
82-
},
76+
blueprint: defaultStartBlueprint,
8377
packageRange: startVersion
8478
},
8579
endOptions: {
86-
blueprint: {
87-
name: 'ember-cli',
88-
version: endVersion
89-
},
80+
blueprint: defaultEndBlueprint,
9081
packageRange: endVersion
9182
}
9283
});
@@ -99,9 +90,7 @@ describe(_getStartAndEndCommands, function() {
9990
packageRoot,
10091
options: {
10192
projectName,
102-
blueprint: loadSafeBlueprint({
103-
name: 'ember-cli'
104-
})
93+
blueprint: loadSafeDefaultBlueprint(['welcome'])
10594
}
10695
});
10796

@@ -131,10 +120,7 @@ describe(_getStartAndEndCommands, function() {
131120
let createProject = createProjectFromRemote({
132121
options: {
133122
projectName,
134-
blueprint: loadSafeBlueprint({
135-
name: 'ember-cli',
136-
version: packageVersion
137-
})
123+
blueprint: loadSafeDefaultBlueprint(['welcome'], packageVersion)
138124
}
139125
});
140126

@@ -298,10 +284,7 @@ describe(_getStartAndEndCommands, function() {
298284
packageRange: null
299285
},
300286
endOptions: {
301-
blueprint: {
302-
name: 'ember-cli',
303-
version: endVersion
304-
},
287+
blueprint: defaultEndBlueprint,
305288
packageRange: endVersion
306289
}
307290
});
@@ -363,11 +346,10 @@ describe(_getStartAndEndCommands, function() {
363346
let createProject = createProjectFromRemote({
364347
options: {
365348
projectName,
366-
blueprint: loadSafeBlueprint({
367-
name: 'ember-cli',
368-
version: packageVersion,
349+
blueprint: {
350+
...loadSafeDefaultBlueprint(['welcome'], packageVersion),
369351
path: blueprintPath
370-
})
352+
}
371353
}
372354
});
373355

@@ -418,12 +400,7 @@ describe(_getStartAndEndCommands, function() {
418400
});
419401

420402
describe('options', function() {
421-
async function processBlueprint(blueprint) {
422-
let defaultBlueprint = {
423-
name: 'ember-cli',
424-
...blueprint
425-
};
426-
403+
async function processBlueprint(defaultBlueprint = loadSafeDefaultBlueprint()) {
427404
let options = getStartAndEndCommands({
428405
startBlueprint: defaultBlueprint,
429406
endBlueprint: defaultBlueprint
@@ -456,7 +433,7 @@ describe(_getStartAndEndCommands, function() {
456433
});
457434

458435
it('can create an addon', async function() {
459-
let args = await processBlueprint({ type: 'addon' });
436+
let args = await processBlueprint(loadSafeDefaultBlueprint(['addon']));
460437

461438
let i = args.indexOf('-b');
462439

@@ -466,13 +443,13 @@ describe(_getStartAndEndCommands, function() {
466443
});
467444

468445
it('can create an app with the --no-welcome option', async function() {
469-
let args = await processBlueprint({ options: ['--no-welcome'] });
446+
let args = await processBlueprint();
470447

471448
expect(args).to.include('--no-welcome');
472449
});
473450

474451
it('can create an app without the --no-welcome option', async function() {
475-
let args = await processBlueprint();
452+
let args = await processBlueprint(loadSafeDefaultBlueprint(['welcome']));
476453

477454
expect(args).to.not.include('--no-welcome');
478455
});
@@ -484,7 +461,7 @@ describe(_getStartAndEndCommands, function() {
484461
});
485462

486463
it('can create an app with the yarn option', async function() {
487-
let args = await processBlueprint({ options: ['--yarn'] });
464+
let args = await processBlueprint(loadSafeDefaultBlueprint(['yarn']));
488465

489466
expect(args).to.include('--yarn');
490467
});
@@ -494,11 +471,7 @@ describe(_getStartAndEndCommands, function() {
494471
let projectName = 'my-project';
495472

496473
it('works for default app', function() {
497-
let blueprint = {
498-
name: 'ember-cli',
499-
type: 'app',
500-
options: []
501-
};
474+
let blueprint = loadSafeDefaultBlueprint(['welcome']);
502475

503476
let args = getArgs(projectName, blueprint);
504477

@@ -514,11 +487,7 @@ describe(_getStartAndEndCommands, function() {
514487
});
515488

516489
it('works for default addon', function() {
517-
let blueprint = {
518-
name: 'ember-cli',
519-
type: 'addon',
520-
options: []
521-
};
490+
let blueprint = loadSafeDefaultBlueprint(['addon']);
522491

523492
let args = getArgs(projectName, blueprint);
524493

@@ -529,16 +498,16 @@ describe(_getStartAndEndCommands, function() {
529498
'-sb',
530499
'-sg',
531500
'-b',
532-
'addon'
501+
'addon',
502+
'--no-welcome'
533503
]);
534504
});
535505

536506
it('works for custom app', function() {
537-
let blueprint = {
507+
let blueprint = loadSafeBlueprint({
538508
name: 'my-blueprint',
539-
path: '/path/to/my-blueprint',
540-
options: []
541-
};
509+
path: '/path/to/my-blueprint'
510+
});
542511

543512
let args = getArgs(projectName, blueprint);
544513

@@ -555,8 +524,7 @@ describe(_getStartAndEndCommands, function() {
555524

556525
it('handles options', function() {
557526
let blueprint = {
558-
name: 'ember-cli',
559-
type: 'app',
527+
...loadSafeDefaultBlueprint(['welcome']),
560528
options: [
561529
'--my-option-1',
562530
'--my-option-2'

test/unit/save-default-blueprint-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const path = require('path');
66
const sinon = require('sinon');
77
const utils = require('../../src/utils');
88
const saveDefaultBlueprint = require('../../src/save-default-blueprint');
9+
const loadSafeDefaultBlueprint = require('../../src/load-safe-default-blueprint');
910

1011
describe(saveDefaultBlueprint, function() {
1112
let sandbox;
@@ -44,7 +45,7 @@ describe(saveDefaultBlueprint, function() {
4445

4546
await saveDefaultBlueprint({
4647
cwd: '/test/path',
47-
blueprint: { name: 'ember-cli' }
48+
blueprint: loadSafeDefaultBlueprint()
4849
});
4950

5051
expect(require).to.be.calledOnce;

0 commit comments

Comments
 (0)