Skip to content

Commit a3632f2

Browse files
author
Kelly Selden
committed
remove base default insertion
1 parent 5a20d9a commit a3632f2

10 files changed

Lines changed: 173 additions & 120 deletions

File tree

bin/commands/init.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ module.exports.builder = {
1414
reset: args['reset']
1515
};
1616

17+
module.exports.blueprintOptionsDefault = [];
18+
1719
module.exports.handler = async function handler(argv) {
1820
let blueprint = argv['blueprint'];
1921
let to = argv['to'];
2022
let resolveConflicts = argv['resolve-conflicts'];
2123
let reset = argv['reset'];
22-
let blueprintOptions = argv['--'] || [];
24+
let blueprintOptions = argv['--'] || module.exports.blueprintOptionsDefault;
2325

2426
try {
2527
let message = await init({

src/get-base-blueprint.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const parseBlueprintPackage = require('./parse-blueprint-package');
44
const downloadPackage = require('./download-package');
5-
const loadDefaultBlueprintFromDisk = require('./load-default-blueprint-from-disk');
65
const loadSafeBlueprint = require('./load-safe-blueprint');
76
const isDefaultBlueprint = require('./is-default-blueprint');
87

@@ -12,7 +11,6 @@ async function getBaseBlueprint({
1211
blueprint
1312
}) {
1413
let baseBlueprint;
15-
let defaultBlueprint;
1614

1715
let isCustomBlueprint = !isDefaultBlueprint(blueprint);
1816

@@ -35,16 +33,10 @@ async function getBaseBlueprint({
3533
baseBlueprint.path = downloadedPackage.path;
3634
}
3735
}
38-
} else {
39-
defaultBlueprint = await loadDefaultBlueprintFromDisk(cwd);
40-
baseBlueprint = defaultBlueprint;
4136
}
4237
}
4338

44-
return {
45-
baseBlueprint,
46-
defaultBlueprint
47-
};
39+
return baseBlueprint;
4840
}
4941

5042
module.exports = getBaseBlueprint;

src/index.js

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const boilerplateUpdate = require('boilerplate-update');
1111
const getStartAndEndCommands = require('./get-start-and-end-commands');
1212
const parseBlueprintPackage = require('./parse-blueprint-package');
1313
const downloadPackage = require('./download-package');
14-
const loadBlueprintFile = require('./load-blueprint-file');
1514
const loadSafeBlueprintFile = require('./load-safe-blueprint-file');
1615
const saveBlueprint = require('./save-blueprint');
1716
const loadDefaultBlueprint = require('./load-default-blueprint');
@@ -158,10 +157,7 @@ module.exports = async function emberCliUpdate({
158157
createCustomDiff = true;
159158
}
160159

161-
let {
162-
baseBlueprint,
163-
defaultBlueprint
164-
} = await getBaseBlueprint({
160+
let baseBlueprint = await getBaseBlueprint({
165161
cwd,
166162
emberCliUpdateJson,
167163
blueprint
@@ -258,32 +254,7 @@ module.exports = async function emberCliUpdate({
258254
wasRunAsExecutable
259255
})).promise;
260256

261-
if (_blueprint) {
262-
let emberCliUpdateJson = await loadBlueprintFile(emberCliUpdateJsonPath);
263-
264-
// If you don't have a state file, save the default blueprint,
265-
// even if you are currently working on a custom blueprint.
266-
if (!emberCliUpdateJson || !isCustomBlueprint) {
267-
await saveBlueprint({
268-
emberCliUpdateJsonPath,
269-
blueprint: defaultBlueprint
270-
});
271-
}
272-
273-
if (isCustomBlueprint) {
274-
await saveBlueprint({
275-
emberCliUpdateJsonPath,
276-
blueprint: endBlueprint
277-
});
278-
}
279-
280-
if (!reset) {
281-
await stageBlueprintFile({
282-
cwd,
283-
emberCliUpdateJsonPath
284-
});
285-
}
286-
} else if (isPersistedBlueprint) {
257+
if (_blueprint || isPersistedBlueprint) {
287258
await saveBlueprint({
288259
emberCliUpdateJsonPath,
289260
blueprint: endBlueprint

src/init.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,24 @@ const loadSafeBlueprint = require('./load-safe-blueprint');
99
const loadSafeBlueprintFile = require('./load-safe-blueprint-file');
1010
const stageBlueprintFile = require('./stage-blueprint-file');
1111
const { getBlueprintRelativeFilePath } = require('./get-blueprint-file-path');
12-
const loadBlueprintFile = require('./load-blueprint-file');
13-
const bootstrap = require('./bootstrap');
1412
const findBlueprint = require('./find-blueprint');
1513
const getBaseBlueprint = require('./get-base-blueprint');
1614
const getBlueprintFilePath = require('./get-blueprint-file-path');
1715
const resolvePackage = require('./resolve-package');
1816

17+
const {
18+
'to': { default: toDefault }
19+
} = require('./args');
20+
const {
21+
blueprintOptionsDefault
22+
} = require('../bin/commands/init');
23+
1924
module.exports = async function init({
2025
blueprint: _blueprint,
21-
to,
26+
to = toDefault,
2227
resolveConflicts,
2328
reset,
24-
blueprintOptions,
29+
blueprintOptions = blueprintOptionsDefault,
2530
wasRunAsExecutable
2631
}) {
2732
let cwd = process.cwd();
@@ -84,9 +89,7 @@ module.exports = async function init({
8489
blueprint.version = version;
8590
blueprint.path = path;
8691

87-
let {
88-
baseBlueprint
89-
} = await getBaseBlueprint({
92+
let baseBlueprint = await getBaseBlueprint({
9093
cwd,
9194
emberCliUpdateJson,
9295
blueprint
@@ -117,10 +120,6 @@ module.exports = async function init({
117120
wasRunAsExecutable
118121
})).promise;
119122

120-
if (!await loadBlueprintFile(emberCliUpdateJsonPath)) {
121-
await bootstrap();
122-
}
123-
124123
await saveBlueprint({
125124
emberCliUpdateJsonPath,
126125
blueprint

src/save.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const parseBlueprintPackage = require('./parse-blueprint-package');
44
const loadSafeBlueprint = require('./load-safe-blueprint');
55
const saveBlueprint = require('./save-blueprint');
66
const loadBlueprintFile = require('./load-blueprint-file');
7-
const bootstrap = require('./bootstrap');
87
const getBlueprintFilePath = require('./get-blueprint-file-path');
98
const resolvePackage = require('./resolve-package');
109

@@ -47,7 +46,7 @@ module.exports = async function save({
4746
});
4847

4948
if (!await loadBlueprintFile(emberCliUpdateJsonPath)) {
50-
await bootstrap();
49+
blueprint.isBaseBlueprint = true;
5150
}
5251

5352
await saveBlueprint({

test/acceptance/ember-cli-update-test.js

Lines changed: 69 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const { expect } = require('../helpers/chai');
77
const {
88
buildTmp,
99
processBin,
10-
fixtureCompare: _fixtureCompare
10+
fixtureCompare: _fixtureCompare,
11+
commit
1112
} = require('git-fixtures');
1213
const {
1314
assertNormalUpdate,
@@ -550,27 +551,48 @@ describe(function() {
550551
});
551552

552553
it('can save an old blueprint\'s state', async function() {
553-
let {
554-
location,
555-
version: from
556-
} = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/local/my-app/config/ember-cli-update.json')).blueprints[1];
554+
let [
555+
{
556+
packageName,
557+
version: base
558+
},
559+
{
560+
location,
561+
version: partial,
562+
options
563+
}
564+
] = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/local-app/local/my-app/config/ember-cli-update.json')).blueprints;
557565

558-
let {
559-
status
560-
} = await (await merge({
566+
let commitMessage = 'my-app';
567+
568+
await (await merge({
561569
fixturesPath: 'test/fixtures/blueprint/app/local-app/init',
562-
commitMessage: 'my-app',
570+
commitMessage,
563571
save: true,
564-
blueprint: location,
565-
blueprintOptions: ['--supplied-option=foo'],
566-
from,
567-
async beforeMerge() {
568-
await initBlueprint({
569-
fixturesPath: 'test/fixtures/blueprint/app/local',
570-
resolvedFrom: tmpPath,
571-
relativeDir: location
572-
});
573-
}
572+
from: base,
573+
blueprint: packageName
574+
})).promise;
575+
576+
await initBlueprint({
577+
fixturesPath: path.resolve(__dirname, '../fixtures/blueprint/app/local'),
578+
resolvedFrom: tmpPath,
579+
relativeDir: location
580+
});
581+
582+
let {
583+
status
584+
} = await (await processBin({
585+
binFile: 'ember-cli-update',
586+
args: [
587+
'save',
588+
`-b=${location}`,
589+
`--from=${partial}`,
590+
'--',
591+
...options
592+
],
593+
cwd: tmpPath,
594+
commitMessage,
595+
expect
574596
})).promise;
575597

576598
assertNoStaged(status);
@@ -594,22 +616,36 @@ describe(function() {
594616
version: to
595617
} = (await loadSafeBlueprintFile('test/fixtures/blueprint/app/legacy-app/merge/my-app/config2/ember-cli-update.json')).blueprints[1];
596618

597-
let {
598-
status
599-
} = await (await merge({
619+
await (await merge({
600620
fixturesPath: 'test/fixtures/blueprint/app/legacy-app/init',
601621
commitMessage: 'my-app',
602-
blueprint: location,
603-
from,
604-
to,
605-
blueprintOptions: options,
606-
async beforeMerge() {
607-
await initBlueprint({
608-
fixturesPath: 'test/fixtures/blueprint/app/legacy',
609-
resolvedFrom: tmpPath,
610-
relativeDir: location
611-
});
612-
}
622+
bootstrap: true
623+
})).promise;
624+
625+
let commitMessage = 'bootstrap';
626+
627+
await commit({ m: commitMessage, cwd: tmpPath });
628+
629+
await initBlueprint({
630+
fixturesPath: path.resolve(__dirname, '../fixtures/blueprint/app/legacy'),
631+
resolvedFrom: tmpPath,
632+
relativeDir: location
633+
});
634+
635+
let {
636+
status
637+
} = await (await processBin({
638+
binFile: 'ember-cli-update',
639+
args: [
640+
`-b=${location}`,
641+
`--from=${from}`,
642+
`--to=${to}`,
643+
'--',
644+
...options
645+
],
646+
cwd: tmpPath,
647+
commitMessage,
648+
expect
613649
})).promise;
614650

615651
fixtureCompare({

test/fixtures/blueprint/app/local-app/init/my-app/config/ember-cli-update.json

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.24
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.24

0 commit comments

Comments
 (0)